From 3480c41caa20271b2a45e3e1025cfc48e847de8b Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 3 Jun 2014 16:09:27 +0200 Subject: [PATCH] PNS router handles net class settings (dependent on the selected start item). --- include/class_board_design_settings.h | 67 +++++++++++++++++--------- pcbnew/class_board_design_settings.cpp | 4 ++ pcbnew/router/pns_line_placer.cpp | 7 +-- pcbnew/router/pns_line_placer.h | 12 +++-- pcbnew/router/pns_router.cpp | 25 +++++++++- 5 files changed, 80 insertions(+), 35 deletions(-) diff --git a/include/class_board_design_settings.h b/include/class_board_design_settings.h index 28201dd866..4e81ff0652 100644 --- a/include/class_board_design_settings.h +++ b/include/class_board_design_settings.h @@ -114,11 +114,29 @@ public: * Function GetCurrentNetClassName * @return the current net class name. */ - const wxString& GetCurrentNetClassName() const + inline const wxString& GetCurrentNetClassName() const { return m_currentNetClassName; } + /** + * Function UseNetClassTrack + * returns true if netclass values should be used to obtain appropriate track width. + */ + inline bool UseNetClassTrack() const + { + return ( m_trackWidthIndex == 0 && !m_useCustomTrackVia ); + } + + /** + * Function UseNetClassVia + * returns true if netclass values should be used to obtain appropriate via size. + */ + inline bool UseNetClassVia() const + { + return ( m_viaSizeIndex == 0 && !m_useCustomTrackVia ); + } + /** * Function SetCurrentNetClass * Must be called after a netclass selection (or after a netclass parameter change @@ -159,7 +177,7 @@ public: * Function GetTrackWidthIndex * @return the current track width list index. */ - unsigned GetTrackWidthIndex() const { return m_trackWidthIndex; } + inline unsigned GetTrackWidthIndex() const { return m_trackWidthIndex; } /** * Function SetTrackWidthIndex @@ -175,7 +193,7 @@ public: * ( using the default netclass value or a preset/custom value ) * the default netclass is always in m_TrackWidthList[0] */ - int GetCurrentTrackWidth() const + inline int GetCurrentTrackWidth() const { return m_useCustomTrackVia ? m_customTrackWidth : m_TrackWidthList[m_trackWidthIndex]; } @@ -187,7 +205,7 @@ public: * (UseCustomTrackViaSize()). * @param aWidth is the new track width. */ - void SetCustomTrackWidth( int aWidth ) + inline void SetCustomTrackWidth( int aWidth ) { m_customTrackWidth = aWidth; } @@ -196,7 +214,7 @@ public: * Function GetCustomTrackWidth * @return Current custom width for a track. */ - int GetCustomTrackWidth() const + inline int GetCustomTrackWidth() const { return m_customTrackWidth; } @@ -205,7 +223,10 @@ public: * Function GetViaSizeIndex * @return the current via size list index. */ - unsigned GetViaSizeIndex() const { return m_viaSizeIndex; } + inline unsigned GetViaSizeIndex() const + { + return m_viaSizeIndex; + } /** * Function SetViaSizeIndex @@ -221,7 +242,7 @@ public: * ( using the default netclass value or a preset/custom value ) * the default netclass is always in m_TrackWidthList[0] */ - int GetCurrentViaSize() const + inline int GetCurrentViaSize() const { if( m_useCustomTrackVia ) return m_customViaSize.m_Diameter; @@ -236,7 +257,7 @@ public: * (UseCustomTrackViaSize()). * @param aSize is the new drill diameter. */ - void SetCustomViaSize( int aSize ) + inline void SetCustomViaSize( int aSize ) { m_customViaSize.m_Diameter = aSize; } @@ -245,7 +266,7 @@ public: * Function GetCustomViaSize * @return Current custom size for the via diameter. */ - int GetCustomViaSize() const + inline int GetCustomViaSize() const { return m_customViaSize.m_Diameter; } @@ -265,7 +286,7 @@ public: * (UseCustomTrackViaSize()). * @param aDrill is the new drill size. */ - void SetCustomViaDrill( int aDrill ) + inline void SetCustomViaDrill( int aDrill ) { m_customViaSize.m_Drill = aDrill; } @@ -274,7 +295,7 @@ public: * Function GetCustomViaDrill * @return Current custom size for the via drill. */ - int GetCustomViaDrill() const + inline int GetCustomViaDrill() const { return m_customViaSize.m_Drill; } @@ -286,7 +307,7 @@ public: * tracks and vias. * @param aEnabled decides if custom settings should be used for new tracks/vias. */ - void UseCustomTrackViaSize( bool aEnabled ) + inline void UseCustomTrackViaSize( bool aEnabled ) { m_useCustomTrackVia = aEnabled; } @@ -295,7 +316,7 @@ public: * Function UseCustomTrackViaSize * @return True if custom sizes of tracks & vias are enabled, false otherwise. */ - bool UseCustomTrackViaSize() const + inline bool UseCustomTrackViaSize() const { return m_useCustomTrackVia; } @@ -305,7 +326,7 @@ public: * returns a bit-mask of all the layers that are visible * @return int - the visible layers in bit-mapped form. */ - LAYER_MSK GetVisibleLayers() const + inline LAYER_MSK GetVisibleLayers() const { return m_visibleLayers; } @@ -322,7 +343,7 @@ public: * changes the bit-mask of visible layers * @param aMask = The new bit-mask of visible layers */ - void SetVisibleLayers( LAYER_MSK aMask ) + inline void SetVisibleLayers( LAYER_MSK aMask ) { m_visibleLayers = aMask & m_enabledLayers & FULL_LAYERS; } @@ -333,7 +354,7 @@ public: * @param aLayer = The layer to be tested * @return bool - true if the layer is visible. */ - bool IsLayerVisible( LAYER_NUM aLayer ) const + inline bool IsLayerVisible( LAYER_NUM aLayer ) const { // If a layer is disabled, it is automatically invisible return m_visibleLayers & m_enabledLayers & GetLayerMask( aLayer ); @@ -352,7 +373,7 @@ public: * returns a bit-mask of all the element categories that are visible * @return int - the visible element categories in bit-mapped form. */ - int GetVisibleElements() const + inline int GetVisibleElements() const { return m_visibleElements; } @@ -362,7 +383,7 @@ public: * changes the bit-mask of visible element categories * @param aMask = The new bit-mask of visible element categories */ - void SetVisibleElements( int aMask ) + inline void SetVisibleElements( int aMask ) { m_visibleElements = aMask; } @@ -375,7 +396,7 @@ public: * @return bool - true if the element is visible. * @see enum PCB_VISIBLE */ - bool IsElementVisible( int aElementCategory ) const + inline bool IsElementVisible( int aElementCategory ) const { assert( aElementCategory >= 0 && aElementCategory < END_PCB_VISIBLE_LIST ); @@ -414,7 +435,7 @@ public: * @param aLayer = The of the layer to be tested * @return bool - true if the layer is enabled */ - bool IsLayerEnabled( LAYER_NUM aLayer ) const + inline bool IsLayerEnabled( LAYER_NUM aLayer ) const { return m_enabledLayers & GetLayerMask( aLayer ); } @@ -423,7 +444,7 @@ public: * Function GetCopperLayerCount * @return int - the number of neabled copper layers */ - int GetCopperLayerCount() const + inline int GetCopperLayerCount() const { return m_copperLayerCount; } @@ -443,8 +464,8 @@ public: */ void AppendConfigs( PARAM_CFG_ARRAY* aResult ); - int GetBoardThickness() const { return m_boardThickness; } - void SetBoardThickness( int aThickness ) { m_boardThickness = aThickness; } + inline int GetBoardThickness() const { return m_boardThickness; } + inline void SetBoardThickness( int aThickness ) { m_boardThickness = aThickness; } private: /// Index for #m_ViasDimensionsList to select the current via size. diff --git a/pcbnew/class_board_design_settings.cpp b/pcbnew/class_board_design_settings.cpp index b4017ae21d..975972b1aa 100644 --- a/pcbnew/class_board_design_settings.cpp +++ b/pcbnew/class_board_design_settings.cpp @@ -274,6 +274,8 @@ void BOARD_DESIGN_SETTINGS::SetViaSizeIndex( unsigned aIndex ) m_viaSizeIndex = m_ViasDimensionsList.size(); else m_viaSizeIndex = aIndex; + + m_useCustomTrackVia = false; } @@ -296,6 +298,8 @@ void BOARD_DESIGN_SETTINGS::SetTrackWidthIndex( unsigned aIndex ) m_trackWidthIndex = m_TrackWidthList.size(); else m_trackWidthIndex = aIndex; + + m_useCustomTrackVia = false; } diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 3b94a2ed1f..e60729c90c 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -764,12 +764,6 @@ void PNS_LINE_PLACER::SetLayer(int aLayer) } -void PNS_LINE_PLACER::SetWidth(int aWidth) -{ - m_currentWidth = aWidth; -} - - void PNS_LINE_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) { VECTOR2I p( aP ); @@ -995,6 +989,7 @@ void PNS_LINE_PLACER::UpdateSizes( const PNS_ROUTING_SETTINGS& aSettings ) m_head.SetWidth( trackWidth ); m_tail.SetWidth( trackWidth ); + m_currentWidth = trackWidth; m_viaDiameter = aSettings.GetViaDiameter(); m_viaDrill = aSettings.GetViaDrill(); } diff --git a/pcbnew/router/pns_line_placer.h b/pcbnew/router/pns_line_placer.h index 66fdb32c17..1ae3b2d69c 100644 --- a/pcbnew/router/pns_line_placer.h +++ b/pcbnew/router/pns_line_placer.h @@ -252,7 +252,7 @@ private: * and redundant vertexes. If a simplification bhas been found, replaces the * old line with the simplified one in aNode. */ - void simplifyNewLine ( PNS_NODE *aNode, PNS_SEGMENT *aLatest ); + void simplifyNewLine( PNS_NODE *aNode, PNS_SEGMENT *aLatest ); /** * Function handleViaPlacement() @@ -338,13 +338,13 @@ private: void routeStep( const VECTOR2I& aP ); ///> route step, walkaround mode - bool rhWalkOnly ( const VECTOR2I& aP, PNS_LINE& aNewHead); + bool rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead); ///> route step, shove mode - bool rhShoveOnly ( const VECTOR2I& aP, PNS_LINE& aNewHead); + bool rhShoveOnly( const VECTOR2I& aP, PNS_LINE& aNewHead); ///> route step, mark obstacles mode - bool rhMarkObstacles ( const VECTOR2I& aP, PNS_LINE& aNewHead ); + bool rhMarkObstacles( const VECTOR2I& aP, PNS_LINE& aNewHead ); ///> current routing direction DIRECTION_45 m_direction; @@ -386,7 +386,9 @@ private: ///> current via drill int m_viaDrill; + ///> current track width int m_currentWidth; + int m_currentNet; int m_currentLayer; @@ -395,7 +397,7 @@ private: VECTOR2I m_originalStart, m_currentEnd, m_currentStart; PNS_LINE m_currentTrace; - PNS_MODE m_currentMode; + PNS_MODE m_currentMode; }; #endif // __PNS_LINE_PLACER_H diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index b45ec0deff..e10ebd9190 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -484,7 +484,30 @@ bool PNS_ROUTER::StartRouting( const VECTOR2I& aP, PNS_ITEM* aStartItem ) m_placer = new PNS_LINE_PLACER( this ); m_placer->SetLayer( m_currentLayer ); - m_placer->SetWidth( m_settings.GetTrackWidth() ); + + const BOARD_DESIGN_SETTINGS& dsnSettings = m_board->GetDesignSettings(); + + if( dsnSettings.UseNetClassTrack() && aStartItem != NULL ) // netclass value + { + m_settings.SetTrackWidth( aStartItem->Parent()->GetNetClass()->GetTrackWidth() ); + } + else + { + m_settings.SetTrackWidth( dsnSettings.GetCurrentTrackWidth() ); + } + + if( dsnSettings.UseNetClassVia() && aStartItem != NULL ) // netclass value + { + m_settings.SetViaDiameter( aStartItem->Parent()->GetNetClass()->GetViaDiameter() ); + m_settings.SetViaDrill( aStartItem->Parent()->GetNetClass()->GetViaDrill() ); + } + else + { + m_settings.SetViaDiameter( dsnSettings.GetCurrentViaSize() ); + m_settings.SetViaDrill( dsnSettings.GetCurrentViaDrill() ); + } + + m_placer->UpdateSizes( m_settings ); m_placer->Start( aP, aStartItem ); m_currentEnd = aP; m_currentEndItem = NULL;