From 0e9997d9ca895029999974278b3d159cd418aac2 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Fri, 11 Sep 2020 20:36:43 -0400 Subject: [PATCH] Add new dimension features to board design defaults --- include/board_design_settings.h | 16 +- pcbnew/board_design_settings.cpp | 39 +- pcbnew/class_dimension.h | 1 + .../dialogs/panel_setup_text_and_graphics.cpp | 27 +- .../dialogs/panel_setup_text_and_graphics.h | 1 + .../panel_setup_text_and_graphics_base.cpp | 75 ++- .../panel_setup_text_and_graphics_base.fbp | 596 +++++++++++++++++- .../panel_setup_text_and_graphics_base.h | 15 +- pcbnew/pcb_parser.cpp | 3 +- pcbnew/tools/drawing_tool.cpp | 9 +- 10 files changed, 725 insertions(+), 57 deletions(-) diff --git a/include/board_design_settings.h b/include/board_design_settings.h index 65efe3188f..a753295349 100644 --- a/include/board_design_settings.h +++ b/include/board_design_settings.h @@ -49,6 +49,8 @@ #define DEFAULT_COPPER_TEXT_WIDTH 0.30 #define DEFAULT_TEXT_WIDTH 0.15 +#define DEFAULT_DIMENSION_ARROW_LENGTH 50 // mils, for legacy purposes + // Board thickness, mainly for 3D view: #define DEFAULT_BOARD_THICKNESS_MM 1.6 @@ -203,6 +205,11 @@ struct TEXT_ITEM_INFO // forward declaration from class_track.h enum class VIATYPE : int; +// forward declarations from class_dimension.h +enum class DIM_UNITS_FORMAT : int; +enum class DIM_TEXT_POSITION : int; +enum class DIM_UNITS_MODE : int; + /** * BOARD_DESIGN_SETTINGS @@ -269,8 +276,13 @@ public: bool m_TextItalic[ LAYER_CLASS_COUNT ]; bool m_TextUpright[ LAYER_CLASS_COUNT ]; - int m_DimensionUnits; - int m_DimensionPrecision; ///< Number of digits after the decimal + // Default values for dimension objects + DIM_UNITS_MODE m_DimensionUnitsMode; + int m_DimensionPrecision; ///< Number of digits after the decimal + DIM_UNITS_FORMAT m_DimensionUnitsFormat; + DIM_TEXT_POSITION m_DimensionTextPosition; + bool m_DimensionKeepTextAligned; + int m_DimensionArrowLength; // Miscellaneous wxPoint m_AuxOrigin; ///< origin for plot exports diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index 4e44ca6411..0a0a310848 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -118,8 +119,12 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std: m_TextItalic[ LAYER_CLASS_OTHERS ] = false; m_TextUpright[ LAYER_CLASS_OTHERS ] = false; - m_DimensionUnits = 0; // Inches - m_DimensionPrecision = 4; + m_DimensionPrecision = 4; + m_DimensionUnitsMode = DIM_UNITS_MODE::AUTOMATIC; + m_DimensionUnitsFormat = DIM_UNITS_FORMAT::BARE_SUFFIX; + m_DimensionTextPosition = DIM_TEXT_POSITION::OUTSIDE; + m_DimensionKeepTextAligned = true; + m_DimensionArrowLength = Mils2iu( DEFAULT_DIMENSION_ARROW_LENGTH ); m_useCustomTrackVia = false; m_customTrackWidth = Millimeter2iu( DEFAULT_CUSTOMTRACKWIDTH ); @@ -510,12 +515,29 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std: m_params.emplace_back( new PARAM( "defaults.other_text_upright", &m_TextUpright[LAYER_CLASS_OTHERS], true ) ); - m_params.emplace_back( new PARAM( "defaults.dimension_units", - &m_DimensionUnits, 0, 0, 2 ) ); + m_params.emplace_back( new PARAM_ENUM( "defaults.dimension_units", + &m_DimensionUnitsMode, DIM_UNITS_MODE::AUTOMATIC, DIM_UNITS_MODE::INCHES, + DIM_UNITS_MODE::AUTOMATIC ) ); m_params.emplace_back( new PARAM( "defaults.dimension_precision", &m_DimensionPrecision, 4, 0, 5 ) ); + m_params.emplace_back( new PARAM_ENUM( "defaults.dimensions.units_format", + &m_DimensionUnitsFormat, DIM_UNITS_FORMAT::BARE_SUFFIX, DIM_UNITS_FORMAT::NO_SUFFIX, + DIM_UNITS_FORMAT::PAREN_SUFFIX ) ); + + // NOTE: excluding DIM_TEXT_POSITION::MANUAL from the valid range here + m_params.emplace_back( new PARAM_ENUM( "defaults.dimensions.text_position", + &m_DimensionTextPosition, DIM_TEXT_POSITION::OUTSIDE, DIM_TEXT_POSITION::OUTSIDE, + DIM_TEXT_POSITION::INLINE ) ); + + m_params.emplace_back( new PARAM( "defaults.dimensions.keep_text_aligned", + &m_DimensionKeepTextAligned, true ) ); + + m_params.emplace_back( new PARAM( "defaults.dimensions.arrow_length", + &m_DimensionArrowLength, + Mils2iu( DEFAULT_DIMENSION_ARROW_LENGTH ) ) ); + m_params.emplace_back( new PARAM( "defaults.zones.45_degree_only", &m_defaultZoneSettings.m_Zone_45_Only, false ) ); @@ -635,8 +657,13 @@ void BOARD_DESIGN_SETTINGS::initFromOther( const BOARD_DESIGN_SETTINGS& aOther ) std::copy( std::begin( aOther.m_TextUpright ), std::end( aOther.m_TextUpright ), std::begin( m_TextUpright ) ); - m_DimensionUnits = aOther.m_DimensionUnits; - m_DimensionPrecision = aOther.m_DimensionPrecision; + m_DimensionUnitsMode = aOther.m_DimensionUnitsMode; + m_DimensionPrecision = aOther.m_DimensionPrecision; + m_DimensionUnitsFormat = aOther.m_DimensionUnitsFormat; + m_DimensionTextPosition = aOther.m_DimensionTextPosition; + m_DimensionKeepTextAligned = aOther.m_DimensionKeepTextAligned; + m_DimensionArrowLength = aOther.m_DimensionArrowLength; + m_AuxOrigin = aOther.m_AuxOrigin; m_GridOrigin = aOther.m_GridOrigin; m_HasStackup = aOther.m_HasStackup; diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h index 7b4e29247e..109ce9d1e4 100644 --- a/pcbnew/class_dimension.h +++ b/pcbnew/class_dimension.h @@ -33,6 +33,7 @@ #include #include +#include class LINE_READER; diff --git a/pcbnew/dialogs/panel_setup_text_and_graphics.cpp b/pcbnew/dialogs/panel_setup_text_and_graphics.cpp index 302c21402d..790f158ec2 100644 --- a/pcbnew/dialogs/panel_setup_text_and_graphics.cpp +++ b/pcbnew/dialogs/panel_setup_text_and_graphics.cpp @@ -56,7 +56,8 @@ enum PANEL_SETUP_TEXT_AND_GRAPHICS::PANEL_SETUP_TEXT_AND_GRAPHICS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) : - PANEL_SETUP_TEXT_AND_GRAPHICS_BASE( aParent->GetTreebook() ) + PANEL_SETUP_TEXT_AND_GRAPHICS_BASE( aParent->GetTreebook() ), + m_arrowLength( aFrame, m_lblArrowLength, m_dimensionArrowLength, m_arrowLengthUnits ) { m_Parent = aParent; m_Frame = aFrame; @@ -134,9 +135,20 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow() wxASSERT_MSG( m_BrdSettings->m_DimensionPrecision <= 4, "Unhandled dimension precision!" ); - m_dimensionUnits->SetSelection( m_BrdSettings->m_DimensionUnits ); + int mode = static_cast( m_BrdSettings->m_DimensionUnitsMode ); + m_dimensionUnits->SetSelection( mode ); + + int format = static_cast( m_BrdSettings->m_DimensionUnitsFormat ); + m_dimensionUnitsFormat->SetSelection( format ); + m_dimensionPrecision->SetSelection( m_BrdSettings->m_DimensionPrecision ); + int position = static_cast( m_BrdSettings->m_DimensionTextPosition ); + m_dimensionTextPositionMode->SetSelection( position ); + + m_dimensionTextKeepAligned->SetValue( m_BrdSettings->m_DimensionKeepTextAligned ); + m_arrowLength.SetValue( m_BrdSettings->m_DimensionArrowLength ); + return true; } @@ -192,8 +204,15 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow() wxGridCellBoolEditor::IsTrueValue( m_grid->GetCellValue( i, COL_TEXT_UPRIGHT ) ); } - m_BrdSettings->m_DimensionUnits = m_dimensionUnits->GetSelection(); - m_BrdSettings->m_DimensionPrecision = m_dimensionPrecision->GetSelection(); + int mode = m_dimensionUnits->GetSelection(); + m_BrdSettings->m_DimensionUnitsMode = static_cast( mode ); + int format = m_dimensionUnitsFormat->GetSelection(); + m_BrdSettings->m_DimensionUnitsFormat = static_cast( format ); + m_BrdSettings->m_DimensionPrecision = m_dimensionPrecision->GetSelection(); + int position = m_dimensionTextPositionMode->GetSelection(); + m_BrdSettings->m_DimensionTextPosition = static_cast( position ); + m_BrdSettings->m_DimensionKeepTextAligned = m_dimensionTextKeepAligned->GetValue(); + m_BrdSettings->m_DimensionArrowLength = m_arrowLength.GetValue(); return true; } diff --git a/pcbnew/dialogs/panel_setup_text_and_graphics.h b/pcbnew/dialogs/panel_setup_text_and_graphics.h index 1eb61b43bc..76faf8f6d7 100644 --- a/pcbnew/dialogs/panel_setup_text_and_graphics.h +++ b/pcbnew/dialogs/panel_setup_text_and_graphics.h @@ -41,6 +41,7 @@ private: PAGED_DIALOG* m_Parent; PCB_EDIT_FRAME* m_Frame; BOARD_DESIGN_SETTINGS* m_BrdSettings; + UNIT_BINDER m_arrowLength; private: bool validateData(); diff --git a/pcbnew/dialogs/panel_setup_text_and_graphics_base.cpp b/pcbnew/dialogs/panel_setup_text_and_graphics_base.cpp index 5671325403..4765b3d69a 100644 --- a/pcbnew/dialogs/panel_setup_text_and_graphics_base.cpp +++ b/pcbnew/dialogs/panel_setup_text_and_graphics_base.cpp @@ -75,33 +75,78 @@ PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::PANEL_SETUP_TEXT_AND_GRAPHICS_BASE( wxWindow m_staticText2->Wrap( -1 ); m_gridSizer->Add( m_staticText2, 0, wxALL, 5 ); - wxFlexGridSizer* fgSizer1; - fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 ); - fgSizer1->SetFlexibleDirection( wxBOTH ); - fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + wxGridBagSizer* gbSizer1; + gbSizer1 = new wxGridBagSizer( 0, 0 ); + gbSizer1->SetFlexibleDirection( wxHORIZONTAL ); + gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_NONE ); - m_dimensionUnitsLabel = new wxStaticText( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_dimensionUnitsLabel->Wrap( -1 ); - fgSizer1->Add( m_dimensionUnitsLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + m_lblDimensionUnits = new wxStaticText( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblDimensionUnits->Wrap( -1 ); + gbSizer1->Add( m_lblDimensionUnits, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - wxString m_dimensionUnitsChoices[] = { _("Inches"), _("Mils"), _("Millimeters") }; + wxString m_dimensionUnitsChoices[] = { _("Inches"), _("Mils"), _("Millimeters"), _("Automatic") }; int m_dimensionUnitsNChoices = sizeof( m_dimensionUnitsChoices ) / sizeof( wxString ); m_dimensionUnits = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_dimensionUnitsNChoices, m_dimensionUnitsChoices, 0 ); m_dimensionUnits->SetSelection( 0 ); - fgSizer1->Add( m_dimensionUnits, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + m_dimensionUnits->SetToolTip( _("Default units for dimensions (\"automatic\" to follow the chosen UI units)") ); - m_dimensionPrecisionLabel = new wxStaticText( this, wxID_ANY, _("Precision:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_dimensionPrecisionLabel->Wrap( -1 ); - fgSizer1->Add( m_dimensionPrecisionLabel, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + gbSizer1->Add( m_dimensionUnits, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - wxString m_dimensionPrecisionChoices[] = { _("0"), _("0.0"), _("0.00"), _("0.000"), _("0.0000") }; + + gbSizer1->Add( 40, 0, wxGBPosition( 0, 2 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); + + m_lblTextPositionMode = new wxStaticText( this, wxID_ANY, _("Text position:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextPositionMode->Wrap( -1 ); + gbSizer1->Add( m_lblTextPositionMode, wxGBPosition( 0, 3 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + wxString m_dimensionTextPositionModeChoices[] = { _("Outside"), _("Inline") }; + int m_dimensionTextPositionModeNChoices = sizeof( m_dimensionTextPositionModeChoices ) / sizeof( wxString ); + m_dimensionTextPositionMode = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_dimensionTextPositionModeNChoices, m_dimensionTextPositionModeChoices, 0 ); + m_dimensionTextPositionMode->SetSelection( 0 ); + m_dimensionTextPositionMode->SetToolTip( _("Where to position the dimension text relative to the dimension line") ); + + gbSizer1->Add( m_dimensionTextPositionMode, wxGBPosition( 0, 4 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); + + m_lblDimensionUnitsFormat = new wxStaticText( this, wxID_ANY, _("Units format:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblDimensionUnitsFormat->Wrap( -1 ); + gbSizer1->Add( m_lblDimensionUnitsFormat, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + wxString m_dimensionUnitsFormatChoices[] = { _("1234"), _("1234 mm"), _("1234 (mm)") }; + int m_dimensionUnitsFormatNChoices = sizeof( m_dimensionUnitsFormatChoices ) / sizeof( wxString ); + m_dimensionUnitsFormat = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_dimensionUnitsFormatNChoices, m_dimensionUnitsFormatChoices, 0 ); + m_dimensionUnitsFormat->SetSelection( 1 ); + gbSizer1->Add( m_dimensionUnitsFormat, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); + + m_dimensionTextKeepAligned = new wxCheckBox( this, wxID_ANY, _("Keep text aligned"), wxDefaultPosition, wxDefaultSize, 0 ); + m_dimensionTextKeepAligned->SetToolTip( _("When checked, dimension text will be kept aligned with dimension lines") ); + + gbSizer1->Add( m_dimensionTextKeepAligned, wxGBPosition( 1, 3 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); + + m_lblDimensionPrecision = new wxStaticText( this, wxID_ANY, _("Precision:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblDimensionPrecision->Wrap( -1 ); + gbSizer1->Add( m_lblDimensionPrecision, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + wxString m_dimensionPrecisionChoices[] = { _("0"), _("0.0"), _("0.00"), _("0.000"), _("0.0000"), _("0.00000") }; int m_dimensionPrecisionNChoices = sizeof( m_dimensionPrecisionChoices ) / sizeof( wxString ); m_dimensionPrecision = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_dimensionPrecisionNChoices, m_dimensionPrecisionChoices, 0 ); m_dimensionPrecision->SetSelection( 4 ); - fgSizer1->Add( m_dimensionPrecision, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + m_dimensionPrecision->SetToolTip( _("How many digits of precision to show") ); + + gbSizer1->Add( m_dimensionPrecision, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); + + m_lblArrowLength = new wxStaticText( this, wxID_ANY, _("Arrow length:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblArrowLength->Wrap( -1 ); + gbSizer1->Add( m_lblArrowLength, wxGBPosition( 2, 3 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + m_dimensionArrowLength = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_dimensionArrowLength, wxGBPosition( 2, 4 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); + + m_arrowLengthUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_arrowLengthUnits->Wrap( -1 ); + gbSizer1->Add( m_arrowLengthUnits, wxGBPosition( 2, 5 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_gridSizer->Add( fgSizer1, 1, wxEXPAND|wxBOTTOM|wxLEFT, 20 ); + m_gridSizer->Add( gbSizer1, 1, wxBOTTOM|wxEXPAND|wxLEFT, 20 ); mainSizer->Add( m_gridSizer, 0, wxRIGHT|wxLEFT, 5 ); diff --git a/pcbnew/dialogs/panel_setup_text_and_graphics_base.fbp b/pcbnew/dialogs/panel_setup_text_and_graphics_base.fbp index edb62cd284..76b08ee998 100644 --- a/pcbnew/dialogs/panel_setup_text_and_graphics_base.fbp +++ b/pcbnew/dialogs/panel_setup_text_and_graphics_base.fbp @@ -285,24 +285,26 @@ 20 - wxEXPAND|wxBOTTOM|wxLEFT + wxBOTTOM|wxEXPAND|wxLEFT 1 - - 2 - wxBOTH + + + wxHORIZONTAL 0 - fgSizer1 - wxFLEX_GROWMODE_SPECIFIED + gbSizer1 + wxFLEX_GROWMODE_NONE none - 0 0 - + 5 - wxALL|wxALIGN_CENTER_VERTICAL - 0 + 1 + 0 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + 1 1 1 @@ -340,7 +342,7 @@ 0 1 - m_dimensionUnitsLabel + m_lblDimensionUnits 1 @@ -360,10 +362,13 @@ -1 - + 5 - wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND - 0 + 1 + 1 + wxALL|wxEXPAND + 0 + 1 1 1 @@ -378,7 +383,7 @@ 1 0 - "Inches" "Mils" "Millimeters" + "Inches" "Mils" "Millimeters" "Automatic" 1 1 @@ -414,6 +419,281 @@ ; ; forward_declare 0 + Default units for dimensions ("automatic" to follow the chosen UI units) + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + 1 + 2 + wxEXPAND + 0 + 1 + + 0 + protected + 40 + + + + 5 + 1 + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Text position: + 0 + + 0 + + + 0 + + 1 + m_lblTextPositionMode + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 4 + wxALL|wxEXPAND + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Outside" "Inline" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_dimensionTextPositionMode + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + Where to position the dimension text relative to the dimension line + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL|wxALL + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Units format: + 0 + + 0 + + + 0 + + 1 + m_lblDimensionUnitsFormat + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALL|wxEXPAND + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "1234" "1234 mm" "1234 (mm)" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_dimensionUnitsFormat + 1 + + + protected + 1 + + Resizable + 1 + 1 + + + ; ; forward_declare + 0 wxFILTER_NONE @@ -424,10 +704,80 @@ - + 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL - 0 + 2 + 3 + wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Keep text aligned + + 0 + + + 0 + + 1 + m_dimensionTextKeepAligned + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + When checked, dimension text will be kept aligned with dimension lines + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL|wxALL + 2 + 1 1 1 @@ -465,7 +815,7 @@ 0 1 - m_dimensionPrecisionLabel + m_lblDimensionPrecision 1 @@ -485,10 +835,13 @@ -1 - + 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND - 0 + 1 + 1 + wxALL|wxEXPAND + 2 + 1 1 1 @@ -503,7 +856,7 @@ 1 0 - "0" "0.0" "0.00" "0.000" "0.0000" + "0" "0.0" "0.00" "0.000" "0.0000" "0.00000" 1 1 @@ -539,7 +892,7 @@ ; ; forward_declare 0 - + How many digits of precision to show wxFILTER_NONE wxDefaultValidator @@ -549,6 +902,201 @@ + + 5 + 1 + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Arrow length: + 0 + + 0 + + + 0 + + 1 + m_lblArrowLength + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 4 + wxALL|wxEXPAND + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_dimensionArrowLength + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + 1 + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + unit + 0 + + 0 + + + 0 + + 1 + m_arrowLengthUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + diff --git a/pcbnew/dialogs/panel_setup_text_and_graphics_base.h b/pcbnew/dialogs/panel_setup_text_and_graphics_base.h index b38eabc5e3..f51140805a 100644 --- a/pcbnew/dialogs/panel_setup_text_and_graphics_base.h +++ b/pcbnew/dialogs/panel_setup_text_and_graphics_base.h @@ -20,6 +20,9 @@ class WX_GRID; #include #include #include +#include +#include +#include #include #include @@ -37,10 +40,18 @@ class PANEL_SETUP_TEXT_AND_GRAPHICS_BASE : public wxPanel wxStaticText* m_staticText1; WX_GRID* m_grid; wxStaticText* m_staticText2; - wxStaticText* m_dimensionUnitsLabel; + wxStaticText* m_lblDimensionUnits; wxChoice* m_dimensionUnits; - wxStaticText* m_dimensionPrecisionLabel; + wxStaticText* m_lblTextPositionMode; + wxChoice* m_dimensionTextPositionMode; + wxStaticText* m_lblDimensionUnitsFormat; + wxChoice* m_dimensionUnitsFormat; + wxCheckBox* m_dimensionTextKeepAligned; + wxStaticText* m_lblDimensionPrecision; wxChoice* m_dimensionPrecision; + wxStaticText* m_lblArrowLength; + wxTextCtrl* m_dimensionArrowLength; + wxStaticText* m_arrowLengthUnits; public: diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 4e81f9245e..716fbe65af 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -1914,7 +1914,8 @@ void PCB_PARSER::parseDefaults( BOARD_DESIGN_SETTINGS& designSettings ) break; case T_dimension_units: - designSettings.m_DimensionUnits = parseInt( "dimension units" ); + designSettings.m_DimensionUnitsMode = + static_cast( parseInt( "dimension units" ) ); NeedRIGHT(); break; diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index ad8c9f17cf..19089a378a 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -738,9 +738,12 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) dimension->Text().SetTextThickness( boardSettings.GetTextThickness( layer ) ); dimension->Text().SetItalic( boardSettings.GetTextItalic( layer ) ); dimension->SetLineThickness( boardSettings.GetLineThickness( layer ) ); - dimension->SetUnits( boardSettings.m_DimensionUnits == 2 ? EDA_UNITS::MILLIMETRES : - EDA_UNITS::INCHES, - boardSettings.m_DimensionUnits == 1 ); + dimension->SetUnitsMode( boardSettings.m_DimensionUnitsMode ); + dimension->SetUnitsFormat( boardSettings.m_DimensionUnitsFormat ); + dimension->SetPrecision( boardSettings.m_DimensionPrecision ); + dimension->SetTextPositionMode( boardSettings.m_DimensionTextPosition ); + dimension->SetKeepTextAligned( boardSettings.m_DimensionKeepTextAligned ); + dimension->SetArrowLength( boardSettings.m_DimensionArrowLength ); dimension->SetStart( (wxPoint) cursorPos ); dimension->SetEnd( (wxPoint) cursorPos );