From 45dad4ded570226ff50566e3d7d73c61956f66fe Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 18 May 2018 13:24:02 +0200 Subject: [PATCH] DIALOG_POSITION_RELATIVE: make dialog more understandable. Better texts, and add a helper comment. --- pcbnew/dialogs/dialog_position_relative.cpp | 17 +- pcbnew/dialogs/dialog_position_relative.h | 2 +- .../dialogs/dialog_position_relative_base.cpp | 35 +- .../dialogs/dialog_position_relative_base.fbp | 420 +++++++++++++----- .../dialogs/dialog_position_relative_base.h | 13 +- pcbnew/tools/position_relative_tool.cpp | 6 +- 6 files changed, 351 insertions(+), 142 deletions(-) diff --git a/pcbnew/dialogs/dialog_position_relative.cpp b/pcbnew/dialogs/dialog_position_relative.cpp index 94693b335e..f7df25d0c8 100644 --- a/pcbnew/dialogs/dialog_position_relative.cpp +++ b/pcbnew/dialogs/dialog_position_relative.cpp @@ -58,6 +58,9 @@ DIALOG_POSITION_RELATIVE::DIALOG_POSITION_RELATIVE( PCB_BASE_FRAME* aParent, TOO m_rotEntry->SetValue( wxString::FromDouble( m_options.entryRotation ) ); updateDlgTexts( m_polarCoords->IsChecked() ); + PutValueInLocalUnits( *m_anchor_x, m_anchor_position.x ); + PutValueInLocalUnits( *m_anchor_y, m_anchor_position.y ); + m_stdButtonsOK->SetDefault(); GetSizer()->SetSizeHints( this ); @@ -138,15 +141,15 @@ void DIALOG_POSITION_RELATIVE::updateDlgTexts( bool aPolar ) { if( aPolar ) { - m_xLabel->SetLabelText( _( "Distance:" ) ); // Polar radius + m_xLabel->SetLabelText( _( "Distance from anchor:" ) ); // Polar radius m_yLabel->SetLabelText( _( "Angle:" ) ); // Polar theta or angle m_yUnit->SetLabelText( GetAbbreviatedUnitsLabel( DEGREES ) ); } else { - m_xLabel->SetLabelText( _( "Move vector X:" ) ); - m_yLabel->SetLabelText( _( "Move vector Y:" ) ); + m_xLabel->SetLabelText( _( "Position from anchor X:" ) ); + m_yLabel->SetLabelText( _( "Position from anchor Y:" ) ); m_yUnit->SetLabelText( GetAbbreviatedUnitsLabel( g_UserUnit ) ); } @@ -187,11 +190,11 @@ void DIALOG_POSITION_RELATIVE::OnSelectItemClick( wxCommandEvent& event ) } -void DIALOG_POSITION_RELATIVE::UpdateAnchor( BOARD_ITEM* aBoardItem ) +void DIALOG_POSITION_RELATIVE::UpdateAnchor( const wxPoint& aPosition ) { - m_anchor_position = aBoardItem->GetPosition(); - PutValueInLocalUnits( *m_anchor_x, m_anchor_position.x ); - PutValueInLocalUnits( *m_anchor_y, m_anchor_position.y ); + m_anchor_position = aPosition; + PutValueInLocalUnits( *m_anchor_x, aPosition.x ); + PutValueInLocalUnits( *m_anchor_y, aPosition.y ); } diff --git a/pcbnew/dialogs/dialog_position_relative.h b/pcbnew/dialogs/dialog_position_relative.h index 2adaf0c0c6..3e4160a5d2 100644 --- a/pcbnew/dialogs/dialog_position_relative.h +++ b/pcbnew/dialogs/dialog_position_relative.h @@ -46,7 +46,7 @@ public: double& rotation, wxPoint& anchorposition ); ~DIALOG_POSITION_RELATIVE(); - void UpdateAnchor( BOARD_ITEM* aBoardItem ); + void UpdateAnchor( const wxPoint& aPosition ); private: diff --git a/pcbnew/dialogs/dialog_position_relative_base.cpp b/pcbnew/dialogs/dialog_position_relative_base.cpp index b230272ba3..7d2b160eeb 100644 --- a/pcbnew/dialogs/dialog_position_relative_base.cpp +++ b/pcbnew/dialogs/dialog_position_relative_base.cpp @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Jul 2 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO *NOT* EDIT THIS FILE! +// PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #include "widgets/text_ctrl_eval.h" @@ -18,7 +18,15 @@ DIALOG_POSITION_RELATIVE_BASE::DIALOG_POSITION_RELATIVE_BASE( wxWindow* parent, wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); + m_staticTextHelp = new wxStaticText( this, wxID_ANY, _("The Anchor position is the origin of coordinates for the transform."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextHelp->Wrap( -1 ); + bMainSizer->Add( m_staticTextHelp, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bMainSizer->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 ); + m_polarCoords = new wxCheckBox( this, wxID_ANY, _("Use polar coordinates"), wxDefaultPosition, wxDefaultSize, 0 ); + m_polarCoords->SetValue(true); bMainSizer->Add( m_polarCoords, 0, wxALL|wxEXPAND, 5 ); wxFlexGridSizer* fgSizer2; @@ -69,18 +77,20 @@ DIALOG_POSITION_RELATIVE_BASE::DIALOG_POSITION_RELATIVE_BASE( wxWindow* parent, m_clearRot = new wxButton( this, wxID_ANY, _("Reset"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); fgSizer2->Add( m_clearRot, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_anchor_xLabel = new wxStaticText( this, wxID_ANY, _("Anchor X:"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); + m_anchor_xLabel = new wxStaticText( this, wxID_ANY, _("Anchor position X:"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); m_anchor_xLabel->Wrap( -1 ); + m_anchor_xLabel->SetToolTip( _("The Anchor position is the origin of coordinates for the transform.") ); + fgSizer2->Add( m_anchor_xLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - m_anchor_x = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_anchor_x = new TEXT_CTRL_EVAL( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); fgSizer2->Add( m_anchor_x, 0, wxALL, 5 ); m_anchor_yLabel = new wxStaticText( this, wxID_ANY, _("Y:"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); m_anchor_yLabel->Wrap( -1 ); fgSizer2->Add( m_anchor_yLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - m_anchor_y = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_anchor_y = new TEXT_CTRL_EVAL( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); fgSizer2->Add( m_anchor_y, 0, wxALL, 5 ); @@ -89,8 +99,14 @@ DIALOG_POSITION_RELATIVE_BASE::DIALOG_POSITION_RELATIVE_BASE( wxWindow* parent, m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); - m_select_anchor_button = new wxButton( this, wxID_ANY, _("Select Anchor Item"), wxDefaultPosition, wxDefaultSize, 0 ); - bMainSizer->Add( m_select_anchor_button, 0, wxALL, 5 ); + wxBoxSizer* bSizerBottom; + bSizerBottom = new wxBoxSizer( wxHORIZONTAL ); + + m_select_anchor_button = new wxButton( this, wxID_ANY, _("Select Anchor Position"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerBottom->Add( m_select_anchor_button, 0, wxALL, 5 ); + + + bSizerBottom->Add( 0, 0, 1, wxEXPAND, 5 ); m_stdButtons = new wxStdDialogButtonSizer(); m_stdButtonsOK = new wxButton( this, wxID_OK ); @@ -99,7 +115,10 @@ DIALOG_POSITION_RELATIVE_BASE::DIALOG_POSITION_RELATIVE_BASE( wxWindow* parent, m_stdButtons->AddButton( m_stdButtonsCancel ); m_stdButtons->Realize(); - bMainSizer->Add( m_stdButtons, 0, wxALL|wxEXPAND, 5 ); + bSizerBottom->Add( m_stdButtons, 0, wxALL|wxEXPAND, 5 ); + + + bMainSizer->Add( bSizerBottom, 0, wxEXPAND, 5 ); this->SetSizer( bMainSizer ); diff --git a/pcbnew/dialogs/dialog_position_relative_base.fbp b/pcbnew/dialogs/dialog_position_relative_base.fbp index 81fcd68870..0c28c12aad 100644 --- a/pcbnew/dialogs/dialog_position_relative_base.fbp +++ b/pcbnew/dialogs/dialog_position_relative_base.fbp @@ -14,7 +14,6 @@ dialog_position_relative_base 1000 none - 1 DIALOG_POSITION_RELATIVE_BASE @@ -94,6 +93,170 @@ bMainSizer wxVERTICAL none + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + The Anchor position is the origin of coordinates for the transform. + + 0 + + + 0 + + 1 + m_staticTextHelp + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline2 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxALL|wxEXPAND @@ -112,7 +275,7 @@ 1 0 - 0 + 1 1 1 @@ -316,7 +479,7 @@ 0 - + 0 0 @@ -661,7 +824,7 @@ 0 - + 0 0 @@ -1265,7 +1428,7 @@ 0 0 wxID_ANY - Anchor X: + Anchor position X: 0 @@ -1286,7 +1449,7 @@ 0 - + The Anchor position is the origin of coordinates for the transform. @@ -1351,7 +1514,7 @@ 0 - + 0 0 @@ -1374,7 +1537,7 @@ wxFILTER_NONE wxDefaultValidator - + 0 @@ -1525,7 +1688,7 @@ 0 - + 0 0 @@ -1548,7 +1711,7 @@ wxFILTER_NONE wxDefaultValidator - + 0 @@ -1666,116 +1829,137 @@ 5 - wxALL + wxEXPAND 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Select Anchor Item - - 0 - - - 0 + - 1 - m_select_anchor_button - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnSelectItemClick - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_stdButtons - protected - - - - - - OnOkClick - - + bSizerBottom + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Select Anchor Position + + 0 + + + 0 + + 1 + m_select_anchor_button + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSelectItemClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_stdButtons + protected + + + + + + OnOkClick + + + + diff --git a/pcbnew/dialogs/dialog_position_relative_base.h b/pcbnew/dialogs/dialog_position_relative_base.h index 84a0b611cd..361d97fbf7 100644 --- a/pcbnew/dialogs/dialog_position_relative_base.h +++ b/pcbnew/dialogs/dialog_position_relative_base.h @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Jul 2 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO *NOT* EDIT THIS FILE! +// PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #ifndef __DIALOG_POSITION_RELATIVE_BASE_H__ @@ -11,20 +11,21 @@ #include #include #include +class DIALOG_SHIM; class TEXT_CTRL_EVAL; #include "dialog_shim.h" #include -#include +#include #include #include #include #include -#include +#include +#include #include #include #include -#include #include /////////////////////////////////////////////////////////////////////////// @@ -38,6 +39,8 @@ class DIALOG_POSITION_RELATIVE_BASE : public DIALOG_SHIM private: protected: + wxStaticText* m_staticTextHelp; + wxStaticLine* m_staticline2; wxCheckBox* m_polarCoords; wxStaticText* m_xLabel; TEXT_CTRL_EVAL* m_xEntry; diff --git a/pcbnew/tools/position_relative_tool.cpp b/pcbnew/tools/position_relative_tool.cpp index 2dc0697e5a..8cf43bd481 100644 --- a/pcbnew/tools/position_relative_tool.cpp +++ b/pcbnew/tools/position_relative_tool.cpp @@ -41,8 +41,8 @@ using namespace std::placeholders; TOOL_ACTION PCB_ACTIONS::positionRelative( "pcbnew.PositionRelative.positionRelative", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_POSITION_RELATIVE ), - _( "Position Relative To..." ), _( - "Positions the selected item(s) by an exact amount relative to another" ), + _( "Position Relative To..." ), + _( "Positions the selected item(s) by an exact amount relative to another" ), move_relative_xpm ); @@ -180,7 +180,7 @@ void POSITION_RELATIVE_TOOL::UpdateAnchor( BOARD_ITEM* aItem ) m_anchor_item = aItem; if( m_position_relative_dialog ) - m_position_relative_dialog->UpdateAnchor( aItem ); + m_position_relative_dialog->UpdateAnchor( aItem->GetPosition() ); }