Removed redundant accessor calls in MODULE_TOOLS.
This commit is contained in:
parent
ed88c40be5
commit
cf79b4c64f
|
@ -210,22 +210,20 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
m_controls->SetSnapping( true );
|
||||||
controls->SetSnapping( true );
|
m_controls->ShowCursor( true );
|
||||||
controls->ShowCursor( true );
|
m_controls->SetAutoPan( true );
|
||||||
controls->SetAutoPan( true );
|
|
||||||
|
|
||||||
PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
|
m_frame->DisplayToolMsg( _( "Select reference point" ) );
|
||||||
frame->DisplayToolMsg( _( "Select reference point" ) );
|
|
||||||
|
|
||||||
bool cancelled = false;
|
bool cancelled = false;
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
|
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||||
|
|
||||||
while( OPT_TOOL_EVENT evt = Wait() )
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
{
|
{
|
||||||
if( evt->IsMotion() )
|
if( evt->IsMotion() )
|
||||||
{
|
{
|
||||||
cursorPos = getViewControls()->GetCursorPosition();
|
cursorPos = m_controls->GetCursorPosition();
|
||||||
}
|
}
|
||||||
else if( evt->IsClick( BUT_LEFT ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
|
@ -243,7 +241,7 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
|
||||||
PCB_IO io( CTL_FOR_CLIPBOARD );
|
PCB_IO io( CTL_FOR_CLIPBOARD );
|
||||||
|
|
||||||
// Create a temporary module that contains selected items to ease serialization
|
// Create a temporary module that contains selected items to ease serialization
|
||||||
MODULE module( getModel<BOARD>() );
|
MODULE module( m_board );
|
||||||
|
|
||||||
for( int i = 0; i < selection.Size(); ++i )
|
for( int i = 0; i < selection.Size(); ++i )
|
||||||
{
|
{
|
||||||
|
@ -257,7 +255,7 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the new relative internal local coordinates of copied items
|
// Set the new relative internal local coordinates of copied items
|
||||||
MODULE* editedModule = getModel<BOARD>()->m_Modules;
|
MODULE* editedModule = m_board->m_Modules;
|
||||||
wxPoint moveVector = module.GetPosition() + editedModule->GetPosition() -
|
wxPoint moveVector = module.GetPosition() + editedModule->GetPosition() -
|
||||||
wxPoint( cursorPos.x, cursorPos.y );
|
wxPoint( cursorPos.x, cursorPos.y );
|
||||||
module.MoveAnchorPosition( moveVector );
|
module.MoveAnchorPosition( moveVector );
|
||||||
|
@ -267,10 +265,10 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->SaveClipboard( data );
|
m_toolMgr->SaveClipboard( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->DisplayToolMsg( wxString::Format( _( "Copied %d item(s)" ), selection.Size() ) );
|
m_frame->DisplayToolMsg( wxString::Format( _( "Copied %d item(s)" ), selection.Size() ) );
|
||||||
controls->SetSnapping( false );
|
m_controls->SetSnapping( false );
|
||||||
controls->ShowCursor( false );
|
m_controls->ShowCursor( false );
|
||||||
controls->SetAutoPan( false );
|
m_controls->SetAutoPan( false );
|
||||||
|
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
|
||||||
|
@ -282,7 +280,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
// Parse clipboard
|
// Parse clipboard
|
||||||
PCB_IO io( CTL_FOR_CLIPBOARD );
|
PCB_IO io( CTL_FOR_CLIPBOARD );
|
||||||
MODULE* currentModule = getModel<BOARD>()->m_Modules;
|
MODULE* currentModule = m_board->m_Modules;
|
||||||
MODULE* pastedModule = NULL;
|
MODULE* pastedModule = NULL;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -300,31 +298,27 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Placement tool part
|
// Placement tool part
|
||||||
KIGFX::VIEW* view = getView();
|
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
|
||||||
BOARD* board = getModel<BOARD>();
|
|
||||||
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
|
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
|
|
||||||
|
|
||||||
// Add a VIEW_GROUP that serves as a preview for the new item
|
// Add a VIEW_GROUP that serves as a preview for the new item
|
||||||
KIGFX::VIEW_GROUP preview( view );
|
KIGFX::VIEW_GROUP preview( m_view );
|
||||||
pastedModule->SetParent( board );
|
pastedModule->SetParent( m_board );
|
||||||
pastedModule->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
pastedModule->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||||
pastedModule->RunOnChildren( boost::bind( &KIGFX::VIEW_GROUP::Add, boost::ref( preview ), _1 ) );
|
pastedModule->RunOnChildren( boost::bind( &KIGFX::VIEW_GROUP::Add, boost::ref( preview ), _1 ) );
|
||||||
preview.Add( pastedModule );
|
preview.Add( pastedModule );
|
||||||
view->Add( &preview );
|
m_view->Add( &preview );
|
||||||
|
|
||||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear );
|
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear );
|
||||||
controls->ShowCursor( true );
|
m_controls->ShowCursor( true );
|
||||||
controls->SetSnapping( true );
|
m_controls->SetSnapping( true );
|
||||||
controls->SetAutoPan( true );
|
m_controls->SetAutoPan( true );
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( OPT_TOOL_EVENT evt = Wait() )
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
{
|
{
|
||||||
cursorPos = controls->GetCursorPosition();
|
cursorPos = m_controls->GetCursorPosition();
|
||||||
|
|
||||||
if( evt->IsMotion() )
|
if( evt->IsMotion() )
|
||||||
{
|
{
|
||||||
|
@ -336,7 +330,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( evt->IsAction( &COMMON_ACTIONS::rotate ) )
|
if( evt->IsAction( &COMMON_ACTIONS::rotate ) )
|
||||||
{
|
{
|
||||||
pastedModule->Rotate( pastedModule->GetPosition(), frame->GetRotationAngle() );
|
pastedModule->Rotate( pastedModule->GetPosition(), m_frame->GetRotationAngle() );
|
||||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||||
}
|
}
|
||||||
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
|
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
|
||||||
|
@ -353,10 +347,10 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_LEFT ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
frame->OnModify();
|
m_frame->OnModify();
|
||||||
frame->SaveCopyInUndoList( currentModule, UR_MODEDIT );
|
m_frame->SaveCopyInUndoList( currentModule, UR_MODEDIT );
|
||||||
|
|
||||||
board->m_Status_Pcb = 0; // I have no clue why, but it is done in the legacy view
|
m_board->m_Status_Pcb = 0; // I have no clue why, but it is done in the legacy view
|
||||||
currentModule->SetLastEditTime();
|
currentModule->SetLastEditTime();
|
||||||
|
|
||||||
// MODULE::RunOnChildren is infeasible here: we need to create copies of items, do not
|
// MODULE::RunOnChildren is infeasible here: we need to create copies of items, do not
|
||||||
|
@ -368,7 +362,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
currentModule->Add( clone );
|
currentModule->Add( clone );
|
||||||
clone->SetLocalCoord();
|
clone->SetLocalCoord();
|
||||||
view->Add( clone );
|
m_view->Add( clone );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( BOARD_ITEM* drawing = pastedModule->GraphicalItems();
|
for( BOARD_ITEM* drawing = pastedModule->GraphicalItems();
|
||||||
|
@ -393,7 +387,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
|
||||||
edge->SetLocalCoord();
|
edge->SetLocalCoord();
|
||||||
}
|
}
|
||||||
|
|
||||||
view->Add( clone );
|
m_view->Add( clone );
|
||||||
}
|
}
|
||||||
|
|
||||||
preview.Clear();
|
preview.Clear();
|
||||||
|
@ -403,10 +397,10 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pastedModule;
|
delete pastedModule;
|
||||||
controls->ShowCursor( false );
|
m_controls->ShowCursor( false );
|
||||||
controls->SetSnapping( false );
|
m_controls->SetSnapping( false );
|
||||||
controls->SetAutoPan( false );
|
m_controls->SetAutoPan( false );
|
||||||
view->Remove( &preview );
|
m_view->Remove( &preview );
|
||||||
|
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue