diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index aa31cc9c82..1eb809acbf 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -831,7 +831,14 @@ public: */ bool Other_Layer_Route( TRACK* track, 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 ); + TRACK* Delete_Segment( wxDC* DC, TRACK* Track ); void Delete_Track( wxDC* DC, TRACK* Track ); void Delete_net( wxDC* DC, TRACK* Track ); @@ -900,7 +907,6 @@ public: */ 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_Track( TRACK* track, wxDC* DC, bool Flag_On ); void Attribut_net( wxDC* DC, int net_code, bool Flag_On ); @@ -1177,7 +1183,15 @@ public: void ReadAutoroutedTracks( 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 Clean_Pcb( wxDC* DC ); void InstallFindFrame( const wxPoint& pos, wxDC* DC ); diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index efe493b69b..df1054687e 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -15,14 +15,11 @@ */ wxPoint BOARD_ITEM::ZeroOffset( 0, 0 ); + // Current design settings (used also to read configs): BOARD_DESIGN_SETTINGS boardDesignSettings; -/*****************/ -/* Class BOARD: */ -/*****************/ - BOARD::BOARD( EDA_ITEM* parent, PCB_BASE_FRAME* frame ) : BOARD_ITEM( (BOARD_ITEM*)parent, TYPE_PCB ), m_NetClasses( this ) @@ -87,36 +84,19 @@ BOARD::~BOARD() } -/* - * Function PushHightLight - * save current hight light info for later use - */ -void BOARD::PushHightLight() +void BOARD::PushHighLight() { m_hightLightPrevious = m_hightLight; } -/* - * Function PopHightLight - * retrieve a previously saved hight light info - */ -void BOARD::PopHightLight() +void BOARD::PopHighLight() { m_hightLight = m_hightLightPrevious; 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 ) { 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 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() { 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() { 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 * 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; 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 ) { if( layer==LAYER_N_FRONT ) @@ -621,8 +580,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) aBoardItem->SetParent( this ); // Because the list of pads has changed, reset the status - // This indicate the list of pad and nets must be recalculated before - // use + // This indicate the list of pad and nets must be recalculated before use m_Status_Pcb = 0; break; @@ -654,7 +612,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) 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 ); switch( aBoardItem->Type() ) @@ -737,28 +695,24 @@ void BOARD::DeleteZONEOutlines() } -/* Calculate the track segment count */ int BOARD::GetNumSegmTrack() { return m_Track.GetCount(); } -/* Calculate the zone segment count */ int BOARD::GetNumSegmZone() { return m_Zone.GetCount(); } -// return the unconnection count unsigned BOARD::GetNoconnectCount() { return m_NbNoconnect; } -// return the active pad count ( pads with a netcode > 0 ) unsigned BOARD::GetNodesCount() { return m_NbNodes; @@ -858,9 +812,6 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) // virtual, see pcbstruct.h - -/* Display board statistics: pads, nets, connections.. count - */ void BOARD::DisplayInfo( EDA_DRAW_FRAME* frame ) { 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 // 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 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 // a non ordered list) because when it searches for a connexion, first // 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 { // 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 { // 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 ) { if( m_NetInfo->GetCount() == 0 ) @@ -1406,6 +1338,7 @@ bool BOARD::Save( FILE* aFile ) const // save the tracks & vias fprintf( aFile, "$TRACK\n" ); + for( item = m_Track; item; item = item->Next() ) if( !item->Save( aFile ) ) 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 ) { 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 ) { 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, int aStartLayer, int aEndLayer ) @@ -1507,8 +1420,8 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos, if( (layer < aStartLayer) || (layer > aEndLayer) ) continue; - if( area->GetState( BUSY ) ) // In locate functions we must skip - // tagged items with BUSY flag set. + // In locate functions we must skip tagged items with BUSY flag set. + if( area->GetState( BUSY ) ) continue; 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 error_count = 0; @@ -1555,8 +1455,9 @@ int BOARD::SetAreasNetCodesFromNetNames( void ) else { 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) -/** - * 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 ) { BOARD_ITEM* p; @@ -1630,9 +1550,7 @@ void BOARD::Show( int nestLevel, std::ostream& os ) p->Show( nestLevel + 1, os ); } - NestedSpace( nestLevel, os ) << "\n"; + NestedSpace( nestLevel, os ) << "\n"; } - #endif diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 6bcbf40485..4b129953cb 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -14,6 +14,9 @@ class ZONE_CONTAINER; +#define HISTORY_MAX_COUNT 8 + + /** * Enum LAYER_T * gives the allowed types of layers, same as Specctra DSN spec. @@ -41,7 +44,6 @@ struct LAYER // int m_Color; // bool m_Visible; // ? use flags in m_Color instead ? - /** * Function ShowType * converts a LAYER_T enum to a const char* @@ -78,8 +80,7 @@ public: bool operator ==( const VIA_DIMENSION& other ) const { - return (m_Diameter == other.m_Diameter) - && (m_Drill == other.m_Drill); + return (m_Diameter == other.m_Diameter) && (m_Drill == other.m_Drill); } @@ -87,94 +88,120 @@ public: { if( m_Diameter != other.m_Diameter ) return m_Diameter < other.m_Diameter; + 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; protected: - int m_netCode; // net selected for hightlight (-1 when no net selected ) - bool m_hightLightOn; // hightlight active + int m_netCode; // net selected for highlight (-1 when no net selected ) + bool m_highLightOn; // highlight active protected: void Clear() { m_netCode = -1; - m_hightLightOn = false; + m_highLightOn = false; } - HIGHT_LIGHT_INFO() + HIGH_LIGHT_INFO() { Clear(); } }; + /** * Class BOARD * holds information pertinent to a PCBNEW printed circuit board. */ -#define HISTORY_MAX_COUNT 8 class BOARD : public BOARD_ITEM { friend class PCB_EDIT_FRAME; private: - typedef std::vector MARKERS; // @todo: switch to boost:ptr_vector, and change ~BOARD() - MARKERS m_markers; ///< MARKER_PCBs for clearance problems, owned by pointer + // @todo: switch to boost:ptr_vector, and change ~BOARD() + typedef std::vector MARKERS; - typedef std::vector ZONE_CONTAINERS; // @todo: switch to boost::ptr_vector, and change ~BOARD() - ZONE_CONTAINERS m_ZoneDescriptorList; ///< edge zone descriptors, owned by pointer + /// MARKER_PCBs for clearance problems, owned by pointer. + MARKERS m_markers; + + // @todo: switch to boost::ptr_vector, and change ~BOARD() + typedef std::vector ZONE_CONTAINERS; + + /// edge zone descriptors, owned by pointer. + ZONE_CONTAINERS m_ZoneDescriptorList; LAYER m_Layer[NB_COPPER_LAYERS]; - // if true m_hightLight_NetCode is used - HIGHT_LIGHT_INFO m_hightLight; // current hight light data - HIGHT_LIGHT_INFO m_hightLightPrevious; // a previously stored hight light data + // if true m_hightLight_NetCode is used + HIGH_LIGHT_INFO m_hightLight; // current high light data + HIGH_LIGHT_INFO m_hightLightPrevious; // a previously stored high light data public: - PCB_BASE_FRAME* m_PcbFrame; // Window of visualization - 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) + PCB_BASE_FRAME* m_PcbFrame; // Window of visualization + EDA_RECT m_BoundaryBox; // Board size and position - DLIST m_Drawings; // linked list of lines & texts - DLIST m_Modules; // linked list of MODULEs - DLIST m_Track; // linked list of TRACKs and SEGVIAs - DLIST m_Zone; // linked list of SEGZONEs + /// Flags used in ratsnest calculation and update. + int m_Status_Pcb; - NETINFO_LIST* m_NetInfo; // nets info list (name, design constraints .. + /// Active pads (pads attached to a net ) count. + int m_NbNodes; - std::vector m_FullRatsnest; // Rastnest list for the BOARD - std::vector m_LocalRatsnest; /* Rastnest list relative to a given footprint - * (used while moving a footprint) */ + /// Active ratsnest count (ratsnests not already connected by tracks) + int m_NbNoconnect; - ZONE_CONTAINER* m_CurrentZoneContour; // zone contour currently in progress + DLIST m_Drawings; // linked list of lines & texts + DLIST m_Modules; // linked list of MODULEs + DLIST m_Track; // linked list of TRACKs and SEGVIAs + DLIST m_Zone; // linked list of SEGZONEs - NETCLASSES m_NetClasses; ///< List of current netclasses. There is always the default netclass - wxString m_CurrentNetClassName; /* Current net class name used to display netclass info. - * this is also the last used netclass after starting a track - */ + /// nets info list (name, design constraints .. + NETINFO_LIST* m_NetInfo; + /// Ratsnest list for the BOARD + std::vector m_FullRatsnest; + + /// Ratsnest list relative to a given footprint (used while moving a footprint). + std::vector 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: // the first value is always the value of the current NetClass // The others values are extra values - std::vector m_ViasDimensionsList; // vias size and drill list(max count = HISTORY_MAX_COUNT) + + /// Vias size and drill list(max count = HISTORY_MAX_COUNT) + std::vector m_ViasDimensionsList; + // The first value is the current netclass via size - std::vector m_TrackWidthList; // tracks widths (max count = HISTORY_MAX_COUNT) - // The first value is the current netclass track width - unsigned m_ViaSizeSelector; // index for m_ViaSizeList to select the value - // 0 is the index selection of the default value Netclass - unsigned m_TrackWidthSelector; // index for m_TrackWidthList to select the value + // tracks widths (max count = HISTORY_MAX_COUNT) + // The first value is the current netclass track width + std::vector m_TrackWidthList; + + /// 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: BOARD_DESIGN_SETTINGS* m_boardDesignSettings; // Link to current design settings COLORS_DESIGN_SETTINGS* m_colorsSettings; // Link to current colors settings - /**********************************/ public: BOARD( EDA_ITEM* aParent, PCB_BASE_FRAME* frame ); ~BOARD(); @@ -200,14 +227,13 @@ public: */ wxPoint& GetPosition(); - /** * Function Add * adds the given item to this BOARD and takes ownership of its memory. * @param aBoardItem The item to add to this board. * @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 @@ -217,9 +243,11 @@ public: * removes the given single item from this BOARD and deletes its memory. * @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 ) delete Remove( aBoardItem ); } @@ -227,25 +255,23 @@ public: /** * Function Remove - * removes \a aBoardItem from this BOARD and returns it to caller without - * deleting it. + * removes \a aBoardItem from this BOARD and returns it to caller without deleting it. * @param aBoardItem The item to remove from this board. * @return BOARD_ITEM* \a aBoardItem which was passed in. */ BOARD_ITEM* Remove( BOARD_ITEM* aBoardItem ); - /** * Function DeleteMARKERs * deletes ALL MARKERS from the board. */ - void DeleteMARKERs(); + void DeleteMARKERs(); /** * Function DeleteZONEOutlines * deletes ALL zone outlines from the board. */ - void DeleteZONEOutlines(); + void DeleteZONEOutlines(); /** @@ -258,6 +284,7 @@ public: { if( (unsigned) index < m_markers.size() ) return m_markers[index]; + return NULL; } @@ -273,61 +300,61 @@ public: /** - * Function ResetHightLight - * Reset all hight light data to the init state + * Function ResetHighLight + * Reset all high light data to the init state */ - void ResetHightLight() + void ResetHighLight() { m_hightLight.Clear(); m_hightLightPrevious.Clear(); } /** - * Function GetHightLightNetCode - * @return netcode of net to hightlight (-1 when no net selected) + * Function GetHighLightNetCode + * @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 - * @param aNetCode = netcode of net to hightlight + * Function SetHighLightNet + * @param aNetCode = netcode of net to highlight */ - void SetHightLightNet( int aNetCode) + void SetHighLightNet( int aNetCode) { m_hightLight.m_netCode = aNetCode; } /** - * Function IsHightLightNetON - * @return true if a net is currently hightlighted + * Function IsHighLightNetON + * @return true if a net is currently highlighted */ - bool IsHightLightNetON() { return m_hightLight.m_hightLightOn; } + bool IsHighLightNetON() { return m_hightLight.m_highLightOn; } /** - * Function HightLightOFF - * Disable hightlight. + * Function HighLightOFF + * Disable highlight. */ - void HightLightOFF() { m_hightLight.m_hightLightOn = false; } + void HighLightOFF() { m_hightLight.m_highLightOn = false; } /** - * Function HightLightON - * Enable hightlight. - * if m_hightLight_NetCode >= 0, this net will be hightlighted + * Function HighLightON + * Enable highlight. + * 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 - * save current hight light info for later use + * Function PushHighLight + * save current high light info for later use */ - void PushHightLight(); + void PushHighLight(); /** - * Function PopHightLight - * retrieve a previously saved hight light info + * Function PopHighLight + * retrieve a previously saved high light info */ - void PopHightLight(); + void PopHighLight(); /** * Function GetCopperLayerCount @@ -337,7 +364,6 @@ public: void SetCopperLayerCount( int aCount ); - /** * Function GetEnabledLayers * 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 * @see enum PCB_VISIBLE */ - int GetVisibleElements() const; + int GetVisibleElements() const; /** * Function SetVisibleElements @@ -455,9 +481,9 @@ public: * returns the color of a pcb visible element. * @see enum PCB_VISIBLE */ - int GetVisibleElementColor( int aPCB_VISIBLE ); - void SetVisibleElementColor( int aPCB_VISIBLE, int aColor ); + int GetVisibleElementColor( int aPCB_VISIBLE ); + void SetVisibleElementColor( int aPCB_VISIBLE, int aColor ); /** * Function GetBoardDesignSettings @@ -478,6 +504,7 @@ public: m_boardDesignSettings = aDesignSettings; } + /** * Function SetBoardSettings * @return the current COLORS_DESIGN_SETTINGS in use @@ -487,6 +514,7 @@ public: return m_colorsSettings; } + /** * Function SetColorsSettings * @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 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. */ - bool SetLayerName( int aLayerIndex, const wxString& aLayerName ); + bool SetLayerName( int aLayerIndex, const wxString& aLayerName ); /** * Function GetLayerType @@ -525,7 +553,7 @@ public: * @return LAYER_T - the layer type, or LAYER_T(-1) if the * index was out of range. */ - LAYER_T GetLayerType( int aLayerIndex ) const; + LAYER_T GetLayerType( int aLayerIndex ) const; /** * Function SetLayerType @@ -535,30 +563,33 @@ public: * @param aLayerType The new layer type. * @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 * 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 * 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 */ - int GetNumSegmTrack(); - int GetNumSegmZone(); + int GetNumSegmTrack(); + + /* Calculate the zone segment count */ + int GetNumSegmZone(); + unsigned GetNoconnectCount(); // Return the number of missing links. /** * Function GetNumRatsnests * @return int - The number of rats */ - unsigned GetRatsnestsCount() + unsigned GetRatsnestsCount() { return m_FullRatsnest.size(); } @@ -574,7 +605,7 @@ public: * Function GetPadsCount * @return the number of pads in board */ - unsigned GetPadsCount() + unsigned GetPadsCount() { return m_NetInfo->GetPadsCount(); } @@ -585,7 +616,7 @@ public: * @param aBoardEdgesOnly is true if we are interested in board edge segments only. * @return bool - True if items (or board edge segments) were found. */ - bool ComputeBoundingBox( bool aBoardEdgesOnly = false ); + bool ComputeBoundingBox( bool aBoardEdgesOnly = false ); /** * Function DisplayInfo @@ -594,18 +625,18 @@ public: * Is virtual from EDA_ITEM. * @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. * Redraw the BOARD items but not cursors, axis or grid. * @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 aOffset = an draw offset value (default = 0,0) */ - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - int aDrawMode, const wxPoint& aOffset = ZeroOffset ); + void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, + int aDrawMode, const wxPoint& aOffset = ZeroOffset ); /** * Function DrawHighLight @@ -613,10 +644,10 @@ public: * and turns on or off the brilliance associated with that net according to the * current value of global g_HighLight_Status * @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. */ - void DrawHighLight( EDA_DRAW_PANEL* aDrawPanel, wxDC* aDC, int aNetCode ); + void DrawHighLight( EDA_DRAW_PANEL* aDrawPanel, wxDC* aDC, int aNetCode ); /** * Function Visit @@ -644,7 +675,7 @@ public: NETINFO_ITEM* FindNet( int aNetcode ) const; /** - * Function FindNet overlayed + * Function FindNet overloaded * 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. @@ -660,15 +691,16 @@ public: * @return MODULE* - If found, the MODULE having the given reference * designator, else NULL. */ - MODULE* FindModuleByReference( const wxString& aReference ) const; + MODULE* FindModuleByReference( const wxString& aReference ) const; /** * 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) + * @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 ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount ); + int ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount ); /**************************************/ /** @@ -678,16 +710,16 @@ public: /** * Function SynchronizeNetsAndNetClasses * 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) - * Also this function removes the non existing nets in netclasses and add net nets in default netclass - * (this happens after reading a netlist) + * Must be called after a Design Rules edition, or after reading a netlist (or editing + * the list of nets) Also this function removes the non existing nets in netclasses + * and add net nets in default netclass (this happens after reading a netlist) */ void SynchronizeNetsAndNetClasses(); /** * Function SetCurrentNetClass * 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 ....) * @param aNetClassName = the new netclass name * @return true if lists of tracks and vias sizes are modified @@ -698,7 +730,7 @@ public: * Function GetBiggestClearanceValue * @return the biggest clearance value found in NetClasses list */ - int GetBiggestClearanceValue(); + int GetBiggestClearanceValue(); /** * Function GetCurrentTrackWidth @@ -706,7 +738,7 @@ public: * ( using the default netclass value or a preset value ) * the default netclass is always in m_TrackWidthList[0] */ - int GetCurrentTrackWidth() + int GetCurrentTrackWidth() { return m_TrackWidthList[m_TrackWidthSelector]; } @@ -718,7 +750,7 @@ public: * ( using the default netclass value or a preset value ) * the default netclass is always in m_TrackWidthList[0] */ - int GetCurrentViaSize() + int GetCurrentViaSize() { return m_ViasDimensionsList[m_ViaSizeSelector].m_Diameter; } @@ -730,7 +762,7 @@ public: * ( using the default netclass value or a preset value ) * the default netclass is always in m_TrackWidthList[0] */ - int GetCurrentViaDrill() + int GetCurrentViaDrill() { return m_ViasDimensionsList[m_ViaSizeSelector].m_Drill > 0 ? m_ViasDimensionsList[m_ViaSizeSelector].m_Drill : -1; @@ -779,7 +811,7 @@ public: * 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. + * of nesting of this object within the overall tree. * @param os The ostream& to output to. */ void Show( int nestLevel, std::ostream& os ); @@ -809,10 +841,10 @@ public: * Function RedrawAreasOutlines * Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 ) */ - void RedrawAreasOutlines( EDA_DRAW_PANEL* aPanel, - wxDC* aDC, - int aDrawMode, - int aLayer ); + void RedrawAreasOutlines( EDA_DRAW_PANEL* aPanel, + wxDC* aDC, + int aDrawMode, + int aLayer ); /** * Function RedrawFilledAreas @@ -882,10 +914,10 @@ public: * Add an empty copper area to board areas list * @param aNewZonesList = a PICKED_ITEMS_LIST * where to store new areas pickers (useful * 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 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 */ ZONE_CONTAINER* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, @@ -906,7 +938,7 @@ public: * @param style = style of last corner * @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 @@ -919,7 +951,7 @@ public: * 1 if intersecting sides, but no intersecting arcs * Also sets utility2 flag of area with return value */ - int TestAreaPolygon( ZONE_CONTAINER* CurrArea ); + int TestAreaPolygon( ZONE_CONTAINER* CurrArea ); /** * Function ClipAreaPolygon @@ -937,11 +969,11 @@ public: * 1 if intersecting sides * Also sets areas->utility1 flags if areas are modified */ - int ClipAreaPolygon( PICKED_ITEMS_LIST* aNewZonesList, - ZONE_CONTAINER* aCurrArea, - bool bMessageBoxArc, - bool bMessageBoxInt, - bool bRetainArcs = true ); + int ClipAreaPolygon( PICKED_ITEMS_LIST* aNewZonesList, + ZONE_CONTAINER* aCurrArea, + bool bMessageBoxArc, + bool bMessageBoxInt, + bool bRetainArcs = true ); /** * Process an area that has been modified, by clipping its polygon against @@ -965,8 +997,8 @@ public: /** * Function CombineAllAreasInNet * 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 - * can be NULL + * @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful + * in undo commands can be NULL * @param aNetCode = net to consider * @param bMessageBox : if true display warning message box * @param bUseUtility : if true, don't check areas if both utility flags are 0 @@ -981,8 +1013,8 @@ public: /** * Function RemoveArea * 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 - * can be NULL + * @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful + * in undo commands can be NULL * @param area_to_remove = area to delete or put in deleted list */ void RemoveArea( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_to_remove ); @@ -1004,13 +1036,13 @@ public: * 1 if intersection * 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 * If possible, combine 2 copper areas - * @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful in undo commands - * can be NULL + * @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful + * in undo commands can be NULL * @param area_ref = the main area (zone) * @param area_to_combine = the zone that can be merged with area_ref * area_ref must be BEFORE area_to_combine @@ -1019,9 +1051,9 @@ public: * 1 if intersection * 2 if arcs intersect */ - int CombineAreas( PICKED_ITEMS_LIST* aDeletedList, - ZONE_CONTAINER* area_ref, - ZONE_CONTAINER* area_to_combine ); + int CombineAreas( PICKED_ITEMS_LIST* aDeletedList, + ZONE_CONTAINER* area_ref, + ZONE_CONTAINER* area_to_combine ); /** * 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 * @return errors count */ - int Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_Examine, - bool aCreate_Markers ); + int Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_Examine, + bool aCreate_Markers ); /****** function relative to ratsnest calculations: */ @@ -1045,6 +1077,20 @@ public: * @param aNetcode = netcode to analyze. if -1, analyze all nets */ void Test_Connections_To_Copper_Areas( int aNetcode = -1 ); + + /** + * Function GetViaByPosition + * finds the first via at \a aPosition on \a aLayer. + *

+ * 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. + *

+ * @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 diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 95410d1dae..6c25583673 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -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 { 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 { - // Currently tracks have no specific clearance parameter - // on a per track or per segment basis. - // the NETCLASS clearance is used + // Currently tracks have no specific clearance parameter on a per track or per + // segment basis. The NETCLASS clearance is used. 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 { if( Type() != TYPE_VIA ) @@ -215,7 +193,6 @@ int TRACK::GetDrillValue() const } -// return true if segment length = 0 bool TRACK::IsNull() { 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 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 ) { 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 ) { m_Start.y = aCentre.y - (m_Start.y - aCentre.y); @@ -366,7 +325,6 @@ void TRACK::Flip( const wxPoint& aCentre ) // see class_track.h -// SEGVIA and SEGZONE inherit this version SEARCH_RESULT TRACK::Visit( INSPECTOR* inspector, const void* testData, 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() { 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 ) { 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 { 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 = 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* 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 ); fprintf( aFile, "De %d %d %d %lX %X\n", - m_Layer, type, GetNet(), - m_TimeStamp, ReturnStatus() ); + m_Layer, type, GetNet(), + m_TimeStamp, ReturnStatus() ); 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 ); } } + 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 if( DisplayOpt.m_DisplayViaMode != VIA_HOLE_NOT_SHOW ) { - if( (DisplayOpt.m_DisplayViaMode == ALL_VIA_HOLE_SHOW) // Display all drill holes requested - || ( (drill_radius > 0 ) && !IsDrillDefault() ) ) // Or Display non default holes requested + // Display all drill holes requested or Display non default holes requested + if( (DisplayOpt.m_DisplayViaMode == ALL_VIA_HOLE_SHOW) + || ( (drill_radius > 0 ) && !IsDrillDefault() ) ) { 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 ) GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, radius + GetClearance(), 0, color ); - // for Micro Vias, draw a partial cross : - // X on component layer, or + on copper layer + // for Micro Vias, draw a partial cross : X on component layer, or + on copper layer // (so we can see 2 superimposed microvias ): 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 ); } - // for Buried Vias, draw a partial line : - // orient depending on layer pair + // for Buried Vias, draw a partial line : orient depending on layer pair // (so we can see superimposed buried vias ): 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 ) { - 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, WHITE, net->GetShortNetname(), 0, wxSize( tsize, tsize ), 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 ) { wxString msg; @@ -1071,7 +998,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame ) 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() ); 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 ) { 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 ) { 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 text; @@ -1231,13 +1197,6 @@ wxString TRACK::GetSelectMenuText() const #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 ) { 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 ) { const char* cp; @@ -1355,5 +1307,4 @@ wxString TRACK::ShowState( int stateBits ) return ret; } - #endif diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 45dce8fa37..09218d3eab 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -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 #define CLASS_TRACK_H @@ -52,15 +53,20 @@ public: * Function Copy * will copy this object whether it is a TRACK or a SEGVIA returning * 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 - * denominator: TRACK + * denominator: TRACK */ TRACK* Copy() const; TRACK* Next() const { return (TRACK*) Pnext; } TRACK* Back() const { return (TRACK*) Pback; } - /** * Function Move * move this object. @@ -105,7 +111,7 @@ public: * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ - bool Save( FILE* aFile ) const; + bool Save( FILE* aFile ) const; /** * Function GetBestInsertPoint @@ -115,24 +121,24 @@ public: * @param aPcb The BOARD to search for the insertion point. * @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 * ( 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 * ( the linked list is always sorted by net codes ) */ - TRACK* GetEndNetCode( int NetCode ); + TRACK* GetEndNetCode( int NetCode ); /** * Function GetLength * returns the length of the track using the hypotenuse calculation. * @return double - the length of the track */ - double GetLength() const + double GetLength() const { int dx = m_Start.x - m_End.x; int dy = m_Start.y - m_End.y; @@ -142,8 +148,8 @@ public: /* Display on screen: */ - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, - const wxPoint& aOffset = ZeroOffset ); + void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, + const wxPoint& aOffset = ZeroOffset ); /* divers */ int Shape() const { return m_Shape & 0xFF; } @@ -196,15 +202,22 @@ public: * TRACK segment or SEGVIA physically resides. * @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 * returns true if segment length is zero. */ - bool IsNull(); + bool IsNull(); /** * Function DisplayInfo @@ -214,7 +227,7 @@ public: * Display info about the track segment and the full track length * @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 @@ -223,13 +236,13 @@ public: * 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 DisplayInfoBase( EDA_DRAW_FRAME* frame ); + void DisplayInfoBase( EDA_DRAW_FRAME* frame ); /** * Function ShowWidth * returns the width of the track in displayable user units. */ - wxString ShowWidth() const; + wxString ShowWidth() const; /** * Function Visit @@ -244,8 +257,8 @@ public: * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * else SCAN_CONTINUE, and determined by the inspector. */ - SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData, - const KICAD_T scanTypes[] ); + SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData, + const KICAD_T scanTypes[] ); /** @@ -254,7 +267,7 @@ public: * @param refPos A wxPoint to test * @return bool - true if a hit, else false */ - bool HitTest( const wxPoint& refPos ); + bool HitTest( const wxPoint& refPos ); /** * Function HitTest (overlaid) @@ -263,7 +276,29 @@ public: * @param refArea an EDA_RECT to test * @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 @@ -348,9 +383,8 @@ public: } - void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, - const wxPoint& aOffset = ZeroOffset ); - + void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, + const wxPoint& aOffset = ZeroOffset ); /** * Function IsOnLayer @@ -359,10 +393,28 @@ public: * @param aLayer the layer to test for. * @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 @@ -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 diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index 9f1b91516c..8759cdc1c0 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -96,17 +96,19 @@ void RemoteCommand( const char* cmdline ) if( netcode > 0 ) /* highlight the pad net*/ { - pcb->HightLightON(); - pcb->SetHightLightNet( netcode ); + pcb->HighLightON(); + pcb->SetHighLightNet( netcode ); } else { - pcb->HightLightOFF(); - pcb->SetHightLightNet( -1 ); + pcb->HighLightOFF(); + pcb->SetHighLightNet( -1 ); } if( module == NULL ) + { msg.Printf( _( "%s not found" ), GetChars( modName ) ); + } else if( pad == NULL ) { msg.Printf( _( "%s pin %s not found" ), GetChars( modName ), GetChars( pinName ) ); diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index 344db56e5b..06c6fd6942 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -78,7 +78,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack ) { DrawPanel->SetMouseCapture( NULL, NULL ); - if( GetBoard()->IsHightLightNetON() ) + if( GetBoard()->IsHighLightNetON() ) High_Light( DC ); SetCurItem( NULL ); diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index d4080c55e8..a6522d26b8 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -1290,8 +1290,7 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) if( DisplayOpt.DisplayZonesMode != 0 ) DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) ); - if( !GetBoard()->IsHightLightNetON() && - (GetBoard()->GetHightLightNetCode() > 0 ) ) + if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) ) High_Light( &dc ); break; diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index 77cf7eb03d..9eb47a8844 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -14,89 +14,6 @@ #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 ) { 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: */ - if( Locate_Via( GetBoard(), g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) ) + if( GetBoard()->GetViaByPosition( g_CurrentTrackSegment->m_End, + g_CurrentTrackSegment->GetLayer() ) ) return false; 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_Shape = GetBoard()->GetBoardDesignSettings()->m_CurrentViaType; via->m_Width = GetBoard()->GetCurrentViaSize(); - via->SetNet( GetBoard()->GetHightLightNetCode() ); + via->SetNet( GetBoard()->GetHighLightNetCode() ); via->m_Start = via->m_End = g_CurrentTrackSegment->m_End; // 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 ) { 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 ) { 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 ) { for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ ) diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index fbcf43afea..11cd569ef0 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -39,13 +39,13 @@ static void Abort_Create_Track( EDA_DRAW_PANEL* Panel, wxDC* DC ) /* Erase the current drawing */ ShowNewTrackWhenMovingCursor( Panel, DC, wxDefaultPosition, false ); - if( pcb->IsHightLightNetON() ) + if( pcb->IsHighLightNetON() ) frame->High_Light( DC ); - pcb->PopHightLight(); + pcb->PopHighLight(); - if( pcb->IsHightLightNetON() ) - pcb->DrawHighLight( Panel, DC, pcb->GetHightLightNetCode() ); + if( pcb->IsHighLightNetON() ) + pcb->DrawHighLight( Panel, DC, pcb->GetHighLightNetCode() ); frame->MsgPanel->EraseMsgBox(); @@ -92,16 +92,16 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) // Prepare the undo command info s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be necessary, but... - GetBoard()->PushHightLight(); + GetBoard()->PushHighLight(); // erase old highlight - if( GetBoard()->IsHightLightNetON() ) + if( GetBoard()->IsHighLightNetON() ) High_Light( DC ); g_CurrentTrackList.PushBack( new TRACK( GetBoard() ) ); 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 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 */ pos = pt_pad->m_Pos; - GetBoard()->SetHightLightNet( pt_pad->GetNet() ); + GetBoard()->SetHighLightNet( pt_pad->GetNet() ); } else /* A track segment is found */ { TrackOnStartPoint = (TRACK*) LockPoint; - GetBoard()->SetHightLightNet( TrackOnStartPoint->GetNet() ); + GetBoard()->SetHighLightNet( TrackOnStartPoint->GetNet() ); 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 ); if( zone ) - GetBoard()->SetHightLightNet( zone->GetNet() ); + GetBoard()->SetHighLightNet( zone->GetNet() ); } D( g_CurrentTrackList.VerifyListIntegrity(); ); @@ -139,11 +139,11 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* DC ) D( g_CurrentTrackList.VerifyListIntegrity(); ); - GetBoard()->HightLightON(); - GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHightLightNetCode() ); + GetBoard()->HighLightON(); + GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHighLightNetCode() ); // 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() ); 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. */ { TRACK* adr_buf = (TRACK*) LockPoint; - GetBoard()->SetHightLightNet( adr_buf->GetNet() ); + GetBoard()->SetHighLightNet( adr_buf->GetNet() ); /* Possible establishment of a hanging point. */ LockPoint = CreateLockPoint( GetBoard(), @@ -527,13 +527,13 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* DC ) wxASSERT( g_CurrentTrackSegment == NULL ); wxASSERT( g_CurrentTrackList.GetCount() == 0 ); - if( GetBoard()->IsHightLightNetON() ) + if( GetBoard()->IsHighLightNetON() ) High_Light( DC ); - GetBoard()->PopHightLight(); + GetBoard()->PopHighLight(); - if( GetBoard()->IsHightLightNetON() ) - GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHightLightNetCode() ); + if( GetBoard()->IsHighLightNetON() ) + GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHighLightNetCode() ); DrawPanel->SetMouseCapture( NULL, NULL ); SetCurItem( NULL ); diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index bd8a724920..143d5f4b8b 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -51,7 +51,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery ) GetScreen()->Init(); GetScreen()->SetGrid( gridsize ); - GetBoard()->ResetHightLight(); + GetBoard()->ResetHighLight(); // Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled) GetBoard()->SetEnabledLayers(ALL_LAYERS); diff --git a/pcbnew/locate.cpp b/pcbnew/locate.cpp index a7cb4bb2c5..a88b6d05e4 100644 --- a/pcbnew/locate.cpp +++ b/pcbnew/locate.cpp @@ -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 * input: ptr_trace: pointer to the segment of track * 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; } - - -/* 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; -} diff --git a/pcbnew/magnetic_tracks_functions.cpp b/pcbnew/magnetic_tracks_functions.cpp index dcbe7cf126..823c1cbaff 100644 --- a/pcbnew/magnetic_tracks_functions.cpp +++ b/pcbnew/magnetic_tracks_functions.cpp @@ -1,8 +1,8 @@ -/********************************************************/ +/*********************************/ /* 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 * (the current created track is kept near existing 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; 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() ) { 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 - * square. + * In two segment mode, ignore the final segment if it's inside a grid square. */ if( !amMovingVia && currTrack && g_TwoSegmentTrackBuild && currTrack->Back() && 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( 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 ) { @@ -275,8 +274,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr return true; } - // @todo otherwise confine curpos such that it stays centered - // within "track" + // @todo otherwise confine curpos such that it stays centered within "track" } } } diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 2a0d077869..e2a59f4a8c 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -62,8 +62,8 @@ static void Abort_MoveTrack( EDA_DRAW_PANEL* Panel, wxDC* DC ) Panel->m_mouseCaptureCallback( Panel, DC, wxDefaultPosition, true ); Panel->GetScreen()->SetCrossHairPosition( oldpos ); - pcb->HightLightOFF(); - pcb->DrawHighLight( Panel, DC, pcb->GetHightLightNetCode() ); + pcb->HighLightOFF(); + pcb->DrawHighLight( Panel, DC, pcb->GetHighLightNetCode() ); if( NewTrack ) { @@ -119,10 +119,10 @@ static void Abort_MoveTrack( EDA_DRAW_PANEL* Panel, wxDC* DC ) // Clear the undo picker list: s_ItemsListPicker.ClearListAndDeleteItems(); - pcb->PopHightLight(); + pcb->PopHighLight(); - if( pcb->IsHightLightNetON() ) - pcb->DrawHighLight( Panel, DC, pcb->GetHightLightNetCode() ); + if( pcb->IsHighLightNetON() ) + pcb->DrawHighLight( Panel, DC, pcb->GetHighLightNetCode() ); EraseDragList(); Panel->SetMouseCapture( NULL, NULL ); @@ -665,9 +665,9 @@ void PCB_EDIT_FRAME::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int com EraseDragList(); /* Change highlighted net: the new one will be highlighted */ - GetBoard()->PushHightLight(); + GetBoard()->PushHighLight(); - if( GetBoard()->IsHightLightNetON() ) + if( GetBoard()->IsHighLightNetON() ) High_Light( DC ); PosInit = GetScreen()->GetCrossHairPosition(); @@ -742,10 +742,10 @@ void PCB_EDIT_FRAME::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int com s_LastPos = PosInit; DrawPanel->SetMouseCapture( Show_MoveNode, Abort_MoveTrack ); - GetBoard()->SetHightLightNet( track->GetNet() ); - GetBoard()->HightLightON(); + GetBoard()->SetHighLightNet( track->GetNet() ); + GetBoard()->HighLightON(); - GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHightLightNetCode() ); + GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHighLightNetCode() ); DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true ); } @@ -904,9 +904,9 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC s_EndSegmentPresent = false; /* Change high light net: the new one will be highlighted */ - GetBoard()->PushHightLight(); + GetBoard()->PushHighLight(); - if( GetBoard()->IsHightLightNetON() ) + if( GetBoard()->IsHighLightNetON() ) High_Light( DC ); EraseDragList(); @@ -944,9 +944,9 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC s_LastPos = GetScreen()->GetCrossHairPosition(); DrawPanel->SetMouseCapture( Show_Drag_Track_Segment_With_Cte_Slope, Abort_MoveTrack ); - GetBoard()->SetHightLightNet( track->GetNet() ); - GetBoard()->HightLightON(); - GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHightLightNetCode() ); + GetBoard()->SetHighLightNet( track->GetNet() ); + GetBoard()->HighLightON(); + GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHighLightNetCode() ); // Prepare the Undo command ITEM_PICKER picker( NULL, UR_CHANGED ); @@ -1038,13 +1038,13 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED ); s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items - if( GetBoard()->IsHightLightNetON() ) + if( GetBoard()->IsHighLightNetON() ) High_Light( DC ); - GetBoard()->PopHightLight(); + GetBoard()->PopHighLight(); - if( GetBoard()->IsHightLightNetON() ) - GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHightLightNetCode() ); + if( GetBoard()->IsHighLightNetON() ) + GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHighLightNetCode() ); OnModify(); DrawPanel->SetMouseCapture( NULL, NULL ); diff --git a/pcbnew/protos.h b/pcbnew/protos.h index 6e50cefda1..0c92ddd70b 100644 --- a/pcbnew/protos.h +++ b/pcbnew/protos.h @@ -66,25 +66,6 @@ void DrawTraces( EDA_DRAW_PANEL* panel, /* 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 * by masquelayer. * Search is done to address start_adr has end_adr (not included) diff --git a/pcbnew/surbrill.cpp b/pcbnew/surbrill.cpp index aa23d6942b..c365b9bdb1 100644 --- a/pcbnew/surbrill.cpp +++ b/pcbnew/surbrill.cpp @@ -80,10 +80,10 @@ void PCB_EDIT_FRAME::ListNetsAndSelect( wxCommandEvent& event ) { INSTALL_UNBUFFERED_DC( dc, DrawPanel ); - if( GetBoard()->IsHightLightNetON() ) + if( GetBoard()->IsHighLightNetON() ) High_Light( &dc ); - GetBoard()->SetHightLightNet( netcode ); + GetBoard()->SetHighLightNet( netcode ); High_Light( &dc ); } } @@ -95,7 +95,8 @@ void PCB_EDIT_FRAME::ListNetsAndSelect( wxCommandEvent& event ) int PCB_EDIT_FRAME::Select_High_Light( wxDC* DC ) { int netcode = -1; - if( GetBoard()->IsHightLightNetON() ) + + if( GetBoard()->IsHighLightNetON() ) High_Light( DC ); // 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 ) { - GetBoard()->SetHightLightNet( netcode ); + GetBoard()->SetHighLightNet( netcode ); High_Light( DC ); } @@ -155,10 +156,10 @@ int PCB_EDIT_FRAME::Select_High_Light( wxDC* DC ) */ void PCB_EDIT_FRAME::High_Light( wxDC* DC ) { - if( GetBoard()->IsHightLightNetON() ) - GetBoard()->HightLightOFF(); + if( GetBoard()->IsHighLightNetON() ) + GetBoard()->HighLightOFF(); else - GetBoard()->HightLightON(); + GetBoard()->HighLightON(); - GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHightLightNetCode() ); + GetBoard()->DrawHighLight( DrawPanel, DC, GetBoard()->GetHighLightNetCode() ); } diff --git a/pcbnew/tr_modif.cpp b/pcbnew/tr_modif.cpp index a2e06772b8..72f162fe91 100644 --- a/pcbnew/tr_modif.cpp +++ b/pcbnew/tr_modif.cpp @@ -14,18 +14,6 @@ extern int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, 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, TRACK* aNewTrack, int aNewTrackSegmentsCount, @@ -41,9 +29,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, 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 ); @@ -58,8 +44,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, wxASSERT( aNewTrack ); #if 0 && defined(DEBUG) - TRACK* EndNewTrack; /* The last segment of the list chained to - * the track */ + TRACK* EndNewTrack; /* The last segment of the list chained to the track */ EndNewTrack = aNewTrack; @@ -110,7 +95,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, endmasklayer = EndTrack->ReturnMaskLayer(); /* 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 ) startmasklayer |= pt_segm->ReturnMaskLayer(); @@ -122,7 +107,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, 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 ) endmasklayer |= pt_segm->ReturnMaskLayer(); @@ -133,8 +118,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, endmasklayer |= pt_pad->m_layerMask; } - /* Mark as deleted a new track (which is not involved in the search for - * other connections) + /* Mark as deleted a new track (which is not involved in the search for other connections) */ ListSetState( aNewTrack, aNewTrackSegmentsCount, IS_DELETED, ON ); @@ -190,9 +174,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, return 0; } - /* Mark trace as edited (which does not involve searching for other - * tracks) - */ + // Mark trace as edited (which does not involve searching for other tracks) ListSetState( aNewTrack, aNewTrackSegmentsCount, IS_DELETED, OFF ); 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 onoff value, using bit mask State +/* Set the bits of .m_State member to on off value, using bit mask State * of a list of EDA_ITEM */ static void ListSetState( EDA_ITEM* Start, int NbItem, int State, int onoff ) diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index a505ee6692..739df60dd2 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -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 ); } - if( IsHightLightNetON() ) - DrawHighLight( aPanel, DC, GetHightLightNetCode() ); + if( IsHighLightNetON() ) + DrawHighLight( aPanel, DC, GetHighLightNetCode() ); // 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 ) @@ -209,7 +209,7 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* aDrawPanel, wxDC* DC, int aNetCode ) { int draw_mode; - if( IsHightLightNetON() ) + if( IsHighLightNetON() ) draw_mode = GR_SURBRILL | GR_OR; else draw_mode = GR_AND | GR_SURBRILL; diff --git a/pcbnew/track.cpp b/pcbnew/track.cpp index b6e3f51d95..e46c36e490 100644 --- a/pcbnew/track.cpp +++ b/pcbnew/track.cpp @@ -10,11 +10,9 @@ #include "protos.h" /* Functions to recognize a track. - * A track is a list of connected segments (or/and vias) - * from a starting to an ending point - * starting and ending points are a pad or a point with more than 2 segments - *connected - * (and obviously a dangling segment end) + * A track is a list of connected segments (or/and vias) from a starting to an ending point + * starting and ending points are a pad or a point with more than 2 segments connected + * (and obviously a dangling segment end) */ typedef std::vector TRACK_PTRS; // buffer of item candidates when @@ -22,10 +20,7 @@ typedef std::vector TRACK_PTRS; // buffer of item candidates when /* Local functions */ -static void ChainMarkedSegments( BOARD* Pcb, - wxPoint ref_pos, - int masklayer, - TRACK_PTRS* aList ); +static void ChainMarkedSegments( BOARD* Pcb, wxPoint ref_pos, int masklayer, TRACK_PTRS* aList ); 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 - // If a via is connected to only one or 2 segments, it is flagged (is on - // the track) + // If a via is connected to only one or 2 segments, it is flagged (is on the track) // If a via is connected to more than 2 segments, it is a track end, and it // is removed from the list // 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 * 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 ) { @@ -442,7 +436,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, TRACK** StartTrack, TRACK** En continue; layerMask = Track->ReturnMaskLayer(); - via = Fast_Locate_Via( RefTrack, TrackListEnd, Track->m_Start, layerMask ); + via = RefTrack->GetVia( TrackListEnd, Track->m_Start, layerMask ); if( via ) { @@ -489,7 +483,7 @@ int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, TRACK** StartTrack, TRACK** En } layerMask = Track->ReturnMaskLayer(); - via = Fast_Locate_Via( RefTrack, TrackListEnd, Track->m_End, layerMask ); + via = RefTrack->GetVia( TrackListEnd, Track->m_End, layerMask ); if( via ) { diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 36cd92e7a7..0e861577b0 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -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( GetBoard()->IsHightLightNetON() && DC ) + if( GetBoard()->IsHighLightNetON() && DC ) { High_Light( DC ); // Remove old hightlight selection } g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet(); - GetBoard()->SetHightLightNet( zone_container->GetNet() ); + GetBoard()->SetHighLightNet( zone_container->GetNet() ); if( 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 */ if( zone_container->IsOnCopperLayer() ) /* Show the Net */ { - if( GetBoard()->IsHightLightNetON() ) + if( GetBoard()->IsHighLightNetON() ) { High_Light( DC ); // Remove old hightlight selection } g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet(); - GetBoard()->SetHightLightNet( zone_container->GetNet() ); + GetBoard()->SetHighLightNet( zone_container->GetNet() ); High_Light( DC ); } @@ -495,9 +495,9 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) if( zone->IsOnCopperLayer() ) { // 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->SetNetNameFromNetCode( ); @@ -541,12 +541,12 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) if( s_CurrentZone ) g_Zone_Default_Setting.m_NetcodeSelection = s_CurrentZone->GetNet(); - if( GetBoard()->IsHightLightNetON() ) + if( GetBoard()->IsHighLightNetON() ) { 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 ); }