Add default units and precision for new dimension objects.

Fixes: lp:1846376
* https://bugs.launchpad.net/kicad/+bug/1846376
This commit is contained in:
Jeff Young 2019-10-31 23:25:50 +00:00
parent a6a4973324
commit 1c153c55c0
12 changed files with 494 additions and 176 deletions

View File

@ -228,6 +228,9 @@ public:
bool m_TextItalic[ LAYER_CLASS_COUNT ]; bool m_TextItalic[ LAYER_CLASS_COUNT ];
bool m_TextUpright[ LAYER_CLASS_COUNT ]; bool m_TextUpright[ LAYER_CLASS_COUNT ];
int m_DimensionUnits;
int m_DimensionPrecision;
// Variables used in footprint editing (default value in item/footprint creation) // Variables used in footprint editing (default value in item/footprint creation)
wxString m_RefDefaultText; ///< Default ref text on fp creation wxString m_RefDefaultText; ///< Default ref text on fp creation

View File

@ -479,6 +479,9 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() :
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_DimensionUnits = 0; // Inches
m_DimensionPrecision = 1; // 0.001mm / 0.1 mil
m_useCustomTrackVia = false; m_useCustomTrackVia = false;
m_customTrackWidth = Millimeter2iu( DEFAULT_CUSTOMTRACKWIDTH ); m_customTrackWidth = Millimeter2iu( DEFAULT_CUSTOMTRACKWIDTH );
m_customViaSize.m_Diameter = Millimeter2iu( DEFAULT_VIASMINSIZE ); m_customViaSize.m_Diameter = Millimeter2iu( DEFAULT_VIASMINSIZE );
@ -673,6 +676,11 @@ void BOARD_DESIGN_SETTINGS::AppendConfigs( BOARD* aBoard, PARAM_CFG_ARRAY* aResu
aResult->push_back( new PARAM_CFG_BOOL( wxT( "OthersTextUpright" ), aResult->push_back( new PARAM_CFG_BOOL( wxT( "OthersTextUpright" ),
&m_TextUpright[ LAYER_CLASS_OTHERS ], true ) ); &m_TextUpright[ LAYER_CLASS_OTHERS ], true ) );
aResult->push_back( new PARAM_CFG_INT( wxT( "DimensionUnits" ),
&m_DimensionUnits, 0, 0, 2 ) );
aResult->push_back( new PARAM_CFG_INT( wxT( "DimensionPrecision" ),
&m_DimensionPrecision, 1, 0, 2 ) );
aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SolderMaskClearance" ), aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "SolderMaskClearance" ),
&m_SolderMaskMargin, &m_SolderMaskMargin,
Millimeter2iu( DEFAULT_SOLDERMASK_CLEARANCE ), Millimeter2iu( -1.0 ), Millimeter2iu( 1.0 ), Millimeter2iu( DEFAULT_SOLDERMASK_CLEARANCE ), Millimeter2iu( -1.0 ), Millimeter2iu( 1.0 ),
@ -987,3 +995,5 @@ bool BOARD_DESIGN_SETTINGS::GetTextUpright( PCB_LAYER_ID aLayer ) const
{ {
return m_TextUpright[ GetLayerClass( aLayer ) ]; return m_TextUpright[ GetLayerClass( aLayer ) ];
} }

View File

@ -191,27 +191,27 @@ void DIMENSION::Mirror( const wxPoint& axis_pos, bool aMirrorLeftRight )
} }
void DIMENSION::SetOrigin( const wxPoint& aOrigin ) void DIMENSION::SetOrigin( const wxPoint& aOrigin, int aPrecision )
{ {
m_featureLineGO = aOrigin; m_featureLineGO = aOrigin;
AdjustDimensionDetails(); AdjustDimensionDetails( aPrecision );
} }
void DIMENSION::SetEnd( const wxPoint& aEnd ) void DIMENSION::SetEnd( const wxPoint& aEnd, int aPrecision )
{ {
m_featureLineDO = aEnd; m_featureLineDO = aEnd;
AdjustDimensionDetails(); AdjustDimensionDetails( aPrecision );
} }
void DIMENSION::SetHeight( int aHeight ) void DIMENSION::SetHeight( int aHeight, int aPrecision )
{ {
m_Height = aHeight; m_Height = aHeight;
AdjustDimensionDetails(); AdjustDimensionDetails( aPrecision );
} }
@ -227,7 +227,7 @@ void DIMENSION::UpdateHeight()
} }
void DIMENSION::AdjustDimensionDetails() void DIMENSION::AdjustDimensionDetails( int aPrecision )
{ {
const int arrowz = Mils2iu( 50 ); // size of arrows const int arrowz = Mils2iu( 50 ); // size of arrows
int ii; int ii;
@ -335,7 +335,20 @@ void DIMENSION::AdjustDimensionDetails()
m_Text.SetTextAngle( newAngle ); m_Text.SetTextAngle( newAngle );
m_Value = measure; m_Value = measure;
SetText( MessageTextFromValue( m_Unit, m_Value, m_UseMils ) );
if( m_Unit == MILLIMETRES )
aPrecision += 2;
else if( !m_UseMils )
aPrecision += 3;
wxString text;
wxString format = wxT( "%." ) + wxString::Format( "%i", aPrecision ) + wxT( "f" );
text.Printf( format, To_User_Unit( m_Unit, m_Value, m_UseMils ) );
text += " ";
text += GetAbbreviatedUnitsLabel( m_Unit, m_UseMils );
SetText( text );
} }

View File

@ -113,8 +113,9 @@ public:
* Function SetOrigin * Function SetOrigin
* Sets a new origin of the crossbar line. All remaining lines are adjusted after that. * Sets a new origin of the crossbar line. All remaining lines are adjusted after that.
* @param aOrigin is the new point to be used as the new origin of the crossbar line. * @param aOrigin is the new point to be used as the new origin of the crossbar line.
* @param aPrecision number of decimal places for mils (scaled appropriately for other units).
*/ */
void SetOrigin( const wxPoint& aOrigin ); void SetOrigin( const wxPoint& aOrigin, int aPrecision );
/** /**
* Function GetOrigin * Function GetOrigin
@ -129,8 +130,9 @@ public:
* Function SetEnd * Function SetEnd
* Sets a new end of the crossbar line. All remaining lines are adjusted after that. * Sets a new end of the crossbar line. All remaining lines are adjusted after that.
* @param aEnd is the new point to be used as the new end of the crossbar line. * @param aEnd is the new point to be used as the new end of the crossbar line.
* @param aPrecision number of decimal places for mils (scaled appropriately for other units).
*/ */
void SetEnd( const wxPoint& aEnd ); void SetEnd( const wxPoint& aEnd, int aPrecision );
/** /**
* Function GetEnd * Function GetEnd
@ -145,8 +147,9 @@ public:
* Function SetHeight * Function SetHeight
* Sets the length of feature lines. * Sets the length of feature lines.
* @param aHeight is the new height. * @param aHeight is the new height.
* @param aPrecision number of decimal places for mils (scaled appropriately for other units).
*/ */
void SetHeight( int aHeight ); void SetHeight( int aHeight, int aPrecision );
/** /**
* Function GetHeight * Function GetHeight
@ -178,8 +181,9 @@ public:
/** /**
* Function AdjustDimensionDetails * Function AdjustDimensionDetails
* Calculate coordinates of segments used to draw the dimension. * Calculate coordinates of segments used to draw the dimension.
* @param aPrecision number of decimal places for mils (scaled appropriately for other units).
*/ */
void AdjustDimensionDetails(); void AdjustDimensionDetails( int aPrecision );
void GetUnits( EDA_UNITS_T& aUnits, bool& aUseMils ) const void GetUnits( EDA_UNITS_T& aUnits, bool& aUseMils ) const
{ {

View File

@ -131,6 +131,9 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow()
Layout(); Layout();
m_dimensionUnits->SetSelection( m_BrdSettings->m_DimensionUnits );
m_dimensionPrecision->SetSelection( m_BrdSettings->m_DimensionPrecision );
return true; return true;
} }
@ -186,6 +189,9 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow()
wxGridCellBoolEditor::IsTrueValue( m_grid->GetCellValue( i, COL_TEXT_UPRIGHT ) ); wxGridCellBoolEditor::IsTrueValue( m_grid->GetCellValue( i, COL_TEXT_UPRIGHT ) );
} }
m_BrdSettings->m_DimensionUnits = m_dimensionUnits->GetSelection();
m_BrdSettings->m_DimensionPrecision = m_dimensionPrecision->GetSelection();
return true; return true;
} }

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 30 2017) // C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -11,26 +11,26 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::PANEL_SETUP_TEXT_AND_GRAPHICS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::PANEL_SETUP_TEXT_AND_GRAPHICS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
{ {
wxBoxSizer* mainSizer; wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxVERTICAL ); mainSizer = new wxBoxSizer( wxVERTICAL );
m_gridSizer = new wxBoxSizer( wxVERTICAL ); m_gridSizer = new wxBoxSizer( wxVERTICAL );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Default properties for new graphic items:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1 = new wxStaticText( this, wxID_ANY, _("Default properties for new graphic items:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 ); m_staticText1->Wrap( -1 );
m_gridSizer->Add( m_staticText1, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_gridSizer->Add( m_staticText1, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
// Grid // Grid
m_grid->CreateGrid( 5, 6 ); m_grid->CreateGrid( 5, 6 );
m_grid->EnableEditing( true ); m_grid->EnableEditing( true );
m_grid->EnableGridLines( true ); m_grid->EnableGridLines( true );
m_grid->EnableDragGridSize( false ); m_grid->EnableDragGridSize( false );
m_grid->SetMargins( 0, 0 ); m_grid->SetMargins( 0, 0 );
// Columns // Columns
m_grid->SetColSize( 0, 140 ); m_grid->SetColSize( 0, 140 );
m_grid->SetColSize( 1, 140 ); m_grid->SetColSize( 1, 140 );
@ -47,8 +47,8 @@ PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::PANEL_SETUP_TEXT_AND_GRAPHICS_BASE( wxWindow
m_grid->SetColLabelValue( 3, _("Text Thickness") ); m_grid->SetColLabelValue( 3, _("Text Thickness") );
m_grid->SetColLabelValue( 4, _("Italic") ); m_grid->SetColLabelValue( 4, _("Italic") );
m_grid->SetColLabelValue( 5, _("Keep Upright") ); m_grid->SetColLabelValue( 5, _("Keep Upright") );
m_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows // Rows
m_grid->EnableDragRowSize( false ); m_grid->EnableDragRowSize( false );
m_grid->SetRowLabelSize( 132 ); m_grid->SetRowLabelSize( 132 );
@ -57,20 +57,55 @@ PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::PANEL_SETUP_TEXT_AND_GRAPHICS_BASE( wxWindow
m_grid->SetRowLabelValue( 2, _("Edge Cuts") ); m_grid->SetRowLabelValue( 2, _("Edge Cuts") );
m_grid->SetRowLabelValue( 3, _("Courtyards") ); m_grid->SetRowLabelValue( 3, _("Courtyards") );
m_grid->SetRowLabelValue( 4, _("Other Layers") ); m_grid->SetRowLabelValue( 4, _("Other Layers") );
m_grid->SetRowLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE ); m_grid->SetRowLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTER );
// Label Appearance // Label Appearance
// Cell Defaults // Cell Defaults
m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
m_grid->SetToolTip( _("Net Class parameters") ); m_grid->SetToolTip( _("Net Class parameters") );
m_gridSizer->Add( m_grid, 0, wxBOTTOM|wxLEFT, 20 ); m_gridSizer->Add( m_grid, 0, wxBOTTOM|wxLEFT, 20 );
m_gridSizer->Add( 0, 0, 0, wxEXPAND|wxTOP, 5 );
m_staticText2 = new wxStaticText( this, wxID_ANY, _("Default properties for new dimension objects:"), wxDefaultPosition, wxDefaultSize, 0 );
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 );
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 );
wxString m_dimensionUnitsChoices[] = { _("Inches"), _("Mils"), _("Millimeters") };
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_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 );
wxString m_dimensionPrecisionChoices[] = { _("0.01 mm / 1 mil"), _("0.001 mm / 0.1 mil"), _("0.0001mm / 0.01 mil") };
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( 0 );
fgSizer1->Add( m_dimensionPrecision, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_gridSizer->Add( fgSizer1, 1, wxEXPAND|wxBOTTOM|wxLEFT, 20 );
mainSizer->Add( m_gridSizer, 0, wxRIGHT|wxLEFT, 5 ); mainSizer->Add( m_gridSizer, 0, wxRIGHT|wxLEFT, 5 );
this->SetSizer( mainSizer ); this->SetSizer( mainSizer );
this->Layout(); this->Layout();
mainSizer->Fit( this ); mainSizer->Fit( this );

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project> <wxFormBuilder_Project>
<FileVersion major="1" minor="13" /> <FileVersion major="1" minor="15" />
<object class="Project" expanded="1"> <object class="Project" expanded="1">
<property name="class_decoration"></property> <property name="class_decoration"></property>
<property name="code_generation">C++</property> <property name="code_generation">C++</property>
@ -14,6 +14,7 @@
<property name="file">panel_setup_text_and_graphics_base</property> <property name="file">panel_setup_text_and_graphics_base</property>
<property name="first_id">1000</property> <property name="first_id">1000</property>
<property name="help_provider">none</property> <property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property> <property name="internationalize">1</property>
<property name="name">panel_setup_text_and_graphics_base</property> <property name="name">panel_setup_text_and_graphics_base</property>
<property name="namespace"></property> <property name="namespace"></property>
@ -48,36 +49,6 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property> <property name="window_style">wxTAB_TRAVERSAL</property>
<event name="OnAuiFindManager"></event>
<event name="OnAuiPaneButton"></event>
<event name="OnAuiPaneClose"></event>
<event name="OnAuiPaneMaximize"></event>
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnInitDialog"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">mainSizer</property> <property name="name">mainSizer</property>
@ -125,6 +96,7 @@
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Default properties for new graphic items:</property> <property name="label">Default properties for new graphic items:</property>
<property name="markup">0</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
@ -150,29 +122,6 @@
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<property name="wrap">-1</property> <property name="wrap">-1</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
@ -201,10 +150,10 @@
<property name="cell_vert_alignment">wxALIGN_TOP</property> <property name="cell_vert_alignment">wxALIGN_TOP</property>
<property name="center_pane">0</property> <property name="center_pane">0</property>
<property name="close_button">1</property> <property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTRE</property> <property name="col_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="col_label_size">24</property> <property name="col_label_size">24</property>
<property name="col_label_values">&quot;Line Thickness&quot; &quot;Text Width&quot; &quot;Text Height&quot; &quot;Text Thickness&quot; &quot;Italic&quot; &quot;Keep Upright&quot;</property> <property name="col_label_values">&quot;Line Thickness&quot; &quot;Text Width&quot; &quot;Text Height&quot; &quot;Text Thickness&quot; &quot;Italic&quot; &quot;Keep Upright&quot;</property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property> <property name="col_label_vert_alignment">wxALIGN_CENTER</property>
<property name="cols">6</property> <property name="cols">6</property>
<property name="column_sizes">140,140,140,140,80,120</property> <property name="column_sizes">140,140,140,140,80,120</property>
<property name="context_help"></property> <property name="context_help"></property>
@ -250,7 +199,7 @@
<property name="row_label_horiz_alignment">wxALIGN_LEFT</property> <property name="row_label_horiz_alignment">wxALIGN_LEFT</property>
<property name="row_label_size">132</property> <property name="row_label_size">132</property>
<property name="row_label_values">&quot;Silk Layers&quot; &quot;Copper Layers&quot; &quot;Edge Cuts&quot; &quot;Courtyards&quot; &quot;Other Layers&quot;</property> <property name="row_label_values">&quot;Silk Layers&quot; &quot;Copper Layers&quot; &quot;Edge Cuts&quot; &quot;Courtyards&quot; &quot;Other Layers&quot;</property>
<property name="row_label_vert_alignment">wxALIGN_CENTRE</property> <property name="row_label_vert_alignment">wxALIGN_CENTER</property>
<property name="row_sizes"></property> <property name="row_sizes"></property>
<property name="rows">5</property> <property name="rows">5</property>
<property name="show">1</property> <property name="show">1</property>
@ -261,61 +210,345 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property> <property name="window_style">wxTAB_TRAVERSAL</property>
<event name="OnChar"></event> </object>
<event name="OnEnterWindow"></event> </object>
<event name="OnEraseBackground"></event> <object class="sizeritem" expanded="1">
<event name="OnGridCellChange"></event> <property name="border">5</property>
<event name="OnGridCellLeftClick"></event> <property name="flag">wxEXPAND|wxTOP</property>
<event name="OnGridCellLeftDClick"></event> <property name="proportion">0</property>
<event name="OnGridCellRightClick"></event> <object class="spacer" expanded="1">
<event name="OnGridCellRightDClick"></event> <property name="height">0</property>
<event name="OnGridCmdCellChange"></event> <property name="permission">protected</property>
<event name="OnGridCmdCellLeftClick"></event> <property name="width">0</property>
<event name="OnGridCmdCellLeftDClick"></event> </object>
<event name="OnGridCmdCellRightClick"></event> </object>
<event name="OnGridCmdCellRightDClick"></event> <object class="sizeritem" expanded="1">
<event name="OnGridCmdColSize"></event> <property name="border">5</property>
<event name="OnGridCmdEditorCreated"></event> <property name="flag">wxALL</property>
<event name="OnGridCmdEditorHidden"></event> <property name="proportion">0</property>
<event name="OnGridCmdEditorShown"></event> <object class="wxStaticText" expanded="1">
<event name="OnGridCmdLabelLeftClick"></event> <property name="BottomDockable">1</property>
<event name="OnGridCmdLabelLeftDClick"></event> <property name="LeftDockable">1</property>
<event name="OnGridCmdLabelRightClick"></event> <property name="RightDockable">1</property>
<event name="OnGridCmdLabelRightDClick"></event> <property name="TopDockable">1</property>
<event name="OnGridCmdRangeSelect"></event> <property name="aui_layer"></property>
<event name="OnGridCmdRowSize"></event> <property name="aui_name"></property>
<event name="OnGridCmdSelectCell"></event> <property name="aui_position"></property>
<event name="OnGridColSize"></event> <property name="aui_row"></property>
<event name="OnGridEditorCreated"></event> <property name="best_size"></property>
<event name="OnGridEditorHidden"></event> <property name="bg"></property>
<event name="OnGridEditorShown"></event> <property name="caption"></property>
<event name="OnGridLabelLeftClick"></event> <property name="caption_visible">1</property>
<event name="OnGridLabelLeftDClick"></event> <property name="center_pane">0</property>
<event name="OnGridLabelRightClick"></event> <property name="close_button">1</property>
<event name="OnGridLabelRightDClick"></event> <property name="context_help"></property>
<event name="OnGridRangeSelect"></event> <property name="context_menu">1</property>
<event name="OnGridRowSize"></event> <property name="default_pane">0</property>
<event name="OnGridSelectCell"></event> <property name="dock">Dock</property>
<event name="OnKeyDown"></event> <property name="dock_fixed">0</property>
<event name="OnKeyUp"></event> <property name="docking">Left</property>
<event name="OnKillFocus"></event> <property name="enabled">1</property>
<event name="OnLeaveWindow"></event> <property name="fg"></property>
<event name="OnLeftDClick"></event> <property name="floatable">1</property>
<event name="OnLeftDown"></event> <property name="font"></property>
<event name="OnLeftUp"></event> <property name="gripper">0</property>
<event name="OnMiddleDClick"></event> <property name="hidden">0</property>
<event name="OnMiddleDown"></event> <property name="id">wxID_ANY</property>
<event name="OnMiddleUp"></event> <property name="label">Default properties for new dimension objects:</property>
<event name="OnMotion"></event> <property name="markup">0</property>
<event name="OnMouseEvents"></event> <property name="max_size"></property>
<event name="OnMouseWheel"></event> <property name="maximize_button">0</property>
<event name="OnPaint"></event> <property name="maximum_size"></property>
<event name="OnRightDClick"></event> <property name="min_size"></property>
<event name="OnRightDown"></event> <property name="minimize_button">0</property>
<event name="OnRightUp"></event> <property name="minimum_size"></property>
<event name="OnSetFocus"></event> <property name="moveable">1</property>
<event name="OnSize"></event> <property name="name">m_staticText2</property>
<event name="OnUpdateUI"></event> <property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">20</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizer1</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Units:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_dimensionUnitsLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Inches&quot; &quot;Mils&quot; &quot;Millimeters&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_dimensionUnits</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Precision:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_dimensionPrecisionLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;0.01 mm / 1 mil&quot; &quot;0.001 mm / 0.1 mil&quot; &quot;0.0001mm / 0.01 mil&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_dimensionPrecision</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object> </object>
</object> </object>
</object> </object>

View File

@ -1,12 +1,11 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 30 2017) // C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __PANEL_SETUP_TEXT_AND_GRAPHICS_BASE_H__ #pragma once
#define __PANEL_SETUP_TEXT_AND_GRAPHICS_BASE_H__
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
@ -20,6 +19,7 @@ class WX_GRID;
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/grid.h> #include <wx/grid.h>
#include <wx/choice.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/panel.h> #include <wx/panel.h>
@ -28,20 +28,24 @@ class WX_GRID;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class PANEL_SETUP_TEXT_AND_GRAPHICS_BASE /// Class PANEL_SETUP_TEXT_AND_GRAPHICS_BASE
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class PANEL_SETUP_TEXT_AND_GRAPHICS_BASE : public wxPanel class PANEL_SETUP_TEXT_AND_GRAPHICS_BASE : public wxPanel
{ {
private: private:
protected: protected:
wxBoxSizer* m_gridSizer; wxBoxSizer* m_gridSizer;
wxStaticText* m_staticText1; wxStaticText* m_staticText1;
WX_GRID* m_grid; WX_GRID* m_grid;
wxStaticText* m_staticText2;
wxStaticText* m_dimensionUnitsLabel;
wxChoice* m_dimensionUnits;
wxStaticText* m_dimensionPrecisionLabel;
wxChoice* m_dimensionPrecision;
public: public:
PANEL_SETUP_TEXT_AND_GRAPHICS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL ); PANEL_SETUP_TEXT_AND_GRAPHICS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_SETUP_TEXT_AND_GRAPHICS_BASE(); ~PANEL_SETUP_TEXT_AND_GRAPHICS_BASE();
}; };
#endif //__PANEL_SETUP_TEXT_AND_GRAPHICS_BASE_H__

View File

@ -467,6 +467,8 @@ void EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers )
} }
#define DIMENSION_PRECISION 1 // 0.001 mm
void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
{ {
if( !aGraphics ) if( !aGraphics )
@ -758,8 +760,10 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
dimension->SetLayer( layer ); dimension->SetLayer( layer );
// The origin and end are assumed to always be in this order from eagle // The origin and end are assumed to always be in this order from eagle
dimension->SetOrigin( wxPoint( kicad_x( d.x1 ), kicad_y( d.y1 ) ) ); dimension->SetOrigin( wxPoint( kicad_x( d.x1 ), kicad_y( d.y1 ) ),
dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ) ); DIMENSION_PRECISION );
dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ),
DIMENSION_PRECISION );
dimension->Text().SetTextSize( designSettings.GetTextSize( layer ) ); dimension->Text().SetTextSize( designSettings.GetTextSize( layer ) );
dimension->Text().SetThickness( designSettings.GetTextThickness( layer ) ); dimension->Text().SetThickness( designSettings.GetTextThickness( layer ) );
dimension->SetWidth( designSettings.GetLineThickness( layer ) ); dimension->SetWidth( designSettings.GetLineThickness( layer ) );
@ -770,11 +774,11 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
// Note the check is just if two axes are close enough to each other // Note the check is just if two axes are close enough to each other
// Eagle appears to have some rounding errors // Eagle appears to have some rounding errors
if( abs( ( d.x1 - d.x2 ).ToPcbUnits() ) < 50000 ) // 50000 nm = 0.05 mm if( abs( ( d.x1 - d.x2 ).ToPcbUnits() ) < 50000 ) // 50000 nm = 0.05 mm
dimension->SetHeight( kicad_x( d.x3 - d.x1 ) ); dimension->SetHeight( kicad_x( d.x3 - d.x1 ), DIMENSION_PRECISION );
else else
dimension->SetHeight( kicad_y( d.y3 - d.y1 ) ); dimension->SetHeight( kicad_y( d.y3 - d.y1 ), DIMENSION_PRECISION );
dimension->AdjustDimensionDetails(); dimension->AdjustDimensionDetails( DIMENSION_PRECISION );
} }
} }

View File

@ -446,12 +446,12 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
} }
void DRAWING_TOOL::constrainDimension( DIMENSION* dimension ) void DRAWING_TOOL::constrainDimension( DIMENSION* aDim )
{ {
const VECTOR2I lineVector{ dimension->GetEnd() - dimension->GetOrigin() }; const VECTOR2I lineVector{ aDim->GetEnd() - aDim->GetOrigin() };
dimension->SetEnd( wxPoint( aDim->SetEnd( wxPoint( VECTOR2I( aDim->GetOrigin() ) + GetVectorSnapped45( lineVector ) ),
VECTOR2I( dimension->GetOrigin() ) + GetVectorSnapped45( lineVector ) ) ); board()->GetDesignSettings().m_DimensionPrecision );
} }
@ -463,7 +463,9 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
POINT_EDITOR* pointEditor = m_toolMgr->GetTool<POINT_EDITOR>(); POINT_EDITOR* pointEditor = m_toolMgr->GetTool<POINT_EDITOR>();
DIMENSION* dimension = NULL; DIMENSION* dimension = NULL;
BOARD_COMMIT commit( m_frame ); BOARD_COMMIT commit( m_frame );
GRID_HELPER grid( m_frame ); GRID_HELPER grid( m_frame );
const BOARD_DESIGN_SETTINGS& boardSettings = m_board->GetDesignSettings();
// Add a VIEW_GROUP that serves as a preview for the new item // Add a VIEW_GROUP that serves as a preview for the new item
PCBNEW_SELECTION preview; PCBNEW_SELECTION preview;
@ -582,7 +584,6 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
PCB_LAYER_ID layer = getDrawingLayer(); PCB_LAYER_ID layer = getDrawingLayer();
const BOARD_DESIGN_SETTINGS& boardSettings = m_board->GetDesignSettings();
if( layer == Edge_Cuts ) // dimensions are not allowed on EdgeCuts if( layer == Edge_Cuts ) // dimensions are not allowed on EdgeCuts
layer = Dwgs_User; layer = Dwgs_User;
@ -590,14 +591,15 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
// Init the new item attributes // Init the new item attributes
dimension = new DIMENSION( m_board ); dimension = new DIMENSION( m_board );
dimension->SetLayer( layer ); dimension->SetLayer( layer );
dimension->SetOrigin( (wxPoint) cursorPos ); dimension->SetOrigin( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision );
dimension->SetEnd( (wxPoint) cursorPos ); dimension->SetEnd( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision );
dimension->Text().SetTextSize( boardSettings.GetTextSize( layer ) ); dimension->Text().SetTextSize( boardSettings.GetTextSize( layer ) );
dimension->Text().SetThickness( boardSettings.GetTextThickness( layer ) ); dimension->Text().SetThickness( boardSettings.GetTextThickness( layer ) );
dimension->Text().SetItalic( boardSettings.GetTextItalic( layer ) ); dimension->Text().SetItalic( boardSettings.GetTextItalic( layer ) );
dimension->SetWidth( boardSettings.GetLineThickness( layer ) ); dimension->SetWidth( boardSettings.GetLineThickness( layer ) );
dimension->SetUnits( m_frame->GetUserUnits(), false ); dimension->SetUnits( boardSettings.m_DimensionUnits == 2 ? MILLIMETRES : INCHES,
dimension->AdjustDimensionDetails(); boardSettings.m_DimensionUnits == 1 );
dimension->AdjustDimensionDetails( boardSettings.m_DimensionPrecision );
preview.Add( dimension ); preview.Add( dimension );
frame()->SetMsgPanel( dimension ); frame()->SetMsgPanel( dimension );
@ -608,7 +610,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
break; break;
case SET_END: case SET_END:
dimension->SetEnd( (wxPoint) cursorPos ); dimension->SetEnd( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision );
if( !!evt->Modifier( MD_CTRL ) ) if( !!evt->Modifier( MD_CTRL ) )
constrainDimension( dimension ); constrainDimension( dimension );
@ -649,7 +651,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
switch( step ) switch( step )
{ {
case SET_END: case SET_END:
dimension->SetEnd( (wxPoint) cursorPos ); dimension->SetEnd( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision );
if( !!evt->Modifier( MD_CTRL ) ) if( !!evt->Modifier( MD_CTRL ) )
constrainDimension( dimension ); constrainDimension( dimension );
@ -663,7 +665,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
wxPoint delta( (wxPoint) cursorPos - dimension->m_featureLineDO ); wxPoint delta( (wxPoint) cursorPos - dimension->m_featureLineDO );
double height = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) ); double height = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) );
dimension->SetHeight( height ); dimension->SetHeight( height, boardSettings.m_DimensionPrecision );
} }
break; break;
} }

View File

@ -212,7 +212,7 @@ private:
* Forces the dimension lime to be drawn on multiple of 45 degrees * Forces the dimension lime to be drawn on multiple of 45 degrees
* @param aDimension is the dimension element currently being drawn * @param aDimension is the dimension element currently being drawn
*/ */
void constrainDimension( DIMENSION* dimension ); void constrainDimension( DIMENSION* aDim );
///> Returns the appropriate width for a segment depending on the settings. ///> Returns the appropriate width for a segment depending on the settings.
int getSegmentWidth( PCB_LAYER_ID aLayer ) const; int getSegmentWidth( PCB_LAYER_ID aLayer ) const;

View File

@ -416,6 +416,8 @@ void POINT_EDITOR::updateItem() const
{ {
EDA_ITEM* item = m_editPoints->GetParent(); EDA_ITEM* item = m_editPoints->GetParent();
const BOARD_DESIGN_SETTINGS& boardSettings = board()->GetDesignSettings();
if( !item ) if( !item )
return; return;
@ -571,9 +573,9 @@ void POINT_EDITOR::updateItem() const
VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() ); VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
if( featureLine.Cross( crossBar ) > 0 ) if( featureLine.Cross( crossBar ) > 0 )
dimension->SetHeight( -featureLine.EuclideanNorm() ); dimension->SetHeight( -featureLine.EuclideanNorm(), boardSettings.m_DimensionPrecision );
else else
dimension->SetHeight( featureLine.EuclideanNorm() ); dimension->SetHeight( featureLine.EuclideanNorm(), boardSettings.m_DimensionPrecision );
} }
else if( isModified( m_editPoints->Point( DIM_CROSSBARF ) ) ) else if( isModified( m_editPoints->Point( DIM_CROSSBARF ) ) )
@ -582,14 +584,15 @@ void POINT_EDITOR::updateItem() const
VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() ); VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
if( featureLine.Cross( crossBar ) > 0 ) if( featureLine.Cross( crossBar ) > 0 )
dimension->SetHeight( -featureLine.EuclideanNorm() ); dimension->SetHeight( -featureLine.EuclideanNorm(), boardSettings.m_DimensionPrecision );
else else
dimension->SetHeight( featureLine.EuclideanNorm() ); dimension->SetHeight( featureLine.EuclideanNorm(), boardSettings.m_DimensionPrecision );
} }
else if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) ) else if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
{ {
dimension->SetOrigin( wxPoint( m_editedPoint->GetPosition().x, m_editedPoint->GetPosition().y ) ); dimension->SetOrigin( wxPoint( m_editedPoint->GetPosition().x, m_editedPoint->GetPosition().y ),
boardSettings.m_DimensionPrecision );
m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ), m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
m_editPoints->Point( DIM_FEATUREGO ) ) ); m_editPoints->Point( DIM_FEATUREGO ) ) );
m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ), m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
@ -598,7 +601,8 @@ void POINT_EDITOR::updateItem() const
else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) ) else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
{ {
dimension->SetEnd( wxPoint( m_editedPoint->GetPosition().x, m_editedPoint->GetPosition().y ) ); dimension->SetEnd( wxPoint( m_editedPoint->GetPosition().x, m_editedPoint->GetPosition().y ) ,
boardSettings.m_DimensionPrecision );
m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ), m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
m_editPoints->Point( DIM_FEATUREGO ) ) ); m_editPoints->Point( DIM_FEATUREGO ) ) );
m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ), m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),