Commit ab76e809 authored by Wayne Stambaugh's avatar Wayne Stambaugh

PCBNew trace mark code refactoring and other minor fixes.

* Refactor trace mark functions into the board object.
* Remove track.cpp as it is no longer needed.
* Dead code removal.
parent e4d1fa12
...@@ -182,7 +182,6 @@ set(PCBNEW_SRCS ...@@ -182,7 +182,6 @@ set(PCBNEW_SRCS
tool_pcb.cpp tool_pcb.cpp
toolbars_update_user_interface.cpp toolbars_update_user_interface.cpp
tracepcb.cpp tracepcb.cpp
track.cpp
tr_modif.cpp tr_modif.cpp
trpiste.cpp trpiste.cpp
work.cpp work.cpp
......
...@@ -39,7 +39,7 @@ void PCB_EDIT_FRAME::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On ) ...@@ -39,7 +39,7 @@ void PCB_EDIT_FRAME::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On )
return; return;
DrawPanel->CrossHairOff( DC ); // Erase cursor shape DrawPanel->CrossHairOff( DC ); // Erase cursor shape
Track = MarkTrace( GetBoard(), track, &nb_segm, NULL, NULL, true ); Track = GetBoard()->MarkTrace( track, &nb_segm, NULL, NULL, true );
DrawTraces( DrawPanel, DC, Track, nb_segm, GR_OR | GR_SURBRILL ); DrawTraces( DrawPanel, DC, Track, nb_segm, GR_OR | GR_SURBRILL );
for( ; (Track != NULL) && (nb_segm > 0); nb_segm-- ) for( ; (Track != NULL) && (nb_segm > 0); nb_segm-- )
......
This diff is collapsed.
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
class ZONE_CONTAINER; class ZONE_CONTAINER;
// buffer of item candidates when search for items on the same track.
typedef std::vector< TRACK* > TRACK_PTRS;
#define HISTORY_MAX_COUNT 8 #define HISTORY_MAX_COUNT 8
...@@ -203,6 +207,17 @@ private: ...@@ -203,6 +207,17 @@ 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
/**
* Function chainMarkedSegments
* is used by MarkTrace() to set the BUSY flag of connected segments of the trace
* segment located at \a aPosition on aLayerMask.
* Vias are put in list but their flags BUSY is not set
* @param aPosition A wxPoint object containing the position of the starting search.
* @param aLayerMask The allowed layers for segments to search.
* @param aList The track list to fill with points of flagged segments.
*/
void chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* aList );
public: public:
BOARD( EDA_ITEM* aParent, PCB_BASE_FRAME* frame ); BOARD( EDA_ITEM* aParent, PCB_BASE_FRAME* frame );
~BOARD(); ~BOARD();
...@@ -1154,6 +1169,33 @@ public: ...@@ -1154,6 +1169,33 @@ public:
* @return A TRACK object pointer if found otherwise NULL. * @return A TRACK object pointer if found otherwise NULL.
*/ */
TRACK* GetTrace( TRACK* aTrace, const wxPoint& aPosition, int aLayerMask ); TRACK* GetTrace( TRACK* aTrace, const wxPoint& aPosition, int aLayerMask );
/**
* Function MarkTrace
* marks a chain of trace segments, connected to \aaTrace.
* <p>
* Each segment is marked by setting the BUSY bit into m_Flags. Electrical
* continuity is detected by walking each segment, and finally the segments
* are rearranged into a contiguous chain within the given list.
* </p>
*
* @param aTrace The segment within a list of trace segments to test.
* @param aCount A pointer to an integer where to return the number of
* marked segments.
* @param aTraceLength A pointer to an integer where to return the length of the
* trace.
* @param aDieLength A pointer to an integer where to return the extra lengths inside
* integrated circuits from the pads connected to this track to the
* die (if any).
* @param aReorder true for reorder the interesting segments (useful for
* track edition/deletion) in this case the flag BUSY is
* set (the user is responsible of flag clearing). False
* for no reorder : useful when we want just calculate the
* track length in this case, flags are reset
* @return TRACK* The first in the chain of interesting segments.
*/
TRACK* MarkTrace( TRACK* aTrace, int* aCount, int* aTraceLength,
int* aDieLength, bool aReorder );
}; };
#endif // #ifndef CLASS_BOARD_H #endif // #ifndef CLASS_BOARD_H
...@@ -979,7 +979,7 @@ void TRACK::DisplayInfo( EDA_DRAW_FRAME* frame ) ...@@ -979,7 +979,7 @@ void TRACK::DisplayInfo( EDA_DRAW_FRAME* frame )
{ {
int trackLen = 0; int trackLen = 0;
int lenDie = 0; int lenDie = 0;
MarkTrace( board, this, NULL, &trackLen, &lenDie, false ); board->MarkTrace( this, NULL, &trackLen, &lenDie, false );
msg = frame->CoordinateToString( trackLen ); msg = frame->CoordinateToString( trackLen );
frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN ); frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN );
......
...@@ -176,8 +176,8 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm ) ...@@ -176,8 +176,8 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
if( pt_segm == NULL ) if( pt_segm == NULL )
return; return;
TRACK* trackList = MarkTrace( GetBoard(), pt_segm, &segments_to_delete_count, TRACK* trackList = GetBoard()->MarkTrace( pt_segm, &segments_to_delete_count,
NULL, NULL, true ); NULL, NULL, true );
if( segments_to_delete_count == 0 ) if( segments_to_delete_count == 0 )
return; return;
......
/*************************************************************** /**
* Tracks and Vias size edition: * @file edit_track_width.cpp
* Functions to modify sizes of segment, track, net , all vias and/or all tracks * @breif Functions to modify sizes of segment, track, net , all vias and/or all tracks
***************************************************************/ */
#include "fctsys.h" #include "fctsys.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
...@@ -68,7 +68,8 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem, ...@@ -68,7 +68,8 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
aTrackItem->m_Width = new_width; aTrackItem->m_Width = new_width;
if( initial_width < new_width ) /* make a DRC test because the new size is bigger than the old size */ /* make a DRC test because the new size is bigger than the old size */
if( initial_width < new_width )
{ {
int diagdrc = OK_DRC; int diagdrc = OK_DRC;
...@@ -82,11 +83,9 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem, ...@@ -82,11 +83,9 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
{ {
change_ok = true; change_ok = true;
} }
// if new width == initial_width: do nothing,
// unless a via has its drill value changed
else if( (aTrackItem->Type() == TYPE_VIA) && (initial_drill != new_drill) ) else if( (aTrackItem->Type() == TYPE_VIA) && (initial_drill != new_drill) )
{ {
// if new width == initial_width: do nothing, unless a via has its drill value changed
change_ok = true; change_ok = true;
} }
...@@ -166,7 +165,7 @@ void PCB_EDIT_FRAME::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment ) ...@@ -166,7 +165,7 @@ void PCB_EDIT_FRAME::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment )
if( aTrackSegment == NULL ) if( aTrackSegment == NULL )
return; return;
pt_track = MarkTrace( GetBoard(), aTrackSegment, &nb_segm, NULL, NULL, true ); pt_track = GetBoard()->MarkTrace( aTrackSegment, &nb_segm, NULL, NULL, true );
PICKED_ITEMS_LIST itemsListPicker; PICKED_ITEMS_LIST itemsListPicker;
bool change = false; bool change = false;
...@@ -205,7 +204,7 @@ void PCB_EDIT_FRAME::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment ) ...@@ -205,7 +204,7 @@ void PCB_EDIT_FRAME::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment )
/** /**
* Function Change_Net_Tracks_And_Vias_Sizes * Function Change_Net_Tracks_And_Vias_Sizes
* Reset all tracks width and vias diameters and drill * Reset all tracks width and vias diameters and drill
* to their default Netclass value ou current values * to their default Netclass value or current values
* @param aNetcode : the netcode of the net to edit * @param aNetcode : the netcode of the net to edit
* @param aUseNetclassValue : bool. True to use netclass values, false to use current values * @param aUseNetclassValue : bool. True to use netclass values, false to use current values
*/ */
......
...@@ -70,8 +70,6 @@ void DrawTraces( EDA_DRAW_PANEL* panel, ...@@ -70,8 +70,6 @@ void DrawTraces( EDA_DRAW_PANEL* panel,
MODULE* Locate_Prefered_Module( BOARD* aPcb, const wxPoint& aPosition, int aActiveLayer, MODULE* Locate_Prefered_Module( BOARD* aPcb, const wxPoint& aPosition, int aActiveLayer,
bool aVisibleOnly, bool aIgnoreLocked = false ); bool aVisibleOnly, bool aIgnoreLocked = false );
DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc );
/*************/ /*************/
/* MODULES.C */ /* MODULES.C */
/*************/ /*************/
...@@ -95,53 +93,6 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo ...@@ -95,53 +93,6 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
void CalculateSegmentEndPoint( const wxPoint& aPosition, int ox, int oy, int* fx, int* fy ); void CalculateSegmentEndPoint( const wxPoint& aPosition, int ox, int oy, int* fx, int* fy );
/***************/
/* TRACK.CPP : */
/***************/
/**
* Function MarkTrace
* marks a chain of track segments, connected to aTrackList.
* Each segment is marked by setting the BUSY bit into m_Flags. Electrical
* continuity is detected by walking each segment, and finally the segments
* are rearranged into a contiguous chain within the given list.
*
* @param aPcb = the board to analyze
* @param aStartSegm - The first interesting segment within a list of track
* segment of aPcb
* @param aSegmCount = a pointer to an integer where to return the number of
* interesting segments
* @param aTrackLen = a pointer to an integer where to return the lenght of the
* track
* @param aLengthDie = a pointer to an integer where to return the extra lengths inside
* integrated circuits from the pads connected to this track to the
* die (if any)
* @param aReorder = true for reorder the interesting segments (useful for
* track edition/deletion) in this case the flag BUSY is
* set (the user is responsible of flag clearing). False
* for no reorder : useful when we want just calculate the
* track length in this case, flags are reset
* @return TRACK* the first in the chain of interesting segments.
*/
TRACK* MarkTrace( BOARD* aPcb,
TRACK* aStartSegm,
int* aSegmCount,
int* aTrackLen,
int* aLengthDie,
bool aReorder );
/* Calculate end coordinate of a trace.
* Returns 1 if OK, 0 if trace looped back on itself.
* The coord are returned StartTrack-> ox, oy
* And EndTrack-> fx, fy if OK
* The segments are drawn consecutively.
*/
int ReturnEndsTrack( TRACK* RefTrack, int NbSegm, TRACK** StartTrack, TRACK** EndTrack );
/***************/
/***************/
/* Routine to find the point "attachment" at the end of a trace. /* Routine to find the point "attachment" at the end of a trace.
* This may be a PAD or another trace segment. * This may be a PAD or another trace segment.
* Returns: * Returns:
......
...@@ -38,7 +38,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, ...@@ -38,7 +38,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
if( aNewTrack->Type() == TYPE_VIA && ( aNewTrackSegmentsCount > 1 ) ) if( aNewTrack->Type() == TYPE_VIA && ( aNewTrackSegmentsCount > 1 ) )
aNewTrack = aNewTrack->Next(); aNewTrack = aNewTrack->Next();
aNewTrack = MarkTrace( GetBoard(), aNewTrack, &aNewTrackSegmentsCount, NULL, NULL, true ); aNewTrack = GetBoard()->MarkTrace( aNewTrack, &aNewTrackSegmentsCount, NULL, NULL, true );
wxASSERT( aNewTrack ); wxASSERT( aNewTrack );
#if 0 && defined(DEBUG) #if 0 && defined(DEBUG)
...@@ -190,7 +190,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, ...@@ -190,7 +190,7 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
nbconnect--; nbconnect--;
pt_del->SetState( IS_LINKED, OFF ); pt_del->SetState( IS_LINKED, OFF );
pt_del = MarkTrace( GetBoard(), pt_del, &nb_segm, NULL, NULL, true ); pt_del = GetBoard()->MarkTrace( pt_del, &nb_segm, NULL, NULL, true );
/* Test if the marked track is redundant, i.e. if one of marked segments /* Test if the marked track is redundant, i.e. if one of marked segments
* is connected to the starting point of the new track. * is connected to the starting point of the new track.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment