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)
This commit is contained in:
Jeff Young 2018-06-12 08:36:35 +01:00
parent 5ce0f8ba54
commit 2ff414adb4
18 changed files with 1673 additions and 2781 deletions

View File

@ -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 );

View File

@ -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.

View File

@ -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;

View File

@ -23,11 +23,6 @@
*/
#include <pcb_edit_frame.h>
#include <base_units.h>
#include <macros.h>
#include <footprint_edit_frame.h>
#include <widgets/text_ctrl_eval.h>
#include "dialog_move_exact.h"
@ -35,103 +30,69 @@
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 <space> 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 <place> 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 <place> 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 );
}
@ -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<MOVE_EXACT_ORIGIN>( m_originChooser->GetSelection() );
if( m_cbOverride->IsChecked() && m_allowOverride )
{
m_anchor = static_cast<MOVE_EXACT_ANCHOR>( 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<MOVE_EXACT_ANCHOR>( 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;
}

View File

@ -26,54 +26,38 @@
#define __DIALOG_MOVE_EXACT__
#include <vector>
// Include the wxFormBuider header base:
#include <widgets/unit_binder.h>
#include <dialog_move_exact_base.h>
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:
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;
ROTATION_ANCHOR& m_rotationAnchor;
UNIT_BINDER m_moveX;
UNIT_BINDER m_moveY;
UNIT_BINDER m_rotate;
std::vector<ROTATION_ANCHOR> 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,8 +88,10 @@ 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
@ -119,18 +102,14 @@ private:
double entry1;
double entry2;
double entryRotation;
MOVE_EXACT_ORIGIN origin;
MOVE_EXACT_ANCHOR anchor;
bool overrideAnchor;
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 )
{
}
};

View File

@ -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 );
}

View File

@ -44,7 +44,7 @@
<property name="minimum_size">-1,-1</property>
<property name="name">DIALOG_MOVE_EXACT_BASE</property>
<property name="pos"></property>
<property name="size">427,250</property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Move Item</property>
@ -93,113 +93,16 @@
<property name="name">bMainSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Use polar coordinates</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_polarCoords</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox">OnPolarChanged</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bMiddleSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxBOTTOM|wxEXPAND|wxTOP</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="0">
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">4</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="hgap">5</property>
<property name="minimum_size"></property>
<property name="name">fgInputSizer</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
@ -208,7 +111,7 @@
<property name="vgap">0</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -238,7 +141,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">X:</property>
<property name="label">Move X:</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -291,7 +194,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
@ -340,7 +243,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
@ -382,7 +285,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxTOP|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -465,7 +368,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="0">
<property name="BottomDockable">1</property>
@ -553,7 +456,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -583,7 +486,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Y:</property>
<property name="label">Move Y:</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -636,7 +539,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxEXPAND|wxTOP|wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
@ -685,7 +588,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
@ -727,7 +630,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -810,7 +713,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="0">
<property name="BottomDockable">1</property>
@ -898,7 +801,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -928,7 +831,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Item rotation:</property>
<property name="label">Rotate:</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -981,7 +884,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxEXPAND|wxTOP|wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
@ -1030,7 +933,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
@ -1072,7 +975,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -1155,7 +1058,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="0">
<property name="BottomDockable">1</property>
@ -1241,200 +1144,19 @@
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxRadioBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Current position&quot; &quot;User origin&quot; &quot;Grid origin&quot; &quot;Drill/Place origin&quot; &quot;Sheet origin&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Move Relative To:</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_originChooser</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRadioBox">OnOriginChanged</event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bAnchorSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">1</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Override default footprint anchor with:</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbOverride</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox">OnOverrideChanged</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
<property name="flag">wxEXPAND|wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="1">
<property name="BottomDockable">1</property>
@ -1450,7 +1172,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Top left pad&quot; &quot;Footprint center&quot;</property>
<property name="choices">&quot;Rotate around center of selection&quot; &quot;Rotate around User Origin&quot; &quot;Rotate around Drill/Place Origin&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
@ -1472,7 +1194,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_anchorChoice</property>
<property name="name">m_anchorOptions</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1484,7 +1206,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
@ -1523,8 +1245,8 @@
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="border">10</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="0">
<property name="BottomDockable">1</property>
@ -1603,10 +1325,107 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bBottomSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">10</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Use polar coordinates</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_polarCoords</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox">OnPolarChanged</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<property name="proportion">1</property>
<object class="wxStdDialogButtonSizer" expanded="0">
<property name="Apply">0</property>
<property name="Cancel">1</property>
@ -1632,4 +1451,6 @@
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
class TEXT_CTRL_EVAL;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/checkbox.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/radiobox.h>
#include <wx/choice.h>
#include <wx/sizer.h>
#include <wx/statline.h>
#include <wx/checkbox.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@ -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();
};

View File

@ -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 <pcb_edit_frame.h>
#include <base_units.h>
#include <macros.h>
#include <widgets/text_ctrl_eval.h>
#include <footprint_edit_frame.h>
#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();
}
@ -86,8 +68,8 @@ 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 ) );
@ -95,8 +77,8 @@ bool DIALOG_POSITION_RELATIVE::GetTranslationInIU( wxPoint& val, bool polar )
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<POSITION_RELATIVE_TOOL>();
wxASSERT( posrelTool );
m_referenceInfo->SetLabel( _( "Reference item: <click item on canvas to select>" ) );
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 = _( "<none selected>" );
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<POSITION_RELATIVE_TOOL>();
wxASSERT( posrelTool );
posrelTool->RelativeItemSelectionMove( m_anchor_position, m_translation, m_rotation );
posrelTool->RelativeItemSelectionMove( m_anchor_position, m_translation, 0.0 );
event.Skip();
}

View File

@ -29,6 +29,7 @@
#include <dialogs/dialog_position_relative_base.h>
#include <tool/tool_manager.h>
#include <widgets/unit_binder.h>
#include "tools/position_relative_tool.h"
class DIALOG_POSITION_RELATIVE : public DIALOG_POSITION_RELATIVE_BASE
@ -37,16 +38,18 @@ private:
TOOL_MANAGER* m_toolMgr;
wxPoint& m_translation;
double& m_rotation;
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:
@ -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 )
{
}
};

View File

@ -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: <none selected>"), 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 );
}

File diff suppressed because it is too large Load Diff

View File

@ -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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
class TEXT_CTRL_EVAL;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
@ -21,11 +18,11 @@ class TEXT_CTRL_EVAL;
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/statline.h>
#include <wx/checkbox.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statline.h>
#include <wx/textctrl.h>
#include <wx/checkbox.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@ -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();
};

View File

@ -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<MODULE*>( 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();
}
case ROTATE_AROUND_ITEM_ANCHOR:
item->Rotate( item->GetPosition(), rotation );
break;
case ANCHOR_CENTER_FOOTPRINT:
anchorPoint = mod->GetFootprintRect().GetCenter();
case ROTATE_AROUND_USER_ORIGIN:
item->Rotate( GetScreen()->m_O_Curseur, rotation );
break;
case ANCHOR_FROM_LIBRARY:
; // nothing to do
}
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();
}
}

View File

@ -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;

View File

@ -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 &params )
{
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<BOARD_ITEM*>( 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<MODULE*>( 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<D_PAD*>( 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<BOARD_ITEM*>( 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<PCB_BASE_FRAME>();
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<BOARD_ITEM*>( selItem );
if( !item->IsNew() )
m_commit->Modify( item );
static_cast<BOARD_ITEM*>( item )->Move( finalMoveVector );
static_cast<BOARD_ITEM*>( 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 );

View File

@ -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,17 +94,14 @@ int POSITION_RELATIVE_TOOL::PositionRelative( const TOOL_EVENT& aEvent )
if( selection.Empty() )
return 0;
m_position_relative_selection = selection;
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
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_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 );
}

View File

@ -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;
};