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>
30 #include <dialogs/dialog_configure_paths.h>
31 #include <eda_draw_frame.h>
32 #include <gal/graphics_abstraction_layer.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 
COMMON_TOOLS()45 COMMON_TOOLS::COMMON_TOOLS() :
46     TOOL_INTERACTIVE( "common.Control" ),
47     m_frame( nullptr ),
48     m_imperialUnit( EDA_UNITS::INCHES ),
49     m_metricUnit( EDA_UNITS::MILLIMETRES )
50 {
51 }
52 
Reset(RESET_REASON aReason)53 void COMMON_TOOLS::Reset( RESET_REASON aReason )
54 {
55     m_frame = getEditFrame<EDA_DRAW_FRAME>();
56 
57     GRID_SETTINGS& settings = m_toolMgr->GetSettings()->m_Window.grid;
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 ),
68                           ValueFromString( EDA_UNITS::MILLIMETRES, settings.user_grid_y ) );
69 
70     OnGridChanged();
71 }
72 
73 
SetLastUnits(EDA_UNITS aUnit)74 void COMMON_TOOLS::SetLastUnits( EDA_UNITS aUnit )
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 
SelectionTool(const TOOL_EVENT & aEvent)85 int COMMON_TOOLS::SelectionTool( const TOOL_EVENT& aEvent )
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 
90     m_toolMgr->ProcessEvent( TOOL_EVENT( TC_COMMAND, TA_CANCEL_TOOL ) );
91     return 0;
92 }
93 
94 
95 // Cursor control
CursorControl(const TOOL_EVENT & aEvent)96 int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent )
97 {
98     long type = aEvent.Parameter<intptr_t>();
99     bool fastMove = type & ACTIONS::CURSOR_FAST_MOVE;
100     type &= ~ACTIONS::CURSOR_FAST_MOVE;
101     bool mirroredX = getView()->IsMirroredX();
102 
103     VECTOR2D cursor = getViewControls()->GetRawCursorPosition( false );
104     VECTOR2D gridSize = getView()->GetGAL()->GetGridSize();
105 
106     if( fastMove )
107         gridSize = gridSize * 10;
108 
109     switch( type )
110     {
111     case ACTIONS::CURSOR_UP:
112         cursor -= VECTOR2D( 0, gridSize.y );
113         break;
114 
115     case ACTIONS::CURSOR_DOWN:
116         cursor += VECTOR2D( 0, gridSize.y );
117         break;
118 
119     case ACTIONS::CURSOR_LEFT:
120         cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
121         break;
122 
123     case ACTIONS::CURSOR_RIGHT:
124         cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
125         break;
126 
127     case ACTIONS::CURSOR_CLICK:              // fall through
128     case ACTIONS::CURSOR_DBL_CLICK:
129     case ACTIONS::CURSOR_RIGHT_CLICK:
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( static_cast<intptr_t>( 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 );
157     m_toolMgr->RunAction( ACTIONS::refreshPreview );
158 
159     return 0;
160 }
161 
162 
PanControl(const TOOL_EVENT & aEvent)163 int COMMON_TOOLS::PanControl( const TOOL_EVENT& aEvent )
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 
177     case ACTIONS::CURSOR_DOWN:
178         center += VECTOR2D( 0, gridSize.y );
179         break;
180 
181     case ACTIONS::CURSOR_LEFT:
182         center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
183         break;
184 
185     case ACTIONS::CURSOR_RIGHT:
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 
ZoomRedraw(const TOOL_EVENT & aEvent)200 int COMMON_TOOLS::ZoomRedraw( const TOOL_EVENT& aEvent )
201 {
202     m_frame->HardRedraw();
203     return 0;
204 }
205 
206 
ZoomInOut(const TOOL_EVENT & aEvent)207 int COMMON_TOOLS::ZoomInOut( const TOOL_EVENT& aEvent )
208 {
209     bool direction = aEvent.IsAction( &ACTIONS::zoomIn );
210     return doZoomInOut( direction, true );
211 }
212 
213 
ZoomInOutCenter(const TOOL_EVENT & aEvent)214 int COMMON_TOOLS::ZoomInOutCenter( const TOOL_EVENT& aEvent )
215 {
216     bool direction = aEvent.IsAction( &ACTIONS::zoomInCenter );
217     return doZoomInOut( direction, false );
218 }
219 
220 
doZoomInOut(bool aDirection,bool aCenterOnCursor)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 
ZoomCenter(const TOOL_EVENT & aEvent)263 int COMMON_TOOLS::ZoomCenter( const TOOL_EVENT& aEvent )
264 {
265     KIGFX::VIEW_CONTROLS* ctls = getViewControls();
266 
267     ctls->CenterOnCursor();
268 
269     return 0;
270 }
271 
272 
ZoomFitScreen(const TOOL_EVENT & aEvent)273 int COMMON_TOOLS::ZoomFitScreen( const TOOL_EVENT& aEvent )
274 {
275     return doZoomFit( ZOOM_FIT_ALL );
276 }
277 
278 
ZoomFitObjects(const TOOL_EVENT & aEvent)279 int COMMON_TOOLS::ZoomFitObjects( const TOOL_EVENT& aEvent )
280 {
281     return doZoomFit( ZOOM_FIT_OBJECTS );
282 }
283 
284 
doZoomFit(ZOOM_FIT_TYPE_T aFitType)285 int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType )
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 
338         if( frame->IsType( FRAME_FOOTPRINT_VIEWER ) || frame->IsType( FRAME_FOOTPRINT_VIEWER_MODAL )
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 
CenterContents(const TOOL_EVENT & aEvent)357 int COMMON_TOOLS::CenterContents( const TOOL_EVENT& aEvent )
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 
ZoomPreset(const TOOL_EVENT & aEvent)376 int COMMON_TOOLS::ZoomPreset( const TOOL_EVENT& aEvent )
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
doZoomToPreset(int idx,bool aCenterOnCursor)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     {
390         TOOL_EVENT dummy;
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() )
405             getViewControls()->CenterOnCursor();
406     }
407     else
408     {
409         getView()->SetScale( scale );
410     }
411 
412     return 0;
413 }
414 
415 
416 // Grid control
GridNext(const TOOL_EVENT & aEvent)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 
GridPrev(const TOOL_EVENT & aEvent)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 
GridPreset(const TOOL_EVENT & aEvent)439 int COMMON_TOOLS::GridPreset( const TOOL_EVENT& aEvent )
440 {
441     return GridPreset( aEvent.Parameter<intptr_t>() );
442 }
443 
444 
GridPreset(int idx)445 int COMMON_TOOLS::GridPreset( int idx )
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 
OnGridChanged()455 int COMMON_TOOLS::OnGridChanged()
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;
463     m_frame->OnUpdateSelectGrid( dummy );
464 
465     // Update GAL canvas from screen
466     getView()->GetGAL()->SetGridSize( m_grids[ currentGrid ] );
467     getView()->GetGAL()->SetGridVisibility( m_toolMgr->GetSettings()->m_Window.grid.show );
468     getView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
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 
GridFast1(const TOOL_EVENT & aEvent)478 int COMMON_TOOLS::GridFast1( const TOOL_EVENT& aEvent )
479 {
480     return GridPreset( m_frame->config()->m_Window.grid.fast_grid_1 );
481 }
482 
483 
GridFast2(const TOOL_EVENT & aEvent)484 int COMMON_TOOLS::GridFast2( const TOOL_EVENT& aEvent )
485 {
486     return GridPreset( m_frame->config()->m_Window.grid.fast_grid_2 );
487 }
488 
489 
ToggleGrid(const TOOL_EVENT & aEvent)490 int COMMON_TOOLS::ToggleGrid( const TOOL_EVENT& aEvent )
491 {
492     m_frame->SetGridVisibility( !m_frame->IsGridVisible() );
493 
494     return 0;
495 }
496 
497 
GridProperties(const TOOL_EVENT & aEvent)498 int COMMON_TOOLS::GridProperties( const TOOL_EVENT& aEvent )
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 
SwitchUnits(const TOOL_EVENT & aEvent)509 int COMMON_TOOLS::SwitchUnits( const TOOL_EVENT& aEvent )
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 
ToggleUnits(const TOOL_EVENT & aEvent)525 int COMMON_TOOLS::ToggleUnits( const TOOL_EVENT& aEvent )
526 {
527     m_frame->ChangeUserUnits( EDA_UNIT_UTILS::IsImperialUnit( m_frame->GetUserUnits() ) ?
528                                       m_metricUnit :
529                                       m_imperialUnit );
530     return 0;
531 }
532 
533 
TogglePolarCoords(const TOOL_EVENT & aEvent)534 int COMMON_TOOLS::TogglePolarCoords( const TOOL_EVENT& aEvent )
535 {
536     m_frame->SetStatusText( wxEmptyString );
537     m_frame->SetShowPolarCoords( !m_frame->GetShowPolarCoords() );
538     m_frame->UpdateStatusBar();
539 
540     return 0;
541 }
542 
543 
ResetLocalCoords(const TOOL_EVENT & aEvent)544 int COMMON_TOOLS::ResetLocalCoords( const TOOL_EVENT& aEvent )
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
552         m_frame->GetScreen()->m_LocalOrigin = getViewControls()->GetCursorPosition();
553 
554     m_frame->UpdateStatusBar();
555 
556     return 0;
557 }
558 
559 
ToggleCursor(const TOOL_EVENT & aEvent)560 int COMMON_TOOLS::ToggleCursor( const TOOL_EVENT& aEvent )
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 
ToggleCursorStyle(const TOOL_EVENT & aEvent)571 int COMMON_TOOLS::ToggleCursorStyle( const TOOL_EVENT& aEvent )
572 {
573     KIGFX::GAL_DISPLAY_OPTIONS& galOpts = m_frame->GetGalDisplayOptions();
574 
575     galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
576     galOpts.NotifyChanged();
577 
578     return 0;
579 }
580 
581 
setTransitions()582 void COMMON_TOOLS::setTransitions()
583 {
584     Go( &COMMON_TOOLS::SelectionTool,      ACTIONS::selectionTool.MakeEvent() );
585 
586     // Cursor control
587     Go( &COMMON_TOOLS::CursorControl,      ACTIONS::cursorUp.MakeEvent() );
588     Go( &COMMON_TOOLS::CursorControl,      ACTIONS::cursorDown.MakeEvent() );
589     Go( &COMMON_TOOLS::CursorControl,      ACTIONS::cursorLeft.MakeEvent() );
590     Go( &COMMON_TOOLS::CursorControl,      ACTIONS::cursorRight.MakeEvent() );
591     Go( &COMMON_TOOLS::CursorControl,      ACTIONS::cursorUpFast.MakeEvent() );
592     Go( &COMMON_TOOLS::CursorControl,      ACTIONS::cursorDownFast.MakeEvent() );
593     Go( &COMMON_TOOLS::CursorControl,      ACTIONS::cursorLeftFast.MakeEvent() );
594     Go( &COMMON_TOOLS::CursorControl,      ACTIONS::cursorRightFast.MakeEvent() );
595 
596     Go( &COMMON_TOOLS::CursorControl,      ACTIONS::cursorClick.MakeEvent() );
597     Go( &COMMON_TOOLS::CursorControl,      ACTIONS::cursorDblClick.MakeEvent() );
598     Go( &COMMON_TOOLS::CursorControl,      ACTIONS::showContextMenu.MakeEvent() );
599 
600     // Pan control
601     Go( &COMMON_TOOLS::PanControl,         ACTIONS::panUp.MakeEvent() );
602     Go( &COMMON_TOOLS::PanControl,         ACTIONS::panDown.MakeEvent() );
603     Go( &COMMON_TOOLS::PanControl,         ACTIONS::panLeft.MakeEvent() );
604     Go( &COMMON_TOOLS::PanControl,         ACTIONS::panRight.MakeEvent() );
605 
606     // Zoom control
607     Go( &COMMON_TOOLS::ZoomRedraw,         ACTIONS::zoomRedraw.MakeEvent() );
608     Go( &COMMON_TOOLS::ZoomInOut,          ACTIONS::zoomIn.MakeEvent() );
609     Go( &COMMON_TOOLS::ZoomInOut,          ACTIONS::zoomOut.MakeEvent() );
610     Go( &COMMON_TOOLS::ZoomInOutCenter,    ACTIONS::zoomInCenter.MakeEvent() );
611     Go( &COMMON_TOOLS::ZoomInOutCenter,    ACTIONS::zoomOutCenter.MakeEvent() );
612     Go( &COMMON_TOOLS::ZoomCenter,         ACTIONS::zoomCenter.MakeEvent() );
613     Go( &COMMON_TOOLS::ZoomFitScreen,      ACTIONS::zoomFitScreen.MakeEvent() );
614     Go( &COMMON_TOOLS::ZoomFitObjects,     ACTIONS::zoomFitObjects.MakeEvent() );
615     Go( &COMMON_TOOLS::ZoomPreset,         ACTIONS::zoomPreset.MakeEvent() );
616     Go( &COMMON_TOOLS::CenterContents,     ACTIONS::centerContents.MakeEvent() );
617 
618     // Grid control
619     Go( &COMMON_TOOLS::GridNext,           ACTIONS::gridNext.MakeEvent() );
620     Go( &COMMON_TOOLS::GridPrev,           ACTIONS::gridPrev.MakeEvent() );
621     Go( &COMMON_TOOLS::GridPreset,         ACTIONS::gridPreset.MakeEvent() );
622     Go( &COMMON_TOOLS::GridFast1,          ACTIONS::gridFast1.MakeEvent() );
623     Go( &COMMON_TOOLS::GridFast2,          ACTIONS::gridFast2.MakeEvent() );
624     Go( &COMMON_TOOLS::ToggleGrid,         ACTIONS::toggleGrid.MakeEvent() );
625     Go( &COMMON_TOOLS::GridProperties,     ACTIONS::gridProperties.MakeEvent() );
626 
627     // Units and coordinates
628     Go( &COMMON_TOOLS::SwitchUnits,        ACTIONS::inchesUnits.MakeEvent() );
629     Go( &COMMON_TOOLS::SwitchUnits,        ACTIONS::milsUnits.MakeEvent() );
630     Go( &COMMON_TOOLS::SwitchUnits,        ACTIONS::millimetersUnits.MakeEvent() );
631     Go( &COMMON_TOOLS::ToggleUnits,        ACTIONS::toggleUnits.MakeEvent() );
632     Go( &COMMON_TOOLS::TogglePolarCoords,  ACTIONS::togglePolarCoords.MakeEvent() );
633     Go( &COMMON_TOOLS::ResetLocalCoords,   ACTIONS::resetLocalCoords.MakeEvent() );
634 
635     // Misc
636     Go( &COMMON_TOOLS::ToggleCursor,       ACTIONS::toggleCursor.MakeEvent() );
637     Go( &COMMON_TOOLS::ToggleCursorStyle,  ACTIONS::toggleCursorStyle.MakeEvent() );
638 }
639 
640 
641