Removed code resetting VIEW_CONTROLS settings
As the VIEW_CONTROLS settings are managed for each tool, there is no need to restore the settings to initial state when a tool is finished.
This commit is contained in:
parent
ac38f1112d
commit
3174573361
|
@ -421,11 +421,6 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
m_controls->ShowCursor( false );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
|
||||
m_view->Remove( &preview );
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
||||
|
@ -603,12 +598,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
|||
if( step != SET_ORIGIN )
|
||||
delete dimension;
|
||||
|
||||
m_controls->ShowCursor( false );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_view->Remove( &preview );
|
||||
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
||||
return 0;
|
||||
|
@ -826,11 +816,6 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
preview.Clear();
|
||||
|
||||
m_controls->ShowCursor( false );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_view->Remove( &preview );
|
||||
|
||||
return 0;
|
||||
|
@ -879,11 +864,6 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
|||
break;
|
||||
}
|
||||
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->ShowCursor( false );
|
||||
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
||||
return 0;
|
||||
|
@ -1053,10 +1033,6 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
|
|||
}
|
||||
}
|
||||
|
||||
m_controls->ShowCursor( false );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_view->Remove( &preview );
|
||||
|
||||
return started;
|
||||
|
@ -1223,18 +1199,13 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
|
|||
}
|
||||
}
|
||||
|
||||
m_controls->ShowCursor( false );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_view->Remove( &preview );
|
||||
|
||||
return ( step > SET_ORIGIN );
|
||||
}
|
||||
|
||||
|
||||
std::unique_ptr<ZONE_CONTAINER> DRAWING_TOOL::createNewZone(
|
||||
bool aKeepout )
|
||||
std::unique_ptr<ZONE_CONTAINER> DRAWING_TOOL::createNewZone( bool aKeepout )
|
||||
{
|
||||
const auto& board = *getModel<BOARD>();
|
||||
|
||||
|
@ -1541,12 +1512,7 @@ int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode )
|
|||
}
|
||||
}
|
||||
|
||||
m_controls->ShowCursor( false );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_view->Remove( &preview );
|
||||
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -425,9 +425,6 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
else
|
||||
m_commit->Push( _( "Drag" ) );
|
||||
|
||||
controls->ShowCursor( false );
|
||||
controls->SetAutoPan( false );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -193,11 +193,7 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
m_controls->ShowCursor( false );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_view->Remove( &preview );
|
||||
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
||||
return 0;
|
||||
|
@ -341,7 +337,6 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
m_frame->DisplayToolMsg( wxEmptyString );
|
||||
m_controls->ShowCursor( false );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -409,9 +404,6 @@ int MODULE_EDITOR_TOOLS::CopyItems( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
m_frame->DisplayToolMsg( wxString::Format( _( "Copied %d item(s)" ), selection.Size() ) );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->ShowCursor( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -528,9 +520,6 @@ int MODULE_EDITOR_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
delete pastedModule;
|
||||
m_controls->ShowCursor( false );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_view->Remove( &preview );
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -481,12 +481,7 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
controls->ShowCursor( false );
|
||||
controls->SetSnapping( false );
|
||||
controls->SetAutoPan( false );
|
||||
controls->CaptureCursor( false );
|
||||
view->Remove( &preview );
|
||||
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -254,113 +254,109 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||
|
||||
if( selection.Size() == 1 )
|
||||
if( selection.Size() != 1 )
|
||||
return 0;
|
||||
|
||||
Activate();
|
||||
|
||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||
KIGFX::VIEW* view = getView();
|
||||
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
||||
auto item = selection.Front();
|
||||
|
||||
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
|
||||
|
||||
if( !m_editPoints )
|
||||
return 0;
|
||||
|
||||
view->Add( m_editPoints.get() );
|
||||
m_editedPoint = NULL;
|
||||
bool modified = false;
|
||||
|
||||
BOARD_COMMIT commit( editFrame );
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
{
|
||||
Activate();
|
||||
|
||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||
KIGFX::VIEW* view = getView();
|
||||
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
||||
auto item = selection.Front();
|
||||
|
||||
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
|
||||
|
||||
if( !m_editPoints )
|
||||
return 0;
|
||||
|
||||
view->Add( m_editPoints.get() );
|
||||
m_editedPoint = NULL;
|
||||
bool modified = false;
|
||||
|
||||
BOARD_COMMIT commit( editFrame );
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
if( !m_editPoints ||
|
||||
evt->Matches( m_selectionTool->ClearedEvent ) ||
|
||||
evt->Matches( m_selectionTool->UnselectedEvent ) ||
|
||||
evt->Matches( m_selectionTool->SelectedEvent ) )
|
||||
{
|
||||
if( !m_editPoints ||
|
||||
evt->Matches( m_selectionTool->ClearedEvent ) ||
|
||||
evt->Matches( m_selectionTool->UnselectedEvent ) ||
|
||||
evt->Matches( m_selectionTool->SelectedEvent ) )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !modified )
|
||||
updateEditedPoint( *evt );
|
||||
|
||||
if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
|
||||
{
|
||||
if( !modified )
|
||||
{
|
||||
break;
|
||||
commit.StageItems( selection, CHT_MODIFY );
|
||||
|
||||
controls->ForceCursorPosition( false );
|
||||
m_original = *m_editedPoint; // Save the original position
|
||||
controls->SetAutoPan( true );
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if ( !modified )
|
||||
updateEditedPoint( *evt );
|
||||
bool enableAltConstraint = !!evt->Modifier( MD_CTRL );
|
||||
|
||||
if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
|
||||
{
|
||||
if( !modified )
|
||||
{
|
||||
commit.StageItems( selection, CHT_MODIFY );
|
||||
if( enableAltConstraint != (bool) m_altConstraint ) // alternative constraint
|
||||
setAltConstraint( enableAltConstraint );
|
||||
|
||||
controls->ForceCursorPosition( false );
|
||||
m_original = *m_editedPoint; // Save the original position
|
||||
controls->SetAutoPan( true );
|
||||
modified = true;
|
||||
}
|
||||
|
||||
bool enableAltConstraint = !!evt->Modifier( MD_CTRL );
|
||||
|
||||
if( enableAltConstraint != (bool) m_altConstraint ) // alternative constraint
|
||||
setAltConstraint( enableAltConstraint );
|
||||
|
||||
m_editedPoint->SetPosition( controls->GetCursorPosition() );
|
||||
|
||||
if( m_altConstraint )
|
||||
m_altConstraint->Apply();
|
||||
else
|
||||
m_editedPoint->ApplyConstraint();
|
||||
|
||||
updateItem();
|
||||
updatePoints();
|
||||
}
|
||||
|
||||
else if( evt->IsMouseUp( BUT_LEFT ) )
|
||||
{
|
||||
controls->SetAutoPan( false );
|
||||
setAltConstraint( false );
|
||||
|
||||
if( modified )
|
||||
{
|
||||
commit.Push( _( "Drag a line ending" ) );
|
||||
modified = false;
|
||||
}
|
||||
|
||||
m_toolMgr->PassEvent();
|
||||
}
|
||||
|
||||
else if( evt->IsCancel() )
|
||||
{
|
||||
if( modified ) // Restore the last change
|
||||
{
|
||||
commit.Revert();
|
||||
updatePoints();
|
||||
modified = false;
|
||||
}
|
||||
|
||||
// Let the selection tool receive the event too
|
||||
m_toolMgr->PassEvent();
|
||||
|
||||
break;
|
||||
}
|
||||
m_editedPoint->SetPosition( controls->GetCursorPosition() );
|
||||
|
||||
if( m_altConstraint )
|
||||
m_altConstraint->Apply();
|
||||
else
|
||||
{
|
||||
m_toolMgr->PassEvent();
|
||||
}
|
||||
m_editedPoint->ApplyConstraint();
|
||||
|
||||
updateItem();
|
||||
updatePoints();
|
||||
}
|
||||
|
||||
if( m_editPoints )
|
||||
else if( evt->IsMouseUp( BUT_LEFT ) )
|
||||
{
|
||||
finishItem();
|
||||
view->Remove( m_editPoints.get() );
|
||||
m_editPoints.reset();
|
||||
controls->SetAutoPan( false );
|
||||
setAltConstraint( false );
|
||||
|
||||
if( modified )
|
||||
{
|
||||
commit.Push( _( "Drag a line ending" ) );
|
||||
modified = false;
|
||||
}
|
||||
|
||||
m_toolMgr->PassEvent();
|
||||
}
|
||||
|
||||
controls->ShowCursor( false );
|
||||
controls->SetAutoPan( false );
|
||||
controls->SetSnapping( false );
|
||||
else if( evt->IsCancel() )
|
||||
{
|
||||
if( modified ) // Restore the last change
|
||||
{
|
||||
commit.Revert();
|
||||
updatePoints();
|
||||
modified = false;
|
||||
}
|
||||
|
||||
// Let the selection tool receive the event too
|
||||
m_toolMgr->PassEvent();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
m_toolMgr->PassEvent();
|
||||
}
|
||||
}
|
||||
|
||||
if( m_editPoints )
|
||||
{
|
||||
finishItem();
|
||||
view->Remove( m_editPoints.get() );
|
||||
m_editPoints.reset();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue