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:
parent
a3d834bef1
commit
461def2719
|
@ -281,7 +281,7 @@ void EDA_DRAW_FRAME::ToggleUserUnits()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetUserUnits( GetUserUnits() == EDA_UNITS::INCHES ? EDA_UNITS::MILLIMETRES
|
SetUserUnits( GetUserUnits() == EDA_UNITS::INCHES ? EDA_UNITS::MILLIMETRES
|
||||||
: EDA_UNITS::INCHES );
|
: EDA_UNITS::INCHES );
|
||||||
unitsChangeRefresh();
|
unitsChangeRefresh();
|
||||||
|
|
||||||
wxCommandEvent e( UNITS_CHANGED );
|
wxCommandEvent e( UNITS_CHANGED );
|
||||||
|
|
|
@ -212,6 +212,7 @@ enum class VIATYPE : int;
|
||||||
enum class DIM_UNITS_FORMAT : int;
|
enum class DIM_UNITS_FORMAT : int;
|
||||||
enum class DIM_TEXT_POSITION : int;
|
enum class DIM_TEXT_POSITION : int;
|
||||||
enum class DIM_UNITS_MODE : int;
|
enum class DIM_UNITS_MODE : int;
|
||||||
|
enum class DIM_PRECISION : int;
|
||||||
|
|
||||||
class PAD;
|
class PAD;
|
||||||
|
|
||||||
|
@ -704,7 +705,7 @@ public:
|
||||||
|
|
||||||
// Default values for dimension objects
|
// Default values for dimension objects
|
||||||
DIM_UNITS_MODE m_DimensionUnitsMode;
|
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;
|
DIM_UNITS_FORMAT m_DimensionUnitsFormat;
|
||||||
bool m_DimensionSuppressZeroes;
|
bool m_DimensionSuppressZeroes;
|
||||||
DIM_TEXT_POSITION m_DimensionTextPosition;
|
DIM_TEXT_POSITION m_DimensionTextPosition;
|
||||||
|
|
|
@ -641,6 +641,9 @@ public:
|
||||||
|
|
||||||
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
|
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
|
* Extract the board outlines and build a closed polygon from lines, arcs and circle items
|
||||||
* on edge cut layer.
|
* on edge cut layer.
|
||||||
|
@ -1216,6 +1219,7 @@ private:
|
||||||
TITLE_BLOCK m_titles; // text in lower right of screen and plots
|
TITLE_BLOCK m_titles; // text in lower right of screen and plots
|
||||||
PCB_PLOT_PARAMS m_plotOptions;
|
PCB_PLOT_PARAMS m_plotOptions;
|
||||||
PROJECT* m_project; // project this board is a part of
|
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
|
* All of the board design settings are stored as a JSON object inside the project file. The
|
||||||
|
|
|
@ -117,7 +117,7 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std:
|
||||||
m_TextItalic[ LAYER_CLASS_OTHERS ] = false;
|
m_TextItalic[ LAYER_CLASS_OTHERS ] = false;
|
||||||
m_TextUpright[ 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_DimensionUnitsMode = DIM_UNITS_MODE::AUTOMATIC;
|
||||||
m_DimensionUnitsFormat = DIM_UNITS_FORMAT::BARE_SUFFIX;
|
m_DimensionUnitsFormat = DIM_UNITS_FORMAT::BARE_SUFFIX;
|
||||||
m_DimensionSuppressZeroes = false;
|
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,
|
&m_DimensionUnitsMode, DIM_UNITS_MODE::AUTOMATIC, DIM_UNITS_MODE::INCHES,
|
||||||
DIM_UNITS_MODE::AUTOMATIC ) );
|
DIM_UNITS_MODE::AUTOMATIC ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<int>( "defaults.dimension_precision",
|
m_params.emplace_back( new PARAM_ENUM<DIM_PRECISION>( "defaults.dimension_precision",
|
||||||
&m_DimensionPrecision, 4, 0, 5 ) );
|
&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_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,
|
&m_DimensionUnitsFormat, DIM_UNITS_FORMAT::BARE_SUFFIX, DIM_UNITS_FORMAT::NO_SUFFIX,
|
||||||
|
|
|
@ -383,26 +383,14 @@ void DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog( PCB_DIMENSION_BASE*
|
||||||
|
|
||||||
switch( m_cbUnits->GetSelection() )
|
switch( m_cbUnits->GetSelection() )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0: aTarget->SetUnitsMode( DIM_UNITS_MODE::INCHES ); break;
|
||||||
aTarget->SetUnitsMode( DIM_UNITS_MODE::INCHES );
|
case 1: aTarget->SetUnitsMode( DIM_UNITS_MODE::MILS ); break;
|
||||||
break;
|
case 2: aTarget->SetUnitsMode( DIM_UNITS_MODE::MILLIMETRES ); break;
|
||||||
|
case 3: aTarget->SetUnitsMode( DIM_UNITS_MODE::AUTOMATIC ); 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aTarget->SetUnitsFormat( static_cast<DIM_UNITS_FORMAT>( m_cbUnitsFormat->GetSelection() ) );
|
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() );
|
aTarget->SetSuppressZeroes( m_cbSuppressZeroes->GetValue() );
|
||||||
|
|
||||||
DIM_TEXT_POSITION tpm = static_cast<DIM_TEXT_POSITION>( m_cbTextPositionMode->GetSelection() );
|
DIM_TEXT_POSITION tpm = static_cast<DIM_TEXT_POSITION>( m_cbTextPositionMode->GetSelection() );
|
||||||
|
|
|
@ -176,16 +176,9 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow()
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
|
|
||||||
wxASSERT_MSG( m_BrdSettings->m_DimensionPrecision <= 4,
|
m_dimensionUnits->SetSelection( static_cast<int>( m_BrdSettings->m_DimensionUnitsMode ) );
|
||||||
wxT( "Unhandled dimension precision!" ) );
|
m_dimensionUnitsFormat->SetSelection( static_cast<int>( m_BrdSettings->m_DimensionUnitsFormat ) );
|
||||||
|
m_dimensionPrecision->SetSelection( static_cast<int>( m_BrdSettings->m_DimensionPrecision ) );
|
||||||
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_dimensionSuppressZeroes->SetValue( m_BrdSettings->m_DimensionSuppressZeroes );
|
m_dimensionSuppressZeroes->SetValue( m_BrdSettings->m_DimensionSuppressZeroes );
|
||||||
|
|
||||||
int position = static_cast<int>( m_BrdSettings->m_DimensionTextPosition );
|
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 );
|
m_BrdSettings->m_DimensionUnitsMode = static_cast<DIM_UNITS_MODE>( mode );
|
||||||
int format = m_dimensionUnitsFormat->GetSelection();
|
int format = m_dimensionUnitsFormat->GetSelection();
|
||||||
m_BrdSettings->m_DimensionUnitsFormat = static_cast<DIM_UNITS_FORMAT>( format );
|
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();
|
m_BrdSettings->m_DimensionSuppressZeroes = m_dimensionSuppressZeroes->GetValue();
|
||||||
int position = m_dimensionTextPositionMode->GetSelection();
|
int position = m_dimensionTextPositionMode->GetSelection();
|
||||||
m_BrdSettings->m_DimensionTextPosition = static_cast<DIM_TEXT_POSITION>( position );
|
m_BrdSettings->m_DimensionTextPosition = static_cast<DIM_TEXT_POSITION>( position );
|
||||||
|
|
|
@ -54,6 +54,7 @@ FOOTPRINT_PREVIEW_PANEL::FOOTPRINT_PREVIEW_PANEL( KIWAY* aKiway, wxWindow* aPare
|
||||||
EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas
|
EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas
|
||||||
|
|
||||||
m_dummyBoard = std::make_unique<BOARD>();
|
m_dummyBoard = std::make_unique<BOARD>();
|
||||||
|
m_dummyBoard->SetUserUnits( m_userUnits );
|
||||||
UpdateColors();
|
UpdateColors();
|
||||||
SyncLayersVisibility( m_dummyBoard.get() );
|
SyncLayersVisibility( m_dummyBoard.get() );
|
||||||
|
|
||||||
|
@ -111,14 +112,7 @@ void FOOTPRINT_PREVIEW_PANEL::renderFootprint( std::shared_ptr<FOOTPRINT> aFootp
|
||||||
INSPECTOR_FUNC inspector =
|
INSPECTOR_FUNC inspector =
|
||||||
[&]( EDA_ITEM* descendant, void* aTestData )
|
[&]( EDA_ITEM* descendant, void* aTestData )
|
||||||
{
|
{
|
||||||
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( descendant );
|
static_cast<PCB_DIMENSION_BASE*>( descendant )->UpdateUnits();
|
||||||
|
|
||||||
if( dimension->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC )
|
|
||||||
{
|
|
||||||
dimension->SetUnits( m_userUnits );
|
|
||||||
dimension->Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
return INSPECT_RESULT::CONTINUE;
|
return INSPECT_RESULT::CONTINUE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -212,6 +212,9 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
|
||||||
delete m_pcb;
|
delete m_pcb;
|
||||||
m_pcb = aBoard;
|
m_pcb = aBoard;
|
||||||
|
|
||||||
|
if( GetBoard() )
|
||||||
|
GetBoard()->SetUserUnits( GetUserUnits() );
|
||||||
|
|
||||||
if( GetBoard() && GetCanvas() )
|
if( GetBoard() && GetCanvas() )
|
||||||
{
|
{
|
||||||
RENDER_SETTINGS* rs = GetCanvas()->GetView()->GetPainter()->GetSettings();
|
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 )
|
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 =
|
INSPECTOR_FUNC inspector =
|
||||||
[&]( EDA_ITEM* descendant, void* aTestData )
|
[&]( 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 )
|
if( dimension->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC )
|
||||||
{
|
{
|
||||||
dimension->SetUnits( units );
|
dimension->UpdateUnits();
|
||||||
dimension->Update();
|
|
||||||
|
|
||||||
if( aSelectedItemsModified && dimension->IsSelected() )
|
if( aSelectedItemsModified && dimension->IsSelected() )
|
||||||
*aSelectedItemsModified = true;
|
*aSelectedItemsModified = true;
|
||||||
|
@ -892,6 +893,9 @@ void PCB_BASE_FRAME::unitsChangeRefresh()
|
||||||
{
|
{
|
||||||
EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
|
EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
|
||||||
|
|
||||||
|
if( GetBoard() )
|
||||||
|
GetBoard()->SetUserUnits( GetUserUnits() );
|
||||||
|
|
||||||
UpdateGridSelectBox();
|
UpdateGridSelectBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ PCB_DIMENSION_BASE::PCB_DIMENSION_BASE( BOARD_ITEM* aParent, KICAD_T aType ) :
|
||||||
m_units( EDA_UNITS::INCHES ),
|
m_units( EDA_UNITS::INCHES ),
|
||||||
m_autoUnits( false ),
|
m_autoUnits( false ),
|
||||||
m_unitsFormat( DIM_UNITS_FORMAT::BARE_SUFFIX ),
|
m_unitsFormat( DIM_UNITS_FORMAT::BARE_SUFFIX ),
|
||||||
m_precision( 4 ),
|
m_precision( DIM_PRECISION::X_XXXX ),
|
||||||
m_suppressZeroes( false ),
|
m_suppressZeroes( false ),
|
||||||
m_lineThickness( pcbIUScale.mmToIU( 0.2 ) ),
|
m_lineThickness( pcbIUScale.mmToIU( 0.2 ) ),
|
||||||
m_arrowLength( pcbIUScale.MilsToIU( 50 ) ),
|
m_arrowLength( pcbIUScale.MilsToIU( 50 ) ),
|
||||||
|
@ -115,7 +115,7 @@ wxString PCB_DIMENSION_BASE::GetValueText() const
|
||||||
wxChar sep = lc->decimal_point[0];
|
wxChar sep = lc->decimal_point[0];
|
||||||
|
|
||||||
int val = GetMeasuredValue();
|
int val = GetMeasuredValue();
|
||||||
int precision = m_precision;
|
int precision = static_cast<int>( m_precision );
|
||||||
wxString text;
|
wxString text;
|
||||||
|
|
||||||
if( precision >= 6 )
|
if( precision >= 6 )
|
||||||
|
@ -190,14 +190,27 @@ DIM_UNITS_MODE PCB_DIMENSION_BASE::GetUnitsMode() const
|
||||||
|
|
||||||
void PCB_DIMENSION_BASE::SetUnitsMode( DIM_UNITS_MODE aMode )
|
void PCB_DIMENSION_BASE::SetUnitsMode( DIM_UNITS_MODE aMode )
|
||||||
{
|
{
|
||||||
m_autoUnits = false;
|
|
||||||
|
|
||||||
switch( aMode )
|
switch( aMode )
|
||||||
{
|
{
|
||||||
case DIM_UNITS_MODE::INCHES: m_units = EDA_UNITS::INCHES; break;
|
case DIM_UNITS_MODE::INCHES:
|
||||||
case DIM_UNITS_MODE::MILS: m_units = EDA_UNITS::MILS; break;
|
m_autoUnits = false;
|
||||||
case DIM_UNITS_MODE::MILLIMETRES: m_units = EDA_UNITS::MILLIMETRES; break;
|
m_units = EDA_UNITS::INCHES;
|
||||||
case DIM_UNITS_MODE::AUTOMATIC: m_autoUnits = true; break;
|
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() )
|
switch( GetPrecision() )
|
||||||
{
|
{
|
||||||
case 6: msg = wxT( "0.00 in / 0 mils / 0.0 mm" ); break;
|
case DIM_PRECISION::V_VV: 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 DIM_PRECISION::V_VVV: 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 DIM_PRECISION::V_VVVV: 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;
|
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() );
|
default: msg = wxT( "%" ) + wxString::Format( wxT( "1.%df" ), GetPrecision() );
|
||||||
}
|
}
|
||||||
|
|
||||||
aList.emplace_back( _( "Precision" ), wxString::Format( msg, 0.0 ) );
|
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()
|
void PCB_DIM_LEADER::updateGeometry()
|
||||||
{
|
{
|
||||||
m_shapes.clear();
|
m_shapes.clear();
|
||||||
|
|
||||||
updateText();
|
PCB_DIMENSION_BASE::updateText();
|
||||||
|
|
||||||
// Now that we have the text updated, we can determine how to draw the second line
|
// 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
|
// 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 )
|
void PCB_DIM_LEADER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
||||||
{
|
{
|
||||||
aList.emplace_back( _( "Leader" ), GetShownText() );
|
aList.emplace_back( _( "Leader" ), GetShownText() );
|
||||||
|
@ -1296,6 +1299,18 @@ static struct DIMENSION_DESC
|
||||||
{
|
{
|
||||||
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()
|
ENUM_MAP<DIM_UNITS_FORMAT>::Instance()
|
||||||
.Map( DIM_UNITS_FORMAT::NO_SUFFIX, _HKI( "1234.0" ) )
|
.Map( DIM_UNITS_FORMAT::NO_SUFFIX, _HKI( "1234.0" ) )
|
||||||
.Map( DIM_UNITS_FORMAT::BARE_SUFFIX, _HKI( "1234.0 mm" ) )
|
.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" ),
|
propMgr.AddProperty( new PROPERTY_ENUM<PCB_DIMENSION_BASE, DIM_UNITS_FORMAT>( _HKI( "Units Format" ),
|
||||||
&PCB_DIMENSION_BASE::ChangeUnitsFormat, &PCB_DIMENSION_BASE::GetUnitsFormat ),
|
&PCB_DIMENSION_BASE::ChangeUnitsFormat, &PCB_DIMENSION_BASE::GetUnitsFormat ),
|
||||||
groupDimension );
|
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 ),
|
&PCB_DIMENSION_BASE::ChangePrecision, &PCB_DIMENSION_BASE::GetPrecision ),
|
||||||
groupDimension );
|
groupDimension );
|
||||||
propMgr.AddProperty( new PROPERTY<PCB_DIMENSION_BASE, bool>( _HKI( "Suppress Trailing Zeroes" ),
|
propMgr.AddProperty( new PROPERTY<PCB_DIMENSION_BASE, bool>( _HKI( "Suppress Trailing Zeroes" ),
|
||||||
|
@ -1343,6 +1358,7 @@ static struct DIMENSION_DESC
|
||||||
}
|
}
|
||||||
} _DIMENSION_DESC;
|
} _DIMENSION_DESC;
|
||||||
|
|
||||||
|
ENUM_TO_WXANY( DIM_PRECISION )
|
||||||
ENUM_TO_WXANY( DIM_UNITS_FORMAT )
|
ENUM_TO_WXANY( DIM_UNITS_FORMAT )
|
||||||
ENUM_TO_WXANY( DIM_UNITS_MODE )
|
ENUM_TO_WXANY( DIM_UNITS_MODE )
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,20 @@ enum class DIM_UNITS_FORMAT
|
||||||
PAREN_SUFFIX // 1234.0 (mm)
|
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
|
/// Where to place the text on a dimension
|
||||||
enum class DIM_TEXT_POSITION
|
enum class DIM_TEXT_POSITION
|
||||||
{
|
{
|
||||||
|
@ -157,6 +171,12 @@ public:
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateUnits()
|
||||||
|
{
|
||||||
|
SetUnitsMode( GetUnitsMode() );
|
||||||
|
updateText();
|
||||||
|
}
|
||||||
|
|
||||||
wxString GetPrefix() const { return m_prefix; }
|
wxString GetPrefix() const { return m_prefix; }
|
||||||
void SetPrefix( const wxString& aPrefix );
|
void SetPrefix( const wxString& aPrefix );
|
||||||
|
|
||||||
|
@ -198,10 +218,10 @@ public:
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetPrecision() const { return m_precision; }
|
DIM_PRECISION GetPrecision() const { return m_precision; }
|
||||||
void SetPrecision( int aPrecision ) { m_precision = aPrecision; }
|
void SetPrecision( DIM_PRECISION aPrecision ) { m_precision = aPrecision; }
|
||||||
|
|
||||||
void ChangePrecision( int aPrecision )
|
void ChangePrecision( DIM_PRECISION aPrecision )
|
||||||
{
|
{
|
||||||
SetPrecision( aPrecision );
|
SetPrecision( aPrecision );
|
||||||
updateText();
|
updateText();
|
||||||
|
@ -311,7 +331,7 @@ protected:
|
||||||
EDA_UNITS m_units; ///< 0 = inches, 1 = mm
|
EDA_UNITS m_units; ///< 0 = inches, 1 = mm
|
||||||
bool m_autoUnits; ///< If true, follow the currently selected UI units
|
bool m_autoUnits; ///< If true, follow the currently selected UI units
|
||||||
DIM_UNITS_FORMAT m_unitsFormat; ///< How to render the units suffix
|
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
|
bool m_suppressZeroes; ///< Suppress trailing zeroes
|
||||||
|
|
||||||
// Geometry
|
// Geometry
|
||||||
|
@ -613,13 +633,12 @@ public:
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearRenderCache() override;
|
|
||||||
|
|
||||||
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void swapData( BOARD_ITEM* aImage ) override;
|
virtual void swapData( BOARD_ITEM* aImage ) override;
|
||||||
|
|
||||||
|
void updateText() override;
|
||||||
void updateGeometry() override;
|
void updateGeometry() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -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 );
|
PCB_DIM_ALIGNED* dimension = new PCB_DIM_ALIGNED( m_board, PCB_DIM_ALIGNED_T );
|
||||||
m_board->Add( dimension, ADD_MODE::APPEND );
|
m_board->Add( dimension, ADD_MODE::APPEND );
|
||||||
|
|
||||||
dimension->SetPrecision( aElem.textprecision );
|
dimension->SetPrecision( static_cast<DIM_PRECISION>( aElem.textprecision ) );
|
||||||
dimension->SetLayer( klayer );
|
dimension->SetLayer( klayer );
|
||||||
dimension->SetStart( referencePoint0 );
|
dimension->SetStart( referencePoint0 );
|
||||||
|
|
||||||
|
@ -1366,7 +1366,7 @@ void ALTIUM_PCB::HelperParseDimensions6Radial(const ADIMENSION6 &aElem)
|
||||||
m_board->Add( dimension, ADD_MODE::APPEND );
|
m_board->Add( dimension, ADD_MODE::APPEND );
|
||||||
m_radialDimensions.push_back( dimension );
|
m_radialDimensions.push_back( dimension );
|
||||||
|
|
||||||
dimension->SetPrecision( aElem.textprecision );
|
dimension->SetPrecision( static_cast<DIM_PRECISION>( aElem.textprecision ) );
|
||||||
dimension->SetLayer( klayer );
|
dimension->SetLayer( klayer );
|
||||||
dimension->SetStart( referencePoint0 );
|
dimension->SetStart( referencePoint0 );
|
||||||
dimension->SetEnd( aElem.xy1 );
|
dimension->SetEnd( aElem.xy1 );
|
||||||
|
|
|
@ -3629,7 +3629,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::applyDimensionSettings( const DIMENSION& aCads
|
||||||
LINECODE linecode = Assignments.Codedefs.LineCodes.at( aCadstarDim.Line.LineCodeID );
|
LINECODE linecode = Assignments.Codedefs.LineCodes.at( aCadstarDim.Line.LineCodeID );
|
||||||
|
|
||||||
aKiCadDim->SetLayer( getKiCadLayer( aCadstarDim.LayerID ) );
|
aKiCadDim->SetLayer( getKiCadLayer( aCadstarDim.LayerID ) );
|
||||||
aKiCadDim->SetPrecision( aCadstarDim.Precision );
|
aKiCadDim->SetPrecision( static_cast<DIM_PRECISION>( aCadstarDim.Precision ) );
|
||||||
aKiCadDim->SetStart( getKiCadPoint( aCadstarDim.ExtensionLineParams.Start ) );
|
aKiCadDim->SetStart( getKiCadPoint( aCadstarDim.ExtensionLineParams.Start ) );
|
||||||
aKiCadDim->SetEnd( getKiCadPoint( aCadstarDim.ExtensionLineParams.End ) );
|
aKiCadDim->SetEnd( getKiCadPoint( aCadstarDim.ExtensionLineParams.End ) );
|
||||||
aKiCadDim->SetExtensionOffset( getKiCadLength( aCadstarDim.ExtensionLineParams.Offset ) );
|
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.
|
// For now we will hardcode the units as per the original CADSTAR design.
|
||||||
// TODO: update this when KiCad supports design units
|
// 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;
|
dimensionUnits = Assignments.Technology.Units;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 )
|
void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
|
||||||
|
|
|
@ -2279,7 +2279,8 @@ void PCB_PARSER::parseDefaults( BOARD_DESIGN_SETTINGS& designSettings )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_dimension_precision:
|
case T_dimension_precision:
|
||||||
designSettings.m_DimensionPrecision = parseInt( "dimension precision" );
|
designSettings.m_DimensionPrecision =
|
||||||
|
static_cast<DIM_PRECISION>( parseInt( "dimension precision" ) );
|
||||||
NeedRIGHT();
|
NeedRIGHT();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -3334,7 +3335,7 @@ PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION( BOARD_ITEM* aParent, bool aInFP
|
||||||
}
|
}
|
||||||
|
|
||||||
case T_precision:
|
case T_precision:
|
||||||
dim->SetPrecision( parseInt( "dim precision" ) );
|
dim->SetPrecision( static_cast<DIM_PRECISION>( parseInt( "dim precision" ) ) );
|
||||||
NeedRIGHT();
|
NeedRIGHT();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -1218,9 +1218,6 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
||||||
aDim->SetSuppressZeroes( boardSettings.m_DimensionSuppressZeroes );
|
aDim->SetSuppressZeroes( boardSettings.m_DimensionSuppressZeroes );
|
||||||
aDim->SetTextPositionMode( boardSettings.m_DimensionTextPosition );
|
aDim->SetTextPositionMode( boardSettings.m_DimensionTextPosition );
|
||||||
aDim->SetKeepTextAligned( boardSettings.m_DimensionKeepTextAligned );
|
aDim->SetKeepTextAligned( boardSettings.m_DimensionKeepTextAligned );
|
||||||
|
|
||||||
if( boardSettings.m_DimensionUnitsMode == DIM_UNITS_MODE::AUTOMATIC )
|
|
||||||
aDim->SetUnits( m_frame->GetUserUnits() );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if( originalEvent.IsAction( &PCB_ACTIONS::drawAlignedDimension ) )
|
if( originalEvent.IsAction( &PCB_ACTIONS::drawAlignedDimension ) )
|
||||||
|
|
|
@ -1117,17 +1117,6 @@ int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
|
||||||
std::vector<BOARD_ITEM*> itemsToSel;
|
std::vector<BOARD_ITEM*> itemsToSel;
|
||||||
itemsToSel.reserve( aItems.size() );
|
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 )
|
for( BOARD_ITEM* item : aItems )
|
||||||
{
|
{
|
||||||
if( aIsNew )
|
if( aIsNew )
|
||||||
|
@ -1144,7 +1133,7 @@ int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
|
||||||
// Update item attributes if needed
|
// Update item attributes if needed
|
||||||
if( BaseType( item->Type() ) == PCB_DIMENSION_T )
|
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 )
|
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() )
|
for( BOARD_ITEM* dwg : footprint->GraphicalItems() )
|
||||||
{
|
{
|
||||||
if( BaseType( dwg->Type() ) == PCB_DIMENSION_T )
|
if( BaseType( dwg->Type() ) == PCB_DIMENSION_T )
|
||||||
updateDimensionUnits( static_cast<PCB_DIMENSION_BASE*>( dwg ) );
|
static_cast<PCB_DIMENSION_BASE*>( dwg )->UpdateUnits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue