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 ()
 
 ~COMMON_TOOLS ()
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
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 GridNext (const TOOL_EVENT &aEvent)
 
int GridPrev (const TOOL_EVENT &aEvent)
 
int GridPreset (const TOOL_EVENT &aEvent)
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 
void Activate ()
 Function Activate() Runs the tool. More...
 
void SetContextMenu (CONTEXT_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...
 
void updateGrid ()
 

Applies the legacy canvas grid settings for GAL.

More...
 

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

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 ( )

Definition at line 44 of file common_tools.cpp.

44  :
45  TOOL_INTERACTIVE( "common.Control" ), m_frame( NULL )
46 {
47 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:72
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Constructor.
COMMON_TOOLS::~COMMON_TOOLS ( )

Definition at line 50 of file common_tools.cpp.

51 {
52 }

Member Function Documentation

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.

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

Referenced by AUTOPLACE_TOOL::autoplace(), PCBNEW_CONTROL::DeleteItemCursor(), EDIT_TOOL::doCopyToClipboard(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), 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(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
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.

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

Referenced by TOOL_MANAGER::RegisterTool().

60 {
61  m_toolMgr = aManager;
62  m_toolSettings = TOOL_SETTINGS( this );
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
friend class TOOL_SETTINGS
Definition: tool_base.h:155
int COMMON_TOOLS::CenterContents ( const TOOL_EVENT aEvent)

Definition at line 269 of file common_tools.cpp.

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().

270 {
271  EDA_DRAW_PANEL_GAL* galCanvas = m_frame->GetGalCanvas();
272  BOX2I bBox = getModel<EDA_ITEM>()->ViewBBox();
273 
274  if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
275  bBox = galCanvas->GetDefaultViewBBox();
276 
277  getView()->SetCenter( bBox.Centre() );
278 
279  // Take scrollbars into account
280  VECTOR2D scrollbarSize = VECTOR2D( galCanvas->GetSize() - galCanvas->GetClientSize() );
281  VECTOR2D worldScrollbarSize = getView()->ToWorld( scrollbarSize, false );
282  getView()->SetCenter( getView()->GetCenter() + worldScrollbarSize / 2.0 );
283 
284  return 0;
285 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:72
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:464
coord_type GetWidth() const
Definition: box2.h:195
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:590
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual BOX2I GetDefaultViewBBox() const
Returns the bounding box of the view that should be used if model is not valid For example...
Vec Centre() const
Definition: box2.h:77
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
coord_type GetHeight() const
Definition: box2.h:196
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:918
int COMMON_TOOLS::CursorControl ( const TOOL_EVENT aEvent)

Definition at line 62 of file common_tools.cpp.

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().

63 {
64  long type = aEvent.Parameter<intptr_t>();
65  bool fastMove = type & ACTIONS::CURSOR_FAST_MOVE;
66  type &= ~ACTIONS::CURSOR_FAST_MOVE;
67  bool mirroredX = getView()->IsMirroredX();
68 
69  VECTOR2D cursor = getViewControls()->GetRawCursorPosition( false );
70  VECTOR2I gridSize = VECTOR2D( m_frame->GetScreen()->GetGridSize() );
71 
72  if( fastMove )
73  gridSize = gridSize * 10;
74 
75  switch( type )
76  {
77  case ACTIONS::CURSOR_UP:
78  cursor -= VECTOR2D( 0, gridSize.y );
79  break;
80 
82  cursor += VECTOR2D( 0, gridSize.y );
83  break;
84 
86  cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
87  break;
88 
90  cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
91  break;
92 
93  case ACTIONS::CURSOR_CLICK: // fall through
95  {
96  TOOL_ACTIONS action = TA_NONE;
97  int modifiers = 0;
98 
99  modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
100  modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
101  modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
102 
103  if( type == ACTIONS::CURSOR_CLICK )
104  action = TA_MOUSE_CLICK;
105  else if( type == ACTIONS::CURSOR_DBL_CLICK )
106  action = TA_MOUSE_DBLCLICK;
107  else
108  wxFAIL;
109 
110  TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers );
111  evt.SetMousePosition( getViewControls()->GetCursorPosition() );
112  m_toolMgr->ProcessEvent( evt );
113 
114  return 0;
115  }
116  break;
117  }
118 
119  getViewControls()->SetCursorPosition( cursor );
120 
121  return 0;
122 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:72
bool IsMirroredX() const
Function IsMirroredX() Returns true if view is flipped across the X axis.
Definition: view.h:230
TOOL_ACTIONS
Definition: tool_event.h:61
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves cursor to the requested position expressed in world coordinates.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:397
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).
Class TOOL_EVENT.
Definition: tool_event.h:168
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:387
virtual VECTOR2D GetRawCursorPosition(bool aSnappingEnabled=true) const =0
Returns the current cursor position in world coordinates - ingoring the cursorUp position force mode...
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
Class ACTIONS.
Definition: actions.h:41
int COMMON_TOOLS::doZoomInOut ( bool  aDirection,
bool  aCenterOnCursor 
)
private

Definition at line 176 of file common_tools.cpp.

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().

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

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

Definition at line 296 of file common_tools.cpp.

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().

297 {
298  std::vector<double>& zoomList = m_frame->GetScreen()->m_ZoomList;
299  KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
300 
301  if( idx == 0 ) // Zoom Auto
302  {
304  return ZoomFitScreen( dummy );
305  }
306  else
307  {
308  idx--;
309  }
310 
311  double scale = m_frame->GetZoomLevelCoeff() / zoomList[idx];
312 
313  if( aCenterOnCursor )
314  {
315  view->SetScale( scale, getViewControls()->GetCursorPosition() );
316 
317  if( getViewControls()->IsCursorWarpingEnabled() )
319  }
320  else
321  {
322  view->SetScale( scale );
323  }
324 
325  return 0;
326 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:72
int ZoomFitScreen(const TOOL_EVENT &aEvent)
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:250
double GetZoomLevelCoeff() const
Return the coefficient to convert internal display scale factor to zoom level.
Definition: draw_frame.h:464
virtual void CenterOnCursor() const =0
Function CenterOnCursor() Sets the viewport center to the current cursor position and warps the curso...
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:397
Class TOOL_EVENT.
Definition: tool_event.h:168
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
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...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:918
Class VIEW.
Definition: view.h:61
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:219
const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited
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.

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

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47
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.

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

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:210
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.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL::doInteractiveItemPlacement(), CONTEXT_MENU::getToolManager(), CONTEXT_MENU::onMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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.

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

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

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

134  {
135  return m_toolName;
136  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:214
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

Referenced by GERBVIEW_CONTROL::HighlightControl(), ROUTER_TOOL::Init(), and ROUTER_TOOL::~ROUTER_TOOL().

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
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.

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

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:207
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.

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

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), CenterContents(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), DRAWING_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), POINT_EDITOR::updateEditedPoint(), updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), CVPCB_SELECTION_TOOL::~CVPCB_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

36 {
37  return m_toolMgr->GetView();
38 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
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.

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

Referenced by POINT_EDITOR::addCorner(), CursorControl(), doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), 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(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), 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(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PICKER_TOOL::setControls(), POINT_EDITOR::setEditedPoint(), EDIT_TOOL::updateModificationPoint(), and ZoomCenter().

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257
template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited
int COMMON_TOOLS::GridNext ( const TOOL_EVENT aEvent)

Definition at line 330 of file common_tools.cpp.

References m_frame, EDA_DRAW_FRAME::SetNextGrid(), and updateGrid().

Referenced by setTransitions().

331 {
332  m_frame->SetNextGrid();
333  updateGrid();
334 
335  return 0;
336 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:72
void updateGrid()
Applies the legacy canvas grid settings for GAL.
virtual void SetNextGrid()
Change the grid size settings to the next one available.
int COMMON_TOOLS::GridPreset ( const TOOL_EVENT aEvent)

Definition at line 348 of file common_tools.cpp.

References m_frame, TOOL_EVENT::Parameter(), EDA_DRAW_FRAME::SetPresetGrid(), and updateGrid().

Referenced by setTransitions().

349 {
350  long idx = aEvent.Parameter<intptr_t>();
351 
352  m_frame->SetPresetGrid( idx );
353  updateGrid();
354 
355  return 0;
356 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:72
void updateGrid()
Applies the legacy canvas grid settings for GAL.
void SetPresetGrid(int aIndex)
Change the grid size to one of the preset values.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:387
int COMMON_TOOLS::GridPrev ( const TOOL_EVENT aEvent)

Definition at line 339 of file common_tools.cpp.

References m_frame, EDA_DRAW_FRAME::SetPrevGrid(), and updateGrid().

Referenced by setTransitions().

340 {
341  m_frame->SetPrevGrid();
342  updateGrid();
343 
344  return 0;
345 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:72
void updateGrid()
Applies the legacy canvas grid settings for GAL.
virtual void SetPrevGrid()
Change the grid size settings to the previous one available.
virtual bool TOOL_BASE::Init ( )
inlinevirtualinherited

Function Init() Init() is called once upon a registration of the tool.

Returns
True if the initialization went fine, false - otherwise.

Reimplemented in PCB_TOOL, SELECTION_TOOL, EDIT_TOOL, DRAWING_TOOL, GERBVIEW_SELECTION_TOOL, POSITION_RELATIVE_TOOL, CVPCB_SELECTION_TOOL, PCB_EDITOR_CONTROL, POINT_EDITOR, PAD_TOOL, ALIGN_DISTRIBUTE_TOOL, and ROUTER_TOOL.

Definition at line 93 of file tool_base.h.

Referenced by TOOL_MANAGER::InitTools().

94  {
95  return true;
96  }
bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

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

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

Definition at line 125 of file common_tools.cpp.

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().

126 {
127  long type = aEvent.Parameter<intptr_t>();
128  KIGFX::VIEW* view = getView();
129  VECTOR2D center = view->GetCenter();
130  VECTOR2I gridSize = VECTOR2D( m_frame->GetScreen()->GetGridSize() ) * 10;
131  bool mirroredX = view->IsMirroredX();
132 
133  switch( type )
134  {
135  case ACTIONS::CURSOR_UP:
136  center -= VECTOR2D( 0, gridSize.y );
137  break;
138 
140  center += VECTOR2D( 0, gridSize.y );
141  break;
142 
144  center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
145  break;
146 
148  center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
149  break;
150 
151  default:
152  wxFAIL;
153  break;
154  }
155 
156  view->SetCenter( center );
157 
158  return 0;
159 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:72
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:397
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:387
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
Class VIEW.
Definition: view.h:61
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 55 of file common_tools.cpp.

References m_frame.

56 {
57  m_frame = getEditFrame<EDA_DRAW_FRAME>();
58 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:72
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.

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

Referenced by DRAWING_TOOL::PlaceText().

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_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.

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

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

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:215
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool&#39;s context popup menu.
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void COMMON_TOOLS::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

Definition at line 370 of file common_tools.cpp.

References ACT_toggleCursor, 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, TOOL_ACTION::MakeEvent(), PanControl(), ACTIONS::panDown, ACTIONS::panLeft, ACTIONS::panRight, ACTIONS::panUp, ToggleCursor(), ZoomCenter(), ACTIONS::zoomCenter, ZoomFitScreen(), ACTIONS::zoomFitScreen, ACTIONS::zoomIn, ACTIONS::zoomInCenter, ZoomInOut(), ZoomInOutCenter(), ACTIONS::zoomOut, ACTIONS::zoomOutCenter, ZoomPreset(), and ACTIONS::zoomPreset.

371 {
372  // Cursor control
381 
384 
385  // Pan control
386  Go( &COMMON_TOOLS::PanControl, ACTIONS::panUp.MakeEvent() );
390 
391  // Zoom control
392  Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomIn.MakeEvent() );
399 
401 
405 
407 }
int ZoomFitScreen(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoomPreset
Definition: actions.h:57
static TOOL_ACTION zoomInCenter
Definition: actions.h:53
static TOOL_ACTION cursorRight
Definition: actions.h:65
static TOOL_ACTION zoomFitScreen
Definition: actions.h:56
static TOOL_ACTION cursorRightFast
Definition: actions.h:70
int GridPreset(const TOOL_EVENT &aEvent)
static TOOL_ACTION panLeft
Definition: actions.h:78
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION zoomOutCenter
Definition: actions.h:54
int GridNext(const TOOL_EVENT &aEvent)
int ZoomInOutCenter(const TOOL_EVENT &aEvent)
static TOOL_ACTION centerContents
Definition: actions.h:59
static TOOL_ACTION gridPreset
Definition: actions.h:88
static TOOL_ACTION gridPrev
Definition: actions.h:85
static TOOL_ACTION panDown
Definition: actions.h:77
int GridPrev(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorUpFast
Definition: actions.h:67
static TOOL_ACTION cursorDownFast
Definition: actions.h:68
static TOOL_ACTION cursorLeft
Definition: actions.h:64
static TOOL_ACTION panRight
Definition: actions.h:79
int ZoomCenter(const TOOL_EVENT &aEvent)
int ZoomInOut(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorLeftFast
Definition: actions.h:69
int CursorControl(const TOOL_EVENT &aEvent)
int ToggleCursor(const TOOL_EVENT &aEvent)
int CenterContents(const TOOL_EVENT &aEvent)
TOOL_EVENT MakeEvent() const
Function HasHotKey() Checks if the action has a hot key assigned.
Definition: tool_action.h:104
static TOOL_ACTION zoomCenter
Definition: actions.h:55
static TOOL_ACTION cursorUp
Cursor control with keyboard.
Definition: actions.h:62
static TOOL_ACTION cursorDblClick
Definition: actions.h:73
int ZoomPreset(const TOOL_EVENT &aEvent)
static TOOL_ACTION gridNext
Definition: actions.h:84
static TOOL_ACTION panUp
Definition: actions.h:76
static TOOL_ACTION zoomIn
Definition: actions.h:51
static TOOL_ACTION zoomOut
Definition: actions.h:52
static TOOL_ACTION cursorDown
Definition: actions.h:63
int PanControl(const TOOL_EVENT &aEvent)
static TOOL_ACTION ACT_toggleCursor("common.Control.toggleCursor", AS_GLOBAL, TOOL_ACTION::LegacyHotKey(HK_TOGGLE_CURSOR), _("Toggle Always Show Cursor"), _("Toggle display of the cursor, even when not in an interactive tool"))
static TOOL_ACTION cursorClick
Definition: actions.h:72
int COMMON_TOOLS::ToggleCursor ( const TOOL_EVENT aEvent)

Definition at line 359 of file common_tools.cpp.

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

Referenced by setTransitions().

360 {
361  auto& galOpts = m_frame->GetGalDisplayOptions();
362 
363  galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor;
364  galOpts.NotifyChanged();
365 
366  return 0;
367 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:72
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
Definition: draw_frame.h:936
bool m_forceDisplayCursor
Force cursor display
void COMMON_TOOLS::updateGrid ( )
private

Applies the legacy canvas grid settings for GAL.

Definition at line 410 of file common_tools.cpp.

References KIGFX::VIEW::GetGAL(), BASE_SCREEN::GetGridSize(), EDA_DRAW_FRAME::GetScreen(), TOOL_BASE::getView(), m_frame, KIGFX::VIEW::MarkTargetDirty(), KIGFX::GAL::SetGridSize(), and KIGFX::TARGET_NONCACHED.

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

411 {
412  BASE_SCREEN* screen = m_frame->GetScreen();
413  getView()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
415 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:72
Auxiliary rendering target (noncached)
Definition: definitions.h:42
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:397
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:180
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:596
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
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
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.

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

Referenced by PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_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(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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.
int COMMON_TOOLS::ZoomCenter ( const TOOL_EVENT aEvent)

Definition at line 217 of file common_tools.cpp.

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

Referenced by setTransitions().

218 {
220 
221  ctls->CenterOnCursor();
222 
223  return 0;
224 }
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
int COMMON_TOOLS::ZoomFitScreen ( const TOOL_EVENT aEvent)

Definition at line 227 of file common_tools.cpp.

References 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::GetGalCanvas(), KIGFX::VIEW::GetScale(), TOOL_BASE::getView(), m_frame, max, scale, KIGFX::VIEW::SetCenter(), KIGFX::VIEW::SetScale(), KIGFX::VIEW::ToWorld(), EDA_ITEM::ViewBBox(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by doZoomToPreset(), and setTransitions().

228 {
229  KIGFX::VIEW* view = getView();
230  EDA_DRAW_PANEL_GAL* galCanvas = m_frame->GetGalCanvas();
231  EDA_ITEM* model = getModel<EDA_ITEM>();
232  EDA_BASE_FRAME* frame = getEditFrame<EDA_BASE_FRAME>();
233 
234  BOX2I bBox = model->ViewBBox();
235  VECTOR2D scrollbarSize = VECTOR2D( galCanvas->GetSize() - galCanvas->GetClientSize() );
236  VECTOR2D screenSize = view->ToWorld( galCanvas->GetClientSize(), false );
237 
238  if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
239  {
240  bBox = galCanvas->GetDefaultViewBBox();
241  }
242 
243  VECTOR2D vsize = bBox.GetSize();
244  double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
245  fabs( vsize.y / screenSize.y ) );
246 
247  // Reserve a 10% margin around component bounding box.
248  double margin_scale_factor = 1.1;
249 
250  // Leave 20% for library editors & viewers
251  if( frame->IsType( FRAME_PCB_MODULE_VIEWER ) || frame->IsType( FRAME_PCB_MODULE_VIEWER_MODAL )
252  || frame->IsType( FRAME_SCH_VIEWER ) || frame->IsType( FRAME_SCH_VIEWER_MODAL )
253  || frame->IsType( FRAME_SCH_LIB_EDITOR ) || frame->IsType( FRAME_PCB_MODULE_EDITOR ) )
254  {
255  margin_scale_factor = 1.2;
256  }
257 
258  view->SetScale( scale / margin_scale_factor );
259  view->SetCenter( bBox.Centre() );
260 
261  // Take scrollbars into account
262  VECTOR2D worldScrollbarSize = view->ToWorld( scrollbarSize, false );
263  view->SetCenter( view->GetCenter() + worldScrollbarSize / 2.0 );
264 
265  return 0;
266 }
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:72
const VECTOR2D & GetCenter() const
Function GetCenter() Returns the center point of this VIEW (in world space coordinates) ...
Definition: view.h:339
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:464
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:590
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual BOX2I GetDefaultViewBBox() const
Returns the bounding box of the view that should be used if model is not valid For example...
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
const int scale
#define max(a, b)
Definition: auxiliary.h:86
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
double GetScale() const
Function GetScale()
Definition: view.h:268
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:918
Class VIEW.
Definition: view.h:61
virtual const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers. ...
int COMMON_TOOLS::ZoomInOut ( const TOOL_EVENT aEvent)

Definition at line 162 of file common_tools.cpp.

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

Referenced by setTransitions().

163 {
164  bool direction = aEvent.IsAction( &ACTIONS::zoomIn );
165  return doZoomInOut( direction, true );
166 }
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:51
int COMMON_TOOLS::ZoomInOutCenter ( const TOOL_EVENT aEvent)

Definition at line 169 of file common_tools.cpp.

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

Referenced by setTransitions().

170 {
171  bool direction = aEvent.IsAction( &ACTIONS::zoomInCenter );
172  return doZoomInOut( direction, false );
173 }
static TOOL_ACTION zoomInCenter
Definition: actions.h:53
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)
int COMMON_TOOLS::ZoomPreset ( const TOOL_EVENT aEvent)

Definition at line 288 of file common_tools.cpp.

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

Referenced by setTransitions().

289 {
290  unsigned int idx = aEvent.Parameter<intptr_t>();
291  return doZoomToPreset( idx, false );
292 }
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:387

Member Data Documentation

EDA_DRAW_FRAME* COMMON_TOOLS::m_frame
private

Pointer to the currently used edit frame.

Definition at line 72 of file common_tools.h.

Referenced by CenterContents(), CursorControl(), doZoomInOut(), doZoomToPreset(), GridNext(), GridPreset(), GridPrev(), PanControl(), Reset(), ToggleCursor(), updateGrid(), and ZoomFitScreen().

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 210 of file tool_base.h.

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), PCB_EDITOR_CONTROL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandSelectedConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), PCBNEW_CONTROL::placeBoardItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), SELECTION_TOOL::RequestSelection(), CVPCB_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), TOOL_INTERACTIVE::resetTransitions(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), ZONE_FILLER_TOOL::SegzoneDeleteFill(), SELECTION_TOOL::selectCopper(), PCB_TOOL::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), GERBVIEW_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

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 214 of file tool_base.h.

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 of file tool_base.h.

Referenced by TOOL_BASE::attachManager().

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 207 of file tool_base.h.


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