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 <netlist_object.h>
34 #include <tool/tool_manager.h>
35 #include <tool/picker_tool.h>
36 #include <tools/ee_actions.h>
38 #include <tools/ee_selection.h>
40 #include <advanced_config.h>
41 #include <simulation_cursors.h>
42 #include <sim/sim_plot_frame.h>
43 #include <sch_legacy_plugin.h>
44 #include <class_library.h>
45 #include <confirm.h>
46 #include <sch_painter.h>
47 #include <status_popup.h>
48 #include <ws_proxy_undo_item.h>
51 #include <invoke_sch_dialog.h>
54 #include <math/util.h> // for KiROUND
55 
56 
57 int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
58 {
60  return 0;
61 }
62 
63 
65 {
67  return 0;
68 }
69 
70 
72 {
74  return 0;
75 }
76 
77 
79 {
80  m_frame->Save_File( true );
81  return 0;
82 }
83 
84 
86 {
87  PICKED_ITEMS_LIST undoCmd;
89  ITEM_PICKER wrapper( undoItem, UR_PAGESETTINGS );
90 
91  undoCmd.PushItem( wrapper );
93 
96 
97  if( dlg.ShowModal() != wxID_OK )
99 
100  return 0;
101 }
102 
103 
105 {
106  m_frame->Print();
107  return 0;
108 }
109 
110 
112 {
114  return 0;
115 }
116 
117 
119 {
120  m_frame->Close( false );
121  return 0;
122 }
123 
124 
125 // A dummy wxFindReplaceData signalling any marker should be found
126 static wxFindReplaceData g_markersOnly;
127 
128 
130 {
132  return UpdateFind( aEvent );
133 }
134 
136 {
138  return 0;
139 }
140 
142 {
143  wxFindReplaceData* data = m_frame->GetFindReplaceData();
144 
145  if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
146  || aEvent.IsAction( &ACTIONS::updateFind ) )
147  {
149 
150  for( auto item : m_frame->GetScreen()->Items() )
151  {
152  if( data && item->Matches( *data, nullptr ) )
153  m_selectionTool->BrightenItem( item );
154  else if( item->IsBrightened() )
156  }
157  }
158  else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
159  {
160  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
161  {
162  if( data && item->Matches( *data, nullptr ) )
163  m_selectionTool->BrightenItem( item );
164  else if( item->IsBrightened() )
166  }
167  }
168 
169  getView()->UpdateItems();
170  m_frame->GetCanvas()->Refresh();
171  m_frame->UpdateTitle();
172 
173  return 0;
174 }
175 
176 
178  SCH_SCREEN* aScreen, SCH_ITEM* aAfter, wxFindReplaceData* aData )
179 {
180  bool past_item = ( aAfter == nullptr );
181 
182  for( auto item : aScreen->Items() )
183  {
184  if( item == aAfter )
185  past_item = true;
186 
187  if( past_item
188  && ( ( aData == &g_markersOnly && item->Type() == SCH_MARKER_T )
189  || item->Matches( *aData, nullptr ) ) )
190  return item;
191  }
192 
193  return nullptr;
194 }
195 
196 
198 {
199  // A timer during which a subsequent FindNext will result in a wrap-around
200  static wxTimer wrapAroundTimer;
201 
202  wxFindReplaceData* data = m_frame->GetFindReplaceData();
203 
204  if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
205  {
206  if( data )
207  g_markersOnly.SetFlags( data->GetFlags() );
208 
209  data = &g_markersOnly;
210  }
211  else if( !data )
212  {
213  return FindAndReplace( ACTIONS::find.MakeEvent() );
214  }
215 
216  bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
217  EE_SELECTION& selection = m_selectionTool->GetSelection();
218  SCH_SCREEN* afterScreen = m_frame->GetScreen();
219  SCH_ITEM* afterItem = dynamic_cast<SCH_ITEM*>( selection.Front() );
220  SCH_ITEM* item = nullptr;
221 
222  if( wrapAroundTimer.IsRunning() )
223  {
224  afterScreen = nullptr;
225  afterItem = nullptr;
226  wrapAroundTimer.Stop();
228  }
229 
231 
232  if( afterScreen || !searchAllSheets )
233  item = nextMatch( m_frame->GetScreen(), afterItem, data );
234 
235  if( !item && searchAllSheets )
236  {
237  SCH_SHEET_LIST schematic( g_RootSheet );
238  SCH_SCREENS screens;
239 
240  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
241  {
242  if( afterScreen )
243  {
244  if( afterScreen == screen )
245  afterScreen = nullptr;
246 
247  continue;
248  }
249 
250  item = nextMatch( screen, nullptr, data );
251 
252  if( item )
253  {
254  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
255  wxCHECK_MSG( sheet, 0, "Sheet not found for " + screen->GetFileName() );
256 
257  *g_CurrentSheet = *sheet;
259 
260  screen->SetZoom( m_frame->GetScreen()->GetZoom() );
261  screen->TestDanglingEnds();
262 
263  m_frame->SetScreen( screen );
264  UpdateFind( ACTIONS::updateFind.MakeEvent() );
265 
266  break;
267  }
268  }
269  }
270 
271  if( item )
272  {
273  m_selectionTool->AddItemToSel( item );
274  m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter(), true );
275  m_frame->GetCanvas()->Refresh();
276  }
277  else
278  {
279  wxString msg = searchAllSheets ? _( "Reached end of schematic." )
280  : _( "Reached end of sheet." );
281 
282  m_frame->ShowFindReplaceStatus( msg + _( "\nFind again to wrap around to the start." ) );
283  wrapAroundTimer.StartOnce( 4000 );
284  }
285 
286  return 0;
287 }
288 
289 
291 {
292  wxFindReplaceData* data = m_frame->GetFindReplaceData();
294 
295  return data && item && item->Matches( *data, nullptr );
296 }
297 
298 
300 {
301  wxFindReplaceData* data = m_frame->GetFindReplaceData();
303 
304  if( !data )
305  return FindAndReplace( ACTIONS::find.MakeEvent() );
306 
307  if( item && item->Matches( *data, nullptr ) )
308  {
309  item->Replace( *data, g_CurrentSheet );
310  FindNext( ACTIONS::findNext.MakeEvent() );
311  }
312 
313  return 0;
314 }
315 
316 
318 {
319  wxFindReplaceData* data = m_frame->GetFindReplaceData();
320 
321  if( !data )
322  return FindAndReplace( ACTIONS::find.MakeEvent() );
323 
324  SCH_SHEET_LIST schematic( g_RootSheet );
325  SCH_SCREENS screens;
326 
327  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
328  {
329  //TODO(snh): Fix ReplaceAll
330  // screen->ForEachItem() for( EDA_ITEM* item = nextMatch( screen, nullptr, data ); item;
331  // item = nextMatch( screen, item, data ) )
332  // {
333  // item->Replace( *data, schematic.FindSheetForScreen( screen ) );
334  // }
335  }
336 
337  return 0;
338 }
339 
340 
342 {
343  doCrossProbeSchToPcb( aEvent, false );
344  return 0;
345 }
346 
347 
349 {
350  doCrossProbeSchToPcb( aEvent, true );
351  return 0;
352 }
353 
354 
355 void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
356 {
357  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
358  if( m_probingPcbToSch )
359  return;
360 
362  SCH_ITEM* item = nullptr;
363  SCH_COMPONENT* component = nullptr;
364 
365  if( aForce )
366  {
367  EE_SELECTION& selection = selTool->RequestSelection();
368 
369  if( selection.GetSize() >= 1 )
370  item = (SCH_ITEM*) selection.Front();
371  }
372  else
373  {
374  EE_SELECTION& selection = selTool->GetSelection();
375 
376  if( selection.GetSize() >= 1 )
377  item = (SCH_ITEM*) selection.Front();
378  }
379 
380  if( !item )
381  {
382  if( aForce )
383  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
384 
385  return;
386  }
387 
388 
389  switch( item->Type() )
390  {
391  case SCH_FIELD_T:
392  case LIB_FIELD_T:
393  component = (SCH_COMPONENT*) item->GetParent();
394  m_frame->SendMessageToPCBNEW( item, component );
395  break;
396 
397  case SCH_COMPONENT_T:
398  component = (SCH_COMPONENT*) item;
399  m_frame->SendMessageToPCBNEW( item, component );
400  break;
401 
402  case SCH_PIN_T:
403  component = (SCH_COMPONENT*) item->GetParent();
404  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), component );
405  break;
406 
407  case SCH_SHEET_T:
408  if( aForce )
409  m_frame->SendMessageToPCBNEW( item, nullptr );
410  break;
411 
412  default:
413  break;
414  }
415 }
416 
417 
418 #ifdef KICAD_SPICE
419 
420 static KICAD_T wires[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
421 static KICAD_T wiresAndPins[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT };
422 static KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
423 
424 #define HITTEST_THRESHOLD_PIXELS 5
425 
426 
427 int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
428 {
429  auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
430  auto simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
431 
432  if( !simFrame ) // Defensive coding; shouldn't happen.
433  return 0;
434 
435  // Deactivate other tools; particularly important if another PICKER is currently running
436  Activate();
437 
438  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) );
439 
440  picker->SetClickHandler(
441  [this, simFrame] ( const VECTOR2D& aPosition )
442  {
444  EDA_ITEM* item = selTool->SelectPoint( aPosition, wiresAndPins );
445 
446  if( !item )
447  return false;
448 
449  if( item->IsType( wires ) )
450  {
451  std::unique_ptr<NETLIST_OBJECT_LIST> netlist( m_frame->BuildNetListBase() );
452 
453  for( NETLIST_OBJECT* obj : *netlist )
454  {
455  if( obj->m_Comp == item )
456  {
457  simFrame->AddVoltagePlot( UnescapeString( obj->GetNetName() ) );
458  break;
459  }
460  }
461  }
462  else if( item->Type() == SCH_PIN_T )
463  {
464  SCH_PIN* pin = (SCH_PIN*) item;
465  SCH_COMPONENT* comp = (SCH_COMPONENT*) item->GetParent();
466  wxString param;
467  wxString primitive;
468 
470  primitive.LowerCase();
471 
472  if( primitive == "c" || primitive == "l" || primitive == "r" )
473  param = wxT( "I" );
474  else if( primitive == "d" )
475  param = wxT( "Id" );
476  else
477  param = wxString::Format( wxT( "I%s" ), pin->GetName().Lower() );
478 
479  simFrame->AddCurrentPlot( comp->GetRef( g_CurrentSheet ), param );
480  }
481 
482  return true;
483  } );
484 
485  picker->SetMotionHandler(
486  [this, picker] ( const VECTOR2D& aPos )
487  {
488  EE_COLLECTOR collector;
489  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
490  collector.Collect( m_frame->GetScreen(), wiresAndPins, (wxPoint) aPos );
491 
493  selectionTool->GuessSelectionCandidates( collector, aPos );
494 
495  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
496  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
497  wxString netName;
498 
499  if( wire )
500  {
501  item = nullptr;
502 
503  if( wire->Connection( *g_CurrentSheet ) )
504  netName = wire->Connection( *g_CurrentSheet )->Name();
505  }
506 
507  if( item && item->Type() == SCH_PIN_T )
508  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURRENT_PROBE ) );
509  else
510  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) );
511 
512  if( m_pickerItem != item )
513  {
514 
515  if( m_pickerItem )
516  selectionTool->UnbrightenItem( m_pickerItem );
517 
518  m_pickerItem = item;
519 
520  if( m_pickerItem )
521  selectionTool->BrightenItem( m_pickerItem );
522  }
523 
524  if( m_frame->GetSelectedNetName() != netName )
525  {
526  m_frame->SetSelectedNetName( netName );
527 
528  TOOL_EVENT dummyEvent;
529  UpdateNetHighlighting( dummyEvent );
530  }
531  } );
532 
533  picker->SetFinalizeHandler(
534  [this] ( const int& aFinalState )
535  {
536  if( m_pickerItem )
538 
539  if( !m_frame->GetSelectedNetName().IsEmpty() )
540  {
541  m_frame->SetSelectedNetName( wxEmptyString );
542 
543  TOOL_EVENT dummyEvent;
544  UpdateNetHighlighting( dummyEvent );
545  }
546  } );
547 
548  std::string tool = aEvent.GetCommandStr().get();
549  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
550 
551  return 0;
552 }
553 
554 
555 int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
556 {
558 
559  // Deactivate other tools; particularly important if another PICKER is currently running
560  Activate();
561 
562  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURSOR::TUNE ) );
563 
564  picker->SetClickHandler(
565  [this] ( const VECTOR2D& aPosition )
566  {
568  EDA_ITEM* item = selTool->SelectPoint( aPosition, fieldsAndComponents );
569 
570  if( !item )
571  return false;
572 
573  if( item->Type() != SCH_COMPONENT_T )
574  {
575  item = item->GetParent();
576 
577  if( item->Type() != SCH_COMPONENT_T )
578  return false;
579  }
580 
581  SIM_PLOT_FRAME* simFrame =
583 
584  if( simFrame )
585  simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
586 
587  return true;
588  } );
589 
590  picker->SetMotionHandler(
591  [this] ( const VECTOR2D& aPos )
592  {
593  EE_COLLECTOR collector;
594  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
595  collector.Collect( m_frame->GetScreen(), fieldsAndComponents, (wxPoint) aPos );
596 
598  selectionTool->GuessSelectionCandidates( collector, aPos );
599 
600  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
601 
602  if( m_pickerItem != item )
603  {
604  if( m_pickerItem )
605  selectionTool->UnbrightenItem( m_pickerItem );
606 
607  m_pickerItem = item;
608 
609  if( m_pickerItem )
610  selectionTool->BrightenItem( m_pickerItem );
611  }
612  } );
613 
614  picker->SetFinalizeHandler(
615  [this] ( const int& aFinalState )
616  {
617  if( m_pickerItem )
619  } );
620 
621  std::string tool = aEvent.GetCommandStr().get();
622  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
623 
624  return 0;
625 }
626 #endif /* KICAD_SPICE */
627 
628 
629 // A singleton reference for clearing the highlight
631 
632 
633 // TODO(JE) Probably use netcode rather than connection name here eventually
634 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
635 {
636  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
637  EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
638  SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
639  wxString netName;
640  bool retVal = true;
641 
642  if( aPosition != CLEAR )
643  {
644  if( TestDuplicateSheetNames( false ) > 0 )
645  {
646  wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
647  retVal = false;
648  }
649  else
650  {
651  SCH_ITEM* item = (SCH_ITEM*) selTool->GetNode( aPosition );
652 
653  if( item && item->Connection( *g_CurrentSheet ) )
654  netName = item->Connection( *g_CurrentSheet )->Name();
655  }
656  }
657 
658  if( netName.empty() )
659  {
660  editFrame->SetStatusText( wxT( "" ) );
661  editFrame->SendCrossProbeClearHighlight();
662  }
663  else
664  {
665  editFrame->SendCrossProbeNetName( netName );
666  editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
667  UnescapeString( netName ) ) );
668  }
669 
670  editFrame->SetSelectedNetName( netName );
672  editorControl->UpdateNetHighlighting( dummy );
673 
674  return retVal;
675 }
676 
677 
679 {
681  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
682 
683  highlightNet( m_toolMgr, cursorPos );
684 
685  return 0;
686 }
687 
688 
690 {
692 
693  return 0;
694 }
695 
696 
698 {
699  SCH_SCREEN* screen = g_CurrentSheet->LastScreen();
700  std::vector<EDA_ITEM*> itemsToRedraw;
701  wxString selectedNetName = m_frame->GetSelectedNetName();
702 
703  if( !screen )
704  return 0;
705 
706  for( auto item : screen->Items() )
707  {
708  SCH_CONNECTION* conn = item->Connection( *g_CurrentSheet );
709  bool redraw = item->IsBrightened();
710 
711  if( conn && conn->Name() == selectedNetName )
712  item->SetBrightened();
713  else
714  item->ClearBrightened();
715 
716  redraw |= item->IsBrightened();
717 
718  if( item->Type() == SCH_COMPONENT_T )
719  {
720  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
721 
722  redraw |= comp->HasBrightenedPins();
723 
724  comp->ClearBrightenedPins();
725  std::vector<LIB_PIN*> pins;
726  comp->GetPins( pins );
727 
728  for( LIB_PIN* pin : pins )
729  {
730  auto pin_conn = comp->GetConnectionForPin( pin, *g_CurrentSheet );
731 
732  if( pin_conn && pin_conn->Name( false ) == selectedNetName )
733  {
734  comp->BrightenPin( pin );
735  redraw = true;
736  }
737  }
738  }
739  else if( item->Type() == SCH_SHEET_T )
740  {
741  for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
742  {
743  auto pin_conn = pin->Connection( *g_CurrentSheet );
744  bool redrawPin = pin->IsBrightened();
745 
746  if( pin_conn && pin_conn->Name() == selectedNetName )
747  pin->SetBrightened();
748  else
749  pin->ClearBrightened();
750 
751  redrawPin |= pin->IsBrightened();
752 
753  if( redrawPin )
754  itemsToRedraw.push_back( pin );
755  }
756  }
757 
758  if( redraw )
759  itemsToRedraw.push_back( item );
760  }
761 
762  // Be sure highlight change will be redrawn
763  KIGFX::VIEW* view = getView();
764 
765  for( auto redrawItem : itemsToRedraw )
767 
768  m_frame->GetCanvas()->Refresh();
769 
770  return 0;
771 }
772 
773 
775 {
776  // TODO(JE) remove once real-time connectivity is a given
777  if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
779 
780  std::string tool = aEvent.GetCommandStr().get();
782 
783  // Deactivate other tools; particularly important if another PICKER is currently running
784  Activate();
785 
786  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
787 
788  picker->SetClickHandler(
789  [this] ( const VECTOR2D& aPos )
790  {
791  return highlightNet( m_toolMgr, aPos );
792  } );
793 
794  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
795 
796  return 0;
797 }
798 
799 
801 {
802  if( m_frame->GetScreen()->GetUndoCommandCount() <= 0 )
803  return 0;
804 
805  // Inform tools that undo command was issued
807 
808  /* Get the old list */
810 
811  /* Undo the command */
812  m_frame->PutDataInPreviousState( List, false );
813 
814  /* Put the old list in RedoList */
815  List->ReversePickersListOrder();
817 
819  selTool->RebuildSelection();
820 
823 
824  m_frame->SyncView();
825  m_frame->GetCanvas()->Refresh();
826  m_frame->OnModify();
827 
828  return 0;
829 }
830 
831 
833 {
834  if( m_frame->GetScreen()->GetRedoCommandCount() == 0 )
835  return 0;
836 
837  // Inform tools that undo command was issued
839 
840  /* Get the old list */
842 
843  /* Redo the command: */
844  m_frame->PutDataInPreviousState( List, true );
845 
846  /* Put the old list in UndoList */
847  List->ReversePickersListOrder();
849 
851  selTool->RebuildSelection();
852 
855 
856  m_frame->SyncView();
857  m_frame->GetCanvas()->Refresh();
858  m_frame->OnModify();
859 
860  return 0;
861 }
862 
863 
865 {
867  EE_SELECTION& selection = selTool->RequestSelection();
868 
869  if( !selection.GetSize() )
870  return false;
871 
872  m_supplementaryClipboard.clear();
873 
874  for( EDA_ITEM* item : selection )
875  {
876  if( item->Type() == SCH_SHEET_T )
877  {
878  SCH_SHEET* sheet = (SCH_SHEET*) item;
879  m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
880  }
881  }
882 
883  STRING_FORMATTER formatter;
884  SCH_LEGACY_PLUGIN plugin;
885 
886  plugin.Format( &selection, &formatter );
887 
888  return m_toolMgr->SaveClipboard( formatter.GetString() );
889 }
890 
891 
892 bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
893  SCH_SCREEN** aScreen )
894 {
895  if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
896  {
897  *aScreen = m_supplementaryClipboard[ aSheetFilename ];
898  return true;
899  }
900 
901  return false;
902 }
903 
904 
906 {
907  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
908 
909  if( textEntry )
910  {
911  textEntry->Cut();
912  return 0;
913  }
914 
915  if( doCopy() )
917 
918  return 0;
919 }
920 
921 
923 {
924  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
925 
926  if( textEntry )
927  {
928  textEntry->Copy();
929  return 0;
930  }
931 
932  doCopy();
933 
934  return 0;
935 }
936 
937 
939 {
940  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
941 
942  if( textEntry )
943  {
944  textEntry->Paste();
945  return 0;
946  }
947 
949  std::string text = m_toolMgr->GetClipboard();
950 
951  if( text.empty() )
952  return 0;
953 
954  STRING_LINE_READER reader( text, "Clipboard" );
955  SCH_LEGACY_PLUGIN plugin;
956 
957  SCH_SCREEN paste_screen( &m_frame->GetScreen()->Kiway() );
958 
959  try
960  {
961  plugin.LoadContent( reader, &paste_screen );
962  }
963  catch( IO_ERROR& e )
964  {
965  // If it wasn't content, then paste as text
966  paste_screen.Append( new SCH_TEXT( wxPoint( 0, 0 ), text ) );
967  }
968 
969  bool forceKeepAnnotations = false;
970  bool forceDropAnnotations = false;
971  bool dropAnnotations = false;
972 
973  if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
974  {
975  DIALOG_PASTE_SPECIAL dlg( m_frame, &forceKeepAnnotations, &forceDropAnnotations );
976 
977  if( dlg.ShowModal() == wxID_CANCEL )
978  return 0;
979  }
980 
981  if( forceDropAnnotations )
982  dropAnnotations = true;
983 
984  // SCH_LEGACY_PLUGIN added the items to the paste screen, but not to the view or anything
985  // else. Pull them back out to start with.
986  //
987  EDA_ITEMS loadedItems;
988  bool sheetsPasted = false;
989  SCH_SHEET_LIST hierarchy( g_RootSheet );
990  wxFileName destFn = g_CurrentSheet->Last()->GetFileName();
991 
992  if( destFn.IsRelative() )
993  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
994 
995  for( auto item : paste_screen.Items() )
996  {
997  loadedItems.push_back( item );
998 
999  if( item->Type() == SCH_COMPONENT_T )
1000  {
1001  if( !dropAnnotations && !forceKeepAnnotations )
1002  {
1003  for( auto existingItem : m_frame->GetScreen()->Items() )
1004  {
1005  if( item->GetTimeStamp() == existingItem->GetTimeStamp() )
1006  {
1007  dropAnnotations = true;
1008  break;
1009  }
1010  }
1011  }
1012  }
1013  else if( item->Type() == SCH_SHEET_T )
1014  {
1015  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1016  wxFileName srcFn = sheet->GetFileName();
1017 
1018  if( srcFn.IsRelative() )
1019  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1020 
1021  SCH_SHEET_LIST sheetHierarchy( sheet );
1022 
1023  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1024  {
1025  auto msg = wxString::Format( _( "The pasted sheet \"%s\"\n"
1026  "was dropped because the destination already has "
1027  "the sheet or one of its subsheets as a parent." ),
1028  sheet->GetFileName() );
1029  DisplayError( m_frame, msg );
1030  loadedItems.pop_back();
1031  }
1032  }
1033  }
1034 
1035  // Remove the references from our temporary screen to prevent freeing on the DTOR
1036  paste_screen.Clear( false );
1037 
1038  // Now we can resolve the components and add everything to the screen, view, etc.
1039  //
1040  SYMBOL_LIB_TABLE* symLibTable = m_frame->Prj().SchSymbolLibTable();
1041  PART_LIB* partLib = m_frame->Prj().SchLibs()->GetCacheLibrary();
1042 
1043  for( unsigned i = 0; i < loadedItems.size(); ++i )
1044  {
1045  EDA_ITEM* item = loadedItems[i];
1046 
1047  if( item->Type() == SCH_COMPONENT_T )
1048  {
1049  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1050 
1051  if( dropAnnotations )
1052  {
1053  component->SetTimeStamp( GetNewTimeStamp() );
1054 
1055  // clear the annotation, but preserve the selected unit
1056  int unit = component->GetUnit();
1057  component->ClearAnnotation( nullptr );
1058  component->SetUnit( unit );
1059  }
1060 
1061  component->Resolve( *symLibTable, partLib );
1062  component->UpdatePins();
1063  }
1064  else if( item->Type() == SCH_SHEET_T )
1065  {
1066  SCH_SHEET* sheet = (SCH_SHEET*) item;
1067  wxFileName fn = sheet->GetFileName();
1068  SCH_SCREEN* existingScreen = nullptr;
1069  bool dropSheetAnnotations = false;
1070 
1071  // Duplicate sheet names and timestamps are not valid. Generate new timestamps
1072  // and timestamp-based sheet names.
1073  timestamp_t uid = GetNewTimeStamp();
1074 
1075  sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), (unsigned long)uid ) );
1076  sheet->SetTimeStamp( uid );
1077  sheet->SetParent( g_CurrentSheet->Last() );
1078  sheet->SetScreen( nullptr );
1079  sheetsPasted = true;
1080 
1081  if( !fn.IsAbsolute() )
1082  {
1083  wxFileName currentSheetFileName = g_CurrentSheet->LastScreen()->GetFileName();
1084  fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
1085  }
1086 
1087  if( g_RootSheet->SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ), &existingScreen ) )
1088  dropSheetAnnotations = true;
1089  else
1090  searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1091 
1092  if( existingScreen )
1093  {
1094  sheet->SetScreen( existingScreen );
1095 
1096  SCH_SHEET_PATH sheetpath = *g_CurrentSheet;
1097  sheetpath.push_back( sheet );
1098 
1099  // Clear annotation and create the AR for this path, if not exists,
1100  // when the screen is shared by sheet paths.
1101  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1102  // reference default value and takes the latest displayed value
1103  existingScreen->EnsureAlternateReferencesExist();
1104 
1105  if( forceDropAnnotations || dropSheetAnnotations )
1106  existingScreen->ClearAnnotation( &sheetpath );
1107  }
1108  else
1109  {
1110  if( !m_frame->LoadSheetFromFile( sheet, g_CurrentSheet, fn.GetFullPath() ) )
1111  m_frame->InitSheet( sheet, sheet->GetFileName() );
1112  }
1113  }
1114 
1115  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1116  m_frame->AddItemToScreenAndUndoList( (SCH_ITEM*) item, i > 0 );
1117 
1118  // Reset flags for subsequent move operation
1119  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1120  // Start out hidden so the pasted items aren't "ghosted" in their original location
1121  // before being moved to the current location.
1122  getView()->Hide( item, true );
1123  }
1124 
1125  if( sheetsPasted )
1126  {
1129  }
1130 
1131  // Now clear the previous selection, select the pasted items, and fire up the "move"
1132  // tool.
1133  //
1135  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1136 
1137  EE_SELECTION& selection = selTool->GetSelection();
1138 
1139  if( !selection.Empty() )
1140  {
1141  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
1142 
1143  selection.SetReferencePoint( item->GetPosition() );
1145  }
1146 
1147  return 0;
1148 }
1149 
1150 
1152 {
1155  SCH_COMPONENT* sym = nullptr;
1156  LIB_EDIT_FRAME* libEdit;
1157 
1158  if( selection.GetSize() >= 1 )
1159  sym = (SCH_COMPONENT*) selection.Front();
1160 
1161  if( !sym || sym->GetEditFlags() != 0 )
1162  return 0;
1163 
1165  libEdit = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
1166 
1167  if( libEdit )
1168  libEdit->LoadComponentAndSelectLib( sym->GetLibId(), sym->GetUnit(), sym->GetConvert() );
1169 
1170  return 0;
1171 }
1172 
1173 
1175 {
1176  wxCommandEvent dummy;
1177  m_frame->OnAnnotate( dummy );
1178  return 0;
1179 }
1180 
1181 
1183 {
1184  wxCommandEvent dummy;
1186  return 0;
1187 }
1188 
1189 
1191 {
1193  dlg.ShowQuasiModal();
1194  return 0;
1195 }
1196 
1197 
1199 {
1201  m_frame->HardRedraw();
1202 
1203  return 0;
1204 }
1205 
1206 
1208 {
1209  wxCommandEvent dummy;
1211  return 0;
1212 }
1213 
1214 
1216 {
1217  wxCommandEvent dummy;
1219  return 0;
1220 }
1221 
1222 
1224 {
1225  int result = NET_PLUGIN_CHANGE;
1226 
1227  // If a plugin is removed or added, rebuild and reopen the new dialog
1228  while( result == NET_PLUGIN_CHANGE )
1229  result = InvokeDialogNetList( m_frame );
1230 
1231  return 0;
1232 }
1233 
1234 
1236 {
1238  return 0;
1239 }
1240 
1241 
1243 {
1245  return 0;
1246 }
1247 
1248 
1250 {
1252  return 0;
1253 }
1254 
1255 
1257 {
1259  const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
1260 
1261  if( selection.GetSize() == 1 )
1262  {
1263  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1264 
1267 
1268  g_CurrentSheet->push_back( sheet );
1271  }
1272 
1273  return 0;
1274 }
1275 
1276 
1278 {
1279  if( g_CurrentSheet->Last() != g_RootSheet )
1280  {
1283 
1287  }
1288 
1289  return 0;
1290 }
1291 
1292 
1294 {
1296 
1297  auto painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
1298  painter->GetSettings()->m_ShowHiddenPins = m_frame->GetShowAllPins();
1299 
1301  m_frame->GetCanvas()->Refresh();
1302 
1303  return 0;
1304 }
1305 
1306 
1308 {
1310 
1311  return 0;
1312 }
1313 
1314 
1316 {
1317  Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1318  Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1319  Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1322  Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
1323  Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1324  Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1325 
1334 
1339 
1340 #ifdef KICAD_SPICE
1341  Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
1342  Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
1343 #endif /* KICAD_SPICE */
1344 
1351 
1352  Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1353  Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1354  Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
1355  Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
1356  Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1358 
1370 
1372 
1376 
1379 }
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)
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.
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:157
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:540
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:981
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 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:101
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...
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:219
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:111
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:231
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:109
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:833
bool IsBrightened() const
Definition: base_struct.h:226
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:217
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:759
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:278
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.
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:235
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
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:116
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:244
timestamp_t GetNewTimeStamp()
Definition: common.cpp:215
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
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:255
wxString Name(bool aIgnoreSheet=false) const
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 SetName(const wxString &aName)
Definition: sch_sheet.h:270
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:216
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:260
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:601
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)
void UpdatePins(SCH_SHEET_PATH *aSheet=nullptr)
Updates the local cache of SCH_PIN_CONNECTION objects for each pin.
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.
timestamp_t GetTimeStamp() const
Definition: base_struct.h:213
int ImportFPAssignments(const TOOL_EVENT &aEvent)
Definition: backanno.cpp:207
EDA_ITEM * GetParent() const
Definition: base_struct.h:215
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: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
SCH_SHEET_PATH.
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
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.
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...
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:206
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:99
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:616
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)
SCH_SCREEN * LastScreen()
Function LastScreen.
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: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:31
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:89
#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: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:742
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:970
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:52
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.
Definition for part library class.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
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: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.
STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
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:471
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:136
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:498
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:207
void SetTimeStamp(timestamp_t aNewTimeStamp)
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