KiCad PCB EDA Suite
ee_selection_tool.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) 2019 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 
25 #include <ee_actions.h>
26 #include <core/typeinfo.h>
27 #include <sch_item.h>
28 #include <ee_selection_tool.h>
29 #include <sch_base_frame.h>
30 #include <sch_edit_frame.h>
31 #include <lib_edit_frame.h>
32 #include <sch_component.h>
33 #include <sch_sheet.h>
34 #include <sch_field.h>
35 #include <view/view.h>
36 #include <view/view_controls.h>
37 #include <view/view_group.h>
39 #include <tool/tool_event.h>
40 #include <tool/tool_manager.h>
42 #include <ee_actions.h>
43 #include <ee_collectors.h>
44 #include <painter.h>
45 #include <eeschema_id.h>
46 #include <menus_helpers.h>
47 #include <ee_hotkeys.h>
48 
49 // Selection tool actions
50 TOOL_ACTION EE_ACTIONS::selectionActivate( "eeschema.InteractiveSelection",
51  AS_GLOBAL, 0, "", "", // No description, not shown anywhere
52  nullptr, AF_ACTIVATE );
53 
54 TOOL_ACTION EE_ACTIONS::selectionTool( "eeschema.InteractiveSelection.selectionTool",
55  AS_GLOBAL, 0, _( "Select item(s)" ), "",
56  cursor_xpm, AF_ACTIVATE );
57 
58 TOOL_ACTION EE_ACTIONS::selectNode( "eeschema.InteractiveSelection.SelectNode",
60  _( "Select Node" ), _( "Select a connection item under the cursor" ) );
61 
62 TOOL_ACTION EE_ACTIONS::selectConnection( "eeschema.InteractiveSelection.SelectConnection",
64  _( "Select Connection" ), _( "Select a complete connection" ) );
65 
66 TOOL_ACTION EE_ACTIONS::selectionMenu( "eeschema.InteractiveSelection.SelectionMenu",
67  AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
68 
69 TOOL_ACTION EE_ACTIONS::addItemToSel( "eeschema.InteractiveSelection.AddItemToSel",
70  AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
71 
72 TOOL_ACTION EE_ACTIONS::addItemsToSel( "eeschema.InteractiveSelection.AddItemsToSel",
73  AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
74 
75 TOOL_ACTION EE_ACTIONS::removeItemFromSel( "eeschema.InteractiveSelection.RemoveItemFromSel",
76  AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
77 
78 TOOL_ACTION EE_ACTIONS::removeItemsFromSel( "eeschema.InteractiveSelection.RemoveItemsFromSel",
79  AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
80 
81 TOOL_ACTION EE_ACTIONS::clearSelection( "eeschema.InteractiveSelection.ClearSelection",
82  AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere
83 
84 
85 SELECTION_CONDITION EE_CONDITIONS::Empty = [] (const SELECTION& aSelection )
86 {
87  return aSelection.Empty();
88 };
89 
90 
91 SELECTION_CONDITION EE_CONDITIONS::Idle = [] (const SELECTION& aSelection )
92 {
93  return ( !aSelection.Front() || aSelection.Front()->GetEditFlags() == 0 );
94 };
95 
96 
98 {
99  return ( aSelection.Front() && aSelection.Front()->GetEditFlags() == 0 );
100 };
101 
102 
104 {
105  if( aSel.GetSize() == 1 )
106  {
107  SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( aSel.Front() );
108 
109  if( comp )
110  {
111  auto partRef = comp->GetPartRef().lock();
112  return !partRef || !partRef->IsPower();
113  }
114  }
115 
116  return false;
117 };
118 
119 
121 {
122  if( aSel.GetSize() == 1 )
123  {
124  SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( aSel.Front() );
125 
126  if( comp )
127  {
128  auto partRef = comp->GetPartRef().lock();
129  return partRef && partRef->HasConversion();
130  }
131  }
132 
133  return false;
134 };
135 
136 
138 {
139  if( aSel.GetSize() == 1 )
140  {
141  SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( aSel.Front() );
142 
143  if( comp )
144  {
145  auto partRef = comp->GetPartRef().lock();
146  return partRef && partRef->GetUnitCount() >= 2;
147  }
148  }
149 
150  return false;
151 };
152 
153 
154 #define HITTEST_THRESHOLD_PIXELS 5
155 
156 
158  TOOL_INTERACTIVE( "eeschema.InteractiveSelection" ),
159  m_frame( nullptr ),
160  m_additive( false ),
161  m_subtractive( false ),
162  m_multiple( false ),
163  m_skip_heuristics( false ),
164  m_isLibEdit( false ),
165  m_unit( 0 ),
166  m_convert( 0 ),
167  m_menu( *this )
168 {
169 }
170 
171 
173 {
174  getView()->Remove( &m_selection );
175 }
176 
177 
179 {
180  m_frame = getEditFrame<SCH_BASE_FRAME>();
181 
182  LIB_EDIT_FRAME* libEditFrame = dynamic_cast<LIB_EDIT_FRAME*>( m_frame );
183 
184  if( libEditFrame )
185  {
186  m_isLibEdit = true;
187  m_unit = libEditFrame->GetUnit();
188  m_convert = libEditFrame->GetConvert();
189  }
190 
191  static KICAD_T wireOrBusTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
192 
193  auto wireSelection = EE_CONDITIONS::MoreThan( 0 )
195 
196  auto busSelection = EE_CONDITIONS::MoreThan( 0 )
198 
199  auto wireOrBusSelection = EE_CONDITIONS::MoreThan( 0 )
200  && EE_CONDITIONS::OnlyTypes( wireOrBusTypes );
201 
202  auto sheetSelection = SELECTION_CONDITIONS::Count( 1 )
204 
205  auto libEdit = [this] ( const SELECTION& aSel ) {
206  return m_isLibEdit;
207  };
208 
209  auto belowRootSheetCondition = [this] ( const SELECTION& aSel ) {
210  return !m_isLibEdit && g_CurrentSheet->Last() != g_RootSheet;
211  };
212 
213  auto& menu = m_menu.GetMenu();
214 
215  menu.AddItem( EE_ACTIONS::enterSheet, sheetSelection && EE_CONDITIONS::Idle, 1 );
216  menu.AddItem( EE_ACTIONS::explicitCrossProbe, sheetSelection && EE_CONDITIONS::Idle, 1 );
217  menu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 1 );
218 
219  menu.AddSeparator( EE_CONDITIONS::Empty, 100 );
220  menu.AddItem( EE_ACTIONS::startWire, !libEdit && EE_CONDITIONS::Empty, 100 );
221  menu.AddItem( EE_ACTIONS::startBus, !libEdit && EE_CONDITIONS::Empty, 100 );
222 
223  menu.AddSeparator( SCH_WIRE_BUS_TOOL::IsDrawingWire, 100 );
225 
226  menu.AddSeparator( SCH_WIRE_BUS_TOOL::IsDrawingBus, 100 );
228 
229  menu.AddSeparator( EE_CONDITIONS::NotEmpty, 200 );
230  menu.AddItem( EE_ACTIONS::selectConnection, wireOrBusSelection && EE_CONDITIONS::Idle, 200 );
231  menu.AddItem( EE_ACTIONS::addJunction, wireOrBusSelection && EE_CONDITIONS::Idle, 200 );
232  menu.AddItem( EE_ACTIONS::addLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 200 );
233  menu.AddItem( EE_ACTIONS::addGlobalLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 200 );
234  menu.AddItem( EE_ACTIONS::addHierLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 200 );
235  menu.AddItem( EE_ACTIONS::breakWire, wireSelection && EE_CONDITIONS::Idle, 200 );
236  menu.AddItem( EE_ACTIONS::breakBus, busSelection && EE_CONDITIONS::Idle, 200 );
237  menu.AddItem( EE_ACTIONS::importSheetPin, sheetSelection && EE_CONDITIONS::Idle, 200 );
238 
239  menu.AddSeparator( libEdit && EE_CONDITIONS::Empty, 400 );
240  menu.AddItem( EE_ACTIONS::symbolProperties, libEdit && EE_CONDITIONS::Empty, 400 );
241  menu.AddItem( EE_ACTIONS::pinTable, libEdit && EE_CONDITIONS::Empty, 400 );
242 
243  menu.AddSeparator( SELECTION_CONDITIONS::ShowAlways, 1000 );
245 
246  return true;
247 }
248 
249 
251 {
252  m_frame = getEditFrame<SCH_BASE_FRAME>();
253 
254  if( aReason == TOOL_BASE::MODEL_RELOAD )
255  {
256  // Remove pointers to the selected items from containers without changing their
257  // properties (as they are already deleted while a new sheet is loaded)
258  m_selection.Clear();
259  getView()->GetPainter()->GetSettings()->SetHighlight( false );
260 
261  LIB_EDIT_FRAME* libEditFrame = dynamic_cast<LIB_EDIT_FRAME*>( m_frame );
262 
263  if( libEditFrame )
264  {
265  m_isLibEdit = true;
266  m_unit = libEditFrame->GetUnit();
267  m_convert = libEditFrame->GetConvert();
268  }
269  }
270  else
271  // Restore previous properties of selected items and remove them from containers
272  clearSelection();
273 
274  // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
275  getView()->Remove( &m_selection );
276  getView()->Add( &m_selection );
277 }
278 
279 
281 {
282  ACTION_MENU* actionMenu = aEvent.Parameter<ACTION_MENU*>();
283  CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
284 
285  if( conditionalMenu )
286  conditionalMenu->Evaluate( m_selection );
287 
288  if( actionMenu )
289  actionMenu->UpdateAll();
290 
291  return 0;
292 }
293 
294 
296 {
297  // Main loop: keep receiving events
298  while( OPT_TOOL_EVENT evt = Wait() )
299  {
300  // Should selected items be added to the current selection or
301  // become the new selection (discarding previously selected items)
302  m_additive = evt->Modifier( MD_SHIFT );
303 
304  // Should selected items be REMOVED from the current selection?
305  // This will be ignored if the SHIFT modifier is pressed
306  m_subtractive = !m_additive && evt->Modifier( MD_CTRL );
307 
308  // Is the user requesting that the selection list include all possible
309  // items without removing less likely selection candidates
310  m_skip_heuristics = !!evt->Modifier( MD_ALT );
311 
312  // Single click? Select single object
313  if( evt->IsClick( BUT_LEFT ) )
314  {
315  // JEY TODO: this is a hack, but I can't figure out why it's needed to
316  // keep from getting the first click when running the Place Symbol tool.
318  continue;
319 
320  if( evt->Modifier( MD_CTRL ) && dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
321  {
323  }
324  else
325  {
326  // If no modifier keys are pressed, clear the selection
327  if( !m_additive )
328  clearSelection();
329 
330  SelectPoint( evt->Position());
331  }
332  }
333 
334  // right click? if there is any object - show the context menu
335  else if( evt->IsClick( BUT_RIGHT ) )
336  {
337  bool selectionCancelled = false;
338 
339  if( m_selection.Empty() )
340  {
341  SelectPoint( evt->Position(), EE_COLLECTOR::AllItems, &selectionCancelled );
342  m_selection.SetIsHover( true );
343  }
344 
345  if( !selectionCancelled )
347  }
348 
349  // double click? Display the properties window
350  else if( evt->IsDblClick( BUT_LEFT ) )
351  {
352  if( m_selection.Empty() )
353  SelectPoint( evt->Position());
354 
355  EDA_ITEM* item = m_selection.Front();
356 
357  if( item && item->Type() == SCH_SHEET_T )
359  else
361  }
362 
363  // drag with LMB? Select multiple objects (or at least draw a selection box) or drag them
364  else if( evt->IsDrag( BUT_LEFT ) )
365  {
367  {
368  selectMultiple();
369  }
370  else
371  {
372  // Check if dragging has started within any of selected items bounding box
373  if( selectionContains( evt->Position() ) )
374  {
375  // Yes -> run the move tool and wait till it finishes
376  m_toolMgr->InvokeTool( "eeschema.InteractiveEdit" );
377  }
378  else
379  {
380  // No -> clear the selection list
381  clearSelection();
382  }
383  }
384  }
385 
386  // context sub-menu selection? Handle unit selection or bus unfolding
387  else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CONTEXT_MENU_CHOICE )
388  {
389  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
390  && evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_CMP_MAX )
391  {
392  SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( m_selection.Front() );
393  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
394 
395  if( component )
396  static_cast<SCH_EDIT_FRAME*>( m_frame )->SelectUnit( component, unit );
397  }
398  else if( evt->GetCommandId().get() >= ID_POPUP_SCH_UNFOLD_BUS
399  && evt->GetCommandId().get() <= ID_POPUP_SCH_UNFOLD_BUS_END )
400  {
401  wxString* net = new wxString( *evt->Parameter<wxString*>() );
403  }
404 
405  }
406 
407  else if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsCancel() )
408  {
409  clearSelection();
411  }
412 
413  else if( evt->Action() == TA_UNDO_REDO_PRE )
414  {
415  clearSelection();
416  }
417 
418  else if( evt->Action() == TA_CONTEXT_MENU_CLOSED )
419  {
420  m_menu.CloseContextMenu( evt );
421  }
422  }
423 
424  // This tool is supposed to be active forever
425  assert( false );
426 
427  return 0;
428 }
429 
430 
432 {
433  return m_selection;
434 }
435 
436 
437 EDA_ITEM* EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T* aFilterList,
438  bool* aSelectionCancelledFlag, bool aCheckLocked )
439 {
440  EDA_ITEM* start;
441  EE_COLLECTOR collector;
442 
443  if( m_isLibEdit )
444  start = static_cast<LIB_EDIT_FRAME*>( m_frame )->GetCurPart();
445  else
446  start = m_frame->GetScreen()->GetDrawItems();
447 
448  // Empty schematics have no draw items
449  if( !start )
450  return nullptr;
451 
452  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
453  collector.Collect( start, aFilterList, (wxPoint) aWhere, m_unit, m_convert );
454 
455  bool anyCollected = collector.GetCount() != 0;
456 
457  // Remove unselectable items
458  for( int i = collector.GetCount() - 1; i >= 0; --i )
459  {
460  if( !selectable( collector[ i ] ) )
461  collector.Remove( i );
462 
463  if( aCheckLocked && collector[ i ]->IsLocked() )
464  collector.Remove( i );
465  }
466 
468 
469  // Apply some ugly heuristics to avoid disambiguation menus whenever possible
470  if( collector.GetCount() > 1 && !m_skip_heuristics )
471  {
472  guessSelectionCandidates( collector, aWhere );
473  }
474 
475  // If still more than one item we're going to have to ask the user.
476  if( collector.GetCount() > 1 )
477  {
478  collector.m_MenuTitle = _( "Clarify Selection" );
479  // Must call selectionMenu via RunAction() to avoid event-loop contention
480  m_toolMgr->RunAction( EE_ACTIONS::selectionMenu, true, &collector );
481 
482  if( collector.m_MenuCancelled )
483  {
484  if( aSelectionCancelledFlag )
485  *aSelectionCancelledFlag = true;
486 
487  return nullptr;
488  }
489  }
490 
491  if( collector.GetCount() == 1 )
492  {
493  EDA_ITEM* item = collector[ 0 ];
494 
495  toggleSelection( item );
496  return item;
497  }
498 
499  if( !m_additive && anyCollected )
500  clearSelection();
501 
502  return nullptr;
503 }
504 
505 
507 {
508  // There are certain parent/child and enclosure combinations that can be handled
509  // automatically. Since schematics are meant to be human-readable we don't have
510  // all the various overlap and coverage issues that we do in Pcbnew.
511  if( collector.GetCount() == 2 )
512  {
513  EDA_ITEM* a = collector[ 0 ];
514  EDA_ITEM* b = collector[ 1 ];
515 
516  if( a->GetParent() == b )
517  collector.Remove( b );
518  else if( a == b->GetParent() )
519  collector.Remove( a );
520  else if( a->Type() == SCH_SHEET_T && b->Type() != SCH_SHEET_T )
521  collector.Remove( a );
522  else if( b->Type() == SCH_SHEET_T && a->Type() != SCH_SHEET_T )
523  collector.Remove( b );
524  }
525 }
526 
527 
529 {
530  // Filter an existing selection
531  if( !m_selection.Empty() )
532  {
533  for( int i = m_selection.GetSize() - 1; i >= 0; --i )
534  {
535  EDA_ITEM* item = (EDA_ITEM*) m_selection.GetItem( i );
536 
537  if( !item->IsType( aFilterList ) )
538  toggleSelection( item );
539  }
540 
541  }
542 
543  // If nothing was selected, or we filtered everything out, do a hover selection
544  if( m_selection.Empty() )
545  {
546  VECTOR2D cursorPos = getViewControls()->GetCursorPosition( true );
547 
548  clearSelection();
549  SelectPoint( cursorPos, aFilterList );
550  m_selection.SetIsHover( true );
551  }
552 
553  return m_selection;
554 }
555 
556 
558 {
559  bool cancelled = false; // Was the tool cancelled while it was running?
560  m_multiple = true; // Multiple selection mode is active
561  KIGFX::VIEW* view = getView();
562 
564  view->Add( &area );
565 
566  while( OPT_TOOL_EVENT evt = Wait() )
567  {
568  if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsActivate() || evt->IsCancel() )
569  {
570  cancelled = true;
571  break;
572  }
573 
574  if( evt->IsDrag( BUT_LEFT ) )
575  {
576  // Start drawing a selection box
577  area.SetOrigin( evt->DragOrigin() );
578  area.SetEnd( evt->Position() );
579  area.SetAdditive( m_additive );
581 
582  view->SetVisible( &area, true );
583  view->Update( &area );
584  getViewControls()->SetAutoPan( true );
585  }
586 
587  if( evt->IsMouseUp( BUT_LEFT ) )
588  {
589  getViewControls()->SetAutoPan( false );
590 
591  // End drawing the selection box
592  view->SetVisible( &area, false );
593 
594  // Mark items within the selection box as selected
595  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
596 
597  // Filter the view items based on the selection box
598  BOX2I selectionBox = area.ViewBBox();
599  view->Query( selectionBox, selectedItems ); // Get the list of selected items
600 
601  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR>::iterator it, it_end;
602 
603  int width = area.GetEnd().x - area.GetOrigin().x;
604  int height = area.GetEnd().y - area.GetOrigin().y;
605 
606  /* Selection mode depends on direction of drag-selection:
607  * Left > Right : Select objects that are fully enclosed by selection
608  * Right > Left : Select objects that are crossed by selection
609  */
610  bool windowSelection = width >= 0 ? true : false;
611 
612  if( view->IsMirroredX() )
613  windowSelection = !windowSelection;
614 
615  // Construct an EDA_RECT to determine EDA_ITEM selection
616  EDA_RECT selectionRect( (wxPoint)area.GetOrigin(), wxSize( width, height ) );
617 
618  selectionRect.Normalize();
619 
620  for( it = selectedItems.begin(), it_end = selectedItems.end(); it != it_end; ++it )
621  {
622  EDA_ITEM* item = static_cast<EDA_ITEM*>( it->first );
623 
624  if( !item || !selectable( item ) )
625  continue;
626 
627  if( item->HitTest( selectionRect, windowSelection ) )
628  {
629  if( m_subtractive )
630  unselect( item );
631  else
632  select( item );
633  }
634  }
635 
636  // Inform other potentially interested tools
637  if( !m_selection.Empty() )
639 
640  break; // Stop waiting for events
641  }
642  }
643 
644  getViewControls()->SetAutoPan( false );
645 
646  // Stop drawing the selection box
647  view->Remove( &area );
648  m_multiple = false; // Multiple selection mode is inactive
649 
650  if( !cancelled )
652 
653  return cancelled;
654 }
655 
656 
657 static KICAD_T nodeTypes[] =
658 {
663  SCH_LABEL_T,
668  EOT
669 };
670 
671 
673 {
674  EE_COLLECTOR collector;
675 
676  collector.Collect( m_frame->GetScreen()->GetDrawItems(), nodeTypes, (wxPoint) aPosition );
677 
678  return collector.GetCount() ? collector[ 0 ] : nullptr;
679 }
680 
681 
683 {
684  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
685 
686  SelectPoint( cursorPos, nodeTypes );
687 
688  return 0;
689 }
690 
691 
693 {
694  static KICAD_T wiresAndBusses[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
695 
696  RequestSelection( wiresAndBusses );
697 
698  if( m_selection.Empty() )
699  return 0;
700 
701  SCH_LINE* line = (SCH_LINE*) m_selection.Front();
702  EDA_ITEMS items;
703 
705  m_frame->GetScreen()->MarkConnections( line );
706 
707  for( EDA_ITEM* item = m_frame->GetScreen()->GetDrawItems(); item; item = item->Next() )
708  {
709  if( item->GetFlags() & CANDIDATE )
710  select( item );
711  }
712 
713  if( m_selection.GetSize() > 1 )
715 
716  return 0;
717 }
718 
719 
721 {
722  AddItemToSel( aEvent.Parameter<EDA_ITEM*>() );
723  return 0;
724 }
725 
726 
727 void EE_SELECTION_TOOL::AddItemToSel( EDA_ITEM* aItem, bool aQuietMode )
728 {
729  if( aItem )
730  {
731  select( aItem );
732 
733  // Inform other potentially interested tools
734  if( !aQuietMode )
736  }
737 }
738 
739 
741 {
742  AddItemsToSel( aEvent.Parameter<EDA_ITEMS*>(), false );
743  return 0;
744 }
745 
746 
747 void EE_SELECTION_TOOL::AddItemsToSel( EDA_ITEMS* aList, bool aQuietMode )
748 {
749  if( aList )
750  {
751  for( EDA_ITEM* item : *aList )
752  select( item );
753 
754  // Inform other potentially interested tools
755  if( !aQuietMode )
757  }
758 }
759 
760 
762 {
763  RemoveItemFromSel( aEvent.Parameter<EDA_ITEM*>() );
764  return 0;
765 }
766 
767 
768 void EE_SELECTION_TOOL::RemoveItemFromSel( EDA_ITEM* aItem, bool aQuietMode )
769 {
770  if( aItem )
771  {
772  unselect( aItem );
773 
774  // Inform other potentially interested tools
775  if( !aQuietMode )
777  }
778 }
779 
780 
782 {
783  RemoveItemsFromSel( aEvent.Parameter<EDA_ITEMS*>(), false );
784  return 0;
785 }
786 
787 
788 void EE_SELECTION_TOOL::RemoveItemsFromSel( EDA_ITEMS* aList, bool aQuietMode )
789 {
790  if( aList )
791  {
792  for( EDA_ITEM* item : *aList )
793  unselect( item );
794 
795  // Inform other potentially interested tools
796  if( !aQuietMode )
798  }
799 }
800 
801 
803 {
804  clearSelection();
805 
806  return 0;
807 }
808 
809 
811 {
812  m_selection.Clear();
813 
814  EDA_ITEM* start = nullptr;
815 
816  if( m_isLibEdit )
817  start = static_cast<LIB_EDIT_FRAME*>( m_frame )->GetCurPart();
818  else
819  start = m_frame->GetScreen()->GetDrawItems();
820 
821  INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* testData )
822  {
823  if( item->IsSelected() )
824  select( item );
825 
826  return SEARCH_CONTINUE;
827  };
828 
829  EDA_ITEM::IterateForward( start, inspector, nullptr, EE_COLLECTOR::AllItems );
830 }
831 
832 
834 {
835  EE_COLLECTOR* collector = aEvent.Parameter<EE_COLLECTOR*>();
836 
837  if( !doSelectionMenu( collector ) )
838  collector->m_MenuCancelled = true;
839 
840  return 0;
841 }
842 
843 
845 {
846  EDA_ITEM* current = nullptr;
847  ACTION_MENU menu;
848 
849  int limit = std::min( MAX_SELECT_ITEM_IDS, aCollector->GetCount() );
850 
851  for( int i = 0; i < limit; ++i )
852  {
853  wxString text;
854  EDA_ITEM* item = ( *aCollector )[i];
855  text = item->GetSelectMenuText( m_frame->GetUserUnits() );
856 
857  wxString menuText = wxString::Format("&%d. %s", i + 1, text );
858  menu.Add( menuText, i + 1, item->GetMenuImage() );
859  }
860 
861  if( aCollector->m_MenuTitle.Length() )
862  menu.SetTitle( aCollector->m_MenuTitle );
863 
864  menu.SetIcon( info_xpm );
865  menu.DisplayTitle( true );
866  SetContextMenu( &menu, CMENU_NOW );
867 
868  while( OPT_TOOL_EVENT evt = Wait() )
869  {
870  if( evt->Action() == TA_CONTEXT_MENU_UPDATE )
871  {
872  if( current )
873  unhighlight( current, BRIGHTENED );
874 
875  int id = *evt->GetCommandId();
876 
877  // User has pointed an item, so show it in a different way
878  if( id > 0 && id <= limit )
879  {
880  current = ( *aCollector )[id - 1];
881  highlight( current, BRIGHTENED );
882  }
883  else
884  {
885  current = NULL;
886  }
887  }
888  else if( evt->Action() == TA_CONTEXT_MENU_CHOICE )
889  {
890  if( current )
891  unhighlight( current, BRIGHTENED );
892 
893  OPT<int> id = evt->GetCommandId();
894 
895  // User has selected an item, so this one will be returned
896  if( id && ( *id > 0 ) )
897  current = ( *aCollector )[*id - 1];
898  else
899  current = NULL;
900 
901  break;
902  }
903 
904  getView()->UpdateItems();
905  m_frame->GetCanvas()->Refresh();
906  }
907 
908  if( current )
909  {
910  unhighlight( current, BRIGHTENED );
911 
912  getView()->UpdateItems();
913  m_frame->GetCanvas()->Refresh();
914 
915  aCollector->Empty();
916  aCollector->Append( current );
917  return true;
918  }
919 
920  return false;
921 }
922 
923 
924 bool EE_SELECTION_TOOL::selectable( const EDA_ITEM* aItem, bool checkVisibilityOnly ) const
925 {
926  // NOTE: in the future this is where eeschema layer/itemtype visibility will be handled
927 
928  switch( aItem->Type() )
929  {
930  case SCH_PIN_T:
931  if( !static_cast<const SCH_PIN*>( aItem )->IsVisible() && !m_frame->GetShowAllPins() )
932  return false;
933  break;
934 
935  case LIB_PART_T: // In libedit we do not want to select the symbol itself.
936  return false;
937 
938  case LIB_PIN_T:
939  {
940  LIB_EDIT_FRAME* editFrame = (LIB_EDIT_FRAME*) m_frame;
941  LIB_PIN* pin = (LIB_PIN*) aItem;
942 
943  if( ( pin->GetUnit() && pin->GetUnit() != editFrame->GetUnit() )
944  || ( pin->GetConvert() && pin->GetConvert() != editFrame->GetConvert() ) )
945  {
946  // Specific rules for pins:
947  // - do not select pins in other units when synchronized pin edit mode is disabled
948  // - do not select pins in other units when units are not interchangeable
949  // - in other cases verify if the pin belongs to the requested DeMorgan variant
950  if( !editFrame->SynchronizePins()
951  || editFrame->GetCurPart()->UnitsLocked()
952  || ( pin->GetConvert() && pin->GetConvert() != editFrame->GetConvert() ) )
953  {
954  return false;
955  }
956  }
957  break;
958  }
959  case SCH_MARKER_T: // Always selectable
960  return true;
961 
962  default: // Suppress warnings
963  break;
964  }
965 
966  return true;
967 }
968 
969 
971 {
972  if( m_selection.Empty() )
973  return;
974 
975  while( m_selection.GetSize() )
977 
978  getView()->Update( &m_selection );
979 
980  m_selection.SetIsHover( false );
982 
983  // Inform other potentially interested tools
985 }
986 
987 
988 void EE_SELECTION_TOOL::toggleSelection( EDA_ITEM* aItem, bool aForce )
989 {
990  if( aItem->IsSelected() )
991  {
992  unselect( aItem );
993 
994  // Inform other potentially interested tools
996  }
997  else
998  {
999  if( !m_additive )
1000  clearSelection();
1001 
1002  // Prevent selection of invisible or inactive items
1003  if( aForce || selectable( aItem ) )
1004  {
1005  select( aItem );
1006 
1007  // Inform other potentially interested tools
1009  }
1010  }
1011 
1012  if( m_frame )
1014 }
1015 
1016 
1018 {
1019  highlight( aItem, SELECTED, &m_selection );
1020 }
1021 
1022 
1024 {
1025  unhighlight( aItem, SELECTED, &m_selection );
1026 }
1027 
1028 
1029 void EE_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup )
1030 {
1031  if( aMode == SELECTED )
1032  aItem->SetSelected();
1033  else if( aMode == BRIGHTENED )
1034  aItem->SetBrightened();
1035 
1036  if( aGroup )
1037  aGroup->Add( aItem );
1038 
1039  // Highlight pins and fields. (All the other component children are currently only
1040  // represented in the LIB_PART and will inherit the settings of the parent component.)
1041  if( aItem->Type() == SCH_COMPONENT_T )
1042  {
1043  SCH_PINS& pins = static_cast<SCH_COMPONENT*>( aItem )->GetPins();
1044 
1045  for( SCH_PIN& pin : pins )
1046  {
1047  if( aMode == SELECTED )
1048  pin.SetSelected();
1049  else if( aMode == BRIGHTENED )
1050  pin.SetBrightened();
1051  }
1052 
1053  std::vector<SCH_FIELD*> fields;
1054  static_cast<SCH_COMPONENT*>( aItem )->GetFields( fields, false );
1055 
1056  for( SCH_FIELD* field : fields )
1057  {
1058  if( aMode == SELECTED )
1059  field->SetSelected();
1060  else if( aMode == BRIGHTENED )
1061  field->SetBrightened();
1062  }
1063  }
1064  else if( aItem->Type() == SCH_SHEET_T )
1065  {
1066  SCH_SHEET_PINS& pins = static_cast<SCH_SHEET*>( aItem )->GetPins();
1067 
1068  for( SCH_SHEET_PIN& pin : pins )
1069  {
1070  if( aMode == SELECTED )
1071  pin.SetSelected();
1072  else if( aMode == BRIGHTENED )
1073  pin.SetBrightened();
1074  }
1075  }
1076 
1077  if( aItem->Type() == SCH_PIN_T || aItem->Type() == SCH_FIELD_T )
1078  getView()->Update( aItem->GetParent() );
1079  else
1080  getView()->Update( aItem );
1081 }
1082 
1083 
1084 void EE_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup )
1085 {
1086  if( aMode == SELECTED )
1087  aItem->ClearSelected();
1088  else if( aMode == BRIGHTENED )
1089  aItem->ClearBrightened();
1090 
1091  if( aGroup )
1092  aGroup->Remove( aItem );
1093 
1094  // Unhighlight pins and fields. (All the other component children are currently only
1095  // represented in the LIB_PART.)
1096  if( aItem->Type() == SCH_COMPONENT_T )
1097  {
1098  SCH_PINS& pins = static_cast<SCH_COMPONENT*>( aItem )->GetPins();
1099 
1100  for( SCH_PIN& pin : pins )
1101  {
1102  if( aMode == SELECTED )
1103  pin.ClearSelected();
1104  else if( aMode == BRIGHTENED )
1105  pin.ClearBrightened();
1106  }
1107 
1108  std::vector<SCH_FIELD*> fields;
1109  static_cast<SCH_COMPONENT*>( aItem )->GetFields( fields, false );
1110 
1111  for( SCH_FIELD* field : fields )
1112  {
1113  if( aMode == SELECTED )
1114  field->ClearSelected();
1115  else if( aMode == BRIGHTENED )
1116  field->ClearBrightened();
1117  }
1118  }
1119  else if( aItem->Type() == SCH_SHEET_T )
1120  {
1121  SCH_SHEET_PINS& pins = static_cast<SCH_SHEET*>( aItem )->GetPins();
1122 
1123  for( SCH_SHEET_PIN& pin : pins )
1124  {
1125  if( aMode == SELECTED )
1126  pin.ClearSelected();
1127  else if( aMode == BRIGHTENED )
1128  pin.ClearBrightened();
1129  }
1130  }
1131 
1132  if( aItem->Type() == SCH_PIN_T || aItem->Type() == SCH_FIELD_T )
1133  getView()->Update( aItem->GetParent() );
1134  else
1135  getView()->Update( aItem );
1136 }
1137 
1138 
1140 {
1141  const unsigned GRIP_MARGIN = 20;
1142  VECTOR2I margin = getView()->ToWorld( VECTOR2I( GRIP_MARGIN, GRIP_MARGIN ), false );
1143 
1144  // Check if the point is located within any of the currently selected items bounding boxes
1145  for( auto item : m_selection )
1146  {
1147  BOX2I itemBox = item->ViewBBox();
1148  itemBox.Inflate( margin.x, margin.y ); // Give some margin for gripping an item
1149 
1150  if( itemBox.Contains( aPoint ) )
1151  return true;
1152  }
1153 
1154  return false;
1155 }
1156 
1157 
1159 {
1161 
1166 
1172 }
1173 
1174 
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:123
wxString m_MenuTitle
SELECTION & GetSelection()
Function GetSelection()
static bool ShowAlways(const SELECTION &aSelection)
Function ShowAlways The default condition function (always returns true).
void ClearReferencePoint()
Definition: selection.h:213
static TOOL_ACTION pinTable
Definition: ee_actions.h:166
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
static TOOL_ACTION properties
Definition: ee_actions.h:124
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
void AddStandardSubMenus(EDA_DRAW_FRAME *aFrame)
Function CreateBasicMenu.
Definition: tool_menu.cpp:83
static SEARCH_RESULT IterateForward(EDA_ITEM *listStart, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function IterateForward walks through the object tree calling the inspector() on each object type req...
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
Definition: actions.h:132
void SetEnd(VECTOR2I aEnd)
Set the current end of the rectangle (the corner that moves with the cursor.
bool selectionContains(const VECTOR2I &aPoint) const
Function selectionContains() Checks if the given point is placed within any of selected items' boundi...
int UpdateMenu(const TOOL_EVENT &aEvent)
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:93
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
PART_REF & GetPartRef()
std::function< SEARCH_RESULT(EDA_ITEM *aItem, void *aTestData) > INSPECTOR_FUNC
Typedef INSPECTOR is used to inspect and possibly collect the (search) results of iterating over a li...
Definition: base_struct.h:77
static TOOL_ACTION addHierLabel
Definition: ee_actions.h:135
#define MAX_SELECT_ITEM_IDS
The maximum number of items in the clarify selection context menu.
Definition: eeschema_id.h:37
void highlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr)
Function highlight() Highlights the item visually.
static TOOL_ACTION breakBus
Definition: ee_actions.h:143
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
static SELECTION_CONDITION SingleSymbol
bool IsSelected() const
Definition: base_struct.h:227
Model changes (required full reload)
Definition: tool_base.h:83
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
Definition: actions.h:133
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
Class ACTION_MENU.
Definition: action_menu.h:43
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Function ToWorld() Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:475
SCH_ITEM * Next() const
Definition: sch_item.h:153
std::vector< SCH_PIN > SCH_PINS
A container for several SCH_PIN items.
Definition: sch_component.h:51
void SetOrigin(VECTOR2I aOrigin)
Set the origin of the rectange (the fixed corner)
void ClearSelected()
Definition: base_struct.h:237
static SELECTION_CONDITION MoreThan(int aNumber)
Function MoreThan Creates a functor that tests if the number of selected items is greater than the va...
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:64
VIEW_CONTROLS class definition.
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Function OnlyTypes Creates a functor that tests if the selected items are only of given types.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:931
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
static TOOL_ACTION selectConnection
If current selection is a wire or bus, expand to entire connection.
Definition: ee_actions.h:54
static TOOL_ACTION cancelInteractive
Definition: actions.h:45
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
static SELECTION_CONDITION IdleSelection
bool selectMultiple()
Function selectMultiple() Handles drawing a selection box that allows one to select many items at the...
static TOOL_ACTION unfoldBus
Definition: ee_actions.h:84
void SetBrightened()
Definition: base_struct.h:235
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
#define HITTEST_THRESHOLD_PIXELS
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static int LegacyHotKey(int aHotKey)
Creates a hot key code that refers to a legacy hot key setting, instead of a particular key.
Definition: tool_action.h:165
Class EE_COLLECTOR.
Definition: ee_collectors.h:38
virtual bool IsType(const KICAD_T aScanTypes[])
Function IsType Checks whether the item is one of the listed types.
Definition: base_struct.h:287
int AddItemsToSel(const TOOL_EVENT &aEvent)
void select(EDA_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
void UpdateAll()
Function UpdateAll() Runs update handlers for the menu and its submenus.
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
#define CANDIDATE
flag indicating that the structure is connected
Definition: base_struct.h:124
static TOOL_ACTION removeItemsFromSel
Definition: ee_actions.h:65
static SELECTION_CONDITION Idle
static SELECTION_CONDITION Count(int aNumber)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Function SetContextMenu()
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
static bool NotEmpty(const SELECTION &aSelection)
Function NotEmpty Tests if there are any items selected.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:143
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
static TOOL_ACTION breakWire
Definition: ee_actions.h:142
void SetIsHover(bool aIsHover)
Definition: selection.h:64
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:161
void ClearBrightened()
Definition: base_struct.h:239
static TOOL_ACTION removeItemFromSel
Definition: ee_actions.h:61
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:133
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: base_struct.h:333
static SELECTION_CONDITION SingleDeMorganSymbol
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:114
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
#define SELECTED
Definition: base_struct.h:121
int SelectNode(const TOOL_EVENT &aEvent)
Select node under cursor
int GetUnit() const
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
void guessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aWhere)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
void toggleSelection(EDA_ITEM *aItem, bool aForce=false)
Function toggleSelection() Changes selection status of a given item.
static SELECTION_CONDITION Empty
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:60
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
void SetSelected()
Definition: base_struct.h:233
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:588
static TOOL_ACTION explicitCrossProbe
Definition: ee_actions.h:169
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:289
void MarkConnections(SCH_LINE *aSegment)
Add all wires and junctions connected to aSegment which are not connected any component pin to aItemL...
Definition: sch_screen.cpp:308
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:165
SCH_DRAW_PANEL * GetCanvas() const override
void SetIcon(const BITMAP_OPAQUE *aIcon)
Function SetIcon() Assigns an icon for the entry.
Definition: action_menu.cpp:82
bool Contains(const Vec &aPoint) const
Function Contains.
Definition: box2.h:149
Class TOOL_EVENT.
Definition: tool_event.h:167
const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers.
void Collect(EDA_ITEM *aItem, const KICAD_T aFilterList[], const wxPoint &aPos, int aUnit=0, int aConvert=0)
Function Collect scans a EDA_ITEM using this class's Inspector method, which does the collection.
static TOOL_ACTION addJunction
Definition: ee_actions.h:132
void clearSelection()
Function clearSelection() Clears the current selection.
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:137
EDA_ITEM * GetParent() const
Definition: base_struct.h:214
VIEW_GROUP extends VIEW_ITEM by possibility of grouping items into a single object.
int SelectConnection(const TOOL_EVENT &aEvent)
If node selected then expand to connection, otherwise select connection under cursor
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
Definition: actions.h:134
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
void UpdateItems()
Function UpdateItems() Iterates through the list of items that asked for updating and updates them.
Definition: view.cpp:1420
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:47
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:56
void unhighlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr)
Function unhighlight() Unhighlights the item visually.
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:94
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:57
static bool IsDrawingBus(const SELECTION &aSelection)
bool m_MenuCancelled
static TOOL_ACTION updateMenu
Definition: actions.h:49
static SELECTION_CONDITION SingleMultiUnitSymbol
All active tools
Definition: tool_event.h:143
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:103
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1539
int GetConvert() const
EDA_ITEM * GetNode(VECTOR2I aPosition)
Find (but don't select) node under cursor
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
bool selectable(const EDA_ITEM *aItem, bool checkVisibilityOnly=false) const
Function selectable() Checks conditions for an item to be selected.
bool IsMirroredX() const
Function IsMirroredX() Returns true if view is flipped across the X axis.
Definition: view.h:230
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:98
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:316
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
void Normalize()
Function Normalize ensures that the height ant width are positive.
void unselect(EDA_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:300
static KICAD_T nodeTypes[]
The symbol library editor main window.
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the menu.
Definition: action_menu.cpp:96
void CloseContextMenu(OPT_TOOL_EVENT &evt)
Function CloseContextMenu.
Definition: tool_menu.cpp:75
int AddItemToSel(const TOOL_EVENT &aEvent)
boost::ptr_vector< SCH_SHEET_PIN > SCH_SHEET_PINS
Definition: sch_sheet.h:195
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
virtual bool GetShowAllPins() const
Allow some frames to show/hide hidden pins.
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
int SelectionMenu(const TOOL_EVENT &aEvent)
Function SelectionMenu() Shows a popup menu to trim the COLLECTOR passed as aEvent's parameter down t...
void SetSubtractive(bool aSubtractive)
bool doSelectionMenu(EE_COLLECTOR *aItems)
Allows the selection of a single item from a list via pop-up menu.
SCH_BASE_FRAME * m_frame
static TOOL_ACTION selectionMenu
Runs a selection menu to select from a list of items.
Definition: ee_actions.h:68
Class TOOL_ACTION.
Definition: tool_action.h:46
size_t i
Definition: json11.cpp:597
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Function OnlyType Creates a functor that tests if the selected items are only of given type.
void RebuildSelection()
Rebuilds the selection from the EDA_ITEMs' selection flags.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
static const KICAD_T AllItems[]
Definition: ee_collectors.h:41
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
virtual wxString GetSelectMenuText(EDA_UNITS_T aUnits) const
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
static TOOL_ACTION selectNode
Select the junction, wire or bus segment under the cursor.
Definition: ee_actions.h:50
static TOOL_ACTION startWire
Definition: ee_actions.h:80
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
static TOOL_ACTION enterSheet
Definition: ee_actions.h:160
boost::optional< T > OPT
Definition: optional.h:7
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:183
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1485
bool SynchronizePins()
Pin editing (add, delete, move...) can be synchronized between units when units are interchangeable b...
wxMenuItem * Add(const wxString &aLabel, int aId, const BITMAP_OPAQUE *aIcon=NULL)
Function Add() Adds an entry to the menu.
static TOOL_ACTION startBus
Definition: ee_actions.h:82
Class SELECTION_AREA.
static TOOL_ACTION addLabel
Definition: ee_actions.h:133
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
void setTransitions() override
Sets up handlers for various events.
void ClearDrawingState()
Clear the state flags of all the items in the screen.
Definition: sch_screen.cpp:604
static TOOL_ACTION highlightNet
Definition: ee_actions.h:182
virtual int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Function Query() Finds all visible items that touch or are within the rectangle aRect.
Definition: view.cpp:452
static TOOL_ACTION addGlobalLabel
Definition: ee_actions.h:134
EDA_ITEM * SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, bool *aSelectionCancelledFlag=NULL, bool aCheckLocked=false)
Function selectPoint() Selects an item pointed by the parameter aWhere.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
static TOOL_ACTION selectionTool
Definition: ee_actions.h:76
Class VIEW.
Definition: view.h:61
static TOOL_ACTION finishBus
Definition: ee_actions.h:101
void SetAdditive(bool aAdditive)
int RemoveItemsFromSel(const TOOL_EVENT &aEvent)
virtual BITMAP_DEF GetMenuImage() const
Function GetMenuImage returns a pointer to an image to be used in menus.
void SetHighlight(bool aEnabled, int aNetcode=-1)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer or the specifie...
Definition: painter.h:140
static bool IsDrawingWire(const SELECTION &aSelection)
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION finishWire
Definition: ee_actions.h:100
bool UnitsLocked() const
Check whether part units are interchangeable.
int GetToolId() const
Definition: draw_frame.h:524
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:155
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
#define min(a, b)
Definition: auxiliary.h:85
int Main(const TOOL_EVENT &aEvent)
Function Main()
void DisplayTitle(bool aDisplay=true)
Function DisplayTitle() Decides whether a title for a pop up menu should be displayed.
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:153
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:85