Move automatic dimension processing inside PCB_DIMENSION_BASE.

Also move dimension precision to an enum so it can get a proper dropdown
in the properties inspector.
This commit is contained in:
Jeff Young 2023-03-05 13:27:22 +00:00
parent a3d834bef1
commit 461def2719
16 changed files with 113 additions and 106 deletions

View File

@ -281,7 +281,7 @@ void EDA_DRAW_FRAME::ToggleUserUnits()
else
{
SetUserUnits( GetUserUnits() == EDA_UNITS::INCHES ? EDA_UNITS::MILLIMETRES
: EDA_UNITS::INCHES );
: EDA_UNITS::INCHES );
unitsChangeRefresh();
wxCommandEvent e( UNITS_CHANGED );

View File

@ -212,6 +212,7 @@ enum class VIATYPE : int;
enum class DIM_UNITS_FORMAT : int;
enum class DIM_TEXT_POSITION : int;
enum class DIM_UNITS_MODE : int;
enum class DIM_PRECISION : int;
class PAD;
@ -704,7 +705,7 @@ public:
// Default values for dimension objects
DIM_UNITS_MODE m_DimensionUnitsMode;
int m_DimensionPrecision; ///< Number of digits after the decimal
DIM_PRECISION m_DimensionPrecision; ///< Number of digits after the decimal
DIM_UNITS_FORMAT m_DimensionUnitsFormat;
bool m_DimensionSuppressZeroes;
DIM_TEXT_POSITION m_DimensionTextPosition;

View File

@ -641,6 +641,9 @@ public:
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
EDA_UNITS GetUserUnits() { return m_userUnits; }
void SetUserUnits( EDA_UNITS aUnits ) { m_userUnits = aUnits; }
/**
* Extract the board outlines and build a closed polygon from lines, arcs and circle items
* on edge cut layer.
@ -1216,6 +1219,7 @@ private:
TITLE_BLOCK m_titles; // text in lower right of screen and plots
PCB_PLOT_PARAMS m_plotOptions;
PROJECT* m_project; // project this board is a part of
EDA_UNITS m_userUnits;
/**
* All of the board design settings are stored as a JSON object inside the project file. The

View File

@ -117,7 +117,7 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std:
m_TextItalic[ LAYER_CLASS_OTHERS ] = false;
m_TextUpright[ LAYER_CLASS_OTHERS ] = false;
m_DimensionPrecision = 4;
m_DimensionPrecision = DIM_PRECISION::X_XXXX;
m_DimensionUnitsMode = DIM_UNITS_MODE::AUTOMATIC;
m_DimensionUnitsFormat = DIM_UNITS_FORMAT::BARE_SUFFIX;
m_DimensionSuppressZeroes = false;
@ -678,8 +678,8 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std:
&m_DimensionUnitsMode, DIM_UNITS_MODE::AUTOMATIC, DIM_UNITS_MODE::INCHES,
DIM_UNITS_MODE::AUTOMATIC ) );
m_params.emplace_back( new PARAM<int>( "defaults.dimension_precision",
&m_DimensionPrecision, 4, 0, 5 ) );
m_params.emplace_back( new PARAM_ENUM<DIM_PRECISION>( "defaults.dimension_precision",
&m_DimensionPrecision, DIM_PRECISION::X_XXXX, DIM_PRECISION::X, DIM_PRECISION::V_VVVVV ) );
m_params.emplace_back( new PARAM_ENUM<DIM_UNITS_FORMAT>( "defaults.dimensions.units_format",
&m_DimensionUnitsFormat, DIM_UNITS_FORMAT::BARE_SUFFIX, DIM_UNITS_FORMAT::NO_SUFFIX,

View File

@ -383,26 +383,14 @@ void DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog( PCB_DIMENSION_BASE*
switch( m_cbUnits->GetSelection() )
{
case 0:
aTarget->SetUnitsMode( DIM_UNITS_MODE::INCHES );
break;
case 1:
aTarget->SetUnitsMode( DIM_UNITS_MODE::MILS );
break;
case 2:
aTarget->SetUnitsMode( DIM_UNITS_MODE::MILLIMETRES );
break;
case 3:
aTarget->SetUnitsMode( DIM_UNITS_MODE::AUTOMATIC );
aTarget->SetUnits( m_frame->GetUserUnits() );
break;
case 0: aTarget->SetUnitsMode( DIM_UNITS_MODE::INCHES ); break;
case 1: aTarget->SetUnitsMode( DIM_UNITS_MODE::MILS ); break;
case 2: aTarget->SetUnitsMode( DIM_UNITS_MODE::MILLIMETRES ); break;
case 3: aTarget->SetUnitsMode( DIM_UNITS_MODE::AUTOMATIC ); break;
}
aTarget->SetUnitsFormat( static_cast<DIM_UNITS_FORMAT>( m_cbUnitsFormat->GetSelection() ) );
aTarget->SetPrecision( m_cbPrecision->GetSelection() );
aTarget->SetPrecision( static_cast<DIM_PRECISION>( m_cbPrecision->GetSelection() ) );
aTarget->SetSuppressZeroes( m_cbSuppressZeroes->GetValue() );
DIM_TEXT_POSITION tpm = static_cast<DIM_TEXT_POSITION>( m_cbTextPositionMode->GetSelection() );

View File

@ -176,16 +176,9 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow()
Layout();
wxASSERT_MSG( m_BrdSettings->m_DimensionPrecision <= 4,
wxT( "Unhandled dimension precision!" ) );
int mode = static_cast<int>( m_BrdSettings->m_DimensionUnitsMode );
m_dimensionUnits->SetSelection( mode );
int format = static_cast<int>( m_BrdSettings->m_DimensionUnitsFormat );
m_dimensionUnitsFormat->SetSelection( format );
m_dimensionPrecision->SetSelection( m_BrdSettings->m_DimensionPrecision );
m_dimensionUnits->SetSelection( static_cast<int>( m_BrdSettings->m_DimensionUnitsMode ) );
m_dimensionUnitsFormat->SetSelection( static_cast<int>( m_BrdSettings->m_DimensionUnitsFormat ) );
m_dimensionPrecision->SetSelection( static_cast<int>( m_BrdSettings->m_DimensionPrecision ) );
m_dimensionSuppressZeroes->SetValue( m_BrdSettings->m_DimensionSuppressZeroes );
int position = static_cast<int>( m_BrdSettings->m_DimensionTextPosition );
@ -226,7 +219,8 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow()
m_BrdSettings->m_DimensionUnitsMode = static_cast<DIM_UNITS_MODE>( mode );
int format = m_dimensionUnitsFormat->GetSelection();
m_BrdSettings->m_DimensionUnitsFormat = static_cast<DIM_UNITS_FORMAT>( format );
m_BrdSettings->m_DimensionPrecision = m_dimensionPrecision->GetSelection();
int precision = m_dimensionPrecision->GetSelection();
m_BrdSettings->m_DimensionPrecision = static_cast<DIM_PRECISION>( precision );
m_BrdSettings->m_DimensionSuppressZeroes = m_dimensionSuppressZeroes->GetValue();
int position = m_dimensionTextPositionMode->GetSelection();
m_BrdSettings->m_DimensionTextPosition = static_cast<DIM_TEXT_POSITION>( position );

View File

@ -54,6 +54,7 @@ FOOTPRINT_PREVIEW_PANEL::FOOTPRINT_PREVIEW_PANEL( KIWAY* aKiway, wxWindow* aPare
EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas
m_dummyBoard = std::make_unique<BOARD>();
m_dummyBoard->SetUserUnits( m_userUnits );
UpdateColors();
SyncLayersVisibility( m_dummyBoard.get() );
@ -111,14 +112,7 @@ void FOOTPRINT_PREVIEW_PANEL::renderFootprint( std::shared_ptr<FOOTPRINT> aFootp
INSPECTOR_FUNC inspector =
[&]( EDA_ITEM* descendant, void* aTestData )
{
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( descendant );
if( dimension->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC )
{
dimension->SetUnits( m_userUnits );
dimension->Update();
}
static_cast<PCB_DIMENSION_BASE*>( descendant )->UpdateUnits();
return INSPECT_RESULT::CONTINUE;
};

View File

@ -212,6 +212,9 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
delete m_pcb;
m_pcb = aBoard;
if( GetBoard() )
GetBoard()->SetUserUnits( GetUserUnits() );
if( GetBoard() && GetCanvas() )
{
RENDER_SETTINGS* rs = GetCanvas()->GetView()->GetPainter()->GetSettings();
@ -254,8 +257,7 @@ void PCB_BASE_FRAME::AddFootprintToBoard( FOOTPRINT* aFootprint )
void PCB_BASE_FRAME::UpdateUserUnits( BOARD_ITEM* aItem, bool* aSelectedItemsModified )
{
EDA_UNITS units = GetUserUnits();
KIGFX::VIEW* view = GetCanvas()->GetView();
KIGFX::VIEW* view = GetCanvas()->GetView();
INSPECTOR_FUNC inspector =
[&]( EDA_ITEM* descendant, void* aTestData )
@ -264,8 +266,7 @@ void PCB_BASE_FRAME::UpdateUserUnits( BOARD_ITEM* aItem, bool* aSelectedItemsMod
if( dimension->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC )
{
dimension->SetUnits( units );
dimension->Update();
dimension->UpdateUnits();
if( aSelectedItemsModified && dimension->IsSelected() )
*aSelectedItemsModified = true;
@ -892,6 +893,9 @@ void PCB_BASE_FRAME::unitsChangeRefresh()
{
EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
if( GetBoard() )
GetBoard()->SetUserUnits( GetUserUnits() );
UpdateGridSelectBox();
}

View File

@ -47,7 +47,7 @@ PCB_DIMENSION_BASE::PCB_DIMENSION_BASE( BOARD_ITEM* aParent, KICAD_T aType ) :
m_units( EDA_UNITS::INCHES ),
m_autoUnits( false ),
m_unitsFormat( DIM_UNITS_FORMAT::BARE_SUFFIX ),
m_precision( 4 ),
m_precision( DIM_PRECISION::X_XXXX ),
m_suppressZeroes( false ),
m_lineThickness( pcbIUScale.mmToIU( 0.2 ) ),
m_arrowLength( pcbIUScale.MilsToIU( 50 ) ),
@ -115,7 +115,7 @@ wxString PCB_DIMENSION_BASE::GetValueText() const
wxChar sep = lc->decimal_point[0];
int val = GetMeasuredValue();
int precision = m_precision;
int precision = static_cast<int>( m_precision );
wxString text;
if( precision >= 6 )
@ -190,14 +190,27 @@ DIM_UNITS_MODE PCB_DIMENSION_BASE::GetUnitsMode() const
void PCB_DIMENSION_BASE::SetUnitsMode( DIM_UNITS_MODE aMode )
{
m_autoUnits = false;
switch( aMode )
{
case DIM_UNITS_MODE::INCHES: m_units = EDA_UNITS::INCHES; break;
case DIM_UNITS_MODE::MILS: m_units = EDA_UNITS::MILS; break;
case DIM_UNITS_MODE::MILLIMETRES: m_units = EDA_UNITS::MILLIMETRES; break;
case DIM_UNITS_MODE::AUTOMATIC: m_autoUnits = true; break;
case DIM_UNITS_MODE::INCHES:
m_autoUnits = false;
m_units = EDA_UNITS::INCHES;
break;
case DIM_UNITS_MODE::MILS:
m_autoUnits = false;
m_units = EDA_UNITS::MILS;
break;
case DIM_UNITS_MODE::MILLIMETRES:
m_autoUnits = false;
m_units = EDA_UNITS::MILLIMETRES;
break;
case DIM_UNITS_MODE::AUTOMATIC:
m_autoUnits = true;
m_units = GetBoard()->GetUserUnits();
break;
}
}
@ -296,11 +309,11 @@ void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
switch( GetPrecision() )
{
case 6: msg = wxT( "0.00 in / 0 mils / 0.0 mm" ); break;
case 7: msg = wxT( "0.000 in / 0 mils / 0.00 mm" ); break;
case 8: msg = wxT( "0.0000 in / 0.0 mils / 0.000 mm" ); break;
case 9: msg = wxT( "0.00000 in / 0.00 mils / 0.0000 mm" ); break;
default: msg = wxT( "%" ) + wxString::Format( wxT( "1.%df" ), GetPrecision() );
case DIM_PRECISION::V_VV: msg = wxT( "0.00 in / 0 mils / 0.0 mm" ); break;
case DIM_PRECISION::V_VVV: msg = wxT( "0.000 in / 0 mils / 0.00 mm" ); break;
case DIM_PRECISION::V_VVVV: msg = wxT( "0.0000 in / 0.0 mils / 0.000 mm" ); break;
case DIM_PRECISION::V_VVVVV: msg = wxT( "0.00000 in / 0.00 mils / 0.0000 mm" ); break;
default: msg = wxT( "%" ) + wxString::Format( wxT( "1.%df" ), GetPrecision() );
}
aList.emplace_back( _( "Precision" ), wxString::Format( msg, 0.0 ) );
@ -972,11 +985,18 @@ BITMAPS PCB_DIM_LEADER::GetMenuImage() const
}
void PCB_DIM_LEADER::updateText()
{
// Our geometry is dependent on the size of the text, so just update the whole shebang
updateGeometry();
}
void PCB_DIM_LEADER::updateGeometry()
{
m_shapes.clear();
updateText();
PCB_DIMENSION_BASE::updateText();
// Now that we have the text updated, we can determine how to draw the second line
// First we need to create an appropriate bounding polygon to collide with
@ -1060,23 +1080,6 @@ void PCB_DIM_LEADER::updateGeometry()
}
void PCB_DIM_LEADER::ClearRenderCache()
{
PCB_DIMENSION_BASE::ClearRenderCache();
// We use EDA_TEXT::ClearRenderCache() as a signal that the properties of the EDA_TEXT
// have changed and we may need to update the dimension text
if( !m_inClearRenderCache )
{
m_inClearRenderCache = true;
updateText();
updateGeometry();
m_inClearRenderCache = false;
}
}
void PCB_DIM_LEADER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{
aList.emplace_back( _( "Leader" ), GetShownText() );
@ -1296,6 +1299,18 @@ static struct DIMENSION_DESC
{
DIMENSION_DESC()
{
ENUM_MAP<DIM_PRECISION>::Instance()
.Map( DIM_PRECISION::X, _HKI( "0" ) )
.Map( DIM_PRECISION::X_X, _HKI( "0.0" ) )
.Map( DIM_PRECISION::X_XX, _HKI( "0.00" ) )
.Map( DIM_PRECISION::X_XXX, _HKI( "0.000" ) )
.Map( DIM_PRECISION::X_XXXX, _HKI( "0.0000" ) )
.Map( DIM_PRECISION::X_XXXXX, _HKI( "0.00000" ) )
.Map( DIM_PRECISION::V_VV, _HKI( "0.00 in / 0 mils / 0.0 mm" ) )
.Map( DIM_PRECISION::V_VVV, _HKI( "0.000 / 0 / 0.00" ) )
.Map( DIM_PRECISION::V_VVVV, _HKI( "0.0000 / 0.0 / 0.000" ) )
.Map( DIM_PRECISION::V_VVVVV, _HKI( "0.00000 / 0.00 / 0.0000" ) );
ENUM_MAP<DIM_UNITS_FORMAT>::Instance()
.Map( DIM_UNITS_FORMAT::NO_SUFFIX, _HKI( "1234.0" ) )
.Map( DIM_UNITS_FORMAT::BARE_SUFFIX, _HKI( "1234.0 mm" ) )
@ -1334,7 +1349,7 @@ static struct DIMENSION_DESC
propMgr.AddProperty( new PROPERTY_ENUM<PCB_DIMENSION_BASE, DIM_UNITS_FORMAT>( _HKI( "Units Format" ),
&PCB_DIMENSION_BASE::ChangeUnitsFormat, &PCB_DIMENSION_BASE::GetUnitsFormat ),
groupDimension );
propMgr.AddProperty( new PROPERTY<PCB_DIMENSION_BASE, int>( _HKI( "Precision" ),
propMgr.AddProperty( new PROPERTY_ENUM<PCB_DIMENSION_BASE, DIM_PRECISION>( _HKI( "Precision" ),
&PCB_DIMENSION_BASE::ChangePrecision, &PCB_DIMENSION_BASE::GetPrecision ),
groupDimension );
propMgr.AddProperty( new PROPERTY<PCB_DIMENSION_BASE, bool>( _HKI( "Suppress Trailing Zeroes" ),
@ -1343,6 +1358,7 @@ static struct DIMENSION_DESC
}
} _DIMENSION_DESC;
ENUM_TO_WXANY( DIM_PRECISION )
ENUM_TO_WXANY( DIM_UNITS_FORMAT )
ENUM_TO_WXANY( DIM_UNITS_MODE )

View File

@ -43,6 +43,20 @@ enum class DIM_UNITS_FORMAT
PAREN_SUFFIX // 1234.0 (mm)
};
enum class DIM_PRECISION
{
X = 0, // 0
X_X, // 0.0
X_XX, // 0.00
X_XXX, // 0.000
X_XXXX, // 0.0000
X_XXXXX, // 0.00000
V_VV, // 0.00 / 0 / 0.0
V_VVV, // 0.000 / 0 / 0.00
V_VVVV, // 0.0000 / 0.0 / 0.000
V_VVVVV // 0.00000 / 0.00 / 0.0000
};
/// Where to place the text on a dimension
enum class DIM_TEXT_POSITION
{
@ -157,6 +171,12 @@ public:
updateText();
}
void UpdateUnits()
{
SetUnitsMode( GetUnitsMode() );
updateText();
}
wxString GetPrefix() const { return m_prefix; }
void SetPrefix( const wxString& aPrefix );
@ -198,10 +218,10 @@ public:
updateText();
}
int GetPrecision() const { return m_precision; }
void SetPrecision( int aPrecision ) { m_precision = aPrecision; }
DIM_PRECISION GetPrecision() const { return m_precision; }
void SetPrecision( DIM_PRECISION aPrecision ) { m_precision = aPrecision; }
void ChangePrecision( int aPrecision )
void ChangePrecision( DIM_PRECISION aPrecision )
{
SetPrecision( aPrecision );
updateText();
@ -311,7 +331,7 @@ protected:
EDA_UNITS m_units; ///< 0 = inches, 1 = mm
bool m_autoUnits; ///< If true, follow the currently selected UI units
DIM_UNITS_FORMAT m_unitsFormat; ///< How to render the units suffix
int m_precision; ///< Number of digits to display after decimal
DIM_PRECISION m_precision; ///< Number of digits to display after decimal
bool m_suppressZeroes; ///< Suppress trailing zeroes
// Geometry
@ -613,13 +633,12 @@ public:
updateGeometry();
}
void ClearRenderCache() override;
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
protected:
virtual void swapData( BOARD_ITEM* aImage ) override;
void updateText() override;
void updateGeometry() override;
private:

View File

@ -1269,7 +1269,7 @@ void ALTIUM_PCB::HelperParseDimensions6Linear( const ADIMENSION6& aElem )
PCB_DIM_ALIGNED* dimension = new PCB_DIM_ALIGNED( m_board, PCB_DIM_ALIGNED_T );
m_board->Add( dimension, ADD_MODE::APPEND );
dimension->SetPrecision( aElem.textprecision );
dimension->SetPrecision( static_cast<DIM_PRECISION>( aElem.textprecision ) );
dimension->SetLayer( klayer );
dimension->SetStart( referencePoint0 );
@ -1366,7 +1366,7 @@ void ALTIUM_PCB::HelperParseDimensions6Radial(const ADIMENSION6 &aElem)
m_board->Add( dimension, ADD_MODE::APPEND );
m_radialDimensions.push_back( dimension );
dimension->SetPrecision( aElem.textprecision );
dimension->SetPrecision( static_cast<DIM_PRECISION>( aElem.textprecision ) );
dimension->SetLayer( klayer );
dimension->SetStart( referencePoint0 );
dimension->SetEnd( aElem.xy1 );

View File

@ -3629,7 +3629,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::applyDimensionSettings( const DIMENSION& aCads
LINECODE linecode = Assignments.Codedefs.LineCodes.at( aCadstarDim.Line.LineCodeID );
aKiCadDim->SetLayer( getKiCadLayer( aCadstarDim.LayerID ) );
aKiCadDim->SetPrecision( aCadstarDim.Precision );
aKiCadDim->SetPrecision( static_cast<DIM_PRECISION>( aCadstarDim.Precision ) );
aKiCadDim->SetStart( getKiCadPoint( aCadstarDim.ExtensionLineParams.Start ) );
aKiCadDim->SetEnd( getKiCadPoint( aCadstarDim.ExtensionLineParams.End ) );
aKiCadDim->SetExtensionOffset( getKiCadLength( aCadstarDim.ExtensionLineParams.Offset ) );
@ -3667,7 +3667,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::applyDimensionSettings( const DIMENSION& aCads
{
// For now we will hardcode the units as per the original CADSTAR design.
// TODO: update this when KiCad supports design units
aKiCadDim->SetPrecision( Assignments.Technology.UnitDisplPrecision );
aKiCadDim->SetPrecision( static_cast<DIM_PRECISION>( Assignments.Technology.UnitDisplPrecision ) );
dimensionUnits = Assignments.Technology.Units;
}

View File

@ -610,7 +610,7 @@ void EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers )
}
#define DIMENSION_PRECISION 2 // 0.01 mm
#define DIMENSION_PRECISION DIM_PRECISION::X_XX // 0.01 mm
void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )

View File

@ -2279,7 +2279,8 @@ void PCB_PARSER::parseDefaults( BOARD_DESIGN_SETTINGS& designSettings )
break;
case T_dimension_precision:
designSettings.m_DimensionPrecision = parseInt( "dimension precision" );
designSettings.m_DimensionPrecision =
static_cast<DIM_PRECISION>( parseInt( "dimension precision" ) );
NeedRIGHT();
break;
@ -3334,7 +3335,7 @@ PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION( BOARD_ITEM* aParent, bool aInFP
}
case T_precision:
dim->SetPrecision( parseInt( "dim precision" ) );
dim->SetPrecision( static_cast<DIM_PRECISION>( parseInt( "dim precision" ) ) );
NeedRIGHT();
break;

View File

@ -1218,9 +1218,6 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
aDim->SetSuppressZeroes( boardSettings.m_DimensionSuppressZeroes );
aDim->SetTextPositionMode( boardSettings.m_DimensionTextPosition );
aDim->SetKeepTextAligned( boardSettings.m_DimensionKeepTextAligned );
if( boardSettings.m_DimensionUnitsMode == DIM_UNITS_MODE::AUTOMATIC )
aDim->SetUnits( m_frame->GetUserUnits() );
};
if( originalEvent.IsAction( &PCB_ACTIONS::drawAlignedDimension ) )

View File

@ -1117,17 +1117,6 @@ int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
std::vector<BOARD_ITEM*> itemsToSel;
itemsToSel.reserve( aItems.size() );
auto updateDimensionUnits =
[this]( PCB_DIMENSION_BASE* dimension )
{
// Dimensions need to have their units updated if they are automatic
if( dimension->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC )
{
dimension->SetUnits( frame()->GetUserUnits() );
dimension->Update();
}
};
for( BOARD_ITEM* item : aItems )
{
if( aIsNew )
@ -1144,7 +1133,7 @@ int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
// Update item attributes if needed
if( BaseType( item->Type() ) == PCB_DIMENSION_T )
{
updateDimensionUnits( static_cast<PCB_DIMENSION_BASE*>( item ) );
static_cast<PCB_DIMENSION_BASE*>( item )->UpdateUnits();
}
else if( item->Type() == PCB_FOOTPRINT_T )
{
@ -1157,7 +1146,7 @@ int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
for( BOARD_ITEM* dwg : footprint->GraphicalItems() )
{
if( BaseType( dwg->Type() ) == PCB_DIMENSION_T )
updateDimensionUnits( static_cast<PCB_DIMENSION_BASE*>( dwg ) );
static_cast<PCB_DIMENSION_BASE*>( dwg )->UpdateUnits();
}
}