Commit 7b4b3297 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

- Better way to iterate on vias in the track list (GetFirstVia)

- Converted the Next/Prev C casts to static casts and removed the type
  unsafe ones
- Splitted as virtual the VIA::Flip member instead of using RTTI
- Heavily refactored the 'unconnected track' cleanup routine
- Misc constification
parent 7b843eca
...@@ -274,7 +274,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -274,7 +274,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
bool hightQualityMode = false; bool hightQualityMode = false;
for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER;
layer++ ) ++layer )
{ {
if( layer != LAST_COPPER_LAYER if( layer != LAST_COPPER_LAYER
&& layer >= g_Parm_3D_Visu.m_CopperLayersCount ) && layer >= g_Parm_3D_Visu.m_CopperLayersCount )
...@@ -528,21 +528,19 @@ void EDA_3D_CANVAS::BuildTechLayers3DView() ...@@ -528,21 +528,19 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
} }
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU(); int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
for( TRACK* track = pcb->m_Track; track != NULL; track = track->Next() )
// Add via holes
for( VIA* via = GetFirstVia( pcb->m_Track ); via != NULL;
via = GetFirstVia( via->Next() ) )
{ {
// Add via hole VIATYPE_T viatype = via->GetViaType();
if( track->Type() == PCB_VIA_T ) int holediameter = via->GetDrillValue();
{ int hole_outer_radius = (holediameter + thickness) / 2;
const VIA *via = static_cast<const VIA*>( track );
VIATYPE_T viatype = via->GetViaType(); if( viatype == VIA_THROUGH )
int holediameter = via->GetDrillValue(); TransformCircleToPolygon( allLayerHoles,
int hole_outer_radius = (holediameter + thickness) / 2; via->GetStart(), hole_outer_radius,
segcountLowQuality );
if( viatype == VIA_THROUGH )
TransformCircleToPolygon( allLayerHoles,
via->GetStart(), hole_outer_radius,
segcountLowQuality );
}
} }
// draw pads holes // draw pads holes
...@@ -562,7 +560,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView() ...@@ -562,7 +560,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
allLayerHoles.ExportTo( brdpolysetHoles ); allLayerHoles.ExportTo( brdpolysetHoles );
for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER; for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER;
layer++ ) ++layer )
{ {
// Skip user layers, which are not drawn here // Skip user layers, which are not drawn here
if( IsUserLayer( layer) ) if( IsUserLayer( layer) )
...@@ -713,7 +711,7 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers() ...@@ -713,7 +711,7 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers()
bufferPolys.reserve( 5000 ); // Reserve for items not on board bufferPolys.reserve( 5000 ); // Reserve for items not on board
for( LAYER_NUM layer = FIRST_USER_LAYER; layer <= LAST_USER_LAYER; for( LAYER_NUM layer = FIRST_USER_LAYER; layer <= LAST_USER_LAYER;
layer++ ) ++layer )
{ {
if( !Is3DLayerEnabled( layer ) ) if( !Is3DLayerEnabled( layer ) )
continue; continue;
......
...@@ -1345,7 +1345,7 @@ SCH_SCREEN* SCH_SCREENS::GetNext() ...@@ -1345,7 +1345,7 @@ SCH_SCREEN* SCH_SCREENS::GetNext()
} }
SCH_SCREEN* SCH_SCREENS::GetScreen( unsigned int aIndex ) SCH_SCREEN* SCH_SCREENS::GetScreen( unsigned int aIndex ) const
{ {
if( aIndex < m_screens.size() ) if( aIndex < m_screens.size() )
return m_screens[ aIndex ]; return m_screens[ aIndex ];
......
...@@ -112,7 +112,7 @@ int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const ...@@ -112,7 +112,7 @@ int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const
} }
SCH_SHEET* SCH_SHEET_PATH::Last() SCH_SHEET* SCH_SHEET_PATH::Last() const
{ {
if( m_numSheets ) if( m_numSheets )
return m_sheets[m_numSheets - 1]; return m_sheets[m_numSheets - 1];
...@@ -121,7 +121,7 @@ SCH_SHEET* SCH_SHEET_PATH::Last() ...@@ -121,7 +121,7 @@ SCH_SHEET* SCH_SHEET_PATH::Last()
} }
SCH_SCREEN* SCH_SHEET_PATH::LastScreen() SCH_SCREEN* SCH_SHEET_PATH::LastScreen() const
{ {
SCH_SHEET* lastSheet = Last(); SCH_SHEET* lastSheet = Last();
...@@ -132,7 +132,7 @@ SCH_SCREEN* SCH_SHEET_PATH::LastScreen() ...@@ -132,7 +132,7 @@ SCH_SCREEN* SCH_SHEET_PATH::LastScreen()
} }
SCH_ITEM* SCH_SHEET_PATH::LastDrawList() SCH_ITEM* SCH_SHEET_PATH::LastDrawList() const
{ {
SCH_SHEET* lastSheet = Last(); SCH_SHEET* lastSheet = Last();
...@@ -143,7 +143,7 @@ SCH_ITEM* SCH_SHEET_PATH::LastDrawList() ...@@ -143,7 +143,7 @@ SCH_ITEM* SCH_SHEET_PATH::LastDrawList()
} }
SCH_ITEM* SCH_SHEET_PATH::FirstDrawList() SCH_ITEM* SCH_SHEET_PATH::FirstDrawList() const
{ {
SCH_ITEM* item = NULL; SCH_ITEM* item = NULL;
...@@ -316,7 +316,7 @@ void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aInclu ...@@ -316,7 +316,7 @@ void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aInclu
} }
SCH_ITEM* SCH_SHEET_PATH::FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) SCH_ITEM* SCH_SHEET_PATH::FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) const
{ {
bool hasWrapped = false; bool hasWrapped = false;
bool firstItemFound = false; bool firstItemFound = false;
...@@ -349,7 +349,7 @@ SCH_ITEM* SCH_SHEET_PATH::FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem, bool ...@@ -349,7 +349,7 @@ SCH_ITEM* SCH_SHEET_PATH::FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem, bool
} }
SCH_ITEM* SCH_SHEET_PATH::FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) SCH_ITEM* SCH_SHEET_PATH::FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) const
{ {
bool hasWrapped = false; bool hasWrapped = false;
bool firstItemFound = false; bool firstItemFound = false;
......
...@@ -129,20 +129,20 @@ public: ...@@ -129,20 +129,20 @@ public:
* returns a pointer to the last sheet of the list * returns a pointer to the last sheet of the list
* One can see the others sheet as the "path" to reach this last sheet * One can see the others sheet as the "path" to reach this last sheet
*/ */
SCH_SHEET* Last(); SCH_SHEET* Last() const;
/** /**
* Function LastScreen * Function LastScreen
* @return the SCH_SCREEN relative to the last sheet in list * @return the SCH_SCREEN relative to the last sheet in list
*/ */
SCH_SCREEN* LastScreen(); SCH_SCREEN* LastScreen() const;
/** /**
* Function LastDrawList * Function LastDrawList
* @return a pointer to the first schematic item handled by the * @return a pointer to the first schematic item handled by the
* SCH_SCREEN relative to the last sheet in list * SCH_SCREEN relative to the last sheet in list
*/ */
SCH_ITEM* LastDrawList(); SCH_ITEM* LastDrawList() const;
/** /**
* Get the last schematic item relative to the first sheet in the list. * Get the last schematic item relative to the first sheet in the list.
...@@ -150,7 +150,7 @@ public: ...@@ -150,7 +150,7 @@ public:
* @return Last schematic item relative to the first sheet in the list if list * @return Last schematic item relative to the first sheet in the list if list
* is not empty. Otherwise NULL. * is not empty. Otherwise NULL.
*/ */
SCH_ITEM* FirstDrawList(); SCH_ITEM* FirstDrawList() const;
/** /**
* Function Push * Function Push
...@@ -248,7 +248,7 @@ public: ...@@ -248,7 +248,7 @@ public:
* is defined. * is defined.
* @return - The next schematic item if found. Otherwise, NULL is returned. * @return - The next schematic item if found. Otherwise, NULL is returned.
*/ */
SCH_ITEM* FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ); SCH_ITEM* FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ) const;
/** /**
* Find the previous schematic item in this sheet path object. * Find the previous schematic item in this sheet path object.
...@@ -260,7 +260,7 @@ public: ...@@ -260,7 +260,7 @@ public:
* is defined. * is defined.
* @return - The previous schematic item if found. Otherwise, NULL is returned. * @return - The previous schematic item if found. Otherwise, NULL is returned.
*/ */
SCH_ITEM* FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ); SCH_ITEM* FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ) const;
SCH_SHEET_PATH& operator=( const SCH_SHEET_PATH& d1 ); SCH_SHEET_PATH& operator=( const SCH_SHEET_PATH& d1 );
...@@ -318,7 +318,7 @@ public: ...@@ -318,7 +318,7 @@ public:
* @return the number of sheets in list: * @return the number of sheets in list:
* usually the number of sheets found in the whole hierarchy * usually the number of sheets found in the whole hierarchy
*/ */
int GetCount() { return m_count; } int GetCount() const { return m_count; }
/** /**
* Function GetFirst * Function GetFirst
......
...@@ -26,7 +26,7 @@ public: ...@@ -26,7 +26,7 @@ public:
~GBR_SCREEN(); ~GBR_SCREEN();
GBR_SCREEN* Next() { return (GBR_SCREEN*) Pnext; } GBR_SCREEN* Next() const { return static_cast<GBR_SCREEN*>( Pnext ); }
// void SetNextZoom(); // void SetNextZoom();
// void SetPreviousZoom(); // void SetPreviousZoom();
......
...@@ -116,8 +116,8 @@ public: ...@@ -116,8 +116,8 @@ public:
*/ */
GERBER_DRAW_ITEM* Copy() const; GERBER_DRAW_ITEM* Copy() const;
GERBER_DRAW_ITEM* Next() const { return (GERBER_DRAW_ITEM*) Pnext; } GERBER_DRAW_ITEM* Next() const { return static_cast<GERBER_DRAW_ITEM*>( Pnext ); }
GERBER_DRAW_ITEM* Back() const { return (GERBER_DRAW_ITEM*) Pback; } GERBER_DRAW_ITEM* Back() const { return static_cast<GERBER_DRAW_ITEM*>( Pback ); }
/** /**
* Function GetLayer * Function GetLayer
......
...@@ -375,8 +375,8 @@ public: ...@@ -375,8 +375,8 @@ public:
void SetTimeStamp( time_t aNewTimeStamp ) { m_TimeStamp = aNewTimeStamp; } void SetTimeStamp( time_t aNewTimeStamp ) { m_TimeStamp = aNewTimeStamp; }
time_t GetTimeStamp() const { return m_TimeStamp; } time_t GetTimeStamp() const { return m_TimeStamp; }
EDA_ITEM* Next() const { return (EDA_ITEM*) Pnext; } EDA_ITEM* Next() const { return Pnext; }
EDA_ITEM* Back() const { return (EDA_ITEM*) Pback; } EDA_ITEM* Back() const { return Pback; }
EDA_ITEM* GetParent() const { return m_Parent; } EDA_ITEM* GetParent() const { return m_Parent; }
DHEAD* GetList() const { return m_List; } DHEAD* GetList() const { return m_List; }
......
...@@ -108,8 +108,8 @@ public: ...@@ -108,8 +108,8 @@ public:
*/ */
static wxPoint ZeroOffset; static wxPoint ZeroOffset;
BOARD_ITEM* Next() const { return (BOARD_ITEM*) Pnext; } BOARD_ITEM* Next() const { return static_cast<BOARD_ITEM*>( Pnext ); }
BOARD_ITEM* Back() const { return (BOARD_ITEM*) Pback; } BOARD_ITEM* Back() const { return static_cast<BOARD_ITEM*>( Pback ); }
BOARD_ITEM* GetParent() const { return (BOARD_ITEM*) m_Parent; } BOARD_ITEM* GetParent() const { return (BOARD_ITEM*) m_Parent; }
/** /**
......
...@@ -31,7 +31,7 @@ public: ...@@ -31,7 +31,7 @@ public:
~PCB_SCREEN(); ~PCB_SCREEN();
PCB_SCREEN* Next() { return (PCB_SCREEN*) Pnext; } PCB_SCREEN* Next() const { return static_cast<PCB_SCREEN*>( Pnext ); }
void SetNextZoom(); void SetNextZoom();
void SetPreviousZoom(); void SetPreviousZoom();
......
...@@ -523,7 +523,7 @@ public: ...@@ -523,7 +523,7 @@ public:
int GetCount() const { return m_screens.size(); } int GetCount() const { return m_screens.size(); }
SCH_SCREEN* GetFirst(); SCH_SCREEN* GetFirst();
SCH_SCREEN* GetNext(); SCH_SCREEN* GetNext();
SCH_SCREEN* GetScreen( unsigned int aIndex ); SCH_SCREEN* GetScreen( unsigned int aIndex ) const;
/** /**
* Function ClearAnnotation * Function ClearAnnotation
......
...@@ -136,8 +136,8 @@ public: ...@@ -136,8 +136,8 @@ public:
*/ */
virtual void SwapData( SCH_ITEM* aItem ); virtual void SwapData( SCH_ITEM* aItem );
SCH_ITEM* Next() { return (SCH_ITEM*) Pnext; } SCH_ITEM* Next() const { return static_cast<SCH_ITEM*>( Pnext ); }
SCH_ITEM* Back() { return (SCH_ITEM*) Pback; } SCH_ITEM* Back() const { return static_cast<SCH_ITEM*>( Pback ); }
/** /**
* Function GetLayer * Function GetLayer
......
...@@ -1563,19 +1563,12 @@ int BOARD::SetAreasNetCodesFromNetNames( void ) ...@@ -1563,19 +1563,12 @@ int BOARD::SetAreasNetCodesFromNetNames( void )
VIA* BOARD::GetViaByPosition( const wxPoint& aPosition, LAYER_NUM aLayer) const VIA* BOARD::GetViaByPosition( const wxPoint& aPosition, LAYER_NUM aLayer) const
{ {
for( TRACK *track = m_Track; track; track = track->Next() ) for( VIA *via = GetFirstVia( m_Track); via; via = GetFirstVia( via->Next() ) )
{ {
if( track->Type() != PCB_VIA_T ) if( (via->GetStart() == aPosition) &&
continue; (via->GetState( BUSY | IS_DELETED ) == 0) &&
((aLayer == UNDEFINED_LAYER) || (via->IsOnLayer( aLayer ))) )
if( track->GetStart() != aPosition ) return via;
continue;
if( track->GetState( BUSY | IS_DELETED ) )
continue;
if( (aLayer == UNDEFINED_LAYER) || (track->IsOnLayer( aLayer )) )
return static_cast<VIA *>( track );
} }
return NULL; return NULL;
......
...@@ -68,9 +68,6 @@ public: ...@@ -68,9 +68,6 @@ public:
/// skip the linked list stuff, and parent /// skip the linked list stuff, and parent
const DRAWSEGMENT& operator = ( const DRAWSEGMENT& rhs ); const DRAWSEGMENT& operator = ( const DRAWSEGMENT& rhs );
DRAWSEGMENT* Next() const { return (DRAWSEGMENT*) Pnext; }
DRAWSEGMENT* Back() const { return (DRAWSEGMENT*) Pback; }
void SetWidth( int aWidth ) { m_Width = aWidth; } void SetWidth( int aWidth ) { m_Width = aWidth; }
int GetWidth() const { return m_Width; } int GetWidth() const { return m_Width; }
......
...@@ -51,9 +51,6 @@ public: ...@@ -51,9 +51,6 @@ public:
~EDGE_MODULE(); ~EDGE_MODULE();
EDGE_MODULE* Next() const { return (EDGE_MODULE*) Pnext; }
EDGE_MODULE* Back() const { return (EDGE_MODULE*) Pback; }
/// skip the linked list stuff, and parent /// skip the linked list stuff, and parent
const EDGE_MODULE& operator = ( const EDGE_MODULE& rhs ); const EDGE_MODULE& operator = ( const EDGE_MODULE& rhs );
......
...@@ -56,9 +56,6 @@ public: ...@@ -56,9 +56,6 @@ public:
~PCB_TARGET(); ~PCB_TARGET();
PCB_TARGET* Next() const { return (PCB_TARGET*) Pnext; }
PCB_TARGET* Back() const { return (PCB_TARGET*) Pnext; }
void SetPosition( const wxPoint& aPos ) { m_Pos = aPos; } // override void SetPosition( const wxPoint& aPos ) { m_Pos = aPos; } // override
const wxPoint& GetPosition() const { return m_Pos; } // override const wxPoint& GetPosition() const { return m_Pos; } // override
......
...@@ -422,9 +422,12 @@ EDA_RECT MODULE::GetFootprintRect() const ...@@ -422,9 +422,12 @@ EDA_RECT MODULE::GetFootprintRect() const
area.SetEnd( m_Pos ); area.SetEnd( m_Pos );
area.Inflate( Millimeter2iu( 0.25 ) ); // Give a min size to the area area.Inflate( Millimeter2iu( 0.25 ) ); // Give a min size to the area
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() ) for( const BOARD_ITEM* item = m_Drawings.GetFirst(); item; item = item->Next() )
if( edge->Type() == PCB_MODULE_EDGE_T ) {
const EDGE_MODULE *edge = dynamic_cast<const EDGE_MODULE*>( item );
if( edge )
area.Merge( edge->GetBoundingBox() ); area.Merge( edge->GetBoundingBox() );
}
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
area.Merge( pad->GetBoundingBox() ); area.Merge( pad->GetBoundingBox() );
......
...@@ -77,8 +77,8 @@ public: ...@@ -77,8 +77,8 @@ public:
~MODULE(); ~MODULE();
MODULE* Next() const { return (MODULE*) Pnext; } MODULE* Next() const { return static_cast<MODULE*>( Pnext ); }
MODULE* Back() const { return (MODULE*) Pback; } MODULE* Back() const { return static_cast<MODULE*>( Pback ); }
void Copy( MODULE* Module ); // Copy structure void Copy( MODULE* Module ); // Copy structure
......
...@@ -106,7 +106,7 @@ public: ...@@ -106,7 +106,7 @@ public:
void Copy( D_PAD* source ); void Copy( D_PAD* source );
D_PAD* Next() const { return (D_PAD*) Pnext; } D_PAD* Next() const { return static_cast<D_PAD*>( Pnext ); }
MODULE* GetParent() const { return (MODULE*) m_Parent; } MODULE* GetParent() const { return (MODULE*) m_Parent; }
......
...@@ -98,10 +98,6 @@ public: ...@@ -98,10 +98,6 @@ public:
void Flip( const wxPoint& aCentre ); void Flip( const wxPoint& aCentre );
TEXTE_MODULE* Next() const { return (TEXTE_MODULE*) Pnext; }
TEXTE_MODULE* Back() const { return (TEXTE_MODULE*) Pback; }
/// @deprecated it seems (but the type is used to 'protect' /// @deprecated it seems (but the type is used to 'protect'
//reference and value from deletion, and for identification) //reference and value from deletion, and for identification)
void SetType( TEXT_TYPE aType ) { m_Type = aType; } void SetType( TEXT_TYPE aType ) { m_Type = aType; }
......
...@@ -88,12 +88,9 @@ inline bool IsNear( const wxPoint& p1, const wxPoint& p2, int max_dist ) ...@@ -88,12 +88,9 @@ inline bool IsNear( const wxPoint& p1, const wxPoint& p2, int max_dist )
} }
TRACK* GetTrack( TRACK* aStartTrace, TRACK* aEndTrace, TRACK* GetTrack( TRACK* aStartTrace, const TRACK* aEndTrace,
const wxPoint& aPosition, LAYER_MSK aLayerMask ) const wxPoint& aPosition, LAYER_MSK aLayerMask )
{ {
if( aStartTrace == NULL )
return NULL;
for( TRACK *PtSegm = aStartTrace; PtSegm != NULL; PtSegm = PtSegm->Next() ) for( TRACK *PtSegm = aStartTrace; PtSegm != NULL; PtSegm = PtSegm->Next() )
{ {
if( PtSegm->GetState( IS_DELETED | BUSY ) == 0 ) if( PtSegm->GetState( IS_DELETED | BUSY ) == 0 )
...@@ -180,7 +177,6 @@ VIA::VIA( BOARD_ITEM* aParent ) : ...@@ -180,7 +177,6 @@ VIA::VIA( BOARD_ITEM* aParent ) :
{ {
SetViaType( VIA_THROUGH ); SetViaType( VIA_THROUGH );
m_BottomLayer = LAYER_N_BACK; m_BottomLayer = LAYER_N_BACK;
m_Width = Millimeter2iu( 0.5 );
SetDrillDefault(); SetDrillDefault();
} }
...@@ -369,9 +365,14 @@ void TRACK::Flip( const wxPoint& aCentre ) ...@@ -369,9 +365,14 @@ void TRACK::Flip( const wxPoint& aCentre )
{ {
m_Start.y = aCentre.y - (m_Start.y - aCentre.y); m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
m_End.y = aCentre.y - (m_End.y - aCentre.y); m_End.y = aCentre.y - (m_End.y - aCentre.y);
SetLayer( FlipLayer( GetLayer() ) );
}
if( Type() != PCB_VIA_T ) void VIA::Flip( const wxPoint& aCentre )
SetLayer( FlipLayer( GetLayer() ) ); {
m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
m_End.y = aCentre.y - (m_End.y - aCentre.y);
} }
......
...@@ -74,7 +74,7 @@ enum VIATYPE_T ...@@ -74,7 +74,7 @@ enum VIATYPE_T
* layer mask. * layer mask.
* @return A TRACK object pointer if found otherwise NULL. * @return A TRACK object pointer if found otherwise NULL.
*/ */
extern TRACK* GetTrack( TRACK* aStartTrace, TRACK* aEndTrace, extern TRACK* GetTrack( TRACK* aStartTrace, const TRACK* aEndTrace,
const wxPoint& aPosition, LAYER_MSK aLayerMask ); const wxPoint& aPosition, LAYER_MSK aLayerMask );
class TRACK : public BOARD_CONNECTED_ITEM class TRACK : public BOARD_CONNECTED_ITEM
...@@ -100,8 +100,8 @@ public: ...@@ -100,8 +100,8 @@ public:
// Do not create a copy constructor. The one generated by the compiler is adequate. // Do not create a copy constructor. The one generated by the compiler is adequate.
TRACK* Next() const { return (TRACK*) Pnext; } TRACK* Next() const { return static_cast<TRACK*>( Pnext ); }
TRACK* Back() const { return (TRACK*) Pback; } TRACK* Back() const { return static_cast<TRACK*>( Pback ); }
virtual void Move( const wxPoint& aMoveVector ) virtual void Move( const wxPoint& aMoveVector )
{ {
...@@ -350,7 +350,7 @@ public: ...@@ -350,7 +350,7 @@ public:
} }
SEGZONE* Next() const { return (SEGZONE*) Pnext; } SEGZONE* Next() const { return static_cast<SEGZONE*>( Pnext ); }
wxString GetSelectMenuText() const; wxString GetSelectMenuText() const;
...@@ -415,6 +415,8 @@ public: ...@@ -415,6 +415,8 @@ public:
/// @copydoc VIEW_ITEM::ViewGetLayers() /// @copydoc VIEW_ITEM::ViewGetLayers()
virtual void ViewGetLayers( int aLayers[], int& aCount ) const; virtual void ViewGetLayers( int aLayers[], int& aCount ) const;
virtual void Flip( const wxPoint& aCentre );
#if defined (DEBUG) #if defined (DEBUG)
virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif #endif
...@@ -469,5 +471,13 @@ private: ...@@ -469,5 +471,13 @@ private:
int m_Drill; // for vias: via drill (- 1 for default value) int m_Drill; // for vias: via drill (- 1 for default value)
}; };
/// Scan a track list for the first VIA o NULL if not found (or NULL passed)
inline VIA *GetFirstVia( TRACK *aTrk, const TRACK *aStopPoint = NULL )
{
while( aTrk && (aTrk != aStopPoint) && (aTrk->Type() != PCB_VIA_T) )
aTrk = aTrk->Next();
return static_cast<VIA*>( aTrk );
}
#endif /* CLASS_TRACK_H */ #endif /* CLASS_TRACK_H */
This diff is collapsed.
...@@ -169,12 +169,11 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Width( EDGE_MODULE* aEdge ) ...@@ -169,12 +169,11 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Width( EDGE_MODULE* aEdge )
{ {
aEdge = (EDGE_MODULE*) (BOARD_ITEM*) module->GraphicalItems(); aEdge = (EDGE_MODULE*) (BOARD_ITEM*) module->GraphicalItems();
for( ; aEdge != NULL; aEdge = aEdge->Next() ) for( BOARD_ITEM *item = module->GraphicalItems(); item; item = item->Next() )
{ {
if( aEdge->Type() != PCB_MODULE_EDGE_T ) aEdge = dynamic_cast<EDGE_MODULE*>( item );
continue; if( aEdge )
aEdge->SetWidth( GetDesignSettings().m_ModuleSegmentWidth );
aEdge->SetWidth( GetDesignSettings().m_ModuleSegmentWidth );
} }
} }
else else
...@@ -216,14 +215,12 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* aEdge ) ...@@ -216,14 +215,12 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* aEdge )
if( aEdge == NULL ) if( aEdge == NULL )
{ {
aEdge = (EDGE_MODULE*) (BOARD_ITEM*) module->GraphicalItems(); for( BOARD_ITEM *item = module->GraphicalItems() ; item != NULL;
item = item->Next() )
for( ; aEdge != NULL; aEdge = aEdge->Next() )
{ {
if( aEdge->Type() != PCB_MODULE_EDGE_T ) aEdge = dynamic_cast<EDGE_MODULE*>( item );
continue;
if( aEdge->GetLayer() != new_layer ) if( aEdge && (aEdge->GetLayer() != new_layer) )
{ {
if( ! modified ) // save only once if( ! modified ) // save only once
SaveCopyInUndoList( module, UR_MODEDIT ); SaveCopyInUndoList( module, UR_MODEDIT );
......
...@@ -62,9 +62,9 @@ static void Abort_Create_Track( EDA_DRAW_PANEL* Panel, wxDC* DC ) ...@@ -62,9 +62,9 @@ static void Abort_Create_Track( EDA_DRAW_PANEL* Panel, wxDC* DC )
{ {
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Panel->GetParent(); PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Panel->GetParent();
BOARD* pcb = frame->GetBoard(); BOARD* pcb = frame->GetBoard();
TRACK* track = (TRACK*) frame->GetCurItem(); TRACK* track = dynamic_cast<TRACK*>( frame->GetCurItem() );
if( track && ( track->Type()==PCB_VIA_T || track->Type()==PCB_TRACE_T ) ) if( track )
{ {
// Erase the current drawing // Erase the current drawing
ShowNewTrackWhenMovingCursor( Panel, DC, wxDefaultPosition, false ); ShowNewTrackWhenMovingCursor( Panel, DC, wxDefaultPosition, false );
......
...@@ -271,12 +271,10 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb ) ...@@ -271,12 +271,10 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
} }
// The same for vias // The same for vias
for( TRACK* track = aPcb->m_Track; track != NULL; track = track->Next() ) for( VIA* via = GetFirstVia( aPcb->m_Track ); via != NULL;
via = GetFirstVia( via->Next() ) )
{ {
if( track->Type() == PCB_VIA_T ) vias.push_back( via );
{
vias.push_back( static_cast<VIA*>(track) );
}
} }
qsort( &vias[0], vias.size(), sizeof(VIA*), ViaSort ); qsort( &vias[0], vias.size(), sizeof(VIA*), ViaSort );
......
...@@ -453,12 +453,9 @@ void EXCELLON_WRITER::BuildHolesList( int aFirstLayer, ...@@ -453,12 +453,9 @@ void EXCELLON_WRITER::BuildHolesList( int aFirstLayer,
// build hole list for vias // build hole list for vias
if( ! aGenerateNPTH_list ) // vias are always plated ! if( ! aGenerateNPTH_list ) // vias are always plated !
{ {
for( TRACK* track = m_pcb->m_Track; track; track = track->Next() ) for( VIA* via = GetFirstVia( m_pcb->m_Track ); via;
via = GetFirstVia( via->Next() ) )
{ {
if( track->Type() != PCB_VIA_T )
continue;
const VIA* via = (const VIA*) track;
hole_value = via->GetDrillValue(); hole_value = via->GetDrillValue();
if( hole_value == 0 ) if( hole_value == 0 )
......
...@@ -148,10 +148,11 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule ) ...@@ -148,10 +148,11 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule )
PlotTextModule( &aModule->Value(), GetValueColor() ); PlotTextModule( &aModule->Value(), GetValueColor() );
} }
for( textModule = (TEXTE_MODULE*) aModule->GraphicalItems().GetFirst(); for( BOARD_ITEM *item = aModule->GraphicalItems().GetFirst();
textModule != NULL; textModule = textModule->Next() ) item != NULL; item = item->Next() )
{ {
if( textModule->Type() != PCB_MODULE_TEXT_T ) textModule = dynamic_cast<TEXTE_MODULE*>( item );
if( !textModule )
continue; continue;
if( !GetPlotOtherText() ) if( !GetPlotOtherText() )
...@@ -350,13 +351,11 @@ void BRDITEMS_PLOTTER::Plot_Edges_Modules() ...@@ -350,13 +351,11 @@ void BRDITEMS_PLOTTER::Plot_Edges_Modules()
{ {
for( MODULE* module = m_board->m_Modules; module; module = module->Next() ) for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
{ {
for( EDGE_MODULE* edge = (EDGE_MODULE*) module->GraphicalItems().GetFirst(); for( BOARD_ITEM* item = module->GraphicalItems().GetFirst(); item; item = item->Next() )
edge; edge = edge->Next() )
{ {
if( edge->Type() != PCB_MODULE_EDGE_T ) EDGE_MODULE *edge = dynamic_cast<EDGE_MODULE*>( item );
continue;
if( ( GetLayerMask( edge->GetLayer() ) & m_layerMask ) == 0 ) if( !edge || (( GetLayerMask( edge->GetLayer() ) & m_layerMask ) == 0) )
continue; continue;
Plot_1_EdgeModule( edge ); Plot_1_EdgeModule( edge );
......
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