TOOL_EVENT: make command string non-optional
We're getting segfaults in places where this isn't checked. Also, add some asserts so we can catch bad tool push/pop. Removes all uses of GetCommandStr() and makes it private.
This commit is contained in:
parent
b7ba24b2d9
commit
9304607624
|
@ -77,8 +77,7 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
int finalize_state = WAIT_CANCEL;
|
int finalize_state = WAIT_CANCEL;
|
||||||
|
|
||||||
std::string tool = *aEvent.Parameter<std::string*>();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
setControls();
|
setControls();
|
||||||
|
@ -194,7 +193,7 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
controls->ForceCursorPosition( false );
|
controls->ForceCursorPosition( false );
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,8 +180,7 @@ const std::string TOOL_EVENT::Format() const
|
||||||
ev += tmp;
|
ev += tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_commandStr )
|
ev += "cmd-str: " + m_commandStr;
|
||||||
ev += "cmd-str: " + ( *m_commandStr );
|
|
||||||
|
|
||||||
return ev;
|
return ev;
|
||||||
}
|
}
|
||||||
|
@ -212,9 +211,9 @@ bool TOOL_EVENT::IsDblClick( int aButtonMask ) const
|
||||||
|
|
||||||
bool TOOL_EVENT::IsCancelInteractive() const
|
bool TOOL_EVENT::IsCancelInteractive() const
|
||||||
{
|
{
|
||||||
return ( ( m_commandStr && *m_commandStr == ACTIONS::cancelInteractive.GetName() )
|
return ( ( m_commandStr == ACTIONS::cancelInteractive.GetName() )
|
||||||
|| ( m_commandId && *m_commandId == ACTIONS::cancelInteractive.GetId() )
|
|| ( m_commandId && *m_commandId == ACTIONS::cancelInteractive.GetId() )
|
||||||
|| ( m_actions == TA_CANCEL_TOOL ) );
|
|| ( m_actions == TA_CANCEL_TOOL ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -229,26 +228,24 @@ bool TOOL_EVENT::IsSelectionEvent() const
|
||||||
|
|
||||||
bool TOOL_EVENT::IsPointEditor() const
|
bool TOOL_EVENT::IsPointEditor() const
|
||||||
{
|
{
|
||||||
return ( ( m_commandStr && m_commandStr->find( "PointEditor" ) != GetCommandStr()->npos )
|
return ( ( m_commandStr.find( "PointEditor" ) != getCommandStr().npos )
|
||||||
|| ( m_commandId && *m_commandId == ACTIONS::activatePointEditor.GetId() ) );
|
|| ( m_commandId && *m_commandId == ACTIONS::activatePointEditor.GetId() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TOOL_EVENT::IsMoveTool() const
|
bool TOOL_EVENT::IsMoveTool() const
|
||||||
{
|
{
|
||||||
return ( m_commandStr
|
return ( m_commandStr.find( "InteractiveMove" ) != getCommandStr().npos );
|
||||||
&& m_commandStr->find( "InteractiveMove" ) != GetCommandStr()->npos );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TOOL_EVENT::IsEditorTool() const
|
bool TOOL_EVENT::IsEditorTool() const
|
||||||
{
|
{
|
||||||
return ( m_commandStr
|
return ( m_commandStr.find( "InteractiveEdit" ) != getCommandStr().npos );
|
||||||
&& m_commandStr->find( "InteractiveEdit" ) != GetCommandStr()->npos );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TOOL_EVENT::IsSimulator() const
|
bool TOOL_EVENT::IsSimulator() const
|
||||||
{
|
{
|
||||||
return ( m_commandStr && m_commandStr->find( "Simulation" ) != GetCommandStr()->npos );
|
return ( m_commandStr.find( "Simulation" ) != getCommandStr().npos );
|
||||||
}
|
}
|
||||||
|
|
|
@ -829,7 +829,7 @@ bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( aEvent.IsActivate() )
|
if( aEvent.IsActivate() )
|
||||||
{
|
{
|
||||||
auto tool = m_toolNameIndex.find( *aEvent.GetCommandStr() );
|
auto tool = m_toolNameIndex.find( aEvent.getCommandStr() );
|
||||||
|
|
||||||
if( tool != m_toolNameIndex.end() )
|
if( tool != m_toolNameIndex.end() )
|
||||||
{
|
{
|
||||||
|
@ -1153,9 +1153,8 @@ bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent )
|
||||||
if( GetToolHolder() && !GetToolHolder()->GetDoImmediateActions() )
|
if( GetToolHolder() && !GetToolHolder()->GetDoImmediateActions() )
|
||||||
{
|
{
|
||||||
// An tool-selection-event has no position
|
// An tool-selection-event has no position
|
||||||
if( mod_event.GetCommandStr()
|
if( mod_event.getCommandStr() != GetToolHolder()->CurrentToolName()
|
||||||
&& *mod_event.GetCommandStr() != GetToolHolder()->CurrentToolName()
|
&& !mod_event.ForceImmediate() )
|
||||||
&& !mod_event.ForceImmediate() )
|
|
||||||
{
|
{
|
||||||
mod_event.SetHasPosition( false );
|
mod_event.SetHasPosition( false );
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,12 @@ TOOLS_HOLDER::TOOLS_HOLDER() :
|
||||||
|
|
||||||
|
|
||||||
// TODO: Implement an RAII mechanism for the stack PushTool/PopTool pairs
|
// TODO: Implement an RAII mechanism for the stack PushTool/PopTool pairs
|
||||||
void TOOLS_HOLDER::PushTool( const std::string& actionName )
|
void TOOLS_HOLDER::PushTool( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
|
const std::string& actionName = aEvent.getCommandStr();
|
||||||
|
|
||||||
|
wxASSERT_MSG( !actionName.empty(), "Pushed Empty Tool Name!" );
|
||||||
|
|
||||||
m_toolStack.push_back( actionName );
|
m_toolStack.push_back( actionName );
|
||||||
|
|
||||||
// Human cognitive stacking is very shallow; deeper tool stacks just get annoying
|
// Human cognitive stacking is very shallow; deeper tool stacks just get annoying
|
||||||
|
@ -58,8 +62,12 @@ void TOOLS_HOLDER::PushTool( const std::string& actionName )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TOOLS_HOLDER::PopTool( const std::string& actionName )
|
void TOOLS_HOLDER::PopTool( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
|
const std::string& actionName = aEvent.getCommandStr();
|
||||||
|
|
||||||
|
wxASSERT_MSG( !aEvent.getCommandStr().empty(), "Popped Empty Tool Name!" );
|
||||||
|
|
||||||
// Push/pop events can get out of order (such as when they're generated by the Simulator
|
// Push/pop events can get out of order (such as when they're generated by the Simulator
|
||||||
// frame but not processed until the mouse is back in the Schematic frame), so make sure
|
// frame but not processed until the mouse is back in the Schematic frame), so make sure
|
||||||
// we're popping the right stack frame.
|
// we're popping the right stack frame.
|
||||||
|
@ -94,6 +102,8 @@ void TOOLS_HOLDER::PopTool( const std::string& actionName )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxASSERT_MSG( false, "Popped a Tool Not on the Tool Stack!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,12 +60,7 @@ void ZOOM_TOOL::Reset( RESET_REASON aReason )
|
||||||
|
|
||||||
int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
|
int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::string tool;
|
m_frame->PushTool( aEvent );
|
||||||
|
|
||||||
if( aEvent.GetCommandStr() )
|
|
||||||
tool = *aEvent.GetCommandStr();
|
|
||||||
|
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -102,7 +97,7 @@ int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
// Exit zoom tool
|
// Exit zoom tool
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,8 +144,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
||||||
wxFAIL_MSG( "PlaceSymbol(): unexpected request" );
|
wxFAIL_MSG( "PlaceSymbol(): unexpected request" );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto addSymbol =
|
auto addSymbol =
|
||||||
[&]( SCH_SYMBOL* aSymbol )
|
[&]( SCH_SYMBOL* aSymbol )
|
||||||
|
@ -250,9 +249,8 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
||||||
|
|
||||||
// The tool hotkey is interpreted as a click when drawing
|
// The tool hotkey is interpreted as a click when drawing
|
||||||
bool isSyntheticClick = symbol
|
bool isSyntheticClick = symbol && evt->IsActivate() && evt->HasPosition()
|
||||||
&& evt->IsActivate() && evt->HasPosition()
|
&& evt->Matches( aEvent );
|
||||||
&& evt->GetCommandStr() == tool;
|
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
|
@ -264,7 +262,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,7 +289,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,8 +461,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
m_view->AddToPreview( image->Clone() );
|
m_view->AddToPreview( image->Clone() );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -514,9 +511,8 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
||||||
|
|
||||||
// The tool hotkey is interpreted as a click when drawing
|
// The tool hotkey is interpreted as a click when drawing
|
||||||
bool isSyntheticClick = image
|
bool isSyntheticClick = image && evt->IsActivate() && evt->HasPosition()
|
||||||
&& evt->IsActivate() && evt->HasPosition()
|
&& evt->Matches( aEvent );
|
||||||
&& evt->GetCommandStr() == tool;
|
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
|
@ -528,13 +524,13 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( immediateMode )
|
if( immediateMode )
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -561,7 +557,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -629,7 +625,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( immediateMode )
|
if( immediateMode )
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -751,8 +747,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
aEvent.Position() :
|
aEvent.Position() :
|
||||||
controls->GetMousePosition() );
|
controls->GetMousePosition() );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -790,7 +785,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( evt->IsActivate() )
|
else if( evt->IsActivate() )
|
||||||
|
@ -802,7 +797,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -841,7 +836,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( evt->IsDblClick( BUT_LEFT ) || type == SCH_SHEET_PIN_T ) // Finish tool.
|
if( evt->IsDblClick( BUT_LEFT ) || type == SCH_SHEET_PIN_T ) // Finish tool.
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1135,8 +1130,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
{
|
{
|
||||||
|
@ -1208,9 +1202,8 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
controls->ForceCursorPosition( true, cursorPos );
|
controls->ForceCursorPosition( true, cursorPos );
|
||||||
|
|
||||||
// The tool hotkey is interpreted as a click when drawing
|
// The tool hotkey is interpreted as a click when drawing
|
||||||
bool isSyntheticClick = item
|
bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
|
||||||
&& evt->IsActivate() && evt->HasPosition()
|
&& evt->Matches( aEvent );
|
||||||
&& evt->GetCommandStr() == tool;
|
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
|
@ -1222,7 +1215,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1252,7 +1245,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1489,8 +1482,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -1526,9 +1518,8 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
||||||
|
|
||||||
// The tool hotkey is interpreted as a click when drawing
|
// The tool hotkey is interpreted as a click when drawing
|
||||||
bool isSyntheticClick = item
|
bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
|
||||||
&& evt->IsActivate() && evt->HasPosition()
|
&& evt->Matches( aEvent );
|
||||||
&& evt->GetCommandStr() == tool;
|
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
|
@ -1538,7 +1529,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1565,7 +1556,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1698,8 +1689,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -1735,9 +1725,8 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
||||||
|
|
||||||
// The tool hotkey is interpreted as a click when drawing
|
// The tool hotkey is interpreted as a click when drawing
|
||||||
bool isSyntheticClick = sheet
|
bool isSyntheticClick = sheet && evt->IsActivate() && evt->HasPosition()
|
||||||
&& evt->IsActivate() && evt->HasPosition()
|
&& evt->Matches( aEvent );
|
||||||
&& evt->GetCommandStr() == tool;
|
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
|
@ -1749,7 +1738,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1780,7 +1769,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1294,7 +1294,6 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
|
||||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
@ -1355,7 +1354,7 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -922,8 +922,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1012,8 +1011,7 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1384,7 +1382,6 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
|
||||||
if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
|
if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
|
||||||
m_frame->RecalculateConnections( NO_CLEANUP );
|
m_frame->RecalculateConnections( NO_CLEANUP );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
|
||||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||||
|
|
||||||
// Deactivate other tools; particularly important if another PICKER is currently running
|
// Deactivate other tools; particularly important if another PICKER is currently running
|
||||||
|
@ -1399,7 +1396,7 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
|
||||||
return highlightNet( m_toolMgr, aPos );
|
return highlightNet( m_toolMgr, aPos );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,8 +302,7 @@ int SCH_LINE_WIRE_BUS_TOOL::DrawSegments( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
DRAW_SEGMENT_EVENT_PARAMS* params = aEvent.Parameter<DRAW_SEGMENT_EVENT_PARAMS*>();
|
DRAW_SEGMENT_EVENT_PARAMS* params = aEvent.Parameter<DRAW_SEGMENT_EVENT_PARAMS*>();
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
if( aEvent.HasPosition() )
|
if( aEvent.HasPosition() )
|
||||||
|
@ -316,7 +315,7 @@ int SCH_LINE_WIRE_BUS_TOOL::DrawSegments( const TOOL_EVENT& aEvent )
|
||||||
startSegments( params->layer, cursorPos, params->sourceSegment );
|
startSegments( params->layer, cursorPos, params->sourceSegment );
|
||||||
}
|
}
|
||||||
|
|
||||||
return doDrawSegments( tool, params->layer, params->quitOnDraw );
|
return doDrawSegments( aEvent, params->layer, params->quitOnDraw );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -331,8 +330,7 @@ int SCH_LINE_WIRE_BUS_TOOL::UnfoldBus( const TOOL_EVENT& aEvent )
|
||||||
wxString net;
|
wxString net;
|
||||||
SCH_LINE* segment = nullptr;
|
SCH_LINE* segment = nullptr;
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
if( netPtr )
|
if( netPtr )
|
||||||
|
@ -377,11 +375,11 @@ int SCH_LINE_WIRE_BUS_TOOL::UnfoldBus( const TOOL_EVENT& aEvent )
|
||||||
// If we have an unfolded wire to draw, then draw it
|
// If we have an unfolded wire to draw, then draw it
|
||||||
if( segment )
|
if( segment )
|
||||||
{
|
{
|
||||||
return doDrawSegments( tool, LAYER_WIRE, false );
|
return doDrawSegments( aEvent, LAYER_WIRE, false );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -574,7 +572,7 @@ void SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint( const std::pair<SCH_LINE*, SCH_L
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType, bool aQuitOnDraw )
|
int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const TOOL_EVENT& aTool, int aType, bool aQuitOnDraw )
|
||||||
{
|
{
|
||||||
SCH_SCREEN* screen = m_frame->GetScreen();
|
SCH_SCREEN* screen = m_frame->GetScreen();
|
||||||
SCH_LINE* segment = nullptr;
|
SCH_LINE* segment = nullptr;
|
||||||
|
@ -647,9 +645,8 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
|
||||||
bool twoSegments = currentMode != LINE_MODE::LINE_MODE_FREE;
|
bool twoSegments = currentMode != LINE_MODE::LINE_MODE_FREE;
|
||||||
|
|
||||||
// The tool hotkey is interpreted as a click when drawing
|
// The tool hotkey is interpreted as a click when drawing
|
||||||
bool isSyntheticClick = ( segment || m_busUnfold.in_progress )
|
bool isSyntheticClick = ( segment || m_busUnfold.in_progress ) && evt->IsActivate()
|
||||||
&& evt->IsActivate() && evt->HasPosition()
|
&& evt->HasPosition() && evt->Matches( aTool );
|
||||||
&& evt->GetCommandStr() == aTool;
|
|
||||||
|
|
||||||
setCursor();
|
setCursor();
|
||||||
grid.SetMask( GRID_HELPER::ALL );
|
grid.SetMask( GRID_HELPER::ALL );
|
||||||
|
|
|
@ -100,7 +100,7 @@ public:
|
||||||
int TrimOverLappingWires( const TOOL_EVENT& aEvent );
|
int TrimOverLappingWires( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int doDrawSegments( const std::string& aTool, int aType, bool aQuitOnDraw );
|
int doDrawSegments( const TOOL_EVENT& aTool, int aType, bool aQuitOnDraw );
|
||||||
SCH_LINE* startSegments( int aType, const VECTOR2D& aPos, SCH_LINE* aSegment = nullptr );
|
SCH_LINE* startSegments( int aType, const VECTOR2D& aPos, SCH_LINE* aSegment = nullptr );
|
||||||
SCH_LINE* doUnfoldBus( const wxString& aNet, const VECTOR2I& aPos = VECTOR2I( 0, 0 ) );
|
SCH_LINE* doUnfoldBus( const wxString& aNet, const VECTOR2I& aPos = VECTOR2I( 0, 0 ) );
|
||||||
void finishSegments();
|
void finishSegments();
|
||||||
|
|
|
@ -144,20 +144,20 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
// Must be done after Activate() so that it gets set into the correct context
|
// Must be done after Activate() so that it gets set into the correct context
|
||||||
controls->ShowCursor( true );
|
controls->ShowCursor( true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
if( selection.Empty() )
|
if( selection.Empty() )
|
||||||
{
|
{
|
||||||
// Note that it's important to go through push/pop even when the selection is empty.
|
// Note that it's important to go through push/pop even when the selection is empty.
|
||||||
// This keeps other tools from having to special-case an empty move.
|
// This keeps other tools from having to special-case an empty move.
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool restore_state = false;
|
bool restore_state = false;
|
||||||
bool chain_commands = false;
|
bool chain_commands = false;
|
||||||
TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
|
TOOL_EVENT copy = aEvent;
|
||||||
|
TOOL_EVENT* evt = ©
|
||||||
VECTOR2I prevPos;
|
VECTOR2I prevPos;
|
||||||
int snapLayer = UNDEFINED_LAYER;
|
int snapLayer = UNDEFINED_LAYER;
|
||||||
|
|
||||||
|
@ -910,7 +910,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
m_dragAdditions.clear();
|
m_dragAdditions.clear();
|
||||||
m_lineConnectionCache.clear();
|
m_lineConnectionCache.clear();
|
||||||
m_moveInProgress = false;
|
m_moveInProgress = false;
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -145,9 +144,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
controls->ForceCursorPosition( true, cursorPos );
|
controls->ForceCursorPosition( true, cursorPos );
|
||||||
|
|
||||||
// The tool hotkey is interpreted as a click when drawing
|
// The tool hotkey is interpreted as a click when drawing
|
||||||
bool isSyntheticClick = item
|
bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
|
||||||
&& evt->IsActivate() && evt->HasPosition()
|
&& evt->Matches( aEvent );
|
||||||
&& evt->GetCommandStr() == tool;
|
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
|
@ -159,7 +157,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,7 +187,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,8 +339,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -376,9 +373,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
||||||
|
|
||||||
// The tool hotkey is interpreted as a click when drawing
|
// The tool hotkey is interpreted as a click when drawing
|
||||||
bool isSyntheticClick = item
|
bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
|
||||||
&& evt->IsActivate() && evt->HasPosition()
|
&& evt->Matches( aEvent );
|
||||||
&& evt->GetCommandStr() == tool;
|
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
|
@ -388,7 +384,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,7 +404,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -542,8 +538,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
int SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -564,12 +559,12 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( evt->IsActivate() )
|
else if( evt->IsActivate() )
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
|
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
|
||||||
|
|
|
@ -333,7 +333,6 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
int SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
|
||||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
@ -401,7 +400,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,8 +110,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
// Must be done after Activate() so that it gets set into the correct context
|
// Must be done after Activate() so that it gets set into the correct context
|
||||||
|
@ -120,7 +119,8 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
bool restore_state = false;
|
bool restore_state = false;
|
||||||
bool chain_commands = false;
|
bool chain_commands = false;
|
||||||
TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
|
TOOL_EVENT copy = aEvent;
|
||||||
|
TOOL_EVENT* evt = ©
|
||||||
VECTOR2I prevPos;
|
VECTOR2I prevPos;
|
||||||
|
|
||||||
if( !selection.Front()->IsNew() )
|
if( !selection.Front()->IsNew() )
|
||||||
|
@ -365,7 +365,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
m_moveInProgress = false;
|
m_moveInProgress = false;
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,8 +207,7 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
EDA_UNITS units = m_frame->GetUserUnits();
|
EDA_UNITS units = m_frame->GetUserUnits();
|
||||||
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, gerbIUScale, units, false, false );
|
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, gerbIUScale, units, false, false );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -247,7 +246,7 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +262,7 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
class TOOL_ACTION;
|
class TOOL_ACTION;
|
||||||
class TOOL_MANAGER;
|
class TOOL_MANAGER;
|
||||||
class TOOL_BASE;
|
class TOOL_BASE;
|
||||||
|
class TOOLS_HOLDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal (GUI-independent) event definitions.
|
* Internal (GUI-independent) event definitions.
|
||||||
|
@ -368,8 +369,8 @@ public:
|
||||||
|
|
||||||
if( m_category == TC_COMMAND || m_category == TC_MESSAGE )
|
if( m_category == TC_COMMAND || m_category == TC_MESSAGE )
|
||||||
{
|
{
|
||||||
if( (bool) m_commandStr && (bool) aEvent.m_commandStr )
|
if( !m_commandStr.empty() && !aEvent.getCommandStr().empty() )
|
||||||
return *m_commandStr == *aEvent.m_commandStr;
|
return m_commandStr == aEvent.m_commandStr;
|
||||||
|
|
||||||
if( (bool) m_commandId && (bool) aEvent.m_commandId )
|
if( (bool) m_commandId && (bool) aEvent.m_commandId )
|
||||||
return *m_commandId == *aEvent.m_commandId;
|
return *m_commandId == *aEvent.m_commandId;
|
||||||
|
@ -466,11 +467,6 @@ public:
|
||||||
return m_commandId;
|
return m_commandId;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> GetCommandStr() const
|
|
||||||
{
|
|
||||||
return m_commandStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetMousePosition( const VECTOR2D& aP )
|
void SetMousePosition( const VECTOR2D& aP )
|
||||||
{
|
{
|
||||||
m_mousePos = aP;
|
m_mousePos = aP;
|
||||||
|
@ -478,9 +474,13 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class TOOL_DISPATCHER;
|
friend class TOOL_DISPATCHER;
|
||||||
|
friend class TOOL_MANAGER;
|
||||||
|
friend class TOOLS_HOLDER;
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
const std::string& getCommandStr() const { return m_commandStr; }
|
||||||
|
|
||||||
void setMouseDragOrigin( const VECTOR2D& aP )
|
void setMouseDragOrigin( const VECTOR2D& aP )
|
||||||
{
|
{
|
||||||
m_mouseDragOrigin = aP;
|
m_mouseDragOrigin = aP;
|
||||||
|
@ -551,7 +551,7 @@ private:
|
||||||
TOOL_BASE* m_firstResponder;
|
TOOL_BASE* m_firstResponder;
|
||||||
|
|
||||||
std::optional<int> m_commandId;
|
std::optional<int> m_commandId;
|
||||||
std::optional<std::string> m_commandStr;
|
std::string m_commandStr;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::optional<TOOL_EVENT> OPT_TOOL_EVENT;
|
typedef std::optional<TOOL_EVENT> OPT_TOOL_EVENT;
|
||||||
|
|
|
@ -110,8 +110,20 @@ public:
|
||||||
* "tools", such as rectangle and circle, or wire and bus. So each user-level tool is
|
* "tools", such as rectangle and circle, or wire and bus. So each user-level tool is
|
||||||
* actually a #TOOL_ACTION.
|
* actually a #TOOL_ACTION.
|
||||||
*/
|
*/
|
||||||
virtual void PushTool( const std::string& actionName );
|
|
||||||
virtual void PopTool( const std::string& actionName );
|
/**
|
||||||
|
* @brief Pushes a tool to the stack.
|
||||||
|
*
|
||||||
|
* @param aEvent The event that is starting the tool to be pushed to the stack.
|
||||||
|
*/
|
||||||
|
virtual void PushTool( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Pops a tool from the stack.
|
||||||
|
*
|
||||||
|
* @param aEvent The event that started the tool that was pushed to the stack.
|
||||||
|
*/
|
||||||
|
virtual void PopTool( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
bool ToolStackIsEmpty() { return m_toolStack.empty(); }
|
bool ToolStackIsEmpty() { return m_toolStack.empty(); }
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -122,7 +121,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
||||||
cleanup();
|
cleanup();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +137,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,8 +225,7 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -333,7 +331,7 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
getViewControls()->SetAutoPan( false );
|
getViewControls()->SetAutoPan( false );
|
||||||
getViewControls()->CaptureCursor( false );
|
getViewControls()->CaptureCursor( false );
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,8 +117,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
unique_peers.insert( drawItem->GetPeer() );
|
unique_peers.insert( drawItem->GetPeer() );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
// Must be done after Activate() so that it gets set into the correct context
|
// Must be done after Activate() so that it gets set into the correct context
|
||||||
|
@ -127,7 +126,8 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
bool restore_state = false;
|
bool restore_state = false;
|
||||||
bool chain_commands = false;
|
bool chain_commands = false;
|
||||||
TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
|
TOOL_EVENT copy = aEvent;
|
||||||
|
TOOL_EVENT* evt = ©
|
||||||
VECTOR2I prevPos;
|
VECTOR2I prevPos;
|
||||||
|
|
||||||
if( !selection.Front()->IsNew() )
|
if( !selection.Front()->IsNew() )
|
||||||
|
@ -301,7 +301,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->PostEvent( EVENTS::SelectedEvent );
|
m_toolMgr->PostEvent( EVENTS::SelectedEvent );
|
||||||
|
|
||||||
m_moveInProgress = false;
|
m_moveInProgress = false;
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +389,6 @@ int PL_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
|
||||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||||
|
|
||||||
// Deactivate other tools; particularly important if another PICKER is currently running
|
// Deactivate other tools; particularly important if another PICKER is currently running
|
||||||
|
@ -455,7 +454,7 @@ int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( PL_ACTIONS::selectionActivate, false );
|
m_toolMgr->RunAction( PL_ACTIONS::selectionActivate, false );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,7 @@ int MICROWAVE_TOOL::addMicrowaveFootprint( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
MICROWAVE_PLACER placer( this, aEvent.Parameter<MICROWAVE_FOOTPRINT_SHAPE>() );
|
MICROWAVE_PLACER placer( this, aEvent.Parameter<MICROWAVE_FOOTPRINT_SHAPE>() );
|
||||||
|
|
||||||
doInteractiveItemPlacement( *aEvent.GetCommandStr(), &placer,
|
doInteractiveItemPlacement( aEvent, &placer, _( "Place microwave feature" ),
|
||||||
_( "Place microwave feature" ),
|
|
||||||
IPO_REPEAT | IPO_ROTATE | IPO_FLIP );
|
IPO_REPEAT | IPO_ROTATE | IPO_FLIP );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -114,8 +113,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
|
||||||
KIGFX::VIEW_CONTROLS& controls = *getViewControls();
|
KIGFX::VIEW_CONTROLS& controls = *getViewControls();
|
||||||
PCB_EDIT_FRAME& frame = *getEditFrame<PCB_EDIT_FRAME>();
|
PCB_EDIT_FRAME& frame = *getEditFrame<PCB_EDIT_FRAME>();
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
frame.PushTool( aEvent );
|
||||||
frame.PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -161,7 +159,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
|
||||||
cleanup();
|
cleanup();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
frame.PopTool( tool );
|
frame.PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +175,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
frame.PopTool( tool );
|
frame.PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,8 +274,7 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
||||||
// Deselect all items
|
// Deselect all items
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
frame()->PushTool( aEvent );
|
||||||
frame()->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -338,7 +337,7 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
||||||
m_savedSizes = m_router->Sizes();
|
m_savedSizes = m_router->Sizes();
|
||||||
|
|
||||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||||
frame()->PopTool( tool );
|
frame()->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1534,8 +1534,7 @@ int ROUTER_TOOL::RouteSelected( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().value();
|
frame->PushTool( aEvent );
|
||||||
frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -1632,7 +1631,7 @@ int ROUTER_TOOL::RouteSelected( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
m_iface->SetCommitFlags( 0 );
|
m_iface->SetCommitFlags( 0 );
|
||||||
frame->PopTool( tool );
|
frame->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1654,8 +1653,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
||||||
// Deselect all items
|
// Deselect all items
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
frame->PushTool( aEvent );
|
||||||
frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -1684,7 +1682,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
frame->PopTool( tool );
|
frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( evt->IsActivate() )
|
else if( evt->IsActivate() )
|
||||||
|
@ -1696,7 +1694,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
frame->PopTool( tool );
|
frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1769,7 +1767,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( m_cancelled )
|
if( m_cancelled )
|
||||||
{
|
{
|
||||||
frame->PopTool( tool );
|
frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -982,8 +982,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -1058,7 +1057,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1074,7 +1073,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
frame()->PopTool( tool );
|
frame()->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1570,7 +1569,6 @@ void BOARD_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME*
|
||||||
|
|
||||||
int BOARD_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
|
int BOARD_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
|
||||||
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
||||||
|
|
||||||
// Deactivate other tools; particularly important if another PICKER is currently running
|
// Deactivate other tools; particularly important if another PICKER is currently running
|
||||||
|
@ -1584,7 +1582,7 @@ int BOARD_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
|
||||||
return false; // drill origin is a one-shot; don't continue with tool
|
return false; // drill origin is a one-shot; don't continue with tool
|
||||||
} );
|
} );
|
||||||
|
|
||||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1539,7 +1539,6 @@ int BOARD_INSPECTION_TOOL::ClearHighlight( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int BOARD_INSPECTION_TOOL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
|
int BOARD_INSPECTION_TOOL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
|
||||||
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
||||||
BOARD* board = getModel<BOARD>();
|
BOARD* board = getModel<BOARD>();
|
||||||
|
|
||||||
|
@ -1610,7 +1609,7 @@ int BOARD_INSPECTION_TOOL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -554,8 +554,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
|
||||||
// do not capture or auto-pan until we start placing the table
|
// do not capture or auto-pan until we start placing the table
|
||||||
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
// Must be done after Activate() so that it gets set into the correct context
|
// Must be done after Activate() so that it gets set into the correct context
|
||||||
|
@ -586,7 +585,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -617,7 +616,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -638,7 +637,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
|
||||||
if( destLayer == PCB_LAYER_ID::UNDEFINED_LAYER )
|
if( destLayer == PCB_LAYER_ID::UNDEFINED_LAYER )
|
||||||
{
|
{
|
||||||
// The user did not pick any layer.
|
// The user did not pick any layer.
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -663,7 +662,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
|
||||||
}
|
}
|
||||||
|
|
||||||
commit.Push( wxT( "Placing items" ) );
|
commit.Push( wxT( "Placing items" ) );
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,11 +313,10 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
|
||||||
if( aEvent.HasPosition() )
|
if( aEvent.HasPosition() )
|
||||||
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
while( drawShape( tool, &line, startingPoint ) )
|
while( drawShape( aEvent, &line, startingPoint ) )
|
||||||
{
|
{
|
||||||
if( line )
|
if( line )
|
||||||
{
|
{
|
||||||
|
@ -387,11 +386,10 @@ int DRAWING_TOOL::DrawRectangle( const TOOL_EVENT& aEvent )
|
||||||
if( aEvent.HasPosition() )
|
if( aEvent.HasPosition() )
|
||||||
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
while( drawShape( tool, &rect, startingPoint ) )
|
while( drawShape( aEvent, &rect, startingPoint ) )
|
||||||
{
|
{
|
||||||
if( rect )
|
if( rect )
|
||||||
{
|
{
|
||||||
|
@ -447,11 +445,10 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
|
||||||
if( aEvent.HasPosition() )
|
if( aEvent.HasPosition() )
|
||||||
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
while( drawShape( tool, &circle, startingPoint ) )
|
while( drawShape( aEvent, &circle, startingPoint ) )
|
||||||
{
|
{
|
||||||
if( circle )
|
if( circle )
|
||||||
{
|
{
|
||||||
|
@ -495,14 +492,13 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
|
||||||
arc->SetShape( SHAPE_T::ARC );
|
arc->SetShape( SHAPE_T::ARC );
|
||||||
arc->SetFlags( IS_NEW );
|
arc->SetFlags( IS_NEW );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
if( aEvent.HasPosition() )
|
if( aEvent.HasPosition() )
|
||||||
startingPoint = aEvent.Position();
|
startingPoint = aEvent.Position();
|
||||||
|
|
||||||
while( drawArc( tool, &arc, startingPoint ) )
|
while( drawArc( aEvent, &arc, startingPoint ) )
|
||||||
{
|
{
|
||||||
if( arc )
|
if( arc )
|
||||||
{
|
{
|
||||||
|
@ -553,8 +549,7 @@ int DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
m_view->AddToPreview( image->Clone() );
|
m_view->AddToPreview( image->Clone() );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
{
|
{
|
||||||
|
@ -610,13 +605,13 @@ int DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( immediateMode )
|
if( immediateMode )
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -643,7 +638,7 @@ int DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -715,7 +710,7 @@ int DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( immediateMode )
|
if( immediateMode )
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -797,8 +792,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
// Must be done after Activate() so that it gets set into the correct context
|
// Must be done after Activate() so that it gets set into the correct context
|
||||||
|
@ -832,7 +826,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -848,7 +842,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1079,8 +1073,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
// Must be done after Activate() so that it gets set into the correct context
|
// Must be done after Activate() so that it gets set into the correct context
|
||||||
|
@ -1130,7 +1123,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1150,7 +1143,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1560,8 +1553,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &selectedItems );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &selectedItems );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -1636,7 +1628,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||||
m_controls->ForceCursorPosition( false );
|
m_controls->ForceCursorPosition( false );
|
||||||
|
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1659,8 +1651,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -1701,7 +1692,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
// Usually, we do not need to change twice the anchor position,
|
// Usually, we do not need to change twice the anchor position,
|
||||||
// so deselect the active tool
|
// so deselect the active tool
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
|
@ -1710,7 +1701,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else if( evt->IsCancelInteractive() || evt->IsActivate() )
|
else if( evt->IsCancelInteractive() || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1759,7 +1750,7 @@ static void updateSegmentFromGeometryMgr( const KIGFX::PREVIEW::TWO_POINT_GEOMET
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DRAWING_TOOL::drawShape( const std::string& aTool, PCB_SHAPE** aGraphic,
|
bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
||||||
std::optional<VECTOR2D> aStartingPoint )
|
std::optional<VECTOR2D> aStartingPoint )
|
||||||
{
|
{
|
||||||
SHAPE_T shape = ( *aGraphic )->GetShape();
|
SHAPE_T shape = ( *aGraphic )->GetShape();
|
||||||
|
@ -2152,7 +2143,7 @@ static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic,
|
bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
||||||
std::optional<VECTOR2D> aStartingPoint )
|
std::optional<VECTOR2D> aStartingPoint )
|
||||||
{
|
{
|
||||||
PCB_SHAPE*& graphic = *aGraphic;
|
PCB_SHAPE*& graphic = *aGraphic;
|
||||||
|
@ -2498,8 +2489,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
||||||
status.SetTextColor( wxColour( 255, 0, 0 ) );
|
status.SetTextColor( wxColour( 255, 0, 0 ) );
|
||||||
status.SetText( _( "Self-intersecting polygons are not allowed" ) );
|
status.SetText( _( "Self-intersecting polygons are not allowed" ) );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
m_frame->PushTool( aEvent );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
|
|
||||||
auto setCursor =
|
auto setCursor =
|
||||||
[&]()
|
[&]()
|
||||||
|
@ -2554,7 +2544,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
// We've handled the cancel event. Don't cancel other tools
|
// We've handled the cancel event. Don't cancel other tools
|
||||||
evt->SetPassEvent( false );
|
evt->SetPassEvent( false );
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2574,7 +2564,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3216,8 +3206,7 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA );
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA );
|
||||||
|
|
||||||
doInteractiveItemPlacement( *aEvent.GetCommandStr(), &placer, _( "Place via" ),
|
doInteractiveItemPlacement( aEvent, &placer, _( "Place via" ), IPO_REPEAT | IPO_SINGLE_CLICK );
|
||||||
IPO_REPEAT | IPO_SINGLE_CLICK );
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,8 @@ private:
|
||||||
* @return False if the tool was canceled before the origin was set or origin and end are
|
* @return False if the tool was canceled before the origin was set or origin and end are
|
||||||
* the same point.
|
* the same point.
|
||||||
*/
|
*/
|
||||||
bool drawShape( const std::string& aTool, PCB_SHAPE** aGraphic, std::optional<VECTOR2D> aStartingPoint );
|
bool drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
||||||
|
std::optional<VECTOR2D> aStartingPoint );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start drawing an arc.
|
* Start drawing an arc.
|
||||||
|
@ -239,7 +240,8 @@ private:
|
||||||
* @return False if the tool was canceled before the origin was set or origin and end are
|
* @return False if the tool was canceled before the origin was set or origin and end are
|
||||||
* the same point.
|
* the same point.
|
||||||
*/
|
*/
|
||||||
bool drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, std::optional<VECTOR2D> aStartingPoint );
|
bool drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
||||||
|
std::optional<VECTOR2D> aStartingPoint );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a polygon, that is added as a zone or a keepout area.
|
* Draw a polygon, that is added as a zone or a keepout area.
|
||||||
|
|
|
@ -1431,8 +1431,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
editFrame->PushTool( aEvent );
|
||||||
editFrame->PushTool( tool );
|
|
||||||
|
|
||||||
std::vector<BOARD_ITEM*> lockedItems;
|
std::vector<BOARD_ITEM*> lockedItems;
|
||||||
Activate();
|
Activate();
|
||||||
|
@ -1473,7 +1472,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
wxBell();
|
wxBell();
|
||||||
canvas()->Refresh();
|
canvas()->Refresh();
|
||||||
editFrame->PopTool( tool );
|
editFrame->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1669,7 +1668,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
|
||||||
else
|
else
|
||||||
m_commit->Push( _( "Delete" ) );
|
m_commit->Push( _( "Delete" ) );
|
||||||
|
|
||||||
editFrame->PopTool( tool );
|
editFrame->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2087,12 +2086,14 @@ bool EDIT_TOOL::pickReferencePoint( const wxString& aTooltip, const wxString& aS
|
||||||
|
|
||||||
int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
|
int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::string tool = "pcbnew.InteractiveEdit.selectReferencePoint";
|
|
||||||
CLIPBOARD_IO io;
|
CLIPBOARD_IO io;
|
||||||
PCB_GRID_HELPER grid( m_toolMgr,
|
PCB_GRID_HELPER grid( m_toolMgr,
|
||||||
getEditFrame<PCB_BASE_EDIT_FRAME>()->GetMagneticItemsSettings() );
|
getEditFrame<PCB_BASE_EDIT_FRAME>()->GetMagneticItemsSettings() );
|
||||||
|
TOOL_EVENT selectReferencePoint( aEvent.Category(), aEvent.Action(),
|
||||||
|
"pcbnew.InteractiveEdit.selectReferencePoint",
|
||||||
|
TOOL_ACTION_SCOPE::AS_GLOBAL );
|
||||||
|
|
||||||
frame()->PushTool( tool );
|
frame()->PushTool( selectReferencePoint );
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
||||||
|
@ -2128,7 +2129,7 @@ int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
|
||||||
_( "Copy canceled" ),
|
_( "Copy canceled" ),
|
||||||
refPoint ) )
|
refPoint ) )
|
||||||
{
|
{
|
||||||
frame()->PopTool( tool );
|
frame()->PopTool( selectReferencePoint );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2144,7 +2145,7 @@ int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
|
||||||
frame()->SetStatusText( _( "Selection copied" ) );
|
frame()->SetStatusText( _( "Selection copied" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
frame()->PopTool( tool );
|
frame()->PopTool( selectReferencePoint );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2157,7 +2158,7 @@ int EDIT_TOOL::cutToClipboard( const TOOL_EVENT& aEvent )
|
||||||
// N.B. Setting the CUT flag prevents lock filtering as we only want to delete the items
|
// N.B. Setting the CUT flag prevents lock filtering as we only want to delete the items
|
||||||
// that were copied to the clipboard, no more, no fewer. Filtering for locked item, if
|
// that were copied to the clipboard, no more, no fewer. Filtering for locked item, if
|
||||||
// any will be done in the copyToClipboard() routine
|
// any will be done in the copyToClipboard() routine
|
||||||
TOOL_EVENT evt( aEvent.Category(), aEvent.Action(), TOOL_ACTION_SCOPE::AS_GLOBAL );
|
TOOL_EVENT evt = aEvent;
|
||||||
evt.SetParameter( PCB_ACTIONS::REMOVE_FLAGS::CUT );
|
evt.SetParameter( PCB_ACTIONS::REMOVE_FLAGS::CUT );
|
||||||
Remove( evt );
|
Remove( evt );
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,7 @@ private:
|
||||||
bool invokeInlineRouter( int aDragMode );
|
bool invokeInlineRouter( int aDragMode );
|
||||||
bool isRouterActive() const;
|
bool isRouterActive() const;
|
||||||
|
|
||||||
int doMoveSelection( TOOL_EVENT aEvent, bool aPickReference = false );
|
int doMoveSelection( const TOOL_EVENT& aEvent, bool aPickReference = false );
|
||||||
|
|
||||||
VECTOR2I getSafeMovement( const VECTOR2I& aMovement, const BOX2I& aSourceBBox,
|
VECTOR2I getSafeMovement( const VECTOR2I& aMovement, const BOX2I& aSourceBBox,
|
||||||
const VECTOR2D& aBBoxOffset );
|
const VECTOR2D& aBBoxOffset );
|
||||||
|
|
|
@ -439,9 +439,7 @@ VECTOR2I EDIT_TOOL::getSafeMovement( const VECTOR2I& aMovement, const BOX2I& aSo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Note: aEvent MUST NOT be const&; the source will get de-allocated if we go into the picker's
|
int EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, bool aPickReference )
|
||||||
// event loop.
|
|
||||||
int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
|
|
||||||
{
|
{
|
||||||
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
||||||
BOARD* board = editFrame->GetBoard();
|
BOARD* board = editFrame->GetBoard();
|
||||||
|
@ -485,8 +483,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
|
||||||
if( selection.Empty() )
|
if( selection.Empty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
editFrame->PushTool( aEvent );
|
||||||
editFrame->PushTool( tool );
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
// Must be done after Activate() so that it gets set into the correct context
|
// Must be done after Activate() so that it gets set into the correct context
|
||||||
|
@ -500,7 +497,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
|
||||||
if( is_hover )
|
if( is_hover )
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
editFrame->PopTool( tool );
|
editFrame->PopTool( aEvent );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,7 +543,8 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
|
||||||
BOX2I originalBBox;
|
BOX2I originalBBox;
|
||||||
bool updateBBox = true;
|
bool updateBBox = true;
|
||||||
PCB_GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() );
|
PCB_GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() );
|
||||||
TOOL_EVENT* evt = &aEvent;
|
TOOL_EVENT copy = aEvent;
|
||||||
|
TOOL_EVENT* evt = ©
|
||||||
VECTOR2I prevPos;
|
VECTOR2I prevPos;
|
||||||
|
|
||||||
bool hv45Mode = false;
|
bool hv45Mode = false;
|
||||||
|
@ -926,7 +924,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &orig_items );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &orig_items );
|
||||||
|
|
||||||
editFrame->PopTool( tool );
|
editFrame->PopTool( aEvent );
|
||||||
editFrame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
editFrame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||||
|
|
||||||
return restore_state ? -1 : 0;
|
return restore_state ? -1 : 0;
|
||||||
|
|
|
@ -299,8 +299,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
frame()->PushTool( aEvent );
|
||||||
frame()->PushTool( tool );
|
|
||||||
|
|
||||||
VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag
|
VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag
|
||||||
std::list<PAD*> selectedPads;
|
std::list<PAD*> selectedPads;
|
||||||
|
@ -349,14 +348,14 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
commit.Revert();
|
commit.Revert();
|
||||||
|
|
||||||
frame()->PopTool( tool );
|
frame()->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( evt->IsActivate() )
|
else if( evt->IsActivate() )
|
||||||
{
|
{
|
||||||
commit.Push( _( "Renumber pads" ) );
|
commit.Push( _( "Renumber pads" ) );
|
||||||
|
|
||||||
frame()->PopTool( tool );
|
frame()->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
|
else if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
|
||||||
|
@ -452,7 +451,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
|
||||||
evt->IsDblClick( BUT_LEFT ) )
|
evt->IsDblClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
commit.Push( _( "Renumber pads" ) );
|
commit.Push( _( "Renumber pads" ) );
|
||||||
frame()->PopTool( tool );
|
frame()->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
|
@ -558,7 +557,7 @@ int PAD_TOOL::PlacePad( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
PAD_PLACER placer( this );
|
PAD_PLACER placer( this );
|
||||||
|
|
||||||
doInteractiveItemPlacement( *aEvent.GetCommandStr(), &placer, _( "Place pad" ),
|
doInteractiveItemPlacement( aEvent, &placer, _( "Place pad" ),
|
||||||
IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP );
|
IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -518,7 +518,6 @@ int PCB_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
|
||||||
if( m_isFootprintEditor && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
|
if( m_isFootprintEditor && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
|
||||||
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
||||||
|
|
||||||
if( !picker ) // Happens in footprint wizard
|
if( !picker ) // Happens in footprint wizard
|
||||||
|
@ -535,7 +534,7 @@ int PCB_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
|
||||||
return false; // drill origin is a one-shot; don't continue with tool
|
return false; // drill origin is a one-shot; don't continue with tool
|
||||||
} );
|
} );
|
||||||
|
|
||||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -558,7 +557,6 @@ int PCB_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
if( m_isFootprintEditor && !m_frame->GetBoard()->GetFirstFootprint() )
|
if( m_isFootprintEditor && !m_frame->GetBoard()->GetFirstFootprint() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
|
||||||
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
||||||
|
|
||||||
m_pickerItem = nullptr;
|
m_pickerItem = nullptr;
|
||||||
|
@ -644,7 +642,7 @@ int PCB_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
m_frame->GetCanvas()->Refresh();
|
m_frame->GetCanvas()->Refresh();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,7 @@ int PCB_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
PCB_GRID_HELPER grid( m_toolMgr, frame->GetMagneticItemsSettings() );
|
PCB_GRID_HELPER grid( m_toolMgr, frame->GetMagneticItemsSettings() );
|
||||||
int finalize_state = WAIT_CANCEL;
|
int finalize_state = WAIT_CANCEL;
|
||||||
|
|
||||||
std::string tool = *aEvent.Parameter<std::string*>();
|
frame->PushTool( aEvent );
|
||||||
|
|
||||||
if( !tool.empty() )
|
|
||||||
frame->PushTool( tool );
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
setControls();
|
setControls();
|
||||||
|
@ -173,8 +170,7 @@ int PCB_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
controls->ForceCursorPosition( false );
|
controls->ForceCursorPosition( false );
|
||||||
controls->ShowCursor( false );
|
controls->ShowCursor( false );
|
||||||
|
|
||||||
if( !tool.empty() )
|
frame->PopTool( aEvent );
|
||||||
frame->PopTool( tool );
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include <tools/pcb_actions.h>
|
#include <tools/pcb_actions.h>
|
||||||
#include <tools/tool_event_utils.h>
|
#include <tools/tool_event_utils.h>
|
||||||
|
|
||||||
void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool,
|
void PCB_TOOL_BASE::doInteractiveItemPlacement( const TOOL_EVENT& aTool,
|
||||||
INTERACTIVE_PLACER_BASE* aPlacer,
|
INTERACTIVE_PLACER_BASE* aPlacer,
|
||||||
const wxString& aCommitMessage, int aOptions )
|
const wxString& aCommitMessage, int aOptions )
|
||||||
{
|
{
|
||||||
|
|
|
@ -145,7 +145,7 @@ protected:
|
||||||
* @param aItemCreator the callable that will attempt to create the item
|
* @param aItemCreator the callable that will attempt to create the item
|
||||||
* @param aCommitMessage the message used on a successful commit
|
* @param aCommitMessage the message used on a successful commit
|
||||||
*/
|
*/
|
||||||
void doInteractiveItemPlacement( const std::string& aTool, INTERACTIVE_PLACER_BASE *aPlacer,
|
void doInteractiveItemPlacement( const TOOL_EVENT& aTool, INTERACTIVE_PLACER_BASE* aPlacer,
|
||||||
const wxString& aCommitMessage,
|
const wxString& aCommitMessage,
|
||||||
int aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT );
|
int aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT );
|
||||||
|
|
||||||
|
|
|
@ -197,8 +197,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
auto& view = *getView();
|
auto& view = *getView();
|
||||||
auto& controls = *getViewControls();
|
auto& controls = *getViewControls();
|
||||||
|
|
||||||
std::string tool = *aEvent.GetCommandStr();
|
frame()->PushTool( aEvent );
|
||||||
frame()->PushTool( tool );
|
|
||||||
|
|
||||||
TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
|
TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
|
||||||
PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() );
|
PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() );
|
||||||
|
@ -253,7 +252,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
frame()->PopTool( tool );
|
frame()->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +268,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
frame()->PopTool( tool );
|
frame()->PopTool( aEvent );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue