Commit 0d734e88 authored by Maciej Suminski's avatar Maciej Suminski

Placing the grid origin is possible with GAL.

parent 20f512e5
......@@ -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 "";
......
......@@ -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;
......
......@@ -412,6 +412,39 @@ int PCBNEW_CONTROL::GridPrev( TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::GridSetOrigin( TOOL_EVENT& aEvent )
{
Activate();
getEditFrame<PCB_EDIT_FRAME>()->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() );
......
......@@ -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 );
......
......@@ -212,7 +212,7 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment