From 2ff414adb41a7294bd3de39ff9028e7315ad3d61 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 12 Jun 2018 08:36:35 +0100 Subject: [PATCH] Simplify Move Exactly and Postion Relative dialogs. Also removes g_UserUnit references. Fixes: lp:1660154 * https://bugs.launchpad.net/kicad/+bug/1660154 (cherry picked from commit 1639636) --- common/widgets/unit_binder.cpp | 6 + include/widgets/unit_binder.h | 2 + pcbnew/block_footprint_editor.cpp | 27 +- pcbnew/dialogs/dialog_move_exact.cpp | 270 +- pcbnew/dialogs/dialog_move_exact.h | 79 +- pcbnew/dialogs/dialog_move_exact_base.cpp | 100 +- pcbnew/dialogs/dialog_move_exact_base.fbp | 2237 ++++++++--------- pcbnew/dialogs/dialog_move_exact_base.h | 33 +- pcbnew/dialogs/dialog_position_relative.cpp | 120 +- pcbnew/dialogs/dialog_position_relative.h | 33 +- .../dialogs/dialog_position_relative_base.cpp | 127 +- .../dialogs/dialog_position_relative_base.fbp | 1138 ++------- .../dialogs/dialog_position_relative_base.h | 37 +- pcbnew/edit.cpp | 52 +- pcbnew/footprint_editor_utils.cpp | 47 +- pcbnew/tools/edit_tool.cpp | 117 +- pcbnew/tools/position_relative_tool.cpp | 20 +- pcbnew/tools/position_relative_tool.h | 9 +- 18 files changed, 1673 insertions(+), 2781 deletions(-) diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 6692e19043..a0960b2aca 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -237,6 +237,12 @@ bool UNIT_BINDER::IsIndeterminate() const } +void UNIT_BINDER::SetLabel( const wxString& aLabel ) +{ + m_label->SetLabel( aLabel ); +} + + void UNIT_BINDER::Enable( bool aEnable ) { m_label->Enable( aEnable ); diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index 9421f8e452..42958b5fbd 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -97,6 +97,8 @@ public: */ virtual bool Validate( bool setFocusOnError = false ); + void SetLabel( const wxString& aLabel ); + /** * Function Enable * Enables/diasables the label, widget and units label. diff --git a/pcbnew/block_footprint_editor.cpp b/pcbnew/block_footprint_editor.cpp index e16b0be1e0..add517487f 100644 --- a/pcbnew/block_footprint_editor.cpp +++ b/pcbnew/block_footprint_editor.cpp @@ -187,26 +187,29 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) if( itemsCount ) { - MOVE_PARAMETERS params; - params.allowOverride = false; + wxPoint translation; + double rotation; + ROTATION_ANCHOR rotationAnchor = ROTATE_AROUND_SEL_CENTER; - DIALOG_MOVE_EXACT dialog( this, params ); + DIALOG_MOVE_EXACT dialog( this, translation, rotation, rotationAnchor ); - int ret = dialog.ShowModal(); - - if( ret == wxID_OK ) + if( dialog.ShowModal() == wxID_OK ) { SaveCopyInUndoList( currentModule, UR_CHANGED ); wxPoint blockCentre = GetScreen()->m_BlockLocate.Centre(); + blockCentre += translation; - if( params.origin == RELATIVE_TO_CURRENT_POSITION ) + switch( rotationAnchor ) { - blockCentre = wxPoint( 0, 0 ); + case ROTATE_AROUND_SEL_CENTER: + MoveMarkedItemsExactly( currentModule, blockCentre, translation, rotation ); + break; + case ROTATE_AROUND_USER_ORIGIN: + MoveMarkedItemsExactly( currentModule, GetScreen()->m_O_Curseur, translation, rotation ); + break; + default: + wxFAIL_MSG( "Rotation choice shouldn't have been available in this context." ); } - - wxPoint finalMoveVector = params.translation - blockCentre; - - MoveMarkedItemsExactly( currentModule, blockCentre, finalMoveVector, params.rotation ); } } break; diff --git a/pcbnew/dialogs/dialog_move_exact.cpp b/pcbnew/dialogs/dialog_move_exact.cpp index 3da9ab6ac1..b81a29ce75 100644 --- a/pcbnew/dialogs/dialog_move_exact.cpp +++ b/pcbnew/dialogs/dialog_move_exact.cpp @@ -23,11 +23,6 @@ */ #include -#include -#include - -#include -#include #include "dialog_move_exact.h" @@ -35,110 +30,76 @@ DIALOG_MOVE_EXACT::MOVE_EXACT_OPTIONS DIALOG_MOVE_EXACT::m_options; -DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT(PCB_BASE_FRAME *aParent, MOVE_PARAMETERS &aParams ) : +DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT( PCB_BASE_FRAME *aParent, wxPoint& aTranslate, + double& aRotate, ROTATION_ANCHOR& aAnchor ) : DIALOG_MOVE_EXACT_BASE( aParent ), - m_parent( aParent ), - m_translation( aParams.translation ), - m_rotation( aParams.rotation ), - m_origin( aParams.origin ), - m_anchor( aParams.anchor ), - m_allowOverride( aParams.allowOverride ), - m_editingFootprint( aParams.editingFootprint ) + m_translation( aTranslate ), + m_rotation( aRotate ), + m_rotationAnchor( aAnchor ), + m_moveX( aParent, m_xLabel, m_xEntry, m_xUnit ), + m_moveY( aParent, m_yLabel, m_yEntry, m_yUnit ), + m_rotate( aParent, m_rotLabel, m_rotEntry, m_rotUnit ) { - // set the unit labels - m_xUnit->SetLabelText( GetAbbreviatedUnitsLabel( g_UserUnit ) ); - m_yUnit->SetLabelText( GetAbbreviatedUnitsLabel( g_UserUnit ) ); - // tabbing goes through the entries in sequence m_yEntry->MoveAfterInTabOrder( m_xEntry ); m_rotEntry->MoveAfterInTabOrder( m_yEntry ); + updateDialogControls( m_options.polarCoords ); + + m_menuIDs.push_back( aAnchor ); + m_menuIDs.push_back( ROTATE_AROUND_USER_ORIGIN ); + + if( aParent->IsType( FRAME_PCB ) ) + m_menuIDs.push_back( ROTATE_AROUND_AUX_ORIGIN ); + + buildRotationAnchorMenu(); + // and set up the entries according to the saved options m_polarCoords->SetValue( m_options.polarCoords ); - m_xEntry->SetValue( wxString::FromDouble( m_options.entry1 ) ); - m_yEntry->SetValue( wxString::FromDouble( m_options.entry2 ) ); - m_rotEntry->SetValue( wxString::FromDouble( m_options.entryRotation ) ); - m_originChooser->SetSelection( m_options.origin ); + m_moveX.SetValue( m_options.entry1 ); + m_moveY.SetValue( m_options.entry2 ); - if( m_allowOverride ) - { - m_cbOverride->SetValue( m_options.overrideAnchor ); - m_anchorChoice->Enable( m_options.overrideAnchor ); - - // ME_ANCHOR_FROM_LIBRARY is not in the wxChoice options so show the first choice instead - if( m_options.anchor == ANCHOR_FROM_LIBRARY ) - { - m_anchorChoice->SetSelection( ANCHOR_TOP_LEFT_PAD ); - } - else - { - m_anchorChoice->SetSelection( m_options.anchor ); - } - - if( m_options.origin == RELATIVE_TO_CURRENT_POSITION ) - { - // no footprint override necessary in this mode - m_cbOverride->Disable(); - m_anchorChoice->Disable(); - } - - if( m_editingFootprint ) - { - // there is no point in showing the center footprint option when editing footprints - m_anchorChoice->Delete( ANCHOR_CENTER_FOOTPRINT ); - } - } - else - { - // hide the checkbox and choice control if overides are not allowed - bMainSizer->Hide( bAnchorSizer, true ); - } - - if( wxPoint( 0, 0 ) == aParent->GetScreen()->m_O_Curseur ) - { - // disble the user origin option when the user oigin is not set - m_originChooser->Enable( RELATIVE_TO_USER_ORIGIN, false ); - m_originChooser->SetItemToolTip( RELATIVE_TO_USER_ORIGIN, - wxString( "The user origin is currently not set\n" - "Set it by using the hotkey" ) ); - } - - if( wxPoint( 0, 0 ) == aParent->GetGridOrigin() ) - { - // disble the grid origin option when the user oigin is not set - m_originChooser->Enable( RELATIVE_TO_GRID_ORIGIN, false ); - m_originChooser->SetItemToolTip( RELATIVE_TO_GRID_ORIGIN, - wxString( "The grid origin is currently not set\n" - "Set it by using the tool in the menu" ) ); - } - - if( wxPoint( 0, 0 ) == aParent->GetAuxOrigin() ) - { - // disble the grid origin option when the drill/place oigin is not set - m_originChooser->Enable( RELATIVE_TO_DRILL_PLACE_ORIGIN, false ); - m_originChooser->SetItemToolTip( RELATIVE_TO_DRILL_PLACE_ORIGIN, - wxString( "The drill/place origin is currently not set\n" - "Set it by using the tool in the menu" ) ); - } - - updateDlgTexts( m_polarCoords->IsChecked() ); + m_rotate.SetUnits( DEGREES ); + m_rotate.SetValue( m_options.entryRotation ); + m_anchorOptions->SetSelection( std::min( m_options.entryAnchorSelection, m_menuIDs.size() ) ); m_stdButtonsOK->SetDefault(); - GetSizer()->SetSizeHints( this ); - Layout(); + FinishDialogSettings(); } -DIALOG_MOVE_EXACT::~DIALOG_MOVE_EXACT() +void DIALOG_MOVE_EXACT::buildRotationAnchorMenu() { + wxArrayString menuItems; + + for( auto anchorID : m_menuIDs ) + { + switch( anchorID ) + { + case ROTATE_AROUND_ITEM_ANCHOR: + menuItems.push_back( _( "Rotate around item anchor" ) ); + break; + case ROTATE_AROUND_SEL_CENTER: + menuItems.push_back( _( "Rotate around selection center" ) ); + break; + case ROTATE_AROUND_USER_ORIGIN: + menuItems.push_back( _( "Rotate around user origin" ) ); + break; + case ROTATE_AROUND_AUX_ORIGIN: + menuItems.push_back( _( "Rotate around drill/place origin" ) ); + break; + } + } + + m_anchorOptions->Set( menuItems ); } void DIALOG_MOVE_EXACT::ToPolarDeg( double x, double y, double& r, double& q ) { // convert to polar coordinates - r = hypot ( x, y ); + r = hypot( x, y ); q = ( r != 0) ? RAD2DEG( atan2( y, x ) ) : 0; } @@ -148,8 +109,8 @@ bool DIALOG_MOVE_EXACT::GetTranslationInIU ( wxPoint& val, bool polar ) { if( polar ) { - const int r = ValueFromTextCtrl( *m_xEntry ); - const double q = DoubleValueFromString( DEGREES, m_yEntry->GetValue() ); + const int r = m_moveX.GetValue(); + const double q = m_moveY.GetValue(); val.x = r * cos( DEG2RAD( q / 10.0 ) ); val.y = r * sin( DEG2RAD( q / 10.0 ) ); @@ -157,8 +118,8 @@ bool DIALOG_MOVE_EXACT::GetTranslationInIU ( wxPoint& val, bool polar ) else { // direct read - val.x = ValueFromTextCtrl( *m_xEntry ); - val.y = ValueFromTextCtrl( *m_yEntry ); + val.x = m_moveX.GetValue(); + val.y = m_moveY.GetValue(); } // no validation to do here, but in future, you could return false here @@ -169,20 +130,22 @@ bool DIALOG_MOVE_EXACT::GetTranslationInIU ( wxPoint& val, bool polar ) void DIALOG_MOVE_EXACT::OnPolarChanged( wxCommandEvent& event ) { bool newPolar = m_polarCoords->IsChecked(); - updateDlgTexts( newPolar ); wxPoint val; // get the value as previously stored GetTranslationInIU( val, !newPolar ); + // now switch the controls to the new representations + updateDialogControls( newPolar ); + if( newPolar ) { // convert to polar coordinates double r, q; ToPolarDeg( val.x, val.y, r, q ); - PutValueInLocalUnits( *m_xEntry, KiROUND( r / 10.0) * 10 ); - m_yEntry->SetValue( wxString::FromDouble( q ) ); + m_moveX.SetValue( KiROUND( r / 10.0) * 10 ); + m_moveY.SetValue( q * 10 ); } else { @@ -190,84 +153,49 @@ void DIALOG_MOVE_EXACT::OnPolarChanged( wxCommandEvent& event ) // note - round off the last decimal place (10nm) to prevent // (some) rounding causing errors when round-tripping // you can never eliminate entirely, however - PutValueInLocalUnits( *m_xEntry, KiROUND( val.x / 10.0 ) * 10 ); - PutValueInLocalUnits( *m_yEntry, KiROUND( val.y / 10.0 ) * 10 ); + m_moveX.SetValue( KiROUND( val.x / 10.0 ) * 10 ); + m_moveY.SetValue( KiROUND( val.y / 10.0 ) * 10 ); } - Layout(); + } -void DIALOG_MOVE_EXACT::OnOriginChanged( wxCommandEvent& event ) -{ - if( m_originChooser->GetSelection() == RELATIVE_TO_CURRENT_POSITION ) - { - //no need to override the achor in this mode since the reference in the current position - m_cbOverride->Disable(); - m_anchorChoice->Disable(); - } - else if( m_allowOverride ) - { - m_cbOverride->Enable(); - - if( m_cbOverride->IsChecked() ) - m_anchorChoice->Enable(); - } -} - - -void DIALOG_MOVE_EXACT::OnOverrideChanged( wxCommandEvent& event ) -{ - if( m_cbOverride->IsChecked() ) - { - m_anchorChoice->Enable(); - } - else - { - m_anchorChoice->Disable(); - } -} - - -void DIALOG_MOVE_EXACT::updateDlgTexts( bool aPolar ) +void DIALOG_MOVE_EXACT::updateDialogControls( bool aPolar ) { if( aPolar ) { - m_xLabel->SetLabelText( _( "Distance:" ) ); // Polar radius - m_yLabel->SetLabelText( _( "Angle:" ) ); // Polar theta or angle - - m_yUnit->SetLabelText( GetAbbreviatedUnitsLabel( DEGREES ) ); + m_moveX.SetLabel( _( "Distance:" ) ); // Polar radius + m_moveY.SetLabel( _( "Angle:" ) ); // Polar theta or angle + m_moveY.SetUnits( DEGREES ); } else { - m_xLabel->SetLabelText( _( "Move vector X:" ) ); - m_yLabel->SetLabelText( _( "Move vector Y:" ) ); - - m_yUnit->SetLabelText( GetAbbreviatedUnitsLabel( g_UserUnit ) ); + m_moveX.SetLabel( _( "Move X:" ) ); + m_moveY.SetLabel( _( "Move Y:" ) ); + m_moveY.SetUnits( GetUserUnits() ); } + + Layout(); } void DIALOG_MOVE_EXACT::OnClear( wxCommandEvent& event ) { wxObject* obj = event.GetEventObject(); - wxTextCtrl* entry = NULL; if( obj == m_clearX ) { - entry = m_xEntry; + m_moveX.SetValue( 0 ); } else if( obj == m_clearY ) { - entry = m_yEntry; + m_moveY.SetValue( 0 ); } else if( obj == m_clearRot ) { - entry = m_rotEntry; + m_rotate.SetValue( 0 ); } - if( entry ) - entry->SetValue( "0" ); - // Keep m_stdButtonsOK focused to allow enter key actiavte the OK button m_stdButtonsOK->SetFocus(); } @@ -275,59 +203,19 @@ void DIALOG_MOVE_EXACT::OnClear( wxCommandEvent& event ) bool DIALOG_MOVE_EXACT::TransferDataFromWindow() { - m_rotation = DoubleValueFromString( DEGREES, m_rotEntry->GetValue() ); - m_origin = static_cast( m_originChooser->GetSelection() ); - - if( m_cbOverride->IsChecked() && m_allowOverride ) - { - m_anchor = static_cast( m_anchorChoice->GetSelection() ); - } - else - { - m_anchor = ANCHOR_FROM_LIBRARY; - } - - wxPoint move_vector, origin; // for the output, we only deliver a Cartesian vector - bool ok = GetTranslationInIU( move_vector, m_polarCoords->IsChecked() ); - - switch( m_origin ) - { - case RELATIVE_TO_USER_ORIGIN: - origin = m_parent->GetScreen()->m_O_Curseur; - break; - - case RELATIVE_TO_GRID_ORIGIN: - origin = m_parent->GetGridOrigin(); - break; - - case RELATIVE_TO_DRILL_PLACE_ORIGIN: - origin = m_parent->GetAuxOrigin(); - break; - - case RELATIVE_TO_SHEET_ORIGIN: - origin = wxPoint( 0, 0 ); - break; - - case RELATIVE_TO_CURRENT_POSITION: - // relative movement means that only the translation values should be used: - // -> set origin and anchor to zero - origin = wxPoint( 0, 0 ); - break; - } - - m_translation = move_vector + origin; + bool ok = GetTranslationInIU( m_translation, m_polarCoords->IsChecked() ); + m_rotation = m_rotate.GetValue(); + m_rotationAnchor = m_menuIDs[ m_anchorOptions->GetSelection() ]; if( ok ) { // save the settings m_options.polarCoords = m_polarCoords->GetValue(); - m_options.entry1 = DoubleValueFromString( UNSCALED_UNITS, m_xEntry->GetValue() ); - m_options.entry2 = DoubleValueFromString( UNSCALED_UNITS, m_yEntry->GetValue() ); - m_options.entryRotation = DoubleValueFromString( UNSCALED_UNITS, m_rotEntry->GetValue() ); - m_options.origin = m_origin; - m_options.anchor = static_cast( m_anchorChoice->GetSelection() ); - m_options.overrideAnchor = m_cbOverride->IsChecked(); + m_options.entry1 = m_moveX.GetValue(); + m_options.entry2 = m_moveY.GetValue(); + m_options.entryRotation = m_rotate.GetValue(); + m_options.entryAnchorSelection = (size_t) std::max( m_anchorOptions->GetSelection(), 0 ); return true; } diff --git a/pcbnew/dialogs/dialog_move_exact.h b/pcbnew/dialogs/dialog_move_exact.h index ce18bdb160..cc1d522437 100644 --- a/pcbnew/dialogs/dialog_move_exact.h +++ b/pcbnew/dialogs/dialog_move_exact.h @@ -26,54 +26,38 @@ #define __DIALOG_MOVE_EXACT__ #include -// Include the wxFormBuider header base: +#include + #include -enum MOVE_EXACT_ORIGIN + +enum ROTATION_ANCHOR { - RELATIVE_TO_CURRENT_POSITION, - RELATIVE_TO_USER_ORIGIN, - RELATIVE_TO_GRID_ORIGIN, - RELATIVE_TO_DRILL_PLACE_ORIGIN, - RELATIVE_TO_SHEET_ORIGIN -}; - - -enum MOVE_EXACT_ANCHOR -{ - ANCHOR_TOP_LEFT_PAD, - ANCHOR_CENTER_FOOTPRINT, - ANCHOR_FROM_LIBRARY -}; - - -struct MOVE_PARAMETERS -{ - wxPoint translation = wxPoint( 0,0 ); - double rotation = 0; - MOVE_EXACT_ORIGIN origin = RELATIVE_TO_CURRENT_POSITION; - MOVE_EXACT_ANCHOR anchor = ANCHOR_FROM_LIBRARY; - bool allowOverride = true; - bool editingFootprint = false; + ROTATE_AROUND_ITEM_ANCHOR, + ROTATE_AROUND_SEL_CENTER, + ROTATE_AROUND_USER_ORIGIN, + ROTATE_AROUND_AUX_ORIGIN }; class DIALOG_MOVE_EXACT : public DIALOG_MOVE_EXACT_BASE { private: + wxPoint& m_translation; + double& m_rotation; + ROTATION_ANCHOR& m_rotationAnchor; - PCB_BASE_FRAME* m_parent; - wxPoint& m_translation; - double& m_rotation; - MOVE_EXACT_ORIGIN& m_origin; - MOVE_EXACT_ANCHOR& m_anchor; - bool& m_allowOverride; - bool& m_editingFootprint; + UNIT_BINDER m_moveX; + UNIT_BINDER m_moveY; + UNIT_BINDER m_rotate; + + std::vector m_menuIDs; public: // Constructor and destructor - DIALOG_MOVE_EXACT(PCB_BASE_FRAME *aParent, MOVE_PARAMETERS &aParams ); - ~DIALOG_MOVE_EXACT(); + DIALOG_MOVE_EXACT(PCB_BASE_FRAME *aParent, wxPoint& aTranslate, + double& aRotate, ROTATION_ANCHOR& aAnchor ); + ~DIALOG_MOVE_EXACT() { }; private: @@ -85,9 +69,6 @@ private: void OnPolarChanged( wxCommandEvent& event ) override; void OnClear( wxCommandEvent& event ) override; - void OnOriginChanged( wxCommandEvent& event ) override; - void OnOverrideChanged( wxCommandEvent& event ) override; - // Automatically called when clicking on the OK button bool TransferDataFromWindow() override; @@ -107,30 +88,28 @@ private: */ bool GetTranslationInIU ( wxPoint& val, bool polar ); - // Update texts (comments) after changing the coordinates type (polar/cartesian) - void updateDlgTexts( bool aPolar ); + void buildRotationAnchorMenu(); + + // Update controls and their labels after changing the coordinates type (polar/cartesian) + void updateDialogControls( bool aPolar ); /** * Persistent dialog options */ struct MOVE_EXACT_OPTIONS { - bool polarCoords; - double entry1; - double entry2; - double entryRotation; - MOVE_EXACT_ORIGIN origin; - MOVE_EXACT_ANCHOR anchor; - bool overrideAnchor; + bool polarCoords; + double entry1; + double entry2; + double entryRotation; + size_t entryAnchorSelection; MOVE_EXACT_OPTIONS(): polarCoords( false ), entry1( 0 ), entry2( 0 ), entryRotation( 0 ), - origin( RELATIVE_TO_CURRENT_POSITION ), - anchor( ANCHOR_FROM_LIBRARY ), - overrideAnchor( false ) + entryAnchorSelection( 0 ) { } }; diff --git a/pcbnew/dialogs/dialog_move_exact_base.cpp b/pcbnew/dialogs/dialog_move_exact_base.cpp index fe3c8b81e1..60cb4fd4aa 100644 --- a/pcbnew/dialogs/dialog_move_exact_base.cpp +++ b/pcbnew/dialogs/dialog_move_exact_base.cpp @@ -1,12 +1,10 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 4 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "widgets/text_ctrl_eval.h" - #include "dialog_move_exact_base.h" /////////////////////////////////////////////////////////////////////////// @@ -17,88 +15,74 @@ DIALOG_MOVE_EXACT_BASE::DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id, bMainSizer = new wxBoxSizer( wxVERTICAL ); - m_polarCoords = new wxCheckBox( this, wxID_ANY, _("Use polar coordinates"), wxDefaultPosition, wxDefaultSize, 0 ); - bMainSizer->Add( m_polarCoords, 0, wxALL|wxEXPAND, 5 ); - - wxBoxSizer* bMiddleSizer; - bMiddleSizer = new wxBoxSizer( wxHORIZONTAL ); - wxFlexGridSizer* fgInputSizer; - fgInputSizer = new wxFlexGridSizer( 0, 4, 0, 0 ); + fgInputSizer = new wxFlexGridSizer( 0, 4, 0, 5 ); fgInputSizer->AddGrowableCol( 1 ); fgInputSizer->SetFlexibleDirection( wxBOTH ); fgInputSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_xLabel = new wxStaticText( this, wxID_ANY, _("X:"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); + m_xLabel = new wxStaticText( this, wxID_ANY, _("Move X:"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); m_xLabel->Wrap( -1 ); - fgInputSizer->Add( m_xLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgInputSizer->Add( m_xLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 ); - m_xEntry = new TEXT_CTRL_EVAL( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); - fgInputSizer->Add( m_xEntry, 0, wxALL|wxEXPAND, 5 ); + m_xEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); + fgInputSizer->Add( m_xEntry, 0, wxEXPAND|wxTOP, 5 ); m_xUnit = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_xUnit->Wrap( -1 ); - fgInputSizer->Add( m_xUnit, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5 ); + fgInputSizer->Add( m_xUnit, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxTOP|wxRIGHT, 5 ); m_clearX = new wxButton( this, wxID_ANY, _("Reset"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); - fgInputSizer->Add( m_clearX, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgInputSizer->Add( m_clearX, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_yLabel = new wxStaticText( this, wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_yLabel = new wxStaticText( this, wxID_ANY, _("Move Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_yLabel->Wrap( -1 ); - fgInputSizer->Add( m_yLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgInputSizer->Add( m_yLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5 ); - m_yEntry = new TEXT_CTRL_EVAL( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); - fgInputSizer->Add( m_yEntry, 0, wxALL|wxEXPAND, 5 ); + m_yEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); + fgInputSizer->Add( m_yEntry, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); m_yUnit = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_yUnit->Wrap( -1 ); - fgInputSizer->Add( m_yUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgInputSizer->Add( m_yUnit, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); m_clearY = new wxButton( this, wxID_ANY, _("Reset"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); - fgInputSizer->Add( m_clearY, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgInputSizer->Add( m_clearY, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - m_rotLabel = new wxStaticText( this, wxID_ANY, _("Item rotation:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_rotLabel = new wxStaticText( this, wxID_ANY, _("Rotate:"), wxDefaultPosition, wxDefaultSize, 0 ); m_rotLabel->Wrap( -1 ); - fgInputSizer->Add( m_rotLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgInputSizer->Add( m_rotLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5 ); - m_rotEntry = new TEXT_CTRL_EVAL( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); - fgInputSizer->Add( m_rotEntry, 0, wxALL|wxEXPAND, 5 ); + m_rotEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); + fgInputSizer->Add( m_rotEntry, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); m_rotUnit = new wxStaticText( this, wxID_ANY, _("deg"), wxDefaultPosition, wxDefaultSize, 0 ); m_rotUnit->Wrap( -1 ); - fgInputSizer->Add( m_rotUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgInputSizer->Add( m_rotUnit, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); m_clearRot = new wxButton( this, wxID_ANY, _("Reset"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); - fgInputSizer->Add( m_clearRot, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgInputSizer->Add( m_clearRot, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - bMiddleSizer->Add( fgInputSizer, 1, wxALL|wxBOTTOM|wxEXPAND|wxTOP, 5 ); + fgInputSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - wxString m_originChooserChoices[] = { _("Current position"), _("User origin"), _("Grid origin"), _("Drill/Place origin"), _("Sheet origin") }; - int m_originChooserNChoices = sizeof( m_originChooserChoices ) / sizeof( wxString ); - m_originChooser = new wxRadioBox( this, wxID_ANY, _("Move Relative To:"), wxDefaultPosition, wxDefaultSize, m_originChooserNChoices, m_originChooserChoices, 1, wxRA_SPECIFY_COLS ); - m_originChooser->SetSelection( 0 ); - bMiddleSizer->Add( m_originChooser, 0, wxALL, 5 ); + wxString m_anchorOptionsChoices[] = { _("Rotate around center of selection"), _("Rotate around User Origin"), _("Rotate around Drill/Place Origin") }; + int m_anchorOptionsNChoices = sizeof( m_anchorOptionsChoices ) / sizeof( wxString ); + m_anchorOptions = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_anchorOptionsNChoices, m_anchorOptionsChoices, 0 ); + m_anchorOptions->SetSelection( 0 ); + fgInputSizer->Add( m_anchorOptions, 0, wxEXPAND|wxBOTTOM, 5 ); - bMainSizer->Add( bMiddleSizer, 1, wxEXPAND, 5 ); - - bAnchorSizer = new wxBoxSizer( wxHORIZONTAL ); - - m_cbOverride = new wxCheckBox( this, wxID_ANY, _("Override default footprint anchor with:"), wxDefaultPosition, wxDefaultSize, 0 ); - bAnchorSizer->Add( m_cbOverride, 1, wxALL, 5 ); - - wxString m_anchorChoiceChoices[] = { _("Top left pad"), _("Footprint center") }; - int m_anchorChoiceNChoices = sizeof( m_anchorChoiceChoices ) / sizeof( wxString ); - m_anchorChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_anchorChoiceNChoices, m_anchorChoiceChoices, 0 ); - m_anchorChoice->SetSelection( 0 ); - bAnchorSizer->Add( m_anchorChoice, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - - bMainSizer->Add( bAnchorSizer, 0, wxEXPAND, 5 ); + bMainSizer->Add( fgInputSizer, 0, wxEXPAND|wxALL, 10 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); + bMainSizer->Add( m_staticline1, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); + + wxBoxSizer* bBottomSizer; + bBottomSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_polarCoords = new wxCheckBox( this, wxID_ANY, _("Use polar coordinates"), wxDefaultPosition, wxDefaultSize, 0 ); + bBottomSizer->Add( m_polarCoords, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 10 ); m_stdButtons = new wxStdDialogButtonSizer(); m_stdButtonsOK = new wxButton( this, wxID_OK ); @@ -107,35 +91,35 @@ DIALOG_MOVE_EXACT_BASE::DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id, m_stdButtons->AddButton( m_stdButtonsCancel ); m_stdButtons->Realize(); - bMainSizer->Add( m_stdButtons, 0, wxALL|wxEXPAND, 5 ); + bBottomSizer->Add( m_stdButtons, 1, wxALL|wxEXPAND, 5 ); + + + bMainSizer->Add( bBottomSizer, 0, wxEXPAND, 5 ); this->SetSizer( bMainSizer ); this->Layout(); + bMainSizer->Fit( this ); // Connect Events - m_polarCoords->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnPolarChanged ), NULL, this ); m_xEntry->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_MOVE_EXACT_BASE::OnTextFocusLost ), NULL, this ); m_clearX->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnClear ), NULL, this ); m_yEntry->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_MOVE_EXACT_BASE::OnTextFocusLost ), NULL, this ); m_clearY->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnClear ), NULL, this ); m_rotEntry->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_MOVE_EXACT_BASE::OnTextFocusLost ), NULL, this ); m_clearRot->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnClear ), NULL, this ); - m_originChooser->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnOriginChanged ), NULL, this ); - m_cbOverride->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnOverrideChanged ), NULL, this ); + m_polarCoords->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnPolarChanged ), NULL, this ); } DIALOG_MOVE_EXACT_BASE::~DIALOG_MOVE_EXACT_BASE() { // Disconnect Events - m_polarCoords->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnPolarChanged ), NULL, this ); m_xEntry->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_MOVE_EXACT_BASE::OnTextFocusLost ), NULL, this ); m_clearX->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnClear ), NULL, this ); m_yEntry->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_MOVE_EXACT_BASE::OnTextFocusLost ), NULL, this ); m_clearY->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnClear ), NULL, this ); m_rotEntry->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_MOVE_EXACT_BASE::OnTextFocusLost ), NULL, this ); m_clearRot->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnClear ), NULL, this ); - m_originChooser->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnOriginChanged ), NULL, this ); - m_cbOverride->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnOverrideChanged ), NULL, this ); + m_polarCoords->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_MOVE_EXACT_BASE::OnPolarChanged ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_move_exact_base.fbp b/pcbnew/dialogs/dialog_move_exact_base.fbp index cbb91c3da8..c628613a3f 100644 --- a/pcbnew/dialogs/dialog_move_exact_base.fbp +++ b/pcbnew/dialogs/dialog_move_exact_base.fbp @@ -44,7 +44,7 @@ -1,-1 DIALOG_MOVE_EXACT_BASE - 427,250 + -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Move Item @@ -93,1161 +93,27 @@ bMainSizer wxVERTICAL protected - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Use polar coordinates - - 0 - - - 0 - - 1 - m_polarCoords - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - OnPolarChanged - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - + 10 + wxEXPAND|wxALL + 0 + + 4 + wxBOTH + 1 + + 5 - bMiddleSizer - wxHORIZONTAL + fgInputSizer + wxFLEX_GROWMODE_SPECIFIED none - - 5 - wxALL|wxBOTTOM|wxEXPAND|wxTOP - 1 - - 4 - wxBOTH - 1 - - 0 - - fgInputSizer - wxFLEX_GROWMODE_SPECIFIED - none - 0 - 0 - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - X: - - 0 - - - 0 - - 1 - m_xLabel - 1 - - - protected - 1 - - Resizable - 1 - -1,-1 - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_xEntry - 1 - - - protected - 1 - - Resizable - 1 - - - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - - - - - - OnTextFocusLost - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - - 0 - - - 0 - - 1 - m_xUnit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Reset - - 0 - - - 0 - - 1 - m_clearX - 1 - - - protected - 1 - - Resizable - 1 - - wxBU_EXACTFIT - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnClear - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Y: - - 0 - - - 0 - - 1 - m_yLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_yEntry - 1 - - - protected - 1 - - Resizable - 1 - - - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - - - - - - OnTextFocusLost - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - - 0 - - - 0 - - 1 - m_yUnit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Reset - - 0 - - - 0 - - 1 - m_clearY - 1 - - - protected - 1 - - Resizable - 1 - - wxBU_EXACTFIT - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnClear - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Item rotation: - - 0 - - - 0 - - 1 - m_rotLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_rotEntry - 1 - - - protected - 1 - - Resizable - 1 - - - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - - - - - - OnTextFocusLost - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - deg - - 0 - - - 0 - - 1 - m_rotUnit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Reset - - 0 - - - 0 - - 1 - m_clearRot - 1 - - - protected - 1 - - Resizable - 1 - - wxBU_EXACTFIT - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnClear - - - - - - - - - - - - - - - - - - - - - - - - - - - + 0 + 0 5 - wxALL + wxALIGN_CENTER_VERTICAL|wxTOP 0 - + 1 1 1 @@ -1261,7 +127,6 @@ 1 0 - "Current position" "User origin" "Grid origin" "Drill/Place origin" "Sheet origin" 1 1 @@ -1276,8 +141,7 @@ 0 0 wxID_ANY - Move Relative To: - 1 + Move X: 0 @@ -1285,7 +149,7 @@ 0 1 - m_originChooser + m_xLabel 1 @@ -1293,20 +157,16 @@ 1 Resizable - 0 1 - - wxRA_SPECIFY_COLS + -1,-1 + 0 - - wxFILTER_NONE - wxDefaultValidator - + -1 @@ -1324,7 +184,6 @@ - OnOriginChanged @@ -1333,22 +192,11 @@ - - - - 5 - wxEXPAND - 0 - - - bAnchorSizer - wxHORIZONTAL - protected - + 5 - wxALL - 1 - + wxEXPAND|wxTOP + 0 + 1 1 1 @@ -1362,7 +210,6 @@ 1 0 - 0 1 1 @@ -1377,7 +224,98 @@ 0 0 wxID_ANY - Override default footprint anchor with: + + 0 + + 0 + + 0 + + 1 + m_xEntry + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + OnTextFocusLost + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxTOP|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm 0 @@ -1385,7 +323,7 @@ 0 1 - m_cbOverride + m_xUnit 1 @@ -1399,6 +337,90 @@ 0 + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Reset + + 0 + + + 0 + + 1 + m_clearX + 1 + + + protected + 1 + + Resizable + 1 + + wxBU_EXACTFIT + + 0 + wxFILTER_NONE wxDefaultValidator @@ -1406,8 +428,698 @@ + OnClear + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Move Y: + + 0 + + + 0 + + 1 + m_yLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_yEntry + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + OnTextFocusLost + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + + 0 + + + 0 + + 1 + m_yUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Reset + + 0 + + + 0 + + 1 + m_clearY + 1 + + + protected + 1 + + Resizable + 1 + + wxBU_EXACTFIT + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnClear + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Rotate: + + 0 + + + 0 + + 1 + m_rotLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_rotEntry + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + OnTextFocusLost + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + deg + + 0 + + + 0 + + 1 + m_rotUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Reset + + 0 + + + 0 + + 1 + m_clearRot + 1 + + + protected + 1 + + Resizable + 1 + + wxBU_EXACTFIT + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnClear - OnOverrideChanged @@ -1434,7 +1146,17 @@ 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND|wxBOTTOM 0 1 @@ -1450,7 +1172,7 @@ 1 0 - "Top left pad" "Footprint center" + "Rotate around center of selection" "Rotate around User Origin" "Rotate around Drill/Place Origin" 1 1 @@ -1472,7 +1194,7 @@ 0 1 - m_anchorChoice + m_anchorOptions 1 @@ -1484,7 +1206,7 @@ 1 - + ; forward_declare 0 @@ -1523,8 +1245,8 @@ - 5 - wxEXPAND | wxALL + 10 + wxEXPAND|wxRIGHT|wxLEFT 0 1 @@ -1603,30 +1325,129 @@ - + 5 - wxALL|wxEXPAND + wxEXPAND 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 + - m_stdButtons - protected - - - - - - - - + bBottomSizer + wxHORIZONTAL + none + + 10 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Use polar coordinates + + 0 + + + 0 + + 1 + m_polarCoords + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + OnPolarChanged + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_stdButtons + protected + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_move_exact_base.h b/pcbnew/dialogs/dialog_move_exact_base.h index 29db62806f..17ff1e4c22 100644 --- a/pcbnew/dialogs/dialog_move_exact_base.h +++ b/pcbnew/dialogs/dialog_move_exact_base.h @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 4 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #ifndef __DIALOG_MOVE_EXACT_BASE_H__ @@ -11,23 +11,19 @@ #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 +#include #include /////////////////////////////////////////////////////////////////////////// @@ -42,39 +38,34 @@ class DIALOG_MOVE_EXACT_BASE : public DIALOG_SHIM protected: wxBoxSizer* bMainSizer; - wxCheckBox* m_polarCoords; wxStaticText* m_xLabel; - TEXT_CTRL_EVAL* m_xEntry; + wxTextCtrl* m_xEntry; wxStaticText* m_xUnit; wxButton* m_clearX; wxStaticText* m_yLabel; - TEXT_CTRL_EVAL* m_yEntry; + wxTextCtrl* m_yEntry; wxStaticText* m_yUnit; wxButton* m_clearY; wxStaticText* m_rotLabel; - TEXT_CTRL_EVAL* m_rotEntry; + wxTextCtrl* m_rotEntry; wxStaticText* m_rotUnit; wxButton* m_clearRot; - wxRadioBox* m_originChooser; - wxBoxSizer* bAnchorSizer; - wxCheckBox* m_cbOverride; - wxChoice* m_anchorChoice; + wxChoice* m_anchorOptions; wxStaticLine* m_staticline1; + wxCheckBox* m_polarCoords; wxStdDialogButtonSizer* m_stdButtons; wxButton* m_stdButtonsOK; wxButton* m_stdButtonsCancel; // Virtual event handlers, overide them in your derived class - virtual void OnPolarChanged( wxCommandEvent& event ) { event.Skip(); } virtual void OnTextFocusLost( wxFocusEvent& event ) { event.Skip(); } virtual void OnClear( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOriginChanged( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOverrideChanged( wxCommandEvent& event ) { event.Skip(); } + virtual void OnPolarChanged( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Move Item"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 427,250 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_MOVE_EXACT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Move Item"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_MOVE_EXACT_BASE(); }; diff --git a/pcbnew/dialogs/dialog_position_relative.cpp b/pcbnew/dialogs/dialog_position_relative.cpp index f7df25d0c8..bfd28b98cd 100644 --- a/pcbnew/dialogs/dialog_position_relative.cpp +++ b/pcbnew/dialogs/dialog_position_relative.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -22,54 +22,36 @@ */ #include -#include -#include -#include - -#include +#include "tools/pcb_actions.h" #include "dialog_position_relative.h" -#include "tools/pcb_actions.h" // initialise statics DIALOG_POSITION_RELATIVE::POSITION_RELATIVE_OPTIONS DIALOG_POSITION_RELATIVE::m_options; DIALOG_POSITION_RELATIVE::DIALOG_POSITION_RELATIVE( PCB_BASE_FRAME* aParent, TOOL_MANAGER* toolMgr, - wxPoint& translation, double& rotation, wxPoint& anchorPosition ) : + wxPoint& translation, wxPoint& anchorPosition ) : DIALOG_POSITION_RELATIVE_BASE( aParent ), m_toolMgr( toolMgr ), m_translation( translation ), - m_rotation( rotation ), - m_anchor_position( anchorPosition ) + m_anchor_position( anchorPosition ), + m_xOffset( aParent, m_xLabel, m_xEntry, m_xUnit ), + m_yOffset( aParent, m_yLabel, m_yEntry, m_yUnit ) { - // set the unit labels - m_xUnit->SetLabelText( GetAbbreviatedUnitsLabel( g_UserUnit ) ); - m_yUnit->SetLabelText( GetAbbreviatedUnitsLabel( g_UserUnit ) ); - // tabbing goes through the entries in sequence m_yEntry->MoveAfterInTabOrder( m_xEntry ); - m_rotEntry->MoveAfterInTabOrder( m_yEntry ); // and set up the entries according to the saved options m_polarCoords->SetValue( m_options.polarCoords ); - m_xEntry->SetValue( wxString::FromDouble( m_options.entry1 ) ); - m_yEntry->SetValue( wxString::FromDouble( m_options.entry2 ) ); - m_rotEntry->SetValue( wxString::FromDouble( m_options.entryRotation ) ); - updateDlgTexts( m_polarCoords->IsChecked() ); + updateDialogControls( m_polarCoords->IsChecked() ); - PutValueInLocalUnits( *m_anchor_x, m_anchor_position.x ); - PutValueInLocalUnits( *m_anchor_y, m_anchor_position.y ); + m_xOffset.SetValue( m_options.entry1 ); + m_yOffset.SetValue( m_options.entry2 ); m_stdButtonsOK->SetDefault(); - GetSizer()->SetSizeHints( this ); - Layout(); -} - - -DIALOG_POSITION_RELATIVE::~DIALOG_POSITION_RELATIVE() -{ + FinishDialogSettings(); } @@ -82,21 +64,21 @@ void DIALOG_POSITION_RELATIVE::ToPolarDeg( double x, double y, double& r, double } -bool DIALOG_POSITION_RELATIVE::GetTranslationInIU( wxPoint& val, bool polar ) +bool DIALOG_POSITION_RELATIVE::GetTranslationInIU ( wxPoint& val, bool polar ) { if( polar ) { - const int r = ValueFromTextCtrl( *m_xEntry ); - const double q = DoubleValueFromString( DEGREES, m_yEntry->GetValue() ); + const int r = m_xOffset.GetValue(); + const double q = m_yOffset.GetValue(); - val.x = r * cos( DEG2RAD( q / 10.0 ) ); - val.y = r * sin( DEG2RAD( q / 10.0 ) ); + val.x = r * cos( DEG2RAD( q / 10.0 ) ); + val.y = r * sin( DEG2RAD( q / 10.0 ) ); } else { // direct read - val.x = ValueFromTextCtrl( *m_xEntry ); - val.y = ValueFromTextCtrl( *m_yEntry ); + val.x = m_xOffset.GetValue(); + val.y = m_yOffset.GetValue(); } // no validation to do here, but in future, you could return false here @@ -107,21 +89,22 @@ bool DIALOG_POSITION_RELATIVE::GetTranslationInIU( wxPoint& val, bool polar ) void DIALOG_POSITION_RELATIVE::OnPolarChanged( wxCommandEvent& event ) { bool newPolar = m_polarCoords->IsChecked(); - - updateDlgTexts( newPolar ); wxPoint val; // get the value as previously stored GetTranslationInIU( val, !newPolar ); + // now switch the controls to the new representations + updateDialogControls( newPolar ); + if( newPolar ) { // convert to polar coordinates double r, q; ToPolarDeg( val.x, val.y, r, q ); - PutValueInLocalUnits( *m_xEntry, KiROUND( r / 10.0 ) * 10 ); - m_yEntry->SetValue( wxString::FromDouble( q ) ); + m_xOffset.SetValue( KiROUND( r / 10.0) * 10 ); + m_yOffset.SetValue( q * 10 ); } else { @@ -129,29 +112,26 @@ void DIALOG_POSITION_RELATIVE::OnPolarChanged( wxCommandEvent& event ) // note - round off the last decimal place (10nm) to prevent // (some) rounding causing errors when round-tripping // you can never eliminate entirely, however - PutValueInLocalUnits( *m_xEntry, KiROUND( val.x / 10.0 ) * 10 ); - PutValueInLocalUnits( *m_yEntry, KiROUND( val.y / 10.0 ) * 10 ); + m_xOffset.SetValue( KiROUND( val.x / 10.0 ) * 10 ); + m_yOffset.SetValue( KiROUND( val.y / 10.0 ) * 10 ); } - Layout(); } -void DIALOG_POSITION_RELATIVE::updateDlgTexts( bool aPolar ) +void DIALOG_POSITION_RELATIVE::updateDialogControls( bool aPolar ) { if( aPolar ) { - m_xLabel->SetLabelText( _( "Distance from anchor:" ) ); // Polar radius - m_yLabel->SetLabelText( _( "Angle:" ) ); // Polar theta or angle - - m_yUnit->SetLabelText( GetAbbreviatedUnitsLabel( DEGREES ) ); + m_xOffset.SetLabel( _( "Distance:" ) ); // Polar radius + m_yOffset.SetLabel( _( "Angle:" ) ); // Polar theta or angle + m_yOffset.SetUnits( DEGREES ); } else { - m_xLabel->SetLabelText( _( "Position from anchor X:" ) ); - m_yLabel->SetLabelText( _( "Position from anchor Y:" ) ); - - m_yUnit->SetLabelText( GetAbbreviatedUnitsLabel( g_UserUnit ) ); + m_xOffset.SetLabel( _( "Offset X:" ) ); + m_yOffset.SetLabel( _( "Offset Y:" ) ); + m_yOffset.SetUnits( GetUserUnits() ); } } @@ -159,23 +139,15 @@ void DIALOG_POSITION_RELATIVE::updateDlgTexts( bool aPolar ) void DIALOG_POSITION_RELATIVE::OnClear( wxCommandEvent& event ) { wxObject* obj = event.GetEventObject(); - wxTextCtrl* entry = NULL; if( obj == m_clearX ) { - entry = m_xEntry; + m_xOffset.SetValue( 0 ); } else if( obj == m_clearY ) { - entry = m_yEntry; + m_yOffset.SetValue( 0 ); } - else if( obj == m_clearRot ) - { - entry = m_rotEntry; - } - - if( entry ) - entry->SetValue( "0" ); } @@ -186,22 +158,29 @@ void DIALOG_POSITION_RELATIVE::OnSelectItemClick( wxCommandEvent& event ) POSITION_RELATIVE_TOOL* posrelTool = m_toolMgr->GetTool(); wxASSERT( posrelTool ); + m_referenceInfo->SetLabel( _( "Reference item: " ) ); m_toolMgr->RunAction( PCB_ACTIONS::selectpositionRelativeItem, true ); } -void DIALOG_POSITION_RELATIVE::UpdateAnchor( const wxPoint& aPosition ) +void DIALOG_POSITION_RELATIVE::UpdateAnchor( BOARD_ITEM* aItem ) { - m_anchor_position = aPosition; - PutValueInLocalUnits( *m_anchor_x, aPosition.x ); - PutValueInLocalUnits( *m_anchor_y, aPosition.y ); + wxString reference = _( "" ); + + if( aItem ) + { + m_anchor_position = aItem->GetPosition(); + reference = aItem->GetSelectMenuText( GetUserUnits() ); + } + + m_referenceInfo->SetLabel( _( "Reference item: " ) + reference ); + + Raise(); // required at least on OSX } void DIALOG_POSITION_RELATIVE::OnOkClick( wxCommandEvent& event ) { - m_rotation = DoubleValueFromString( DEGREES, m_rotEntry->GetValue() ); - // for the output, we only deliver a Cartesian vector bool ok = GetTranslationInIU( m_translation, m_polarCoords->IsChecked() ); @@ -209,13 +188,12 @@ void DIALOG_POSITION_RELATIVE::OnOkClick( wxCommandEvent& event ) { // save the settings m_options.polarCoords = m_polarCoords->GetValue(); - m_options.entry1 = DoubleValueFromString( UNSCALED_UNITS, m_xEntry->GetValue() ); - m_options.entry2 = DoubleValueFromString( UNSCALED_UNITS, m_yEntry->GetValue() ); - m_options.entryRotation = DoubleValueFromString( UNSCALED_UNITS, m_rotEntry->GetValue() ); + m_options.entry1 = m_xOffset.GetValue(); + m_options.entry2 = m_yOffset.GetValue(); POSITION_RELATIVE_TOOL* posrelTool = m_toolMgr->GetTool(); wxASSERT( posrelTool ); - posrelTool->RelativeItemSelectionMove( m_anchor_position, m_translation, m_rotation ); + posrelTool->RelativeItemSelectionMove( m_anchor_position, m_translation, 0.0 ); event.Skip(); } diff --git a/pcbnew/dialogs/dialog_position_relative.h b/pcbnew/dialogs/dialog_position_relative.h index 3e4160a5d2..7882ad778b 100644 --- a/pcbnew/dialogs/dialog_position_relative.h +++ b/pcbnew/dialogs/dialog_position_relative.h @@ -29,6 +29,7 @@ #include #include +#include #include "tools/position_relative_tool.h" class DIALOG_POSITION_RELATIVE : public DIALOG_POSITION_RELATIVE_BASE @@ -36,17 +37,19 @@ class DIALOG_POSITION_RELATIVE : public DIALOG_POSITION_RELATIVE_BASE private: TOOL_MANAGER* m_toolMgr; - wxPoint& m_translation; - double& m_rotation; - wxPoint& m_anchor_position; + wxPoint& m_translation; + wxPoint& m_anchor_position; + + UNIT_BINDER m_xOffset; + UNIT_BINDER m_yOffset; public: // Constructor and destructor - DIALOG_POSITION_RELATIVE( PCB_BASE_FRAME* aParent, TOOL_MANAGER* toolMgr, wxPoint& translation, - double& rotation, wxPoint& anchorposition ); - ~DIALOG_POSITION_RELATIVE(); + DIALOG_POSITION_RELATIVE( PCB_BASE_FRAME* aParent, TOOL_MANAGER* toolMgr, + wxPoint& translation, wxPoint& anchorposition ); + ~DIALOG_POSITION_RELATIVE() { }; - void UpdateAnchor( const wxPoint& aPosition ); + void UpdateAnchor( BOARD_ITEM* aItem ); private: @@ -55,11 +58,11 @@ private: */ void OnTextFocusLost( wxFocusEvent& event ) override; - void OnPolarChanged( wxCommandEvent& event ) override; - void OnClear( wxCommandEvent& event ) override; + void OnPolarChanged( wxCommandEvent& event ) override; + void OnClear( wxCommandEvent& event ) override; - void OnSelectItemClick( wxCommandEvent& event ) override; - void OnOkClick( wxCommandEvent& event ) override; + void OnSelectItemClick( wxCommandEvent& event ) override; + void OnOkClick( wxCommandEvent& event ) override; /** * Convert a given Cartesian point into a polar representation. @@ -77,8 +80,8 @@ private: */ bool GetTranslationInIU( wxPoint& val, bool polar ); - // Update texts (comments) after changing the coordinates type (polar/cartesian) - void updateDlgTexts( bool aPolar ); + // Update controls and their labels after changing the coordinates type (polar/cartesian) + void updateDialogControls( bool aPolar ); /** * Persistent dialog options @@ -88,13 +91,11 @@ private: bool polarCoords; double entry1; double entry2; - double entryRotation; POSITION_RELATIVE_OPTIONS() : polarCoords( false ), entry1( 0 ), - entry2( 0 ), - entryRotation( 0 ) + entry2( 0 ) { } }; diff --git a/pcbnew/dialogs/dialog_position_relative_base.cpp b/pcbnew/dialogs/dialog_position_relative_base.cpp index fb3116e362..3c2a635b89 100644 --- a/pcbnew/dialogs/dialog_position_relative_base.cpp +++ b/pcbnew/dialogs/dialog_position_relative_base.cpp @@ -1,12 +1,10 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jul 2 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "widgets/text_ctrl_eval.h" - #include "dialog_position_relative_base.h" /////////////////////////////////////////////////////////////////////////// @@ -18,97 +16,82 @@ 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 ); + wxBoxSizer* bUpperSizer; + bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_referenceInfo = new wxStaticText( this, wxID_ANY, _("Reference item: "), wxDefaultPosition, wxDefaultSize, 0 ); + m_referenceInfo->Wrap( -1 ); + m_referenceInfo->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); + m_referenceInfo->SetMinSize( wxSize( 340,-1 ) ); + + bUpperSizer->Add( m_referenceInfo, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + + + bUpperSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_select_anchor_button = new wxButton( this, wxID_ANY, _("Select"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); + m_select_anchor_button->SetToolTip( _("Click and select a board item.\nThe anchor position will be the position of the selected item.") ); + + bUpperSizer->Add( m_select_anchor_button, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + + bMainSizer->Add( bUpperSizer, 0, wxEXPAND|wxALL, 10 ); 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 ); + bMainSizer->Add( m_staticline2, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); wxFlexGridSizer* fgSizer2; - fgSizer2 = new wxFlexGridSizer( 0, 4, 0, 0 ); + fgSizer2 = new wxFlexGridSizer( 0, 5, 5, 0 ); fgSizer2->AddGrowableCol( 1 ); fgSizer2->SetFlexibleDirection( wxBOTH ); fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_xLabel = new wxStaticText( this, wxID_ANY, _("X:"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); + m_xLabel = new wxStaticText( this, wxID_ANY, _("Offset X:"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); m_xLabel->Wrap( -1 ); - fgSizer2->Add( m_xLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgSizer2->Add( m_xLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 ); - m_xEntry = new TEXT_CTRL_EVAL( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_xEntry, 0, wxALL|wxEXPAND, 5 ); + m_xEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer2->Add( m_xEntry, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); m_xUnit = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_xUnit->Wrap( -1 ); - fgSizer2->Add( m_xUnit, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5 ); + fgSizer2->Add( m_xUnit, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxTOP|wxRIGHT, 5 ); + + + fgSizer2->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); m_clearX = new wxButton( this, wxID_ANY, _("Reset"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); - fgSizer2->Add( m_clearX, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgSizer2->Add( m_clearX, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_yLabel = new wxStaticText( this, wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_yLabel = new wxStaticText( this, wxID_ANY, _("Offset Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_yLabel->Wrap( -1 ); - fgSizer2->Add( m_yLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgSizer2->Add( m_yLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); - m_yEntry = new TEXT_CTRL_EVAL( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_yEntry, 0, wxALL|wxEXPAND, 5 ); + m_yEntry = new wxTextCtrl( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer2->Add( m_yEntry, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_yUnit = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_yUnit->Wrap( -1 ); - fgSizer2->Add( m_yUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgSizer2->Add( m_yUnit, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + + + fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 ); m_clearY = new wxButton( this, wxID_ANY, _("Reset"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); - fgSizer2->Add( m_clearY, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - m_rotLabel = new wxStaticText( this, wxID_ANY, _("Item rotation:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_rotLabel->Wrap( -1 ); - fgSizer2->Add( m_rotLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - - m_rotEntry = new TEXT_CTRL_EVAL( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_rotEntry, 0, wxALL|wxEXPAND, 5 ); - - m_rotUnit = new wxStaticText( this, wxID_ANY, _("deg"), wxDefaultPosition, wxDefaultSize, 0 ); - m_rotUnit->Wrap( -1 ); - fgSizer2->Add( m_rotUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - 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 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, _("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, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer2->Add( m_anchor_y, 0, wxALL, 5 ); + fgSizer2->Add( m_clearY, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - bMainSizer->Add( fgSizer2, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 ); + bMainSizer->Add( fgSizer2, 1, wxEXPAND|wxALL, 10 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); + bMainSizer->Add( m_staticline1, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); wxBoxSizer* bSizerBottom; bSizerBottom = new wxBoxSizer( wxHORIZONTAL ); - m_select_anchor_button = new wxButton( this, wxID_ANY, _("Select Anchor Position"), wxDefaultPosition, wxDefaultSize, 0 ); - m_select_anchor_button->SetToolTip( _("Click and select a board item.\nThe anchor position will be the position of the selected item.") ); - - bSizerBottom->Add( m_select_anchor_button, 0, wxALL, 5 ); - - - bSizerBottom->Add( 0, 0, 1, wxEXPAND, 5 ); + m_polarCoords = new wxCheckBox( this, wxID_ANY, _("Use polar coordinates"), wxDefaultPosition, wxDefaultSize, 0 ); + m_polarCoords->SetValue(true); + bSizerBottom->Add( m_polarCoords, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_stdButtons = new wxStdDialogButtonSizer(); m_stdButtonsOK = new wxButton( this, wxID_OK ); @@ -117,10 +100,10 @@ DIALOG_POSITION_RELATIVE_BASE::DIALOG_POSITION_RELATIVE_BASE( wxWindow* parent, m_stdButtons->AddButton( m_stdButtonsCancel ); m_stdButtons->Realize(); - bSizerBottom->Add( m_stdButtons, 0, wxALL|wxEXPAND, 5 ); + bSizerBottom->Add( m_stdButtons, 1, wxALL|wxEXPAND, 5 ); - bMainSizer->Add( bSizerBottom, 0, wxEXPAND, 5 ); + bMainSizer->Add( bSizerBottom, 0, wxEXPAND|wxLEFT, 5 ); this->SetSizer( bMainSizer ); @@ -129,14 +112,12 @@ DIALOG_POSITION_RELATIVE_BASE::DIALOG_POSITION_RELATIVE_BASE( wxWindow* parent, // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnClose ) ); - m_polarCoords->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnPolarChanged ), NULL, this ); + m_select_anchor_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnSelectItemClick ), NULL, this ); m_xEntry->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnTextFocusLost ), NULL, this ); m_clearX->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnClear ), NULL, this ); m_yEntry->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnTextFocusLost ), NULL, this ); m_clearY->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnClear ), NULL, this ); - m_rotEntry->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnTextFocusLost ), NULL, this ); - m_clearRot->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnClear ), NULL, this ); - m_select_anchor_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnSelectItemClick ), NULL, this ); + m_polarCoords->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnPolarChanged ), NULL, this ); m_stdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnOkClick ), NULL, this ); } @@ -144,14 +125,12 @@ DIALOG_POSITION_RELATIVE_BASE::~DIALOG_POSITION_RELATIVE_BASE() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnClose ) ); - m_polarCoords->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnPolarChanged ), NULL, this ); + m_select_anchor_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnSelectItemClick ), NULL, this ); m_xEntry->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnTextFocusLost ), NULL, this ); m_clearX->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnClear ), NULL, this ); m_yEntry->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnTextFocusLost ), NULL, this ); m_clearY->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnClear ), NULL, this ); - m_rotEntry->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnTextFocusLost ), NULL, this ); - m_clearRot->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnClear ), NULL, this ); - m_select_anchor_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnSelectItemClick ), NULL, this ); + m_polarCoords->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnPolarChanged ), NULL, this ); m_stdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_POSITION_RELATIVE_BASE::OnOkClick ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_position_relative_base.fbp b/pcbnew/dialogs/dialog_position_relative_base.fbp index 6ed793bdb5..a454d01110 100644 --- a/pcbnew/dialogs/dialog_position_relative_base.fbp +++ b/pcbnew/dialogs/dialog_position_relative_base.fbp @@ -47,7 +47,7 @@ -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h - Position Relative + Position Relative To Reference Item @@ -94,91 +94,200 @@ wxVERTICAL none - 5 - wxALL|wxALIGN_CENTER_HORIZONTAL + 10 + wxEXPAND|wxALL 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 - - - - - - - - - - - - - - - - - - - - - - - + bUpperSizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_HORIZONTAL|wxTOP|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,90,-1,70,0 + 0 + 0 + wxID_ANY + Reference item: <none selected> + + 0 + + + 0 + 340,-1 + 1 + m_referenceInfo + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Select + + 0 + + + 0 + + 1 + m_select_anchor_button + 1 + + + protected + 1 + + Resizable + 1 + + wxBU_EXACTFIT + + 0 + Click and select a board item. The anchor position will be the position of the selected item. + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSelectItemClick + + + + + + + + + + + + + + + + + + + + + + + + + - 5 - wxEXPAND | wxALL + 10 + wxEXPAND|wxRIGHT|wxLEFT 0 1 @@ -257,100 +366,12 @@ - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Use polar coordinates - - 0 - - - 0 - - 1 - m_polarCoords - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - OnPolarChanged - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP|wxBOTTOM + 10 + wxEXPAND|wxALL 1 - 4 + 5 wxBOTH 1 @@ -360,10 +381,10 @@ wxFLEX_GROWMODE_SPECIFIED none 0 - 0 + 5 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT 0 1 @@ -393,7 +414,7 @@ 0 0 wxID_ANY - X: + Offset X: 0 @@ -446,7 +467,7 @@ 5 - wxALL|wxEXPAND + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -495,7 +516,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -537,7 +558,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL + wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxTOP|wxRIGHT 0 1 @@ -620,7 +641,17 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxEXPAND|wxRIGHT|wxLEFT + 1 + + 0 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -708,7 +739,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 1 @@ -738,7 +769,7 @@ 0 0 wxID_ANY - Y: + Offset Y: 0 @@ -791,7 +822,7 @@ 5 - wxALL|wxEXPAND + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -840,7 +871,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -882,7 +913,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 1 @@ -965,7 +996,17 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -1051,704 +1092,11 @@ - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Item rotation: - - 0 - - - 0 - - 1 - m_rotLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_rotEntry - 1 - - - protected - 1 - - Resizable - 1 - - - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - - - - - - OnTextFocusLost - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - deg - - 0 - - - 0 - - 1 - m_rotUnit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Reset - - 0 - - - 0 - - 1 - m_clearRot - 1 - - - protected - 1 - - Resizable - 1 - - wxBU_EXACTFIT - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnClear - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Anchor position X: - - 0 - - - 0 - - 1 - m_anchor_xLabel - 1 - - - protected - 1 - - Resizable - 1 - -1,-1 - - - 0 - The Anchor position is the origin of coordinates for the transform. - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_anchor_x - 1 - - - protected - 1 - - Resizable - 1 - - - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Y: - - 0 - - - 0 - - 1 - m_anchor_yLabel - 1 - - - protected - 1 - - Resizable - 1 - -1,-1 - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_anchor_y - 1 - - - protected - 1 - - Resizable - 1 - - - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND | wxALL + 10 + wxEXPAND|wxRIGHT|wxLEFT 0 1 @@ -1829,18 +1177,18 @@ 5 - wxEXPAND + wxEXPAND|wxLEFT 0 bSizerBottom wxHORIZONTAL none - + 5 - wxALL + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -1854,10 +1202,10 @@ 1 0 + 1 1 1 - 0 0 Dock 0 @@ -1869,7 +1217,7 @@ 0 0 wxID_ANY - Select Anchor Position + Use polar coordinates 0 @@ -1877,7 +1225,7 @@ 0 1 - m_select_anchor_button + m_polarCoords 1 @@ -1890,7 +1238,7 @@ 0 - Click and select a board item. The anchor position will be the position of the selected item. + wxFILTER_NONE wxDefaultValidator @@ -1898,8 +1246,8 @@ - OnSelectItemClick + OnPolarChanged @@ -1924,20 +1272,10 @@ - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - 5 wxALL|wxEXPAND - 0 + 1 0 1 diff --git a/pcbnew/dialogs/dialog_position_relative_base.h b/pcbnew/dialogs/dialog_position_relative_base.h index 361d97fbf7..389bedaac7 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 Jul 2 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #ifndef __DIALOG_POSITION_RELATIVE_BASE_H__ @@ -11,9 +11,6 @@ #include #include #include -class DIALOG_SHIM; -class TEXT_CTRL_EVAL; - #include "dialog_shim.h" #include #include @@ -21,11 +18,11 @@ class TEXT_CTRL_EVAL; #include #include #include -#include -#include -#include #include #include +#include +#include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -39,43 +36,35 @@ class DIALOG_POSITION_RELATIVE_BASE : public DIALOG_SHIM private: protected: - wxStaticText* m_staticTextHelp; + wxStaticText* m_referenceInfo; + wxButton* m_select_anchor_button; wxStaticLine* m_staticline2; - wxCheckBox* m_polarCoords; wxStaticText* m_xLabel; - TEXT_CTRL_EVAL* m_xEntry; + wxTextCtrl* m_xEntry; wxStaticText* m_xUnit; wxButton* m_clearX; wxStaticText* m_yLabel; - TEXT_CTRL_EVAL* m_yEntry; + wxTextCtrl* m_yEntry; wxStaticText* m_yUnit; wxButton* m_clearY; - wxStaticText* m_rotLabel; - TEXT_CTRL_EVAL* m_rotEntry; - wxStaticText* m_rotUnit; - wxButton* m_clearRot; - wxStaticText* m_anchor_xLabel; - TEXT_CTRL_EVAL* m_anchor_x; - wxStaticText* m_anchor_yLabel; - TEXT_CTRL_EVAL* m_anchor_y; wxStaticLine* m_staticline1; - wxButton* m_select_anchor_button; + wxCheckBox* m_polarCoords; wxStdDialogButtonSizer* m_stdButtons; wxButton* m_stdButtonsOK; wxButton* m_stdButtonsCancel; // Virtual event handlers, overide them in your derived class virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } - virtual void OnPolarChanged( wxCommandEvent& event ) { event.Skip(); } + virtual void OnSelectItemClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnTextFocusLost( wxFocusEvent& event ) { event.Skip(); } virtual void OnClear( wxCommandEvent& event ) { event.Skip(); } - virtual void OnSelectItemClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnPolarChanged( wxCommandEvent& event ) { event.Skip(); } virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_POSITION_RELATIVE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Position Relative"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_POSITION_RELATIVE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Position Relative To Reference Item"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_POSITION_RELATIVE_BASE(); }; diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 6b4c8ab6ad..e40649c97e 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -1598,9 +1598,11 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) void PCB_EDIT_FRAME::moveExact() { - MOVE_PARAMETERS params; + wxPoint translation; + double rotation; + ROTATION_ANCHOR rotationAnchor = ROTATE_AROUND_ITEM_ANCHOR; - DIALOG_MOVE_EXACT dialog( this, params ); + DIALOG_MOVE_EXACT dialog( this, translation, rotation, rotationAnchor ); int ret = dialog.ShowModal(); if( ret == wxID_OK ) @@ -1616,43 +1618,23 @@ void PCB_EDIT_FRAME::moveExact() // Could be moved or rotated SaveCopyInUndoList( itemToSave, UR_CHANGED ); - // begin with the default anchor - wxPoint anchorPoint = item->GetPosition(); + item->Move( translation ); - if( item->Type() == PCB_MODULE_T ) + switch( rotationAnchor ) { - // cast to module to allow access to the pads - MODULE* mod = static_cast( item ); - - switch( params.anchor ) - { - case ANCHOR_TOP_LEFT_PAD: - if( mod->GetTopLeftPad()->GetAttribute() == PAD_ATTRIB_SMD ) - { - anchorPoint = mod->GetTopLeftPad()->GetBoundingBox().GetPosition(); - } - else - { - anchorPoint = mod->GetTopLeftPad()->GetPosition(); - } - break; - case ANCHOR_CENTER_FOOTPRINT: - anchorPoint = mod->GetFootprintRect().GetCenter(); - break; - case ANCHOR_FROM_LIBRARY: - ; // nothing to do - } + case ROTATE_AROUND_ITEM_ANCHOR: + item->Rotate( item->GetPosition(), rotation ); + break; + case ROTATE_AROUND_USER_ORIGIN: + item->Rotate( GetScreen()->m_O_Curseur, rotation ); + break; + case ROTATE_AROUND_AUX_ORIGIN: + item->Rotate( GetAuxOrigin(), rotation ); + break; + default: + wxFAIL_MSG( "Rotation choice shouldn't have been available in this context." ); } - if( params.origin == RELATIVE_TO_CURRENT_POSITION ) - { - anchorPoint = wxPoint( 0, 0 ); - } - - wxPoint finalMoveVector = params.translation - anchorPoint; - - item->Move( finalMoveVector ); - item->Rotate( item->GetPosition(), params.rotation ); m_canvas->Refresh(); } } diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index 47d2a378f9..9a947d042f 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -845,11 +845,11 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) void FOOTPRINT_EDIT_FRAME::moveExact() { - MOVE_PARAMETERS params; - params.allowOverride = false; - params.editingFootprint = true; + wxPoint translation; + double rotation; + ROTATION_ANCHOR rotationAnchor = ROTATE_AROUND_ITEM_ANCHOR; - DIALOG_MOVE_EXACT dialog( this, params ); + DIALOG_MOVE_EXACT dialog( this, translation, rotation, rotationAnchor ); int ret = dialog.ShowModal(); if( ret == wxID_OK ) @@ -858,17 +858,22 @@ void FOOTPRINT_EDIT_FRAME::moveExact() BOARD_ITEM* item = GetScreen()->GetCurItem(); - wxPoint anchorPoint = item->GetPosition(); + item->Move( translation ); - if( params.origin == RELATIVE_TO_CURRENT_POSITION ) + switch( rotationAnchor ) { - anchorPoint = wxPoint( 0, 0 ); + case ROTATE_AROUND_ITEM_ANCHOR: + item->Rotate( item->GetPosition(), rotation ); + break; + case ROTATE_AROUND_USER_ORIGIN: + item->Rotate( GetScreen()->m_O_Curseur, rotation ); + break; + default: + wxFAIL_MSG( "Rotation choice shouldn't have been available in this context." ); } - wxPoint finalMoveVector = params.translation - anchorPoint; - item->Move( finalMoveVector ); - item->Rotate( item->GetPosition(), params.rotation ); + item->Rotate( item->GetPosition(), rotation ); m_canvas->Refresh(); } @@ -898,15 +903,25 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) case ID_MODEDIT_MODULE_MOVE_EXACT: { - MOVE_PARAMETERS params; + wxPoint translation; + double rotation; + ROTATION_ANCHOR rotationAnchor = ROTATE_AROUND_ITEM_ANCHOR; - DIALOG_MOVE_EXACT dialog( this, params ); - int ret = dialog.ShowModal(); + DIALOG_MOVE_EXACT dialog( this, translation, rotation, rotationAnchor ); - if( ret == wxID_OK ) + if( dialog.ShowModal() == wxID_OK ) { - MoveMarkedItemsExactly( module, wxPoint( 0, 0 ), - params.translation, params.rotation, true ); + switch( rotationAnchor ) + { + case ROTATE_AROUND_ITEM_ANCHOR: + MoveMarkedItemsExactly( module, module->GetPosition() + translation, translation, rotation, true ); + break; + case ROTATE_AROUND_USER_ORIGIN: + MoveMarkedItemsExactly( module, GetScreen()->m_O_Curseur, translation, rotation, true ); + break; + default: + wxFAIL_MSG( "Rotation choice shouldn't have been available in this context." ); + } } break; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 159e4e6e3e..88efeee0c5 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -185,80 +185,6 @@ TOOL_ACTION PCB_ACTIONS::cutToClipboard( "pcbnew.InteractiveEdit.CutToClipboard" _( "Cut" ), _( "Cut selected content to clipboard" ), cut_xpm ); -static wxPoint getAnchorPoint( const SELECTION &selection, const MOVE_PARAMETERS ¶ms ) -{ - wxPoint anchorPoint; - - if( params.origin == RELATIVE_TO_CURRENT_POSITION ) - { - return wxPoint( 0, 0 ); - } - - // set default anchor - VECTOR2I rp = selection.GetCenter(); - anchorPoint = wxPoint( rp.x, rp.y ); - - // If the anchor is not ANCHOR_FROM_LIBRARY then the user applied an override. - // Also run through this block if only one item is slected because it may be a module, - // in which case we want something different than the center of the selection - if( ( params.anchor != ANCHOR_FROM_LIBRARY ) || ( selection.GetSize() == 1 ) ) - { - BOARD_ITEM* topLeftItem = static_cast( selection.GetTopLeftModule() ); - - // no module found if the GetTopLeftModule() returns null - if( topLeftItem != nullptr ) - { - if( topLeftItem->Type() == PCB_MODULE_T ) - { - // Cast to module to allow access to the pads - MODULE* mod = static_cast( topLeftItem ); - - switch( params.anchor ) - { - case ANCHOR_FROM_LIBRARY: - anchorPoint = mod->GetPosition(); - break; - - case ANCHOR_TOP_LEFT_PAD: - topLeftItem = mod->GetTopLeftPad(); - break; - - case ANCHOR_CENTER_FOOTPRINT: - anchorPoint = mod->GetFootprintRect().GetCenter(); - break; - } - } - - if( topLeftItem->Type() == PCB_PAD_T ) - { - if( static_cast( topLeftItem )->GetAttribute() == PAD_ATTRIB_SMD ) - { - // Use the top left corner of SMD pads as an anchor instead of the center - anchorPoint = topLeftItem->GetBoundingBox().GetPosition(); - } - else - { - anchorPoint = topLeftItem->GetPosition(); - } - } - } - else // no module found in the selection - { - // in a selection of non-modules - if( params.anchor == ANCHOR_TOP_LEFT_PAD ) - { - // approach the top left pad override for non-modules by using the position of - // the topleft item as an anchor - topLeftItem = static_cast( selection.GetTopLeftItem() ); - anchorPoint = topLeftItem->GetPosition(); - } - } - } - - return anchorPoint; -} - - void filterItems( GENERAL_COLLECTOR& aCollector, bool sanitizePads, bool ensureEditable ) { // Iterate from the back so we don't have to worry about removals. @@ -340,6 +266,7 @@ bool EDIT_TOOL::Init() m_defaultSelectionFilter = SanitizePadsEnsureEditableFilter; + // Allow pad editing in Footprint Editor if( editFrame->IsType( FRAME_PCB_MODULE_EDITOR ) ) m_defaultSelectionFilter = EnsureEditableFilter; @@ -930,7 +857,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent ) if( routerTool && routerTool->Router() && routerTool->Router()->RoutingInProgress() ) return 0; - // get a copy instead of reference (as we're going to clear the selectio before removing items) + // get a copy instead of reference (as we're going to clear the selection before removing items) auto selection = m_selectionTool->RequestSelection( m_defaultSelectionFilter ); if( m_selectionTool->CheckLock() == SELECTION_LOCKED ) @@ -974,32 +901,46 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent ) return 0; PCB_BASE_FRAME* editFrame = getEditFrame(); + wxPoint translation; + double rotation; + ROTATION_ANCHOR rotationAnchor = selection.Size() > 1 ? ROTATE_AROUND_SEL_CENTER + : ROTATE_AROUND_ITEM_ANCHOR; - MOVE_PARAMETERS params; - params.editingFootprint = m_editModules; - - DIALOG_MOVE_EXACT dialog( editFrame, params ); + DIALOG_MOVE_EXACT dialog( editFrame, translation, rotation, rotationAnchor ); int ret = dialog.ShowModal(); if( ret == wxID_OK ) { VECTOR2I rp = selection.GetCenter(); - wxPoint rotPoint( rp.x, rp.y ); - - wxPoint anchorPoint = getAnchorPoint( selection, params ); - - wxPoint finalMoveVector = params.translation - anchorPoint; + wxPoint selCenter( rp.x, rp.y ); // Make sure the rotation is from the right reference point - rotPoint += finalMoveVector; + selCenter += translation; - for( auto item : selection ) + for( auto selItem : selection ) { + BOARD_ITEM* item = dynamic_cast( selItem ); + if( !item->IsNew() ) m_commit->Modify( item ); - static_cast( item )->Move( finalMoveVector ); - static_cast( item )->Rotate( rotPoint, params.rotation ); + item->Move( translation ); + + switch( rotationAnchor ) + { + case ROTATE_AROUND_ITEM_ANCHOR: + item->Rotate( item->GetPosition(), rotation ); + break; + case ROTATE_AROUND_SEL_CENTER: + item->Rotate( selCenter, rotation ); + break; + case ROTATE_AROUND_USER_ORIGIN: + item->Rotate( editFrame->GetScreen()->m_O_Curseur, rotation ); + break; + case ROTATE_AROUND_AUX_ORIGIN: + item->Rotate( editFrame->GetAuxOrigin(), rotation ); + break; + } if( !m_dragging ) getView()->Update( item ); diff --git a/pcbnew/tools/position_relative_tool.cpp b/pcbnew/tools/position_relative_tool.cpp index ab2c2ac6c3..85169995da 100644 --- a/pcbnew/tools/position_relative_tool.cpp +++ b/pcbnew/tools/position_relative_tool.cpp @@ -53,10 +53,11 @@ TOOL_ACTION PCB_ACTIONS::selectpositionRelativeItem( POSITION_RELATIVE_TOOL::POSITION_RELATIVE_TOOL() : - PCB_TOOL( "pcbnew.PositionRelative" ), m_position_relative_dialog( NULL ), - m_selectionTool( NULL ), m_anchor_item( NULL ) + PCB_TOOL( "pcbnew.PositionRelative" ), + m_position_relative_dialog( NULL ), + m_selectionTool( NULL ), + m_anchor_item( NULL ) { - m_position_relative_rotation = 0.0; } @@ -93,18 +94,15 @@ int POSITION_RELATIVE_TOOL::PositionRelative( const TOOL_EVENT& aEvent ) if( selection.Empty() ) return 0; - m_position_relative_selection = selection; PCB_BASE_FRAME* editFrame = getEditFrame(); - m_position_relative_rotation = 0; if( !m_position_relative_dialog ) m_position_relative_dialog = new DIALOG_POSITION_RELATIVE( editFrame, - m_toolMgr, - m_position_relative_translation, - m_position_relative_rotation, - m_anchor_position ); + m_toolMgr, + m_position_relative_translation, + m_anchor_position ); m_position_relative_dialog->Show( true ); @@ -121,7 +119,7 @@ static bool selectPRitem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition ) aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - const SELECTION& selection = selectionTool->RequestSelection( SanitizePadsFilter ); + const SELECTION& selection = selectionTool->RequestSelection( EnsureEditableFilter ); if( selection.Empty() ) return true; @@ -179,7 +177,7 @@ void POSITION_RELATIVE_TOOL::UpdateAnchor( BOARD_ITEM* aItem ) m_anchor_item = aItem; if( m_position_relative_dialog ) - m_position_relative_dialog->UpdateAnchor( aItem->GetPosition() ); + m_position_relative_dialog->UpdateAnchor( aItem ); } diff --git a/pcbnew/tools/position_relative_tool.h b/pcbnew/tools/position_relative_tool.h index 0eb4374191..ebafac291e 100644 --- a/pcbnew/tools/position_relative_tool.h +++ b/pcbnew/tools/position_relative_tool.h @@ -105,16 +105,13 @@ private: ///> Last anchor item selected by Position Relative To function. BOARD_ITEM* m_anchor_item; - ///> Translation for position relative function. + ///> Translation for Position Relative To function. wxPoint m_position_relative_translation; - ///> Anchor position for positive relative function. + ///> Anchor position for Position Relative To function. wxPoint m_anchor_position; - ///> Rotation for positive relative function. - double m_position_relative_rotation; - - ///> Selected that will be moved by Position relative function. + ///> Selection that will be moved by Position Relative To function. SELECTION m_position_relative_selection; };