Commit f8f38438 authored by dickelbeck's avatar dickelbeck

search and debug infrastructure, beautification

parent dda28ed6
...@@ -171,7 +171,7 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) ...@@ -171,7 +171,7 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
/*********************************************/ /*********************************************/
wxString EDA_BaseStruct::ReturnClassName( void ) wxString EDA_BaseStruct::ReturnClassName() const
/*********************************************/ /*********************************************/
/* Used at run time for diags: return the class name of the item, /* Used at run time for diags: return the class name of the item,
...@@ -202,7 +202,7 @@ wxString EDA_BaseStruct::ReturnClassName( void ) ...@@ -202,7 +202,7 @@ wxString EDA_BaseStruct::ReturnClassName( void )
void EDA_BaseStruct::Show( int nestLevel, std::ostream& os ) void EDA_BaseStruct::Show( int nestLevel, std::ostream& os )
{ {
// for now, make it look like XML: // for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
EDA_BaseStruct* kid = m_Son; EDA_BaseStruct* kid = m_Son;
for( ; kid; kid = kid->Pnext ) for( ; kid; kid = kid->Pnext )
...@@ -210,7 +210,7 @@ void EDA_BaseStruct::Show( int nestLevel, std::ostream& os ) ...@@ -210,7 +210,7 @@ void EDA_BaseStruct::Show( int nestLevel, std::ostream& os )
kid->Show( nestLevel+1, os ); kid->Show( nestLevel+1, os );
} }
NestedSpace( nestLevel, os ) << "</" << ReturnClassName().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
...@@ -236,7 +236,7 @@ SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart, ...@@ -236,7 +236,7 @@ SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart,
EDA_BaseStruct* p = listStart; EDA_BaseStruct* p = listStart;
for( ; p; p = p->Pnext ) for( ; p; p = p->Pnext )
{ {
if( SEARCH_QUIT == p->Traverse( inspector, testData, scanTypes ) ) if( SEARCH_QUIT == p->Visit( inspector, testData, scanTypes ) )
return SEARCH_QUIT; return SEARCH_QUIT;
} }
...@@ -245,7 +245,7 @@ SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart, ...@@ -245,7 +245,7 @@ SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart,
// see base_struct.h // see base_struct.h
SEARCH_RESULT EDA_BaseStruct::Traverse( INSPECTOR* inspector, const void* testData, SEARCH_RESULT EDA_BaseStruct::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ) const KICAD_T scanTypes[] )
{ {
KICAD_T stype; KICAD_T stype;
......
...@@ -164,7 +164,7 @@ public: ...@@ -164,7 +164,7 @@ public:
m_Status = new_status; m_Status = new_status;
} }
wxString ReturnClassName( void ); wxString ReturnClassName() const;
/* addition d'une nouvelle struct a la liste chain� */ /* addition d'une nouvelle struct a la liste chain� */
void AddToChain( EDA_BaseStruct* laststruct ); void AddToChain( EDA_BaseStruct* laststruct );
...@@ -179,6 +179,23 @@ public: ...@@ -179,6 +179,23 @@ public:
int Color = -1 ); int Color = -1 );
#if defined(DEBUG) #if defined(DEBUG)
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
virtual wxString GetClass() const
{
// ReturnClassName() is too hard to maintain, coordinating the array
// with the enum. It would be nice to migrate to virtual GetClass()
// away from ReturnClassName(). Over time, derived classes should
// simply return a wxString from their virtual GetClass() function.
// Some classes do that now.
return ReturnClassName();
}
/** /**
* Function Show * Function Show
* is used to output the object tree, currently for debugging only. * is used to output the object tree, currently for debugging only.
...@@ -221,7 +238,7 @@ public: ...@@ -221,7 +238,7 @@ public:
/** /**
* Function Traverse * Function Visit
* should be re-implemented for each derived class in order to handle * should be re-implemented for each derived class in order to handle
* all the types given by its member data. Implementations should call * all the types given by its member data. Implementations should call
* inspector->Inspect() on types in scanTypes[], and may use IterateForward() * inspector->Inspect() on types in scanTypes[], and may use IterateForward()
...@@ -231,9 +248,9 @@ public: ...@@ -231,9 +248,9 @@ public:
* @param scanTypes Which KICAD_T types are of interest and the order * @param scanTypes Which KICAD_T types are of interest and the order
* is significant too, terminated by EOT. * is significant too, terminated by EOT.
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE; * else SCAN_CONTINUE, and determined by the inspector.
*/ */
virtual SEARCH_RESULT Traverse( INSPECTOR* inspector, const void* testData, virtual SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ); const KICAD_T scanTypes[] );
......
This diff is collapsed.
...@@ -234,6 +234,18 @@ public: ...@@ -234,6 +234,18 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
virtual wxString GetClass() const
{
return wxT( "BOARD" );
}
/** /**
* Function Show * Function Show
* is used to output the object tree, currently for debugging only. * is used to output the object tree, currently for debugging only.
......
...@@ -257,6 +257,7 @@ bool BOARD::ComputeBoundaryBox( void ) ...@@ -257,6 +257,7 @@ bool BOARD::ComputeBoundaryBox( void )
#if defined(DEBUG) #if defined(DEBUG)
/** /**
* Function Show * Function Show
* is used to output the object tree, currently for debugging only. * is used to output the object tree, currently for debugging only.
...@@ -267,7 +268,7 @@ bool BOARD::ComputeBoundaryBox( void ) ...@@ -267,7 +268,7 @@ bool BOARD::ComputeBoundaryBox( void )
void BOARD::Show( int nestLevel, std::ostream& os ) void BOARD::Show( int nestLevel, std::ostream& os )
{ {
// for now, make it look like XML: // for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
// specialization of the output: // specialization of the output:
EDA_BaseStruct* p = m_Modules; EDA_BaseStruct* p = m_Modules;
...@@ -284,11 +285,10 @@ void BOARD::Show( int nestLevel, std::ostream& os ) ...@@ -284,11 +285,10 @@ void BOARD::Show( int nestLevel, std::ostream& os )
kid->Show( nestLevel+1, os ); kid->Show( nestLevel+1, os );
} }
NestedSpace( nestLevel, os ) << "</" << ReturnClassName().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
class ModuleOrPad : public INSPECTOR class ModuleOrPad : public INSPECTOR
{ {
public: public:
......
...@@ -446,7 +446,7 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File, ...@@ -446,7 +446,7 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File,
void EDGE_MODULE::Show( int nestLevel, std::ostream& os ) void EDGE_MODULE::Show( int nestLevel, std::ostream& os )
{ {
// for now, make it look like XML: // for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << "/>\n"; NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << "/>\n";
} }
#endif #endif
...@@ -43,6 +43,17 @@ public: ...@@ -43,6 +43,17 @@ public:
void Draw3D( Pcb3D_GLCanvas* glcanvas ); void Draw3D( Pcb3D_GLCanvas* glcanvas );
#if defined(DEBUG) #if defined(DEBUG)
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
virtual wxString GetClass() const
{
return wxT( "POLYLINE" );
// return wxT( "EDGE" ); ?
}
/** /**
* Function Show * Function Show
* is used to output the object tree, currently for debugging only. * is used to output the object tree, currently for debugging only.
......
...@@ -1158,7 +1158,7 @@ void MODULE::Show( int nestLevel, std::ostream& os ) ...@@ -1158,7 +1158,7 @@ void MODULE::Show( int nestLevel, std::ostream& os )
{ {
// for now, make it look like XML, expand on this later. // for now, make it look like XML, expand on this later.
NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
// " ref=\"" << m_Reference->m_Text.mb_str() << // " ref=\"" << m_Reference->m_Text.mb_str() <<
// "\" value=\"" << m_Value->m_Text.mb_str() << '"' << // "\" value=\"" << m_Value->m_Text.mb_str() << '"' <<
">\n"; ">\n";
...@@ -1172,23 +1172,27 @@ void MODULE::Show( int nestLevel, std::ostream& os ) ...@@ -1172,23 +1172,27 @@ void MODULE::Show( int nestLevel, std::ostream& os )
p = m_Value; p = m_Value;
for( ; p; p = p->Pnext ) for( ; p; p = p->Pnext )
p->Show( nestLevel+1, os ); p->Show( nestLevel+1, os );
p = m_Pads;
for( ; p; p = p->Pnext )
p->Show( nestLevel+1, os );
p = m_Drawings; p = m_Drawings;
for( ; p; p = p->Pnext ) for( ; p; p = p->Pnext )
p->Show( nestLevel+1, os ); p->Show( nestLevel+1, os );
p = m_Son; p = m_Son;
for( ; p; p = p->Pnext ) for( ; p; p = p->Pnext )
{ {
p->Show( nestLevel+1, os ); p->Show( nestLevel+1, os );
} }
NestedSpace( nestLevel, os ) << "</" << ReturnClassName().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
// see class_module.h // see class_module.h
SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, const void* testData, SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ) const KICAD_T scanTypes[] )
{ {
KICAD_T stype; KICAD_T stype;
...@@ -1201,13 +1205,6 @@ SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, const void* testData, ...@@ -1201,13 +1205,6 @@ SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, const void* testData,
if( SEARCH_QUIT == inspector->Inspect( this, testData ) ) if( SEARCH_QUIT == inspector->Inspect( this, testData ) )
return SEARCH_QUIT; return SEARCH_QUIT;
} }
else if( stype == TYPEEDGEMODULE )
{
// iterate over m_Drawings
if( SEARCH_QUIT == IterateForward( m_Drawings, inspector,
testData, scanTypes ) )
return SEARCH_QUIT;
}
else if( stype == TYPETEXTEMODULE ) else if( stype == TYPETEXTEMODULE )
{ {
// iterate over m_Reference // iterate over m_Reference
...@@ -1220,6 +1217,19 @@ SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, const void* testData, ...@@ -1220,6 +1217,19 @@ SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, const void* testData,
testData, scanTypes ) ) testData, scanTypes ) )
return SEARCH_QUIT; return SEARCH_QUIT;
} }
else if( stype == TYPEPAD )
{
if( SEARCH_QUIT == IterateForward( m_Pads, inspector,
testData, scanTypes ) )
return SEARCH_QUIT;
}
else if( stype == TYPEEDGEMODULE )
{
// iterate over m_Drawings
if( SEARCH_QUIT == IterateForward( m_Drawings, inspector,
testData, scanTypes ) )
return SEARCH_QUIT;
}
} }
return SEARCH_CONTINUE; return SEARCH_CONTINUE;
......
...@@ -27,9 +27,9 @@ enum Mod_Attribut /* Attributs d'un module */ ...@@ -27,9 +27,9 @@ enum Mod_Attribut /* Attributs d'un module */
* fichiers de placement automatique (principalement modules CMS */ * fichiers de placement automatique (principalement modules CMS */
MOD_VIRTUAL = 2 /* Module virtuel constitue par un dessin sur circuit MOD_VIRTUAL = 2 /* Module virtuel constitue par un dessin sur circuit
* (connecteur, trou de percage..) */ * (connecteur, trou de percage..) */
}; };
/* flags for autoplace and autoroute (.m_ModuleStatus member) */ /* flags for autoplace and autoroute (.m_ModuleStatus member) */
#define MODULE_is_LOCKED 0x01 /* module LOCKED: no autoplace allowed */ #define MODULE_is_LOCKED 0x01 /* module LOCKED: no autoplace allowed */
#define MODULE_is_PLACED 0x02 /* In autoplace: module automatically placed */ #define MODULE_is_PLACED 0x02 /* In autoplace: module automatically placed */
...@@ -55,7 +55,8 @@ public: ...@@ -55,7 +55,8 @@ public:
EDA_Rect m_RealBoundaryBox; /* position/taille du module (coord relles) */ EDA_Rect m_RealBoundaryBox; /* position/taille du module (coord relles) */
int m_PadNum; // Nombre total de pads int m_PadNum; // Nombre total de pads
int m_AltPadNum; // en placement auto Nombre de pads actifs pour int m_AltPadNum; // en placement auto Nombre de pads actifs pour
// les calculs // les calculs
int m_CntRot90; // Placement auto: cout ( 0..10 ) de la rotation 90 degre int m_CntRot90; // Placement auto: cout ( 0..10 ) de la rotation 90 degre
int m_CntRot180; // Placement auto: cout ( 0..10 ) de la rotation 180 degre int m_CntRot180; // Placement auto: cout ( 0..10 ) de la rotation 180 degre
wxSize m_Ext; // marges de "garde": utilise en placement auto. wxSize m_Ext; // marges de "garde": utilise en placement auto.
...@@ -77,11 +78,10 @@ public: ...@@ -77,11 +78,10 @@ public:
MODULE* Next( void ) { return (MODULE*) Pnext; } MODULE* Next( void ) { return (MODULE*) Pnext; }
void Set_Rectangle_Encadrement( void );/* mise a jour du rect d'encadrement void Set_Rectangle_Encadrement( void );/* mise a jour du rect d'encadrement
* en coord locales (orient 0 et origine = pos module) */ * en coord locales (orient 0 et origine = pos module) */
void SetRectangleExinscrit( void );/* mise a jour du rect d'encadrement void SetRectangleExinscrit( void );/* mise a jour du rect d'encadrement
* et de la surface en coord reelles */ * et de la surface en coord reelles */
// deplacements // deplacements
void SetPosition( const wxPoint& newpos ); void SetPosition( const wxPoint& newpos );
...@@ -134,6 +134,18 @@ public: ...@@ -134,6 +134,18 @@ public:
void Display_Infos( WinEDA_BasePcbFrame* frame ); void Display_Infos( WinEDA_BasePcbFrame* frame );
#if defined(DEBUG) #if defined(DEBUG)
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
virtual wxString GetClass() const
{
return wxT( "MODULE" );
}
/** /**
* Function Show * Function Show
* is used to output the object tree, currently for debugging only. * is used to output the object tree, currently for debugging only.
...@@ -145,8 +157,8 @@ public: ...@@ -145,8 +157,8 @@ public:
/** /**
* Function Traverse * Function Visit
* should be re-implemented for each derrived class in order to handle * should be re-implemented for each derived class in order to handle
* all the types given by its member data. Implementations should call * all the types given by its member data. Implementations should call
* inspector->Inspect() on types in scanTypes[], and may use IterateForward() * inspector->Inspect() on types in scanTypes[], and may use IterateForward()
* to do so on lists of such data. * to do so on lists of such data.
...@@ -157,7 +169,7 @@ public: ...@@ -157,7 +169,7 @@ public:
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE; * else SCAN_CONTINUE;
*/ */
virtual SEARCH_RESULT Traverse( INSPECTOR* inspector, const void* testData, virtual SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ); const KICAD_T scanTypes[] );
#endif #endif
......
This diff is collapsed.
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
/* supprime du chainage la structure Struct */ /* supprime du chainage la structure Struct */
void UnLink( void ); void UnLink( void );
/* Readind and writing data on files */ /* Reading and writing data on files */
int ReadDescr( FILE* File, int* LineNum = NULL ); int ReadDescr( FILE* File, int* LineNum = NULL );
int WriteDescr( FILE* File ); int WriteDescr( FILE* File );
...@@ -83,7 +83,7 @@ public: ...@@ -83,7 +83,7 @@ public:
void Draw3D( Pcb3D_GLCanvas* glcanvas ); void Draw3D( Pcb3D_GLCanvas* glcanvas );
// autres // autres
void SetPadName( const wxString& name ); // Change pade name void SetPadName( const wxString& name ); // Change pad name
wxString ReturnStringPadName( void ); // Return pad name as string in a wxString wxString ReturnStringPadName( void ); // Return pad name as string in a wxString
void ReturnStringPadName( wxString& text ); // Return pad name as string in a buffer void ReturnStringPadName( wxString& text ); // Return pad name as string in a buffer
void ComputeRayon( void ); // met a jour m_Rayon, rayon du cercle exinscrit void ComputeRayon( void ); // met a jour m_Rayon, rayon du cercle exinscrit
...@@ -91,6 +91,28 @@ public: ...@@ -91,6 +91,28 @@ public:
// de la forme (pastilles excentrees) // de la forme (pastilles excentrees)
void Display_Infos( WinEDA_BasePcbFrame* frame ); void Display_Infos( WinEDA_BasePcbFrame* frame );
#if defined(DEBUG)
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
virtual wxString GetClass() const
{
return wxT( "PAD" );
}
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
virtual void Show( int nestLevel, std::ostream& os );
#endif
}; };
typedef class D_PAD * LISTE_PAD; typedef class D_PAD * LISTE_PAD;
...@@ -11,130 +11,162 @@ ...@@ -11,130 +11,162 @@
#include "pcbnew.h" #include "pcbnew.h"
/*******************/ /*******************/
/* class TEXTE_PCB */ /* class TEXTE_PCB */
/*******************/ /*******************/
TEXTE_PCB::TEXTE_PCB(EDA_BaseStruct * parent): TEXTE_PCB::TEXTE_PCB( EDA_BaseStruct* parent ) :
EDA_BaseStruct(parent, TYPETEXTE), EDA_TextStruct() EDA_BaseStruct( parent, TYPETEXTE ),
EDA_TextStruct()
{ {
} }
/* Destructeur */ /* Destructeur */
TEXTE_PCB:: ~TEXTE_PCB(void) TEXTE_PCB:: ~TEXTE_PCB( void )
{ {
} }
/* copie de stucture */ /* copie de stucture */
void TEXTE_PCB::Copy(TEXTE_PCB * source) void TEXTE_PCB::Copy( TEXTE_PCB* source )
{ {
m_Parent = source->m_Parent; m_Parent = source->m_Parent;
Pback = Pnext = NULL; Pback = Pnext = NULL;
m_Miroir = source->m_Miroir; m_Miroir = source->m_Miroir;
m_Size = source->m_Size; m_Size = source->m_Size;
m_Orient = source->m_Orient; m_Orient = source->m_Orient;
m_Pos = source->m_Pos; m_Pos = source->m_Pos;
m_Layer = source->m_Layer; m_Layer = source->m_Layer;
m_Width = source->m_Width; m_Width = source->m_Width;
m_Attributs = source->m_Attributs; m_Attributs = source->m_Attributs;
m_CharType = source->m_CharType; m_CharType = source->m_CharType;
m_HJustify = source->m_HJustify; m_HJustify = source->m_HJustify;
m_VJustify = source->m_VJustify; m_VJustify = source->m_VJustify;
m_Text = source->m_Text; m_Text = source->m_Text;
} }
void TEXTE_PCB::UnLink( void ) void TEXTE_PCB::UnLink( void )
{ {
/* Modification du chainage arriere */ /* Modification du chainage arriere */
if( Pback ) if( Pback )
{ {
if( Pback->m_StructType != TYPEPCB) if( Pback->m_StructType != TYPEPCB )
{ {
Pback->Pnext = Pnext; Pback->Pnext = Pnext;
} }
else /* Le chainage arriere pointe sur la structure "Pere" */
else /* Le chainage arriere pointe sur la structure "Pere" */ {
{ ( (BOARD*) Pback )->m_Drawings = Pnext;
((BOARD*)Pback)->m_Drawings = Pnext; }
} }
}
/* Modification du chainage avant */
/* Modification du chainage avant */ if( Pnext )
if( Pnext) Pnext->Pback = Pback; Pnext->Pback = Pback;
Pnext = Pback = NULL; Pnext = Pback = NULL;
} }
/****************************************************************/ /****************************************************************/
int TEXTE_PCB::ReadTextePcbDescr(FILE * File, int * LineNum) int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum )
/****************************************************************/ /****************************************************************/
{ {
char text[1024], Line[1024]; char text[1024], Line[1024];
int dummy; int dummy;
while( GetLine(File, Line, LineNum ) != NULL ) while( GetLine( File, Line, LineNum ) != NULL )
{ {
if(strnicmp(Line,"$EndTEXTPCB",11) == 0) return 0; if( strnicmp( Line, "$EndTEXTPCB", 11 ) == 0 )
if( strncmp(Line,"Te", 2) == 0 ) /* Texte */ return 0;
{ if( strncmp( Line, "Te", 2 ) == 0 ) /* Texte */
ReadDelimitedText(text, Line+2, sizeof(text) ); {
m_Text = CONV_FROM_UTF8(text); ReadDelimitedText( text, Line + 2, sizeof(text) );
continue; m_Text = CONV_FROM_UTF8( text );
} continue;
if( strncmp(Line,"Po", 2) == 0 ) }
{ if( strncmp( Line, "Po", 2 ) == 0 )
sscanf( Line+2," %d %d %d %d %d %d", {
&m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y, sscanf( Line + 2, " %d %d %d %d %d %d",
&m_Width, &m_Orient); &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y,
continue; &m_Width, &m_Orient );
} continue;
if( strncmp(Line,"De", 2) == 0 ) }
{ if( strncmp( Line, "De", 2 ) == 0 )
sscanf( Line+2," %d %d %lX %d\n",&m_Layer, &m_Miroir, {
&m_TimeStamp, &dummy); sscanf( Line + 2, " %d %d %lX %d\n", &m_Layer, &m_Miroir,
if ( m_Layer < LAYER_CUIVRE_N ) &m_TimeStamp, &dummy );
m_Layer = LAYER_CUIVRE_N; if( m_Layer < LAYER_CUIVRE_N )
if ( m_Layer > LAST_NO_COPPER_LAYER ) m_Layer = LAYER_CUIVRE_N;
m_Layer = LAST_NO_COPPER_LAYER; if( m_Layer > LAST_NO_COPPER_LAYER )
m_Layer = LAST_NO_COPPER_LAYER;
continue;
} continue;
} }
return(1); }
return 1;
} }
/**************************************************/ /**************************************************/
int TEXTE_PCB::WriteTextePcbDescr(FILE * File) int TEXTE_PCB::WriteTextePcbDescr( FILE* File )
/**************************************************/ /**************************************************/
{ {
if( GetState(DELETED) ) return(0); if( GetState( DELETED ) )
return 0;
if(m_Text.IsEmpty() ) return(0);
fprintf( File,"$TEXTPCB\n"); if( m_Text.IsEmpty() )
fprintf( File,"Te \"%s\"\n",CONV_TO_UTF8(m_Text)); return 0;
fprintf( File,"Po %d %d %d %d %d %d\n", fprintf( File, "$TEXTPCB\n" );
m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Width, m_Orient ); fprintf( File, "Te \"%s\"\n", CONV_TO_UTF8( m_Text ) );
fprintf( File,"De %d %d %lX %d\n", m_Layer, m_Miroir, m_TimeStamp, 0); fprintf( File, "Po %d %d %d %d %d %d\n",
fprintf( File,"$EndTEXTPCB\n"); m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Width, m_Orient );
return(1); fprintf( File, "De %d %d %lX %d\n", m_Layer, m_Miroir, m_TimeStamp, 0 );
fprintf( File, "$EndTEXTPCB\n" );
return 1;
} }
/**********************************************************************/ /**********************************************************************/
void TEXTE_PCB::Draw(WinEDA_DrawPanel * panel, wxDC * DC, void TEXTE_PCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint & offset, int DrawMode) const wxPoint& offset, int DrawMode )
/**********************************************************************/ /**********************************************************************/
/* /*
DrawMode = GR_OR, GR_XOR.., -1 si mode courant. * DrawMode = GR_OR, GR_XOR.., -1 si mode courant.
*/ */
{ {
int color = g_DesignSettings.m_LayerColor[m_Layer]; int color = g_DesignSettings.m_LayerColor[m_Layer];
if(color & ITEM_NOT_SHOW ) return ;
EDA_TextStruct::Draw(panel, DC, offset, color, if( color & ITEM_NOT_SHOW )
DrawMode, DisplayOpt.DisplayDrawItems, return;
(g_AnchorColor & ITEM_NOT_SHOW) ? -1 : (g_AnchorColor & MASKCOLOR));
EDA_TextStruct::Draw( panel, DC, offset, color,
DrawMode, DisplayOpt.DisplayDrawItems,
(g_AnchorColor & ITEM_NOT_SHOW) ? -1 : (g_AnchorColor & MASKCOLOR) );
}
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void TEXTE_PCB::Show( int nestLevel, std::ostream& os )
{
// for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
NestedSpace( nestLevel+1, os ) << m_Text.mb_str() << '\n';
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
#endif
...@@ -25,6 +25,28 @@ public: ...@@ -25,6 +25,28 @@ public:
// File Operations: // File Operations:
int ReadTextePcbDescr(FILE * File, int * LineNum); int ReadTextePcbDescr(FILE * File, int * LineNum);
int WriteTextePcbDescr(FILE * File); int WriteTextePcbDescr(FILE * File);
#if defined(DEBUG)
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
virtual wxString GetClass() const
{
return wxT("PTEXT");
}
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
virtual void Show( int nestLevel, std::ostream& os );
#endif
}; };
#endif // #define CLASS_PCB_TEXT_H #endif // #define CLASS_PCB_TEXT_H
...@@ -307,10 +307,10 @@ void TEXTE_MODULE::Show( int nestLevel, std::ostream& os ) ...@@ -307,10 +307,10 @@ void TEXTE_MODULE::Show( int nestLevel, std::ostream& os )
{ {
// for now, make it look like XML, expand on this later. // for now, make it look like XML, expand on this later.
NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
NestedSpace( nestLevel+1, os ) << m_Text.mb_str() << '\n'; NestedSpace( nestLevel+1, os ) << m_Text.mb_str() << '\n';
NestedSpace( nestLevel, os ) << "</" << ReturnClassName().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
#endif #endif
...@@ -58,9 +58,18 @@ public: ...@@ -58,9 +58,18 @@ public:
* @return bool - true if a hit, else false * @return bool - true if a hit, else false
*/ */
bool HitTest( const wxPoint& posref ); bool HitTest( const wxPoint& posref );
#if defined(DEBUG) #if defined(DEBUG)
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
virtual wxString GetClass() const
{
return wxT( "MTEXT" );
}
/** /**
* Function Show * Function Show
* is used to output the object tree, currently for debugging only. * is used to output the object tree, currently for debugging only.
......
...@@ -675,14 +675,17 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer ) ...@@ -675,14 +675,17 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer )
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{ {
shape_pos = pt_pad->ReturnShapePos(); shape_pos = pt_pad->ReturnShapePos();
ux0 = shape_pos.x; uy0 = shape_pos.y; /* pos x,y du centre du pad */
deltaX = ref_pos.x - ux0; deltaY = ref_pos.y - uy0; ux0 = shape_pos.x;
uy0 = shape_pos.y; /* pos x,y du centre du pad */
deltaX = ref_pos.x - ux0;
deltaY = ref_pos.y - uy0;
/* Test rapide: le point a tester doit etre a l'interieur du cercle /* Test rapide: le point a tester doit etre a l'interieur du cercle
* exinscrit ... */ * exinscrit ... */
if( (abs( deltaX ) > pt_pad->m_Rayon ) if( (abs( deltaX ) > pt_pad->m_Rayon )
|| (abs( deltaY ) > pt_pad->m_Rayon) ) || (abs( deltaY ) > pt_pad->m_Rayon) )
continue; continue;
/* ... et sur la bonne couche */ /* ... et sur la bonne couche */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment