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 <math/vector2wx.h>
36#include <kiface_base.h>
38#include <tool/actions.h>
39#include <tool/common_tools.h>
40#include <tool/tool_manager.h>
41#include <view/view.h>
42#include <view/view_controls.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
59
60 m_grids.clear();
61
62 for( const wxString& gridDef : settings.sizes )
63 {
65 gridDef );
66
67 m_grids.emplace_back( KiROUND<double, int>( gridSize ), KiROUND<double, int>( gridSize ) );
68 }
69
71 settings.user_grid_x );
73 settings.user_grid_y );
74
75 m_grids.emplace_back( KiROUND<double, int>( userGridX ), KiROUND<double, int>( userGridY ) );
76
78}
79
80
82{
84 m_imperialUnit = aUnit;
85 else if( EDA_UNIT_UTILS::IsMetricUnit( aUnit ) )
86 m_metricUnit = aUnit;
87 else
88 wxASSERT_MSG( false, wxS( "Invalid unit" ) );
89}
90
91
93{
94 // Since selection tools are run permanently underneath the toolStack, this is really
95 // just a cancel of whatever other tools might be running.
96
98 return 0;
99}
100
101
102// Cursor control
104{
105 long type = aEvent.Parameter<intptr_t>();
106 bool fastMove = type & ACTIONS::CURSOR_FAST_MOVE;
107 type &= ~ACTIONS::CURSOR_FAST_MOVE;
108 bool mirroredX = getView()->IsMirroredX();
109
111 VECTOR2D gridSize = getView()->GetGAL()->GetGridSize();
112
113 if( fastMove )
114 gridSize = gridSize * 10;
115
116 switch( type )
117 {
119 cursor -= VECTOR2D( 0, gridSize.y );
120 break;
121
123 cursor += VECTOR2D( 0, gridSize.y );
124 break;
125
127 cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
128 break;
129
131 cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
132 break;
133
134 case ACTIONS::CURSOR_CLICK: // fall through
137 {
140 int modifiers = 0;
141
142 modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
143 modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
144 modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
145
146 if( type == ACTIONS::CURSOR_DBL_CLICK )
147 action = TA_MOUSE_DBLCLICK;
148
149 if( type == ACTIONS::CURSOR_RIGHT_CLICK )
150 button = BUT_RIGHT;
151
152 TOOL_EVENT evt( TC_MOUSE, action, button | modifiers );
153 evt.SetParameter( static_cast<intptr_t>( type ) );
154 evt.SetMousePosition( getViewControls()->GetCursorPosition() );
155 m_toolMgr->ProcessEvent( evt );
156
157 return 0;
158 }
159 default:
160 wxFAIL_MSG( wxS( "CursorControl(): unexpected request" ) );
161 }
162
163 getViewControls()->SetCursorPosition( cursor, true, true, type );
165
166 return 0;
167}
168
169
171{
172 long type = aEvent.Parameter<intptr_t>();
173 KIGFX::VIEW* view = getView();
174 VECTOR2D center = view->GetCenter();
175 VECTOR2D gridSize = getView()->GetGAL()->GetGridSize() * 10;
176 bool mirroredX = view->IsMirroredX();
177
178 switch( type )
179 {
181 center -= VECTOR2D( 0, gridSize.y );
182 break;
183
185 center += VECTOR2D( 0, gridSize.y );
186 break;
187
189 center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
190 break;
191
193 center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
194 break;
195
196 default:
197 wxFAIL;
198 break;
199 }
200
201 view->SetCenter( center );
202
203 return 0;
204}
205
206
208{
210 return 0;
211}
212
213
215{
216 bool direction = aEvent.IsAction( &ACTIONS::zoomIn );
217 return doZoomInOut( direction, true );
218}
219
220
222{
223 bool direction = aEvent.IsAction( &ACTIONS::zoomInCenter );
224 return doZoomInOut( direction, false );
225}
226
227
228int COMMON_TOOLS::doZoomInOut( bool aDirection, bool aCenterOnCursor )
229{
230 double zoom = getView()->GetGAL()->GetZoomFactor();
231
232 // Step must be AT LEAST 1.3
233 if( aDirection )
234 zoom *= 1.3;
235 else
236 zoom /= 1.3;
237
238 // Now look for the next closest menu step
239 std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
240 int idx;
241
242 if( aDirection )
243 {
244 for( idx = 0; idx < int( zoomList.size() ); ++idx )
245 {
246 if( zoomList[idx] >= zoom )
247 break;
248 }
249
250 if( idx >= int( zoomList.size() ) )
251 idx = (int) zoomList.size() - 1; // if we ran off the end then peg to the end
252 }
253 else
254 {
255 for( idx = int( zoomList.size() ) - 1; idx >= 0; --idx )
256 {
257 if( zoomList[idx] <= zoom )
258 break;
259 }
260
261 if( idx < 0 )
262 idx = 0; // if we ran off the end then peg to the end
263 }
264
265 // Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
266 return doZoomToPreset( idx + 1, aCenterOnCursor );
267}
268
269
271{
273
274 ctls->CenterOnCursor();
275
276 return 0;
277}
278
279
281{
282 return doZoomFit( ZOOM_FIT_ALL );
283}
284
285
287{
288 return doZoomFit( ZOOM_FIT_OBJECTS );
289}
290
291
293{
294 KIGFX::VIEW* view = getView();
296 EDA_DRAW_FRAME* frame = getEditFrame<EDA_DRAW_FRAME>();
297
298 BOX2I bBox = frame->GetDocumentExtents();
299 BOX2I defaultBox = canvas->GetDefaultViewBBox();
300
301 view->SetScale( 1.0 ); // The best scale will be determined later, but this initial
302 // value ensures all view parameters are up to date (especially
303 // at init time)
304 VECTOR2D screenSize = view->ToWorld( ToVECTOR2I( canvas->GetClientSize() ), false );
305
306 // Currently "Zoom to Objects" is only supported in Eeschema & Pcbnew. Support for other
307 // programs in the suite can be added as needed.
308
309 if( aFitType == ZOOM_FIT_OBJECTS )
310 {
311 if( frame->IsType( FRAME_SCH ) || frame->IsType( FRAME_PCB_EDITOR ) )
312 bBox = m_frame->GetDocumentExtents( false );
313 else
314 aFitType = ZOOM_FIT_ALL; // Just do a "Zoom to Fit" for unsupported editors
315 }
316
317 // If the screen is empty then use the default view bbox
318
319 if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
320 bBox = defaultBox;
321
322 VECTOR2D vsize = bBox.GetSize();
323 double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
324 fabs( vsize.y / screenSize.y ) );
325
326 // if the scale isn't finite (most likely due to an empty canvas)
327 // simply just make sure we are centered and quit out of trying to zoom to fit
328 if( !std::isfinite( scale ) )
329 {
330 view->SetCenter( VECTOR2D( 0, 0 ) );
331 return 0;
332 }
333
334 // Reserve enough margin to limit the amount of the view that might be obscured behind the
335 // infobar.
336 double margin_scale_factor = 1.04;
337
338 if( canvas->GetClientSize().y < 768 )
339 margin_scale_factor = 1.10;
340
341 if( aFitType == ZOOM_FIT_ALL )
342 {
343 // Leave a bigger margin for library editors & viewers
344
346 || frame->IsType( FRAME_SCH_VIEWER ) || frame->IsType( FRAME_SCH_VIEWER_MODAL ) )
347 {
348 margin_scale_factor = 1.30;
349 }
350 else if( frame->IsType( FRAME_SCH_SYMBOL_EDITOR )
351 || frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
352 {
353 margin_scale_factor = 1.48;
354 }
355 }
356
357 view->SetScale( scale / margin_scale_factor );
358 view->SetCenter( bBox.Centre() );
359
360 return 0;
361}
362
363
365{
367 BOX2I bBox = getModel<EDA_ITEM>()->ViewBBox();
368
369 if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
370 bBox = canvas->GetDefaultViewBBox();
371
372 getView()->SetCenter( bBox.Centre() );
373
374 // Take scrollbars into account
375 VECTOR2D scrollbarSize = VECTOR2D( ToVECTOR2D( canvas->GetSize() - canvas->GetClientSize() ) );
376 VECTOR2D worldScrollbarSize = getView()->ToWorld( scrollbarSize, false );
377 getView()->SetCenter( getView()->GetCenter() + worldScrollbarSize / 2.0 );
378
379 return 0;
380}
381
382
384{
385 unsigned int idx = aEvent.Parameter<intptr_t>();
386 return doZoomToPreset( (int) idx, false );
387}
388
389
390// Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
391int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
392{
393 std::vector<double>& zoomList = m_toolMgr->GetSettings()->m_Window.zoom_factors;
394
395 if( idx == 0 ) // Zoom Auto
396 {
398 return ZoomFitScreen( dummy );
399 }
400 else
401 {
402 idx--;
403 }
404
405 double scale = zoomList[idx];
406
407 if( aCenterOnCursor )
408 {
409 getView()->SetScale( scale, getViewControls()->GetCursorPosition() );
410
411 if( getViewControls()->IsCursorWarpingEnabled() )
413 }
414 else
415 {
416 getView()->SetScale( scale );
417 }
418
419 return 0;
420}
421
422
423// Grid control
425{
426 int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
427
428 currentGrid++;
429
430 if( currentGrid >= int( m_grids.size() ) )
431 currentGrid = 0;
432
433 return OnGridChanged();
434}
435
436
438{
439 int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
440
441 currentGrid--;
442
443 if( currentGrid < 0 )
444 currentGrid = (int) m_grids.size() - 1;
445
446 return OnGridChanged();
447}
448
449
451{
452 return GridPreset( aEvent.Parameter<intptr_t>() );
453}
454
455
457{
458 int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
459
460 currentGrid = std::max( 0, std::min( idx, (int) m_grids.size() - 1 ) );
461
462 return OnGridChanged();
463}
464
465
467{
468 int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
469
470 currentGrid = std::max( 0, std::min( currentGrid, static_cast<int>( m_grids.size() ) - 1 ) );
471
472 // Update the combobox (if any)
473 wxUpdateUIEvent dummy;
475
476 // Update GAL canvas from screen
477 getView()->GetGAL()->SetGridSize( m_grids[ currentGrid ] );
480
481 // Put cursor on new grid
482 VECTOR2D gridCursor = getViewControls()->GetCursorPosition( true );
483 getViewControls()->SetCrossHairCursorPosition( gridCursor, false );
484
485 return 0;
486}
487
488
490{
492}
493
494
496{
498}
499
500
502{
504
505 return 0;
506}
507
508
510{
511 wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
512
513 cmd.SetId( ID_GRID_SETTINGS );
514 m_frame->ProcessEvent( cmd );
515
516 return 0;
517}
518
519
521{
522 EDA_UNITS newUnit = aEvent.Parameter<EDA_UNITS>();
523
524 if( EDA_UNIT_UTILS::IsMetricUnit( newUnit ) )
525 m_metricUnit = newUnit;
526 else if( EDA_UNIT_UTILS::IsImperialUnit( newUnit ) )
527 m_imperialUnit = newUnit;
528 else
529 wxASSERT_MSG( false, wxS( "Invalid unit for the frame" ) );
530
531 m_frame->ChangeUserUnits( newUnit );
532 return 0;
533}
534
535
537{
541 return 0;
542}
543
544
546{
547 m_frame->SetStatusText( wxEmptyString );
550
551 return 0;
552}
553
554
556{
557 auto vcSettings = m_toolMgr->GetCurrentToolVC();
558
559 // Use either the active tool forced cursor position or the general settings
560 if( vcSettings.m_forceCursorPosition )
561 m_frame->GetScreen()->m_LocalOrigin = vcSettings.m_forcedPosition;
562 else
564
566
567 return 0;
568}
569
570
572{
573 auto& galOpts = m_frame->GetGalDisplayOptions();
574
575 galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor;
576 galOpts.WriteConfig( m_toolMgr->GetSettings()->m_Window );
577 galOpts.NotifyChanged();
578
579 return 0;
580}
581
582
584{
586
587 galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
589 galOpts.NotifyChanged();
590
591 return 0;
592}
593
594
596{
598
599 if( canvas )
600 {
602
604
605 canvas->GetView()->UpdateAllItems( KIGFX::ALL );
606 canvas->ForceRefresh();
607 }
608
609 return 0;
610}
611
612
614{
616
617 // Cursor control
626
630
631 // Pan control
636
637 // Zoom control
648
649 // Grid control
657
658 // Units and coordinates
665
666 // Misc
670}
671
672
BASE_SCREEN class implementation.
Gather all the actions that are shared by tools.
Definition: actions.h:41
static TOOL_ACTION gridProperties
Definition: actions.h:145
static TOOL_ACTION toggleGrid
Definition: actions.h:144
static TOOL_ACTION zoomRedraw
Definition: actions.h:93
static TOOL_ACTION millimetersUnits
Definition: actions.h:150
static TOOL_ACTION gridFast1
Definition: actions.h:137
static TOOL_ACTION gridPrev
Definition: actions.h:140
static TOOL_ACTION cursorLeft
Definition: actions.h:119
static TOOL_ACTION zoomOutCenter
Definition: actions.h:97
static TOOL_ACTION togglePolarCoords
Definition: actions.h:153
static TOOL_ACTION zoomIn
Definition: actions.h:94
static TOOL_ACTION cursorLeftFast
Definition: actions.h:124
static TOOL_ACTION gridPreset
Definition: actions.h:143
static TOOL_ACTION cursorDown
Definition: actions.h:118
static TOOL_ACTION zoomOut
Definition: actions.h:95
static TOOL_ACTION milsUnits
Definition: actions.h:149
static TOOL_ACTION cursorRightFast
Definition: actions.h:125
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:108
static TOOL_ACTION showContextMenu
Definition: actions.h:64
static TOOL_ACTION toggleCursor
Definition: actions.h:104
static TOOL_ACTION centerContents
Definition: actions.h:103
static TOOL_ACTION zoomCenter
Definition: actions.h:98
static TOOL_ACTION panDown
Definition: actions.h:132
static TOOL_ACTION cursorDblClick
Definition: actions.h:128
@ CURSOR_DBL_CLICK
Definition: actions.h:192
@ CURSOR_RIGHT
Definition: actions.h:191
@ CURSOR_FAST_MOVE
Definition: actions.h:193
@ CURSOR_LEFT
Definition: actions.h:191
@ CURSOR_CLICK
Definition: actions.h:192
@ CURSOR_UP
Definition: actions.h:191
@ CURSOR_DOWN
Definition: actions.h:191
@ CURSOR_RIGHT_CLICK
Definition: actions.h:192
static TOOL_ACTION cursorDownFast
Definition: actions.h:123
static TOOL_ACTION inchesUnits
Definition: actions.h:148
static TOOL_ACTION cursorUpFast
Definition: actions.h:122
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:105
static TOOL_ACTION panLeft
Definition: actions.h:133
static TOOL_ACTION selectionTool
Definition: actions.h:157
static TOOL_ACTION cursorClick
Definition: actions.h:127
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION zoomPreset
Definition: actions.h:101
static TOOL_ACTION panUp
Definition: actions.h:131
static TOOL_ACTION zoomFitObjects
Definition: actions.h:100
static TOOL_ACTION toggleUnits
Definition: actions.h:152
static TOOL_ACTION zoomInCenter
Definition: actions.h:96
static TOOL_ACTION panRight
Definition: actions.h:134
static TOOL_ACTION gridFast2
Definition: actions.h:138
static TOOL_ACTION cursorUp
Cursor control with keyboard.
Definition: actions.h:117
static TOOL_ACTION refreshPreview
Definition: actions.h:110
static TOOL_ACTION gridNext
Definition: actions.h:139
static TOOL_ACTION cursorRight
Definition: actions.h:120
static TOOL_ACTION resetLocalCoords
Definition: actions.h:154
WINDOW_SETTINGS m_Window
Definition: app_settings.h:187
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 CenterOnCursor()=0
Set the viewport center to the current cursor position and warps the cursor to the screen center.
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 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:551
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:448
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:1484
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:577
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:215
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:81
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:445
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
const int scale
std::vector< FAB_LAYER_COLOR > dummy
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:99
std::vector< double > zoom_factors
Definition: app_settings.h:96
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:589
VECTOR2I ToVECTOR2I(const wxSize &aSize)
Definition: vector2wx.h:30
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)
Definition: vector2wx.h:40