PCBNew locate via code refactoring and other minor fixes.

* Refactor via locate code into the appropriate object.
* Rename all HightLight code to HighLight.
* Dead code removal.
This commit is contained in:
Wayne Stambaugh 2011-09-14 16:04:58 -04:00
parent 5bf7f4cd09
commit 3d7c91af44
20 changed files with 472 additions and 721 deletions

View File

@ -831,7 +831,14 @@ public:
*/ */
bool Other_Layer_Route( TRACK* track, wxDC* DC ); bool Other_Layer_Route( TRACK* track, wxDC* DC );
void HighlightUnconnectedPads( wxDC* DC ); void HighlightUnconnectedPads( wxDC* DC );
/**
* Function DisplayNetStatus
* shows the status of the net at the current mouse position or the
* PCB status if no segment selected.
*/
void DisplayNetStatus( wxDC* DC ); void DisplayNetStatus( wxDC* DC );
TRACK* Delete_Segment( wxDC* DC, TRACK* Track ); TRACK* Delete_Segment( wxDC* DC, TRACK* Track );
void Delete_Track( wxDC* DC, TRACK* Track ); void Delete_Track( wxDC* DC, TRACK* Track );
void Delete_net( wxDC* DC, TRACK* Track ); void Delete_net( wxDC* DC, TRACK* Track );
@ -900,7 +907,6 @@ public:
*/ */
bool End_Route( TRACK* aTrack, wxDC* aDC ); bool End_Route( TRACK* aTrack, wxDC* aDC );
void ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC );
void Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On ); void Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On );
void Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On ); void Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On );
void Attribut_net( wxDC* DC, int net_code, bool Flag_On ); void Attribut_net( wxDC* DC, int net_code, bool Flag_On );
@ -1177,7 +1183,15 @@ public:
void ReadAutoroutedTracks( wxDC* DC ); void ReadAutoroutedTracks( wxDC* DC );
void GlobalRoute( wxDC* DC ); void GlobalRoute( wxDC* DC );
/**
* Function Show_1_Ratsnest
* draw ratsnest.
*
* The net edge pad with mouse or module locates the mouse.
* Delete the ratsnest if no module or pad is selected.
*/
void Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC ); void Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC );
void Clean_Pcb( wxDC* DC ); void Clean_Pcb( wxDC* DC );
void InstallFindFrame( const wxPoint& pos, wxDC* DC ); void InstallFindFrame( const wxPoint& pos, wxDC* DC );

View File

@ -15,14 +15,11 @@
*/ */
wxPoint BOARD_ITEM::ZeroOffset( 0, 0 ); wxPoint BOARD_ITEM::ZeroOffset( 0, 0 );
// Current design settings (used also to read configs): // Current design settings (used also to read configs):
BOARD_DESIGN_SETTINGS boardDesignSettings; BOARD_DESIGN_SETTINGS boardDesignSettings;
/*****************/
/* Class BOARD: */
/*****************/
BOARD::BOARD( EDA_ITEM* parent, PCB_BASE_FRAME* frame ) : BOARD::BOARD( EDA_ITEM* parent, PCB_BASE_FRAME* frame ) :
BOARD_ITEM( (BOARD_ITEM*)parent, TYPE_PCB ), BOARD_ITEM( (BOARD_ITEM*)parent, TYPE_PCB ),
m_NetClasses( this ) m_NetClasses( this )
@ -87,36 +84,19 @@ BOARD::~BOARD()
} }
/* void BOARD::PushHighLight()
* Function PushHightLight
* save current hight light info for later use
*/
void BOARD::PushHightLight()
{ {
m_hightLightPrevious = m_hightLight; m_hightLightPrevious = m_hightLight;
} }
/* void BOARD::PopHighLight()
* Function PopHightLight
* retrieve a previously saved hight light info
*/
void BOARD::PopHightLight()
{ {
m_hightLight = m_hightLightPrevious; m_hightLight = m_hightLightPrevious;
m_hightLightPrevious.Clear(); m_hightLightPrevious.Clear();
} }
/**
* Function SetCurrentNetClass
* Must be called after a netclass selection (or after a netclass parameter
* change
* Initialize vias and tracks values displayed in combo boxes of the auxiliary
* toolbar and some other parameters (netclass name ....)
* @param aNetClassName = the new netclass name
* @return true if lists of tracks and vias sizes are modified
*/
bool BOARD::SetCurrentNetClass( const wxString& aNetClassName ) bool BOARD::SetCurrentNetClass( const wxString& aNetClassName )
{ {
NETCLASS* netClass = m_NetClasses.Find( aNetClassName ); NETCLASS* netClass = m_NetClasses.Find( aNetClassName );
@ -165,10 +145,6 @@ bool BOARD::SetCurrentNetClass( const wxString& aNetClassName )
} }
/**
* Function GetBiggestClearanceValue
* @return the biggest clearance value found in NetClasses list
*/
int BOARD::GetBiggestClearanceValue() int BOARD::GetBiggestClearanceValue()
{ {
int clearance = m_NetClasses.GetDefault()->GetClearance(); int clearance = m_NetClasses.GetDefault()->GetClearance();
@ -184,11 +160,6 @@ int BOARD::GetBiggestClearanceValue()
} }
/**
* Function GetCurrentMicroViaSize
* @return the current micro via size,
* that is the current netclass value
*/
int BOARD::GetCurrentMicroViaSize() int BOARD::GetCurrentMicroViaSize()
{ {
NETCLASS* netclass = m_NetClasses.Find( m_CurrentNetClassName ); NETCLASS* netclass = m_NetClasses.Find( m_CurrentNetClassName );
@ -197,11 +168,6 @@ int BOARD::GetCurrentMicroViaSize()
} }
/**
* Function GetCurrentMicroViaDrill
* @return the current micro via drill,
* that is the current netclass value
*/
int BOARD::GetCurrentMicroViaDrill() int BOARD::GetCurrentMicroViaDrill()
{ {
NETCLASS* netclass = m_NetClasses.Find( m_CurrentNetClassName ); NETCLASS* netclass = m_NetClasses.Find( m_CurrentNetClassName );
@ -423,7 +389,7 @@ void BOARD::SetVisibleElements( int aMask )
* to ensure specific calculations that can be needed by some items * to ensure specific calculations that can be needed by some items
* just change the visibility flags could be not sufficient * just change the visibility flags could be not sufficient
*/ */
for( int ii = 0; ii < PCB_VISIBLE(END_PCB_VISIBLE_LIST); ii++ ) for( int ii = 0; ii < PCB_VISIBLE( END_PCB_VISIBLE_LIST ); ii++ )
{ {
int item_mask = 1 << ii; int item_mask = 1 << ii;
SetElementVisibility( ii, aMask & item_mask ); SetElementVisibility( ii, aMask & item_mask );
@ -548,13 +514,6 @@ int BOARD::GetLayerColor( int aLayer )
} }
/**
* Function IsModuleLayerVisible
* expects either of the two layers on which a module can reside, and returns
* whether that layer is visible.
* @param layer One of the two allowed layers for modules: LAYER_N_FRONT or LAYER_N_BACK
* @return bool - true if the layer is visible, else false.
*/
bool BOARD::IsModuleLayerVisible( int layer ) bool BOARD::IsModuleLayerVisible( int layer )
{ {
if( layer==LAYER_N_FRONT ) if( layer==LAYER_N_FRONT )
@ -621,8 +580,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
aBoardItem->SetParent( this ); aBoardItem->SetParent( this );
// Because the list of pads has changed, reset the status // Because the list of pads has changed, reset the status
// This indicate the list of pad and nets must be recalculated before // This indicate the list of pad and nets must be recalculated before use
// use
m_Status_Pcb = 0; m_Status_Pcb = 0;
break; break;
@ -654,7 +612,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem ) BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
{ {
// find these calls and fix them! Don't send me no stinkin' NULL. // find these calls and fix them! Don't send me no stinking' NULL.
wxASSERT( aBoardItem ); wxASSERT( aBoardItem );
switch( aBoardItem->Type() ) switch( aBoardItem->Type() )
@ -737,28 +695,24 @@ void BOARD::DeleteZONEOutlines()
} }
/* Calculate the track segment count */
int BOARD::GetNumSegmTrack() int BOARD::GetNumSegmTrack()
{ {
return m_Track.GetCount(); return m_Track.GetCount();
} }
/* Calculate the zone segment count */
int BOARD::GetNumSegmZone() int BOARD::GetNumSegmZone()
{ {
return m_Zone.GetCount(); return m_Zone.GetCount();
} }
// return the unconnection count
unsigned BOARD::GetNoconnectCount() unsigned BOARD::GetNoconnectCount()
{ {
return m_NbNoconnect; return m_NbNoconnect;
} }
// return the active pad count ( pads with a netcode > 0 )
unsigned BOARD::GetNodesCount() unsigned BOARD::GetNodesCount()
{ {
return m_NbNodes; return m_NbNodes;
@ -858,9 +812,6 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly )
// virtual, see pcbstruct.h // virtual, see pcbstruct.h
/* Display board statistics: pads, nets, connections.. count
*/
void BOARD::DisplayInfo( EDA_DRAW_FRAME* frame ) void BOARD::DisplayInfo( EDA_DRAW_FRAME* frame )
{ {
wxString txt; wxString txt;
@ -1005,7 +956,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
// when created, if a track or via is connected to an existing track or // when created, if a track or via is connected to an existing track or
// via, it is put in linked list after this existing track or via // via, it is put in linked list after this existing track or via
// So usually, connected tracks or vias are grouped in this list // So usually, connected tracks or vias are grouped in this list
// So the algorithm (used in rastnest computations) which computes the // So the algorithm (used in ratsnest computations) which computes the
// track connectivity is faster (more than 100 time regarding to // track connectivity is faster (more than 100 time regarding to
// a non ordered list) because when it searches for a connexion, first // a non ordered list) because when it searches for a connexion, first
// it tests the near (near in term of linked list) 50 items // it tests the near (near in term of linked list) 50 items
@ -1174,12 +1125,6 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
*/ */
/**
* Function FindNet
* searches for a net with the given netcode.
* @param aNetcode The netcode to search for.
* @return NETINFO_ITEM* - the net or NULL if not found.
*/
NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
{ {
// the first valid netcode is 1 and the last is m_NetInfo->GetCount()-1. // the first valid netcode is 1 and the last is m_NetInfo->GetCount()-1.
@ -1202,12 +1147,6 @@ NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
} }
/**
* Function FindNet overlaid
* searches for a net with the given name.
* @param aNetname A Netname to search for.
* @return NETINFO_ITEM* - the net or NULL if not found.
*/
NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const
{ {
// the first valid netcode is 1. // the first valid netcode is 1.
@ -1327,13 +1266,6 @@ static bool s_SortByNodes( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
} }
/**
* Function ReturnSortedNetnamesList
* @param aNames An array string to fill with net names.
* @param aSortbyPadsCount : true = sort by active pads count, false = no sort
* (i.e. leave the sort by net names)
* @return int - net names count.
*/
int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount ) int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount )
{ {
if( m_NetInfo->GetCount() == 0 ) if( m_NetInfo->GetCount() == 0 )
@ -1406,6 +1338,7 @@ bool BOARD::Save( FILE* aFile ) const
// save the tracks & vias // save the tracks & vias
fprintf( aFile, "$TRACK\n" ); fprintf( aFile, "$TRACK\n" );
for( item = m_Track; item; item = item->Next() ) for( item = m_Track; item; item = item->Next() )
if( !item->Save( aFile ) ) if( !item->Save( aFile ) )
goto out; goto out;
@ -1439,10 +1372,6 @@ out:
} }
/*
* Function RedrawAreasOutlines
* Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 )
*/
void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode, int aLayer ) void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode, int aLayer )
{ {
if( !aDC ) if( !aDC )
@ -1458,10 +1387,6 @@ void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode
} }
/**
* Function RedrawFilledAreas
* Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 )
*/
void BOARD::RedrawFilledAreas( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode, int aLayer ) void BOARD::RedrawFilledAreas( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode, int aLayer )
{ {
if( !aDC ) if( !aDC )
@ -1477,18 +1402,6 @@ void BOARD::RedrawFilledAreas( EDA_DRAW_PANEL* panel, wxDC* aDC, int aDrawMode,
} }
/**
* Function HitTestForAnyFilledArea
* tests if the given wxPoint is within the bounds of a filled area of this
* zone.
* the test is made on zones on layer from aStartLayer to aEndLayer
* Note: if a zone has its flag BUSY (in .m_State) is set, it is ignored.
* @param aRefPos A wxPoint to test
* @param aStartLayer the first layer to test
* @param aEndLayer the last layer (-1 to ignore it) to test
* @return ZONE_CONTAINER* return a pointer to the ZONE_CONTAINER found, else
* NULL
*/
ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos, ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
int aStartLayer, int aStartLayer,
int aEndLayer ) int aEndLayer )
@ -1507,8 +1420,8 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
if( (layer < aStartLayer) || (layer > aEndLayer) ) if( (layer < aStartLayer) || (layer > aEndLayer) )
continue; continue;
if( area->GetState( BUSY ) ) // In locate functions we must skip // In locate functions we must skip tagged items with BUSY flag set.
// tagged items with BUSY flag set. if( area->GetState( BUSY ) )
continue; continue;
if( area->HitTestFilledArea( aRefPos ) ) if( area->HitTestFilledArea( aRefPos ) )
@ -1519,19 +1432,6 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
} }
/**
* Function SetAreasNetCodesFromNetNames
* Set the .m_NetCode member of all copper areas, according to the area Net
* Name
* The SetNetCodesFromNetNames is an equivalent to net name, for fast
* comparisons.
* However the Netcode is an arbitrary equivalence, it must be set after each
* netlist read
* or net change
* Must be called after pad netcodes are calculated
* @return : error count
* For non copper areas, netcode is set to 0
*/
int BOARD::SetAreasNetCodesFromNetNames( void ) int BOARD::SetAreasNetCodesFromNetNames( void )
{ {
int error_count = 0; int error_count = 0;
@ -1555,8 +1455,9 @@ int BOARD::SetAreasNetCodesFromNetNames( void )
else else
{ {
error_count++; error_count++;
GetArea( ii )->SetNet( -1 ); // keep Net Name and set
// m_NetCode to -1 : error flag // keep Net Name and set m_NetCode to -1 : error flag.
GetArea( ii )->SetNet( -1 );
} }
} }
} }
@ -1565,15 +1466,34 @@ int BOARD::SetAreasNetCodesFromNetNames( void )
} }
TRACK* BOARD::GetViaByPosition( const wxPoint& aPosition, int aLayerMask )
{
TRACK* track;
for( track = m_Track; track; track = track->Next() )
{
if( track->Type() != TYPE_VIA )
continue;
if( track->m_Start != aPosition )
continue;
if( track->GetState( BUSY | IS_DELETED ) )
continue;
if( aLayerMask < 0 )
break;
if( track->IsOnLayer( aLayerMask ) )
break;
}
return track;
}
#if defined(DEBUG) #if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void BOARD::Show( int nestLevel, std::ostream& os ) void BOARD::Show( int nestLevel, std::ostream& os )
{ {
BOARD_ITEM* p; BOARD_ITEM* p;
@ -1630,9 +1550,7 @@ void BOARD::Show( int nestLevel, std::ostream& os )
p->Show( nestLevel + 1, os ); p->Show( nestLevel + 1, os );
} }
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
<< ">\n";
} }
#endif #endif

View File

@ -14,6 +14,9 @@
class ZONE_CONTAINER; class ZONE_CONTAINER;
#define HISTORY_MAX_COUNT 8
/** /**
* Enum LAYER_T * Enum LAYER_T
* gives the allowed types of layers, same as Specctra DSN spec. * gives the allowed types of layers, same as Specctra DSN spec.
@ -41,7 +44,6 @@ struct LAYER
// int m_Color; // int m_Color;
// bool m_Visible; // ? use flags in m_Color instead ? // bool m_Visible; // ? use flags in m_Color instead ?
/** /**
* Function ShowType * Function ShowType
* converts a LAYER_T enum to a const char* * converts a LAYER_T enum to a const char*
@ -78,8 +80,7 @@ public:
bool operator ==( const VIA_DIMENSION& other ) const bool operator ==( const VIA_DIMENSION& other ) const
{ {
return (m_Diameter == other.m_Diameter) return (m_Diameter == other.m_Diameter) && (m_Drill == other.m_Drill);
&& (m_Drill == other.m_Drill);
} }
@ -87,94 +88,120 @@ public:
{ {
if( m_Diameter != other.m_Diameter ) if( m_Diameter != other.m_Diameter )
return m_Diameter < other.m_Diameter; return m_Diameter < other.m_Diameter;
return m_Drill < other.m_Drill; return m_Drill < other.m_Drill;
} }
}; };
// Helper class to handle hight light nets
class HIGHT_LIGHT_INFO // Helper class to handle high light nets
class HIGH_LIGHT_INFO
{ {
friend class BOARD; friend class BOARD;
protected: protected:
int m_netCode; // net selected for hightlight (-1 when no net selected ) int m_netCode; // net selected for highlight (-1 when no net selected )
bool m_hightLightOn; // hightlight active bool m_highLightOn; // highlight active
protected: protected:
void Clear() void Clear()
{ {
m_netCode = -1; m_netCode = -1;
m_hightLightOn = false; m_highLightOn = false;
} }
HIGHT_LIGHT_INFO() HIGH_LIGHT_INFO()
{ {
Clear(); Clear();
} }
}; };
/** /**
* Class BOARD * Class BOARD
* holds information pertinent to a PCBNEW printed circuit board. * holds information pertinent to a PCBNEW printed circuit board.
*/ */
#define HISTORY_MAX_COUNT 8
class BOARD : public BOARD_ITEM class BOARD : public BOARD_ITEM
{ {
friend class PCB_EDIT_FRAME; friend class PCB_EDIT_FRAME;
private: private:
typedef std::vector<MARKER_PCB*> MARKERS; // @todo: switch to boost:ptr_vector, and change ~BOARD() // @todo: switch to boost:ptr_vector, and change ~BOARD()
MARKERS m_markers; ///< MARKER_PCBs for clearance problems, owned by pointer typedef std::vector<MARKER_PCB*> MARKERS;
typedef std::vector<ZONE_CONTAINER*> ZONE_CONTAINERS; // @todo: switch to boost::ptr_vector, and change ~BOARD() /// MARKER_PCBs for clearance problems, owned by pointer.
ZONE_CONTAINERS m_ZoneDescriptorList; ///< edge zone descriptors, owned by pointer MARKERS m_markers;
// @todo: switch to boost::ptr_vector, and change ~BOARD()
typedef std::vector<ZONE_CONTAINER*> ZONE_CONTAINERS;
/// edge zone descriptors, owned by pointer.
ZONE_CONTAINERS m_ZoneDescriptorList;
LAYER m_Layer[NB_COPPER_LAYERS]; LAYER m_Layer[NB_COPPER_LAYERS];
// if true m_hightLight_NetCode is used // if true m_hightLight_NetCode is used
HIGHT_LIGHT_INFO m_hightLight; // current hight light data HIGH_LIGHT_INFO m_hightLight; // current high light data
HIGHT_LIGHT_INFO m_hightLightPrevious; // a previously stored hight light data HIGH_LIGHT_INFO m_hightLightPrevious; // a previously stored high light data
public: public:
PCB_BASE_FRAME* m_PcbFrame; // Window of visualization PCB_BASE_FRAME* m_PcbFrame; // Window of visualization
EDA_RECT m_BoundaryBox; // Board size and position EDA_RECT m_BoundaryBox; // Board size and position
int m_Status_Pcb; // Flags used in ratsnet calculation and update
int m_NbNodes; // Active pads (pads attached to a net ) count
int m_NbNoconnect; // Active ratsnet count (rastnests not already connected by tracks)
DLIST<BOARD_ITEM> m_Drawings; // linked list of lines & texts /// Flags used in ratsnest calculation and update.
DLIST<MODULE> m_Modules; // linked list of MODULEs int m_Status_Pcb;
DLIST<TRACK> m_Track; // linked list of TRACKs and SEGVIAs
DLIST<SEGZONE> m_Zone; // linked list of SEGZONEs
NETINFO_LIST* m_NetInfo; // nets info list (name, design constraints .. /// Active pads (pads attached to a net ) count.
int m_NbNodes;
std::vector<RATSNEST_ITEM> m_FullRatsnest; // Rastnest list for the BOARD /// Active ratsnest count (ratsnests not already connected by tracks)
std::vector<RATSNEST_ITEM> m_LocalRatsnest; /* Rastnest list relative to a given footprint int m_NbNoconnect;
* (used while moving a footprint) */
ZONE_CONTAINER* m_CurrentZoneContour; // zone contour currently in progress DLIST<BOARD_ITEM> m_Drawings; // linked list of lines & texts
DLIST<MODULE> m_Modules; // linked list of MODULEs
DLIST<TRACK> m_Track; // linked list of TRACKs and SEGVIAs
DLIST<SEGZONE> m_Zone; // linked list of SEGZONEs
NETCLASSES m_NetClasses; ///< List of current netclasses. There is always the default netclass /// nets info list (name, design constraints ..
wxString m_CurrentNetClassName; /* Current net class name used to display netclass info. NETINFO_LIST* m_NetInfo;
* this is also the last used netclass after starting a track
*/
/// Ratsnest list for the BOARD
std::vector<RATSNEST_ITEM> m_FullRatsnest;
/// Ratsnest list relative to a given footprint (used while moving a footprint).
std::vector<RATSNEST_ITEM> m_LocalRatsnest;
/// zone contour currently in progress
ZONE_CONTAINER* m_CurrentZoneContour;
/// List of current netclasses. There is always the default netclass.
NETCLASSES m_NetClasses;
/// Current net class name used to display netclass info.
/// This is also the last used netclass after starting a track.
wxString m_CurrentNetClassName;
// handling of vias and tracks size: // handling of vias and tracks size:
// the first value is always the value of the current NetClass // the first value is always the value of the current NetClass
// The others values are extra values // The others values are extra values
std::vector <VIA_DIMENSION> m_ViasDimensionsList; // vias size and drill list(max count = HISTORY_MAX_COUNT)
/// Vias size and drill list(max count = HISTORY_MAX_COUNT)
std::vector <VIA_DIMENSION> m_ViasDimensionsList;
// The first value is the current netclass via size // The first value is the current netclass via size
std::vector <int> m_TrackWidthList; // tracks widths (max count = HISTORY_MAX_COUNT) // tracks widths (max count = HISTORY_MAX_COUNT)
// The first value is the current netclass track width // The first value is the current netclass track width
unsigned m_ViaSizeSelector; // index for m_ViaSizeList to select the value std::vector <int> m_TrackWidthList;
// 0 is the index selection of the default value Netclass
unsigned m_TrackWidthSelector; // index for m_TrackWidthList to select the value /// Index for m_ViaSizeList to select the value.
/// 0 is the index selection of the default value Netclass
unsigned m_ViaSizeSelector;
// Index for m_TrackWidthList to select the value.
unsigned m_TrackWidthSelector;
private: private:
BOARD_DESIGN_SETTINGS* m_boardDesignSettings; // Link to current design settings BOARD_DESIGN_SETTINGS* m_boardDesignSettings; // Link to current design settings
COLORS_DESIGN_SETTINGS* m_colorsSettings; // Link to current colors settings COLORS_DESIGN_SETTINGS* m_colorsSettings; // Link to current colors settings
/**********************************/
public: public:
BOARD( EDA_ITEM* aParent, PCB_BASE_FRAME* frame ); BOARD( EDA_ITEM* aParent, PCB_BASE_FRAME* frame );
~BOARD(); ~BOARD();
@ -200,14 +227,13 @@ public:
*/ */
wxPoint& GetPosition(); wxPoint& GetPosition();
/** /**
* Function Add * Function Add
* adds the given item to this BOARD and takes ownership of its memory. * adds the given item to this BOARD and takes ownership of its memory.
* @param aBoardItem The item to add to this board. * @param aBoardItem The item to add to this board.
* @param aControl An int which can vary how the item is added. * @param aControl An int which can vary how the item is added.
*/ */
void Add( BOARD_ITEM* aBoardItem, int aControl = 0 ); void Add( BOARD_ITEM* aBoardItem, int aControl = 0 );
#define ADD_APPEND 1 ///< aControl flag for Add( aControl ), appends not inserts #define ADD_APPEND 1 ///< aControl flag for Add( aControl ), appends not inserts
@ -217,9 +243,11 @@ public:
* removes the given single item from this BOARD and deletes its memory. * removes the given single item from this BOARD and deletes its memory.
* @param aBoardItem The item to remove from this board and delete * @param aBoardItem The item to remove from this board and delete
*/ */
void Delete( BOARD_ITEM* aBoardItem ) void Delete( BOARD_ITEM* aBoardItem )
{ {
wxASSERT( aBoardItem ); // developers should run DEBUG versions and fix such calls with NULL // developers should run DEBUG versions and fix such calls with NULL
wxASSERT( aBoardItem );
if( aBoardItem ) if( aBoardItem )
delete Remove( aBoardItem ); delete Remove( aBoardItem );
} }
@ -227,25 +255,23 @@ public:
/** /**
* Function Remove * Function Remove
* removes \a aBoardItem from this BOARD and returns it to caller without * removes \a aBoardItem from this BOARD and returns it to caller without deleting it.
* deleting it.
* @param aBoardItem The item to remove from this board. * @param aBoardItem The item to remove from this board.
* @return BOARD_ITEM* \a aBoardItem which was passed in. * @return BOARD_ITEM* \a aBoardItem which was passed in.
*/ */
BOARD_ITEM* Remove( BOARD_ITEM* aBoardItem ); BOARD_ITEM* Remove( BOARD_ITEM* aBoardItem );
/** /**
* Function DeleteMARKERs * Function DeleteMARKERs
* deletes ALL MARKERS from the board. * deletes ALL MARKERS from the board.
*/ */
void DeleteMARKERs(); void DeleteMARKERs();
/** /**
* Function DeleteZONEOutlines * Function DeleteZONEOutlines
* deletes ALL zone outlines from the board. * deletes ALL zone outlines from the board.
*/ */
void DeleteZONEOutlines(); void DeleteZONEOutlines();
/** /**
@ -258,6 +284,7 @@ public:
{ {
if( (unsigned) index < m_markers.size() ) if( (unsigned) index < m_markers.size() )
return m_markers[index]; return m_markers[index];
return NULL; return NULL;
} }
@ -273,61 +300,61 @@ public:
/** /**
* Function ResetHightLight * Function ResetHighLight
* Reset all hight light data to the init state * Reset all high light data to the init state
*/ */
void ResetHightLight() void ResetHighLight()
{ {
m_hightLight.Clear(); m_hightLight.Clear();
m_hightLightPrevious.Clear(); m_hightLightPrevious.Clear();
} }
/** /**
* Function GetHightLightNetCode * Function GetHighLightNetCode
* @return netcode of net to hightlight (-1 when no net selected) * @return netcode of net to highlight (-1 when no net selected)
*/ */
int GetHightLightNetCode() { return m_hightLight.m_netCode; } int GetHighLightNetCode() { return m_hightLight.m_netCode; }
/** /**
* Function SetHightLightNet * Function SetHighLightNet
* @param aNetCode = netcode of net to hightlight * @param aNetCode = netcode of net to highlight
*/ */
void SetHightLightNet( int aNetCode) void SetHighLightNet( int aNetCode)
{ {
m_hightLight.m_netCode = aNetCode; m_hightLight.m_netCode = aNetCode;
} }
/** /**
* Function IsHightLightNetON * Function IsHighLightNetON
* @return true if a net is currently hightlighted * @return true if a net is currently highlighted
*/ */
bool IsHightLightNetON() { return m_hightLight.m_hightLightOn; } bool IsHighLightNetON() { return m_hightLight.m_highLightOn; }
/** /**
* Function HightLightOFF * Function HighLightOFF
* Disable hightlight. * Disable highlight.
*/ */
void HightLightOFF() { m_hightLight.m_hightLightOn = false; } void HighLightOFF() { m_hightLight.m_highLightOn = false; }
/** /**
* Function HightLightON * Function HighLightON
* Enable hightlight. * Enable highlight.
* if m_hightLight_NetCode >= 0, this net will be hightlighted * if m_hightLight_NetCode >= 0, this net will be highlighted
*/ */
void HightLightON() { m_hightLight.m_hightLightOn = true; } void HighLightON() { m_hightLight.m_highLightOn = true; }
/** /**
* Function PushHightLight * Function PushHighLight
* save current hight light info for later use * save current high light info for later use
*/ */
void PushHightLight(); void PushHighLight();
/** /**
* Function PopHightLight * Function PopHighLight
* retrieve a previously saved hight light info * retrieve a previously saved high light info
*/ */
void PopHightLight(); void PopHighLight();
/** /**
* Function GetCopperLayerCount * Function GetCopperLayerCount
@ -337,7 +364,6 @@ public:
void SetCopperLayerCount( int aCount ); void SetCopperLayerCount( int aCount );
/** /**
* Function GetEnabledLayers * Function GetEnabledLayers
* is a proxy function that calls the correspondent function in m_BoardSettings * is a proxy function that calls the correspondent function in m_BoardSettings
@ -404,7 +430,7 @@ public:
* @return int - the visible element bitmap or-ed from enum PCB_VISIBLE * @return int - the visible element bitmap or-ed from enum PCB_VISIBLE
* @see enum PCB_VISIBLE * @see enum PCB_VISIBLE
*/ */
int GetVisibleElements() const; int GetVisibleElements() const;
/** /**
* Function SetVisibleElements * Function SetVisibleElements
@ -455,9 +481,9 @@ public:
* returns the color of a pcb visible element. * returns the color of a pcb visible element.
* @see enum PCB_VISIBLE * @see enum PCB_VISIBLE
*/ */
int GetVisibleElementColor( int aPCB_VISIBLE ); int GetVisibleElementColor( int aPCB_VISIBLE );
void SetVisibleElementColor( int aPCB_VISIBLE, int aColor );
void SetVisibleElementColor( int aPCB_VISIBLE, int aColor );
/** /**
* Function GetBoardDesignSettings * Function GetBoardDesignSettings
@ -478,6 +504,7 @@ public:
m_boardDesignSettings = aDesignSettings; m_boardDesignSettings = aDesignSettings;
} }
/** /**
* Function SetBoardSettings * Function SetBoardSettings
* @return the current COLORS_DESIGN_SETTINGS in use * @return the current COLORS_DESIGN_SETTINGS in use
@ -487,6 +514,7 @@ public:
return m_colorsSettings; return m_colorsSettings;
} }
/** /**
* Function SetColorsSettings * Function SetColorsSettings
* @param aColorsSettings = the new COLORS_DESIGN_SETTINGS to use * @param aColorsSettings = the new COLORS_DESIGN_SETTINGS to use
@ -512,10 +540,10 @@ public:
* *
* @param aLayerIndex A layer index, like LAYER_N_BACK, etc. * @param aLayerIndex A layer index, like LAYER_N_BACK, etc.
* @param aLayerName The new layer name * @param aLayerName The new layer name
* @return bool - true if aLayerName was legal and unique amoung other * @return bool - true if aLayerName was legal and unique among other
* layer names at other layer indices and aLayerIndex was within range, else false. * layer names at other layer indices and aLayerIndex was within range, else false.
*/ */
bool SetLayerName( int aLayerIndex, const wxString& aLayerName ); bool SetLayerName( int aLayerIndex, const wxString& aLayerName );
/** /**
* Function GetLayerType * Function GetLayerType
@ -525,7 +553,7 @@ public:
* @return LAYER_T - the layer type, or LAYER_T(-1) if the * @return LAYER_T - the layer type, or LAYER_T(-1) if the
* index was out of range. * index was out of range.
*/ */
LAYER_T GetLayerType( int aLayerIndex ) const; LAYER_T GetLayerType( int aLayerIndex ) const;
/** /**
* Function SetLayerType * Function SetLayerType
@ -535,30 +563,33 @@ public:
* @param aLayerType The new layer type. * @param aLayerType The new layer type.
* @return bool - true if aLayerType was legal and aLayerIndex was within range, else false. * @return bool - true if aLayerType was legal and aLayerIndex was within range, else false.
*/ */
bool SetLayerType( int aLayerIndex, LAYER_T aLayerType ); bool SetLayerType( int aLayerIndex, LAYER_T aLayerType );
/** /**
* Function SetLayerColor * Function SetLayerColor
* changes a layer color for any valid layer, including non-copper ones. * changes a layer color for any valid layer, including non-copper ones.
*/ */
void SetLayerColor( int aLayer, int aColor ); void SetLayerColor( int aLayer, int aColor );
/** /**
* Function GetLayerColor * Function GetLayerColor
* gets a layer color for any valid layer, including non-copper ones. * gets a layer color for any valid layer, including non-copper ones.
*/ */
int GetLayerColor( int aLayer ); int GetLayerColor( int aLayer );
/* Functions to get some items count */ /* Functions to get some items count */
int GetNumSegmTrack(); int GetNumSegmTrack();
int GetNumSegmZone();
/* Calculate the zone segment count */
int GetNumSegmZone();
unsigned GetNoconnectCount(); // Return the number of missing links. unsigned GetNoconnectCount(); // Return the number of missing links.
/** /**
* Function GetNumRatsnests * Function GetNumRatsnests
* @return int - The number of rats * @return int - The number of rats
*/ */
unsigned GetRatsnestsCount() unsigned GetRatsnestsCount()
{ {
return m_FullRatsnest.size(); return m_FullRatsnest.size();
} }
@ -574,7 +605,7 @@ public:
* Function GetPadsCount * Function GetPadsCount
* @return the number of pads in board * @return the number of pads in board
*/ */
unsigned GetPadsCount() unsigned GetPadsCount()
{ {
return m_NetInfo->GetPadsCount(); return m_NetInfo->GetPadsCount();
} }
@ -585,7 +616,7 @@ public:
* @param aBoardEdgesOnly is true if we are interested in board edge segments only. * @param aBoardEdgesOnly is true if we are interested in board edge segments only.
* @return bool - True if items (or board edge segments) were found. * @return bool - True if items (or board edge segments) were found.
*/ */
bool ComputeBoundingBox( bool aBoardEdgesOnly = false ); bool ComputeBoundingBox( bool aBoardEdgesOnly = false );
/** /**
* Function DisplayInfo * Function DisplayInfo
@ -594,18 +625,18 @@ public:
* Is virtual from EDA_ITEM. * Is virtual from EDA_ITEM.
* @param frame A EDA_DRAW_FRAME in which to print status information. * @param frame A EDA_DRAW_FRAME in which to print status information.
*/ */
void DisplayInfo( EDA_DRAW_FRAME* frame ); void DisplayInfo( EDA_DRAW_FRAME* frame );
/** /**
* Function Draw. * Function Draw.
* Redraw the BOARD items but not cursors, axis or grid. * Redraw the BOARD items but not cursors, axis or grid.
* @param aPanel = the panel relative to the board * @param aPanel = the panel relative to the board
* @param aDC = the curent device context * @param aDC = the current device context
* @param aDrawMode = GR_COPY, GR_OR ... (not always used) * @param aDrawMode = GR_COPY, GR_OR ... (not always used)
* @param aOffset = an draw offset value (default = 0,0) * @param aOffset = an draw offset value (default = 0,0)
*/ */
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
int aDrawMode, const wxPoint& aOffset = ZeroOffset ); int aDrawMode, const wxPoint& aOffset = ZeroOffset );
/** /**
* Function DrawHighLight * Function DrawHighLight
@ -613,10 +644,10 @@ public:
* and turns on or off the brilliance associated with that net according to the * and turns on or off the brilliance associated with that net according to the
* current value of global g_HighLight_Status * current value of global g_HighLight_Status
* @param aDrawPanel is needed for the clipping support. * @param aDrawPanel is needed for the clipping support.
* @param aDC = the curent device context * @param aDC = the current device context
* @param aNetCode is the net number to highlight or to dim. * @param aNetCode is the net number to highlight or to dim.
*/ */
void DrawHighLight( EDA_DRAW_PANEL* aDrawPanel, wxDC* aDC, int aNetCode ); void DrawHighLight( EDA_DRAW_PANEL* aDrawPanel, wxDC* aDC, int aNetCode );
/** /**
* Function Visit * Function Visit
@ -644,7 +675,7 @@ public:
NETINFO_ITEM* FindNet( int aNetcode ) const; NETINFO_ITEM* FindNet( int aNetcode ) const;
/** /**
* Function FindNet overlayed * Function FindNet overloaded
* searches for a net with the given name. * searches for a net with the given name.
* @param aNetname A Netname to search for. * @param aNetname A Netname to search for.
* @return NETINFO_ITEM* - the net or NULL if not found. * @return NETINFO_ITEM* - the net or NULL if not found.
@ -660,15 +691,16 @@ public:
* @return MODULE* - If found, the MODULE having the given reference * @return MODULE* - If found, the MODULE having the given reference
* designator, else NULL. * designator, else NULL.
*/ */
MODULE* FindModuleByReference( const wxString& aReference ) const; MODULE* FindModuleByReference( const wxString& aReference ) const;
/** /**
* Function ReturnSortedNetnamesList * Function ReturnSortedNetnamesList
* @param aNames An array string to fill with net names. * @param aNames An array string to fill with net names.
* @param aSortbyPadsCount : true = sort by active pads count, false = no sort (i.e. leave the sort by net names) * @param aSortbyPadsCount true = sort by active pads count, false = no sort (i.e.
* leave the sort by net names)
* @return int - net names count. * @return int - net names count.
*/ */
int ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount ); int ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount );
/**************************************/ /**************************************/
/** /**
@ -678,16 +710,16 @@ public:
/** /**
* Function SynchronizeNetsAndNetClasses * Function SynchronizeNetsAndNetClasses
* copies NETCLASS info to each NET, based on NET membership in a NETCLASS. * copies NETCLASS info to each NET, based on NET membership in a NETCLASS.
* Must be called after a Design Rules edition, or after reading a netlist (or editing the list of nets) * Must be called after a Design Rules edition, or after reading a netlist (or editing
* Also this function removes the non existing nets in netclasses and add net nets in default netclass * the list of nets) Also this function removes the non existing nets in netclasses
* (this happens after reading a netlist) * and add net nets in default netclass (this happens after reading a netlist)
*/ */
void SynchronizeNetsAndNetClasses(); void SynchronizeNetsAndNetClasses();
/** /**
* Function SetCurrentNetClass * Function SetCurrentNetClass
* Must be called after a netclass selection (or after a netclass parameter change * Must be called after a netclass selection (or after a netclass parameter change
* Initialise vias and tracks values displayed in comb boxes of the auxiliary toolbar * Initialize vias and tracks values displayed in comb boxes of the auxiliary toolbar
* and some others parameters (netclass name ....) * and some others parameters (netclass name ....)
* @param aNetClassName = the new netclass name * @param aNetClassName = the new netclass name
* @return true if lists of tracks and vias sizes are modified * @return true if lists of tracks and vias sizes are modified
@ -698,7 +730,7 @@ public:
* Function GetBiggestClearanceValue * Function GetBiggestClearanceValue
* @return the biggest clearance value found in NetClasses list * @return the biggest clearance value found in NetClasses list
*/ */
int GetBiggestClearanceValue(); int GetBiggestClearanceValue();
/** /**
* Function GetCurrentTrackWidth * Function GetCurrentTrackWidth
@ -706,7 +738,7 @@ public:
* ( using the default netclass value or a preset value ) * ( using the default netclass value or a preset value )
* the default netclass is always in m_TrackWidthList[0] * the default netclass is always in m_TrackWidthList[0]
*/ */
int GetCurrentTrackWidth() int GetCurrentTrackWidth()
{ {
return m_TrackWidthList[m_TrackWidthSelector]; return m_TrackWidthList[m_TrackWidthSelector];
} }
@ -718,7 +750,7 @@ public:
* ( using the default netclass value or a preset value ) * ( using the default netclass value or a preset value )
* the default netclass is always in m_TrackWidthList[0] * the default netclass is always in m_TrackWidthList[0]
*/ */
int GetCurrentViaSize() int GetCurrentViaSize()
{ {
return m_ViasDimensionsList[m_ViaSizeSelector].m_Diameter; return m_ViasDimensionsList[m_ViaSizeSelector].m_Diameter;
} }
@ -730,7 +762,7 @@ public:
* ( using the default netclass value or a preset value ) * ( using the default netclass value or a preset value )
* the default netclass is always in m_TrackWidthList[0] * the default netclass is always in m_TrackWidthList[0]
*/ */
int GetCurrentViaDrill() int GetCurrentViaDrill()
{ {
return m_ViasDimensionsList[m_ViaSizeSelector].m_Drill > 0 ? return m_ViasDimensionsList[m_ViaSizeSelector].m_Drill > 0 ?
m_ViasDimensionsList[m_ViaSizeSelector].m_Drill : -1; m_ViasDimensionsList[m_ViaSizeSelector].m_Drill : -1;
@ -779,7 +811,7 @@ public:
* Function Show * Function Show
* is used to output the object tree, currently for debugging only. * is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level * @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree. * of nesting of this object within the overall tree.
* @param os The ostream& to output to. * @param os The ostream& to output to.
*/ */
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
@ -809,10 +841,10 @@ public:
* Function RedrawAreasOutlines * Function RedrawAreasOutlines
* Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 ) * Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 )
*/ */
void RedrawAreasOutlines( EDA_DRAW_PANEL* aPanel, void RedrawAreasOutlines( EDA_DRAW_PANEL* aPanel,
wxDC* aDC, wxDC* aDC,
int aDrawMode, int aDrawMode,
int aLayer ); int aLayer );
/** /**
* Function RedrawFilledAreas * Function RedrawFilledAreas
@ -882,10 +914,10 @@ public:
* Add an empty copper area to board areas list * Add an empty copper area to board areas list
* @param aNewZonesList = a PICKED_ITEMS_LIST * where to store new areas pickers (useful * @param aNewZonesList = a PICKED_ITEMS_LIST * where to store new areas pickers (useful
* in undo commands) can be NULL * in undo commands) can be NULL
* @param aNetcode = the necode of the copper area (0 = no net) * @param aNetcode = the netcode of the copper area (0 = no net)
* @param aLayer = the layer of area * @param aLayer = the layer of area
* @param aStartPointPosition = position of the first point of the polygon outline of this area * @param aStartPointPosition = position of the first point of the polygon outline of this area
* @param aHatch = hacth option * @param aHatch = hatch option
* @return pointer to the new area * @return pointer to the new area
*/ */
ZONE_CONTAINER* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, ZONE_CONTAINER* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode,
@ -906,7 +938,7 @@ public:
* @param style = style of last corner * @param style = style of last corner
* @return 1 if Ok, 0 if area removed * @return 1 if Ok, 0 if area removed
*/ */
int CompleteArea( ZONE_CONTAINER* area_to_complete, int style ); int CompleteArea( ZONE_CONTAINER* area_to_complete, int style );
/** /**
* Function TestAreaPolygon * Function TestAreaPolygon
@ -919,7 +951,7 @@ public:
* 1 if intersecting sides, but no intersecting arcs * 1 if intersecting sides, but no intersecting arcs
* Also sets utility2 flag of area with return value * Also sets utility2 flag of area with return value
*/ */
int TestAreaPolygon( ZONE_CONTAINER* CurrArea ); int TestAreaPolygon( ZONE_CONTAINER* CurrArea );
/** /**
* Function ClipAreaPolygon * Function ClipAreaPolygon
@ -937,11 +969,11 @@ public:
* 1 if intersecting sides * 1 if intersecting sides
* Also sets areas->utility1 flags if areas are modified * Also sets areas->utility1 flags if areas are modified
*/ */
int ClipAreaPolygon( PICKED_ITEMS_LIST* aNewZonesList, int ClipAreaPolygon( PICKED_ITEMS_LIST* aNewZonesList,
ZONE_CONTAINER* aCurrArea, ZONE_CONTAINER* aCurrArea,
bool bMessageBoxArc, bool bMessageBoxArc,
bool bMessageBoxInt, bool bMessageBoxInt,
bool bRetainArcs = true ); bool bRetainArcs = true );
/** /**
* Process an area that has been modified, by clipping its polygon against * Process an area that has been modified, by clipping its polygon against
@ -965,8 +997,8 @@ public:
/** /**
* Function CombineAllAreasInNet * Function CombineAllAreasInNet
* Checks all copper areas in net for intersections, combining them if found * Checks all copper areas in net for intersections, combining them if found
* @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful in undo commands * @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful
* can be NULL * in undo commands can be NULL
* @param aNetCode = net to consider * @param aNetCode = net to consider
* @param bMessageBox : if true display warning message box * @param bMessageBox : if true display warning message box
* @param bUseUtility : if true, don't check areas if both utility flags are 0 * @param bUseUtility : if true, don't check areas if both utility flags are 0
@ -981,8 +1013,8 @@ public:
/** /**
* Function RemoveArea * Function RemoveArea
* remove copper area from net, and put it in a deleted list (if exists) * remove copper area from net, and put it in a deleted list (if exists)
* @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful in undo commands * @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful
* can be NULL * in undo commands can be NULL
* @param area_to_remove = area to delete or put in deleted list * @param area_to_remove = area to delete or put in deleted list
*/ */
void RemoveArea( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_to_remove ); void RemoveArea( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_to_remove );
@ -1004,13 +1036,13 @@ public:
* 1 if intersection * 1 if intersection
* 2 if arcs intersect * 2 if arcs intersect
*/ */
int TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_test ); int TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_test );
/** /**
* Function CombineAreas * Function CombineAreas
* If possible, combine 2 copper areas * If possible, combine 2 copper areas
* @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful in undo commands * @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful
* can be NULL * in undo commands can be NULL
* @param area_ref = the main area (zone) * @param area_ref = the main area (zone)
* @param area_to_combine = the zone that can be merged with area_ref * @param area_to_combine = the zone that can be merged with area_ref
* area_ref must be BEFORE area_to_combine * area_ref must be BEFORE area_to_combine
@ -1019,9 +1051,9 @@ public:
* 1 if intersection * 1 if intersection
* 2 if arcs intersect * 2 if arcs intersect
*/ */
int CombineAreas( PICKED_ITEMS_LIST* aDeletedList, int CombineAreas( PICKED_ITEMS_LIST* aDeletedList,
ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_ref,
ZONE_CONTAINER* area_to_combine ); ZONE_CONTAINER* area_to_combine );
/** /**
* Function Test_Drc_Areas_Outlines_To_Areas_Outlines * Function Test_Drc_Areas_Outlines_To_Areas_Outlines
@ -1034,8 +1066,8 @@ public:
* @param aCreate_Markers: if true create DRC markers. False: do not creates anything * @param aCreate_Markers: if true create DRC markers. False: do not creates anything
* @return errors count * @return errors count
*/ */
int Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_Examine, int Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_Examine,
bool aCreate_Markers ); bool aCreate_Markers );
/****** function relative to ratsnest calculations: */ /****** function relative to ratsnest calculations: */
@ -1045,6 +1077,20 @@ public:
* @param aNetcode = netcode to analyze. if -1, analyze all nets * @param aNetcode = netcode to analyze. if -1, analyze all nets
*/ */
void Test_Connections_To_Copper_Areas( int aNetcode = -1 ); void Test_Connections_To_Copper_Areas( int aNetcode = -1 );
/**
* Function GetViaByPosition
* finds the first via at \a aPosition on \a aLayer.
* <p>
* This function does not use the normal hit test to locate a via which which tests
* if a position is within the via's bounding box. It tests for the actual locate
* of the via.
* </p>
* @param aPosition The wxPoint to HitTest() against.
* @param aLayerMask The layers to search. Use -1 for a don't care.
* @return TRACK* A point a to the SEGVIA object if found, else NULL.
*/
TRACK* GetViaByPosition( const wxPoint& aPosition, int aLayerMask = -1 );
}; };
#endif // #ifndef CLASS_BOARD_H #endif // #ifndef CLASS_BOARD_H

View File

@ -152,12 +152,6 @@ TRACK::TRACK( const TRACK& Source ) :
} }
/* Because of the way SEGVIA and SEGZONE are derived from TRACK and because there are
* virtual functions being used, we can no longer simply copy a TRACK and
* expect it to be a via or zone. We must construct a true SEGVIA or SEGZONE so its constructor
* can initialize the virtual function table properly. This factory type of
* function called Copy() can duplicate either a TRACK, SEGVIA, or SEGZONE.
*/
TRACK* TRACK::Copy() const TRACK* TRACK::Copy() const
{ {
if( Type() == TYPE_TRACK ) if( Type() == TYPE_TRACK )
@ -173,30 +167,14 @@ TRACK* TRACK::Copy() const
} }
/**
* Function GetClearance (virtual)
* returns the clearance in internal units. If \a aItem is not NULL then the
* returned clearance is the greater of this object's clearance and
* aItem's clearance. If \a aItem is NULL, then this objects
* clearance
* is returned.
* @param aItem is another BOARD_CONNECTED_ITEM or NULL
* @return int - the clearance in internal units.
*/
int TRACK::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const int TRACK::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
{ {
// Currently tracks have no specific clearance parameter // Currently tracks have no specific clearance parameter on a per track or per
// on a per track or per segment basis. // segment basis. The NETCLASS clearance is used.
// the NETCLASS clearance is used
return BOARD_CONNECTED_ITEM::GetClearance( aItem ); return BOARD_CONNECTED_ITEM::GetClearance( aItem );
} }
/**
* Function GetDrillValue
* calculate the drill value for vias (m_Drill if > 0, or default drill value for the Netclass
* @return real drill_value
*/
int TRACK::GetDrillValue() const int TRACK::GetDrillValue() const
{ {
if( Type() != TYPE_VIA ) if( Type() != TYPE_VIA )
@ -215,7 +193,6 @@ int TRACK::GetDrillValue() const
} }
// return true if segment length = 0
bool TRACK::IsNull() bool TRACK::IsNull()
{ {
if( ( Type() != TYPE_VIA ) && ( m_Start == m_End ) ) if( ( Type() != TYPE_VIA ) && ( m_Start == m_End ) )
@ -225,13 +202,6 @@ bool TRACK::IsNull()
} }
/* Return:
* STARTPOINT if point if near (dist = min_dist) star point
* ENDPOINT if point if near (dist = min_dist) end point
* STARTPOINT|ENDPOINT if point if near (dist = min_dist) both ends
* 0 if no
* if min_dist < 0: min_dist = track_width/2
*/
int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
{ {
int result = 0; int result = 0;
@ -331,12 +301,6 @@ EDA_RECT TRACK::GetBoundingBox() const
} }
/**
* Function Rotate
* Rotate this object.
* @param aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
void TRACK::Rotate( const wxPoint& aRotCentre, int aAngle ) void TRACK::Rotate( const wxPoint& aRotCentre, int aAngle )
{ {
RotatePoint( &m_Start, aRotCentre, aAngle ); RotatePoint( &m_Start, aRotCentre, aAngle );
@ -344,11 +308,6 @@ void TRACK::Rotate( const wxPoint& aRotCentre, int aAngle )
} }
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param aCentre - the rotation point.
*/
void TRACK::Flip( const wxPoint& aCentre ) void TRACK::Flip( const wxPoint& aCentre )
{ {
m_Start.y = aCentre.y - (m_Start.y - aCentre.y); m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
@ -366,7 +325,6 @@ void TRACK::Flip( const wxPoint& aCentre )
// see class_track.h // see class_track.h
// SEGVIA and SEGZONE inherit this version
SEARCH_RESULT TRACK::Visit( INSPECTOR* inspector, const void* testData, SEARCH_RESULT TRACK::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ) const KICAD_T scanTypes[] )
{ {
@ -400,9 +358,6 @@ bool SEGVIA::IsOnLayer( int layer_number ) const
} }
/* Return the mask layer for this.
* for a via, there is more than one layer used
*/
int TRACK::ReturnMaskLayer() int TRACK::ReturnMaskLayer()
{ {
if( Type() == TYPE_VIA ) if( Type() == TYPE_VIA )
@ -435,14 +390,6 @@ int TRACK::ReturnMaskLayer()
} }
/** Set the .m_Layer member param:
* For a via m_Layer contains the 2 layers :
* top layer and bottom layer used by the via.
* The via connect all layers from top layer to bottom layer
* 4 bits for the first layer and 4 next bits for the secaon layer
* @param top_layer = first layer connected by the via
* @param bottom_layer = last layer connected by the via
*/
void SEGVIA::SetLayerPair( int top_layer, int bottom_layer ) void SEGVIA::SetLayerPair( int top_layer, int bottom_layer )
{ {
if( Shape() == VIA_THROUGH ) if( Shape() == VIA_THROUGH )
@ -458,13 +405,6 @@ void SEGVIA::SetLayerPair( int top_layer, int bottom_layer )
} }
/**
* Function ReturnLayerPair
* Return the 2 layers used by the via (the via actually uses
* all layers between these 2 layers)
* @param top_layer = pointer to the first layer (can be null)
* @param bottom_layer = pointer to the last layer (can be null)
*/
void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const
{ {
int b_layer = LAYER_N_BACK; int b_layer = LAYER_N_BACK;
@ -506,9 +446,6 @@ TRACK* TRACK::GetBestInsertPoint( BOARD* aPcb )
} }
/* Search (within the track linked list) the first segment matching the netcode
* ( the linked list is always sorted by net codes )
*/
TRACK* TRACK::GetStartNetCode( int NetCode ) TRACK* TRACK::GetStartNetCode( int NetCode )
{ {
TRACK* Track = this; TRACK* Track = this;
@ -538,9 +475,6 @@ TRACK* TRACK::GetStartNetCode( int NetCode )
} }
/* Search (within the track linked list) the last segment matching the netcode
* ( the linked list is always sorted by net codes )
*/
TRACK* TRACK::GetEndNetCode( int NetCode ) TRACK* TRACK::GetEndNetCode( int NetCode )
{ {
TRACK* NextS, * Track = this; TRACK* NextS, * Track = this;
@ -586,8 +520,8 @@ bool TRACK::Save( FILE* aFile ) const
m_Start.x, m_Start.y, m_End.x, m_End.y, m_Width, m_Drill ); m_Start.x, m_Start.y, m_End.x, m_End.y, m_Width, m_Drill );
fprintf( aFile, "De %d %d %d %lX %X\n", fprintf( aFile, "De %d %d %d %lX %X\n",
m_Layer, type, GetNet(), m_Layer, type, GetNet(),
m_TimeStamp, ReturnStatus() ); m_TimeStamp, ReturnStatus() );
return true; return true;
} }
@ -667,6 +601,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint&
m_Start.y + aOffset.y, radius, m_Width, color ); m_Start.y + aOffset.y, radius, m_Width, color );
} }
} }
return; return;
} }
@ -838,8 +773,9 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
// Draw the via hole if the display option allows it // Draw the via hole if the display option allows it
if( DisplayOpt.m_DisplayViaMode != VIA_HOLE_NOT_SHOW ) if( DisplayOpt.m_DisplayViaMode != VIA_HOLE_NOT_SHOW )
{ {
if( (DisplayOpt.m_DisplayViaMode == ALL_VIA_HOLE_SHOW) // Display all drill holes requested // Display all drill holes requested or Display non default holes requested
|| ( (drill_radius > 0 ) && !IsDrillDefault() ) ) // Or Display non default holes requested if( (DisplayOpt.m_DisplayViaMode == ALL_VIA_HOLE_SHOW)
|| ( (drill_radius > 0 ) && !IsDrillDefault() ) )
{ {
if( fillvia ) if( fillvia )
{ {
@ -879,8 +815,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
if( DisplayOpt.ShowTrackClearanceMode == SHOW_CLEARANCE_ALWAYS ) if( DisplayOpt.ShowTrackClearanceMode == SHOW_CLEARANCE_ALWAYS )
GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, radius + GetClearance(), 0, color ); GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, radius + GetClearance(), 0, color );
// for Micro Vias, draw a partial cross : // for Micro Vias, draw a partial cross : X on component layer, or + on copper layer
// X on component layer, or + on copper layer
// (so we can see 2 superimposed microvias ): // (so we can see 2 superimposed microvias ):
if( Shape() == VIA_MICROVIA ) if( Shape() == VIA_MICROVIA )
{ {
@ -918,8 +853,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
m_Start.y + aOffset.y + ax, 0, color ); m_Start.y + aOffset.y + ax, 0, color );
} }
// for Buried Vias, draw a partial line : // for Buried Vias, draw a partial line : orient depending on layer pair
// orient depending on layer pair
// (so we can see superimposed buried vias ): // (so we can see superimposed buried vias ):
if( Shape() == VIA_BLIND_BURIED ) if( Shape() == VIA_BLIND_BURIED )
{ {
@ -967,7 +901,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
if( DC->LogicalToDeviceXRel( tsize ) >= 6 ) if( DC->LogicalToDeviceXRel( tsize ) >= 6 )
{ {
tsize = (tsize * 8) / 10; // small reduction to give a better look, inside via tsize = (tsize * 8) / 10; // small reduction to give a better look, inside via
DrawGraphicText( panel, DC, m_Start, DrawGraphicText( panel, DC, m_Start,
WHITE, net->GetShortNetname(), 0, wxSize( tsize, tsize ), WHITE, net->GetShortNetname(), 0, wxSize( tsize, tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7,
@ -1026,13 +960,6 @@ void TRACK::DisplayInfo( EDA_DRAW_FRAME* frame )
} }
/*
* Function DisplayInfoBase
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* Display info about the track segment only, and does not calculate the full track length
* @param frame A EDA_DRAW_FRAME in which to print status information.
*/
void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame ) void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
{ {
wxString msg; wxString msg;
@ -1071,7 +998,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
frame->AppendMsgPanel( _( "NetName" ), msg, RED ); frame->AppendMsgPanel( _( "NetName" ), msg, RED );
/* Display net code : (usefull in test or debug) */ /* Display net code : (useful in test or debug) */
msg.Printf( wxT( "%d .%d" ), GetNet(), GetSubNet() ); msg.Printf( wxT( "%d .%d" ), GetNet(), GetSubNet() );
frame->AppendMsgPanel( _( "NetCode" ), msg, RED ); frame->AppendMsgPanel( _( "NetCode" ), msg, RED );
} }
@ -1148,12 +1075,6 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
} }
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool TRACK::HitTest( const wxPoint& refPos ) bool TRACK::HitTest( const wxPoint& refPos )
{ {
int radius = m_Width >> 1; int radius = m_Width >> 1;
@ -1180,13 +1101,6 @@ bool TRACK::HitTest( const wxPoint& refPos )
} }
/**
* Function HitTest (overlaid)
* tests if the given EDA_RECT intersect this object.
* For now, an ending point must be inside this rect.
* @param refArea an EDA_RECT to test
* @return bool - true if a hit, else false
*/
bool TRACK::HitTest( EDA_RECT& refArea ) bool TRACK::HitTest( EDA_RECT& refArea )
{ {
if( refArea.Contains( m_Start ) ) if( refArea.Contains( m_Start ) )
@ -1199,6 +1113,58 @@ bool TRACK::HitTest( EDA_RECT& refArea )
} }
TRACK* TRACK::GetVia( const wxPoint& aPosition, int aLayerMask )
{
TRACK* track;
for( track = this; track; track = track->Next() )
{
if( track->Type() != TYPE_VIA )
continue;
if( !track->HitTest( aPosition ) )
continue;
if( track->GetState( BUSY | IS_DELETED ) )
continue;
if( aLayerMask < 0 )
break;
if( track->IsOnLayer( aLayerMask ) )
break;
}
return track;
}
TRACK* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask )
{
TRACK* trace;
for( trace = this; trace != NULL; trace = trace->Next() )
{
if( trace->Type() == TYPE_VIA )
{
if( aPosition == trace->m_Start )
{
if( trace->GetState( BUSY | IS_DELETED ) == 0 )
{
if( aLayerMask & trace->ReturnMaskLayer() )
return trace;
}
}
}
if( trace == aEndTrace )
break;
}
return NULL;
}
wxString TRACK::GetSelectMenuText() const wxString TRACK::GetSelectMenuText() const
{ {
wxString text; wxString text;
@ -1231,13 +1197,6 @@ wxString TRACK::GetSelectMenuText() const
#if defined(DEBUG) #if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void TRACK::Show( int nestLevel, std::ostream& os ) void TRACK::Show( int nestLevel, std::ostream& os )
{ {
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
@ -1258,13 +1217,6 @@ void TRACK::Show( int nestLevel, std::ostream& os )
} }
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void SEGVIA::Show( int nestLevel, std::ostream& os ) void SEGVIA::Show( int nestLevel, std::ostream& os )
{ {
const char* cp; const char* cp;
@ -1355,5 +1307,4 @@ wxString TRACK::ShowState( int stateBits )
return ret; return ret;
} }
#endif #endif

View File

@ -1,6 +1,7 @@
/*******************************************************************/ /**
/* class_track.h: definitions relatives to tracks, vias and zones */ * @file class_track.h
/*******************************************************************/ * @brief Definitions for tracks, vias and zones.
*/
#ifndef CLASS_TRACK_H #ifndef CLASS_TRACK_H
#define CLASS_TRACK_H #define CLASS_TRACK_H
@ -52,15 +53,20 @@ public:
* Function Copy * Function Copy
* will copy this object whether it is a TRACK or a SEGVIA returning * will copy this object whether it is a TRACK or a SEGVIA returning
* the corresponding type. * the corresponding type.
* Because of the way SEGVIA and SEGZONE are derived from TRACK and because there are
* virtual functions being used, we can no longer simply copy a TRACK and
* expect it to be a via or zone. We must construct a true SEGVIA or SEGZONE so its
* constructor can initialize the virtual function table properly. This factory type
* of function called Copy() can duplicate either a TRACK, SEGVIA, or SEGZONE.
*
* @return - TRACK*, SEGVIA*, or SEGZONE*, declared as the least common * @return - TRACK*, SEGVIA*, or SEGZONE*, declared as the least common
* denominator: TRACK * denominator: TRACK
*/ */
TRACK* Copy() const; TRACK* Copy() const;
TRACK* Next() const { return (TRACK*) Pnext; } TRACK* Next() const { return (TRACK*) Pnext; }
TRACK* Back() const { return (TRACK*) Pback; } TRACK* Back() const { return (TRACK*) Pback; }
/** /**
* Function Move * Function Move
* move this object. * move this object.
@ -105,7 +111,7 @@ public:
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** /**
* Function GetBestInsertPoint * Function GetBestInsertPoint
@ -115,24 +121,24 @@ public:
* @param aPcb The BOARD to search for the insertion point. * @param aPcb The BOARD to search for the insertion point.
* @return TRACK* - the item found in the linked list (or NULL if no track) * @return TRACK* - the item found in the linked list (or NULL if no track)
*/ */
TRACK* GetBestInsertPoint( BOARD* aPcb ); TRACK* GetBestInsertPoint( BOARD* aPcb );
/* Search (within the track linked list) the first segment matching the netcode /* Search (within the track linked list) the first segment matching the netcode
* ( the linked list is always sorted by net codes ) * ( the linked list is always sorted by net codes )
*/ */
TRACK* GetStartNetCode( int NetCode ); TRACK* GetStartNetCode( int NetCode );
/* Search (within the track linked list) the last segment matching the netcode /* Search (within the track linked list) the last segment matching the netcode
* ( the linked list is always sorted by net codes ) * ( the linked list is always sorted by net codes )
*/ */
TRACK* GetEndNetCode( int NetCode ); TRACK* GetEndNetCode( int NetCode );
/** /**
* Function GetLength * Function GetLength
* returns the length of the track using the hypotenuse calculation. * returns the length of the track using the hypotenuse calculation.
* @return double - the length of the track * @return double - the length of the track
*/ */
double GetLength() const double GetLength() const
{ {
int dx = m_Start.x - m_End.x; int dx = m_Start.x - m_End.x;
int dy = m_Start.y - m_End.y; int dy = m_Start.y - m_End.y;
@ -142,8 +148,8 @@ public:
/* Display on screen: */ /* Display on screen: */
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode,
const wxPoint& aOffset = ZeroOffset ); const wxPoint& aOffset = ZeroOffset );
/* divers */ /* divers */
int Shape() const { return m_Shape & 0xFF; } int Shape() const { return m_Shape & 0xFF; }
@ -196,15 +202,22 @@ public:
* TRACK segment or SEGVIA physically resides. * TRACK segment or SEGVIA physically resides.
* @return int - a layer mask, see pcbstruct.h's LAYER_BACK, etc. * @return int - a layer mask, see pcbstruct.h's LAYER_BACK, etc.
*/ */
int ReturnMaskLayer(); int ReturnMaskLayer();
int IsPointOnEnds( const wxPoint& point, int min_dist = 0 ); /**
* Function IsPointOnEnds
* returns STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if
* point if near (dist = min_dist) end point,STARTPOINT|ENDPOINT if point if near
* (dist = min_dist) both ends, or 0 if none of the above.
* if min_dist < 0: min_dist = track_width/2
*/
int IsPointOnEnds( const wxPoint& point, int min_dist = 0 );
/** /**
* Function IsNull * Function IsNull
* returns true if segment length is zero. * returns true if segment length is zero.
*/ */
bool IsNull(); bool IsNull();
/** /**
* Function DisplayInfo * Function DisplayInfo
@ -214,7 +227,7 @@ public:
* Display info about the track segment and the full track length * Display info about the track segment and the full track length
* @param frame A EDA_DRAW_FRAME in which to print status information. * @param frame A EDA_DRAW_FRAME in which to print status information.
*/ */
void DisplayInfo( EDA_DRAW_FRAME* frame ); void DisplayInfo( EDA_DRAW_FRAME* frame );
/** /**
* Function DisplayInfoBase * Function DisplayInfoBase
@ -223,13 +236,13 @@ public:
* Display info about the track segment only, and does not calculate the full track length * Display info about the track segment only, and does not calculate the full track length
* @param frame A EDA_DRAW_FRAME in which to print status information. * @param frame A EDA_DRAW_FRAME in which to print status information.
*/ */
void DisplayInfoBase( EDA_DRAW_FRAME* frame ); void DisplayInfoBase( EDA_DRAW_FRAME* frame );
/** /**
* Function ShowWidth * Function ShowWidth
* returns the width of the track in displayable user units. * returns the width of the track in displayable user units.
*/ */
wxString ShowWidth() const; wxString ShowWidth() const;
/** /**
* Function Visit * Function Visit
@ -244,8 +257,8 @@ public:
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE, and determined by the inspector. * else SCAN_CONTINUE, and determined by the inspector.
*/ */
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData, SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ); const KICAD_T scanTypes[] );
/** /**
@ -254,7 +267,7 @@ public:
* @param refPos A wxPoint to test * @param refPos A wxPoint to test
* @return bool - true if a hit, else false * @return bool - true if a hit, else false
*/ */
bool HitTest( const wxPoint& refPos ); bool HitTest( const wxPoint& refPos );
/** /**
* Function HitTest (overlaid) * Function HitTest (overlaid)
@ -263,7 +276,29 @@ public:
* @param refArea an EDA_RECT to test * @param refArea an EDA_RECT to test
* @return bool - true if a hit, else false * @return bool - true if a hit, else false
*/ */
bool HitTest( EDA_RECT& refArea ); bool HitTest( EDA_RECT& refArea );
/**
* Function GetVia
* finds the first SEGVIA object at \a aPosition on \a aLayer starting at the trace.
*
* @param aPosition The wxPoint to HitTest() against.
* @param aLayerMask The layer to match, pass -1 for a don't care.
* @return A pointer to a SEGVIA object if found, else NULL.
*/
TRACK* GetVia( const wxPoint& aPosition, int aLayerMask = -1 );
/**
* Function GetVia
* finds the first SEGVIA object at \a aPosition on \a aLayer starting at the trace
* and ending at \a aEndTrace.
*
* @param aEndTrace Pointer to the last TRACK object to end search.
* @param aPosition The wxPoint to HitTest() against.
* @param aLayerMask The layers to match, pass -1 for a don't care.
* @return A pointer to a SEGVIA object if found, else NULL.
*/
TRACK* GetVia( TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask );
/** /**
* Function GetClass * Function GetClass
@ -348,9 +383,8 @@ public:
} }
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode,
const wxPoint& aOffset = ZeroOffset ); const wxPoint& aOffset = ZeroOffset );
/** /**
* Function IsOnLayer * Function IsOnLayer
@ -359,10 +393,28 @@ public:
* @param aLayer the layer to test for. * @param aLayer the layer to test for.
* @return bool - true if on given layer, else false. * @return bool - true if on given layer, else false.
*/ */
bool IsOnLayer( int aLayer ) const; bool IsOnLayer( int aLayer ) const;
void SetLayerPair( int top_layer, int bottom_layer ); /**
void ReturnLayerPair( int* top_layer, int* bottom_layer ) const; * Function SetLayerPair
* set the .m_Layer member param:
* For a via m_Layer contains the 2 layers :
* top layer and bottom layer used by the via.
* The via connect all layers from top layer to bottom layer
* 4 bits for the first layer and 4 next bits for the secaon layer
* @param top_layer = first layer connected by the via
* @param bottom_layer = last layer connected by the via
*/
void SetLayerPair( int top_layer, int bottom_layer );
/**
* Function ReturnLayerPair
* Return the 2 layers used by the via (the via actually uses
* all layers between these 2 layers)
* @param top_layer = pointer to the first layer (can be null)
* @param bottom_layer = pointer to the last layer (can be null)
*/
void ReturnLayerPair( int* top_layer, int* bottom_layer ) const;
/** /**
* Function GetPosition * Function GetPosition
@ -375,7 +427,7 @@ public:
} }
void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; } void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; }
/** /**
* Function GetClass * Function GetClass

View File

@ -96,17 +96,19 @@ void RemoteCommand( const char* cmdline )
if( netcode > 0 ) /* highlight the pad net*/ if( netcode > 0 ) /* highlight the pad net*/
{ {
pcb->HightLightON(); pcb->HighLightON();
pcb->SetHightLightNet( netcode ); pcb->SetHighLightNet( netcode );
} }
else else
{ {
pcb->HightLightOFF(); pcb->HighLightOFF();
pcb->SetHightLightNet( -1 ); pcb->SetHighLightNet( -1 );
} }
if( module == NULL ) if( module == NULL )
{
msg.Printf( _( "%s not found" ), GetChars( modName ) ); msg.Printf( _( "%s not found" ), GetChars( modName ) );
}
else if( pad == NULL ) else if( pad == NULL )
{ {
msg.Printf( _( "%s pin %s not found" ), GetChars( modName ), GetChars( pinName ) ); msg.Printf( _( "%s pin %s not found" ), GetChars( modName ), GetChars( pinName ) );

View File

@ -78,7 +78,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
{ {
DrawPanel->SetMouseCapture( NULL, NULL ); DrawPanel->SetMouseCapture( NULL, NULL );
if( GetBoard()->IsHightLightNetON() ) if( GetBoard()->IsHighLightNetON() )
High_Light( DC ); High_Light( DC );
SetCurItem( NULL ); SetCurItem( NULL );

View File

@ -1290,8 +1290,7 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
if( DisplayOpt.DisplayZonesMode != 0 ) if( DisplayOpt.DisplayZonesMode != 0 )
DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) ); DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) );
if( !GetBoard()->IsHightLightNetON() && if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) )
(GetBoard()->GetHightLightNetCode() > 0 ) )
High_Light( &dc ); High_Light( &dc );
break; break;

View File

@ -14,89 +14,6 @@
#include "protos.h" #include "protos.h"
/*
* Exchange layer the track pointed to by the mouse:
* The track must be on one layer of work,
* It is put on another layer of work, if possible
* (Or DRC = Off).
*/
void PCB_EDIT_FRAME::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
{
int ii;
TRACK* pt_track;
int l1, l2, nb_segm;
if( ( pt_segm == NULL ) || ( pt_segm->Type() == TYPE_ZONE ) )
{
return;
}
l1 = Route_Layer_TOP; l2 = Route_Layer_BOTTOM;
pt_track = MarkTrace( GetBoard(), pt_segm, &nb_segm, NULL, NULL, true );
if ( DC )
DrawTraces( DrawPanel, DC, pt_track, nb_segm, GR_XOR );
/* Clear the BUSY flag and backup member. Param layer original. */
ii = nb_segm; pt_segm = pt_track;
for( ; ii > 0; ii--, pt_segm = (TRACK*) pt_segm->Next() )
{
pt_segm->SetState( BUSY, OFF );
pt_segm->m_Param = pt_segm->GetLayer(); /* For backup. */
}
ii = 0; pt_segm = pt_track;
for( ; ii < nb_segm; ii++, pt_segm = (TRACK*) pt_segm->Next() )
{
if( pt_segm->Type() == TYPE_VIA )
continue;
/* Invert layers. */
if( pt_segm->GetLayer() == l1 )
pt_segm->SetLayer( l2 );
else if( pt_segm->GetLayer() == l2 )
pt_segm->SetLayer( l1 );
if( Drc_On && BAD_DRC==m_drc->Drc( pt_segm, GetBoard()->m_Track ) )
{
/* Discard changes. */
ii = 0;
pt_segm = pt_track;
for( ; ii < nb_segm; ii++, pt_segm = pt_segm->Next() )
{
pt_segm->SetLayer( pt_segm->m_Param );
}
if( DC )
DrawTraces( DrawPanel, DC, pt_track, nb_segm, GR_OR );
DisplayError( this, _( "Drc error, canceled" ) );
return;
}
}
DrawTraces( DrawPanel, DC, pt_track, nb_segm, GR_OR | GR_SURBRILL );
/* Control of segment end point, is it on a pad? */
ii = 0;
pt_segm = pt_track;
for( ; ii < nb_segm; pt_segm = pt_segm->Next(), ii++ )
{
pt_segm->start = Locate_Pad_Connecte( GetBoard(), pt_segm, START );
pt_segm->end = Locate_Pad_Connecte( GetBoard(), pt_segm, END );
}
test_1_net_connexion( DC, pt_track->GetNet() );
pt_track->DisplayInfo( this );
OnModify();
}
bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
{ {
unsigned itmp; unsigned itmp;
@ -113,7 +30,8 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
} }
/* Avoid more than one via on the current location: */ /* Avoid more than one via on the current location: */
if( Locate_Via( GetBoard(), g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) ) if( GetBoard()->GetViaByPosition( g_CurrentTrackSegment->m_End,
g_CurrentTrackSegment->GetLayer() ) )
return false; return false;
for( TRACK* segm = g_FirstTrackSegment; segm; segm = segm->Next() ) for( TRACK* segm = g_FirstTrackSegment; segm; segm = segm->Next() )
@ -150,7 +68,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
via->m_Flags = IS_NEW; via->m_Flags = IS_NEW;
via->m_Shape = GetBoard()->GetBoardDesignSettings()->m_CurrentViaType; via->m_Shape = GetBoard()->GetBoardDesignSettings()->m_CurrentViaType;
via->m_Width = GetBoard()->GetCurrentViaSize(); via->m_Width = GetBoard()->GetCurrentViaSize();
via->SetNet( GetBoard()->GetHightLightNetCode() ); via->SetNet( GetBoard()->GetHighLightNetCode() );
via->m_Start = via->m_End = g_CurrentTrackSegment->m_End; via->m_Start = via->m_End = g_CurrentTrackSegment->m_End;
// Usual via is from copper to component. // Usual via is from copper to component.
@ -267,10 +185,6 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
} }
/* Displays:
* The status of the net on top of the screen segment advanced by mouse.
* PCB status or bottom of screen if no segment peak.
*/
void PCB_EDIT_FRAME::DisplayNetStatus( wxDC* DC ) void PCB_EDIT_FRAME::DisplayNetStatus( wxDC* DC )
{ {
TRACK* pt_segm; TRACK* pt_segm;
@ -286,11 +200,6 @@ void PCB_EDIT_FRAME::DisplayNetStatus( wxDC* DC )
} }
/* Draw ratsnest.
*
* The net edge pad with mouse or module locates the mouse.
* Delete if the ratsnest if no module or pad is selected.
*/
void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC ) void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC )
{ {
D_PAD* pt_pad = NULL; D_PAD* pt_pad = NULL;
@ -386,8 +295,6 @@ void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC )
} }
/* High light the unconnected pads
*/
void PCB_EDIT_FRAME::HighlightUnconnectedPads( wxDC* DC ) void PCB_EDIT_FRAME::HighlightUnconnectedPads( wxDC* DC )
{ {
for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ ) for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )

View File

@ -39,13 +39,13 @@ static void Abort_Create_Track( EDA_DRAW_PANEL* Panel, wxDC* DC )
/* Erase the current drawing */ /* Erase the current drawing */
ShowNewTrackWhenMovingCursor( Panel, DC, wxDefaultPosition, false ); ShowNewTrackWhenMovingCursor( Panel, DC, wxDefaultPosition, false );
if( pcb->IsHightLightNetON() ) if( pcb->IsHighLightNetON() )
frame->High_Light( DC ); frame->High_Light( DC );
pcb->PopHightLight(); pcb->PopHighLight();
if( pcb->IsHightLightNetON() ) if( pcb->IsHighLightNetON() )
pcb->DrawHighLight( Panel, DC, pcb->GetHightLightNetCode() ); pcb->DrawHighLight( Panel, DC, pcb->GetHighLightNetCode() );
frame->MsgPanel->EraseMsgBox(); frame->MsgPanel->EraseMsgBox();
@ -92,16 +92,16 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC )
// Prepare the undo command info // Prepare the undo command info
s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be necessary, but... s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be necessary, but...
GetBoard()->PushHightLight(); GetBoard()->PushHighLight();
// erase old highlight // erase old highlight
if( GetBoard()->IsHightLightNetON() ) if( GetBoard()->IsHighLightNetON() )
High_Light( DC ); High_Light( DC );
g_CurrentTrackList.PushBack( new TRACK( GetBoard() ) ); g_CurrentTrackList.PushBack( new TRACK( GetBoard() ) );
g_CurrentTrackSegment->m_Flags = IS_NEW; g_CurrentTrackSegment->m_Flags = IS_NEW;
GetBoard()->SetHightLightNet(0); GetBoard()->SetHighLightNet( 0 );
// Search for a starting point of the new track, a track or pad // Search for a starting point of the new track, a track or pad
LockPoint = LocateLockPoint( GetBoard(), pos, layerMask ); LockPoint = LocateLockPoint( GetBoard(), pos, layerMask );
@ -114,12 +114,12 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC )
/* A pad is found: put the starting point on pad centre */ /* A pad is found: put the starting point on pad centre */
pos = pt_pad->m_Pos; pos = pt_pad->m_Pos;
GetBoard()->SetHightLightNet( pt_pad->GetNet() ); GetBoard()->SetHighLightNet( pt_pad->GetNet() );
} }
else /* A track segment is found */ else /* A track segment is found */
{ {
TrackOnStartPoint = (TRACK*) LockPoint; TrackOnStartPoint = (TRACK*) LockPoint;
GetBoard()->SetHightLightNet( TrackOnStartPoint->GetNet() ); GetBoard()->SetHighLightNet( TrackOnStartPoint->GetNet() );
CreateLockPoint( GetBoard(), pos, TrackOnStartPoint, &s_ItemsListPicker ); CreateLockPoint( GetBoard(), pos, TrackOnStartPoint, &s_ItemsListPicker );
} }
} }
@ -130,7 +130,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC )
zone = GetBoard()->HitTestForAnyFilledArea( pos, GetScreen()-> m_Active_Layer ); zone = GetBoard()->HitTestForAnyFilledArea( pos, GetScreen()-> m_Active_Layer );
if( zone ) if( zone )
GetBoard()->SetHightLightNet( zone->GetNet() ); GetBoard()->SetHighLightNet( zone->GetNet() );
} }
D( g_CurrentTrackList.VerifyListIntegrity(); ); D( g_CurrentTrackList.VerifyListIntegrity(); );
@ -139,11 +139,11 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC )
D( g_CurrentTrackList.VerifyListIntegrity(); ); D( g_CurrentTrackList.VerifyListIntegrity(); );
GetBoard()->HightLightON(); GetBoard()->HighLightON();
GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHightLightNetCode() ); GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHighLightNetCode() );
// Display info about track Net class, and init track and vias sizes: // Display info about track Net class, and init track and vias sizes:
g_CurrentTrackSegment->SetNet( GetBoard()->GetHightLightNetCode() ); g_CurrentTrackSegment->SetNet( GetBoard()->GetHighLightNetCode() );
GetBoard()->SetCurrentNetClass( g_CurrentTrackSegment->GetNetClassName() ); GetBoard()->SetCurrentNetClass( g_CurrentTrackSegment->GetNetClassName() );
g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer );
@ -463,7 +463,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC )
* possibly create an anchor. */ * possibly create an anchor. */
{ {
TRACK* adr_buf = (TRACK*) LockPoint; TRACK* adr_buf = (TRACK*) LockPoint;
GetBoard()->SetHightLightNet( adr_buf->GetNet() ); GetBoard()->SetHighLightNet( adr_buf->GetNet() );
/* Possible establishment of a hanging point. */ /* Possible establishment of a hanging point. */
LockPoint = CreateLockPoint( GetBoard(), LockPoint = CreateLockPoint( GetBoard(),
@ -527,13 +527,13 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC )
wxASSERT( g_CurrentTrackSegment == NULL ); wxASSERT( g_CurrentTrackSegment == NULL );
wxASSERT( g_CurrentTrackList.GetCount() == 0 ); wxASSERT( g_CurrentTrackList.GetCount() == 0 );
if( GetBoard()->IsHightLightNetON() ) if( GetBoard()->IsHighLightNetON() )
High_Light( DC ); High_Light( DC );
GetBoard()->PopHightLight(); GetBoard()->PopHighLight();
if( GetBoard()->IsHightLightNetON() ) if( GetBoard()->IsHighLightNetON() )
GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHightLightNetCode() ); GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHighLightNetCode() );
DrawPanel->SetMouseCapture( NULL, NULL ); DrawPanel->SetMouseCapture( NULL, NULL );
SetCurItem( NULL ); SetCurItem( NULL );

View File

@ -51,7 +51,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
GetScreen()->Init(); GetScreen()->Init();
GetScreen()->SetGrid( gridsize ); GetScreen()->SetGrid( gridsize );
GetBoard()->ResetHightLight(); GetBoard()->ResetHighLight();
// Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled) // Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled)
GetBoard()->SetEnabledLayers(ALL_LAYERS); GetBoard()->SetEnabledLayers(ALL_LAYERS);

View File

@ -13,68 +13,6 @@
/* Locates a via point pX, pY
* If layer < 0 will be located via whatever layer
* If layer = 0 .. 15 Via will be located according to its type:
* - Traverse: all layers
* - = Blind between layers useful
* - Blind idem
* Entry: coord point of reference, layer
* Output: NULL if not via
* (* TRACK) address via
*/
TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer )
{
TRACK* track;
for( track = Pcb->m_Track; track; track = track->Next() )
{
if( track->Type() != TYPE_VIA )
continue;
if( track->m_Start != pos )
continue;
if( track->GetState( BUSY | IS_DELETED ) )
continue;
if( layer < 0 )
break;
if( track->IsOnLayer( layer ) )
break;
}
return track;
}
TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& pos, int layer )
{
TRACK* track;
for( track = aStart; track; track = track->Next() )
{
if( track->Type() != TYPE_VIA )
continue;
if( !track->HitTest(pos) )
continue;
if( track->GetState( BUSY | IS_DELETED ) )
continue;
if( layer < 0 )
break;
if( track->IsOnLayer( layer ) )
break;
}
return track;
}
/* Locate the pad CONNECTED to a track /* Locate the pad CONNECTED to a track
* input: ptr_trace: pointer to the segment of track * input: ptr_trace: pointer to the segment of track
* Extr = flag = START -> beginning of the test segment * Extr = flag = START -> beginning of the test segment
@ -553,34 +491,3 @@ TRACK* GetTrace( TRACK* start_adr, TRACK* end_adr, const wxPoint& ref_pos, int M
return NULL; return NULL;
} }
/* Locates via through the point x, y, on layer data by masklayer.
* Search is done to address start_adr has end_adr.
* If end_adr = NULL, end search list
* Vias whose parameter has the State or IS_DELETED bit BUSY = 1 are ignored
*/
TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, const wxPoint& pos, int MaskLayer )
{
TRACK* PtSegm;
for( PtSegm = start_adr; PtSegm != NULL; PtSegm = PtSegm->Next() )
{
if( PtSegm->Type() == TYPE_VIA )
{
if( pos == PtSegm->m_Start )
{
if( PtSegm->GetState( BUSY | IS_DELETED ) == 0 )
{
if( MaskLayer & PtSegm->ReturnMaskLayer() )
return PtSegm;
}
}
}
if( PtSegm == end_adr )
break;
}
return NULL;
}

View File

@ -1,8 +1,8 @@
/********************************************************/ /*********************************/
/* magnetic_tracks_functions.cpp */ /* magnetic_tracks_functions.cpp */
/********************************************************/ /*********************************/
/* functions used to controle the cursor position, when creating a track /* functions used to control the cursor position, when creating a track
* and when the "magnetic tracks" option is on * and when the "magnetic tracks" option is on
* (the current created track is kept near existing tracks * (the current created track is kept near existing tracks
* the distance is the clearance between tracks) * the distance is the clearance between tracks)
@ -171,7 +171,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr
int layer = screen->m_Active_Layer; int layer = screen->m_Active_Layer;
for( TRACK* via = m_Pcb->m_Track; for( TRACK* via = m_Pcb->m_Track;
via && (via = Locate_Via_Area( via, *curpos, layer )) != NULL; via && (via = via->GetVia( *curpos, layer )) != NULL;
via = via->Next() ) via = via->Next() )
{ {
if( via != currTrack ) // a via cannot influence itself if( via != currTrack ) // a via cannot influence itself
@ -206,8 +206,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr
} }
/* /*
* In two segment mode, ignore the final segment if it's inside a grid * In two segment mode, ignore the final segment if it's inside a grid square.
* square.
*/ */
if( !amMovingVia && currTrack && g_TwoSegmentTrackBuild && currTrack->Back() if( !amMovingVia && currTrack && g_TwoSegmentTrackBuild && currTrack->Back()
&& currTrack->m_Start.x - grid.x < currTrack->m_End.x && currTrack->m_Start.x - grid.x < currTrack->m_End.x
@ -259,7 +258,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr
// if track not via, or if its a via dragging but not with its adjacent track // if track not via, or if its a via dragging but not with its adjacent track
if( currTrack->Type() != TYPE_VIA if( currTrack->Type() != TYPE_VIA
|| ( currTrack->m_Start != track->m_Start && currTrack->m_Start != track->m_End )) || ( currTrack->m_Start != track->m_Start && currTrack->m_Start != track->m_End ))
{ {
if( distStart <= currTrack->m_Width/2 ) if( distStart <= currTrack->m_Width/2 )
{ {
@ -275,8 +274,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr
return true; return true;
} }
// @todo otherwise confine curpos such that it stays centered // @todo otherwise confine curpos such that it stays centered within "track"
// within "track"
} }
} }
} }

View File

@ -62,8 +62,8 @@ static void Abort_MoveTrack( EDA_DRAW_PANEL* Panel, wxDC* DC )
Panel->m_mouseCaptureCallback( Panel, DC, wxDefaultPosition, true ); Panel->m_mouseCaptureCallback( Panel, DC, wxDefaultPosition, true );
Panel->GetScreen()->SetCrossHairPosition( oldpos ); Panel->GetScreen()->SetCrossHairPosition( oldpos );
pcb->HightLightOFF(); pcb->HighLightOFF();
pcb->DrawHighLight( Panel, DC, pcb->GetHightLightNetCode() ); pcb->DrawHighLight( Panel, DC, pcb->GetHighLightNetCode() );
if( NewTrack ) if( NewTrack )
{ {
@ -119,10 +119,10 @@ static void Abort_MoveTrack( EDA_DRAW_PANEL* Panel, wxDC* DC )
// Clear the undo picker list: // Clear the undo picker list:
s_ItemsListPicker.ClearListAndDeleteItems(); s_ItemsListPicker.ClearListAndDeleteItems();
pcb->PopHightLight(); pcb->PopHighLight();
if( pcb->IsHightLightNetON() ) if( pcb->IsHighLightNetON() )
pcb->DrawHighLight( Panel, DC, pcb->GetHightLightNetCode() ); pcb->DrawHighLight( Panel, DC, pcb->GetHighLightNetCode() );
EraseDragList(); EraseDragList();
Panel->SetMouseCapture( NULL, NULL ); Panel->SetMouseCapture( NULL, NULL );
@ -665,9 +665,9 @@ void PCB_EDIT_FRAME::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int com
EraseDragList(); EraseDragList();
/* Change highlighted net: the new one will be highlighted */ /* Change highlighted net: the new one will be highlighted */
GetBoard()->PushHightLight(); GetBoard()->PushHighLight();
if( GetBoard()->IsHightLightNetON() ) if( GetBoard()->IsHighLightNetON() )
High_Light( DC ); High_Light( DC );
PosInit = GetScreen()->GetCrossHairPosition(); PosInit = GetScreen()->GetCrossHairPosition();
@ -742,10 +742,10 @@ void PCB_EDIT_FRAME::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int com
s_LastPos = PosInit; s_LastPos = PosInit;
DrawPanel->SetMouseCapture( Show_MoveNode, Abort_MoveTrack ); DrawPanel->SetMouseCapture( Show_MoveNode, Abort_MoveTrack );
GetBoard()->SetHightLightNet( track->GetNet() ); GetBoard()->SetHighLightNet( track->GetNet() );
GetBoard()->HightLightON(); GetBoard()->HighLightON();
GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHightLightNetCode() ); GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHighLightNetCode() );
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true ); DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true );
} }
@ -904,9 +904,9 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
s_EndSegmentPresent = false; s_EndSegmentPresent = false;
/* Change high light net: the new one will be highlighted */ /* Change high light net: the new one will be highlighted */
GetBoard()->PushHightLight(); GetBoard()->PushHighLight();
if( GetBoard()->IsHightLightNetON() ) if( GetBoard()->IsHighLightNetON() )
High_Light( DC ); High_Light( DC );
EraseDragList(); EraseDragList();
@ -944,9 +944,9 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
s_LastPos = GetScreen()->GetCrossHairPosition(); s_LastPos = GetScreen()->GetCrossHairPosition();
DrawPanel->SetMouseCapture( Show_Drag_Track_Segment_With_Cte_Slope, Abort_MoveTrack ); DrawPanel->SetMouseCapture( Show_Drag_Track_Segment_With_Cte_Slope, Abort_MoveTrack );
GetBoard()->SetHightLightNet( track->GetNet() ); GetBoard()->SetHighLightNet( track->GetNet() );
GetBoard()->HightLightON(); GetBoard()->HighLightON();
GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHightLightNetCode() ); GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHighLightNetCode() );
// Prepare the Undo command // Prepare the Undo command
ITEM_PICKER picker( NULL, UR_CHANGED ); ITEM_PICKER picker( NULL, UR_CHANGED );
@ -1038,13 +1038,13 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC )
SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED ); SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED );
s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
if( GetBoard()->IsHightLightNetON() ) if( GetBoard()->IsHighLightNetON() )
High_Light( DC ); High_Light( DC );
GetBoard()->PopHightLight(); GetBoard()->PopHighLight();
if( GetBoard()->IsHightLightNetON() ) if( GetBoard()->IsHighLightNetON() )
GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHightLightNetCode() ); GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHighLightNetCode() );
OnModify(); OnModify();
DrawPanel->SetMouseCapture( NULL, NULL ); DrawPanel->SetMouseCapture( NULL, NULL );

View File

@ -66,25 +66,6 @@ void DrawTraces( EDA_DRAW_PANEL* panel,
/* LOCATE.CPP : */ /* LOCATE.CPP : */
/****************/ /****************/
/* Find a pad by it's name om the module. */
TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer = -1 );
/**
* Function Locate_Via_Area
* finds the first SEGVIA which covers the given aPos with a matching layer.
* @param aStart The starting TRACK or SEGVIA in the BOARD's list.
* @param aPos The wxPoint to HitTest() against.
* @param aLayer The layer to match, pass -1 for a don't care.
* @return TRACK* - actually a SEGVIA* if found, else NULL.
*/
TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& aPos, int aLayer = ALL_LAYERS );
/* Locates the center through the point x, y, on layer data
* by masquelayer.
* Search is done to address start_adr has end_adr (not included)
*/
TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, const wxPoint& pos, int masquelayer );
/* Locates the center through the point x, y, on layer data /* Locates the center through the point x, y, on layer data
* by masquelayer. * by masquelayer.
* Search is done to address start_adr has end_adr (not included) * Search is done to address start_adr has end_adr (not included)

View File

@ -80,10 +80,10 @@ void PCB_EDIT_FRAME::ListNetsAndSelect( wxCommandEvent& event )
{ {
INSTALL_UNBUFFERED_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
if( GetBoard()->IsHightLightNetON() ) if( GetBoard()->IsHighLightNetON() )
High_Light( &dc ); High_Light( &dc );
GetBoard()->SetHightLightNet( netcode ); GetBoard()->SetHighLightNet( netcode );
High_Light( &dc ); High_Light( &dc );
} }
} }
@ -95,7 +95,8 @@ void PCB_EDIT_FRAME::ListNetsAndSelect( wxCommandEvent& event )
int PCB_EDIT_FRAME::Select_High_Light( wxDC* DC ) int PCB_EDIT_FRAME::Select_High_Light( wxDC* DC )
{ {
int netcode = -1; int netcode = -1;
if( GetBoard()->IsHightLightNetON() )
if( GetBoard()->IsHighLightNetON() )
High_Light( DC ); High_Light( DC );
// use this scheme because a pad is a higher priority than a track in the // use this scheme because a pad is a higher priority than a track in the
@ -139,7 +140,7 @@ int PCB_EDIT_FRAME::Select_High_Light( wxDC* DC )
} }
if( netcode >= 0 ) if( netcode >= 0 )
{ {
GetBoard()->SetHightLightNet( netcode ); GetBoard()->SetHighLightNet( netcode );
High_Light( DC ); High_Light( DC );
} }
@ -155,10 +156,10 @@ int PCB_EDIT_FRAME::Select_High_Light( wxDC* DC )
*/ */
void PCB_EDIT_FRAME::High_Light( wxDC* DC ) void PCB_EDIT_FRAME::High_Light( wxDC* DC )
{ {
if( GetBoard()->IsHightLightNetON() ) if( GetBoard()->IsHighLightNetON() )
GetBoard()->HightLightOFF(); GetBoard()->HighLightOFF();
else else
GetBoard()->HightLightON(); GetBoard()->HighLightON();
GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHightLightNetCode() ); GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHighLightNetCode() );
} }

View File

@ -14,18 +14,6 @@ extern int ReturnEndsTrack( TRACK* RefTrack, int NbSegm,
TRACK** StartTrack, TRACK** EndTrack ); TRACK** StartTrack, TRACK** EndTrack );
/**
* Function EraseRedundantTrack
* Called after creating a track
* Remove (if exists) the old track that have the same starting and the same
* ending point as the new created track (this is the redunding track)
* @param aDC = the current device context (can be NULL)
* @param aNewTrack = the new created track (a pointer to a segment of the
* track list)
* @param aNewTrackSegmentsCount = number of segments in this new track
* @param aItemsListPicker = the list picker to use for an undo command (can
* be NULL)
*/
int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
TRACK* aNewTrack, TRACK* aNewTrack,
int aNewTrackSegmentsCount, int aNewTrackSegmentsCount,
@ -41,9 +29,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
int netcode = aNewTrack->GetNet(); int netcode = aNewTrack->GetNet();
/* Reconstruct the complete track (the new track has to start on a segment of track).
/* Reconstruct the complete track (the new track has to start on a
* segment of track).
*/ */
ListSetState( aNewTrack, aNewTrackSegmentsCount, BUSY, OFF ); ListSetState( aNewTrack, aNewTrackSegmentsCount, BUSY, OFF );
@ -58,8 +44,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
wxASSERT( aNewTrack ); wxASSERT( aNewTrack );
#if 0 && defined(DEBUG) #if 0 && defined(DEBUG)
TRACK* EndNewTrack; /* The last segment of the list chained to TRACK* EndNewTrack; /* The last segment of the list chained to the track */
* the track */
EndNewTrack = aNewTrack; EndNewTrack = aNewTrack;
@ -110,7 +95,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
endmasklayer = EndTrack->ReturnMaskLayer(); endmasklayer = EndTrack->ReturnMaskLayer();
/* There may be a via or a pad on the end points. */ /* There may be a via or a pad on the end points. */
pt_segm = Fast_Locate_Via( m_Pcb->m_Track, NULL, start, startmasklayer ); pt_segm = m_Pcb->m_Track->GetVia( NULL, start, startmasklayer );
if( pt_segm ) if( pt_segm )
startmasklayer |= pt_segm->ReturnMaskLayer(); startmasklayer |= pt_segm->ReturnMaskLayer();
@ -122,7 +107,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
startmasklayer |= pt_pad->m_layerMask; startmasklayer |= pt_pad->m_layerMask;
} }
pt_segm = Fast_Locate_Via( m_Pcb->m_Track, NULL, end, endmasklayer ); pt_segm = m_Pcb->m_Track->GetVia( NULL, end, endmasklayer );
if( pt_segm ) if( pt_segm )
endmasklayer |= pt_segm->ReturnMaskLayer(); endmasklayer |= pt_segm->ReturnMaskLayer();
@ -133,8 +118,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
endmasklayer |= pt_pad->m_layerMask; endmasklayer |= pt_pad->m_layerMask;
} }
/* Mark as deleted a new track (which is not involved in the search for /* Mark as deleted a new track (which is not involved in the search for other connections)
* other connections)
*/ */
ListSetState( aNewTrack, aNewTrackSegmentsCount, IS_DELETED, ON ); ListSetState( aNewTrack, aNewTrackSegmentsCount, IS_DELETED, ON );
@ -190,9 +174,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
return 0; return 0;
} }
/* Mark trace as edited (which does not involve searching for other // Mark trace as edited (which does not involve searching for other tracks)
* tracks)
*/
ListSetState( aNewTrack, aNewTrackSegmentsCount, IS_DELETED, OFF ); ListSetState( aNewTrack, aNewTrackSegmentsCount, IS_DELETED, OFF );
ListSetState( aNewTrack, aNewTrackSegmentsCount, IN_EDIT, ON ); ListSetState( aNewTrack, aNewTrackSegmentsCount, IN_EDIT, ON );
@ -285,8 +267,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
} }
/* Set the bits of .m_State member to on off value, using bit mask State
/* Set the bits of .m_State member to onoff value, using bit mask State
* of a list of EDA_ITEM * of a list of EDA_ITEM
*/ */
static void ListSetState( EDA_ITEM* Start, int NbItem, int State, int onoff ) static void ListSetState( EDA_ITEM* Start, int NbItem, int State, int onoff )

View File

@ -194,8 +194,8 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, int aDrawMode, const wxPoint
Trace_Pads_Only( aPanel, DC, module, 0, 0, layerMask, aDrawMode ); Trace_Pads_Only( aPanel, DC, module, 0, 0, layerMask, aDrawMode );
} }
if( IsHightLightNetON() ) if( IsHighLightNetON() )
DrawHighLight( aPanel, DC, GetHightLightNetCode() ); DrawHighLight( aPanel, DC, GetHighLightNetCode() );
// draw the BOARD's markers last, otherwise the high light will erase any marker on a pad // draw the BOARD's markers last, otherwise the high light will erase any marker on a pad
for( unsigned i=0; i < m_markers.size(); ++i ) for( unsigned i=0; i < m_markers.size(); ++i )
@ -209,7 +209,7 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* aDrawPanel, wxDC* DC, int aNetCode )
{ {
int draw_mode; int draw_mode;
if( IsHightLightNetON() ) if( IsHighLightNetON() )
draw_mode = GR_SURBRILL | GR_OR; draw_mode = GR_SURBRILL | GR_OR;
else else
draw_mode = GR_AND | GR_SURBRILL; draw_mode = GR_AND | GR_SURBRILL;

View File

@ -10,11 +10,9 @@
#include "protos.h" #include "protos.h"
/* Functions to recognize a track. /* Functions to recognize a track.
* A track is a list of connected segments (or/and vias) * A track is a list of connected segments (or/and vias) from a starting to an ending point
* from a starting to an ending point * starting and ending points are a pad or a point with more than 2 segments connected
* starting and ending points are a pad or a point with more than 2 segments * (and obviously a dangling segment end)
*connected
* (and obviously a dangling segment end)
*/ */
typedef std::vector<TRACK*> TRACK_PTRS; // buffer of item candidates when typedef std::vector<TRACK*> TRACK_PTRS; // buffer of item candidates when
@ -22,10 +20,7 @@ typedef std::vector<TRACK*> TRACK_PTRS; // buffer of item candidates when
/* Local functions */ /* Local functions */
static void ChainMarkedSegments( BOARD* Pcb, static void ChainMarkedSegments( BOARD* Pcb, wxPoint ref_pos, int masklayer, TRACK_PTRS* aList );
wxPoint ref_pos,
int masklayer,
TRACK_PTRS* aList );
TRACK* MarkTrace( BOARD* aPcb, TRACK* MarkTrace( BOARD* aPcb,
@ -108,8 +103,7 @@ TRACK* MarkTrace( BOARD* aPcb,
} }
// Now examine selected vias and flag them if they are on the track // Now examine selected vias and flag them if they are on the track
// If a via is connected to only one or 2 segments, it is flagged (is on // If a via is connected to only one or 2 segments, it is flagged (is on the track)
// the track)
// If a via is connected to more than 2 segments, it is a track end, and it // If a via is connected to more than 2 segments, it is a track end, and it
// is removed from the list // is removed from the list
// go through the list backwards. // go through the list backwards.
@ -327,7 +321,7 @@ static void ChainMarkedSegments( BOARD* aPcb,
* is found we do not know at this time the number of connected items * is found we do not know at this time the number of connected items
* and we do not know if this via is on the track or finish the track * and we do not know if this via is on the track or finish the track
*/ */
pt_via = Fast_Locate_Via( aPcb->m_Track, NULL, aRef_pos, aLayerMask ); pt_via = aPcb->m_Track->GetVia( NULL, aRef_pos, aLayerMask );
if( pt_via ) if( pt_via )
{ {
@ -442,7 +436,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, TRACK** StartTrack, TRACK** En
continue; continue;
layerMask = Track->ReturnMaskLayer(); layerMask = Track->ReturnMaskLayer();
via = Fast_Locate_Via( RefTrack, TrackListEnd, Track->m_Start, layerMask ); via = RefTrack->GetVia( TrackListEnd, Track->m_Start, layerMask );
if( via ) if( via )
{ {
@ -489,7 +483,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, TRACK** StartTrack, TRACK** En
} }
layerMask = Track->ReturnMaskLayer(); layerMask = Track->ReturnMaskLayer();
via = Fast_Locate_Via( RefTrack, TrackListEnd, Track->m_End, layerMask ); via = RefTrack->GetVia( TrackListEnd, Track->m_End, layerMask );
if( via ) if( via )
{ {

View File

@ -158,13 +158,13 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_cont
{ {
if( zone_container->IsOnCopperLayer() ) /* Show the Net */ if( zone_container->IsOnCopperLayer() ) /* Show the Net */
{ {
if( GetBoard()->IsHightLightNetON() && DC ) if( GetBoard()->IsHighLightNetON() && DC )
{ {
High_Light( DC ); // Remove old hightlight selection High_Light( DC ); // Remove old hightlight selection
} }
g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet(); g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet();
GetBoard()->SetHightLightNet( zone_container->GetNet() ); GetBoard()->SetHighLightNet( zone_container->GetNet() );
if( DC ) if( DC )
High_Light( DC ); High_Light( DC );
@ -230,13 +230,13 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_co
/* Show the Net */ /* Show the Net */
if( zone_container->IsOnCopperLayer() ) /* Show the Net */ if( zone_container->IsOnCopperLayer() ) /* Show the Net */
{ {
if( GetBoard()->IsHightLightNetON() ) if( GetBoard()->IsHighLightNetON() )
{ {
High_Light( DC ); // Remove old hightlight selection High_Light( DC ); // Remove old hightlight selection
} }
g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet(); g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet();
GetBoard()->SetHightLightNet( zone_container->GetNet() ); GetBoard()->SetHighLightNet( zone_container->GetNet() );
High_Light( DC ); High_Light( DC );
} }
@ -495,9 +495,9 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
if( zone->IsOnCopperLayer() ) if( zone->IsOnCopperLayer() )
{ // Put a zone on a copper layer { // Put a zone on a copper layer
if ( GetBoard()->GetHightLightNetCode() > 0 ) if ( GetBoard()->GetHighLightNetCode() > 0 )
{ {
g_Zone_Default_Setting.m_NetcodeSelection = GetBoard()->GetHightLightNetCode(); g_Zone_Default_Setting.m_NetcodeSelection = GetBoard()->GetHighLightNetCode();
zone->SetNet( g_Zone_Default_Setting.m_NetcodeSelection ); zone->SetNet( g_Zone_Default_Setting.m_NetcodeSelection );
zone->SetNetNameFromNetCode( ); zone->SetNetNameFromNetCode( );
@ -541,12 +541,12 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
if( s_CurrentZone ) if( s_CurrentZone )
g_Zone_Default_Setting.m_NetcodeSelection = s_CurrentZone->GetNet(); g_Zone_Default_Setting.m_NetcodeSelection = s_CurrentZone->GetNet();
if( GetBoard()->IsHightLightNetON() ) if( GetBoard()->IsHighLightNetON() )
{ {
High_Light( DC ); // Remove old hightlight selection High_Light( DC ); // Remove old hightlight selection
} }
GetBoard()->SetHightLightNet( g_Zone_Default_Setting.m_NetcodeSelection ); GetBoard()->SetHighLightNet( g_Zone_Default_Setting.m_NetcodeSelection );
High_Light( DC ); High_Light( DC );
} }