Move eeschema zoom operations to modern toolset.

This commit is contained in:
Jeff Young 2019-04-12 20:18:45 +01:00
parent 734e61d4c2
commit fc7f5630c7
10 changed files with 288 additions and 349 deletions

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-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
@ -23,10 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file draw_frame.cpp
*/
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
@ -102,13 +98,9 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
EVT_MOUSEWHEEL( EDA_DRAW_FRAME::OnMouseEvent )
EVT_MENU_OPEN( EDA_DRAW_FRAME::OnMenuOpen )
EVT_ACTIVATE( EDA_DRAW_FRAME::OnActivate )
EVT_MENU_RANGE( ID_ZOOM_BEGIN, ID_ZOOM_END, EDA_DRAW_FRAME::OnZoom )
EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
EDA_DRAW_FRAME::OnZoom )
EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER,
EDA_DRAW_FRAME::OnSelectGrid )
EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE, EDA_DRAW_FRAME::OnZoom )
EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER, EDA_DRAW_FRAME::OnSelectGrid )
EVT_TOOL( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnToggleGridState )
EVT_TOOL_RANGE( ID_TB_OPTIONS_SELECT_UNIT_MM, ID_TB_OPTIONS_SELECT_UNIT_INCH,
@ -354,27 +346,6 @@ bool EDA_DRAW_FRAME::GetToolToggled( int aToolId )
}
wxAuiToolBarItem* EDA_DRAW_FRAME::GetToolbarTool( int aToolId )
{
// Checks all the toolbars and returns a reference to the given tool id
// (or the first tool found, but only one or 0 tool is expected, because on
// Windows, when different tools have the same ID, it creates issues)
if( m_mainToolBar && m_mainToolBar->FindTool( aToolId ) )
return m_mainToolBar->FindTool( aToolId );
if( m_optionsToolBar && m_optionsToolBar->FindTool( aToolId ) )
return m_optionsToolBar->FindTool( aToolId );
if( m_drawToolBar && m_drawToolBar->FindTool( aToolId ) )
return m_drawToolBar->FindTool( aToolId );
if( m_auxiliaryToolBar && m_auxiliaryToolBar->FindTool( aToolId ) )
return m_auxiliaryToolBar->FindTool( aToolId );
return nullptr;
}
void EDA_DRAW_FRAME::OnSelectUnits( wxCommandEvent& aEvent )
{
if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM && m_UserUnits != MILLIMETRES )
@ -557,37 +528,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
{
if( m_zoomSelectBox == NULL )
return; // Should not happen!
int id = m_zoomSelectBox->GetCurrentSelection();
if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
return;
if( id == 0 ) // Auto zoom (Fit in Page)
{
Zoom_Automatique( true );
}
else
{
double selectedZoom = GetScreen()->m_ZoomList[id-1];
if( GetScreen()->GetZoom() == selectedZoom )
return;
GetScreen()->SetZoom( selectedZoom );
RedrawScreen( GetScrollCenterPosition(), false );
}
// Notify GAL
TOOL_MANAGER* mgr = GetToolManager();
if( mgr && IsGalCanvasActive() )
{
mgr->RunAction( "common.Control.zoomPreset", true, id );
UpdateStatusBar();
}
wxFAIL_MSG( "Obsolete! Should go through ToolManager." );
}
@ -629,7 +570,6 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg()
}
void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
{
m_FrameSize = GetClientSize( );
@ -832,7 +772,7 @@ void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
m_LastGridSizeId = 0;
m_UndoRedoCountMax = aCfg->Read( baseCfgName + MaxUndoItemsEntry,
long( DEFAULT_MAX_UNDO_ITEMS ) );
long( DEFAULT_MAX_UNDO_ITEMS ) );
aCfg->Read( baseCfgName + FirstRunShownKeyword, &m_firstRunDialogSetting, 0L );
@ -858,8 +798,7 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
}
void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
const wxString& textLower,
void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper, const wxString& textLower,
COLOR4D color, int pad )
{
if( m_messagePanel == NULL )
@ -920,7 +859,7 @@ void EDA_DRAW_FRAME::PushPreferences( const EDA_DRAW_PANEL* aParentCanvas )
bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
int aExplicitCommand )
int aExplicitCommand )
{
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
@ -1195,37 +1134,13 @@ void EDA_DRAW_FRAME::SetScrollCenterPosition( const wxPoint& aPoint )
//-----</BASE_SCREEN API moved here >--------------------------------------------
void EDA_DRAW_FRAME::RefreshCrossHair( const wxPoint &aOldPos,
const wxPoint &aEvtPos,
wxDC* aDC )
void EDA_DRAW_FRAME::RefreshCrossHair( const wxPoint &aOldPos, const wxPoint &aEvtPos, wxDC* aDC )
{
wxFAIL_MSG( "shouldn't be using RefreshCrossHair() anymore; use CallMouseCapture() directly" );
// CrossHair is no longer XORed; no need for most of this
#if 0
wxPoint newpos = GetCrossHairPosition();
// Redraw the crosshair if it moved
if( aOldPos != newpos )
{
SetCrossHairPosition( aOldPos, false );
m_canvas->CrossHairOff( aDC );
SetCrossHairPosition( newpos, false );
m_canvas->CrossHairOn( aDC );
#endif
if( m_canvas->IsMouseCaptured() )
{
m_canvas->CallMouseCapture( aDC, aEvtPos, true );
}
#if 0
}
#endif
wxFAIL_MSG( "Obsolete; use CallMouseCapture() directly" );
}
bool EDA_DRAW_FRAME::GeneralControlKeyMovement( int aHotKey, wxPoint *aPos,
bool aSnapToGrid )
bool EDA_DRAW_FRAME::GeneralControlKeyMovement( int aHotKey, wxPoint *aPos, bool aSnapToGrid )
{
bool key_handled = false;
@ -1369,11 +1284,7 @@ double EDA_DRAW_FRAME::bestZoom( double sizeX, double sizeY, double scaleFactor,
void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
{
if ( IsGalCanvasActive() )
{
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
return;
}
}
@ -1387,166 +1298,32 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
if( m_canvas == NULL )
return;
int id = event.GetId();
bool warp_cursor = false;
VECTOR2D cpos = GetCrossHairPosition();//GetGalCanvas()->GetViewControls()->GetCursorPosition();
wxPoint zoom_center( (int)cpos.x, (int)cpos.y );
TOOL_MANAGER* mgr = GetToolManager();
int id = event.GetId();
if ( id == ID_KEY_ZOOM_IN )
if( id == ID_KEY_ZOOM_IN )
{
id = GetCanvas()->GetEnableZoomNoCenter() ?
ID_OFFCENTER_ZOOM_IN : ID_POPUP_ZOOM_IN;
if( GetCanvas()->GetEnableZoomNoCenter() )
mgr->RunAction( "common.Control.zoomIn", true, id );
else
mgr->RunAction( "common.Control.zoomInCenter", true, id );
}
else if ( id == ID_KEY_ZOOM_OUT )
else if( id == ID_KEY_ZOOM_OUT )
{
id = GetCanvas()->GetEnableZoomNoCenter() ?
ID_OFFCENTER_ZOOM_OUT : ID_POPUP_ZOOM_OUT;
if( GetCanvas()->GetEnableZoomNoCenter() )
mgr->RunAction( "common.Control.zoomOut", true, id );
else
mgr->RunAction( "common.Control.zoomOutCenter", true, id );
}
switch( id )
else if( id >= ID_POPUP_ZOOM_LEVEL_START && id <= ID_POPUP_ZOOM_LEVEL_END )
{
case ID_OFFCENTER_ZOOM_IN:
SetPreviousZoomAndRedraw( zoom_center,warp_cursor );
break;
case ID_POPUP_ZOOM_IN:
warp_cursor = true;
// fall thru
case ID_VIEWER_ZOOM_IN:
case ID_ZOOM_IN:
SetPreviousZoomAndRedraw( zoom_center,warp_cursor );
break;
case ID_OFFCENTER_ZOOM_OUT:
SetNextZoomAndRedraw( zoom_center, warp_cursor );
break;
case ID_POPUP_ZOOM_OUT:
warp_cursor = true;
// fall thru
case ID_VIEWER_ZOOM_OUT:
case ID_ZOOM_OUT:
SetNextZoomAndRedraw( zoom_center, warp_cursor );
break;
case ID_VIEWER_ZOOM_REDRAW:
case ID_POPUP_ZOOM_REDRAW:
case ID_ZOOM_REDRAW:
// This usually means something went wrong. Do a hard refresh.
HardRedraw();
break;
case ID_POPUP_ZOOM_CENTER:
GetGalCanvas()->GetView()->SetScale( GetGalCanvas()->GetView()->GetScale(), zoom_center );
GetGalCanvas()->GetViewControls()->CenterOnCursor();
break;
case ID_POPUP_ZOOM_PAGE:
case ID_VIEWER_ZOOM_PAGE:
case ID_ZOOM_PAGE:
Zoom_Automatique( false );
break;
case ID_POPUP_ZOOM_SELECT:
break;
case ID_POPUP_CANCEL:
m_canvas->MoveCursorToCrossHair();
break;
default:
SetPresetZoom( id - ID_POPUP_ZOOM_LEVEL_START );
mgr->RunAction( "common.Control.zoomPreset", true, id - ID_POPUP_ZOOM_LEVEL_START );
}
UpdateStatusBar();
}
void EDA_DRAW_FRAME::SetNextZoom()
{
GetScreen()->SetNextZoom();
}
void EDA_DRAW_FRAME::SetPrevZoom()
{
GetScreen()->SetPreviousZoom();
}
void EDA_DRAW_FRAME::SetNextZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer )
{
double zoom = GetGalCanvas()->GetLegacyZoom();
zoom *= 1.3;
// Now look for the next closest menu step
std::vector<double>& zoomList = GetScreen()->m_ZoomList;
int idx;
for( idx = 0; idx < (int)zoomList.size(); ++idx )
{
if( zoomList[idx] > zoom )
break;
}
if( idx >= (int)zoomList.size() )
return;
if( m_zoomSelectBox )
m_zoomSelectBox->SetSelection( idx );
GetScreen()->SetZoom( GetScreen()->m_ZoomList[idx] );
RedrawScreen( aCenterPoint, aWarpPointer );
}
void EDA_DRAW_FRAME::SetPreviousZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer )
{
double zoom = GetGalCanvas()->GetLegacyZoom();
zoom /= 1.3;
// Now look for the next closest menu step
std::vector<double>& zoomList = GetScreen()->m_ZoomList;
int idx;
for( idx = zoomList.size() - 1; idx >= 0; --idx )
{
if( zoomList[idx] < zoom )
break;
}
if( idx < 0 )
return;
if( m_zoomSelectBox )
m_zoomSelectBox->SetSelection( idx );
GetScreen()->SetZoom( GetScreen()->m_ZoomList[idx] );
RedrawScreen( aCenterPoint, aWarpPointer );
}
void EDA_DRAW_FRAME::SetPresetZoom( int aIndex )
{
BASE_SCREEN* screen = GetScreen();
if( aIndex >= (int) screen->m_ZoomList.size() )
{
wxLogDebug( wxT( "%s %d: index %d is outside the bounds of the zoom list." ),
__TFILE__, __LINE__, aIndex );
return;
}
if( m_zoomSelectBox )
m_zoomSelectBox->SetSelection( aIndex );
if( screen->SetZoom( screen->m_ZoomList[aIndex] ) )
RedrawScreen( GetScrollCenterPosition(), true );
UpdateStatusBar();
}
void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
{
int maxZoomIds;
@ -1591,8 +1368,8 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
if( screen->GetGridCount() )
{
wxMenu* gridMenu = new wxMenu;
AddMenuItem( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT,
_( "Grid" ), KiBitmap( grid_select_xpm ) );
AddMenuItem( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT, _( "Grid" ),
KiBitmap( grid_select_xpm ) );
wxArrayString gridsList;
int icurr = screen->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
@ -1729,13 +1506,10 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
screen->m_IsPrinting = true;
dc.SetUserScale( scale, scale );
aFrame->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ),
wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) );
aFrame->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) );
if( DrawBlock )
{
dc.SetClippingRegion( DrawArea );
}
dc.Clear();
aFrame->GetCanvas()->EraseScreen( &dc );
@ -1792,8 +1566,7 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
drawList.SetSheetName( aFullSheetName );
drawList.SetSheetLayer( aSheetLayer );
drawList.BuildWorkSheetGraphicList( aPageInfo,
aTitleBlock, aColor, aAltColor );
drawList.BuildWorkSheetGraphicList( aPageInfo, aTitleBlock, aColor, aAltColor );
// Draw item list
drawList.Draw( aClipBox, aDC );
@ -1814,9 +1587,8 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi
if( !aScreen->m_IsPrinting && m_showPageLimits )
{
GRSetDrawMode( aDC, GR_COPY );
GRRect( m_canvas->GetClipBox(), aDC, 0, 0,
pageSize.x * aScalar, pageSize.y * aScalar, aLineWidth,
m_drawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY );
GRRect( m_canvas->GetClipBox(), aDC, 0, 0, pageSize.x * aScalar, pageSize.y * aScalar,
aLineWidth, m_drawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY );
}
TITLE_BLOCK t_block = GetTitleBlock();
@ -1830,10 +1602,9 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi
aDC->SetAxisOrientation( true, false );
}
DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo,
GetScreenDesc(), aFilename, t_block,
aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber,
aLineWidth, aScalar, color, color, aSheetLayer );
DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo, GetScreenDesc(), aFilename, t_block,
aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, aLineWidth, aScalar,
color, color, aSheetLayer );
if( aScreen->m_IsPrinting && origin.y > 0 )
{

View File

@ -356,27 +356,6 @@ bool EDA_DRAW_FRAME::GetToolToggled( int aToolId )
}
wxAuiToolBarItem* EDA_DRAW_FRAME::GetToolbarTool( int aToolId )
{
// Checks all the toolbars and returns a reference to the given tool id
// (or the first tool found, but only one or 0 tool is expected, because on
// Windows, when different tools have the same ID, it creates issues)
if( m_mainToolBar && m_mainToolBar->FindTool( aToolId ) )
return m_mainToolBar->FindTool( aToolId );
if( m_optionsToolBar && m_optionsToolBar->FindTool( aToolId ) )
return m_optionsToolBar->FindTool( aToolId );
if( m_drawToolBar && m_drawToolBar->FindTool( aToolId ) )
return m_drawToolBar->FindTool( aToolId );
if( m_auxiliaryToolBar && m_auxiliaryToolBar->FindTool( aToolId ) )
return m_auxiliaryToolBar->FindTool( aToolId );
return nullptr;
}
void EDA_DRAW_FRAME::OnSelectUnits( wxCommandEvent& aEvent )
{
if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM && m_UserUnits != MILLIMETRES )

View File

@ -25,6 +25,7 @@ include_directories(
./widgets
./libedit
./libview
./tools
../common
../common/dialogs
${INC_AFTER}
@ -241,6 +242,9 @@ set( EESCHEMA_SRCS
netlist_exporters/netlist_exporter_kicad.cpp
netlist_exporters/netlist_exporter_orcadpcb2.cpp
netlist_exporters/netlist_exporter_pspice.cpp
tools/sch_actions.cpp
tools/tools_common.cpp
)

View File

@ -65,6 +65,8 @@
#include <dialog_symbol_remap.h>
#include <view/view.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tools/sch_actions.h>
#include <wx/display.h>
#include <build_version.h>
@ -397,8 +399,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_busUnfold = {};
m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
m_toolManager = new TOOL_MANAGER;
SetForceHVLines( true );
SetSpiceAjustPassiveValues( false );
@ -443,6 +443,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_auimgr.Update();
setupTools();
Zoom_Automatique( false );
if( GetGalCanvas() )
@ -480,6 +482,22 @@ SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
}
void SCH_EDIT_FRAME::setupTools()
{
// Create the manager and dispatcher & route draw panel events to the dispatcher
m_toolManager = new TOOL_MANAGER;
m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(),
GetCanvas()->GetViewControls(), this );
m_actions = new SCH_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
// Register tools
m_actions->RegisterAllTools( m_toolManager );
m_toolManager->InitTools();
GetCanvas()->SetEventDispatcher( m_toolDispatcher );
}
void SCH_EDIT_FRAME::SetRepeatItem( SCH_ITEM* aItem )
{
// we cannot store a pointer to an item in the display list here since

View File

@ -203,6 +203,9 @@ private:
static wxPoint m_lastSheetPinPosition; ///< Last sheet pin position.
protected:
// The Tool Framework initalization
void setupTools();
/**
* Initializing accessor for the pin text size
*/

View File

@ -0,0 +1,66 @@
/*
* 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 <common.h>
#include <eeschema_id.h>
#include <sch_actions.h>
OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
{
switch( aId )
{
case ID_ZOOM_REDRAW:
case ID_POPUP_ZOOM_REDRAW:
case ID_VIEWER_ZOOM_REDRAW:
return ACTIONS::zoomRedraw.MakeEvent();
case ID_POPUP_ZOOM_IN:
return ACTIONS::zoomIn.MakeEvent();
case ID_ZOOM_IN: // toolbar button "Zoom In"
case ID_VIEWER_ZOOM_IN:
return ACTIONS::zoomInCenter.MakeEvent();
case ID_POPUP_ZOOM_OUT:
return ACTIONS::zoomOut.MakeEvent();
case ID_ZOOM_OUT: // toolbar button "Zoom Out"
case ID_VIEWER_ZOOM_OUT:
return ACTIONS::zoomOutCenter.MakeEvent();
case ID_POPUP_ZOOM_PAGE:
case ID_ZOOM_PAGE: // toolbar button "Fit on Screen"
case ID_VIEWER_ZOOM_PAGE:
return ACTIONS::zoomFitScreen.MakeEvent();
case ID_POPUP_ZOOM_CENTER:
return ACTIONS::zoomCenter.MakeEvent();
case ID_ZOOM_SELECTION:
return ACTIONS::zoomTool.MakeEvent();
}
return OPT<TOOL_EVENT>();
}

View File

@ -0,0 +1,125 @@
/*
* 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 SCH_ACTIONS_H
#define SCH_ACTIONS_H
#include <tool/tool_action.h>
#include <tool/actions.h>
#include <core/optional.h>
class TOOL_EVENT;
class TOOL_MANAGER;
/**
* Class SCH_ACTIONS
*
* Gathers all the actions that are shared by tools. The instance of SCH_ACTIONS is created
* inside of ACTION_MANAGER object that registers the actions.
*/
class SCH_ACTIONS : public ACTIONS
{
public:
// Selection Tool
/// Activation of the selection tool
static TOOL_ACTION selectionActivate;
/// Select a single item under the cursor position
static TOOL_ACTION selectionCursor;
/// Clears the current selection
static TOOL_ACTION selectionClear;
/// Selects an item (specified as the event parameter).
static TOOL_ACTION selectItem;
static TOOL_ACTION unselectItem;
/// Selects a list of items (specified as the event parameter)
static TOOL_ACTION selectItems;
static TOOL_ACTION unselectItems;
/// Runs a selection menu to select from a list of items
static TOOL_ACTION selectionMenu;
// Display modes
static TOOL_ACTION ratsnestLineMode;
static TOOL_ACTION trackDisplayMode;
static TOOL_ACTION padDisplayMode;
static TOOL_ACTION viaDisplayMode;
static TOOL_ACTION graphicDisplayMode;
static TOOL_ACTION zoneDisplayEnable;
static TOOL_ACTION zoneDisplayDisable;
static TOOL_ACTION zoneDisplayOutlines;
static TOOL_ACTION highContrastMode;
static TOOL_ACTION highContrastInc;
static TOOL_ACTION highContrastDec;
/* Can we share these with PCBNew?
// Layer control
static TOOL_ACTION layerTop;
static TOOL_ACTION layerInner1;
static TOOL_ACTION layerInner2;
static TOOL_ACTION layerInner3;
static TOOL_ACTION layerInner4;
static TOOL_ACTION layerInner5;
static TOOL_ACTION layerInner6;
static TOOL_ACTION layerBottom;
static TOOL_ACTION layerNext;
static TOOL_ACTION layerPrev;
static TOOL_ACTION layerAlphaInc;
static TOOL_ACTION layerAlphaDec;
static TOOL_ACTION layerToggle;
static TOOL_ACTION layerChanged; // notification
*/
/// Clipboard
static TOOL_ACTION copyToClipboard;
static TOOL_ACTION pasteFromClipboard;
static TOOL_ACTION cutToClipboard;
// Locking
static TOOL_ACTION toggleLock;
static TOOL_ACTION lock;
static TOOL_ACTION unlock;
// Miscellaneous
static TOOL_ACTION selectionTool;
static TOOL_ACTION pickerTool;
static TOOL_ACTION switchCursor;
static TOOL_ACTION switchUnits;
static TOOL_ACTION updateUnits;
static TOOL_ACTION deleteItemCursor;
static TOOL_ACTION clearHighlight;
static TOOL_ACTION highlightNet;
static TOOL_ACTION highlightNetCursor;
static TOOL_ACTION highlightNetSelection;
///> @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override;
///> @copydoc COMMON_ACTIONS::RegisterAllTools()
virtual void RegisterAllTools( TOOL_MANAGER* aToolManager ) override;
};
#endif

View File

@ -0,0 +1,33 @@
/*
* 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 <tool/tool_manager.h>
#include <tool/common_tools.h>
#include <tools/sch_actions.h>
void SCH_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
{
aToolManager->RegisterTool( new COMMON_TOOLS );
}

View File

@ -492,12 +492,6 @@ public:
*/
bool GetToolToggled( int aToolId );
/**
* Checks all the toolbars and returns a reference to the given tool id
* or nullptr if not found
*/
wxAuiToolBarItem* GetToolbarTool( int aToolId );
/**
* Set the tool command ID to \a aId and sets the cursor to \a aCursor.
*

View File

@ -54,14 +54,10 @@ public:
/// Selects an item (specified as the event parameter).
static TOOL_ACTION selectItem;
static TOOL_ACTION unselectItem;
/// Selects a list of items (specified as the event parameter)
static TOOL_ACTION selectItems;
/// Unselects an item (specified as the event parameter).
static TOOL_ACTION unselectItem;
/// Unselects a list of items (specified as the event parameter)
static TOOL_ACTION unselectItems;
/// Runs a selection menu to select from a list of items
@ -95,10 +91,8 @@ public:
/// move an item
static TOOL_ACTION move;
/// Rotation of selected objects clockwise
/// Rotation of selected objects
static TOOL_ACTION rotateCw;
/// Rotation of selected objects counter-clockwise
static TOOL_ACTION rotateCcw;
/// Flipping of selected objects
@ -142,50 +136,21 @@ public:
static TOOL_ACTION dragFreeAngle;
// Drawing Tool
/// Activation of the drawing tool (line)
// Drawing Tool Activations
static TOOL_ACTION drawLine;
// Activation of the drawing tool (graphic polygons)
static TOOL_ACTION drawGraphicPolygon;
/// Activation of the drawing tool (circle)
static TOOL_ACTION drawCircle;
/// Activation of the drawing tool (arc)
static TOOL_ACTION drawArc;
/// Activation of the drawing tool (text)
static TOOL_ACTION placeText;
/// Activation of the drawing tool (dimension)
static TOOL_ACTION drawDimension;
/// Activation of the drawing tool (drawing a ZONE)
static TOOL_ACTION drawZone;
/// Activation of the drawing tool (drawing a VIA)
static TOOL_ACTION drawVia;
/// Activation of the drawing tool (drawing a keepout area)
static TOOL_ACTION drawZoneKeepout;
/// Activation of the drawing tool (drawing a ZONE cutout)
static TOOL_ACTION drawZoneCutout;
/// Activation of the drawing tool (drawing a similar ZONE to another one)
static TOOL_ACTION drawSimilarZone;
/// Activation of the drawing tool (placing a TARGET)
static TOOL_ACTION placeTarget;
/// Activation of the drawing tool (placing a MODULE)
static TOOL_ACTION placeModule;
/// Activation of the drawing tool (placing a drawing imported from DXF or SVG file)
static TOOL_ACTION placeImportedGraphics;
/// Activation of the drawing tool (placing the footprint anchor)
static TOOL_ACTION setAnchor;
/// Increase width of currently drawn line
@ -230,28 +195,13 @@ public:
static TOOL_ACTION pointEditorRemoveCorner;
// Placement tool
/// Align items to the top edge of selection bounding box
static TOOL_ACTION alignTop;
/// Align items to the bottom edge of selection bounding box
static TOOL_ACTION alignBottom;
/// Align items to the left edge of selection bounding box
static TOOL_ACTION alignLeft;
/// Align items to the right edge of selection bounding box
static TOOL_ACTION alignRight;
/// Align items to the middle of selection bounding box
static TOOL_ACTION alignCenterX;
/// Align items to the center of selection bounding box
static TOOL_ACTION alignCenterY;
/// Distributes items evenly along the horizontal axis
static TOOL_ACTION distributeHorizontally;
/// Distributes items evenly along the vertical axis
static TOOL_ACTION distributeVertically;
// Position Relative Tool
@ -322,13 +272,9 @@ public:
/// Tool for creating an array of objects
static TOOL_ACTION createArray;
/// Copy selected items to clipboard
/// Clipboard
static TOOL_ACTION copyToClipboard;
/// Paste from clipboard
static TOOL_ACTION pasteFromClipboard;
/// Paste from clipboard
static TOOL_ACTION cutToClipboard;
/// Display module edges as outlines