diff --git a/pcbnew/tools/common_actions.cpp b/pcbnew/tools/common_actions.cpp index 2a6aa25305..285d662aed 100644 --- a/pcbnew/tools/common_actions.cpp +++ b/pcbnew/tools/common_actions.cpp @@ -223,6 +223,10 @@ TOOL_ACTION COMMON_ACTIONS::gridPrev( "pcbnew.gridPrev", AS_GLOBAL, MD_CTRL + int( '`' ), "", "" ); +TOOL_ACTION COMMON_ACTIONS::gridSetOrigin( "pcbnew.gridSetOrigin", + AS_GLOBAL, 0, + "", "" ); + // Track & via size control TOOL_ACTION COMMON_ACTIONS::trackWidthInc( "pcbnew.trackWidthInc", @@ -241,7 +245,9 @@ TOOL_ACTION COMMON_ACTIONS::viaSizeDec( "pcbnew.viaSizeDec", AS_GLOBAL, '\\', "", "" ); -TOOL_ACTION COMMON_ACTIONS::trackViaSizeChanged( "pcbnew.trackViaSizeChanged", AS_GLOBAL, 0, "", "" ); +TOOL_ACTION COMMON_ACTIONS::trackViaSizeChanged( "pcbnew.trackViaSizeChanged", + AS_GLOBAL, 0, + "", "" ); // Miscellaneous TOOL_ACTION COMMON_ACTIONS::resetCoords( "pcbnew.resetCoords", @@ -290,6 +296,9 @@ std::string COMMON_ACTIONS::TranslateLegacyId( int aId ) case ID_PCB_MIRE_BUTT: return COMMON_ACTIONS::placeTarget.GetName(); + + case ID_PCB_PLACE_GRID_COORD_BUTT: + return COMMON_ACTIONS::gridSetOrigin.GetName(); } return ""; diff --git a/pcbnew/tools/common_actions.h b/pcbnew/tools/common_actions.h index 671a509699..428115bb6e 100644 --- a/pcbnew/tools/common_actions.h +++ b/pcbnew/tools/common_actions.h @@ -130,6 +130,7 @@ public: static TOOL_ACTION gridFast2; static TOOL_ACTION gridNext; static TOOL_ACTION gridPrev; + static TOOL_ACTION gridSetOrigin; // Track & via size control static TOOL_ACTION trackWidthInc; diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 3fb689e71f..f6b52d08bd 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -412,6 +412,39 @@ int PCBNEW_CONTROL::GridPrev( TOOL_EVENT& aEvent ) } +int PCBNEW_CONTROL::GridSetOrigin( TOOL_EVENT& aEvent ) +{ + Activate(); + getEditFrame()->SetToolID( ID_PCB_PLACE_GRID_COORD_BUTT, wxCURSOR_PENCIL, + _( "Adjust grid origin" ) ); + + KIGFX::VIEW_CONTROLS* controls = getViewControls(); + controls->ShowCursor( true ); + controls->SetSnapping( true ); + controls->SetAutoPan( true ); + + while( OPT_TOOL_EVENT evt = Wait() ) + { + if( evt->IsClick( BUT_LEFT ) ) + { + getView()->GetGAL()->SetGridOrigin( controls->GetCursorPosition() ); + getView()->MarkDirty(); + } + + else if( evt->IsCancel() ) + break; + } + + controls->SetAutoPan( false ); + controls->SetSnapping( false ); + controls->ShowCursor( false ); + setTransitions(); + m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); + + return 0; +} + + // Track & via size control int PCBNEW_CONTROL::TrackWidthInc( TOOL_EVENT& aEvent ) { @@ -574,6 +607,7 @@ void PCBNEW_CONTROL::setTransitions() Go( &PCBNEW_CONTROL::GridFast2, COMMON_ACTIONS::gridFast2.MakeEvent() ); Go( &PCBNEW_CONTROL::GridNext, COMMON_ACTIONS::gridNext.MakeEvent() ); Go( &PCBNEW_CONTROL::GridPrev, COMMON_ACTIONS::gridPrev.MakeEvent() ); + Go( &PCBNEW_CONTROL::GridSetOrigin, COMMON_ACTIONS::gridSetOrigin.MakeEvent() ); // Track & via size control Go( &PCBNEW_CONTROL::TrackWidthInc, COMMON_ACTIONS::trackWidthInc.MakeEvent() ); diff --git a/pcbnew/tools/pcbnew_control.h b/pcbnew/tools/pcbnew_control.h index 8acc0fba8c..e4920484db 100644 --- a/pcbnew/tools/pcbnew_control.h +++ b/pcbnew/tools/pcbnew_control.h @@ -79,6 +79,7 @@ public: int GridFast2( TOOL_EVENT& aEvent ); int GridNext( TOOL_EVENT& aEvent ); int GridPrev( TOOL_EVENT& aEvent ); + int GridSetOrigin( TOOL_EVENT& aEvent ); // Track & via size control int TrackWidthInc( TOOL_EVENT& aEvent ); diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index f7e5b374c2..3a2e62416a 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -212,7 +212,7 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent ) PCB_EDIT_FRAME* editFrame = getEditFrame(); EDA_ITEM* item = selection.items.GetPickedItem( 0 ); - m_editPoints = EDIT_POINTS_FACTORY::Make( item, m_toolMgr->GetView()->GetGAL() ); + m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() ); if( !m_editPoints ) { setTransitions();