KiCad PCB EDA Suite
COMMON_TOOLS Class Reference

Class COMMON_TOOLS. More...

#include <common_tools.h>

Inheritance diagram for COMMON_TOOLS:
TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 COMMON_TOOLS ()
 
virtual ~COMMON_TOOLS ()
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
int ZoomRedraw (const TOOL_EVENT &aEvent)
 
int ZoomInOut (const TOOL_EVENT &aEvent)
 
int ZoomInOutCenter (const TOOL_EVENT &aEvent)
 
int ZoomCenter (const TOOL_EVENT &aEvent)
 
int ZoomFitScreen (const TOOL_EVENT &aEvent)
 
int ZoomPreset (const TOOL_EVENT &aEvent)
 
int CenterContents (const TOOL_EVENT &aEvent)
 
int PanControl (const TOOL_EVENT &aEvent)
 
int CursorControl (const TOOL_EVENT &aEvent)
 
int ToggleCursor (const TOOL_EVENT &aEvent)
 
int ToggleCursorStyle (const TOOL_EVENT &aEvent)
 
int ImperialUnits (const TOOL_EVENT &aEvent)
 
int MetricUnits (const TOOL_EVENT &aEvent)
 
int ToggleUnits (const TOOL_EVENT &aEvent)
 
int GridNext (const TOOL_EVENT &aEvent)
 
int GridPrev (const TOOL_EVENT &aEvent)
 
int GridPreset (const TOOL_EVENT &aEvent)
 
int ToggleGrid (const TOOL_EVENT &aEvent)
 
int GridProperties (const TOOL_EVENT &aEvent)
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 
void Activate ()
 Function Activate() Runs the tool. More...
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
OPT_TOOL_EVENT Wait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
virtual bool Init ()
 Function Init() Init() is called once upon a registration of the tool. More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Protected Member Functions

const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

int doZoomInOut (bool aDirection, bool aCenterOnCursor)
 
int doZoomToPreset (int idx, bool aCenterOnCursor)
 

Note: idx == 0 is Auto; idx == 1 is first entry in zoomList

More...
 
int doGridPreset (int idx)
 

Private Attributes

EDA_DRAW_FRAMEm_frame
 

Pointer to the currently used edit frame.

More...
 

Detailed Description

Class COMMON_TOOLS.

Handles actions that are shared between different applications

Definition at line 38 of file common_tools.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 80 of file tool_base.h.

81  {
82  RUN,
83  MODEL_RELOAD,
84  GAL_SWITCH
85  };
Model changes (required full reload)
Definition: tool_base.h:83
Tool is invoked after being inactive.
Definition: tool_base.h:82
Rendering engine changes.
Definition: tool_base.h:84

Constructor & Destructor Documentation

◆ COMMON_TOOLS()

COMMON_TOOLS::COMMON_TOOLS ( )
inline

Definition at line 41 of file common_tools.h.

41  :
42  TOOL_INTERACTIVE( "common.Control" ),
43  m_frame( NULL )
44  { }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Constructor.

◆ ~COMMON_TOOLS()

virtual COMMON_TOOLS::~COMMON_TOOLS ( )
inlinevirtual

Definition at line 46 of file common_tools.h.

46 { }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

After activation, the tool starts receiving events until it is finished.

Definition at line 49 of file tool_interactive.cpp.

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:211
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.

References TOOL_MANAGER::InvokeTool(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplace(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), EDIT_TOOL::doCopyToClipboard(), SCH_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SCH_WIRE_BUS_TOOL::StartBus(), SCH_WIRE_BUS_TOOL::StartWire(), and SCH_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

Sets the TOOL_MANAGER the tool will belong to. Called by TOOL_MANAGER::RegisterTool()

Definition at line 59 of file tool_base.cpp.

60 {
61  m_toolMgr = aManager;
62  m_toolSettings = TOOL_SETTINGS( this );
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:217
friend class TOOL_SETTINGS
Definition: tool_base.h:155

References TOOL_BASE::m_toolMgr, TOOL_BASE::m_toolSettings, and TOOL_BASE::TOOL_SETTINGS.

Referenced by TOOL_MANAGER::RegisterTool().

◆ CenterContents()

int COMMON_TOOLS::CenterContents ( const TOOL_EVENT aEvent)

Definition at line 258 of file common_tools.cpp.

259 {
260  EDA_DRAW_PANEL_GAL* galCanvas = m_frame->GetGalCanvas();
261  BOX2I bBox = getModel<EDA_ITEM>()->ViewBBox();
262 
263  if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
264  bBox = galCanvas->GetDefaultViewBBox();
265 
266  getView()->SetCenter( bBox.Centre() );
267 
268  // Take scrollbars into account
269  VECTOR2D scrollbarSize = VECTOR2D( galCanvas->GetSize() - galCanvas->GetClientSize() );
270  VECTOR2D worldScrollbarSize = getView()->ToWorld( scrollbarSize, false );
271  getView()->SetCenter( getView()->GetCenter() + worldScrollbarSize / 2.0 );
272 
273  return 0;
274 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Function ToWorld() Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:475
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:931
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:601
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
coord_type GetWidth() const
Definition: box2.h:195
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
Vec Centre() const
Definition: box2.h:77
coord_type GetHeight() const
Definition: box2.h:196
virtual BOX2I GetDefaultViewBBox() const
Returns the bounding box of the view that should be used if model is not valid For example,...

References BOX2< Vec >::Centre(), EDA_DRAW_PANEL_GAL::GetDefaultViewBBox(), EDA_DRAW_FRAME::GetGalCanvas(), BOX2< Vec >::GetHeight(), TOOL_BASE::getView(), BOX2< Vec >::GetWidth(), m_frame, KIGFX::VIEW::SetCenter(), and KIGFX::VIEW::ToWorld().

Referenced by setTransitions().

◆ CursorControl()

int COMMON_TOOLS::CursorControl ( const TOOL_EVENT aEvent)

Definition at line 45 of file common_tools.cpp.

46 {
47  long type = aEvent.Parameter<intptr_t>();
48  bool fastMove = type & ACTIONS::CURSOR_FAST_MOVE;
49  type &= ~ACTIONS::CURSOR_FAST_MOVE;
50  bool mirroredX = getView()->IsMirroredX();
51 
52  VECTOR2D cursor = getViewControls()->GetRawCursorPosition( false );
53  VECTOR2I gridSize = VECTOR2D( m_frame->GetScreen()->GetGridSize() );
54 
55  if( fastMove )
56  gridSize = gridSize * 10;
57 
58  switch( type )
59  {
60  case ACTIONS::CURSOR_UP:
61  cursor -= VECTOR2D( 0, gridSize.y );
62  break;
63 
65  cursor += VECTOR2D( 0, gridSize.y );
66  break;
67 
69  cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
70  break;
71 
73  cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
74  break;
75 
76  case ACTIONS::CURSOR_CLICK: // fall through
78  {
79  TOOL_ACTIONS action = TA_NONE;
80  int modifiers = 0;
81 
82  modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
83  modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
84  modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
85 
86  if( type == ACTIONS::CURSOR_CLICK )
87  action = TA_MOUSE_CLICK;
88  else if( type == ACTIONS::CURSOR_DBL_CLICK )
89  action = TA_MOUSE_DBLCLICK;
90  else
91  wxFAIL;
92 
93  TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers );
94  evt.SetMousePosition( getViewControls()->GetCursorPosition() );
95  m_toolMgr->ProcessEvent( evt );
96 
97  return 0;
98  }
99  break;
100  }
101 
102  getViewControls()->SetCursorPosition( cursor, true, true );
103 
104  return 0;
105 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
TOOL_ACTIONS
Definition: tool_event.h:60
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
Class TOOL_EVENT.
Definition: tool_event.h:167
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
bool IsMirroredX() const
Function IsMirroredX() Returns true if view is flipped across the X axis.
Definition: view.h:230
virtual VECTOR2D GetRawCursorPosition(bool aSnappingEnabled=true) const =0
Returns the current cursor position in world coordinates - ingoring the cursorUp position force mode.
Class ACTIONS.
Definition: actions.h:41
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:408
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false)=0
Moves cursor to the requested position expressed in world coordinates.

References BUT_LEFT, ACTIONS::CURSOR_CLICK, ACTIONS::CURSOR_DBL_CLICK, ACTIONS::CURSOR_DOWN, ACTIONS::CURSOR_FAST_MOVE, ACTIONS::CURSOR_LEFT, ACTIONS::CURSOR_RIGHT, ACTIONS::CURSOR_UP, BASE_SCREEN::GetGridSize(), KIGFX::VIEW_CONTROLS::GetRawCursorPosition(), EDA_DRAW_FRAME::GetScreen(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), KIGFX::VIEW::IsMirroredX(), m_frame, TOOL_BASE::m_toolMgr, MD_ALT, MD_CTRL, MD_SHIFT, TOOL_EVENT::Parameter(), TOOL_MANAGER::ProcessEvent(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), TOOL_EVENT::SetMousePosition(), TA_MOUSE_CLICK, TA_MOUSE_DBLCLICK, TA_NONE, TC_MOUSE, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

◆ doGridPreset()

int COMMON_TOOLS::doGridPreset ( int  idx)
private

Definition at line 353 of file common_tools.cpp.

354 {
355  BASE_SCREEN* screen = m_frame->GetScreen();
356 
357  if( !screen->GridExists( idx + ID_POPUP_GRID_LEVEL_1000 ) )
358  idx = 0;
359 
360  screen->SetGrid( idx + ID_POPUP_GRID_LEVEL_1000 );
361 
362  // Be sure m_LastGridSizeId is up to date.
363  m_frame->SetLastGridSizeId( idx );
364 
365  // Update the combobox (if any)
366  wxUpdateUIEvent dummy;
368 
369  // Update GAL canvas from screen
370  getView()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
372 
373  // Put cursor on new grid
375 
376  return 0;
377 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:180
Auxiliary rendering target (noncached)
Definition: definitions.h:49
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:596
void OnUpdateSelectGrid(wxUpdateUIEvent &aEvent)
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
bool GridExists(int aCommandId)
Function GridExists tests for grid command ID (not an index in grid list, but a wxID) exists in grid ...
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
void SetLastGridSizeId(int aId)
Definition: draw_frame.h:313
wxPoint RefPos(bool useMouse) const
Return the reference position, coming from either the mouse position or the cursor position.
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Set the screen cross hair position to aPosition in logical (drawing) units.
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:408

References dummy(), KIGFX::VIEW::GetGAL(), BASE_SCREEN::GetGridSize(), EDA_DRAW_FRAME::GetScreen(), TOOL_BASE::getView(), BASE_SCREEN::GridExists(), ID_POPUP_GRID_LEVEL_1000, m_frame, KIGFX::VIEW::MarkTargetDirty(), EDA_DRAW_FRAME::OnUpdateSelectGrid(), EDA_DRAW_FRAME::RefPos(), EDA_DRAW_FRAME::SetCrossHairPosition(), BASE_SCREEN::SetGrid(), KIGFX::GAL::SetGridSize(), EDA_DRAW_FRAME::SetLastGridSizeId(), and KIGFX::TARGET_NONCACHED.

Referenced by GridNext(), GridPreset(), and GridPrev().

◆ doZoomInOut()

int COMMON_TOOLS::doZoomInOut ( bool  aDirection,
bool  aCenterOnCursor 
)
private

Definition at line 166 of file common_tools.cpp.

167 {
168  double zoom = m_frame->GetGalCanvas()->GetLegacyZoom();
169 
170  // Step must be AT LEAST 1.3
171  if( aDirection )
172  zoom /= 1.3;
173  else
174  zoom *= 1.3;
175 
176  // Now look for the next closest menu step
177  std::vector<double>& zoomList = m_frame->GetScreen()->m_ZoomList;
178  int idx;
179 
180  if( aDirection )
181  {
182  for( idx = zoomList.size() - 1; idx >= 0; --idx )
183  {
184  if( zoomList[idx] <= zoom )
185  break;
186  }
187 
188  if( idx < 0 )
189  idx = 0; // if we ran off the end then peg to the end
190  }
191  else
192  {
193  for( idx = 0; idx < (int)zoomList.size(); ++idx )
194  {
195  if( zoomList[idx] >= zoom )
196  break;
197  }
198 
199  if( idx >= (int)zoomList.size() )
200  idx = zoomList.size() - 1; // if we ran off the end then peg to the end
201  }
202 
203  return doZoomToPreset( idx + 1, aCenterOnCursor );
204 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:931
int doZoomToPreset(int idx, bool aCenterOnCursor)
Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
double GetLegacyZoom() const
Function GetLegacyZoom() Returns current view scale converted to zoom value used by the legacy canvas...
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:408
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:219

References doZoomToPreset(), EDA_DRAW_FRAME::GetGalCanvas(), EDA_DRAW_PANEL_GAL::GetLegacyZoom(), EDA_DRAW_FRAME::GetScreen(), m_frame, and BASE_SCREEN::m_ZoomList.

Referenced by ZoomInOut(), and ZoomInOutCenter().

◆ doZoomToPreset()

int COMMON_TOOLS::doZoomToPreset ( int  idx,
bool  aCenterOnCursor 
)
private

Note: idx == 0 is Auto; idx == 1 is first entry in zoomList

Definition at line 285 of file common_tools.cpp.

286 {
287  std::vector<double>& zoomList = m_frame->GetScreen()->m_ZoomList;
288  KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
289 
290  if( idx == 0 ) // Zoom Auto
291  {
293  return ZoomFitScreen( dummy );
294  }
295  else
296  {
297  idx--;
298  }
299 
300  double scale = m_frame->GetZoomLevelCoeff() / zoomList[idx];
301 
302  if( aCenterOnCursor )
303  {
304  view->SetScale( scale, getViewControls()->GetCursorPosition() );
305 
306  if( getViewControls()->IsCursorWarpingEnabled() )
308  }
309  else
310  {
311  view->SetScale( scale );
312  }
313 
314  return 0;
315 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
int ZoomFitScreen(const TOOL_EVENT &aEvent)
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:931
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:250
virtual void CenterOnCursor() const =0
Function CenterOnCursor() Sets the viewport center to the current cursor position and warps the curso...
double GetZoomLevelCoeff() const
Return the coefficient to convert internal display scale factor to zoom level.
Definition: draw_frame.h:475
Class TOOL_EVENT.
Definition: tool_event.h:167
const int scale
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
Class VIEW.
Definition: view.h:61
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:408
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:219

References KIGFX::VIEW_CONTROLS::CenterOnCursor(), dummy(), EDA_DRAW_FRAME::GetGalCanvas(), EDA_DRAW_FRAME::GetScreen(), EDA_DRAW_PANEL_GAL::GetView(), TOOL_BASE::getViewControls(), EDA_DRAW_FRAME::GetZoomLevelCoeff(), m_frame, BASE_SCREEN::m_ZoomList, scale, KIGFX::VIEW::SetScale(), and ZoomFitScreen().

Referenced by doZoomInOut(), and ZoomPreset().

◆ evActivate()

const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

◆ evButtonDown()

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited

◆ evButtonUp()

const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited

◆ evClick()

const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited

◆ evCommand() [1/2]

const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited

◆ evCommand() [2/2]

const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited

◆ evDrag()

const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited

◆ evMotion()

const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited

◆ getEditFrame()

template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

Returns the application window object, casted to requested user type.

Definition at line 188 of file tool_base.h.

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47

References TOOL_BASE::getEditFrameInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), and TOOL_SETTINGS::getConfigBase().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Function GetId() Returns the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

123  {
124  return m_toolId;
125  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:211

References TOOL_BASE::m_toolId.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::saveViewControls().

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER. If there is no TOOL_MANAGER associated, it returns NULL.

Definition at line 144 of file tool_base.h.

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), ACTION_MENU::onMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ getModel()

template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 199 of file tool_base.h.

200  {
201  EDA_ITEM* m = getModelInt();
202  wxASSERT( dynamic_cast<T*>( m ) );
203 
204  return static_cast<T*>( m );
205  }
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:53
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157

References TOOL_BASE::getModelInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), ZONE_CREATE_HELPER::createZoneFromExisting(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ GetName()

const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Function GetName() Returns the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

134  {
135  return m_toolName;
136  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:215

References TOOL_BASE::m_toolName.

Referenced by TOOL_SETTINGS::getKeyName(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), and TOOL_MANAGER::RegisterTool().

◆ GetSettings()

TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:217

References TOOL_BASE::m_toolSettings.

Referenced by ROUTER_TOOL::Init(), GERBVIEW_SELECTION_TOOL::selectable(), and ROUTER_TOOL::~ROUTER_TOOL().

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:208

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), and TOOL_MANAGER::runTool().

◆ getView()

KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Function getView()

Returns the instance of VIEW object used in the application. It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 35 of file tool_base.cpp.

36 {
37  return m_toolMgr->GetView();
38 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216

References TOOL_MANAGER::GetView(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), CenterContents(), EE_SELECTION_TOOL::clearSelection(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), doGridPreset(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), EE_POINT_EDITOR::Main(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PanControl(), LIB_EDIT_TOOL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), ToggleGrid(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), PCBNEW_CONTROL::updateGrid(), EE_POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_TOOL_BASE::view(), ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), CVPCB_SELECTION_TOOL::~CVPCB_SELECTION_TOOL(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited

Function getViewControls()

Returns the instance of VIEW_CONTROLS object used in the application. It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.)

Returns
The instance of VIEW_CONTROLS.

Definition at line 41 of file tool_base.cpp.

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257

References TOOL_MANAGER::GetViewControls(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCorner(), POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), CursorControl(), SCH_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), SCH_WIRE_BUS_TOOL::finishSegments(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), CVPCB_CONTROL::ResetCoords(), GERBVIEW_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), EE_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), LIB_MOVE_TOOL::updateModificationPoint(), SCH_MOVE_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and ZoomCenter().

◆ Go()

template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Function Go()

Defines which state (aStateFunc) to go when a certain event arrives (aConditions). No conditions means any event.

Definition at line 135 of file tool_interactive.h.

137 {
138  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
139 
140  goInternal( sptr, aConditions );
141 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), LIB_CONTROL::setTransitions(), LIB_PIN_TOOL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), LIB_MOVE_TOOL::setTransitions(), POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), setTransitions(), CVPCB_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), SCH_WIRE_BUS_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), EE_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), SELECTION_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ GridNext()

int COMMON_TOOLS::GridNext ( const TOOL_EVENT aEvent)

Definition at line 319 of file common_tools.cpp.

320 {
321  BASE_SCREEN * screen = m_frame->GetScreen();
322 
323  int new_grid_cmd = screen->GetGridCmdId();
324 
325  // if the grid id is the not the last, increment it
326  if( screen->GridExists( new_grid_cmd + 1 ) )
327  new_grid_cmd += 1;
328 
329  return doGridPreset( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
330 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
int doGridPreset(int idx)
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
bool GridExists(int aCommandId)
Function GridExists tests for grid command ID (not an index in grid list, but a wxID) exists in grid ...
int GetGridCmdId() const
Return the command ID of the currently selected grid.
Definition: base_screen.h:403
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:408

References doGridPreset(), BASE_SCREEN::GetGridCmdId(), EDA_DRAW_FRAME::GetScreen(), BASE_SCREEN::GridExists(), ID_POPUP_GRID_LEVEL_1000, and m_frame.

Referenced by setTransitions().

◆ GridPreset()

int COMMON_TOOLS::GridPreset ( const TOOL_EVENT aEvent)

Definition at line 347 of file common_tools.cpp.

348 {
349  return doGridPreset( aEvent.Parameter<intptr_t>() );
350 }
int doGridPreset(int idx)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378

References doGridPreset(), and TOOL_EVENT::Parameter().

Referenced by setTransitions().

◆ GridPrev()

int COMMON_TOOLS::GridPrev ( const TOOL_EVENT aEvent)

Definition at line 333 of file common_tools.cpp.

334 {
335  BASE_SCREEN * screen = m_frame->GetScreen();
336 
337  int new_grid_cmd = screen->GetGridCmdId();
338 
339  // if the grid id is the not the first, increment it
340  if( screen->GridExists( new_grid_cmd - 1 ) )
341  new_grid_cmd -= 1;
342 
343  return doGridPreset( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
344 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
int doGridPreset(int idx)
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
bool GridExists(int aCommandId)
Function GridExists tests for grid command ID (not an index in grid list, but a wxID) exists in grid ...
int GetGridCmdId() const
Return the command ID of the currently selected grid.
Definition: base_screen.h:403
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:408

References doGridPreset(), BASE_SCREEN::GetGridCmdId(), EDA_DRAW_FRAME::GetScreen(), BASE_SCREEN::GridExists(), ID_POPUP_GRID_LEVEL_1000, and m_frame.

Referenced by setTransitions().

◆ GridProperties()

int COMMON_TOOLS::GridProperties ( const TOOL_EVENT aEvent)

Definition at line 392 of file common_tools.cpp.

393 {
394  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
395 
396  cmd.SetId( ID_GRID_SETTINGS );
397  m_frame->ProcessEvent( cmd );
398 
399  return 0;
400 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.

References ID_GRID_SETTINGS, m_frame, and EDA_BASE_FRAME::ProcessEvent().

Referenced by setTransitions().

◆ ImperialUnits()

int COMMON_TOOLS::ImperialUnits ( const TOOL_EVENT aEvent)

Definition at line 410 of file common_tools.cpp.

411 {
413  return 0;
414 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
void ChangeUserUnits(EDA_UNITS_T aUnits)
Definition: draw_frame.h:292
Definition: common.h:158

References EDA_DRAW_FRAME::ChangeUserUnits(), INCHES, and m_frame.

Referenced by setTransitions().

◆ Init()

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

31 {
32  return m_toolMgr->IsToolActive( m_toolId );
33 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:211
bool IsToolActive(TOOL_ID aId) const
Function IsToolActive() Returns true if a tool with given id is active (executing)

References TOOL_MANAGER::IsToolActive(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

◆ MetricUnits()

int COMMON_TOOLS::MetricUnits ( const TOOL_EVENT aEvent)

Definition at line 403 of file common_tools.cpp.

404 {
406  return 0;
407 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
void ChangeUserUnits(EDA_UNITS_T aUnits)
Definition: draw_frame.h:292

References EDA_DRAW_FRAME::ChangeUserUnits(), m_frame, and MILLIMETRES.

Referenced by setTransitions().

◆ PanControl()

int COMMON_TOOLS::PanControl ( const TOOL_EVENT aEvent)

Definition at line 108 of file common_tools.cpp.

109 {
110  long type = aEvent.Parameter<intptr_t>();
111  KIGFX::VIEW* view = getView();
112  VECTOR2D center = view->GetCenter();
113  VECTOR2I gridSize = VECTOR2D( m_frame->GetScreen()->GetGridSize() ) * 10;
114  bool mirroredX = view->IsMirroredX();
115 
116  switch( type )
117  {
118  case ACTIONS::CURSOR_UP:
119  center -= VECTOR2D( 0, gridSize.y );
120  break;
121 
123  center += VECTOR2D( 0, gridSize.y );
124  break;
125 
127  center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
128  break;
129 
131  center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
132  break;
133 
134  default:
135  wxFAIL;
136  break;
137  }
138 
139  view->SetCenter( center );
140 
141  return 0;
142 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
Class VIEW.
Definition: view.h:61
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:408

References ACTIONS::CURSOR_DOWN, ACTIONS::CURSOR_LEFT, ACTIONS::CURSOR_RIGHT, ACTIONS::CURSOR_UP, BASE_SCREEN::GetGridSize(), EDA_DRAW_FRAME::GetScreen(), TOOL_BASE::getView(), m_frame, TOOL_EVENT::Parameter(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

◆ Reset()

void COMMON_TOOLS::Reset ( RESET_REASON  aReason)
overridevirtual

Function Reset() Brings the tool to a known, initial state.

If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Implements TOOL_BASE.

Definition at line 38 of file common_tools.cpp.

39 {
40  m_frame = getEditFrame<EDA_DRAW_FRAME>();
41 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85

References m_frame.

◆ RunMainStack()

void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 85 of file tool_interactive.cpp.

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::RunMainStack().

Referenced by DRAWING_TOOL::PlaceText().

◆ SetContextMenu()

void TOOL_INTERACTIVE::SetContextMenu ( ACTION_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Function SetContextMenu()

Assigns a context menu and tells when it should be activated.

Parameters
aMenuis the menu to be assigned.
aTriggerdetermines conditions upon which the context menu is activated.

Definition at line 74 of file tool_interactive.cpp.

75 {
76  if( aMenu )
77  aMenu->SetTool( this );
78  else
79  aTrigger = CMENU_OFF;
80 
81  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
82 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool's context popup menu.

References CMENU_OFF, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ScheduleContextMenu(), and ACTION_MENU::SetTool().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), TOOL_MENU::ShowContextMenu(), and SCH_WIRE_BUS_TOOL::UnfoldBus().

◆ setTransitions()

void COMMON_TOOLS::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

Definition at line 446 of file common_tools.cpp.

447 {
448  // Cursor control
457 
460 
461  // Pan control
462  Go( &COMMON_TOOLS::PanControl, ACTIONS::panUp.MakeEvent() );
466 
467  // Zoom control
469  Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomIn.MakeEvent() );
476 
478 
484 
488 
491 }
int MetricUnits(const TOOL_EVENT &aEvent)
int ZoomFitScreen(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoomPreset
Definition: actions.h:64
static TOOL_ACTION zoomInCenter
Definition: actions.h:60
int ToggleCursorStyle(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorRight
Definition: actions.h:74
static TOOL_ACTION zoomFitScreen
Definition: actions.h:63
static TOOL_ACTION cursorRightFast
Definition: actions.h:79
int GridPreset(const TOOL_EVENT &aEvent)
static TOOL_ACTION panLeft
Definition: actions.h:87
static TOOL_ACTION imperialUnits
Definition: actions.h:102
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int ImperialUnits(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoomOutCenter
Definition: actions.h:61
int GridNext(const TOOL_EVENT &aEvent)
int ToggleUnits(const TOOL_EVENT &aEvent)
int ZoomInOutCenter(const TOOL_EVENT &aEvent)
static TOOL_ACTION centerContents
Definition: actions.h:66
static TOOL_ACTION toggleCursor
Definition: actions.h:67
static TOOL_ACTION gridPreset
Definition: actions.h:97
static TOOL_ACTION gridPrev
Definition: actions.h:94
static TOOL_ACTION panDown
Definition: actions.h:86
int GridPrev(const TOOL_EVENT &aEvent)
static TOOL_ACTION toggleGrid
Definition: actions.h:98
static TOOL_ACTION cursorUpFast
Definition: actions.h:76
static TOOL_ACTION cursorDownFast
Definition: actions.h:77
static TOOL_ACTION cursorLeft
Definition: actions.h:73
static TOOL_ACTION panRight
Definition: actions.h:88
int ZoomCenter(const TOOL_EVENT &aEvent)
int ToggleGrid(const TOOL_EVENT &aEvent)
int ZoomInOut(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorLeftFast
Definition: actions.h:78
int CursorControl(const TOOL_EVENT &aEvent)
int ToggleCursor(const TOOL_EVENT &aEvent)
int CenterContents(const TOOL_EVENT &aEvent)
static TOOL_ACTION metricUnits
Definition: actions.h:103
static TOOL_ACTION zoomCenter
Definition: actions.h:62
static TOOL_ACTION cursorUp
Cursor control with keyboard.
Definition: actions.h:71
static TOOL_ACTION zoomRedraw
Definition: actions.h:57
static TOOL_ACTION cursorDblClick
Definition: actions.h:82
int ZoomPreset(const TOOL_EVENT &aEvent)
static TOOL_ACTION gridNext
Definition: actions.h:93
static TOOL_ACTION gridProperties
Definition: actions.h:99
static TOOL_ACTION panUp
Definition: actions.h:85
static TOOL_ACTION zoomIn
Definition: actions.h:58
static TOOL_ACTION zoomOut
Definition: actions.h:59
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:68
static TOOL_ACTION cursorDown
Definition: actions.h:72
int PanControl(const TOOL_EVENT &aEvent)
int ZoomRedraw(const TOOL_EVENT &aEvent)
static TOOL_ACTION toggleUnits
Definition: actions.h:104
int GridProperties(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorClick
Definition: actions.h:81

References CenterContents(), ACTIONS::centerContents, ACTIONS::cursorClick, CursorControl(), ACTIONS::cursorDblClick, ACTIONS::cursorDown, ACTIONS::cursorDownFast, ACTIONS::cursorLeft, ACTIONS::cursorLeftFast, ACTIONS::cursorRight, ACTIONS::cursorRightFast, ACTIONS::cursorUp, ACTIONS::cursorUpFast, TOOL_INTERACTIVE::Go(), GridNext(), ACTIONS::gridNext, GridPreset(), ACTIONS::gridPreset, GridPrev(), ACTIONS::gridPrev, GridProperties(), ACTIONS::gridProperties, ImperialUnits(), ACTIONS::imperialUnits, MetricUnits(), ACTIONS::metricUnits, PanControl(), ACTIONS::panDown, ACTIONS::panLeft, ACTIONS::panRight, ACTIONS::panUp, ToggleCursor(), ACTIONS::toggleCursor, ToggleCursorStyle(), ACTIONS::toggleCursorStyle, ToggleGrid(), ACTIONS::toggleGrid, ToggleUnits(), ACTIONS::toggleUnits, ZoomCenter(), ACTIONS::zoomCenter, ZoomFitScreen(), ACTIONS::zoomFitScreen, ACTIONS::zoomIn, ACTIONS::zoomInCenter, ZoomInOut(), ZoomInOutCenter(), ACTIONS::zoomOut, ACTIONS::zoomOutCenter, ZoomPreset(), ACTIONS::zoomPreset, ZoomRedraw(), and ACTIONS::zoomRedraw.

◆ ToggleCursor()

int COMMON_TOOLS::ToggleCursor ( const TOOL_EVENT aEvent)

Definition at line 424 of file common_tools.cpp.

425 {
426  auto& galOpts = m_frame->GetGalDisplayOptions();
427 
428  galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor;
429  galOpts.NotifyChanged();
430 
431  return 0;
432 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
Definition: draw_frame.h:949
bool m_forceDisplayCursor
Force cursor display

References EDA_DRAW_FRAME::GetGalDisplayOptions(), KIGFX::GAL_DISPLAY_OPTIONS::m_forceDisplayCursor, and m_frame.

Referenced by setTransitions().

◆ ToggleCursorStyle()

int COMMON_TOOLS::ToggleCursorStyle ( const TOOL_EVENT aEvent)

Definition at line 435 of file common_tools.cpp.

436 {
438 
439  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
440  galOpts.NotifyChanged();
441 
442  return 0;
443 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
Definition: draw_frame.h:949
bool m_fullscreenCursor
Fullscreen crosshair or small cross

References EDA_DRAW_FRAME::GetGalDisplayOptions(), m_frame, KIGFX::GAL_DISPLAY_OPTIONS::m_fullscreenCursor, and KIGFX::GAL_DISPLAY_OPTIONS::NotifyChanged().

Referenced by setTransitions().

◆ ToggleGrid()

int COMMON_TOOLS::ToggleGrid ( const TOOL_EVENT aEvent)

Definition at line 380 of file common_tools.cpp.

381 {
383 
387 
388  return 0;
389 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
virtual bool IsGridVisible() const
Definition: draw_frame.h:533
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:931
Auxiliary rendering target (noncached)
Definition: definitions.h:49
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:596
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
virtual void SetGridVisibility(bool aVisible)
It may be overloaded by derived classes.
Definition: draw_frame.h:542

References EDA_DRAW_PANEL_GAL::GetGAL(), EDA_DRAW_FRAME::GetGalCanvas(), TOOL_BASE::getView(), EDA_DRAW_FRAME::IsGridVisible(), m_frame, KIGFX::VIEW::MarkTargetDirty(), EDA_DRAW_PANEL_GAL::Refresh(), EDA_DRAW_FRAME::SetGridVisibility(), KIGFX::GAL::SetGridVisibility(), and KIGFX::TARGET_NONCACHED.

Referenced by setTransitions().

◆ ToggleUnits()

int COMMON_TOOLS::ToggleUnits ( const TOOL_EVENT aEvent)

Definition at line 417 of file common_tools.cpp.

418 {
420  return 0;
421 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
void ChangeUserUnits(EDA_UNITS_T aUnits)
Definition: draw_frame.h:292
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:289
Definition: common.h:158

References EDA_DRAW_FRAME::ChangeUserUnits(), EDA_DRAW_FRAME::GetUserUnits(), INCHES, m_frame, and MILLIMETRES.

Referenced by setTransitions().

◆ Wait()

OPT_TOOL_EVENT TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

Suspends execution of the tool until an event specified in aEventList arrives. No parameters means waiting for any event.

Definition at line 55 of file tool_interactive.cpp.

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
OPT< TOOL_EVENT > ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pauses execution of a given tool until one or more events matching aConditions arrives.

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::ScheduleWait().

Referenced by LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_DRAWING_TOOLS::doPlaceComponent(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), and SCH_WIRE_BUS_TOOL::UnfoldBus().

◆ ZoomCenter()

int COMMON_TOOLS::ZoomCenter ( const TOOL_EVENT aEvent)

Definition at line 207 of file common_tools.cpp.

208 {
210 
211  ctls->CenterOnCursor();
212 
213  return 0;
214 }
virtual void CenterOnCursor() const =0
Function CenterOnCursor() Sets the viewport center to the current cursor position and warps the curso...
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41

References KIGFX::VIEW_CONTROLS::CenterOnCursor(), and TOOL_BASE::getViewControls().

Referenced by setTransitions().

◆ ZoomFitScreen()

int COMMON_TOOLS::ZoomFitScreen ( const TOOL_EVENT aEvent)

Definition at line 217 of file common_tools.cpp.

218 {
219  KIGFX::VIEW* view = getView();
220  EDA_DRAW_PANEL_GAL* galCanvas = m_frame->GetGalCanvas();
221  EDA_DRAW_FRAME* frame = getEditFrame<EDA_DRAW_FRAME>();
222 
223  BOX2I bBox = frame->GetDocumentExtents();
224  VECTOR2D scrollbarSize = VECTOR2D( galCanvas->GetSize() - galCanvas->GetClientSize() );
225  VECTOR2D screenSize = view->ToWorld( galCanvas->GetClientSize(), false );
226 
227  if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
228  {
229  bBox = galCanvas->GetDefaultViewBBox();
230  }
231 
232  VECTOR2D vsize = bBox.GetSize();
233  double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
234  fabs( vsize.y / screenSize.y ) );
235 
236  // Reserve a 10% margin around component bounding box.
237  double margin_scale_factor = 1.1;
238 
239  // Leave 20% for library editors & viewers
241  || frame->IsType( FRAME_SCH_VIEWER ) || frame->IsType( FRAME_SCH_VIEWER_MODAL )
242  || frame->IsType( FRAME_SCH_LIB_EDITOR ) || frame->IsType( FRAME_PCB_MODULE_EDITOR ) )
243  {
244  margin_scale_factor = 1.2;
245  }
246 
247  view->SetScale( scale / margin_scale_factor );
248  view->SetCenter( bBox.Centre() );
249 
250  // Take scrollbars into account
251  VECTOR2D worldScrollbarSize = view->ToWorld( scrollbarSize, false );
252  view->SetCenter( view->GetCenter() + worldScrollbarSize / 2.0 );
253 
254  return 0;
255 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Function ToWorld() Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:475
const VECTOR2D & GetCenter() const
Function GetCenter() Returns the center point of this VIEW (in world space coordinates)
Definition: view.h:339
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:931
The base class for create windows for drawing purpose.
Definition: draw_frame.h:82
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:250
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:601
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
coord_type GetWidth() const
Definition: box2.h:195
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
const int scale
bool IsType(FRAME_T aType) const
Vec Centre() const
Definition: box2.h:77
#define max(a, b)
Definition: auxiliary.h:86
coord_type GetHeight() const
Definition: box2.h:196
const Vec & GetSize() const
Definition: box2.h:187
Class VIEW.
Definition: view.h:61
double GetScale() const
Function GetScale()
Definition: view.h:268
virtual BOX2I GetDefaultViewBBox() const
Returns the bounding box of the view that should be used if model is not valid For example,...
virtual const BOX2I GetDocumentExtents() const

References BOX2< Vec >::Centre(), FRAME_PCB_MODULE_EDITOR, FRAME_PCB_MODULE_VIEWER, FRAME_PCB_MODULE_VIEWER_MODAL, FRAME_SCH_LIB_EDITOR, FRAME_SCH_VIEWER, FRAME_SCH_VIEWER_MODAL, KIGFX::VIEW::GetCenter(), EDA_DRAW_PANEL_GAL::GetDefaultViewBBox(), EDA_DRAW_FRAME::GetDocumentExtents(), EDA_DRAW_FRAME::GetGalCanvas(), BOX2< Vec >::GetHeight(), KIGFX::VIEW::GetScale(), BOX2< Vec >::GetSize(), TOOL_BASE::getView(), BOX2< Vec >::GetWidth(), EDA_BASE_FRAME::IsType(), m_frame, max, scale, KIGFX::VIEW::SetCenter(), KIGFX::VIEW::SetScale(), KIGFX::VIEW::ToWorld(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by doZoomToPreset(), and setTransitions().

◆ ZoomInOut()

int COMMON_TOOLS::ZoomInOut ( const TOOL_EVENT aEvent)

Definition at line 152 of file common_tools.cpp.

153 {
154  bool direction = aEvent.IsAction( &ACTIONS::zoomIn );
155  return doZoomInOut( direction, true );
156 }
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:54
int doZoomInOut(bool aDirection, bool aCenterOnCursor)
static TOOL_ACTION zoomIn
Definition: actions.h:58

References doZoomInOut(), TOOL_EVENT::IsAction(), and ACTIONS::zoomIn.

Referenced by setTransitions().

◆ ZoomInOutCenter()

int COMMON_TOOLS::ZoomInOutCenter ( const TOOL_EVENT aEvent)

Definition at line 159 of file common_tools.cpp.

160 {
161  bool direction = aEvent.IsAction( &ACTIONS::zoomInCenter );
162  return doZoomInOut( direction, false );
163 }
static TOOL_ACTION zoomInCenter
Definition: actions.h:60
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:54
int doZoomInOut(bool aDirection, bool aCenterOnCursor)

References doZoomInOut(), TOOL_EVENT::IsAction(), and ACTIONS::zoomInCenter.

Referenced by setTransitions().

◆ ZoomPreset()

int COMMON_TOOLS::ZoomPreset ( const TOOL_EVENT aEvent)

Definition at line 277 of file common_tools.cpp.

278 {
279  unsigned int idx = aEvent.Parameter<intptr_t>();
280  return doZoomToPreset( idx, false );
281 }
int doZoomToPreset(int idx, bool aCenterOnCursor)
Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378

References doZoomToPreset(), and TOOL_EVENT::Parameter().

Referenced by setTransitions().

◆ ZoomRedraw()

int COMMON_TOOLS::ZoomRedraw ( const TOOL_EVENT aEvent)

Definition at line 145 of file common_tools.cpp.

146 {
147  m_frame->HardRedraw();
148  return 0;
149 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
virtual void HardRedraw()
Rebuild the GAL and redraws the screen.

References EDA_DRAW_FRAME::HardRedraw(), and m_frame.

Referenced by setTransitions().

Member Data Documentation

◆ m_frame

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

Definition at line 211 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::GetId(), and TOOL_BASE::IsToolActive().

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 216 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemToSel(), SCH_DRAWING_TOOLS::AddJunction(), SCH_DRAWING_TOOLS::AddLabel(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDITOR_CONTROL::ClearHighlight(), PCB_EDITOR_CONTROL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), SCH_EDITOR_CONTROL::Cut(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), SCH_WIRE_BUS_TOOL::DrawBusses(), DRAWING_TOOL::DrawDimension(), SCH_WIRE_BUS_TOOL::DrawLines(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_WIRE_BUS_TOOL::DrawWires(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), SCH_EDITOR_CONTROL::EnterSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), SCH_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), EE_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), SELECTION_TOOL::RequestSelection(), CVPCB_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), EE_SELECTION_TOOL::SelectConnection(), SELECTION_TOOL::selectCopper(), PCB_TOOL_BASE::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), EE_SELECTION_TOOL::SelectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SCH_WIRE_BUS_TOOL::StartBus(), SCH_WIRE_BUS_TOOL::StartLine(), SCH_WIRE_BUS_TOOL::StartWire(), GERBVIEW_SELECTION_TOOL::toggleSelection(), EE_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), SCH_EDITOR_CONTROL::Undo(), SCH_WIRE_BUS_TOOL::UnfoldBus(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName (eg. pcbnew.InteractiveSelection).

Definition at line 215 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 217 of file tool_base.h.

Referenced by TOOL_BASE::attachManager(), and TOOL_BASE::GetSettings().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 208 of file tool_base.h.

Referenced by TOOL_BASE::GetType().


The documentation for this class was generated from the following files: