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_base.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 
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.SetParameter( type );
147  evt.SetMousePosition( getViewControls()->GetCursorPosition() );
148  m_toolMgr->ProcessEvent( evt );
149 
150  return 0;
151  }
152  default:
153  wxFAIL_MSG( "CursorControl(): unexpected request" );
154  }
155 
156  getViewControls()->SetCursorPosition( cursor, true, true, type );
158 
159  return 0;
160 }
161 
162 
164 {
165  long type = aEvent.Parameter<intptr_t>();
166  KIGFX::VIEW* view = getView();
167  VECTOR2D center = view->GetCenter();
168  VECTOR2D gridSize = getView()->GetGAL()->GetGridSize() * 10;
169  bool mirroredX = view->IsMirroredX();
170 
171  switch( type )
172  {
173  case ACTIONS::CURSOR_UP:
174  center -= VECTOR2D( 0, gridSize.y );
175  break;
176 
178  center += VECTOR2D( 0, gridSize.y );
179  break;
180 
182  center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
183  break;
184 
186  center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
187  break;
188 
189  default:
190  wxFAIL;
191  break;
192  }
193 
194  view->SetCenter( center );
195 
196  return 0;
197 }
198 
199 
201 {
202  m_frame->HardRedraw();
203  return 0;
204 }
205 
206 
208 {
209  bool direction = aEvent.IsAction( &ACTIONS::zoomIn );
210  return doZoomInOut( direction, true );
211 }
212 
213 
215 {
216  bool direction = aEvent.IsAction( &ACTIONS::zoomInCenter );
217  return doZoomInOut( direction, false );
218 }
219 
220 
221 int COMMON_TOOLS::doZoomInOut( bool aDirection, bool aCenterOnCursor )
222 {
223  double zoom = getView()->GetGAL()->GetZoomFactor();
224 
225  // Step must be AT LEAST 1.3
226  if( aDirection )
227  zoom *= 1.3;
228  else
229  zoom /= 1.3;
230 
231  // Now look for the next closest menu step
232  std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
233  int idx;
234 
235  if( aDirection )
236  {
237  for( idx = 0; idx < int( zoomList.size() ); ++idx )
238  {
239  if( zoomList[idx] >= zoom )
240  break;
241  }
242 
243  if( idx >= int( zoomList.size() ) )
244  idx = (int) zoomList.size() - 1; // if we ran off the end then peg to the end
245  }
246  else
247  {
248  for( idx = int( zoomList.size() ) - 1; idx >= 0; --idx )
249  {
250  if( zoomList[idx] <= zoom )
251  break;
252  }
253 
254  if( idx < 0 )
255  idx = 0; // if we ran off the end then peg to the end
256  }
257 
258  // Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
259  return doZoomToPreset( idx + 1, aCenterOnCursor );
260 }
261 
262 
264 {
266 
267  ctls->CenterOnCursor();
268 
269  return 0;
270 }
271 
272 
274 {
275  return doZoomFit( ZOOM_FIT_ALL );
276 }
277 
278 
280 {
281  return doZoomFit( ZOOM_FIT_OBJECTS );
282 }
283 
284 
286 {
287  KIGFX::VIEW* view = getView();
288  EDA_DRAW_PANEL_GAL* canvas = m_frame->GetCanvas();
289  EDA_DRAW_FRAME* frame = getEditFrame<EDA_DRAW_FRAME>();
290 
291  BOX2I bBox = frame->GetDocumentExtents();
292  BOX2I defaultBox = canvas->GetDefaultViewBBox();
293 
294  view->SetScale( 1.0 ); // The best scale will be determined later, but this initial
295  // value ensures all view parameters are up to date (especially
296  // at init time)
297  VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
298 
299  // Currently "Zoom to Objects" is only supported in Eeschema & Pcbnew. Support for other
300  // programs in the suite can be added as needed.
301 
302  if( aFitType == ZOOM_FIT_OBJECTS )
303  {
304  if( frame->IsType( FRAME_SCH ) || frame->IsType( FRAME_PCB_EDITOR ) )
305  bBox = m_frame->GetDocumentExtents( false );
306  else
307  aFitType = ZOOM_FIT_ALL; // Just do a "Zoom to Fit" for unsupported editors
308  }
309 
310  // If the screen is empty then use the default view bbox
311 
312  if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
313  bBox = defaultBox;
314 
315  VECTOR2D vsize = bBox.GetSize();
316  double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
317  fabs( vsize.y / screenSize.y ) );
318 
319  // if the scale isn't finite (most likely due to an empty canvas)
320  // simply just make sure we are centered and quit out of trying to zoom to fit
321  if( !std::isfinite( scale ) )
322  {
323  view->SetCenter( VECTOR2D( 0, 0 ) );
324  return 0;
325  }
326 
327  // Reserve enough margin to limit the amount of the view that might be obscured behind the
328  // infobar.
329  double margin_scale_factor = 1.04;
330 
331  if( canvas->GetClientSize().y < 768 )
332  margin_scale_factor = 1.10;
333 
334  if( aFitType == ZOOM_FIT_ALL )
335  {
336  // Leave a bigger margin for library editors & viewers
337 
339  || frame->IsType( FRAME_SCH_VIEWER ) || frame->IsType( FRAME_SCH_VIEWER_MODAL ) )
340  {
341  margin_scale_factor = 1.30;
342  }
343  else if( frame->IsType( FRAME_SCH_SYMBOL_EDITOR )
344  || frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
345  {
346  margin_scale_factor = 1.48;
347  }
348  }
349 
350  view->SetScale( scale / margin_scale_factor );
351  view->SetCenter( bBox.Centre() );
352 
353  return 0;
354 }
355 
356 
358 {
359  EDA_DRAW_PANEL_GAL* canvas = m_frame->GetCanvas();
360  BOX2I bBox = getModel<EDA_ITEM>()->ViewBBox();
361 
362  if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
363  bBox = canvas->GetDefaultViewBBox();
364 
365  getView()->SetCenter( bBox.Centre() );
366 
367  // Take scrollbars into account
368  VECTOR2D scrollbarSize = VECTOR2D( canvas->GetSize() - canvas->GetClientSize() );
369  VECTOR2D worldScrollbarSize = getView()->ToWorld( scrollbarSize, false );
370  getView()->SetCenter( getView()->GetCenter() + worldScrollbarSize / 2.0 );
371 
372  return 0;
373 }
374 
375 
377 {
378  unsigned int idx = aEvent.Parameter<intptr_t>();
379  return doZoomToPreset( (int) idx, false );
380 }
381 
382 
383 // Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
384 int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
385 {
386  std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
387 
388  if( idx == 0 ) // Zoom Auto
389  {
391  return ZoomFitScreen( dummy );
392  }
393  else
394  {
395  idx--;
396  }
397 
398  double scale = zoomList[idx];
399 
400  if( aCenterOnCursor )
401  {
402  getView()->SetScale( scale, getViewControls()->GetCursorPosition() );
403 
404  if( getViewControls()->IsCursorWarpingEnabled() )
406  }
407  else
408  {
409  getView()->SetScale( scale );
410  }
411 
412  return 0;
413 }
414 
415 
416 // Grid control
417 int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent )
418 {
419  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
420 
421  if( currentGrid + 1 < int( m_grids.size() ) )
422  currentGrid++;
423 
424  return OnGridChanged();
425 }
426 
427 
428 int COMMON_TOOLS::GridPrev( const TOOL_EVENT& aEvent )
429 {
430  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
431 
432  if( currentGrid > 0 )
433  currentGrid--;
434 
435  return OnGridChanged();
436 }
437 
438 
440 {
441  return GridPreset( aEvent.Parameter<intptr_t>() );
442 }
443 
444 
446 {
447  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
448 
449  currentGrid = std::max( 0, std::min( idx, (int) m_grids.size() - 1 ) );
450 
451  return OnGridChanged();
452 }
453 
454 
456 {
457  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
458 
459  currentGrid = std::max( 0, std::min( currentGrid, static_cast<int>( m_grids.size() ) - 1 ) );
460 
461  // Update the combobox (if any)
462  wxUpdateUIEvent dummy;
464 
465  // Update GAL canvas from screen
466  getView()->GetGAL()->SetGridSize( m_grids[ currentGrid ] );
469 
470  // Put cursor on new grid
471  VECTOR2D gridCursor = getViewControls()->GetCursorPosition( true );
472  getViewControls()->SetCrossHairCursorPosition( gridCursor, false );
473 
474  return 0;
475 }
476 
477 
479 {
481 }
482 
483 
485 {
487 }
488 
489 
491 {
493 
494  return 0;
495 }
496 
497 
499 {
500  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
501 
502  cmd.SetId( ID_GRID_SETTINGS );
503  m_frame->ProcessEvent( cmd );
504 
505  return 0;
506 }
507 
508 
510 {
511  EDA_UNITS newUnit = aEvent.Parameter<EDA_UNITS>();
512 
513  if( EDA_UNIT_UTILS::IsMetricUnit( newUnit ) )
514  m_metricUnit = newUnit;
515  else if( EDA_UNIT_UTILS::IsImperialUnit( newUnit ) )
516  m_imperialUnit = newUnit;
517  else
518  wxASSERT_MSG( false, "Invalid unit for the frame" );
519 
520  m_frame->ChangeUserUnits( newUnit );
521  return 0;
522 }
523 
524 
526 {
528  m_metricUnit :
529  m_imperialUnit );
530  return 0;
531 }
532 
533 
535 {
536  m_frame->SetStatusText( wxEmptyString );
539 
540  return 0;
541 }
542 
543 
545 {
546  auto vcSettings = m_toolMgr->GetCurrentToolVC();
547 
548  // Use either the active tool forced cursor position or the general settings
549  if( vcSettings.m_forceCursorPosition )
550  m_frame->GetScreen()->m_LocalOrigin = vcSettings.m_forcedPosition;
551  else
553 
555 
556  return 0;
557 }
558 
559 
561 {
562  auto& galOpts = m_frame->GetGalDisplayOptions();
563 
564  galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor;
565  galOpts.NotifyChanged();
566 
567  return 0;
568 }
569 
570 
572 {
574 
575  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
576  galOpts.NotifyChanged();
577 
578  return 0;
579 }
580 
581 
583 {
585 
586  // Cursor control
595 
599 
600  // Pan control
601  Go( &COMMON_TOOLS::PanControl, ACTIONS::panUp.MakeEvent() );
605 
606  // Zoom control
608  Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomIn.MakeEvent() );
617 
618  // Grid control
626 
627  // Units and coordinates
634 
635  // Misc
638 }
639 
640 
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:98
static TOOL_ACTION zoomInCenter
Definition: actions.h:93
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:452
int ToggleCursorStyle(const TOOL_EVENT &aEvent)
TOOL_ACTIONS
Definition: tool_event.h:57
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:214
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:116
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static TOOL_ACTION cursorRightFast
Definition: actions.h:121
static TOOL_ACTION gridFast1
Definition: actions.h:133
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:190
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:97
static TOOL_ACTION panLeft
Definition: actions.h:129
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:465
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:94
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:88
int GridNext(const TOOL_EVENT &aEvent)
int GridFast2(const TOOL_EVENT &aEvent)
int ToggleUnits(const TOOL_EVENT &aEvent)
int ZoomInOutCenter(const TOOL_EVENT &aEvent)
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
virtual void CenterOnCursor() const =0
Set the viewport center to the current cursor position and warps the cursor to the screen center.
void SetParameter(T aParam)
Set a non-standard parameter assigned to the event.
Definition: tool_event.h:450
static TOOL_ACTION centerContents
Definition: actions.h:100
static TOOL_ACTION gridFast2
Definition: actions.h:134
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:581
static TOOL_ACTION toggleCursor
Definition: actions.h:101
static TOOL_ACTION gridPreset
Definition: actions.h:139
bool IsMetricUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:42
static TOOL_ACTION gridPrev
Definition: actions.h:136
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
static TOOL_ACTION panDown
Definition: actions.h:128
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:416
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
int GridPrev(const TOOL_EVENT &aEvent)
bool IsGridVisible() const
static TOOL_ACTION toggleGrid
Definition: actions.h:140
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:144
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
coord_type GetWidth() const
Definition: box2.h:180
Generic, UI-independent tool event.
Definition: tool_event.h:152
static TOOL_ACTION cursorUpFast
Definition: actions.h:118
static TOOL_ACTION cursorDownFast
Definition: actions.h:119
static TOOL_ACTION cursorLeft
Definition: actions.h:115
static TOOL_ACTION panRight
Definition: actions.h:130
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:149
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:120
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:145
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:238
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:555
TOOL_MOUSE_BUTTONS
Definition: tool_event.h:123
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:63
static TOOL_ACTION zoomCenter
Definition: actions.h:95
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:113
static TOOL_ACTION zoomRedraw
Definition: actions.h:90
static TOOL_ACTION cursorDblClick
Definition: actions.h:124
int ZoomPreset(const TOOL_EVENT &aEvent)
static TOOL_ACTION resetLocalCoords
Definition: actions.h:150
coord_type GetHeight() const
Definition: box2.h:181
int ZoomFitObjects(const TOOL_EVENT &aEvent)
static TOOL_ACTION gridNext
Definition: actions.h:135
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:77
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:141
Gather all the actions that are shared by tools.
Definition: actions.h:40
static TOOL_ACTION panUp
Definition: actions.h:127
static TOOL_ACTION zoomIn
Definition: actions.h:91
static TOOL_ACTION zoomOut
Definition: actions.h:92
int TogglePolarCoords(const TOOL_EVENT &aEvent)
const Vec & GetSize() const
Definition: box2.h:172
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:102
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:68
double GetScale() const
Definition: view.h:264
BASE_SCREEN class implementation.
static TOOL_ACTION showContextMenu
Definition: actions.h:63
static TOOL_ACTION cursorDown
Definition: actions.h:114
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:148
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:153
APP_SETTINGS_BASE * GetSettings() const
Definition: tool_manager.h:292
static TOOL_ACTION refreshPreview
Definition: actions.h:106
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:123
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:90
Common grid settings, available to every frame.
Definition: app_settings.h:49
int doZoomFit(ZOOM_FIT_TYPE_T aFitType)