Add automatic precision choices for dimensions.
Fixes https://gitlab.com/kicad/code/kicad/issues/6690
This commit is contained in:
parent
38c54ffa8f
commit
9b087a3c25
|
@ -169,7 +169,7 @@ DIALOG_DIMENSION_PROPERTIES_BASE::DIALOG_DIMENSION_PROPERTIES_BASE( wxWindow* pa
|
||||||
|
|
||||||
gbSizerFormat->Add( m_lblPrecision, wxGBPosition( 2, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
gbSizerFormat->Add( m_lblPrecision, wxGBPosition( 2, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||||
|
|
||||||
wxString m_cbPrecisionChoices[] = { _("0"), _("0.0"), _("0.00"), _("0.000"), _("0.0000"), _("0.00000") };
|
wxString m_cbPrecisionChoices[] = { _("0"), _("0.0"), _("0.00"), _("0.000"), _("0.0000"), _("0.00000"), _("0.00 in / 0 mils / 0.0 mm"), _("0.000 / 0 / 0.00"), _("0.0000 / 0.0 / 0.000"), _("0.00000 / 0.00 / 0.0000") };
|
||||||
int m_cbPrecisionNChoices = sizeof( m_cbPrecisionChoices ) / sizeof( wxString );
|
int m_cbPrecisionNChoices = sizeof( m_cbPrecisionChoices ) / sizeof( wxString );
|
||||||
m_cbPrecision = new wxChoice( m_sizerFormat->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_cbPrecisionNChoices, m_cbPrecisionChoices, 0 );
|
m_cbPrecision = new wxChoice( m_sizerFormat->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_cbPrecisionNChoices, m_cbPrecisionChoices, 0 );
|
||||||
m_cbPrecision->SetSelection( 0 );
|
m_cbPrecision->SetSelection( 0 );
|
||||||
|
|
|
@ -1508,7 +1508,7 @@
|
||||||
<property name="caption"></property>
|
<property name="caption"></property>
|
||||||
<property name="caption_visible">1</property>
|
<property name="caption_visible">1</property>
|
||||||
<property name="center_pane">0</property>
|
<property name="center_pane">0</property>
|
||||||
<property name="choices">"0" "0.0" "0.00" "0.000" "0.0000" "0.00000"</property>
|
<property name="choices">"0" "0.0" "0.00" "0.000" "0.0000" "0.00000" "0.00 in / 0 mils / 0.0 mm" "0.000 / 0 / 0.00" "0.0000 / 0.0 / 0.000" "0.00000 / 0.00 / 0.0000"</property>
|
||||||
<property name="close_button">1</property>
|
<property name="close_button">1</property>
|
||||||
<property name="context_help"></property>
|
<property name="context_help"></property>
|
||||||
<property name="context_menu">1</property>
|
<property name="context_menu">1</property>
|
||||||
|
|
|
@ -219,9 +219,10 @@ void PCB_BASE_EDIT_FRAME::unitsChangeRefresh()
|
||||||
{
|
{
|
||||||
EDA_UNITS units = GetUserUnits();
|
EDA_UNITS units = GetUserUnits();
|
||||||
KIGFX::VIEW* view = GetCanvas()->GetView();
|
KIGFX::VIEW* view = GetCanvas()->GetView();
|
||||||
|
bool selectedItemModified = false;
|
||||||
|
|
||||||
INSPECTOR_FUNC inspector =
|
INSPECTOR_FUNC inspector =
|
||||||
[units, view]( EDA_ITEM* aItem, void* aTestData )
|
[units, view, &selectedItemModified]( EDA_ITEM* aItem, void* aTestData )
|
||||||
{
|
{
|
||||||
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( aItem );
|
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( aItem );
|
||||||
|
|
||||||
|
@ -229,6 +230,10 @@ void PCB_BASE_EDIT_FRAME::unitsChangeRefresh()
|
||||||
{
|
{
|
||||||
dimension->SetUnits( units );
|
dimension->SetUnits( units );
|
||||||
dimension->Update();
|
dimension->Update();
|
||||||
|
|
||||||
|
if( dimension->IsSelected() )
|
||||||
|
selectedItemModified = true;
|
||||||
|
|
||||||
view->Update( dimension );
|
view->Update( dimension );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,6 +241,9 @@ void PCB_BASE_EDIT_FRAME::unitsChangeRefresh()
|
||||||
};
|
};
|
||||||
|
|
||||||
board->Visit( inspector, nullptr, GENERAL_COLLECTOR::Dimensions );
|
board->Visit( inspector, nullptr, GENERAL_COLLECTOR::Dimensions );
|
||||||
|
|
||||||
|
if( selectedItemModified )
|
||||||
|
m_toolManager->PostEvent( EVENTS::SelectedItemsModified );
|
||||||
}
|
}
|
||||||
|
|
||||||
ReCreateAuxiliaryToolbar();
|
ReCreateAuxiliaryToolbar();
|
||||||
|
|
|
@ -109,8 +109,21 @@ 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;
|
||||||
wxString text;
|
wxString text;
|
||||||
wxString format = wxT( "%." ) + wxString::Format( wxT( "%i" ), m_precision ) + wxT( "f" );
|
|
||||||
|
if( precision >= 6 )
|
||||||
|
{
|
||||||
|
switch( m_units )
|
||||||
|
{
|
||||||
|
case EDA_UNITS::INCHES: precision = precision - 4; break;
|
||||||
|
case EDA_UNITS::MILS: precision = std::max( 0, precision - 7 ); break;
|
||||||
|
case EDA_UNITS::MILLIMETRES: precision = precision - 5; break;
|
||||||
|
default: precision = precision - 4; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString format = wxT( "%." ) + wxString::Format( wxT( "%i" ), precision ) + wxT( "f" );
|
||||||
|
|
||||||
text.Printf( format, To_User_Unit( m_units, val ) );
|
text.Printf( format, To_User_Unit( m_units, val ) );
|
||||||
|
|
||||||
|
@ -294,7 +307,24 @@ void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
|
||||||
{
|
{
|
||||||
aList.emplace_back( _( "Value" ), GetValueText() );
|
aList.emplace_back( _( "Value" ), GetValueText() );
|
||||||
|
|
||||||
msg = wxT( "%" ) + wxString::Format( wxT( "1.%df" ), GetPrecision() );
|
switch( GetPrecision() )
|
||||||
|
{
|
||||||
|
case 6:
|
||||||
|
msg = wxT( "0.00 in / 0 mils / 0.0 mm" );
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
msg = wxT( "0.000 in / 0 mils / 0.00 mm" );
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
msg = wxT( "0.0000 in / 0.0 mils / 0.000 mm" );
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
msg = wxT( "0.00000 in / 0.00 mils / 0.0000 mm" );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
msg = wxT( "%" ) + wxString::Format( wxT( "1.%df" ), GetPrecision() );
|
||||||
|
}
|
||||||
|
|
||||||
aList.emplace_back( _( "Precision" ), wxString::Format( msg, 0.0 ) );
|
aList.emplace_back( _( "Precision" ), wxString::Format( msg, 0.0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,8 @@ class SHAPE_LINE_CHAIN;
|
||||||
//#define SEXPR_BOARD_FILE_VERSION 20220211 // End support for V5 zone fill strategy
|
//#define SEXPR_BOARD_FILE_VERSION 20220211 // End support for V5 zone fill strategy
|
||||||
//#define SEXPR_BOARD_FILE_VERSION 20220225 // Remove TEDIT
|
//#define SEXPR_BOARD_FILE_VERSION 20220225 // Remove TEDIT
|
||||||
//#define SEXPR_BOARD_FILE_VERSION 20220308 // Knockout text and Locked graphic text property saved
|
//#define SEXPR_BOARD_FILE_VERSION 20220308 // Knockout text and Locked graphic text property saved
|
||||||
#define SEXPR_BOARD_FILE_VERSION 20220331 // Plot on all layers selection setting.
|
//#define SEXPR_BOARD_FILE_VERSION 20220331 // Plot on all layers selection setting
|
||||||
|
#define SEXPR_BOARD_FILE_VERSION 20220417 // Automatic dimension precisions
|
||||||
|
|
||||||
#define BOARD_FILE_HOST_VERSION 20200825 ///< Earlier files than this include the host tag
|
#define BOARD_FILE_HOST_VERSION 20200825 ///< Earlier files than this include the host tag
|
||||||
#define LEGACY_ARC_FORMATTING 20210925 ///< These were the last to use old arc formatting
|
#define LEGACY_ARC_FORMATTING 20210925 ///< These were the last to use old arc formatting
|
||||||
|
|
Loading…
Reference in New Issue