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;
case RECT :
case SPECIAL_PAD:
// case SPECIAL_PAD:
case TRAPEZE:
{
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
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>
================================================================================
+ eeschema & pcbnew

View File

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

View File

@ -160,7 +160,7 @@ private:
int m_Status;
private:
void InitVars( void );
void InitVars();
public:
@ -174,7 +174,7 @@ public:
int GetState( int type );
void SetState( int type, int state );
int ReturnStatus( void ) const
int ReturnStatus() const
{
return m_Status;
}
@ -347,11 +347,11 @@ public:
public:
EDA_TextStruct( const wxString& text = wxEmptyString );
virtual ~EDA_TextStruct( void );
void CreateDrawData( void );
virtual ~EDA_TextStruct();
void CreateDrawData();
int GetLength( void ) { return m_Text.Length(); };
int Pitch( void );/* retourne le pas entre 2 caracteres */
int GetLength() { return m_Text.Length(); };
int Pitch();/* retourne le pas entre 2 caracteres */
void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int color,
int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 );
@ -364,13 +364,13 @@ public:
*/
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
* 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
* found in PCBNEW or other programs that use class BOARD and its contents.
* The corresponding class in EESCHEMA seems to be DrawPartStruct.
@ -441,7 +441,7 @@ public:
/**
* 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
{
@ -469,11 +469,11 @@ public:
public:
DrawPickedStruct( EDA_BaseStruct* pickedstruct = NULL );
~DrawPickedStruct( void );
~DrawPickedStruct();
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
public:
EDA_Rect( void ) { };
wxPoint Centre( void )
EDA_Rect() { };
wxPoint Centre()
{
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( int x, int y ) { return Inside( wxPoint( x, y ) ); }
wxSize GetSize( void ) { return m_Size; }
int GetX( void ) { return m_Pos.x; }
int GetY( void ) { return m_Pos.y; }
wxPoint GetOrigin( void ) { return m_Pos; }
wxPoint GetPosition( void ) { return m_Pos; }
wxPoint GetEnd( void ) { return wxPoint( GetRight(), GetBottom() ); }
int GetWidth( void ) { return m_Size.x; }
int GetHeight( void ) { return m_Size.y; }
int GetRight( void ) { return m_Pos.x + m_Size.x; }
int GetBottom( void ) { return m_Pos.y + m_Size.y; }
wxSize GetSize() { return m_Size; }
int GetX() { return m_Pos.x; }
int GetY() { return m_Pos.y; }
wxPoint GetOrigin() { return m_Pos; }
wxPoint GetPosition() { return m_Pos; }
wxPoint GetEnd() { return wxPoint( GetRight(), GetBottom() ); }
int GetWidth() { return m_Size.x; }
int GetHeight() { return m_Size.y; }
int GetRight() { return m_Pos.x + m_Size.x; }
int GetBottom() { return m_Pos.y + m_Size.y; }
void SetOrigin( const wxPoint& pos ) { m_Pos = pos; }
void SetOrigin( int x, int y ) { m_Pos.x = x; m_Pos.y = y; }
void SetSize( const wxSize& size ) { m_Size = size; }

View File

@ -54,15 +54,15 @@ protected:
/// Which object types to scan
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.
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;
/// 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.
int m_TimeAtCollection;
@ -71,7 +71,6 @@ public:
COLLECTOR()
{
m_PreferredLayer = 0;
m_ScanTypes = 0;
}
@ -80,19 +79,13 @@ public:
}
void SetPreferredLayer( int aPreferredLayer )
{
m_PreferredLayer = aPreferredLayer;
}
/**
* Function GetCount
* returns the number of objects in the list
*/
unsigned GetCount() const
{
return list.size();
return m_List.size();
}
@ -102,7 +95,7 @@ public:
*/
void Empty()
{
list.clear();
m_List.clear();
}
@ -113,7 +106,7 @@ public:
*/
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
{
if( (unsigned)ndx < GetCount() )
return list[ ndx ];
return m_List[ ndx ];
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 )
{
m_ScanTypes = scanTypes;
}
wxPoint GetRefPos() const { return m_RefPos; }
void SetRefPos( const wxPoint& arefPos )
{
m_RefPos = arefPos;
}
void SetTimeNow()
{
m_TimeAtCollection = GetTimeStamp();
@ -151,6 +145,12 @@ public:
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
@ -196,28 +196,56 @@ public:
/**
* Function Scan
* scans a BOARD using this class's Inspector method, which does the collection.
* @param board A BOARD to scan.
* @param refPos A wxPoint to use in hit-testing.
* 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 aRefPos A wxPoint to use in hit-testing.
*
* example implementation, in derived class:
*
virtual void Scan( BOARD* board, const wxPoint& refPos )
virtual void Collect( EDA_BaseStruct* container, const wxPoint& aRefPos )
{
example implementation:
SetRefPos( refPos ); // remember where the snapshot was taken from
SetRefPos( aRefPos ); // remember where the snapshot was taken from
Empty(); // empty the collection
// visit the board with the INSPECTOR (me).
board->Visit( this, // INSPECTOR* inspector
container->Visit( this, // INSPECTOR* inspector
NULL, // const void* testData,
m_ScanTypes);
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

View File

@ -175,14 +175,14 @@ public:
int m_RatsnestColor; // Ratsnest color
public:
EDA_BoardDesignSettings( void );
EDA_BoardDesignSettings();
/**
* Function GetVisibleLayers
* returns a bit-map of all the layers that are visible.
* @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 */
BOARD( EDA_BaseStruct* StructFather, WinEDA_BasePcbFrame* frame );
~BOARD( void );
~BOARD();
/* supprime du chainage la structure Struct */
void UnLink( void );
void UnLink();
/* Routines de calcul des nombres de segments pistes et zones */
int GetNumSegmTrack( void );
int GetNumSegmZone( void );
int GetNumNoconnect( void ); // retourne le nombre de connexions manquantes
int GetNumRatsnests( void ); // retourne le nombre de chevelus
int GetNumNodes( void ); // retourne le nombre de pads a netcode > 0
int GetNumSegmTrack();
int GetNumSegmZone();
int GetNumNoconnect(); // retourne le nombre de connexions manquantes
int GetNumRatsnests(); // retourne le nombre de chevelus
int GetNumNodes(); // retourne le nombre de pads a netcode > 0
// 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
* about this object into the frame's message panel.
* 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 );
@ -284,10 +284,10 @@ public:
/**
* Function FindNet
* 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.
*/
EQUIPOT* FindNet( int anetcode );
EQUIPOT* FindNet( int aNetcode );
#if defined(DEBUG)
@ -324,12 +324,12 @@ public:
public:
PCB_SCREEN( int idscreen );
~PCB_SCREEN( void );
PCB_SCREEN* Next( void ) { return (PCB_SCREEN*) Pnext; }
void Init( void );
void SetNextZoom( void );
void SetPreviousZoom( void );
void SetLastZoom( void );
~PCB_SCREEN();
PCB_SCREEN* Next() { return (PCB_SCREEN*) Pnext; }
void Init();
void SetNextZoom();
void SetPreviousZoom();
void SetLastZoom();
};
/***************************/
@ -360,14 +360,14 @@ public:
public:
DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT );
~DRAWSEGMENT( void );
~DRAWSEGMENT();
// Read/write data
bool WriteDrawSegmentDescr( FILE* File );
bool ReadDrawSegmentDescr( FILE* File, int* LineNum );
/* supprime du chainage la structure Struct */
void UnLink( void );
void UnLink();
void Copy( DRAWSEGMENT* source );
@ -419,7 +419,7 @@ class EDGE_ZONE : public DRAWSEGMENT
public:
EDGE_ZONE( BOARD_ITEM* StructFather );
EDGE_ZONE( const EDGE_ZONE& edgezone );
~EDGE_ZONE( void );
~EDGE_ZONE();
};
@ -439,8 +439,8 @@ public:
public:
MARQUEUR( BOARD_ITEM* StructFather );
~MARQUEUR( void );
void UnLink( void );
~MARQUEUR();
void UnLink();
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode );
};
@ -471,7 +471,7 @@ public:
bool ContrastModeDisplay;
public:
DISPLAY_OPTIONS( void );
DISPLAY_OPTIONS();
};

View File

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

View File

@ -1288,7 +1288,8 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
{
next_track = track->Next();
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 = track->Copy( 1 );
new_track->Insert( m_Pcb, NULL );

View File

@ -46,12 +46,12 @@ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
/***************/
/* Destructeur */
/***************/
BOARD::~BOARD( void )
BOARD::~BOARD()
{
}
void BOARD::UnLink( void )
void BOARD::UnLink()
{
/* Modification du chainage arriere */
if( Pback )
@ -75,7 +75,7 @@ void BOARD::UnLink( void )
/* Routines de calcul des nombres de segments pistes et zones */
int BOARD::GetNumSegmTrack( void )
int BOARD::GetNumSegmTrack()
{
TRACK* CurTrack = m_Track;
int ii = 0;
@ -88,7 +88,7 @@ int BOARD::GetNumSegmTrack( void )
}
int BOARD::GetNumSegmZone( void )
int BOARD::GetNumSegmZone()
{
TRACK* CurTrack = m_Zone;
int ii = 0;
@ -102,28 +102,28 @@ int BOARD::GetNumSegmZone( void )
// retourne le nombre de connexions manquantes
int BOARD::GetNumNoconnect( void )
int BOARD::GetNumNoconnect()
{
return m_NbNoconnect;
}
// retourne le nombre de chevelus
int BOARD::GetNumRatsnests( void )
int BOARD::GetNumRatsnests()
{
return m_NbLinks;
}
// retourne le nombre de pads a netcode > 0
int BOARD::GetNumNodes( void )
int BOARD::GetNumNodes()
{
return m_NbNodes;
}
/***********************************/
bool BOARD::ComputeBoundaryBox( void )
bool BOARD::ComputeBoundaryBox()
/***********************************/
/* 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;
bool done=false;
#if defined(DEBUG)
#if 0 && defined(DEBUG)
std::cout << GetClass().mb_str() << ' ';
#endif
@ -381,6 +381,9 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
;
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 TYPETRACK:
result = IterateForward( m_Track, inspector, testData, p );
@ -397,6 +400,17 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
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:
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";
}
/* 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

View File

@ -47,7 +47,7 @@ public:
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* 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 );

View File

@ -52,7 +52,7 @@ public:
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* 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 );

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

View File

@ -134,9 +134,9 @@ public:
* Function Display_Infos
* has knowledge about the frame and how and where to put status information
* 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
* 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
* about this object into the frame's message panel.
* 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 );
/**
* 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
* 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
* about this object into the frame's message panel.
* 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 );

View File

@ -61,7 +61,7 @@ public:
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* 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 );

View File

@ -53,13 +53,14 @@ SEGVIA::SEGVIA( BOARD_ITEM* StructFather ) :
TRACK::TRACK( const TRACK& 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_NetCode = Source.m_NetCode;
m_Flags = Source.m_Flags;
m_TimeStamp = Source.m_TimeStamp;
SetStatus( Source.ReturnStatus() );
m_Layer = Source.m_Layer;
m_Start = Source.m_Start;
m_End = Source.m_End;
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
@ -134,36 +135,56 @@ int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
}
/******************************************/
bool SEGVIA::IsViaOnLayer( int layer_number )
/******************************************/
// see class_track.h
// 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();
if( via_type == VIA_NORMALE )
{
if( layer_number <= LAYER_CMP_N )
return TRUE;
return true;
else
return FALSE;
return false;
}
// VIA_BORGNE ou VIA_ENTERREE:
int bottom_layer, top_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
return FALSE;
return false;
}
/***********************************/
int TRACK::ReturnMaskLayer( void )
int TRACK::ReturnMaskLayer()
/***********************************/
/* 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
@ -239,7 +260,7 @@ void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer )
/* supprime du chainage la structure Struct
* les structures arrieres et avant sont chainees directement
*/
void TRACK::UnLink( void )
void TRACK::UnLink()
{
/* Modification du chainage arriere */
if( Pback )
@ -503,15 +524,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode )
if( DisplayOpt.ContrastModeDisplay )
{
if( m_StructType == TYPEVIA )
{
if( !( (SEGVIA*) this )->IsViaOnLayer( curr_layer ) )
{
color &= ~MASKCOLOR;
color |= DARKDARKGRAY;
}
}
else if( m_Layer != curr_layer )
if( !IsOnLayer( curr_layer ) )
{
color &= ~MASKCOLOR;
color |= DARKDARKGRAY;

View File

@ -49,7 +49,7 @@ public:
/* supprime du chainage la structure Struct */
void UnLink( void );
void UnLink();
// Read/write data
bool WriteTrackDescr( FILE* File );
@ -74,11 +74,11 @@ public:
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode );
/* 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 );
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
* about this object into the frame's message panel.
* 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 );
/**
* 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
* tests if the given wxPoint is within the bounds of this object.
@ -146,9 +163,19 @@ class SEGVIA : public TRACK
{
public:
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 ReturnLayerPair( int* top_layer, int* bottom_layer );
void ReturnLayerPair( int* top_layer, int* bottom_layer ) const;
#if defined(DEBUG)
/**

View File

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

View File

@ -34,7 +34,7 @@
// see collectors.h
const KICAD_T GENERALCOLLECTOR::AllBoardItems[] = {
const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
TYPETEXTE,
TYPEDRAWSEGMENT,
TYPECOTATION,
@ -59,7 +59,7 @@ const KICAD_T GENERALCOLLECTOR::AllBoardItems[] = {
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* 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;
@ -94,7 +94,12 @@ SEARCH_RESULT GENERALCOLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* n
}
break;
case TYPEMODULE:
MODULE* m;
m = (MODULE*) item;
if( m->GetReference() == wxT("L1") )
{
breakhere++;
}
break;
default:
breakhere++;
@ -102,17 +107,68 @@ SEARCH_RESULT GENERALCOLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* n
}
#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:
if( item->IsOnLayer( m_PreferredLayer ) )
{
@ -131,18 +187,16 @@ SEARCH_RESULT GENERALCOLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* n
if( item->HitTest( m_RefPos ) )
Append2nd( item );
}
break;
#endif
default:
printf("OOPS, not expecting class type %d\n", item->m_StructType );
}
return SEARCH_CONTINUE;
exit:
return SEARCH_CONTINUE; // always when collecting
}
// see collectors.h
void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos,
/*
void GENERAL_COLLECTOR::Collect( BOARD* board, const wxPoint& refPos,
int aPreferredLayer, int aLayerMask )
{
Empty(); // empty the collection, primary criteria list
@ -151,9 +205,7 @@ void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos,
SetPreferredLayer( aPreferredLayer );
SetLayerMask( aLayerMask );
/* remember where the snapshot was taken from and pass refPos to
the Inspect() function.
*/
// remember refPos, pass to Inspect()
SetRefPos( refPos );
#if defined(DEBUG)
@ -173,25 +225,23 @@ void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos,
Empty2nd();
}
*/
// see collectors.h
void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos,
const COLLECTORS_GUIDE& guide )
void GENERAL_COLLECTOR::Collect( BOARD* board, const wxPoint& refPos,
const COLLECTORS_GUIDE* guide )
{
Empty(); // empty the collection, primary 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 );
// visit the board with the INSPECTOR (me).
board->Visit( this, // INSPECTOR* inspector
NULL, // const void* testData, not used here
@ -199,14 +249,32 @@ void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos,
SetTimeNow(); // when snapshot was taken
// append 2nd list onto end of the first "list"
for( unsigned i=0; i<list2nd.size(); ++i )
Append( list2nd[i] );
// append 2nd list onto end of the first list
for( unsigned i=0; i<m_List2nd.size(); ++i )
Append( m_List2nd[i] );
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
//EOF

View File

@ -32,14 +32,25 @@
#include "class_collector.h"
#include "pcbstruct.h" // LAYER_COUNT, layer defs
/**
* Class COLLECTORS_GUIDE
* is an abstract base class that may be passed to a GENERALCOLLECTOR, telling
* it what should be collected (aside from HitTest()ing and KICAD_T scanTypes[],
* information which are provided to the GENERALCOLLECTOR through attributes or
* arguments separately).
* is an abstract base class whose derivatives may be passed to a GENERALCOLLECTOR,
* telling GENERALCOLLECTOR what should be collected (aside from HitTest()ing
* and KICAD_T scanTypes[], information which are provided to the GENERALCOLLECTOR
* 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>
* This class introduces the notion of layer locking.
*/
@ -55,18 +66,6 @@ public:
*/
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
* @return bool - true if the given layer is visible, else false.
@ -75,7 +74,7 @@ public:
/**
* 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;
@ -91,14 +90,42 @@ public:
*/
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
* plain "arrow" tool is in effect. This class can be used by window classes
* such as WinEDA_PcbFrame.
@ -108,22 +135,22 @@ public:
* but can handle those concerns by the SetPreferredLayer() function and the
* 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
* criteria, but would be acceptable if nothing else is found.
* "2nd" choice, which will be appended to the end of COLLECTOR's prime
* "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
* on a secondary search criterion basis.
* Determines which items are to be collected by Inspect()
*/
int m_LayerMask;
const COLLECTORS_GUIDE* m_Guide;
public:
@ -135,23 +162,30 @@ public:
/**
* Constructor GENERALCOLLECTOR
*/
GENERALCOLLECTOR()
GENERAL_COLLECTOR()
{
m_LayerMask = 0;
SetScanTypes( AllBoardItems );
}
void Empty2nd()
{
list2nd.clear();
m_List2nd.clear();
}
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
* 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
* visible, selected, etc. All those concerns are handled outside this
* class, as stated in the class Philosophy above.
*/
void SetLayerMask( int aLayerMask )
{
m_LayerMask = aLayerMask;
}
*/
/**
@ -181,7 +215,7 @@ public:
BOARD_ITEM* operator[]( int ndx ) const
{
if( (unsigned)ndx < (unsigned)GetCount() )
return (BOARD_ITEM*) list[ ndx ];
return (BOARD_ITEM*) m_List[ ndx ];
return NULL;
}
@ -200,25 +234,154 @@ public:
/**
* Function Scan
* Function Collect
* scans a BOARD using this class's Inspector method, which does the collection.
* @param board A BOARD to scan.
* @param refPos A wxPoint to use in hit-testing.
* @param aPreferredLayer The layer meeting the primary 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.
* @param board A BOARD to scan.
* @param refPos A wxPoint to use in hit-testing.
* @param guide The COLLECTORS_GUIDE to use in collecting items.
* @param aBoard A BOARD to scan.
* @param aRefPos A wxPoint to use in hit-testing.
* @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

View File

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

View File

@ -228,7 +228,8 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
Via->SetLayer( 0x0F );
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;
GetScreen()->m_Active_Layer = g_CurrentTrackSegment->GetLayer();
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
@ -245,8 +246,10 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
g_TrackSegmentCount++;
g_CurrentTrackSegment->Pback = Via;
Via->Pnext = g_CurrentTrackSegment;
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;
g_CurrentTrackSegment = new TRACK( *track );
g_TrackSegmentCount++;

View File

@ -114,6 +114,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC )
if( LockPoint->m_StructType == TYPEPAD )
{
pt_pad = (D_PAD*) LockPoint;
/* le debut de la piste est remis sur le centre du pad */
pos = pt_pad->m_Pos;
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;
if( g_TwoSegmentTrackBuild )
{ // Create 2 segments
{
// Create 2 segments
g_CurrentTrackSegment = new TRACK( *g_CurrentTrackSegment );
g_TrackSegmentCount++;
g_CurrentTrackSegment->Pback = g_FirstTrackSegment;
@ -793,13 +795,15 @@ void EnsureEndTrackOnPad( D_PAD* Pad )
TRACK* lasttrack = g_CurrentTrackSegment;
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_TrackSegmentCount++;
lasttrack->Pnext = g_CurrentTrackSegment;
g_CurrentTrackSegment->Pback = lasttrack;
lasttrack->end = g_CurrentTrackSegment;
}
g_CurrentTrackSegment->m_End = Pad->m_Pos;
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 );
#if 0 && defined(DEBUG)
#if 1 && defined(DEBUG)
// note this seems to freeze up pcbnew when run under the kicad project
// manager. runs fine from command prompt.
// 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,
TRACK* PtSegm, int StructType,
int* LineNum, int NumSegm )
TRACK* PtSegm, int StructType, int* LineNum, int NumSegm )
/**********************************************************************/
/* 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 ii = 0, PerCent, Pas;
char Line[256];
char line1[256];
char line2[256];
TRACK* NewTrack;
PerCent = 0; Pas = NumSegm / 99;
PerCent = 0;
Pas = NumSegm / 99;
#ifdef PCBNEW
switch( StructType )
@ -111,14 +114,36 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
}
#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 */
}
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:
case TYPETRACK:
@ -134,29 +159,27 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
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_End.x, &PtSegm->m_End.y, &width,
&PtSegm->m_Drill );
PtSegm->m_Width = width; PtSegm->m_Shape = shape;
PtSegm->m_Width = width;
PtSegm->m_Shape = shape;
if( arg_count < 7 )
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->m_NetCode = net_code; PtSegm->SetState( flags, ON );
PtSegm->m_NetCode = net_code;
PtSegm->SetState( flags, ON );
#ifdef PCBNEW
PtSegm->Draw( DrawPanel, DC, GR_OR );
#endif
@ -166,7 +189,7 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
PerCent++;
#ifdef PCBNEW
switch( StructType )
switch( makeType )
{
case TYPETRACK:
case TYPEVIA:
@ -178,7 +201,6 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File,
break;
}
#endif
}
}

View File

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

View File

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