KiCad PCB EDA Suite
sch_editor_control.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 CERN
5  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <fctsys.h>
26 #include <kiway.h>
27 #include <sch_view.h>
28 #include <sch_edit_frame.h>
29 #include <sch_sheet.h>
30 #include <sch_line.h>
31 #include <connection_graph.h>
32 #include <erc.h>
33 #include <eeschema_id.h>
34 #include <netlist_object.h>
35 #include <tool/tool_manager.h>
36 #include <tool/picker_tool.h>
37 #include <tools/ee_actions.h>
39 #include <tools/ee_selection.h>
41 #include <advanced_config.h>
42 #include <simulation_cursors.h>
43 #include <sim/sim_plot_frame.h>
44 #include <sch_legacy_plugin.h>
45 #include <class_library.h>
46 #include <confirm.h>
47 #include <sch_painter.h>
48 #include <status_popup.h>
49 #include <ws_proxy_undo_item.h>
52 #include <invoke_sch_dialog.h>
55 
56 int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
57 {
59  return 0;
60 }
61 
62 
64 {
66  return 0;
67 }
68 
69 
71 {
73  return 0;
74 }
75 
76 
78 {
79  m_frame->Save_File( true );
80  return 0;
81 }
82 
83 
85 {
86  PICKED_ITEMS_LIST undoCmd;
88  ITEM_PICKER wrapper( undoItem, UR_PAGESETTINGS );
89 
90  undoCmd.PushItem( wrapper );
92 
95 
96  if( dlg.ShowModal() != wxID_OK )
98 
99  return 0;
100 }
101 
102 
104 {
105  m_frame->Print();
106  return 0;
107 }
108 
109 
111 {
113  return 0;
114 }
115 
116 
118 {
119  m_frame->Close( false );
120  return 0;
121 }
122 
123 
124 // A dummy wxFindReplaceData signalling any marker should be found
125 static wxFindReplaceData g_markersOnly;
126 
127 
129 {
131  return UpdateFind( aEvent );
132 }
133 
134 
136 {
137  wxFindReplaceData* data = m_frame->GetFindReplaceData();
138 
139  if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
140  || aEvent.IsAction( &ACTIONS::updateFind ) )
141  {
143 
144  INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* )
145  {
146  if( data && item->Matches( *data, nullptr ) )
147  m_selectionTool->BrightenItem( item );
148  else if( item->IsBrightened() )
150 
151  return SEARCH_CONTINUE;
152  };
153 
154  EDA_ITEM* start = m_frame->GetScreen()->GetDrawItems();
155  EDA_ITEM::IterateForward( start, inspector, nullptr, EE_COLLECTOR::AllItems );
156  }
157  else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
158  {
159  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
160  {
161  if( data && item->Matches( *data, nullptr ) )
162  m_selectionTool->BrightenItem( item );
163  else if( item->IsBrightened() )
165  }
166  }
167 
168  getView()->UpdateItems();
169  m_frame->GetCanvas()->Refresh();
170 
171  return 0;
172 }
173 
174 
175 EDA_ITEM* nextMatch( SCH_SCREEN* aScreen, EDA_ITEM* after, wxFindReplaceData* data )
176 {
177  EDA_ITEM* found = nullptr;
178 
179  INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* testData )
180  {
181  if( after )
182  {
183  if( after == item )
184  after = nullptr;
185 
186  return SEARCH_CONTINUE;
187  }
188 
189  if( ( data == &g_markersOnly && item->Type() == SCH_MARKER_T )
190  || item->Matches( *data, nullptr ) )
191  {
192  found = item;
193  return SEARCH_QUIT;
194  }
195 
196  return SEARCH_CONTINUE;
197  };
198 
199  EDA_ITEM::IterateForward( aScreen->GetDrawItems(), inspector, nullptr, EE_COLLECTOR::AllItems );
200 
201  return found;
202 }
203 
204 
206 {
207  // A timer during which a subsequent FindNext will result in a wrap-around
208  static wxTimer wrapAroundTimer;
209 
210  wxFindReplaceData* data = m_frame->GetFindReplaceData();
211 
212  if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
213  {
214  if( data )
215  g_markersOnly.SetFlags( data->GetFlags() );
216 
217  data = &g_markersOnly;
218  }
219  else if( !data )
220  {
221  return FindAndReplace( ACTIONS::find.MakeEvent() );
222  }
223 
224  bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
225  EE_SELECTION& selection = m_selectionTool->GetSelection();
226  SCH_SCREEN* afterScreen = m_frame->GetScreen();
227  EDA_ITEM* afterItem = selection.Front();
228  EDA_ITEM* item = nullptr;
229 
230  if( wrapAroundTimer.IsRunning() )
231  {
232  afterScreen = nullptr;
233  afterItem = nullptr;
234  wrapAroundTimer.Stop();
236  }
237 
239 
240  if( afterScreen || !searchAllSheets )
241  item = nextMatch( m_frame->GetScreen(), afterItem, data );
242 
243  if( !item && searchAllSheets )
244  {
245  SCH_SHEET_LIST schematic( g_RootSheet );
246  SCH_SCREENS screens;
247 
248  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
249  {
250  if( afterScreen )
251  {
252  if( afterScreen == screen )
253  afterScreen = nullptr;
254 
255  continue;
256  }
257 
258  item = nextMatch( screen, nullptr, data );
259 
260  if( item )
261  {
262  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
263  wxCHECK_MSG( sheet, 0, "Sheet not found for " + screen->GetFileName() );
264 
265  *g_CurrentSheet = *sheet;
267 
268  screen->SetZoom( m_frame->GetScreen()->GetZoom() );
269  screen->TestDanglingEnds();
270 
271  m_frame->SetScreen( screen );
272  UpdateFind( ACTIONS::updateFind.MakeEvent() );
273 
274  break;
275  }
276  }
277  }
278 
279  if( item )
280  {
281  m_selectionTool->AddItemToSel( item );
282  m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter(), true );
283  m_frame->GetCanvas()->Refresh();
284  }
285  else
286  {
287  wxString msg = searchAllSheets ? _( "Reached end of schematic." )
288  : _( "Reached end of sheet." );
289 
290  m_frame->ShowFindReplaceStatus( msg + _( "\nFind again to wrap around to the start." ) );
291  wrapAroundTimer.StartOnce( 4000 );
292  }
293 
294  return 0;
295 }
296 
297 
299 {
300  wxFindReplaceData* data = m_frame->GetFindReplaceData();
302 
303  return data && item && item->Matches( *data, nullptr );
304 }
305 
306 
308 {
309  wxFindReplaceData* data = m_frame->GetFindReplaceData();
311 
312  if( !data )
313  return FindAndReplace( ACTIONS::find.MakeEvent() );
314 
315  if( item && item->Matches( *data, nullptr ) )
316  {
317  item->Replace( *data, g_CurrentSheet );
318  FindNext( ACTIONS::findNext.MakeEvent() );
319  }
320 
321  return 0;
322 }
323 
324 
326 {
327  wxFindReplaceData* data = m_frame->GetFindReplaceData();
328 
329  if( !data )
330  return FindAndReplace( ACTIONS::find.MakeEvent() );
331 
332  SCH_SHEET_LIST schematic( g_RootSheet );
333  SCH_SCREENS screens;
334 
335  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
336  {
337  for( EDA_ITEM* item = nextMatch( screen, nullptr, data ); item;
338  item = nextMatch( screen, item, data ) )
339  {
340  item->Replace( *data, schematic.FindSheetForScreen( screen ) );
341  }
342  }
343 
344  return 0;
345 }
346 
347 
349 {
350  doCrossProbeSchToPcb( aEvent, false );
351  return 0;
352 }
353 
354 
356 {
357  doCrossProbeSchToPcb( aEvent, true );
358  return 0;
359 }
360 
361 
362 void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
363 {
364  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
365  if( m_probingPcbToSch )
366  return;
367 
369  SCH_ITEM* item = nullptr;
370  SCH_COMPONENT* component = nullptr;
371 
372  if( aForce )
373  {
374  EE_SELECTION& selection = selTool->RequestSelection();
375 
376  if( selection.GetSize() >= 1 )
377  item = (SCH_ITEM*) selection.Front();
378  }
379  else
380  {
381  EE_SELECTION& selection = selTool->GetSelection();
382 
383  if( selection.GetSize() >= 1 )
384  item = (SCH_ITEM*) selection.Front();
385  }
386 
387  if( !item )
388  {
389  if( aForce )
390  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
391 
392  return;
393  }
394 
395 
396  switch( item->Type() )
397  {
398  case SCH_FIELD_T:
399  case LIB_FIELD_T:
400  component = (SCH_COMPONENT*) item->GetParent();
401  m_frame->SendMessageToPCBNEW( item, component );
402  break;
403 
404  case SCH_COMPONENT_T:
405  component = (SCH_COMPONENT*) item;
406  m_frame->SendMessageToPCBNEW( item, component );
407  break;
408 
409  case SCH_PIN_T:
410  component = (SCH_COMPONENT*) item->GetParent();
411  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), component );
412  break;
413 
414  case SCH_SHEET_T:
415  if( aForce )
416  m_frame->SendMessageToPCBNEW( item, nullptr );
417  break;
418 
419  default:
420  break;
421  }
422 }
423 
424 
425 #ifdef KICAD_SPICE
426 
427 static KICAD_T wires[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
428 static KICAD_T wiresAndPins[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT };
429 static KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
430 
431 #define HITTEST_THRESHOLD_PIXELS 5
432 
433 
434 int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
435 {
436  auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
437  auto simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
438 
439  if( !simFrame ) // Defensive coding; shouldn't happen.
440  return 0;
441 
442  // Deactivate other tools; particularly important if another PICKER is currently running
443  Activate();
444 
445  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) );
446 
447  picker->SetClickHandler(
448  [this, simFrame] ( const VECTOR2D& aPosition )
449  {
451  EDA_ITEM* item = selTool->SelectPoint( aPosition, wiresAndPins );
452 
453  if( !item )
454  return false;
455 
456  if( item->IsType( wires ) )
457  {
458  std::unique_ptr<NETLIST_OBJECT_LIST> netlist( m_frame->BuildNetListBase() );
459 
460  for( NETLIST_OBJECT* obj : *netlist )
461  {
462  if( obj->m_Comp == item )
463  {
464  simFrame->AddVoltagePlot( UnescapeString( obj->GetNetName() ) );
465  break;
466  }
467  }
468  }
469  else if( item->Type() == SCH_PIN_T )
470  {
471  SCH_PIN* pin = (SCH_PIN*) item;
472  SCH_COMPONENT* comp = (SCH_COMPONENT*) item->GetParent();
473  wxString param;
474  wxString primitive;
475 
477  primitive.LowerCase();
478 
479  if( primitive == "c" || primitive == "l" || primitive == "r" )
480  param = wxT( "I" );
481  else if( primitive == "d" )
482  param = wxT( "Id" );
483  else
484  param = wxString::Format( wxT( "I%s" ), pin->GetName().Lower() );
485 
486  simFrame->AddCurrentPlot( comp->GetRef( g_CurrentSheet ), param );
487  }
488 
489  return true;
490  } );
491 
492  picker->SetMotionHandler(
493  [this, picker] ( const VECTOR2D& aPos )
494  {
495  EE_COLLECTOR collector;
496  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
497  collector.Collect( m_frame->GetScreen()->GetDrawItems(), wiresAndPins, (wxPoint) aPos );
498 
500  selectionTool->GuessSelectionCandidates( collector, aPos );
501 
502  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
503  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
504  wxString netName;
505 
506  if( wire )
507  {
508  item = nullptr;
509 
510  if( wire->Connection( *g_CurrentSheet ) )
511  netName = wire->Connection( *g_CurrentSheet )->Name();
512  }
513 
514  if( item && item->Type() == SCH_PIN_T )
515  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURRENT_PROBE ) );
516  else
517  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) );
518 
519  if( m_pickerItem != item )
520  {
521 
522  if( m_pickerItem )
523  selectionTool->UnbrightenItem( m_pickerItem );
524 
525  m_pickerItem = item;
526 
527  if( m_pickerItem )
528  selectionTool->BrightenItem( m_pickerItem );
529  }
530 
531  if( m_frame->GetSelectedNetName() != netName )
532  {
533  m_frame->SetSelectedNetName( netName );
534 
535  TOOL_EVENT dummyEvent;
536  UpdateNetHighlighting( dummyEvent );
537  }
538  } );
539 
540  picker->SetFinalizeHandler(
541  [this] ( const int& aFinalState )
542  {
543  if( m_pickerItem )
545 
546  if( !m_frame->GetSelectedNetName().IsEmpty() )
547  {
548  m_frame->SetSelectedNetName( wxEmptyString );
549 
550  TOOL_EVENT dummyEvent;
551  UpdateNetHighlighting( dummyEvent );
552  }
553  } );
554 
555  std::string tool = aEvent.GetCommandStr().get();
556  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
557 
558  return 0;
559 }
560 
561 
562 int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
563 {
565 
566  // Deactivate other tools; particularly important if another PICKER is currently running
567  Activate();
568 
569  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURSOR::TUNE ) );
570 
571  picker->SetClickHandler(
572  [this] ( const VECTOR2D& aPosition )
573  {
575  EDA_ITEM* item = selTool->SelectPoint( aPosition, fieldsAndComponents );
576 
577  if( !item )
578  return false;
579 
580  if( item->Type() != SCH_COMPONENT_T )
581  {
582  item = item->GetParent();
583 
584  if( item->Type() != SCH_COMPONENT_T )
585  return false;
586  }
587 
588  SIM_PLOT_FRAME* simFrame =
590 
591  if( simFrame )
592  simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
593 
594  return true;
595  } );
596 
597  picker->SetMotionHandler(
598  [this] ( const VECTOR2D& aPos )
599  {
600  EE_COLLECTOR collector;
601  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
602  collector.Collect( m_frame->GetScreen()->GetDrawItems(), fieldsAndComponents, (wxPoint) aPos );
603 
605  selectionTool->GuessSelectionCandidates( collector, aPos );
606 
607  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
608 
609  if( m_pickerItem != item )
610  {
611  if( m_pickerItem )
612  selectionTool->UnbrightenItem( m_pickerItem );
613 
614  m_pickerItem = item;
615 
616  if( m_pickerItem )
617  selectionTool->BrightenItem( m_pickerItem );
618  }
619  } );
620 
621  picker->SetFinalizeHandler(
622  [this] ( const int& aFinalState )
623  {
624  if( m_pickerItem )
626  } );
627 
628  std::string tool = aEvent.GetCommandStr().get();
629  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
630 
631  return 0;
632 }
633 #endif /* KICAD_SPICE */
634 
635 
636 // A singleton reference for clearing the highlight
638 
639 
640 // TODO(JE) Probably use netcode rather than connection name here eventually
641 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
642 {
643  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
644  EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
645  SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
646  wxString netName;
647  bool retVal = true;
648 
649  if( aPosition != CLEAR )
650  {
651  if( TestDuplicateSheetNames( false ) > 0 )
652  {
653  wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
654  retVal = false;
655  }
656  else
657  {
658  SCH_ITEM* item = (SCH_ITEM*) selTool->GetNode( aPosition );
659 
660  if( item && item->Connection( *g_CurrentSheet ) )
661  netName = item->Connection( *g_CurrentSheet )->Name();
662  }
663  }
664 
665  if( netName.empty() )
666  {
667  editFrame->SetStatusText( wxT( "" ) );
668  editFrame->SendCrossProbeClearHighlight();
669  }
670  else
671  {
672  editFrame->SendCrossProbeNetName( netName );
673  editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
674  UnescapeString( netName ) ) );
675  }
676 
677  editFrame->SetSelectedNetName( netName );
679  editorControl->UpdateNetHighlighting( dummy );
680 
681  return retVal;
682 }
683 
684 
686 {
688  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
689 
690  highlightNet( m_toolMgr, cursorPos );
691 
692  return 0;
693 }
694 
695 
697 {
699 
700  return 0;
701 }
702 
703 
705 {
706  SCH_SCREEN* screen = g_CurrentSheet->LastScreen();
707  std::vector<EDA_ITEM*> itemsToRedraw;
708  wxString selectedNetName = m_frame->GetSelectedNetName();
709 
710  if( !screen )
711  return 0;
712 
713  for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
714  {
715  SCH_CONNECTION* conn = item->Connection( *g_CurrentSheet );
716  bool redraw = item->IsBrightened();
717 
718  if( conn && conn->Name() == selectedNetName )
719  item->SetBrightened();
720  else
721  item->ClearBrightened();
722 
723  redraw |= item->IsBrightened();
724 
725  if( item->Type() == SCH_COMPONENT_T )
726  {
727  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
728 
729  redraw |= comp->HasBrightenedPins();
730 
731  comp->ClearBrightenedPins();
732  std::vector<LIB_PIN*> pins;
733  comp->GetPins( pins );
734 
735  for( LIB_PIN* pin : pins )
736  {
737  auto pin_conn = comp->GetConnectionForPin( pin, *g_CurrentSheet );
738 
739  if( pin_conn && pin_conn->Name( false ) == selectedNetName )
740  {
741  comp->BrightenPin( pin );
742  redraw = true;
743  }
744  }
745  }
746  else if( item->Type() == SCH_SHEET_T )
747  {
748  for( SCH_SHEET_PIN& pin : static_cast<SCH_SHEET*>( item )->GetPins() )
749  {
750  auto pin_conn = pin.Connection( *g_CurrentSheet );
751  bool redrawPin = pin.IsBrightened();
752 
753  if( pin_conn && pin_conn->Name() == selectedNetName )
754  pin.SetBrightened();
755  else
756  pin.ClearBrightened();
757 
758  redrawPin |= pin.IsBrightened();
759 
760  if( redrawPin )
761  itemsToRedraw.push_back( &pin );
762  }
763  }
764 
765  if( redraw )
766  itemsToRedraw.push_back( item );
767  }
768 
769  // Be sure highlight change will be redrawn
770  KIGFX::VIEW* view = getView();
771 
772  for( auto redrawItem : itemsToRedraw )
774 
775  m_frame->GetCanvas()->Refresh();
776 
777  return 0;
778 }
779 
780 
782 {
783  // TODO(JE) remove once real-time connectivity is a given
784  if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
786 
787  std::string tool = aEvent.GetCommandStr().get();
789 
790  // Deactivate other tools; particularly important if another PICKER is currently running
791  Activate();
792 
793  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
794 
795  picker->SetClickHandler(
796  [this] ( const VECTOR2D& aPos )
797  {
798  return highlightNet( m_toolMgr, aPos );
799  } );
800 
801  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
802 
803  return 0;
804 }
805 
806 
808 {
809  if( m_frame->GetScreen()->GetUndoCommandCount() <= 0 )
810  return 0;
811 
812  // Inform tools that undo command was issued
814 
815  /* Get the old list */
817 
818  /* Undo the command */
819  m_frame->PutDataInPreviousState( List, false );
820 
821  /* Put the old list in RedoList */
822  List->ReversePickersListOrder();
824 
826  selTool->RebuildSelection();
827 
830 
831  m_frame->SyncView();
832  m_frame->GetCanvas()->Refresh();
833  m_frame->OnModify();
834 
835  return 0;
836 }
837 
838 
840 {
841  if( m_frame->GetScreen()->GetRedoCommandCount() == 0 )
842  return 0;
843 
844  // Inform tools that undo command was issued
846 
847  /* Get the old list */
849 
850  /* Redo the command: */
851  m_frame->PutDataInPreviousState( List, true );
852 
853  /* Put the old list in UndoList */
854  List->ReversePickersListOrder();
856 
858  selTool->RebuildSelection();
859 
862 
863  m_frame->SyncView();
864  m_frame->GetCanvas()->Refresh();
865  m_frame->OnModify();
866 
867  return 0;
868 }
869 
870 
872 {
874  EE_SELECTION& selection = selTool->RequestSelection();
875 
876  if( !selection.GetSize() )
877  return false;
878 
879  m_supplementaryClipboard.clear();
880 
881  for( EDA_ITEM* item : selection )
882  {
883  if( item->Type() == SCH_SHEET_T )
884  {
885  SCH_SHEET* sheet = (SCH_SHEET*) item;
886  m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
887  }
888  }
889 
890  STRING_FORMATTER formatter;
891  SCH_LEGACY_PLUGIN plugin;
892 
893  plugin.Format( &selection, &formatter );
894 
895  return m_toolMgr->SaveClipboard( formatter.GetString() );
896 }
897 
898 
899 bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
900  SCH_SCREEN** aScreen )
901 {
902  if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
903  {
904  *aScreen = m_supplementaryClipboard[ aSheetFilename ];
905  return true;
906  }
907 
908  return false;
909 }
910 
911 
913 {
914  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
915 
916  if( textEntry )
917  {
918  textEntry->Cut();
919  return 0;
920  }
921 
922  if( doCopy() )
924 
925  return 0;
926 }
927 
928 
930 {
931  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
932 
933  if( textEntry )
934  {
935  textEntry->Copy();
936  return 0;
937  }
938 
939  doCopy();
940 
941  return 0;
942 }
943 
944 
946 {
947  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
948 
949  if( textEntry )
950  {
951  textEntry->Paste();
952  return 0;
953  }
954 
956 
958  SCH_ITEM* lastExisting = dlist.GetLast();
959 
960  std::string text = m_toolMgr->GetClipboard();
961 
962  if( text.empty() )
963  return 0;
964 
965  STRING_LINE_READER reader( text, "Clipboard" );
966  SCH_LEGACY_PLUGIN plugin;
967 
968  try
969  {
970  plugin.LoadContent( reader, m_frame->GetScreen() );
971  }
972  catch( IO_ERROR& e )
973  {
974  // If it wasn't content, then paste as text
975  dlist.Append( new SCH_TEXT( wxPoint( 0, 0 ), text ) );
976  }
977 
978  bool forceKeepAnnotations = false;
979  bool forceDropAnnotations = false;
980  bool dropAnnotations = false;
981 
982  if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
983  {
984  DIALOG_PASTE_SPECIAL dlg( m_frame, &forceKeepAnnotations, &forceDropAnnotations );
985 
986  if( dlg.ShowModal() == wxID_CANCEL )
987  return 0;
988  }
989 
990  if( forceDropAnnotations )
991  dropAnnotations = true;
992 
993  // SCH_LEGACY_PLUGIN added the items to the DLIST, but not to the view or anything
994  // else. Pull them back out to start with.
995  //
996  SCH_ITEM* firstNew = lastExisting ? lastExisting->Next() : dlist.GetFirst();
997  EDA_ITEMS loadedItems;
998  SCH_ITEM* next = nullptr;
999 
1000  bool sheetsPasted = false;
1001  SCH_SHEET_LIST hierarchy( g_RootSheet );
1002  wxFileName destFn = g_CurrentSheet->Last()->GetFileName();
1003 
1004  if( destFn.IsRelative() )
1005  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1006 
1007  for( SCH_ITEM* item = firstNew; item; item = next )
1008  {
1009  next = item->Next();
1010  dlist.Remove( item );
1011 
1012  loadedItems.push_back( item );
1013 
1014  if( item->Type() == SCH_COMPONENT_T )
1015  {
1016  if( !dropAnnotations && !forceKeepAnnotations )
1017  {
1018  for( SCH_ITEM* temp = dlist.GetFirst(); temp != lastExisting; temp = temp->Next() )
1019  {
1020  if( item->GetTimeStamp() == temp->GetTimeStamp() )
1021  dropAnnotations = true;
1022  }
1023  }
1024  }
1025  else if( item->Type() == SCH_SHEET_T )
1026  {
1027  SCH_SHEET* sheet = (SCH_SHEET*) item;
1028  wxFileName srcFn = sheet->GetFileName();
1029 
1030  if( srcFn.IsRelative() )
1031  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1032 
1033  SCH_SHEET_LIST sheetHierarchy( sheet );
1034 
1035  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1036  {
1037  auto msg = wxString::Format( _( "The pasted sheet \"%s\"\n"
1038  "was dropped because the destination already has "
1039  "the sheet or one of its subsheets as a parent." ),
1040  sheet->GetFileName() );
1041  DisplayError( m_frame, msg );
1042  loadedItems.pop_back();
1043  }
1044  }
1045  }
1046 
1047  // Now we can resolve the components and add everything to the screen, view, etc.
1048  //
1049  SYMBOL_LIB_TABLE* symLibTable = m_frame->Prj().SchSymbolLibTable();
1050  PART_LIB* partLib = m_frame->Prj().SchLibs()->GetCacheLibrary();
1051 
1052  for( unsigned i = 0; i < loadedItems.size(); ++i )
1053  {
1054  EDA_ITEM* item = loadedItems[i];
1055 
1056  if( item->Type() == SCH_COMPONENT_T )
1057  {
1058  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1059 
1060  if( dropAnnotations )
1061  {
1062  component->SetTimeStamp( GetNewTimeStamp() );
1063 
1064  // clear the annotation, but preserve the selected unit
1065  int unit = component->GetUnit();
1066  component->ClearAnnotation( nullptr );
1067  component->SetUnit( unit );
1068  }
1069 
1070  component->Resolve( *symLibTable, partLib );
1071  component->UpdatePins();
1072  }
1073  else if( item->Type() == SCH_SHEET_T )
1074  {
1075  SCH_SHEET* sheet = (SCH_SHEET*) item;
1076  wxFileName fn = sheet->GetFileName();
1077  SCH_SCREEN* existingScreen = nullptr;
1078  bool dropSheetAnnotations = false;
1079 
1080  // Duplicate sheet names and timestamps are not valid. Generate new timestamps
1081  // and timestamp-based sheet names.
1082  timestamp_t uid = GetNewTimeStamp();
1083 
1084  sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), (unsigned long)uid ) );
1085  sheet->SetTimeStamp( uid );
1086  sheet->SetParent( g_CurrentSheet->Last() );
1087  sheet->SetScreen( nullptr );
1088  sheetsPasted = true;
1089 
1090  if( !fn.IsAbsolute() )
1091  {
1092  wxFileName currentSheetFileName = g_CurrentSheet->LastScreen()->GetFileName();
1093  fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
1094  }
1095 
1096  if( g_RootSheet->SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ), &existingScreen ) )
1097  dropSheetAnnotations = true;
1098  else
1099  searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1100 
1101  if( existingScreen )
1102  {
1103  sheet->SetScreen( existingScreen );
1104 
1105  SCH_SHEET_PATH sheetpath = *g_CurrentSheet;
1106  sheetpath.push_back( sheet );
1107 
1108  // Clear annotation and create the AR for this path, if not exists,
1109  // when the screen is shared by sheet paths.
1110  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1111  // reference default value and takes the latest displayed value
1112  existingScreen->EnsureAlternateReferencesExist();
1113 
1114  if( forceDropAnnotations || dropSheetAnnotations )
1115  existingScreen->ClearAnnotation( &sheetpath );
1116  }
1117  else
1118  {
1119  if( !m_frame->LoadSheetFromFile( sheet, g_CurrentSheet, fn.GetFullPath() ) )
1120  m_frame->InitSheet( sheet, sheet->GetFileName() );
1121  }
1122  }
1123 
1124  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1125  m_frame->AddItemToScreenAndUndoList( (SCH_ITEM*) item, i > 0 );
1126 
1127  // Reset flags for subsequent move operation
1128  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1129  // Start out hidden so the pasted items aren't "ghosted" in their original location
1130  // before being moved to the current location.
1131  getView()->Hide( item, true );
1132  }
1133 
1134  if( sheetsPasted )
1136 
1137  // Now clear the previous selection, select the pasted items, and fire up the "move"
1138  // tool.
1139  //
1141  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1142 
1143  EE_SELECTION& selection = selTool->GetSelection();
1144 
1145  if( !selection.Empty() )
1146  {
1147  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
1148 
1149  selection.SetReferencePoint( item->GetPosition() );
1151  }
1152 
1153  return 0;
1154 }
1155 
1156 
1158 {
1161  SCH_COMPONENT* sym = nullptr;
1162  LIB_EDIT_FRAME* libEdit;
1163 
1164  if( selection.GetSize() >= 1 )
1165  sym = (SCH_COMPONENT*) selection.Front();
1166 
1167  if( !sym || sym->GetEditFlags() != 0 )
1168  return 0;
1169 
1171  libEdit = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
1172 
1173  if( libEdit )
1174  libEdit->LoadComponentAndSelectLib( sym->GetLibId(), sym->GetUnit(), sym->GetConvert() );
1175 
1176  return 0;
1177 }
1178 
1179 
1181 {
1182  wxCommandEvent dummy;
1183  m_frame->OnAnnotate( dummy );
1184  return 0;
1185 }
1186 
1187 
1189 {
1190  wxCommandEvent dummy;
1192  return 0;
1193 }
1194 
1195 
1197 {
1199  dlg.ShowQuasiModal();
1200  return 0;
1201 }
1202 
1203 
1205 {
1207  m_frame->HardRedraw();
1208 
1209  return 0;
1210 }
1211 
1212 
1214 {
1215  wxCommandEvent dummy;
1217  return 0;
1218 }
1219 
1220 
1222 {
1223  wxCommandEvent dummy;
1225  return 0;
1226 }
1227 
1228 
1230 {
1231  int result = NET_PLUGIN_CHANGE;
1232 
1233  // If a plugin is removed or added, rebuild and reopen the new dialog
1234  while( result == NET_PLUGIN_CHANGE )
1235  result = InvokeDialogNetList( m_frame );
1236 
1237  return 0;
1238 }
1239 
1240 
1242 {
1244  return 0;
1245 }
1246 
1247 
1249 {
1251  return 0;
1252 }
1253 
1254 
1256 {
1258  return 0;
1259 }
1260 
1261 
1263 {
1265  const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
1266 
1267  if( selection.GetSize() == 1 )
1268  {
1269  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1270 
1273 
1274  g_CurrentSheet->push_back( sheet );
1276  }
1277 
1278  return 0;
1279 }
1280 
1281 
1283 {
1284  if( g_CurrentSheet->Last() != g_RootSheet )
1285  {
1288 
1291  }
1292 
1293  return 0;
1294 }
1295 
1296 
1298 {
1300 
1301  auto painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
1302  painter->GetSettings()->m_ShowHiddenPins = m_frame->GetShowAllPins();
1303 
1305  m_frame->GetCanvas()->Refresh();
1306 
1307  return 0;
1308 }
1309 
1310 
1312 {
1314 
1315  return 0;
1316 }
1317 
1318 
1320 {
1321  Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1322  Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1323  Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1326  Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
1327  Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1328  Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1329 
1338 
1343 
1344 #ifdef KICAD_SPICE
1345  Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
1346  Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
1347 #endif /* KICAD_SPICE */
1348 
1355 
1356  Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1357  Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1358  Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
1359  Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
1360  Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1362 
1374 
1376 
1380 
1383 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
int Save(const TOOL_EVENT &aEvent)
CITER next(CITER it)
Definition: ptree.cpp:130
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1507
Class SCH_SHEET_LIST.
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Function PushCommandToUndoList add a command to undo in undo list delete the very old commands when t...
void LoadContent(LINE_READER &aReader, SCH_SCREEN *aScreen, int version=EESCHEMA_VERSION)
static void UpdatePins(const EE_COLLECTOR &aComponents)
Update the pin cache for all components in aComponents.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Change the time stamp to aNewTimeStamp and updates the reference path.
int FindAndReplace(const TOOL_EVENT &aEvent)
void OnOpenCvpcb(wxCommandEvent &event)
void Save_File(bool doSaveAs=false)
void SetCursor(const wxCursor &aCursor)
Definition: picker_tool.h:65
const wxString & GetFileName() const
Definition: sch_screen.h:123
int Copy(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
Definition: actions.h:197
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)
static TOOL_ACTION findAndReplace
Definition: actions.h:79
int m_Threshold
Definition: collector.h:68
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:559
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:994
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
const wxString & GetSelectedNetName() const
NETLIST_OBJECT_LIST * BuildNetListBase(bool updateStatusText=true)
Create a flat list which stores all connected objects.
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:83
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:159
wxFindReplaceData * GetFindReplaceData()
Get the find criteria (as set by the dialog).
static TOOL_ACTION navigateHierarchy
Definition: ee_actions.h:178
int HighlightNetCursor(const TOOL_EVENT &aEvent)
Launches a tool to highlight nets.
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:152
EDA_BASE_FRAME * GetEditFrame() const
Definition: tool_manager.h:268
void SendCrossProbeNetName(const wxString &aNetName)
Sends a net name to pcbnew for highlighting.
const wxString & GetName() const
Definition: sch_pin.h:100
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:82
static TOOL_ACTION pageSettings
Definition: actions.h:59
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generates the connection data for the entire schematic hierarchy.
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:198
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...
This file is part of the common library.
void SetForceHVLines(bool aForceHVdirection)
void ReversePickersListOrder()
Function ReversePickersListOrder reverses the order of pickers stored in this list.
static TOOL_ACTION doDelete
Definition: actions.h:74
static bool Replace(wxFindReplaceData &aSearchData, wxString &aText)
Helper function used in search and replace dialog Function Replace performs a text replace on aText u...
SCH_ITEM * Next() const
Definition: sch_item.h:153
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:72
bool SaveClipboard(const std::string &aText)
Stores an information to the system clipboard.
void SetScreen(BASE_SCREEN *aScreen) override
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:65
static wxFindReplaceData g_markersOnly
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:240
int Redo(const TOOL_EVENT &aEvent)
int NavigateHierarchy(const TOOL_EVENT &aEvent)
Definition: hierarch.cpp:132
int EditSymbolFields(const TOOL_EVENT &aEvent)
bool Resolve(PART_LIBS *aLibs)
Assigns the current LIB_PART from aLibs which this symbol is based on.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
int GetUndoCommandCount() const
Definition: base_screen.h:201
void SendCrossProbeClearHighlight()
Tells PcbNew to clear the existing highlighted net, if one exists.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:104
static TOOL_ACTION replaceAll
Definition: actions.h:83
int ReplaceAndFindNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
void UpdateAllItems(int aUpdateFlags)
Updates all items in the view according to the given flags.
Definition: view.cpp:1444
void SetWksFileName(const wxString &aFilename)
static const wxCursor & GetCursor(CURSOR aCursorType)
void SetBrightened()
Definition: base_struct.h:241
#define HITTEST_THRESHOLD_PIXELS
void ClearBrightenedPins()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
int New(const TOOL_EVENT &aEvent)
void Format(SCH_SCREEN *aScreen)
Class EE_COLLECTOR.
Definition: ee_collectors.h:39
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:93
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:840
bool IsBrightened() const
Definition: base_struct.h:236
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
Schematic editor (Eeschema) main window.
int FindNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:153
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:216
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
int ExplicitCrossProbeToPcb(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:44
void EnsureAlternateReferencesExist()
For screens shared by many sheetpaths (complex hierarchies): to be able to clear or modify any refere...
Definition: sch_screen.cpp:748
bool searchSupplementaryClipboard(const wxString &aSheetFilename, SCH_SCREEN **aScreen)
static TOOL_ACTION print
Definition: actions.h:60
int Annotate(const TOOL_EVENT &aEvent)
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:261
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:45
Class VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
int GenerateBOM(const TOOL_EVENT &aEvent)
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
static TOOL_ACTION find
Definition: actions.h:78
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:281
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Notifies pcbnew about the selected item.
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:204
SCH_SHEET_PATH * FindSheetForScreen(SCH_SCREEN *aScreen)
Function FindSheetForScreen.
void setTransitions() override
Sets up handlers for various events.
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int DrawSheetOnClipboard(const TOOL_EVENT &aEvent)
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
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:201
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
int SaveAs(const TOOL_EVENT &aEvent)
int ToggleForceHV(const TOOL_EVENT &aEvent)
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
void pop_back()
Forwarded method from std::vector.
EDA_ITEM * Next() const
Definition: base_struct.h:218
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net under the cursor.
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:177
void ClearBrightened()
Definition: base_struct.h:245
static TOOL_ACTION pickerTool
Definition: actions.h:145
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
Definition: picker_tool.h:102
EE_SELECTION & GetSelection()
Function GetSelection()
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:109
static TOOL_ACTION updateFind
Definition: actions.h:84
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
PopCommandFromUndoList return the last command to undo and remove it from list nothing is deleted.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
static TOOL_ACTION annotate
Definition: ee_actions.h:146
Class SCH_EDITOR_CONTROL.
Class TOOL_MANAGER.
Definition: tool_manager.h:50
int EnterSheet(const TOOL_EVENT &aEvent)
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:113
int ShowPcbNew(const TOOL_EVENT &aEvent)
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard
int Paste(const TOOL_EVENT &aEvent)
void SendMessageToPCBNEW(EDA_ITEM *aObjectToSync, SCH_COMPONENT *aPart)
Send a message to Pcbnew via a socket connection.
static TOOL_ACTION showPcbNew
Definition: ee_actions.h:157
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:243
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
int UpdatePCB(const TOOL_EVENT &aEvent)
int ShowCvpcb(const TOOL_EVENT &aEvent)
int GetUnit() const
void BrightenPin(LIB_PIN *aPin)
void BrightenItem(EDA_ITEM *aItem)
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:205
virtual wxPoint GetPosition() const =0
Function GetPosition.
static TOOL_ACTION showBusManager
Definition: ee_actions.h:153
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:147
Item is being added to the view.
Definition: view_item.h:60
bool LoadSheetFromFile(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, const wxString &aFileName)
Load a the KiCad schematic file aFileName into the sheet aSheet.
Definition: sheet.cpp:102
int TestDuplicateSheetNames(bool aCreateMarker)
Function TestDuplicateSheetNames( ) inside a given sheet, one cannot have sheets with duplicate names...
Definition: erc.cpp:174
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:265
wxString Name(bool aIgnoreSheet=false) const
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:47
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:328
int LeaveSheet(const TOOL_EVENT &aEvent)
static TOOL_ACTION simTune
Definition: ee_actions.h:199
int Print(const TOOL_EVENT &aEvent)
void SetName(const wxString &aName)
Definition: sch_sheet.h:273
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:225
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:270
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
bool GetForceHVLines() const
void SyncView()
Mark all items for refresh.
int ReplaceAll(const TOOL_EVENT &aEvent)
int ShowQuasiModal()
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:642
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
static TOOL_ACTION open
Definition: actions.h:53
static TOOL_ACTION explicitCrossProbe
Definition: ee_actions.h:186
static TOOL_ACTION save
Definition: actions.h:54
static TOOL_ACTION doNew
Definition: actions.h:47
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
int UpdateFind(const TOOL_EVENT &aEvent)
Class TOOL_EVENT.
Definition: tool_event.h:171
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
PopCommandFromRedoList return the last command to undo and remove it from list nothing is deleted.
int EditWithLibEdit(const TOOL_EVENT &aEvent)
int Plot(const TOOL_EVENT &aEvent)
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
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 cut
Definition: actions.h:69
timestamp_t GetTimeStamp() const
Definition: base_struct.h:216
int ImportFPAssignments(const TOOL_EVENT &aEvent)
Definition: backanno.cpp:207
EDA_ITEM * GetParent() const
Definition: base_struct.h:220
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...
Definition: base_struct.h:418
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
static TOOL_ACTION quit
Definition: actions.h:62
EDA_ITEM * nextMatch(SCH_SCREEN *aScreen, EDA_ITEM *after, wxFindReplaceData *data)
SCH_CONNECTION * GetConnectionForPin(LIB_PIN *aPin, const SCH_SHEET_PATH &aSheet)
Retrieves the connection for a given pin of the component.
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:140
bool InvokeDialogEditComponentsLibId(SCH_EDIT_FRAME *aCaller)
Run a dialog to modify the LIB_ID of components for instance when a symbol has moved from a symbol li...
static const TOOL_EVENT ClearedEvent
Definition: actions.h:199
static TOOL_ACTION replaceAndFindNext
Definition: actions.h:82
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
static TOOL_ACTION plot
Definition: actions.h:61
void UpdateItems()
Function UpdateItems() Iterates through the list of items that asked for updating and updates them.
Definition: view.cpp:1421
const std::string & GetString()
Definition: richio.h:475
bool Matches(const TOOL_EVENT &aEvent) const
Function Matches() Tests whether two events match in terms of category & action or command.
Definition: tool_event.h:364
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:75
void SetUnit(int aUnit)
Change the unit number to aUnit.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
Class SCH_SHEET_PATH.
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Updates net highlighting after an edit
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear exiting component annotation.
All active tools
Definition: tool_event.h:147
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:1540
void OnUpdatePCB(wxCommandEvent &event)
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
bool LoadComponentAndSelectLib(const LIB_ID &aLibId, int aUnit, int aConvert)
Selects the currently active library and loads the symbol from aLibId.
Definition: libedit.cpp:141
static VECTOR2D CLEAR
#define _(s)
void UnbrightenItem(EDA_ITEM *aItem)
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual 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...
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:128
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
A SCH_PLUGIN derivation for loading schematic files created before the new s-expression file format.
Implementing SIM_PLOT_FRAME_BASE.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList, bool aRedoCommand)
Restore an undo or redo command to put data pointed by aList in the previous state.
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:98
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:646
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
static bool m_allowRealTime
void OnAnnotate(wxCommandEvent &event)
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
int Open(const TOOL_EVENT &aEvent)
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
static TOOL_ACTION findNextMarker
Definition: actions.h:81
static TOOL_ACTION redo
Definition: actions.h:68
int PageSetup(const TOOL_EVENT &aEvent)
void ClearFindReplaceStatus()
void GetPins(std::vector< LIB_PIN * > &aPinsList)
Populate a vector with all the pins from the library object.
The symbol library editor main window.
int Quit(const TOOL_EVENT &aEvent)
void FocusOnLocation(const wxPoint &aPos, bool aCenterView=false)
Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor...
int AddItemToSel(const TOOL_EVENT &aEvent)
static TOOL_ACTION showSymbolEditor
Definition: actions.h:150
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
static TOOL_ACTION saveAs
Definition: actions.h:55
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:183
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
int ShowBusManager(const TOOL_EVENT &aEvent)
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
int Cut(const TOOL_EVENT &aEvent)
Clipboard support.
static TOOL_ACTION importFPAssignments
Definition: ee_actions.h:158
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
void RollbackSchematicFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
bool HasBrightenedPins()
size_t i
Definition: json11.cpp:649
std::string GetClipboard() const
Returns the information currently stored in the system clipboard.
void RebuildSelection()
Rebuilds the selection from the EDA_ITEMs' selection flags.
int ClearHighlight(const TOOL_EVENT &aEvent)
Removes any net highlighting
static wxString GetSpiceField(SPICE_FIELD aField, SCH_COMPONENT *aComponent, unsigned aCtl)
Retrieves either the requested field value or the default value.
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Function PushCommandToRedoList add a command to redo in redo list delete the very old commands when t...
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
static const KICAD_T AllItems[]
Definition: ee_collectors.h:42
void OnOpenPcbnew(wxCommandEvent &event)
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
#define NET_PLUGIN_CHANGE
Create and shows NETLIST_DIALOG and returns whatever NETLIST_DIALOG::ShowModal() returns.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
static TOOL_ACTION drawSheetOnClipboard
Definition: ee_actions.h:193
int Undo(const TOOL_EVENT &aEvent)
bool doCopy()
copy selection to clipboard
static TOOL_ACTION enterSheet
Definition: ee_actions.h:176
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:203
void Activate()
Function Activate() Runs the tool.
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:729
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:156
static TOOL_ACTION move
Definition: ee_actions.h:115
static TOOL_ACTION simProbe
Definition: ee_actions.h:198
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
int GetConvert() const
static TOOL_ACTION undo
Definition: actions.h:67
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:983
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: common.h:53
static TOOL_ACTION generateBOM
Definition: ee_actions.h:160
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void Print()
Show the print dialog.
static TOOL_ACTION highlightNet
Definition: ee_actions.h:202
#define MAX_PAGE_SIZE_MILS
Definition: page_info.h:41
void InvokeDialogBusManager(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BUS_MANAGER.
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition for part library class.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
Class VIEW.
Definition: view.h:61
void AddTuner(SCH_COMPONENT *aComponent)
Adds a tuner for a component.
const wxPoint GetCenter() const
Definition: eda_rect.h:117
EDA_ITEM * SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, bool *aSelectionCancelledFlag=NULL, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
Function selectPoint() Selects an item pointed by the parameter aWhere.
Definition of the NETLIST_OBJECT class.
static TOOL_ACTION editSymbolLibraryLinks
Definition: ee_actions.h:148
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:192
const LIB_ID & GetLibId() const
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName) const
Function TestForRecursion.
Class STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
Class STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
DLIST< SCH_ITEM > & GetDrawList()
Definition: sch_screen.h:106
Object used to load, save, search, and otherwise manipulate symbol library files.
void ShowFindReplaceStatus(const wxString &aMsg)
int GetRedoCommandCount() const
Definition: base_screen.h:206
void SetSelectedNetName(const wxString &aNetName)
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:512
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
static TOOL_ACTION findNext
Definition: actions.h:80
static TOOL_ACTION paste
Definition: actions.h:71
bool GetShowAllPins() const override
Allow some frames to show/hide hidden pins.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: base_struct.h:133
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
SCH_SCREEN * LastScreen() const
Function LastScreen.
EDA_ITEM * Front() const
Definition: selection.h:182
void SetShowAllPins(bool aEnable)
int ExportNetlist(const TOOL_EVENT &aEvent)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:215
void AddItemToScreenAndUndoList(SCH_ITEM *aItem, bool aUndoAppend=false)
Add an item to the schematic and adds the changes to the undo/redo container.
#define IS_MOVED
Item being moved.
Definition: base_struct.h:119
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:152