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 )
/*********************************************/
wxString EDA_BaseStruct::ReturnClassName( void )
wxString EDA_BaseStruct::ReturnClassName() const
/*********************************************/
/* Used at run time for diags: return the class name of the item,
......@@ -202,7 +202,7 @@ wxString EDA_BaseStruct::ReturnClassName( void )
void EDA_BaseStruct::Show( int nestLevel, std::ostream& os )
{
// 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;
for( ; kid; kid = kid->Pnext )
......@@ -210,7 +210,7 @@ void EDA_BaseStruct::Show( int nestLevel, std::ostream& 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,
EDA_BaseStruct* p = listStart;
for( ; p; p = p->Pnext )
{
if( SEARCH_QUIT == p->Traverse( inspector, testData, scanTypes ) )
if( SEARCH_QUIT == p->Visit( inspector, testData, scanTypes ) )
return SEARCH_QUIT;
}
......@@ -245,7 +245,7 @@ SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart,
// 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[] )
{
KICAD_T stype;
......
......@@ -164,7 +164,7 @@ public:
m_Status = new_status;
}
wxString ReturnClassName( void );
wxString ReturnClassName() const;
/* addition d'une nouvelle struct a la liste chain� */
void AddToChain( EDA_BaseStruct* laststruct );
......@@ -179,6 +179,23 @@ public:
int Color = -1 );
#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
* is used to output the object tree, currently for debugging only.
......@@ -221,7 +238,7 @@ public:
/**
* Function Traverse
* Function Visit
* should be re-implemented for each derived class in order to handle
* all the types given by its member data. Implementations should call
* inspector->Inspect() on types in scanTypes[], and may use IterateForward()
......@@ -231,9 +248,9 @@ public:
* @param scanTypes Which KICAD_T types are of interest and the order
* is significant too, terminated by EOT.
* @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[] );
......
This diff is collapsed.
......@@ -234,6 +234,18 @@ public:
#if defined(DEBUG)
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
virtual wxString GetClass() const
{
return wxT( "BOARD" );
}
/**
* Function Show
* is used to output the object tree, currently for debugging only.
......
......@@ -257,6 +257,7 @@ bool BOARD::ComputeBoundaryBox( void )
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
......@@ -267,7 +268,7 @@ bool BOARD::ComputeBoundaryBox( void )
void BOARD::Show( int nestLevel, std::ostream& os )
{
// 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:
EDA_BaseStruct* p = m_Modules;
......@@ -284,11 +285,10 @@ void BOARD::Show( int nestLevel, std::ostream& 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
{
public:
......
......@@ -446,7 +446,7 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File,
void EDGE_MODULE::Show( int nestLevel, std::ostream& os )
{
// for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << "/>\n";
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << "/>\n";
}
#endif
......@@ -43,6 +43,17 @@ public:
void Draw3D( Pcb3D_GLCanvas* glcanvas );
#if defined(DEBUG)
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
virtual wxString GetClass() const
{
return wxT( "POLYLINE" );
// return wxT( "EDGE" ); ?
}
/**
* Function Show
* is used to output the object tree, currently for debugging only.
......
......@@ -1158,7 +1158,7 @@ void MODULE::Show( int nestLevel, std::ostream& os )
{
// 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() <<
// "\" value=\"" << m_Value->m_Text.mb_str() << '"' <<
">\n";
......@@ -1173,6 +1173,10 @@ void MODULE::Show( int nestLevel, std::ostream& os )
for( ; p; p = p->Pnext )
p->Show( nestLevel+1, os );
p = m_Pads;
for( ; p; p = p->Pnext )
p->Show( nestLevel+1, os );
p = m_Drawings;
for( ; p; p = p->Pnext )
p->Show( nestLevel+1, os );
......@@ -1183,12 +1187,12 @@ void MODULE::Show( int nestLevel, std::ostream& 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
SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, const void* testData,
SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] )
{
KICAD_T stype;
......@@ -1201,13 +1205,6 @@ SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, const void* testData,
if( SEARCH_QUIT == inspector->Inspect( this, testData ) )
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 )
{
// iterate over m_Reference
......@@ -1220,6 +1217,19 @@ SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, const void* testData,
testData, scanTypes ) )
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;
......
......@@ -27,9 +27,9 @@ enum Mod_Attribut /* Attributs d'un module */
* fichiers de placement automatique (principalement modules CMS */
MOD_VIRTUAL = 2 /* Module virtuel constitue par un dessin sur circuit
* (connecteur, trou de percage..) */
};
/* flags for autoplace and autoroute (.m_ModuleStatus member) */
#define MODULE_is_LOCKED 0x01 /* module LOCKED: no autoplace allowed */
#define MODULE_is_PLACED 0x02 /* In autoplace: module automatically placed */
......@@ -56,6 +56,7 @@ public:
int m_PadNum; // Nombre total de pads
int m_AltPadNum; // en placement auto Nombre de pads actifs pour
// les calculs
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
wxSize m_Ext; // marges de "garde": utilise en placement auto.
......@@ -82,7 +83,6 @@ public:
void SetRectangleExinscrit( void );/* mise a jour du rect d'encadrement
* et de la surface en coord reelles */
// deplacements
void SetPosition( const wxPoint& newpos );
void SetOrientation( int newangle );
......@@ -134,6 +134,18 @@ public:
void Display_Infos( WinEDA_BasePcbFrame* frame );
#if defined(DEBUG)
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
virtual wxString GetClass() const
{
return wxT( "MODULE" );
}
/**
* Function Show
* is used to output the object tree, currently for debugging only.
......@@ -145,8 +157,8 @@ public:
/**
* Function Traverse
* should be re-implemented for each derrived class in order to handle
* Function Visit
* should be re-implemented for each derived class in order to handle
* all the types given by its member data. Implementations should call
* inspector->Inspect() on types in scanTypes[], and may use IterateForward()
* to do so on lists of such data.
......@@ -157,7 +169,7 @@ public:
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* 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[] );
#endif
......
This diff is collapsed.
......@@ -74,7 +74,7 @@ public:
/* supprime du chainage la structure Struct */
void UnLink( void );
/* Readind and writing data on files */
/* Reading and writing data on files */
int ReadDescr( FILE* File, int* LineNum = NULL );
int WriteDescr( FILE* File );
......@@ -83,7 +83,7 @@ public:
void Draw3D( Pcb3D_GLCanvas* glcanvas );
// 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
void ReturnStringPadName( wxString& text ); // Return pad name as string in a buffer
void ComputeRayon( void ); // met a jour m_Rayon, rayon du cercle exinscrit
......@@ -91,6 +91,28 @@ public:
// de la forme (pastilles excentrees)
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;
......@@ -11,22 +11,25 @@
#include "pcbnew.h"
/*******************/
/* class TEXTE_PCB */
/*******************/
/*******************/
/* class TEXTE_PCB */
/*******************/
TEXTE_PCB::TEXTE_PCB(EDA_BaseStruct * parent):
EDA_BaseStruct(parent, TYPETEXTE), EDA_TextStruct()
TEXTE_PCB::TEXTE_PCB( EDA_BaseStruct* parent ) :
EDA_BaseStruct( parent, TYPETEXTE ),
EDA_TextStruct()
{
}
/* Destructeur */
TEXTE_PCB:: ~TEXTE_PCB(void)
TEXTE_PCB:: ~TEXTE_PCB( void )
{
}
/* copie de stucture */
void TEXTE_PCB::Copy(TEXTE_PCB * source)
void TEXTE_PCB::Copy( TEXTE_PCB* source )
{
m_Parent = source->m_Parent;
Pback = Pnext = NULL;
......@@ -44,97 +47,126 @@ void TEXTE_PCB::Copy(TEXTE_PCB * source)
m_Text = source->m_Text;
}
void TEXTE_PCB::UnLink( void )
{
/* Modification du chainage arriere */
if( Pback )
{
if( Pback->m_StructType != TYPEPCB)
if( Pback->m_StructType != TYPEPCB )
{
Pback->Pnext = Pnext;
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
((BOARD*)Pback)->m_Drawings = Pnext;
( (BOARD*) Pback )->m_Drawings = Pnext;
}
}
/* Modification du chainage avant */
if( Pnext) Pnext->Pback = Pback;
if( Pnext )
Pnext->Pback = Pback;
Pnext = Pback = NULL;
}
/****************************************************************/
int TEXTE_PCB::ReadTextePcbDescr(FILE * File, int * LineNum)
int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum )
/****************************************************************/
{
char text[1024], Line[1024];
int dummy;
char text[1024], Line[1024];
int dummy;
while( GetLine(File, Line, LineNum ) != NULL )
while( GetLine( File, Line, LineNum ) != NULL )
{
if(strnicmp(Line,"$EndTEXTPCB",11) == 0) return 0;
if( strncmp(Line,"Te", 2) == 0 ) /* Texte */
if( strnicmp( Line, "$EndTEXTPCB", 11 ) == 0 )
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) );
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",
sscanf( Line + 2, " %d %d %d %d %d %d",
&m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y,
&m_Width, &m_Orient);
&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);
if ( m_Layer < LAYER_CUIVRE_N )
sscanf( Line + 2, " %d %d %lX %d\n", &m_Layer, &m_Miroir,
&m_TimeStamp, &dummy );
if( m_Layer < LAYER_CUIVRE_N )
m_Layer = LAYER_CUIVRE_N;
if ( m_Layer > LAST_NO_COPPER_LAYER )
if( m_Layer > LAST_NO_COPPER_LAYER )
m_Layer = LAST_NO_COPPER_LAYER;
continue;
}
}
return(1);
return 1;
}
/**************************************************/
int TEXTE_PCB::WriteTextePcbDescr(FILE * File)
int TEXTE_PCB::WriteTextePcbDescr( FILE* File )
/**************************************************/
{
if( GetState(DELETED) ) return(0);
if(m_Text.IsEmpty() ) return(0);
fprintf( File,"$TEXTPCB\n");
fprintf( File,"Te \"%s\"\n",CONV_TO_UTF8(m_Text));
fprintf( File,"Po %d %d %d %d %d %d\n",
if( GetState( DELETED ) )
return 0;
if( m_Text.IsEmpty() )
return 0;
fprintf( File, "$TEXTPCB\n" );
fprintf( File, "Te \"%s\"\n", CONV_TO_UTF8( m_Text ) );
fprintf( File, "Po %d %d %d %d %d %d\n",
m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Width, m_Orient );
fprintf( File,"De %d %d %lX %d\n", m_Layer, m_Miroir, m_TimeStamp, 0);
fprintf( File,"$EndTEXTPCB\n");
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,
const wxPoint & offset, int DrawMode)
void TEXTE_PCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
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];
if(color & ITEM_NOT_SHOW ) return ;
int color = g_DesignSettings.m_LayerColor[m_Layer];
if( color & ITEM_NOT_SHOW )
return;
EDA_TextStruct::Draw(panel, DC, offset, color,
EDA_TextStruct::Draw( panel, DC, offset, color,
DrawMode, DisplayOpt.DisplayDrawItems,
(g_AnchorColor & ITEM_NOT_SHOW) ? -1 : (g_AnchorColor & MASKCOLOR));
(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:
// File Operations:
int ReadTextePcbDescr(FILE * File, int * LineNum);
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
......@@ -307,10 +307,10 @@ void TEXTE_MODULE::Show( int nestLevel, std::ostream& os )
{
// 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, os ) << "</" << ReturnClassName().mb_str() << ">\n";
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
}
#endif
......@@ -59,8 +59,17 @@ public:
*/
bool HitTest( const wxPoint& posref );
#if defined(DEBUG)
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
virtual wxString GetClass() const
{
return wxT( "MTEXT" );
}
/**
* Function Show
* is used to output the object tree, currently for debugging only.
......
......@@ -675,9 +675,12 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer )
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{
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
* exinscrit ... */
......
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