diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index d9a726acc9..36c96efb57 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -194,7 +194,7 @@ void PCB_DIMENSION_BASE::ClearRenderCache() if( !m_inClearRenderCache ) { m_inClearRenderCache = true; - updateText(); + Update(); m_inClearRenderCache = false; } } @@ -313,7 +313,7 @@ void PCB_DIMENSION_BASE::SetUnitsMode( DIM_UNITS_MODE aMode ) } -void PCB_DIMENSION_BASE::SetTextAngleDegreesProp( double aDegrees ) +void PCB_DIMENSION_BASE::ChangeTextAngleDegrees( double aDegrees ) { SetTextAngleDegrees( aDegrees ); // Create or repair any knockouts @@ -321,7 +321,7 @@ void PCB_DIMENSION_BASE::SetTextAngleDegreesProp( double aDegrees ) } -void PCB_DIMENSION_BASE::SetKeepTextAlignedProp( bool aKeepAligned ) +void PCB_DIMENSION_BASE::ChangeKeepTextAligned( bool aKeepAligned ) { SetKeepTextAligned( aKeepAligned ); // Re-align the text and repair any knockouts @@ -1509,12 +1509,12 @@ static struct DIMENSION_DESC }; propMgr.AddProperty( new PROPERTY( _HKI( "Keep Aligned with Dimension" ), - &PCB_DIMENSION_BASE::SetKeepTextAlignedProp, + &PCB_DIMENSION_BASE::ChangeKeepTextAligned, &PCB_DIMENSION_BASE::GetKeepTextAligned ), groupText ); propMgr.AddProperty( new PROPERTY( _HKI( "Orientation" ), - &PCB_DIMENSION_BASE::SetTextAngleDegreesProp, + &PCB_DIMENSION_BASE::ChangeTextAngleDegrees, &PCB_DIMENSION_BASE::GetTextAngleDegreesProp, PROPERTY_DISPLAY::PT_DEGREE ), groupText ) diff --git a/pcbnew/pcb_dimension.h b/pcbnew/pcb_dimension.h index ec2f4dd51e..00152d694c 100644 --- a/pcbnew/pcb_dimension.h +++ b/pcbnew/pcb_dimension.h @@ -135,7 +135,7 @@ public: { SetOverrideTextEnabled( true ); SetOverrideText( aValue ); - updateText(); + Update(); } int GetMeasuredValue() const { return m_measuredValue; } @@ -150,17 +150,21 @@ public: /** * Update the dimension's cached text and geometry. + * + * Call this whenever you change something in the geometry + * definition, or the text (which can affect geometry, e.g. by + * a knockout of a crossbar line or similar) */ void Update() { + // Calls updateText internally updateGeometry(); - updateText(); } void UpdateUnits() { SetUnitsMode( GetUnitsMode() ); - updateText(); + Update(); } wxString GetPrefix() const { return m_prefix; } @@ -169,7 +173,7 @@ public: void ChangePrefix( const wxString& aPrefix ) { SetPrefix( aPrefix ); - updateText(); + Update(); } wxString GetSuffix() const { return m_suffix; } @@ -178,7 +182,7 @@ public: void ChangeSuffix( const wxString& aSuffix ) { SetSuffix( aSuffix ); - updateText(); + Update(); } EDA_UNITS GetUnits() const { return m_units; } @@ -190,7 +194,7 @@ public: void ChangeUnitsMode( DIM_UNITS_MODE aMode ) { SetUnitsMode( aMode ); - updateText(); + Update(); } void SetAutoUnits( bool aAuto = true ) { m_autoUnits = aAuto; } @@ -201,7 +205,7 @@ public: void ChangeUnitsFormat( const DIM_UNITS_FORMAT aFormat ) { SetUnitsFormat( aFormat ); - updateText(); + Update(); } DIM_PRECISION GetPrecision() const { return m_precision; } @@ -210,7 +214,7 @@ public: void ChangePrecision( DIM_PRECISION aPrecision ) { SetPrecision( aPrecision ); - updateText(); + Update(); } bool GetSuppressZeroes() const { return m_suppressZeroes; } @@ -219,15 +223,15 @@ public: void ChangeSuppressZeroes( bool aSuppress ) { SetSuppressZeroes( aSuppress ); - updateText(); + Update(); } bool GetKeepTextAligned() const { return m_keepTextAligned; } void SetKeepTextAligned( bool aKeepAligned ) { m_keepTextAligned = aKeepAligned; } double GetTextAngleDegreesProp() const { return GetTextAngleDegrees(); } - void SetTextAngleDegreesProp( double aDegrees ); - void SetKeepTextAlignedProp( bool aKeepAligned ); + void ChangeTextAngleDegrees( double aDegrees ); + void ChangeKeepTextAligned( bool aKeepAligned ); void SetTextPositionMode( DIM_TEXT_POSITION aMode ) { m_textPosition = aMode; } DIM_TEXT_POSITION GetTextPositionMode() const { return m_textPosition; } @@ -299,6 +303,9 @@ protected: /** * Update the text field value from the current geometry (called by updateGeometry normally). + * + * If you change the text, you should call updateGeometry which will call this, + * and also handle any text-dependent geoemtry handling (like a knockout) */ virtual void updateText(); @@ -410,7 +417,7 @@ public: void ChangeHeight( int aHeight ) { SetHeight( aHeight ); - updateGeometry(); + Update(); } /** @@ -426,7 +433,7 @@ public: void ChangeExtensionHeight( int aHeight ) { SetExtensionHeight( aHeight ); - updateGeometry(); + Update(); } /** @@ -557,7 +564,7 @@ public: void ChangeLeaderLength( int aLength ) { SetLeaderLength( aLength ); - updateGeometry(); + Update(); } // Returns the point (c). @@ -620,7 +627,7 @@ public: void ChangeTextBorder( DIM_TEXT_BORDER aBorder ) { SetTextBorder( aBorder ); - updateGeometry(); + Update(); } void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override;