Push Eeschema & PLEditor PICKER_TOOLs down into common.
Also implements a more robust push/pop tool strategy for pickers.
This commit is contained in:
parent
16f672a9bd
commit
e816a0c29d
|
@ -379,6 +379,7 @@ set( COMMON_SRCS
|
||||||
tool/edit_constraints.cpp
|
tool/edit_constraints.cpp
|
||||||
tool/edit_points.cpp
|
tool/edit_points.cpp
|
||||||
tool/grid_menu.cpp
|
tool/grid_menu.cpp
|
||||||
|
tool/picker_tool.cpp
|
||||||
tool/selection_conditions.cpp
|
tool/selection_conditions.cpp
|
||||||
tool/tool_action.cpp
|
tool/tool_action.cpp
|
||||||
tool/tool_base.cpp
|
tool/tool_base.cpp
|
||||||
|
|
|
@ -481,6 +481,9 @@ TOOL_ACTION ACTIONS::measureTool( "common.InteractiveEdit.measureTool",
|
||||||
_( "Measure Tool" ), _( "Interactively measure distance between points" ),
|
_( "Measure Tool" ), _( "Interactively measure distance between points" ),
|
||||||
measurement_xpm, AF_ACTIVATE );
|
measurement_xpm, AF_ACTIVATE );
|
||||||
|
|
||||||
|
TOOL_ACTION ACTIONS::pickerTool( "common.InteractivePicker.pickerTool",
|
||||||
|
AS_GLOBAL, 0, "", "", "", NULL, AF_ACTIVATE );
|
||||||
|
|
||||||
TOOL_ACTION ACTIONS::show3DViewer( "common.Control.show3DViewer",
|
TOOL_ACTION ACTIONS::show3DViewer( "common.Control.show3DViewer",
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
MD_ALT + '3', LEGACY_HK_NAME( "3D Viewer" ),
|
MD_ALT + '3', LEGACY_HK_NAME( "3D Viewer" ),
|
||||||
|
|
|
@ -21,25 +21,22 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/actions.h>
|
||||||
#include <tool/selection_conditions.h>
|
#include <tool/picker_tool.h>
|
||||||
#include <tools/pl_picker_tool.h>
|
|
||||||
#include <tools/pl_actions.h>
|
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
#include <pl_editor_frame.h>
|
#include <eda_draw_frame.h>
|
||||||
|
|
||||||
|
|
||||||
PL_PICKER_TOOL::PL_PICKER_TOOL() :
|
PICKER_TOOL::PICKER_TOOL()
|
||||||
TOOL_INTERACTIVE( "plEditor.InteractivePicker" ),
|
: TOOL_INTERACTIVE( "common.InteractivePicker" )
|
||||||
m_frame( nullptr )
|
|
||||||
{
|
{
|
||||||
resetPicker();
|
resetPicker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PL_PICKER_TOOL::Init()
|
bool PICKER_TOOL::Init()
|
||||||
{
|
{
|
||||||
m_frame = getEditFrame<PL_EDITOR_FRAME>();
|
m_frame = getEditFrame<EDA_DRAW_FRAME>();
|
||||||
|
|
||||||
auto& ctxMenu = m_menu.GetMenu();
|
auto& ctxMenu = m_menu.GetMenu();
|
||||||
|
|
||||||
|
@ -54,22 +51,24 @@ bool PL_PICKER_TOOL::Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PL_PICKER_TOOL::Reset( RESET_REASON aReason )
|
int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PL_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( tool );
|
||||||
|
Activate();
|
||||||
|
|
||||||
|
// To many things are off-grid in LibEdit; turn snapping off.
|
||||||
|
bool snap = !m_frame->IsType( FRAME_SCH_LIB_EDITOR );
|
||||||
|
|
||||||
setControls();
|
setControls();
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
|
m_frame->GetCanvas()->SetCursor( m_cursor );
|
||||||
VECTOR2I cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2D cursorPos = controls->GetCursorPosition( snap && !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( evt->IsClick( BUT_LEFT ) )
|
if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
|
@ -85,7 +84,7 @@ int PL_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
{
|
{
|
||||||
std::cerr << "PL_PICKER_TOOL click handler error: " << e.what() << std::endl;
|
std::cerr << "PICKER_TOOL click handler error: " << e.what() << std::endl;
|
||||||
finalize_state = EXCEPTION_CANCEL;
|
finalize_state = EXCEPTION_CANCEL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +109,7 @@ int PL_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
{
|
{
|
||||||
std::cerr << "PL_PICKER_TOOL motion handler error: " << e.what() << std::endl;
|
std::cerr << "PICKER_TOOL motion handler error: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,11 +124,12 @@ int PL_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
{
|
{
|
||||||
std::cerr << "PL_PICKER_TOOL cancel handler error: " << e.what() << std::endl;
|
std::cerr << "PICKER_TOOL cancel handler error: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activating a new tool may have alternate finalization from canceling the current tool
|
// Activating a new tool may have alternate finalization from canceling the current
|
||||||
|
// tool
|
||||||
if( evt->IsActivate() )
|
if( evt->IsActivate() )
|
||||||
finalize_state = END_ACTIVATE;
|
finalize_state = END_ACTIVATE;
|
||||||
else
|
else
|
||||||
|
@ -153,33 +153,36 @@ int PL_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
{
|
{
|
||||||
std::cerr << "PL_PICKER_TOOL finalize handler error: " << e.what() << std::endl;
|
std::cerr << "PICKER_TOOL finalize handler error: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resetPicker();
|
resetPicker();
|
||||||
controls->ForceCursorPosition( false );
|
controls->ForceCursorPosition( false );
|
||||||
|
m_frame->PopTool( tool );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PL_PICKER_TOOL::setTransitions()
|
void PICKER_TOOL::setTransitions()
|
||||||
{
|
{
|
||||||
Go( &PL_PICKER_TOOL::Main, PL_ACTIONS::pickerTool.MakeEvent() );
|
Go( &PICKER_TOOL::Main, ACTIONS::pickerTool.MakeEvent() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PL_PICKER_TOOL::resetPicker()
|
void PICKER_TOOL::resetPicker()
|
||||||
{
|
{
|
||||||
|
m_cursor = wxStockCursor( wxCURSOR_ARROW );
|
||||||
|
|
||||||
m_picked = NULLOPT;
|
m_picked = NULLOPT;
|
||||||
m_motionHandler = NULLOPT;
|
|
||||||
m_clickHandler = NULLOPT;
|
m_clickHandler = NULLOPT;
|
||||||
|
m_motionHandler = NULLOPT;
|
||||||
m_cancelHandler = NULLOPT;
|
m_cancelHandler = NULLOPT;
|
||||||
m_finalizeHandler = NULLOPT;
|
m_finalizeHandler = NULLOPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PL_PICKER_TOOL::setControls()
|
void PICKER_TOOL::setControls()
|
||||||
{
|
{
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
|
|
|
@ -220,7 +220,6 @@ set( EESCHEMA_SRCS
|
||||||
tools/backanno.cpp
|
tools/backanno.cpp
|
||||||
tools/ee_actions.cpp
|
tools/ee_actions.cpp
|
||||||
tools/ee_inspection_tool.cpp
|
tools/ee_inspection_tool.cpp
|
||||||
tools/ee_picker_tool.cpp
|
|
||||||
tools/ee_point_editor.cpp
|
tools/ee_point_editor.cpp
|
||||||
tools/ee_selection.cpp
|
tools/ee_selection.cpp
|
||||||
tools/ee_selection_tool.cpp
|
tools/ee_selection_tool.cpp
|
||||||
|
|
|
@ -45,11 +45,11 @@
|
||||||
#include <tool/tool_dispatcher.h>
|
#include <tool/tool_dispatcher.h>
|
||||||
#include <tool/action_toolbar.h>
|
#include <tool/action_toolbar.h>
|
||||||
#include <tool/common_control.h>
|
#include <tool/common_control.h>
|
||||||
|
#include <tool/picker_tool.h>
|
||||||
#include <tool/common_tools.h>
|
#include <tool/common_tools.h>
|
||||||
#include <tool/zoom_tool.h>
|
#include <tool/zoom_tool.h>
|
||||||
#include <tools/ee_actions.h>
|
#include <tools/ee_actions.h>
|
||||||
#include <tools/ee_selection_tool.h>
|
#include <tools/ee_selection_tool.h>
|
||||||
#include <tools/ee_picker_tool.h>
|
|
||||||
#include <tools/ee_inspection_tool.h>
|
#include <tools/ee_inspection_tool.h>
|
||||||
#include <tools/lib_pin_tool.h>
|
#include <tools/lib_pin_tool.h>
|
||||||
#include <tools/lib_edit_tool.h>
|
#include <tools/lib_edit_tool.h>
|
||||||
|
@ -218,7 +218,7 @@ void LIB_EDIT_FRAME::setupTools()
|
||||||
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
||||||
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
||||||
m_toolManager->RegisterTool( new EE_SELECTION_TOOL );
|
m_toolManager->RegisterTool( new EE_SELECTION_TOOL );
|
||||||
m_toolManager->RegisterTool( new EE_PICKER_TOOL );
|
m_toolManager->RegisterTool( new PICKER_TOOL );
|
||||||
m_toolManager->RegisterTool( new EE_INSPECTION_TOOL );
|
m_toolManager->RegisterTool( new EE_INSPECTION_TOOL );
|
||||||
m_toolManager->RegisterTool( new LIB_PIN_TOOL );
|
m_toolManager->RegisterTool( new LIB_PIN_TOOL );
|
||||||
m_toolManager->RegisterTool( new LIB_DRAWING_TOOLS );
|
m_toolManager->RegisterTool( new LIB_DRAWING_TOOLS );
|
||||||
|
|
|
@ -54,10 +54,10 @@
|
||||||
#include <tool/action_toolbar.h>
|
#include <tool/action_toolbar.h>
|
||||||
#include <tool/common_control.h>
|
#include <tool/common_control.h>
|
||||||
#include <tool/common_tools.h>
|
#include <tool/common_tools.h>
|
||||||
|
#include <tool/picker_tool.h>
|
||||||
#include <tool/zoom_tool.h>
|
#include <tool/zoom_tool.h>
|
||||||
#include <tools/ee_actions.h>
|
#include <tools/ee_actions.h>
|
||||||
#include <tools/ee_selection_tool.h>
|
#include <tools/ee_selection_tool.h>
|
||||||
#include <tools/ee_picker_tool.h>
|
|
||||||
#include <tools/ee_point_editor.h>
|
#include <tools/ee_point_editor.h>
|
||||||
#include <tools/sch_drawing_tools.h>
|
#include <tools/sch_drawing_tools.h>
|
||||||
#include <tools/sch_line_wire_bus_tool.h>
|
#include <tools/sch_line_wire_bus_tool.h>
|
||||||
|
@ -336,7 +336,7 @@ void SCH_EDIT_FRAME::setupTools()
|
||||||
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
||||||
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
||||||
m_toolManager->RegisterTool( new EE_SELECTION_TOOL );
|
m_toolManager->RegisterTool( new EE_SELECTION_TOOL );
|
||||||
m_toolManager->RegisterTool( new EE_PICKER_TOOL );
|
m_toolManager->RegisterTool( new PICKER_TOOL );
|
||||||
m_toolManager->RegisterTool( new SCH_DRAWING_TOOLS );
|
m_toolManager->RegisterTool( new SCH_DRAWING_TOOLS );
|
||||||
m_toolManager->RegisterTool( new SCH_LINE_WIRE_BUS_TOOL );
|
m_toolManager->RegisterTool( new SCH_LINE_WIRE_BUS_TOOL );
|
||||||
m_toolManager->RegisterTool( new SCH_MOVE_TOOL );
|
m_toolManager->RegisterTool( new SCH_MOVE_TOOL );
|
||||||
|
|
|
@ -60,12 +60,6 @@ TOOL_ACTION EE_ACTIONS::showMarkerInfo( "eeschema.InspectionTool.showMarkerInfo"
|
||||||
info_xpm );
|
info_xpm );
|
||||||
|
|
||||||
|
|
||||||
// EE_PICKER
|
|
||||||
//
|
|
||||||
TOOL_ACTION EE_ACTIONS::pickerTool( "eeschema.InteractivePicker",
|
|
||||||
AS_GLOBAL, 0, "", "", "", NULL, AF_ACTIVATE );
|
|
||||||
|
|
||||||
|
|
||||||
// EE_POINT_EDITOR
|
// EE_POINT_EDITOR
|
||||||
//
|
//
|
||||||
TOOL_ACTION EE_ACTIONS::pointEditorAddCorner( "eeschema.PointEditor.addCorner",
|
TOOL_ACTION EE_ACTIONS::pointEditorAddCorner( "eeschema.PointEditor.addCorner",
|
||||||
|
|
|
@ -1,163 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, you may find one here:
|
|
||||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
||||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
||||||
* or you may write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ee_picker_tool.h>
|
|
||||||
#include <ee_actions.h>
|
|
||||||
#include <view/view_controls.h>
|
|
||||||
#include <sch_base_frame.h>
|
|
||||||
|
|
||||||
|
|
||||||
EE_PICKER_TOOL::EE_PICKER_TOOL()
|
|
||||||
: EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.InteractivePicker" )
|
|
||||||
{
|
|
||||||
resetPicker();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int EE_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
|
||||||
{
|
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
|
||||||
int finalize_state = WAIT_CANCEL;
|
|
||||||
|
|
||||||
// To many things are off-grid in LibEdit; turn snapping off.
|
|
||||||
bool snap = !m_isLibEdit;
|
|
||||||
|
|
||||||
setControls();
|
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
|
||||||
{
|
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
|
|
||||||
VECTOR2D cursorPos = controls->GetCursorPosition( snap && !evt->Modifier( MD_ALT ) );
|
|
||||||
|
|
||||||
if( evt->IsClick( BUT_LEFT ) )
|
|
||||||
{
|
|
||||||
bool getNext = false;
|
|
||||||
|
|
||||||
if( m_clickHandler )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getNext = (*m_clickHandler)( cursorPos );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
|
||||||
std::cerr << "EE_PICKER_TOOL click handler error: " << e.what() << std::endl;
|
|
||||||
finalize_state = EXCEPTION_CANCEL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !getNext )
|
|
||||||
{
|
|
||||||
finalize_state = CLICK_CANCEL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
setControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if( evt->IsMotion() )
|
|
||||||
{
|
|
||||||
if( m_motionHandler )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
(*m_motionHandler)( cursorPos );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
|
||||||
std::cerr << "EE_PICKER_TOOL motion handler error: " << e.what() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if( evt->IsCancelInteractive() || evt->IsActivate() )
|
|
||||||
{
|
|
||||||
if( m_cancelHandler )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
(*m_cancelHandler)();
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
|
||||||
std::cerr << "EE_PICKER_TOOL cancel handler error: " << e.what() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Activating a new tool may have alternate finalization from canceling the current tool
|
|
||||||
if( evt->IsActivate() )
|
|
||||||
finalize_state = END_ACTIVATE;
|
|
||||||
else
|
|
||||||
finalize_state = EVT_CANCEL;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
|
||||||
{
|
|
||||||
m_menu.ShowContextMenu();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
evt->SetPassEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( m_finalizeHandler )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
(*m_finalizeHandler)( finalize_state );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
|
||||||
std::cerr << "EE_PICKER_TOOL finalize handler error: " << e.what() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resetPicker();
|
|
||||||
controls->ForceCursorPosition( false );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void EE_PICKER_TOOL::setTransitions()
|
|
||||||
{
|
|
||||||
Go( &EE_PICKER_TOOL::Main, EE_ACTIONS::pickerTool.MakeEvent() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void EE_PICKER_TOOL::resetPicker()
|
|
||||||
{
|
|
||||||
m_clickHandler = NULLOPT;
|
|
||||||
m_motionHandler = NULLOPT;
|
|
||||||
m_cancelHandler = NULLOPT;
|
|
||||||
m_finalizeHandler = NULLOPT;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void EE_PICKER_TOOL::setControls()
|
|
||||||
{
|
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
|
||||||
|
|
||||||
controls->CaptureCursor( false );
|
|
||||||
controls->SetAutoPan( false );
|
|
||||||
}
|
|
|
@ -1,116 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, you may find one here:
|
|
||||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
||||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
||||||
* or you may write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef EE_PICKER_TOOL_H
|
|
||||||
#define EE_PICKER_TOOL_H
|
|
||||||
|
|
||||||
#include <boost/optional/optional.hpp>
|
|
||||||
#include <tools/ee_tool_base.h>
|
|
||||||
|
|
||||||
|
|
||||||
class SCH_BASE_FRAME;
|
|
||||||
|
|
||||||
|
|
||||||
class EE_PICKER_TOOL : public EE_TOOL_BASE<SCH_BASE_FRAME>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
EE_PICKER_TOOL();
|
|
||||||
~EE_PICKER_TOOL() {}
|
|
||||||
|
|
||||||
///> Event handler types.
|
|
||||||
typedef std::function<bool(const VECTOR2D&)> CLICK_HANDLER;
|
|
||||||
typedef std::function<void(const VECTOR2D&)> MOTION_HANDLER;
|
|
||||||
typedef std::function<void(void)> CANCEL_HANDLER;
|
|
||||||
typedef std::function<void(const int&)> FINALIZE_HANDLER;
|
|
||||||
|
|
||||||
enum pickerEndState
|
|
||||||
{
|
|
||||||
WAIT_CANCEL,
|
|
||||||
CLICK_CANCEL,
|
|
||||||
END_ACTIVATE,
|
|
||||||
EVT_CANCEL,
|
|
||||||
EXCEPTION_CANCEL
|
|
||||||
};
|
|
||||||
|
|
||||||
///> Main event loop.
|
|
||||||
int Main( const TOOL_EVENT& aEvent );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function SetClickHandler()
|
|
||||||
* Sets a handler for mouse click event. Handler may decide to receive further click by
|
|
||||||
* returning true.
|
|
||||||
*/
|
|
||||||
inline void SetClickHandler( CLICK_HANDLER aHandler )
|
|
||||||
{
|
|
||||||
wxASSERT( !m_clickHandler );
|
|
||||||
m_clickHandler = aHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function SetMotionHandler()
|
|
||||||
* Sets a handler for mouse motion. Used for roll-over highlighting.
|
|
||||||
*/
|
|
||||||
inline void SetMotionHandler( MOTION_HANDLER aHandler )
|
|
||||||
{
|
|
||||||
wxASSERT( !m_motionHandler );
|
|
||||||
m_motionHandler = aHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function SetCancelHandler()
|
|
||||||
* Sets a handler for cancel events (ESC or context-menu Cancel).
|
|
||||||
*/
|
|
||||||
inline void SetCancelHandler( CANCEL_HANDLER aHandler )
|
|
||||||
{
|
|
||||||
wxASSERT( !m_cancelHandler );
|
|
||||||
m_cancelHandler = aHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function SetFinalizeHandler()
|
|
||||||
* Sets a handler for the finalize event. Takes the state of the exit from the Main loop
|
|
||||||
*/
|
|
||||||
inline void SetFinalizeHandler( FINALIZE_HANDLER aHandler )
|
|
||||||
{
|
|
||||||
wxASSERT( !m_finalizeHandler );
|
|
||||||
m_finalizeHandler = aHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
///> Reinitializes tool to its initial state.
|
|
||||||
void resetPicker();
|
|
||||||
|
|
||||||
///> Applies the requested VIEW_CONTROLS settings.
|
|
||||||
void setControls();
|
|
||||||
|
|
||||||
///> @copydoc TOOL_INTERACTIVE::setTransitions();
|
|
||||||
void setTransitions() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
OPT<CLICK_HANDLER> m_clickHandler;
|
|
||||||
OPT<MOTION_HANDLER> m_motionHandler;
|
|
||||||
OPT<CANCEL_HANDLER> m_cancelHandler;
|
|
||||||
OPT<FINALIZE_HANDLER> m_finalizeHandler;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* EE_PICKER_TOOL_H */
|
|
|
@ -22,8 +22,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
|
#include <tool/picker_tool.h>
|
||||||
#include <tools/ee_selection_tool.h>
|
#include <tools/ee_selection_tool.h>
|
||||||
#include <tools/ee_picker_tool.h>
|
|
||||||
#include <tools/lib_pin_tool.h>
|
#include <tools/lib_pin_tool.h>
|
||||||
#include <tools/lib_drawing_tools.h>
|
#include <tools/lib_drawing_tools.h>
|
||||||
#include <tools/lib_move_tool.h>
|
#include <tools/lib_move_tool.h>
|
||||||
|
@ -280,62 +280,62 @@ int LIB_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
|
||||||
|
|
||||||
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
|
|
||||||
m_pickerItem = nullptr;
|
m_pickerItem = nullptr;
|
||||||
|
|
||||||
picker->SetClickHandler( [this] ( const VECTOR2D& aPosition ) -> bool
|
picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
|
||||||
{
|
|
||||||
if( m_pickerItem )
|
|
||||||
{
|
|
||||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
||||||
selectionTool->UnbrightenItem( m_pickerItem );
|
|
||||||
selectionTool->AddItemToSel( m_pickerItem, true );
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::doDelete, true );
|
|
||||||
m_pickerItem = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
picker->SetClickHandler(
|
||||||
} );
|
[this] ( const VECTOR2D& aPosition ) -> bool
|
||||||
|
|
||||||
picker->SetMotionHandler( [this] ( const VECTOR2D& aPos )
|
|
||||||
{
|
|
||||||
EE_COLLECTOR collector;
|
|
||||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
|
||||||
collector.Collect( m_frame->GetCurPart(), nonFields, (wxPoint) aPos );
|
|
||||||
|
|
||||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
||||||
selectionTool->GuessSelectionCandidates( collector, aPos );
|
|
||||||
|
|
||||||
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
|
||||||
|
|
||||||
if( m_pickerItem != item )
|
|
||||||
{
|
{
|
||||||
if( m_pickerItem )
|
if( m_pickerItem )
|
||||||
|
{
|
||||||
|
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||||
selectionTool->UnbrightenItem( m_pickerItem );
|
selectionTool->UnbrightenItem( m_pickerItem );
|
||||||
|
selectionTool->AddItemToSel( m_pickerItem, true );
|
||||||
|
m_toolMgr->RunAction( EE_ACTIONS::doDelete, true );
|
||||||
|
m_pickerItem = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
m_pickerItem = item;
|
return true;
|
||||||
|
} );
|
||||||
|
|
||||||
|
picker->SetMotionHandler(
|
||||||
|
[this] ( const VECTOR2D& aPos )
|
||||||
|
{
|
||||||
|
EE_COLLECTOR collector;
|
||||||
|
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||||
|
collector.Collect( m_frame->GetCurPart(), nonFields, (wxPoint) aPos );
|
||||||
|
|
||||||
|
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||||
|
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||||
|
|
||||||
|
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||||
|
|
||||||
|
if( m_pickerItem != item )
|
||||||
|
{
|
||||||
|
if( m_pickerItem )
|
||||||
|
selectionTool->UnbrightenItem( m_pickerItem );
|
||||||
|
|
||||||
|
m_pickerItem = item;
|
||||||
|
|
||||||
|
if( m_pickerItem )
|
||||||
|
selectionTool->BrightenItem( m_pickerItem );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
picker->SetFinalizeHandler(
|
||||||
|
[this] ( const int& aFinalState )
|
||||||
|
{
|
||||||
if( m_pickerItem )
|
if( m_pickerItem )
|
||||||
selectionTool->BrightenItem( m_pickerItem );
|
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||||
}
|
} );
|
||||||
} );
|
|
||||||
|
|
||||||
picker->SetFinalizeHandler( [this] ( const int& aFinalState )
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
{
|
|
||||||
if( m_pickerItem )
|
|
||||||
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
|
||||||
} );
|
|
||||||
|
|
||||||
picker->Activate();
|
|
||||||
Wait();
|
|
||||||
|
|
||||||
m_frame->PopTool( tool );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,15 +22,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
|
#include <tool/picker_tool.h>
|
||||||
#include <tools/sch_edit_tool.h>
|
#include <tools/sch_edit_tool.h>
|
||||||
#include <tools/ee_selection_tool.h>
|
#include <tools/ee_selection_tool.h>
|
||||||
#include <tools/sch_line_wire_bus_tool.h>
|
#include <tools/sch_line_wire_bus_tool.h>
|
||||||
#include <tools/ee_picker_tool.h>
|
|
||||||
#include <tools/sch_move_tool.h>
|
#include <tools/sch_move_tool.h>
|
||||||
#include <ee_actions.h>
|
#include <ee_actions.h>
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
#include <eda_doc.h>
|
|
||||||
#include <base_struct.h>
|
#include <base_struct.h>
|
||||||
#include <sch_item.h>
|
#include <sch_item.h>
|
||||||
#include <sch_component.h>
|
#include <sch_component.h>
|
||||||
|
@ -39,7 +38,6 @@
|
||||||
#include <sch_bitmap.h>
|
#include <sch_bitmap.h>
|
||||||
#include <sch_view.h>
|
#include <sch_view.h>
|
||||||
#include <sch_line.h>
|
#include <sch_line.h>
|
||||||
#include <sch_item.h>
|
|
||||||
#include <sch_bus_entry.h>
|
#include <sch_bus_entry.h>
|
||||||
#include <sch_edit_frame.h>
|
#include <sch_edit_frame.h>
|
||||||
#include <eeschema_id.h>
|
#include <eeschema_id.h>
|
||||||
|
@ -942,73 +940,73 @@ 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().get();
|
||||||
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
|
||||||
|
|
||||||
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
|
|
||||||
m_pickerItem = nullptr;
|
m_pickerItem = nullptr;
|
||||||
|
|
||||||
picker->SetClickHandler( [this] ( const VECTOR2D& aPosition ) -> bool
|
picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
|
||||||
{
|
|
||||||
if( m_pickerItem )
|
|
||||||
{
|
|
||||||
SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( m_pickerItem );
|
|
||||||
|
|
||||||
if( sch_item && sch_item->IsLocked() )
|
picker->SetClickHandler(
|
||||||
|
[this] ( const VECTOR2D& aPosition ) -> bool
|
||||||
|
{
|
||||||
|
if( m_pickerItem )
|
||||||
{
|
{
|
||||||
STATUS_TEXT_POPUP statusPopup( m_frame );
|
SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( m_pickerItem );
|
||||||
statusPopup.SetText( _( "Item locked." ) );
|
|
||||||
statusPopup.PopupFor( 2000 );
|
if( sch_item && sch_item->IsLocked() )
|
||||||
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
|
{
|
||||||
return true;
|
STATUS_TEXT_POPUP statusPopup( m_frame );
|
||||||
|
statusPopup.SetText( _( "Item locked." ) );
|
||||||
|
statusPopup.PopupFor( 2000 );
|
||||||
|
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||||
|
selectionTool->UnbrightenItem( m_pickerItem );
|
||||||
|
selectionTool->AddItemToSel( m_pickerItem, true );
|
||||||
|
m_toolMgr->RunAction( EE_ACTIONS::doDelete, true );
|
||||||
|
m_pickerItem = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} );
|
||||||
|
|
||||||
|
picker->SetMotionHandler(
|
||||||
|
[this] ( const VECTOR2D& aPos )
|
||||||
|
{
|
||||||
|
EE_COLLECTOR collector;
|
||||||
|
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||||
|
collector.Collect( m_frame->GetScreen()->GetDrawItems(), deletableItems, (wxPoint) aPos );
|
||||||
|
|
||||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||||
selectionTool->UnbrightenItem( m_pickerItem );
|
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||||
selectionTool->AddItemToSel( m_pickerItem, true );
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::doDelete, true );
|
|
||||||
m_pickerItem = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||||
} );
|
|
||||||
|
|
||||||
picker->SetMotionHandler( [this] ( const VECTOR2D& aPos )
|
if( m_pickerItem != item )
|
||||||
{
|
{
|
||||||
EE_COLLECTOR collector;
|
if( m_pickerItem )
|
||||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
selectionTool->UnbrightenItem( m_pickerItem );
|
||||||
collector.Collect( m_frame->GetScreen()->GetDrawItems(), deletableItems, (wxPoint) aPos );
|
|
||||||
|
|
||||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
m_pickerItem = item;
|
||||||
selectionTool->GuessSelectionCandidates( collector, aPos );
|
|
||||||
|
|
||||||
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
if( m_pickerItem )
|
||||||
|
selectionTool->BrightenItem( m_pickerItem );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
if( m_pickerItem != item )
|
picker->SetFinalizeHandler(
|
||||||
|
[this] ( const int& aFinalState )
|
||||||
{
|
{
|
||||||
if( m_pickerItem )
|
if( m_pickerItem )
|
||||||
selectionTool->UnbrightenItem( m_pickerItem );
|
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||||
|
} );
|
||||||
|
|
||||||
m_pickerItem = item;
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
|
|
||||||
if( m_pickerItem )
|
|
||||||
selectionTool->BrightenItem( m_pickerItem );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
picker->SetFinalizeHandler( [this] ( const int& aFinalState )
|
|
||||||
{
|
|
||||||
if( m_pickerItem )
|
|
||||||
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
|
||||||
} );
|
|
||||||
|
|
||||||
picker->Activate();
|
|
||||||
Wait();
|
|
||||||
|
|
||||||
m_frame->PopTool( tool );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,11 @@
|
||||||
#include <eeschema_id.h>
|
#include <eeschema_id.h>
|
||||||
#include <netlist_object.h>
|
#include <netlist_object.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
|
#include <tool/picker_tool.h>
|
||||||
#include <tools/ee_actions.h>
|
#include <tools/ee_actions.h>
|
||||||
#include <tools/ee_picker_tool.h>
|
|
||||||
#include <tools/sch_editor_control.h>
|
#include <tools/sch_editor_control.h>
|
||||||
#include <tools/ee_selection.h>
|
#include <tools/ee_selection.h>
|
||||||
#include <tools/ee_selection_tool.h>
|
#include <tools/ee_selection_tool.h>
|
||||||
#include <tools/sch_drawing_tools.h>
|
|
||||||
#include <tools/sch_line_wire_bus_tool.h>
|
|
||||||
#include <advanced_config.h>
|
#include <advanced_config.h>
|
||||||
#include <simulation_cursors.h>
|
#include <simulation_cursors.h>
|
||||||
#include <sim/sim_plot_frame.h>
|
#include <sim/sim_plot_frame.h>
|
||||||
|
@ -142,9 +140,8 @@ int SCH_EDITOR_CONTROL::UpdateFind( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
wxFindReplaceData* data = m_frame->GetFindReplaceData();
|
wxFindReplaceData* data = m_frame->GetFindReplaceData();
|
||||||
|
|
||||||
if( aEvent.IsAction( &ACTIONS::find )
|
if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
|
||||||
|| aEvent.IsAction( &ACTIONS::findAndReplace )
|
|| aEvent.IsAction( &ACTIONS::updateFind ) )
|
||||||
|| aEvent.IsAction( &ACTIONS::updateFind ) )
|
|
||||||
{
|
{
|
||||||
m_selectionTool->ClearSelection();
|
m_selectionTool->ClearSelection();
|
||||||
|
|
||||||
|
@ -298,12 +295,8 @@ int SCH_EDITOR_CONTROL::FindNext( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg = searchAllSheets ? _( "Reached end of schematic." )
|
||||||
|
: _( "Reached end of sheet." );
|
||||||
if( searchAllSheets )
|
|
||||||
msg = _( "Reached end of schematic." );
|
|
||||||
else
|
|
||||||
msg = _( "Reached end of sheet." );
|
|
||||||
|
|
||||||
m_frame->ShowFindReplaceStatus( msg + _( "\nFind again to wrap around to the start." ) );
|
m_frame->ShowFindReplaceStatus( msg + _( "\nFind again to wrap around to the start." ) );
|
||||||
wrapAroundTimer.StartOnce( 4000 );
|
wrapAroundTimer.StartOnce( 4000 );
|
||||||
|
@ -352,8 +345,7 @@ int SCH_EDITOR_CONTROL::ReplaceAll( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||||
{
|
{
|
||||||
for( EDA_ITEM* item = nextMatch( screen, nullptr, data );
|
for( EDA_ITEM* item = nextMatch( screen, nullptr, data ); item;
|
||||||
item;
|
|
||||||
item = nextMatch( screen, item, data ) )
|
item = nextMatch( screen, item, data ) )
|
||||||
{
|
{
|
||||||
item->Replace( *data, schematic.FindSheetForScreen( screen ) );
|
item->Replace( *data, schematic.FindSheetForScreen( screen ) );
|
||||||
|
@ -445,93 +437,83 @@ void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aF
|
||||||
|
|
||||||
|
|
||||||
#ifdef KICAD_SPICE
|
#ifdef KICAD_SPICE
|
||||||
static bool probeSimulation( SCH_EDIT_FRAME* aFrame, const VECTOR2D& aPosition )
|
|
||||||
{
|
|
||||||
constexpr KICAD_T wiresAndComponents[] = { SCH_LINE_T, SCH_COMPONENT_T, SCH_SHEET_PIN_T, EOT };
|
|
||||||
EE_SELECTION_TOOL* selTool = aFrame->GetToolManager()->GetTool<EE_SELECTION_TOOL>();
|
|
||||||
|
|
||||||
EDA_ITEM* item = selTool->SelectPoint( aPosition, wiresAndComponents );
|
|
||||||
|
|
||||||
if( !item )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
std::unique_ptr<NETLIST_OBJECT_LIST> netlist( aFrame->BuildNetListBase() );
|
|
||||||
|
|
||||||
for( NETLIST_OBJECT* obj : *netlist )
|
|
||||||
{
|
|
||||||
if( obj->m_Comp == item )
|
|
||||||
{
|
|
||||||
auto simFrame = (SIM_PLOT_FRAME*) aFrame->Kiway().Player( FRAME_SIMULATOR, false );
|
|
||||||
|
|
||||||
if( simFrame )
|
|
||||||
simFrame->AddVoltagePlot( obj->GetNetName() );
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
|
int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
|
constexpr KICAD_T wiresAndComponents[] = { SCH_LINE_T, SCH_COMPONENT_T, SCH_SHEET_PIN_T, EOT };
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
|
||||||
m_frame->PushTool( tool );
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
Activate();
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||||
m_frame->GetCanvas()->SetCursor( SIMULATION_CURSORS::GetCursor( SIMULATION_CURSORS::CURSOR::PROBE ) );
|
|
||||||
|
|
||||||
picker->SetClickHandler( std::bind( probeSimulation, m_frame, std::placeholders::_1 ) );
|
picker->SetCursor( SIMULATION_CURSORS::GetCursor( SIMULATION_CURSORS::CURSOR::PROBE ) );
|
||||||
picker->Activate();
|
|
||||||
Wait();
|
picker->SetClickHandler(
|
||||||
|
[&]( const VECTOR2D& aPosition )
|
||||||
|
{
|
||||||
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||||
|
|
||||||
|
EDA_ITEM* item = selTool->SelectPoint( aPosition, wiresAndComponents );
|
||||||
|
|
||||||
|
if( !item )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::unique_ptr<NETLIST_OBJECT_LIST> netlist( m_frame->BuildNetListBase() );
|
||||||
|
|
||||||
|
for( NETLIST_OBJECT* obj : *netlist )
|
||||||
|
{
|
||||||
|
if( obj->m_Comp == item )
|
||||||
|
{
|
||||||
|
if( simFrame )
|
||||||
|
simFrame->AddVoltagePlot( obj->GetNetName() );
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} );
|
||||||
|
|
||||||
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
|
|
||||||
m_frame->PopTool( tool );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool tuneSimulation( SCH_EDIT_FRAME* aFrame, const VECTOR2D& aPosition )
|
|
||||||
{
|
|
||||||
constexpr KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
|
|
||||||
EE_SELECTION_TOOL* selTool = aFrame->GetToolManager()->GetTool<EE_SELECTION_TOOL>();
|
|
||||||
EDA_ITEM* item = selTool->SelectPoint( aPosition, fieldsAndComponents );
|
|
||||||
|
|
||||||
if( !item )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if( item->Type() != SCH_COMPONENT_T )
|
|
||||||
{
|
|
||||||
item = item->GetParent();
|
|
||||||
|
|
||||||
if( item->Type() != SCH_COMPONENT_T )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto simFrame = (SIM_PLOT_FRAME*) aFrame->Kiway().Player( FRAME_SIMULATOR, false );
|
|
||||||
|
|
||||||
if( simFrame )
|
|
||||||
simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
|
int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
|
constexpr KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
m_frame->PushTool( tool );
|
SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
|
||||||
Activate();
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||||
m_frame->GetCanvas()->SetCursor( SIMULATION_CURSORS::GetCursor( SIMULATION_CURSORS::CURSOR::TUNE ) );
|
|
||||||
|
|
||||||
picker->SetClickHandler( std::bind( tuneSimulation, m_frame, std::placeholders::_1 ) );
|
picker->SetCursor( SIMULATION_CURSORS::GetCursor( SIMULATION_CURSORS::CURSOR::TUNE ) );
|
||||||
picker->Activate();
|
|
||||||
Wait();
|
picker->SetClickHandler(
|
||||||
|
[&]( const VECTOR2D& aPosition )
|
||||||
|
{
|
||||||
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||||
|
EDA_ITEM* item = selTool->SelectPoint( aPosition, fieldsAndComponents );
|
||||||
|
|
||||||
|
if( !item )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( item->Type() != SCH_COMPONENT_T )
|
||||||
|
{
|
||||||
|
item = item->GetParent();
|
||||||
|
|
||||||
|
if( item->Type() != SCH_COMPONENT_T )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( simFrame )
|
||||||
|
simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} );
|
||||||
|
|
||||||
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
|
|
||||||
m_frame->PopTool( tool );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* KICAD_SPICE */
|
#endif /* KICAD_SPICE */
|
||||||
|
@ -688,17 +670,19 @@ 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();
|
m_frame->RecalculateConnections();
|
||||||
|
|
||||||
EE_PICKER_TOOL* picker = m_toolMgr->GetTool<EE_PICKER_TOOL>();
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
|
||||||
|
|
||||||
picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, std::placeholders::_1 ) );
|
picker->SetClickHandler(
|
||||||
picker->Activate();
|
[this]( const VECTOR2D& aPos )
|
||||||
Wait();
|
{
|
||||||
|
return highlightNet( m_toolMgr, aPos );
|
||||||
|
} );
|
||||||
|
|
||||||
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
|
|
||||||
m_frame->PopTool( tool );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1129,7 +1113,6 @@ int SCH_EDITOR_CONTROL::ToggleForceHV( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDITOR_CONTROL::setTransitions()
|
void SCH_EDITOR_CONTROL::setTransitions()
|
||||||
{
|
{
|
||||||
Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
|
Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
|
||||||
|
@ -1151,12 +1134,6 @@ void SCH_EDITOR_CONTROL::setTransitions()
|
||||||
Go( &SCH_EDITOR_CONTROL::UpdateFind, ACTIONS::updateFind.MakeEvent() );
|
Go( &SCH_EDITOR_CONTROL::UpdateFind, ACTIONS::updateFind.MakeEvent() );
|
||||||
Go( &SCH_EDITOR_CONTROL::UpdateFind, EVENTS::SelectedItemsModified );
|
Go( &SCH_EDITOR_CONTROL::UpdateFind, EVENTS::SelectedItemsModified );
|
||||||
|
|
||||||
/*
|
|
||||||
Go( &SCH_EDITOR_CONTROL::ToggleLockSelected, EE_ACTIONS::toggleLock.MakeEvent() );
|
|
||||||
Go( &SCH_EDITOR_CONTROL::LockSelected, EE_ACTIONS::lock.MakeEvent() );
|
|
||||||
Go( &SCH_EDITOR_CONTROL::UnlockSelected, EE_ACTIONS::unlock.MakeEvent() );
|
|
||||||
*/
|
|
||||||
|
|
||||||
Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::SelectedEvent );
|
Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::SelectedEvent );
|
||||||
Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::UnselectedEvent );
|
Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::UnselectedEvent );
|
||||||
Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::ClearedEvent );
|
Go( &SCH_EDITOR_CONTROL::CrossProbeToPcb, EVENTS::ClearedEvent );
|
||||||
|
|
|
@ -140,6 +140,7 @@ public:
|
||||||
// Common Tools
|
// Common Tools
|
||||||
static TOOL_ACTION selectionTool;
|
static TOOL_ACTION selectionTool;
|
||||||
static TOOL_ACTION measureTool;
|
static TOOL_ACTION measureTool;
|
||||||
|
static TOOL_ACTION pickerTool;
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
static TOOL_ACTION show3DViewer;
|
static TOOL_ACTION show3DViewer;
|
||||||
|
|
|
@ -21,27 +21,27 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PL_PICKER_TOOL_H
|
#ifndef PICKER_TOOL_H
|
||||||
#define PL_PICKER_TOOL_H
|
#define PICKER_TOOL_H
|
||||||
|
|
||||||
#include <boost/optional/optional.hpp>
|
#include <boost/optional/optional.hpp>
|
||||||
|
#include <math/vector2d.h>
|
||||||
#include <tool/tool_interactive.h>
|
#include <tool/tool_interactive.h>
|
||||||
#include <tool/tool_menu.h>
|
|
||||||
|
|
||||||
class PL_EDITOR_FRAME;
|
class EDA_DRAW_FRAME;
|
||||||
|
|
||||||
|
|
||||||
class PL_PICKER_TOOL : public TOOL_INTERACTIVE
|
class PICKER_TOOL : public TOOL_INTERACTIVE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PL_PICKER_TOOL();
|
PICKER_TOOL();
|
||||||
~PL_PICKER_TOOL() {}
|
~PICKER_TOOL() {}
|
||||||
|
|
||||||
/// @copydoc TOOL_INTERACTIVE::Init()
|
/// @copydoc TOOL_INTERACTIVE::Init()
|
||||||
bool Init() override;
|
bool Init() override;
|
||||||
|
|
||||||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||||
void Reset( RESET_REASON aReason ) override;
|
void Reset( RESET_REASON aReason ) override { }
|
||||||
|
|
||||||
///> Event handler types.
|
///> Event handler types.
|
||||||
typedef std::function<bool(const VECTOR2D&)> CLICK_HANDLER;
|
typedef std::function<bool(const VECTOR2D&)> CLICK_HANDLER;
|
||||||
|
@ -61,6 +61,8 @@ public:
|
||||||
///> Main event loop.
|
///> Main event loop.
|
||||||
int Main( const TOOL_EVENT& aEvent );
|
int Main( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
inline void SetCursor( const wxCursor& aCursor ) { m_cursor = aCursor; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SetClickHandler()
|
* Function SetClickHandler()
|
||||||
* Sets a handler for mouse click event. Handler may decide to receive further click by
|
* Sets a handler for mouse click event. Handler may decide to receive further click by
|
||||||
|
@ -68,7 +70,7 @@ public:
|
||||||
*/
|
*/
|
||||||
inline void SetClickHandler( CLICK_HANDLER aHandler )
|
inline void SetClickHandler( CLICK_HANDLER aHandler )
|
||||||
{
|
{
|
||||||
assert( !m_clickHandler );
|
wxASSERT( !m_clickHandler );
|
||||||
m_clickHandler = aHandler;
|
m_clickHandler = aHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +90,7 @@ public:
|
||||||
*/
|
*/
|
||||||
inline void SetCancelHandler( CANCEL_HANDLER aHandler )
|
inline void SetCancelHandler( CANCEL_HANDLER aHandler )
|
||||||
{
|
{
|
||||||
assert( !m_cancelHandler );
|
wxASSERT( !m_cancelHandler );
|
||||||
m_cancelHandler = aHandler;
|
m_cancelHandler = aHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +100,7 @@ public:
|
||||||
*/
|
*/
|
||||||
inline void SetFinalizeHandler( FINALIZE_HANDLER aHandler )
|
inline void SetFinalizeHandler( FINALIZE_HANDLER aHandler )
|
||||||
{
|
{
|
||||||
assert( !m_finalizeHandler );
|
wxASSERT( !m_finalizeHandler );
|
||||||
m_finalizeHandler = aHandler;
|
m_finalizeHandler = aHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,14 +115,15 @@ private:
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PL_EDITOR_FRAME* m_frame;
|
EDA_DRAW_FRAME* m_frame;
|
||||||
|
wxCursor m_cursor;
|
||||||
|
|
||||||
OPT<CLICK_HANDLER> m_clickHandler;
|
OPT<CLICK_HANDLER> m_clickHandler;
|
||||||
OPT<MOTION_HANDLER> m_motionHandler;
|
OPT<MOTION_HANDLER> m_motionHandler;
|
||||||
OPT<CANCEL_HANDLER> m_cancelHandler;
|
OPT<CANCEL_HANDLER> m_cancelHandler;
|
||||||
OPT<FINALIZE_HANDLER> m_finalizeHandler;
|
OPT<FINALIZE_HANDLER> m_finalizeHandler;
|
||||||
|
|
||||||
OPT<VECTOR2D> m_picked;
|
OPT<VECTOR2D> m_picked;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PL_PICKER_TOOL_H */
|
#endif /* PICKER_TOOL_H */
|
|
@ -35,7 +35,6 @@ set( PL_EDITOR_SRCS
|
||||||
tools/pl_drawing_tools.cpp
|
tools/pl_drawing_tools.cpp
|
||||||
tools/pl_edit_tool.cpp
|
tools/pl_edit_tool.cpp
|
||||||
tools/pl_editor_control.cpp
|
tools/pl_editor_control.cpp
|
||||||
tools/pl_picker_tool.cpp
|
|
||||||
tools/pl_point_editor.cpp
|
tools/pl_point_editor.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -44,13 +44,13 @@
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tool/common_control.h>
|
#include <tool/common_control.h>
|
||||||
#include <tool/common_tools.h>
|
#include <tool/common_tools.h>
|
||||||
|
#include <tool/picker_tool.h>
|
||||||
#include <tool/zoom_tool.h>
|
#include <tool/zoom_tool.h>
|
||||||
#include <tools/pl_actions.h>
|
#include <tools/pl_actions.h>
|
||||||
#include <tools/pl_selection_tool.h>
|
#include <tools/pl_selection_tool.h>
|
||||||
#include <tools/pl_drawing_tools.h>
|
#include <tools/pl_drawing_tools.h>
|
||||||
#include <tools/pl_edit_tool.h>
|
#include <tools/pl_edit_tool.h>
|
||||||
#include <tools/pl_point_editor.h>
|
#include <tools/pl_point_editor.h>
|
||||||
#include <tools/pl_picker_tool.h>
|
|
||||||
#include <invoke_pl_editor_dialog.h>
|
#include <invoke_pl_editor_dialog.h>
|
||||||
#include <tools/pl_editor_control.h>
|
#include <tools/pl_editor_control.h>
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ void PL_EDITOR_FRAME::setupTools()
|
||||||
m_toolManager->RegisterTool( new PL_DRAWING_TOOLS );
|
m_toolManager->RegisterTool( new PL_DRAWING_TOOLS );
|
||||||
m_toolManager->RegisterTool( new PL_EDIT_TOOL );
|
m_toolManager->RegisterTool( new PL_EDIT_TOOL );
|
||||||
m_toolManager->RegisterTool( new PL_POINT_EDITOR );
|
m_toolManager->RegisterTool( new PL_POINT_EDITOR );
|
||||||
m_toolManager->RegisterTool( new PL_PICKER_TOOL );
|
m_toolManager->RegisterTool( new PICKER_TOOL );
|
||||||
m_toolManager->InitTools();
|
m_toolManager->InitTools();
|
||||||
|
|
||||||
// Run the selection tool, it is supposed to be always active
|
// Run the selection tool, it is supposed to be always active
|
||||||
|
|
|
@ -96,12 +96,6 @@ TOOL_ACTION PL_ACTIONS::previewSettings( "plEditor.EditorControl.PreviewSettings
|
||||||
sheetset_xpm );
|
sheetset_xpm );
|
||||||
|
|
||||||
|
|
||||||
// PL_PICKER_TOOL
|
|
||||||
//
|
|
||||||
TOOL_ACTION PL_ACTIONS::pickerTool( "plEditor.InteractivePicker",
|
|
||||||
AS_GLOBAL, 0, "", "", "", NULL, AF_ACTIVATE );
|
|
||||||
|
|
||||||
|
|
||||||
// PL_SELECTION_TOOL
|
// PL_SELECTION_TOOL
|
||||||
//
|
//
|
||||||
TOOL_ACTION PL_ACTIONS::selectionActivate( "plEditor.InteractiveSelection",
|
TOOL_ACTION PL_ACTIONS::selectionActivate( "plEditor.InteractiveSelection",
|
||||||
|
|
|
@ -22,20 +22,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
|
#include <tool/picker_tool.h>
|
||||||
#include <tools/pl_selection_tool.h>
|
#include <tools/pl_selection_tool.h>
|
||||||
#include <tools/pl_drawing_tools.h>
|
|
||||||
#include <tools/pl_actions.h>
|
#include <tools/pl_actions.h>
|
||||||
#include <tools/pl_edit_tool.h>
|
#include <tools/pl_edit_tool.h>
|
||||||
#include <tools/pl_picker_tool.h>
|
|
||||||
#include <ws_data_model.h>
|
#include <ws_data_model.h>
|
||||||
#include <ws_draw_item.h>
|
#include <ws_draw_item.h>
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
#include <base_struct.h>
|
#include <base_struct.h>
|
||||||
#include <view/view.h>
|
|
||||||
#include <pl_editor_frame.h>
|
#include <pl_editor_frame.h>
|
||||||
#include <pl_editor_id.h>
|
#include <pl_editor_id.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
|
||||||
|
|
||||||
|
|
||||||
PL_EDIT_TOOL::PL_EDIT_TOOL() :
|
PL_EDIT_TOOL::PL_EDIT_TOOL() :
|
||||||
|
@ -341,68 +338,68 @@ 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().get();
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
m_frame->PushTool( tool );
|
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||||
Activate();
|
|
||||||
|
|
||||||
PL_PICKER_TOOL* picker = m_toolMgr->GetTool<PL_PICKER_TOOL>();
|
picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
|
||||||
m_pickerItem = nullptr;
|
m_pickerItem = nullptr;
|
||||||
|
|
||||||
picker->SetClickHandler( [this] ( const VECTOR2D& aPosition ) -> bool
|
picker->SetClickHandler(
|
||||||
{
|
[this] ( const VECTOR2D& aPosition ) -> bool
|
||||||
if( m_pickerItem )
|
|
||||||
{
|
{
|
||||||
PL_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>();
|
if( m_pickerItem )
|
||||||
selectionTool->UnbrightenItem( m_pickerItem );
|
|
||||||
selectionTool->AddItemToSel( m_pickerItem, true );
|
|
||||||
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
|
||||||
m_pickerItem = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} );
|
|
||||||
|
|
||||||
picker->SetMotionHandler( [this] ( const VECTOR2D& aPos )
|
|
||||||
{
|
|
||||||
int threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
|
||||||
EDA_ITEM* item = nullptr;
|
|
||||||
|
|
||||||
for( WS_DATA_ITEM* dataItem : WS_DATA_MODEL::GetTheInstance().GetItems() )
|
|
||||||
{
|
|
||||||
for( WS_DRAW_ITEM_BASE* drawItem : dataItem->GetDrawItems() )
|
|
||||||
{
|
{
|
||||||
if( drawItem->HitTest( (wxPoint) aPos, threshold ) )
|
PL_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>();
|
||||||
|
selectionTool->UnbrightenItem( m_pickerItem );
|
||||||
|
selectionTool->AddItemToSel( m_pickerItem, true );
|
||||||
|
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
||||||
|
m_pickerItem = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} );
|
||||||
|
|
||||||
|
picker->SetMotionHandler(
|
||||||
|
[this] ( const VECTOR2D& aPos )
|
||||||
|
{
|
||||||
|
int threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||||
|
EDA_ITEM* item = nullptr;
|
||||||
|
|
||||||
|
for( WS_DATA_ITEM* dataItem : WS_DATA_MODEL::GetTheInstance().GetItems() )
|
||||||
|
{
|
||||||
|
for( WS_DRAW_ITEM_BASE* drawItem : dataItem->GetDrawItems() )
|
||||||
{
|
{
|
||||||
item = drawItem;
|
if( drawItem->HitTest( (wxPoint) aPos, threshold ) )
|
||||||
break;
|
{
|
||||||
|
item = drawItem;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if( m_pickerItem != item )
|
if( m_pickerItem != item )
|
||||||
|
{
|
||||||
|
PL_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>();
|
||||||
|
|
||||||
|
if( m_pickerItem )
|
||||||
|
selectionTool->UnbrightenItem( m_pickerItem );
|
||||||
|
|
||||||
|
m_pickerItem = item;
|
||||||
|
|
||||||
|
if( m_pickerItem )
|
||||||
|
selectionTool->BrightenItem( m_pickerItem );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
picker->SetFinalizeHandler(
|
||||||
|
[this] ( const int& aFinalState )
|
||||||
{
|
{
|
||||||
PL_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>();
|
|
||||||
|
|
||||||
if( m_pickerItem )
|
if( m_pickerItem )
|
||||||
selectionTool->UnbrightenItem( m_pickerItem );
|
m_toolMgr->GetTool<PL_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||||
|
} );
|
||||||
|
|
||||||
m_pickerItem = item;
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
|
|
||||||
if( m_pickerItem )
|
|
||||||
selectionTool->BrightenItem( m_pickerItem );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
picker->SetFinalizeHandler( [this] ( const int& aFinalState )
|
|
||||||
{
|
|
||||||
if( m_pickerItem )
|
|
||||||
m_toolMgr->GetTool<PL_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
|
||||||
} );
|
|
||||||
|
|
||||||
picker->Activate();
|
|
||||||
Wait();
|
|
||||||
|
|
||||||
m_frame->PopTool( tool );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,19 +20,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <wx/numdlg.h>
|
#include <wx/numdlg.h>
|
||||||
|
|
||||||
#include <core/optional.h>
|
#include <core/optional.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
#include "class_draw_panel_gal.h"
|
|
||||||
#include "class_board.h"
|
#include "class_board.h"
|
||||||
|
|
||||||
#include <pcb_edit_frame.h>
|
#include <pcb_edit_frame.h>
|
||||||
#include <id.h>
|
#include <id.h>
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
#include <view/view.h>
|
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
#include <pcb_layer_widget.h>
|
#include <pcb_layer_widget.h>
|
||||||
#include <pcb_painter.h>
|
#include <pcb_painter.h>
|
||||||
|
@ -45,14 +40,11 @@ using namespace std::placeholders;
|
||||||
#include <collectors.h>
|
#include <collectors.h>
|
||||||
#include <tool/action_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tool/tool_settings.h>
|
|
||||||
#include <tool/grid_menu.h>
|
#include <tool/grid_menu.h>
|
||||||
#include <tool/zoom_menu.h>
|
#include <tool/zoom_menu.h>
|
||||||
#include <tools/pcb_actions.h>
|
#include <tools/pcb_actions.h>
|
||||||
#include <tools/selection_tool.h>
|
#include <tools/selection_tool.h>
|
||||||
#include <tools/edit_tool.h>
|
|
||||||
#include <tools/grid_helper.h>
|
#include <tools/grid_helper.h>
|
||||||
#include <tools/tool_event_utils.h>
|
|
||||||
|
|
||||||
#include "router_tool.h"
|
#include "router_tool.h"
|
||||||
#include "pns_segment.h"
|
#include "pns_segment.h"
|
||||||
|
@ -1004,7 +996,7 @@ void ROUTER_TOOL::performDragging( int aMode )
|
||||||
highlightNet( true, m_startItem->Net() );
|
highlightNet( true, m_startItem->Net() );
|
||||||
|
|
||||||
ctls->SetAutoPan( true );
|
ctls->SetAutoPan( true );
|
||||||
m_gridHelper->SetAuxAxes( true, m_startSnapPoint, true );
|
m_gridHelper->SetAuxAxes( true, m_startSnapPoint );
|
||||||
frame()->UndoRedoBlock( true );
|
frame()->UndoRedoBlock( true );
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
|
@ -1160,7 +1152,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
||||||
if( !dragStarted )
|
if( !dragStarted )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
m_gridHelper->SetAuxAxes( true, p, true );
|
m_gridHelper->SetAuxAxes( true, p );
|
||||||
controls()->ShowCursor( true );
|
controls()->ShowCursor( true );
|
||||||
controls()->ForceCursorPosition( false );
|
controls()->ForceCursorPosition( false );
|
||||||
controls()->SetAutoPan( true );
|
controls()->SetAutoPan( true );
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
#include <class_edge_mod.h>
|
#include <class_edge_mod.h>
|
||||||
|
@ -33,15 +32,12 @@
|
||||||
#include <collectors.h>
|
#include <collectors.h>
|
||||||
#include <pcb_edit_frame.h>
|
#include <pcb_edit_frame.h>
|
||||||
#include <kiway.h>
|
#include <kiway.h>
|
||||||
#include <class_draw_panel_gal.h>
|
|
||||||
#include <footprint_edit_frame.h>
|
#include <footprint_edit_frame.h>
|
||||||
#include <array_creator.h>
|
#include <array_creator.h>
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
#include <status_popup.h>
|
#include <status_popup.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
#include <view/view.h>
|
|
||||||
#include <gal/graphics_abstraction_layer.h>
|
|
||||||
#include <connectivity/connectivity_data.h>
|
#include <connectivity/connectivity_data.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
|
@ -54,11 +50,9 @@ using namespace std::placeholders;
|
||||||
#include "pcbnew_picker_tool.h"
|
#include "pcbnew_picker_tool.h"
|
||||||
#include "grid_helper.h"
|
#include "grid_helper.h"
|
||||||
#include "kicad_clipboard.h"
|
#include "kicad_clipboard.h"
|
||||||
#include "pcbnew_control.h"
|
|
||||||
#include <router/router_tool.h>
|
#include <router/router_tool.h>
|
||||||
#include <dialogs/dialog_move_exact.h>
|
#include <dialogs/dialog_move_exact.h>
|
||||||
#include <dialogs/dialog_track_via_properties.h>
|
#include <dialogs/dialog_track_via_properties.h>
|
||||||
#include <dialogs/dialog_exchange_footprints.h>
|
|
||||||
#include <tools/tool_event_utils.h>
|
#include <tools/tool_event_utils.h>
|
||||||
#include <preview_items/ruler_item.h>
|
#include <preview_items/ruler_item.h>
|
||||||
#include <board_commit.h>
|
#include <board_commit.h>
|
||||||
|
@ -155,13 +149,11 @@ bool EDIT_TOOL::Init()
|
||||||
menu.AddItem( PCB_ACTIONS::properties, SELECTION_CONDITIONS::Count( 1 )
|
menu.AddItem( PCB_ACTIONS::properties, SELECTION_CONDITIONS::Count( 1 )
|
||||||
|| SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
|| SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
||||||
|
|
||||||
|
|
||||||
menu.AddItem( PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddItem( PCB_ACTIONS::positionRelative, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( PCB_ACTIONS::positionRelative, SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddItem( ACTIONS::duplicate, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( ACTIONS::duplicate, SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddItem( PCB_ACTIONS::createArray, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( PCB_ACTIONS::createArray, SELECTION_CONDITIONS::NotEmpty );
|
||||||
|
|
||||||
|
|
||||||
menu.AddSeparator();
|
menu.AddSeparator();
|
||||||
menu.AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty );
|
||||||
|
@ -250,8 +242,10 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
// Be sure that there is at least one item that we can modify. If nothing was selected before,
|
// Be sure that there is at least one item that we can modify. If nothing was selected before,
|
||||||
// try looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection)
|
// try looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection)
|
||||||
auto& selection = m_selectionTool->RequestSelection(
|
auto& selection = m_selectionTool->RequestSelection(
|
||||||
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
|
||||||
{ EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } );
|
{
|
||||||
|
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS );
|
||||||
|
} );
|
||||||
|
|
||||||
if( m_dragging || selection.Empty() )
|
if( m_dragging || selection.Empty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1294,42 +1288,42 @@ int EDIT_TOOL::EditFpInFpEditor( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
bool EDIT_TOOL::pickCopyReferencePoint( VECTOR2I& aP )
|
bool EDIT_TOOL::pickCopyReferencePoint( VECTOR2I& aP )
|
||||||
{
|
{
|
||||||
STATUS_TEXT_POPUP statusPopup( frame() );
|
std::string tool = "pcbnew.InteractiveEdit.selectReferencePoint";
|
||||||
|
STATUS_TEXT_POPUP statusPopup( frame() );
|
||||||
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
||||||
bool picking = true;
|
bool retVal = true;
|
||||||
bool retVal = true;
|
|
||||||
|
|
||||||
frame()->PushTool( "pcbnew.InteractiveEdit.selectReferencePoint" );
|
|
||||||
statusPopup.SetText( _( "Select reference point for the copy..." ) );
|
statusPopup.SetText( _( "Select reference point for the copy..." ) );
|
||||||
|
|
||||||
picker->Activate();
|
picker->SetClickHandler(
|
||||||
picker->SetClickHandler( [&]( const VECTOR2D& aPoint ) -> bool
|
[&]( const VECTOR2D& aPoint ) -> bool
|
||||||
{
|
{
|
||||||
aP = aPoint;
|
aP = aPoint;
|
||||||
statusPopup.SetText( _( "Selection copied." ) );
|
statusPopup.SetText( _( "Selection copied." ) );
|
||||||
statusPopup.Expire( 800 );
|
statusPopup.Expire( 800 );
|
||||||
picking = false;
|
return false; // we don't need any more points
|
||||||
return false; // we don't need any more points
|
} );
|
||||||
} );
|
|
||||||
picker->SetCancelHandler( [&]()
|
picker->SetMotionHandler(
|
||||||
{
|
[&] ( const VECTOR2D& aPos )
|
||||||
statusPopup.SetText( _( "Copy cancelled." ) );
|
{
|
||||||
statusPopup.Expire( 800 );
|
statusPopup.Move( aPos + wxPoint( 20, -50 ) );
|
||||||
picking = false;
|
} );
|
||||||
retVal = false;
|
|
||||||
} );
|
picker->SetCancelHandler(
|
||||||
|
[&]()
|
||||||
|
{
|
||||||
|
statusPopup.SetText( _( "Copy cancelled." ) );
|
||||||
|
statusPopup.Expire( 800 );
|
||||||
|
retVal = false;
|
||||||
|
} );
|
||||||
|
|
||||||
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
|
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
|
||||||
statusPopup.Popup();
|
statusPopup.Popup();
|
||||||
|
|
||||||
while( picking )
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
{
|
|
||||||
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
|
|
||||||
Wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
statusPopup.Hide();
|
statusPopup.Hide();
|
||||||
// Picker calls PopTool() so that it gets done before activating tool's PushTool()
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,73 +75,61 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Main()
|
* Function Main()
|
||||||
*
|
|
||||||
* Main loop in which events are handled.
|
* Main loop in which events are handled.
|
||||||
* @param aEvent is the handled event.
|
|
||||||
*/
|
*/
|
||||||
int Main( const TOOL_EVENT& aEvent );
|
int Main( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Drag()
|
* Function Drag()
|
||||||
*
|
|
||||||
* Invoke the PNS router to drag tracks.
|
* Invoke the PNS router to drag tracks.
|
||||||
*/
|
*/
|
||||||
int Drag( const TOOL_EVENT& aEvent );
|
int Drag( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Edit()
|
* Function Properties()
|
||||||
*
|
|
||||||
* Displays properties window for the selected object.
|
* Displays properties window for the selected object.
|
||||||
*/
|
*/
|
||||||
int Properties( const TOOL_EVENT& aEvent );
|
int Properties( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Rotate()
|
* Function Rotate()
|
||||||
*
|
|
||||||
* Rotates currently selected items.
|
* Rotates currently selected items.
|
||||||
*/
|
*/
|
||||||
int Rotate( const TOOL_EVENT& aEvent );
|
int Rotate( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Flip()
|
* Function Flip()
|
||||||
*
|
|
||||||
* Rotates currently selected items. The rotation point is the current cursor position.
|
* Rotates currently selected items. The rotation point is the current cursor position.
|
||||||
*/
|
*/
|
||||||
int Flip( const TOOL_EVENT& aEvent );
|
int Flip( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Mirror
|
* Function Mirror
|
||||||
*
|
|
||||||
* Mirrors the current selection. The mirror axis passes through the current point.
|
* Mirrors the current selection. The mirror axis passes through the current point.
|
||||||
*/
|
*/
|
||||||
int Mirror( const TOOL_EVENT& aEvent );
|
int Mirror( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Remove()
|
* Function Remove()
|
||||||
*
|
|
||||||
* Deletes currently selected items. The rotation point is the current cursor position.
|
* Deletes currently selected items. The rotation point is the current cursor position.
|
||||||
*/
|
*/
|
||||||
int Remove( const TOOL_EVENT& aEvent );
|
int Remove( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Duplicate()
|
* Function Duplicate()
|
||||||
*
|
|
||||||
* Duplicates the current selection and starts a move action.
|
* Duplicates the current selection and starts a move action.
|
||||||
*/
|
*/
|
||||||
int Duplicate( const TOOL_EVENT& aEvent );
|
int Duplicate( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function MoveExact()
|
* Function MoveExact()
|
||||||
*
|
|
||||||
* Invokes a dialog box to allow moving of the item by an exact amount.
|
* Invokes a dialog box to allow moving of the item by an exact amount.
|
||||||
*/
|
*/
|
||||||
int MoveExact( const TOOL_EVENT& aEvent );
|
int MoveExact( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function CreateArray()
|
* Function CreateArray()
|
||||||
*
|
* Creates an array of the selected items, invoking the array editor dialog to set the options.
|
||||||
* Creates an array of the selected items, invoking the array editor dialog
|
|
||||||
* to set the array options
|
|
||||||
*/
|
*/
|
||||||
int CreateArray( const TOOL_EVENT& aEvent );
|
int CreateArray( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
@ -150,17 +138,13 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function FootprintFilter()
|
* Function FootprintFilter()
|
||||||
*
|
* A selection filter which prunes the selection to contain only items of type PCB_MODULE_T
|
||||||
* A selection filter which prunes the selection to contain only items
|
|
||||||
* of type PCB_MODULE_T
|
|
||||||
*/
|
*/
|
||||||
static void FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector );
|
static void FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function PadFilter()
|
* Function PadFilter()
|
||||||
*
|
* A selection filter which prunes the selection to contain only items of type PCB_PAD_T
|
||||||
* A selection filter which prunes the selection to contain only items
|
|
||||||
* of type PCB_PAD_T
|
|
||||||
*/
|
*/
|
||||||
static void PadFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector );
|
static void PadFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector );
|
||||||
|
|
||||||
|
@ -171,7 +155,6 @@ public:
|
||||||
* Function copyToClipboard()
|
* Function copyToClipboard()
|
||||||
* Sends the current selection to the clipboard by formatting it as a fake pcb
|
* Sends the current selection to the clipboard by formatting it as a fake pcb
|
||||||
* see AppendBoardFromClipboard for importing
|
* see AppendBoardFromClipboard for importing
|
||||||
* @return True if it was sent succesfully
|
|
||||||
*/
|
*/
|
||||||
int copyToClipboard( const TOOL_EVENT& aEvent );
|
int copyToClipboard( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
@ -179,28 +162,17 @@ public:
|
||||||
* Function cutToClipboard()
|
* Function cutToClipboard()
|
||||||
* Cuts the current selection to the clipboard by formatting it as a fake pcb
|
* Cuts the current selection to the clipboard by formatting it as a fake pcb
|
||||||
* see AppendBoardFromClipboard for importing
|
* see AppendBoardFromClipboard for importing
|
||||||
* @return True if it was sent succesfully
|
|
||||||
*/
|
*/
|
||||||
int cutToClipboard( const TOOL_EVENT& aEvent );
|
int cutToClipboard( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
BOARD_COMMIT* GetCurrentCommit() const
|
BOARD_COMMIT* GetCurrentCommit() const { return m_commit.get(); }
|
||||||
{
|
|
||||||
return m_commit.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///> Selection tool used for obtaining selected items
|
SELECTION_TOOL* m_selectionTool; // Selection tool used for obtaining selected items
|
||||||
SELECTION_TOOL* m_selectionTool;
|
bool m_dragging; // Indicates objects are being dragged right now
|
||||||
|
bool m_lockedSelected; // Determines if we prompt before removing locked objects
|
||||||
///> Flag determining if anything is being dragged right now
|
VECTOR2I m_cursor; // Last cursor position (needed for getModificationPoint()
|
||||||
bool m_dragging;
|
// to avoid changes of edit reference point).
|
||||||
|
|
||||||
///> Flag determining whether we are prompting for locked removal
|
|
||||||
bool m_lockedSelected;
|
|
||||||
|
|
||||||
///> Last cursor position (needed for getModificationPoint() to avoid changes
|
|
||||||
///> of edit reference point).
|
|
||||||
VECTOR2I m_cursor;
|
|
||||||
|
|
||||||
///> Returns the right modification point (e.g. for rotation), depending on the number of
|
///> Returns the right modification point (e.g. for rotation), depending on the number of
|
||||||
///> selected items.
|
///> selected items.
|
||||||
|
|
|
@ -48,7 +48,6 @@ using namespace std::placeholders;
|
||||||
GRID_HELPER::GRID_HELPER( PCB_BASE_FRAME* aFrame ) :
|
GRID_HELPER::GRID_HELPER( PCB_BASE_FRAME* aFrame ) :
|
||||||
m_frame( aFrame )
|
m_frame( aFrame )
|
||||||
{
|
{
|
||||||
m_diagonalAuxAxesEnable = true;
|
|
||||||
m_enableSnap = true;
|
m_enableSnap = true;
|
||||||
m_enableGrid = true;
|
m_enableGrid = true;
|
||||||
m_snapSize = 100;
|
m_snapSize = 100;
|
||||||
|
@ -74,18 +73,6 @@ GRID_HELPER::~GRID_HELPER()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GRID_HELPER::SetGrid( int aSize )
|
|
||||||
{
|
|
||||||
assert( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GRID_HELPER::SetOrigin( const VECTOR2I& aOrigin )
|
|
||||||
{
|
|
||||||
assert( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VECTOR2I GRID_HELPER::GetGrid() const
|
VECTOR2I GRID_HELPER::GetGrid() const
|
||||||
{
|
{
|
||||||
PCB_SCREEN* screen = m_frame->GetScreen();
|
PCB_SCREEN* screen = m_frame->GetScreen();
|
||||||
|
@ -102,7 +89,7 @@ VECTOR2I GRID_HELPER::GetOrigin() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin, bool aEnableDiagonal )
|
void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin )
|
||||||
{
|
{
|
||||||
if( aEnable )
|
if( aEnable )
|
||||||
{
|
{
|
||||||
|
@ -115,8 +102,6 @@ void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin, bool aEnabl
|
||||||
m_auxAxis = OPT<VECTOR2I>();
|
m_auxAxis = OPT<VECTOR2I>();
|
||||||
m_frame->GetCanvas()->GetView()->SetVisible( &m_viewAxis, false );
|
m_frame->GetCanvas()->GetView()->SetVisible( &m_viewAxis, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_diagonalAuxAxesEnable = aEnable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,10 +111,10 @@ VECTOR2I GRID_HELPER::Align( const VECTOR2I& aPoint ) const
|
||||||
return aPoint;
|
return aPoint;
|
||||||
|
|
||||||
const VECTOR2D gridOffset( GetOrigin() );
|
const VECTOR2D gridOffset( GetOrigin() );
|
||||||
const VECTOR2D gridSize( GetGrid() );
|
const VECTOR2D grid( GetGrid() );
|
||||||
|
|
||||||
VECTOR2I nearest( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
|
VECTOR2I nearest( KiROUND( ( aPoint.x - gridOffset.x ) / grid.x ) * grid.x + gridOffset.x,
|
||||||
KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
|
KiROUND( ( aPoint.y - gridOffset.y ) / grid.y ) * grid.y + gridOffset.y );
|
||||||
|
|
||||||
if( !m_auxAxis )
|
if( !m_auxAxis )
|
||||||
return nearest;
|
return nearest;
|
||||||
|
@ -320,7 +305,7 @@ BOARD_ITEM* GRID_HELPER::GetSnapped( void ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, const bool aFrom )
|
void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, bool aFrom )
|
||||||
{
|
{
|
||||||
VECTOR2I origin;
|
VECTOR2I origin;
|
||||||
|
|
||||||
|
@ -332,8 +317,8 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, co
|
||||||
|
|
||||||
for( auto pad : mod->Pads() )
|
for( auto pad : mod->Pads() )
|
||||||
{
|
{
|
||||||
if(( aFrom || m_frame->Settings().m_MagneticPads == CAPTURE_ALWAYS ) &&
|
if( ( aFrom || m_frame->Settings().m_MagneticPads == CAPTURE_ALWAYS )
|
||||||
pad->GetBoundingBox().Contains( wxPoint( aRefPos.x, aRefPos.y ) ) )
|
&& pad->GetBoundingBox().Contains( wxPoint( aRefPos.x, aRefPos.y ) ) )
|
||||||
{
|
{
|
||||||
addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
|
addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -26,13 +26,10 @@
|
||||||
#define __GRID_HELPER_H
|
#define __GRID_HELPER_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <math/vector2d.h>
|
#include <math/vector2d.h>
|
||||||
#include <core/optional.h>
|
#include <core/optional.h>
|
||||||
#include <origin_viewitem.h>
|
#include <origin_viewitem.h>
|
||||||
|
|
||||||
#include <layers_id_colors_and_visibility.h>
|
#include <layers_id_colors_and_visibility.h>
|
||||||
|
|
||||||
#include <geometry/seg.h>
|
#include <geometry/seg.h>
|
||||||
|
|
||||||
class PCB_BASE_FRAME;
|
class PCB_BASE_FRAME;
|
||||||
|
@ -43,9 +40,6 @@ public:
|
||||||
GRID_HELPER( PCB_BASE_FRAME* aFrame );
|
GRID_HELPER( PCB_BASE_FRAME* aFrame );
|
||||||
~GRID_HELPER();
|
~GRID_HELPER();
|
||||||
|
|
||||||
void SetGrid( int aSize );
|
|
||||||
void SetOrigin( const VECTOR2I& aOrigin );
|
|
||||||
|
|
||||||
VECTOR2I GetGrid() const;
|
VECTOR2I GetGrid() const;
|
||||||
VECTOR2I GetOrigin() const;
|
VECTOR2I GetOrigin() const;
|
||||||
|
|
||||||
|
@ -58,7 +52,7 @@ public:
|
||||||
*/
|
*/
|
||||||
BOARD_ITEM* GetSnapped() const;
|
BOARD_ITEM* GetSnapped() const;
|
||||||
|
|
||||||
void SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin = VECTOR2I( 0, 0 ), bool aEnableDiagonal = false );
|
void SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin = VECTOR2I( 0, 0 ) );
|
||||||
|
|
||||||
VECTOR2I Align( const VECTOR2I& aPoint ) const;
|
VECTOR2I Align( const VECTOR2I& aPoint ) const;
|
||||||
|
|
||||||
|
@ -67,7 +61,7 @@ public:
|
||||||
VECTOR2I BestDragOrigin( const VECTOR2I& aMousePos, BOARD_ITEM* aItem );
|
VECTOR2I BestDragOrigin( const VECTOR2I& aMousePos, BOARD_ITEM* aItem );
|
||||||
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, BOARD_ITEM* aDraggedItem );
|
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, BOARD_ITEM* aDraggedItem );
|
||||||
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLayers,
|
VECTOR2I BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLayers,
|
||||||
const std::vector<BOARD_ITEM*> aSkip = {} );
|
const std::vector<BOARD_ITEM*> aSkip = {} );
|
||||||
|
|
||||||
void SetSnap( bool aSnap )
|
void SetSnap( bool aSnap )
|
||||||
{
|
{
|
||||||
|
@ -89,8 +83,11 @@ private:
|
||||||
|
|
||||||
struct ANCHOR
|
struct ANCHOR
|
||||||
{
|
{
|
||||||
ANCHOR( VECTOR2I aPos, int aFlags = CORNER | SNAPPABLE, BOARD_ITEM* aItem = NULL ):
|
ANCHOR( VECTOR2I aPos, int aFlags = CORNER | SNAPPABLE, BOARD_ITEM* aItem = NULL ) :
|
||||||
pos( aPos ), flags( aFlags ), item( aItem ) {} ;
|
pos( aPos ),
|
||||||
|
flags( aFlags ),
|
||||||
|
item( aItem )
|
||||||
|
{ };
|
||||||
|
|
||||||
VECTOR2I pos;
|
VECTOR2I pos;
|
||||||
int flags;
|
int flags;
|
||||||
|
@ -105,11 +102,11 @@ private:
|
||||||
std::vector<ANCHOR> m_anchors;
|
std::vector<ANCHOR> m_anchors;
|
||||||
|
|
||||||
std::set<BOARD_ITEM*> queryVisible( const BOX2I& aArea,
|
std::set<BOARD_ITEM*> queryVisible( const BOX2I& aArea,
|
||||||
const std::vector<BOARD_ITEM*> aSkip ) const;
|
const std::vector<BOARD_ITEM*> aSkip ) const;
|
||||||
|
|
||||||
void addAnchor( const VECTOR2I& aPos, int aFlags = CORNER | SNAPPABLE, BOARD_ITEM* aItem = NULL )
|
void addAnchor( const VECTOR2I& aPos, int aFlags, BOARD_ITEM* aItem )
|
||||||
{
|
{
|
||||||
m_anchors.push_back( ANCHOR( aPos, aFlags, aItem ) );
|
m_anchors.emplace_back( ANCHOR( aPos, aFlags, aItem ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
ANCHOR* nearestAnchor( const VECTOR2I& aPos, int aFlags, LSET aMatchLayers );
|
ANCHOR* nearestAnchor( const VECTOR2I& aPos, int aFlags, LSET aMatchLayers );
|
||||||
|
@ -122,7 +119,7 @@ private:
|
||||||
* @param aRefPos The point for which to compute the anchors (if used by the component)
|
* @param aRefPos The point for which to compute the anchors (if used by the component)
|
||||||
* @param aFrom Is this for an anchor that is designating a source point (aFrom=true) or not
|
* @param aFrom Is this for an anchor that is designating a source point (aFrom=true) or not
|
||||||
*/
|
*/
|
||||||
void computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, const bool aFrom = false );
|
void computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, bool aFrom = false );
|
||||||
|
|
||||||
void clearAnchors()
|
void clearAnchors()
|
||||||
{
|
{
|
||||||
|
@ -132,7 +129,6 @@ private:
|
||||||
PCB_BASE_FRAME* m_frame;
|
PCB_BASE_FRAME* m_frame;
|
||||||
OPT<VECTOR2I> m_auxAxis;
|
OPT<VECTOR2I> m_auxAxis;
|
||||||
|
|
||||||
bool m_diagonalAuxAxesEnable; ///< If true, use the aux axis for snapping as well
|
|
||||||
bool m_enableSnap; ///< If true, allow snapping to other items on the layers
|
bool m_enableSnap; ///< If true, allow snapping to other items on the layers
|
||||||
bool m_enableGrid; ///< If true, allow snapping to grid
|
bool m_enableGrid; ///< If true, allow snapping to grid
|
||||||
int m_snapSize; ///< Sets the radius in screen units for snapping to items
|
int m_snapSize; ///< Sets the radius in screen units for snapping to items
|
||||||
|
|
|
@ -907,12 +907,6 @@ TOOL_ACTION PCB_ACTIONS::deleteTool( "pcbnew.Control.deleteTool",
|
||||||
delete_xpm );
|
delete_xpm );
|
||||||
|
|
||||||
|
|
||||||
// PCBNEW_PICKER_TOOL
|
|
||||||
//
|
|
||||||
TOOL_ACTION PCB_ACTIONS::pickerTool( "pcbnew.InteractivePicker",
|
|
||||||
AS_GLOBAL, 0, "", "", "", nullptr, AF_ACTIVATE );
|
|
||||||
|
|
||||||
|
|
||||||
// PLACEMENT_TOOL
|
// PLACEMENT_TOOL
|
||||||
//
|
//
|
||||||
TOOL_ACTION PCB_ACTIONS::alignTop( "pcbnew.AlignAndDistribute.alignTop",
|
TOOL_ACTION PCB_ACTIONS::alignTop( "pcbnew.AlignAndDistribute.alignTop",
|
||||||
|
|
|
@ -23,40 +23,33 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <thread>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "pcb_editor_control.h"
|
#include "pcb_editor_control.h"
|
||||||
#include "pcb_actions.h"
|
#include "pcb_actions.h"
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tools/tool_event_utils.h>
|
#include <tools/tool_event_utils.h>
|
||||||
#include <wx/progdlg.h>
|
|
||||||
#include <ws_proxy_undo_item.h>
|
#include <ws_proxy_undo_item.h>
|
||||||
#include "edit_tool.h"
|
#include "edit_tool.h"
|
||||||
#include "selection_tool.h"
|
#include "selection_tool.h"
|
||||||
#include "drawing_tool.h"
|
#include "drawing_tool.h"
|
||||||
#include "pcbnew_picker_tool.h"
|
#include "pcbnew_picker_tool.h"
|
||||||
|
|
||||||
#include <painter.h>
|
#include <painter.h>
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
#include <pcb_edit_frame.h>
|
#include <pcb_edit_frame.h>
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <class_zone.h>
|
#include <class_zone.h>
|
||||||
#include <pcb_draw_panel_gal.h>
|
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
#include <class_pcb_target.h>
|
#include <class_pcb_target.h>
|
||||||
#include <connectivity/connectivity_data.h>
|
#include <connectivity/connectivity_data.h>
|
||||||
#include <collectors.h>
|
#include <collectors.h>
|
||||||
#include <zones_functions_for_undo_redo.h>
|
|
||||||
#include <board_commit.h>
|
#include <board_commit.h>
|
||||||
#include <confirm.h>
|
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <view/view_group.h>
|
#include <view/view_group.h>
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
#include <origin_viewitem.h>
|
#include <origin_viewitem.h>
|
||||||
#include <profile.h>
|
#include <profile.h>
|
||||||
#include <widgets/progress_reporter.h>
|
#include <widgets/progress_reporter.h>
|
||||||
#include <dialogs/dialog_find.h>
|
|
||||||
#include <dialogs/dialog_page_settings.h>
|
#include <dialogs/dialog_page_settings.h>
|
||||||
#include <pcb_netlist.h>
|
#include <pcb_netlist.h>
|
||||||
#include <dialogs/dialog_update_pcb.h>
|
#include <dialogs/dialog_update_pcb.h>
|
||||||
|
@ -1120,24 +1113,19 @@ void PCB_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* a
|
||||||
|
|
||||||
int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
|
int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
|
||||||
|
|
||||||
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
||||||
assert( picker );
|
|
||||||
|
|
||||||
picker->SetClickHandler( [this] ( const VECTOR2D& pt ) -> bool
|
picker->SetClickHandler(
|
||||||
|
[this] ( const VECTOR2D& pt ) -> bool
|
||||||
{
|
{
|
||||||
m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UR_DRILLORIGIN );
|
m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UR_DRILLORIGIN );
|
||||||
DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), pt );
|
DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), pt );
|
||||||
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
|
||||||
} );
|
} );
|
||||||
|
|
||||||
picker->Activate();
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
Wait();
|
|
||||||
|
|
||||||
m_frame->PopTool( tool );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1299,6 +1287,9 @@ int PCB_EDITOR_CONTROL::ClearHighlight( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PCB_EDITOR_CONTROL::HighlightNetTool( const TOOL_EVENT& aEvent )
|
int PCB_EDITOR_CONTROL::HighlightNetTool( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
|
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
||||||
|
|
||||||
// If the keyboard hotkey was triggered and we are already in the highlight tool, behave
|
// If the keyboard hotkey was triggered and we are already in the highlight tool, behave
|
||||||
// the same as a left-click. Otherwise highlight the net of the selected item(s), or if
|
// the same as a left-click. Otherwise highlight the net of the selected item(s), or if
|
||||||
// there is no selection, then behave like a ctrl-left-click.
|
// there is no selection, then behave like a ctrl-left-click.
|
||||||
|
@ -1308,90 +1299,78 @@ int PCB_EDITOR_CONTROL::HighlightNetTool( const TOOL_EVENT& aEvent )
|
||||||
highlightNet( getViewControls()->GetMousePosition(), use_selection );
|
highlightNet( getViewControls()->GetMousePosition(), use_selection );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
picker->SetClickHandler(
|
||||||
m_frame->PushTool( tool );
|
[this] ( const VECTOR2D& pt ) -> bool
|
||||||
Activate();
|
|
||||||
|
|
||||||
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
|
||||||
|
|
||||||
picker->SetClickHandler( [this] ( const VECTOR2D& pt ) -> bool
|
|
||||||
{
|
{
|
||||||
highlightNet( pt, false );
|
highlightNet( pt, false );
|
||||||
return true;
|
return true;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
picker->SetLayerSet( LSET::AllCuMask() );
|
picker->SetLayerSet( LSET::AllCuMask() );
|
||||||
picker->Activate();
|
|
||||||
Wait();
|
|
||||||
|
|
||||||
m_frame->PopTool( tool );
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, BOARD* aBoard, bool aShow, const VECTOR2D& aPosition )
|
|
||||||
{
|
|
||||||
auto selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
|
|
||||||
|
|
||||||
aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
||||||
aToolMgr->RunAction( PCB_ACTIONS::selectionCursor, true, EDIT_TOOL::PadFilter );
|
|
||||||
PCBNEW_SELECTION& selection = selectionTool->GetSelection();
|
|
||||||
|
|
||||||
if( selection.Empty() )
|
|
||||||
{
|
|
||||||
aToolMgr->RunAction( PCB_ACTIONS::selectionCursor, true, EDIT_TOOL::FootprintFilter );
|
|
||||||
selection = selectionTool->GetSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( selection.Empty() )
|
|
||||||
{
|
|
||||||
// Clear the previous local ratsnest if we click off all items
|
|
||||||
for( auto mod : aBoard->Modules() )
|
|
||||||
{
|
|
||||||
for( auto pad : mod->Pads() )
|
|
||||||
pad->SetLocalRatsnestVisible( aShow );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for( auto item : selection )
|
|
||||||
{
|
|
||||||
if( auto pad = dyn_cast<D_PAD*>(item) )
|
|
||||||
{
|
|
||||||
pad->SetLocalRatsnestVisible( !pad->GetLocalRatsnestVisible() );
|
|
||||||
}
|
|
||||||
else if( auto mod = dyn_cast<MODULE*>(item) )
|
|
||||||
{
|
|
||||||
bool enable = !( *( mod->Pads().begin() ) )->GetLocalRatsnestVisible();
|
|
||||||
|
|
||||||
for( auto modpad : mod->Pads() )
|
|
||||||
modpad->SetLocalRatsnestVisible( enable );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
aToolMgr->GetView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PCB_EDITOR_CONTROL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
|
int PCB_EDITOR_CONTROL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
m_frame->PushTool( tool );
|
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
||||||
Activate();
|
BOARD* board = getModel<BOARD>();
|
||||||
|
PCB_DISPLAY_OPTIONS* opt = displayOptions();
|
||||||
|
|
||||||
auto picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
picker->SetClickHandler(
|
||||||
auto board = getModel<BOARD>();
|
[&] ( const VECTOR2D& pt ) -> bool
|
||||||
auto opt = displayOptions();
|
{
|
||||||
wxASSERT( picker );
|
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||||
wxASSERT( board );
|
|
||||||
|
|
||||||
picker->SetClickHandler( std::bind( showLocalRatsnest, m_toolMgr, board,
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
opt->m_ShowGlobalRatsnest, _1 ) );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true, EDIT_TOOL::PadFilter );
|
||||||
|
PCBNEW_SELECTION& selection = selectionTool->GetSelection();
|
||||||
|
|
||||||
picker->SetFinalizeHandler( [ board, opt ]( int aCondition )
|
if( selection.Empty() )
|
||||||
|
{
|
||||||
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true,
|
||||||
|
EDIT_TOOL::FootprintFilter );
|
||||||
|
selection = selectionTool->GetSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( selection.Empty() )
|
||||||
|
{
|
||||||
|
// Clear the previous local ratsnest if we click off all items
|
||||||
|
for( auto mod : board->Modules() )
|
||||||
|
{
|
||||||
|
for( auto pad : mod->Pads() )
|
||||||
|
pad->SetLocalRatsnestVisible( opt->m_ShowGlobalRatsnest );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for( auto item : selection )
|
||||||
|
{
|
||||||
|
if( auto pad = dyn_cast<D_PAD*>(item) )
|
||||||
|
{
|
||||||
|
pad->SetLocalRatsnestVisible( !pad->GetLocalRatsnestVisible() );
|
||||||
|
}
|
||||||
|
else if( auto mod = dyn_cast<MODULE*>(item) )
|
||||||
|
{
|
||||||
|
bool enable = !( *( mod->Pads().begin() ) )->GetLocalRatsnestVisible();
|
||||||
|
|
||||||
|
for( auto modpad : mod->Pads() )
|
||||||
|
modpad->SetLocalRatsnestVisible( enable );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_toolMgr->GetView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} );
|
||||||
|
|
||||||
|
picker->SetFinalizeHandler(
|
||||||
|
[ board, opt ]( int aCondition )
|
||||||
{
|
{
|
||||||
if( aCondition != PCBNEW_PICKER_TOOL::END_ACTIVATE )
|
if( aCondition != PCBNEW_PICKER_TOOL::END_ACTIVATE )
|
||||||
{
|
{
|
||||||
|
@ -1403,10 +1382,8 @@ int PCB_EDITOR_CONTROL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
picker->Activate();
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
Wait();
|
|
||||||
|
|
||||||
m_frame->PopTool( tool );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -412,7 +412,6 @@ int PCBNEW_CONTROL::GridFast1( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_frame->SetFastGrid1();
|
m_frame->SetFastGrid1();
|
||||||
updateGrid();
|
updateGrid();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +420,6 @@ int PCBNEW_CONTROL::GridFast2( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_frame->SetFastGrid2();
|
m_frame->SetFastGrid2();
|
||||||
updateGrid();
|
updateGrid();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,29 +442,23 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
|
||||||
if( origin )
|
if( origin )
|
||||||
{
|
{
|
||||||
// We can't undo the other grid dialog settings, so no sense undoing just the origin
|
// We can't undo the other grid dialog settings, so no sense undoing just the origin
|
||||||
|
|
||||||
DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
|
DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
|
||||||
delete origin;
|
delete origin;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
|
||||||
|
|
||||||
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
||||||
|
|
||||||
picker->SetClickHandler( [this] ( const VECTOR2D& pt ) -> bool
|
picker->SetClickHandler(
|
||||||
|
[this] ( const VECTOR2D& pt ) -> bool
|
||||||
{
|
{
|
||||||
m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UR_GRIDORIGIN );
|
m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UR_GRIDORIGIN );
|
||||||
DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
|
DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
|
||||||
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
|
||||||
} );
|
} );
|
||||||
|
|
||||||
picker->Activate();
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
Wait();
|
|
||||||
|
|
||||||
m_frame->PopTool( tool );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -486,76 +478,76 @@ int PCBNEW_CONTROL::GridResetOrigin( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
|
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
||||||
|
|
||||||
|
m_pickerItem = nullptr;
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
|
||||||
m_frame->PushTool( tool );
|
|
||||||
Activate();
|
|
||||||
|
|
||||||
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
picker->SetClickHandler(
|
||||||
m_pickerItem = nullptr;
|
[this] ( const VECTOR2D& aPosition ) -> bool
|
||||||
|
|
||||||
picker->SetClickHandler( [this] ( const VECTOR2D& aPosition ) -> bool
|
|
||||||
{
|
|
||||||
if( m_pickerItem )
|
|
||||||
{
|
{
|
||||||
if( m_pickerItem && m_pickerItem->IsLocked() )
|
if( m_pickerItem )
|
||||||
{
|
{
|
||||||
STATUS_TEXT_POPUP statusPopup( m_frame );
|
if( m_pickerItem && m_pickerItem->IsLocked() )
|
||||||
statusPopup.SetText( _( "Item locked." ) );
|
{
|
||||||
statusPopup.PopupFor( 2000 );
|
STATUS_TEXT_POPUP statusPopup( m_frame );
|
||||||
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
|
statusPopup.SetText( _( "Item locked." ) );
|
||||||
return true;
|
statusPopup.PopupFor( 2000 );
|
||||||
|
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||||
|
selectionTool->UnbrightenItem( m_pickerItem );
|
||||||
|
selectionTool->AddItemToSel( m_pickerItem, true );
|
||||||
|
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
||||||
|
m_pickerItem = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
return true;
|
||||||
selectionTool->UnbrightenItem( m_pickerItem );
|
} );
|
||||||
selectionTool->AddItemToSel( m_pickerItem, true );
|
|
||||||
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
|
||||||
m_pickerItem = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
picker->SetMotionHandler(
|
||||||
} );
|
[this] ( const VECTOR2D& aPos )
|
||||||
|
|
||||||
picker->SetMotionHandler( [this] ( const VECTOR2D& aPos )
|
|
||||||
{
|
|
||||||
BOARD* board = m_frame->GetBoard();
|
|
||||||
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
|
|
||||||
GENERAL_COLLECTOR collector;
|
|
||||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
|
||||||
|
|
||||||
if( m_editModules )
|
|
||||||
collector.Collect( board, GENERAL_COLLECTOR::ModuleItems, (wxPoint) aPos, guide );
|
|
||||||
else
|
|
||||||
collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, (wxPoint) aPos, guide );
|
|
||||||
|
|
||||||
BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
|
||||||
|
|
||||||
if( m_pickerItem != item )
|
|
||||||
{
|
{
|
||||||
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
BOARD* board = m_frame->GetBoard();
|
||||||
|
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
|
||||||
|
GENERAL_COLLECTOR collector;
|
||||||
|
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||||
|
|
||||||
|
if( m_editModules )
|
||||||
|
collector.Collect( board, GENERAL_COLLECTOR::ModuleItems, (wxPoint) aPos, guide );
|
||||||
|
else
|
||||||
|
collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, (wxPoint) aPos, guide );
|
||||||
|
|
||||||
|
BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||||
|
|
||||||
|
if( m_pickerItem != item )
|
||||||
|
{
|
||||||
|
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||||
|
|
||||||
|
if( m_pickerItem )
|
||||||
|
selectionTool->UnbrightenItem( m_pickerItem );
|
||||||
|
|
||||||
|
m_pickerItem = item;
|
||||||
|
|
||||||
|
if( m_pickerItem )
|
||||||
|
selectionTool->BrightenItem( m_pickerItem );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
picker->SetFinalizeHandler(
|
||||||
|
[&]( const int& aFinalState )
|
||||||
|
{
|
||||||
if( m_pickerItem )
|
if( m_pickerItem )
|
||||||
selectionTool->UnbrightenItem( m_pickerItem );
|
m_toolMgr->GetTool<SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||||
|
} );
|
||||||
|
|
||||||
m_pickerItem = item;
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
|
|
||||||
if( m_pickerItem )
|
|
||||||
selectionTool->BrightenItem( m_pickerItem );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
picker->SetFinalizeHandler( [&]( const int& aFinalState )
|
|
||||||
{
|
|
||||||
if( m_pickerItem )
|
|
||||||
m_toolMgr->GetTool<SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
|
||||||
} );
|
|
||||||
|
|
||||||
picker->Activate();
|
|
||||||
Wait();
|
|
||||||
|
|
||||||
m_frame->PopTool( tool );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,7 +659,8 @@ template<typename T>
|
||||||
static void moveNoFlagToVector( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
|
static void moveNoFlagToVector( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
|
||||||
{
|
{
|
||||||
std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
|
std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
|
||||||
[](T aItem){
|
[](T aItem)
|
||||||
|
{
|
||||||
bool retval = ( aItem->GetFlags() & FLAG0 ) == 0;
|
bool retval = ( aItem->GetFlags() & FLAG0 ) == 0;
|
||||||
aItem->ClearFlags( FLAG0 );
|
aItem->ClearFlags( FLAG0 );
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -857,6 +850,7 @@ int PCBNEW_CONTROL::Redo( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( editFrame )
|
if( editFrame )
|
||||||
editFrame->RestoreCopyFromRedoList( dummy );
|
editFrame->RestoreCopyFromRedoList( dummy );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,7 +881,6 @@ int PCBNEW_CONTROL::Show3DViewer( const TOOL_EVENT& aEvent )
|
||||||
void PCBNEW_CONTROL::updateGrid()
|
void PCBNEW_CONTROL::updateGrid()
|
||||||
{
|
{
|
||||||
BASE_SCREEN* screen = m_frame->GetScreen();
|
BASE_SCREEN* screen = m_frame->GetScreen();
|
||||||
//GRID_TYPE grid = screen->GetGrid( idx );
|
|
||||||
getView()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
|
getView()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
|
||||||
getView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
getView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "grid_helper.h"
|
#include "grid_helper.h"
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include "tool_event_utils.h"
|
|
||||||
#include "selection_tool.h"
|
#include "selection_tool.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,11 +44,13 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
GRID_HELPER grid( frame() );
|
GRID_HELPER grid( frame() );
|
||||||
int finalize_state = WAIT_CANCEL;
|
int finalize_state = WAIT_CANCEL;
|
||||||
|
|
||||||
|
Activate();
|
||||||
setControls();
|
setControls();
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
|
frame()->GetCanvas()->SetCursor( m_cursor );
|
||||||
|
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
@ -153,13 +154,14 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
void PCBNEW_PICKER_TOOL::setTransitions()
|
void PCBNEW_PICKER_TOOL::setTransitions()
|
||||||
{
|
{
|
||||||
Go( &PCBNEW_PICKER_TOOL::Main, PCB_ACTIONS::pickerTool.MakeEvent() );
|
Go( &PCBNEW_PICKER_TOOL::Main, ACTIONS::pickerTool.MakeEvent() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCBNEW_PICKER_TOOL::reset()
|
void PCBNEW_PICKER_TOOL::reset()
|
||||||
{
|
{
|
||||||
m_layerMask = LSET::AllLayersMask();
|
m_layerMask = LSET::AllLayersMask();
|
||||||
|
m_cursor = wxStockCursor( wxCURSOR_ARROW );
|
||||||
|
|
||||||
m_picked = NULLOPT;
|
m_picked = NULLOPT;
|
||||||
m_clickHandler = NULLOPT;
|
m_clickHandler = NULLOPT;
|
||||||
|
|
|
@ -35,7 +35,7 @@ class PCBNEW_PICKER_TOOL : public PCB_TOOL_BASE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PCBNEW_PICKER_TOOL();
|
PCBNEW_PICKER_TOOL();
|
||||||
~PCBNEW_PICKER_TOOL() {}
|
~PCBNEW_PICKER_TOOL() override { }
|
||||||
|
|
||||||
///> Event handler types.
|
///> Event handler types.
|
||||||
typedef std::function<bool(const VECTOR2D&)> CLICK_HANDLER;
|
typedef std::function<bool(const VECTOR2D&)> CLICK_HANDLER;
|
||||||
|
@ -64,6 +64,8 @@ public:
|
||||||
*/
|
*/
|
||||||
inline void SetLayerSet( LSET aLayerSet ) { m_layerMask = aLayerSet; }
|
inline void SetLayerSet( LSET aLayerSet ) { m_layerMask = aLayerSet; }
|
||||||
|
|
||||||
|
inline void SetCursor( const wxCursor& aCursor ) { m_cursor = aCursor; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SetClickHandler()
|
* Function SetClickHandler()
|
||||||
* Sets a handler for mouse click event. Handler may decide to receive further click by
|
* Sets a handler for mouse click event. Handler may decide to receive further click by
|
||||||
|
@ -105,25 +107,27 @@ public:
|
||||||
m_finalizeHandler = aHandler;
|
m_finalizeHandler = aHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
///> @copydoc TOOL_INTERACTIVE::setTransitions();
|
///> @copydoc TOOL_INTERACTIVE::setTransitions();
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
private:
|
|
||||||
///> The layer set to use for optional snapping
|
|
||||||
LSET m_layerMask;
|
|
||||||
|
|
||||||
OPT<CLICK_HANDLER> m_clickHandler;
|
|
||||||
OPT<MOTION_HANDLER> m_motionHandler;
|
|
||||||
OPT<CANCEL_HANDLER> m_cancelHandler;
|
|
||||||
OPT<FINALIZE_HANDLER> m_finalizeHandler;
|
|
||||||
|
|
||||||
OPT<VECTOR2D> m_picked;
|
|
||||||
|
|
||||||
///> Reinitializes tool to its initial state.
|
///> Reinitializes tool to its initial state.
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
///> Applies the requested VIEW_CONTROLS settings.
|
///> Applies the requested VIEW_CONTROLS settings.
|
||||||
void setControls();
|
void setControls();
|
||||||
|
|
||||||
|
private:
|
||||||
|
///> The layer set to use for optional snapping
|
||||||
|
LSET m_layerMask;
|
||||||
|
wxCursor m_cursor;
|
||||||
|
|
||||||
|
OPT<CLICK_HANDLER> m_clickHandler;
|
||||||
|
OPT<MOTION_HANDLER> m_motionHandler;
|
||||||
|
OPT<CANCEL_HANDLER> m_cancelHandler;
|
||||||
|
OPT<FINALIZE_HANDLER> m_finalizeHandler;
|
||||||
|
|
||||||
|
OPT<VECTOR2D> m_picked;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PICKER_TOOL_H */
|
#endif /* PICKER_TOOL_H */
|
||||||
|
|
|
@ -24,13 +24,11 @@
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
#include <gal/graphics_abstraction_layer.h>
|
#include <gal/graphics_abstraction_layer.h>
|
||||||
#include <geometry/seg.h>
|
#include <geometry/seg.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
|
|
||||||
#include "pcb_actions.h"
|
#include "pcb_actions.h"
|
||||||
#include "selection_tool.h"
|
#include "selection_tool.h"
|
||||||
#include "point_editor.h"
|
#include "point_editor.h"
|
||||||
|
@ -38,18 +36,13 @@ using namespace std::placeholders;
|
||||||
#include <board_commit.h>
|
#include <board_commit.h>
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <status_popup.h>
|
#include <status_popup.h>
|
||||||
|
|
||||||
#include <pcb_edit_frame.h>
|
#include <pcb_edit_frame.h>
|
||||||
#include <class_edge_mod.h>
|
#include <class_edge_mod.h>
|
||||||
#include <class_dimension.h>
|
#include <class_dimension.h>
|
||||||
#include <class_zone.h>
|
#include <class_zone.h>
|
||||||
#include <class_board.h>
|
|
||||||
#include <class_module.h>
|
|
||||||
#include <connectivity/connectivity_data.h>
|
#include <connectivity/connectivity_data.h>
|
||||||
#include <widgets/progress_reporter.h>
|
#include <widgets/progress_reporter.h>
|
||||||
|
|
||||||
#include "zone_filler.h"
|
|
||||||
|
|
||||||
// Few constants to avoid using bare numbers for point indices
|
// Few constants to avoid using bare numbers for point indices
|
||||||
enum SEG_POINTS
|
enum SEG_POINTS
|
||||||
{
|
{
|
||||||
|
@ -354,7 +347,7 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
||||||
m_original = *m_editedPoint; // Save the original position
|
m_original = *m_editedPoint; // Save the original position
|
||||||
controls->SetAutoPan( true );
|
controls->SetAutoPan( true );
|
||||||
inDrag = true;
|
inDrag = true;
|
||||||
grid.SetAuxAxes( true, m_original.GetPosition(), true );
|
grid.SetAuxAxes( true, m_original.GetPosition() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: unify the constraints to solve simultaneously instead of sequentially
|
//TODO: unify the constraints to solve simultaneously instead of sequentially
|
||||||
|
|
|
@ -122,56 +122,55 @@ int POSITION_RELATIVE_TOOL::RelativeItemSelectionMove( wxPoint aPosAnchor, wxPoi
|
||||||
|
|
||||||
int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent )
|
int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
Activate();
|
std::string tool = "pcbnew.PositionRelative.selectReferenceItem";
|
||||||
|
|
||||||
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
||||||
STATUS_TEXT_POPUP statusPopup( frame() );
|
STATUS_TEXT_POPUP statusPopup( frame() );
|
||||||
bool picking = true;
|
|
||||||
|
|
||||||
frame()->PushTool( "pcbnew.PositionRelative.selectReferenceItem" );
|
|
||||||
statusPopup.SetText( _( "Select reference item..." ) );
|
statusPopup.SetText( _( "Select reference item..." ) );
|
||||||
picker->Activate();
|
|
||||||
|
|
||||||
picker->SetClickHandler( [&]( const VECTOR2D& aPoint ) -> bool
|
picker->SetClickHandler(
|
||||||
{
|
[&]( const VECTOR2D& aPoint ) -> bool
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
{
|
||||||
const PCBNEW_SELECTION& sel = m_selectionTool->RequestSelection(
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
|
const PCBNEW_SELECTION& sel = m_selectionTool->RequestSelection(
|
||||||
{ EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } );
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
|
||||||
|
{
|
||||||
|
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS );
|
||||||
|
} );
|
||||||
|
|
||||||
if( sel.Empty() )
|
if( sel.Empty() )
|
||||||
return true; // still looking for an item
|
return true; // still looking for an item
|
||||||
|
|
||||||
m_anchor_item = sel.Front();
|
m_anchor_item = sel.Front();
|
||||||
statusPopup.Hide();
|
statusPopup.Hide();
|
||||||
|
|
||||||
if( m_dialog )
|
if( m_dialog )
|
||||||
m_dialog->UpdateAnchor( sel.Front() );
|
m_dialog->UpdateAnchor( sel.Front() );
|
||||||
|
|
||||||
picking = false;
|
return false; // got our item; don't need any more
|
||||||
return false; // got our item; don't need any more
|
} );
|
||||||
} );
|
|
||||||
|
|
||||||
picker->SetCancelHandler( [&]()
|
picker->SetMotionHandler(
|
||||||
{
|
[&] ( const VECTOR2D& aPos )
|
||||||
statusPopup.Hide();
|
{
|
||||||
|
statusPopup.Move( aPos + wxPoint( 20, -50 ) );
|
||||||
|
} );
|
||||||
|
|
||||||
if( m_dialog )
|
picker->SetCancelHandler(
|
||||||
m_dialog->UpdateAnchor( m_anchor_item );
|
[&]()
|
||||||
|
{
|
||||||
|
statusPopup.Hide();
|
||||||
|
|
||||||
picking = false;
|
if( m_dialog )
|
||||||
} );
|
m_dialog->UpdateAnchor( m_anchor_item );
|
||||||
|
} );
|
||||||
|
|
||||||
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
|
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
|
||||||
statusPopup.Popup();
|
statusPopup.Popup();
|
||||||
|
|
||||||
while( picking )
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
{
|
|
||||||
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
|
|
||||||
Wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
frame()->PopTool( "pcbnew.PositionRelative.selectReferenceItem" );
|
statusPopup.Hide();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue