KiCad PCB EDA Suite
common_tools.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014-2016 CERN
5  * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <base_screen.h>
27 #include <base_units.h>
28 #include <bitmaps.h>
29 #include <class_draw_panel_gal.h>
31 #include <eda_draw_frame.h>
33 #include <id.h>
34 #include <kiface_i.h>
35 #include <project.h>
36 #include <settings/app_settings.h>
37 #include <tool/actions.h>
38 #include <tool/common_tools.h>
39 #include <tool/tool_manager.h>
40 #include <view/view.h>
41 #include <view/view_controls.h>
42 
43 
45  TOOL_INTERACTIVE( "common.Control" ),
46  m_frame( nullptr ),
47  m_imperialUnit( EDA_UNITS::INCHES ),
48  m_metricUnit( EDA_UNITS::MILLIMETRES )
49 {
50 }
51 
53 {
54  m_frame = getEditFrame<EDA_DRAW_FRAME>();
55 
57 
58  m_grids.clear();
59 
60  for( const wxString& gridDef : settings.sizes )
61  {
62  int gridSize = (int) ValueFromString( EDA_UNITS::MILLIMETRES, gridDef );
63  m_grids.emplace_back( gridSize, gridSize );
64  }
65 
66  m_grids.emplace_back( ValueFromString( EDA_UNITS::MILLIMETRES, settings.user_grid_x ),
68 
69  OnGridChanged();
70 }
71 
72 
74 {
75  if( EDA_UNIT_UTILS::IsImperialUnit( aUnit ) )
76  m_imperialUnit = aUnit;
77  else if( EDA_UNIT_UTILS::IsMetricUnit( aUnit ) )
78  m_metricUnit = aUnit;
79  else
80  wxASSERT_MSG( false, "Invalid unit" );
81 }
82 
83 
85 {
86  // Since selection tools are run permanently underneath the toolStack, this is really
87  // just a cancel of whatever other tools might be running.
88 
90  return 0;
91 }
92 
93 
94 // Cursor control
96 {
97  long type = aEvent.Parameter<intptr_t>();
98  bool fastMove = type & ACTIONS::CURSOR_FAST_MOVE;
99  type &= ~ACTIONS::CURSOR_FAST_MOVE;
100  bool mirroredX = getView()->IsMirroredX();
101 
102  VECTOR2D cursor = getViewControls()->GetRawCursorPosition( false );
103  VECTOR2D gridSize = getView()->GetGAL()->GetGridSize();
104 
105  if( fastMove )
106  gridSize = gridSize * 10;
107 
108  switch( type )
109  {
110  case ACTIONS::CURSOR_UP:
111  cursor -= VECTOR2D( 0, gridSize.y );
112  break;
113 
115  cursor += VECTOR2D( 0, gridSize.y );
116  break;
117 
119  cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
120  break;
121 
123  cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
124  break;
125 
126  case ACTIONS::CURSOR_CLICK: // fall through
129  {
130  TOOL_ACTIONS action = TA_MOUSE_CLICK;
131  TOOL_MOUSE_BUTTONS button = BUT_LEFT;
132  int modifiers = 0;
133 
134  modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
135  modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
136  modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
137 
138  if( type == ACTIONS::CURSOR_DBL_CLICK )
139  action = TA_MOUSE_DBLCLICK;
140 
141  if( type == ACTIONS::CURSOR_RIGHT_CLICK )
142  button = BUT_RIGHT;
143 
144  TOOL_EVENT evt( TC_MOUSE, action, button | modifiers );
145  evt.SetMousePosition( getViewControls()->GetCursorPosition() );
146  m_toolMgr->ProcessEvent( evt );
147 
148  return 0;
149  }
150  default:
151  wxFAIL_MSG( "CursorControl(): unexpected request" );
152  }
153 
154  getViewControls()->SetCursorPosition( cursor, true, true, type );
156 
157  return 0;
158 }
159 
160 
162 {
163  long type = aEvent.Parameter<intptr_t>();
164  KIGFX::VIEW* view = getView();
165  VECTOR2D center = view->GetCenter();
166  VECTOR2D gridSize = getView()->GetGAL()->GetGridSize() * 10;
167  bool mirroredX = view->IsMirroredX();
168 
169  switch( type )
170  {
171  case ACTIONS::CURSOR_UP:
172  center -= VECTOR2D( 0, gridSize.y );
173  break;
174 
176  center += VECTOR2D( 0, gridSize.y );
177  break;
178 
180  center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
181  break;
182 
184  center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
185  break;
186 
187  default:
188  wxFAIL;
189  break;
190  }
191 
192  view->SetCenter( center );
193 
194  return 0;
195 }
196 
197 
199 {
200  m_frame->HardRedraw();
201  return 0;
202 }
203 
204 
206 {
207  bool direction = aEvent.IsAction( &ACTIONS::zoomIn );
208  return doZoomInOut( direction, true );
209 }
210 
211 
213 {
214  bool direction = aEvent.IsAction( &ACTIONS::zoomInCenter );
215  return doZoomInOut( direction, false );
216 }
217 
218 
219 int COMMON_TOOLS::doZoomInOut( bool aDirection, bool aCenterOnCursor )
220 {
221  double zoom = getView()->GetGAL()->GetZoomFactor() / ZOOM_COEFF;
222 
223  // Step must be AT LEAST 1.3
224  if( aDirection )
225  zoom *= 1.3;
226  else
227  zoom /= 1.3;
228 
229  // Now look for the next closest menu step
230  std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
231  int idx;
232 
233  if( aDirection )
234  {
235  for( idx = 0; idx < int( zoomList.size() ); ++idx )
236  {
237  if( zoomList[idx] >= zoom )
238  break;
239  }
240 
241  if( idx >= int( zoomList.size() ) )
242  idx = (int) zoomList.size() - 1; // if we ran off the end then peg to the end
243  }
244  else
245  {
246  for( idx = int( zoomList.size() ) - 1; idx >= 0; --idx )
247  {
248  if( zoomList[idx] <= zoom )
249  break;
250  }
251 
252  if( idx < 0 )
253  idx = 0; // if we ran off the end then peg to the end
254  }
255 
256  return doZoomToPreset( idx + 1, aCenterOnCursor );
257 }
258 
259 
261 {
263 
264  ctls->CenterOnCursor();
265 
266  return 0;
267 }
268 
269 
271 {
272  return doZoomFit( ZOOM_FIT_ALL );
273 }
274 
275 
277 {
278  return doZoomFit( ZOOM_FIT_OBJECTS );
279 }
280 
281 
283 {
284  KIGFX::VIEW* view = getView();
285  EDA_DRAW_PANEL_GAL* canvas = m_frame->GetCanvas();
286  EDA_DRAW_FRAME* frame = getEditFrame<EDA_DRAW_FRAME>();
287 
288  BOX2I bBox = frame->GetDocumentExtents();
289  BOX2I defaultBox = canvas->GetDefaultViewBBox();
290 
291  view->SetScale( 1.0 ); // The best scale will be determined later, but this initial
292  // value ensures all view parameters are up to date (especially
293  // at init time)
294  VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
295 
296  // Currently "Zoom to Objects" is only supported in Eeschema & Pcbnew. Support for other
297  // programs in the suite can be added as needed.
298 
299  if( aFitType == ZOOM_FIT_OBJECTS )
300  {
301  if( frame->IsType( FRAME_SCH ) || frame->IsType( FRAME_PCB_EDITOR ) )
302  {
303  bBox = m_frame->GetDocumentExtents( false );
304  }
305  else
306  aFitType = ZOOM_FIT_ALL; // Just do a "Zoom to Fit" for unsupported editors
307  }
308 
309  // If the screen is empty then use the default view bbox
310 
311  if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
312  bBox = defaultBox;
313 
314  VECTOR2D vsize = bBox.GetSize();
315  double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
316  fabs( vsize.y / screenSize.y ) );
317 
318  // if the scale isn't finite (most likely due to an empty canvas)
319  // simply just make sure we are centered and quit out of trying to zoom to fit
320  if( !std::isfinite( scale ) )
321  {
322  view->SetCenter( VECTOR2D( 0, 0 ) );
323  return 0;
324  }
325 
326  // Reserve a 2% margin around bounding boxes.
327  double margin_scale_factor = 1.02;
328 
329  switch( aFitType )
330  {
331  case ZOOM_FIT_ALL:
332  // Leave a bigger margin for library editors & viewers
333 
335  || frame->IsType( FRAME_SCH_VIEWER ) || frame->IsType( FRAME_SCH_VIEWER_MODAL ) )
336  {
337  margin_scale_factor = 1.4;
338  }
339  else if( frame->IsType( FRAME_SCH_LIB_EDITOR ) || frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
340  {
341  margin_scale_factor = 2;
342  }
343  break;
344 
345  // Currently the same value as "ZOOM_FIT_ALL" but allows easy expansion/change in the future.
346  case ZOOM_FIT_OBJECTS:
347  margin_scale_factor = 1.02; // Reserve a 2% margin around bounding box.
348  break;
349 
350  default:
351  margin_scale_factor = 1.02;
352  }
353 
354  view->SetScale( scale / margin_scale_factor );
355  view->SetCenter( bBox.Centre() );
356 
357  return 0;
358 }
359 
360 
362 {
363  EDA_DRAW_PANEL_GAL* canvas = m_frame->GetCanvas();
364  BOX2I bBox = getModel<EDA_ITEM>()->ViewBBox();
365 
366  if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
367  bBox = canvas->GetDefaultViewBBox();
368 
369  getView()->SetCenter( bBox.Centre() );
370 
371  // Take scrollbars into account
372  VECTOR2D scrollbarSize = VECTOR2D( canvas->GetSize() - canvas->GetClientSize() );
373  VECTOR2D worldScrollbarSize = getView()->ToWorld( scrollbarSize, false );
374  getView()->SetCenter( getView()->GetCenter() + worldScrollbarSize / 2.0 );
375 
376  return 0;
377 }
378 
379 
381 {
382  unsigned int idx = aEvent.Parameter<intptr_t>();
383  return doZoomToPreset( (int) idx, false );
384 }
385 
386 
387 // Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
388 int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
389 {
390  std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
391 
392  if( idx == 0 ) // Zoom Auto
393  {
395  return ZoomFitScreen( dummy );
396  }
397  else
398  {
399  idx--;
400  }
401 
402  double scale = zoomList[idx] * ZOOM_COEFF;
403 
404  if( aCenterOnCursor )
405  {
406  getView()->SetScale( scale, getViewControls()->GetCursorPosition() );
407 
408  if( getViewControls()->IsCursorWarpingEnabled() )
410  }
411  else
412  {
413  getView()->SetScale( scale );
414  }
415 
416  return 0;
417 }
418 
419 
420 // Grid control
421 int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent )
422 {
423  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
424 
425  if( currentGrid + 1 < int( m_grids.size() ) )
426  currentGrid++;
427 
428  return OnGridChanged();
429 }
430 
431 
432 int COMMON_TOOLS::GridPrev( const TOOL_EVENT& aEvent )
433 {
434  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
435 
436  if( currentGrid > 0 )
437  currentGrid--;
438 
439  return OnGridChanged();
440 }
441 
442 
444 {
445  return GridPreset( aEvent.Parameter<intptr_t>() );
446 }
447 
448 
450 {
451  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
452 
453  currentGrid = std::max( 0, std::min( idx, (int) m_grids.size() - 1 ) );
454 
455  return OnGridChanged();
456 }
457 
458 
460 {
461  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
462 
463  currentGrid = std::max( 0, std::min( currentGrid, static_cast<int>( m_grids.size() ) - 1 ) );
464 
465  // Update the combobox (if any)
466  wxUpdateUIEvent dummy;
468 
469  // Update GAL canvas from screen
470  getView()->GetGAL()->SetGridSize( m_grids[ currentGrid ] );
473 
474  // Put cursor on new grid
475  VECTOR2D gridCursor = getViewControls()->GetCursorPosition( true );
476  getViewControls()->SetCrossHairCursorPosition( gridCursor, false );
477 
478  return 0;
479 }
480 
481 
483 {
485 }
486 
487 
489 {
491 }
492 
493 
495 {
497 
498  return 0;
499 }
500 
501 
503 {
504  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
505 
506  cmd.SetId( ID_GRID_SETTINGS );
507  m_frame->ProcessEvent( cmd );
508 
509  return 0;
510 }
511 
512 
514 {
515  EDA_UNITS newUnit = aEvent.Parameter<EDA_UNITS>();
516 
517  if( EDA_UNIT_UTILS::IsMetricUnit( newUnit ) )
518  m_metricUnit = newUnit;
519  else if( EDA_UNIT_UTILS::IsImperialUnit( newUnit ) )
520  m_imperialUnit = newUnit;
521  else
522  wxASSERT_MSG( false, "Invalid unit for the frame" );
523 
524  m_frame->ChangeUserUnits( newUnit );
525  return 0;
526 }
527 
528 
530 {
532  m_metricUnit :
533  m_imperialUnit );
534  return 0;
535 }
536 
537 
539 {
540  m_frame->SetStatusText( wxEmptyString );
543 
544  return 0;
545 }
546 
547 
549 {
550  auto vcSettings = m_toolMgr->GetCurrentToolVC();
551 
552  // Use either the active tool forced cursor position or the general settings
553  if( vcSettings.m_forceCursorPosition )
554  m_frame->GetScreen()->m_LocalOrigin = vcSettings.m_forcedPosition;
555  else
557 
559 
560  return 0;
561 }
562 
563 
565 {
566  auto& galOpts = m_frame->GetGalDisplayOptions();
567 
568  galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor;
569  galOpts.NotifyChanged();
570 
571  return 0;
572 }
573 
574 
576 {
578 
579  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
580  galOpts.NotifyChanged();
581 
582  return 0;
583 }
584 
585 
587 {
588  if( aEvent.IsAction( &ACTIONS::acceleratedGraphics ) )
590 #ifndef __WXMAC__
591  else if( aEvent.IsAction( &ACTIONS::standardGraphics ) )
593 #endif
594  else
595  wxFAIL_MSG( "Unknown canvas type" );
596 
597  return 0;
598 }
599 
600 
602 {
604 
605  // Cursor control
614 
618 
619  // Pan control
620  Go( &COMMON_TOOLS::PanControl, ACTIONS::panUp.MakeEvent() );
624 
625  // Zoom control
627  Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomIn.MakeEvent() );
636 
637  // Grid control
645 
646  // Units and coordinates
653 
654  // Misc
659 }
660 
661 
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:106
int ZoomFitScreen(const TOOL_EVENT &aEvent)
int GridFast1(const TOOL_EVENT &aEvent)
wxString user_grid_y
Definition: app_settings.h:54
static TOOL_ACTION zoomPreset
Definition: actions.h:96
static TOOL_ACTION zoomInCenter
Definition: actions.h:91
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
wxString user_grid_x
Definition: app_settings.h:53
Implementation of conversion functions that require both schematic and board internal units.
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:456
VIEW_CONTROLS class definition.
#define ZOOM_COEFF
int ToggleCursorStyle(const TOOL_EVENT &aEvent)
TOOL_ACTIONS
Definition: tool_event.h:61
void SetShowPolarCoords(bool aShow)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetLastUnits(EDA_UNITS aUnit)
static TOOL_ACTION cursorRight
Definition: actions.h:114
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
static TOOL_ACTION millimetersUnits
Definition: actions.h:144
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
static TOOL_ACTION standardGraphics
Definition: actions.h:164
static TOOL_ACTION cursorRightFast
Definition: actions.h:119
static TOOL_ACTION gridFast1
Definition: actions.h:131
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:182
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Moves cursor to the requested position expressed in world coordinates.
int GridPreset(const TOOL_EVENT &aEvent)
void ChangeUserUnits(EDA_UNITS aUnits)
static TOOL_ACTION zoomFitObjects
Definition: actions.h:95
static TOOL_ACTION panLeft
Definition: actions.h:127
bool m_forceDisplayCursor
Force cursor display
int ResetLocalCoords(const TOOL_EVENT &aEvent)
The base class for create windows for drawing purpose.
void SetMousePosition(const VECTOR2D &aP)
Definition: tool_event.h:468
int doZoomToPreset(int idx, bool aCenterOnCursor)
Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int SwitchUnits(const TOOL_EVENT &aEvent)
std::vector< double > zoom_factors
Definition: app_settings.h:86
bool IsImperialUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:26
static TOOL_ACTION zoomOutCenter
Definition: actions.h:92
Auxiliary rendering target (noncached)
Definition: definitions.h:49
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:67
int GridNext(const TOOL_EVENT &aEvent)
int GridFast2(const TOOL_EVENT &aEvent)
int ToggleUnits(const TOOL_EVENT &aEvent)
int ZoomInOutCenter(const TOOL_EVENT &aEvent)
virtual void CenterOnCursor() const =0
Function CenterOnCursor() Sets the viewport center to the current cursor position and warps the curso...
static TOOL_ACTION centerContents
Definition: actions.h:98
static TOOL_ACTION gridFast2
Definition: actions.h:132
std::vector< wxString > sizes
Definition: app_settings.h:52
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:585
static TOOL_ACTION toggleCursor
Definition: actions.h:99
static TOOL_ACTION gridPreset
Definition: actions.h:137
bool IsMetricUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:42
static TOOL_ACTION gridPrev
Definition: actions.h:134
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
static TOOL_ACTION panDown
Definition: actions.h:126
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:444
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:571
int GridPrev(const TOOL_EVENT &aEvent)
bool IsGridVisible() const
static TOOL_ACTION toggleGrid
Definition: actions.h:138
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
GRID_SETTINGS grid
Definition: app_settings.h:89
int doZoomInOut(bool aDirection, bool aCenterOnCursor)
void OnUpdateSelectGrid(wxUpdateUIEvent &aEvent)
Update the checked item in the grid combobox.
static TOOL_ACTION inchesUnits
Definition: actions.h:142
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
coord_type GetWidth() const
Definition: box2.h:197
TOOL_EVENT.
Definition: tool_event.h:171
static TOOL_ACTION cursorUpFast
Definition: actions.h:116
static TOOL_ACTION cursorDownFast
Definition: actions.h:117
static TOOL_ACTION cursorLeft
Definition: actions.h:113
static TOOL_ACTION panRight
Definition: actions.h:128
int ZoomCenter(const TOOL_EVENT &aEvent)
const KIGFX::VC_SETTINGS & GetCurrentToolVC() const
Returns the view controls settings for the current tool or the general settings if there is no active...
static TOOL_ACTION togglePolarCoords
Definition: actions.h:147
int ToggleGrid(const TOOL_EVENT &aEvent)
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
int ZoomInOut(const TOOL_EVENT &aEvent)
double GetZoomFactor() const
Get the zoom factor.
EDA_UNITS m_imperialUnit
Definition: common_tools.h:119
static TOOL_ACTION cursorLeftFast
Definition: actions.h:118
virtual const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const
Returns bbox of document with option to not include some items.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves the graphic crosshair cursor to the requested position expressed in world coordinates.
int CursorControl(const TOOL_EVENT &aEvent)
int ToggleCursor(const TOOL_EVENT &aEvent)
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
int SwitchCanvas(const TOOL_EVENT &aEvent)
static TOOL_ACTION milsUnits
Definition: actions.h:143
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual void HardRedraw()
Rebuild the GAL and redraws the screen.
void setTransitions() override
Sets up handlers for various events.
bool IsMirroredX() const
Function IsMirroredX() Returns true if view is flipped across the X axis.
Definition: view.h:232
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Function SetScale() Sets the scaling factor, zooming around a given anchor point.
Definition: view.cpp:559
TOOL_MOUSE_BUTTONS
Definition: tool_event.h:124
EDA_UNITS
Definition: eda_units.h:38
const VECTOR2D & GetGridSize() const
Returns the grid size.
int CenterContents(const TOOL_EVENT &aEvent)
int SelectionTool(const TOOL_EVENT &aEvent)
std::vector< VECTOR2I > m_grids
Definition: common_tools.h:115
WINDOW_SETTINGS m_Window
Definition: app_settings.h:173
const int scale
virtual VECTOR2D GetRawCursorPosition(bool aSnappingEnabled=true) const =0
Returns the current cursor position in world coordinates - ingoring the cursorUp position force mode.
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
bool IsType(FRAME_T aType) const
Vec Centre() const
Definition: box2.h:79
static TOOL_ACTION zoomCenter
Definition: actions.h:93
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
ZOOM_FIT_TYPE_T
Enum ZOOM_FIT_TYPE_T is the set of "Zoom to Fit" types that can be performed.
Definition: common_tools.h:96
static TOOL_ACTION cursorUp
Cursor control with keyboard.
Definition: actions.h:111
static TOOL_ACTION zoomRedraw
Definition: actions.h:88
static TOOL_ACTION cursorDblClick
Definition: actions.h:122
int ZoomPreset(const TOOL_EVENT &aEvent)
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:163
static TOOL_ACTION resetLocalCoords
Definition: actions.h:148
coord_type GetHeight() const
Definition: box2.h:198
int ZoomFitObjects(const TOOL_EVENT &aEvent)
static TOOL_ACTION gridNext
Definition: actions.h:133
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
EDA_UNITS m_metricUnit
Definition: common_tools.h:120
static TOOL_ACTION gridProperties
Definition: actions.h:139
ACTIONS.
Definition: actions.h:43
static TOOL_ACTION panUp
Definition: actions.h:125
static TOOL_ACTION zoomIn
Definition: actions.h:89
static TOOL_ACTION zoomOut
Definition: actions.h:90
int TogglePolarCoords(const TOOL_EVENT &aEvent)
const Vec & GetSize() const
Definition: box2.h:189
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:100
void UpdateStatusBar() override
Update the status bar information.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VIEW.
Definition: view.h:63
double GetScale() const
Function GetScale()
Definition: view.h:259
BASE_SCREEN class implementation.
static TOOL_ACTION showContextMenu
Definition: actions.h:66
static TOOL_ACTION cursorDown
Definition: actions.h:112
int PanControl(const TOOL_EVENT &aEvent)
int ZoomRedraw(const TOOL_EVENT &aEvent)
virtual BOX2I GetDefaultViewBBox() const
Returns the bounding box of the view that should be used if model is not valid For example,...
static TOOL_ACTION toggleUnits
Definition: actions.h:146
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool m_fullscreenCursor
Fullscreen crosshair or small cross
virtual void SetGridVisibility(bool aVisible)
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
int GridProperties(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectionTool
Definition: actions.h:151
APP_SETTINGS_BASE * GetSettings() const
Definition: tool_manager.h:299
static TOOL_ACTION refreshPreview
Definition: actions.h:104
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:121
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:89
Common grid settings, available to every frame.
Definition: app_settings.h:49
int doZoomFit(ZOOM_FIT_TYPE_T aFitType)