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 #include <zoom_defines.h>
43 
44 
46  TOOL_INTERACTIVE( "common.Control" ),
47  m_frame( nullptr ),
48  m_imperialUnit( EDA_UNITS::INCHES ),
49  m_metricUnit( EDA_UNITS::MILLIMETRES )
50 {
51 }
52 
54 {
55  m_frame = getEditFrame<EDA_DRAW_FRAME>();
56 
58 
59  m_grids.clear();
60 
61  for( const wxString& gridDef : settings.sizes )
62  {
63  int gridSize = (int) ValueFromString( EDA_UNITS::MILLIMETRES, gridDef );
64  m_grids.emplace_back( gridSize, gridSize );
65  }
66 
67  m_grids.emplace_back( ValueFromString( EDA_UNITS::MILLIMETRES, settings.user_grid_x ),
69 
70  OnGridChanged();
71 }
72 
73 
75 {
76  if( EDA_UNIT_UTILS::IsImperialUnit( aUnit ) )
77  m_imperialUnit = aUnit;
78  else if( EDA_UNIT_UTILS::IsMetricUnit( aUnit ) )
79  m_metricUnit = aUnit;
80  else
81  wxASSERT_MSG( false, "Invalid unit" );
82 }
83 
84 
86 {
87  // Since selection tools are run permanently underneath the toolStack, this is really
88  // just a cancel of whatever other tools might be running.
89 
91  return 0;
92 }
93 
94 
95 // Cursor control
97 {
98  long type = aEvent.Parameter<intptr_t>();
99  bool fastMove = type & ACTIONS::CURSOR_FAST_MOVE;
100  type &= ~ACTIONS::CURSOR_FAST_MOVE;
101  bool mirroredX = getView()->IsMirroredX();
102 
103  VECTOR2D cursor = getViewControls()->GetRawCursorPosition( false );
104  VECTOR2D gridSize = getView()->GetGAL()->GetGridSize();
105 
106  if( fastMove )
107  gridSize = gridSize * 10;
108 
109  switch( type )
110  {
111  case ACTIONS::CURSOR_UP:
112  cursor -= VECTOR2D( 0, gridSize.y );
113  break;
114 
116  cursor += VECTOR2D( 0, gridSize.y );
117  break;
118 
120  cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
121  break;
122 
124  cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
125  break;
126 
127  case ACTIONS::CURSOR_CLICK: // fall through
130  {
131  TOOL_ACTIONS action = TA_MOUSE_CLICK;
132  TOOL_MOUSE_BUTTONS button = BUT_LEFT;
133  int modifiers = 0;
134 
135  modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
136  modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
137  modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
138 
139  if( type == ACTIONS::CURSOR_DBL_CLICK )
140  action = TA_MOUSE_DBLCLICK;
141 
142  if( type == ACTIONS::CURSOR_RIGHT_CLICK )
143  button = BUT_RIGHT;
144 
145  TOOL_EVENT evt( TC_MOUSE, action, button | modifiers );
146  evt.SetMousePosition( getViewControls()->GetCursorPosition() );
147  m_toolMgr->ProcessEvent( evt );
148 
149  return 0;
150  }
151  default:
152  wxFAIL_MSG( "CursorControl(): unexpected request" );
153  }
154 
155  getViewControls()->SetCursorPosition( cursor, true, true, type );
157 
158  return 0;
159 }
160 
161 
163 {
164  long type = aEvent.Parameter<intptr_t>();
165  KIGFX::VIEW* view = getView();
166  VECTOR2D center = view->GetCenter();
167  VECTOR2D gridSize = getView()->GetGAL()->GetGridSize() * 10;
168  bool mirroredX = view->IsMirroredX();
169 
170  switch( type )
171  {
172  case ACTIONS::CURSOR_UP:
173  center -= VECTOR2D( 0, gridSize.y );
174  break;
175 
177  center += VECTOR2D( 0, gridSize.y );
178  break;
179 
181  center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
182  break;
183 
185  center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
186  break;
187 
188  default:
189  wxFAIL;
190  break;
191  }
192 
193  view->SetCenter( center );
194 
195  return 0;
196 }
197 
198 
200 {
201  m_frame->HardRedraw();
202  return 0;
203 }
204 
205 
207 {
208  bool direction = aEvent.IsAction( &ACTIONS::zoomIn );
209  return doZoomInOut( direction, true );
210 }
211 
212 
214 {
215  bool direction = aEvent.IsAction( &ACTIONS::zoomInCenter );
216  return doZoomInOut( direction, false );
217 }
218 
219 
220 int COMMON_TOOLS::doZoomInOut( bool aDirection, bool aCenterOnCursor )
221 {
222  double zoom = getView()->GetGAL()->GetZoomFactor();
223 
224  // Step must be AT LEAST 1.3
225  if( aDirection )
226  zoom *= 1.3;
227  else
228  zoom /= 1.3;
229 
230  // Now look for the next closest menu step
231  std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
232  int idx;
233 
234  if( aDirection )
235  {
236  for( idx = 0; idx < int( zoomList.size() ); ++idx )
237  {
238  if( zoomList[idx] >= zoom )
239  break;
240  }
241 
242  if( idx >= int( zoomList.size() ) )
243  idx = (int) zoomList.size() - 1; // if we ran off the end then peg to the end
244  }
245  else
246  {
247  for( idx = int( zoomList.size() ) - 1; idx >= 0; --idx )
248  {
249  if( zoomList[idx] <= zoom )
250  break;
251  }
252 
253  if( idx < 0 )
254  idx = 0; // if we ran off the end then peg to the end
255  }
256 
257  // Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
258  return doZoomToPreset( idx + 1, aCenterOnCursor );
259 }
260 
261 
263 {
265 
266  ctls->CenterOnCursor();
267 
268  return 0;
269 }
270 
271 
273 {
274  return doZoomFit( ZOOM_FIT_ALL );
275 }
276 
277 
279 {
280  return doZoomFit( ZOOM_FIT_OBJECTS );
281 }
282 
283 
285 {
286  KIGFX::VIEW* view = getView();
287  EDA_DRAW_PANEL_GAL* canvas = m_frame->GetCanvas();
288  EDA_DRAW_FRAME* frame = getEditFrame<EDA_DRAW_FRAME>();
289 
290  BOX2I bBox = frame->GetDocumentExtents();
291  BOX2I defaultBox = canvas->GetDefaultViewBBox();
292 
293  view->SetScale( 1.0 ); // The best scale will be determined later, but this initial
294  // value ensures all view parameters are up to date (especially
295  // at init time)
296  VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
297 
298  // Currently "Zoom to Objects" is only supported in Eeschema & Pcbnew. Support for other
299  // programs in the suite can be added as needed.
300 
301  if( aFitType == ZOOM_FIT_OBJECTS )
302  {
303  if( frame->IsType( FRAME_SCH ) || frame->IsType( FRAME_PCB_EDITOR ) )
304  bBox = m_frame->GetDocumentExtents( false );
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_SYMBOL_EDITOR )
340  || frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
341  {
342  margin_scale_factor = 2;
343  }
344  break;
345 
346  // Currently the same value as "ZOOM_FIT_ALL" but allows easy expansion/change in the future.
347  case ZOOM_FIT_OBJECTS:
348  margin_scale_factor = 1.02; // Reserve a 2% margin around bounding box.
349  break;
350 
351  default:
352  margin_scale_factor = 1.02;
353  }
354 
355  view->SetScale( scale / margin_scale_factor );
356  view->SetCenter( bBox.Centre() );
357 
358  return 0;
359 }
360 
361 
363 {
364  EDA_DRAW_PANEL_GAL* canvas = m_frame->GetCanvas();
365  BOX2I bBox = getModel<EDA_ITEM>()->ViewBBox();
366 
367  if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
368  bBox = canvas->GetDefaultViewBBox();
369 
370  getView()->SetCenter( bBox.Centre() );
371 
372  // Take scrollbars into account
373  VECTOR2D scrollbarSize = VECTOR2D( canvas->GetSize() - canvas->GetClientSize() );
374  VECTOR2D worldScrollbarSize = getView()->ToWorld( scrollbarSize, false );
375  getView()->SetCenter( getView()->GetCenter() + worldScrollbarSize / 2.0 );
376 
377  return 0;
378 }
379 
380 
382 {
383  unsigned int idx = aEvent.Parameter<intptr_t>();
384  return doZoomToPreset( (int) idx, false );
385 }
386 
387 
388 // Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
389 int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
390 {
391  std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
392 
393  if( idx == 0 ) // Zoom Auto
394  {
396  return ZoomFitScreen( dummy );
397  }
398  else
399  {
400  idx--;
401  }
402 
403  double scale = zoomList[idx];
404 
405  if( aCenterOnCursor )
406  {
407  getView()->SetScale( scale, getViewControls()->GetCursorPosition() );
408 
409  if( getViewControls()->IsCursorWarpingEnabled() )
411  }
412  else
413  {
414  getView()->SetScale( scale );
415  }
416 
417  return 0;
418 }
419 
420 
421 // Grid control
422 int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent )
423 {
424  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
425 
426  if( currentGrid + 1 < int( m_grids.size() ) )
427  currentGrid++;
428 
429  return OnGridChanged();
430 }
431 
432 
433 int COMMON_TOOLS::GridPrev( const TOOL_EVENT& aEvent )
434 {
435  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
436 
437  if( currentGrid > 0 )
438  currentGrid--;
439 
440  return OnGridChanged();
441 }
442 
443 
445 {
446  return GridPreset( aEvent.Parameter<intptr_t>() );
447 }
448 
449 
451 {
452  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
453 
454  currentGrid = std::max( 0, std::min( idx, (int) m_grids.size() - 1 ) );
455 
456  return OnGridChanged();
457 }
458 
459 
461 {
462  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
463 
464  currentGrid = std::max( 0, std::min( currentGrid, static_cast<int>( m_grids.size() ) - 1 ) );
465 
466  // Update the combobox (if any)
467  wxUpdateUIEvent dummy;
469 
470  // Update GAL canvas from screen
471  getView()->GetGAL()->SetGridSize( m_grids[ currentGrid ] );
474 
475  // Put cursor on new grid
476  VECTOR2D gridCursor = getViewControls()->GetCursorPosition( true );
477  getViewControls()->SetCrossHairCursorPosition( gridCursor, false );
478 
479  return 0;
480 }
481 
482 
484 {
486 }
487 
488 
490 {
492 }
493 
494 
496 {
498 
499  return 0;
500 }
501 
502 
504 {
505  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
506 
507  cmd.SetId( ID_GRID_SETTINGS );
508  m_frame->ProcessEvent( cmd );
509 
510  return 0;
511 }
512 
513 
515 {
516  EDA_UNITS newUnit = aEvent.Parameter<EDA_UNITS>();
517 
518  if( EDA_UNIT_UTILS::IsMetricUnit( newUnit ) )
519  m_metricUnit = newUnit;
520  else if( EDA_UNIT_UTILS::IsImperialUnit( newUnit ) )
521  m_imperialUnit = newUnit;
522  else
523  wxASSERT_MSG( false, "Invalid unit for the frame" );
524 
525  m_frame->ChangeUserUnits( newUnit );
526  return 0;
527 }
528 
529 
531 {
533  m_metricUnit :
534  m_imperialUnit );
535  return 0;
536 }
537 
538 
540 {
541  m_frame->SetStatusText( wxEmptyString );
544 
545  return 0;
546 }
547 
548 
550 {
551  auto vcSettings = m_toolMgr->GetCurrentToolVC();
552 
553  // Use either the active tool forced cursor position or the general settings
554  if( vcSettings.m_forceCursorPosition )
555  m_frame->GetScreen()->m_LocalOrigin = vcSettings.m_forcedPosition;
556  else
558 
560 
561  return 0;
562 }
563 
564 
566 {
567  auto& galOpts = m_frame->GetGalDisplayOptions();
568 
569  galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor;
570  galOpts.NotifyChanged();
571 
572  return 0;
573 }
574 
575 
577 {
579 
580  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
581  galOpts.NotifyChanged();
582 
583  return 0;
584 }
585 
586 
588 {
590 
591  // Cursor control
600 
604 
605  // Pan control
606  Go( &COMMON_TOOLS::PanControl, ACTIONS::panUp.MakeEvent() );
610 
611  // Zoom control
613  Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomIn.MakeEvent() );
622 
623  // Grid control
631 
632  // Units and coordinates
639 
640  // Misc
643 }
644 
645 
EDA_DRAW_FRAME * m_frame
Definition: common_tools.h:102
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:101
static TOOL_ACTION zoomInCenter
Definition: actions.h:96
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
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:450
int ToggleCursorStyle(const TOOL_EVENT &aEvent)
TOOL_ACTIONS
Definition: tool_event.h:62
void SetShowPolarCoords(bool aShow)
Zoom to fall all items in view INCLUDING page and border.
Definition: common_tools.h:94
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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:119
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
static TOOL_ACTION cursorRightFast
Definition: actions.h:124
static TOOL_ACTION gridFast1
Definition: actions.h:136
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move 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:100
static TOOL_ACTION panLeft
Definition: actions.h:132
bool m_forceDisplayCursor
The pixel scale factor (>1 for hi-DPI scaled displays)
int ResetLocalCoords(const TOOL_EVENT &aEvent)
The base class for create windows for drawing purpose.
void SetMousePosition(const VECTOR2D &aP)
Definition: tool_event.h:476
int doZoomToPreset(int idx, bool aCenterOnCursor)
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
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:97
Auxiliary rendering target (noncached)
Definition: definitions.h:49
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:70
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
Set the viewport center to the current cursor position and warps the cursor to the screen center.
static TOOL_ACTION centerContents
Definition: actions.h:103
static TOOL_ACTION gridFast2
Definition: actions.h:137
std::vector< wxString > sizes
Definition: app_settings.h:52
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:579
static TOOL_ACTION toggleCursor
Definition: actions.h:104
static TOOL_ACTION gridPreset
Definition: actions.h:142
bool IsMetricUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:42
static TOOL_ACTION gridPrev
Definition: actions.h:139
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
static TOOL_ACTION panDown
Definition: actions.h:131
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:451
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:574
int GridPrev(const TOOL_EVENT &aEvent)
bool IsGridVisible() const
static TOOL_ACTION toggleGrid
Definition: actions.h:143
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate 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)
Note: idx == 0 is Auto; idx == 1 is first entry in zoomList.
void OnUpdateSelectGrid(wxUpdateUIEvent &aEvent)
Update the checked item in the grid combobox.
static TOOL_ACTION inchesUnits
Definition: actions.h:147
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:443
coord_type GetWidth() const
Definition: box2.h:197
Generic, UI-independent tool event.
Definition: tool_event.h:173
static TOOL_ACTION cursorUpFast
Definition: actions.h:121
static TOOL_ACTION cursorDownFast
Definition: actions.h:122
static TOOL_ACTION cursorLeft
Definition: actions.h:118
static TOOL_ACTION panRight
Definition: actions.h:133
int ZoomCenter(const TOOL_EVENT &aEvent)
const KIGFX::VC_SETTINGS & GetCurrentToolVC() const
Return the view controls settings for the current tool or the general settings if there is no active ...
static TOOL_ACTION togglePolarCoords
Definition: actions.h:152
Zoom to fit all items in view EXCLUDING page and border.
Definition: common_tools.h:95
int ToggleGrid(const TOOL_EVENT &aEvent)
An interface for classes handling user events controlling the view behavior such as zooming,...
int ZoomInOut(const TOOL_EVENT &aEvent)
double GetZoomFactor() const
Get the zoom factor.
EDA_UNITS m_imperialUnit
Definition: common_tools.h:115
static TOOL_ACTION cursorLeftFast
Definition: actions.h:123
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
Move 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.
static TOOL_ACTION milsUnits
Definition: actions.h:148
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void HardRedraw()
Rebuild the GAL and redraws the screen.
void setTransitions() override
Pointer to the currently used edit frame.
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:237
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:553
TOOL_MOUSE_BUTTONS
Definition: tool_event.h:128
EDA_UNITS
Definition: eda_units.h:38
const VECTOR2D & GetGridSize() const
Return the grid size.
int CenterContents(const TOOL_EVENT &aEvent)
int SelectionTool(const TOOL_EVENT &aEvent)
std::vector< VECTOR2I > m_grids
Grids from #APP_SETTINGS converted to internal units and with the user grid appended.
Definition: common_tools.h:111
WINDOW_SETTINGS m_Window
Definition: app_settings.h:181
const int scale
virtual VECTOR2D GetRawCursorPosition(bool aSnappingEnabled=true) const =0
Return the current cursor position in world coordinates ignoring 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:98
ZOOM_FIT_TYPE_T
The set of "Zoom to Fit" types that can be performed.
Definition: common_tools.h:92
static TOOL_ACTION cursorUp
Cursor control with keyboard.
Definition: actions.h:116
static TOOL_ACTION zoomRedraw
Definition: actions.h:93
static TOOL_ACTION cursorDblClick
Definition: actions.h:127
int ZoomPreset(const TOOL_EVENT &aEvent)
static TOOL_ACTION resetLocalCoords
Definition: actions.h:153
coord_type GetHeight() const
Definition: box2.h:198
int ZoomFitObjects(const TOOL_EVENT &aEvent)
static TOOL_ACTION gridNext
Definition: actions.h:138
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
void SetGridVisibility(bool aVisibility)
Set the visibility setting of the grid.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
EDA_UNITS m_metricUnit
Definition: common_tools.h:116
static TOOL_ACTION gridProperties
Definition: actions.h:144
Gather all the actions that are shared by tools.
Definition: actions.h:43
static TOOL_ACTION panUp
Definition: actions.h:130
static TOOL_ACTION zoomIn
Definition: actions.h:94
static TOOL_ACTION zoomOut
Definition: actions.h:95
int TogglePolarCoords(const TOOL_EVENT &aEvent)
const Vec & GetSize() const
Definition: box2.h:189
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:105
void UpdateStatusBar() override
Update the status bar information.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
double GetScale() const
Definition: view.h:263
BASE_SCREEN class implementation.
static TOOL_ACTION showContextMenu
Definition: actions.h:66
static TOOL_ACTION cursorDown
Definition: actions.h:117
int PanControl(const TOOL_EVENT &aEvent)
int ZoomRedraw(const TOOL_EVENT &aEvent)
virtual BOX2I GetDefaultViewBBox() const
Return the bounding box of the view that should be used if model is not valid.
static TOOL_ACTION toggleUnits
Definition: actions.h:151
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool m_fullscreenCursor
Force cursor display.
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:156
APP_SETTINGS_BASE * GetSettings() const
Definition: tool_manager.h:298
static TOOL_ACTION refreshPreview
Definition: actions.h:109
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:126
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:94
Common grid settings, available to every frame.
Definition: app_settings.h:49
int doZoomFit(ZOOM_FIT_TYPE_T aFitType)