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 <[email protected]>
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 <painter.h>
29#include <bitmaps.h>
32#include <eda_draw_frame.h>
34#include <id.h>
35#include <kiface_base.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
58
59 m_grids.clear();
60
61 for( const wxString& gridDef : settings.sizes )
62 {
64 gridDef );
65
66 m_grids.emplace_back( KiROUND<double, int>( gridSize ), KiROUND<double, int>( gridSize ) );
67 }
68
70 settings.user_grid_x );
72 settings.user_grid_y );
73
74 m_grids.emplace_back( KiROUND<double, int>( userGridX ), KiROUND<double, int>( userGridY ) );
75
77}
78
79
81{
83 m_imperialUnit = aUnit;
84 else if( EDA_UNIT_UTILS::IsMetricUnit( aUnit ) )
85 m_metricUnit = aUnit;
86 else
87 wxASSERT_MSG( false, "Invalid unit" );
88}
89
90
92{
93 // Since selection tools are run permanently underneath the toolStack, this is really
94 // just a cancel of whatever other tools might be running.
95
97 return 0;
98}
99
100
101// Cursor control
103{
104 long type = aEvent.Parameter<intptr_t>();
105 bool fastMove = type & ACTIONS::CURSOR_FAST_MOVE;
106 type &= ~ACTIONS::CURSOR_FAST_MOVE;
107 bool mirroredX = getView()->IsMirroredX();
108
110 VECTOR2D gridSize = getView()->GetGAL()->GetGridSize();
111
112 if( fastMove )
113 gridSize = gridSize * 10;
114
115 switch( type )
116 {
118 cursor -= VECTOR2D( 0, gridSize.y );
119 break;
120
122 cursor += VECTOR2D( 0, gridSize.y );
123 break;
124
126 cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
127 break;
128
130 cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
131 break;
132
133 case ACTIONS::CURSOR_CLICK: // fall through
136 {
139 int modifiers = 0;
140
141 modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
142 modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
143 modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
144
145 if( type == ACTIONS::CURSOR_DBL_CLICK )
146 action = TA_MOUSE_DBLCLICK;
147
148 if( type == ACTIONS::CURSOR_RIGHT_CLICK )
149 button = BUT_RIGHT;
150
151 TOOL_EVENT evt( TC_MOUSE, action, button | modifiers );
152 evt.SetParameter( static_cast<intptr_t>( type ) );
153 evt.SetMousePosition( getViewControls()->GetCursorPosition() );
154 m_toolMgr->ProcessEvent( evt );
155
156 return 0;
157 }
158 default:
159 wxFAIL_MSG( "CursorControl(): unexpected request" );
160 }
161
162 getViewControls()->SetCursorPosition( cursor, true, true, type );
164
165 return 0;
166}
167
168
170{
171 long type = aEvent.Parameter<intptr_t>();
172 KIGFX::VIEW* view = getView();
173 VECTOR2D center = view->GetCenter();
174 VECTOR2D gridSize = getView()->GetGAL()->GetGridSize() * 10;
175 bool mirroredX = view->IsMirroredX();
176
177 switch( type )
178 {
180 center -= VECTOR2D( 0, gridSize.y );
181 break;
182
184 center += VECTOR2D( 0, gridSize.y );
185 break;
186
188 center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
189 break;
190
192 center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
193 break;
194
195 default:
196 wxFAIL;
197 break;
198 }
199
200 view->SetCenter( center );
201
202 return 0;
203}
204
205
207{
209 return 0;
210}
211
212
214{
215 bool direction = aEvent.IsAction( &ACTIONS::zoomIn );
216 return doZoomInOut( direction, true );
217}
218
219
221{
222 bool direction = aEvent.IsAction( &ACTIONS::zoomInCenter );
223 return doZoomInOut( direction, false );
224}
225
226
227int COMMON_TOOLS::doZoomInOut( bool aDirection, bool aCenterOnCursor )
228{
229 double zoom = getView()->GetGAL()->GetZoomFactor();
230
231 // Step must be AT LEAST 1.3
232 if( aDirection )
233 zoom *= 1.3;
234 else
235 zoom /= 1.3;
236
237 // Now look for the next closest menu step
238 std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
239 int idx;
240
241 if( aDirection )
242 {
243 for( idx = 0; idx < int( zoomList.size() ); ++idx )
244 {
245 if( zoomList[idx] >= zoom )
246 break;
247 }
248
249 if( idx >= int( zoomList.size() ) )
250 idx = (int) zoomList.size() - 1; // if we ran off the end then peg to the end
251 }
252 else
253 {
254 for( idx = int( zoomList.size() ) - 1; idx >= 0; --idx )
255 {
256 if( zoomList[idx] <= zoom )
257 break;
258 }
259
260 if( idx < 0 )
261 idx = 0; // if we ran off the end then peg to the end
262 }
263
264 // Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
265 return doZoomToPreset( idx + 1, aCenterOnCursor );
266}
267
268
270{
272
273 ctls->CenterOnCursor();
274
275 return 0;
276}
277
278
280{
281 return doZoomFit( ZOOM_FIT_ALL );
282}
283
284
286{
287 return doZoomFit( ZOOM_FIT_OBJECTS );
288}
289
290
292{
293 KIGFX::VIEW* view = getView();
295 EDA_DRAW_FRAME* frame = getEditFrame<EDA_DRAW_FRAME>();
296
297 BOX2I bBox = frame->GetDocumentExtents();
298 BOX2I defaultBox = canvas->GetDefaultViewBBox();
299
300 view->SetScale( 1.0 ); // The best scale will be determined later, but this initial
301 // value ensures all view parameters are up to date (especially
302 // at init time)
303 VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
304
305 // Currently "Zoom to Objects" is only supported in Eeschema & Pcbnew. Support for other
306 // programs in the suite can be added as needed.
307
308 if( aFitType == ZOOM_FIT_OBJECTS )
309 {
310 if( frame->IsType( FRAME_SCH ) || frame->IsType( FRAME_PCB_EDITOR ) )
311 bBox = m_frame->GetDocumentExtents( false );
312 else
313 aFitType = ZOOM_FIT_ALL; // Just do a "Zoom to Fit" for unsupported editors
314 }
315
316 // If the screen is empty then use the default view bbox
317
318 if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
319 bBox = defaultBox;
320
321 VECTOR2D vsize = bBox.GetSize();
322 double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
323 fabs( vsize.y / screenSize.y ) );
324
325 // if the scale isn't finite (most likely due to an empty canvas)
326 // simply just make sure we are centered and quit out of trying to zoom to fit
327 if( !std::isfinite( scale ) )
328 {
329 view->SetCenter( VECTOR2D( 0, 0 ) );
330 return 0;
331 }
332
333 // Reserve enough margin to limit the amount of the view that might be obscured behind the
334 // infobar.
335 double margin_scale_factor = 1.04;
336
337 if( canvas->GetClientSize().y < 768 )
338 margin_scale_factor = 1.10;
339
340 if( aFitType == ZOOM_FIT_ALL )
341 {
342 // Leave a bigger margin for library editors & viewers
343
345 || frame->IsType( FRAME_SCH_VIEWER ) || frame->IsType( FRAME_SCH_VIEWER_MODAL ) )
346 {
347 margin_scale_factor = 1.30;
348 }
349 else if( frame->IsType( FRAME_SCH_SYMBOL_EDITOR )
350 || frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
351 {
352 margin_scale_factor = 1.48;
353 }
354 }
355
356 view->SetScale( scale / margin_scale_factor );
357 view->SetCenter( bBox.Centre() );
358
359 return 0;
360}
361
362
364{
366 BOX2I bBox = getModel<EDA_ITEM>()->ViewBBox();
367
368 if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
369 bBox = canvas->GetDefaultViewBBox();
370
371 getView()->SetCenter( bBox.Centre() );
372
373 // Take scrollbars into account
374 VECTOR2D scrollbarSize = VECTOR2D( canvas->GetSize() - canvas->GetClientSize() );
375 VECTOR2D worldScrollbarSize = getView()->ToWorld( scrollbarSize, false );
376 getView()->SetCenter( getView()->GetCenter() + worldScrollbarSize / 2.0 );
377
378 return 0;
379}
380
381
383{
384 unsigned int idx = aEvent.Parameter<intptr_t>();
385 return doZoomToPreset( (int) idx, false );
386}
387
388
389// Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
390int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
391{
392 std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
393
394 if( idx == 0 ) // Zoom Auto
395 {
397 return ZoomFitScreen( dummy );
398 }
399 else
400 {
401 idx--;
402 }
403
404 double scale = zoomList[idx];
405
406 if( aCenterOnCursor )
407 {
408 getView()->SetScale( scale, getViewControls()->GetCursorPosition() );
409
410 if( getViewControls()->IsCursorWarpingEnabled() )
412 }
413 else
414 {
415 getView()->SetScale( scale );
416 }
417
418 return 0;
419}
420
421
422// Grid control
424{
425 int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
426
427 if( currentGrid + 1 < int( m_grids.size() ) )
428 currentGrid++;
429
430 return OnGridChanged();
431}
432
433
435{
436 int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
437
438 if( currentGrid > 0 )
439 currentGrid--;
440
441 return OnGridChanged();
442}
443
444
446{
447 return GridPreset( aEvent.Parameter<intptr_t>() );
448}
449
450
452{
453 int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
454
455 currentGrid = std::max( 0, std::min( idx, (int) m_grids.size() - 1 ) );
456
457 return OnGridChanged();
458}
459
460
462{
463 int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
464
465 currentGrid = std::max( 0, std::min( currentGrid, static_cast<int>( m_grids.size() ) - 1 ) );
466
467 // Update the combobox (if any)
468 wxUpdateUIEvent dummy;
470
471 // Update GAL canvas from screen
472 getView()->GetGAL()->SetGridSize( m_grids[ currentGrid ] );
475
476 // Put cursor on new grid
477 VECTOR2D gridCursor = getViewControls()->GetCursorPosition( true );
478 getViewControls()->SetCrossHairCursorPosition( gridCursor, false );
479
480 return 0;
481}
482
483
485{
487}
488
489
491{
493}
494
495
497{
499
500 return 0;
501}
502
503
505{
506 wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
507
508 cmd.SetId( ID_GRID_SETTINGS );
509 m_frame->ProcessEvent( cmd );
510
511 return 0;
512}
513
514
516{
517 EDA_UNITS newUnit = aEvent.Parameter<EDA_UNITS>();
518
519 if( EDA_UNIT_UTILS::IsMetricUnit( newUnit ) )
520 m_metricUnit = newUnit;
521 else if( EDA_UNIT_UTILS::IsImperialUnit( newUnit ) )
522 m_imperialUnit = newUnit;
523 else
524 wxASSERT_MSG( false, "Invalid unit for the frame" );
525
526 m_frame->ChangeUserUnits( newUnit );
527 return 0;
528}
529
530
532{
536 return 0;
537}
538
539
541{
542 m_frame->SetStatusText( wxEmptyString );
545
546 return 0;
547}
548
549
551{
552 auto vcSettings = m_toolMgr->GetCurrentToolVC();
553
554 // Use either the active tool forced cursor position or the general settings
555 if( vcSettings.m_forceCursorPosition )
556 m_frame->GetScreen()->m_LocalOrigin = vcSettings.m_forcedPosition;
557 else
559
561
562 return 0;
563}
564
565
567{
568 auto& galOpts = m_frame->GetGalDisplayOptions();
569
570 galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor;
571 galOpts.WriteConfig( m_toolMgr->GetSettings()->m_Window );
572 galOpts.NotifyChanged();
573
574 return 0;
575}
576
577
579{
581
582 galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
584 galOpts.NotifyChanged();
585
586 return 0;
587}
588
589
591{
593
594 if( canvas )
595 {
597
599
600 canvas->GetView()->UpdateAllItems( KIGFX::ALL );
601 canvas->ForceRefresh();
602 }
603
604 return 0;
605}
606
607
609{
611
612 // Cursor control
621
625
626 // Pan control
631
632 // Zoom control
643
644 // Grid control
652
653 // Units and coordinates
660
661 // Misc
665}
666
667
BASE_SCREEN class implementation.
Gather all the actions that are shared by tools.
Definition: actions.h:41
static TOOL_ACTION gridProperties
Definition: actions.h:144
static TOOL_ACTION toggleGrid
Definition: actions.h:143
static TOOL_ACTION zoomRedraw
Definition: actions.h:92
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
static TOOL_ACTION gridFast1
Definition: actions.h:136
static TOOL_ACTION gridPrev
Definition: actions.h:139
static TOOL_ACTION cursorLeft
Definition: actions.h:118
static TOOL_ACTION zoomOutCenter
Definition: actions.h:96
static TOOL_ACTION togglePolarCoords
Definition: actions.h:152
static TOOL_ACTION zoomIn
Definition: actions.h:93
static TOOL_ACTION cursorLeftFast
Definition: actions.h:123
static TOOL_ACTION gridPreset
Definition: actions.h:142
static TOOL_ACTION cursorDown
Definition: actions.h:117
static TOOL_ACTION zoomOut
Definition: actions.h:94
static TOOL_ACTION milsUnits
Definition: actions.h:148
static TOOL_ACTION cursorRightFast
Definition: actions.h:124
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:107
static TOOL_ACTION showContextMenu
Definition: actions.h:64
static TOOL_ACTION toggleCursor
Definition: actions.h:103
static TOOL_ACTION centerContents
Definition: actions.h:102
static TOOL_ACTION zoomCenter
Definition: actions.h:97
static TOOL_ACTION panDown
Definition: actions.h:131
static TOOL_ACTION cursorDblClick
Definition: actions.h:127
@ CURSOR_DBL_CLICK
Definition: actions.h:191
@ CURSOR_RIGHT
Definition: actions.h:190
@ CURSOR_FAST_MOVE
Definition: actions.h:192
@ CURSOR_LEFT
Definition: actions.h:190
@ CURSOR_CLICK
Definition: actions.h:191
@ CURSOR_UP
Definition: actions.h:190
@ CURSOR_DOWN
Definition: actions.h:190
@ CURSOR_RIGHT_CLICK
Definition: actions.h:191
static TOOL_ACTION cursorDownFast
Definition: actions.h:122
static TOOL_ACTION inchesUnits
Definition: actions.h:147
static TOOL_ACTION cursorUpFast
Definition: actions.h:121
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:104
static TOOL_ACTION panLeft
Definition: actions.h:132
static TOOL_ACTION selectionTool
Definition: actions.h:156
static TOOL_ACTION cursorClick
Definition: actions.h:126
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
static TOOL_ACTION zoomPreset
Definition: actions.h:100
static TOOL_ACTION panUp
Definition: actions.h:130
static TOOL_ACTION zoomFitObjects
Definition: actions.h:99
static TOOL_ACTION toggleUnits
Definition: actions.h:151
static TOOL_ACTION zoomInCenter
Definition: actions.h:95
static TOOL_ACTION panRight
Definition: actions.h:133
static TOOL_ACTION gridFast2
Definition: actions.h:137
static TOOL_ACTION cursorUp
Cursor control with keyboard.
Definition: actions.h:116
static TOOL_ACTION refreshPreview
Definition: actions.h:109
static TOOL_ACTION gridNext
Definition: actions.h:138
static TOOL_ACTION cursorRight
Definition: actions.h:119
static TOOL_ACTION resetLocalCoords
Definition: actions.h:153
WINDOW_SETTINGS m_Window
Definition: app_settings.h:184
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:90
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
Vec Centre() const
Definition: box2.h:70
const Vec & GetSize() const
Definition: box2.h:179
int ZoomCenter(const TOOL_EVENT &aEvent)
int GridProperties(const TOOL_EVENT &aEvent)
int ToggleCursorStyle(const TOOL_EVENT &aEvent)
int doZoomToPreset(int idx, bool aCenterOnCursor)
int PanControl(const TOOL_EVENT &aEvent)
EDA_UNITS m_metricUnit
Definition: common_tools.h:118
EDA_UNITS m_imperialUnit
Definition: common_tools.h:117
int SwitchUnits(const TOOL_EVENT &aEvent)
int ToggleGrid(const TOOL_EVENT &aEvent)
int GridFast1(const TOOL_EVENT &aEvent)
void SetLastUnits(EDA_UNITS aUnit)
int ToggleUnits(const TOOL_EVENT &aEvent)
int GridFast2(const TOOL_EVENT &aEvent)
int GridNext(const TOOL_EVENT &aEvent)
void setTransitions() override
Pointer to the currently used edit frame.
int ZoomPreset(const TOOL_EVENT &aEvent)
int ZoomFitScreen(const TOOL_EVENT &aEvent)
int ToggleBoundingBoxes(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:113
int ToggleCursor(const TOOL_EVENT &aEvent)
int ZoomFitObjects(const TOOL_EVENT &aEvent)
int CenterContents(const TOOL_EVENT &aEvent)
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
int TogglePolarCoords(const TOOL_EVENT &aEvent)
int GridPrev(const TOOL_EVENT &aEvent)
int ZoomInOutCenter(const TOOL_EVENT &aEvent)
int ZoomRedraw(const TOOL_EVENT &aEvent)
int ResetLocalCoords(const TOOL_EVENT &aEvent)
EDA_DRAW_FRAME * m_frame
Definition: common_tools.h:104
int doZoomFit(ZOOM_FIT_TYPE_T aFitType)
int CursorControl(const TOOL_EVENT &aEvent)
ZOOM_FIT_TYPE_T
The set of "Zoom to Fit" types that can be performed.
Definition: common_tools.h:95
@ ZOOM_FIT_ALL
Zoom to fall all items in view INCLUDING page and border.
Definition: common_tools.h:96
@ ZOOM_FIT_OBJECTS
Zoom to fit all items in view EXCLUDING page and border.
Definition: common_tools.h:97
int SelectionTool(const TOOL_EVENT &aEvent)
int GridPreset(const TOOL_EVENT &aEvent)
int ZoomInOut(const TOOL_EVENT &aEvent)
int doZoomInOut(bool aDirection, bool aCenterOnCursor)
Note: idx == 0 is Auto; idx == 1 is first entry in zoomList.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void ChangeUserUnits(EDA_UNITS aUnits)
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
virtual const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const
Returns bbox of document with option to not include some items.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual void HardRedraw()
Rebuild the GAL and redraws the screen.
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void SetShowPolarCoords(bool aShow)
virtual void SetGridVisibility(bool aVisible)
void UpdateStatusBar() override
Update the status bar information.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
bool IsGridVisible() const
void OnUpdateSelectGrid(wxUpdateUIEvent &aEvent)
Update the checked item in the grid wxchoice.
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
virtual BOX2I GetDefaultViewBBox() const
Return the bounding box of the view that should be used if model is not valid.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
void ForceRefresh()
Force a redraw.
void WriteConfig(WINDOW_SETTINGS &aCfg)
bool m_forceDisplayCursor
The pixel scale factor (>1 for hi-DPI scaled displays)
bool m_fullscreenCursor
Force cursor display.
double GetZoomFactor() const
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
const VECTOR2D & GetGridSize() const
Return the grid size.
void SetGridVisibility(bool aVisibility)
Set the visibility setting of the grid.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetDrawBoundingBoxes(bool aEnabled)
bool GetDrawBoundingBoxes() const
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual VECTOR2D GetRawCursorPosition(bool aSnappingEnabled=true) const =0
Return the current cursor position in world coordinates ignoring the cursorUp position force mode.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual void CenterOnCursor() const =0
Set the viewport center to the current cursor position and warps the cursor to the screen center.
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.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
double GetScale() const
Definition: view.h:269
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:548
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:195
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:445
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:243
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1478
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:574
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:617
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
Generic, UI-independent tool event.
Definition: tool_event.h:156
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
void SetMousePosition(const VECTOR2D &aP)
Definition: tool_event.h:470
void SetParameter(T aParam)
Set a non-standard parameter assigned to the event.
Definition: tool_event.h:460
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
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).
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
const KIGFX::VC_SETTINGS & GetCurrentToolVC() const
Return the view controls settings for the current tool or the general settings if there is no active ...
APP_SETTINGS_BASE * GetSettings() const
Definition: tool_manager.h:294
const EDA_IU_SCALE & GetIuScale() const
EDA_UNITS GetUserUnits() const
EDA_UNITS
Definition: eda_units.h:43
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ FRAME_FOOTPRINT_VIEWER_MODAL
Definition: frame_type.h:43
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ FRAME_FOOTPRINT_VIEWER
Definition: frame_type.h:42
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ FRAME_SCH
Definition: frame_type.h:34
@ FRAME_SCH_VIEWER_MODAL
Definition: frame_type.h:37
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
@ ID_GRID_SETTINGS
Definition: id.h:146
double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function DoubleValueFromString converts aTextValue to a double.
Definition: eda_units.cpp:449
bool IsImperialUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:29
bool IsMetricUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:43
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:53
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition: definitions.h:49
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74
const int scale
Common grid settings, available to every frame.
Definition: app_settings.h:51
wxString user_grid_x
Definition: app_settings.h:54
wxString user_grid_y
Definition: app_settings.h:55
std::vector< wxString > sizes
Definition: app_settings.h:53
GRID_SETTINGS grid
Definition: app_settings.h:90
std::vector< double > zoom_factors
Definition: app_settings.h:87
TOOL_ACTIONS
Definition: tool_event.h:59
@ TA_MOUSE_CLICK
Definition: tool_event.h:62
@ TA_MOUSE_DBLCLICK
Definition: tool_event.h:63
@ TA_CANCEL_TOOL
Definition: tool_event.h:85
@ TC_COMMAND
Definition: tool_event.h:52
@ TC_MOUSE
Definition: tool_event.h:50
@ MD_ALT
Definition: tool_event.h:140
@ MD_CTRL
Definition: tool_event.h:139
@ MD_SHIFT
Definition: tool_event.h:138
TOOL_MOUSE_BUTTONS
Definition: tool_event.h:125
@ BUT_LEFT
Definition: tool_event.h:127
@ BUT_RIGHT
Definition: tool_event.h:128
VECTOR2< double > VECTOR2D
Definition: vector2d.h:617