collector work

This commit is contained in:
dickelbeck 2007-08-30 22:20:52 +00:00
parent 4272380e40
commit 726a8ab4df
29 changed files with 712 additions and 286 deletions

View File

@ -530,7 +530,7 @@ int color;
break; break;
case RECT : case RECT :
case SPECIAL_PAD: // case SPECIAL_PAD:
case TRAPEZE: case TRAPEZE:
{ {
int ddx, ddy ; int ddx, ddy ;

View File

@ -4,6 +4,26 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Aug-30 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+ pcbnew
* Removed SEGVIA::IsViaOnLayer, and instead implemented an override to
virtual BOARD_ITEM::IsOnLayer() called SEGVIA::IsOnLayer().
* Tweaked TRACK::Visit() to not traverse the KICAD_T scan list and a
corresponding change to BOARD::Vist() so we can now get VIA priority
if desired. (Have to traverse m_Tracks twice, wonder if we could use
two lists: m_Tracks and a new m_Vias?)
* Changed signature of MODULE::Display_Infos( WinEDA_DrawFrame* frame ) so
it gets called virtually with any BOARD_ITEM* which is actually a MODULE*.
This was a bug.
* With virtual functions, it is now critical that the correct object type
be instantiated. This was not happening in ioascii.cpp when reading
the vias. Bug fixed.
* GENERAL_COLLECTOR getting closer to useable.
@todo search further for new TRACK( TRACK* ) and make sure no vias are
being made this way.
2007-aug-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2007-aug-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+ eeschema & pcbnew + eeschema & pcbnew

View File

@ -211,7 +211,7 @@ SEARCH_RESULT EDA_BaseStruct::Visit( INSPECTOR* inspector, const void* testData,
{ {
KICAD_T stype; KICAD_T stype;
#if defined(DEBUG) #if 0 && defined(DEBUG)
std::cout << GetClass().mb_str() << ' '; std::cout << GetClass().mb_str() << ' ';
#endif #endif

View File

@ -160,7 +160,7 @@ private:
int m_Status; int m_Status;
private: private:
void InitVars( void ); void InitVars();
public: public:
@ -174,7 +174,7 @@ public:
int GetState( int type ); int GetState( int type );
void SetState( int type, int state ); void SetState( int type, int state );
int ReturnStatus( void ) const int ReturnStatus() const
{ {
return m_Status; return m_Status;
} }
@ -347,11 +347,11 @@ public:
public: public:
EDA_TextStruct( const wxString& text = wxEmptyString ); EDA_TextStruct( const wxString& text = wxEmptyString );
virtual ~EDA_TextStruct( void ); virtual ~EDA_TextStruct();
void CreateDrawData( void ); void CreateDrawData();
int GetLength( void ) { return m_Text.Length(); }; int GetLength() { return m_Text.Length(); };
int Pitch( void );/* retourne le pas entre 2 caracteres */ int Pitch();/* retourne le pas entre 2 caracteres */
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int color, const wxPoint& offset, int color,
int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 ); int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 );
@ -364,13 +364,13 @@ public:
*/ */
bool HitTest( const wxPoint& ref_pos ); bool HitTest( const wxPoint& ref_pos );
int Len_Size( void ); // Return the text lenght in internal units int Len_Size(); // Return the text lenght in internal units
}; };
/** /**
* Class BOARD_ITEM * Class BOARD_ITEM
* is an abstract base class for any item which can be embedded within the BOARD * is a base class for any item which can be embedded within the BOARD
* container class, and therefore instances of derived classes should only be * container class, and therefore instances of derived classes should only be
* found in PCBNEW or other programs that use class BOARD and its contents. * found in PCBNEW or other programs that use class BOARD and its contents.
* The corresponding class in EESCHEMA seems to be DrawPartStruct. * The corresponding class in EESCHEMA seems to be DrawPartStruct.
@ -441,7 +441,7 @@ public:
/** /**
* Function IsLocked * Function IsLocked
* @returns bool - true if the object is locked, else false * @return bool - true if the object is locked, else false
*/ */
virtual bool IsLocked() const virtual bool IsLocked() const
{ {
@ -469,11 +469,11 @@ public:
public: public:
DrawPickedStruct( EDA_BaseStruct* pickedstruct = NULL ); DrawPickedStruct( EDA_BaseStruct* pickedstruct = NULL );
~DrawPickedStruct( void ); ~DrawPickedStruct();
void Place( WinEDA_DrawFrame* frame, wxDC* DC ) { }; void Place( WinEDA_DrawFrame* frame, wxDC* DC ) { };
void DeleteWrapperList( void ); void DeleteWrapperList();
DrawPickedStruct* Next( void ) { return (DrawPickedStruct*) Pnext; } DrawPickedStruct* Next() { return (DrawPickedStruct*) Pnext; }
}; };
@ -490,27 +490,28 @@ public:
wxSize m_Size; // Rectangle Size wxSize m_Size; // Rectangle Size
public: public:
EDA_Rect( void ) { }; EDA_Rect() { };
wxPoint Centre( void )
wxPoint Centre()
{ {
return wxPoint( m_Pos.x + (m_Size.x >> 1), m_Pos.y + (m_Size.y >> 1) ); return wxPoint( m_Pos.x + (m_Size.x >> 1), m_Pos.y + (m_Size.y >> 1) );
} }
void Normalize( void ); // Ensure the height ant width are >= 0 void Normalize(); // Ensure the height and width are >= 0
bool Inside( const wxPoint& point ); // Return TRUE if point is in Rect bool Inside( const wxPoint& point ); // Return TRUE if point is in Rect
bool Inside( int x, int y ) { return Inside( wxPoint( x, y ) ); } bool Inside( int x, int y ) { return Inside( wxPoint( x, y ) ); }
wxSize GetSize( void ) { return m_Size; } wxSize GetSize() { return m_Size; }
int GetX( void ) { return m_Pos.x; } int GetX() { return m_Pos.x; }
int GetY( void ) { return m_Pos.y; } int GetY() { return m_Pos.y; }
wxPoint GetOrigin( void ) { return m_Pos; } wxPoint GetOrigin() { return m_Pos; }
wxPoint GetPosition( void ) { return m_Pos; } wxPoint GetPosition() { return m_Pos; }
wxPoint GetEnd( void ) { return wxPoint( GetRight(), GetBottom() ); } wxPoint GetEnd() { return wxPoint( GetRight(), GetBottom() ); }
int GetWidth( void ) { return m_Size.x; } int GetWidth() { return m_Size.x; }
int GetHeight( void ) { return m_Size.y; } int GetHeight() { return m_Size.y; }
int GetRight( void ) { return m_Pos.x + m_Size.x; } int GetRight() { return m_Pos.x + m_Size.x; }
int GetBottom( void ) { return m_Pos.y + m_Size.y; } int GetBottom() { return m_Pos.y + m_Size.y; }
void SetOrigin( const wxPoint& pos ) { m_Pos = pos; } void SetOrigin( const wxPoint& pos ) { m_Pos = pos; }
void SetOrigin( int x, int y ) { m_Pos.x = x; m_Pos.y = y; } void SetOrigin( int x, int y ) { m_Pos.x = x; m_Pos.y = y; }
void SetSize( const wxSize& size ) { m_Size = size; } void SetSize( const wxSize& size ) { m_Size = size; }

View File

@ -54,15 +54,15 @@ protected:
/// Which object types to scan /// Which object types to scan
const KICAD_T* m_ScanTypes; const KICAD_T* m_ScanTypes;
/// The layer that is desired as a primary search criterion
int m_PreferredLayer;
/// A place to hold collected objects without taking ownership of their memory. /// A place to hold collected objects without taking ownership of their memory.
std::vector<EDA_BaseStruct*> list; std::vector<EDA_BaseStruct*> m_List;
/// The point at which the snapshot was taken. /// A point to test against, andt that was used to make the collection.
wxPoint m_RefPos; wxPoint m_RefPos;
/// A bounding box to test against, and that was used to make the collection.
EDA_Rect m_RefBox;
/// The time at which the collection was made. /// The time at which the collection was made.
int m_TimeAtCollection; int m_TimeAtCollection;
@ -71,7 +71,6 @@ public:
COLLECTOR() COLLECTOR()
{ {
m_PreferredLayer = 0;
m_ScanTypes = 0; m_ScanTypes = 0;
} }
@ -80,19 +79,13 @@ public:
} }
void SetPreferredLayer( int aPreferredLayer )
{
m_PreferredLayer = aPreferredLayer;
}
/** /**
* Function GetCount * Function GetCount
* returns the number of objects in the list * returns the number of objects in the list
*/ */
unsigned GetCount() const unsigned GetCount() const
{ {
return list.size(); return m_List.size();
} }
@ -102,7 +95,7 @@ public:
*/ */
void Empty() void Empty()
{ {
list.clear(); m_List.clear();
} }
@ -113,7 +106,7 @@ public:
*/ */
void Append( EDA_BaseStruct* item ) void Append( EDA_BaseStruct* item )
{ {
list.push_back( item ); m_List.push_back( item );
} }
@ -126,22 +119,23 @@ public:
EDA_BaseStruct* operator[]( int ndx ) const EDA_BaseStruct* operator[]( int ndx ) const
{ {
if( (unsigned)ndx < GetCount() ) if( (unsigned)ndx < GetCount() )
return list[ ndx ]; return m_List[ ndx ];
return NULL; return NULL;
} }
/**
* Function SetScanTypes
* records the list of KICAD_T types to consider for collection by
* the Inspect() function.
* @param scanTypes An array of KICAD_T, terminated by EOT. No copy is
* is made of this array (so cannot come from caller's stack).
*/
void SetScanTypes( const KICAD_T* scanTypes ) void SetScanTypes( const KICAD_T* scanTypes )
{ {
m_ScanTypes = scanTypes; m_ScanTypes = scanTypes;
} }
wxPoint GetRefPos() const { return m_RefPos; }
void SetRefPos( const wxPoint& arefPos )
{
m_RefPos = arefPos;
}
void SetTimeNow() void SetTimeNow()
{ {
m_TimeAtCollection = GetTimeStamp(); m_TimeAtCollection = GetTimeStamp();
@ -151,6 +145,12 @@ public:
return m_TimeAtCollection; return m_TimeAtCollection;
} }
void SetRefPos( const wxPoint& aRefPos ) { m_RefPos = aRefPos; }
const wxPoint& GetRefPos() const { return m_RefPos; }
void SetBoundingBox( const EDA_Rect& aRefBox ) { m_RefBox = aRefBox; }
const EDA_Rect& GetBoundingBox() const { return m_RefBox; }
/** /**
* Function IsSimilarPointAndTime * Function IsSimilarPointAndTime
@ -196,28 +196,56 @@ public:
/** /**
* Function Scan * Function Collect
* scans a BOARD using this class's Inspector method, which does the collection. * scans an EDA_BaseStruct using this class's Inspector method, which does
* @param board A BOARD to scan. * the collection.
* @param refPos A wxPoint to use in hit-testing. * @param container An EDA_BaseStruct to scan, including those items it contains.
* @param aRefPos A wxPoint to use in hit-testing.
* *
* example implementation, in derived class: * example implementation, in derived class:
* *
virtual void Scan( BOARD* board, const wxPoint& refPos ) virtual void Collect( EDA_BaseStruct* container, const wxPoint& aRefPos )
{ {
example implementation: example implementation:
SetRefPos( refPos ); // remember where the snapshot was taken from SetRefPos( aRefPos ); // remember where the snapshot was taken from
Empty(); // empty the collection Empty(); // empty the collection
// visit the board with the INSPECTOR (me). // visit the board with the INSPECTOR (me).
board->Visit( this, // INSPECTOR* inspector container->Visit( this, // INSPECTOR* inspector
NULL, // const void* testData, NULL, // const void* testData,
m_ScanTypes); m_ScanTypes);
SetTimeNow(); // when it was taken SetTimeNow(); // when it was taken
} }
*/ */
/**
* Function Collect
* scans an EDA_BaseStruct using this class's Inspector method, which does
* the collection.
* @param container An EDA_BaseStruct to scan, including those items it contains.
* @param aRefBox An EDA_Rect to use in bounds-testing.
*
* example implementation, in derived class:
*
virtual void Collect( EDA_BaseStruct* container, const EDA_Rect& aRefBox )
{
example implementation:
SetBoundingBox( aRefBox ); // pass box to Inspect()
Empty(); // empty the collection
// visit the board with the INSPECTOR (me).
container->Visit( this, // INSPECTOR* inspector
NULL, // const void* testData,
m_ScanTypes);
SetTimeNow(); // when it was taken
}
*/
}; };
#endif // COLLECTOR_H #endif // COLLECTOR_H

View File

@ -175,14 +175,14 @@ public:
int m_RatsnestColor; // Ratsnest color int m_RatsnestColor; // Ratsnest color
public: public:
EDA_BoardDesignSettings( void ); EDA_BoardDesignSettings();
/** /**
* Function GetVisibleLayers * Function GetVisibleLayers
* returns a bit-map of all the layers that are visible. * returns a bit-map of all the layers that are visible.
* @return int - the visible layers in bit-mapped form. * @return int - the visible layers in bit-mapped form.
*/ */
int GetVisibleLayers(); int GetVisibleLayers() const;
}; };
@ -226,20 +226,20 @@ public:
* de delimitation de la zone en cours de trace */ * de delimitation de la zone en cours de trace */
BOARD( EDA_BaseStruct* StructFather, WinEDA_BasePcbFrame* frame ); BOARD( EDA_BaseStruct* StructFather, WinEDA_BasePcbFrame* frame );
~BOARD( void ); ~BOARD();
/* supprime du chainage la structure Struct */ /* supprime du chainage la structure Struct */
void UnLink( void ); void UnLink();
/* Routines de calcul des nombres de segments pistes et zones */ /* Routines de calcul des nombres de segments pistes et zones */
int GetNumSegmTrack( void ); int GetNumSegmTrack();
int GetNumSegmZone( void ); int GetNumSegmZone();
int GetNumNoconnect( void ); // retourne le nombre de connexions manquantes int GetNumNoconnect(); // retourne le nombre de connexions manquantes
int GetNumRatsnests( void ); // retourne le nombre de chevelus int GetNumRatsnests(); // retourne le nombre de chevelus
int GetNumNodes( void ); // retourne le nombre de pads a netcode > 0 int GetNumNodes(); // retourne le nombre de pads a netcode > 0
// Calcul du rectangle d'encadrement: // Calcul du rectangle d'encadrement:
bool ComputeBoundaryBox( void ); bool ComputeBoundaryBox();
/** /**
@ -247,7 +247,7 @@ public:
* has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel. * about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct. * Is virtual from EDA_BaseStruct.
* @param frame A WinEDA_BasePcbFrame in which to print status information. * @param frame A WinEDA_DrawFrame in which to print status information.
*/ */
void Display_Infos( WinEDA_DrawFrame* frame ); void Display_Infos( WinEDA_DrawFrame* frame );
@ -284,10 +284,10 @@ public:
/** /**
* Function FindNet * Function FindNet
* searches for a net with the given netcode. * searches for a net with the given netcode.
* @param anetcode A netcode to search for. * @param aNetcode A netcode to search for.
* @return EQUIPOT* - the net or NULL if not found. * @return EQUIPOT* - the net or NULL if not found.
*/ */
EQUIPOT* FindNet( int anetcode ); EQUIPOT* FindNet( int aNetcode );
#if defined(DEBUG) #if defined(DEBUG)
@ -324,12 +324,12 @@ public:
public: public:
PCB_SCREEN( int idscreen ); PCB_SCREEN( int idscreen );
~PCB_SCREEN( void ); ~PCB_SCREEN();
PCB_SCREEN* Next( void ) { return (PCB_SCREEN*) Pnext; } PCB_SCREEN* Next() { return (PCB_SCREEN*) Pnext; }
void Init( void ); void Init();
void SetNextZoom( void ); void SetNextZoom();
void SetPreviousZoom( void ); void SetPreviousZoom();
void SetLastZoom( void ); void SetLastZoom();
}; };
/***************************/ /***************************/
@ -360,14 +360,14 @@ public:
public: public:
DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT ); DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT );
~DRAWSEGMENT( void ); ~DRAWSEGMENT();
// Read/write data // Read/write data
bool WriteDrawSegmentDescr( FILE* File ); bool WriteDrawSegmentDescr( FILE* File );
bool ReadDrawSegmentDescr( FILE* File, int* LineNum ); bool ReadDrawSegmentDescr( FILE* File, int* LineNum );
/* supprime du chainage la structure Struct */ /* supprime du chainage la structure Struct */
void UnLink( void ); void UnLink();
void Copy( DRAWSEGMENT* source ); void Copy( DRAWSEGMENT* source );
@ -419,7 +419,7 @@ class EDGE_ZONE : public DRAWSEGMENT
public: public:
EDGE_ZONE( BOARD_ITEM* StructFather ); EDGE_ZONE( BOARD_ITEM* StructFather );
EDGE_ZONE( const EDGE_ZONE& edgezone ); EDGE_ZONE( const EDGE_ZONE& edgezone );
~EDGE_ZONE( void ); ~EDGE_ZONE();
}; };
@ -439,8 +439,8 @@ public:
public: public:
MARQUEUR( BOARD_ITEM* StructFather ); MARQUEUR( BOARD_ITEM* StructFather );
~MARQUEUR( void ); ~MARQUEUR();
void UnLink( void ); void UnLink();
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode ); void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode );
}; };
@ -471,7 +471,7 @@ public:
bool ContrastModeDisplay; bool ContrastModeDisplay;
public: public:
DISPLAY_OPTIONS( void ); DISPLAY_OPTIONS();
}; };

View File

@ -96,7 +96,7 @@ class WinEDA3D_DrawFrame;
class PARAM_CFG_BASE; class PARAM_CFG_BASE;
class Ki_PageDescr; class Ki_PageDescr;
class Ki_HotkeyInfo; class Ki_HotkeyInfo;
class GENERALCOLLECTOR; class GENERAL_COLLECTOR;
enum id_librarytype { enum id_librarytype {
@ -374,7 +374,7 @@ private:
#if defined(DEBUG) #if defined(DEBUG)
protected: protected:
GENERALCOLLECTOR* m_Collector; GENERAL_COLLECTOR* m_Collector;
#endif #endif

View File

@ -1288,7 +1288,8 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
{ {
next_track = track->Next(); next_track = track->Next();
if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) if( IsSegmentInBox( GetScreen()->BlockLocate, track ) )
{ /* la piste est ici bonne a etre deplacee */ {
/* la piste est ici bonne a etre deplacee */
new_track = new TRACK( m_Pcb ); new_track = new TRACK( m_Pcb );
new_track = track->Copy( 1 ); new_track = track->Copy( 1 );
new_track->Insert( m_Pcb, NULL ); new_track->Insert( m_Pcb, NULL );

View File

@ -46,12 +46,12 @@ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
/***************/ /***************/
/* Destructeur */ /* Destructeur */
/***************/ /***************/
BOARD::~BOARD( void ) BOARD::~BOARD()
{ {
} }
void BOARD::UnLink( void ) void BOARD::UnLink()
{ {
/* Modification du chainage arriere */ /* Modification du chainage arriere */
if( Pback ) if( Pback )
@ -75,7 +75,7 @@ void BOARD::UnLink( void )
/* Routines de calcul des nombres de segments pistes et zones */ /* Routines de calcul des nombres de segments pistes et zones */
int BOARD::GetNumSegmTrack( void ) int BOARD::GetNumSegmTrack()
{ {
TRACK* CurTrack = m_Track; TRACK* CurTrack = m_Track;
int ii = 0; int ii = 0;
@ -88,7 +88,7 @@ int BOARD::GetNumSegmTrack( void )
} }
int BOARD::GetNumSegmZone( void ) int BOARD::GetNumSegmZone()
{ {
TRACK* CurTrack = m_Zone; TRACK* CurTrack = m_Zone;
int ii = 0; int ii = 0;
@ -102,28 +102,28 @@ int BOARD::GetNumSegmZone( void )
// retourne le nombre de connexions manquantes // retourne le nombre de connexions manquantes
int BOARD::GetNumNoconnect( void ) int BOARD::GetNumNoconnect()
{ {
return m_NbNoconnect; return m_NbNoconnect;
} }
// retourne le nombre de chevelus // retourne le nombre de chevelus
int BOARD::GetNumRatsnests( void ) int BOARD::GetNumRatsnests()
{ {
return m_NbLinks; return m_NbLinks;
} }
// retourne le nombre de pads a netcode > 0 // retourne le nombre de pads a netcode > 0
int BOARD::GetNumNodes( void ) int BOARD::GetNumNodes()
{ {
return m_NbNodes; return m_NbNodes;
} }
/***********************************/ /***********************************/
bool BOARD::ComputeBoundaryBox( void ) bool BOARD::ComputeBoundaryBox()
/***********************************/ /***********************************/
/* Determine le rectangle d'encadrement du pcb /* Determine le rectangle d'encadrement du pcb
@ -313,7 +313,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T* p = scanTypes; const KICAD_T* p = scanTypes;
bool done=false; bool done=false;
#if defined(DEBUG) #if 0 && defined(DEBUG)
std::cout << GetClass().mb_str() << ' '; std::cout << GetClass().mb_str() << ' ';
#endif #endif
@ -381,6 +381,9 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
; ;
break; break;
#if 0 // both these are on same list, so we must scan it twice in order to get VIA priority,
// using new #else code below.
// @todo: consider why we are not using separte lists for TRACKs and SEGVIAs.
case TYPEVIA: case TYPEVIA:
case TYPETRACK: case TYPETRACK:
result = IterateForward( m_Track, inspector, testData, p ); result = IterateForward( m_Track, inspector, testData, p );
@ -397,6 +400,17 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
break; break;
} }
break; break;
#else
case TYPEVIA:
result = IterateForward( m_Track, inspector, testData, p );
++p;
break;
case TYPETRACK:
result = IterateForward( m_Track, inspector, testData, p );
++p;
break;
#endif
case PCB_EQUIPOT_STRUCT_TYPE: case PCB_EQUIPOT_STRUCT_TYPE:
result = IterateForward( m_Equipots, inspector, testData, p ); result = IterateForward( m_Equipots, inspector, testData, p );
@ -586,4 +600,48 @@ void BOARD::Show( int nestLevel, std::ostream& os )
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
/* wrote this before discovering ReturnLayerName()
const char* BOARD::ShowLayer( int aLayer )
{
const char* rs;
switch( aLayer )
{
case LAYER_CUIVRE_N: rs = "cu"; break;
case LAYER_N_2: rs = "layer2"; break;
case LAYER_N_3: rs = "layer3"; break;
case LAYER_N_4: rs = "layer4"; break;
case LAYER_N_5: rs = "layer5"; break;
case LAYER_N_6: rs = "layer6"; break;
case LAYER_N_7: rs = "layer7"; break;
case LAYER_N_8: rs = "layer8"; break;
case LAYER_N_9: rs = "layer9"; break;
case LAYER_N_10: rs = "layer10"; break;
case LAYER_N_11: rs = "layer11"; break;
case LAYER_N_12: rs = "layer12"; break;
case LAYER_N_13: rs = "layer13"; break;
case LAYER_N_14: rs = "layer14"; break;
case LAYER_N_15: rs = "layer15"; break;
case LAYER_CMP_N: rs = "cmp"; break;
case ADHESIVE_N_CU: rs = "cu/adhesive"; break;
case ADHESIVE_N_CMP: rs = "cmp/adhesive"; break;
case SOLDERPASTE_N_CU: rs = "cu/sldrpaste"; break;
case SOLDERPASTE_N_CMP: rs = "cmp/sldrpaste"; break;
case SILKSCREEN_N_CU: rs = "cu/silkscreen"; break;
case SILKSCREEN_N_CMP: rs = "cmp/silkscreen"; break;
case SOLDERMASK_N_CU: rs = "cu/sldrmask"; break;
case SOLDERMASK_N_CMP: rs = "cmp/sldrmask"; break;
case DRAW_N: rs = "drawing"; break;
case COMMENT_N: rs = "comment"; break;
case ECO1_N: rs = "eco_1"; break;
case ECO2_N: rs = "eco_2"; break;
case EDGE_N: rs = "edge"; break;
default: rs = "???"; break;
}
return rs;
}
*/
#endif #endif

View File

@ -47,7 +47,7 @@ public:
* has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel. * about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct. * Is virtual from EDA_BaseStruct.
* @param frame A WinEDA_BasePcbFrame in which to print status information. * @param frame A WinEDA_DrawFrame in which to print status information.
*/ */
void Display_Infos( WinEDA_DrawFrame* frame ); void Display_Infos( WinEDA_DrawFrame* frame );

View File

@ -52,7 +52,7 @@ public:
* has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel. * about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct. * Is virtual from EDA_BaseStruct.
* @param frame A WinEDA_BasePcbFrame in which to print status information. * @param frame A WinEDA_DrawFrame in which to print status information.
*/ */
void Display_Infos( WinEDA_DrawFrame* frame ); void Display_Infos( WinEDA_DrawFrame* frame );

View File

@ -1077,7 +1077,7 @@ void MODULE::SetRectangleExinscrit( void )
/*******************************************************/ /*******************************************************/
void MODULE::Display_Infos( WinEDA_BasePcbFrame* frame ) void MODULE::Display_Infos( WinEDA_DrawFrame* frame )
/*******************************************************/ /*******************************************************/
{ {
int nbpad; int nbpad;
@ -1183,7 +1183,7 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T* p = scanTypes; const KICAD_T* p = scanTypes;
bool done = false; bool done = false;
#if defined(DEBUG) #if 0 && defined(DEBUG)
std::cout << GetClass().mb_str() << ' '; std::cout << GetClass().mb_str() << ' ';
#endif #endif
@ -1256,6 +1256,7 @@ void MODULE::Show( int nestLevel, std::ostream& os )
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().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() << '"' <<
" layer=\"" << ReturnPcbLayerName(m_Layer,true,false).mb_str() << '"' <<
">\n"; ">\n";
NestedSpace( nestLevel+1, os ) << NestedSpace( nestLevel+1, os ) <<

View File

@ -134,9 +134,9 @@ public:
* Function Display_Infos * Function Display_Infos
* has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel. * about this object into the frame's message panel.
* @param frame A WinEDA_BasePcbFrame in which to print status information. * @param frame A WinEDA_DrawFrame in which to print status information.
*/ */
void Display_Infos( WinEDA_BasePcbFrame* frame ); void Display_Infos( WinEDA_DrawFrame* frame );
/** /**

View File

@ -958,6 +958,13 @@ void D_PAD::Display_Infos( WinEDA_DrawFrame* frame )
} }
// see class_pad.h
bool D_PAD::IsOnLayer( int aLayer ) const
{
return (1<<aLayer) & m_Masque_Layer;
}
/** /**
* Function HitTest * Function HitTest
* tests if the given wxPoint is within the bounds of this object. * tests if the given wxPoint is within the bounds of this object.

View File

@ -93,10 +93,22 @@ public:
* has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel. * about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct. * Is virtual from EDA_BaseStruct.
* @param frame A WinEDA_BasePcbFrame in which to print status information. * @param frame A WinEDA_DrawFrame in which to print status information.
*/ */
void Display_Infos( WinEDA_DrawFrame* frame ); void Display_Infos( WinEDA_DrawFrame* frame );
/**
* Function IsOnLayer
* tests to see if this object is on the given layer. Is virtual so
* objects like D_PAD, which reside on multiple layers can do their own
* form of testing.
* @param aLayer The layer to test for.
* @return bool - true if on given layer, else false.
*/
bool IsOnLayer( int aLayer ) const;
/** /**
* Function HitTest * Function HitTest
* tests if the given wxPoint is within the bounds of this object. * tests if the given wxPoint is within the bounds of this object.

View File

@ -32,7 +32,7 @@ public:
* has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel. * about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct. * Is virtual from EDA_BaseStruct.
* @param frame A WinEDA_BasePcbFrame in which to print status information. * @param frame A WinEDA_DrawFrame in which to print status information.
*/ */
void Display_Infos( WinEDA_DrawFrame* frame ); void Display_Infos( WinEDA_DrawFrame* frame );

View File

@ -61,7 +61,7 @@ public:
* has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel. * about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct. * Is virtual from EDA_BaseStruct.
* @param frame A WinEDA_BasePcbFrame in which to print status information. * @param frame A WinEDA_DrawFrame in which to print status information.
*/ */
void Display_Infos( WinEDA_DrawFrame* frame ); void Display_Infos( WinEDA_DrawFrame* frame );

View File

@ -53,13 +53,14 @@ SEGVIA::SEGVIA( BOARD_ITEM* StructFather ) :
TRACK::TRACK( const TRACK& Source ) : TRACK::TRACK( const TRACK& Source ) :
BOARD_ITEM( (const BOARD_ITEM&) Source ) BOARD_ITEM( (const BOARD_ITEM&) Source )
{ {
m_StructType = Source.m_StructType; // m_StructType = Source.m_StructType;
// m_Layer = Source.m_Layer;
m_Shape = Source.m_Shape; m_Shape = Source.m_Shape;
m_NetCode = Source.m_NetCode; m_NetCode = Source.m_NetCode;
m_Flags = Source.m_Flags; m_Flags = Source.m_Flags;
m_TimeStamp = Source.m_TimeStamp; m_TimeStamp = Source.m_TimeStamp;
SetStatus( Source.ReturnStatus() ); SetStatus( Source.ReturnStatus() );
m_Layer = Source.m_Layer;
m_Start = Source.m_Start; m_Start = Source.m_Start;
m_End = Source.m_End; m_End = Source.m_End;
m_Width = Source.m_Width; m_Width = Source.m_Width;
@ -70,7 +71,7 @@ TRACK::TRACK( const TRACK& Source ) :
/***********************/ /***********************/
bool TRACK::IsNull( void ) bool TRACK::IsNull()
/***********************/ /***********************/
// return TRUE if segment length = 0 // return TRUE if segment length = 0
@ -134,36 +135,56 @@ int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
} }
/******************************************/ // see class_track.h
bool SEGVIA::IsViaOnLayer( int layer_number ) // SEGVIA and SEGZONE inherit this version
/******************************************/ SEARCH_RESULT TRACK::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] )
{
KICAD_T stype = *scanTypes;
/* Retoune TRUE si Via sur layer layer_number #if 0 && defined(DEBUG)
*/ std::cout << GetClass().mb_str() << ' ';
#endif
// If caller wants to inspect my type
if( stype == m_StructType )
{
if( SEARCH_QUIT == inspector->Inspect( this, testData ) )
return SEARCH_QUIT;
}
return SEARCH_CONTINUE;
}
// see class_track.h
bool SEGVIA::IsOnLayer( int layer_number ) const
{ {
int via_type = Shape(); int via_type = Shape();
if( via_type == VIA_NORMALE ) if( via_type == VIA_NORMALE )
{ {
if( layer_number <= LAYER_CMP_N ) if( layer_number <= LAYER_CMP_N )
return TRUE; return true;
else else
return FALSE; return false;
} }
// VIA_BORGNE ou VIA_ENTERREE: // VIA_BORGNE ou VIA_ENTERREE:
int bottom_layer, top_layer; int bottom_layer, top_layer;
ReturnLayerPair( &top_layer, &bottom_layer ); ReturnLayerPair( &top_layer, &bottom_layer );
if( (bottom_layer <= layer_number) && (top_layer >= layer_number) )
return TRUE; if( bottom_layer <= layer_number && top_layer >= layer_number )
return true;
else else
return FALSE; return false;
} }
/***********************************/ /***********************************/
int TRACK::ReturnMaskLayer( void ) int TRACK::ReturnMaskLayer()
/***********************************/ /***********************************/
/* Retourne le masque (liste bit a bit ) des couches occupees par le segment /* Retourne le masque (liste bit a bit ) des couches occupees par le segment
@ -217,7 +238,7 @@ void SEGVIA::SetLayerPair( int top_layer, int bottom_layer )
/***************************************************************/ /***************************************************************/
void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const
/***************************************************************/ /***************************************************************/
/* Retourne les 2 couches limitant la via /* Retourne les 2 couches limitant la via
@ -239,7 +260,7 @@ void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer )
/* supprime du chainage la structure Struct /* supprime du chainage la structure Struct
* les structures arrieres et avant sont chainees directement * les structures arrieres et avant sont chainees directement
*/ */
void TRACK::UnLink( void ) void TRACK::UnLink()
{ {
/* Modification du chainage arriere */ /* Modification du chainage arriere */
if( Pback ) if( Pback )
@ -503,15 +524,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode )
if( DisplayOpt.ContrastModeDisplay ) if( DisplayOpt.ContrastModeDisplay )
{ {
if( m_StructType == TYPEVIA ) if( !IsOnLayer( curr_layer ) )
{
if( !( (SEGVIA*) this )->IsViaOnLayer( curr_layer ) )
{
color &= ~MASKCOLOR;
color |= DARKDARKGRAY;
}
}
else if( m_Layer != curr_layer )
{ {
color &= ~MASKCOLOR; color &= ~MASKCOLOR;
color |= DARKDARKGRAY; color |= DARKDARKGRAY;

View File

@ -49,7 +49,7 @@ public:
/* supprime du chainage la structure Struct */ /* supprime du chainage la structure Struct */
void UnLink( void ); void UnLink();
// Read/write data // Read/write data
bool WriteTrackDescr( FILE* File ); bool WriteTrackDescr( FILE* File );
@ -74,11 +74,11 @@ public:
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode ); void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode );
/* divers */ /* divers */
int Shape( void ) { return m_Shape & 0xFF; } int Shape() const { return m_Shape & 0xFF; }
int ReturnMaskLayer( void ); int ReturnMaskLayer();
int IsPointOnEnds( const wxPoint& point, int min_dist = 0 ); int IsPointOnEnds( const wxPoint& point, int min_dist = 0 );
bool IsNull( void ); // return TRUE if segment lenght = 0 bool IsNull(); // return TRUE if segment lenght = 0
/** /**
@ -86,11 +86,28 @@ public:
* has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel. * about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct. * Is virtual from EDA_BaseStruct.
* @param frame A WinEDA_BasePcbFrame in which to print status information. * @param frame A WinEDA_DrawFrame in which to print status information.
*/ */
void Display_Infos( WinEDA_DrawFrame* frame ); void Display_Infos( WinEDA_DrawFrame* frame );
/**
* Function Visit
* is re-implemented here because TRACKs and SEGVIAs are in the same list
* within BOARD. If that were not true, then we could inherit the
* version from EDA_BaseStruct. This one does not iterate through scanTypes
* but only looks at the first item in the list.
* @param inspector An INSPECTOR instance to use in the inspection.
* @param testData Arbitrary data used by the inspector.
* @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, and determined by the inspector.
*/
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] );
/** /**
* Function HitTest * Function HitTest
* tests if the given wxPoint is within the bounds of this object. * tests if the given wxPoint is within the bounds of this object.
@ -146,9 +163,19 @@ class SEGVIA : public TRACK
{ {
public: public:
SEGVIA( BOARD_ITEM* StructFather ); SEGVIA( BOARD_ITEM* StructFather );
bool IsViaOnLayer( int layer );
/**
* Function IsOnLayer
* tests to see if this object is on the given layer. Is virtual
* from BOARD_ITEM. Tests the starting and ending range of layers for the
* via.
* @param aLayer The layer to test for.
* @return bool - true if on given layer, else false.
*/
bool IsOnLayer( int aLayer ) const;
void SetLayerPair( int top_layer, int bottom_layer ); void SetLayerPair( int top_layer, int bottom_layer );
void ReturnLayerPair( int* top_layer, int* bottom_layer ); void ReturnLayerPair( int* top_layer, int* bottom_layer ) const;
#if defined(DEBUG) #if defined(DEBUG)
/** /**

View File

@ -432,7 +432,7 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings( void )
// see pcbstruct.h // see pcbstruct.h
int EDA_BoardDesignSettings::GetVisibleLayers() int EDA_BoardDesignSettings::GetVisibleLayers() const
{ {
int layerMask = 0; int layerMask = 0;

View File

@ -34,7 +34,7 @@
// see collectors.h // see collectors.h
const KICAD_T GENERALCOLLECTOR::AllBoardItems[] = { const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
TYPETEXTE, TYPETEXTE,
TYPEDRAWSEGMENT, TYPEDRAWSEGMENT,
TYPECOTATION, TYPECOTATION,
@ -59,7 +59,7 @@ const KICAD_T GENERALCOLLECTOR::AllBoardItems[] = {
* @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;
*/ */
SEARCH_RESULT GENERALCOLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* notUsed ) SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* notUsed )
{ {
BOARD_ITEM* item = (BOARD_ITEM*) testItem; BOARD_ITEM* item = (BOARD_ITEM*) testItem;
@ -94,7 +94,12 @@ SEARCH_RESULT GENERALCOLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* n
} }
break; break;
case TYPEMODULE: case TYPEMODULE:
MODULE* m;
m = (MODULE*) item;
if( m->GetReference() == wxT("L1") )
{
breakhere++; breakhere++;
}
break; break;
default: default:
breakhere++; breakhere++;
@ -102,17 +107,68 @@ SEARCH_RESULT GENERALCOLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* n
} }
#endif #endif
switch( item->m_StructType )
{
case TYPEPAD:
case TYPEVIA:
case TYPETRACK:
case TYPETEXTE:
case TYPEDRAWSEGMENT:
case TYPECOTATION:
case TYPETEXTEMODULE:
case TYPEMODULE:
#if 1
/*
int m_PreferredLayer; x
bool m_IgnorePreferredLayer
int m_LayerVisible; x
bool m_IgnoreNonVisibleLayers;
int m_LayerLocked; x
bool m_IgnoreLockedLayers;
bool m_IgnoreLockedItems; x
bool m_IncludeSecondary;
*/
if( item->IsOnLayer( m_Guide->GetPreferredLayer() ) || m_Guide->IgnorePreferredLayer() )
{
int layer = item->GetLayer();
if( m_Guide->IsLayerVisible( layer ) || !m_Guide->IgnoreNonVisibleLayers() )
{
if( !m_Guide->IsLayerLocked(layer) || !m_Guide->IgnoreLockedLayers() )
{
if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
{
if( item->HitTest( m_RefPos ) )
{
Append( item );
goto exit;
}
}
}
}
}
if( m_Guide->IncludeSecondary() )
{
// for now, "secondary" means "tolerate any layer". It has
// no effect on other criteria, since there is a separate "ignore" control for
// those in the COLLECTORS_GUIDE
int layer = item->GetLayer();
if( m_Guide->IsLayerVisible( layer ) || !m_Guide->IgnoreNonVisibleLayers() )
{
if( !m_Guide->IsLayerLocked(layer) || !m_Guide->IgnoreLockedLayers() )
{
if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
{
if( item->HitTest( m_RefPos ) )
{
Append2nd( item );
goto exit;
}
}
}
}
}
#else
// The primary search criteria: // The primary search criteria:
if( item->IsOnLayer( m_PreferredLayer ) ) if( item->IsOnLayer( m_PreferredLayer ) )
{ {
@ -131,18 +187,16 @@ SEARCH_RESULT GENERALCOLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* n
if( item->HitTest( m_RefPos ) ) if( item->HitTest( m_RefPos ) )
Append2nd( item ); Append2nd( item );
} }
break; #endif
default: exit:
printf("OOPS, not expecting class type %d\n", item->m_StructType ); return SEARCH_CONTINUE; // always when collecting
}
return SEARCH_CONTINUE;
} }
// see collectors.h // see collectors.h
void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos, /*
void GENERAL_COLLECTOR::Collect( BOARD* board, const wxPoint& refPos,
int aPreferredLayer, int aLayerMask ) int aPreferredLayer, int aLayerMask )
{ {
Empty(); // empty the collection, primary criteria list Empty(); // empty the collection, primary criteria list
@ -151,9 +205,7 @@ void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos,
SetPreferredLayer( aPreferredLayer ); SetPreferredLayer( aPreferredLayer );
SetLayerMask( aLayerMask ); SetLayerMask( aLayerMask );
/* remember where the snapshot was taken from and pass refPos to // remember refPos, pass to Inspect()
the Inspect() function.
*/
SetRefPos( refPos ); SetRefPos( refPos );
#if defined(DEBUG) #if defined(DEBUG)
@ -173,25 +225,23 @@ void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos,
Empty2nd(); Empty2nd();
} }
*/
// see collectors.h // see collectors.h
void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos, void GENERAL_COLLECTOR::Collect( BOARD* board, const wxPoint& refPos,
const COLLECTORS_GUIDE& guide ) const COLLECTORS_GUIDE* guide )
{ {
Empty(); // empty the collection, primary criteria list Empty(); // empty the collection, primary criteria list
Empty2nd(); // empty the collection, secondary criteria list Empty2nd(); // empty the collection, secondary criteria list
// remember guide, pass it to Inspect()
SetGuide( guide );
// @todo: remember the guide here, pass it to Inspect() // remember where the snapshot was taken from and pass refPos to
// the Inspect() function.
/* remember where the snapshot was taken from and pass refPos to
the Inspect() function.
*/
SetRefPos( refPos ); SetRefPos( refPos );
// visit the board with the INSPECTOR (me). // visit the board with the INSPECTOR (me).
board->Visit( this, // INSPECTOR* inspector board->Visit( this, // INSPECTOR* inspector
NULL, // const void* testData, not used here NULL, // const void* testData, not used here
@ -199,14 +249,32 @@ void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos,
SetTimeNow(); // when snapshot was taken SetTimeNow(); // when snapshot was taken
// append 2nd list onto end of the first "list" // append 2nd list onto end of the first list
for( unsigned i=0; i<list2nd.size(); ++i ) for( unsigned i=0; i<m_List2nd.size(); ++i )
Append( list2nd[i] ); Append( m_List2nd[i] );
Empty2nd(); Empty2nd();
} }
/** is still inline
* Constructor GENERAL_COLLECTORS_GUIDE
* grabs stuff from global preferences and uses reasonable defaults.
* Add more constructors as needed.
GENERAL_COLLECTORS_GUIDE::GENERAL_COLLECTORS_GUIDE()
{
m_LayerLocked;
m_LayerVisible;
m_IgnoreLockedLayers;
m_IgnoreNonVisibleLayers;
m_PreferredLayer;
m_IgnoreLockedItems;
m_IncludeSecondary;
}
*/
#endif // DEBUG #endif // DEBUG
//EOF //EOF

View File

@ -32,14 +32,25 @@
#include "class_collector.h" #include "class_collector.h"
#include "pcbstruct.h" // LAYER_COUNT, layer defs
/** /**
* Class COLLECTORS_GUIDE * Class COLLECTORS_GUIDE
* is an abstract base class that may be passed to a GENERALCOLLECTOR, telling * is an abstract base class whose derivatives may be passed to a GENERALCOLLECTOR,
* it what should be collected (aside from HitTest()ing and KICAD_T scanTypes[], * telling GENERALCOLLECTOR what should be collected (aside from HitTest()ing
* information which are provided to the GENERALCOLLECTOR through attributes or * and KICAD_T scanTypes[], information which are provided to the GENERALCOLLECTOR
* arguments separately). * through attributes or arguments separately).
* <p>
* A justification for this class is to keep the structural storage details of
* the program's "global preferences" or "configuration options" out of
* GENERAL_COLLECTOR::Inspect(). This class carries all the necessary details
* in with it to the Inspect() call. The constructors or other functions of
* this class's derivatives are then the only place where knowledge of the
* specific structure of the global preference storage is needed. Thus,
* GENERAL_COLLECTOR::Inspect() can be kept as simple as possible, and insulated
* from changes in global preference storage (and even then it is
* not simple enough).
* <p> * <p>
* This class introduces the notion of layer locking. * This class introduces the notion of layer locking.
*/ */
@ -55,18 +66,6 @@ public:
*/ */
virtual bool IsLayerLocked( int layer ) const = 0; virtual bool IsLayerLocked( int layer ) const = 0;
/**
* Function IsCopperLayerVisible
* @return bool - true if the copper layer is visible.
*/
virtual bool IsCopperLayerVisible() const = 0;
/**
* Function IsComponentLayerVisible
* @return bool - true if the component layer is visible, else false.
*/
virtual bool IsComponentLayerVisible() const = 0;
/** /**
* Function IsLayerVisible * Function IsLayerVisible
* @return bool - true if the given layer is visible, else false. * @return bool - true if the given layer is visible, else false.
@ -75,7 +74,7 @@ public:
/** /**
* Function IgnoreLockedLayers * Function IgnoreLockedLayers
* @return bool - true if should ignored locked layers, else false. * @return bool - true if should ignore locked layers, else false.
*/ */
virtual bool IgnoreLockedLayers() const = 0; virtual bool IgnoreLockedLayers() const = 0;
@ -91,14 +90,42 @@ public:
*/ */
virtual int GetPreferredLayer() const = 0; virtual int GetPreferredLayer() const = 0;
/**
* Function IgnorePreferredLayer
* provides wildcard behavior regarding the preferred layer.
* @return bool - true if should ignore preferred layer, else false.
*/
virtual bool IgnorePreferredLayer() const = 0;
/**
* Function IgnoreLockedItems
* @return bool - true if should ignore locked items, else false.
*/
virtual bool IgnoreLockedItems() const = 0;
/**
* Function IncludeSecondary
* determines if the secondary criteria, or 2nd choice items should be
* included.
* @return bool - true if should include, else false.
*/
virtual bool IncludeSecondary() const = 0;
/**
* Function UseHitTesting
* @return bool - true if Inspect() should use BOARD_ITEM::HitTest()
* or false if Inspect() should use BOARD_ITEM::BoundsTest().
virtual bool UseHitTesting() const = 0;
*/
// more soon
}; };
/** /**
* Class GENERALCOLLECTOR * Class GENERAL_COLLECTOR
* is intended for use when the right click button is pressed, or when the * is intended for use when the right click button is pressed, or when the
* plain "arrow" tool is in effect. This class can be used by window classes * plain "arrow" tool is in effect. This class can be used by window classes
* such as WinEDA_PcbFrame. * such as WinEDA_PcbFrame.
@ -108,22 +135,22 @@ public:
* but can handle those concerns by the SetPreferredLayer() function and the * but can handle those concerns by the SetPreferredLayer() function and the
* SetLayerMask() fuction. * SetLayerMask() fuction.
*/ */
class GENERALCOLLECTOR : public COLLECTOR class GENERAL_COLLECTOR : public COLLECTOR
{ {
protected:
/** /**
* A place to hold collected objects which don't match precisely the search * A place to hold collected objects which don't match precisely the search
* criteria, but would be acceptable if nothing else is found. * criteria, but would be acceptable if nothing else is found.
* "2nd" choice, which will be appended to the end of COLLECTOR's prime * "2nd" choice, which will be appended to the end of COLLECTOR's prime
* "list" at the end of the search. * "list" at the end of the search.
*/ */
std::vector<BOARD_ITEM*> list2nd; std::vector<BOARD_ITEM*> m_List2nd;
/** /**
* A bit-mapped layer mask that defines any layers which are acceptable * Determines which items are to be collected by Inspect()
* on a secondary search criterion basis.
*/ */
int m_LayerMask; const COLLECTORS_GUIDE* m_Guide;
public: public:
@ -135,23 +162,30 @@ public:
/** /**
* Constructor GENERALCOLLECTOR * Constructor GENERALCOLLECTOR
*/ */
GENERALCOLLECTOR() GENERAL_COLLECTOR()
{ {
m_LayerMask = 0;
SetScanTypes( AllBoardItems ); SetScanTypes( AllBoardItems );
} }
void Empty2nd() void Empty2nd()
{ {
list2nd.clear(); m_List2nd.clear();
} }
void Append2nd( BOARD_ITEM* item ) void Append2nd( BOARD_ITEM* item )
{ {
list2nd.push_back( item ); m_List2nd.push_back( item );
} }
/**
* Function SetGuide
* records which COLLECTORS_GUIDE to used.
* @param aGuide Which guide to use in the collection.
*/
void SetGuide( const COLLECTORS_GUIDE* aGuide ) { m_Guide = aGuide; }
/** /**
* Function SetLayerMask * Function SetLayerMask
* takes a bit-mapped layer mask and records it. During the scan/search, * takes a bit-mapped layer mask and records it. During the scan/search,
@ -164,11 +198,11 @@ public:
* layers are acceptable. Caller must pay attention to which layers are * layers are acceptable. Caller must pay attention to which layers are
* visible, selected, etc. All those concerns are handled outside this * visible, selected, etc. All those concerns are handled outside this
* class, as stated in the class Philosophy above. * class, as stated in the class Philosophy above.
*/
void SetLayerMask( int aLayerMask ) void SetLayerMask( int aLayerMask )
{ {
m_LayerMask = aLayerMask; m_LayerMask = aLayerMask;
} }
*/
/** /**
@ -181,7 +215,7 @@ public:
BOARD_ITEM* operator[]( int ndx ) const BOARD_ITEM* operator[]( int ndx ) const
{ {
if( (unsigned)ndx < (unsigned)GetCount() ) if( (unsigned)ndx < (unsigned)GetCount() )
return (BOARD_ITEM*) list[ ndx ]; return (BOARD_ITEM*) m_List[ ndx ];
return NULL; return NULL;
} }
@ -200,25 +234,154 @@ public:
/** /**
* Function Scan * Function Collect
* scans a BOARD using this class's Inspector method, which does the collection. * scans a BOARD using this class's Inspector method, which does the collection.
* @param board A BOARD to scan. * @param board A BOARD to scan.
* @param refPos A wxPoint to use in hit-testing. * @param refPos A wxPoint to use in hit-testing.
* @param aPreferredLayer The layer meeting the primary search criterion. * @param aPreferredLayer The layer meeting the primary search criterion.
* @param aLayerMask The layers, in bit-mapped form, meeting the secondary search criterion. * @param aLayerMask The layers, in bit-mapped form, meeting the secondary search criterion.
void Collect( BOARD* board, const wxPoint& refPos, int aPreferredLayer, int aLayerMask );
*/ */
void Scan( BOARD* board, const wxPoint& refPos, int aPreferredLayer, int aLayerMask );
/** /**
* Function Scan * Function Collect
* scans a BOARD using this class's Inspector method, which does the collection. * scans a BOARD using this class's Inspector method, which does the collection.
* @param board A BOARD to scan. * @param aBoard A BOARD to scan.
* @param refPos A wxPoint to use in hit-testing. * @param aRefPos A wxPoint to use in hit-testing.
* @param guide The COLLECTORS_GUIDE to use in collecting items. * @param aGuide The COLLECTORS_GUIDE to use in collecting items.
*/ */
void Scan( BOARD* board, const wxPoint& refPos, const COLLECTORS_GUIDE& guide ); void Collect( BOARD* aBoard, const wxPoint& aRefPos, const COLLECTORS_GUIDE* aGuide );
}; };
/**
* Class GENERAL_COLLECTORS_GUIDE
* is a general implementation of a COLLECTORS_GUIDE. One of its constructors is
* entitled to grab information from the program's global preferences.
*/
class GENERAL_COLLECTORS_GUIDE : public COLLECTORS_GUIDE
{
private:
// the storage architecture here is not important, since this is only
// a carrier object and its functions are what is used, and data only indirectly.
int m_PreferredLayer;
bool m_IgnorePreferredLayer;
int m_LayerLocked; ///< bit-mapped layer locked bits
bool m_IgnoreLockedLayers;
int m_LayerVisible; ///< bit-mapped layer visible bits
bool m_IgnoreNonVisibleLayers;
bool m_IgnoreLockedItems;
bool m_IncludeSecondary;
public:
/**
* Constructor GENERAL_COLLECTORS_GUIDE
* grabs stuff from global preferences and uses reasonable defaults.
* Add more constructors as needed.
* @param settings The EDA_BoardDesignSettings to reference.
*/
GENERAL_COLLECTORS_GUIDE( const EDA_BoardDesignSettings* settings )
{
m_PreferredLayer = LAYER_CMP_N;
m_IgnorePreferredLayer = false;
m_LayerLocked = 0;
m_LayerVisible = settings->GetVisibleLayers();
m_IgnoreLockedLayers = true;
m_IgnoreNonVisibleLayers = true;
m_IgnoreLockedItems = true;
#if defined(USE_MATCH_LAYER)
m_IncludeSecondary = false;
#else
m_IncludeSecondary = true;
#endif
}
/**
* Function IsLayerLocked
* @return bool - true if the given layer is locked, else false.
*/
bool IsLayerLocked( int aLayer ) const { return (1<<aLayer) & m_LayerLocked; }
void SetLayerLocked( int aLayer, bool isLocked )
{
if( isLocked )
m_LayerLocked |= 1 << aLayer;
else
m_LayerLocked &= ~(1 << aLayer);
}
/**
* Function IsLayerVisible
* @return bool - true if the given layer is visible, else false.
*/
bool IsLayerVisible( int aLayer ) const { return (1<<aLayer) & m_LayerVisible; }
void SetLayerVisible( int aLayer, bool isVisible )
{
if( isVisible )
m_LayerVisible |= 1 << aLayer;
else
m_LayerVisible &= ~(1 << aLayer);
}
void SetLayerVisibleBits( int aLayerBits ) { m_LayerVisible = aLayerBits; }
/**
* Function IgnoreLockedLayers
* @return bool - true if should ignore locked layers, else false.
*/
bool IgnoreLockedLayers() const { return m_IgnoreLockedLayers; }
void SetIgnoreLockedLayers( bool ignore ) { m_IgnoreLockedLayers = ignore; }
/**
* Function IgnoredNonVisibleLayers
* @return bool - true if should ignore non-visible layers, else false.
*/
bool IgnoreNonVisibleLayers() const { return m_IgnoreNonVisibleLayers; }
void SetIgnoreNonVisibleLayers( bool ignore ) { m_IgnoreLockedLayers = ignore; }
/**
* Function GetPreferredLayer
* @return int - the preferred layer for HitTest()ing.
*/
int GetPreferredLayer() const { return m_PreferredLayer; }
void SetPreferredLayer( int aLayer ) { m_PreferredLayer = aLayer; }
/**
* Function IgnorePreferredLayer
* provides wildcard behavior regarding the preferred layer.
* @return bool - true if should ignore preferred layer, else false.
*/
bool IgnorePreferredLayer() const { return m_IgnorePreferredLayer; }
void SetIgnorePreferredLayer( bool ignore ) { m_IgnorePreferredLayer = ignore; }
/**
* Function IgnoreLockedItems
* @return bool - true if should ignore locked items, else false.
*/
bool IgnoreLockedItems() const { return m_IgnoreLockedItems; }
void SetIgnoreLockedItems( bool ignore ) { m_IgnoreLockedItems = ignore; }
/**
* Function IncludeSecondary
* determines if the secondary criteria, or 2nd choice items should be
* included.
* @return bool - true if should include, else false.
*/
bool IncludeSecondary() const { return m_IncludeSecondary; }
void SetIncludeSecondary( bool include ) { m_IncludeSecondary = include; }
};
#endif // COLLECTORS_H #endif // COLLECTORS_H

View File

@ -130,16 +130,15 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay()
#if defined(DEBUG) #if defined(DEBUG)
// test scaffolding for Scan(): // test scaffolding for Collect():
m_Collector->Scan( m_Pcb, GENERAL_COLLECTORS_GUIDE guide( m_Pcb->m_BoardSettings );
GetScreen()->RefPos(true),
// these two are inadequate, because the layer support guide.SetIgnoreLockedItems( false );
// in Kicad is not elegant or easily understood. guide.SetPreferredLayer( GetScreen()->m_Active_Layer );
// The final solution will be a new class COLLECTORS_GUIDE!
GetScreen()->m_Active_Layer, m_Collector->Collect( m_Pcb,
g_DesignSettings.GetVisibleLayers() GetScreen()->RefPos(true),
); &guide );
// use only the first one collected for now. // use only the first one collected for now.
item = (*m_Collector)[0]; // grab first one, may be NULL item = (*m_Collector)[0]; // grab first one, may be NULL
@ -150,7 +149,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay()
{ {
item->Display_Infos( this ); item->Display_Infos( this );
// debugging: print out the collected items, showing their order too. // debugging: print out the collected items, showing their priority order too.
for( unsigned i=0; i<m_Collector->GetCount(); ++i ) for( unsigned i=0; i<m_Collector->GetCount(); ++i )
(*m_Collector)[i]->Show( 0, std::cout ); (*m_Collector)[i]->Show( 0, std::cout );
} }
@ -170,7 +169,6 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay()
void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
/*****************************************************************/ /*****************************************************************/
{ {
int ll;
wxSize delta; wxSize delta;
int zoom = GetScreen()->GetZoom(); int zoom = GetScreen()->GetZoom();
wxPoint curpos, oldpos; wxPoint curpos, oldpos;

View File

@ -228,7 +228,8 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
Via->SetLayer( 0x0F ); Via->SetLayer( 0x0F );
if( Drc_On &&( Drc( this, DC, Via, m_Pcb->m_Track, 1 ) == BAD_DRC ) ) if( Drc_On &&( Drc( this, DC, Via, m_Pcb->m_Track, 1 ) == BAD_DRC ) )
{ /* Via impossible a placer ici */ {
/* Via impossible a placer ici */
delete Via; delete Via;
GetScreen()->m_Active_Layer = g_CurrentTrackSegment->GetLayer(); GetScreen()->m_Active_Layer = g_CurrentTrackSegment->GetLayer();
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
@ -245,8 +246,10 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
g_TrackSegmentCount++; g_TrackSegmentCount++;
g_CurrentTrackSegment->Pback = Via; g_CurrentTrackSegment->Pback = Via;
Via->Pnext = g_CurrentTrackSegment; Via->Pnext = g_CurrentTrackSegment;
if( g_TwoSegmentTrackBuild ) if( g_TwoSegmentTrackBuild )
{ // Create a second segment (we must have 2 track segments to adjust) {
// Create a second segment (we must have 2 track segments to adjust)
TRACK* track = g_CurrentTrackSegment; TRACK* track = g_CurrentTrackSegment;
g_CurrentTrackSegment = new TRACK( *track ); g_CurrentTrackSegment = new TRACK( *track );
g_TrackSegmentCount++; g_TrackSegmentCount++;

View File

@ -114,6 +114,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
if( LockPoint->m_StructType == TYPEPAD ) if( LockPoint->m_StructType == TYPEPAD )
{ {
pt_pad = (D_PAD*) LockPoint; pt_pad = (D_PAD*) LockPoint;
/* le debut de la piste est remis sur le centre du pad */ /* le debut de la piste est remis sur le centre du pad */
pos = pt_pad->m_Pos; pos = pt_pad->m_Pos;
g_HightLigth_NetCode = pt_pad->m_NetCode; g_HightLigth_NetCode = pt_pad->m_NetCode;
@ -144,7 +145,8 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
g_CurrentTrackSegment->start = adr_buf; g_CurrentTrackSegment->start = adr_buf;
if( g_TwoSegmentTrackBuild ) if( g_TwoSegmentTrackBuild )
{ // Create 2 segments {
// Create 2 segments
g_CurrentTrackSegment = new TRACK( *g_CurrentTrackSegment ); g_CurrentTrackSegment = new TRACK( *g_CurrentTrackSegment );
g_TrackSegmentCount++; g_TrackSegmentCount++;
g_CurrentTrackSegment->Pback = g_FirstTrackSegment; g_CurrentTrackSegment->Pback = g_FirstTrackSegment;
@ -793,13 +795,15 @@ void EnsureEndTrackOnPad( D_PAD* Pad )
TRACK* lasttrack = g_CurrentTrackSegment; TRACK* lasttrack = g_CurrentTrackSegment;
if( !g_CurrentTrackSegment->IsNull() ) if( !g_CurrentTrackSegment->IsNull() )
{ /* Must create a new segment, from track end to pad center */ {
/* Must create a new segment, from track end to pad center */
g_CurrentTrackSegment = new TRACK( *lasttrack ); g_CurrentTrackSegment = new TRACK( *lasttrack );
g_TrackSegmentCount++; g_TrackSegmentCount++;
lasttrack->Pnext = g_CurrentTrackSegment; lasttrack->Pnext = g_CurrentTrackSegment;
g_CurrentTrackSegment->Pback = lasttrack; g_CurrentTrackSegment->Pback = lasttrack;
lasttrack->end = g_CurrentTrackSegment; lasttrack->end = g_CurrentTrackSegment;
} }
g_CurrentTrackSegment->m_End = Pad->m_Pos; g_CurrentTrackSegment->m_End = Pad->m_Pos;
g_CurrentTrackSegment->SetState( END_ONPAD, OFF ); g_CurrentTrackSegment->SetState( END_ONPAD, OFF );

View File

@ -235,7 +235,7 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, wxDC* DC, boo
g_SaveTime = time( NULL ); g_SaveTime = time( NULL );
#if 0 && defined(DEBUG) #if 1 && defined(DEBUG)
// note this seems to freeze up pcbnew when run under the kicad project // note this seems to freeze up pcbnew when run under the kicad project
// manager. runs fine from command prompt. // manager. runs fine from command prompt.
// output the board object tree to stdout: // output the board object tree to stdout:

View File

@ -80,8 +80,7 @@ int NbDraw, NbTrack, NbZone, NbMod, NbNets;
/**********************************************************************/ /**********************************************************************/
int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File, int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
TRACK* PtSegm, int StructType, TRACK* PtSegm, int StructType, int* LineNum, int NumSegm )
int* LineNum, int NumSegm )
/**********************************************************************/ /**********************************************************************/
/* Lecture de la description d'une liste de segments (Tracks, zones) /* Lecture de la description d'une liste de segments (Tracks, zones)
@ -92,10 +91,14 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
{ {
int shape, width, layer, type, flags, net_code; int shape, width, layer, type, flags, net_code;
int ii = 0, PerCent, Pas; int ii = 0, PerCent, Pas;
char Line[256]; char line1[256];
char line2[256];
TRACK* NewTrack; TRACK* NewTrack;
PerCent = 0; Pas = NumSegm / 99; PerCent = 0;
Pas = NumSegm / 99;
#ifdef PCBNEW #ifdef PCBNEW
switch( StructType ) switch( StructType )
@ -111,14 +114,36 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
} }
#endif #endif
while( GetLine( File, Line, LineNum ) ) while( GetLine( File, line1, LineNum ) )
{ {
if( Line[0] == '$' ) int makeType;
unsigned long timeStamp;
if( line1[0] == '$' )
{ {
return ii; /* fin de liste OK */ return ii; /* fin de liste OK */
} }
switch( StructType ) // Read the 2nd line to determine the exact type, one of:
// TYPETRACK, TYPEVIA, or TYPEZONE. The type field in 2nd line
// differentiates between TYPETRACK and TYPEVIA. With virtual
// functions in use, it is critical to instantiate the TYPEVIA exactly.
if( GetLine( File, line2, LineNum ) == NULL )
break;
if( line2[0] == '$' )
break;
// parse the 2nd line first to determine the type of object
sscanf( line2 + 2, " %d %d %d %lX %X", &layer, &type, &net_code,
&timeStamp, &flags );
if( StructType==TYPETRACK && type==1 )
makeType = TYPEVIA;
else
makeType = StructType;
switch( makeType )
{ {
default: default:
case TYPETRACK: case TYPETRACK:
@ -134,29 +159,27 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
break; break;
} }
NewTrack->Insert( m_Pcb, PtSegm ); PtSegm = NewTrack; NewTrack->Insert( m_Pcb, PtSegm );
int arg_count = sscanf( Line + 2, " %d %d %d %d %d %d %d", &shape, PtSegm = NewTrack;
PtSegm->m_TimeStamp = timeStamp;
int arg_count = sscanf( line1 + 2, " %d %d %d %d %d %d %d", &shape,
&PtSegm->m_Start.x, &PtSegm->m_Start.y, &PtSegm->m_Start.x, &PtSegm->m_Start.y,
&PtSegm->m_End.x, &PtSegm->m_End.y, &width, &PtSegm->m_End.x, &PtSegm->m_End.y, &width,
&PtSegm->m_Drill ); &PtSegm->m_Drill );
PtSegm->m_Width = width; PtSegm->m_Shape = shape; PtSegm->m_Width = width;
PtSegm->m_Shape = shape;
if( arg_count < 7 ) if( arg_count < 7 )
PtSegm->m_Drill = -1; PtSegm->m_Drill = -1;
if( GetLine( File, Line, LineNum ) == NULL )
break;
if( Line[0] == '$' )
break;
sscanf( Line + 2, " %d %d %d %lX %X", &layer, &type, &net_code,
&PtSegm->m_TimeStamp, &flags );
if( type == 1 )
PtSegm->m_StructType = TYPEVIA;
PtSegm->SetLayer( layer ); PtSegm->SetLayer( layer );
PtSegm->m_NetCode = net_code; PtSegm->SetState( flags, ON ); PtSegm->m_NetCode = net_code;
PtSegm->SetState( flags, ON );
#ifdef PCBNEW #ifdef PCBNEW
PtSegm->Draw( DrawPanel, DC, GR_OR ); PtSegm->Draw( DrawPanel, DC, GR_OR );
#endif #endif
@ -166,7 +189,7 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
PerCent++; PerCent++;
#ifdef PCBNEW #ifdef PCBNEW
switch( StructType ) switch( makeType )
{ {
case TYPETRACK: case TYPETRACK:
case TYPEVIA: case TYPEVIA:
@ -178,7 +201,6 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
break; break;
} }
#endif #endif
} }
} }

View File

@ -240,7 +240,7 @@ TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer )
continue; continue;
if( layer < 0 ) if( layer < 0 )
return Track; return Track;
if( ( (SEGVIA*) Track )->IsViaOnLayer( layer ) ) if( Track->IsOnLayer( layer ) )
return Track; return Track;
} }

View File

@ -193,7 +193,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent,
m_SelViaSizeBox_Changed = FALSE; m_SelViaSizeBox_Changed = FALSE;
#if defined(DEBUG) #if defined(DEBUG)
m_Collector = new GENERALCOLLECTOR(); m_Collector = new GENERAL_COLLECTOR();
#endif #endif
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;