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 <class_library.h>
26 #include <confirm.h>
27 #include <connection_graph.h>
31 #include <erc.h>
32 #include <fctsys.h>
33 #include <invoke_sch_dialog.h>
34 #include <kiway.h>
36 #include <netlist_object.h>
37 #include <sch_edit_frame.h>
38 #include <sch_legacy_plugin.h>
39 #include <sch_line.h>
40 #include <sch_painter.h>
41 #include <sch_sheet.h>
42 #include <sch_view.h>
43 #include <advanced_config.h>
44 #include <sim/sim_plot_frame.h>
45 #include <simulation_cursors.h>
46 #include <status_popup.h>
47 #include <tool/picker_tool.h>
48 #include <tool/tool_manager.h>
49 #include <tools/ee_actions.h>
50 #include <tools/ee_selection.h>
53 #include <ws_proxy_undo_item.h>
56 #include <invoke_sch_dialog.h>
59 #include <math/util.h> // for KiROUND
60 #include <dialog_update_from_pcb.h>
61 
62 int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
63 {
65  return 0;
66 }
67 
68 
70 {
72  return 0;
73 }
74 
75 
77 {
79  return 0;
80 }
81 
82 
84 {
85  m_frame->Save_File( true );
86  return 0;
87 }
88 
89 
91 {
93  return 0;
94 }
95 
96 
98 {
99  PICKED_ITEMS_LIST undoCmd;
100  WS_PROXY_UNDO_ITEM* undoItem = new WS_PROXY_UNDO_ITEM( m_frame );
101  ITEM_PICKER wrapper( undoItem, UR_PAGESETTINGS );
102 
103  undoCmd.PushItem( wrapper );
105 
108 
109  if( dlg.ShowModal() != wxID_OK )
111 
112  return 0;
113 }
114 
115 
117 {
118  m_frame->Print();
119  return 0;
120 }
121 
122 
124 {
126  return 0;
127 }
128 
129 
131 {
132  m_frame->Close( false );
133  return 0;
134 }
135 
136 
137 // A dummy wxFindReplaceData signalling any marker should be found
138 static wxFindReplaceData g_markersOnly;
139 
140 
142 {
144  return UpdateFind( aEvent );
145 }
146 
148 {
150  return 0;
151 }
152 
154 {
155  wxFindReplaceData* data = m_frame->GetFindReplaceData();
156 
157  if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
158  || aEvent.IsAction( &ACTIONS::updateFind ) )
159  {
161 
162  for( auto item : m_frame->GetScreen()->Items() )
163  {
164  if( data && item->Matches( *data, nullptr ) )
165  m_selectionTool->BrightenItem( item );
166  else if( item->IsBrightened() )
168  }
169  }
170  else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
171  {
172  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
173  {
174  if( data && item->Matches( *data, nullptr ) )
175  m_selectionTool->BrightenItem( item );
176  else if( item->IsBrightened() )
178  }
179  }
180 
181  getView()->UpdateItems();
182  m_frame->GetCanvas()->Refresh();
183  m_frame->UpdateTitle();
184 
185  return 0;
186 }
187 
188 
190  SCH_SCREEN* aScreen, SCH_ITEM* aAfter, wxFindReplaceData* aData )
191 {
192  bool past_item = true;
193 
194  if( aAfter != nullptr )
195  {
196  past_item = false;
197 
198  if( aAfter->Type() == SCH_PIN_T || aAfter->Type() == SCH_FIELD_T )
199  aAfter = static_cast<SCH_ITEM*>( aAfter->GetParent() );
200  }
201 
202 
203  for( auto item : aScreen->Items() )
204  {
205  if( item == aAfter )
206  {
207  past_item = true;
208  }
209  else if( past_item )
210  {
211  if( aData == &g_markersOnly && item->Type() == SCH_MARKER_T )
212  return item;
213 
214  if( item->Matches( *aData, nullptr ) )
215  return item;
216 
217  if( item->Type() == SCH_COMPONENT_T )
218  {
219  auto cmp = static_cast<SCH_COMPONENT*>( item );
220 
221  for( auto field : cmp->GetFields() )
222  {
223  if( field->Matches( *aData, nullptr ) )
224  return field;
225  }
226 
227  for( auto pin : cmp->GetSchPins() )
228  {
229  if( pin->Matches( *aData, nullptr ) )
230  return pin;
231  }
232  }
233 
234  if( item->Type() == SCH_SHEET_T )
235  {
236  auto sheet = static_cast<SCH_SHEET*>( item );
237 
238  for( SCH_FIELD& field : sheet->GetFields() )
239  {
240  if( field.Matches( *aData, nullptr ) )
241  return &field;
242  }
243 
244  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
245  {
246  if( pin->Matches( *aData, nullptr ) )
247  return pin;
248  }
249  }
250  }
251  }
252 
253  return nullptr;
254 }
255 
256 
258 {
259  // A timer during which a subsequent FindNext will result in a wrap-around
260  static wxTimer wrapAroundTimer;
261 
262  wxFindReplaceData* data = m_frame->GetFindReplaceData();
263 
264  if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
265  {
266  if( data )
267  g_markersOnly.SetFlags( data->GetFlags() );
268 
269  data = &g_markersOnly;
270  }
271  else if( !data )
272  {
273  return FindAndReplace( ACTIONS::find.MakeEvent() );
274  }
275 
276  bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
277  EE_SELECTION& selection = m_selectionTool->GetSelection();
278  SCH_SCREEN* afterScreen = m_frame->GetScreen();
279  SCH_ITEM* afterItem = dynamic_cast<SCH_ITEM*>( selection.Front() );
280  SCH_ITEM* item = nullptr;
281 
282  if( wrapAroundTimer.IsRunning() )
283  {
284  afterScreen = nullptr;
285  afterItem = nullptr;
286  wrapAroundTimer.Stop();
288  }
289 
291 
292  if( afterScreen || !searchAllSheets )
293  item = nextMatch( m_frame->GetScreen(), afterItem, data );
294 
295  if( !item && searchAllSheets )
296  {
297  SCH_SHEET_LIST schematic( g_RootSheet );
298  SCH_SCREENS screens;
299 
300  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
301  {
302  if( afterScreen )
303  {
304  if( afterScreen == screen )
305  afterScreen = nullptr;
306 
307  continue;
308  }
309 
310  item = nextMatch( screen, nullptr, data );
311 
312  if( item )
313  {
314  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
315  wxCHECK_MSG( sheet, 0, "Sheet not found for " + screen->GetFileName() );
316 
317  *g_CurrentSheet = *sheet;
319 
320  screen->SetZoom( m_frame->GetScreen()->GetZoom() );
321  screen->TestDanglingEnds();
322 
323  m_frame->SetScreen( screen );
324  UpdateFind( ACTIONS::updateFind.MakeEvent() );
325 
326  break;
327  }
328  }
329  }
330 
331  if( item )
332  {
333  m_selectionTool->AddItemToSel( item );
334  m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter() );
335  m_frame->GetCanvas()->Refresh();
336  }
337  else
338  {
339  wxString msg = searchAllSheets ? _( "Reached end of schematic." )
340  : _( "Reached end of sheet." );
341 
342  m_frame->ShowFindReplaceStatus( msg + _( "\nFind again to wrap around to the start." ) );
343  wrapAroundTimer.StartOnce( 4000 );
344  }
345 
346  return 0;
347 }
348 
349 
351 {
352  wxFindReplaceData* data = m_frame->GetFindReplaceData();
354 
355  return data && item && item->Matches( *data, nullptr );
356 }
357 
358 
360 {
361  wxFindReplaceData* data = m_frame->GetFindReplaceData();
363 
364  if( !data )
365  return FindAndReplace( ACTIONS::find.MakeEvent() );
366 
367  if( item && item->Matches( *data, nullptr ) )
368  {
369  item->Replace( *data, g_CurrentSheet );
370  FindNext( ACTIONS::findNext.MakeEvent() );
371  }
372 
373  return 0;
374 }
375 
376 
378 {
379  wxFindReplaceData* data = m_frame->GetFindReplaceData();
380 
381  if( !data )
382  return FindAndReplace( ACTIONS::find.MakeEvent() );
383 
384  SCH_SHEET_LIST schematic( g_RootSheet );
385  SCH_SCREENS screens;
386 
387  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
388  {
389  //TODO(snh): Fix ReplaceAll
390  // screen->ForEachItem() for( EDA_ITEM* item = nextMatch( screen, nullptr, data ); item;
391  // item = nextMatch( screen, item, data ) )
392  // {
393  // item->Replace( *data, schematic.FindSheetForScreen( screen ) );
394  // }
395  }
396 
397  return 0;
398 }
399 
400 
402 {
403  doCrossProbeSchToPcb( aEvent, false );
404  return 0;
405 }
406 
407 
409 {
410  doCrossProbeSchToPcb( aEvent, true );
411  return 0;
412 }
413 
414 
415 void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
416 {
417  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
418  if( m_probingPcbToSch )
419  return;
420 
422  SCH_ITEM* item = nullptr;
423  SCH_COMPONENT* component = nullptr;
424 
425  if( aForce )
426  {
427  EE_SELECTION& selection = selTool->RequestSelection();
428 
429  if( selection.GetSize() >= 1 )
430  item = (SCH_ITEM*) selection.Front();
431  }
432  else
433  {
434  EE_SELECTION& selection = selTool->GetSelection();
435 
436  if( selection.GetSize() >= 1 )
437  item = (SCH_ITEM*) selection.Front();
438  }
439 
440  if( !item )
441  {
442  if( aForce )
443  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
444 
445  return;
446  }
447 
448 
449  switch( item->Type() )
450  {
451  case SCH_FIELD_T:
452  case LIB_FIELD_T:
453  if( item->GetParent() && item->GetParent()->Type() == SCH_COMPONENT_T )
454  {
455  component = (SCH_COMPONENT*) item->GetParent();
456  m_frame->SendMessageToPCBNEW( item, component );
457  }
458  break;
459 
460  case SCH_COMPONENT_T:
461  component = (SCH_COMPONENT*) item;
462  m_frame->SendMessageToPCBNEW( item, component );
463  break;
464 
465  case SCH_PIN_T:
466  component = (SCH_COMPONENT*) item->GetParent();
467  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), component );
468  break;
469 
470  case SCH_SHEET_T:
471  if( aForce )
472  m_frame->SendMessageToPCBNEW( item, nullptr );
473  break;
474 
475  default:
476  break;
477  }
478 }
479 
480 
481 #ifdef KICAD_SPICE
482 
483 static KICAD_T wires[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
484 static KICAD_T wiresAndPins[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT };
485 static KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
486 
487 #define HITTEST_THRESHOLD_PIXELS 5
488 
489 
490 int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
491 {
492  auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
493  auto simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
494 
495  if( !simFrame ) // Defensive coding; shouldn't happen.
496  return 0;
497 
498  // Deactivate other tools; particularly important if another PICKER is currently running
499  Activate();
500 
501  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) );
502 
503  picker->SetClickHandler(
504  [this, simFrame] ( const VECTOR2D& aPosition )
505  {
507  EDA_ITEM* item = selTool->SelectPoint( aPosition, wiresAndPins );
508 
509  if( !item )
510  return false;
511 
512  if( item->IsType( wires ) )
513  {
514  std::unique_ptr<NETLIST_OBJECT_LIST> netlist( m_frame->BuildNetListBase() );
515 
516  for( NETLIST_OBJECT* obj : *netlist )
517  {
518  if( obj->m_Comp == item )
519  {
520  simFrame->AddVoltagePlot( UnescapeString( obj->GetNetName() ) );
521  break;
522  }
523  }
524  }
525  else if( item->Type() == SCH_PIN_T )
526  {
527  SCH_PIN* pin = (SCH_PIN*) item;
528  SCH_COMPONENT* comp = (SCH_COMPONENT*) item->GetParent();
529  wxString param;
530  wxString primitive;
531 
533  primitive.LowerCase();
534 
535  if( primitive == "c" || primitive == "l" || primitive == "r" )
536  param = wxT( "I" );
537  else if( primitive == "d" )
538  param = wxT( "Id" );
539  else
540  param = wxString::Format( wxT( "I%s" ), pin->GetName().Lower() );
541 
542  simFrame->AddCurrentPlot( comp->GetRef( g_CurrentSheet ), param );
543  }
544 
545  return true;
546  } );
547 
548  picker->SetMotionHandler(
549  [this, picker] ( const VECTOR2D& aPos )
550  {
551  EE_COLLECTOR collector;
552  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
553  collector.Collect( m_frame->GetScreen(), wiresAndPins, (wxPoint) aPos );
554 
556  selectionTool->GuessSelectionCandidates( collector, aPos );
557 
558  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
559  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
560  wxString netName;
561 
562  if( wire )
563  {
564  item = nullptr;
565 
566  if( wire->Connection( *g_CurrentSheet ) )
567  netName = wire->Connection( *g_CurrentSheet )->Name();
568  }
569 
570  if( item && item->Type() == SCH_PIN_T )
571  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURRENT_PROBE ) );
572  else
573  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) );
574 
575  if( m_pickerItem != item )
576  {
577 
578  if( m_pickerItem )
579  selectionTool->UnbrightenItem( m_pickerItem );
580 
581  m_pickerItem = item;
582 
583  if( m_pickerItem )
584  selectionTool->BrightenItem( m_pickerItem );
585  }
586 
587  if( m_frame->GetSelectedNetName() != netName )
588  {
589  m_frame->SetSelectedNetName( netName );
590 
591  TOOL_EVENT dummyEvent;
592  UpdateNetHighlighting( dummyEvent );
593  }
594  } );
595 
596  picker->SetFinalizeHandler(
597  [this] ( const int& aFinalState )
598  {
599  if( m_pickerItem )
601 
602  if( !m_frame->GetSelectedNetName().IsEmpty() )
603  {
604  m_frame->SetSelectedNetName( wxEmptyString );
605 
606  TOOL_EVENT dummyEvent;
607  UpdateNetHighlighting( dummyEvent );
608  }
609  } );
610 
611  std::string tool = aEvent.GetCommandStr().get();
612  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
613 
614  return 0;
615 }
616 
617 
618 int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
619 {
621 
622  // Deactivate other tools; particularly important if another PICKER is currently running
623  Activate();
624 
625  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURSOR::TUNE ) );
626 
627  picker->SetClickHandler(
628  [this] ( const VECTOR2D& aPosition )
629  {
631  EDA_ITEM* item = selTool->SelectPoint( aPosition, fieldsAndComponents );
632 
633  if( !item )
634  return false;
635 
636  if( item->Type() != SCH_COMPONENT_T )
637  {
638  item = item->GetParent();
639 
640  if( item->Type() != SCH_COMPONENT_T )
641  return false;
642  }
643 
644  SIM_PLOT_FRAME* simFrame =
646 
647  if( simFrame )
648  simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
649 
650  return true;
651  } );
652 
653  picker->SetMotionHandler(
654  [this] ( const VECTOR2D& aPos )
655  {
656  EE_COLLECTOR collector;
657  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
658  collector.Collect( m_frame->GetScreen(), fieldsAndComponents, (wxPoint) aPos );
659 
661  selectionTool->GuessSelectionCandidates( collector, aPos );
662 
663  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
664 
665  if( m_pickerItem != item )
666  {
667  if( m_pickerItem )
668  selectionTool->UnbrightenItem( m_pickerItem );
669 
670  m_pickerItem = item;
671 
672  if( m_pickerItem )
673  selectionTool->BrightenItem( m_pickerItem );
674  }
675  } );
676 
677  picker->SetFinalizeHandler(
678  [this] ( const int& aFinalState )
679  {
680  if( m_pickerItem )
682  } );
683 
684  std::string tool = aEvent.GetCommandStr().get();
685  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
686 
687  return 0;
688 }
689 #endif /* KICAD_SPICE */
690 
691 
692 // A singleton reference for clearing the highlight
694 
695 
696 // TODO(JE) Probably use netcode rather than connection name here eventually
697 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
698 {
699  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
700  EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
701  SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
702  wxString netName;
703  bool retVal = true;
704 
705  if( aPosition != CLEAR )
706  {
707  if( TestDuplicateSheetNames( false ) > 0 )
708  {
709  wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
710  retVal = false;
711  }
712  else
713  {
714  SCH_ITEM* item = (SCH_ITEM*) selTool->GetNode( aPosition );
715 
716  if( item && item->Connection( *g_CurrentSheet ) )
717  netName = item->Connection( *g_CurrentSheet )->Name();
718  }
719  }
720 
721  if( netName.empty() )
722  {
723  editFrame->SetStatusText( wxT( "" ) );
724  editFrame->SendCrossProbeClearHighlight();
725  }
726  else
727  {
728  editFrame->SendCrossProbeNetName( netName );
729  editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
730  UnescapeString( netName ) ) );
731  }
732 
733  editFrame->SetSelectedNetName( netName );
735  editorControl->UpdateNetHighlighting( dummy );
736 
737  return retVal;
738 }
739 
740 
742 {
744  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
745 
746  highlightNet( m_toolMgr, cursorPos );
747 
748  return 0;
749 }
750 
751 
753 {
755 
756  return 0;
757 }
758 
759 
761 {
762  SCH_SCREEN* screen = g_CurrentSheet->LastScreen();
763  std::vector<EDA_ITEM*> itemsToRedraw;
764  wxString selectedNetName = m_frame->GetSelectedNetName();
765 
766  if( !screen )
767  return 0;
768 
769  for( auto item : screen->Items() )
770  {
771  SCH_CONNECTION* conn = item->Connection( *g_CurrentSheet );
772  bool redraw = item->IsBrightened();
773 
774  if( conn && conn->Name() == selectedNetName )
775  item->SetBrightened();
776  else
777  item->ClearBrightened();
778 
779  redraw |= item->IsBrightened();
780 
781  if( item->Type() == SCH_COMPONENT_T )
782  {
783  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
784 
785  redraw |= comp->HasBrightenedPins();
786 
787  comp->ClearBrightenedPins();
788  std::vector<LIB_PIN*> pins;
789  comp->GetPins( pins );
790 
791  for( LIB_PIN* pin : pins )
792  {
793  auto pin_conn = comp->GetConnectionForPin( pin, *g_CurrentSheet );
794 
795  if( pin_conn && pin_conn->Name( false ) == selectedNetName )
796  {
797  comp->BrightenPin( pin );
798  redraw = true;
799  }
800  }
801  }
802  else if( item->Type() == SCH_SHEET_T )
803  {
804  for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
805  {
806  auto pin_conn = pin->Connection( *g_CurrentSheet );
807  bool redrawPin = pin->IsBrightened();
808 
809  if( pin_conn && pin_conn->Name() == selectedNetName )
810  pin->SetBrightened();
811  else
812  pin->ClearBrightened();
813 
814  redrawPin |= pin->IsBrightened();
815 
816  if( redrawPin )
817  itemsToRedraw.push_back( pin );
818  }
819  }
820 
821  if( redraw )
822  itemsToRedraw.push_back( item );
823  }
824 
825  // Be sure highlight change will be redrawn
826  KIGFX::VIEW* view = getView();
827 
828  for( auto redrawItem : itemsToRedraw )
830 
831  m_frame->GetCanvas()->Refresh();
832 
833  return 0;
834 }
835 
836 
838 {
839  // TODO(JE) remove once real-time connectivity is a given
840  if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
842 
843  std::string tool = aEvent.GetCommandStr().get();
845 
846  // Deactivate other tools; particularly important if another PICKER is currently running
847  Activate();
848 
849  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
850 
851  picker->SetClickHandler(
852  [this] ( const VECTOR2D& aPos )
853  {
854  return highlightNet( m_toolMgr, aPos );
855  } );
856 
857  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
858 
859  return 0;
860 }
861 
862 
864 {
865  if( m_frame->GetScreen()->GetUndoCommandCount() <= 0 )
866  return 0;
867 
868  // Inform tools that undo command was issued
870 
871  /* Get the old list */
873 
874  /* Undo the command */
875  m_frame->PutDataInPreviousState( List, false );
876 
877  /* Put the old list in RedoList */
878  List->ReversePickersListOrder();
880 
882  selTool->RebuildSelection();
883 
886 
887  m_frame->SyncView();
888  m_frame->GetCanvas()->Refresh();
889  m_frame->OnModify();
890 
891  return 0;
892 }
893 
894 
896 {
897  if( m_frame->GetScreen()->GetRedoCommandCount() == 0 )
898  return 0;
899 
900  // Inform tools that undo command was issued
902 
903  /* Get the old list */
905 
906  /* Redo the command: */
907  m_frame->PutDataInPreviousState( List, true );
908 
909  /* Put the old list in UndoList */
910  List->ReversePickersListOrder();
912 
914  selTool->RebuildSelection();
915 
918 
919  m_frame->SyncView();
920  m_frame->GetCanvas()->Refresh();
921  m_frame->OnModify();
922 
923  return 0;
924 }
925 
926 
928 {
930  EE_SELECTION& selection = selTool->RequestSelection();
931 
932  if( !selection.GetSize() )
933  return false;
934 
935  m_supplementaryClipboard.clear();
936 
937  for( EDA_ITEM* item : selection )
938  {
939  if( item->Type() == SCH_SHEET_T )
940  {
941  SCH_SHEET* sheet = (SCH_SHEET*) item;
942  m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
943  }
944  }
945 
946  STRING_FORMATTER formatter;
947  SCH_LEGACY_PLUGIN plugin;
948 
949  plugin.Format( &selection, &formatter );
950 
951  return m_toolMgr->SaveClipboard( formatter.GetString() );
952 }
953 
954 
955 bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
956  SCH_SCREEN** aScreen )
957 {
958  if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
959  {
960  *aScreen = m_supplementaryClipboard[ aSheetFilename ];
961  return true;
962  }
963 
964  return false;
965 }
966 
967 
969 {
970  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
971 
972  if( textEntry )
973  {
974  textEntry->Cut();
975  return 0;
976  }
977 
978  if( doCopy() )
980 
981  return 0;
982 }
983 
984 
986 {
987  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
988 
989  if( textEntry )
990  {
991  textEntry->Copy();
992  return 0;
993  }
994 
995  doCopy();
996 
997  return 0;
998 }
999 
1000 
1002 {
1003  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1004 
1005  if( textEntry )
1006  {
1007  textEntry->Paste();
1008  return 0;
1009  }
1010 
1012  std::string text = m_toolMgr->GetClipboard();
1013 
1014  if( text.empty() )
1015  return 0;
1016 
1017  STRING_LINE_READER reader( text, "Clipboard" );
1018  SCH_LEGACY_PLUGIN plugin;
1019 
1020  SCH_SCREEN paste_screen( &m_frame->GetScreen()->Kiway() );
1021 
1022  try
1023  {
1024  plugin.LoadContent( reader, &paste_screen );
1025  }
1026  catch( IO_ERROR& )
1027  {
1028  // If it wasn't content, then paste as text
1029  paste_screen.Append( new SCH_TEXT( wxPoint( 0, 0 ), text ) );
1030  }
1031 
1032  bool forceKeepAnnotations = false;
1033  bool forceDropAnnotations = false;
1034  bool dropAnnotations = false;
1035 
1036  if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1037  {
1038  DIALOG_PASTE_SPECIAL dlg( m_frame, &forceKeepAnnotations, &forceDropAnnotations );
1039 
1040  if( dlg.ShowModal() == wxID_CANCEL )
1041  return 0;
1042  }
1043 
1044  if( forceDropAnnotations )
1045  dropAnnotations = true;
1046 
1047  // SCH_LEGACY_PLUGIN added the items to the paste screen, but not to the view or anything
1048  // else. Pull them back out to start with.
1049  //
1050  EDA_ITEMS loadedItems;
1051  bool sheetsPasted = false;
1052  SCH_SHEET_LIST hierarchy( g_RootSheet );
1053  wxFileName destFn = g_CurrentSheet->Last()->GetFileName();
1054 
1055  if( destFn.IsRelative() )
1056  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1057 
1058  for( auto item : paste_screen.Items() )
1059  {
1060  loadedItems.push_back( item );
1061 
1062  if( item->Type() == SCH_COMPONENT_T )
1063  {
1064  if( !dropAnnotations && !forceKeepAnnotations )
1065  {
1066  for( auto existingItem : m_frame->GetScreen()->Items() )
1067  {
1068  if( item->m_Uuid == existingItem->m_Uuid )
1069  {
1070  dropAnnotations = true;
1071  break;
1072  }
1073  }
1074  }
1075  }
1076  else if( item->Type() == SCH_SHEET_T )
1077  {
1078  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1079  wxFileName srcFn = sheet->GetFileName();
1080 
1081  if( srcFn.IsRelative() )
1082  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1083 
1084  SCH_SHEET_LIST sheetHierarchy( sheet );
1085 
1086  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1087  {
1088  auto msg = wxString::Format( _( "The pasted sheet \"%s\"\n"
1089  "was dropped because the destination already has "
1090  "the sheet or one of its subsheets as a parent." ),
1091  sheet->GetFileName() );
1092  DisplayError( m_frame, msg );
1093  loadedItems.pop_back();
1094  }
1095  }
1096  }
1097 
1098  // Remove the references from our temporary screen to prevent freeing on the DTOR
1099  paste_screen.Clear( false );
1100 
1101  // Now we can resolve the components and add everything to the screen, view, etc.
1102  //
1103  SYMBOL_LIB_TABLE* symLibTable = m_frame->Prj().SchSymbolLibTable();
1104  PART_LIB* partLib = m_frame->Prj().SchLibs()->GetCacheLibrary();
1105 
1106  for( unsigned i = 0; i < loadedItems.size(); ++i )
1107  {
1108  EDA_ITEM* item = loadedItems[i];
1109 
1110  if( item->Type() == SCH_COMPONENT_T )
1111  {
1112  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1113 
1114  if( dropAnnotations )
1115  {
1116  const_cast<KIID&>( component->m_Uuid ) = KIID();
1117 
1118  // clear the annotation, but preserve the selected unit
1119  int unit = component->GetUnit();
1120  component->ClearAnnotation( nullptr );
1121  component->SetUnit( unit );
1122  }
1123 
1124  component->Resolve( *symLibTable, partLib );
1125  component->UpdatePins();
1126  }
1127  else
1128  {
1129  // Everything else gets a new UUID
1130  const_cast<KIID&>( item->m_Uuid ) = KIID();
1131  }
1132 
1133  if( item->Type() == SCH_SHEET_T )
1134  {
1135  SCH_SHEET* sheet = (SCH_SHEET*) item;
1136  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1137  wxFileName fn = sheet->GetFileName();
1138  SCH_SCREEN* existingScreen = nullptr;
1139  bool dropSheetAnnotations = false;
1140  wxString baseName = nameField.GetText();
1141  wxString candidateName = baseName;
1142  int uniquifier = 1;
1143 
1144  while( hierarchy.NameExists( candidateName ) )
1145  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1146 
1147  nameField.SetText( candidateName );
1148 
1149  sheet->SetParent( g_CurrentSheet->Last() );
1150  sheet->SetScreen( nullptr );
1151  sheetsPasted = true;
1152 
1153  if( !fn.IsAbsolute() )
1154  {
1155  wxFileName currentSheetFileName = g_CurrentSheet->LastScreen()->GetFileName();
1156  fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
1157  }
1158 
1159  if( g_RootSheet->SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ), &existingScreen ) )
1160  dropSheetAnnotations = !forceKeepAnnotations;
1161  else
1162  searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1163 
1164  if( existingScreen )
1165  {
1166  sheet->SetScreen( existingScreen );
1167 
1168  SCH_SHEET_PATH sheetpath = *g_CurrentSheet;
1169  sheetpath.push_back( sheet );
1170 
1171  // Clear annotation and create the AR for this path, if not exists,
1172  // when the screen is shared by sheet paths.
1173  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1174  // reference default value and takes the latest displayed value
1175  existingScreen->EnsureAlternateReferencesExist();
1176 
1177  if( forceDropAnnotations || dropSheetAnnotations )
1178  existingScreen->ClearAnnotation( &sheetpath );
1179  }
1180  else
1181  {
1182  if( !m_frame->LoadSheetFromFile( sheet, g_CurrentSheet, fn.GetFullPath() ) )
1183  m_frame->InitSheet( sheet, sheet->GetFileName() );
1184  }
1185  }
1186 
1187  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1188  m_frame->AddItemToScreenAndUndoList( (SCH_ITEM*) item, i > 0 );
1189 
1190  // Reset flags for subsequent move operation
1191  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1192  // Start out hidden so the pasted items aren't "ghosted" in their original location
1193  // before being moved to the current location.
1194  getView()->Hide( item, true );
1195  }
1196 
1197  if( sheetsPasted )
1198  {
1201  }
1202 
1203  // Now clear the previous selection, select the pasted items, and fire up the "move"
1204  // tool.
1205  //
1207  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1208 
1209  EE_SELECTION& selection = selTool->GetSelection();
1210 
1211  if( !selection.Empty() )
1212  {
1213  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
1214 
1215  selection.SetReferencePoint( item->GetPosition() );
1217  }
1218 
1219  return 0;
1220 }
1221 
1222 
1224 {
1227  SCH_COMPONENT* sym = nullptr;
1228  LIB_EDIT_FRAME* libEdit;
1229 
1230  if( selection.GetSize() >= 1 )
1231  sym = (SCH_COMPONENT*) selection.Front();
1232 
1233  if( !sym || sym->GetEditFlags() != 0 )
1234  return 0;
1235 
1237  libEdit = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
1238 
1239  if( libEdit )
1240  libEdit->LoadComponentAndSelectLib( sym->GetLibId(), sym->GetUnit(), sym->GetConvert() );
1241 
1242  return 0;
1243 }
1244 
1245 
1247 {
1248  wxCommandEvent dummy;
1249  m_frame->OnAnnotate( dummy );
1250  return 0;
1251 }
1252 
1253 
1255 {
1256  wxCommandEvent dummy;
1258  return 0;
1259 }
1260 
1261 
1263 {
1265  dlg.ShowQuasiModal();
1266  return 0;
1267 }
1268 
1269 
1271 {
1273  m_frame->HardRedraw();
1274 
1275  return 0;
1276 }
1277 
1278 
1280 {
1281  wxCommandEvent dummy;
1283  return 0;
1284 }
1285 
1286 
1288 {
1289  wxCommandEvent dummy;
1291  return 0;
1292 }
1293 
1294 
1296 {
1298  dlg.ShowModal();
1299  return 0;
1300 }
1301 
1302 
1304 {
1305  int result = NET_PLUGIN_CHANGE;
1306 
1307  // If a plugin is removed or added, rebuild and reopen the new dialog
1308  while( result == NET_PLUGIN_CHANGE )
1309  result = InvokeDialogNetList( m_frame );
1310 
1311  return 0;
1312 }
1313 
1314 
1316 {
1318  return 0;
1319 }
1320 
1321 
1323 {
1325  return 0;
1326 }
1327 
1328 
1330 {
1332  return 0;
1333 }
1334 
1335 
1337 {
1339  const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
1340 
1341  if( selection.GetSize() == 1 )
1342  {
1343  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1344 
1347 
1348  g_CurrentSheet->push_back( sheet );
1351  }
1352 
1353  return 0;
1354 }
1355 
1356 
1358 {
1359  if( g_CurrentSheet->Last() != g_RootSheet )
1360  {
1363 
1367  }
1368 
1369  return 0;
1370 }
1371 
1372 
1374 {
1376 
1377  auto painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
1378  painter->GetSettings()->m_ShowHiddenPins = m_frame->GetShowAllPins();
1379 
1381  m_frame->GetCanvas()->Refresh();
1382 
1383  return 0;
1384 }
1385 
1386 
1388 {
1390 
1391  return 0;
1392 }
1393 
1394 
1396 {
1397  Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1398  Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1399  Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1403  Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
1404  Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1405  Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1406 
1415 
1420 
1421 #ifdef KICAD_SPICE
1422  Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
1423  Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
1424 #endif /* KICAD_SPICE */
1425 
1432 
1433  Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1434  Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1435  Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
1436  Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
1437  Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1439 
1452 
1454 
1458 
1461 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
int Save(const TOOL_EVENT &aEvent)
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1507
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)
SCH_ITEM * nextMatch(SCH_SCREEN *aScreen, SCH_ITEM *aAfter, wxFindReplaceData *aData)
Advances the search and returns the next matching item after aAfter.
int FindAndReplace(const TOOL_EVENT &aEvent)
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
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:157
int Copy(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
Definition: actions.h:201
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)
static TOOL_ACTION findAndReplace
Definition: actions.h:79
int m_Threshold
Definition: collector.h:66
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:584
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
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.
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 ShowSchematicSetup(const TOOL_EVENT &aEvent)
int HighlightNetCursor(const TOOL_EVENT &aEvent)
Launches a tool to highlight nets.
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:151
EDA_BASE_FRAME * GetEditFrame() const
Definition: tool_manager.h:298
void SendCrossProbeNetName(const wxString &aNetName)
Sends a net name to pcbnew for highlighting.
const wxString & GetName() const
Definition: sch_pin.h:102
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:202
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...
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
void Collect(SCH_SCREEN *aScreen, 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 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)
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:218
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:149
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:233
void ClearBrightenedPins()
#define HITTEST_THRESHOLD_PIXELS
void UpdateTitle()
Set the main window title bar text.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
int New(const TOOL_EVENT &aEvent)
void Format(SCH_SCREEN *aScreen)
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:565
bool IsBrightened() const
Definition: base_struct.h:228
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:156
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:214
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:749
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:218
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:45
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:282
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:205
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.
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:237
static TOOL_ACTION pickerTool
Definition: actions.h:148
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()
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:268
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:145
SCH_EDITOR_CONTROL.
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:100
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
Definition: common.h:65
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:244
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:152
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:157
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:146
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
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:257
wxString Name(bool aIgnoreSheet=false) const
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:111
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:341
int LeaveSheet(const TOOL_EVENT &aEvent)
static TOOL_ACTION simTune
Definition: ee_actions.h:199
int Print(const TOOL_EVENT &aEvent)
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:218
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:262
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:603
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)
TOOL_EVENT.
Definition: tool_event.h:171
int TestDuplicateSheetNames(bool aCreateMarker)
Function TestDuplicateSheetNames( ) inside a given sheet, one cannot have sheets with duplicate names...
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.
static TOOL_ACTION cut
Definition: actions.h:69
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
int ImportFPAssignments(const TOOL_EVENT &aEvent)
Definition: backanno.cpp:207
EDA_ITEM * GetParent() const
Definition: base_struct.h:217
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
static TOOL_ACTION quit
Definition: actions.h:62
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:153
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:203
void DoShowSchematicSetupDialog(const wxString &aInitialPage=wxEmptyString, const wxString &aInitialParentPage=wxEmptyString)
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:84
void SetUnit(int aUnit)
Change the unit number to aUnit.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
SCH_SHEET_PATH.
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false)
Return the reference for the given sheet path.
PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:491
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)
bool LoadComponentAndSelectLib(const LIB_ID &aLibId, int aUnit, int aConvert)
Selects the currently active library and loads the symbol from aLibId.
static VECTOR2D CLEAR
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...
bool NameExists(const wxString &aSheetName)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet Note: the returned value can ...
Definition: sch_item.cpp:128
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
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:215
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
const KIID m_Uuid
Definition: base_struct.h:169
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:99
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)
int AddItemToSel(const TOOL_EVENT &aEvent)
SCH_SCREEN * LastScreen()
Function LastScreen.
static TOOL_ACTION showSymbolEditor
Definition: actions.h:153
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
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.
#define _(s)
Definition: 3d_actions.cpp:33
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()
std::string GetClipboard() const
Returns the information currently stored in the system clipboard.
EE_RTREE & Items()
Definition: sch_screen.h:127
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.
void OnOpenPcbnew(wxCommandEvent &event)
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
#define NET_PLUGIN_CHANGE
Create and shows NETLIST_DIALOG and returns whatever NETLIST_DIALOG::ShowModal() returns.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
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:732
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:959
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...
SCH_SHEET * g_RootSheet
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.
static TOOL_ACTION schematicSetup
Definition: ee_actions.h:153
Definition for part library class.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
VIEW.
Definition: view.h:61
void AddTuner(SCH_COMPONENT *aComponent)
Adds a tuner for a component.
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:147
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:192
const LIB_ID & GetLibId() const
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor...
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName) const
Function TestForRecursion.
STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
int UpdateFromPCB(const TOOL_EVENT &aEvent)
STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
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:473
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
static TOOL_ACTION findNext
Definition: actions.h:80
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
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.
EDA_ITEM * Front() const
Definition: selection.h:183
void SetShowAllPins(bool aEnable)
int ExportNetlist(const TOOL_EVENT &aEvent)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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