From ffe212ea5e8b928bd9f30bf3c26de7142af9541a Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 13 May 2014 11:22:51 +0200 Subject: [PATCH] Initial support for custom track width & via size. --- pcbnew/class_board.cpp | 6 ++ pcbnew/class_board.h | 125 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 121 insertions(+), 10 deletions(-) diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index a7b4e35987..81399f456f 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -106,6 +106,12 @@ BOARD::BOARD() : SetCurrentNetClass( m_NetClasses.GetDefault()->GetName() ); + // Set sensible initial values for custom track width & via size + m_useCustomTrackVia = false; + m_customTrackWidth = GetCurrentTrackWidth(); + m_customViaSize.m_Diameter = GetCurrentViaSize(); + m_customViaSize.m_Drill = GetCurrentViaDrill(); + // Initialize ratsnest m_ratsnest = new RN_DATA( this ); m_ratsnestViewItem = new KIGFX::RATSNEST_VIEWITEM( m_ratsnest ); diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 308f69a13d..7fc8987198 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -258,6 +258,15 @@ private: // Index for m_TrackWidthList to select the value. unsigned m_trackWidthIndex; + ///> Use custom values for track/via sizes (not specified in net class nor in the size lists). + bool m_useCustomTrackVia; + + ///> Custom track width (used after UseCustomTrackViaSize( true ) was called). + int m_customTrackWidth; + + ///> Custom via size (used after UseCustomTrackViaSize( true ) was called). + VIA_DIMENSION m_customViaSize; + /** * Function chainMarkedSegments * is used by MarkTrace() to set the BUSY flag of connected segments of the trace @@ -303,15 +312,14 @@ public: // the first value is always the value of the current NetClass // The others values are extra values - // The first value is the current netclass via size // TODO verify + // The first value is the current netclass via size /// Vias size and drill list std::vector m_ViasDimensionsList; - // The first value is the current netclass track width // TODO verify + // The first value is the current netclass track width /// Track width list std::vector m_TrackWidthList; - BOARD(); ~BOARD(); @@ -1074,12 +1082,36 @@ public: /** * Function GetCurrentTrackWidth * @return the current track width, according to the selected options - * ( using the default netclass value or a preset value ) + * ( using the default netclass value or a preset/custom value ) * the default netclass is always in m_TrackWidthList[0] */ int GetCurrentTrackWidth() const { - return m_TrackWidthList[m_trackWidthIndex]; + if( m_useCustomTrackVia ) + return m_customTrackWidth; + else + return m_TrackWidthList[m_trackWidthIndex]; + } + + /** + * Function SetCustomTrackWidth + * Sets custom width for track (i.e. not available in netclasses or preset list). To have + * it returned with GetCurrentTrackWidth() you need to enable custom track & via sizes + * (UseCustomTrackViaSize()). + * @param aWidth is the new track width. + */ + void SetCustomTrackWidth( int aWidth ) + { + m_customTrackWidth = aWidth; + } + + /** + * Function GetCustomTrackWidth + * @return Current custom width for a track. + */ + int GetCustomTrackWidth() const + { + return m_customTrackWidth; } /** @@ -1099,24 +1131,76 @@ public: /** * Function GetCurrentViaSize * @return the current via size, according to the selected options - * ( using the default netclass value or a preset value ) + * ( using the default netclass value or a preset/custom value ) * the default netclass is always in m_TrackWidthList[0] */ int GetCurrentViaSize() { - return m_ViasDimensionsList[m_viaSizeIndex].m_Diameter; + if( m_useCustomTrackVia ) + return m_customViaSize.m_Diameter; + else + return m_ViasDimensionsList[m_viaSizeIndex].m_Diameter; } + /** + * Function SetCustomViaSize + * Sets custom size for via diameter (i.e. not available in netclasses or preset list). To have + * it returned with GetCurrentViaSize() you need to enable custom track & via sizes + * (UseCustomTrackViaSize()). + * @param aSize is the new drill diameter. + */ + void SetCustomViaSize( int aSize ) + { + m_customViaSize.m_Diameter = aSize; + } + + /** + * Function GetCustomViaSize + * @return Current custom size for the via diameter. + */ + int GetCustomViaSize() const + { + return m_customViaSize.m_Diameter; + } + + /** * Function GetCurrentViaDrill * @return the current via size, according to the selected options - * ( using the default netclass value or a preset value ) + * ( using the default netclass value or a preset/custom value ) * the default netclass is always in m_TrackWidthList[0] */ int GetCurrentViaDrill() { - return m_ViasDimensionsList[m_viaSizeIndex].m_Drill > 0 ? - m_ViasDimensionsList[m_viaSizeIndex].m_Drill : -1; + int drill; + + if( m_useCustomTrackVia ) + drill = m_customViaSize.m_Drill; + else + drill = m_ViasDimensionsList[m_viaSizeIndex].m_Drill; + + return drill > 0 ? drill : -1; + } + + /** + * Function SetCustomViaDrill + * Sets custom size for via drill (i.e. not available in netclasses or preset list). To have + * it returned with GetCurrentViaDrill() you need to enable custom track & via sizes + * (UseCustomTrackViaSize()). + * @param aDrill is the new drill size. + */ + void SetCustomViaDrill( int aDrill ) + { + m_customViaSize.m_Drill = aDrill; + } + + /** + * Function GetCustomViaDrill + * @return Current custom size for the via drill. + */ + int GetCustomViaDrill() const + { + return m_customViaSize.m_Drill; } /** @@ -1133,6 +1217,27 @@ public: */ int GetCurrentMicroViaDrill(); + /** + * Function UseCustomTrackViaSize + * Enables/disables custom track/via size settings. If enabled, values set with + * SetCustomTrackWidth()/SetCustomViaSize()/SetCustomViaDrill() are used for newly created + * tracks and vias. + * @param aEnabled decides if custom settings should be used for new tracks/vias. + */ + void UseCustomTrackViaSize( bool aEnabled ) + { + m_useCustomTrackVia = aEnabled; + } + + /** + * Function UseCustomTrackViaSize + * @return True if custom sizes of tracks & vias are enabled, false otherwise. + */ + bool UseCustomTrackViaSize() const + { + return m_useCustomTrackVia; + } + /***************************************************************************/ wxString GetClass() const