Rename cvpcb footprint viewer tools

This is in preparation for the actionization of the main cvpcb window.
This commit is contained in:
Ian McInerney 2019-07-18 22:32:12 +02:00 committed by Wayne Stambaugh
parent 4c2ea8879f
commit c0b80c67b9
6 changed files with 63 additions and 55 deletions

View File

@ -47,8 +47,8 @@ set( CVPCB_SRCS
readwrite_dlgs.cpp readwrite_dlgs.cpp
toolbars_cvpcb.cpp toolbars_cvpcb.cpp
tools/cvpcb_actions.cpp tools/cvpcb_actions.cpp
tools/cvpcb_control.cpp tools/cvpcb_fpviewer_control.cpp
tools/cvpcb_selection_tool.cpp tools/cvpcb_fpviewer_selection_tool.cpp
) )

View File

@ -48,8 +48,8 @@
#include <tool/common_tools.h> #include <tool/common_tools.h>
#include <tool/zoom_tool.h> #include <tool/zoom_tool.h>
#include <tools/cvpcb_actions.h> #include <tools/cvpcb_actions.h>
#include <tools/cvpcb_selection_tool.h> #include <tools/cvpcb_fpviewer_control.h>
#include <tools/cvpcb_control.h> #include <tools/cvpcb_fpviewer_selection_tool.h>
// Colors for layers and items // Colors for layers and items
COLORS_DESIGN_SETTINGS g_ColorsSettings( FRAME_CVPCB_DISPLAY ); COLORS_DESIGN_SETTINGS g_ColorsSettings( FRAME_CVPCB_DISPLAY );
@ -119,8 +119,8 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
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 CVPCB_SELECTION_TOOL ); m_toolManager->RegisterTool( new CVPCB_FOOTPRINT_VIEWER_CONTROL );
m_toolManager->RegisterTool( new CVPCB_CONTROL ); m_toolManager->RegisterTool( new CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL );
m_toolManager->InitTools(); m_toolManager->InitTools();
// Run the control tool, it is supposed to be always active // Run the control tool, it is supposed to be always active

View File

@ -25,33 +25,33 @@
#include <cstdint> #include <cstdint>
#include <functional> #include <functional>
#include <tool/actions.h>
#include <tools/cvpcb_control.h>
using namespace std::placeholders; using namespace std::placeholders;
#include <tool/actions.h>
#include <tools/cvpcb_fpviewer_control.h>
CVPCB_CONTROL::CVPCB_CONTROL() :
TOOL_INTERACTIVE( "cvpcb.Control" ), CVPCB_FOOTPRINT_VIEWER_CONTROL::CVPCB_FOOTPRINT_VIEWER_CONTROL() :
m_frame( nullptr ) TOOL_INTERACTIVE( "cvpcb.FootprintViewerControl" ),
m_frame( nullptr )
{ {
} }
void CVPCB_CONTROL::Reset( RESET_REASON aReason ) void CVPCB_FOOTPRINT_VIEWER_CONTROL::Reset( RESET_REASON aReason )
{ {
m_frame = getEditFrame<DISPLAY_FOOTPRINTS_FRAME>(); m_frame = getEditFrame<DISPLAY_FOOTPRINTS_FRAME>();
} }
int CVPCB_CONTROL::Show3DViewer( const TOOL_EVENT& aEvent ) int CVPCB_FOOTPRINT_VIEWER_CONTROL::Show3DViewer( const TOOL_EVENT& aEvent )
{ {
m_frame->CreateAndShow3D_Frame(); m_frame->CreateAndShow3D_Frame();
return 0; return 0;
} }
void CVPCB_CONTROL::setTransitions() void CVPCB_FOOTPRINT_VIEWER_CONTROL::setTransitions()
{ {
// Miscellaneous Go( &CVPCB_FOOTPRINT_VIEWER_CONTROL::Show3DViewer, ACTIONS::show3DViewer.MakeEvent() );
Go( &CVPCB_CONTROL::Show3DViewer, ACTIONS::show3DViewer.MakeEvent() );
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2014-2016 CERN * Copyright (C) 2014-2016 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch> * @author Maciej Suminski <maciej.suminski@cern.ch>
* Copyright (C) 2007-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2007-2019 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -23,28 +23,29 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#ifndef CVPCB_CONTROL_H #ifndef CVPCB_FOOTPRINT_VIEWER_CONTROL_H_
#define CVPCB_CONTROL_H #define CVPCB_FOOTPRINT_VIEWER_CONTROL_H_
#include <tool/tool_interactive.h>
#include <display_footprints_frame.h> #include <display_footprints_frame.h>
#include <tool/tool_interactive.h>
/** /**
* Class CVPCB_CONTROL * Class CVPCB_FOOTPRINT_VIEWER_CONTROL
* *
* Handles actions in cvpcb display frame. * Handles control actions for the cvpcb footprint display frame.
*/ */
class CVPCB_CONTROL : public TOOL_INTERACTIVE class CVPCB_FOOTPRINT_VIEWER_CONTROL : public TOOL_INTERACTIVE
{ {
public: public:
CVPCB_CONTROL(); CVPCB_FOOTPRINT_VIEWER_CONTROL();
~CVPCB_CONTROL() { } ~CVPCB_FOOTPRINT_VIEWER_CONTROL() {}
/// @copydoc TOOL_INTERACTIVE::Reset() /// @copydoc TOOL_INTERACTIVE::Reset()
void Reset( RESET_REASON aReason ) override; void Reset( RESET_REASON aReason ) override;
///> Show the 3D viewer with the currently selected footprint
int Show3DViewer( const TOOL_EVENT& aEvent ); int Show3DViewer( const TOOL_EVENT& aEvent );
///> Sets up handlers for various events. ///> Sets up handlers for various events.

View File

@ -17,41 +17,41 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <limits>
#include <functional> #include <functional>
#include <limits>
using namespace std::placeholders; using namespace std::placeholders;
#include <class_draw_panel_gal.h>
#include <view/view.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <class_draw_panel_gal.h>
#include <cvpcb_id.h>
#include <preview_items/ruler_item.h>
#include <tool/tool_event.h> #include <tool/tool_event.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/cvpcb_actions.h> #include <tools/cvpcb_actions.h>
#include <tools/cvpcb_selection_tool.h> #include <tools/cvpcb_fpviewer_selection_tool.h>
#include <preview_items/ruler_item.h> #include <view/view.h>
#include <cvpcb_id.h>
CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL() :
CVPCB_SELECTION_TOOL::CVPCB_SELECTION_TOOL() : TOOL_INTERACTIVE( "cvpcb.FootprintViewerInteractiveSelection" ),
TOOL_INTERACTIVE( "cvpcb.InteractiveSelection" ),
m_frame( nullptr ) m_frame( nullptr )
{ {
} }
bool CVPCB_SELECTION_TOOL::Init() bool CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init()
{ {
getEditFrame<DISPLAY_FOOTPRINTS_FRAME>()->AddStandardSubMenus( m_menu ); getEditFrame<DISPLAY_FOOTPRINTS_FRAME>()->AddStandardSubMenus( m_menu );
return true; return true;
} }
void CVPCB_SELECTION_TOOL::Reset( RESET_REASON aReason ) void CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Reset( RESET_REASON aReason )
{ {
m_frame = getEditFrame<DISPLAY_FOOTPRINTS_FRAME>(); m_frame = getEditFrame<DISPLAY_FOOTPRINTS_FRAME>();
} }
int CVPCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) int CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{ {
// Main loop: keep receiving events // Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() ) while( TOOL_EVENT* evt = Wait() )
@ -102,18 +102,18 @@ int CVPCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
} }
int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) int CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
{ {
auto& view = *getView(); auto& view = *getView();
auto& controls = *getViewControls(); auto& controls = *getViewControls();
auto previous_settings = controls.GetSettings(); auto previous_settings = controls.GetSettings();
std::string tool = aEvent.GetCommandStr().get(); std::string tool = aEvent.GetCommandStr().get();
m_frame->PushTool( tool ); m_frame->PushTool( tool );
Activate(); Activate();
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr; KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, m_frame->GetUserUnits() ); KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, m_frame->GetUserUnits() );
view.Add( &ruler ); view.Add( &ruler );
view.SetVisible( &ruler, false ); view.SetVisible( &ruler, false );
@ -129,7 +129,7 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
const VECTOR2I cursorPos = controls.GetCursorPosition(); const VECTOR2I cursorPos = controls.GetCursorPosition();
auto clearRuler = [&] () { auto clearRuler = [&]() {
view.SetVisible( &ruler, false ); view.SetVisible( &ruler, false );
controls.SetAutoPan( false ); controls.SetAutoPan( false );
controls.CaptureCursor( false ); controls.CaptureCursor( false );
@ -223,9 +223,9 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
return 0; return 0;
} }
void CVPCB_SELECTION_TOOL::setTransitions() void CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions()
{ {
Go( &CVPCB_SELECTION_TOOL::Main, CVPCB_ACTIONS::selectionActivate.MakeEvent() ); Go( &CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main,
Go( &CVPCB_SELECTION_TOOL::MeasureTool, ACTIONS::measureTool.MakeEvent() ); CVPCB_ACTIONS::selectionActivate.MakeEvent() );
Go( &CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool, ACTIONS::measureTool.MakeEvent() );
} }

View File

@ -17,25 +17,27 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CVPCB_SELECTION_TOOL_H #ifndef CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL_H_
#define CVPCB_SELECTION_TOOL_H #define CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL_H_
#include <display_footprints_frame.h>
#include <tool/tool_interactive.h>
#include <tool/action_menu.h> #include <tool/action_menu.h>
#include <tool/selection.h> #include <tool/selection.h>
#include <tool/tool_interactive.h>
#include <tool/tool_menu.h> #include <tool/tool_menu.h>
#include <display_footprints_frame.h>
/** /**
* Class CVPCB_SELECTION_TOOL * Class CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL
*
* Selection tool for the footprint viewer in cvpcb.
*/ */
class CVPCB_SELECTION_TOOL : public TOOL_INTERACTIVE class CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL : public TOOL_INTERACTIVE
{ {
public: public:
CVPCB_SELECTION_TOOL(); CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL();
~CVPCB_SELECTION_TOOL() { } ~CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL() {}
/// @copydoc TOOL_BASE::Init() /// @copydoc TOOL_BASE::Init()
bool Init() override; bool Init() override;
@ -53,8 +55,12 @@ public:
/** /**
* Selections aren't currently supported in the footprint viewer. * Selections aren't currently supported in the footprint viewer.
*/ */
SELECTION& GetSelection() { return m_selection; } SELECTION& GetSelection()
void clearSelection() {}; {
return m_selection;
}
void clearSelection() {}
///> Launches a tool to measure between points ///> Launches a tool to measure between points
int MeasureTool( const TOOL_EVENT& aEvent ); int MeasureTool( const TOOL_EVENT& aEvent );
@ -63,6 +69,7 @@ public:
void setTransitions() override; void setTransitions() override;
private: private:
/// Pointer to the parent frame.
DISPLAY_FOOTPRINTS_FRAME* m_frame; DISPLAY_FOOTPRINTS_FRAME* m_frame;
/// Current state of selection (not really used: no selection in display footprints frame). /// Current state of selection (not really used: no selection in display footprints frame).