KiCad PCB EDA Suite
schedit.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008-2017 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
30 #include <fctsys.h>
31 #include <kiway.h>
32 #include <gr_basic.h>
33 #include <pgm_base.h>
34 #include <class_drawpanel.h>
35 #include <confirm.h>
36 #include <eda_doc.h>
37 #include <schframe.h>
38 #include <kicad_device_context.h>
39 #include <hotkeys_basic.h>
40 
41 #include <general.h>
42 #include <eeschema_id.h>
43 #include <protos.h>
44 #include <class_library.h>
45 #include <sch_bus_entry.h>
46 #include <sch_marker.h>
47 #include <sch_component.h>
48 #include <sch_junction.h>
49 #include <sch_line.h>
50 #include <sch_sheet.h>
51 #include <sch_sheet_path.h>
52 
53 
54 void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
55 {
56  int id = event.GetId();
57  wxPoint pos;
58  SCH_SCREEN* screen = GetScreen();
59  SCH_ITEM* item = screen->GetCurItem();
60 
61  pos = wxGetMousePosition();
62 
63  pos.y += 20;
64 
65  // If needed, stop the current command and deselect current tool
66  switch( id )
67  {
68  case wxID_CUT:
69  case wxID_COPY:
75  case ID_POPUP_END_LINE:
96 
97  /* At this point: Do nothing. these commands do not need to stop the
98  * current command (mainly a block command) or reset the current state
99  * They will be executed later, in next switch structure.
100  */
101  break;
102 
104  case ID_POPUP_SCH_DELETE:
105 
106  // Stop the current command (if any) but keep the current tool
108  break;
109 
110  default:
111  // Stop the current command and deselect the current tool
113  break;
114  }
115 
117  item = screen->GetCurItem(); // Can be modified by previous calls.
118 
119  switch( id )
120  {
121  case ID_HIERARCHY:
122  InstallHierarchyFrame( pos );
123  SetRepeatItem( NULL );
124  break;
125 
126  case wxID_CUT: // save and delete block
127 
128  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
129  break;
131  screen->m_BlockLocate.SetMessageBlock( this );
132  HandleBlockEnd( &dc );
133  SetRepeatItem( NULL );
135  break;
136 
137  case wxID_COPY: // really this is a Save block for paste
139  screen->m_BlockLocate.SetMessageBlock( this );
140  HandleBlockEnd( &dc );
141  break;
142 
143  case wxID_PASTE:
145  break;
146 
149  SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '/' );
150  break;
151 
154  SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '\\' );
155  break;
156 
158  if( m_canvas->IsMouseCaptured() )
159  {
161  SetToolID( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString );
162  }
163  else
164  {
166  }
167 
168  break;
169 
170  case ID_POPUP_END_LINE:
172  EndSegment( &dc );
173  break;
174 
178  break;
179 
183  break;
184 
186  // Not used
187  break;
188 
193  screen->SetCurItem( NULL );
194  SetRepeatItem( NULL );
195 
196  screen->TestDanglingEnds();
197  m_canvas->Refresh();
198 
199  break;
200 
202  {
203  DLIST< SCH_ITEM > oldWires;
204 
205  oldWires.SetOwnership( false ); // Prevent DLIST for deleting items in destructor.
207  screen->ExtractWires( oldWires, true );
208  screen->BreakSegment( GetCrossHairPosition() );
209 
210  if( oldWires.GetCount() != 0 )
211  {
212  PICKED_ITEMS_LIST oldItems;
213 
214  oldItems.m_Status = UR_WIRE_IMAGE;
215 
216  while( oldWires.GetCount() != 0 )
217  {
218  ITEM_PICKER picker = ITEM_PICKER( oldWires.PopFront(), UR_WIRE_IMAGE );
219  oldItems.PushItem( picker );
220  }
221 
222  SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE );
223  }
224 
225  if( screen->TestDanglingEnds() )
226  m_canvas->Refresh();
227  }
228  break;
229 
231  case ID_POPUP_SCH_DELETE:
232  if( item == NULL )
233  break;
234 
235  DeleteItem( item );
236  screen->SetCurItem( NULL );
237  SetRepeatItem( NULL );
238  screen->TestDanglingEnds();
240  m_canvas->Refresh();
241  OnModify();
242  break;
243 
247  break;
248 
250  ReSizeSheet( (SCH_SHEET*) item, &dc );
251 
252  if( screen->TestDanglingEnds() )
253  m_canvas->Refresh();
254 
255  break;
256 
258  if( item != NULL && item->Type() == SCH_SHEET_T )
259  screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, &dc ) );
260  break;
261 
263  if( item != NULL && item->Type() == SCH_SHEET_T )
264  {
265  SCH_SHEET* sheet = (SCH_SHEET*) item;
266 
267  if( !sheet->HasUndefinedPins() )
268  {
269  DisplayInfoMessage( this,
270  _( "There are no undefined labels in this sheet to clean up." ) );
271  return;
272  }
273 
274  if( !IsOK( this, _( "Do you wish to cleanup this sheet?" ) ) )
275  return;
276 
277  /* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */
278  SaveCopyInUndoList( sheet, UR_CHANGED );
279  sheet->CleanupSheet();
280  OnModify();
282  }
283  break;
284 
287  break;
288 
290 
291  // Ensure the struct is a component (could be a struct of a component, like Field, text..)
292  if( item && item->Type() == SCH_COMPONENT_T )
293  {
295  ConvertPart( (SCH_COMPONENT*) item, &dc );
296  }
297 
298  break;
299 
301 
302  // Ensure the struct is a component (could be a piece of a component, like Field, text..)
303  if( item && item->Type() == SCH_COMPONENT_T )
304  {
305  if( PART_LIBS* libs = Prj().SchLibs() )
306  {
307  LIB_ALIAS* entry = libs->FindLibraryAlias( ( (SCH_COMPONENT*) item )->GetLibId() );
308 
309  if( entry && !!entry->GetDocFileName() )
310  {
311  SEARCH_STACK* lib_search = Prj().SchSearchS();
312 
313  GetAssociatedDocument( this, entry->GetDocFileName(), lib_search );
314  }
315  }
316  }
317  break;
318 
320 
321  if( item && (item->Type() == SCH_SHEET_T) )
322  {
323  m_CurrentSheet->push_back( (SCH_SHEET*) item );
325  }
326 
327  break;
328 
330  if( m_CurrentSheet->Last() != g_RootSheet )
331  {
332  m_CurrentSheet->pop_back();
334  }
335 
336  break;
337 
339  m_canvas->SetAutoPanRequest( false );
341  HandleBlockPlace( &dc );
342  break;
343 
344  case ID_POPUP_ZOOM_BLOCK:
346  screen->m_BlockLocate.SetMessageBlock( this );
347  HandleBlockEnd( &dc );
348  break;
349 
351  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
352  break;
353 
356  screen->m_BlockLocate.SetMessageBlock( this );
357  HandleBlockEnd( &dc );
359  break;
360 
362  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
363  break;
364 
367  screen->m_BlockLocate.SetMessageBlock( this );
368  HandleBlockEnd( &dc );
369  break;
370 
371  case ID_POPUP_DRAG_BLOCK:
372  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
373  break;
374 
377  screen->m_BlockLocate.SetMessageBlock( this );
378  HandleBlockEnd( &dc );
379  break;
380 
383  screen->SetCurItem( AddJunction( &dc, GetCrossHairPosition(), true ) );
384 
385  if( screen->TestDanglingEnds() )
386  m_canvas->Refresh();
387 
388  screen->SetCurItem( NULL );
389  break;
390 
393  screen->SetCurItem( CreateNewText( &dc, id == ID_POPUP_SCH_ADD_LABEL ?
395  item = screen->GetCurItem();
396 
397  if( item )
399 
400  break;
401 
403  if( item && item->Type() == SCH_MARKER_T )
404  ( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
405 
406  break;
407 
408  default: // Log error:
409  wxFAIL_MSG( wxString::Format( wxT( "Cannot process command event ID %d" ),
410  event.GetId() ) );
411  break;
412  }
413 
414  // End switch ( id ) (Command execution)
415 
416  if( GetToolId() == ID_NO_TOOL_SELECTED )
417  SetRepeatItem( NULL );
418 }
419 
420 
421 void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
422 {
423  SCH_SCREEN* screen = GetScreen();
424  SCH_ITEM* item = screen->GetCurItem();
425 
426  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
427  {
428  // trying to move an item when there is a block at the same time is not acceptable
429  return;
430  }
431 
432  if( item == NULL )
433  {
434  // If we didn't get here by a hot key, then something has gone wrong.
435  if( aEvent.GetInt() == 0 )
436  return;
437 
438  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
439 
440  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
441 
443  aEvent.GetInt() );
444 
445  // Exit if no item found at the current location or the item is already being edited.
446  if( (item == NULL) || (item->GetFlags() != 0) )
447  return;
448  }
449 
451 
452  switch( item->Type() )
453  {
454  case SCH_LINE_T:
455  break;
456 
457  case SCH_JUNCTION_T:
458  case SCH_NO_CONNECT_T:
459  case SCH_BUS_BUS_ENTRY_T:
461  case SCH_LABEL_T:
462  case SCH_GLOBAL_LABEL_T:
464  case SCH_TEXT_T:
465  case SCH_COMPONENT_T:
466  case SCH_SHEET_PIN_T:
467  case SCH_FIELD_T:
468  case SCH_SHEET_T:
469  PrepareMoveItem( item, &dc );
470  break;
471 
472  case SCH_BITMAP_T:
473  // move an image is a special case:
474  // we cannot undraw/redraw a bitmap just using our xor mode
475  // the MoveImage function handle this undraw/redraw difficulty
476  // By redrawing the full bounding box
477  MoveImage( (SCH_BITMAP*) item, &dc );
478  break;
479 
480  case SCH_MARKER_T:
481  // Moving a marker has no sense
482  break;
483 
484  default:
485  // Unknown items cannot be moved
486  wxFAIL_MSG( wxString::Format(
487  wxT( "Cannot move item type %d" ), item->Type() ) );
488  break;
489  }
490 
491  if( GetToolId() == ID_NO_TOOL_SELECTED )
492  SetRepeatItem( NULL );
493 }
494 
495 
496 void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
497 {
498  SCH_SCREEN* screen = GetScreen();
499 
500  if( screen->IsBlockActive() )
501  {
502  m_canvas->SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() );
503  screen->ClearBlockCommand();
504 
505  // Stop the current command (if any) but keep the current tool
507  }
508  else
509  {
510  if( m_canvas->IsMouseCaptured() ) // Stop the current command but keep the current tool
512  else // Deselect current tool
514  }
515 }
516 
517 
518 void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
519 {
520  int id = aEvent.GetId();
521  int lastToolID = GetToolId();
522 
523  // Stop the current command and deselect the current tool.
525 
526  switch( id )
527  {
528  case ID_NO_TOOL_SELECTED:
530  break;
531 
532  case ID_HIGHLIGHT:
533  SetToolID( id, wxCURSOR_HAND, _("Highlight specific net") );
534  break;
535 
536  case ID_ZOOM_SELECTION:
537  // This tool is located on the main toolbar: switch it on or off on click
538  if( lastToolID != ID_ZOOM_SELECTION )
539  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
540  else
542  break;
543 
544  case ID_NOCONN_BUTT:
545  SetToolID( id, wxCURSOR_PENCIL, _( "Add no connect" ) );
546  break;
547 
548  case ID_WIRE_BUTT:
549  SetToolID( id, wxCURSOR_PENCIL, _( "Add wire" ) );
550  break;
551 
552  case ID_BUS_BUTT:
553  SetToolID( id, wxCURSOR_PENCIL, _( "Add bus" ) );
554  break;
555 
557  SetToolID( id, wxCURSOR_PENCIL, _( "Add lines" ) );
558  break;
559 
560  case ID_JUNCTION_BUTT:
561  SetToolID( id, wxCURSOR_PENCIL, _( "Add junction" ) );
562  break;
563 
564  case ID_LABEL_BUTT:
565  SetToolID( id, wxCURSOR_PENCIL, _( "Add label" ) );
566  break;
567 
568  case ID_GLABEL_BUTT:
569  SetToolID( id, wxCURSOR_PENCIL, _( "Add global label" ) );
570  break;
571 
572  case ID_HIERLABEL_BUTT:
573  SetToolID( id, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
574  break;
575 
577  SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
578  break;
579 
580  case ID_ADD_IMAGE_BUTT:
581  SetToolID( id, wxCURSOR_PENCIL, _( "Add image" ) );
582  break;
583 
585  SetToolID( id, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
586  break;
587 
589  SetToolID( id, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
590  break;
591 
593  SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet" ) );
594  break;
595 
596  case ID_SHEET_PIN_BUTT:
597  SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
598  break;
599 
601  SetToolID( id, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
602  break;
603 
605  SetToolID( id, wxCURSOR_PENCIL, _( "Add component" ) );
606  break;
607 
608  case ID_PLACE_POWER_BUTT:
609  SetToolID( id, wxCURSOR_PENCIL, _( "Add power" ) );
610  break;
611 
613  SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
614  break;
615 
616 #ifdef KICAD_SPICE
617  case ID_SIM_PROBE:
618  SetToolID( id, -1, _( "Add a simulator probe" ) );
619  m_canvas->SetCursor( CURSOR_PROBE );
620  break;
621 
622  case ID_SIM_TUNE:
623  SetToolID( id, -1, _( "Select a value to be tuned" ) );
624  m_canvas->SetCursor( CURSOR_TUNE );
625  break;
626 #endif /* KICAD_SPICE */
627 
628  default:
629  SetRepeatItem( NULL );
630  }
631 
632  // Simulate left click event if we got here from a hot key.
633  if( aEvent.GetClientObject() != NULL )
634  {
635  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
636 
637  wxPoint pos = data->GetPosition();
638 
640  OnLeftClick( &dc, pos );
641  }
642 }
643 
644 
645 void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
646 {
647  aEvent.Check( GetToolId() == aEvent.GetId() );
648 }
649 
650 
651 void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
652 {
653  PICKED_ITEMS_LIST pickList;
654  SCH_SCREEN* screen = GetScreen();
656 
657  if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
658  {
659  DeleteItemsInList( m_canvas, pickList );
660  OnModify();
661  }
662 }
663 
664 
666 {
667  SCH_ITEM* item;
668  SCH_SCREEN* screen = GetScreen();
669 
671 
672  if( item )
673  {
674  bool itemHasConnections = item->IsConnectable();
675 
676  screen->SetCurItem( NULL );
677  SetRepeatItem( NULL );
678  DeleteItem( item );
679 
680  if( itemHasConnections && screen->TestDanglingEnds() )
681  m_canvas->Refresh();
682 
683  OnModify();
684  return true;
685  }
686 
687  return false;
688 }
689 
690 // This function is a callback function, called by the mouse cursor movin event
691 // when an item is currently moved
692 static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
693  const wxPoint& aPosition, bool aErase )
694 {
695  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
696  SCH_ITEM* item = screen->GetCurItem();
697 
698  wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) );
699 
700  SCH_COMPONENT* cmp = NULL;
701 
702  if( item->Type() == SCH_COMPONENT_T )
703  cmp = static_cast< SCH_COMPONENT* >( item );
704 
705 #ifndef USE_WX_OVERLAY
706  // Erase the current item at its current position.
707  if( aErase )
708  {
709  if( cmp ) // Use fast mode (do not draw pin texts)
710  cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, COLOR4D::UNSPECIFIED, false );
711  else
712  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
713  }
714 #endif
715 
716  wxPoint cpos = aPanel->GetParent()->GetCrossHairPosition();
717  cpos -= item->GetStoredPos();
718 
719  item->SetPosition( cpos );
720 
721  // Draw the item item at it's new position.
722  item->SetWireImage(); // While moving, the item may choose to render differently
723 
724  if( cmp ) // Use fast mode (do not draw pin texts)
725  cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, COLOR4D::UNSPECIFIED, false );
726  else
727  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
728 }
729 
730 
731 static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
732 {
733  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
734  SCH_ITEM* item = screen->GetCurItem();
735  SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
736 
737  parent->SetRepeatItem( NULL );
738  screen->SetCurItem( NULL );
739 
740  if( item == NULL ) /* no current item */
741  return;
742 
743  if( item->IsNew() )
744  {
745  delete item;
746  item = NULL;
747  }
748  else
749  {
750  SCH_ITEM* oldItem = parent->GetUndoItem();
751 
752  SCH_ITEM* currentItem;
753 
754  // Items that are children of other objects are undone by swapping the contents
755  // of the parent items.
756  if( (item->Type() == SCH_SHEET_PIN_T) || (item->Type() == SCH_FIELD_T) )
757  {
758  currentItem = (SCH_ITEM*) item->GetParent();
759  }
760  else
761  {
762  currentItem = item;
763  }
764 
765  wxCHECK_RET( oldItem != NULL && currentItem->Type() == oldItem->Type(),
766  wxT( "Cannot restore undefined or bad last schematic item." ) );
767 
768  // Never delete existing item, because it can be referenced by an undo/redo command
769  // Just restore its data
770  currentItem->SwapData( oldItem );
771 
772  // Erase the wire representation before the 'normal' view is drawn.
773  if ( item->IsWireImage() )
774  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
775 
776  item->ClearFlags();
777  }
778 
779  aPanel->Refresh();
780 }
781 
782 
783 void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC )
784 {
785  wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) );
786 
787  SetRepeatItem( NULL );
788 
789  if( !aItem->IsNew() )
790  {
791  if( (aItem->Type() == SCH_SHEET_PIN_T) || (aItem->Type() == SCH_FIELD_T) )
792  SetUndoItem( (SCH_ITEM*) aItem->GetParent() );
793  else
794  SetUndoItem( aItem );
795  }
796 
797  if( aItem->Type() == SCH_FIELD_T && aItem->GetParent()->Type() == SCH_COMPONENT_T )
798  {
799  // Now that we're moving a field, they're no longer autoplaced.
800  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( aItem->GetParent() );
801  parent->ClearFieldsAutoplaced();
802  }
803 
804  aItem->SetFlags( IS_MOVED );
805 
806  // For some items, moving the cursor to anchor is not good
807  // (for instance large hierarchical sheets od componants can have
808  // the anchor position outside the canvas)
809  // these items return IsMovableFromAnchorPoint() == false
810  // For these items, do not wrap the cursor
811  if( aItem->IsMovableFromAnchorPoint() )
812  {
813  SetCrossHairPosition( aItem->GetPosition() );
815  aItem->SetStoredPos( wxPoint( 0,0 ) );
816  }
817  else
818  {
819  // Round the point under the cursor to a multiple of the grid
820  wxPoint cursorpos = GetCrossHairPosition() - aItem->GetPosition();
821  wxPoint gridsize = GetScreen()->GetGridSize();
822  cursorpos.x = ( cursorpos.x / gridsize.x ) * gridsize.x;
823  cursorpos.y = ( cursorpos.y / gridsize.y ) * gridsize.y;
824 
825  aItem->SetStoredPos( cursorpos );
826  }
827 
828  OnModify();
829 
830  GetScreen()->SetCurItem( aItem );
832 
833  m_canvas->Refresh();
834 }
835 
836 
837 void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
838 {
839  SCH_SCREEN* screen = GetScreen();
840  SCH_ITEM* item = screen->GetCurItem();
841 
842  if( item != NULL )
843  {
844  item = LocateAndShowItem( item->GetPosition() );
845  SendMessageToPCBNEW( item, NULL );
846  }
847  else
848  {
849  // If we didn't get here by a hot key, then something has gone wrong.
850  if( aEvent.GetInt() == 0 )
851  return;
852 
853  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
854 
855  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
856 
857  item = LocateAndShowItem( data->GetPosition() );
858  SendMessageToPCBNEW( item, NULL );
859  }
860 }
861 
862 
863 void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
864 {
865  SCH_SCREEN* screen = GetScreen();
866  SCH_ITEM* item = screen->GetCurItem();
867 
869 
870  // Allows block rotate operation on hot key.
871  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
872  {
874  HandleBlockEnd( &dc );
875  return;
876  }
877 
878  if( item == NULL )
879  {
880  // If we didn't get here by a hot key, then something has gone wrong.
881  if( aEvent.GetInt() == 0 )
882  return;
883 
884  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
885 
886  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
887 
889  aEvent.GetInt() );
890 
891  // Exit if no item found at the current location or the item is already being edited.
892  if( (item == NULL) || (item->GetFlags() != 0) )
893  return;
894  }
895 
896  switch( item->Type() )
897  {
898  case SCH_COMPONENT_T:
899  {
900  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
901  if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
903  else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
905  else
906  wxFAIL_MSG( wxT( "Unknown rotate item command ID." ) );
907 
908  if( m_autoplaceFields )
909  component->AutoAutoplaceFields( GetScreen() );
910 
911  m_canvas->Refresh();
912 
913  break;
914  }
915 
916  case SCH_TEXT_T:
917  case SCH_LABEL_T:
918  case SCH_GLOBAL_LABEL_T:
921  ChangeTextOrient( (SCH_TEXT*) item );
922  m_canvas->Refresh();
923  break;
924 
925  case SCH_FIELD_T:
927  RotateField( (SCH_FIELD*) item );
928  if( item->GetParent()->Type() == SCH_COMPONENT_T )
929  {
930  // Now that we're moving a field, they're no longer autoplaced.
931  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( item->GetParent() );
932  parent->ClearFieldsAutoplaced();
933  }
934  m_canvas->Refresh();
935  break;
936 
937  case SCH_BITMAP_T:
938  RotateImage( (SCH_BITMAP*) item );
939  break;
940 
941  case SCH_SHEET_T:
942  if( !item->IsNew() ) // rotate a sheet during its creation has no sense
943  {
944  bool retCCW = ( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE );
945  RotateHierarchicalSheet( static_cast<SCH_SHEET*>( item ), retCCW );
946  }
947 
948  break;
949 
950  case SCH_JUNCTION_T:
951  case SCH_NO_CONNECT_T:
952  // these items are not rotated, because rotation does not change them.
953  break;
954 
955  default:
956  // Other items (wires...) cannot be rotated, at least during creation
957  if( item->IsNew() )
958  break;
959 
960  wxFAIL_MSG( wxString::Format( wxT( "Cannot rotate schematic item type %s." ),
961  GetChars( item->GetClass() ) ) );
962  }
963 
964  if( item->GetFlags() == 0 )
965  screen->SetCurItem( NULL );
966 }
967 
968 
969 void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
970 {
971  SCH_SCREEN* screen = GetScreen();
972  SCH_ITEM* item = screen->GetCurItem();
973 
974  if( item == NULL )
975  {
976  // If we didn't get here by a hot key, then something has gone wrong.
977  if( aEvent.GetInt() == 0 )
978  return;
979 
980  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
981 
982  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
983 
984  // Set the locat filter, according to the edit command
985  const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
986  const KICAD_T* filterListAux = NULL;
987 
988  switch( aEvent.GetId() )
989  {
992  filterListAux = SCH_COLLECTOR::ComponentsOnly;
993  break;
994 
997  filterListAux = SCH_COLLECTOR::ComponentsOnly;
998  break;
999 
1002  filterListAux = SCH_COLLECTOR::ComponentsOnly;
1003  break;
1004 
1005  default:
1006  break;
1007  }
1008 
1009  item = LocateAndShowItem( data->GetPosition(), filterList, aEvent.GetInt() );
1010 
1011  // If no item found, and if an auxiliary filter exists, try to use it
1012  if( !item && filterListAux )
1013  item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
1014 
1015  // Exit if no item found at the current location or the item is already being edited.
1016  if( (item == NULL) || (item->GetFlags() != 0) )
1017  return;
1018  }
1019 
1020  switch( item->Type() )
1021  {
1022  case SCH_COMPONENT_T:
1023  {
1024  switch( aEvent.GetId() )
1025  {
1027  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ) );
1028  break;
1029 
1031  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ) );
1032  break;
1033 
1035  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ) );
1036  break;
1037 
1038  case ID_SCH_EDIT_ITEM:
1039  EditComponent( (SCH_COMPONENT*) item );
1040  break;
1041 
1042  default:
1043  wxFAIL_MSG( wxString::Format( wxT( "Invalid schematic component edit command ID %d" ),
1044  aEvent.GetId() ) );
1045  }
1046 
1047  break;
1048  }
1049 
1050  case SCH_SHEET_T:
1051  if( EditSheet( (SCH_SHEET*) item, m_CurrentSheet ) )
1052  m_canvas->Refresh();
1053  break;
1054 
1055  case SCH_SHEET_PIN_T:
1056  EditSheetPin( (SCH_SHEET_PIN*) item, true );
1057  break;
1058 
1059  case SCH_TEXT_T:
1060  case SCH_LABEL_T:
1061  case SCH_GLOBAL_LABEL_T:
1063  EditSchematicText( (SCH_TEXT*) item );
1064  break;
1065 
1066  case SCH_FIELD_T:
1067  EditComponentFieldText( (SCH_FIELD*) item );
1068  break;
1069 
1070  case SCH_BITMAP_T:
1071  EditImage( (SCH_BITMAP*) item );
1072  break;
1073 
1074  case SCH_LINE_T: // These items have no param to edit
1075  case SCH_MARKER_T:
1076  case SCH_JUNCTION_T:
1077  case SCH_NO_CONNECT_T:
1078  break;
1079 
1080  default: // Unexpected item
1081  wxFAIL_MSG( wxString::Format( wxT( "Cannot edit schematic item type %s." ),
1082  GetChars( item->GetClass() ) ) );
1083  }
1084 
1085  if( item->GetFlags() == 0 )
1086  screen->SetCurItem( NULL );
1087 }
1088 
1089 
1090 void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
1091 {
1092  SCH_SCREEN* screen = GetScreen();
1093  SCH_ITEM* item = screen->GetCurItem();
1094 
1095  // The easiest way to handle a menu or a hot key drag command
1096  // is to simulate a block drag command
1097  //
1098  // When a drag item is requested, some items use a BLOCK_DRAG_ITEM drag type
1099  // an some items use a BLOCK_DRAG drag type (mainly a junction)
1100  // a BLOCK_DRAG collects all items in a block (here a 2x2 rect centered on the cursor)
1101  // and BLOCK_DRAG_ITEM drag only the selected item
1102  BLOCK_COMMAND_T dragType = BLOCK_DRAG_ITEM;
1103 
1104  if( item == NULL )
1105  {
1106  // If we didn't get here by a hot key, then something has gone wrong.
1107  if( aEvent.GetInt() == 0 )
1108  return;
1109 
1110  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1111 
1112  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1113 
1115  aEvent.GetInt() );
1116 
1117  // Exit if no item found at the current location or the item is already being edited.
1118  if( (item == NULL) || (item->GetFlags() != 0) )
1119  return;
1120 
1121  // When a junction or a node is found, a BLOCK_DRAG is better
1124  dragType = BLOCK_DRAG;
1125  }
1126 
1127  switch( item->Type() )
1128  {
1129  case SCH_BUS_BUS_ENTRY_T:
1130  case SCH_BUS_WIRE_ENTRY_T:
1131  case SCH_LINE_T:
1132  case SCH_JUNCTION_T:
1133  case SCH_COMPONENT_T:
1134  case SCH_LABEL_T:
1135  case SCH_GLOBAL_LABEL_T:
1137  case SCH_SHEET_T:
1139 
1140  if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1141  {
1143 
1144  if( !HandleBlockBegin( &dc, dragType, GetCrossHairPosition() ) )
1145  break;
1146 
1147  // Give a non null size to the search block:
1148  screen->m_BlockLocate.Inflate( 1 );
1149  HandleBlockEnd( &dc );
1150  }
1151 
1152  break;
1153 
1154  default:
1155  wxFAIL_MSG( wxString::Format( wxT( "Cannot drag schematic item type %s." ),
1156  GetChars( item->GetClass() ) ) );
1157  }
1158 }
1159 
1160 
1161 void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
1162 {
1163  SCH_SCREEN* screen = GetScreen();
1164  SCH_ITEM* item = screen->GetCurItem();
1165 
1167 
1168  // Allows block rotate operation on hot key.
1169  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
1170  {
1171  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1172  {
1174  screen->m_BlockLocate.SetMessageBlock( this );
1176  HandleBlockEnd( &dc );
1177  }
1178  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1179  {
1181  screen->m_BlockLocate.SetMessageBlock( this );
1183  HandleBlockEnd( &dc );
1184  }
1185  else
1186  {
1187  wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
1188  }
1189 
1190  return;
1191  }
1192 
1193  if( item == NULL )
1194  {
1195  // If we didn't get here by a hot key, then something has gone wrong.
1196  if( aEvent.GetInt() == 0 )
1197  return;
1198 
1199  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1200 
1201  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1202 
1204  aEvent.GetInt() );
1205 
1206  // Exit if no item found at the current location or the item is already being edited.
1207  if( (item == NULL) || (item->GetFlags() != 0) )
1208  return;
1209  }
1210 
1211 
1212  switch( item->Type() )
1213  {
1214  case SCH_COMPONENT_T:
1215  {
1216  SCH_COMPONENT *component = static_cast<SCH_COMPONENT*>( item );
1217  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1219  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1221  else if( aEvent.GetId() == ID_SCH_ORIENT_NORMAL )
1223  else
1224  wxFAIL_MSG( wxT( "Invalid orient schematic component command ID." ) );
1225 
1226  if( m_autoplaceFields )
1227  component->AutoAutoplaceFields( GetScreen() );
1228 
1229  m_canvas->Refresh();
1230 
1231  break;
1232  }
1233 
1234  case SCH_BITMAP_T:
1235  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1236  MirrorImage( (SCH_BITMAP*) item, true );
1237  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1238  MirrorImage( (SCH_BITMAP*) item, false );
1239 
1240  break;
1241 
1242  case SCH_SHEET_T:
1243  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1244  MirrorSheet( (SCH_SHEET*) item, true );
1245  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1246  MirrorSheet( (SCH_SHEET*) item, false );
1247 
1248  break;
1249 
1250  default:
1251  // This object cannot be oriented.
1252  ;
1253  }
1254 
1255  if( item->GetFlags() == 0 )
1256  screen->SetCurItem( NULL );
1257 }
Definition of the SCH_SHEET class for Eeschema.
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
void OrientComponent(COMPONENT_ORIENTATION_T aOrientation=CMP_NORMAL)
Function OrientComponent rotates and mirrors a component.
Definition: getpart.cpp:275
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
void DeleteConnection(bool DeleteFullConnection)
Definition: schedit.cpp:651
void EditComponent(SCH_COMPONENT *aComponent)
Function EditComponent displays the edit component dialog to edit the parameters of aComponent...
static const KICAD_T ParentItems[]
A scan list for only parent schematic items.
void RotateField(SCH_FIELD *aField)
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:269
Part library alias object definition.
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
void OnMoveItem(wxCommandEvent &aEvent)
Function OnMoveItem handles the ID_SCH_MOVE_ITEM event used to move schematic itams.
Definition: schedit.cpp:421
void DeleteItem(SCH_ITEM *aItem)
Function DeleteItem removes aItem from the current screen and saves it in the undo list...
SCH_JUNCTION * AddJunction(wxDC *aDC, const wxPoint &aPosition, bool aPutInUndoList=false)
Function AddJunction adds a new junction at aPosition.
static const KICAD_T RotatableItems[]
A scan list for all rotatable schematic items.
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))
Function SaveCopyInUndoList.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
virtual bool IsMovableFromAnchorPoint()
Virtual function IsMovableFromAnchorPoint.
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:230
void OnModify()
Function OnModify Must be called after a schematic change in order to set the "modify" flag of the cu...
Definition: schframe.cpp:770
bool BreakSegment(const wxPoint &aPoint)
Function BreakSegment checks every wire and bus for a intersection at aPoint and break into two segme...
Definition: sch_screen.cpp:936
int GetCurrentCursor() const
Function GetCurrentCursor.
This file is part of the common library.
void ChangeTextOrient(SCH_TEXT *aTextItem)
Definition: edit_label.cpp:50
void SetMessageBlock(EDA_DRAW_FRAME *frame)
Function SetMessageBlock Displays the type of block command in the status bar of the window...
static const wxCursor CURSOR_TUNE
Tuner cursor, used by circuit simulator
Definition: schframe.h:1412
void addCurrentItemToList(bool aRedraw=true)
Function addCurrentItemToList adds the item currently being edited to the schematic and adds the chan...
Definition: schframe.cpp:1306
EDA_ITEM * GetParent() const
Definition: base_struct.h:222
void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
BLOCK_COMMAND_T
static const KICAD_T ComponentsOnly[]
A scan list for schematic component items only.
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, const wxPathList *aPaths)
Function GetAssociatedDocument open a document (file) with the suitable browser.
Definition: eda_doc.cpp:86
void RefreshDrawingRect(const EDA_RECT &aRect, bool aEraseBackground=true)
Function RefreshDrawingRect redraws the contents of aRect in drawing units.
Definition: draw_panel.cpp:305
void RotateHierarchicalSheet(SCH_SHEET *aSheet, bool aRotCCW)
Rotate a sheet on itself.
Definition: sheet.cpp:405
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
void OnEditItem(wxCommandEvent &aEvent)
Function OnEditItem handles the ID_SCH_EDIT_ITEM event used to edit schematic itams.
Definition: schedit.cpp:969
SCH_ITEM * GetUndoItem() const
Definition: schframe.h:1317
Schematic editor (Eeschema) main window.
Definition: schframe.h:117
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
void ClearBlockCommand()
SCH_COLLECTOR m_collectedItems
List of collected items.
Definition: schframe.h:142
SCH_TEXT * CreateNewText(wxDC *aDC, int aType)
Definition: edit_label.cpp:66
void MirrorImage(SCH_BITMAP *aItem, bool Is_X_axis)
Function MirrorImage Mirror a bitmap.
virtual void HandleBlockPlace(wxDC *DC) override
Function HandleBlockPlace Called after HandleBlockEnd, when a block command needs to be executed afte...
void DisplayCurrentSheet()
Function DisplayCurrentSheet draws the current sheet on the display.
Definition: hierarch.cpp:279
static const KICAD_T MovableItems[]
A scan list for all movable schematic items.
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:347
void EditComponentFieldText(SCH_FIELD *aField)
Function EditComponentFieldText displays the edit field dialog to edit the parameters of aField...
SCH_ITEM * LocateItem(const wxPoint &aPosition, const KICAD_T aFilterList[]=SCH_COLLECTOR::AllItems, int aHotKeyCommandId=0)
Function LocateItem checks for items at aPosition matching the types in aFilterList.
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:90
void PrepareMoveItem(SCH_ITEM *aItem, wxDC *aDC)
Function PrepareMoveItem start moving aItem using the mouse.
Definition: schedit.cpp:783
void SetRepeatItem(SCH_ITEM *aItem)
Function SetRepeatItem clones aItem and owns that clone in this container.
Definition: schframe.cpp:468
void InstallHierarchyFrame(wxPoint &pos)
Definition: hierarch.cpp:150
void ClearFieldsAutoplaced()
Set fields automatically placed flag false.
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:529
void EndSegment(wxDC *DC)
Function EndSegment called to terminate a bus, wire, or line creation.
virtual bool HandleBlockBegin(wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0)
Initialize a block command.
Definition: draw_frame.cpp:834
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
Definition: schframe.h:120
static const KICAD_T CmpFieldValueOnly[]
A scan list for a specific editable field: Value.
Class EDA_HOTKEY_CLIENT_DATA provides client data member for hotkeys to include in command events gen...
void SendMessageToPCBNEW(EDA_ITEM *aObjectToSync, SCH_COMPONENT *aPart)
Function SendMessageToPcbnew send a remote to Pcbnew via a socket connection.
bool IsBlockActive() const
SCH_ITEM * LocateAndShowItem(const wxPoint &aPosition, const KICAD_T aFilterList[]=SCH_COLLECTOR::AllItems, int aHotKeyCommandId=0)
Function LocateAndShowItem checks the schematic at aPosition in logical (drawing) units for a item ma...
wxPoint & GetStoredPos()
virtual wxPoint GetPosition() const =0
Function GetPosition.
int GetConnection(const wxPoint &aPosition, PICKED_ITEMS_LIST &aList, bool aFullConnection)
Functions GetConnection adds all of the wires and junctions to aList that make up a connection to the...
bool IsDraggableJunction() const
Function IsDraggableJunction tests to see if the collected items form a draggable junction...
void SetBusEntryShape(wxDC *DC, SCH_BUS_ENTRY_BASE *BusEntry, char entry_shape)
Definition: busentry.cpp:66
a helper to handle the real device context used in KiCad
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:267
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
EDA_RECT const GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_sheet.cpp:680
virtual void SwapData(SCH_ITEM *aItem)
Function SwapData swap the internal data structures aItem with the schematic item.
bool DeleteItemAtCrossHair(wxDC *aDC)
Function DeleteItemAtCrossHair delete the item found under the cross hair.
Definition: schedit.cpp:665
virtual void SetPosition(const wxPoint &aPosition)=0
Function SetPosition set the schematic item position to aPosition.
bool IsCorner() const
Function IsCorner tests if the collected items forms as corner of two line segments.
void OnUpdateSelectTool(wxUpdateUIEvent &aEvent)
Definition: schedit.cpp:645
void OnRotate(wxCommandEvent &aEvent)
Function OnRotate handles the ID_SCH_ROTATE_CLOCKWISE and ID_SCH_ROTATE_COUNTERCLOCKWISE events used ...
Definition: schedit.cpp:863
SCH_ITEM * GetCurItem() const
Function GetCurItem returns the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
bool IsMouseCaptured() const
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item...
void SetWireImage()
Definition: base_struct.h:240
static const KICAD_T CmpFieldFootprintOnly[]
A scan list for a specific editable field: Footprint.
static const wxCursor CURSOR_PROBE
Probe cursor, used by circuit simulator
Definition: schframe.h:1409
void RotateImage(SCH_BITMAP *aItem)
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:102
Class SCH_SHEET_PIN defines a sheet pin (label) used in sheets to create hierarchical schematics...
Definition: sch_sheet.h:62
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
void SetAutoPanRequest(bool aEnable)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
Definition: draw_frame.cpp:546
void EditSchematicText(SCH_TEXT *TextStruct)
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
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...
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:521
bool m_autoplaceFields
automatically place component fields
Definition: schframe.h:154
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
void OnCancelCurrentCommand(wxCommandEvent &aEvent)
Definition: schedit.cpp:496
static void moveItemWithMouseCursor(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Definition: schedit.cpp:692
static const KICAD_T EditableItems[]
A scan list for all editable schematic items.
Class PART_LIBS is a collection of PART_LIBs.
bool IsNode(bool aIncludePins=true) const
Function IsNode tests if the collected items form a node.
void ReSizeSheet(SCH_SHEET *Sheet, wxDC *DC)
Definition: sheet.cpp:380
void MoveImage(SCH_BITMAP *aItem, wxDC *aDC)
Field Value of part, i.e. "3.3K".
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:571
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
bool HasUndefinedPins()
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:413
wxString GetDocFileName() const
Definition the SCH_COMPONENT class for Eeschema.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
see class PGM_BASE
static const KICAD_T DraggableItems[]
A scan list for all draggable schematic items.
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
BLOCK_STATE_T GetState() const
void SetSheetNumberAndCount()
Function SetSheetNumberAndCount Set the m_ScreenNumber and m_NumberOfScreens members for screens must...
Definition: schframe.cpp:494
#define INSTALL_UNBUFFERED_DC(name, parent)
void OnLeftClick(wxDC *aDC, const wxPoint &aPosition) override
bool TestDanglingEnds()
Function TestDanglingEnds tests all of the connectible objects in the schematic for unused connection...
Definition: sch_screen.cpp:915
static const KICAD_T CmpFieldReferenceOnly[]
A scan list for a specific editable field: Reference.
int GetToolId() const
Definition: draw_frame.h:471
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
void DeleteItemsInList(EDA_DRAW_PANEL *panel, PICKED_ITEMS_LIST &aItemsList)
Function DeleteItemsInList delete schematic items in aItemsList deleted items are put in undo list...
void SetCurItem(SCH_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
void OnSelectTool(wxCommandEvent &aEvent)
Definition: schedit.cpp:518
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
void EditImage(SCH_BITMAP *aItem)
void ExtractWires(DLIST< SCH_ITEM > &aList, bool aCreateCopy)
Function ExtractWires extracts the old wires, junctions and buses.
Definition: sch_screen.cpp:241
virtual wxString GetClass() const override
Function GetClass returns the class name.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:268
BLOCK_COMMAND_T GetCommand() const
unsigned GetCount() const
Function GetCount returns the number of elements in the list.
Definition: dlist.h:126
void SetOwnership(bool Iown)
Function SetOwnership controls whether the list owns the objects and is responsible for deleteing the...
Definition: dlist.h:119
void OnDragItem(wxCommandEvent &aEvent)
Function OnDragItem handles the ID_SCH_DRAG_ITEM event used to drag schematic itams.
Definition: schedit.cpp:1090
SCH_SHEET_PIN * ImportSheetPin(SCH_SHEET *aSheet, wxDC *aDC)
Function ImportSheetPin automatically creates a sheet pin from the hierarchical labels in the schemat...
Definition: sheetlab.cpp:140
virtual bool HandleBlockEnd(wxDC *aDC) override
Function HandleBlockEnd Handle the "end" of a block command, i.e.
void OnOrient(wxCommandEvent &aEvent)
Function OnOrient handles the ID_SCH_MIRROR_X, ID_SCH_MIRROR_Y, and ID_SCH_ORIENT_NORMAL events used ...
Definition: schedit.cpp:1161
Some functions to handle hotkeys in KiCad.
bool EditSheet(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
Function EditSheet is used to edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:44
void MirrorSheet(SCH_SHEET *aSheet, bool aFromXaxis)
Function MirrorSheet Mirror a hierarchical sheet Mirroring is made around its centre.
Definition: sheet.cpp:432
void SetUndoItem(const SCH_ITEM *aItem)
Function SetUndoItem clones aItem which can be used to restore the state of the item being edited whe...
Definition: schframe.cpp:588
Definition for part library class.
bool IsWireImage() const
Definition: base_struct.h:234
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
int EditSheetPin(SCH_SHEET_PIN *aSheetPin, bool aRedraw)
Function EditSheetPin displays the dialog for editing the parameters of aSheetPin.
Definition: sheetlab.cpp:61
int GetDefaultCursor() const
Function GetDefaultCursor.
void SetStoredPos(wxPoint aPos)
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
void Process_Special_Functions(wxCommandEvent &event)
Definition: schedit.cpp:54
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:129
virtual void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED)=0
Function Draw Draw a schematic item.
static void abortMoveItem(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Definition: schedit.cpp:731
static const KICAD_T OrientableItems[]
A scan list for schematic items that can be mirrored.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
T * PopFront()
Definition: dlist.h:221
void SetCommand(BLOCK_COMMAND_T aCommand)
void SelectAllFromSheet(wxCommandEvent &aEvent)
Function SelectAllFromSheet handles the ID_POPUP_SCH_SELECT_ON_PCB event used to select items in pcbn...
Definition: schedit.cpp:837
void ConvertPart(SCH_COMPONENT *DrawComponent, wxDC *DC)
Definition: getpart.cpp:366
#define IS_MOVED
Item being moved.
Definition: base_struct.h:126