EDA_BaseStruct::m_StructType is now type KICAD_T

This commit is contained in:
dickelbeck 2007-08-24 15:10:46 +00:00
parent 908f6d936b
commit f3c324d535
32 changed files with 4536 additions and 3984 deletions

View File

@ -26,7 +26,7 @@ S3D_Vertex::S3D_Vertex(void)
/**************************************************************************/ /**************************************************************************/
S3D_Material::S3D_Material( Struct3D_Master * father, const wxString & name ): S3D_Material::S3D_Material( Struct3D_Master * father, const wxString & name ):
EDA_BaseStruct( father, -1) EDA_BaseStruct( father, NOT_USED )
/**************************************************************************/ /**************************************************************************/
{ {
m_DiffuseColor.x = m_DiffuseColor.y = m_DiffuseColor.z = 1.0; m_DiffuseColor.x = m_DiffuseColor.y = m_DiffuseColor.z = 1.0;
@ -67,7 +67,7 @@ void Struct3D_Master::Copy(Struct3D_Master * pattern)
/***************************************************************/ /***************************************************************/
Struct3D_Master::Struct3D_Master(EDA_BaseStruct * StructFather): Struct3D_Master::Struct3D_Master(EDA_BaseStruct * StructFather):
EDA_BaseStruct( StructFather, -1) EDA_BaseStruct( StructFather, NOT_USED )
/***************************************************************/ /***************************************************************/
{ {
m_MatScale.x = m_MatScale.y = m_MatScale.z = 1.0; m_MatScale.x = m_MatScale.y = m_MatScale.z = 1.0;
@ -100,7 +100,7 @@ S3D_Material * nextmat;
/***************************************************************/ /***************************************************************/
Struct3D_Shape::Struct3D_Shape(EDA_BaseStruct * StructFather): Struct3D_Shape::Struct3D_Shape(EDA_BaseStruct * StructFather):
EDA_BaseStruct( StructFather, -1) EDA_BaseStruct( StructFather, NOT_USED )
/***************************************************************/ /***************************************************************/
{ {
m_3D_Coord = NULL; m_3D_Coord = NULL;

View File

@ -5,6 +5,18 @@ Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Aug-23 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+ eeschema & pcbnew
* Removed class EDA_BaseLineStruct, which brought no behavioral advantage, only data.
Classes which were based on got its data members added and their initializers.
* Changed type of EDA_BaseStruct::m_StructType from int to KICAD_T which is an
enum. This makes debugging easier since gdb will show the name of the
KICAD_T rather than simply a number. Added NOT_USED = -1 to KICAD_T enum for
3d which was using -1.
* More beautification using latest uncrustify and the committed uncrustify.cfg
2007-Aug-24 UPDATE Geoff Harland <gharlandau@yahoo.com.au> 2007-Aug-24 UPDATE Geoff Harland <gharlandau@yahoo.com.au>
================================================================================ ================================================================================
+ pcbnew + pcbnew
@ -27,9 +39,6 @@ email address.
tomorrow I will add a new class COLLECTORS_GUIDE which can be used by a tomorrow I will add a new class COLLECTORS_GUIDE which can be used by a
COLLECTOR to control its operation. It adds the concept of layer COLLECTOR to control its operation. It adds the concept of layer
locking, even though PCBNEW does not support that in the UI yet. locking, even though PCBNEW does not support that in the UI yet.
@todo:
add constructor initializers for classes that were derived from
EDA_BaseLineStruct but are now not. Its late, will do tomorrow.
2007-Aug-22 UPDATE Dick Hollenbeck <dick@softplc.com> 2007-Aug-22 UPDATE Dick Hollenbeck <dick@softplc.com>

View File

@ -17,8 +17,8 @@
#include "macros.h" #include "macros.h"
// DrawStructureType names for error messages only: // KICAD_T names for error messages only:
static wxString DrawStructureTypeName[MAX_STRUCT_TYPE_ID + 1] = { static wxString KICAD_TName[MAX_STRUCT_TYPE_ID + 1] = {
wxT( "Not init" ), wxT( "Not init" ),
wxT( "Pcb" ), wxT( "Pcb" ),
@ -74,7 +74,7 @@ enum textbox {
/******************************************************************************/ /******************************************************************************/
EDA_BaseStruct::EDA_BaseStruct( EDA_BaseStruct* parent, int idType ) EDA_BaseStruct::EDA_BaseStruct( EDA_BaseStruct* parent, KICAD_T idType )
/******************************************************************************/ /******************************************************************************/
{ {
InitVars(); InitVars();
@ -84,7 +84,7 @@ EDA_BaseStruct::EDA_BaseStruct( EDA_BaseStruct* parent, int idType )
/********************************************/ /********************************************/
EDA_BaseStruct::EDA_BaseStruct( int idType ) EDA_BaseStruct::EDA_BaseStruct( KICAD_T idType )
/********************************************/ /********************************************/
{ {
InitVars(); InitVars();
@ -183,7 +183,7 @@ wxString EDA_BaseStruct::ReturnClassName() const
if( (ii < 0) || (ii > MAX_STRUCT_TYPE_ID) ) if( (ii < 0) || (ii > MAX_STRUCT_TYPE_ID) )
ii = MAX_STRUCT_TYPE_ID; ii = MAX_STRUCT_TYPE_ID;
classname = DrawStructureTypeName[ii]; classname = KICAD_TName[ii];
return classname; return classname;
} }
@ -287,16 +287,6 @@ std::ostream& EDA_BaseStruct::NestedSpace( int nestLevel, std::ostream& os )
/**********************************************************************************************/
EDA_BaseLineStruct::EDA_BaseLineStruct( EDA_BaseStruct* StructFather, DrawStructureType idtype ) :
EDA_BaseStruct( StructFather, idtype )
/**********************************************************************************************/
{
m_Layer = 0;
m_Width = 0; // 0 = line, > 0 = tracks, bus ...
};
/*********************************************************/ /*********************************************************/
/* EDA_TextStruct (classe de base, non utilis<69> seule */ /* EDA_TextStruct (classe de base, non utilis<69> seule */
/*********************************************************/ /*********************************************************/

View File

@ -23,11 +23,13 @@ void DrawSheetStruct::Display_Infos(WinEDA_DrawFrame * frame)
Affiche_1_Parametre( frame, 30, _( "FileName" ), m_FileName, BROWN ); Affiche_1_Parametre( frame, 30, _( "FileName" ), m_FileName, BROWN );
} }
/***************************************************************/ /***************************************************************/
void EDA_SchComponentStruct::Display_Infos( WinEDA_DrawFrame* frame ) void EDA_SchComponentStruct::Display_Infos( WinEDA_DrawFrame* frame )
/***************************************************************/ /***************************************************************/
{ {
EDA_LibComponentStruct* Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT );; EDA_LibComponentStruct* Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT );;
wxString msg; wxString msg;
frame->MsgPanel->EraseMsgBox(); frame->MsgPanel->EraseMsgBox();
@ -37,7 +39,8 @@ wxString msg;
if( Entry && Entry->m_Options == ENTRY_POWER ) if( Entry && Entry->m_Options == ENTRY_POWER )
msg = _( "Pwr Symb" ); msg = _( "Pwr Symb" );
else msg = _("Val"); else
msg = _( "Val" );
Affiche_1_Parametre( frame, 10, msg, m_Field[VALUE].m_Text, DARKCYAN ); Affiche_1_Parametre( frame, 10, msg, m_Field[VALUE].m_Text, DARKCYAN );
Affiche_1_Parametre( frame, 28, _( "RefLib" ), m_ChipName.GetData(), BROWN ); Affiche_1_Parametre( frame, 28, _( "RefLib" ), m_ChipName.GetData(), BROWN );
@ -53,10 +56,10 @@ wxString msg;
} }
/*******************************************************/ /*******************************************************/
void LibDrawPin::Display_Infos( WinEDA_DrawFrame* frame ) void LibDrawPin::Display_Infos( WinEDA_DrawFrame* frame )
/*******************************************************/ /*******************************************************/
/* Affiche en bas d'ecran les caracteristiques de la pin /* Affiche en bas d'ecran les caracteristiques de la pin
*/ */
{ {
@ -69,8 +72,10 @@ int ii;
Affiche_1_Parametre( frame, 24, _( "PinName" ), m_PinName, DARKCYAN ); Affiche_1_Parametre( frame, 24, _( "PinName" ), m_PinName, DARKCYAN );
/* Affichage du numero */ /* Affichage du numero */
if(m_PinNum == 0) Text = wxT("?" ); if( m_PinNum == 0 )
else ReturnPinStringNum(Text); Text = wxT( "?" );
else
ReturnPinStringNum( Text );
Affiche_1_Parametre( frame, 40, _( "PinNum" ), Text, DARKCYAN ); Affiche_1_Parametre( frame, 40, _( "PinNum" ), Text, DARKCYAN );
@ -80,8 +85,10 @@ int ii;
/* Affichage de la visiblite */ /* Affichage de la visiblite */
ii = m_Attributs; ii = m_Attributs;
if( ii & 1 ) Text = _("no"); if( ii & 1 )
else Text = _("yes"); Text = _( "no" );
else
Text = _( "yes" );
Affiche_1_Parametre( frame, 58, _( "Display" ), Text, DARKGREEN ); Affiche_1_Parametre( frame, 58, _( "Display" ), Text, DARKGREEN );
/* Affichage de la longueur */ /* Affichage de la longueur */
@ -91,11 +98,20 @@ int ii;
/* Affichage de l'orientation */ /* Affichage de l'orientation */
switch( m_Orient ) switch( m_Orient )
{ {
case PIN_UP: Text = _("Up"); break; case PIN_UP:
case PIN_DOWN: Text = _("Down"); break; Text = _( "Up" ); break;
case PIN_LEFT: Text = _("Left"); break;
case PIN_RIGHT: Text = _("Right"); break; case PIN_DOWN:
default: Text = wxT("??"); break; Text = _( "Down" ); break;
case PIN_LEFT:
Text = _( "Left" ); break;
case PIN_RIGHT:
Text = _( "Right" ); break;
default:
Text = wxT( "??" ); break;
} }
Affiche_1_Parametre( frame, 72, _( "Orient" ), Text, MAGENTA ); Affiche_1_Parametre( frame, 72, _( "Orient" ), Text, MAGENTA );
@ -105,6 +121,7 @@ int ii;
/***********************************************************************/ /***********************************************************************/
void LibEDA_BaseStruct::Display_Infos_DrawEntry( WinEDA_DrawFrame* frame ) void LibEDA_BaseStruct::Display_Infos_DrawEntry( WinEDA_DrawFrame* frame )
/***********************************************************************/ /***********************************************************************/
/* Affiche en bas d'ecran les caracteristiques de l'element /* Affiche en bas d'ecran les caracteristiques de l'element
*/ */
{ {
@ -114,37 +131,59 @@ wxString msg;
/* affichage du type */ /* affichage du type */
msg = wxT( "??" ); msg = wxT( "??" );
switch( m_StructType ) switch( m_StructType )
{ {
case COMPONENT_ARC_DRAW_TYPE: msg = wxT("Arc"); break; case COMPONENT_ARC_DRAW_TYPE:
case COMPONENT_CIRCLE_DRAW_TYPE: msg = wxT("Circle"); break; msg = wxT( "Arc" ); break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: msg = wxT("Text"); break;
case COMPONENT_RECT_DRAW_TYPE: msg = wxT("Rect"); break; case COMPONENT_CIRCLE_DRAW_TYPE:
case COMPONENT_POLYLINE_DRAW_TYPE: msg = wxT("PolyLine"); break; msg = wxT( "Circle" ); break;
case COMPONENT_LINE_DRAW_TYPE: msg = wxT("Segment"); break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
msg = wxT( "Text" ); break;
case COMPONENT_RECT_DRAW_TYPE:
msg = wxT( "Rect" ); break;
case COMPONENT_POLYLINE_DRAW_TYPE:
msg = wxT( "PolyLine" ); break;
case COMPONENT_LINE_DRAW_TYPE:
msg = wxT( "Segment" ); break;
case COMPONENT_PIN_DRAW_TYPE: case COMPONENT_PIN_DRAW_TYPE:
( (LibDrawPin*) this )->Display_Infos( frame ); ( (LibDrawPin*) this )->Display_Infos( frame );
msg = wxT( "Pin" ); msg = wxT( "Pin" );
break; break;
default:
;
} }
Affiche_1_Parametre( frame, 1, wxT( "Type" ), msg, CYAN ); Affiche_1_Parametre( frame, 1, wxT( "Type" ), msg, CYAN );
/* Affichage de l'appartenance */ /* Affichage de l'appartenance */
if( m_Unit == 0 ) msg = _("All"); if( m_Unit == 0 )
else msg.Printf( wxT("%d"), m_Unit ); msg = _( "All" );
else
msg.Printf( wxT( "%d" ), m_Unit );
Affiche_1_Parametre( frame, 10, _( "Unit" ), msg, BROWN ); Affiche_1_Parametre( frame, 10, _( "Unit" ), msg, BROWN );
if( m_Convert == 0 ) msg = _("All" ); if( m_Convert == 0 )
else if( m_Convert == 1 ) msg = _("no"); msg = _( "All" );
else if( m_Convert == 2 ) msg = _("yes"); else if( m_Convert == 1 )
else msg = wxT("?"); msg = _( "no" );
else if( m_Convert == 2 )
msg = _( "yes" );
else
msg = wxT( "?" );
Affiche_1_Parametre( frame, 16, _( "Convert" ), msg, BROWN ); Affiche_1_Parametre( frame, 16, _( "Convert" ), msg, BROWN );
if ( m_Width ) valeur_param(m_Width, msg); if( m_Width )
else msg = _("default"); valeur_param( m_Width, msg );
else
msg = _( "default" );
Affiche_1_Parametre( frame, 24, _( "Width" ), msg, BLUE ); Affiche_1_Parametre( frame, 24, _( "Width" ), msg, BLUE );
} }

View File

@ -841,6 +841,9 @@ static EDA_BaseStruct* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREE
sheet->m_FileName = sheet->m_SheetName + wxT( ".sch" ); sheet->m_FileName = sheet->m_SheetName + wxT( ".sch" );
break; break;
} }
default:
;
} }
SetStructFather( Struct, screen ); SetStructFather( Struct, screen );

View File

@ -594,6 +594,9 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
( (LibDrawText*) item )->m_Pos.x += offset.x; ( (LibDrawText*) item )->m_Pos.x += offset.x;
( (LibDrawText*) item )->m_Pos.y += offset.y; ( (LibDrawText*) item )->m_Pos.y += offset.y;
break; break;
default:
;
} }
item->m_Flags = item->m_Selected = 0; item->m_Flags = item->m_Selected = 0;
@ -701,6 +704,9 @@ void MirrorMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
SETMIRROR( ( (LibDrawText*) item )->m_Pos.x ); SETMIRROR( ( (LibDrawText*) item )->m_Pos.x );
break; break;
default:
;
} }
item->m_Flags = item->m_Selected = 0; item->m_Flags = item->m_Selected = 0;

View File

@ -148,7 +148,7 @@ wxString DrawMarkerStruct::GetComment( void )
/***************************/ /***************************/
EDA_DrawLineStruct::EDA_DrawLineStruct( const wxPoint& pos, int layer ) : EDA_DrawLineStruct::EDA_DrawLineStruct( const wxPoint& pos, int layer ) :
EDA_BaseLineStruct( NULL, DRAW_SEGMENT_STRUCT_TYPE ) EDA_BaseStruct( NULL, DRAW_SEGMENT_STRUCT_TYPE )
{ {
m_Start = pos; m_Start = pos;
m_End = pos; m_End = pos;

View File

@ -23,7 +23,7 @@
/***************************/ /***************************/
/***********************************************************************************/ /***********************************************************************************/
DrawPartStruct::DrawPartStruct( DrawStructureType struct_type, const wxPoint & pos): DrawPartStruct::DrawPartStruct( KICAD_T struct_type, const wxPoint & pos):
EDA_BaseStruct(struct_type) EDA_BaseStruct(struct_type)
/***********************************************************************************/ /***********************************************************************************/
{ {

View File

@ -70,7 +70,7 @@ public:
wxPoint m_Pos; /* Exact position of part. */ wxPoint m_Pos; /* Exact position of part. */
public: public:
DrawPartStruct( DrawStructureType struct_type, const wxPoint & pos); DrawPartStruct( KICAD_T struct_type, const wxPoint & pos);
~DrawPartStruct(void); ~DrawPartStruct(void);
}; };

View File

@ -12,8 +12,7 @@
#include "netlist.h" /* Definitions generales liees au calcul de netliste */ #include "netlist.h" /* Definitions generales liees au calcul de netliste */
#include "protos.h" #include "protos.h"
enum End_Type enum End_Type {
{
UNKNOWN = 0, UNKNOWN = 0,
WIRE_START_END, WIRE_START_END,
WIRE_END_END, WIRE_END_END,
@ -34,8 +33,7 @@ public:
int m_Type; int m_Type;
DanglingEndHandle* m_Pnext; DanglingEndHandle* m_Pnext;
DanglingEndHandle(int type) DanglingEndHandle( int type ) {
{
m_Item = NULL; m_Item = NULL;
m_Type = type; m_Type = type;
m_Pnext = NULL; m_Pnext = NULL;
@ -54,8 +52,9 @@ DanglingEndHandle * RebuildEndList(EDA_BaseStruct *DrawList);
bool SegmentIntersect( int Sx1, int Sy1, int Sx2, int Sy2, bool SegmentIntersect( int Sx1, int Sy1, int Sx2, int Sy2,
int Px1, int Py1 ) int Px1, int Py1 )
/**********************************************************/ /**********************************************************/
/* Retourne TRUE si le point P est sur le segment S. /* Retourne TRUE si le point P est sur le segment S.
Le segment est suppose horizontal ou vertical. * Le segment est suppose horizontal ou vertical.
*/ */
{ {
int Sxmin, Sxmax, Symin, Symax; int Sxmin, Sxmax, Symin, Symax;
@ -63,26 +62,32 @@ int Sxmin, Sxmax, Symin, Symax;
if( Sx1 == Sx2 ) /* Line S is vertical. */ if( Sx1 == Sx2 ) /* Line S is vertical. */
{ {
Symin = MIN( Sy1, Sy2 ); Symax = MAX( Sy1, Sy2 ); Symin = MIN( Sy1, Sy2 ); Symax = MAX( Sy1, Sy2 );
if (Px1 != Sx1) return FALSE; if( Px1 != Sx1 )
if (Py1 >= Symin && Py1 <= Symax) return TRUE; return FALSE;
else return FALSE; if( Py1 >= Symin && Py1 <= Symax )
return TRUE;
else
return FALSE;
} }
else if( Sy1 == Sy2 ) /* Line S is horizontal. */ else if( Sy1 == Sy2 ) /* Line S is horizontal. */
{ {
Sxmin = MIN( Sx1, Sx2 ); Sxmax = MAX( Sx1, Sx2 ); Sxmin = MIN( Sx1, Sx2 ); Sxmax = MAX( Sx1, Sx2 );
if (Py1 != Sy1) return FALSE; if( Py1 != Sy1 )
if (Px1 >= Sxmin && Px1 <= Sxmax) return TRUE; return FALSE;
else return FALSE; if( Px1 >= Sxmin && Px1 <= Sxmax )
return TRUE;
else
return FALSE;
} }
else return FALSE; // Segments quelconques else
return FALSE; // Segments quelconques
} }
/******************************************************************************/ /******************************************************************************/
void WinEDA_SchematicFrame::TestDanglingEnds( EDA_BaseStruct* DrawList, wxDC* DC ) void WinEDA_SchematicFrame::TestDanglingEnds( EDA_BaseStruct* DrawList, wxDC* DC )
/******************************************************************************/ /******************************************************************************/
/* Met a jour les membres m_Dangling des wires, bus, labels /* Met a jour les membres m_Dangling des wires, bus, labels
*/ */
{ {
@ -97,6 +102,7 @@ const DanglingEndHandle * DanglingItem, * nextitem;
} }
ItemList = RebuildEndList( DrawList ); ItemList = RebuildEndList( DrawList );
// Controle des elements // Controle des elements
for( DrawItem = DrawList; DrawItem != NULL; DrawItem = DrawItem->Pnext ) for( DrawItem = DrawList; DrawItem != NULL; DrawItem = DrawItem->Pnext )
{ {
@ -118,7 +124,8 @@ const DanglingEndHandle * DanglingItem, * nextitem;
TestWireForDangling( STRUCT, this, DC ); TestWireForDangling( STRUCT, this, DC );
break; break;
} }
if( STRUCT->m_Layer == LAYER_NOTES) break; if( STRUCT->m_Layer == LAYER_NOTES )
break;
if( STRUCT->m_Layer == LAYER_BUS ) if( STRUCT->m_Layer == LAYER_BUS )
{ {
STRUCT->m_StartIsDangling = STRUCT->m_StartIsDangling =
@ -126,17 +133,22 @@ const DanglingEndHandle * DanglingItem, * nextitem;
break; break;
} }
break; break;
default:
;
} }
} }
} }
/********************************************************************/ /********************************************************************/
LibDrawPin* WinEDA_SchematicFrame::LocatePinEnd( EDA_BaseStruct* DrawList, LibDrawPin* WinEDA_SchematicFrame::LocatePinEnd( EDA_BaseStruct* DrawList,
const wxPoint& pos ) const wxPoint& pos )
/********************************************************************/ /********************************************************************/
/* Teste si le point de coordonnées pos est sur l'extrémité d'une PIN /* Teste si le point de coordonnées pos est sur l'extrémité d'une PIN
retourne un pointeur sur la pin * retourne un pointeur sur la pin
NULL sinon * NULL sinon
*/ */
{ {
EDA_SchComponentStruct* DrawLibItem; EDA_SchComponentStruct* DrawLibItem;
@ -144,11 +156,13 @@ LibDrawPin * Pin;
wxPoint pinpos; wxPoint pinpos;
Pin = LocateAnyPin( DrawList, pos, &DrawLibItem ); Pin = LocateAnyPin( DrawList, pos, &DrawLibItem );
if( ! Pin ) return NULL; if( !Pin )
return NULL;
pinpos = Pin->m_Pos; pinpos = Pin->m_Pos;
if(DrawLibItem == NULL ) pinpos.y = -pinpos.y; if( DrawLibItem == NULL )
pinpos.y = -pinpos.y;
else else
{ {
@ -159,7 +173,8 @@ wxPoint pinpos;
+ DrawLibItem->m_Transform[1][1] * y1; + DrawLibItem->m_Transform[1][1] * y1;
} }
if( (pos.x == pinpos.x) && (pos.y == pinpos.y) ) return Pin; if( (pos.x == pinpos.x) && (pos.y == pinpos.y) )
return Pin;
return NULL; return NULL;
} }
@ -175,22 +190,23 @@ bool Sdangstate = TRUE, Edangstate = TRUE;
for( terminal_item = ItemList; terminal_item != NULL; for( terminal_item = ItemList; terminal_item != NULL;
terminal_item = terminal_item->m_Pnext ) terminal_item = terminal_item->m_Pnext )
{ {
if ( terminal_item->m_Item == DrawRef ) continue; if( terminal_item->m_Item == DrawRef )
continue;
if ( (DrawRef->m_Start.x == terminal_item->m_Pos.x) && if( (DrawRef->m_Start.x == terminal_item->m_Pos.x)
(DrawRef->m_Start.y == terminal_item->m_Pos.y) ) && (DrawRef->m_Start.y == terminal_item->m_Pos.y) )
Sdangstate = FALSE; Sdangstate = FALSE;
if ( (DrawRef->m_End.x == terminal_item->m_Pos.x) && if( (DrawRef->m_End.x == terminal_item->m_Pos.x)
(DrawRef->m_End.y == terminal_item->m_Pos.y) ) && (DrawRef->m_End.y == terminal_item->m_Pos.y) )
Edangstate = FALSE; Edangstate = FALSE;
if( (Sdangstate == FALSE) && (Edangstate == FALSE) ) if( (Sdangstate == FALSE) && (Edangstate == FALSE) )
break; break;
} }
if ( (Sdangstate != DrawRef->m_StartIsDangling) || if( (Sdangstate != DrawRef->m_StartIsDangling)
(Edangstate != DrawRef->m_EndIsDangling) ) || (Edangstate != DrawRef->m_EndIsDangling) )
{ {
if( DC ) if( DC )
RedrawOneStruct( frame->DrawPanel, DC, DrawRef, g_XorMode ); RedrawOneStruct( frame->DrawPanel, DC, DrawRef, g_XorMode );
@ -201,6 +217,7 @@ bool Sdangstate = TRUE, Edangstate = TRUE;
} }
} }
/********************************************************/ /********************************************************/
void TestLabelForDangling( DrawTextStruct* label, void TestLabelForDangling( DrawTextStruct* label,
WinEDA_SchematicFrame* frame, wxDC* DC ) WinEDA_SchematicFrame* frame, wxDC* DC )
@ -212,14 +229,16 @@ bool dangstate = TRUE;
for( terminal_item = ItemList; terminal_item != NULL; for( terminal_item = ItemList; terminal_item != NULL;
terminal_item = terminal_item->m_Pnext ) terminal_item = terminal_item->m_Pnext )
{ {
if ( terminal_item->m_Item == label ) continue; if( terminal_item->m_Item == label )
continue;
switch( terminal_item->m_Type ) switch( terminal_item->m_Type )
{ {
case PIN_END: case PIN_END:
case LABEL_END: case LABEL_END:
case SHEET_LABEL_END: case SHEET_LABEL_END:
if ( (label->m_Pos.x == terminal_item->m_Pos.x) && if( (label->m_Pos.x == terminal_item->m_Pos.x)
(label->m_Pos.y == terminal_item->m_Pos.y) ) && (label->m_Pos.y == terminal_item->m_Pos.y) )
dangstate = FALSE; dangstate = FALSE;
break; break;
@ -241,7 +260,8 @@ bool dangstate = TRUE;
break; break;
} }
if (dangstate == FALSE) break; if( dangstate == FALSE )
break;
} }
if( dangstate != label->m_IsDangling ) if( dangstate != label->m_IsDangling )
@ -259,12 +279,14 @@ bool dangstate = TRUE;
wxPoint ReturnPinPhysicalPosition( LibDrawPin* Pin, wxPoint ReturnPinPhysicalPosition( LibDrawPin* Pin,
EDA_SchComponentStruct* DrawLibItem ) EDA_SchComponentStruct* DrawLibItem )
/****************************************************/ /****************************************************/
/* Retourne la position physique de la pin, qui dépend de l'orientation /* Retourne la position physique de la pin, qui dépend de l'orientation
du composant */ * du composant */
{ {
wxPoint PinPos = Pin->m_Pos; wxPoint PinPos = Pin->m_Pos;
if(DrawLibItem == NULL ) PinPos.y = -PinPos.y; if( DrawLibItem == NULL )
PinPos.y = -PinPos.y;
else else
{ {
@ -297,28 +319,36 @@ EDA_BaseStruct * DrawItem;
#undef STRUCT #undef STRUCT
#define STRUCT ( (DrawGlobalLabelStruct*) DrawItem ) #define STRUCT ( (DrawGlobalLabelStruct*) DrawItem )
item = new DanglingEndHandle( LABEL_END ); item = new DanglingEndHandle( LABEL_END );
item->m_Item = DrawItem; item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_Pos; item->m_Pos = STRUCT->m_Pos;
if ( lastitem ) lastitem->m_Pnext = item; if( lastitem )
else StartList = item; lastitem->m_Pnext = item;
else
StartList = item;
lastitem = item; lastitem = item;
break; break;
case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (EDA_DrawLineStruct*) DrawItem ) #define STRUCT ( (EDA_DrawLineStruct*) DrawItem )
if( STRUCT->m_Layer == LAYER_NOTES ) break; if( STRUCT->m_Layer == LAYER_NOTES )
break;
if( (STRUCT->m_Layer == LAYER_BUS) || (STRUCT->m_Layer == LAYER_WIRE) ) if( (STRUCT->m_Layer == LAYER_BUS) || (STRUCT->m_Layer == LAYER_WIRE) )
{ {
item = new DanglingEndHandle( (STRUCT->m_Layer == LAYER_BUS) ? item = new DanglingEndHandle( (STRUCT->m_Layer == LAYER_BUS) ?
BUS_START_END : WIRE_START_END ); BUS_START_END : WIRE_START_END );
item->m_Item = DrawItem; item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_Start; item->m_Pos = STRUCT->m_Start;
if ( lastitem ) lastitem->m_Pnext = item; if( lastitem )
else StartList = item; lastitem->m_Pnext = item;
else
StartList = item;
lastitem = item; lastitem = item;
item = new DanglingEndHandle( (STRUCT->m_Layer == LAYER_BUS) ? item = new DanglingEndHandle( (STRUCT->m_Layer == LAYER_BUS) ?
BUS_END_END : WIRE_END_END ); BUS_END_END : WIRE_END_END );
item->m_Item = DrawItem; item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_End; item->m_Pos = STRUCT->m_End;
lastitem->m_Pnext = item; lastitem->m_Pnext = item;
@ -330,10 +360,13 @@ EDA_BaseStruct * DrawItem;
#undef STRUCT #undef STRUCT
#define STRUCT ( (DrawJunctionStruct*) DrawItem ) #define STRUCT ( (DrawJunctionStruct*) DrawItem )
item = new DanglingEndHandle( JUNCTION_END ); item = new DanglingEndHandle( JUNCTION_END );
item->m_Item = DrawItem; item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_Pos; item->m_Pos = STRUCT->m_Pos;
if ( lastitem ) lastitem->m_Pnext = item; if( lastitem )
else StartList = item; lastitem->m_Pnext = item;
else
StartList = item;
lastitem = item; lastitem = item;
break; break;
@ -341,12 +374,16 @@ EDA_BaseStruct * DrawItem;
#undef STRUCT #undef STRUCT
#define STRUCT ( (DrawBusEntryStruct*) DrawItem ) #define STRUCT ( (DrawBusEntryStruct*) DrawItem )
item = new DanglingEndHandle( ENTRY_END ); item = new DanglingEndHandle( ENTRY_END );
item->m_Item = DrawItem; item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_Pos; item->m_Pos = STRUCT->m_Pos;
if ( lastitem ) lastitem->m_Pnext = item; if( lastitem )
else StartList = item; lastitem->m_Pnext = item;
else
StartList = item;
lastitem = item; lastitem = item;
item = new DanglingEndHandle( ENTRY_END ); item = new DanglingEndHandle( ENTRY_END );
item->m_Item = DrawItem; item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_End(); item->m_Pos = STRUCT->m_End();
lastitem->m_Pnext = item; lastitem->m_Pnext = item;
@ -359,31 +396,37 @@ EDA_BaseStruct * DrawItem;
#define STRUCT ( (EDA_SchComponentStruct*) DrawItem ) #define STRUCT ( (EDA_SchComponentStruct*) DrawItem )
EDA_LibComponentStruct* Entry; EDA_LibComponentStruct* Entry;
Entry = FindLibPart( STRUCT->m_ChipName, wxEmptyString, FIND_ROOT ); Entry = FindLibPart( STRUCT->m_ChipName, wxEmptyString, FIND_ROOT );
if( Entry == NULL ) break; if( Entry == NULL )
break;
LibEDA_BaseStruct* DrawLibItem = Entry->m_Drawings; LibEDA_BaseStruct* DrawLibItem = Entry->m_Drawings;
for( ; DrawLibItem != NULL; DrawLibItem = DrawLibItem->Next() ) for( ; DrawLibItem != NULL; DrawLibItem = DrawLibItem->Next() )
{ {
if(DrawLibItem->m_StructType != COMPONENT_PIN_DRAW_TYPE) continue; if( DrawLibItem->m_StructType != COMPONENT_PIN_DRAW_TYPE )
continue;
LibDrawPin* Pin = (LibDrawPin*) DrawLibItem; LibDrawPin* Pin = (LibDrawPin*) DrawLibItem;
if( Pin->m_Unit && DrawLibItem->m_Unit && if( Pin->m_Unit && DrawLibItem->m_Unit
(DrawLibItem->m_Unit != Pin->m_Unit) ) && (DrawLibItem->m_Unit != Pin->m_Unit) )
continue; continue;
if( Pin->m_Convert && DrawLibItem->m_Convert && if( Pin->m_Convert && DrawLibItem->m_Convert
(DrawLibItem->m_Convert != Pin->m_Convert) ) && (DrawLibItem->m_Convert != Pin->m_Convert) )
continue; continue;
item = new DanglingEndHandle( PIN_END ); item = new DanglingEndHandle( PIN_END );
item->m_Item = Pin; item->m_Item = Pin;
item->m_Pos = ReturnPinPhysicalPosition( Pin, STRUCT ); item->m_Pos = ReturnPinPhysicalPosition( Pin, STRUCT );
if ( lastitem ) lastitem->m_Pnext = item; if( lastitem )
else StartList = item; lastitem->m_Pnext = item;
else
StartList = item;
lastitem = item; lastitem = item;
} }
break;
break;
} }
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
@ -394,16 +437,24 @@ EDA_BaseStruct * DrawItem;
while( pinsheet ) while( pinsheet )
{ {
item = new DanglingEndHandle( SHEET_LABEL_END ); item = new DanglingEndHandle( SHEET_LABEL_END );
item->m_Item = pinsheet; item->m_Item = pinsheet;
item->m_Pos = pinsheet->m_Pos; item->m_Pos = pinsheet->m_Pos;
if ( lastitem ) lastitem->m_Pnext = item; if( lastitem )
else StartList = item; lastitem->m_Pnext = item;
else
StartList = item;
lastitem = item; lastitem = item;
pinsheet = (DrawSheetLabelStruct*) pinsheet->Pnext; pinsheet = (DrawSheetLabelStruct*) pinsheet->Pnext;
} }
break; break;
} }
default:
;
} }
} }
return StartList; return StartList;
} }

View File

@ -21,17 +21,18 @@
/* Fonctions locales */ /* Fonctions locales */
/* Descr component <DUMMY> used when a component is not found in library, /* Descr component <DUMMY> used when a component is not found in library,
to draw a dummy shape*/ * to draw a dummy shape*/
/* /*
This component is a 400 mils square with the text ?? * This component is a 400 mils square with the text ??
DEF DUMMY U 0 40 Y Y 1 0 N * DEF DUMMY U 0 40 Y Y 1 0 N
F0 "U" 0 -350 60 H V * F0 "U" 0 -350 60 H V
F1 "DUMMY" 0 350 60 H V * F1 "DUMMY" 0 350 60 H V
DRAW * DRAW
T 0 0 0 150 0 0 0 ?? * T 0 0 0 150 0 0 0 ??
S -200 200 200 -200 0 1 0 * S -200 200 200 -200 0 1 0
ENDDRAW * ENDDRAW
ENDDEF * ENDDEF
*/ */
static int s_ItemSelectColor = BROWN; static int s_ItemSelectColor = BROWN;
@ -53,11 +54,13 @@ static void CreateDummyCmp(void)
DummyCmp = new EDA_LibComponentStruct( NULL ); DummyCmp = new EDA_LibComponentStruct( NULL );
LibDrawSquare* Square = new LibDrawSquare(); LibDrawSquare* Square = new LibDrawSquare();
Square->m_Pos = wxPoint( -200, 200 ); Square->m_Pos = wxPoint( -200, 200 );
Square->m_End = wxPoint( 200, -200 ); Square->m_End = wxPoint( 200, -200 );
Square->m_Width = 4; Square->m_Width = 4;
LibDrawText* Text = new LibDrawText(); LibDrawText* Text = new LibDrawText();
Text->m_Size.x = Text->m_Size.y = 150; Text->m_Size.x = Text->m_Size.y = 150;
Text->m_Text = wxT( "??" ); Text->m_Text = wxT( "??" );
@ -73,15 +76,16 @@ void DrawLibEntry(WinEDA_DrawPanel * panel,wxDC * DC,
int Multi, int convert, int Multi, int convert,
int DrawMode, int Color ) int DrawMode, int Color )
/**************************************************************/ /**************************************************************/
/* Routine de dessin d'un composant d'une librairie /* Routine de dessin d'un composant d'une librairie
LibEntry = pointeur sur la description en librairie * LibEntry = pointeur sur la description en librairie
posX, posY = position du composant * posX, posY = position du composant
DrawMode = GrOR .. * DrawMode = GrOR ..
Color = 0 : dessin en vraies couleurs, sinon couleur = Color * Color = 0 : dessin en vraies couleurs, sinon couleur = Color
*
Une croix symbolise le point d'accrochage (ref position) du composant * Une croix symbolise le point d'accrochage (ref position) du composant
*
Le composant est toujours trace avec orientation 0 * Le composant est toujours trace avec orientation 0
*/ */
{ {
int color; int color;
@ -99,24 +103,29 @@ wxPoint text_pos;
convert, DrawMode, Color ); convert, DrawMode, Color );
/* Trace des 2 champs ref et value (Attention aux coord: la matrice /* Trace des 2 champs ref et value (Attention aux coord: la matrice
de transformation change de signe les coord Y */ * de transformation change de signe les coord Y */
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( DC, DrawMode );
if( LibEntry->m_Prefix.m_Attributs & TEXT_NO_VISIBLE ) if( LibEntry->m_Prefix.m_Attributs & TEXT_NO_VISIBLE )
{ {
if( Color >= 0 ) color = Color; if( Color >= 0 )
else color = UNVISIBLE_COLOR; color = Color;
else
color = UNVISIBLE_COLOR;
} }
else
else { {
if( Color >= 0) color = Color; if( Color >= 0 )
else color = ReturnLayerColor(LAYER_REFERENCEPART); color = Color;
else
color = ReturnLayerColor( LAYER_REFERENCEPART );
} }
if( LibEntry->m_UnitCount > 1 ) if( LibEntry->m_UnitCount > 1 )
Prefix.Printf( wxT( "%s?%c" ), LibEntry->m_Prefix.m_Text.GetData(), Multi + 'A' - 1 ); Prefix.Printf( wxT( "%s?%c" ), LibEntry->m_Prefix.m_Text.GetData(), Multi + 'A' - 1 );
else Prefix = LibEntry->m_Prefix.m_Text + wxT("?"); else
Prefix = LibEntry->m_Prefix.m_Text + wxT( "?" );
text_pos.x = LibEntry->m_Prefix.m_Pos.x + posX; text_pos.x = LibEntry->m_Prefix.m_Pos.x + posX;
text_pos.y = posY - LibEntry->m_Prefix.m_Pos.y; text_pos.y = posY - LibEntry->m_Prefix.m_Pos.y;
@ -130,13 +139,17 @@ int LineWidth = MAX(LibEntry->m_Prefix.m_Width, g_DrawMinimunLineWidth);
if( LibEntry->m_Name.m_Attributs & TEXT_NO_VISIBLE ) if( LibEntry->m_Name.m_Attributs & TEXT_NO_VISIBLE )
{ {
if( Color >= 0) color = Color; if( Color >= 0 )
else color = UNVISIBLE_COLOR; color = Color;
else
color = UNVISIBLE_COLOR;
} }
else
else { {
if( Color >= 0 ) color = Color; if( Color >= 0 )
else color = ReturnLayerColor(LAYER_VALUEPART); color = Color;
else
color = ReturnLayerColor( LAYER_VALUEPART );
} }
text_pos.x = LibEntry->m_Name.m_Pos.x + posX; text_pos.x = LibEntry->m_Name.m_Pos.x + posX;
@ -151,17 +164,23 @@ int LineWidth = MAX(LibEntry->m_Prefix.m_Width, g_DrawMinimunLineWidth);
for( Field = LibEntry->Fields; Field != NULL; Field = (LibDrawField*) Field->Pnext ) for( Field = LibEntry->Fields; Field != NULL; Field = (LibDrawField*) Field->Pnext )
{ {
if( Field->m_Text.IsEmpty() ) return; if( Field->m_Text.IsEmpty() )
if ( (Field->m_Flags & IS_MOVED) != 0 ) continue; return;
if( (Field->m_Flags & IS_MOVED) != 0 )
continue;
if( Field->m_Attributs & TEXT_NO_VISIBLE ) if( Field->m_Attributs & TEXT_NO_VISIBLE )
{ {
if( Color >= 0) color = Color; if( Color >= 0 )
else color = UNVISIBLE_COLOR; color = Color;
else
color = UNVISIBLE_COLOR;
} }
else else
{ {
if( Color >= 0) color = Color; if( Color >= 0 )
else color = ReturnLayerColor(LAYER_FIELDS); color = Color;
else
color = ReturnLayerColor( LAYER_FIELDS );
} }
text_pos.x = Field->m_Pos.x + posX; text_pos.x = Field->m_Pos.x + posX;
@ -178,9 +197,9 @@ int LineWidth = MAX(LibEntry->m_Prefix.m_Width, g_DrawMinimunLineWidth);
int len = 3 * panel->GetZoom(); int len = 3 * panel->GetZoom();
GRLine( &panel->m_ClipBox, DC, posX, posY - len, posX, posY + len, 0, color ); GRLine( &panel->m_ClipBox, DC, posX, posY - len, posX, posY + len, 0, color );
GRLine( &panel->m_ClipBox, DC, posX - len, posY, posX + len, posY, 0, color ); GRLine( &panel->m_ClipBox, DC, posX - len, posY, posX + len, posY, 0, color );
} }
/***************************************************************************** /*****************************************************************************
* Routine to draw the given part at given position, transformed/mirror as * * Routine to draw the given part at given position, transformed/mirror as *
* specified, and in the given drawing mode. Only this one is visible... * * specified, and in the given drawing mode. Only this one is visible... *
@ -195,7 +214,8 @@ bool dummy = FALSE;
if( ( Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT ) ) == NULL ) if( ( Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT ) ) == NULL )
{ /* composant non trouvé, on affiche un composant "dummy" */ { /* composant non trouvé, on affiche un composant "dummy" */
dummy = TRUE; dummy = TRUE;
if( DummyCmp == NULL ) CreateDummyCmp(); if( DummyCmp == NULL )
CreateDummyCmp();
Entry = DummyCmp; Entry = DummyCmp;
} }
@ -206,7 +226,7 @@ bool dummy = FALSE;
DrawMode ); DrawMode );
/* Trace des champs, avec placement et orientation selon orient. du /* Trace des champs, avec placement et orientation selon orient. du
composant * composant
*/ */
if( ( (m_Field[REFERENCE].m_Attributs & TEXT_NO_VISIBLE) == 0 ) if( ( (m_Field[REFERENCE].m_Attributs & TEXT_NO_VISIBLE) == 0 )
@ -220,21 +240,24 @@ bool dummy = FALSE;
for( ii = VALUE; ii < NUMBER_OF_FIELDS; ii++ ) for( ii = VALUE; ii < NUMBER_OF_FIELDS; ii++ )
{ {
if (m_Field[ii].m_Flags & IS_MOVED) continue; if( m_Field[ii].m_Flags & IS_MOVED )
continue;
DrawTextField( panel, DC, &m_Field[ii], 0, DrawMode ); DrawTextField( panel, DC, &m_Field[ii], 0, DrawMode );
} }
} }
/***********************************************************/ /***********************************************************/
void DrawTextField( WinEDA_DrawPanel* panel, wxDC* DC, void DrawTextField( WinEDA_DrawPanel* panel, wxDC* DC,
PartTextStruct* Field, int IsMulti, int DrawMode ) PartTextStruct* Field, int IsMulti, int DrawMode )
/***********************************************************/ /***********************************************************/
/* Routine de trace des textes type Field du composant. /* Routine de trace des textes type Field du composant.
entree: * entree:
IsMulti: flag Non Null si il y a plusieurs parts par boitier. * IsMulti: flag Non Null si il y a plusieurs parts par boitier.
n'est utile que pour le champ reference pour ajouter a celui ci * n'est utile que pour le champ reference pour ajouter a celui ci
l'identification de la part ( A, B ... ) * l'identification de la part ( A, B ... )
DrawMode: mode de trace * DrawMode: mode de trace
*/ */
{ {
int orient, color; int orient, color;
@ -243,8 +266,10 @@ EDA_SchComponentStruct *DrawLibItem = (EDA_SchComponentStruct *) Field->m_Parent
int hjustify, vjustify; int hjustify, vjustify;
int LineWidth = MAX( Field->m_Width, g_DrawMinimunLineWidth ); int LineWidth = MAX( Field->m_Width, g_DrawMinimunLineWidth );
if( Field->m_Attributs & TEXT_NO_VISIBLE ) return; if( Field->m_Attributs & TEXT_NO_VISIBLE )
if( Field->IsVoid() ) return; return;
if( Field->IsVoid() )
return;
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( DC, DrawMode );
@ -261,15 +286,20 @@ int LineWidth = MAX(Field->m_Width, g_DrawMinimunLineWidth);
/* Y a t-il rotation (pour l'orientation, la justification)*/ /* Y a t-il rotation (pour l'orientation, la justification)*/
if( DrawLibItem->m_Transform[0][1] ) // Rotation du composant de 90deg if( DrawLibItem->m_Transform[0][1] ) // Rotation du composant de 90deg
{ {
if ( orient == TEXT_ORIENT_HORIZ) orient = TEXT_ORIENT_VERT; if( orient == TEXT_ORIENT_HORIZ )
else orient = TEXT_ORIENT_HORIZ; orient = TEXT_ORIENT_VERT;
else
orient = TEXT_ORIENT_HORIZ;
/* Y a t-il rotation, miroir (pour les justifications)*/ /* Y a t-il rotation, miroir (pour les justifications)*/
EXCHG( hjustify, vjustify ); EXCHG( hjustify, vjustify );
if (DrawLibItem->m_Transform[1][0] < 0 ) vjustify = - vjustify; if( DrawLibItem->m_Transform[1][0] < 0 )
if (DrawLibItem->m_Transform[1][0] > 0 ) hjustify = - hjustify; vjustify = -vjustify;
if( DrawLibItem->m_Transform[1][0] > 0 )
hjustify = -hjustify;
} }
else else
{ /* Texte horizontal: Y a t-il miroir (pour les justifications)*/ {
/* Texte horizontal: Y a t-il miroir (pour les justifications)*/
if( DrawLibItem->m_Transform[0][0] < 0 ) if( DrawLibItem->m_Transform[0][0] < 0 )
hjustify = -hjustify; hjustify = -hjustify;
if( DrawLibItem->m_Transform[1][1] > 0 ) if( DrawLibItem->m_Transform[1][1] > 0 )
@ -280,7 +310,8 @@ int LineWidth = MAX(Field->m_Width, g_DrawMinimunLineWidth);
color = ReturnLayerColor( LAYER_REFERENCEPART ); color = ReturnLayerColor( LAYER_REFERENCEPART );
else if( Field->m_FieldId == VALUE ) else if( Field->m_FieldId == VALUE )
color = ReturnLayerColor( LAYER_VALUEPART ); color = ReturnLayerColor( LAYER_VALUEPART );
else color = ReturnLayerColor(LAYER_FIELDS); else
color = ReturnLayerColor( LAYER_FIELDS );
if( !IsMulti || (Field->m_FieldId != REFERENCE) ) if( !IsMulti || (Field->m_FieldId != REFERENCE) )
{ {
DrawGraphicText( panel, DC, pos, color, Field->m_Text.GetData(), DrawGraphicText( panel, DC, pos, color, Field->m_Text.GetData(),
@ -288,9 +319,9 @@ int LineWidth = MAX(Field->m_Width, g_DrawMinimunLineWidth);
Field->m_Size, Field->m_Size,
hjustify, vjustify, LineWidth ); hjustify, vjustify, LineWidth );
} }
else /* Le champ est la reference, et il y a plusieurs parts par boitier */ else /* Le champ est la reference, et il y a plusieurs parts par boitier */
{/* On ajoute alors A ou B ... a la reference */ {
/* On ajoute alors A ou B ... a la reference */
wxString fulltext = Field->m_Text; wxString fulltext = Field->m_Text;
fulltext.Append( 'A' - 1 + DrawLibItem->m_Multi ); fulltext.Append( 'A' - 1 + DrawLibItem->m_Multi );
DrawGraphicText( panel, DC, pos, color, fulltext.GetData(), DrawGraphicText( panel, DC, pos, color, fulltext.GetData(),
@ -304,18 +335,21 @@ int LineWidth = MAX(Field->m_Width, g_DrawMinimunLineWidth);
/********************************************************************************/ /********************************************************************************/
EDA_LibComponentStruct* FindLibPart( const wxChar* Name, const wxString& LibName, int Alias ) EDA_LibComponentStruct* FindLibPart( const wxChar* Name, const wxString& LibName, int Alias )
/********************************************************************************/ /********************************************************************************/
/* /*
Routine to find a part in one of the libraries given its name. * Routine to find a part in one of the libraries given its name.
Name = Name of part. * Name = Name of part.
LibName = Name of Lib; if "": seach in all libs * LibName = Name of Lib; if "": seach in all libs
Alias = Flag: si flag != 0, retourne un pointeur sur une part ou un alias * Alias = Flag: si flag != 0, retourne un pointeur sur une part ou un alias
si flag = 0, retourne un pointeur sur une part meme si le nom * si flag = 0, retourne un pointeur sur une part meme si le nom
correspond a un alias * correspond a un alias
Alias = FIND_ROOT, ou Alias = FIND_ALIAS * Alias = FIND_ROOT, ou Alias = FIND_ALIAS
*/ */
{ {
EDA_LibComponentStruct* Entry; EDA_LibComponentStruct* Entry;
static EDA_LibComponentStruct DummyEntry( wxEmptyString );/* Used only to call PQFind. */ static EDA_LibComponentStruct DummyEntry( wxEmptyString );/* Used only to call PQFind. */
LibraryStruct* Lib = g_LibraryList; LibraryStruct* Lib = g_LibraryList;
DummyEntry.m_Drawings = NULL;/* Used only to call PQFind. */ DummyEntry.m_Drawings = NULL;/* Used only to call PQFind. */
@ -333,7 +367,8 @@ LibraryStruct *Lib = g_LibraryList;
Lib = Lib->m_Pnext; continue; Lib = Lib->m_Pnext; continue;
} }
} }
if( Lib == NULL ) break; if( Lib == NULL )
break;
Entry = (EDA_LibComponentStruct*) PQFind( Lib->m_Entries, &DummyEntry ); Entry = (EDA_LibComponentStruct*) PQFind( Lib->m_Entries, &DummyEntry );
if( Entry != NULL ) if( Entry != NULL )
{ {
@ -351,9 +386,10 @@ LibraryStruct *Lib = g_LibraryList;
Lib->m_Name, FIND_ROOT ); Lib->m_Name, FIND_ROOT );
} }
return (Entry); return Entry;
} }
/***************************************************************************** /*****************************************************************************
* Routine to draw the given part at given position, transformed/mirror as * Routine to draw the given part at given position, transformed/mirror as
* specified, and in the given drawing mode. * specified, and in the given drawing mode.
@ -375,22 +411,28 @@ int CharColor;
int fill_option; int fill_option;
int SetHightColor; int SetHightColor;
int LineWidth; int LineWidth;
//#define GETCOLOR(l) Color < 0 ? (ReturnLayerColor(l)| SetHightColor) : Color;
#define GETCOLOR(l) Color < 0 ? SetHightColor ? s_ItemSelectColor : (ReturnLayerColor(l)| SetHightColor) : Color;
if (Entry->m_Drawings == NULL) return; //#define GETCOLOR(l) Color < 0 ? (ReturnLayerColor(l)| SetHightColor) : Color;
#define GETCOLOR( l ) Color < 0 ? SetHightColor ?\
s_ItemSelectColor : (ReturnLayerColor( l ) | SetHightColor) : Color;
if( Entry->m_Drawings == NULL )
return;
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( DC, DrawMode );
for( DEntry = Entry->m_Drawings; DEntry != NULL; DEntry = DEntry->Next() ) for( DEntry = Entry->m_Drawings; DEntry != NULL; DEntry = DEntry->Next() )
{ {
/* Elimination des elements non relatifs a l'unite */ /* Elimination des elements non relatifs a l'unite */
if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) ) continue; if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) )
continue;
if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) ) if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) )
continue; continue;
if ( DEntry->m_Flags & IS_MOVED ) continue; // Element en deplacement non trace if( DEntry->m_Flags & IS_MOVED )
continue; // Element en deplacement non trace
SetHightColor = (DEntry->m_Selected & IS_SELECTED) ? HIGHT_LIGHT_FLAG : 0; SetHightColor = (DEntry->m_Selected & IS_SELECTED) ? HIGHT_LIGHT_FLAG : 0;
LineWidth = MAX( DEntry->m_Width, g_DrawMinimunLineWidth ); LineWidth = MAX( DEntry->m_Width, g_DrawMinimunLineWidth );
switch( DEntry->m_StructType ) switch( DEntry->m_StructType )
{ {
case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE:
@ -412,7 +454,10 @@ int LineWidth;
TransMat[1][1] * Arc->m_ArcEnd.y; TransMat[1][1] * Arc->m_ArcEnd.y;
t1 = Arc->t1; t2 = Arc->t2; t1 = Arc->t1; t2 = Arc->t2;
bool swap = MapAngles( &t1, &t2, TransMat ); bool swap = MapAngles( &t1, &t2, TransMat );
if ( swap ) { EXCHG(x1,x2); EXCHG(y1, y2) } if( swap )
{
EXCHG( x1, x2 ); EXCHG( y1, y2 )
}
fill_option = Arc->m_Fill & (~g_PrintFillMask); fill_option = Arc->m_Fill & (~g_PrintFillMask);
if( Color < 0 ) // Normal Color Layer if( Color < 0 ) // Normal Color Layer
{ {
@ -424,18 +469,22 @@ int LineWidth;
GRFilledArc( &panel->m_ClipBox, DC, xc, yc, t1, t2, GRFilledArc( &panel->m_ClipBox, DC, xc, yc, t1, t2,
Arc->m_Rayon, CharColor, CharColor ); Arc->m_Rayon, CharColor, CharColor );
#ifdef DRAW_ARC_WITH_ANGLE #ifdef DRAW_ARC_WITH_ANGLE
else GRArc(&panel->m_ClipBox, DC, xc, yc, t1, t2, else
GRArc( &panel->m_ClipBox, DC, xc, yc, t1, t2,
Arc->m_Rayon, LineWidth, CharColor ); Arc->m_Rayon, LineWidth, CharColor );
#else #else
else GRArc1(&panel->m_ClipBox, DC, x1, y1, x2, y2, else
GRArc1( &panel->m_ClipBox, DC, x1, y1, x2, y2,
xc, yc, LineWidth, CharColor ); xc, yc, LineWidth, CharColor );
#endif #endif
} }
#ifdef DRAW_ARC_WITH_ANGLE #ifdef DRAW_ARC_WITH_ANGLE
else GRArc(&panel->m_ClipBox, DC, xc, yc, t1, t2, else
GRArc( &panel->m_ClipBox, DC, xc, yc, t1, t2,
Arc->m_Rayon, Circle->m_Width, CharColor ); Arc->m_Rayon, Circle->m_Width, CharColor );
#else #else
else GRArc1(&panel->m_ClipBox, DC, x1, y1, x2, y2, else
GRArc1( &panel->m_ClipBox, DC, x1, y1, x2, y2,
xc, yc, Arc->m_Width, CharColor ); xc, yc, Arc->m_Width, CharColor );
#endif #endif
} }
@ -459,10 +508,12 @@ int LineWidth;
else if( fill_option == FILLED_SHAPE ) else if( fill_option == FILLED_SHAPE )
GRFilledCircle( &panel->m_ClipBox, DC, x1, y1, 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, else
GRCircle( &panel->m_ClipBox, DC, x1, y1,
Circle->m_Rayon, LineWidth, CharColor ); Circle->m_Rayon, LineWidth, CharColor );
} }
else GRCircle(&panel->m_ClipBox, DC, x1, y1, else
GRCircle( &panel->m_ClipBox, DC, x1, y1,
Circle->m_Rayon, LineWidth, CharColor ); Circle->m_Rayon, LineWidth, CharColor );
} }
break; break;
@ -473,7 +524,7 @@ int LineWidth;
CharColor = GETCOLOR( LAYER_DEVICE ); CharColor = GETCOLOR( LAYER_DEVICE );
/* The text orientation may need to be flipped if the /* The text orientation may need to be flipped if the
transformation matrix cuases xy axes to be flipped. */ * transformation matrix cuases xy axes to be flipped. */
t1 = (TransMat[0][0] != 0) ^ (Text->m_Horiz != 0); t1 = (TransMat[0][0] != 0) ^ (Text->m_Horiz != 0);
x1 = Pos.x + TransMat[0][0] * Text->m_Pos.x x1 = Pos.x + TransMat[0][0] * Text->m_Pos.x
+ TransMat[0][1] * Text->m_Pos.y; + TransMat[0][1] * Text->m_Pos.y;
@ -509,10 +560,12 @@ int LineWidth;
else if( fill_option == FILLED_SHAPE ) else if( fill_option == FILLED_SHAPE )
GRFilledRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, GRFilledRect( &panel->m_ClipBox, DC, x1, y1, x2, y2,
CharColor, CharColor ); CharColor, CharColor );
else GRRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, else
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2,
LineWidth, CharColor ); LineWidth, CharColor );
} }
else GRRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, else
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2,
LineWidth, CharColor ); LineWidth, CharColor );
} }
break; break;
@ -522,8 +575,8 @@ int LineWidth;
LibDrawPin* Pin = (LibDrawPin*) DEntry; LibDrawPin* Pin = (LibDrawPin*) DEntry;
if( Pin->m_Attributs & PINNOTDRAW ) if( Pin->m_Attributs & PINNOTDRAW )
{ {
if( (ActiveScreen->m_Type == SCHEMATIC_FRAME) && if( (ActiveScreen->m_Type == SCHEMATIC_FRAME)
!g_ShowAllPins ) && !g_ShowAllPins )
break; break;
} }
/* Calcul de l'orientation reelle de la Pin */ /* Calcul de l'orientation reelle de la Pin */
@ -542,6 +595,7 @@ int LineWidth;
if( DrawPinText ) if( DrawPinText )
{ {
wxPoint pinpos( x2, y2 ); wxPoint pinpos( x2, y2 );
CharColor = SetHightColor ? s_ItemSelectColor : Color; CharColor = SetHightColor ? s_ItemSelectColor : Color;
Pin->DrawPinTexts( panel, DC, pinpos, orient, Pin->DrawPinTexts( panel, DC, pinpos, orient,
Entry->m_TextInside, Entry->m_TextInside,
@ -575,6 +629,7 @@ int LineWidth;
TransMat[1][0] * polyline->PolyList[i * 2] + TransMat[1][0] * polyline->PolyList[i * 2] +
TransMat[1][1] * polyline->PolyList[i * 2 + 1]; TransMat[1][1] * polyline->PolyList[i * 2 + 1];
} }
fill_option = polyline->m_Fill & (~g_PrintFillMask); fill_option = polyline->m_Fill & (~g_PrintFillMask);
if( Color < 0 ) if( Color < 0 )
{ {
@ -585,10 +640,12 @@ int LineWidth;
else if( fill_option == FILLED_SHAPE ) else if( fill_option == FILLED_SHAPE )
GRPoly( &panel->m_ClipBox, DC, polyline->n, GRPoly( &panel->m_ClipBox, DC, polyline->n,
Buf_Poly_Drawings, 1, LineWidth, CharColor, CharColor ); Buf_Poly_Drawings, 1, LineWidth, CharColor, CharColor );
else GRPoly(&panel->m_ClipBox, DC, polyline->n, else
GRPoly( &panel->m_ClipBox, DC, polyline->n,
Buf_Poly_Drawings, 0, LineWidth, CharColor, CharColor ); Buf_Poly_Drawings, 0, LineWidth, CharColor, CharColor );
} }
else GRPoly(&panel->m_ClipBox, DC, polyline->n, else
GRPoly( &panel->m_ClipBox, DC, polyline->n,
Buf_Poly_Drawings, 0, LineWidth, CharColor, CharColor ); Buf_Poly_Drawings, 0, LineWidth, CharColor, CharColor );
} }
break; break;
@ -596,13 +653,19 @@ int LineWidth;
default: default:
wxBell(); wxBell();
break; break;
} /* Fin Switch */ }
} /* Fin Boucle de dessin */
/* Fin Switch */
}
/* Fin Boucle de dessin */
if( g_DebugLevel > 4 ) /* Draw the component boundary box */ if( g_DebugLevel > 4 ) /* Draw the component boundary box */
{ {
EDA_Rect BoundaryBox; EDA_Rect BoundaryBox;
if ( Component ) BoundaryBox = Component->GetBoundaryBox(); if( Component )
else BoundaryBox = Entry->GetBoundaryBox(Multi, convert); BoundaryBox = Component->GetBoundaryBox();
else
BoundaryBox = Entry->GetBoundaryBox( Multi, convert );
x1 = BoundaryBox.GetX(); x1 = BoundaryBox.GetX();
y1 = BoundaryBox.GetY(); y1 = BoundaryBox.GetY();
x2 = BoundaryBox.GetRight(); x2 = BoundaryBox.GetRight();
@ -630,7 +693,7 @@ void LibDrawPin::DrawPinSymbol(WinEDA_DrawPanel * panel, wxDC * DC,
/*******************************************************************************/ /*******************************************************************************/
/* Draw the pin symbol (without texts) /* Draw the pin symbol (without texts)
if Color != 0 draw with Color, eles with the normal pin color * if Color != 0 draw with Color, eles with the normal pin color
*/ */
{ {
int MapX1, MapY1, x1, y1; int MapX1, MapY1, x1, y1;
@ -639,23 +702,29 @@ int width = MAX(m_Width, g_DrawMinimunLineWidth);
int posX = pin_pos.x, posY = pin_pos.y, len = m_PinLen; int posX = pin_pos.x, posY = pin_pos.y, len = m_PinLen;
if( Color >= 0) color = Color; if( Color >= 0 )
else color = ReturnLayerColor(LAYER_PIN); color = Color;
else
color = ReturnLayerColor( LAYER_PIN );
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( DC, DrawMode );
MapX1 = MapY1 = 0; x1 = posX; y1 = posY; MapX1 = MapY1 = 0; x1 = posX; y1 = posY;
switch( orient ) switch( orient )
{ {
case PIN_UP: case PIN_UP:
y1 = posY - len; MapY1 = 1; y1 = posY - len; MapY1 = 1;
break; break;
case PIN_DOWN: case PIN_DOWN:
y1 = posY + len; MapY1 = -1; y1 = posY + len; MapY1 = -1;
break; break;
case PIN_LEFT: case PIN_LEFT:
x1 = posX - len, MapX1 = 1; x1 = posX - len, MapX1 = 1;
break; break;
case PIN_RIGHT: case PIN_RIGHT:
x1 = posX + len; MapX1 = -1; x1 = posX + len; MapX1 = -1;
break; break;
@ -671,7 +740,6 @@ int posX = pin_pos.x, posY = pin_pos.y, len = m_PinLen;
MapY1 * INVERT_PIN_RADIUS * 2 + y1 ); MapY1 * INVERT_PIN_RADIUS * 2 + y1 );
GRLineTo( &panel->m_ClipBox, DC, posX, posY, width, color ); GRLineTo( &panel->m_ClipBox, DC, posX, posY, width, color );
} }
else else
{ {
GRMoveTo( x1, y1 ); GRMoveTo( x1, y1 );
@ -718,12 +786,22 @@ int posX = pin_pos.x, posY = pin_pos.y, len = m_PinLen;
if( MapY1 == 0 ) /* MapX1 = +- 1 */ if( MapY1 == 0 ) /* MapX1 = +- 1 */
{ {
GRMoveTo( x1, y1 - IEEE_SYMBOL_PIN_DIM ); GRMoveTo( x1, y1 - IEEE_SYMBOL_PIN_DIM );
GRLineTo(&panel->m_ClipBox, DC, x1 + MapX1 * IEEE_SYMBOL_PIN_DIM*2, y1, width, color); GRLineTo( &panel->m_ClipBox,
DC,
x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1,
width,
color );
} }
else /* MapX1 = 0 */ else /* MapX1 = 0 */
{ {
GRMoveTo( x1 - IEEE_SYMBOL_PIN_DIM, y1 ); GRMoveTo( x1 - IEEE_SYMBOL_PIN_DIM, y1 );
GRLineTo(&panel->m_ClipBox, DC, x1 , y1 + MapY1 * IEEE_SYMBOL_PIN_DIM*2, width, color); GRLineTo( &panel->m_ClipBox,
DC,
x1,
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM * 2,
width,
color );
} }
} }
@ -773,7 +851,8 @@ bool swap = FALSE;
NORMALIZE_ANGLE( *Angle1 ); NORMALIZE_ANGLE( *Angle1 );
NORMALIZE_ANGLE( *Angle2 ); NORMALIZE_ANGLE( *Angle2 );
if (*Angle2 < *Angle1) *Angle2 += 3600; if( *Angle2 < *Angle1 )
*Angle2 += 3600;
if( *Angle2 - *Angle1 > 1800 ) if( *Angle2 - *Angle1 > 1800 )
{ /* Need to swap the two angles. */ { /* Need to swap the two angles. */
@ -783,7 +862,8 @@ bool swap = FALSE;
NORMALIZE_ANGLE( *Angle1 ); NORMALIZE_ANGLE( *Angle1 );
NORMALIZE_ANGLE( *Angle2 ); NORMALIZE_ANGLE( *Angle2 );
if (*Angle2 < *Angle1) *Angle2 += 3600; if( *Angle2 < *Angle1 )
*Angle2 += 3600;
swap = TRUE; swap = TRUE;
} }
@ -811,9 +891,9 @@ int DrawMode = g_XorMode;
DrawLibPartAux( panel, DC, DrawLibItem, LibEntry, wxPoint( PartX, PartY ), DrawLibPartAux( panel, DC, DrawLibItem, LibEntry, wxPoint( PartX, PartY ),
DrawLibItem->m_Transform, DrawLibItem->m_Transform,
multi, convert, DrawMode, Color, DrawPinText ); multi, convert, DrawMode, Color, DrawPinText );
} }
/************************************************************/ /************************************************************/
/* Routine to draw One LibraryDrawStruct at given position, */ /* Routine to draw One LibraryDrawStruct at given position, */
/* matrice de transformation 1 0 0 -1 (normale) */ /* matrice de transformation 1 0 0 -1 (normale) */
@ -860,7 +940,10 @@ int fill_option;
x1 = PartX + Arc->m_ArcEnd.x; x1 = PartX + Arc->m_ArcEnd.x;
y1 = PartY - Arc->m_ArcEnd.y; y1 = PartY - Arc->m_ArcEnd.y;
if ( swap ) { EXCHG(x1,x2); EXCHG(y1, y2)} if( swap )
{
EXCHG( x1, x2 ); EXCHG( y1, y2 )
}
fill_option = Arc->m_Fill & (~g_PrintFillMask); fill_option = Arc->m_Fill & (~g_PrintFillMask);
if( (Arc->m_Fill == FILLED_WITH_BG_BODYCOLOR) && !g_IsPrinting ) if( (Arc->m_Fill == FILLED_WITH_BG_BODYCOLOR) && !g_IsPrinting )
GRFilledArc( &panel->m_ClipBox, DC, xc, yc, t1, t2, GRFilledArc( &panel->m_ClipBox, DC, xc, yc, t1, t2,
@ -870,10 +953,12 @@ int fill_option;
GRFilledArc( &panel->m_ClipBox, DC, xc, yc, t1, t2, 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 #ifdef DRAW_ARC_WITH_ANGLE
else GRArc(&panel->m_ClipBox, DC, xc, yc, t1, t2, else
GRArc( &panel->m_ClipBox, DC, xc, yc, t1, t2,
Arc->m_Rayon, CharColor ); Arc->m_Rayon, CharColor );
#else #else
else GRArc1(&panel->m_ClipBox, DC, x1, y1, x2, y2, else
GRArc1( &panel->m_ClipBox, DC, x1, y1, x2, y2,
xc, yc, LineWidth, CharColor ); xc, yc, LineWidth, CharColor );
#endif #endif
} }
@ -892,7 +977,8 @@ int fill_option;
else if( fill_option == FILLED_SHAPE ) else if( fill_option == FILLED_SHAPE )
GRFilledCircle( &panel->m_ClipBox, DC, x1, y1, 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, else
GRCircle( &panel->m_ClipBox, DC, x1, y1,
Circle->m_Rayon, LineWidth, CharColor ); Circle->m_Rayon, LineWidth, CharColor );
} }
break; break;
@ -924,7 +1010,8 @@ int fill_option;
else if( fill_option == FILLED_SHAPE ) else if( fill_option == FILLED_SHAPE )
GRFilledRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, GRFilledRect( &panel->m_ClipBox, DC, x1, y1, x2, y2,
CharColor, CharColor ); CharColor, CharColor );
else GRRect(&panel->m_ClipBox, DC, x1, y1, x2, y2, LineWidth, else
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, LineWidth,
CharColor ); CharColor );
} }
break; break;
@ -938,11 +1025,14 @@ int fill_option;
orient = Pin->ReturnPinDrawOrient( TransMat ); orient = Pin->ReturnPinDrawOrient( TransMat );
/* Dessin de la pin et du symbole special associe */ /* Dessin de la pin et du symbole special associe */
if( Pin->m_Attributs & PINNOTDRAW) CharColor = DARKGRAY; if( Pin->m_Attributs & PINNOTDRAW )
else CharColor = -1; CharColor = DARKGRAY;
else
CharColor = -1;
Pin->DrawPinSymbol( panel, DC, wxPoint( x2, y2 ), orient, DrawMode ); Pin->DrawPinSymbol( panel, DC, wxPoint( x2, y2 ), orient, DrawMode );
wxPoint pinpos( x2, y2 ); wxPoint pinpos( x2, y2 );
Pin->DrawPinTexts( panel, DC, pinpos, orient, Pin->DrawPinTexts( panel, DC, pinpos, orient,
LibEntry->m_TextInside, LibEntry->m_TextInside,
LibEntry->m_DrawPinNum, LibEntry->m_DrawPinName, LibEntry->m_DrawPinNum, LibEntry->m_DrawPinName,
@ -969,6 +1059,7 @@ int fill_option;
Buf_Poly_Drawings[i * 2] = PartX + polyline->PolyList[i * 2]; Buf_Poly_Drawings[i * 2] = PartX + polyline->PolyList[i * 2];
Buf_Poly_Drawings[i * 2 + 1] = PartY - polyline->PolyList[i * 2 + 1]; Buf_Poly_Drawings[i * 2 + 1] = PartY - polyline->PolyList[i * 2 + 1];
} }
fill_option = polyline->m_Fill & (~g_PrintFillMask); fill_option = polyline->m_Fill & (~g_PrintFillMask);
if( (fill_option == FILLED_WITH_BG_BODYCOLOR) && !g_IsPrinting ) if( (fill_option == FILLED_WITH_BG_BODYCOLOR) && !g_IsPrinting )
GRPoly( &panel->m_ClipBox, DC, polyline->n, GRPoly( &panel->m_ClipBox, DC, polyline->n,
@ -977,10 +1068,13 @@ int fill_option;
else if( fill_option == FILLED_SHAPE ) else if( fill_option == FILLED_SHAPE )
GRPoly( &panel->m_ClipBox, DC, polyline->n, GRPoly( &panel->m_ClipBox, DC, polyline->n,
Buf_Poly_Drawings, 1, LineWidth, CharColor, CharColor ); Buf_Poly_Drawings, 1, LineWidth, CharColor, CharColor );
else GRPoly(&panel->m_ClipBox, DC, polyline->n, else
GRPoly( &panel->m_ClipBox, DC, polyline->n,
Buf_Poly_Drawings, 0, LineWidth, CharColor, CharColor ); Buf_Poly_Drawings, 0, LineWidth, CharColor, CharColor );
break; break;
} }
}
}
default:
;
}
}

View File

@ -69,17 +69,21 @@ wxString FullFileName;
} }
NewLib = new LibraryStruct( LIBRARY_TYPE_EESCHEMA, LibName, FullLibName ); NewLib = new LibraryStruct( LIBRARY_TYPE_EESCHEMA, LibName, FullLibName );
Entries = LoadLibraryAux( frame, NewLib, f, &NumOfParts ); Entries = LoadLibraryAux( frame, NewLib, f, &NumOfParts );
if( Entries != NULL ) if( Entries != NULL )
{ {
NewLib->m_Entries = Entries; NewLib->m_Entries = Entries;
NewLib->m_NumOfParts = NumOfParts; NewLib->m_NumOfParts = NumOfParts;
if ( g_LibraryList == NULL ) g_LibraryList = NewLib; if( g_LibraryList == NULL )
g_LibraryList = NewLib;
else else
{ {
LibraryStruct* tmplib = g_LibraryList; LibraryStruct* tmplib = g_LibraryList;
while ( tmplib->m_Pnext ) tmplib = tmplib->m_Pnext; while( tmplib->m_Pnext )
tmplib = tmplib->m_Pnext;
tmplib->m_Pnext = NewLib; tmplib->m_Pnext = NewLib;
} }
@ -87,7 +91,8 @@ wxString FullFileName;
ChangeFileNameExt( FullFileName, DOC_EXT ); ChangeFileNameExt( FullFileName, DOC_EXT );
LoadDocLib( frame, FullFileName, NewLib->m_Name ); LoadDocLib( frame, FullFileName, NewLib->m_Name );
} }
else delete NewLib; else
delete NewLib;
fclose( f ); fclose( f );
return NewLib; return NewLib;
@ -97,8 +102,9 @@ wxString FullFileName;
/******************************************/ /******************************************/
void LoadLibraries( WinEDA_DrawFrame* frame ) void LoadLibraries( WinEDA_DrawFrame* frame )
/******************************************/ /******************************************/
/* Delete toutes les librairies chargees et recree toutes les librairies /* Delete toutes les librairies chargees et recree toutes les librairies
donnes dans la liste g_LibName_List * donnes dans la liste g_LibName_List
*/ */
{ {
wxString FullLibName, msg; wxString FullLibName, msg;
@ -112,13 +118,15 @@ LibraryStruct *nextlib, *lib = g_LibraryList;
for( ; lib != NULL; lib = nextlib ) for( ; lib != NULL; lib = nextlib )
{ {
nextlib = lib->m_Pnext; nextlib = lib->m_Pnext;
if ( lib->m_IsLibCache ) continue; if( lib->m_IsLibCache )
continue;
wxString libname = lib->m_Name; wxString libname = lib->m_Name;
// is this library in "wanted list" g_LibName_List ? // is this library in "wanted list" g_LibName_List ?
int test = g_LibName_List.Index( libname ); int test = g_LibName_List.Index( libname );
if ( test == wxNOT_FOUND ) FreeCmpLibrary(frame, libname); if( test == wxNOT_FOUND )
FreeCmpLibrary( frame, libname );
} }
// Load missing libraries (if any) // Load missing libraries (if any)
@ -126,7 +134,8 @@ LibraryStruct *nextlib, *lib = g_LibraryList;
{ {
LibName = g_LibName_List[ii]; LibName = g_LibName_List[ii];
if( LibName.IsEmpty() ) continue; if( LibName.IsEmpty() )
continue;
FullLibName = MakeFileName( g_RealLibDirBuffer, LibName, g_LibExtBuffer ); FullLibName = MakeFileName( g_RealLibDirBuffer, LibName, g_LibExtBuffer );
msg = wxT( "Loading " ) + FullLibName; msg = wxT( "Loading " ) + FullLibName;
if( LoadLibraryName( frame, FullLibName, LibName ) ) if( LoadLibraryName( frame, FullLibName, LibName ) )
@ -143,7 +152,9 @@ LibraryStruct *nextlib, *lib = g_LibraryList;
lib->m_Flags = 0; lib->m_Flags = 0;
NumOfLibs++; NumOfLibs++;
} }
if ( NumOfLibs == 0 ) return;
if( NumOfLibs == 0 )
return;
LibraryStruct** libs = LibraryStruct** libs =
(LibraryStruct**) MyZMalloc( sizeof(LibraryStruct *) * (NumOfLibs + 2) ); (LibraryStruct**) MyZMalloc( sizeof(LibraryStruct *) * (NumOfLibs + 2) );
@ -151,7 +162,8 @@ LibraryStruct *nextlib, *lib = g_LibraryList;
int jj = 0; int jj = 0;
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) for( ii = 0; ii < g_LibName_List.GetCount(); ii++ )
{ {
if ( jj >= NumOfLibs ) break; if( jj >= NumOfLibs )
break;
lib = FindLibrary( g_LibName_List[ii] ); lib = FindLibrary( g_LibName_List[ii] );
if( lib ) if( lib )
{ {
@ -159,11 +171,14 @@ LibraryStruct *nextlib, *lib = g_LibraryList;
libs[jj++] = lib; libs[jj++] = lib;
} }
} }
/* Put lib cache at end of list */ /* Put lib cache at end of list */
for( lib = g_LibraryList; lib != NULL; lib = lib->m_Pnext ) for( lib = g_LibraryList; lib != NULL; lib = lib->m_Pnext )
{ {
if ( lib->m_Flags == 0 ) libs[jj++] = lib; if( lib->m_Flags == 0 )
libs[jj++] = lib;
} }
libs[jj] = NULL; libs[jj] = NULL;
/* Change the linked list pointers */ /* Change the linked list pointers */
@ -178,6 +193,7 @@ LibraryStruct *nextlib, *lib = g_LibraryList;
lib->m_Flags = 0; lib->m_Flags = 0;
} }
/***************************************************************************** /*****************************************************************************
* Routine to free a library from the current loaded libraries. * * Routine to free a library from the current loaded libraries. *
*****************************************************************************/ *****************************************************************************/
@ -195,29 +211,37 @@ LibraryStruct *Lib, *TempLib;
/* Search for this library name: */ /* Search for this library name: */
for( Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext ) for( Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
{ {
if (LibName == Lib->m_Name) break; if( LibName == Lib->m_Name )
break;
} }
if (Lib == NULL) return; if( Lib == NULL )
return;
if ( Lib == g_LibraryList) g_LibraryList = Lib->m_Pnext; if( Lib == g_LibraryList )
g_LibraryList = Lib->m_Pnext;
else else
{ {
for( TempLib = g_LibraryList; TempLib->m_Pnext != Lib; TempLib=TempLib->m_Pnext); for( TempLib = g_LibraryList; TempLib->m_Pnext != Lib; TempLib = TempLib->m_Pnext )
;
TempLib->m_Pnext = TempLib->m_Pnext->m_Pnext; TempLib->m_Pnext = TempLib->m_Pnext->m_Pnext;
} }
delete Lib; delete Lib;
/* La librairie supprimee est peut etre celle selectee dans libedit */ /* La librairie supprimee est peut etre celle selectee dans libedit */
if ( Lib == CurrentLib ) CurrentLib = NULL; if( Lib == CurrentLib )
CurrentLib = NULL;
} }
/******************************/ /******************************/
const wxChar** GetLibNames( void ) const wxChar** GetLibNames( void )
/******************************/ /******************************/
/* Routine to return pointers to all library names. /* Routine to return pointers to all library names.
User is responsible to deallocate memory * User is responsible to deallocate memory
*/ */
{ {
int ii, NumOfLibs = NumOfLibraries(); int ii, NumOfLibs = NumOfLibraries();
@ -229,6 +253,7 @@ LibraryStruct *Lib;
{ {
Names[ii] = Lib->m_Name.GetData(); Names[ii] = Lib->m_Name.GetData();
} }
Names[ii] = NULL; Names[ii] = NULL;
return Names; return Names;
@ -244,10 +269,12 @@ int LibraryEntryCompare(EDA_LibComponentStruct *LE1, EDA_LibComponentStruct *LE2
return LE1->m_Name.m_Text.CmpNoCase( LE2->m_Name.m_Text ); return LE1->m_Name.m_Text.CmpNoCase( LE2->m_Name.m_Text );
} }
/***************************************************************************** /*****************************************************************************
* Routine to load a library from given open file. * * Routine to load a library from given open file. *
*****************************************************************************/ *****************************************************************************/
PriorQue *LoadLibraryAux(WinEDA_DrawFrame * frame, LibraryStruct * Library, FILE *libfile, int *NumOfParts) PriorQue* LoadLibraryAux( WinEDA_DrawFrame* frame, LibraryStruct* Library, FILE* libfile,
int* NumOfParts )
{ {
int LineNum = 0; int LineNum = 0;
char Line[1024]; char Line[1024];
@ -273,7 +300,8 @@ wxBusyCursor ShowWait; // Display a Busy Cursor..
return NULL; return NULL;
} }
if ( Library ) Library->m_Header = CONV_FROM_UTF8(Line); if( Library )
Library->m_Header = CONV_FROM_UTF8( Line );
PQInit( &PQ ); PQInit( &PQ );
PQCompFunc( (PQCompFuncType) LibraryEntryCompare ); PQCompFunc( (PQCompFuncType) LibraryEntryCompare );
@ -315,6 +343,7 @@ wxBusyCursor ShowWait; // Display a Busy Cursor..
EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char* Line, EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char* Line,
FILE* f, int* LineNum ) FILE* f, int* LineNum )
/*********************************************************************************************/ /*********************************************************************************************/
/* Routine to Read a DEF/ENDDEF part entry from given open file. /* Routine to Read a DEF/ENDDEF part entry from given open file.
*/ */
{ {
@ -337,36 +366,38 @@ wxString Msg;
char drawnum = 0, drawname = 0; char drawnum = 0, drawname = 0;
LibEntry = new EDA_LibComponentStruct( NULL ); LibEntry = new EDA_LibComponentStruct( NULL );
if ((Name = strtok(NULL, " \t\n")) == NULL || /* Part name: */ if( ( Name = strtok( NULL, " \t\n" ) ) == NULL /* Part name: */
(Prefix = strtok(NULL, " \t\n")) == NULL || /* Prefix name: */ || ( Prefix = strtok( NULL, " \t\n" ) ) == NULL /* Prefix name: */
(p = strtok(NULL, " \t\n")) == NULL || /* NumOfPins: */ || ( p = strtok( NULL, " \t\n" ) ) == NULL /* NumOfPins: */
sscanf(p, "%d", &unused) != 1 || || sscanf( p, "%d", &unused ) != 1
(p = strtok(NULL, " \t\n")) == NULL || /* TextInside: */ || ( p = strtok( NULL, " \t\n" ) ) == NULL /* TextInside: */
sscanf(p, "%d", &LibEntry->m_TextInside) != 1 || || sscanf( p, "%d", &LibEntry->m_TextInside ) != 1
(p = strtok(NULL, " \t\n")) == NULL || /* DrawNums: */ || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */
sscanf(p, "%c", &drawnum) != 1 || || sscanf( p, "%c", &drawnum ) != 1
(p = strtok(NULL, " \t\n")) == NULL || /* DrawNums: */ || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */
sscanf(p, "%c", &drawname) != 1 || || sscanf( p, "%c", &drawname ) != 1
(p = strtok(NULL, " \t\n")) == NULL || /* m_UnitCount: */ || ( p = strtok( NULL, " \t\n" ) ) == NULL /* m_UnitCount: */
sscanf(p, "%d", &LibEntry->m_UnitCount) != 1 ) || sscanf( p, "%d", &LibEntry->m_UnitCount ) != 1 )
{ {
Msg.Printf( wxT( "Wrong DEF format in line %d, skipped." ), *LineNum ); Msg.Printf( wxT( "Wrong DEF format in line %d, skipped." ), *LineNum );
DisplayError( frame, Msg ); DisplayError( frame, Msg );
while( GetLine( f, Line, LineNum, 1024 ) ) while( GetLine( f, Line, LineNum, 1024 ) )
{ {
p = strtok( Line, " \t\n" ); p = strtok( Line, " \t\n" );
if (stricmp(p, "ENDDEF") == 0) break; if( stricmp( p, "ENDDEF" ) == 0 )
} break;
return NULL;
} }
return NULL;
}
else /* Mise a jour des infos de la ligne "DEF" */ else /* Mise a jour des infos de la ligne "DEF" */
{ {
LibEntry->m_DrawPinNum = (drawnum == 'N') ? FALSE : TRUE; LibEntry->m_DrawPinNum = (drawnum == 'N') ? FALSE : TRUE;
LibEntry->m_DrawPinName = (drawname == 'N') ? FALSE : TRUE; LibEntry->m_DrawPinName = (drawname == 'N') ? FALSE : TRUE;
/* Copy part name and prefix. */ /* Copy part name and prefix. */
strupper( Name ); strupper( Name );
if(Name[0] != '~') LibEntry->m_Name.m_Text = CONV_FROM_UTF8(Name); if( Name[0] != '~' )
LibEntry->m_Name.m_Text = CONV_FROM_UTF8( Name );
else else
{ {
LibEntry->m_Name.m_Text = CONV_FROM_UTF8( &Name[1] ); LibEntry->m_Name.m_Text = CONV_FROM_UTF8( &Name[1] );
@ -378,16 +409,19 @@ wxString Msg;
LibEntry->m_Prefix.m_Text.Empty(); LibEntry->m_Prefix.m_Text.Empty();
LibEntry->m_Prefix.m_Attributs |= TEXT_NO_VISIBLE; LibEntry->m_Prefix.m_Attributs |= TEXT_NO_VISIBLE;
} }
else LibEntry->m_Prefix.m_Text = CONV_FROM_UTF8(Prefix); else
LibEntry->m_Prefix.m_Text = CONV_FROM_UTF8( Prefix );
// Copy optional infos // Copy optional infos
if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) // m_UnitSelectionLocked param if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) // m_UnitSelectionLocked param
{ {
if ( *p == 'L') LibEntry->m_UnitSelectionLocked = TRUE; if( *p == 'L' )
LibEntry->m_UnitSelectionLocked = TRUE;
} }
if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) /* Type Of Component */ if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) /* Type Of Component */
{ {
if ( *p == 'P') LibEntry->m_Options = ENTRY_POWER; if( *p == 'P' )
LibEntry->m_Options = ENTRY_POWER;
} }
} }
@ -401,33 +435,27 @@ wxString Msg;
{ {
Res = ReadLibEntryDateAndTime( LibEntry, Line ); Res = ReadLibEntryDateAndTime( LibEntry, Line );
} }
else if( Line[0] == 'F' ) else if( Line[0] == 'F' )
{ {
Res = GetLibEntryField( LibEntry, Line ); Res = GetLibEntryField( LibEntry, Line );
} }
else if( strcmp( p, "ENDDEF" ) == 0 ) else if( strcmp( p, "ENDDEF" ) == 0 )
{ {
break; break;
} }
else if( strcmp( p, "DRAW" ) == 0 ) else if( strcmp( p, "DRAW" ) == 0 )
{ {
LibEntry->m_Drawings = GetDrawEntry( frame, f, Line, LineNum ); LibEntry->m_Drawings = GetDrawEntry( frame, f, Line, LineNum );
} }
else if( strncmp( p, "ALIAS", 5 ) == 0 ) else if( strncmp( p, "ALIAS", 5 ) == 0 )
{ {
p = strtok( NULL, "\r\n" ); p = strtok( NULL, "\r\n" );
Res = AddAliasNames( LibEntry, p ); Res = AddAliasNames( LibEntry, p );
} }
else if( strncmp( p, "$FPLIST", 5 ) == 0 ) else if( strncmp( p, "$FPLIST", 5 ) == 0 )
{ {
Res = AddFootprintFilterList( LibEntry, f, Line, LineNum ); Res = AddFootprintFilterList( LibEntry, f, Line, LineNum );
} }
else else
{ {
Msg.Printf( wxT( "Undefined command \"%s\" in line %d, skipped." ), p, *LineNum ); Msg.Printf( wxT( "Undefined command \"%s\" in line %d, skipped." ), p, *LineNum );
@ -450,7 +478,6 @@ wxString Msg;
} }
/***************************************************************************** /*****************************************************************************
* Routine to load a DRAW definition from given file. Note "DRAW" line has * * Routine to load a DRAW definition from given file. Note "DRAW" line has *
* been read already. Reads upto and include ENDDRAW, or an error (NULL ret). * * been read already. Reads upto and include ENDDRAW, or an error (NULL ret). *
@ -489,16 +516,20 @@ LibEDA_BaseStruct *Tail = NULL,
{ {
int startx, starty, endx, endy; int startx, starty, endx, endy;
LibDrawArc* Arc = new LibDrawArc(); LibDrawArc* Arc = new LibDrawArc();
New = Arc; New = Arc;
ll = 0; ll = 0;
int nbarg = sscanf( &Line[2], "%d %d %d %d %d %d %d %d %s %d %d %d %d", int nbarg = sscanf( &Line[2], "%d %d %d %d %d %d %d %d %s %d %d %d %d",
&Arc->m_Pos.x, &Arc->m_Pos.y, &Arc->m_Rayon, &Arc->m_Pos.x, &Arc->m_Pos.y, &Arc->m_Rayon,
&Arc->t1, &Arc->t2, &Unit, &Convert, &Arc->t1, &Arc->t2, &Unit, &Convert,
&Arc->m_Width, chartmp, &startx, &starty, &endx, &endy ); &Arc->m_Width, chartmp, &startx, &starty, &endx, &endy );
if ( nbarg < 8 ) Error = TRUE; if( nbarg < 8 )
Error = TRUE;
Arc->m_Unit = Unit; Arc->m_Convert = Convert; Arc->m_Unit = Unit; Arc->m_Convert = Convert;
if ( chartmp[0] == 'F') Arc->m_Fill = FILLED_SHAPE; if( chartmp[0] == 'F' )
if ( chartmp[0] == 'f') Arc->m_Fill = FILLED_WITH_BG_BODYCOLOR; Arc->m_Fill = FILLED_SHAPE;
if( chartmp[0] == 'f' )
Arc->m_Fill = FILLED_WITH_BG_BODYCOLOR;
NORMALIZE_ANGLE( Arc->t1 ); NORMALIZE_ANGLE( Arc->t1 );
NORMALIZE_ANGLE( Arc->t2 ); NORMALIZE_ANGLE( Arc->t2 );
@ -523,20 +554,24 @@ LibEDA_BaseStruct *Tail = NULL,
case 'C': /* Circle */ case 'C': /* Circle */
{ {
LibDrawCircle* Circle = new LibDrawCircle(); LibDrawCircle* Circle = new LibDrawCircle();
New = Circle; ll = 0; New = Circle; ll = 0;
Error = sscanf( &Line[2], "%d %d %d %d %d %d %s", Error = sscanf( &Line[2], "%d %d %d %d %d %d %s",
&Circle->m_Pos.x, &Circle->m_Pos.y, &Circle->m_Rayon, &Circle->m_Pos.x, &Circle->m_Pos.y, &Circle->m_Rayon,
&Unit, &Convert, &Circle->m_Width, chartmp ) < 6; &Unit, &Convert, &Circle->m_Width, chartmp ) < 6;
Circle->m_Unit = Unit; Circle->m_Unit = Unit;
Circle->m_Convert = Convert; Circle->m_Convert = Convert;
if ( chartmp[0] == 'F') Circle->m_Fill = FILLED_SHAPE; if( chartmp[0] == 'F' )
if ( chartmp[0] == 'f') Circle->m_Fill = FILLED_WITH_BG_BODYCOLOR; Circle->m_Fill = FILLED_SHAPE;
if( chartmp[0] == 'f' )
Circle->m_Fill = FILLED_WITH_BG_BODYCOLOR;
} }
break; break;
case 'T': /* Text */ case 'T': /* Text */
{ {
LibDrawText* Text = new LibDrawText(); LibDrawText* Text = new LibDrawText();
New = Text; New = Text;
Buffer[0] = 0; Buffer[0] = 0;
Error = sscanf( &Line[2], "%d %d %d %d %d %d %d %s", Error = sscanf( &Line[2], "%d %d %d %d %d %d %d %s",
@ -558,14 +593,17 @@ LibEDA_BaseStruct *Tail = NULL,
case 'S': /* Square */ case 'S': /* Square */
{ {
LibDrawSquare* Square = new LibDrawSquare(); LibDrawSquare* Square = new LibDrawSquare();
New = Square; ll = 0; New = Square; ll = 0;
Error = sscanf( &Line[2], "%d %d %d %d %d %d %d %s", Error = sscanf( &Line[2], "%d %d %d %d %d %d %d %s",
&Square->m_Pos.x, &Square->m_Pos.y, &Square->m_Pos.x, &Square->m_Pos.y,
&Square->m_End.x, &Square->m_End.y, &Square->m_End.x, &Square->m_End.y,
&Unit, &Convert, &Square->m_Width, chartmp ) < 7; &Unit, &Convert, &Square->m_Width, chartmp ) < 7;
Square->m_Unit = Unit; Square->m_Convert = Convert; Square->m_Unit = Unit; Square->m_Convert = Convert;
if ( chartmp[0] == 'F') Square->m_Fill = FILLED_SHAPE; if( chartmp[0] == 'F' )
if ( chartmp[0] == 'f') Square->m_Fill = FILLED_WITH_BG_BODYCOLOR; Square->m_Fill = FILLED_SHAPE;
if( chartmp[0] == 'f' )
Square->m_Fill = FILLED_WITH_BG_BODYCOLOR;
} }
break; break;
@ -573,6 +611,7 @@ LibEDA_BaseStruct *Tail = NULL,
{ {
*Buffer = 0; *Buffer = 0;
LibDrawPin* Pin = new LibDrawPin(); LibDrawPin* Pin = new LibDrawPin();
New = Pin; New = Pin;
i = sscanf( Line + 2, "%s %s %d %d %d %s %d %d %d %d %s %s", i = sscanf( Line + 2, "%s %s %d %d %d %s %d %d %d %d %s %s",
BufName, PinNum, BufName, PinNum,
@ -593,62 +632,88 @@ LibEDA_BaseStruct *Tail = NULL,
Pin->m_PinName = CONV_FROM_UTF8( BufName ); Pin->m_PinName = CONV_FROM_UTF8( BufName );
jj = *chartmp & 255; jj = *chartmp & 255;
switch( jj ) switch( jj )
{ {
case 'I': case 'I':
Pin->m_PinType = PIN_INPUT; break; Pin->m_PinType = PIN_INPUT; break;
case 'O': case 'O':
Pin->m_PinType = PIN_OUTPUT; break; Pin->m_PinType = PIN_OUTPUT; break;
case 'B': case 'B':
Pin->m_PinType = PIN_BIDI; break; Pin->m_PinType = PIN_BIDI; break;
case 'T': case 'T':
Pin->m_PinType = PIN_TRISTATE; break; Pin->m_PinType = PIN_TRISTATE; break;
case 'P': case 'P':
Pin->m_PinType = PIN_PASSIVE; break; Pin->m_PinType = PIN_PASSIVE; break;
case 'U': case 'U':
Pin->m_PinType = PIN_UNSPECIFIED; break; Pin->m_PinType = PIN_UNSPECIFIED; break;
case 'W': case 'W':
Pin->m_PinType = PIN_POWER_IN; break; Pin->m_PinType = PIN_POWER_IN; break;
case 'w': case 'w':
Pin->m_PinType = PIN_POWER_OUT; break; Pin->m_PinType = PIN_POWER_OUT; break;
case 'C': case 'C':
Pin->m_PinType = PIN_OPENCOLLECTOR; break; Pin->m_PinType = PIN_OPENCOLLECTOR; break;
case 'E': case 'E':
Pin->m_PinType = PIN_OPENEMITTER; break; Pin->m_PinType = PIN_OPENEMITTER; break;
default: default:
MsgLine.Printf( wxT( "Unknown Pin Type [%c] line %d" ), MsgLine.Printf( wxT( "Unknown Pin Type [%c] line %d" ),
jj, *LineNum ); jj, *LineNum );
DisplayError( frame, MsgLine ); DisplayError( frame, MsgLine );
} }
if( i == 12 ) /* Special Symbole defined */ if( i == 12 ) /* Special Symbole defined */
for( jj = strlen( Buffer ); jj > 0; ) for( jj = strlen( Buffer ); jj > 0; )
{ {
switch( Buffer[--jj] ) switch( Buffer[--jj] )
{ {
case '~': break; case '~':
case 'N': Pin->m_Attributs |= PINNOTDRAW; break; break;
case 'I': Pin->m_PinShape |= INVERT; break;
case 'C': Pin->m_PinShape |= CLOCK; break; case 'N':
case 'L': Pin->m_PinShape |= LOWLEVEL_IN; break; Pin->m_Attributs |= PINNOTDRAW; break;
case 'V': Pin->m_PinShape |= LOWLEVEL_OUT; break;
case 'I':
Pin->m_PinShape |= INVERT; break;
case 'C':
Pin->m_PinShape |= CLOCK; break;
case 'L':
Pin->m_PinShape |= LOWLEVEL_IN; break;
case 'V':
Pin->m_PinShape |= LOWLEVEL_OUT; break;
default: default:
MsgLine.Printf( wxT( "Unknown Pin Shape [%c] line %d" ), MsgLine.Printf( wxT( "Unknown Pin Shape [%c] line %d" ),
Buffer[jj], *LineNum ); Buffer[jj], *LineNum );
DisplayError( frame, MsgLine ); break; DisplayError( frame, MsgLine ); break;
} }
} }
} }
break; break;
case 'P': /* Polyline */ case 'P': /* Polyline */
{ {
LibDrawPolyline* Polyl = new LibDrawPolyline(); LibDrawPolyline* Polyl = new LibDrawPolyline();
New = Polyl; New = Polyl;
if( sscanf( &Line[2], "%d %d %d %d", if( sscanf( &Line[2], "%d %d %d %d",
&Polyl->n, &Unit, &Convert, &Polyl->n, &Unit, &Convert,
&Polyl->m_Width) == 4 && &Polyl->m_Width ) == 4
Polyl->n > 0) && Polyl->n > 0 )
{ {
Polyl->m_Unit = Unit; Polyl->m_Convert = Convert; Polyl->m_Unit = Unit; Polyl->m_Convert = Convert;
@ -665,16 +730,18 @@ LibEDA_BaseStruct *Tail = NULL,
p = strtok( NULL, " \t\n" ); p = strtok( NULL, " \t\n" );
Error = sscanf( p, "%d", &Polyl->PolyList[i] ) != 1; Error = sscanf( p, "%d", &Polyl->PolyList[i] ) != 1;
} }
Polyl->m_Fill = NO_FILL; Polyl->m_Fill = NO_FILL;
if( ( p = strtok( NULL, " \t\n" ) ) != NULL ) if( ( p = strtok( NULL, " \t\n" ) ) != NULL )
{ {
if ( p[0] == 'F') Polyl->m_Fill = FILLED_SHAPE; if( p[0] == 'F' )
Polyl->m_Fill = FILLED_SHAPE;
if( p[0] == 'f' ) if( p[0] == 'f' )
Polyl->m_Fill = FILLED_WITH_BG_BODYCOLOR; Polyl->m_Fill = FILLED_WITH_BG_BODYCOLOR;
} }
} }
else
else Error = TRUE; Error = TRUE;
} }
break; break;
@ -691,6 +758,7 @@ LibEDA_BaseStruct *Tail = NULL,
Line[0], *LineNum ); Line[0], *LineNum );
DisplayError( frame, MsgLine ); DisplayError( frame, MsgLine );
delete New; delete New;
/* FLush till end of draw: */ /* FLush till end of draw: */
do { do {
if( GetLine( f, Line, LineNum, 1024 ) == NULL ) if( GetLine( f, Line, LineNum, 1024 ) == NULL )
@ -699,12 +767,13 @@ LibEDA_BaseStruct *Tail = NULL,
return Head; return Head;
} }
} while( strncmp( Line, "ENDDRAW", 7 ) != 0 ); } while( strncmp( Line, "ENDDRAW", 7 ) != 0 );
return (Head);
}
return Head;
}
else else
{ {
if (Head == NULL) Head = Tail = New; if( Head == NULL )
Head = Tail = New;
else else
{ {
Tail->Pnext = New; Tail = New; Tail->Pnext = New; Tail = New;
@ -725,12 +794,15 @@ LibraryStruct *Lib = g_LibraryList;
while( Lib ) while( Lib )
{ {
if (Lib->m_Name == Name ) return Lib; if( Lib->m_Name == Name )
return Lib;
Lib = Lib->m_Pnext; Lib = Lib->m_Pnext;
} }
return NULL; return NULL;
} }
/***************************************************************************** /*****************************************************************************
* Routine to find the number of libraries currently loaded. * * Routine to find the number of libraries currently loaded. *
*****************************************************************************/ *****************************************************************************/
@ -739,7 +811,9 @@ int NumOfLibraries(void)
int ii; int ii;
LibraryStruct* Lib = g_LibraryList; LibraryStruct* Lib = g_LibraryList;
for (ii = 0; Lib != NULL; Lib = Lib->m_Pnext) ii++; for( ii = 0; Lib != NULL; Lib = Lib->m_Pnext )
ii++;
return ii; return ii;
} }
@ -747,9 +821,10 @@ LibraryStruct *Lib = g_LibraryList;
/*****************************************************************************/ /*****************************************************************************/
static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line ) static bool GetLibEntryField( EDA_LibComponentStruct* LibEntry, char* line )
/*****************************************************************************/ /*****************************************************************************/
/* Analyse la ligne de description du champ de la forme: /* Analyse la ligne de description du champ de la forme:
Fn "CA3130" 150 -200 50 H V * Fn "CA3130" 150 -200 50 H V
ou n = 0 (REFERENCE), 1 (VALUE) , 2 .. 11 = autres champs, facultatifs * ou n = 0 (REFERENCE), 1 (VALUE) , 2 .. 11 = autres champs, facultatifs
*/ */
{ {
int posx, posy, size, orient, hjustify, vjustify; int posx, posy, size, orient, hjustify, vjustify;
@ -761,36 +836,53 @@ char *Text,
int NumOfField, nbparam; int NumOfField, nbparam;
LibDrawField* Field = NULL; LibDrawField* Field = NULL;
if( sscanf(line+1, "%d", &NumOfField) != 1) return(0); if( sscanf( line + 1, "%d", &NumOfField ) != 1 )
return 0;
/* Recherche du debut des donnees (debut du texte suivant) */ /* Recherche du debut des donnees (debut du texte suivant) */
while(*line != 0) line++; while( *line != 0 )
while(*line == 0) line++; line++;
while( *line == 0 )
line++;
/* recherche du texte */ /* recherche du texte */
while ( *line && (*line != '"') ) line++; while( *line && (*line != '"') )
if ( *line == 0 ) return(0); line++;
if( *line == 0 )
return 0;
line++; Text = line; line++; Text = line;
/* recherche fin de texte */ /* recherche fin de texte */
while ( *line && (*line != '"') ) line++; while( *line && (*line != '"') )
if ( *line == 0 ) return(0); line++;
if( *line == 0 )
return 0;
*line = 0; line++; *line = 0; line++;
FieldUserName[0] = 0; FieldUserName[0] = 0;
nbparam = sscanf( line, " %d %d %d %c %c %c %c", nbparam = sscanf( line, " %d %d %d %c %c %c %c",
&posx, &posy, &size, Char1, Char2, Char3, Char4 ); &posx, &posy, &size, Char1, Char2, Char3, Char4 );
orient = TEXT_ORIENT_HORIZ; if(Char1[0] == 'V') orient = TEXT_ORIENT_VERT; orient = TEXT_ORIENT_HORIZ; if( Char1[0] == 'V' )
draw = TRUE; if(Char2[0] == 'I') draw = FALSE; orient = TEXT_ORIENT_VERT;
draw = TRUE; if( Char2[0] == 'I' )
draw = FALSE;
hjustify = GR_TEXT_HJUSTIFY_CENTER; hjustify = GR_TEXT_HJUSTIFY_CENTER;
vjustify = GR_TEXT_VJUSTIFY_CENTER; vjustify = GR_TEXT_VJUSTIFY_CENTER;
if( nbparam >= 6 ) if( nbparam >= 6 )
{ {
if ( *Char3 == 'L' ) hjustify = GR_TEXT_HJUSTIFY_LEFT; if( *Char3 == 'L' )
else if ( *Char3 == 'R' ) hjustify = GR_TEXT_HJUSTIFY_RIGHT; hjustify = GR_TEXT_HJUSTIFY_LEFT;
if ( *Char4 == 'B' ) vjustify = GR_TEXT_VJUSTIFY_BOTTOM; else if( *Char3 == 'R' )
else if ( *Char4 == 'T' ) vjustify = GR_TEXT_VJUSTIFY_TOP; hjustify = GR_TEXT_HJUSTIFY_RIGHT;
if( *Char4 == 'B' )
vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
else if( *Char4 == 'T' )
vjustify = GR_TEXT_VJUSTIFY_TOP;
} }
switch( NumOfField ) switch( NumOfField )
{ {
case REFERENCE: case REFERENCE:
@ -804,18 +896,22 @@ LibDrawField * Field = NULL;
break; break;
default: default:
if(NumOfField >= NUMBER_OF_FIELDS ) break; if( NumOfField >= NUMBER_OF_FIELDS )
break;
Field = new LibDrawField( NumOfField ); Field = new LibDrawField( NumOfField );
Field->Pnext = LibEntry->Fields; Field->Pnext = LibEntry->Fields;
LibEntry->Fields = Field; LibEntry->Fields = Field;
break; break;
} }
if ( Field == NULL ) return FALSE; if( Field == NULL )
return FALSE;
Field->m_Pos.x = posx; Field->m_Pos.y = posy; Field->m_Pos.x = posx; Field->m_Pos.y = posy;
Field->m_Orient = orient; Field->m_Orient = orient;
if( draw == FALSE ) Field->m_Attributs |= TEXT_NO_VISIBLE; if( draw == FALSE )
Field->m_Attributs |= TEXT_NO_VISIBLE;
Field->m_Size.x = Field->m_Size.y = size; Field->m_Size.x = Field->m_Size.y = size;
Field->m_Text = CONV_FROM_UTF8( Text ); Field->m_Text = CONV_FROM_UTF8( Text );
if( NumOfField >= FIELD1 ) if( NumOfField >= FIELD1 )
@ -825,19 +921,21 @@ LibDrawField * Field = NULL;
} }
Field->m_HJustify = hjustify; Field->m_HJustify = hjustify;
Field->m_VJustify = vjustify; Field->m_VJustify = vjustify;
return(TRUE); return TRUE;
} }
/********************************************************************/ /********************************************************************/
static bool AddAliasNames( EDA_LibComponentStruct* LibEntry, char* line ) static bool AddAliasNames( EDA_LibComponentStruct* LibEntry, char* line )
/********************************************************************/ /********************************************************************/
/* Read the alias names (in buffer line) and add them in alias list /* Read the alias names (in buffer line) and add them in alias list
names are separated by spaces * names are separated by spaces
*/ */
{ {
char* text; char* text;
wxString name; wxString name;
text = strtok( line, " \t\r\n" ); text = strtok( line, " \t\r\n" );
while( text ) while( text )
@ -846,9 +944,11 @@ wxString name;
LibEntry->m_AliasList.Add( name ); LibEntry->m_AliasList.Add( name );
text = strtok( NULL, " \t\r\n" ); text = strtok( NULL, " \t\r\n" );
} }
return( TRUE );
return TRUE;
} }
/********************************************************************/ /********************************************************************/
static void InsertAlias( PriorQue** PQ, EDA_LibComponentStruct* LibEntry, static void InsertAlias( PriorQue** PQ, EDA_LibComponentStruct* LibEntry,
int* NumOfParts ) int* NumOfParts )
@ -865,11 +965,13 @@ unsigned ii;
{ {
AliasEntry = new EDA_LibCmpAliasStruct( LibEntry->m_AliasList[ii], AliasEntry = new EDA_LibCmpAliasStruct( LibEntry->m_AliasList[ii],
LibEntry->m_Name.m_Text.GetData() ); LibEntry->m_Name.m_Text.GetData() );
++ * NumOfParts; ++ * NumOfParts;
PQInsert( PQ, AliasEntry ); PQInsert( PQ, AliasEntry );
} }
} }
/*******************************************************/ /*******************************************************/
/* Routines de lecture des Documentation de composants */ /* Routines de lecture des Documentation de composants */
/*******************************************************/ /*******************************************************/
@ -886,7 +988,8 @@ FILE * f;
wxString msg; wxString msg;
f = wxFopen( FullDocLibName, wxT( "rt" ) ); f = wxFopen( FullDocLibName, wxT( "rt" ) );
if (f == NULL) return(0); if( f == NULL )
return 0;
if( GetLine( f, Line, &LineNum, sizeof(Line) ) == NULL ) if( GetLine( f, Line, &LineNum, sizeof(Line) ) == NULL )
{ /* pas de lignes utiles */ { /* pas de lignes utiles */
@ -917,24 +1020,30 @@ wxString msg;
Entry = FindLibPart( cmpname.GetData(), Libname, FIND_ALIAS ); Entry = FindLibPart( cmpname.GetData(), Libname, FIND_ALIAS );
while( GetLine( f, Line, &LineNum, sizeof(Line) ) ) while( GetLine( f, Line, &LineNum, sizeof(Line) ) )
{ {
if( strncmp(Line, "$ENDCMP",7) == 0) break; if( strncmp( Line, "$ENDCMP", 7 ) == 0 )
break;
Text = strtok( Line + 2, "\n\r" ); Text = strtok( Line + 2, "\n\r" );
switch( Line[0] ) switch( Line[0] )
{ {
case 'D': case 'D':
if(Entry) Entry->m_Doc = CONV_FROM_UTF8(Text); if( Entry )
Entry->m_Doc = CONV_FROM_UTF8( Text );
break; break;
case 'K': case 'K':
if(Entry) Entry->m_KeyWord = CONV_FROM_UTF8(Text); if( Entry )
Entry->m_KeyWord = CONV_FROM_UTF8( Text );
break; break;
case 'F': case 'F':
if(Entry) Entry->m_DocFile = CONV_FROM_UTF8(Text); if( Entry )
Entry->m_DocFile = CONV_FROM_UTF8( Text );
break; break;
} }
} }
} }
fclose( f ); fclose( f );
return 1; return 1;
} }
@ -943,8 +1052,9 @@ wxString msg;
/*********************************************************************************/ /*********************************************************************************/
static bool ReadLibEntryDateAndTime( EDA_LibComponentStruct* LibEntry, char* Line ) static bool ReadLibEntryDateAndTime( EDA_LibComponentStruct* LibEntry, char* Line )
/*********************************************************************************/ /*********************************************************************************/
/* lit date et time de modif composant sous le format: /* lit date et time de modif composant sous le format:
"Ti yy/mm/jj hh:mm:ss" * "Ti yy/mm/jj hh:mm:ss"
*/ */
{ {
int year, mon, day, hour, min, sec; int year, mon, day, hour, min, sec;
@ -966,22 +1076,27 @@ char * text;
return TRUE; return TRUE;
} }
/*******************************************/ /*******************************************/
static int SortItemsFct( const void* ref, const void* item ); static int SortItemsFct( const void* ref, const void* item );
void EDA_LibComponentStruct::SortDrawItems( void ) void EDA_LibComponentStruct::SortDrawItems( void )
/*******************************************/ /*******************************************/
/* Trie les éléments graphiques d'un composant lib pour améliorer /* Trie les éléments graphiques d'un composant lib pour améliorer
le tracé: * le tracé:
items remplis en premier, pins en dernier * items remplis en premier, pins en dernier
En cas de superposition d'items, c'est plus lisible * En cas de superposition d'items, c'est plus lisible
*/ */
{ {
LibEDA_BaseStruct** Bufentry, ** BufentryBase, * Entry = m_Drawings; LibEDA_BaseStruct** Bufentry, ** BufentryBase, * Entry = m_Drawings;
int ii, nbitems; int ii, nbitems;
if(Entry == NULL ) return; /* Pas d'alias pour ce composant */ if( Entry == NULL )
return; /* Pas d'alias pour ce composant */
/* calcul du nombre d'items */ /* calcul du nombre d'items */
for( nbitems = 0; Entry != NULL; Entry = Entry->Next()) nbitems++; for( nbitems = 0; Entry != NULL; Entry = Entry->Next() )
nbitems++;
BufentryBase = BufentryBase =
(LibEDA_BaseStruct**) MyZMalloc( (nbitems + 1) * sizeof(LibEDA_BaseStruct *) ); (LibEDA_BaseStruct**) MyZMalloc( (nbitems + 1) * sizeof(LibEDA_BaseStruct *) );
@ -993,7 +1108,7 @@ int ii, nbitems;
qsort( BufentryBase, nbitems, sizeof(LibEDA_BaseStruct *), SortItemsFct ); qsort( BufentryBase, nbitems, sizeof(LibEDA_BaseStruct *), SortItemsFct );
/* Mise a jour du chainage. Remarque: /* Mise a jour du chainage. Remarque:
le dernier element de BufEntryBase (BufEntryBase[nbitems]) est NULL*/ * le dernier element de BufEntryBase (BufEntryBase[nbitems]) est NULL*/
m_Drawings = *BufentryBase; m_Drawings = *BufentryBase;
Bufentry = BufentryBase; Bufentry = BufentryBase;
for( ii = 0; ii < nbitems; ii++ ) for( ii = 0; ii < nbitems; ii++ )
@ -1005,6 +1120,7 @@ int ii, nbitems;
MyFree( BufentryBase ); MyFree( BufentryBase );
} }
int SortItemsFct( const void* ref, const void* item ) int SortItemsFct( const void* ref, const void* item )
{ {
#define Ref ( *(LibEDA_BaseStruct**) (ref) ) #define Ref ( *(LibEDA_BaseStruct**) (ref) )
@ -1045,8 +1161,10 @@ int fill_ref = 0, fill_item = 0;
} }
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
if ( Item->m_StructType == COMPONENT_PIN_DRAW_TYPE ) return BEFORE; if( Item->m_StructType == COMPONENT_PIN_DRAW_TYPE )
if ( Item->m_StructType == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) return 0; return BEFORE;
if( Item->m_StructType == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE )
return 0;
return 1; return 1;
break; break;
@ -1054,23 +1172,30 @@ int fill_ref = 0, fill_item = 0;
if( Item->m_StructType == COMPONENT_PIN_DRAW_TYPE ) if( Item->m_StructType == COMPONENT_PIN_DRAW_TYPE )
{ {
int ii; int ii;
// We sort the pins by orientation // We sort the pins by orientation
ii = ( (LibDrawPin*) Ref )->m_Orient - ( (LibDrawPin*) Item )->m_Orient; ii = ( (LibDrawPin*) Ref )->m_Orient - ( (LibDrawPin*) Item )->m_Orient;
if ( ii ) return ii; if( ii )
return ii;
/* We sort the pins by position (x or y). /* We sort the pins by position (x or y).
note: at this point, most of pins have same x pos or y pos, * note: at this point, most of pins have same x pos or y pos,
because they are sorted by orientation and generally are vertically or * because they are sorted by orientation and generally are vertically or
horizontally aligned */ * horizontally aligned */
wxPoint pos_ref, pos_tst; wxPoint pos_ref, pos_tst;
pos_ref = ( (LibDrawPin*) Ref )->m_Pos; pos_ref = ( (LibDrawPin*) Ref )->m_Pos;
pos_tst = ( (LibDrawPin*) Item )->m_Pos; pos_tst = ( (LibDrawPin*) Item )->m_Pos;
if ( (ii = pos_ref.x - pos_tst.x) ) return ii; if( (ii = pos_ref.x - pos_tst.x) )
return ii;
ii = pos_ref.y - pos_tst.y; ii = pos_ref.y - pos_tst.y;
return ii; return ii;
} }
else return AFTER; else
return AFTER;
break; break;
default:
;
} }
/* Test de l'item */ /* Test de l'item */
@ -1111,10 +1236,15 @@ int fill_ref = 0, fill_item = 0;
case COMPONENT_PIN_DRAW_TYPE: case COMPONENT_PIN_DRAW_TYPE:
return BEFORE; return BEFORE;
break; break;
default:
;
} }
if ( fill_ref & fill_item ) return 0; if( fill_ref & fill_item )
if ( fill_ref ) return BEFORE; return 0;
if( fill_ref )
return BEFORE;
return AFTER; return AFTER;
} }
@ -1123,10 +1253,11 @@ int fill_ref = 0, fill_item = 0;
int AddFootprintFilterList( EDA_LibComponentStruct* LibEntryLibEntry, FILE* f, int AddFootprintFilterList( EDA_LibComponentStruct* LibEntryLibEntry, FILE* f,
char* Line, int* LineNum ) char* Line, int* LineNum )
/******************************************************************************/ /******************************************************************************/
/* read the FootprintFilter List stating with: /* read the FootprintFilter List stating with:
FPLIST * FPLIST
and ending with: * and ending with:
ENDFPLIST * ENDFPLIST
*/ */
{ {
for( ; ; ) for( ; ; )

View File

@ -212,6 +212,8 @@ wxPoint MousePos = m_CurrentScreen->m_MousePosition;
} }
ChangeTextOrient( (DrawTextStruct*)DrawStruct, DC); ChangeTextOrient( (DrawTextStruct*)DrawStruct, DC);
break; break;
default:;
} }
break; break;

View File

@ -31,29 +31,33 @@ LibraryStruct::LibraryStruct(int type, const wxString & name, const wxString & f
m_TimeStamp = 0; m_TimeStamp = 0;
m_Flags = 0; m_Flags = 0;
m_IsLibCache = FALSE; m_IsLibCache = FALSE;
} }
/*****************************************/ /*****************************************/
void FreeLibraryEntry( LibCmpEntry* Entry ) void FreeLibraryEntry( LibCmpEntry* Entry )
/*****************************************/ /*****************************************/
/* Used by PQFreeFunc() to delete all entries /* Used by PQFreeFunc() to delete all entries
*/ */
{ {
delete Entry; delete Entry;
} }
/******************************/ /******************************/
LibraryStruct::~LibraryStruct() LibraryStruct::~LibraryStruct()
/******************************/ /******************************/
{ {
if ( m_Entries ) PQFreeFunc(m_Entries, (void(*)(void *))FreeLibraryEntry); if( m_Entries )
PQFreeFunc( m_Entries, ( void( * ) ( void* ) )FreeLibraryEntry );
} }
/*******************************************/ /*******************************************/
bool LibraryStruct::WriteHeader( FILE* file ) bool LibraryStruct::WriteHeader( FILE* file )
/*******************************************/ /*******************************************/
/* Ecrit l'entete du fichier librairie /* Ecrit l'entete du fichier librairie
*/ */
{ {
@ -66,17 +70,23 @@ bool succes = TRUE;
BufLine ) != 5 ) BufLine ) != 5 )
succes = FALSE; succes = FALSE;
#if 0 #if 0
if ( fprintf(file,"$HEADER\n") != 1 ) succes = FALSE; if( fprintf( file, "$HEADER\n" ) != 1 )
if ( fprintf(file,"TimeStamp %8.8lX\n", m_TimeStamp) != 2 ) succes = FALSE; succes = FALSE;
if ( fprintf(file,"Parts %d\n", m_NumOfParts) != 2 ) succes = FALSE; if( fprintf( file, "TimeStamp %8.8lX\n", m_TimeStamp ) != 2 )
if ( fprintf(file,"$ENDHEADER\n") != 1 ) succes = FALSE; succes = FALSE;
if( fprintf( file, "Parts %d\n", m_NumOfParts ) != 2 )
succes = FALSE;
if( fprintf( file, "$ENDHEADER\n" ) != 1 )
succes = FALSE;
#endif #endif
return (succes); return succes;
} }
/***********************************************************/ /***********************************************************/
bool LibraryStruct::ReadHeader( FILE* libfile, int* LineNum ) bool LibraryStruct::ReadHeader( FILE* libfile, int* LineNum )
/***********************************************************/ /***********************************************************/
/* Ecrit l'entete du fichier librairie /* Ecrit l'entete du fichier librairie
*/ */
{ {
@ -88,8 +98,10 @@ char Line[1024], * text, * data;
data = strtok( NULL, " \t\r\n" ); data = strtok( NULL, " \t\r\n" );
if( stricmp( text, "TimeStamp" ) == 0 ) if( stricmp( text, "TimeStamp" ) == 0 )
m_TimeStamp = atol( data ); m_TimeStamp = atol( data );
if ( stricmp(text,"$ENDHEADER") == 0 ) return TRUE; if( stricmp( text, "$ENDHEADER" ) == 0 )
return TRUE;
} }
return FALSE; return FALSE;
} }
@ -97,11 +109,12 @@ char Line[1024], * text, * data;
/*********************/ /*********************/
/* class LibCmpEntry */ /* class LibCmpEntry */
/*********************/ /*********************/
/* Basic class for librarty oomponent description /* Basic class for librarty oomponent description
Not directly used * Not directly used
Used to create the 2 derived classes : * Used to create the 2 derived classes :
- EDA_LibCmpAliasStruct * - EDA_LibCmpAliasStruct
- EDA_LibComponentStruct * - EDA_LibComponentStruct
*/ */
/********************************************************************/ /********************************************************************/
@ -111,9 +124,11 @@ LibCmpEntry::LibCmpEntry(LibrEntryType CmpType, const wxChar * CmpName):
{ {
Type = CmpType; Type = CmpType;
m_Name.m_FieldId = VALUE; m_Name.m_FieldId = VALUE;
if ( CmpName ) m_Name.m_Text = CmpName; if( CmpName )
m_Name.m_Text = CmpName;
} }
/******************************/ /******************************/
LibCmpEntry::~LibCmpEntry( void ) LibCmpEntry::~LibCmpEntry( void )
/******************************/ /******************************/
@ -126,21 +141,24 @@ LibCmpEntry::~LibCmpEntry(void)
/*******************************/ /*******************************/
/* Class to define an alias of a component /* Class to define an alias of a component
An alias uses the component defintion (graphic, pins...) * An alias uses the component defintion (graphic, pins...)
but has its own name and documentation. * but has its own name and documentation.
Therefore, when the component is modified, alias of this component are modified. * Therefore, when the component is modified, alias of this component are modified.
This is a simple method to create components with differs very few * This is a simple method to create components with differs very few
(like 74LS00, 74HC00 ... and many op amps ) * (like 74LS00, 74HC00 ... and many op amps )
*/ */
EDA_LibCmpAliasStruct:: EDA_LibCmpAliasStruct( const wxChar* CmpName, EDA_LibCmpAliasStruct:: EDA_LibCmpAliasStruct( const wxChar* CmpName,
const wxChar* CmpRootName ) : const wxChar* CmpRootName ) :
LibCmpEntry( ALIAS, CmpName ) LibCmpEntry( ALIAS, CmpName )
{ {
if ( CmpRootName == NULL) m_RootName.Empty(); if( CmpRootName == NULL )
else m_RootName = CmpRootName; m_RootName.Empty();
else
m_RootName = CmpRootName;
} }
EDA_LibCmpAliasStruct::~EDA_LibCmpAliasStruct( void ) EDA_LibCmpAliasStruct::~EDA_LibCmpAliasStruct( void )
{ {
} }
@ -167,6 +185,7 @@ EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar * CmpName):
m_Prefix.m_FieldId = REFERENCE; m_Prefix.m_FieldId = REFERENCE;
} }
/******************************************************/ /******************************************************/
EDA_LibComponentStruct::~EDA_LibComponentStruct( void ) EDA_LibComponentStruct::~EDA_LibComponentStruct( void )
/******************************************************/ /******************************************************/
@ -195,10 +214,11 @@ LibDrawField *TempField, *field;
/**********************************************************************/ /**********************************************************************/
EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
/**********************************************************************/ /**********************************************************************/
/* Return the componenty boundary box ( in user coordinates ) /* Return the componenty boundary box ( in user coordinates )
The unit Unit, and the shape Convert are considered. * The unit Unit, and the shape Convert are considered.
If Unit == 0, Unit is not used * If Unit == 0, Unit is not used
if Convert == 0 Convert is non used * if Convert == 0 Convert is non used
**/ **/
{ {
int xmin, xmax, ymin, ymax, x1, y1; int xmin, xmax, ymin, ymax, x1, y1;
@ -209,11 +229,13 @@ EDA_Rect BoundaryBox;
DrawEntry = m_Drawings; DrawEntry = m_Drawings;
if( DrawEntry ) if( DrawEntry )
{ {
xmin = ymin = 0x7FFFFFFF; xmax = ymax = 0x80000000; xmin = ymin = 0x7FFFFFFF;
xmax = ymax = 0x80000000;
} }
else else
{ {
xmin = ymin = -50; xmax = ymax = 50; // Min size in 1/1000 inch xmin = ymin = -50;
xmax = ymax = 50; // Min size in 1/1000 inch
} }
for( ; DrawEntry != NULL; DrawEntry = DrawEntry->Next() ) for( ; DrawEntry != NULL; DrawEntry = DrawEntry->Next() )
@ -284,14 +306,23 @@ EDA_Rect BoundaryBox;
xmax = MAX( xmax, x1 ); xmax = MAX( xmax, x1 );
ymin = MIN( ymin, y1 ); ymin = MIN( ymin, y1 );
ymax = MAX( ymax, y1 ); ymax = MAX( ymax, y1 );
#if 0 // 0 pour englober le point origine de la pin, 1 pour englober toute la pin #if 0 \
// 0 pour englober le point origine de la pin, 1 pour englober toute la pin
switch( Pin->Orient ) switch( Pin->Orient )
{ {
case PIN_UP: y1 += Pin->Len; break; case PIN_UP:
case PIN_DOWN: y1 -= Pin->Len; break; y1 += Pin->Len; break;
case PIN_LEFT: x1 -= Pin->Len; break;
case PIN_RIGHT: x1 += Pin->Len; break; case PIN_DOWN:
y1 -= Pin->Len; break;
case PIN_LEFT:
x1 -= Pin->Len; break;
case PIN_RIGHT:
x1 += Pin->Len; break;
} }
xmin = MIN( xmin, x1 ); xmin = MIN( xmin, x1 );
xmax = MAX( xmax, x1 ); xmax = MAX( xmax, x1 );
ymin = MIN( ymin, y1 ); ymin = MIN( ymin, y1 );
@ -309,23 +340,32 @@ EDA_Rect BoundaryBox;
pt = polyline->PolyList; pt = polyline->PolyList;
for( ii = 0; ii < polyline->n; ii++ ) for( ii = 0; ii < polyline->n; ii++ )
{ {
if( xmin > *pt ) xmin = *pt; if( xmin > *pt )
if( xmax < *pt ) xmax = *pt; xmin = *pt;
if( xmax < *pt )
xmax = *pt;
pt++; pt++;
if( ymin > *pt ) ymin = *pt; if( ymin > *pt )
if( ymax < *pt ) ymax = *pt; ymin = *pt;
if( ymax < *pt )
ymax = *pt;
pt++; pt++;
} }
} }
break; break;
default:
;
} }
} }
// Update the BoundaryBox. Remenber the fact the screen Y axis is the reverse */ // Update the BoundaryBox. Remenber the fact the screen Y axis is the reverse */
ymax = -ymax; ymin = -ymin; // Y is is screen axis sense ymax = -ymax; ymin = -ymin; // Y is is screen axis sense
// Ensure w and H > 0 (wxRect assume it) // Ensure w and H > 0 (wxRect assume it)
if ( xmax < xmin ) EXCHG( xmax, xmin ); if( xmax < xmin )
if ( ymax < ymin ) EXCHG( ymax, ymin ); EXCHG( xmax, xmin );
if( ymax < ymin )
EXCHG( ymax, ymin );
BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin ); BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin );
BoundaryBox.SetY( ymin ); BoundaryBox.SetHeight( ymax - ymin ); BoundaryBox.SetY( ymin ); BoundaryBox.SetHeight( ymax - ymin );
@ -336,21 +376,24 @@ EDA_Rect BoundaryBox;
/***************************/ /***************************/
/* class LibraryFieldEntry */ /* class LibraryFieldEntry */
/***************************/ /***************************/
/* 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: /* a Field is a string linked to a component.
REFERENCE * Unlike a pure graphic text, fields can be used in netlist generation
VALUE * and other things.
FOOTPRINT NAME *
SCHEMATIC LINK (reserved but not used in kicad) * 4 fields have a special meaning:
* REFERENCE
* VALUE
* FOOTPRINT NAME
* SCHEMATIC LINK (reserved but not used in kicad)
*/ */
LibDrawField::LibDrawField( int idfield ) : LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE ) LibDrawField::LibDrawField( int idfield ) : LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE )
{ {
m_FieldId = idfield; /* 0 a 11, 0 = REFERENCE, 1 = VALUE*/ m_FieldId = idfield; /* 0 a 11, 0 = REFERENCE, 1 = VALUE*/
if ( m_FieldId < 0 ) m_FieldId = 0; if( m_FieldId < 0 )
if ( m_FieldId >= NUMBER_OF_FIELDS ) m_FieldId = NUMBER_OF_FIELDS - 1; m_FieldId = 0;
if( m_FieldId >= NUMBER_OF_FIELDS )
m_FieldId = NUMBER_OF_FIELDS - 1;
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
m_Orient = 0; /* Orientation */ m_Orient = 0; /* Orientation */
m_Attributs = 0; /* Attributs = unvisible ... */ m_Attributs = 0; /* Attributs = unvisible ... */
@ -359,19 +402,23 @@ LibDrawField::LibDrawField(int idfield) : LibEDA_BaseStruct(COMPONENT_FIELD_DRAW
m_VJustify = GR_TEXT_VJUSTIFY_CENTER; /* Horizontal and vertical text justification */ m_VJustify = GR_TEXT_VJUSTIFY_CENTER; /* Horizontal and vertical text justification */
} }
LibDrawField::~LibDrawField( void ) LibDrawField::~LibDrawField( void )
{ {
} }
// Creation et Duplication d'un field // Creation et Duplication d'un field
LibDrawField* LibDrawField::GenCopy( void ) LibDrawField* LibDrawField::GenCopy( void )
{ {
LibDrawField* newfield = new LibDrawField( m_FieldId ); LibDrawField* newfield = new LibDrawField( m_FieldId );
Copy( newfield ); Copy( newfield );
return newfield; return newfield;
} }
// copie du field dans le field Target // copie du field dans le field Target
void LibDrawField::Copy( LibDrawField* Target ) void LibDrawField::Copy( LibDrawField* Target )
{ {
@ -386,17 +433,19 @@ void LibDrawField::Copy(LibDrawField * Target)
Target->m_VJustify = m_VJustify; Target->m_VJustify = m_VJustify;
} }
/* Elements Graphiques */ /* Elements Graphiques */
LibEDA_BaseStruct::LibEDA_BaseStruct(int struct_type): LibEDA_BaseStruct::LibEDA_BaseStruct( KICAD_T struct_type ) :
EDA_BaseStruct( struct_type ) EDA_BaseStruct( struct_type )
{ {
m_Unit = 0; /* Unit identification (for multi part per package) m_Unit = 0; /* Unit identification (for multi part per package)
0 if the item is common to all units */ * 0 if the item is common to all units */
m_Convert = 0; /* Shape identification (for parts which have a convert shape) m_Convert = 0; /* Shape identification (for parts which have a convert shape)
0 if the item is common to all shapes */ * 0 if the item is common to all shapes */
m_Width = 0; /* Default value to draw lines or arc ... */ m_Width = 0; /* Default value to draw lines or arc ... */
} }
/***************************************************************/ /***************************************************************/
LibDrawPin::LibDrawPin( void ) : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE ) LibDrawPin::LibDrawPin( void ) : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE )
/***************************************************************/ /***************************************************************/
@ -410,6 +459,7 @@ LibDrawPin::LibDrawPin(void) : LibEDA_BaseStruct(COMPONENT_PIN_DRAW_TYPE)
m_PinNumSize = 50; m_PinNumSize = 50;
m_PinNameSize = 50; /* Default size for pin name and num */ m_PinNameSize = 50; /* Default size for pin name and num */
m_Width = 0; m_Width = 0;
// m_PinNumWidth = m_PinNameWidth = 0; // Unused // m_PinNumWidth = m_PinNameWidth = 0; // Unused
} }
@ -417,27 +467,38 @@ LibDrawPin::LibDrawPin(void) : LibEDA_BaseStruct(COMPONENT_PIN_DRAW_TYPE)
/******************************************/ /******************************************/
wxPoint LibDrawPin::ReturnPinEndPoint( void ) wxPoint LibDrawPin::ReturnPinEndPoint( void )
/******************************************/ /******************************************/
/* return the pin end position, for a component in normal orient /* return the pin end position, for a component in normal orient
*/ */
{ {
wxPoint pos = m_Pos; wxPoint pos = m_Pos;
switch( m_Orient ) switch( m_Orient )
{ {
case PIN_UP: pos.y += m_PinLen; break; case PIN_UP:
case PIN_DOWN: pos.y -= m_PinLen; break; pos.y += m_PinLen; break;
case PIN_LEFT: pos.x -= m_PinLen; break;
case PIN_RIGHT: pos.x += m_PinLen; break; case PIN_DOWN:
pos.y -= m_PinLen; break;
case PIN_LEFT:
pos.x -= m_PinLen; break;
case PIN_RIGHT:
pos.x += m_PinLen; break;
} }
return pos; return pos;
} }
/********************************************************/ /********************************************************/
int LibDrawPin::ReturnPinDrawOrient( int TransMat[2][2] ) int LibDrawPin::ReturnPinDrawOrient( int TransMat[2][2] )
/********************************************************/ /********************************************************/
/* Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT), /* Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT),
according to its orientation, * according to its orientation,
AND the matrix transform (rot, mirror) TransMat * AND the matrix transform (rot, mirror) TransMat
*/ */
{ {
int orient; int orient;
@ -446,22 +507,32 @@ int t1, t2;
switch( m_Orient ) switch( m_Orient )
{ {
case PIN_UP: y1 = 1; break; case PIN_UP:
case PIN_DOWN: y1 = -1; break; y1 = 1; break;
case PIN_LEFT: x1 = -1; break;
case PIN_RIGHT: x1 = 1; break; case PIN_DOWN:
y1 = -1; break;
case PIN_LEFT:
x1 = -1; break;
case PIN_RIGHT:
x1 = 1; break;
} }
t1 = TransMat[0][0] * x1 + TransMat[0][1] * y1; t1 = TransMat[0][0] * x1 + TransMat[0][1] * y1;
t2 = TransMat[1][0] * x1 + TransMat[1][1] * y1; t2 = TransMat[1][0] * x1 + TransMat[1][1] * y1;
orient = PIN_UP; orient = PIN_UP;
if( t1 == 0 ) if( t1 == 0 )
{ {
if ( t2 > 0 ) orient = PIN_DOWN; if( t2 > 0 )
orient = PIN_DOWN;
} }
else else
{ {
orient = PIN_RIGHT; orient = PIN_RIGHT;
if ( t1 < 0 ) orient = PIN_LEFT; if( t1 < 0 )
orient = PIN_LEFT;
} }
return orient; return orient;
@ -471,9 +542,10 @@ int t1, t2;
/****************************************************/ /****************************************************/
void LibDrawPin::ReturnPinStringNum( wxString& buffer ) void LibDrawPin::ReturnPinStringNum( wxString& buffer )
/****************************************************/ /****************************************************/
/* fill the buffer with pin num as a wxString /* fill the buffer with pin num as a wxString
Pin num is coded as a long * Pin num is coded as a long
Used to print/draw the pin num * Used to print/draw the pin num
*/ */
{ {
char ascii_buf[5]; char ascii_buf[5];
@ -483,26 +555,32 @@ char ascii_buf[5];
buffer = CONV_FROM_UTF8( ascii_buf ); buffer = CONV_FROM_UTF8( ascii_buf );
} }
/****************************************************/ /****************************************************/
void LibDrawPin::SetPinNumFromString( wxString& buffer ) void LibDrawPin::SetPinNumFromString( wxString& buffer )
/****************************************************/ /****************************************************/
/* fill the buffer with pin num as a wxString /* fill the buffer with pin num as a wxString
Pin num is coded as a long * Pin num is coded as a long
Used to print/draw the pin num * Used to print/draw the pin num
*/ */
{ {
char ascii_buf[4]; char ascii_buf[4];
unsigned ii, len = buffer.Len(); unsigned ii, len = buffer.Len();
ascii_buf[0] = ascii_buf[1] = ascii_buf[2] = ascii_buf[3] = 0; ascii_buf[0] = ascii_buf[1] = ascii_buf[2] = ascii_buf[3] = 0;
if ( len > 4 ) len = 4; if( len > 4 )
len = 4;
for( ii = 0; ii < len; ii++ ) for( ii = 0; ii < len; ii++ )
{ {
ascii_buf[ii] = buffer.GetChar( ii ) & 0xFF; ascii_buf[ii] = buffer.GetChar( ii ) & 0xFF;
} }
strncpy( (char*) &m_PinNum, ascii_buf, 4 ); strncpy( (char*) &m_PinNum, ascii_buf, 4 );
} }
/*************************************/ /*************************************/
LibDrawPin* LibDrawPin::GenCopy( void ) LibDrawPin* LibDrawPin::GenCopy( void )
/*************************************/ /*************************************/
@ -528,6 +606,7 @@ LibDrawPin * newpin = new LibDrawPin();
return newpin; return newpin;
} }
/**************************************************************/ /**************************************************************/
LibDrawArc::LibDrawArc( void ) : LibEDA_BaseStruct( COMPONENT_ARC_DRAW_TYPE ) LibDrawArc::LibDrawArc( void ) : LibEDA_BaseStruct( COMPONENT_ARC_DRAW_TYPE )
/**************************************************************/ /**************************************************************/
@ -568,6 +647,7 @@ LibDrawCircle::LibDrawCircle(void) : LibEDA_BaseStruct(COMPONENT_CIRCLE_DRAW_TYP
m_Fill = NO_FILL; m_Fill = NO_FILL;
} }
/*******************************************/ /*******************************************/
LibDrawCircle* LibDrawCircle::GenCopy( void ) LibDrawCircle* LibDrawCircle::GenCopy( void )
/*******************************************/ /*******************************************/
@ -595,6 +675,7 @@ LibDrawText::LibDrawText(void) : LibEDA_BaseStruct(COMPONENT_GRAPHIC_TEXT_DRAW_T
m_Width = 0; m_Width = 0;
} }
/***************************************/ /***************************************/
LibDrawText* LibDrawText::GenCopy( void ) LibDrawText* LibDrawText::GenCopy( void )
/***************************************/ /***************************************/
@ -614,13 +695,13 @@ LibDrawText * newitem = new LibDrawText();
} }
LibDrawSquare::LibDrawSquare( void ) : LibEDA_BaseStruct( COMPONENT_RECT_DRAW_TYPE ) LibDrawSquare::LibDrawSquare( void ) : LibEDA_BaseStruct( COMPONENT_RECT_DRAW_TYPE )
{ {
m_Width = 0; m_Width = 0;
m_Fill = NO_FILL; m_Fill = NO_FILL;
} }
LibDrawSquare* LibDrawSquare::GenCopy( void ) LibDrawSquare* LibDrawSquare::GenCopy( void )
{ {
LibDrawSquare* newitem = new LibDrawSquare(); LibDrawSquare* newitem = new LibDrawSquare();
@ -635,11 +716,13 @@ LibDrawSquare * newitem = new LibDrawSquare();
return newitem; return newitem;
} }
LibDrawSegment::LibDrawSegment( void ) : LibEDA_BaseStruct( COMPONENT_LINE_DRAW_TYPE ) LibDrawSegment::LibDrawSegment( void ) : LibEDA_BaseStruct( COMPONENT_LINE_DRAW_TYPE )
{ {
m_Width = 0; m_Width = 0;
} }
LibDrawSegment* LibDrawSegment::GenCopy( void ) LibDrawSegment* LibDrawSegment::GenCopy( void )
{ {
LibDrawSegment* newitem = new LibDrawSegment(); LibDrawSegment* newitem = new LibDrawSegment();
@ -662,11 +745,13 @@ LibDrawPolyline::LibDrawPolyline(void) : LibEDA_BaseStruct(COMPONENT_POLYLINE_DR
m_Width = 0; m_Width = 0;
} }
/************************************************/ /************************************************/
LibDrawPolyline* LibDrawPolyline::GenCopy( void ) LibDrawPolyline* LibDrawPolyline::GenCopy( void )
/************************************************/ /************************************************/
{ {
LibDrawPolyline* newitem = new LibDrawPolyline(); LibDrawPolyline* newitem = new LibDrawPolyline();
int size; int size;
newitem->n = n; newitem->n = n;
@ -685,9 +770,11 @@ int size;
return newitem; return newitem;
} }
/***************************************************/ /***************************************************/
void LibDrawPolyline::AddPoint( const wxPoint& point ) void LibDrawPolyline::AddPoint( const wxPoint& point )
/***************************************************/ /***************************************************/
/* add a point to the polyline coordinate list, and realloc the memory /* add a point to the polyline coordinate list, and realloc the memory
*/ */
{ {
@ -703,5 +790,3 @@ int allocsize;
PolyList[(n * 2) - 2] = point.x; PolyList[(n * 2) - 2] = point.x;
PolyList[(n * 2) - 1] = -point.y; PolyList[(n * 2) - 1] = -point.y;
} }

View File

@ -56,9 +56,9 @@ typedef enum {
/* flags utilises dans FindLibPart() : */ /* flags utilises dans FindLibPart() : */
#define FIND_ROOT 0 /* indique la recherche du composant racine si #define FIND_ROOT 0 /* indique la recherche du composant racine si
meme si le composant specifie est un alias */ * meme si le composant specifie est un alias */
#define FIND_ALIAS 1 /* indique la recherche du composant specifie #define FIND_ALIAS 1 /* indique la recherche du composant specifie
(alias ou racine) */ * (alias ou racine) */
/* definition des types des structures d'elements de librairie */ /* definition des types des structures d'elements de librairie */
typedef enum { typedef enum {
@ -105,6 +105,8 @@ eda_global wxChar * MsgPinElectricType[]
wxT( "openEm" ), wxT( "openEm" ),
wxT( "?????" ) wxT( "?????" )
} }
#endif #endif
; ;
@ -161,22 +163,25 @@ public:
/* class LibEDA_BaseStruct : Basic class for items used in a library component /* class LibEDA_BaseStruct : Basic class for items used in a library component
(graphic shapes, texts, fields, pins) * (graphic shapes, texts, fields, pins)
*/ */
class LibEDA_BaseStruct : public EDA_BaseStruct class LibEDA_BaseStruct : public EDA_BaseStruct
{ {
public: public:
int m_Unit; /* Unit identification (for multi part per parkage) int m_Unit; /* Unit identification (for multi part per parkage)
0 if the item is common to all units */ * 0 if the item is common to all units */
int m_Convert; /* Shape identification (for parts which have a convert shape) int m_Convert; /* Shape identification (for parts which have a convert shape)
0 if the item is common to all shapes */ * 0 if the item is common to all shapes */
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */ wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */
int m_Width; /* Width of draw lines */ int m_Width; /* Width of draw lines */
public: public:
LibEDA_BaseStruct * Next(void) {return (LibEDA_BaseStruct *) Pnext;} LibEDA_BaseStruct* Next( void )
LibEDA_BaseStruct(int struct_type); {
return (LibEDA_BaseStruct*) Pnext;
}
LibEDA_BaseStruct( KICAD_T struct_type );
virtual ~LibEDA_BaseStruct( void ) { } virtual ~LibEDA_BaseStruct( void ) { }
void Display_Infos_DrawEntry( WinEDA_DrawFrame* frame ); void Display_Infos_DrawEntry( WinEDA_DrawFrame* frame );
}; };
@ -191,9 +196,10 @@ public:
int m_PinType; /* Electrical pin properties */ int m_PinType; /* Electrical pin properties */
int m_Attributs; /* bit 0 != 0: pin invisible */ int m_Attributs; /* bit 0 != 0: pin invisible */
long m_PinNum; /* Pin number: 4 Ascii code like "12" or "anod" or "G6" long m_PinNum; /* Pin number: 4 Ascii code like "12" or "anod" or "G6"
"12" is really "12\0\0"*/ * "12" is really "12\0\0"*/
wxString m_PinName; wxString m_PinName;
int m_PinNumSize, m_PinNameSize;/* Pin num and Pin name sizes */ int m_PinNumSize, m_PinNameSize;/* Pin num and Pin name sizes */
// short m_PinNumWidth, m_PinNameWidth; /* (Unused) Pin num and Pin name text width */ // short m_PinNumWidth, m_PinNameWidth; /* (Unused) Pin num and Pin name text width */
public: public:
@ -206,7 +212,8 @@ public:
int ReturnPinDrawOrient( int TransMat[2][2] ); int ReturnPinDrawOrient( int TransMat[2][2] );
void ReturnPinStringNum( wxString& buffer ); void ReturnPinStringNum( wxString& buffer );
void SetPinNumFromString( wxString& buffer ); void SetPinNumFromString( wxString& buffer );
void DrawPinSymbol(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & pin_pos, int orient, void DrawPinSymbol( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& pin_pos,
int orient,
int DrawMode, int Color = -1 ); int DrawMode, int Color = -1 );
void DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC, void DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
@ -294,14 +301,17 @@ public:
public: public:
LibDrawPolyline( void ); LibDrawPolyline( void );
~LibDrawPolyline(void){ if ( PolyList ) free(PolyList);} ~LibDrawPolyline( void ) {
if( PolyList )
free( PolyList );
}
LibDrawPolyline* GenCopy( void ); LibDrawPolyline* GenCopy( void );
void AddPoint( const wxPoint& point ); void AddPoint( const wxPoint& point );
bool WriteDescr( FILE* File ); bool WriteDescr( FILE* File );
}; };
/* Fields identiques aux fields des composants, pouvant etre predefinis en lib /* Fields identiques aux fields des composants, pouvant etre predefinis en lib
2 Fields sont toujours presents : Prefix (U, IC..) et Name (74LS00..)*/ * 2 Fields sont toujours presents : Prefix (U, IC..) et Name (74LS00..)*/
class LibDrawField : public LibEDA_BaseStruct class LibDrawField : public LibEDA_BaseStruct
{ {
public: public:
@ -330,7 +340,7 @@ class LibCmpEntry : public EDA_BaseStruct
{ {
public: public:
LibrEntryType Type; /* Type = ROOT; LibrEntryType Type; /* Type = ROOT;
= ALIAS pour struct LibraryAliasType */ * = ALIAS pour struct LibraryAliasType */
LibDrawField m_Name; // name (74LS00 ..) in lib ( = VALUE ) LibDrawField m_Name; // name (74LS00 ..) in lib ( = VALUE )
wxString m_Doc; /* ligne de documentation */ wxString m_Doc; /* ligne de documentation */
wxString m_KeyWord; /* liste des mots cles */ wxString m_KeyWord; /* liste des mots cles */
@ -353,8 +363,8 @@ public:
bool m_UnitSelectionLocked; // True if units are differents and their selection is locked 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 // (i.e. if part A cannot be automatically changed in part B
int m_TextInside;/* if 0: pin name drawn on the pin itself int m_TextInside;/* if 0: pin name drawn on the pin itself
if > 0 pin name drawn inside the component, * if > 0 pin name drawn inside the component,
with a distance of m_TextInside in mils */ * with a distance of m_TextInside in mils */
bool m_DrawPinNum; bool m_DrawPinNum;
bool m_DrawPinName; bool m_DrawPinName;
LibDrawField* Fields; /* Auxiliairy Field list (id = 2 a 11*/ LibDrawField* Fields; /* Auxiliairy Field list (id = 2 a 11*/
@ -364,6 +374,7 @@ public:
public: public:
EDA_LibComponentStruct( const wxChar * CmpName ); EDA_LibComponentStruct( const wxChar * CmpName );
EDA_Rect GetBoundaryBox( int Unit, int Convert );/* return Box around the part. */ EDA_Rect GetBoundaryBox( int Unit, int Convert );/* return Box around the part. */
~EDA_LibComponentStruct( void ); ~EDA_LibComponentStruct( void );
void SortDrawItems( void ); void SortDrawItems( void );
}; };
@ -383,13 +394,13 @@ extern LibraryStruct *LibraryList; /* All part libs are saved here. */
/* Variables Utiles pour les editions de composants en librairie */ /* Variables Utiles pour les editions de composants en librairie */
eda_global LibEDA_BaseStruct* LibItemToRepeat;/* pointeur sur l'élément que l'on eda_global LibEDA_BaseStruct* LibItemToRepeat;/* pointeur sur l'élément que l'on
peut répéter (Pin..;) */ * peut répéter (Pin..;) */
eda_global LibraryStruct* CurrentLib; /* Pointeur sur la librairie du eda_global LibraryStruct* CurrentLib; /* Pointeur sur la librairie du
composant en cours d'edition */ * composant en cours d'edition */
eda_global EDA_LibComponentStruct* CurrentLibEntry; /* pointeur sur le composant en eda_global EDA_LibComponentStruct* CurrentLibEntry; /* pointeur sur le composant en
cours d'edition */ * cours d'edition */
eda_global LibEDA_BaseStruct* CurrentDrawItem;/* pointeur sur les eda_global LibEDA_BaseStruct* CurrentDrawItem;/* pointeur sur les
elements de dessin du comp. en edition */ * elements de dessin du comp. en edition */
eda_global wxString CurrentAliasName; // Nom de l'alias selectionné eda_global wxString CurrentAliasName; // Nom de l'alias selectionné
eda_global bool g_AsDeMorgan; // Pour libedit: eda_global bool g_AsDeMorgan; // Pour libedit:
@ -406,7 +417,6 @@ eda_global int CurrentConvert /* Convert = 1 .. 255 */
eda_global wxString FindLibName; /* nom de la librairie ou a ete trouve le eda_global wxString FindLibName; /* nom de la librairie ou a ete trouve le
dernier composant recherche par FindLibPart() */ * dernier composant recherche par FindLibPart() */
#endif // LIBCMP_H #endif // LIBCMP_H

View File

@ -543,6 +543,7 @@ wxClientDC dc(DrawPanel);
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
EditSymbolText(&dc, CurrentDrawItem); EditSymbolText(&dc, CurrentDrawItem);
break; break;
default:;
} }
DrawPanel->CursorOn(&dc); DrawPanel->CursorOn(&dc);
} }

View File

@ -839,6 +839,9 @@ int seuil;
return(DrawItem); /* Texte trouve */ return(DrawItem); /* Texte trouve */
} }
break; break;
default:
;
} }
} }
return(NULL); return(NULL);

View File

@ -290,6 +290,9 @@ wxPoint pos;
MyFree(Poly); MyFree(Poly);
} }
break; break;
default:;
} /* Fin Switch */ } /* Fin Switch */
Plume('U'); Plume('U');
} /* Fin Boucle de dessin */ } /* Fin Boucle de dessin */

View File

@ -55,22 +55,36 @@ extern const wxChar * NameMarqueurType[];
/* Forward declarations */ /* Forward declarations */
class DrawSheetStruct; class DrawSheetStruct;
class EDA_DrawLineStruct: public EDA_BaseLineStruct /* Segment decription
base class to describe items which have 2 end points (track, wire, draw line ...) */ /**
* Class EDA_DrawLineStruct
* is a segment decription base class to describe items which have 2 end
* points (track, wire, draw line ...)
*/
class EDA_DrawLineStruct : public EDA_BaseStruct
{ {
public: public:
bool m_StartIsDangling, m_EndIsDangling; // TRUE si Start ou End not connected (wires, tracks...) int m_Layer; // Layer number
int m_Width; // 0 = line, > 0 = tracks, bus ...
wxPoint m_Start; // Line start point
wxPoint m_End; // Line end point
bool m_StartIsDangling;
bool m_EndIsDangling; // TRUE si Start ou End not connected (wires, tracks...)
public: public:
EDA_DrawLineStruct( const wxPoint &pos, int layer ); EDA_DrawLineStruct( const wxPoint &pos, int layer );
~EDA_DrawLineStruct( void ) { } ~EDA_DrawLineStruct( void ) { }
bool IsOneEndPointAt( const wxPoint& pos ); bool IsOneEndPointAt( const wxPoint& pos );
EDA_DrawLineStruct* GenCopy( void ); EDA_DrawLineStruct* GenCopy( void );
bool IsNull( void ) bool IsNull( void )
{ {
return (m_Start == m_End); return m_Start == m_End;
} }
virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1);
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
}; };
@ -87,9 +101,11 @@ public:
~DrawMarkerStruct( void ); ~DrawMarkerStruct( void );
DrawMarkerStruct* GenCopy( void ); DrawMarkerStruct* GenCopy( void );
wxString GetComment( void ); wxString GetComment( void );
virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
}; };
class DrawNoConnectStruct : public EDA_BaseStruct /* Symboles de non connexion */ class DrawNoConnectStruct : public EDA_BaseStruct /* Symboles de non connexion */
{ {
public: public:
@ -99,11 +115,16 @@ public:
DrawNoConnectStruct( const wxPoint &pos ); DrawNoConnectStruct( const wxPoint &pos );
~DrawNoConnectStruct( void ) { } ~DrawNoConnectStruct( void ) { }
DrawNoConnectStruct* GenCopy( void ); DrawNoConnectStruct* GenCopy( void );
virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
}; };
class DrawBusEntryStruct: public EDA_BaseStruct /* Struct de descr 1 raccord
a 45 degres de BUS ou WIRE */ /**
* Class DrawBusEntryStruct
* Struct de descr 1 raccord a 45 degres de BUS ou WIRE
*/
class DrawBusEntryStruct : public EDA_BaseStruct
{ {
public: public:
int m_Layer; int m_Layer;
@ -116,7 +137,8 @@ public:
~DrawBusEntryStruct( void ) { } ~DrawBusEntryStruct( void ) { }
DrawBusEntryStruct* GenCopy( void ); DrawBusEntryStruct* GenCopy( void );
wxPoint m_End( void ); // retourne la coord de fin du raccord wxPoint m_End( void ); // retourne la coord de fin du raccord
virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
}; };
class DrawPolylineStruct : public EDA_BaseStruct/* Polyligne (serie de segments) */ class DrawPolylineStruct : public EDA_BaseStruct/* Polyligne (serie de segments) */
@ -131,7 +153,8 @@ public:
DrawPolylineStruct( int layer ); DrawPolylineStruct( int layer );
~DrawPolylineStruct( void ); ~DrawPolylineStruct( void );
DrawPolylineStruct* GenCopy( void ); DrawPolylineStruct* GenCopy( void );
virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
}; };
class DrawJunctionStruct : public EDA_BaseStruct class DrawJunctionStruct : public EDA_BaseStruct
@ -144,7 +167,8 @@ public:
DrawJunctionStruct( const wxPoint &pos ); DrawJunctionStruct( const wxPoint &pos );
~DrawJunctionStruct( void ) { } ~DrawJunctionStruct( void ) { }
DrawJunctionStruct* GenCopy( void ); DrawJunctionStruct* GenCopy( void );
virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
}; };
class DrawTextStruct : public EDA_BaseStruct, public EDA_TextStruct class DrawTextStruct : public EDA_BaseStruct, public EDA_TextStruct
@ -158,13 +182,18 @@ public:
DrawTextStruct( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString ); DrawTextStruct( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString );
~DrawTextStruct( void ) { } ~DrawTextStruct( void ) { }
DrawTextStruct* GenCopy( void ); DrawTextStruct* GenCopy( void );
virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1); virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
void SwapData( DrawTextStruct* copyitem ); void SwapData( DrawTextStruct* copyitem );
virtual void Place( WinEDA_DrawFrame* frame, wxDC* DC ); virtual void Place( WinEDA_DrawFrame* frame, wxDC* DC );
private: private:
void DrawAsText(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color); void DrawAsText( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
void DrawAsLabel(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color); int draw_mode, int Color );
void DrawAsGlobalLabel(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color); void DrawAsLabel( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color );
void DrawAsGlobalLabel( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color );
}; };
@ -179,7 +208,8 @@ public:
class DrawGlobalLabelStruct : public DrawTextStruct class DrawGlobalLabelStruct : public DrawTextStruct
{ {
public: public:
DrawGlobalLabelStruct(const wxPoint & pos = wxPoint(0,0), const wxString & text = wxEmptyString); DrawGlobalLabelStruct( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
~DrawGlobalLabelStruct( void ) { } ~DrawGlobalLabelStruct( void ) { }
}; };
@ -200,4 +230,3 @@ public:
#endif /* PROGRAM_H */ #endif /* PROGRAM_H */

View File

@ -40,6 +40,7 @@ static int FlSymbol_Fill = NO_FILL;
void WinEDA_bodygraphics_PropertiesFrame:: void WinEDA_bodygraphics_PropertiesFrame::
bodygraphics_PropertiesAccept( wxCommandEvent& event ) bodygraphics_PropertiesAccept( wxCommandEvent& event )
/************************************************************/ /************************************************************/
/* Update the current draw item /* Update the current draw item
*/ */
{ {
@ -54,15 +55,20 @@ void WinEDA_bodygraphics_PropertiesFrame::
if( !(CurrentDrawItem->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place if( !(CurrentDrawItem->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place
m_Parent->SaveCopyInUndoList( CurrentLibEntry ); m_Parent->SaveCopyInUndoList( CurrentLibEntry );
wxClientDC dc( m_Parent->DrawPanel ); wxClientDC dc( m_Parent->DrawPanel );
m_Parent->DrawPanel->PrepareGraphicContext( &dc ); m_Parent->DrawPanel->PrepareGraphicContext( &dc );
DrawLibraryDrawStruct( m_Parent->DrawPanel, &dc, CurrentLibEntry, 0, 0, DrawLibraryDrawStruct( m_Parent->DrawPanel, &dc, CurrentLibEntry, 0, 0,
CurrentDrawItem, CurrentUnit, g_XorMode ); CurrentDrawItem, CurrentUnit, g_XorMode );
if( g_FlDrawSpecificUnit ) CurrentDrawItem->m_Unit = CurrentUnit; if( g_FlDrawSpecificUnit )
else CurrentDrawItem->m_Unit = 0; CurrentDrawItem->m_Unit = CurrentUnit;
if( g_FlDrawSpecificConvert ) CurrentDrawItem->m_Convert = CurrentConvert; else
else CurrentDrawItem->m_Convert = 0; CurrentDrawItem->m_Unit = 0;
if( g_FlDrawSpecificConvert )
CurrentDrawItem->m_Convert = CurrentConvert;
else
CurrentDrawItem->m_Convert = 0;
if( m_Filled ) if( m_Filled )
{ {
switch( CurrentDrawItem->m_StructType ) switch( CurrentDrawItem->m_StructType )
@ -84,10 +90,12 @@ void WinEDA_bodygraphics_PropertiesFrame::
case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE:
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
((LibDrawPolyline*)CurrentDrawItem)->m_Width = m_GraphicShapeWidthCtrl->GetValue(); ( (LibDrawPolyline*) CurrentDrawItem )->m_Width = m_GraphicShapeWidthCtrl->
GetValue();
break; break;
default: break; default:
break;
} }
} }
CurrentLibEntry->SortDrawItems(); CurrentLibEntry->SortDrawItems();
@ -105,17 +113,20 @@ void WinEDA_bodygraphics_PropertiesFrame::
m_Parent->ReDrawPanel(); m_Parent->ReDrawPanel();
} }
/**********************************************************/ /**********************************************************/
void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC,
LibEDA_BaseStruct* DrawItem ) LibEDA_BaseStruct* DrawItem )
/**********************************************************/ /**********************************************************/
/* Install the dialog box for editing a graphical item properties /* Install the dialog box for editing a graphical item properties
*/ */
{ {
if ( DrawItem == NULL ) return; if( DrawItem == NULL )
return;
WinEDA_bodygraphics_PropertiesFrame* frame = new WinEDA_bodygraphics_PropertiesFrame( this );
WinEDA_bodygraphics_PropertiesFrame * frame = new
WinEDA_bodygraphics_PropertiesFrame(this);
frame->ShowModal(); frame->Destroy(); frame->ShowModal(); frame->Destroy();
} }
@ -124,11 +135,11 @@ void WinEDA_LibeditFrame::EditGraphicSymbol(wxDC * DC,
static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC ) static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
/****************************************************************/ /****************************************************************/
{ {
StateDrawArc = 0; StateDrawArc = 0;
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
if(CurrentDrawItem == NULL) return; if( CurrentDrawItem == NULL )
return;
if( CurrentDrawItem->m_Flags & IS_NEW ) if( CurrentDrawItem->m_Flags & IS_NEW )
{ {
@ -136,11 +147,11 @@ static void AbortSymbolTraceOn(WinEDA_DrawPanel * Panel, wxDC * DC)
{ {
Panel->m_Parent->RedrawActiveWindow( DC, TRUE ); Panel->m_Parent->RedrawActiveWindow( DC, TRUE );
} }
else DrawLibraryDrawStruct(Panel, DC, CurrentLibEntry, 0 , 0, else
DrawLibraryDrawStruct( Panel, DC, CurrentLibEntry, 0, 0,
CurrentDrawItem, CurrentUnit, g_XorMode ); CurrentDrawItem, CurrentUnit, g_XorMode );
delete CurrentDrawItem; delete CurrentDrawItem;
} }
else else
{ {
wxPoint curpos; wxPoint curpos;
@ -158,23 +169,25 @@ static void AbortSymbolTraceOn(WinEDA_DrawPanel * Panel, wxDC * DC)
} }
/*********************************************************************/ /*********************************************************************/
LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC ) LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC )
/*********************************************************************/ /*********************************************************************/
/* Routine de creation d'un nouvel element type LibraryDrawStruct /* Routine de creation d'un nouvel element type LibraryDrawStruct
POLYLINE * POLYLINE
ARC * ARC
CIRCLE * CIRCLE
RECTANGLE * RECTANGLE
*/ */
{ {
int DrawType; int DrawType;
int* ptpoly; int* ptpoly;
if(CurrentDrawItem) return NULL; if( CurrentDrawItem )
return NULL;
DrawPanel->m_IgnoreMouseEvents = TRUE; DrawPanel->m_IgnoreMouseEvents = TRUE;
// Creation du nouvel element // Creation du nouvel element
switch( m_ID_current_state ) switch( m_ID_current_state )
{ {
@ -211,6 +224,7 @@ int * ptpoly;
case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE:
{ {
LibDrawArc* Arc = new LibDrawArc(); LibDrawArc* Arc = new LibDrawArc();
CurrentDrawItem = Arc; CurrentDrawItem = Arc;
ArcStartX = ArcEndX = m_CurrentScreen->m_Curseur.x; ArcStartX = ArcEndX = m_CurrentScreen->m_Curseur.x;
ArcStartY = ArcEndY = -m_CurrentScreen->m_Curseur.y; ArcStartY = ArcEndY = -m_CurrentScreen->m_Curseur.y;
@ -223,6 +237,7 @@ int * ptpoly;
case COMPONENT_CIRCLE_DRAW_TYPE: case COMPONENT_CIRCLE_DRAW_TYPE:
{ {
LibDrawCircle* Circle = new LibDrawCircle(); LibDrawCircle* Circle = new LibDrawCircle();
CurrentDrawItem = Circle; CurrentDrawItem = Circle;
Circle->m_Pos.x = m_CurrentScreen->m_Curseur.x; Circle->m_Pos.x = m_CurrentScreen->m_Curseur.x;
Circle->m_Pos.y = -m_CurrentScreen->m_Curseur.y; Circle->m_Pos.y = -m_CurrentScreen->m_Curseur.y;
@ -234,6 +249,7 @@ int * ptpoly;
case COMPONENT_RECT_DRAW_TYPE: case COMPONENT_RECT_DRAW_TYPE:
{ {
LibDrawSquare* Square = new LibDrawSquare(); LibDrawSquare* Square = new LibDrawSquare();
CurrentDrawItem = Square; CurrentDrawItem = Square;
Square->m_Pos.x = m_CurrentScreen->m_Curseur.x; Square->m_Pos.x = m_CurrentScreen->m_Curseur.x;
Square->m_Pos.y = -m_CurrentScreen->m_Curseur.y; Square->m_Pos.y = -m_CurrentScreen->m_Curseur.y;
@ -246,6 +262,7 @@ int * ptpoly;
case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE:
{ {
LibDrawPolyline* polyline = new LibDrawPolyline(); LibDrawPolyline* polyline = new LibDrawPolyline();
CurrentDrawItem = polyline; CurrentDrawItem = polyline;
polyline->n = 2; polyline->n = 2;
ptpoly = (int*) MyZMalloc( 4 * sizeof(int) ); ptpoly = (int*) MyZMalloc( 4 * sizeof(int) );
@ -260,6 +277,7 @@ int * ptpoly;
case COMPONENT_LINE_DRAW_TYPE: case COMPONENT_LINE_DRAW_TYPE:
{ {
LibDrawSegment* Segment = new LibDrawSegment(); LibDrawSegment* Segment = new LibDrawSegment();
CurrentDrawItem = Segment; CurrentDrawItem = Segment;
Segment->m_Pos.x = m_CurrentScreen->m_Curseur.x; Segment->m_Pos.x = m_CurrentScreen->m_Curseur.x;
Segment->m_Pos.y = -m_CurrentScreen->m_Curseur.y; Segment->m_Pos.y = -m_CurrentScreen->m_Curseur.y;
@ -271,6 +289,7 @@ int * ptpoly;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
{ {
LibDrawText* Text = new LibDrawText(); LibDrawText* Text = new LibDrawText();
CurrentDrawItem = Text; CurrentDrawItem = Text;
Text->m_Size.x = Text->m_Size.y = g_LastTextSize; Text->m_Size.x = Text->m_Size.y = g_LastTextSize;
Text->m_Horiz = g_LastTextOrient; Text->m_Horiz = g_LastTextOrient;
@ -297,8 +316,10 @@ int * ptpoly;
if( CurrentDrawItem ) if( CurrentDrawItem )
{ {
CurrentDrawItem->m_Flags |= IS_NEW; CurrentDrawItem->m_Flags |= IS_NEW;
if(g_FlDrawSpecificUnit) CurrentDrawItem->m_Unit = CurrentUnit; if( g_FlDrawSpecificUnit )
if(g_FlDrawSpecificConvert) CurrentDrawItem->m_Convert = CurrentConvert; CurrentDrawItem->m_Unit = CurrentUnit;
if( g_FlDrawSpecificConvert )
CurrentDrawItem->m_Convert = CurrentConvert;
} }
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
@ -311,10 +332,12 @@ int * ptpoly;
/********************************************************/ /********************************************************/
void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC ) void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC )
/********************************************************/ /********************************************************/
/* Routine de creation d'un nouvel element type LibraryDrawStruct /* Routine de creation d'un nouvel element type LibraryDrawStruct
*/ */
{ {
if(CurrentDrawItem == NULL) return; if( CurrentDrawItem == NULL )
return;
switch( CurrentDrawItem->m_StructType ) switch( CurrentDrawItem->m_StructType )
{ {
@ -348,13 +371,17 @@ void WinEDA_LibeditFrame::GraphicItemBeginDraw(wxDC * DC)
case COMPONENT_LINE_DRAW_TYPE: case COMPONENT_LINE_DRAW_TYPE:
break; break;
default:
;
}
} }
}
/**************************************************************************/ /**************************************************************************/
static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/**************************************************************************/ /**************************************************************************/
/* Redraw the graphoc shape while moving /* Redraw the graphoc shape while moving
*/ */
{ {
@ -380,7 +407,6 @@ int mx, my;
} }
/*****************************************************************/ /*****************************************************************/
void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos ) void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos )
/*****************************************************************/ /*****************************************************************/
@ -440,14 +466,19 @@ wxSize size;
( (LibDrawText*) CurrentDrawItem )->m_Pos.x = mx; ( (LibDrawText*) CurrentDrawItem )->m_Pos.x = mx;
( (LibDrawText*) CurrentDrawItem )->m_Pos.y = -my; ( (LibDrawText*) CurrentDrawItem )->m_Pos.y = -my;
break; break;
default:
;
} }
} }
/************************************************************/ /************************************************************/
void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC ) void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC )
/************************************************************/ /************************************************************/
{ {
if(CurrentDrawItem == NULL) return; if( CurrentDrawItem == NULL )
return;
SetCursor( wxCURSOR_HAND ); SetCursor( wxCURSOR_HAND );
@ -479,6 +510,9 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol(wxDC * DC)
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
InitPosition = ( (LibDrawText*) CurrentDrawItem )->m_Pos; InitPosition = ( (LibDrawText*) CurrentDrawItem )->m_Pos;
break; break;
default:
;
} }
ItemPreviousPos = m_CurrentScreen->m_Curseur; ItemPreviousPos = m_CurrentScreen->m_Curseur;
@ -488,7 +522,6 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol(wxDC * DC)
} }
/****************************************************************/ /****************************************************************/
/* Routine de Gestion des evenements souris lors de la creation */ /* Routine de Gestion des evenements souris lors de la creation */
/* d'un nouvel element type LibraryDrawStruct */ /* d'un nouvel element type LibraryDrawStruct */
@ -573,6 +606,9 @@ int mx = Screen->m_Curseur.x,
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: /* Traite par des routines specifiques */ case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: /* Traite par des routines specifiques */
break; break;
default:
;
} }
if( StateDrawArc == 1 ) if( StateDrawArc == 1 )
@ -603,15 +639,18 @@ int mx = Screen->m_Curseur.x,
/******************************************************/ /******************************************************/
void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC ) void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
/******************************************************/ /******************************************************/
/* Place la structure courante en liste des structures du composant /* Place la structure courante en liste des structures du composant
courant, si elle existe et redessine toujours celle ci * courant, si elle existe et redessine toujours celle ci
Parametres: (tous globaux) * Parametres: (tous globaux)
CurrentDrawItem * CurrentDrawItem
CurrentLibEntry * CurrentLibEntry
*/ */
{ {
if(CurrentLibEntry == NULL) return; if( CurrentLibEntry == NULL )
if(CurrentDrawItem == NULL) return; return;
if( CurrentDrawItem == NULL )
return;
if( CurrentDrawItem->m_StructType == COMPONENT_ARC_DRAW_TYPE ) if( CurrentDrawItem->m_StructType == COMPONENT_ARC_DRAW_TYPE )
{ {
@ -633,6 +672,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem(wxDC * DC)
SaveCopyInUndoList( CurrentLibEntry ); SaveCopyInUndoList( CurrentLibEntry );
CurrentDrawItem->Pnext = CurrentLibEntry->m_Drawings; CurrentDrawItem->Pnext = CurrentLibEntry->m_Drawings;
CurrentLibEntry->m_Drawings = CurrentDrawItem; CurrentLibEntry->m_Drawings = CurrentDrawItem;
switch( CurrentDrawItem->m_StructType ) switch( CurrentDrawItem->m_StructType )
{ {
case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE:
@ -655,12 +695,18 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem(wxDC * DC)
case COMPONENT_LINE_DRAW_TYPE: case COMPONENT_LINE_DRAW_TYPE:
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
break; break;
default:
;
} }
CurrentLibEntry->SortDrawItems(); CurrentLibEntry->SortDrawItems();
} }
if ( m_ID_current_state ) SetCursor(wxCURSOR_PENCIL); if( m_ID_current_state )
else SetCursor(wxCURSOR_ARROW); SetCursor( wxCURSOR_PENCIL );
else
SetCursor( wxCURSOR_ARROW );
if( (CurrentDrawItem->m_Flags & IS_MOVED) ) if( (CurrentDrawItem->m_Flags & IS_MOVED) )
{ {
@ -683,15 +729,15 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem(wxDC * DC)
} }
/***************************************************************/ /***************************************************************/
static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre ) static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre )
/***************************************************************/ /***************************************************************/
/* routine d'ajustage des parametres de l'arc en cours de trace /* routine d'ajustage des parametres de l'arc en cours de trace
calcule le centre, rayon, angles pour que l'arc en cours * calcule le centre, rayon, angles pour que l'arc en cours
passe par les points ArcStartX,Y et ArcEndX,Y avec le centre le plus proche * passe par les points ArcStartX,Y et ArcEndX,Y avec le centre le plus proche
de la pos souris * de la pos souris
Remarque: le centre n'est evidemment pas sur la grille * Remarque: le centre n'est evidemment pas sur la grille
*/ */
{ {
int dx, dy; int dx, dy;
@ -739,8 +785,10 @@ int angle;
// limitation val abs a < 1800 (1/2 cercle) pour eviter Pbs d'affichage en miroir // limitation val abs a < 1800 (1/2 cercle) pour eviter Pbs d'affichage en miroir
// car en trace on suppose que l'arc fait moins de 180 deg pour trouver // car en trace on suppose que l'arc fait moins de 180 deg pour trouver
// son orientation apres rot, miroir... // son orientation apres rot, miroir...
if ( (DrawItem->t2 - DrawItem->t1) > 1800 ) DrawItem->t2 -= 3600; if( (DrawItem->t2 - DrawItem->t1) > 1800 )
else if ( (DrawItem->t2 - DrawItem->t1) <= -1800 ) DrawItem->t2 += 3600; DrawItem->t2 -= 3600;
else if( (DrawItem->t2 - DrawItem->t1) <= -1800 )
DrawItem->t2 += 3600;
wxString msg; wxString msg;
angle = DrawItem->t2 - DrawItem->t1; angle = DrawItem->t2 - DrawItem->t1;
@ -752,6 +800,7 @@ wxString msg;
DrawItem->t2--; DrawItem->t2--;
DrawItem->t1++; DrawItem->t1++;
} }
while( (DrawItem->t1 - DrawItem->t2) >= 1800 ) while( (DrawItem->t1 - DrawItem->t2) >= 1800 )
{ {
DrawItem->t2++; DrawItem->t2++;
@ -760,17 +809,18 @@ wxString msg;
NORMALIZE_ANGLE( DrawItem->t1 ); NORMALIZE_ANGLE( DrawItem->t1 );
NORMALIZE_ANGLE( DrawItem->t2 ); NORMALIZE_ANGLE( DrawItem->t2 );
} }
/***************************************************/ /***************************************************/
void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC ) void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
/**************************************************/ /**************************************************/
/* Used for deleting last entered segment while creating a Polyline /* Used for deleting last entered segment while creating a Polyline
*/ */
{ {
if( CurrentDrawItem == NULL )
if ( CurrentDrawItem == NULL ) return; return;
if( CurrentDrawItem->m_StructType != COMPONENT_POLYLINE_DRAW_TYPE ) if( CurrentDrawItem->m_StructType != COMPONENT_POLYLINE_DRAW_TYPE )
return; return;
@ -784,8 +834,8 @@ LibDrawPolyline * Poly = (LibDrawPolyline*)CurrentDrawItem;
{ {
Poly->n--; Poly->n--;
ptpoly = Poly->PolyList + ( 2 * (Poly->n - 1) ); ptpoly = Poly->PolyList + ( 2 * (Poly->n - 1) );
if ( (ptpoly[0] != m_CurrentScreen->m_Curseur.x) || if( (ptpoly[0] != m_CurrentScreen->m_Curseur.x)
(ptpoly[1] != - m_CurrentScreen->m_Curseur.y) ) || (ptpoly[1] != -m_CurrentScreen->m_Curseur.y) )
{ {
ptpoly[0] = m_CurrentScreen->m_Curseur.x; ptpoly[0] = m_CurrentScreen->m_Curseur.x;
ptpoly[1] = -m_CurrentScreen->m_Curseur.y; ptpoly[1] = -m_CurrentScreen->m_Curseur.y;
@ -799,4 +849,3 @@ LibDrawPolyline * Poly = (LibDrawPolyline*)CurrentDrawItem;
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, 0, 0, DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, 0, 0,
CurrentDrawItem, CurrentUnit, g_XorMode ); CurrentDrawItem, CurrentUnit, g_XorMode );
} }

View File

@ -25,13 +25,12 @@ static bool CompareSymbols(LibEDA_BaseStruct *DEntryRef,
/* Variables locales */ /* Variables locales */
/***************************************************/ /***************************************************/
void WinEDA_LibeditFrame::LoadOneSymbol( wxDC* DC ) void WinEDA_LibeditFrame::LoadOneSymbol( wxDC* DC )
/***************************************************/ /***************************************************/
/* Read a component shape file and add data (graphic items) to the current /* Read a component shape file and add data (graphic items) to the current
component. * component.
*/ */
{ {
int NumOfParts; int NumOfParts;
@ -42,8 +41,10 @@ wxString FullFileName, mask;
FILE* ImportFile; FILE* ImportFile;
wxString msg; wxString msg;
if(CurrentDrawItem) return; if( CurrentDrawItem )
if( CurrentLibEntry == NULL) return; return;
if( CurrentLibEntry == NULL )
return;
DrawPanel->m_IgnoreMouseEvents = TRUE; DrawPanel->m_IgnoreMouseEvents = TRUE;
@ -62,7 +63,8 @@ wxString msg;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE; DrawPanel->m_IgnoreMouseEvents = FALSE;
if ( FullFileName.IsEmpty() ) return; if( FullFileName.IsEmpty() )
return;
/* Load data */ /* Load data */
@ -78,7 +80,8 @@ wxString msg;
Entries = LoadLibraryAux( this, NULL, ImportFile, &NumOfParts ); Entries = LoadLibraryAux( this, NULL, ImportFile, &NumOfParts );
fclose( ImportFile ); fclose( ImportFile );
if( Entries == NULL) return; if( Entries == NULL )
return;
if( NumOfParts > 1 ) if( NumOfParts > 1 )
DisplayError( this, _( "Warning: more than 1 part in Symbol File" ), 20 ); DisplayError( this, _( "Warning: more than 1 part in Symbol File" ), 20 );
@ -93,8 +96,10 @@ wxString msg;
DrawEntry = LibEntry->m_Drawings; DrawEntry = LibEntry->m_Drawings;
while( DrawEntry ) while( DrawEntry )
{ {
if(DrawEntry->m_Unit) DrawEntry->m_Unit = CurrentUnit; if( DrawEntry->m_Unit )
if(DrawEntry->m_Convert) DrawEntry->m_Convert = CurrentConvert; DrawEntry->m_Unit = CurrentUnit;
if( DrawEntry->m_Convert )
DrawEntry->m_Convert = CurrentConvert;
DrawEntry->m_Flags = IS_NEW; DrawEntry->m_Flags = IS_NEW;
DrawEntry->m_Selected = IS_SELECTED; DrawEntry->m_Selected = IS_SELECTED;
@ -107,8 +112,10 @@ wxString msg;
} }
DrawEntry = DrawEntry->Next(); DrawEntry = DrawEntry->Next();
} }
SuppressDuplicateDrawItem( CurrentLibEntry ); SuppressDuplicateDrawItem( CurrentLibEntry );
m_CurrentScreen->SetModify(); m_CurrentScreen->SetModify();
// Move (and place ) the new draw items: // Move (and place ) the new draw items:
HandleBlockBegin( DC, -1, GetScreen()->m_Curseur ); HandleBlockBegin( DC, -1, GetScreen()->m_Curseur );
HandleBlockEnd( DC ); HandleBlockEnd( DC );
@ -122,9 +129,10 @@ wxString msg;
/********************************************/ /********************************************/
void WinEDA_LibeditFrame::SaveOneSymbol( void ) void WinEDA_LibeditFrame::SaveOneSymbol( void )
/********************************************/ /********************************************/
/* Save in file the current symbol /* Save in file the current symbol
file format is like the standard libraries, but there is only one symbol * file format is like the standard libraries, but there is only one symbol
Invisible pins are not saved * Invisible pins are not saved
*/ */
{ {
EDA_LibComponentStruct* LibEntry = CurrentLibEntry; EDA_LibComponentStruct* LibEntry = CurrentLibEntry;
@ -135,7 +143,8 @@ wxString FullFileName, mask;
wxString msg; wxString msg;
FILE* ExportFile; FILE* ExportFile;
if( LibEntry->m_Drawings == NULL ) return; if( LibEntry->m_Drawings == NULL )
return;
/* Creation du fichier symbole */ /* Creation du fichier symbole */
mask = wxT( "*" ) + g_SymbolExtBuffer; mask = wxT( "*" ) + g_SymbolExtBuffer;
@ -148,7 +157,8 @@ FILE * ExportFile;
wxFD_SAVE, wxFD_SAVE,
TRUE TRUE
); );
if ( FullFileName.IsEmpty() ) return; if( FullFileName.IsEmpty() )
return;
ExportFile = wxFopen( FullFileName, wxT( "wt" ) ); ExportFile = wxFopen( FullFileName, wxT( "wt" ) );
if( ExportFile == NULL ) if( ExportFile == NULL )
@ -175,7 +185,8 @@ FILE * ExportFile;
fprintf( ExportFile, "DEF %s", (const char*) LibEntry->m_Name.m_Text.GetData() ); fprintf( ExportFile, "DEF %s", (const char*) LibEntry->m_Name.m_Text.GetData() );
if( !LibEntry->m_Prefix.m_Text.IsEmpty() ) if( !LibEntry->m_Prefix.m_Text.IsEmpty() )
fprintf( ExportFile, " %s", (const char*) LibEntry->m_Prefix.m_Text.GetData() ); fprintf( ExportFile, " %s", (const char*) LibEntry->m_Prefix.m_Text.GetData() );
else fprintf(ExportFile," ~"); else
fprintf( ExportFile, " ~" );
fprintf( ExportFile, " %d %d %c %c %d %d %c\n", fprintf( ExportFile, " %d %d %c %c %d %d %c\n",
0, /* unused */ 0, /* unused */
@ -201,9 +212,12 @@ FILE * ExportFile;
continue; continue;
/* .Unit , . Convert est laisse a 0 ou mis a 1 */ /* .Unit , . Convert est laisse a 0 ou mis a 1 */
SymbUnit = DrawEntry->m_Unit; if ( SymbUnit > 1) SymbUnit = 1; SymbUnit = DrawEntry->m_Unit; if( SymbUnit > 1 )
SymbUnit = 1;
SymbConvert = DrawEntry->m_Convert; SymbConvert = DrawEntry->m_Convert;
if ( SymbConvert > 1) SymbConvert = 1; if( SymbConvert > 1 )
SymbConvert = 1;
switch( DrawEntry->m_StructType ) switch( DrawEntry->m_StructType )
{ {
case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE:
@ -232,7 +246,8 @@ FILE * ExportFile;
case COMPONENT_PIN_DRAW_TYPE: case COMPONENT_PIN_DRAW_TYPE:
#undef DRAWSTRUCT #undef DRAWSTRUCT
#define DRAWSTRUCT ( (LibDrawPin*) DrawEntry ) #define DRAWSTRUCT ( (LibDrawPin*) DrawEntry )
if(DRAWSTRUCT->m_Attributs & PINNOTDRAW) break; if( DRAWSTRUCT->m_Attributs & PINNOTDRAW )
break;
DRAWSTRUCT->WriteDescr( ExportFile ); DRAWSTRUCT->WriteDescr( ExportFile );
break; break;
@ -241,6 +256,9 @@ FILE * ExportFile;
#define DRAWSTRUCT ( (LibDrawPolyline*) DrawEntry ) #define DRAWSTRUCT ( (LibDrawPolyline*) DrawEntry )
DRAWSTRUCT->WriteDescr( ExportFile ); DRAWSTRUCT->WriteDescr( ExportFile );
break; break;
default:
;
} }
} }
fprintf( ExportFile, "ENDDRAW\n" ); fprintf( ExportFile, "ENDDRAW\n" );
@ -250,13 +268,13 @@ FILE * ExportFile;
} }
/*****************************************************************/ /*****************************************************************/
void SuppressDuplicateDrawItem( EDA_LibComponentStruct* LibEntry ) void SuppressDuplicateDrawItem( EDA_LibComponentStruct* LibEntry )
/*****************************************************************/ /*****************************************************************/
/* Delete redundant graphic items. /* Delete redundant graphic items.
Useful after loading asymbole from a file symbol, because some graphic items * Useful after loading asymbole from a file symbol, because some graphic items
can be duplicated. * can be duplicated.
*/ */
{ {
LibEDA_BaseStruct* DEntryRef, * DEntryCompare; LibEDA_BaseStruct* DEntryRef, * DEntryCompare;
@ -266,9 +284,11 @@ wxDC * DC = NULL;
DEntryRef = LibEntry->m_Drawings; DEntryRef = LibEntry->m_Drawings;
while( DEntryRef ) while( DEntryRef )
{ {
if( DEntryRef->Pnext == NULL ) return; if( DEntryRef->Pnext == NULL )
return;
DEntryCompare = DEntryRef->Next(); DEntryCompare = DEntryRef->Next();
if( DEntryCompare == NULL ) return; if( DEntryCompare == NULL )
return;
deleted = 0; deleted = 0;
while( DEntryCompare ) while( DEntryCompare )
{ {
@ -280,29 +300,35 @@ wxDC * DC = NULL;
} }
DEntryCompare = DEntryCompare->Next(); DEntryCompare = DEntryCompare->Next();
} }
if ( ! deleted ) DEntryRef = DEntryRef->Next();
else DEntryRef = LibEntry->m_Drawings;
}
}
if( !deleted )
DEntryRef = DEntryRef->Next();
else
DEntryRef = LibEntry->m_Drawings;
}
}
/********************************************************************/ /********************************************************************/
static bool CompareSymbols( LibEDA_BaseStruct* DEntryRef, static bool CompareSymbols( LibEDA_BaseStruct* DEntryRef,
LibEDA_BaseStruct* DEntryCompare ) LibEDA_BaseStruct* DEntryCompare )
/********************************************************************/ /********************************************************************/
/* Compare 2 graphic items (arc, lines ...). /* Compare 2 graphic items (arc, lines ...).
return FALSE si different * return FALSE si different
TRUE si they are identical, and therefore redundant * TRUE si they are identical, and therefore redundant
*/ */
{ {
int ii; int ii;
int* ptref, * ptcomp; int* ptref, * ptcomp;
/* Comparaison des proprietes generales */ /* Comparaison des proprietes generales */
if( DEntryRef->m_StructType != DEntryCompare->m_StructType) return(FALSE); if( DEntryRef->m_StructType != DEntryCompare->m_StructType )
if( DEntryRef->m_Unit != DEntryCompare->m_Unit) return(FALSE); return FALSE;
if( DEntryRef->m_Convert != DEntryCompare->m_Convert) return(FALSE); if( DEntryRef->m_Unit != DEntryCompare->m_Unit )
return FALSE;
if( DEntryRef->m_Convert != DEntryCompare->m_Convert )
return FALSE;
switch( DEntryRef->m_StructType ) switch( DEntryRef->m_StructType )
{ {
@ -311,10 +337,14 @@ int * ptref, *ptcomp;
#undef CMPSTRUCT #undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawArc*) DEntryRef ) #define REFSTRUCT ( (LibDrawArc*) DEntryRef )
#define CMPSTRUCT ( (LibDrawArc*) DEntryCompare ) #define CMPSTRUCT ( (LibDrawArc*) DEntryCompare )
if( REFSTRUCT->m_Pos.x != CMPSTRUCT->m_Pos.x) return(FALSE); if( REFSTRUCT->m_Pos.x != CMPSTRUCT->m_Pos.x )
if( REFSTRUCT->m_Pos.y != CMPSTRUCT->m_Pos.y) return(FALSE); return FALSE;
if( REFSTRUCT->t1 != CMPSTRUCT->t1) return(FALSE); if( REFSTRUCT->m_Pos.y != CMPSTRUCT->m_Pos.y )
if( REFSTRUCT->t2 != CMPSTRUCT->t2) return(FALSE); return FALSE;
if( REFSTRUCT->t1 != CMPSTRUCT->t1 )
return FALSE;
if( REFSTRUCT->t2 != CMPSTRUCT->t2 )
return FALSE;
break; break;
case COMPONENT_CIRCLE_DRAW_TYPE: case COMPONENT_CIRCLE_DRAW_TYPE:
@ -322,9 +352,12 @@ int * ptref, *ptcomp;
#undef CMPSTRUCT #undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawCircle*) DEntryRef ) #define REFSTRUCT ( (LibDrawCircle*) DEntryRef )
#define CMPSTRUCT ( (LibDrawCircle*) DEntryCompare ) #define CMPSTRUCT ( (LibDrawCircle*) DEntryCompare )
if( REFSTRUCT->m_Pos.x != CMPSTRUCT->m_Pos.x) return(FALSE); if( REFSTRUCT->m_Pos.x != CMPSTRUCT->m_Pos.x )
if( REFSTRUCT->m_Pos.y != CMPSTRUCT->m_Pos.y) return(FALSE); return FALSE;
if( REFSTRUCT->m_Rayon != CMPSTRUCT->m_Rayon) return(FALSE); if( REFSTRUCT->m_Pos.y != CMPSTRUCT->m_Pos.y )
return FALSE;
if( REFSTRUCT->m_Rayon != CMPSTRUCT->m_Rayon )
return FALSE;
break; break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE: case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
@ -332,10 +365,12 @@ int * ptref, *ptcomp;
#undef CMPSTRUCT #undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawText*) DEntryRef ) #define REFSTRUCT ( (LibDrawText*) DEntryRef )
#define CMPSTRUCT ( (LibDrawText*) DEntryCompare ) #define CMPSTRUCT ( (LibDrawText*) DEntryCompare )
if( REFSTRUCT->m_Pos != CMPSTRUCT->m_Pos) return(FALSE); if( REFSTRUCT->m_Pos != CMPSTRUCT->m_Pos )
if( REFSTRUCT->m_Size != CMPSTRUCT->m_Size) return(FALSE); return FALSE;
if( REFSTRUCT->m_Size != CMPSTRUCT->m_Size )
return FALSE;
if( REFSTRUCT->m_Text != CMPSTRUCT->m_Text ) if( REFSTRUCT->m_Text != CMPSTRUCT->m_Text )
return(FALSE); return FALSE;
break; break;
case COMPONENT_RECT_DRAW_TYPE: case COMPONENT_RECT_DRAW_TYPE:
@ -343,8 +378,10 @@ int * ptref, *ptcomp;
#undef CMPSTRUCT #undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawSquare*) DEntryRef ) #define REFSTRUCT ( (LibDrawSquare*) DEntryRef )
#define CMPSTRUCT ( (LibDrawSquare*) DEntryCompare ) #define CMPSTRUCT ( (LibDrawSquare*) DEntryCompare )
if( REFSTRUCT->m_Pos != CMPSTRUCT->m_Pos) return(FALSE); if( REFSTRUCT->m_Pos != CMPSTRUCT->m_Pos )
if( REFSTRUCT->m_End != CMPSTRUCT->m_End) return(FALSE); return FALSE;
if( REFSTRUCT->m_End != CMPSTRUCT->m_End )
return FALSE;
break; break;
case COMPONENT_PIN_DRAW_TYPE: case COMPONENT_PIN_DRAW_TYPE:
@ -352,7 +389,8 @@ int * ptref, *ptcomp;
#undef CMPSTRUCT #undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawPin*) DEntryRef ) #define REFSTRUCT ( (LibDrawPin*) DEntryRef )
#define CMPSTRUCT ( (LibDrawPin*) DEntryCompare ) #define CMPSTRUCT ( (LibDrawPin*) DEntryCompare )
if( REFSTRUCT->m_Pos != CMPSTRUCT->m_Pos) return(FALSE); if( REFSTRUCT->m_Pos != CMPSTRUCT->m_Pos )
return FALSE;
break; break;
case COMPONENT_POLYLINE_DRAW_TYPE: case COMPONENT_POLYLINE_DRAW_TYPE:
@ -360,19 +398,25 @@ int * ptref, *ptcomp;
#undef CMPSTRUCT #undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawPolyline*) DEntryRef ) #define REFSTRUCT ( (LibDrawPolyline*) DEntryRef )
#define CMPSTRUCT ( (LibDrawPolyline*) DEntryCompare ) #define CMPSTRUCT ( (LibDrawPolyline*) DEntryCompare )
if( REFSTRUCT->n != CMPSTRUCT->n) return(FALSE); if( REFSTRUCT->n != CMPSTRUCT->n )
return FALSE;
ptref = REFSTRUCT->PolyList; ptref = REFSTRUCT->PolyList;
ptcomp = CMPSTRUCT->PolyList; ptcomp = CMPSTRUCT->PolyList;
for( ii = 2 * REFSTRUCT->n; ii > 0; ii-- ) for( ii = 2 * REFSTRUCT->n; ii > 0; ii-- )
{ {
if( *ptref != *ptcomp) return(FALSE); if( *ptref != *ptcomp )
return FALSE;
ptref++; ptcomp++; ptref++; ptcomp++;
} }
break; break;
}
return(TRUE); default:
;
} }
return TRUE;
}
/***************************************************************************/ /***************************************************************************/
@ -394,7 +438,8 @@ LibEDA_BaseStruct * DrawEntry;
dy = m_CurrentScreen->m_Curseur.y; dy = m_CurrentScreen->m_Curseur.y;
LibEntry = CurrentLibEntry; LibEntry = CurrentLibEntry;
if( LibEntry == NULL ) return; if( LibEntry == NULL )
return;
m_CurrentScreen->SetModify(); m_CurrentScreen->SetModify();
@ -457,12 +502,15 @@ LibEDA_BaseStruct * DrawEntry;
*ptsegm += dy; ptsegm++; *ptsegm += dy; ptsegm++;
} }
break; break;
default:
;
} }
DrawEntry = DrawEntry->Next(); DrawEntry = DrawEntry->Next();
} }
/* Redraw the symbol */ /* Redraw the symbol */
m_CurrentScreen->m_Curseur.x = m_CurrentScreen->m_Curseur.y = 0; m_CurrentScreen->m_Curseur.x = m_CurrentScreen->m_Curseur.y = 0;
Recadre_Trace( TRUE ); Recadre_Trace( TRUE );
m_CurrentScreen->SetRefreshReq(); m_CurrentScreen->SetRefreshReq();
} }

View File

@ -14,7 +14,9 @@ extern std::ostream& operator<<( std::ostream& out, const wxPoint& pt );
/* Id for class identification, at run time */ /* Id for class identification, at run time */
enum DrawStructureType { enum KICAD_T {
NOT_USED = -1, // the 3d code uses this value
EOT = 0, // search types array terminator (End Of Types) EOT = 0, // search types array terminator (End Of Types)
@ -80,7 +82,6 @@ enum SEARCH_RESULT {
SEARCH_CONTINUE SEARCH_CONTINUE
}; };
typedef DrawStructureType KICAD_T; // shorter name
class EDA_BaseStruct; class EDA_BaseStruct;
class WinEDA_DrawFrame; class WinEDA_DrawFrame;
@ -126,7 +127,7 @@ public:
class EDA_BaseStruct /* Basic class, not directly used */ class EDA_BaseStruct /* Basic class, not directly used */
{ {
public: public:
int m_StructType; /* Struct ident for run time identification */ KICAD_T m_StructType; /* Struct ident for run time identification */
EDA_BaseStruct* Pnext; /* Linked list: Link (next struct) */ EDA_BaseStruct* Pnext; /* Linked list: Link (next struct) */
EDA_BaseStruct* Pback; /* Linked list: Link (previous struct) */ EDA_BaseStruct* Pback; /* Linked list: Link (previous struct) */
EDA_BaseStruct* m_Parent; /* Linked list: Link (parent struct) */ EDA_BaseStruct* m_Parent; /* Linked list: Link (parent struct) */
@ -163,11 +164,11 @@ private:
public: public:
EDA_BaseStruct( EDA_BaseStruct* parent, int idType ); EDA_BaseStruct( EDA_BaseStruct* parent, KICAD_T idType );
EDA_BaseStruct( int struct_type ); EDA_BaseStruct( KICAD_T struct_type );
virtual ~EDA_BaseStruct() { }; virtual ~EDA_BaseStruct() { };
EDA_BaseStruct* Next( void ) { return Pnext; } EDA_BaseStruct* Next() { return Pnext; }
/* Gestion de l'etat (status) de la structure (active, deleted..) */ /* Gestion de l'etat (status) de la structure (active, deleted..) */
int GetState( int type ); int GetState( int type );
@ -381,7 +382,7 @@ protected:
public: public:
BOARD_ITEM( BOARD_ITEM* StructFather, DrawStructureType idtype ) : BOARD_ITEM( BOARD_ITEM* StructFather, KICAD_T idtype ) :
EDA_BaseStruct( StructFather, idtype ), EDA_BaseStruct( StructFather, idtype ),
m_Layer(0) m_Layer(0)
{ {
@ -450,22 +451,6 @@ public:
}; };
/* Base class for building items like lines, which have 1 start point and 1 end point.
* Arc and circles can use this class.
*/
class EDA_BaseLineStruct : public EDA_BaseStruct
{
public:
int m_Layer; // Layer number
int m_Width; // 0 = line, > 0 = tracks, bus ...
wxPoint m_Start; // Line start point
wxPoint m_End; // Line end point
public:
EDA_BaseLineStruct( EDA_BaseStruct* StructFather, DrawStructureType idtype );
};
/**************************/ /**************************/
/* class DrawPickedStruct */ /* class DrawPickedStruct */
/**************************/ /**************************/

View File

@ -358,7 +358,7 @@ public:
int m_Angle; // pour les arcs: "longueur" de l'arc en 1/10 deg int m_Angle; // pour les arcs: "longueur" de l'arc en 1/10 deg
public: public:
DRAWSEGMENT( BOARD_ITEM* StructFather, DrawStructureType idtype = TYPEDRAWSEGMENT ); DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT );
~DRAWSEGMENT( void ); ~DRAWSEGMENT( void );
// Read/write data // Read/write data

View File

@ -501,7 +501,7 @@ public:
virtual void SwitchLayer( wxDC* DC, int layer ); virtual void SwitchLayer( wxDC* DC, int layer );
// divers // divers
void AddHistory( int value, DrawStructureType type ); // Add value in data list history void AddHistory( int value, KICAD_T type ); // Add value in data list history
void InstallGridFrame( const wxPoint& pos ); void InstallGridFrame( const wxPoint& pos );
}; };

View File

@ -502,6 +502,9 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
( (EDGE_MODULE*) item )->m_End0.x += offset.x; ( (EDGE_MODULE*) item )->m_End0.x += offset.x;
( (EDGE_MODULE*) item )->m_End0.y += offset.y; ( (EDGE_MODULE*) item )->m_End0.y += offset.y;
break; break;
default:
;
} }
item->m_Flags = item->m_Selected = 0; item->m_Flags = item->m_Selected = 0;
@ -588,6 +591,9 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
SETMIRROR( ( (TEXTE_MODULE*) item )->m_Pos.x ); SETMIRROR( ( (TEXTE_MODULE*) item )->m_Pos.x );
( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->m_Pos.x; ( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->m_Pos.x;
break; break;
default:
;
} }
item->m_Flags = item->m_Selected = 0; item->m_Flags = item->m_Selected = 0;
@ -639,6 +645,9 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
( (TEXTE_MODULE*) item )->m_Pos0 = ( (TEXTE_MODULE*) item )->m_Pos; ( (TEXTE_MODULE*) item )->m_Pos0 = ( (TEXTE_MODULE*) item )->m_Pos;
( (TEXTE_MODULE*) item )->m_Orient += 900; ( (TEXTE_MODULE*) item )->m_Orient += 900;
break; break;
default:
;
} }
item->m_Flags = item->m_Selected = 0; item->m_Flags = item->m_Selected = 0;

View File

@ -31,6 +31,7 @@
EDGE_MODULE::EDGE_MODULE( MODULE* parent ) : EDGE_MODULE::EDGE_MODULE( MODULE* parent ) :
BOARD_ITEM( parent, TYPEEDGEMODULE ) BOARD_ITEM( parent, TYPEEDGEMODULE )
{ {
m_Width = 0;
m_Shape = S_SEGMENT; m_Shape = S_SEGMENT;
m_Angle = 0; m_Angle = 0;
m_Width = 120; m_Width = 120;

View File

@ -22,9 +22,10 @@
/* Constructeur des classes type pistes, vias et zones */ /* Constructeur des classes type pistes, vias et zones */
TRACK::TRACK( BOARD_ITEM* StructFather, DrawStructureType idtype ) : TRACK::TRACK( BOARD_ITEM* StructFather, KICAD_T idtype ) :
BOARD_ITEM( StructFather, idtype ) BOARD_ITEM( StructFather, idtype )
{ {
m_Width = 0;
m_Shape = S_SEGMENT; m_Shape = S_SEGMENT;
start = end = NULL; start = end = NULL;
m_NetCode = 0; m_NetCode = 0;

View File

@ -40,7 +40,7 @@ public:
int m_Param; // Auxiliary variable ( used in some computations ) int m_Param; // Auxiliary variable ( used in some computations )
public: public:
TRACK( BOARD_ITEM* StructFather, DrawStructureType idtype = TYPETRACK ); TRACK( BOARD_ITEM* StructFather, KICAD_T idtype = TYPETRACK );
TRACK( const TRACK& track ); TRACK( const TRACK& track );
TRACK* Next() { return (TRACK*) Pnext; } TRACK* Next() { return (TRACK*) Pnext; }

View File

@ -52,10 +52,10 @@ EDGE_ZONE:: ~EDGE_ZONE( void )
/**********************/ /**********************/
/* Classe DRAWSEGMENT: constructeur */ /* Classe DRAWSEGMENT: constructeur */
DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* StructFather, DrawStructureType idtype ) : DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype ) :
BOARD_ITEM( StructFather, idtype ) BOARD_ITEM( StructFather, idtype )
{ {
m_Flags = m_Shape = m_Type = m_Angle = 0; m_Width = m_Flags = m_Shape = m_Type = m_Angle = 0;
} }

View File

@ -19,7 +19,7 @@
/* Constructeur des classes type pistes, vias et zones */ /* Constructeur des classes type pistes, vias et zones */
TRACK::TRACK( EDA_BaseStruct* StructFather, DrawStructureType idtype ) : TRACK::TRACK( EDA_BaseStruct* StructFather, KICAD_T idtype ) :
SEGDRAW_Struct( StructFather, idtype ) SEGDRAW_Struct( StructFather, idtype )
{ {
m_Shape = S_SEGMENT; m_Shape = S_SEGMENT;

View File

@ -281,7 +281,7 @@ void WinEDA_PcbTracksDialog::AcceptPcbOptions(wxCommandEvent& event)
/*********************************************************************/ /*********************************************************************/
void WinEDA_BasePcbFrame::AddHistory(int value, DrawStructureType type) void WinEDA_BasePcbFrame::AddHistory(int value, KICAD_T type)
/**********************************************************************/ /**********************************************************************/
// Mise a jour des listes des dernieres epaisseurs de via et track utilisées // Mise a jour des listes des dernieres epaisseurs de via et track utilisées
{ {

View File

@ -1254,6 +1254,9 @@ int* WinEDA_BasePcbFrame::build_ratsnest_pad( EDA_BaseStruct* ref,
conn_number = track_ref->m_Sous_Netcode; conn_number = track_ref->m_Sous_Netcode;
break; break;
} }
default:
;
} }
if( current_net_code <= 0 ) if( current_net_code <= 0 )