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 
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 enough margin to limit the amount of the view that might be obscured behind the
327  // infobar.
328  double margin_scale_factor = 1.04;
329 
330  if( canvas->GetClientSize().y < 768 )
331  margin_scale_factor = 1.10;
332 
333  if( aFitType == ZOOM_FIT_ALL )
334  {
335  // Leave a bigger margin for library editors & viewers
336 
338  || frame->IsType( FRAME_SCH_VIEWER ) || frame->IsType( FRAME_SCH_VIEWER_MODAL ) )
339  {
340  margin_scale_factor = 1.30;
341  }
342  else if( frame->IsType( FRAME_SCH_SYMBOL_EDITOR )
343  || frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
344  {
345  margin_scale_factor = 1.48;
346  }
347  }
348 
349  view->SetScale( scale / margin_scale_factor );
350  view->SetCenter( bBox.Centre() );
351 
352  return 0;
353 }
354 
355 
357 {
358  EDA_DRAW_PANEL_GAL* canvas = m_frame->GetCanvas();
359  BOX2I bBox = getModel<EDA_ITEM>()->ViewBBox();
360 
361  if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
362  bBox = canvas->GetDefaultViewBBox();
363 
364  getView()->SetCenter( bBox.Centre() );
365 
366  // Take scrollbars into account
367  VECTOR2D scrollbarSize = VECTOR2D( canvas->GetSize() - canvas->GetClientSize() );
368  VECTOR2D worldScrollbarSize = getView()->ToWorld( scrollbarSize, false );
369  getView()->SetCenter( getView()->GetCenter() + worldScrollbarSize / 2.0 );
370 
371  return 0;
372 }
373 
374 
376 {
377  unsigned int idx = aEvent.Parameter<intptr_t>();
378  return doZoomToPreset( (int) idx, false );
379 }
380 
381 
382 // Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
383 int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
384 {
385  std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
386 
387  if( idx == 0 ) // Zoom Auto
388  {
390  return ZoomFitScreen( dummy );
391  }
392  else
393  {
394  idx--;
395  }
396 
397  double scale = zoomList[idx];
398 
399  if( aCenterOnCursor )
400  {
401  getView()->SetScale( scale, getViewControls()->GetCursorPosition() );
402 
403  if( getViewControls()->IsCursorWarpingEnabled() )
405  }
406  else
407  {
408  getView()->SetScale( scale );
409  }
410 
411  return 0;
412 }
413 
414 
415 // Grid control
416 int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent )
417 {
418  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
419 
420  if( currentGrid + 1 < int( m_grids.size() ) )
421  currentGrid++;
422 
423  return OnGridChanged();
424 }
425 
426 
427 int COMMON_TOOLS::GridPrev( const TOOL_EVENT& aEvent )
428 {
429  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
430 
431  if( currentGrid > 0 )
432  currentGrid--;
433 
434  return OnGridChanged();
435 }
436 
437 
439 {
440  return GridPreset( aEvent.Parameter<intptr_t>() );
441 }
442 
443 
445 {
446  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
447 
448  currentGrid = std::max( 0, std::min( idx, (int) m_grids.size() - 1 ) );
449 
450  return OnGridChanged();
451 }
452 
453 
455 {
456  int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
457 
458  currentGrid = std::max( 0, std::min( currentGrid, static_cast<int>( m_grids.size() ) - 1 ) );
459 
460  // Update the combobox (if any)
461  wxUpdateUIEvent dummy;
463 
464  // Update GAL canvas from screen
465  getView()->GetGAL()->SetGridSize( m_grids[ currentGrid ] );
468 
469  // Put cursor on new grid
470  VECTOR2D gridCursor = getViewControls()->GetCursorPosition( true );
471  getViewControls()->SetCrossHairCursorPosition( gridCursor, false );
472 
473  return 0;
474 }
475 
476 
478 {
480 }
481 
482 
484 {
486 }
487 
488 
490 {
492 
493  return 0;
494 }
495 
496 
498 {
499  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
500 
501  cmd.SetId( ID_GRID_SETTINGS );
502  m_frame->ProcessEvent( cmd );
503 
504  return 0;
505 }
506 
507 
509 {
510  EDA_UNITS newUnit = aEvent.Parameter<EDA_UNITS>();
511 
512  if( EDA_UNIT_UTILS::IsMetricUnit( newUnit ) )
513  m_metricUnit = newUnit;
514  else if( EDA_UNIT_UTILS::IsImperialUnit( newUnit ) )
515  m_imperialUnit = newUnit;
516  else
517  wxASSERT_MSG( false, "Invalid unit for the frame" );
518 
519  m_frame->ChangeUserUnits( newUnit );
520  return 0;
521 }
522 
523 
525 {
527  m_metricUnit :
528  m_imperialUnit );
529  return 0;
530 }
531 
532 
534 {
535  m_frame->SetStatusText( wxEmptyString );
538 
539  return 0;
540 }
541 
542 
544 {
545  auto vcSettings = m_toolMgr->GetCurrentToolVC();
546 
547  // Use either the active tool forced cursor position or the general settings
548  if( vcSettings.m_forceCursorPosition )
549  m_frame->GetScreen()->m_LocalOrigin = vcSettings.m_forcedPosition;
550  else
552 
554 
555  return 0;
556 }
557 
558 
560 {
561  auto& galOpts = m_frame->GetGalDisplayOptions();
562 
563  galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor;
564  galOpts.NotifyChanged();
565 
566  return 0;
567 }
568 
569 
571 {
573 
574  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
575  galOpts.NotifyChanged();
576 
577  return 0;
578 }
579 
580 
582 {
584 
585  // Cursor control
594 
598 
599  // Pan control
600  Go( &COMMON_TOOLS::PanControl, ACTIONS::panUp.MakeEvent() );
604 
605  // Zoom control
607  Go( &COMMON_TOOLS::ZoomInOut, ACTIONS::zoomIn.MakeEvent() );
616 
617  // Grid control
625 
626  // Units and coordinates
633 
634  // Misc
637 }
638 
639 
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:451
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: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: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:460
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:70
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: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:580
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:415
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:575
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:427
coord_type GetWidth() const
Definition: box2.h:187
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:237
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:554
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:69
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:188
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:179
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:67
double GetScale() const
Definition: view.h:263
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)