KiCad PCB EDA Suite
Loading...
Searching...
No Matches
tool_manager.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) 2013-2023 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Tomasz Wlostowski <[email protected]>
7 * @author Maciej Suminski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#include <core/kicad_algo.h>
28#include <optional>
29#include <map>
30#include <stack>
31#include <trace_helpers.h>
32#include <kiplatform/ui.h>
33
34#include <wx/event.h>
35#include <wx/clipbrd.h>
36#include <wx/app.h>
37
38#include <math/vector2wx.h>
39
40#include <view/view.h>
41#include <view/view_controls.h>
42#include <eda_base_frame.h>
43#include <tool/tool_base.h>
45#include <tool/tool_manager.h>
46#include <tool/action_menu.h>
47#include <tool/coroutine.h>
48#include <tool/action_manager.h>
49
51
54{
56 theTool( aTool )
57 {
58 clear();
59 }
60
61 TOOL_STATE( const TOOL_STATE& aState )
62 {
63 theTool = aState.theTool;
64 idle = aState.idle;
65 shutdown = aState.shutdown;
66 pendingWait = aState.pendingWait;
68 contextMenu = aState.contextMenu;
70 cofunc = aState.cofunc;
72 wakeupEvent = aState.wakeupEvent;
73 waitEvents = aState.waitEvents;
74 transitions = aState.transitions;
75 vcSettings = aState.vcSettings;
76 // do not copy stateStack
77 }
78
80 {
81 if( !stateStack.empty() )
82 wxFAIL;
83 }
84
87
89 bool idle;
90
93
97
100
103
106
109
112
115
118
121 std::vector<TRANSITION> transitions;
122
125
127 {
128 theTool = aState.theTool;
129 idle = aState.idle;
130 shutdown = aState.shutdown;
131 pendingWait = aState.pendingWait;
133 contextMenu = aState.contextMenu;
135 cofunc = aState.cofunc;
136 initialEvent = aState.initialEvent;
137 wakeupEvent = aState.wakeupEvent;
138 waitEvents = aState.waitEvents;
139 transitions = aState.transitions;
140 vcSettings = aState.vcSettings;
141
142 // do not copy stateStack
143 return *this;
144 }
145
146 bool operator==( const TOOL_MANAGER::TOOL_STATE& aRhs ) const
147 {
148 return aRhs.theTool == theTool;
149 }
150
151 bool operator!=( const TOOL_MANAGER::TOOL_STATE& aRhs ) const
152 {
153 return aRhs.theTool != theTool;
154 }
155
160 void Push()
161 {
162 auto state = std::make_unique<TOOL_STATE>( *this );
163 stateStack.push( std::move( state ) );
164 clear();
165 }
166
173 bool Pop()
174 {
175 delete cofunc;
176
177 if( !stateStack.empty() )
178 {
179 *this = *stateStack.top().get();
180 stateStack.pop();
181 return true;
182 }
183 else
184 {
185 cofunc = nullptr;
186 return false;
187 }
188 }
189
190private:
192 std::stack<std::unique_ptr<TOOL_STATE>> stateStack;
193
195 void clear()
196 {
197 idle = true;
198 shutdown = false;
199 pendingWait = false;
200 pendingContextMenu = false;
201 cofunc = nullptr;
202 contextMenu = nullptr;
205 transitions.clear();
206 }
207};
208
209
211 m_model( nullptr ),
212 m_view( nullptr ),
213 m_viewControls( nullptr ),
214 m_frame( nullptr ),
215 m_settings( nullptr ),
216 m_warpMouseAfterContextMenu( true ),
217 m_menuActive( false ),
218 m_menuOwner( -1 ),
219 m_activeState( nullptr ),
220 m_shuttingDown( false )
221{
222 m_actionMgr = new ACTION_MANAGER( this );
223}
224
225
227{
228 std::map<TOOL_BASE*, TOOL_STATE*>::iterator it, it_end;
229
230 for( it = m_toolState.begin(), it_end = m_toolState.end(); it != it_end; ++it )
231 {
232 delete it->second->cofunc; // delete cofunction
233 delete it->second; // delete TOOL_STATE
234 delete it->first; // delete the tool itself
235 }
236
237 delete m_actionMgr;
238}
239
240
242{
243 wxASSERT_MSG( m_toolNameIndex.find( aTool->GetName() ) == m_toolNameIndex.end(),
244 wxT( "Adding two tools with the same name may result in unexpected behavior.") );
245 wxASSERT_MSG( m_toolIdIndex.find( aTool->GetId() ) == m_toolIdIndex.end(),
246 wxT( "Adding two tools with the same ID may result in unexpected behavior.") );
247 wxASSERT_MSG( m_toolTypes.find( typeid( *aTool ).name() ) == m_toolTypes.end(),
248 wxT( "Adding two tools of the same type may result in unexpected behavior.") );
249
250 wxLogTrace( kicadTraceToolStack,
251 wxS( "TOOL_MANAGER::RegisterTool: Registering tool %s with ID %d" ),
252 aTool->GetName(), aTool->GetId() );
253
254 m_toolOrder.push_back( aTool );
255
256 TOOL_STATE* st = new TOOL_STATE( aTool );
257
258 m_toolState[aTool] = st;
259 m_toolNameIndex[aTool->GetName()] = st;
260 m_toolIdIndex[aTool->GetId()] = st;
261 m_toolTypes[typeid( *aTool ).name()] = st->theTool;
262
263 aTool->attachManager( this );
264}
265
266
268{
269 TOOL_BASE* tool = FindTool( aToolId );
270
271 if( tool && tool->GetType() == INTERACTIVE )
272 return invokeTool( tool );
273
274 wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::InvokeTool - no tool with ID %d" ),
275 aToolId );
276
277 return false; // there is no tool with the given id
278}
279
280
281bool TOOL_MANAGER::InvokeTool( const std::string& aToolName )
282{
283 TOOL_BASE* tool = FindTool( aToolName );
284
285 if( tool && tool->GetType() == INTERACTIVE )
286 return invokeTool( tool );
287
288 wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::InvokeTool - no tool with name %s" ),
289 aToolName );
290
291 return false; // there is no tool with the given name
292}
293
294
295bool TOOL_MANAGER::doRunAction( const std::string& aActionName, bool aNow, const ki::any& aParam,
296 COMMIT* aCommit )
297{
298 TOOL_ACTION* action = m_actionMgr->FindAction( aActionName );
299
300 if( !action )
301 {
302 wxASSERT_MSG( false, wxString::Format( "Could not find action %s.", aActionName ) );
303 return false;
304 }
305
306 doRunAction( *action, aNow, aParam, aCommit );
307
308 return true;
309}
310
311
313{
314 if( m_viewControls )
316 else
318}
319
320
322{
323 if( m_viewControls )
325 else
327}
328
329
330bool TOOL_MANAGER::doRunAction( const TOOL_ACTION& aAction, bool aNow, const ki::any& aParam,
331 COMMIT* aCommit )
332{
333 if( m_shuttingDown )
334 return true;
335
336 bool retVal = false;
337 TOOL_EVENT event = aAction.MakeEvent();
338
339 // We initialize the SYNCHRONOUS state to finished so that tools that don't have an event
340 // loop won't hang if someone forgets to set the state.
341 std::atomic<SYNCRONOUS_TOOL_STATE> synchronousControl = STS_FINISHED;
342
343 if( event.Category() == TC_COMMAND )
344 event.SetMousePosition( GetCursorPosition() );
345
346 // Allow to override the action parameter
347 if( aParam.has_value() )
348 event.SetParameter( aParam );
349
350 // Pass the commit (if any)
351 if( aCommit )
352 {
353 event.SetSynchronous( &synchronousControl );
354 event.SetCommit( aCommit );
355 }
356
357 if( aNow )
358 {
359 TOOL_STATE* current = m_activeState;
360
361 if( aCommit )
362 {
363 // An event with a commit must be run synchronously
364 processEvent( event );
365
366 while( synchronousControl == STS_RUNNING )
367 {
368 wxYield(); // Needed to honor mouse (and other) events during editing
369 wxMilliSleep( 1 ); // Needed to avoid 100% use of one cpu core.
370 // The sleeping time must be must be small to avoid
371 // noticeable lag in mouse and editing events
372 // (1 to 5 ms is a good value)
373 }
374
375 retVal = synchronousControl != STS_CANCELLED;
376 }
377 else
378 {
379 retVal = processEvent( event );
380 }
381
382 setActiveState( current );
383 UpdateUI( event );
384 }
385 else
386 {
387 PostEvent( event );
388 }
389
390 return retVal;
391}
392
393
395{
397
398 processEvent( evt );
399}
400
401
402void TOOL_MANAGER::PrimeTool( const VECTOR2D& aPosition )
403{
404 int modifiers = 0;
405
406 /*
407 * Don't include any modifiers. They're part of the hotkey, not part of the resulting
408 * click.
409 *
410 * modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
411 * modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
412 * modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
413 */
414
415 TOOL_EVENT evt( TC_MOUSE, TA_PRIME, BUT_LEFT | modifiers );
416 evt.SetMousePosition( aPosition );
417
418 PostEvent( evt );
419}
420
421
423{
424 // Horrific hack, but it's a crash bug. Don't let inter-frame commands stack up
425 // waiting to be processed.
426 if( aEvent.IsSimulator() && m_eventQueue.size() > 0 && m_eventQueue.back().IsSimulator() )
427 m_eventQueue.pop_back();
428
429 m_eventQueue.push_back( aEvent );
430}
431
432
433int TOOL_MANAGER::GetHotKey( const TOOL_ACTION& aAction ) const
434{
435 return m_actionMgr->GetHotKey( aAction );
436}
437
438
440{
441 wxASSERT( aTool != nullptr );
442
443 TOOL_EVENT evt( TC_COMMAND, TA_ACTIVATE, aTool->GetName() );
445 processEvent( evt );
446
447 if( TOOL_STATE* active = GetCurrentToolState() )
448 setActiveState( active );
449
450 return true;
451}
452
453
455{
456 wxASSERT( aTool != nullptr );
457
458 if( !isRegistered( aTool ) )
459 {
460 wxASSERT_MSG( false, wxT( "You cannot run unregistered tools" ) );
461 return false;
462 }
463
464 TOOL_ID id = aTool->GetId();
465
466 wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::runTool - running tool %s" ),
467 aTool->GetName() );
468
469 if( aTool->GetType() == INTERACTIVE )
470 static_cast<TOOL_INTERACTIVE*>( aTool )->resetTransitions();
471
472 // If the tool is already active, bring it to the top of the active tools stack
473 if( isActive( aTool ) && m_activeTools.size() > 1 )
474 {
475 auto it = std::find( m_activeTools.begin(), m_activeTools.end(), id );
476
477 if( it != m_activeTools.end() )
478 {
479 if( it != m_activeTools.begin() )
480 {
481 m_activeTools.erase( it );
482 m_activeTools.push_front( id );
483 }
484
485 return false;
486 }
487 }
488
491
492 // Add the tool on the front of the processing queue (it gets events first)
493 m_activeTools.push_front( id );
494
495 return true;
496}
497
498
500{
501 m_shuttingDown = true;
502
503 // Create a temporary list of tools to iterate over since when the tools shutdown
504 // they remove themselves from the list automatically (invalidating the iterator)
505 ID_LIST tmpList = m_activeTools;
506
507 // Make sure each tool knows that it is shutting down, so that loops get shut down
508 // at the dispatcher
509 for( auto id : tmpList )
510 {
511 if( m_toolIdIndex.count( id ) == 0 )
512 continue;
513
514 m_toolIdIndex[id]->shutdown = true;
515 }
516
517 for( auto id : tmpList )
518 {
519 ShutdownTool( id );
520 }
521}
522
523
525{
526 TOOL_BASE* tool = FindTool( aToolId );
527
528 if( tool && tool->GetType() == INTERACTIVE )
529 ShutdownTool( tool );
530
531 wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::ShutdownTool - no tool with ID %d" ),
532 aToolId );
533}
534
535
536void TOOL_MANAGER::ShutdownTool( const std::string& aToolName )
537{
538 TOOL_BASE* tool = FindTool( aToolName );
539
540 if( tool && tool->GetType() == INTERACTIVE )
541 ShutdownTool( tool );
542
543 wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::ShutdownTool - no tool with name %s" ),
544 aToolName );
545}
546
547
549{
550 wxASSERT( aTool != nullptr );
551
552 TOOL_ID id = aTool->GetId();
553
554 if( isActive( aTool ) )
555 {
556 TOOL_MANAGER::ID_LIST::iterator it = std::find( m_activeTools.begin(),
557 m_activeTools.end(), id );
558
559 TOOL_STATE* st = m_toolIdIndex[*it];
560
561 // the tool state handler is waiting for events (i.e. called Wait() method)
562 if( st && st->pendingWait )
563 {
564 // Wake up the tool and tell it to shutdown
565 st->shutdown = true;
566 st->pendingWait = false;
567 st->waitEvents.clear();
568
569 if( st->cofunc )
570 {
571 wxLogTrace( kicadTraceToolStack,
572 wxS( "TOOL_MANAGER::ShutdownTool - Shutting down tool %s" ),
573 st->theTool->GetName() );
574
575 setActiveState( st );
576 bool end = !st->cofunc->Resume();
577
578 if( end )
579 finishTool( st );
580 }
581 }
582 }
583}
584
585
587{
588 std::map<TOOL_ID, TOOL_STATE*>::const_iterator it = m_toolIdIndex.find( aId );
589
590 if( it != m_toolIdIndex.end() )
591 return it->second->theTool;
592
593 return nullptr;
594}
595
596
597TOOL_BASE* TOOL_MANAGER::FindTool( const std::string& aName ) const
598{
599 std::map<std::string, TOOL_STATE*>::const_iterator it = m_toolNameIndex.find( aName );
600
601 if( it != m_toolNameIndex.end() )
602 return it->second->theTool;
603
604 return nullptr;
605}
606
607
609{
610 // Deactivate the active tool, but do not run anything new
612 processEvent( evt );
613}
614
615
617{
618 if( aReason != TOOL_BASE::REDRAW )
620
621 for( auto& state : m_toolState )
622 {
623 TOOL_BASE* tool = state.first;
624
625 wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::ResetTools: Resetting tool '%s'" ),
626 tool->GetName() );
627
628 setActiveState( state.second );
629 tool->Reset( aReason );
630
631 if( tool->GetType() == INTERACTIVE )
632 static_cast<TOOL_INTERACTIVE*>( tool )->resetTransitions();
633 }
634}
635
636
638{
639 for( auto it = m_toolOrder.begin(); it != m_toolOrder.end(); /* iter inside */ )
640 {
641 TOOL_BASE* tool = *it;
642 wxASSERT( m_toolState.count( tool ) );
643 TOOL_STATE* state = m_toolState[tool];
644 setActiveState( state );
645 ++it; // keep the iterator valid if the element is going to be erased
646
647 if( !tool->Init() )
648 {
649 wxLogTrace( kicadTraceToolStack,
650 wxS( "TOOL_MANAGER initialization of tool '%s' failed" ),
651 tool->GetName() );
652
653 // Unregister the tool
654 setActiveState( nullptr );
655 m_toolState.erase( tool );
656 m_toolNameIndex.erase( tool->GetName() );
657 m_toolIdIndex.erase( tool->GetId() );
658 m_toolTypes.erase( typeid( *tool ).name() );
659
660 delete state;
661 delete tool;
662 }
663 }
664
665 m_actionMgr->UpdateHotKeys( true );
666
668}
669
670
671int TOOL_MANAGER::GetPriority( int aToolId ) const
672{
673 int priority = 0;
674
675 for( TOOL_ID tool : m_activeTools )
676 {
677 if( tool == aToolId )
678 return priority;
679
680 ++priority;
681 }
682
683 return -1;
684}
685
686
688 const TOOL_EVENT_LIST& aConditions )
689{
690 TOOL_STATE* st = m_toolState[aTool];
691
692 st->transitions.emplace_back( TRANSITION( aConditions, aHandler ) );
693}
694
695
697{
698 m_toolState[aTool]->transitions.clear();
699}
700
701
702void TOOL_MANAGER::RunMainStack( TOOL_BASE* aTool, std::function<void()> aFunc )
703{
704 TOOL_STATE* st = m_toolState[aTool];
705 setActiveState( st );
706 wxCHECK( st->cofunc, /* void */ );
707 st->cofunc->RunMainStack( std::move( aFunc ) );
708}
709
710
712{
713 TOOL_STATE* st = m_toolState[aTool];
714
715 wxCHECK( !st->pendingWait, nullptr ); // everything collapses on two KiYield() in a row
716
717 // indicate to the manager that we are going to sleep and we shall be
718 // woken up when an event matching aConditions arrive
719 st->pendingWait = true;
720 st->waitEvents = aConditions;
721
722 wxCHECK( st->cofunc, nullptr );
723
724 // switch context back to event dispatcher loop
725 st->cofunc->KiYield();
726
727 // If the tool should shutdown, it gets a null event to break the loop
728 if( st->shutdown )
729 return nullptr;
730 else
731 return &st->wakeupEvent;
732}
733
734
736{
737 bool handled = false;
738
739 wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::dispatchInternal - received event: %s" ),
740 aEvent.Format() );
741
742 auto it = m_activeTools.begin();
743
744 // iterate over active tool stack
745 while( it != m_activeTools.end() )
746 {
747 TOOL_STATE* st = m_toolIdIndex[*it];
748 bool increment = true;
749
750 // forward context menu events to the tool that created the menu
751 if( aEvent.IsChoiceMenu() )
752 {
753 if( *it != m_menuOwner )
754 {
755 ++it;
756 continue;
757 }
758 }
759
760 // If we're pendingWait then we had better have a cofunc to process the wait.
761 wxASSERT( !st || !st->pendingWait || st->cofunc );
762
763 // the tool state handler is waiting for events (i.e. called Wait() method)
764 if( st && st->cofunc && st->pendingWait && st->waitEvents.Matches( aEvent ) )
765 {
766 if( !aEvent.FirstResponder() )
767 aEvent.SetFirstResponder( st->theTool );
768
769 // got matching event? clear wait list and wake up the coroutine
770 st->wakeupEvent = aEvent;
771 st->pendingWait = false;
772 st->waitEvents.clear();
773
774 wxLogTrace( kicadTraceToolStack,
775 wxS( "TOOL_MANAGER::dispatchInternal - Waking tool %s for event: %s" ),
776 st->theTool->GetName(), aEvent.Format() );
777
778 setActiveState( st );
779 bool end = !st->cofunc->Resume();
780
781 if( end )
782 {
783 it = finishTool( st );
784 increment = false;
785 }
786
787 // If the tool did not request the event be passed to other tools, we're done
788 if( !st->wakeupEvent.PassEvent() )
789 {
790 wxLogTrace( kicadTraceToolStack,
791 wxS( "TOOL_MANAGER::dispatchInternal - tool %s stopped passing "
792 "event: %s" ),
793 st->theTool->GetName(), aEvent.Format() );
794
795 return true;
796 }
797 }
798
799 if( increment )
800 ++it;
801 }
802
803 for( const auto& state : m_toolState )
804 {
805 TOOL_STATE* st = state.second;
806 bool finished = false;
807
808 // no state handler in progress - check if there are any transitions (defined by
809 // Go() method that match the event.
810 if( !st->transitions.empty() )
811 {
812 for( const TRANSITION& tr : st->transitions )
813 {
814 if( tr.first.Matches( aEvent ) )
815 {
816 auto func_copy = tr.second;
817
818 if( !aEvent.FirstResponder() )
819 aEvent.SetFirstResponder( st->theTool );
820
821 // if there is already a context, then push it on the stack
822 // and transfer the previous view control settings to the new context
823 if( st->cofunc )
824 {
825 KIGFX::VC_SETTINGS viewControlSettings = st->vcSettings;
826 st->Push();
827 st->vcSettings = std::move( viewControlSettings );
828 }
829
830 st->cofunc = new COROUTINE<int, const TOOL_EVENT&>( std::move( func_copy ) );
831
832 wxLogTrace( kicadTraceToolStack,
833 wxS( "TOOL_MANAGER::dispatchInternal - Running tool %s for "
834 "event: %s" ),
835 st->theTool->GetName(), aEvent.Format() );
836
837 // got match? Run the handler.
838 setActiveState( st );
839 st->idle = false;
840 st->initialEvent = aEvent;
841 st->cofunc->Call( st->initialEvent );
842 handled = true;
843
844 if( !st->cofunc->Running() )
845 finishTool( st ); // The coroutine has finished immediately?
846
847 // if it is a message, continue processing
848 finished = !( aEvent.Category() == TC_MESSAGE );
849
850 // there is no point in further checking, as transitions got cleared
851 break;
852 }
853 }
854 }
855
856 if( finished )
857 break; // only the first tool gets the event
858 }
859
860 wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::dispatchInternal - %s handle event: %s" ),
861 ( handled ? wxS( "Did" ) : wxS( "Did not" ) ), aEvent.Format() );
862
863 return handled;
864}
865
866
868{
869 if( aEvent.Action() == TA_KEY_PRESSED )
870 return m_actionMgr->RunHotKey( aEvent.Modifier() | aEvent.KeyCode() );
871
872 return false;
873}
874
875
877{
878 wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::dispatchActivation - Received event: %s" ),
879 aEvent.Format() );
880
881 if( aEvent.IsActivate() )
882 {
883 auto tool = m_toolNameIndex.find( aEvent.getCommandStr() );
884
885 if( tool != m_toolNameIndex.end() )
886 {
887 wxLogTrace( kicadTraceToolStack,
888 wxS( "TOOL_MANAGER::dispatchActivation - Running tool %s for event: %s" ),
889 tool->second->theTool->GetName(), aEvent.Format() );
890
891 runTool( tool->second->theTool );
892 return true;
893 }
894 }
895
896 return false;
897}
898
899
901{
902 for( TOOL_ID toolId : m_activeTools )
903 {
904 TOOL_STATE* st = m_toolIdIndex[toolId];
905
906 // the tool requested a context menu. The menu is activated on RMB click (CMENU_BUTTON mode)
907 // or immediately (CMENU_NOW) mode. The latter is used for clarification lists.
908 if( st->contextMenuTrigger == CMENU_OFF )
909 continue;
910
911 if( st->contextMenuTrigger == CMENU_BUTTON && !aEvent.IsClick( BUT_RIGHT ) )
912 break;
913
914 if( st->cofunc )
915 {
916 st->pendingWait = true;
918 }
919
920 // Store the menu pointer in case it is changed by the TOOL when handling menu events
921 ACTION_MENU* m = st->contextMenu;
922
923 if( st->contextMenuTrigger == CMENU_NOW )
925
926 // Store the cursor position, so the tools could execute actions
927 // using the point where the user has invoked a context menu
928 if( m_viewControls )
930
931 // Save all tools cursor settings, as they will be overridden
932 for( const std::pair<const TOOL_ID, TOOL_STATE*>& idState : m_toolIdIndex )
933 {
934 TOOL_STATE* s = idState.second;
935 const auto& vc = s->vcSettings;
936
937 if( vc.m_forceCursorPosition )
938 m_cursorSettings[idState.first] = vc.m_forcedPosition;
939 else
940 m_cursorSettings[idState.first] = std::nullopt;
941 }
942
943 if( m_viewControls )
945
946 // Display a copy of menu
947 std::unique_ptr<ACTION_MENU> menu( m->Clone() );
948
949 m_menuOwner = toolId;
950 m_menuActive = true;
951
952 if( wxWindow* frame = dynamic_cast<wxWindow*>( m_frame ) )
953 frame->PopupMenu( menu.get() );
954
955 // Warp the cursor if a menu item was selected
956 if( menu->GetSelected() >= 0 )
957 {
960 }
961 // Otherwise notify the tool of a canceled menu
962 else
963 {
965 evt.SetHasPosition( false );
966 evt.SetParameter( m );
967 dispatchInternal( evt );
968 }
969
970 // Restore setting in case it was vetoed
972
973 // Notify the tools that menu has been closed
975 evt.SetHasPosition( false );
976 evt.SetParameter( m );
977 dispatchInternal( evt );
978
979 m_menuActive = false;
980 m_menuOwner = -1;
981
982 // Restore cursor settings
983 for( const std::pair<const TOOL_ID,
984 std::optional<VECTOR2D>>& cursorSetting : m_cursorSettings )
985 {
986 auto it = m_toolIdIndex.find( cursorSetting.first );
987 wxASSERT( it != m_toolIdIndex.end() );
988
989 if( it == m_toolIdIndex.end() )
990 continue;
991
992 KIGFX::VC_SETTINGS& vc = it->second->vcSettings;
993 vc.m_forceCursorPosition = (bool) cursorSetting.second;
994 vc.m_forcedPosition = cursorSetting.second ? *cursorSetting.second : VECTOR2D( 0, 0 );
995 }
996
997 m_cursorSettings.clear();
998 break;
999 }
1000}
1001
1002
1003TOOL_MANAGER::ID_LIST::iterator TOOL_MANAGER::finishTool( TOOL_STATE* aState )
1004{
1005 auto it = std::find( m_activeTools.begin(), m_activeTools.end(), aState->theTool->GetId() );
1006
1007 if( !aState->Pop() )
1008 {
1009 // Deactivate the tool if there are no other contexts saved on the stack
1010 if( it != m_activeTools.end() )
1011 it = m_activeTools.erase( it );
1012
1013 aState->idle = true;
1014 }
1015
1016 if( aState == m_activeState )
1017 setActiveState( nullptr );
1018
1019 return it;
1020}
1021
1022
1024{
1025 // Once the tool manager is shutting down, don't start
1026 // activating more tools
1027 if( m_shuttingDown )
1028 return true;
1029
1030 bool handled = processEvent( aEvent );
1031
1032 TOOL_STATE* activeTool = GetCurrentToolState();
1033
1034 if( activeTool )
1035 setActiveState( activeTool );
1036
1037 if( m_view && m_view->IsDirty() )
1038 {
1039#if defined( __WXMAC__ )
1040 wxTheApp->ProcessPendingEvents(); // required for updating brightening behind a popup menu
1041#endif
1042 }
1043
1044 UpdateUI( aEvent );
1045
1046 return handled;
1047}
1048
1049
1051 CONTEXT_MENU_TRIGGER aTrigger )
1052{
1053 TOOL_STATE* st = m_toolState[aTool];
1054
1055 st->contextMenu = aMenu;
1056 st->contextMenuTrigger = aTrigger;
1057}
1058
1059
1061{
1062 if( TOOL_STATE* active = GetCurrentToolState() )
1063 return active->vcSettings;
1064
1065 return m_viewControls->GetSettings();
1066}
1067
1068
1069TOOL_ID TOOL_MANAGER::MakeToolId( const std::string& aToolName )
1070{
1071 static int currentId;
1072
1073 return currentId++;
1074}
1075
1076
1078 KIGFX::VIEW_CONTROLS* aViewControls,
1079 APP_SETTINGS_BASE* aSettings, TOOLS_HOLDER* aFrame )
1080{
1081 m_model = aModel;
1082 m_view = aView;
1083 m_viewControls = aViewControls;
1084 m_frame = aFrame;
1085 m_settings = aSettings;
1086}
1087
1088
1090{
1091 if( !isRegistered( aTool ) )
1092 return false;
1093
1094 // Just check if the tool is on the active tools stack
1095 return alg::contains( m_activeTools, aTool->GetId() );
1096}
1097
1098
1100{
1102
1103 if( m_menuActive )
1104 {
1105 // Context menu is active, so the cursor settings are overridden (see DispatchContextMenu())
1106 auto it = m_cursorSettings.find( aState->theTool->GetId() );
1107
1108 if( it != m_cursorSettings.end() )
1109 {
1111
1112 // Tool has overridden the cursor position, so store the new settings
1114 {
1115 if( !curr.m_forceCursorPosition )
1116 it->second = std::nullopt;
1117 else
1118 it->second = curr.m_forcedPosition;
1119 }
1120 else
1121 {
1122 std::optional<VECTOR2D> cursor = it->second;
1123
1124 if( cursor )
1125 {
1126 aState->vcSettings.m_forceCursorPosition = true;
1128 }
1129 else
1130 {
1131 aState->vcSettings.m_forceCursorPosition = false;
1132 }
1133 }
1134 }
1135 }
1136}
1137
1138
1140{
1142}
1143
1144
1146{
1147 wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::processEvent - %s" ), aEvent.Format() );
1148
1149 // First try to dispatch the action associated with the event if it is a key press event
1150 bool handled = DispatchHotKey( aEvent );
1151
1152 if( !handled )
1153 {
1154 TOOL_EVENT mod_event( aEvent );
1155
1156 // Only immediate actions get the position. Otherwise clear for tool activation
1157 if( GetToolHolder() && !GetToolHolder()->GetDoImmediateActions() )
1158 {
1159 // An tool-selection-event has no position
1160 if( !mod_event.getCommandStr().empty()
1161 && mod_event.getCommandStr() != GetToolHolder()->CurrentToolName()
1162 && !mod_event.ForceImmediate() )
1163 {
1164 mod_event.SetHasPosition( false );
1165 }
1166 }
1167
1168 // If the event is not handled through a hotkey activation, pass it to the currently
1169 // running tool loops
1170 handled |= dispatchInternal( mod_event );
1171 handled |= dispatchActivation( mod_event );
1172
1173 // Open the context menu if requested by a tool
1174 DispatchContextMenu( mod_event );
1175
1176 // Dispatch any remaining events in the event queue
1177 while( !m_eventQueue.empty() )
1178 {
1179 TOOL_EVENT event = m_eventQueue.front();
1180 m_eventQueue.pop_front();
1181 processEvent( event );
1182 }
1183 }
1184
1185 wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::processEvent - %s handle event: %s" ),
1186 ( handled ? "Did" : "Did not" ), aEvent.Format() );
1187
1188 return handled;
1189}
1190
1191
1193{
1196
1197 m_activeState = aState;
1198
1200 applyViewControls( aState );
1201}
1202
1203
1205{
1206 auto it = m_toolIdIndex.find( aId );
1207
1208 if( it == m_toolIdIndex.end() )
1209 return false;
1210
1211 return !it->second->idle;
1212}
1213
1214
1216{
1217 EDA_BASE_FRAME* frame = dynamic_cast<EDA_BASE_FRAME*>( GetToolHolder() );
1218
1219 if( frame )
1220 frame->UpdateStatusBar();
1221}
Manage TOOL_ACTION objects.
bool RunHotKey(int aHotKey) const
Run an action associated with a hotkey (if there is one available).
TOOL_ACTION * FindAction(const std::string &aActionName) const
Find an action with a given name (if there is one available).
int GetHotKey(const TOOL_ACTION &aAction) const
Return the hot key associated with a given action or 0 if there is none.
void UpdateHotKeys(bool aFullUpdate)
Optionally read the hotkey config files and then rebuilds the internal hotkey maps.
Define the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
ACTION_MENU * Clone() const
Create a deep, recursive copy of this ACTION_MENU.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:92
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition: commit.h:74
Implement a coroutine.
Definition: coroutine.h:84
bool Call(ArgType aArg)
Start execution of a coroutine, passing args as its arguments.
Definition: coroutine.h:274
void KiYield()
Stop execution of the coroutine and returns control to the caller.
Definition: coroutine.h:237
bool Resume()
Resume execution of a previously yielded coroutine.
Definition: coroutine.h:320
bool Running() const
Definition: coroutine.h:369
void RunMainStack(std::function< void()> func)
Run a functor inside the application main stack context.
Definition: coroutine.h:260
The base frame for deriving all KiCad main window classes.
virtual void UpdateStatusBar()
Update the status bar information.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
void ApplySettings(const VC_SETTINGS &aSettings)
Apply VIEW_CONTROLS settings from an object.
const VC_SETTINGS & GetSettings() const
Return the current VIEW_CONTROLS settings.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
bool IsDirty() const
Return true if any of the VIEW layers needs to be refreshened.
Definition: view.h:607
Represent a single user action.
Definition: tool_action.h:269
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Base abstract interface for all kinds of tools.
Definition: tool_base.h:66
virtual void Reset(RESET_REASON aReason)=0
Bring the tool to a known, initial state.
virtual bool Init()
Init() is called once upon a registration of the tool.
Definition: tool_base.h:92
const std::string & GetName() const
Return the name of the tool.
Definition: tool_base.h:136
TOOL_TYPE GetType() const
Return the type of the tool.
Definition: tool_base.h:111
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
@ REDRAW
Full drawing refresh.
Definition: tool_base.h:83
@ RUN
Tool is invoked after being inactive.
Definition: tool_base.h:79
TOOL_ID GetId() const
Return the unique identifier of the tool.
Definition: tool_base.h:123
void attachManager(TOOL_MANAGER *aManager)
Set the TOOL_MANAGER the tool will belong to.
Definition: tool_base.cpp:62
A list of TOOL_EVENTs, with overloaded || operators allowing for concatenating TOOL_EVENTs with littl...
Definition: tool_event.h:640
OPT_TOOL_EVENT Matches(const TOOL_EVENT &aEvent) const
Definition: tool_event.h:679
Generic, UI-independent tool event.
Definition: tool_event.h:168
bool PassEvent() const
These give a tool a method of informing the TOOL_MANAGER that a particular event should be passed on ...
Definition: tool_event.h:252
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition: tool_event.h:247
void SetMousePosition(const VECTOR2D &aP)
Definition: tool_event.h:530
int KeyCode() const
Definition: tool_event.h:373
TOOL_BASE * FirstResponder() const
Definition: tool_event.h:265
bool IsActivate() const
Definition: tool_event.h:342
void SetFirstResponder(TOOL_BASE *aTool)
Definition: tool_event.h:266
bool IsSimulator() const
Indicate if the event is from the simulator.
Definition: tool_event.cpp:257
void SetParameter(T aParam)
Set a non-standard parameter assigned to the event.
Definition: tool_event.h:520
bool ForceImmediate() const
Returns if the action associated with this event should be treated as immediate regardless of the cur...
Definition: tool_event.h:262
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:209
TOOL_EVENT_CATEGORY Category() const
Return the category (eg. mouse/keyboard/action) of an event.
Definition: tool_event.h:244
int Modifier(int aMask=MD_MODIFIER_MASK) const
Return information about key modifiers state (Ctrl, Alt, etc.).
Definition: tool_event.h:363
void SetHasPosition(bool aHasPosition)
Definition: tool_event.h:258
const std::string & getCommandStr() const
Definition: tool_event.h:550
bool IsChoiceMenu() const
Definition: tool_event.h:352
const std::string Format() const
Return information about event in form of a human-readable string.
Definition: tool_event.cpp:97
void applyViewControls(const TOOL_STATE *aState)
Apply #VIEW_CONTROLS settings stored in a #TOOL_STATE object.
int GetPriority(int aToolId) const
Return priority of a given tool.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
TOOL_STATE * m_activeState
Pointer to the state object corresponding to the currently executed tool.
Definition: tool_manager.h:678
void UpdateUI(const TOOL_EVENT &aEvent)
Update the status bar and synchronizes toolbars.
std::map< TOOL_ID, std::optional< VECTOR2D > > m_cursorSettings
Original cursor position, if overridden by the context menu handler.
Definition: tool_manager.h:655
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
void ScheduleNextState(TOOL_BASE *aTool, TOOL_STATE_FUNC &aHandler, const TOOL_EVENT_LIST &aConditions)
Define a state transition.
std::map< const char *, TOOL_BASE * > m_toolTypes
Index of the registered tools to easily lookup by their type.
Definition: tool_manager.h:646
bool doRunAction(const TOOL_ACTION &aAction, bool aNow, const ki::any &aParam, COMMIT *aCommit)
Helper function to actually run an action.
bool isRegistered(TOOL_BASE *aTool) const
Return information about a tool registration status.
Definition: tool_manager.h:592
APP_SETTINGS_BASE * m_settings
Definition: tool_manager.h:661
TOOL_STATE * GetCurrentToolState() const
Return the #TOOL_STATE object representing the state of the active tool.
Definition: tool_manager.h:430
VECTOR2D GetCursorPosition() const
std::list< TOOL_EVENT > m_eventQueue
Queue that stores events to be processed at the end of the event processing cycle.
Definition: tool_manager.h:664
std::pair< TOOL_EVENT_LIST, TOOL_STATE_FUNC > TRANSITION
Definition: tool_manager.h:535
void setActiveState(TOOL_STATE *aState)
Save the previous active state and sets a new one.
void DeactivateTool()
Deactivate the currently active tool.
bool dispatchInternal(TOOL_EVENT &aEvent)
Pass an event at first to the active tools, then to all others.
void PrimeTool(const VECTOR2D &aPosition)
"Prime" a tool by sending a cursor left-click event with the mouse position set to the passed in posi...
bool runTool(TOOL_BASE *aTool)
Make a tool active, so it can receive events and react to them.
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
NAME_STATE_MAP m_toolNameIndex
Index of the registered tools current states, associated by tools' names.
Definition: tool_manager.h:640
TOOLS_HOLDER * m_frame
Definition: tool_manager.h:660
void CancelTool()
Send a cancel event to the tool currently at the top of the tool stack.
bool m_warpMouseAfterContextMenu
Definition: tool_manager.h:669
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:659
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:652
const KIGFX::VC_SETTINGS & GetCurrentToolVC() const
Return the view controls settings for the current tool or the general settings if there is no active ...
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:402
VECTOR2D GetMousePosition() const
bool processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
std::list< TOOL_ID > ID_LIST
Definition: tool_manager.h:75
ID_LIST::iterator finishTool(TOOL_STATE *aState)
Deactivate a tool and does the necessary clean up.
bool dispatchActivation(const TOOL_EVENT &aEvent)
Check if it is a valid activation event and invokes a proper tool.
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:643
TOOL_ID m_menuOwner
Tool currently displaying a popup menu. It is negative when there is no menu displayed.
Definition: tool_manager.h:675
KIGFX::VIEW * m_view
Definition: tool_manager.h:658
void ClearTransitions(TOOL_BASE *aTool)
Clear the state transition map for a tool.
bool m_shuttingDown
True if the tool manager is shutting down (don't process additional events)
Definition: tool_manager.h:681
void saveViewControls(TOOL_STATE *aState)
Save the #VIEW_CONTROLS settings to the tool state object.
int GetHotKey(const TOOL_ACTION &aAction) const
Return the hot key associated with a given action or 0 if there is none.
bool m_menuActive
Flag indicating whether a context menu is currently displayed.
Definition: tool_manager.h:672
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:637
void ShutdownTool(TOOL_BASE *aTool)
Shutdown the specified tool by waking it up with a null event to terminate the processing loop.
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:649
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
EDA_ITEM * m_model
Definition: tool_manager.h:657
bool DispatchHotKey(const TOOL_EVENT &aEvent)
Handle specific events, that are intended for TOOL_MANAGER rather than tools.
static TOOL_ID MakeToolId(const std::string &aToolName)
Generate a unique ID from for a tool with given name.
bool invokeTool(TOOL_BASE *aTool)
Invoke a tool by sending a proper event (in contrary to runTool, which makes the tool run for real).
void DispatchContextMenu(const TOOL_EVENT &aEvent)
Handle context menu related events.
std::vector< TOOL_BASE * > m_toolOrder
List of tools in the order they were registered.
Definition: tool_manager.h:634
TOOL_BASE * FindTool(int aId) const
Search for a tool with given ID.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Set behavior of the tool's context popup menu.
TOOL_EVENT * ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pause execution of a given tool until one or more events matching aConditions arrives.
bool IsToolActive(TOOL_ID aId) const
Return true if a tool with given id is active (executing)
bool isActive(TOOL_BASE *aTool) const
Return information about a tool activation status.
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void InitTools()
Initialize all registered tools.
VECTOR2D m_menuCursor
Right click context menu position.
Definition: tool_manager.h:667
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
A type-safe container of any type.
Definition: ki_any.h:93
bool has_value() const noexcept
Report whether there is a contained object or not.
Definition: ki_any.h:312
Base window classes and related definitions.
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
wxPoint GetMousePosition()
Returns the mouse position in screen coordinates.
Definition: wxgtk/ui.cpp:677
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:100
Structure to keep VIEW_CONTROLS settings for easy store/restore operations.
Definition: view_controls.h:43
VECTOR2D m_forcedPosition
Forced cursor position (world coordinates).
Definition: view_controls.h:56
void Reset()
Restore the default settings.
bool m_forceCursorPosition
Is the forced cursor position enabled.
Definition: view_controls.h:59
Struct describing the current execution state of a TOOL.
bool operator!=(const TOOL_MANAGER::TOOL_STATE &aRhs) const
bool Pop()
Restore state of the tool from stack.
bool pendingWait
Flag defining if the tool is waiting for any event (i.e.
bool pendingContextMenu
Is there a context menu being displayed.
void Push()
Store the current state of the tool on stack.
CONTEXT_MENU_TRIGGER contextMenuTrigger
Defines when the context menu is opened.
TOOL_EVENT initialEvent
The first event that triggered activation of the tool.
KIGFX::VC_SETTINGS vcSettings
VIEW_CONTROLS settings to preserve settings when the tools are switched.
TOOL_STATE(const TOOL_STATE &aState)
TOOL_STATE(TOOL_BASE *aTool)
ACTION_MENU * contextMenu
Context menu currently used by the tool.
bool idle
Is the tool active (pending execution) or disabled at the moment.
std::vector< TRANSITION > transitions
List of possible transitions (ie.
void clear()
Restores the initial state.
TOOL_EVENT_LIST waitEvents
List of events the tool is currently waiting for.
COROUTINE< int, const TOOL_EVENT & > * cofunc
Tool execution context.
bool shutdown
Should the tool shutdown during next execution.
std::stack< std::unique_ptr< TOOL_STATE > > stateStack
Stack preserving previous states of a TOOL.
TOOL_BASE * theTool
The tool itself.
TOOL_EVENT wakeupEvent
The event that triggered the execution/wakeup of the tool after Wait() call.
TOOL_STATE & operator=(const TOOL_STATE &aState)
bool operator==(const TOOL_MANAGER::TOOL_STATE &aRhs) const
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
int TOOL_ID
Unique identifier for tools.
Definition: tool_base.h:56
@ INTERACTIVE
Tool that interacts with the user.
Definition: tool_base.h:49
CONTEXT_MENU_TRIGGER
Defines when a context menu is opened.
Definition: tool_event.h:151
@ CMENU_NOW
Right now (after TOOL_INTERACTIVE::SetContextMenu).
Definition: tool_event.h:153
@ CMENU_OFF
Never.
Definition: tool_event.h:154
@ CMENU_BUTTON
On the right button.
Definition: tool_event.h:152
@ TA_ANY
Definition: tool_event.h:126
@ TA_CHOICE_MENU_CHOICE
Context menu choice.
Definition: tool_event.h:98
@ TA_ACTIVATE
Tool activation event.
Definition: tool_event.h:115
@ TA_CHOICE_MENU_CLOSED
Context menu is closed, no matter whether anything has been chosen or not.
Definition: tool_event.h:101
@ TA_PRIME
Tool priming event (a special mouse click).
Definition: tool_event.h:124
@ TA_KEY_PRESSED
Definition: tool_event.h:76
@ TA_CANCEL_TOOL
Tool cancel event.
Definition: tool_event.h:90
@ TC_ANY
Definition: tool_event.h:60
@ TC_COMMAND
Definition: tool_event.h:57
@ TC_MOUSE
Definition: tool_event.h:55
@ TC_MESSAGE
Definition: tool_event.h:58
@ STS_CANCELLED
Definition: tool_event.h:161
@ STS_FINISHED
Definition: tool_event.h:160
@ STS_RUNNING
Definition: tool_event.h:159
@ BUT_LEFT
Definition: tool_event.h:132
@ BUT_RIGHT
Definition: tool_event.h:133
wxLogTrace helper definitions.
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)
Definition: vector2wx.h:40