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:
127  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
128  break;
129 
131  screen->m_BlockLocate.SetMessageBlock( this );
132  HandleBlockEnd( &dc );
133  SetRepeatItem( NULL );
135  break;
136 
137  case wxID_PASTE:
139  break;
140 
143  SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '/' );
144  break;
145 
148  SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '\\' );
149  break;
150 
152  if( m_canvas->IsMouseCaptured() )
153  {
155  SetToolID( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString );
156  }
157  else
158  {
160  }
161 
162  break;
163 
164  case ID_POPUP_END_LINE:
166  EndSegment( &dc );
167  break;
168 
172  break;
173 
177  break;
178 
180  // Not used
181  break;
182 
187  screen->SetCurItem( NULL );
188  SetRepeatItem( NULL );
189 
190  screen->TestDanglingEnds();
191  m_canvas->Refresh();
192 
193  break;
194 
196  {
197  DLIST< SCH_ITEM > oldWires;
198 
199  oldWires.SetOwnership( false ); // Prevent DLIST for deleting items in destructor.
201  screen->ExtractWires( oldWires, true );
202  screen->BreakSegment( GetCrossHairPosition() );
203 
204  if( oldWires.GetCount() != 0 )
205  {
206  PICKED_ITEMS_LIST oldItems;
207 
208  oldItems.m_Status = UR_WIRE_IMAGE;
209 
210  while( oldWires.GetCount() != 0 )
211  {
212  ITEM_PICKER picker = ITEM_PICKER( oldWires.PopFront(), UR_WIRE_IMAGE );
213  oldItems.PushItem( picker );
214  }
215 
216  SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE );
217  }
218 
219  if( screen->TestDanglingEnds() )
220  m_canvas->Refresh();
221  }
222  break;
223 
225  case ID_POPUP_SCH_DELETE:
226  if( item == NULL )
227  break;
228 
229  DeleteItem( item );
230  screen->SetCurItem( NULL );
231  SetRepeatItem( NULL );
232  screen->TestDanglingEnds();
234  m_canvas->Refresh();
235  OnModify();
236  break;
237 
241  break;
242 
244  ReSizeSheet( (SCH_SHEET*) item, &dc );
245 
246  if( screen->TestDanglingEnds() )
247  m_canvas->Refresh();
248 
249  break;
250 
252  if( item != NULL && item->Type() == SCH_SHEET_T )
253  screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, &dc ) );
254  break;
255 
257  if( item != NULL && item->Type() == SCH_SHEET_T )
258  {
259  SCH_SHEET* sheet = (SCH_SHEET*) item;
260 
261  if( !sheet->HasUndefinedPins() )
262  {
263  DisplayInfoMessage( this,
264  _( "There are no undefined labels in this sheet to clean up." ) );
265  return;
266  }
267 
268  if( !IsOK( this, _( "Do you wish to cleanup this sheet?" ) ) )
269  return;
270 
271  /* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */
272  SaveCopyInUndoList( sheet, UR_CHANGED );
273  sheet->CleanupSheet();
274  OnModify();
276  }
277  break;
278 
281  break;
282 
284 
285  // Ensure the struct is a component (could be a struct of a component, like Field, text..)
286  if( item && item->Type() == SCH_COMPONENT_T )
287  {
289  ConvertPart( (SCH_COMPONENT*) item, &dc );
290  }
291 
292  break;
293 
295 
296  // Ensure the struct is a component (could be a piece of a component, like Field, text..)
297  if( item && item->Type() == SCH_COMPONENT_T )
298  {
299  if( PART_LIBS* libs = Prj().SchLibs() )
300  {
301  LIB_ALIAS* entry = libs->FindLibraryAlias( ( (SCH_COMPONENT*) item )->GetLibId() );
302 
303  if( entry && !!entry->GetDocFileName() )
304  {
305  SEARCH_STACK* lib_search = Prj().SchSearchS();
306 
307  GetAssociatedDocument( this, entry->GetDocFileName(), lib_search );
308  }
309  }
310  }
311  break;
312 
314 
315  if( item && (item->Type() == SCH_SHEET_T) )
316  {
317  m_CurrentSheet->push_back( (SCH_SHEET*) item );
319  }
320 
321  break;
322 
324  if( m_CurrentSheet->Last() != g_RootSheet )
325  {
326  m_CurrentSheet->pop_back();
328  }
329 
330  break;
331 
332  case wxID_COPY: // really this is a Save block for paste
334  screen->m_BlockLocate.SetMessageBlock( this );
335  HandleBlockEnd( &dc );
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 
361  case ID_POPUP_COPY_BLOCK:
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::OnRotate( wxCommandEvent& aEvent )
838 {
839  SCH_SCREEN* screen = GetScreen();
840  SCH_ITEM* item = screen->GetCurItem();
841 
843 
844  // Allows block rotate operation on hot key.
845  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
846  {
848  HandleBlockEnd( &dc );
849  return;
850  }
851 
852  if( item == NULL )
853  {
854  // If we didn't get here by a hot key, then something has gone wrong.
855  if( aEvent.GetInt() == 0 )
856  return;
857 
858  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
859 
860  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
861 
863  aEvent.GetInt() );
864 
865  // Exit if no item found at the current location or the item is already being edited.
866  if( (item == NULL) || (item->GetFlags() != 0) )
867  return;
868  }
869 
870  switch( item->Type() )
871  {
872  case SCH_COMPONENT_T:
873  {
874  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
875  if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
877  else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
879  else
880  wxFAIL_MSG( wxT( "Unknown rotate item command ID." ) );
881 
882  if( m_autoplaceFields )
883  component->AutoAutoplaceFields( GetScreen() );
884 
885  m_canvas->Refresh();
886 
887  break;
888  }
889 
890  case SCH_TEXT_T:
891  case SCH_LABEL_T:
892  case SCH_GLOBAL_LABEL_T:
895  ChangeTextOrient( (SCH_TEXT*) item );
896  m_canvas->Refresh();
897  break;
898 
899  case SCH_FIELD_T:
901  RotateField( (SCH_FIELD*) item );
902  if( item->GetParent()->Type() == SCH_COMPONENT_T )
903  {
904  // Now that we're moving a field, they're no longer autoplaced.
905  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( item->GetParent() );
906  parent->ClearFieldsAutoplaced();
907  }
908  m_canvas->Refresh();
909  break;
910 
911  case SCH_BITMAP_T:
912  RotateImage( (SCH_BITMAP*) item );
913  break;
914 
915  case SCH_SHEET_T:
916  if( !item->IsNew() ) // rotate a sheet during its creation has no sense
917  {
918  bool retCCW = ( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE );
919  RotateHierarchicalSheet( static_cast<SCH_SHEET*>( item ), retCCW );
920  }
921 
922  break;
923 
924  case SCH_JUNCTION_T:
925  case SCH_NO_CONNECT_T:
926  // these items are not rotated, because rotation does not change them.
927  break;
928 
929  default:
930  // Other items (wires...) cannot be rotated, at least during creation
931  if( item->IsNew() )
932  break;
933 
934  wxFAIL_MSG( wxString::Format( wxT( "Cannot rotate schematic item type %s." ),
935  GetChars( item->GetClass() ) ) );
936  }
937 
938  if( item->GetFlags() == 0 )
939  screen->SetCurItem( NULL );
940 }
941 
942 
943 void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
944 {
945  SCH_SCREEN* screen = GetScreen();
946  SCH_ITEM* item = screen->GetCurItem();
947 
948  if( item == NULL )
949  {
950  // If we didn't get here by a hot key, then something has gone wrong.
951  if( aEvent.GetInt() == 0 )
952  return;
953 
954  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
955 
956  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
957 
958  // Set the locat filter, according to the edit command
959  const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
960  const KICAD_T* filterListAux = NULL;
961 
962  switch( aEvent.GetId() )
963  {
966  filterListAux = SCH_COLLECTOR::ComponentsOnly;
967  break;
968 
971  filterListAux = SCH_COLLECTOR::ComponentsOnly;
972  break;
973 
976  filterListAux = SCH_COLLECTOR::ComponentsOnly;
977  break;
978 
979  default:
980  break;
981  }
982 
983  item = LocateAndShowItem( data->GetPosition(), filterList, aEvent.GetInt() );
984 
985  // If no item found, and if an auxiliary filter exists, try to use it
986  if( !item && filterListAux )
987  item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
988 
989  // Exit if no item found at the current location or the item is already being edited.
990  if( (item == NULL) || (item->GetFlags() != 0) )
991  return;
992  }
993 
994  switch( item->Type() )
995  {
996  case SCH_COMPONENT_T:
997  {
998  switch( aEvent.GetId() )
999  {
1001  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ) );
1002  break;
1003 
1005  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ) );
1006  break;
1007 
1009  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ) );
1010  break;
1011 
1012  case ID_SCH_EDIT_ITEM:
1013  EditComponent( (SCH_COMPONENT*) item );
1014  break;
1015 
1016  default:
1017  wxFAIL_MSG( wxString::Format( wxT( "Invalid schematic component edit command ID %d" ),
1018  aEvent.GetId() ) );
1019  }
1020 
1021  break;
1022  }
1023 
1024  case SCH_SHEET_T:
1025  if( EditSheet( (SCH_SHEET*) item, m_CurrentSheet ) )
1026  m_canvas->Refresh();
1027  break;
1028 
1029  case SCH_SHEET_PIN_T:
1030  EditSheetPin( (SCH_SHEET_PIN*) item, true );
1031  break;
1032 
1033  case SCH_TEXT_T:
1034  case SCH_LABEL_T:
1035  case SCH_GLOBAL_LABEL_T:
1037  EditSchematicText( (SCH_TEXT*) item );
1038  break;
1039 
1040  case SCH_FIELD_T:
1041  EditComponentFieldText( (SCH_FIELD*) item );
1042  break;
1043 
1044  case SCH_BITMAP_T:
1045  EditImage( (SCH_BITMAP*) item );
1046  break;
1047 
1048  case SCH_LINE_T: // These items have no param to edit
1049  case SCH_MARKER_T:
1050  case SCH_JUNCTION_T:
1051  case SCH_NO_CONNECT_T:
1052  break;
1053 
1054  default: // Unexpected item
1055  wxFAIL_MSG( wxString::Format( wxT( "Cannot edit schematic item type %s." ),
1056  GetChars( item->GetClass() ) ) );
1057  }
1058 
1059  if( item->GetFlags() == 0 )
1060  screen->SetCurItem( NULL );
1061 }
1062 
1063 
1064 void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
1065 {
1066  SCH_SCREEN* screen = GetScreen();
1067  SCH_ITEM* item = screen->GetCurItem();
1068 
1069  // The easiest way to handle a menu or a hot key drag command
1070  // is to simulate a block drag command
1071  //
1072  // When a drag item is requested, some items use a BLOCK_DRAG_ITEM drag type
1073  // an some items use a BLOCK_DRAG drag type (mainly a junction)
1074  // a BLOCK_DRAG collects all items in a block (here a 2x2 rect centered on the cursor)
1075  // and BLOCK_DRAG_ITEM drag only the selected item
1076  BLOCK_COMMAND_T dragType = BLOCK_DRAG_ITEM;
1077 
1078  if( item == NULL )
1079  {
1080  // If we didn't get here by a hot key, then something has gone wrong.
1081  if( aEvent.GetInt() == 0 )
1082  return;
1083 
1084  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1085 
1086  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1087 
1089  aEvent.GetInt() );
1090 
1091  // Exit if no item found at the current location or the item is already being edited.
1092  if( (item == NULL) || (item->GetFlags() != 0) )
1093  return;
1094 
1095  // When a junction or a node is found, a BLOCK_DRAG is better
1098  dragType = BLOCK_DRAG;
1099  }
1100 
1101  switch( item->Type() )
1102  {
1103  case SCH_BUS_BUS_ENTRY_T:
1104  case SCH_BUS_WIRE_ENTRY_T:
1105  case SCH_LINE_T:
1106  case SCH_JUNCTION_T:
1107  case SCH_COMPONENT_T:
1108  case SCH_LABEL_T:
1109  case SCH_GLOBAL_LABEL_T:
1111  case SCH_SHEET_T:
1113 
1114  if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1115  {
1117 
1118  if( !HandleBlockBegin( &dc, dragType, GetCrossHairPosition() ) )
1119  break;
1120 
1121  // Give a non null size to the search block:
1122  screen->m_BlockLocate.Inflate( 1 );
1123  HandleBlockEnd( &dc );
1124  }
1125 
1126  break;
1127 
1128  default:
1129  wxFAIL_MSG( wxString::Format( wxT( "Cannot drag schematic item type %s." ),
1130  GetChars( item->GetClass() ) ) );
1131  }
1132 }
1133 
1134 
1135 void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
1136 {
1137  SCH_SCREEN* screen = GetScreen();
1138  SCH_ITEM* item = screen->GetCurItem();
1139 
1141 
1142  // Allows block rotate operation on hot key.
1143  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
1144  {
1145  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1146  {
1148  screen->m_BlockLocate.SetMessageBlock( this );
1150  HandleBlockEnd( &dc );
1151  }
1152  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1153  {
1155  screen->m_BlockLocate.SetMessageBlock( this );
1157  HandleBlockEnd( &dc );
1158  }
1159  else
1160  {
1161  wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
1162  }
1163 
1164  return;
1165  }
1166 
1167  if( item == NULL )
1168  {
1169  // If we didn't get here by a hot key, then something has gone wrong.
1170  if( aEvent.GetInt() == 0 )
1171  return;
1172 
1173  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1174 
1175  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1176 
1178  aEvent.GetInt() );
1179 
1180  // Exit if no item found at the current location or the item is already being edited.
1181  if( (item == NULL) || (item->GetFlags() != 0) )
1182  return;
1183  }
1184 
1185 
1186  switch( item->Type() )
1187  {
1188  case SCH_COMPONENT_T:
1189  {
1190  SCH_COMPONENT *component = static_cast<SCH_COMPONENT*>( item );
1191  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1193  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1195  else if( aEvent.GetId() == ID_SCH_ORIENT_NORMAL )
1197  else
1198  wxFAIL_MSG( wxT( "Invalid orient schematic component command ID." ) );
1199 
1200  if( m_autoplaceFields )
1201  component->AutoAutoplaceFields( GetScreen() );
1202 
1203  m_canvas->Refresh();
1204 
1205  break;
1206  }
1207 
1208  case SCH_BITMAP_T:
1209  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1210  MirrorImage( (SCH_BITMAP*) item, true );
1211  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1212  MirrorImage( (SCH_BITMAP*) item, false );
1213 
1214  break;
1215 
1216  case SCH_SHEET_T:
1217  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1218  MirrorSheet( (SCH_SHEET*) item, true );
1219  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1220  MirrorSheet( (SCH_SHEET*) item, false );
1221 
1222  break;
1223 
1224  default:
1225  // This object cannot be oriented.
1226  ;
1227  }
1228 
1229  if( item->GetFlags() == 0 )
1230  screen->SetCurItem( NULL );
1231 }
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:279
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
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)
Function AutoAutoplaceFields Autoplace fields only if correct to do so automatically.
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:255
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
Definition: draw_panel.cpp:326
virtual bool IsMovableFromAnchorPoint()
Virtual function IsMovableFromAnchorPoint.
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:216
void OnModify()
Function OnModify Must be called after a schematic change in order to set the "modify" flag of the cu...
Definition: schframe.cpp:762
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:932
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:1404
void addCurrentItemToList(bool aRedraw=true)
Function addCurrentItemToList adds the item currently being edited to the schematic and adds the chan...
Definition: schframe.cpp:1279
EDA_ITEM * GetParent() const
Definition: base_struct.h:208
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:306
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:943
SCH_ITEM * GetUndoItem() const
Definition: schframe.h:1309
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:348
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:460
void InstallHierarchyFrame(wxPoint &pos)
Definition: hierarch.cpp:141
void ClearFieldsAutoplaced()
Function ClearFieldsAutoplaced Set fields autoplaced flag false.
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:521
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:823
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...
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:253
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:54
EDA_RECT const GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_sheet.cpp:649
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:837
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:226
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:1401
void RotateImage(SCH_BITMAP *aItem)
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:175
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:535
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:497
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:560
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
bool HasUndefinedPins()
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:415
wxString GetDocFileName() const
void DisplayInfoMessage(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:89
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:486
#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:911
static const KICAD_T CmpFieldReferenceOnly[]
A scan list for a specific editable field: Reference.
int GetToolId() const
Definition: draw_frame.h:419
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Virtual function, from the base class SCH_ITEM::Draw.
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:188
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:254
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:1064
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:1135
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:580
Definition for part library class.
bool IsWireImage() const
Definition: base_struct.h:220
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:111
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 ConvertPart(SCH_COMPONENT *DrawComponent, wxDC *DC)
Definition: getpart.cpp:370
#define IS_MOVED
Item being moved.
Definition: base_struct.h:112