Commit 2f99ef29 authored by charras's avatar charras

eeschema: code cleaning

parent a178978c
......@@ -14,9 +14,11 @@ set(EESCHEMA_SRCS
bus-wire-junction.cpp
class_drawsheet.cpp
class_hierarchical_PIN_sheet.cpp
class_pin.cpp
class_schematic_items.cpp
class_screen.cpp
class_text-label.cpp
classes_body_items.cpp
cleanup.cpp
component_class.cpp
controle.cpp
......
......@@ -139,8 +139,8 @@ int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent,
case COMPONENT_POLYLINE_DRAW_TYPE:
{
int ii, imax = ( (LibDrawPolyline*) item )->n * 2;
int* ptpoly = ( (LibDrawPolyline*) item )->PolyList;
int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2;
int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList;
for( ii = 0; ii < imax; ii += 2 )
{
pos.x = ptpoly[ii]; pos.y = -ptpoly[ii + 1];
......@@ -577,8 +577,8 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
case COMPONENT_POLYLINE_DRAW_TYPE:
{
int ii, imax = ( (LibDrawPolyline*) item )->n * 2;
int* ptpoly = ( (LibDrawPolyline*) item )->PolyList;
int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2;
int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList;
for( ii = 0; ii < imax; ii += 2 )
{
ptpoly[ii] += offset.x;
......@@ -689,8 +689,8 @@ void MirrorMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
case COMPONENT_POLYLINE_DRAW_TYPE:
{
int ii, imax = ( (LibDrawPolyline*) item )->n * 2;
int* ptpoly = ( (LibDrawPolyline*) item )->PolyList;
int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2;
int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList;
for( ii = 0; ii < imax; ii += 2 )
{
SETMIRROR( ptpoly[ii] );
......
/****************************************************************/
/* Headers fo library definition and lib component definitions */
/****************************************************************/
#ifndef CLASS_LIBRARY_H
#define CLASS_LIBRARY_H
/* Types for components in libraries
* components can be a true component or an alias of a true component.
*/
enum LibrEntryType {
ROOT, /* This is a true component standard EDA_LibComponentStruct */
ALIAS /* This is an alias of a true component */
};
/* values for member .m_Options */
enum LibrEntryOptions {
ENTRY_NORMAL, // Libentry is a standard component (real or alias)
ENTRY_POWER // Libentry is a power symbol
};
/******************************/
/* Classe to handle a library */
/******************************/
class LibraryStruct
{
public:
int m_Type; /* type indicator */
wxString m_Name; /* Short Name of the loaded library (without path). */
wxString m_FullFileName; /* Full File Name (with path) of library. */
wxString m_Header; /* first line of loaded library. */
int m_NumOfParts; /* Number of parts this library has. */
PriorQue* m_Entries; /* Parts themselves are saved here. */
LibraryStruct* m_Pnext; /* Point on next lib in chain. */
int m_Modified; /* flag indicateur d'edition */
int m_Size; // Size in bytes (for statistics)
unsigned long m_TimeStamp; // Signature temporelle
int m_Flags; // variable used in some functions
bool m_IsLibCache; /* False for the "standard" libraries,
* True for the library cache */
public:
LibraryStruct( int type, const wxString& name, const wxString& fullname );
~LibraryStruct();
bool WriteHeader( FILE* file );
bool ReadHeader( FILE* file, int* LineNum );
};
#include "classes_body_items.h"
/* basic class to describe components in libraries (true component or alias), non used directly */
class LibCmpEntry : public EDA_BaseStruct
{
public:
LibrEntryType Type; /* Type = ROOT;
* = ALIAS pour struct LibraryAliasType */
LibDrawField m_Name; // name (74LS00 ..) in lib ( = VALUE )
wxString m_Doc; /* documentation for info */
wxString m_KeyWord; /* keyword list (used to select a group of components by keyword) */
wxString m_DocFile; /* Associed doc filename */
LibrEntryOptions m_Options; // special features (i.e. Entry is a POWER)
public:
LibCmpEntry( LibrEntryType CmpType, const wxChar* CmpName );
virtual ~LibCmpEntry();
virtual wxString GetClass() const
{
return wxT( "LibCmpEntry" );
}
bool WriteDescr( FILE* File );
};
/*********************************************/
/* class to handle an usual component in lib */
/*********************************************/
class EDA_LibComponentStruct : public LibCmpEntry
{
public:
LibDrawField m_Prefix; /* Prefix ( U, IC ... ) = REFERENCE */
wxArrayString m_AliasList; /* ALIAS list for the component */
wxArrayString m_FootprintList; /* list of suitable footprint names for the component (wildcard names accepted)*/
int m_UnitCount; /* Units (or sections) per package */
bool m_UnitSelectionLocked; // True if units are differents and their selection is locked
// (i.e. if part A cannot be automatically changed in part B
int m_TextInside; /* if 0: pin name drawn on the pin itself
* if > 0 pin name drawn inside the component,
* with a distance of m_TextInside in mils */
bool m_DrawPinNum;
bool m_DrawPinName;
LibDrawField* Fields; /* Auxiliairy Field list (id = 2 a 11) */
LibEDA_BaseStruct* m_Drawings; /* How to draw this part */
long m_LastDate; // Last change Date
public:
virtual wxString GetClass() const
{
return wxT( "EDA_LibComponentStruct" );
}
EDA_LibComponentStruct( const wxChar* CmpName );
EDA_Rect GetBoundaryBox( int Unit, int Convert ); /* return Box around the part. */
~EDA_LibComponentStruct();
void SortDrawItems();
};
/**************************************************************************/
/* class to handle an alias of an usual component in lib (root component) */
/**************************************************************************/
class EDA_LibCmpAliasStruct : public LibCmpEntry
{
public:
wxString m_RootName; /* Root component Part name */
public:
EDA_LibCmpAliasStruct( const wxChar* CmpName, const wxChar* CmpRootName );
~EDA_LibCmpAliasStruct();
virtual wxString GetClass() const
{
return wxT( "EDA_LibCmpAliasStruct" );
}
};
#endif // CLASS_LIBRARY_H
/*****************/
/* class_pin.cpp */
/*****************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
/**********************************************************************************************/
void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor,
int aDrawMode, void* aData, int aTransformMatrix[2][2] )
/**********************************************************************************************/
{
if( ( m_Attributs & PINNOTDRAW ) && !g_ShowAllPins )
return;
EDA_LibComponentStruct* Entry = ( (DrawPinPrms*) aData )->m_Entry;
bool DrawPinText = ( (DrawPinPrms*) aData )->m_DrawPinText;
/* Calculate Pin orient takin in account the component orientation */
int orient = ReturnPinDrawOrient( aTransformMatrix );
/* Calculate the pin position */
wxPoint pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
/* Dessin de la pin et du symbole special associe */
DrawPinSymbol( aPanel, aDC, pos1, orient, aDrawMode, aColor );
if( DrawPinText )
{
DrawPinTexts( aPanel, aDC, pos1, orient,
Entry->m_TextInside,
Entry->m_DrawPinNum, Entry->m_DrawPinName,
aColor, aDrawMode );
}
}
/********************************************************************************/
void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aPinPos, int aOrient, int aDrawMode, int aColor )
/*******************************************************************************/
/* Draw the pin symbol (without texts)
* if Color != 0 draw with Color, else with the normal pin color
*/
{
int MapX1, MapY1, x1, y1;
int color;
int width = MAX( m_Width, g_DrawMinimunLineWidth );
int posX = aPinPos.x, posY = aPinPos.y, len = m_PinLen;
color = ReturnLayerColor( LAYER_PIN );
if( aColor < 0 ) // Used normal color or selected color
{
if( (m_Selected & IS_SELECTED) )
color = g_ItemSelectetColor;
}
else
color = aColor;
GRSetDrawMode( aDC, aDrawMode );
MapX1 = MapY1 = 0; x1 = posX; y1 = posY;
switch( aOrient )
{
case PIN_UP:
y1 = posY - len; MapY1 = 1;
break;
case PIN_DOWN:
y1 = posY + len; MapY1 = -1;
break;
case PIN_LEFT:
x1 = posX - len, MapX1 = 1;
break;
case PIN_RIGHT:
x1 = posX + len; MapX1 = -1;
break;
}
if( m_PinShape & INVERT )
{
GRCircle( &aPanel->m_ClipBox, aDC, MapX1 * INVERT_PIN_RADIUS + x1,
MapY1 * INVERT_PIN_RADIUS + y1,
INVERT_PIN_RADIUS, width, color );
GRMoveTo( MapX1 * INVERT_PIN_RADIUS * 2 + x1,
MapY1 * INVERT_PIN_RADIUS * 2 + y1 );
GRLineTo( &aPanel->m_ClipBox, aDC, posX, posY, width, color );
}
else
{
GRMoveTo( x1, y1 );
GRLineTo( &aPanel->m_ClipBox, aDC, posX, posY, width, color );
}
if( m_PinShape & CLOCK )
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1, y1 + CLOCK_PIN_DIM );
GRLineTo( &aPanel->m_ClipBox, aDC, x1 - MapX1 * CLOCK_PIN_DIM, y1, width, color );
GRLineTo( &aPanel->m_ClipBox, aDC, x1, y1 - CLOCK_PIN_DIM, width, color );
}
else /* MapX1 = 0 */
{
GRMoveTo( x1 + CLOCK_PIN_DIM, y1 );
GRLineTo( &aPanel->m_ClipBox, aDC, x1, y1 - MapY1 * CLOCK_PIN_DIM, width, color );
GRLineTo( &aPanel->m_ClipBox, aDC, x1 - CLOCK_PIN_DIM, y1, width, color );
}
}
if( m_PinShape & LOWLEVEL_IN ) /* IEEE symbol "Active Low Input" */
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 );
GRLineTo( &aPanel->m_ClipBox, aDC, x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1 - IEEE_SYMBOL_PIN_DIM, width, color );
GRLineTo( &aPanel->m_ClipBox, aDC, x1, y1, width, color );
}
else /* MapX1 = 0 */
{
GRMoveTo( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 );
GRLineTo( &aPanel->m_ClipBox, aDC, x1 - IEEE_SYMBOL_PIN_DIM,
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2, width, color );
GRLineTo( &aPanel->m_ClipBox, aDC, x1, y1, width, color );
}
}
if( m_PinShape & LOWLEVEL_OUT ) /* IEEE symbol "Active Low Output" */
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1, y1 - IEEE_SYMBOL_PIN_DIM );
GRLineTo( &aPanel->m_ClipBox,
aDC,
x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1,
width,
color );
}
else /* MapX1 = 0 */
{
GRMoveTo( x1 - IEEE_SYMBOL_PIN_DIM, y1 );
GRLineTo( &aPanel->m_ClipBox,
aDC,
x1,
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2,
width,
color );
}
}
/* Draw the pin end target (active end of the pin) */
if( !g_IsPrinting ) // Draw but do not print the pin end target 1 pixel width */
GRCircle( &aPanel->m_ClipBox, aDC, posX, posY, TARGET_PIN_DIAM, 0, color );
}
/*****************************************************************************
* Put out pin number and pin text info, given the pin line coordinates.
* The line must be vertical or horizontal.
* If PinText == NULL nothing is printed. If PinNum = 0 no number is printed.
* Current Zoom factor is taken into account.
* If TextInside then the text is been put inside,otherwise all is drawn outside.
* Pin Name: substring beteween '~' is negated
*****************************************************************************/
void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
wxPoint& pin_pos, int orient,
int TextInside, bool DrawPinNum, bool DrawPinName,
int Color, int DrawMode )
/* DrawMode = GR_OR, XOR ... */
{
int ii, x, y, x1, y1, dx, dy, len;
wxString StringPinNum;
wxString PinText;
int PinTextBarPos[256];
int PinTextBarCount;
int NameColor, NumColor;
int PinTxtLen;
wxSize PinNameSize( m_PinNameSize, m_PinNameSize );
wxSize PinNumSize( m_PinNumSize, m_PinNumSize );
int LineWidth = g_DrawMinimunLineWidth;
GRSetDrawMode( DC, DrawMode );
/* Get the num and name colors */
if( (Color < 0) && (m_Selected & IS_SELECTED) )
Color = g_ItemSelectetColor;
NameColor = Color == -1 ? ReturnLayerColor( LAYER_PINNAM ) : Color;
NumColor = Color == -1 ? ReturnLayerColor( LAYER_PINNUM ) : Color;
/* Create the pin num string */
ReturnPinStringNum( StringPinNum );
x1 = pin_pos.x; y1 = pin_pos.y;
switch( orient )
{
case PIN_UP:
y1 -= m_PinLen; break;
case PIN_DOWN:
y1 += m_PinLen; break;
case PIN_LEFT:
x1 -= m_PinLen; break;
case PIN_RIGHT:
x1 += m_PinLen; break;
}
const wxChar* textsrc = m_PinName.GetData();
float fPinTextPitch = PinNameSize.x * 1.1;
/* Do we need to invert the string? Is this string has only "~"? */
PinTextBarCount = 0; PinTxtLen = 0;
ii = 0;
while( *textsrc )
{
if( *textsrc == '~' )
{
PinTextBarPos[PinTextBarCount++] = (int) (PinTxtLen * fPinTextPitch);
}
else
{
PinText.Append( *textsrc );
PinTxtLen++;
}
textsrc++;
}
PinTxtLen = (int) (fPinTextPitch * PinTxtLen);
PinTextBarPos[PinTextBarCount] = PinTxtLen; // Needed if no end '~'
if( PinText[0] == 0 )
DrawPinName = FALSE;
if( TextInside ) /* Draw the text inside, but the pin numbers outside. */
{
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
// It is an horizontal line
{
if( PinText && DrawPinName )
{
if( orient == PIN_RIGHT )
{
x = x1 + TextInside;
DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor, PinText,
TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
GRMoveTo( x, y1 - TXTMARGE );
dy = -PinNameSize.y / 2;
GRMoveRel( 0, dy );
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( dx, 0 );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor );
}
}
else // Orient == PIN_LEFT
{
x = x1 - TextInside;
DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor, PinText,
TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
GRMoveTo( x, y1 - TXTMARGE );
dy = -PinNameSize.y / 2;
GRMoveRel( 0, dy );
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( dx - PinTxtLen, 0 );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor );
}
}
}
if( DrawPinNum )
{
DrawGraphicText( panel, DC,
wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ), NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
}
}
else /* Its a vertical line. */
{
// Text is drawn from bottom to top (i.e. to negative value for Y axis)
if( PinText && DrawPinName )
{
if( orient == PIN_DOWN )
{
y = y1 + TextInside;
DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
GRMoveTo( x1 - TXTMARGE, y );
dy = -PinNameSize.y / 2;
GRMoveRel( dy, 0 );
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( 0, PinTxtLen - dx );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
}
}
else /* PIN_UP */
{
y = y1 - TextInside;
DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
GRMoveTo( x1 - TXTMARGE, y );
dy = -PinNameSize.y / 2;
GRMoveRel( dy, 0 );
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( 0, -dx );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
}
}
}
if( DrawPinNum )
{
DrawGraphicText( panel, DC,
wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ), NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
}
}
}
else /**** Draw num & text pin outside ****/
{
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
/* Its an horizontal line. */
{
if( PinText && DrawPinName )
{
x = (x1 + pin_pos.x) / 2;
DrawGraphicText( panel, DC, wxPoint( x, y1 - TXTMARGE ),
NameColor, PinText,
TEXT_ORIENT_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
GRMoveTo( x, y1 - TXTMARGE * 2 );
GRMoveRel( -PinTxtLen / 2, -PinNameSize.y );
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( dx, 0 );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor );
}
}
if( DrawPinNum )
{
x = (x1 + pin_pos.x) / 2;
DrawGraphicText( panel, DC, wxPoint( x, y1 + TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LineWidth );
}
}
else /* Its a vertical line. */
{
if( PinText && DrawPinName )
{
y = (y1 + pin_pos.y) / 2;
DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE, y ),
NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
GRMoveTo( x1 - (TXTMARGE * 2), y );
GRMoveRel( -PinNameSize.y, -PinTxtLen / 2 );
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( 0, PinTxtLen - dx );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
}
}
if( DrawPinNum )
{
DrawGraphicText( panel, DC, wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
}
}
}
}
/************************/
/* class_body_items.cpp */
/************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
//#define DRAW_ARC_WITH_ANGLE // Used to draw arcs
/** Function Draw (virtual)
* Draw A body item
* @param aPanel = DrawPanel to use (can be null) mainly used for clipping purposes
* @param aDC = Device Context (can be null)
* @param aOffset = offset to draw
* @param aDrawMode = GR_OR, GR_XOR, ...
* @param aDisplay_mode = FILL_T value ( has meaning only for items what can be filled )
* @param aTransformMatrix = Transform Matrix
*/
/**********************************************************************************************/
void LibDrawArc::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor,
int aDrawMode, void* aData, int aTransformMatrix[2][2] )
/**********************************************************************************************/
{
wxPoint pos1, pos2, posc;
int color = ReturnLayerColor( LAYER_DEVICE );
int LineWidth = MAX( m_Width, g_DrawMinimunLineWidth );
if( aColor < 0 ) // Used normal color or selected color
{
if( (m_Selected & IS_SELECTED) )
color = g_ItemSelectetColor;
}
else
color = aColor;
pos1 = TransformCoordinate( aTransformMatrix, m_ArcEnd ) + aOffset;
pos2 = TransformCoordinate( aTransformMatrix, m_ArcStart ) + aOffset;
posc = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
int pt1 = t1;
int pt2 = t2;
bool swap = MapAngles( &pt1, &pt2, aTransformMatrix );
if( swap )
{
EXCHG( pos1.x, pos2.x ); EXCHG( pos1.y, pos2.y )
}
GRSetDrawMode( aDC, aDrawMode );
FILL_T fill = aData ? NO_FILL : m_Fill;
if( aColor >= 0 )
fill = NO_FILL;
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRFilledArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2,
m_Rayon, LineWidth, color,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE && !aData )
GRFilledArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2,
m_Rayon, color, color );
else
#ifdef DRAW_ARC_WITH_ANGLE
GRArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2,
m_Rayon, LineWidth, color );
#else
GRArc1( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y,
posc.x, posc.y, LineWidth, color );
#endif
}
/*************************************************************************************************/
void LibDrawCircle::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor,
int aDrawMode, void* aData, int aTransformMatrix[2][2] )
/*************************************************************************************************/
{
wxPoint pos1;
int color = ReturnLayerColor( LAYER_DEVICE );
int LineWidth = MAX( m_Width, g_DrawMinimunLineWidth );
if( aColor < 0 ) // Used normal color or selected color
{
if( (m_Selected & IS_SELECTED) )
color = g_ItemSelectetColor;
}
else
color = aColor;
pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
GRSetDrawMode( aDC, aDrawMode );
FILL_T fill = aData ? NO_FILL : m_Fill;
if( aColor >= 0 )
fill = NO_FILL;
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRFilledCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y,
m_Rayon, LineWidth, color,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE )
GRFilledCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y,
m_Rayon, 0, color, color );
else
GRCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y,
m_Rayon, LineWidth, color );
}
/*************************************************************************************************/
void LibDrawText::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor,
int aDrawMode, void* aData, int aTransformMatrix[2][2] )
/*************************************************************************************************/
{
wxPoint pos1, pos2;
int color = ReturnLayerColor( LAYER_DEVICE );
int LineWidth = MAX( m_Width, g_DrawMinimunLineWidth );
if( aColor < 0 ) // Used normal color or selected color
{
if( (m_Selected & IS_SELECTED) )
color = g_ItemSelectetColor;
}
else
color = aColor;
pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
/* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. */
int t1 = (aTransformMatrix[0][0] != 0) ^ (m_Horiz != 0);
DrawGraphicText( aPanel, aDC, pos1, color, m_Text,
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
}
/*************************************************************************************************/
void LibDrawSquare::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor,
int aDrawMode, void* aData, int aTransformMatrix[2][2] )
/*************************************************************************************************/
{
wxPoint pos1, pos2;
int color = ReturnLayerColor( LAYER_DEVICE );
int LineWidth = MAX( m_Width, g_DrawMinimunLineWidth );
if( aColor < 0 ) // Used normal color or selected color
{
if( (m_Selected & IS_SELECTED) )
color = g_ItemSelectetColor;
}
else
color = aColor;
pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
pos2 = TransformCoordinate( aTransformMatrix, m_End ) + aOffset;
FILL_T fill = aData ? NO_FILL : m_Fill;
if( aColor >= 0 )
fill = NO_FILL;
if( fill == FILLED_WITH_BG_BODYCOLOR && !aData )
GRFilledRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y,
color, LineWidth,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( m_Fill == FILLED_SHAPE && !aData )
GRFilledRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y,
color, color );
else
GRRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y,
LineWidth, color );
}
/*************************************************************************************************/
void LibDrawSegment::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor,
int aDrawMode, void* aData, int aTransformMatrix[2][2] )
/*************************************************************************************************/
{
wxPoint pos1, pos2;
int color = ReturnLayerColor( LAYER_DEVICE );
int LineWidth = MAX( m_Width, g_DrawMinimunLineWidth );
if( aColor < 0 ) // Used normal color or selected color
{
if( (m_Selected & IS_SELECTED) )
color = g_ItemSelectetColor;
}
else
color = aColor;
pos1 = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
pos2 = TransformCoordinate( aTransformMatrix, m_End ) + aOffset;
GRLine( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, LineWidth, color );
}
/*************************************************************************************************/
void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, int aColor,
int aDrawMode, void* aData,
int aTransformMatrix[2][2] )
/*************************************************************************************************/
{
wxPoint pos1;
int color = ReturnLayerColor( LAYER_DEVICE );
int LineWidth = MAX( m_Width, g_DrawMinimunLineWidth );
static int* Buf_Poly_Drawings = NULL; // Buffer used to store current corners coordinates for drawings
static int Buf_Poly_Size = 0; // Buffer used to store current corners coordinates for drawings
if( aColor < 0 ) // Used normal color or selected color
{
if( (m_Selected & IS_SELECTED) )
color = g_ItemSelectetColor;
}
else
color = aColor;
// Set the size of the buffer od coordinates
if( Buf_Poly_Drawings == NULL )
{
Buf_Poly_Size = m_CornersCount;
Buf_Poly_Drawings = (int*) MyMalloc( sizeof(int) * 2 * Buf_Poly_Size );
}
else if( Buf_Poly_Size < m_CornersCount )
{
Buf_Poly_Size = m_CornersCount;
Buf_Poly_Drawings = (int*) realloc( Buf_Poly_Drawings,
sizeof(int) * 2 * Buf_Poly_Size );
}
for( int ii = 0, jj = 0; ii < m_CornersCount; ii++, jj += 2 )
{
pos1.x = m_PolyList[jj];
pos1.y = m_PolyList[jj + 1];
pos1 = TransformCoordinate( aTransformMatrix, pos1 ) + aOffset;
Buf_Poly_Drawings[jj] = pos1.x;
Buf_Poly_Drawings[jj + 1] = pos1.y;
}
FILL_T fill = aData ? NO_FILL : m_Fill;
if( aColor >= 0 )
fill = NO_FILL;
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount,
Buf_Poly_Drawings, 1, LineWidth, color,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE )
GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount,
Buf_Poly_Drawings, 1, LineWidth, color, color );
else
GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount,
Buf_Poly_Drawings, 0, LineWidth, color, color );
}
/*************************************************************************************************/
void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor,
int aDrawMode, void* aData, int aTransformMatrix[2][2] )
/*************************************************************************************************/
{
}
/****************************************************************/
/* Headers fo library definition and lib component definitions */
/****************************************************************/
#ifndef CLASSES_BODY_ITEMS_H
#define CLASSES_BODY_ITEMS_H
#define TARGET_PIN_DIAM 12 /* Circle diameter drawn at the active end of pins */
#define DEFAULT_TEXT_SIZE 50 /* Default size for field texts */
#define PART_NAME_LEN 15 /* Maximum length of part name. */
#define PREFIX_NAME_LEN 5 /* Maximum length of prefix (IC, R, SW etc.). */
#define PIN_WIDTH 100 /* Width between 2 pins in internal units. */
#define PIN_LENGTH 300 /* Default Length of each pin to be drawn. */
#define INVERT_PIN_RADIUS 35 /* Radius of inverted pin circle. */
#define CLOCK_PIN_DIM 40 /* Dim of clock pin symbol. */
#define IEEE_SYMBOL_PIN_DIM 40 /* Dim of special pin symbol. */
/**
* Enum FILL_T
* is the set of fill types used in plotting or drawing enclosed areas.
*/
enum FILL_T {
NO_FILL, // Poly, Square, Circle, Arc = option No Fill
FILLED_SHAPE, // Poly, Square, Circle, Arc = option Fill with current color ("Solid shape")
FILLED_WITH_BG_BODYCOLOR, /* Poly, Square, Circle, Arc = option Fill with background body color,
* translucent (texts inside this shape can be seen)
* not filled in B&W mode when plotting or printing
*/
};
/**
* Enum ElectricPinType
* is the set of schematic pin types, used in ERC tests.
*/
enum ElectricPinType { /* Type des Pins. si modif: modifier tableau des mgs suivant */
PIN_INPUT,
PIN_OUTPUT,
PIN_BIDI,
PIN_TRISTATE,
PIN_PASSIVE,
PIN_UNSPECIFIED,
PIN_POWER_IN,
PIN_POWER_OUT,
PIN_OPENCOLLECTOR,
PIN_OPENEMITTER,
PIN_NC, /* No connect */
PIN_NMAX /* End of List (no used as pin type) */
};
/* Messages d'affichage du type electrique */
eda_global const wxChar* MsgPinElectricType[]
#ifdef MAIN
= {
wxT( "input" ),
wxT( "output" ),
wxT( "BiDi" ),
wxT( "3state" ),
wxT( "passive" ),
wxT( "unspc" ),
wxT( "power_in" ),
wxT( "power_out" ),
wxT( "openCol" ),
wxT( "openEm" ),
wxT( "?????" )
}
#endif
;
/* Autres bits: bits du membre .Flag des Pins */
#define PINNOTDRAW 1 /* si 1: pin invisible */
/**
* Enum DrawPinShape
* is the set of shapes allowed for pins.
*/
enum DrawPinShape {
NONE = 0,
INVERT = 1,
CLOCK = 2,
LOWLEVEL_IN = 4,
LOWLEVEL_OUT = 8
};
/**
* Enum DrawPinOrient
* is the set of orientations allowed for pins.
*/
enum DrawPinOrient {
PIN_RIGHT = 'R',
PIN_LEFT = 'L',
PIN_UP = 'U',
PIN_DOWN = 'D',
};
// Struct to pass parameters for drawing pins, in function Draw
class DrawPinPrms
{
public:
EDA_LibComponentStruct* m_Entry; // Pointer to the component in lib
bool m_DrawPinText; // Are pin texts drawn ?
DrawPinPrms(EDA_LibComponentStruct* entry, bool drawpintext = true)
{
m_Entry = entry;
m_DrawPinText = drawpintext;
}
};
/****************************************************************************/
/* Classes for handle the body items of a compoment: pins add graphic items */
/****************************************************************************/
/* class LibEDA_BaseStruct : Basic class for items used in a library component
* (graphic shapes, texts, fields, pins)
*/
class LibEDA_BaseStruct : public EDA_BaseStruct
{
public:
int m_Unit; /* Unit identification (for multi part per parkage)
* 0 if the item is common to all units */
int m_Convert; /* Shape identification (for parts which have a convert shape)
* 0 if the item is common to all shapes */
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */
int m_Width; /* Tickness */
public:
LibEDA_BaseStruct* Next()
{
return (LibEDA_BaseStruct*) Pnext;
}
LibEDA_BaseStruct( KICAD_T struct_type );
virtual ~LibEDA_BaseStruct() { }
/** Function Draw (virtual pure)
* Draw A body item
* @param aPanel = DrawPanel to use (can be null) mainly used for clipping purposes
* @param aDC = Device Context (can be null)
* @param aOffset = offset to draw
* @param aColor = -1 to use the normal body item color, or use this color if >= 0
* @param aDrawMode = GR_OR, GR_XOR, ...
* @param aData = pointer used to pass others parametres, depending on body items.
* used for some items to force to force no fill mode
* ( has meaning only for items what can be filled ). used in printing or moving objects mode
* or to pass refernce to the lib component for pins
* @param aTransformMatrix = Transform Matrix
*/
virtual void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
int aDrawMode, void * aData, int aTransformMatrix[2][2] ) = 0;
void Display_Infos_DrawEntry( WinEDA_DrawFrame* frame );
};
/********/
/* Pins */
/********/
class LibDrawPin : public LibEDA_BaseStruct
{
public:
int m_PinLen; /* Pin lenght */
int m_Orient; /* Pin orientation (Up, Down, Left, Right) */
int m_PinShape; /* Bitwise ORed: Pin shape (see enum DrawPinShape) */
int m_PinType; /* Electrical pin properties */
int m_Attributs; /* bit 0 != 0: pin invisible */
long m_PinNum; /* Pin number: 4 Ascii code like "12" or "anod" or "G6"
* "12" is stored as "12\0\0" ans does not depend on endian type*/
wxString m_PinName;
int m_PinNumSize, m_PinNameSize; /* Pin num and Pin name sizes */
// int m_PinNumWidth, m_PinNameWidth; /* (Currently Unused) Pin num and Pin name text width */
public:
LibDrawPin();
~LibDrawPin() { }
virtual wxString GetClass() const
{
return wxT( "LibDrawPin" );
}
LibDrawPin* GenCopy();
bool WriteDescr( FILE* File );
void Display_Infos( WinEDA_DrawFrame* frame );
wxPoint ReturnPinEndPoint();
int ReturnPinDrawOrient( int TransMat[2][2] );
void ReturnPinStringNum( wxString& buffer );
void SetPinNumFromString( wxString& buffer );
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
int aDrawMode, void * aData, int aTransformMatrix[2][2] );
void DrawPinSymbol( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& pin_pos,
int orient,
int DrawMode, int Color = -1 );
void DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
wxPoint& pin_pos, int orient,
int TextInside, bool DrawPinNum, bool DrawPinName,
int Color, int DrawMode );
void PlotPinTexts( wxPoint& pin_pos, int orient,
int TextInside, bool DrawPinNum, bool DrawPinName );
};
/**************************/
/* Graphic Body Item: Arc */
/**************************/
class LibDrawArc : public LibEDA_BaseStruct
{
public:
int m_Rayon;
FILL_T m_Fill; // NO_FILL, FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR
int t1, t2; /* position des 2 extremites de l'arc en 0.1 degres */
wxPoint m_ArcStart, m_ArcEnd; /* position des 2 extremites de l'arc en coord reelles*/
public:
LibDrawArc();
~LibDrawArc() { }
virtual wxString GetClass() const
{
return wxT( "LibDrawArc" );
}
LibDrawArc* GenCopy();
bool WriteDescr( FILE* File );
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
int aDrawMode, void * aData, int aTransformMatrix[2][2] );
};
/*****************************/
/* Graphic Body Item: Circle */
/*****************************/
class LibDrawCircle : public LibEDA_BaseStruct
{
public:
int m_Rayon;
FILL_T m_Fill;
public:
LibDrawCircle();
~LibDrawCircle() { }
virtual wxString GetClass() const
{
return wxT( "LibDrawCircle" );
}
LibDrawCircle* GenCopy();
bool WriteDescr( FILE* File );
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
int aDrawMode, void * aData, int aTransformMatrix[2][2] );
};
/*********************************************/
/* Graphic Body Item: Text */
/* This is only a graphic text. */
/* Fields like Ref , value... are not Text, */
/* they are a separate class */
/*********************************************/
class LibDrawText : public LibEDA_BaseStruct
{
public:
int m_Horiz;
wxSize m_Size;
int m_Type;
wxString m_Text;
public:
LibDrawText();
~LibDrawText() { }
virtual wxString GetClass() const
{
return wxT( "LibDrawText" );
}
LibDrawText* GenCopy();
bool WriteDescr( FILE* File );
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
int aDrawMode, void * aData, int aTransformMatrix[2][2] );
};
/********************************/
/* Graphic Body Item: Rectangle */
/********************************/
class LibDrawSquare : public LibEDA_BaseStruct
{
public:
wxPoint m_End;
FILL_T m_Fill;
public:
LibDrawSquare();
~LibDrawSquare() { }
virtual wxString GetClass() const
{
return wxT( "LibDrawSquare" );
}
LibDrawSquare* GenCopy();
bool WriteDescr( FILE* File );
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
int aDrawMode, void * aData, int aTransformMatrix[2][2] );
};
/**********************************/
/* Graphic Body Item: single line */
/**********************************/
class LibDrawSegment : public LibEDA_BaseStruct
{
public:
wxPoint m_End;
public:
LibDrawSegment();
~LibDrawSegment() { }
virtual wxString GetClass() const
{
return wxT( "LibDrawSegment" );
}
LibDrawSegment* GenCopy();
bool WriteDescr( FILE* File );
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
int aDrawMode, void * aData, int aTransformMatrix[2][2] );
};
/*********************************************/
/* Graphic Body Item: Polygon (set of lines) */
/*********************************************/
class LibDrawPolyline : public LibEDA_BaseStruct
{
public:
int m_CornersCount;
int* m_PolyList;
FILL_T m_Fill;
public:
LibDrawPolyline();
~LibDrawPolyline()
{
if( m_PolyList )
free( m_PolyList );
}
virtual wxString GetClass() const
{
return wxT( "LibDrawPolyline" );
}
LibDrawPolyline* GenCopy();
void AddPoint( const wxPoint& point );
bool WriteDescr( FILE* File );
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
int aDrawMode, void * aData, int aTransformMatrix[2][2] );
};
/**********/
/* Fields */
/**********/
/* Fields , same as component fields.
* can be defined in libraries (mandatory for ref and value, ca be useful for footprints)
* 2 Fields are always defined :
* Prefix (U, IC..) with gives the reference in scxhematic)
* Name (74LS00..) used to find the component in libraries, and give the default value in schematic
*/
class LibDrawField : public LibEDA_BaseStruct
{
public:
int m_FieldId; // 0 a 11
// 0 = Name; 1 = Valeur; 2 .. 11 other fields
wxPoint m_Pos;
wxSize m_Size;
int m_Orient; /* Orientation */
int m_Attributs; /* Attributes (Non visible ...) */
int m_HJustify, m_VJustify; /* Horiz an Vert Texte Justifications */
wxString m_Text; /* Field Data */
wxString m_Name; /* Field Name */
public:
LibDrawField( int idfield = 2 );
~LibDrawField();
virtual wxString GetClass() const
{
return wxT( "LibDrawField" );
}
LibDrawField* GenCopy();
void Copy( LibDrawField* Target );
bool WriteDescr( FILE* File );
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, int aColor,
int aDrawMode, void * aData, int aTransformMatrix[2][2] );
};
#endif // CLASSES_BODY_ITEMS_H
......@@ -35,18 +35,36 @@
* ENDDEF
*/
static int s_ItemSelectColor = BROWN;
static EDA_LibComponentStruct* DummyCmp;
static int* Buf_Poly_Drawings, Buf_Poly_Size; // Used fo polyline drawings
static void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_COMPONENT* Component,
EDA_LibComponentStruct* Entry,
const wxPoint& Pos,
static void DrawLibPartAux( WinEDA_DrawPanel * panel, wxDC * DC,
SCH_COMPONENT * Component,
EDA_LibComponentStruct * Entry,
const wxPoint &Pos,
int TransMat[2][2],
int Multi, int convert,
int DrawMode, int Color = -1, bool DrawPinText = TRUE );
/***************************************************************************/
wxPoint TransformCoordinate( int aTransformMatrix[2][2], wxPoint& aPosition )
/***************************************************************************/
/** Function TransformCoordinate
* Calculate the wew coordinate from the old one, according to the transform matrix.
* @param aTransformMatrix = rotation, mirror .. matrix
* @param aPosition = the position to transform
* @return the new coordinate
*/
{
wxPoint new_pos;
new_pos.x = (aTransformMatrix[0][0] * aPosition.x) + (aTransformMatrix[0][1] * aPosition.y);
new_pos.y = (aTransformMatrix[1][0] * aPosition.x) + (aTransformMatrix[1][1] * aPosition.y);
return new_pos;
}
/******************************/
static void CreateDummyCmp()
/******************************/
......@@ -99,8 +117,8 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
TransMat[1][0] = TransMat[0][1] = 0;
DrawLibPartAux( panel, DC, NULL, LibEntry, wxPoint( posX, posY ),
TransMat, Multi,
convert, DrawMode, Color );
TransMat, Multi,
convert, DrawMode, Color );
/* Trace des 2 champs ref et value (Attention aux coord: la matrice
* de transformation change de signe les coord Y */
......@@ -132,10 +150,10 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
int LineWidth = MAX( LibEntry->m_Prefix.m_Width, g_DrawMinimunLineWidth );
if( (LibEntry->m_Prefix.m_Flags & IS_MOVED) == 0 )
DrawGraphicText( panel, DC, text_pos,
color, LibEntry->m_Prefix.m_Text.GetData(),
LibEntry->m_Prefix.m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
LibEntry->m_Prefix.m_Size,
LibEntry->m_Prefix.m_HJustify, LibEntry->m_Prefix.m_VJustify, LineWidth );
color, LibEntry->m_Prefix.m_Text.GetData(),
LibEntry->m_Prefix.m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
LibEntry->m_Prefix.m_Size,
LibEntry->m_Prefix.m_HJustify, LibEntry->m_Prefix.m_VJustify, LineWidth );
if( LibEntry->m_Name.m_Attributs & TEXT_NO_VISIBLE )
{
......@@ -157,10 +175,10 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
LineWidth = MAX( LibEntry->m_Name.m_Width, g_DrawMinimunLineWidth );
if( (LibEntry->m_Name.m_Flags & IS_MOVED) == 0 )
DrawGraphicText( panel, DC, text_pos,
color, LibEntry->m_Name.m_Text.GetData(),
LibEntry->m_Name.m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
LibEntry->m_Name.m_Size,
LibEntry->m_Name.m_HJustify, LibEntry->m_Name.m_VJustify, LineWidth );
color, LibEntry->m_Name.m_Text.GetData(),
LibEntry->m_Name.m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
LibEntry->m_Name.m_Size,
LibEntry->m_Name.m_HJustify, LibEntry->m_Name.m_VJustify, LineWidth );
for( Field = LibEntry->Fields; Field != NULL; Field = (LibDrawField*) Field->Pnext )
{
......@@ -187,10 +205,10 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
text_pos.y = posY - Field->m_Pos.y;
LineWidth = MAX( Field->m_Width, g_DrawMinimunLineWidth );
DrawGraphicText( panel, DC, text_pos,
color, Field->m_Text,
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify, LineWidth );
color, Field->m_Text,
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify, LineWidth );
}
// Trac� de l'ancre
......@@ -205,7 +223,7 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
* specified, and in the given drawing mode. Only this one is visible... *
*****************************************************************************/
void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color )
const wxPoint& offset, int DrawMode, int Color )
{
EDA_LibComponentStruct* Entry;
int ii;
......@@ -220,10 +238,10 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
}
DrawLibPartAux( panel, DC, this, Entry, m_Pos + offset,
m_Transform,
dummy ? 0 : m_Multi,
dummy ? 0 : m_Convert,
DrawMode );
m_Transform,
dummy ? 0 : m_Multi,
dummy ? 0 : m_Convert,
DrawMode );
/* Trace des champs, avec placement et orientation selon orient. du
* composant
......@@ -254,11 +272,11 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
/***********************************************************/
void PartTextStruct::Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int DrawMode,
int Color)
void PartTextStruct::Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int DrawMode,
int Color )
/***********************************************************/
/* Routine de trace des textes type Field du composant.
......@@ -266,12 +284,12 @@ void PartTextStruct::Draw( WinEDA_DrawPanel* panel,
* DrawMode: mode de trace
*/
{
int orient, color;
int orient, color;
wxPoint pos; /* Position des textes */
wxPoint pos; /* Position des textes */
SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) m_Parent;
int hjustify, vjustify;
int LineWidth = MAX( m_Width, g_DrawMinimunLineWidth );
int hjustify, vjustify;
int LineWidth = MAX( m_Width, g_DrawMinimunLineWidth );
if( m_Attributs & TEXT_NO_VISIBLE )
return;
......@@ -283,9 +301,9 @@ void PartTextStruct::Draw( WinEDA_DrawPanel* panel,
/* Calcul de la position des textes, selon orientation du composant */
orient = m_Orient;
hjustify = m_HJustify; vjustify = m_VJustify;
pos = m_Pos - DrawLibItem->m_Pos;
pos = m_Pos - DrawLibItem->m_Pos;
pos = DrawLibItem->GetScreenCoord( pos );
pos = DrawLibItem->GetScreenCoord( pos );
pos += DrawLibItem->m_Pos;
/* Y a t-il rotation (pour l'orientation, la justification)*/
......@@ -320,19 +338,19 @@ void PartTextStruct::Draw( WinEDA_DrawPanel* panel,
if( !m_AddExtraText || (m_FieldId != REFERENCE) )
{
DrawGraphicText( panel, DC, pos, color, m_Text.GetData(),
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
m_Size,
hjustify, vjustify, LineWidth );
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
m_Size,
hjustify, vjustify, LineWidth );
}
else // Si il y a plusieurs parts par boitier, ajouter a la reference l'identification de la selection ( A, B ... )
{
/* On ajoute alors A ou B ... a la reference */
/* On ajoute alors A ou B ... a la reference */
wxString fulltext = m_Text;
fulltext.Append( 'A' - 1 + DrawLibItem->m_Multi );
DrawGraphicText( panel, DC, pos, color, fulltext.GetData(),
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
m_Size,
hjustify, vjustify, LineWidth );
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
m_Size,
hjustify, vjustify, LineWidth );
}
}
......@@ -351,13 +369,13 @@ EDA_LibComponentStruct* FindLibPart( const wxChar* Name, const wxString& LibName
* Alias = FIND_ROOT, ou Alias = FIND_ALIAS
*/
{
EDA_LibComponentStruct* Entry;
EDA_LibComponentStruct* Entry;
static EDA_LibComponentStruct DummyEntry( wxEmptyString ); /* Used only to call PQFind. */
LibraryStruct* Lib = g_LibraryList;
DummyEntry.m_Drawings = NULL;/* Used only to call PQFind. */
DummyEntry.m_Drawings = NULL; /* Used only to call PQFind. */
DummyEntry.m_Name.m_Text = Name;
PQCompFunc( (PQCompFuncType) LibraryEntryCompare );
......@@ -394,7 +412,7 @@ EDA_LibComponentStruct* FindLibPart( const wxChar* Name, const wxString& LibName
{
if( (Entry->Type != ROOT ) && (Alias == FIND_ROOT) )
Entry = FindLibPart( ( (EDA_LibCmpAliasStruct*) Entry )->m_RootName.GetData(),
Lib->m_Name, FIND_ROOT );
Lib->m_Name, FIND_ROOT );
}
return Entry;
......@@ -416,16 +434,11 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
int Multi, int convert, int DrawMode,
int Color, bool DrawPinText )
{
int i, x1, y1, x2, y2, t1, t2, orient;
wxPoint pos1, pos2;
LibEDA_BaseStruct* DEntry = NULL;
int CharColor;
FILL_T fill_option;
int SetHightColor;
int LineWidth;
//#define GETCOLOR(l) Color < 0 ? (ReturnLayerColor(l)| SetHightColor) : Color;
#define GETCOLOR( l ) Color < 0 ? SetHightColor ?\
s_ItemSelectColor : (ReturnLayerColor( l ) | SetHightColor) : Color;
bool force_nofill;
int SetHightColor;
int LineWidth;
if( Entry->m_Drawings == NULL )
return;
......@@ -441,7 +454,7 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
continue;
if( DEntry->m_Flags & IS_MOVED )
continue; // Element en deplacement non trace
continue; // Element en deplacement non trace
SetHightColor = (DEntry->m_Selected & IS_SELECTED) ? HIGHT_LIGHT_FLAG : 0;
LineWidth = MAX( DEntry->m_Width, g_DrawMinimunLineWidth );
......@@ -450,231 +463,51 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
{
case COMPONENT_ARC_DRAW_TYPE:
{
int xc, yc, x2, y2;
LibDrawArc* Arc = (LibDrawArc*) DEntry;
CharColor = GETCOLOR( LAYER_DEVICE );
xc = Pos.x + TransMat[0][0] * Arc->m_Pos.x +
TransMat[0][1] * Arc->m_Pos.y;
yc = Pos.y + TransMat[1][0] * Arc->m_Pos.x +
TransMat[1][1] * Arc->m_Pos.y;
x2 = Pos.x + TransMat[0][0] * Arc->m_ArcStart.x +
TransMat[0][1] * Arc->m_ArcStart.y;;
y2 = Pos.y + TransMat[1][0] * Arc->m_ArcStart.x +
TransMat[1][1] * Arc->m_ArcStart.y;
x1 = Pos.x + TransMat[0][0] * Arc->m_ArcEnd.x +
TransMat[0][1] * Arc->m_ArcEnd.y;;
y1 = Pos.y + TransMat[1][0] * Arc->m_ArcEnd.x +
TransMat[1][1] * Arc->m_ArcEnd.y;
t1 = Arc->t1; t2 = Arc->t2;
bool swap = MapAngles( &t1, &t2, TransMat );
if( swap )
{
EXCHG( x1, x2 ); EXCHG( y1, y2 )
}
fill_option = Arc->m_Fill;
if ( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState( ) )
fill_option = NO_FILL;
if( Color < 0 ) // Normal Color Layer
{
if( fill_option == FILLED_WITH_BG_BODYCOLOR )
GRFilledArc( &panel->m_ClipBox, DC, xc, yc, t1, t2,
Arc->m_Rayon, Arc->m_Width, CharColor,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill_option == FILLED_SHAPE )
GRFilledArc( &panel->m_ClipBox, DC, xc, yc, t1, t2,
Arc->m_Rayon, CharColor, CharColor );
#ifdef DRAW_ARC_WITH_ANGLE
else
GRArc( &panel->m_ClipBox, DC, xc, yc, t1, t2,
Arc->m_Rayon, LineWidth, CharColor );
#else
else
GRArc1( &panel->m_ClipBox, DC, x1, y1, x2, y2,
xc, yc, LineWidth, CharColor );
#endif
}
#ifdef DRAW_ARC_WITH_ANGLE
else
GRArc( &panel->m_ClipBox, DC, xc, yc, t1, t2,
Arc->m_Rayon, Circle->m_Width, CharColor );
#else
else
GRArc1( &panel->m_ClipBox, DC, x1, y1, x2, y2,
xc, yc, Arc->m_Width, CharColor );
#endif
}
force_nofill = false;
if( g_IsPrinting && Arc->m_Fill == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() )
force_nofill = true;
DEntry->Draw( panel, DC, Pos, Color, DrawMode, (void*)force_nofill, TransMat );
break;
}
case COMPONENT_CIRCLE_DRAW_TYPE:
{
LibDrawCircle* Circle = (LibDrawCircle*) DEntry;
CharColor = GETCOLOR( LAYER_DEVICE );
x1 = Pos.x + TransMat[0][0] * Circle->m_Pos.x +
TransMat[0][1] * Circle->m_Pos.y;
y1 = Pos.y + TransMat[1][0] * Circle->m_Pos.x +
TransMat[1][1] * Circle->m_Pos.y;
fill_option = Circle->m_Fill;
if ( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState( ) )
fill_option = NO_FILL;
if( Color < 0 )
{
if( fill_option == FILLED_WITH_BG_BODYCOLOR )
GRFilledCircle( &panel->m_ClipBox, DC, x1, y1,
Circle->m_Rayon, LineWidth, CharColor,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill_option == FILLED_SHAPE )
GRFilledCircle( &panel->m_ClipBox, DC, x1, y1,
Circle->m_Rayon, 0, CharColor, CharColor );
else
GRCircle( &panel->m_ClipBox, DC, x1, y1,
Circle->m_Rayon, LineWidth, CharColor );
}
else
GRCircle( &panel->m_ClipBox, DC, x1, y1,
Circle->m_Rayon, LineWidth, CharColor );
force_nofill = false;
if( g_IsPrinting && Circle->m_Fill == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() )
force_nofill = true;
DEntry->Draw( panel, DC, Pos, Color, DrawMode, (void*)force_nofill, TransMat );
}
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
{
LibDrawText* Text = (LibDrawText*) DEntry;
CharColor = GETCOLOR( LAYER_DEVICE );
/* The text orientation may need to be flipped if the
* transformation matrix cuases xy axes to be flipped. */
t1 = (TransMat[0][0] != 0) ^ (Text->m_Horiz != 0);
x1 = Pos.x + TransMat[0][0] * Text->m_Pos.x
+ TransMat[0][1] * Text->m_Pos.y;
y1 = Pos.y + TransMat[1][0] * Text->m_Pos.x
+ TransMat[1][1] * Text->m_Pos.y;
DrawGraphicText( panel, DC, wxPoint( x1, y1 ), CharColor, Text->m_Text,
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
Text->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
}
DEntry->Draw( panel, DC, Pos, Color, DrawMode, NULL, TransMat );
break;
case COMPONENT_RECT_DRAW_TYPE:
{
LibDrawSquare* Square = (LibDrawSquare*) DEntry;
CharColor = GETCOLOR( LAYER_DEVICE );
x1 = Pos.x + TransMat[0][0] * Square->m_Pos.x
+ TransMat[0][1] * Square->m_Pos.y;
y1 = Pos.y + TransMat[1][0] * Square->m_Pos.x
+ TransMat[1][1] * Square->m_Pos.y;
x2 = Pos.x + TransMat[0][0] * Square->m_End.x
+ TransMat[0][1] * Square->m_End.y;
y2 = Pos.y + TransMat[1][0] * Square->m_End.x
+ TransMat[1][1] * Square->m_End.y;
fill_option = Square->m_Fill;
if ( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState( ) )
fill_option = NO_FILL;
if( Color < 0 )
{
if( fill_option == FILLED_WITH_BG_BODYCOLOR )
GRFilledRect( &panel->m_ClipBox, DC, x1, y1, x2, y2,
CharColor, LineWidth,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill_option == FILLED_SHAPE )
GRFilledRect( &panel->m_ClipBox, DC, x1, y1, x2, y2,
CharColor, CharColor );
else
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2,
LineWidth, CharColor );
}
else
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2,
LineWidth, CharColor );
force_nofill = false;
if( g_IsPrinting && Square->m_Fill == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() )
force_nofill = true;
DEntry->Draw( panel, DC, Pos, Color, DrawMode, (void*)force_nofill, TransMat );
}
break;
case COMPONENT_PIN_DRAW_TYPE: /* Trace des Pins */
{
LibDrawPin* Pin = (LibDrawPin*) DEntry;
if( Pin->m_Attributs & PINNOTDRAW )
{
if( /*(GetScreen()->m_Type == SCHEMATIC_FRAME )
&&*/ !g_ShowAllPins )
break;
}
/* Calcul de l'orientation reelle de la Pin */
orient = Pin->ReturnPinDrawOrient( TransMat );
/* Calcul de la position du point de reference */
x2 = Pos.x + (TransMat[0][0] * Pin->m_Pos.x)
+ (TransMat[0][1] * Pin->m_Pos.y);
y2 = Pos.y + (TransMat[1][0] * Pin->m_Pos.x)
+ (TransMat[1][1] * Pin->m_Pos.y);
/* Dessin de la pin et du symbole special associe */
CharColor = GETCOLOR( LAYER_PIN );
Pin->DrawPinSymbol( panel, DC, wxPoint( x2, y2 ), orient, DrawMode, CharColor );
if( DrawPinText )
{
wxPoint pinpos( x2, y2 );
CharColor = SetHightColor ? s_ItemSelectColor : Color;
Pin->DrawPinTexts( panel, DC, pinpos, orient,
Entry->m_TextInside,
Entry->m_DrawPinNum, Entry->m_DrawPinName,
CharColor, DrawMode );
}
DrawPinPrms prms(Entry, DrawPinText);
DEntry->Draw( panel, DC, Pos, Color, DrawMode, &prms, TransMat );
}
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
{
LibDrawPolyline* polyline = (LibDrawPolyline*) DEntry;
CharColor = GETCOLOR( LAYER_DEVICE );
if( Buf_Poly_Drawings == NULL )
{
Buf_Poly_Size = polyline->n;
Buf_Poly_Drawings = (int*) MyMalloc( sizeof(int) * 2 * Buf_Poly_Size );
}
else if( Buf_Poly_Size < polyline->n )
{
Buf_Poly_Size = polyline->n;
Buf_Poly_Drawings = (int*) realloc( Buf_Poly_Drawings,
sizeof(int) * 2 * Buf_Poly_Size );
}
for( i = 0; i < polyline->n; i++ )
{
Buf_Poly_Drawings[i * 2] = Pos.x +
TransMat[0][0] * polyline->PolyList[i * 2] +
TransMat[0][1] * polyline->PolyList[i * 2 + 1];
Buf_Poly_Drawings[i * 2 + 1] = Pos.y +
TransMat[1][0] * polyline->PolyList[i * 2] +
TransMat[1][1] * polyline->PolyList[i * 2 + 1];
}
fill_option = polyline->m_Fill;
if ( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState( ) )
fill_option = NO_FILL;
if( Color < 0 )
{
if( fill_option == FILLED_WITH_BG_BODYCOLOR )
GRPoly( &panel->m_ClipBox, DC, polyline->n,
Buf_Poly_Drawings, 1, LineWidth, CharColor,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill_option == FILLED_SHAPE )
GRPoly( &panel->m_ClipBox, DC, polyline->n,
Buf_Poly_Drawings, 1, LineWidth, CharColor, CharColor );
else
GRPoly( &panel->m_ClipBox, DC, polyline->n,
Buf_Poly_Drawings, 0, LineWidth, CharColor, CharColor );
}
else
GRPoly( &panel->m_ClipBox, DC, polyline->n,
Buf_Poly_Drawings, 0, LineWidth, CharColor, CharColor );
force_nofill = false;
if( g_IsPrinting && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() )
force_nofill = true;
DEntry->Draw( panel, DC, Pos, Color, DrawMode, (void*)force_nofill, TransMat );
}
break;
......@@ -694,10 +527,10 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
BoundaryBox = Component->GetBoundaryBox();
else
BoundaryBox = Entry->GetBoundaryBox( Multi, convert );
x1 = BoundaryBox.GetX();
y1 = BoundaryBox.GetY();
x2 = BoundaryBox.GetRight();
y2 = BoundaryBox.GetBottom();
int x1 = BoundaryBox.GetX();
int y1 = BoundaryBox.GetY();
int x2 = BoundaryBox.GetRight();
int y2 = BoundaryBox.GetBottom();
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
BoundaryBox = Component->m_Field[REFERENCE].GetBoundaryBox();
x1 = BoundaryBox.GetX();
......@@ -715,129 +548,6 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
}
/********************************************************************************/
void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& pin_pos, int orient, int DrawMode, int Color )
/*******************************************************************************/
/* Draw the pin symbol (without texts)
* if Color != 0 draw with Color, eles with the normal pin color
*/
{
int MapX1, MapY1, x1, y1;
int color;
int width = MAX( m_Width, g_DrawMinimunLineWidth );
int posX = pin_pos.x, posY = pin_pos.y, len = m_PinLen;
if( Color >= 0 )
color = Color;
else
color = ReturnLayerColor( LAYER_PIN );
GRSetDrawMode( DC, DrawMode );
MapX1 = MapY1 = 0; x1 = posX; y1 = posY;
switch( orient )
{
case PIN_UP:
y1 = posY - len; MapY1 = 1;
break;
case PIN_DOWN:
y1 = posY + len; MapY1 = -1;
break;
case PIN_LEFT:
x1 = posX - len, MapX1 = 1;
break;
case PIN_RIGHT:
x1 = posX + len; MapX1 = -1;
break;
}
if( m_PinShape & INVERT )
{
GRCircle( &panel->m_ClipBox, DC, MapX1 * INVERT_PIN_RADIUS + x1,
MapY1 * INVERT_PIN_RADIUS + y1,
INVERT_PIN_RADIUS, width, color );
GRMoveTo( MapX1 * INVERT_PIN_RADIUS * 2 + x1,
MapY1 * INVERT_PIN_RADIUS * 2 + y1 );
GRLineTo( &panel->m_ClipBox, DC, posX, posY, width, color );
}
else
{
GRMoveTo( x1, y1 );
GRLineTo( &panel->m_ClipBox, DC, posX, posY, width, color );
}
if( m_PinShape & CLOCK )
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1, y1 + CLOCK_PIN_DIM );
GRLineTo( &panel->m_ClipBox, DC, x1 - MapX1 * CLOCK_PIN_DIM, y1, width, color );
GRLineTo( &panel->m_ClipBox, DC, x1, y1 - CLOCK_PIN_DIM, width, color );
}
else /* MapX1 = 0 */
{
GRMoveTo( x1 + CLOCK_PIN_DIM, y1 );
GRLineTo( &panel->m_ClipBox, DC, x1, y1 - MapY1 * CLOCK_PIN_DIM, width, color );
GRLineTo( &panel->m_ClipBox, DC, x1 - CLOCK_PIN_DIM, y1, width, color );
}
}
if( m_PinShape & LOWLEVEL_IN ) /* IEEE symbol "Active Low Input" */
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 );
GRLineTo( &panel->m_ClipBox, DC, x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1 - IEEE_SYMBOL_PIN_DIM, width, color );
GRLineTo( &panel->m_ClipBox, DC, x1, y1, width, color );
}
else /* MapX1 = 0 */
{
GRMoveTo( x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2 );
GRLineTo( &panel->m_ClipBox, DC, x1 - IEEE_SYMBOL_PIN_DIM,
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2, width, color );
GRLineTo( &panel->m_ClipBox, DC, x1, y1, width, color );
}
}
if( m_PinShape & LOWLEVEL_OUT ) /* IEEE symbol "Active Low Output" */
{
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1, y1 - IEEE_SYMBOL_PIN_DIM );
GRLineTo( &panel->m_ClipBox,
DC,
x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1,
width,
color );
}
else /* MapX1 = 0 */
{
GRMoveTo( x1 - IEEE_SYMBOL_PIN_DIM, y1 );
GRLineTo( &panel->m_ClipBox,
DC,
x1,
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2,
width,
color );
}
}
/* Draw the pin end target (active end of the pin) */
if( !g_IsPrinting ) // Draw but do not print the pin end target 1 pixel width */
GRCircle( &panel->m_ClipBox, DC, posX, posY, TARGET_PIN_DIAM, 0, color );
}
/*****************************************************************************
* Routine to rotate the given angular direction by the given Transformation. *
......@@ -917,8 +627,8 @@ void DrawingLibInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
int DrawMode = g_XorMode;
DrawLibPartAux( panel, DC, DrawLibItem, LibEntry, wxPoint( PartX, PartY ),
DrawLibItem->m_Transform,
multi, convert, DrawMode, Color, DrawPinText );
DrawLibItem->m_Transform,
multi, convert, DrawMode, Color, DrawPinText );
}
......@@ -934,10 +644,11 @@ void DrawLibraryDrawStruct( WinEDA_DrawPanel* panel, wxDC* DC,
LibEDA_BaseStruct* DrawItem, int Multi,
int DrawMode, int Color )
{
int i, x1, y1, x2, y2, t1, t2, orient;
int x1, y1, x2, y2, t1, t2, orient;
int CharColor;
int TransMat[2][2];
int fill_option;
wxPoint position(PartX, PartY);
#undef GETCOLOR
#define GETCOLOR( l ) Color < 0 ? ReturnLayerColor( l ) : Color;
......@@ -973,23 +684,23 @@ void DrawLibraryDrawStruct( WinEDA_DrawPanel* panel, wxDC* DC,
EXCHG( x1, x2 ); EXCHG( y1, y2 )
}
fill_option = Arc->m_Fill;
if ( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState( ) )
if( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() )
fill_option = NO_FILL;
if( fill_option == FILLED_WITH_BG_BODYCOLOR )
GRFilledArc( &panel->m_ClipBox, DC, xc, yc, t1, t2,
Arc->m_Rayon, CharColor,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
Arc->m_Rayon, CharColor,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill_option == FILLED_SHAPE )
GRFilledArc( &panel->m_ClipBox, DC, xc, yc, t1, t2,
Arc->m_Rayon, LineWidth, CharColor, CharColor );
Arc->m_Rayon, LineWidth, CharColor, CharColor );
#ifdef DRAW_ARC_WITH_ANGLE
else
GRArc( &panel->m_ClipBox, DC, xc, yc, t1, t2,
Arc->m_Rayon, CharColor );
Arc->m_Rayon, CharColor );
#else
else
GRArc1( &panel->m_ClipBox, DC, x1, y1, x2, y2,
xc, yc, LineWidth, CharColor );
xc, yc, LineWidth, CharColor );
#endif
}
break;
......@@ -1000,18 +711,18 @@ void DrawLibraryDrawStruct( WinEDA_DrawPanel* panel, wxDC* DC,
x1 = PartX + Circle->m_Pos.x;
y1 = PartY - Circle->m_Pos.y;
fill_option = Circle->m_Fill;
if ( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState( ) )
if( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() )
fill_option = NO_FILL;
if( fill_option == FILLED_WITH_BG_BODYCOLOR )
GRFilledCircle( &panel->m_ClipBox, DC, x1, y1,
Circle->m_Rayon, LineWidth, CharColor,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
Circle->m_Rayon, LineWidth, CharColor,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill_option == FILLED_SHAPE )
GRFilledCircle( &panel->m_ClipBox, DC, x1, y1,
Circle->m_Rayon, 0, CharColor, CharColor );
Circle->m_Rayon, 0, CharColor, CharColor );
else
GRCircle( &panel->m_ClipBox, DC, x1, y1,
Circle->m_Rayon, LineWidth, CharColor );
Circle->m_Rayon, LineWidth, CharColor );
}
break;
......@@ -1021,9 +732,9 @@ void DrawLibraryDrawStruct( WinEDA_DrawPanel* panel, wxDC* DC,
x1 = PartX + Text->m_Pos.x;
y1 = PartY - Text->m_Pos.y;
DrawGraphicText( panel, DC, wxPoint( x1, y1 ), CharColor, Text->m_Text,
Text->m_Horiz,
Text->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
Text->m_Horiz,
Text->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
}
break;
......@@ -1035,18 +746,18 @@ void DrawLibraryDrawStruct( WinEDA_DrawPanel* panel, wxDC* DC,
x2 = PartX + Square->m_End.x;
y2 = PartY - Square->m_End.y;
fill_option = Square->m_Fill;
if ( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState( ) )
if( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() )
fill_option = NO_FILL;
if( fill_option == FILLED_WITH_BG_BODYCOLOR )
GRFilledRect( &panel->m_ClipBox, DC, x1, y1, x2, y2,
CharColor, LineWidth,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
CharColor, LineWidth,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill_option == FILLED_SHAPE )
GRFilledRect( &panel->m_ClipBox, DC, x1, y1, x2, y2,
CharColor, CharColor );
CharColor, CharColor );
else
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, LineWidth,
CharColor );
CharColor );
}
break;
......@@ -1068,45 +779,19 @@ void DrawLibraryDrawStruct( WinEDA_DrawPanel* panel, wxDC* DC,
wxPoint pinpos( x2, y2 );
Pin->DrawPinTexts( panel, DC, pinpos, orient,
LibEntry->m_TextInside,
LibEntry->m_DrawPinNum, LibEntry->m_DrawPinName,
CharColor, DrawMode );
LibEntry->m_TextInside,
LibEntry->m_DrawPinNum, LibEntry->m_DrawPinName,
CharColor, DrawMode );
}
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
{
LibDrawPolyline* polyline = (LibDrawPolyline*) DrawItem;
if( Buf_Poly_Drawings == NULL )
{
Buf_Poly_Size = polyline->n;
Buf_Poly_Drawings = (int*) MyMalloc( sizeof(int) * 2 * Buf_Poly_Size );
}
else if( Buf_Poly_Size < polyline->n )
{
Buf_Poly_Size = polyline->n;
Buf_Poly_Drawings = (int*) realloc( Buf_Poly_Drawings,
sizeof(int) * 2 * Buf_Poly_Size );
}
for( i = 0; i < polyline->n; i++ )
{
Buf_Poly_Drawings[i * 2] = PartX + polyline->PolyList[i * 2];
Buf_Poly_Drawings[i * 2 + 1] = PartY - polyline->PolyList[i * 2 + 1];
}
fill_option = polyline->m_Fill;
if ( g_IsPrinting && fill_option == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState( ) )
fill_option = NO_FILL;
if( fill_option == FILLED_WITH_BG_BODYCOLOR )
GRPoly( &panel->m_ClipBox, DC, polyline->n,
Buf_Poly_Drawings, 1, LineWidth, CharColor,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill_option == FILLED_SHAPE )
GRPoly( &panel->m_ClipBox, DC, polyline->n,
Buf_Poly_Drawings, 1, LineWidth, CharColor, CharColor );
else
GRPoly( &panel->m_ClipBox, DC, polyline->n,
Buf_Poly_Drawings, 0, LineWidth, CharColor, CharColor );
fill_option = false;
if( g_IsPrinting && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() )
fill_option = true;
DrawItem->Draw( panel, DC, position, Color,DrawMode, (void *) fill_option, TransMat );
break;
}
......
......@@ -66,8 +66,8 @@ LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
return NULL;
}
currentLibraryName = FullLibName;
currentLibraryName = FullLibName;
NewLib = new LibraryStruct( LIBRARY_TYPE_EESCHEMA, LibName, FullLibName );
Entries = LoadLibraryAux( frame, NewLib, f, &NumOfParts );
......@@ -480,7 +480,7 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
/* End line or block analysis: test for an error */
if( !Res )
{ /* Something went wrong there. */
Msg.Printf( wxT( " Error at line %d of library \n\"%s\",\nlibrary not loaded" ),
Msg.Printf( wxT( " Error at line %d of library \n\"%s\",\nlibrary not loaded" ),
*LineNum, currentLibraryName.GetData() );
DisplayError( frame, Msg );
SAFE_DELETE( LibEntry );
......@@ -734,24 +734,24 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
New = Polyl;
if( sscanf( &Line[2], "%d %d %d %d",
&Polyl->n, &Unit, &Convert,
&Polyl->m_CornersCount, &Unit, &Convert,
&Polyl->m_Width ) == 4
&& Polyl->n > 0 )
&& Polyl->m_CornersCount > 0 )
{
Polyl->m_Unit = Unit; Polyl->m_Convert = Convert;
Polyl->PolyList = (int*)
MyZMalloc( sizeof(int) * Polyl->n * 2 );
Polyl->m_PolyList = (int*)
MyZMalloc( sizeof(int) * Polyl->m_CornersCount * 2 );
p = strtok( &Line[2], " \t\n" );
p = strtok( NULL, " \t\n" );
p = strtok( NULL, " \t\n" );
p = strtok( NULL, " \t\n" );
for( i = 0; i < Polyl->n * 2 && !Error; i++ )
for( i = 0; i < Polyl->m_CornersCount * 2 && !Error; i++ )
{
p = strtok( NULL, " \t\n" );
Error = sscanf( p, "%d", &Polyl->PolyList[i] ) != 1;
Error = sscanf( p, "%d", &Polyl->m_PolyList[i] ) != 1;
}
Polyl->m_Fill = NO_FILL;
......
......@@ -16,260 +16,6 @@
extern void Move_Plume( wxPoint pos, int plume ); // see plot.cpp
/*****************************************************************************
* Put out pin number and pin text info, given the pin line coordinates.
* The line must be vertical or horizontal.
* If PinText == NULL nothing is printed. If PinNum = 0 no number is printed.
* Current Zoom factor is taken into account.
* If TextInside then the text is been put inside,otherwise all is drawn outside.
* Pin Name: substring beteween '~' is negated
*****************************************************************************/
void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
wxPoint& pin_pos, int orient,
int TextInside, bool DrawPinNum, bool DrawPinName,
int Color, int DrawMode )
/* DrawMode = GR_OR, XOR ... */
{
int ii, x, y, x1, y1, dx, dy, len;
wxString StringPinNum;
wxString PinText;
int PinTextBarPos[256];
int PinTextBarCount;
int NameColor, NumColor;
int PinTxtLen;
wxSize PinNameSize( m_PinNameSize, m_PinNameSize );
wxSize PinNumSize( m_PinNumSize, m_PinNumSize );
int LineWidth = g_DrawMinimunLineWidth;
GRSetDrawMode( DC, DrawMode );
/* Get the num and name colors */
NameColor = Color == -1 ? ReturnLayerColor( LAYER_PINNAM ) : Color;
NumColor = Color == -1 ? ReturnLayerColor( LAYER_PINNUM ) : Color;
/* Create the pin num string */
ReturnPinStringNum( StringPinNum );
x1 = pin_pos.x; y1 = pin_pos.y;
switch( orient )
{
case PIN_UP:
y1 -= m_PinLen; break;
case PIN_DOWN:
y1 += m_PinLen; break;
case PIN_LEFT:
x1 -= m_PinLen; break;
case PIN_RIGHT:
x1 += m_PinLen; break;
}
const wxChar* textsrc = m_PinName.GetData();
float fPinTextPitch = PinNameSize.x * 1.1;
/* Do we need to invert the string? Is this string has only "~"? */
PinTextBarCount = 0; PinTxtLen = 0;
ii = 0;
while( *textsrc )
{
if( *textsrc == '~' )
{
PinTextBarPos[PinTextBarCount++] = (int) (PinTxtLen * fPinTextPitch);
}
else
{
PinText.Append( *textsrc );
PinTxtLen++;
}
textsrc++;
}
PinTxtLen = (int) (fPinTextPitch * PinTxtLen);
PinTextBarPos[PinTextBarCount] = PinTxtLen; // Needed if no end '~'
if( PinText[0] == 0 )
DrawPinName = FALSE;
if( TextInside ) /* Draw the text inside, but the pin numbers outside. */
{
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
// It is an horizontal line
{
if( PinText && DrawPinName )
{
if( orient == PIN_RIGHT )
{
x = x1 + TextInside;
DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor, PinText,
TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
GRMoveTo( x, y1 - TXTMARGE );
dy = -PinNameSize.y / 2;
GRMoveRel( 0, dy );
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( dx, 0 );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor );
}
}
else // Orient == PIN_LEFT
{
x = x1 - TextInside;
DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor, PinText,
TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
GRMoveTo( x, y1 - TXTMARGE );
dy = -PinNameSize.y / 2;
GRMoveRel( 0, dy );
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( dx - PinTxtLen, 0 );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor );
}
}
}
if( DrawPinNum )
{
DrawGraphicText( panel, DC,
wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ), NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
}
}
else /* Its a vertical line. */
{
// Text is drawn from bottom to top (i.e. to negative value for Y axis)
if( PinText && DrawPinName )
{
if( orient == PIN_DOWN )
{
y = y1 + TextInside;
DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
GRMoveTo( x1 - TXTMARGE, y );
dy = -PinNameSize.y / 2;
GRMoveRel( dy, 0 );
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( 0, PinTxtLen - dx );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
}
}
else /* PIN_UP */
{
y = y1 - TextInside;
DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
GRMoveTo( x1 - TXTMARGE, y );
dy = -PinNameSize.y / 2;
GRMoveRel( dy, 0 );
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( 0, -dx );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
}
}
}
if( DrawPinNum )
{
DrawGraphicText( panel, DC,
wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ), NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
}
}
}
else /**** Draw num & text pin outside ****/
{
if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
/* Its an horizontal line. */
{
if( PinText && DrawPinName )
{
x = (x1 + pin_pos.x) / 2;
DrawGraphicText( panel, DC, wxPoint( x, y1 - TXTMARGE ),
NameColor, PinText,
TEXT_ORIENT_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
GRMoveTo( x, y1 - TXTMARGE * 2 );
GRMoveRel( -PinTxtLen / 2, -PinNameSize.y );
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( dx, 0 );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor );
}
}
if( DrawPinNum )
{
x = (x1 + pin_pos.x) / 2;
DrawGraphicText( panel, DC, wxPoint( x, y1 + TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LineWidth );
}
}
else /* Its a vertical line. */
{
if( PinText && DrawPinName )
{
y = (y1 + pin_pos.y) / 2;
DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE, y ),
NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
GRMoveTo( x1 - (TXTMARGE * 2), y );
GRMoveRel( -PinNameSize.y, -PinTxtLen / 2 );
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( 0, PinTxtLen - dx );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
}
}
if( DrawPinNum )
{
DrawGraphicText( panel, DC, wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
}
}
}
}
/*****************************************************************************
* Plot pin number and pin text info, given the pin line coordinates. *
* Same as DrawPinTexts((), but output is the plotter
......
......@@ -256,7 +256,7 @@ eda_global wxString g_NetListerCommandLine; // ligne de commande pour l'appel au
eda_global LayerStruct g_LayerDescr; /* couleurs des couches */
eda_global bool g_EditPinByPinIsOn /* bool: TRUE si edition des pins pin a pin au lieu */
#ifdef MAIN /* de l'edition simultan�e des pins de meme coordonn�es */
#ifdef MAIN /* de l'edition simultanee des pins de meme coordonnees */
= FALSE
#endif
;
......@@ -265,6 +265,13 @@ eda_global int g_LibSymbolDefaultLineWidth; /* default line width (in EESCHEMA
eda_global int g_DrawMinimunLineWidth; /* Minimum line (in EESCHEMA units) width used to draw items on screen; 0 = single pixel line width */
eda_global int g_PlotPSMinimunLineWidth; /* Minimum line (in EESCHEMA units) width used to Plot items , postscript format */
eda_global int g_ItemSelectetColor // Color to draw selected items
#ifdef MAIN
= BROWN
#endif
;
/* Config keys */
#define MINI_DRAW_LINE_WIDTH_KEY wxT("MinimunDrawLineWidth")
#define MINI_PLOTPS_LINE_WIDTH_KEY wxT("MinimunPlotPSLineWidth")
......
......@@ -229,12 +229,12 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
DrawEntry = m_Drawings;
if( DrawEntry )
{
xmin = ymin = 0x7FFFFFFF;
xmin = ymin = 0x7FFFFFFF;
xmax = ymax = 0x80000000;
}
else
{
xmin = ymin = -50;
xmin = ymin = -50;
xmax = ymax = 50; // Min size in 1/1000 inch
}
......@@ -337,8 +337,8 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
case COMPONENT_POLYLINE_DRAW_TYPE:
{
LibDrawPolyline* polyline = (LibDrawPolyline*) DrawEntry;
pt = polyline->PolyList;
for( ii = 0; ii < polyline->n; ii++ )
pt = polyline->m_PolyList;
for( ii = 0; ii < polyline->m_CornersCount; ii++ )
{
if( xmin > *pt )
xmin = *pt;
......@@ -353,7 +353,7 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
}
}
break;
default:
;
}
......@@ -380,7 +380,7 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
/* a Field is a string linked to a component.
* Unlike a pure graphic text, fields can be used in netlist generation
* and other things.
*
*
* 4 fields have a special meaning:
* REFERENCE
* VALUE
......@@ -739,8 +739,8 @@ LibDrawSegment* LibDrawSegment::GenCopy()
LibDrawPolyline::LibDrawPolyline() : LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE )
{
n = 0;
PolyList = NULL;
m_CornersCount = 0;
m_PolyList = NULL;
m_Fill = NO_FILL;
m_Width = 0;
}
......@@ -754,12 +754,12 @@ LibDrawPolyline* LibDrawPolyline::GenCopy()
int size;
newitem->n = n;
size = sizeof(int) * 2 * n;
newitem->m_CornersCount = m_CornersCount;
size = sizeof(int) * 2 * m_CornersCount;
if( size )
{
newitem->PolyList = (int*) MyMalloc( size );
memcpy( newitem->PolyList, PolyList, size );
newitem->m_PolyList = (int*) MyMalloc( size );
memcpy( newitem->m_PolyList, m_PolyList, size );
}
newitem->m_Pos = m_Pos;
newitem->m_Width = m_Width;
......@@ -780,13 +780,13 @@ void LibDrawPolyline::AddPoint( const wxPoint& point )
{
int allocsize;
n++;
allocsize = 2 * sizeof(int) * n;
if( PolyList == NULL )
PolyList = (int*) MyMalloc( allocsize );
m_CornersCount++;
allocsize = 2 * sizeof(int) * m_CornersCount;
if( m_PolyList == NULL )
m_PolyList = (int*) MyMalloc( allocsize );
else
PolyList = (int*) realloc( PolyList, allocsize );
m_PolyList = (int*) realloc( m_PolyList, allocsize );
PolyList[(n * 2) - 2] = point.x;
PolyList[(n * 2) - 1] = -point.y;
m_PolyList[(m_CornersCount * 2) - 2] = point.x;
m_PolyList[(m_CornersCount * 2) - 1] = -point.y;
}
/****************************************************************/
/* Headers fo library definition and lib component definitions */
/****************************************************************/
/*****************************************************************/
/* Headers for library definition and lib component definitions */
/*****************************************************************/
#ifndef LIBCMP_H
#define LIBCMP_H
......@@ -11,37 +11,12 @@
#include "priorque.h"
#define LIB_VERSION_MAJOR 2
#define LIB_VERSION_MINOR 3
#define LIBFILE_IDENT "EESchema-LIBRARY Version" /* Must be at the lib file start. */
#define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0" /* Must be at the doc file start. */
#define DOC_EXT wxT( ".dcm" ) /* extension des fichiers de documentation */
#define LIB_VERSION_MAJOR 2
#define LIB_VERSION_MINOR 3
#define LIBFILE_IDENT "EESchema-LIBRARY Version" /* Must be the first line of lib files. */
#define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0" /* Must be the first line of doc files. */
#define DOC_EXT wxT( ".dcm" ) /* Ext. of documentation files */
#define TARGET_PIN_DIAM 12 /* Diam cercle des extremites des pins */
#define DEFAULT_TEXT_SIZE 50 /* Default size for field texts */
#define PART_NAME_LEN 15 /* Maximum length of part name. */
#define PREFIX_NAME_LEN 5 /* Maximum length of prefix (IC, R, SW etc.). */
#define PIN_WIDTH 100 /* Width between 2 pins in internal units. */
#define PIN_LENGTH 300 /* Default Length of each pin to be drawn. */
#define INVERT_PIN_RADIUS 35 /* Radius of inverted pin circle. */
#define CLOCK_PIN_DIM 40 /* Dim of clock pin symbol. */
#define IEEE_SYMBOL_PIN_DIM 40 /* Dim of special pin symbol. */
/**
* Enum FILL_T
* is the set of fill types used in plotting or drawing enclosed areas.
*/
enum FILL_T {
NO_FILL, // Poly, Square, Circle, Arc = option No Fill
FILLED_SHAPE, // Poly, Square, Circle, Arc = option Fill with current color ("Solid shape")
FILLED_WITH_BG_BODYCOLOR, /* Poly, Square, Circle, Arc = option Fill
* with background body color, translucent (texts on this shape can be see)
* not fille in B&W plot mode
*/
};
//Offsets used in editing library component, for handle aliad dats
#define ALIAS_NAME 0
......@@ -52,7 +27,7 @@ enum FILL_T {
enum LocateDrawStructType {
LOCATE_COMPONENT_ARC_DRAW_TYPE = 1,
LOCATE_COMPONENT_ARC_DRAW_TYPE = 1,
LOCATE_COMPONENT_CIRCLE_DRAW_TYPE = 2,
LOCATE_COMPONENT_GRAPHIC_TEXT_DRAW_TYPE = 4,
LOCATE_COMPONENT_RECT_DRAW_TYPE = 8,
......@@ -64,431 +39,20 @@ enum LocateDrawStructType {
#define LOCATE_ALL_DRAW_ITEM 0xFFFFFFFF
/* flags utilises dans FindLibPart() : */
#define FIND_ROOT 0 /* indique la recherche du composant racine si
* meme si le composant specifie est un alias */
#define FIND_ALIAS 1 /* indique la recherche du composant specifie
* (alias ou racine) */
/* definition des types des structures d'elements de librairie */
enum LibrEntryType {
ROOT, /* Structure est a standard EDA_LibComponentStruct */
ALIAS /* Structure is an alias */
};
/* valeur du membre .m_Options */
enum LibrEntryOptions {
ENTRY_NORMAL, // Libentry is standard
ENTRY_POWER // Libentry is a power symbol
};
/**
* Enum ElectricPinType
* is the set of schematic pin types.
*/
enum ElectricPinType { /* Type des Pins. si modif: modifier tableau des mgs suivant */
PIN_INPUT,
PIN_OUTPUT,
PIN_BIDI,
PIN_TRISTATE,
PIN_PASSIVE,
PIN_UNSPECIFIED,
PIN_POWER_IN,
PIN_POWER_OUT,
PIN_OPENCOLLECTOR,
PIN_OPENEMITTER,
PIN_NC, /* No connect */
PIN_NMAX /* Valeur limite ( utilisee comme limite de tableaux) */
};
/* Messages d'affichage du type electrique */
eda_global const wxChar* MsgPinElectricType[]
#ifdef MAIN
= {
wxT( "input" ),
wxT( "output" ),
wxT( "BiDi" ),
wxT( "3state" ),
wxT( "passive" ),
wxT( "unspc" ),
wxT( "power_in" ),
wxT( "power_out" ),
wxT( "openCol" ),
wxT( "openEm" ),
wxT( "?????" )
}
#endif
;
/* Autres bits: bits du membre .Flag des Pins */
#define PINNOTDRAW 1 /* si 1: pin invisible */
/**
* Enum DrawPinShape
* is the set of shapes allowed for pins.
*/
enum DrawPinShape {
NONE = 0,
INVERT = 1,
CLOCK = 2,
LOWLEVEL_IN = 4,
LOWLEVEL_OUT = 8
};
/**
* Enum DrawPinOrient
* is the set of orientations allowed for pins.
*/
enum DrawPinOrient {
PIN_RIGHT = 'R',
PIN_LEFT = 'L',
PIN_UP = 'U',
PIN_DOWN = 'D',
};
/*************************************/
/* Classe representant une librairie */
/*************************************/
class LibraryStruct
{
public:
int m_Type; /* type indicator */
wxString m_Name; /* Name of library loaded. */
wxString m_FullFileName; /* Full File Name (with path) of library loaded. */
wxString m_Header; /* first line of library loaded. */
int m_NumOfParts; /* Number of parts this library has. */
PriorQue* m_Entries; /* Parts themselves are saved here. */
LibraryStruct* m_Pnext; /* Point on next lib in chain. */
int m_Modified; /* flag indicateur d'edition */
int m_Size; // Size in bytes (for statistics)
unsigned long m_TimeStamp; // Signature temporelle
int m_Flags; // variable used in some functions
bool m_IsLibCache; // False for the "standard" libraries,
// True for the library cache
public:
LibraryStruct( int type, const wxString& name, const wxString& fullname );
~LibraryStruct();
bool WriteHeader( FILE* file );
bool ReadHeader( FILE* file, int* LineNum );
};
/*******************************************************************/
/* Classes representant les elments d'un composant d'une libraire */
/*******************************************************************/
/* class LibEDA_BaseStruct : Basic class for items used in a library component
* (graphic shapes, texts, fields, pins)
*/
class LibEDA_BaseStruct : public EDA_BaseStruct
{
public:
int m_Unit; /* Unit identification (for multi part per parkage)
* 0 if the item is common to all units */
int m_Convert; /* Shape identification (for parts which have a convert shape)
* 0 if the item is common to all shapes */
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */
int m_Width; /* Width of draw lines */
public:
LibEDA_BaseStruct* Next()
{
return (LibEDA_BaseStruct*) Pnext;
}
LibEDA_BaseStruct( KICAD_T struct_type );
virtual ~LibEDA_BaseStruct() { }
void Display_Infos_DrawEntry( WinEDA_DrawFrame* frame );
};
class LibDrawPin : public LibEDA_BaseStruct
{
public:
int m_PinLen; /* Pin lenght */
int m_Orient; /* Pin orientation (Up, Down, Left, Right) */
int m_PinShape; /* Bitwise ORed: Pin shape (see enum DrawPinShape) */
int m_PinType; /* Electrical pin properties */
int m_Attributs; /* bit 0 != 0: pin invisible */
long m_PinNum; /* Pin number: 4 Ascii code like "12" or "anod" or "G6"
* "12" is really "12\0\0"*/
wxString m_PinName;
int m_PinNumSize, m_PinNameSize; /* Pin num and Pin name sizes */
// short m_PinNumWidth, m_PinNameWidth; /* (Unused) Pin num and Pin name text width */
public:
LibDrawPin();
~LibDrawPin() { }
virtual wxString GetClass() const
{
return wxT( "LibDrawPin" );
}
LibDrawPin* GenCopy();
bool WriteDescr( FILE* File );
void Display_Infos( WinEDA_DrawFrame* frame );
wxPoint ReturnPinEndPoint();
int ReturnPinDrawOrient( int TransMat[2][2] );
void ReturnPinStringNum( wxString& buffer );
void SetPinNumFromString( wxString& buffer );
void DrawPinSymbol( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& pin_pos,
int orient,
int DrawMode, int Color = -1 );
void DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
wxPoint& pin_pos, int orient,
int TextInside, bool DrawPinNum, bool DrawPinName,
int Color, int DrawMode );
void PlotPinTexts( wxPoint& pin_pos, int orient,
int TextInside, bool DrawPinNum, bool DrawPinName );
};
class LibDrawArc : public LibEDA_BaseStruct
{
public:
int m_Rayon;
FILL_T m_Fill; // NO_FILL, FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR
int t1, t2; /* position des 2 extremites de l'arc en 0,1 degres */
wxPoint m_ArcStart, m_ArcEnd; /* position des 2 extremites de l'arc en coord reelles*/
public:
LibDrawArc();
~LibDrawArc() { }
virtual wxString GetClass() const
{
return wxT( "LibDrawArc" );
}
#define FIND_ROOT 0 /* Used to search for a root component by its name
* if the name is an alias name, FindLibPart() returns the root component */
#define FIND_ALIAS 1 /* Used to search for a component by its name
* FindLibPart() returns the component (root or alias ) */
#include "class_library.h"
LibDrawArc* GenCopy();
bool WriteDescr( FILE* File );
};
class LibDrawCircle : public LibEDA_BaseStruct
{
public:
int m_Rayon;
FILL_T m_Fill;
public:
LibDrawCircle();
~LibDrawCircle() { }
virtual wxString GetClass() const
{
return wxT( "LibDrawCircle" );
}
LibDrawCircle* GenCopy();
bool WriteDescr( FILE* File );
};
class LibDrawText : public LibEDA_BaseStruct
{
public:
int m_Horiz;
wxSize m_Size;
int m_Type;
wxString m_Text;
public:
LibDrawText();
~LibDrawText() { }
virtual wxString GetClass() const
{
return wxT( "LibDrawText" );
}
LibDrawText* GenCopy();
bool WriteDescr( FILE* File );
};
class LibDrawSquare : public LibEDA_BaseStruct
{
public:
wxPoint m_End;
FILL_T m_Fill;
public:
LibDrawSquare();
~LibDrawSquare() { }
virtual wxString GetClass() const
{
return wxT( "LibDrawSquare" );
}
LibDrawSquare* GenCopy();
bool WriteDescr( FILE* File );
};
class LibDrawSegment : public LibEDA_BaseStruct
{
public:
wxPoint m_End;
public:
LibDrawSegment();
~LibDrawSegment() { }
virtual wxString GetClass() const
{
return wxT( "LibDrawSegment" );
}
LibDrawSegment* GenCopy();
bool WriteDescr( FILE* File );
};
class LibDrawPolyline : public LibEDA_BaseStruct
{
public:
int n;
int* PolyList;
FILL_T m_Fill;
public:
LibDrawPolyline();
~LibDrawPolyline()
{
if( PolyList )
free( PolyList );
}
virtual wxString GetClass() const
{
return wxT( "LibDrawPolyline" );
}
LibDrawPolyline* GenCopy();
void AddPoint( const wxPoint& point );
bool WriteDescr( FILE* File );
};
/* Fields identiques aux fields des composants, pouvant etre predefinis en lib
* 2 Fields sont toujours presents : Prefix (U, IC..) et Name (74LS00..)*/
class LibDrawField : public LibEDA_BaseStruct
{
public:
int m_FieldId; // 0 a 11
// 0 = Name; 1 = Valeur; 2 .. 11 other fields
wxPoint m_Pos;
wxSize m_Size;
int m_Orient; /* Orientation */
int m_Attributs; /* Attributes (Non visible ...) */
int m_HJustify, m_VJustify; /* Horiz an Vert Texte Justifications */
wxString m_Text; /* Field Data */
wxString m_Name; /* Field Name */
public:
LibDrawField( int idfield = 2 );
~LibDrawField();
virtual wxString GetClass() const
{
return wxT( "LibDrawField" );
}
LibDrawField* GenCopy();
void Copy( LibDrawField* Target );
bool WriteDescr( FILE* File );
};
/* basic class to describe components in libraries (true component or alias), non used directly */
class LibCmpEntry : public EDA_BaseStruct
{
public:
LibrEntryType Type; /* Type = ROOT;
* = ALIAS pour struct LibraryAliasType */
LibDrawField m_Name; // name (74LS00 ..) in lib ( = VALUE )
wxString m_Doc; /* documentation for info */
wxString m_KeyWord; /* keyword list (used to select a group of components by keyword) */
wxString m_DocFile; /* Associed doc filename */
LibrEntryOptions m_Options; // special features (i.e. Entry is a POWER)
public:
LibCmpEntry( LibrEntryType CmpType, const wxChar* CmpName );
virtual ~LibCmpEntry();
virtual wxString GetClass() const
{
return wxT( "LibCmpEntry" );
}
bool WriteDescr( FILE* File );
};
class EDA_LibComponentStruct : public LibCmpEntry /* usual component in lib */
{
public:
LibDrawField m_Prefix; /* Prefix ( U, IC ... ) = REFERENCE */
wxArrayString m_AliasList; /* ALIAS list for the component */
wxArrayString m_FootprintList; /* list of suitable footprint names for the component (wildcard names accepted)*/
int m_UnitCount; /* Units (or sections) per package */
bool m_UnitSelectionLocked; // True if units are differents and their selection is locked
// (i.e. if part A cannot be automatically changed in part B
int m_TextInside; /* if 0: pin name drawn on the pin itself
* if > 0 pin name drawn inside the component,
* with a distance of m_TextInside in mils */
bool m_DrawPinNum;
bool m_DrawPinName;
LibDrawField* Fields; /* Auxiliairy Field list (id = 2 a 11) */
LibEDA_BaseStruct* m_Drawings; /* How to draw this part */
long m_LastDate; // Last change Date
public:
virtual wxString GetClass() const
{
return wxT( "EDA_LibComponentStruct" );
}
EDA_LibComponentStruct( const wxChar* CmpName );
EDA_Rect GetBoundaryBox( int Unit, int Convert ); /* return Box around the part. */
~EDA_LibComponentStruct();
void SortDrawItems();
};
class EDA_LibCmpAliasStruct : public LibCmpEntry /* alias of an usual component in lib (root component) */
{
public:
wxString m_RootName; /* Root component Part name */
public:
EDA_LibCmpAliasStruct( const wxChar* CmpName, const wxChar* CmpRootName );
~EDA_LibCmpAliasStruct();
virtual wxString GetClass() const
{
return wxT( "EDA_LibCmpAliasStruct" );
}
};
/* Variables */
extern LibraryStruct* LibraryList; /* All part libs are saved here. */
extern LibraryStruct* LibraryList; /* All part libs are saved here. */
/* Variables used by LibEdit */
eda_global LibEDA_BaseStruct* LibItemToRepeat; /* pointeur sur l'lment que l'on
* peut rpter (Pin..;) */
eda_global LibEDA_BaseStruct* LibItemToRepeat; /* pointer on a graphic item than can be duplicated by the Ins key
* (usually the last created item */
eda_global LibraryStruct* CurrentLib; /* Current opened library */
eda_global EDA_LibComponentStruct* CurrentLibEntry; /* Current component */
eda_global LibEDA_BaseStruct* CurrentDrawItem; /* current edited item */
......@@ -506,7 +70,6 @@ eda_global int CurrentConvert /* Convert = 1 .. 255 */
#endif
;
eda_global wxString FindLibName; /* nom de la librairie ou a ete trouve le
* dernier composant recherche par FindLibPart() */
eda_global wxString FindLibName; /* Library (name) containing the last component find by FindLibPart() */
#endif // LIBCMP_H
......@@ -153,7 +153,7 @@ bool BlockActive = (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE);
}
else if( (DrawEntry->m_Flags & IS_NEW) )
{
if( ((LibDrawPolyline*)DrawEntry)->n > 2 )
if( ((LibDrawPolyline*)DrawEntry)->m_CornersCount > 2 )
{
msg = AddHotkeyName( _( "Delete Segment " ), s_Libedit_Hokeys_Descr, HK_DELETE_PIN );
ADD_MENUITEM(PopMenu,
......
......@@ -880,8 +880,8 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
LibDrawPolyline* polyline = (LibDrawPolyline*) DrawItem;
if( (masque & LOCATE_COMPONENT_POLYLINE_DRAW_TYPE) == 0 )
break;
ptpoly = polyline->PolyList;
for( ii = polyline->n - 1; ii > 0; ii--, ptpoly += 2 )
ptpoly = polyline->m_PolyList;
for( ii = polyline->m_CornersCount - 1; ii > 0; ii--, ptpoly += 2 )
{
if( IsPointOnSegment( px, py,
ptpoly[0], -ptpoly[1], ptpoly[2], -ptpoly[3], seuil ) )
......
......@@ -20,7 +20,9 @@ OBJECTS = eeschema.o\
cross-probing.o\
setpage.o\
class_schematic_items.o\
classes_body_items.o\
class_drawsheet.o\
class_pin.o\
class_hierarchical_PIN_sheet.o\
class_text-label.o\
component_class.o\
......
......@@ -326,15 +326,15 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
case COMPONENT_POLYLINE_DRAW_TYPE:
{
LibDrawPolyline* polyline = (LibDrawPolyline*) DEntry;
Poly = (int*) MyMalloc( sizeof(int) * 2 * polyline->n );
for( ii = 0; ii < polyline->n; ii++ )
Poly = (int*) MyMalloc( sizeof(int) * 2 * polyline->m_CornersCount );
for( ii = 0; ii < polyline->m_CornersCount; ii++ )
{
Poly[ii * 2] = PartX +
TransMat[0][0] * polyline->PolyList[ii * 2] +
TransMat[0][1] * polyline->PolyList[ii * 2 + 1];
TransMat[0][0] * polyline->m_PolyList[ii * 2] +
TransMat[0][1] * polyline->m_PolyList[ii * 2 + 1];
Poly[ii * 2 + 1] = PartY +
TransMat[1][0] * polyline->PolyList[ii * 2] +
TransMat[1][1] * polyline->PolyList[ii * 2 + 1];
TransMat[1][0] * polyline->m_PolyList[ii * 2] +
TransMat[1][1] * polyline->m_PolyList[ii * 2 + 1];
}
if ( draw_bgfill && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR )
......
......@@ -36,7 +36,7 @@ void InstallCmpeditFrame(WinEDA_SchematicFrame * parent, wxPoint & pos,
/**************/
/* EELIBS2.CPP */
/* EELIBS_.CPP */
/**************/
/* Functions common to all EELibs?.c modules: */
......@@ -69,6 +69,14 @@ EDA_LibComponentStruct * Read_Component_Definition(WinEDA_DrawFrame * frame, cha
FILE *f, int *LineNum);
/* Routine to Read a DEF/ENDDEF part entry from given open file. */
/** Function TransformCoordinate
* Calculate the wew coordinate from the old one, according to the transform matrix.
* @param aTransformMatrix = rotation, mirror .. matrix
* @param aPosition = the position to transform
* @return the new coordinate
*/
wxPoint TransformCoordinate( int aTransformMatrix[2][2], wxPoint & aPosition );
LibraryStruct *FindLibrary(const wxString & Name);
int LoadDocLib(WinEDA_DrawFrame * frame, const wxString & FullDocLibName, const wxString & Libname);
PriorQue *LoadLibraryAux(WinEDA_DrawFrame * frame, LibraryStruct * library,
......
......@@ -156,11 +156,11 @@ bool LibDrawPolyline::WriteDescr( FILE* ExportFile )
int ii, * ptpoly;
fprintf( ExportFile, "P %d %d %d %d",
n,
m_CornersCount,
m_Unit, m_Convert,
m_Width );
ptpoly = PolyList;
for( ii = n; ii > 0; ii-- )
ptpoly = m_PolyList;
for( ii = m_CornersCount; ii > 0; ii-- )
{
fprintf( ExportFile, " %d %d", *ptpoly, *(ptpoly + 1) );
ptpoly += 2;
......
......@@ -261,9 +261,9 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC )
LibDrawPolyline* polyline = new LibDrawPolyline();
CurrentDrawItem = polyline;
polyline->n = 2;
polyline->m_CornersCount = 2;
ptpoly = (int*) MyZMalloc( 4 * sizeof(int) );
polyline->PolyList = ptpoly;
polyline->m_PolyList = ptpoly;
ptpoly[0] = ptpoly[2] = GetScreen()->m_Curseur.x;
ptpoly[1] = ptpoly[3] = -( GetScreen()->m_Curseur.y );
polyline->m_Fill = FlSymbol_Fill;
......@@ -444,8 +444,8 @@ void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos )
case COMPONENT_POLYLINE_DRAW_TYPE:
{
int ii, imax = ( (LibDrawPolyline*) CurrentDrawItem )->n * 2;
int* ptpoly = ( (LibDrawPolyline*) CurrentDrawItem )->PolyList;
int ii, imax = ( (LibDrawPolyline*) CurrentDrawItem )->m_CornersCount * 2;
int* ptpoly = ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList;
int dx = mx - ptpoly[0];
int dy = -my - ptpoly[1];
for( ii = 0; ii < imax; ii += 2 )
......@@ -497,8 +497,8 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC )
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
InitPosition.x = *( (LibDrawPolyline*) CurrentDrawItem )->PolyList;
InitPosition.y = *( ( (LibDrawPolyline*) CurrentDrawItem )->PolyList + 1 );
InitPosition.x = *( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList;
InitPosition.y = *( ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList + 1 );
break;
case COMPONENT_LINE_DRAW_TYPE:
......@@ -589,8 +589,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
ptpoly = ( (LibDrawPolyline*) CurrentDrawItem )->PolyList;
ptpoly += 2 * ( ( (LibDrawPolyline*) CurrentDrawItem )->n - 1 );
ptpoly = ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList;
ptpoly += 2 * ( ( (LibDrawPolyline*) CurrentDrawItem )->m_CornersCount - 1 );
ptpoly[0] = mx;
ptpoly[1] = -my;
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
......@@ -827,10 +827,10 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, 0, 0,
CurrentDrawItem, CurrentUnit, g_XorMode );
while( Poly->n > 2 ) // First segment is kept, only its end point is changed
while( Poly->m_CornersCount > 2 ) // First segment is kept, only its end point is changed
{
Poly->n--;
ptpoly = Poly->PolyList + ( 2 * (Poly->n - 1) );
Poly->m_CornersCount--;
ptpoly = Poly->m_PolyList + ( 2 * (Poly->m_CornersCount - 1) );
if( (ptpoly[0] != GetScreen()->m_Curseur.x)
|| (ptpoly[1] != -GetScreen()->m_Curseur.y) )
{
......@@ -840,8 +840,8 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
}
}
int allocsize = 2 * sizeof(int) * Poly->n;
Poly->PolyList = (int*) realloc( Poly->PolyList, allocsize );
int allocsize = 2 * sizeof(int) * Poly->m_CornersCount;
Poly->m_PolyList = (int*) realloc( Poly->m_PolyList, allocsize );
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, 0, 0,
CurrentDrawItem, CurrentUnit, g_XorMode );
......
......@@ -398,11 +398,11 @@ static bool CompareSymbols( LibEDA_BaseStruct* DEntryRef,
#undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawPolyline*) DEntryRef )
#define CMPSTRUCT ( (LibDrawPolyline*) DEntryCompare )
if( REFSTRUCT->n != CMPSTRUCT->n )
if( REFSTRUCT->m_CornersCount != CMPSTRUCT->m_CornersCount )
return FALSE;
ptref = REFSTRUCT->PolyList;
ptcomp = CMPSTRUCT->PolyList;
for( ii = 2 * REFSTRUCT->n; ii > 0; ii-- )
ptref = REFSTRUCT->m_PolyList;
ptcomp = CMPSTRUCT->m_PolyList;
for( ii = 2 * REFSTRUCT->m_CornersCount; ii > 0; ii-- )
{
if( *ptref != *ptcomp )
return FALSE;
......@@ -495,14 +495,14 @@ void WinEDA_LibeditFrame::PlaceAncre()
case COMPONENT_POLYLINE_DRAW_TYPE:
#undef STRUCT
#define STRUCT ( (LibDrawPolyline*) DrawEntry )
ptsegm = STRUCT->PolyList;
for( ii = STRUCT->n; ii > 0; ii-- )
ptsegm = STRUCT->m_PolyList;
for( ii = STRUCT->m_CornersCount; ii > 0; ii-- )
{
*ptsegm += dx; ptsegm++;
*ptsegm += dy; ptsegm++;
}
break;
default:
;
}
......
......@@ -22,9 +22,9 @@ DEBUG = 0
#Define the wxWidget path (if not found in environment variables):
ifndef WXWIN
ifeq ($(DEBUG), 1)
WXWIN=f:/wxMSW-2.8.8-debug
WXWIN=f:/wxMSW-2.8.9-debug
else
WXWIN=f:/wxMSW-2.8.8
WXWIN=f:/wxMSW-2.8.9-rc1
endif
endif
LIBVERSION = 2.8
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment