Allow user-specification of dimension units.

Also fixes a units bug when round-tripping a dimension through
the file format.

Fixes: lp:1782797
* https://bugs.launchpad.net/kicad/+bug/1782797
This commit is contained in:
Jeff Young 2018-07-21 13:49:19 +01:00
parent 06ea7cdb79
commit 5c646119a7
13 changed files with 591 additions and 66 deletions

View File

@ -166,7 +166,7 @@ wxString MessageTextFromValue( EDA_UNITS_T aUnits, double aValue, bool aUseMils
text.Printf( format, value );
text += " ";
text += GetAbbreviatedUnitsLabel( aUnits );
text += GetAbbreviatedUnitsLabel( aUnits, aUseMils );
return text;
}
@ -367,6 +367,54 @@ double DoubleValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue, bo
}
void FetchUnitsFromString( const wxString& aTextValue, EDA_UNITS_T& aUnits, bool& aUseMils )
{
// Acquire the 'right' decimal point separator
const struct lconv* lc = localeconv();
wxChar decimal_point = lc->decimal_point[0];
wxString buf( aTextValue.Strip( wxString::both ) );
// Convert the period in decimal point
buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
// Find the end of the numeric part
unsigned brk_point = 0;
while( brk_point < buf.Len() )
{
wxChar ch = buf[brk_point];
if( !( (ch >= '0' && ch <='9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) )
break;
++brk_point;
}
// Check the unit designator (2 ch significant)
wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );
if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
{
aUnits = INCHES;
aUseMils = false;
}
else if( unit == wxT( "mm" ) )
{
aUnits = MILLIMETRES;
}
else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) // "mils" or "thou"
{
aUnits = INCHES;
aUseMils = true;
}
else if( unit == wxT( "de" ) || unit == wxT( "ra" ) ) // "deg" or "rad"
{
aUnits = DEGREES;
}
}
int ValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue, bool aUseMils )
{
double value = DoubleValueFromString( aUnits, aTextValue, aUseMils );
@ -390,31 +438,6 @@ wxString AngleToStringDegrees( double aAngle )
}
wxString GetUnitsLabel( EDA_UNITS_T aUnit, bool aUseMils )
{
switch( aUnit )
{
case INCHES:
if( aUseMils )
return _( "mils" );
else
return _( "inches" );
case MILLIMETRES:
return _( "millimeters" );
case UNSCALED_UNITS:
return _( "units" );
case DEGREES:
return _( "degrees" );
default:
return wxT( "??" );
}
}
wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit, bool aUseMils )
{
switch( aUnit )

View File

@ -163,15 +163,17 @@ double DoubleValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue,
int ValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue, bool aUseMils = false );
/**
* Get a human readable units string.
*
* The strings returned are full text name and not abbreviations or symbolic
* representations of the units. Use ReturnUnitSymbol() for that.
* Function FetchUnitsFromString
* writes any unit info found in the string to aUnits and aUseMils.
*/
void FetchUnitsFromString( const wxString& aTextValue, EDA_UNITS_T& aUnits, bool& aUseMils );
/**
* Get the units string for a given units type.
*
* @param aUnits - The units requested.
* @return The human readable units string.
*/
wxString GetUnitsLabel( EDA_UNITS_T aUnits, bool aUseMils = false );
wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit, bool aUseMils = false );

View File

@ -46,7 +46,12 @@
DIMENSION::DIMENSION( BOARD_ITEM* aParent ) :
BOARD_ITEM( aParent, PCB_DIMENSION_T ),
m_Width( Millimeter2iu( 0.2 ) ), m_Unit( INCHES ), m_Value( 0 ), m_Height( 0 ), m_Text( this )
m_Width( Millimeter2iu( 0.2 ) ),
m_Unit( INCHES ),
m_UseMils( false ),
m_Value( 0 ),
m_Height( 0 ),
m_Text( this )
{
m_Layer = Dwgs_User;
m_Shape = 0;
@ -206,7 +211,7 @@ void DIMENSION::UpdateHeight()
}
void DIMENSION::AdjustDimensionDetails( EDA_UNITS_T aUnits )
void DIMENSION::AdjustDimensionDetails()
{
const int arrowz = Mils2iu( 50 ); // size of arrows
int ii;
@ -216,9 +221,6 @@ void DIMENSION::AdjustDimensionDetails( EDA_UNITS_T aUnits )
int hx, hy; // dimension line interval
double angle, angle_f;
if( aUnits != UNSCALED_UNITS )
m_Unit = aUnits;
// Init layer :
m_Text.SetLayer( GetLayer() );
@ -317,7 +319,7 @@ void DIMENSION::AdjustDimensionDetails( EDA_UNITS_T aUnits )
m_Text.SetTextAngle( newAngle );
m_Value = measure;
SetText( MessageTextFromValue( m_Unit, m_Value ) );
SetText( MessageTextFromValue( m_Unit, m_Value, m_UseMils ) );
}

View File

@ -64,6 +64,7 @@ class DIMENSION : public BOARD_ITEM
int m_Width; ///< Line width
int m_Shape; ///< Currently always 0.
EDA_UNITS_T m_Unit; ///< 0 = inches, 1 = mm
bool m_UseMils; ///< If inches, use mils.
int m_Value; ///< value of PCB dimensions.
int m_Height; ///< length of feature lines
TEXTE_PCB m_Text;
@ -173,9 +174,20 @@ public:
/**
* Function AdjustDimensionDetails
* Calculate coordinates of segments used to draw the dimension.
* @param aUnits the units for the dimension text, or UNSCALED_UNITS to leave unchanged
*/
void AdjustDimensionDetails( EDA_UNITS_T aUnits = UNSCALED_UNITS );
void AdjustDimensionDetails();
void GetUnits( EDA_UNITS_T& aUnits, bool& aUseMils ) const
{
aUnits = m_Unit;
aUseMils = m_UseMils;
}
void SetUnits( EDA_UNITS_T aUnits, bool aUseMils )
{
m_Unit = aUnits;
m_UseMils = aUseMils;
}
void SetText( const wxString& NewText );
const wxString GetText() const;

View File

@ -61,8 +61,7 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO
m_posY( aParent, m_PositionYLabel, m_PositionYCtrl, m_PositionYUnits ),
m_OrientValidator( 1, &m_OrientValue )
{
wxString title, label;
bool multiLine = false;
wxString title;
if( m_item->Type() == PCB_DIMENSION_T )
{
@ -72,9 +71,12 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO
m_edaText = &dimension->Text();
m_pcbText = &dimension->Text();
label = _( "Dimension text:" );
SetInitialFocus( m_DimensionText );
m_SingleLineSizer->Show( false );
m_MultiLineSizer->Show( false );
m_KeepUpright->Show( false );
m_statusLine->Show( false );
}
else if( m_item->Type() == PCB_MODULE_TEXT_T )
{
@ -85,10 +87,14 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO
switch( m_modText->GetType() )
{
case TEXTE_MODULE::TEXT_is_REFERENCE: label = _( "Reference:" ); break;
case TEXTE_MODULE::TEXT_is_VALUE: label = _( "Value:" ); break;
case TEXTE_MODULE::TEXT_is_DIVERS: label = _( "Text:" ); break;
case TEXTE_MODULE::TEXT_is_REFERENCE: m_TextLabel->SetLabel( _( "Reference:" ) ); break;
case TEXTE_MODULE::TEXT_is_VALUE: m_TextLabel->SetLabel( _( "Value:" ) ); break;
case TEXTE_MODULE::TEXT_is_DIVERS: m_TextLabel->SetLabel( _( "Text:" ) ); break;
}
SetInitialFocus( m_SingleLineText );
m_MultiLineSizer->Show( false );
m_DimensionTextSizer->Show( false );
}
else
{
@ -96,19 +102,18 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO
m_pcbText = (TEXTE_PCB*) aItem;
m_edaText = static_cast<EDA_TEXT*>( m_pcbText );
multiLine = true;
SetInitialFocus( m_MultiLineText );
m_SingleLineSizer->Show( false );
m_DimensionTextSizer->Show( false );
m_KeepUpright->Show( false );
m_statusLine->Show( false );
}
SetTitle( title );
m_hash_key = title;
m_TextLabel->SetLabel( label );
m_SingleLineSizer->Show( !multiLine );
m_MultiLineSizer->Show( multiLine );
SetInitialFocus( multiLine ? m_MultiLineText : m_SingleLineText );
// Configure the layers list selector. Note that footprints are built outside the current
// board and so we may need to show all layers if the text is on an unactivated layer.
if( !m_Parent->GetBoard()->IsLayerEnabled( m_item->GetLayer() ) )
@ -190,24 +195,70 @@ void DIALOG_TEXT_PROPERTIES::OnCharHook( wxKeyEvent& aEvent )
}
void DIALOG_TEXT_PROPERTIES::OnDimensionTextChange( wxCommandEvent& event )
{
EDA_UNITS_T units = UNSCALED_UNITS;
bool useMils;
FetchUnitsFromString( m_DimensionText->GetValue(), units, useMils );
if( units != UNSCALED_UNITS )
m_DimensionUnitsOpt->SetSelection( units == MILLIMETRES ? 2 : useMils ? 1 : 0 );
}
void DIALOG_TEXT_PROPERTIES::OnDimensionUnitsChange( wxCommandEvent& event )
{
DIMENSION* dimension = (DIMENSION*) m_item;
EDA_UNITS_T units;
bool useMils;
// Get default units in case dimension text doesn't contain units.
dimension->GetUnits( units, useMils );
double value = ValueFromString( units, m_DimensionText->GetValue(), useMils );
switch( event.GetSelection() )
{
case 0: units = INCHES; useMils = false; break;
case 1: units = INCHES; useMils = true; break;
case 2: units = MILLIMETRES; useMils = false; break;
default: break;
}
m_DimensionText->SetValue( StringFromValue( units, value, true, useMils ) );
}
bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
{
wxString msg;
if( m_SingleLineText->IsShown() )
{
m_SingleLineText->SetValue( m_edaText->GetText() );
m_SingleLineText->SetSelection( -1, -1 );
}
else
else if( m_MultiLineText->IsShown() )
{
m_MultiLineText->SetValue( m_edaText->GetText() );
m_MultiLineText->SetSelection( -1, -1 );
}
else if (m_DimensionText->IsShown() )
{
m_DimensionText->SetValue( m_edaText->GetText() );
m_DimensionText->SetSelection( -1, -1 );
DIMENSION* dimension = (DIMENSION*) m_item;
EDA_UNITS_T units;
bool useMils;
dimension->GetUnits( units, useMils );
m_DimensionUnitsOpt->SetSelection( units == MILLIMETRES ? 2 : useMils ? 1 : 0 );
}
if( m_item->Type() == PCB_MODULE_TEXT_T )
{
MODULE* module = dynamic_cast<MODULE*>( m_modText->GetParent() );
MODULE* module = dynamic_cast<MODULE*>( m_modText->GetParent() );
wxString msg;
if( module )
{
@ -217,9 +268,13 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
module->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ),
module->GetOrientation() / 10.0 );
}
}
m_statusLine->SetLabel( msg );
m_statusLine->SetLabel( msg );
}
else
{
m_statusLine->Show( false );
}
m_LayerSelectionCtrl->SetLayerSelection( m_item->GetLayer() );
@ -285,10 +340,31 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
#endif
// Set the new text content
if( m_SingleLineText->IsShown() && !m_SingleLineText->GetValue().IsEmpty() )
m_edaText->SetText( m_SingleLineText->GetValue() );
else if( m_MultiLineText->IsShown() && !m_MultiLineText->GetValue().IsEmpty() )
m_edaText->SetText( m_MultiLineText->GetValue() );
if( m_SingleLineText->IsShown() )
{
if( !m_SingleLineText->GetValue().IsEmpty() )
m_edaText->SetText( m_SingleLineText->GetValue() );
}
else if( m_MultiLineText->IsShown() )
{
if( !m_MultiLineText->GetValue().IsEmpty() )
m_edaText->SetText( m_MultiLineText->GetValue() );
}
else if( m_DimensionText->IsShown() )
{
if( !m_DimensionText->GetValue().IsEmpty() )
m_edaText->SetText( m_DimensionText->GetValue() );
DIMENSION* dimension = (DIMENSION*) m_item;
switch( m_DimensionUnitsOpt->GetSelection() )
{
case 0: dimension->SetUnits( INCHES, false ); break;
case 1: dimension->SetUnits( INCHES, true ); break;
case 2: dimension->SetUnits( MILLIMETRES, false ); break;
default: break;
}
}
m_item->SetLayer( ToLAYER_ID( m_LayerSelectionCtrl->GetLayerSelection() ) );
@ -304,7 +380,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
if( m_edaText->GetThickness() > maxthickness )
{
DisplayError( NULL, _( "The text thickness is too large for the text size.\n"
DisplayError( this, _( "The text thickness is too large for the text size.\n"
"It will be clamped." ) );
m_edaText->SetThickness( maxthickness );
}

View File

@ -61,6 +61,8 @@ private:
bool TransferDataFromWindow() override;
void OnCharHook( wxKeyEvent& aEvent );
void OnDimensionTextChange( wxCommandEvent& event ) override;
void OnDimensionUnitsChange( wxCommandEvent& event ) override;
};

View File

@ -46,6 +46,31 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
bMainSizer->Add( m_SingleLineSizer, 0, wxEXPAND|wxALL, 10 );
m_DimensionTextSizer = new wxFlexGridSizer( 0, 4, 1, 5 );
m_DimensionTextSizer->AddGrowableCol( 1 );
m_DimensionTextSizer->SetFlexibleDirection( wxBOTH );
m_DimensionTextSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_DimensionTextLabel = new wxStaticText( this, wxID_ANY, _("Dimension text:"), wxDefaultPosition, wxDefaultSize, 0 );
m_DimensionTextLabel->Wrap( -1 );
m_DimensionTextSizer->Add( m_DimensionTextLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
m_DimensionText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DimensionTextSizer->Add( m_DimensionText, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_staticText18 = new wxStaticText( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText18->Wrap( -1 );
m_DimensionTextSizer->Add( m_staticText18, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
wxString m_DimensionUnitsOptChoices[] = { _("Inches"), _("Mils"), _("Millimeters") };
int m_DimensionUnitsOptNChoices = sizeof( m_DimensionUnitsOptChoices ) / sizeof( wxString );
m_DimensionUnitsOpt = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_DimensionUnitsOptNChoices, m_DimensionUnitsOptChoices, 0 );
m_DimensionUnitsOpt->SetSelection( 0 );
m_DimensionTextSizer->Add( m_DimensionUnitsOpt, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
bMainSizer->Add( m_DimensionTextSizer, 0, wxEXPAND|wxALL, 10 );
wxFlexGridSizer* fgSizerSetup;
fgSizerSetup = new wxFlexGridSizer( 0, 5, 4, 0 );
fgSizerSetup->AddGrowableCol( 1 );
@ -206,6 +231,8 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
// Connect Events
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnInitDlg ) );
m_SingleLineText->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_DimensionText->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnDimensionTextChange ), NULL, this );
m_DimensionUnitsOpt->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnDimensionUnitsChange ), NULL, this );
m_SizeXCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_SizeYCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_ThicknessCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
@ -220,6 +247,8 @@ DIALOG_TEXT_PROPERTIES_BASE::~DIALOG_TEXT_PROPERTIES_BASE()
// Disconnect Events
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnInitDlg ) );
m_SingleLineText->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_DimensionText->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnDimensionTextChange ), NULL, this );
m_DimensionUnitsOpt->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnDimensionUnitsChange ), NULL, this );
m_SizeXCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_SizeYCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_ThicknessCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );

View File

@ -463,6 +463,369 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">4</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property>
<property name="growablerows"></property>
<property name="hgap">5</property>
<property name="minimum_size"></property>
<property name="name">m_DimensionTextSizer</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">protected</property>
<property name="rows">0</property>
<property name="vgap">1</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT</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">Dimension text:</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_DimensionTextLabel</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>
<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 class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" 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="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></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_DimensionText</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="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></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="OnText">OnDimensionTextChange</event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT</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="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_staticText18</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>
<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 class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT</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">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_DimensionUnitsOpt</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>
<event name="OnChar"></event>
<event name="OnChoice">OnDimensionUnitsChange</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="1">
<property name="border">10</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>

View File

@ -22,9 +22,9 @@ class PCB_LAYER_BOX_SELECTOR;
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/choice.h>
#include <wx/bmpcbox.h>
#include <wx/checkbox.h>
#include <wx/choice.h>
#include <wx/combobox.h>
#include <wx/statline.h>
#include <wx/button.h>
@ -46,6 +46,11 @@ class DIALOG_TEXT_PROPERTIES_BASE : public DIALOG_SHIM
wxBoxSizer* m_SingleLineSizer;
wxStaticText* m_TextLabel;
wxTextCtrl* m_SingleLineText;
wxFlexGridSizer* m_DimensionTextSizer;
wxStaticText* m_DimensionTextLabel;
wxTextCtrl* m_DimensionText;
wxStaticText* m_staticText18;
wxChoice* m_DimensionUnitsOpt;
wxStaticText* m_LayerLabel;
PCB_LAYER_BOX_SELECTOR* m_LayerSelectionCtrl;
wxCheckBox* m_Visible;
@ -80,6 +85,8 @@ class DIALOG_TEXT_PROPERTIES_BASE : public DIALOG_SHIM
// Virtual event handlers, overide them in your derived class
virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDimensionTextChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDimensionUnitsChange( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -115,7 +115,7 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC )
aDimension->Text().SetThickness( boardSettings.GetTextThickness( GetActiveLayer() ) );
aDimension->Text().SetItalic( boardSettings.GetTextItalic( GetActiveLayer() ) );
aDimension->SetWidth( boardSettings.GetLineThickness( GetActiveLayer() ) );
aDimension->AdjustDimensionDetails( GetUserUnits() );
aDimension->AdjustDimensionDetails();
aDimension->Draw( m_canvas, aDC, GR_XOR );
m_canvas->SetMouseCapture( BuildDimension, AbortBuildDimension );

View File

@ -756,6 +756,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
dimension->Text().SetTextSize( designSettings.GetTextSize( layer ) );
dimension->Text().SetThickness( designSettings.GetTextThickness( layer ) );
dimension->SetWidth( designSettings.GetLineThickness( layer ) );
dimension->SetUnits( MILLIMETRES, false );
// check which axis the dimension runs in
// because the "height" of the dimension is perpendicular to that axis
@ -766,7 +767,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
else
dimension->SetHeight( kicad_y( d.y3 - d.y1 ) );
dimension->AdjustDimensionDetails( MILLIMETRES );
dimension->AdjustDimensionDetails();
}
}

View File

@ -1649,12 +1649,19 @@ DIMENSION* PCB_PARSER::parseDIMENSION()
case T_gr_text:
{
TEXTE_PCB* text = parseTEXTE_PCB();
// This copy (using the copy constructor) rebuild the text timestamp,
// that is not what we want.
dimension->Text() = *text;
// reinitialises the text time stamp to the right value (the dimension time stamp)
dimension->Text().SetTimeStamp( dimension->GetTimeStamp() );
dimension->SetPosition( text->GetTextPos() );
EDA_UNITS_T units = INCHES;
bool useMils = false;
FetchUnitsFromString( text->GetText(), units, useMils );
dimension->SetUnits( units, useMils );
delete text;
break;
}

View File

@ -581,7 +581,8 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
dimension->Text().SetThickness( boardSettings.GetTextThickness( layer ) );
dimension->Text().SetItalic( boardSettings.GetTextItalic( layer ) );
dimension->SetWidth( boardSettings.GetLineThickness( layer ) );
dimension->AdjustDimensionDetails( m_frame->GetUserUnits() );
dimension->SetUnits( m_frame->GetUserUnits(), false );
dimension->AdjustDimensionDetails();
preview.Add( dimension );
frame()->SetMsgPanel( dimension );