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 <sch_edit_frame.h>
38 #include <kicad_device_context.h>
39 #include <hotkeys_basic.h>
40 
41 #include <general.h>
42 #include <eeschema_id.h>
43 #include <list_operations.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  case ID_POPUP_CUT_BLOCK:
128 
129  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
130  break;
132  screen->m_BlockLocate.SetMessageBlock( this );
133  HandleBlockEnd( &dc );
134  SetRepeatItem( NULL );
136  break;
137 
138  case wxID_COPY: // really this is a Save block for paste
139  case ID_POPUP_COPY_BLOCK:
141  screen->m_BlockLocate.SetMessageBlock( this );
142  HandleBlockEnd( &dc );
143  break;
144 
145  case wxID_PASTE:
147  break;
148 
151  SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '/' );
152  break;
153 
156  SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '\\' );
157  break;
158 
160  if( m_canvas->IsMouseCaptured() )
161  {
163  SetToolID( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString );
164  }
165  else
166  {
168  }
169 
170  break;
171 
172  case ID_POPUP_END_LINE:
174  EndSegment();
175  break;
176 
180  break;
181 
185  break;
186 
188  // Not used
189  break;
190 
195  SchematicCleanUp( true );
196  screen->SetCurItem( NULL );
197  SetRepeatItem( NULL );
198 
199  screen->TestDanglingEnds();
200  m_canvas->Refresh();
201 
202  break;
203 
205  {
206  SaveWireImage();
209  if( screen->TestDanglingEnds() )
210  m_canvas->Refresh();
211  }
212  break;
213 
215  case ID_POPUP_SCH_DELETE:
216  if( item == NULL )
217  break;
218 
219  DeleteItem( item );
220  SchematicCleanUp( true );
221  screen->SetCurItem( NULL );
222  SetRepeatItem( NULL );
223  screen->TestDanglingEnds();
225  m_canvas->Refresh();
226  OnModify();
227  break;
228 
232  break;
233 
235  ReSizeSheet( (SCH_SHEET*) item, &dc );
236 
237  if( screen->TestDanglingEnds() )
238  m_canvas->Refresh();
239 
240  break;
241 
243  if( item != NULL && item->Type() == SCH_SHEET_T )
244  screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, &dc ) );
245  break;
246 
248  if( item != NULL && item->Type() == SCH_SHEET_T )
249  {
250  SCH_SHEET* sheet = (SCH_SHEET*) item;
251 
252  if( !sheet->HasUndefinedPins() )
253  {
254  DisplayInfoMessage( this,
255  _( "There are no undefined labels in this sheet to clean up." ) );
256  return;
257  }
258 
259  if( !IsOK( this, _( "Do you wish to cleanup this sheet?" ) ) )
260  return;
261 
262  /* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */
263  SaveCopyInUndoList( sheet, UR_CHANGED );
264  sheet->CleanupSheet();
265  OnModify();
267  }
268  break;
269 
272  break;
273 
275  // Ensure the struct is a component (could be a struct of a component, like Field, text..)
276  if( item && item->Type() == SCH_COMPONENT_T )
277  {
279  ConvertPart( (SCH_COMPONENT*) item, &dc );
280  }
281 
282  break;
283 
285  // Ensure the struct is a component (could be a piece of a component, like Field, text..)
286  if( item && item->Type() == SCH_COMPONENT_T )
287  {
288  wxString text = static_cast<SCH_COMPONENT*>( item )->
289  GetField( DATASHEET )->GetFullyQualifiedText();
290 
291  if( !text.IsEmpty() )
292  GetAssociatedDocument( this, text );
293  }
294  break;
295 
297 
298  if( item && (item->Type() == SCH_SHEET_T) )
299  {
300  m_CurrentSheet->push_back( (SCH_SHEET*) item );
302  }
303 
304  break;
305 
307  if( m_CurrentSheet->Last() != g_RootSheet )
308  {
309  m_CurrentSheet->pop_back();
311  }
312 
313  break;
314 
316  m_canvas->SetAutoPanRequest( false );
318  HandleBlockPlace( &dc );
319  break;
320 
321  case ID_POPUP_ZOOM_BLOCK:
323  screen->m_BlockLocate.SetMessageBlock( this );
324  HandleBlockEnd( &dc );
325  break;
326 
328  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
329  break;
330 
333  screen->m_BlockLocate.SetMessageBlock( this );
334  HandleBlockEnd( &dc );
336  break;
337 
339  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
340  break;
341 
344  screen->m_BlockLocate.SetMessageBlock( this );
345  HandleBlockEnd( &dc );
346  break;
347 
348  case ID_POPUP_DRAG_BLOCK:
349  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
350  break;
351 
354  screen->m_BlockLocate.SetMessageBlock( this );
355  HandleBlockEnd( &dc );
356  break;
357 
361 
362  if( screen->TestDanglingEnds() )
363  m_canvas->Refresh();
364 
365  screen->SetCurItem( NULL );
366  break;
367 
370  screen->SetCurItem( CreateNewText( &dc, id == ID_POPUP_SCH_ADD_LABEL ?
372  item = screen->GetCurItem();
373 
374  if( item )
376 
377  break;
378 
380  if( item && item->Type() == SCH_MARKER_T )
381  ( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
382 
383  break;
384 
385  default: // Log error:
386  wxFAIL_MSG( wxString::Format( wxT( "Cannot process command event ID %d" ),
387  event.GetId() ) );
388  break;
389  }
390 
391  // End switch ( id ) (Command execution)
392 
393  if( GetToolId() == ID_NO_TOOL_SELECTED )
394  SetRepeatItem( NULL );
395 }
396 
397 
398 void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
399 {
400  SCH_SCREEN* screen = GetScreen();
401  SCH_ITEM* item = screen->GetCurItem();
402 
403  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
404  {
405  // trying to move an item when there is a block at the same time is not acceptable
406  return;
407  }
408 
409  if( item == NULL )
410  {
411  // If we didn't get here by a hot key, then something has gone wrong.
412  if( aEvent.GetInt() == 0 )
413  return;
414 
415  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
416 
417  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
418 
420  aEvent.GetInt() );
421 
422  // Exit if no item found at the current location or the item is already being edited.
423  if( (item == NULL) || (item->GetFlags() != 0) )
424  return;
425  }
426 
428 
429  switch( item->Type() )
430  {
431  case SCH_LINE_T:
432  break;
433 
434  case SCH_JUNCTION_T:
435  case SCH_NO_CONNECT_T:
436  case SCH_BUS_BUS_ENTRY_T:
438  case SCH_LABEL_T:
439  case SCH_GLOBAL_LABEL_T:
441  case SCH_TEXT_T:
442  case SCH_COMPONENT_T:
443  case SCH_SHEET_PIN_T:
444  case SCH_FIELD_T:
445  case SCH_SHEET_T:
446  PrepareMoveItem( item, &dc );
447  break;
448 
449  case SCH_BITMAP_T:
450  // move an image is a special case:
451  // we cannot undraw/redraw a bitmap just using our xor mode
452  // the MoveImage function handle this undraw/redraw difficulty
453  // By redrawing the full bounding box
454  MoveImage( (SCH_BITMAP*) item, &dc );
455  break;
456 
457  case SCH_MARKER_T:
458  // Moving a marker has no sense
459  break;
460 
461  default:
462  // Unknown items cannot be moved
463  wxFAIL_MSG( wxString::Format(
464  wxT( "Cannot move item type %d" ), item->Type() ) );
465  break;
466  }
467 
468  if( GetToolId() == ID_NO_TOOL_SELECTED )
469  SetRepeatItem( NULL );
470 }
471 
472 
473 void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
474 {
475  SCH_SCREEN* screen = GetScreen();
476 
477  if( screen->IsBlockActive() )
478  {
479  m_canvas->SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() );
480  screen->ClearBlockCommand();
481 
482  // Stop the current command (if any) but keep the current tool
484  }
485  else
486  {
487  if( m_canvas->IsMouseCaptured() ) // Stop the current command but keep the current tool
489  else // Deselect current tool
491  }
492 }
493 
494 
495 void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
496 {
497  int id = aEvent.GetId();
498  int lastToolID = GetToolId();
499 
500  // Stop the current command and deselect the current tool.
502 
503  switch( id )
504  {
505  case ID_NO_TOOL_SELECTED:
507  break;
508 
509  case ID_HIGHLIGHT:
510  SetToolID( id, wxCURSOR_HAND, _("Highlight specific net") );
511  break;
512 
513  case ID_ZOOM_SELECTION:
514  // This tool is located on the main toolbar: switch it on or off on click
515  if( lastToolID != ID_ZOOM_SELECTION )
516  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
517  else
519  break;
520 
521  case ID_NOCONN_BUTT:
522  SetToolID( id, wxCURSOR_PENCIL, _( "Add no connect" ) );
523  break;
524 
525  case ID_WIRE_BUTT:
526  SetToolID( id, wxCURSOR_PENCIL, _( "Add wire" ) );
527  break;
528 
529  case ID_BUS_BUTT:
530  SetToolID( id, wxCURSOR_PENCIL, _( "Add bus" ) );
531  break;
532 
534  SetToolID( id, wxCURSOR_PENCIL, _( "Add lines" ) );
535  break;
536 
537  case ID_JUNCTION_BUTT:
538  SetToolID( id, wxCURSOR_PENCIL, _( "Add junction" ) );
539  break;
540 
541  case ID_LABEL_BUTT:
542  SetToolID( id, wxCURSOR_PENCIL, _( "Add label" ) );
543  break;
544 
545  case ID_GLABEL_BUTT:
546  SetToolID( id, wxCURSOR_PENCIL, _( "Add global label" ) );
547  break;
548 
549  case ID_HIERLABEL_BUTT:
550  SetToolID( id, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
551  break;
552 
554  SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
555  break;
556 
557  case ID_ADD_IMAGE_BUTT:
558  SetToolID( id, wxCURSOR_PENCIL, _( "Add image" ) );
559  break;
560 
562  SetToolID( id, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
563  break;
564 
566  SetToolID( id, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
567  break;
568 
570  SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet" ) );
571  break;
572 
573  case ID_SHEET_PIN_BUTT:
574  SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
575  break;
576 
578  SetToolID( id, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
579  break;
580 
582  SetToolID( id, wxCURSOR_PENCIL, _( "Add component" ) );
583  break;
584 
585  case ID_PLACE_POWER_BUTT:
586  SetToolID( id, wxCURSOR_PENCIL, _( "Add power" ) );
587  break;
588 
590  SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
591  break;
592 
593 #ifdef KICAD_SPICE
594  case ID_SIM_PROBE:
595  SetToolID( id, -1, _( "Add a simulator probe" ) );
596  m_canvas->SetCursor( CURSOR_PROBE );
597  break;
598 
599  case ID_SIM_TUNE:
600  SetToolID( id, -1, _( "Select a value to be tuned" ) );
601  m_canvas->SetCursor( CURSOR_TUNE );
602  break;
603 #endif /* KICAD_SPICE */
604 
605  default:
606  SetRepeatItem( NULL );
607  }
608 
609  // Simulate left click event if we got here from a hot key.
610  if( aEvent.GetClientObject() != NULL )
611  {
612  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
613 
614  wxPoint pos = data->GetPosition();
615 
617  OnLeftClick( &dc, pos );
618  }
619 }
620 
621 
622 void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
623 {
624  aEvent.Check( GetToolId() == aEvent.GetId() );
625 }
626 
627 
628 void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
629 {
630  PICKED_ITEMS_LIST pickList;
631  SCH_SCREEN* screen = GetScreen();
633 
634  if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
635  {
636  DeleteItemsInList( pickList );
637  SchematicCleanUp( true );
638  OnModify();
639  }
640 }
641 
642 
644 {
645  SCH_ITEM* item;
646  SCH_SCREEN* screen = GetScreen();
647 
649 
650  if( item )
651  {
652  bool itemHasConnections = item->IsConnectable();
653 
654  screen->SetCurItem( NULL );
655  SetRepeatItem( NULL );
656  DeleteItem( item );
657 
658  if( itemHasConnections && screen->TestDanglingEnds() )
659  m_canvas->Refresh();
660 
661  OnModify();
662  return true;
663  }
664 
665  return false;
666 }
667 
668 // This function is a callback function, called by the mouse cursor movin event
669 // when an item is currently moved
670 static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
671  const wxPoint& aPosition, bool aErase )
672 {
673  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
674  SCH_ITEM* item = screen->GetCurItem();
675 
676  wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) );
677 
678  SCH_COMPONENT* cmp = NULL;
679 
680  if( item->Type() == SCH_COMPONENT_T )
681  cmp = static_cast< SCH_COMPONENT* >( item );
682 
683 #ifndef USE_WX_OVERLAY
684  // Erase the current item at its current position.
685  if( aErase )
686  {
687  if( cmp ) // Use fast mode (do not draw pin texts)
688  cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, COLOR4D::UNSPECIFIED, false );
689  else
690  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
691  }
692 #endif
693 
694  wxPoint cpos = aPanel->GetParent()->GetCrossHairPosition();
695  cpos -= item->GetStoredPos();
696 
697  item->SetPosition( cpos );
698 
699  // Draw the item item at it's new position.
700  item->SetWireImage(); // While moving, the item may choose to render differently
701 
702  if( cmp ) // Use fast mode (do not draw pin texts)
703  cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, COLOR4D::UNSPECIFIED, false );
704  else
705  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
706 }
707 
708 
709 static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
710 {
711  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
712  SCH_ITEM* item = screen->GetCurItem();
713  SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
714 
715  parent->SetRepeatItem( NULL );
716  screen->SetCurItem( NULL );
717 
718  if( item == NULL ) /* no current item */
719  return;
720 
721  if( item->IsNew() )
722  {
723  delete item;
724  item = NULL;
725  }
726  else
727  {
728  SCH_ITEM* oldItem = parent->GetUndoItem();
729 
730  SCH_ITEM* currentItem;
731 
732  // Items that are children of other objects are undone by swapping the contents
733  // of the parent items.
734  if( (item->Type() == SCH_SHEET_PIN_T) || (item->Type() == SCH_FIELD_T) )
735  {
736  currentItem = (SCH_ITEM*) item->GetParent();
737  }
738  else
739  {
740  currentItem = item;
741  }
742 
743  wxCHECK_RET( oldItem != NULL && currentItem->Type() == oldItem->Type(),
744  wxT( "Cannot restore undefined or bad last schematic item." ) );
745 
746  // Never delete existing item, because it can be referenced by an undo/redo command
747  // Just restore its data
748  currentItem->SwapData( oldItem );
749 
750  // Erase the wire representation before the 'normal' view is drawn.
751  if ( item->IsWireImage() )
752  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
753 
754  item->ClearFlags();
755  }
756 
757  aPanel->Refresh();
758 }
759 
760 
761 void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC )
762 {
763  wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) );
764 
765  SetRepeatItem( NULL );
766 
767  if( !aItem->IsNew() )
768  {
769  if( (aItem->Type() == SCH_SHEET_PIN_T) || (aItem->Type() == SCH_FIELD_T) )
770  SetUndoItem( (SCH_ITEM*) aItem->GetParent() );
771  else
772  SetUndoItem( aItem );
773  }
774 
775  if( aItem->Type() == SCH_FIELD_T && aItem->GetParent()->Type() == SCH_COMPONENT_T )
776  {
777  // Now that we're moving a field, they're no longer autoplaced.
778  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( aItem->GetParent() );
779  parent->ClearFieldsAutoplaced();
780  }
781 
782  aItem->SetFlags( IS_MOVED );
783 
784  // For some items, moving the cursor to anchor is not good
785  // (for instance large hierarchical sheets od componants can have
786  // the anchor position outside the canvas)
787  // these items return IsMovableFromAnchorPoint() == false
788  // For these items, do not wrap the cursor
789  if( aItem->IsMovableFromAnchorPoint() )
790  {
791  SetCrossHairPosition( aItem->GetPosition() );
793  aItem->SetStoredPos( wxPoint( 0,0 ) );
794  }
795  else
796  {
797  // Round the point under the cursor to a multiple of the grid
798  wxPoint cursorpos = GetCrossHairPosition() - aItem->GetPosition();
799  wxPoint gridsize = GetScreen()->GetGridSize();
800  cursorpos.x = ( cursorpos.x / gridsize.x ) * gridsize.x;
801  cursorpos.y = ( cursorpos.y / gridsize.y ) * gridsize.y;
802 
803  aItem->SetStoredPos( cursorpos );
804  }
805 
806  OnModify();
807 
808  GetScreen()->SetCurItem( aItem );
810 
811  m_canvas->Refresh();
812 }
813 
814 
815 void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
816 {
817  SCH_SCREEN* screen = GetScreen();
818  SCH_ITEM* item = screen->GetCurItem();
819 
820  if( item != NULL )
821  {
822  item = LocateAndShowItem( item->GetPosition() );
823  SendMessageToPCBNEW( item, NULL );
824  }
825  else
826  {
827  // If we didn't get here by a hot key, then something has gone wrong.
828  if( aEvent.GetInt() == 0 )
829  return;
830 
831  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
832 
833  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
834 
835  item = LocateAndShowItem( data->GetPosition() );
836  SendMessageToPCBNEW( item, NULL );
837  }
838 }
839 
840 
841 void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
842 {
843  SCH_SCREEN* screen = GetScreen();
844  SCH_ITEM* item = screen->GetCurItem();
845 
847 
848  // Allows block rotate operation on hot key.
849  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
850  {
852  HandleBlockEnd( &dc );
853  return;
854  }
855 
856  if( item == NULL )
857  {
858  // If we didn't get here by a hot key, then something has gone wrong.
859  if( aEvent.GetInt() == 0 )
860  return;
861 
862  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
863 
864  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
865 
867  aEvent.GetInt() );
868 
869  // Exit if no item found at the current location or the item is already being edited.
870  if( (item == NULL) || (item->GetFlags() != 0) )
871  return;
872  }
873 
874  switch( item->Type() )
875  {
876  case SCH_COMPONENT_T:
877  {
878  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
879  if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
881  else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
883  else
884  wxFAIL_MSG( wxT( "Unknown rotate item command ID." ) );
885 
886  if( m_autoplaceFields )
887  component->AutoAutoplaceFields( GetScreen() );
888 
889  m_canvas->Refresh();
890 
891  break;
892  }
893 
894  case SCH_TEXT_T:
895  case SCH_LABEL_T:
896  case SCH_GLOBAL_LABEL_T:
899  ChangeTextOrient( (SCH_TEXT*) item );
900  m_canvas->Refresh();
901  break;
902 
903  case SCH_FIELD_T:
905  RotateField( (SCH_FIELD*) item );
906  if( item->GetParent()->Type() == SCH_COMPONENT_T )
907  {
908  // Now that we're moving a field, they're no longer autoplaced.
909  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( item->GetParent() );
910  parent->ClearFieldsAutoplaced();
911  }
912  m_canvas->Refresh();
913  break;
914 
915  case SCH_BITMAP_T:
916  RotateImage( (SCH_BITMAP*) item );
917  break;
918 
919  case SCH_SHEET_T:
920  if( !item->IsNew() ) // rotate a sheet during its creation has no sense
921  {
922  bool retCCW = ( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE );
923  RotateHierarchicalSheet( static_cast<SCH_SHEET*>( item ), retCCW );
924  }
925 
926  break;
927 
928  case SCH_JUNCTION_T:
929  case SCH_NO_CONNECT_T:
930  // these items are not rotated, because rotation does not change them.
931  break;
932 
933  default:
934  // Other items (wires...) cannot be rotated, at least during creation
935  if( item->IsNew() )
936  break;
937 
938  wxFAIL_MSG( wxString::Format( wxT( "Cannot rotate schematic item type %s." ),
939  GetChars( item->GetClass() ) ) );
940  }
941 
942  if( item->GetFlags() == 0 )
943  screen->SetCurItem( NULL );
944 }
945 
946 
947 void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
948 {
949  SCH_SCREEN* screen = GetScreen();
950  SCH_ITEM* item = screen->GetCurItem();
951 
952  if( item == NULL )
953  {
954  // If we didn't get here by a hot key, then something has gone wrong.
955  if( aEvent.GetInt() == 0 )
956  return;
957 
958  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
959 
960  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
961 
962  // Set the locat filter, according to the edit command
963  const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
964  const KICAD_T* filterListAux = NULL;
965 
966  switch( aEvent.GetId() )
967  {
970  filterListAux = SCH_COLLECTOR::ComponentsOnly;
971  break;
972 
975  filterListAux = SCH_COLLECTOR::ComponentsOnly;
976  break;
977 
980  filterListAux = SCH_COLLECTOR::ComponentsOnly;
981  break;
982 
983  default:
984  break;
985  }
986 
987  item = LocateAndShowItem( data->GetPosition(), filterList, aEvent.GetInt() );
988 
989  // If no item found, and if an auxiliary filter exists, try to use it
990  if( !item && filterListAux )
991  item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
992 
993  // Exit if no item found at the current location or the item is already being edited.
994  if( (item == NULL) || (item->GetFlags() != 0) )
995  return;
996  }
997 
998  switch( item->Type() )
999  {
1000  case SCH_COMPONENT_T:
1001  {
1002  switch( aEvent.GetId() )
1003  {
1005  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ) );
1006  break;
1007 
1009  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ) );
1010  break;
1011 
1013  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ) );
1014  break;
1015 
1016  case ID_SCH_EDIT_ITEM:
1017  EditComponent( (SCH_COMPONENT*) item );
1018  break;
1019 
1020  default:
1021  wxFAIL_MSG( wxString::Format( wxT( "Invalid schematic component edit command ID %d" ),
1022  aEvent.GetId() ) );
1023  }
1024 
1025  break;
1026  }
1027 
1028  case SCH_SHEET_T:
1029  if( EditSheet( (SCH_SHEET*) item, m_CurrentSheet ) )
1030  m_canvas->Refresh();
1031  break;
1032 
1033  case SCH_SHEET_PIN_T:
1034  EditSheetPin( (SCH_SHEET_PIN*) item, true );
1035  break;
1036 
1037  case SCH_TEXT_T:
1038  case SCH_LABEL_T:
1039  case SCH_GLOBAL_LABEL_T:
1041  EditSchematicText( (SCH_TEXT*) item );
1042  break;
1043 
1044  case SCH_FIELD_T:
1045  EditComponentFieldText( (SCH_FIELD*) item );
1046  break;
1047 
1048  case SCH_BITMAP_T:
1049  EditImage( (SCH_BITMAP*) item );
1050  break;
1051 
1052  case SCH_LINE_T: // These items have no param to edit
1053  EditLine( (SCH_LINE*) item, true );
1054  break;
1055  case SCH_MARKER_T:
1056  case SCH_JUNCTION_T:
1057  case SCH_NO_CONNECT_T:
1058  break;
1059 
1060  default: // Unexpected item
1061  wxFAIL_MSG( wxString::Format( wxT( "Cannot edit schematic item type %s." ),
1062  GetChars( item->GetClass() ) ) );
1063  }
1064 
1065  if( item->GetFlags() == 0 )
1066  screen->SetCurItem( NULL );
1067 }
1068 
1069 
1070 void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
1071 {
1072  SCH_SCREEN* screen = GetScreen();
1073  SCH_ITEM* item = screen->GetCurItem();
1074 
1075  // The easiest way to handle a menu or a hot key drag command
1076  // is to simulate a block drag command
1077  //
1078  // When a drag item is requested, some items use a BLOCK_DRAG_ITEM drag type
1079  // an some items use a BLOCK_DRAG drag type (mainly a junction)
1080  // a BLOCK_DRAG collects all items in a block (here a 2x2 rect centered on the cursor)
1081  // and BLOCK_DRAG_ITEM drag only the selected item
1082  BLOCK_COMMAND_T dragType = BLOCK_DRAG_ITEM;
1083 
1084  if( item == NULL )
1085  {
1086  // If we didn't get here by a hot key, then something has gone wrong.
1087  if( aEvent.GetInt() == 0 )
1088  return;
1089 
1090  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1091 
1092  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1093 
1095  aEvent.GetInt() );
1096 
1097  // Exit if no item found at the current location or the item is already being edited.
1098  if( (item == NULL) || (item->GetFlags() != 0) )
1099  return;
1100 
1101  // When a junction or a node is found, a BLOCK_DRAG is better
1104  dragType = BLOCK_DRAG;
1105  }
1106 
1107  switch( item->Type() )
1108  {
1109  case SCH_BUS_BUS_ENTRY_T:
1110  case SCH_BUS_WIRE_ENTRY_T:
1111  case SCH_LINE_T:
1112  case SCH_JUNCTION_T:
1113  case SCH_COMPONENT_T:
1114  case SCH_LABEL_T:
1115  case SCH_GLOBAL_LABEL_T:
1117  case SCH_SHEET_T:
1119 
1120  if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1121  {
1123 
1124  if( !HandleBlockBegin( &dc, dragType, GetCrossHairPosition() ) )
1125  break;
1126 
1127  // Give a non null size to the search block:
1128  screen->m_BlockLocate.Inflate( 1 );
1129  HandleBlockEnd( &dc );
1130  }
1131 
1132  break;
1133 
1134  default:
1135  wxFAIL_MSG( wxString::Format( wxT( "Cannot drag schematic item type %s." ),
1136  GetChars( item->GetClass() ) ) );
1137  }
1138 }
1139 
1140 
1141 void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
1142 {
1143  SCH_SCREEN* screen = GetScreen();
1144  SCH_ITEM* item = screen->GetCurItem();
1145 
1147 
1148  // Allows block rotate operation on hot key.
1149  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
1150  {
1151  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1152  {
1154  screen->m_BlockLocate.SetMessageBlock( this );
1156  HandleBlockEnd( &dc );
1157  }
1158  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1159  {
1161  screen->m_BlockLocate.SetMessageBlock( this );
1163  HandleBlockEnd( &dc );
1164  }
1165  else
1166  {
1167  wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
1168  }
1169 
1170  return;
1171  }
1172 
1173  if( item == NULL )
1174  {
1175  // If we didn't get here by a hot key, then something has gone wrong.
1176  if( aEvent.GetInt() == 0 )
1177  return;
1178 
1179  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1180 
1181  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1182 
1184  aEvent.GetInt() );
1185 
1186  // Exit if no item found at the current location or the item is already being edited.
1187  if( (item == NULL) || (item->GetFlags() != 0) )
1188  return;
1189  }
1190 
1191 
1192  switch( item->Type() )
1193  {
1194  case SCH_COMPONENT_T:
1195  {
1196  SCH_COMPONENT *component = static_cast<SCH_COMPONENT*>( item );
1197  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1199  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1201  else if( aEvent.GetId() == ID_SCH_ORIENT_NORMAL )
1203  else
1204  wxFAIL_MSG( wxT( "Invalid orient schematic component command ID." ) );
1205 
1206  if( m_autoplaceFields )
1207  component->AutoAutoplaceFields( GetScreen() );
1208 
1209  m_canvas->Refresh();
1210 
1211  break;
1212  }
1213 
1214  case SCH_BITMAP_T:
1215  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1216  MirrorImage( (SCH_BITMAP*) item, true );
1217  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1218  MirrorImage( (SCH_BITMAP*) item, false );
1219 
1220  break;
1221 
1222  case SCH_SHEET_T:
1223  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1224  MirrorSheet( (SCH_SHEET*) item, true );
1225  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1226  MirrorSheet( (SCH_SHEET*) item, false );
1227 
1228  break;
1229 
1230  default:
1231  // This object cannot be oriented.
1232  ;
1233  }
1234 
1235  if( item->GetFlags() == 0 )
1236  screen->SetCurItem( NULL );
1237 }
Definition of the SCH_SHEET class for Eeschema.
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
void OrientComponent(COMPONENT_ORIENTATION_T aOrientation=CMP_NORMAL)
Rotate and mirror a component.
Definition: getpart.cpp:297
SCH_JUNCTION * AddJunction(const wxPoint &aPosition, bool aPutInUndoList=false)
Add a new junction at aPosition.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
Class SCH_FIELD instances are attached to a component and provide a place for the component&#39;s value...
Definition: sch_field.h:56
void DeleteConnection(bool DeleteFullConnection)
Definition: schedit.cpp:628
void EditComponent(SCH_COMPONENT *aComponent)
Display 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:284
int EditLine(SCH_LINE *aLine, bool aRedraw)
Function EditLine displays the dialog for editing the parameters of aLine.
Definition: sch_line.cpp:784
bool SchematicCleanUp(bool aAppend=false)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
void OnMoveItem(wxCommandEvent &aEvent)
Handle the ID_SCH_MOVE_ITEM event used to move schematic items.
Definition: schedit.cpp:398
name of datasheet
static const KICAD_T RotatableItems[]
A scan list for all rotatable schematic items.
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:339
virtual bool IsMovableFromAnchorPoint()
Virtual function IsMovableFromAnchorPoint.
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:245
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
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...
bool BreakSegments(const wxPoint &aPoint, bool aAppend=false)
Checks every wire and bus for a intersection at aPoint and break into two segments at aPoint if an in...
static const wxCursor CURSOR_TUNE
Tuner cursor, used by circuit simulator
void addCurrentItemToList(bool aRedraw=true)
Add the item currently being edited to the schematic and adds the changes to the undo/redo container...
EDA_ITEM * GetParent() const
Definition: base_struct.h:237
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:319
void RotateHierarchicalSheet(SCH_SHEET *aSheet, bool aRotCCW)
Rotate a sheet object.
Definition: sheet.cpp:477
SCH_ITEM * LocateAndShowItem(const wxPoint &aPosition, const KICAD_T aFilterList[]=SCH_COLLECTOR::AllItems, int aHotKeyCommandId=0, bool *clarifySelectionMenuCancelled=nullptr)
Check the schematic at aPosition in logical (drawing) units for a item matching the types in aFilterL...
void OnEditItem(wxCommandEvent &aEvent)
Handle the ID_SCH_EDIT_ITEM event used to edit schematic items.
Definition: schedit.cpp:947
SCH_ITEM * GetUndoItem() const
Schematic editor (Eeschema) main window.
void ClearBlockCommand()
Definition: base_screen.h:501
SCH_COLLECTOR m_collectedItems
List of collected items.
SCH_TEXT * CreateNewText(wxDC *aDC, int aType)
Definition: edit_label.cpp:66
void MirrorImage(SCH_BITMAP *aItem, bool Is_X_axis)
Mirror a bitmap.
virtual void HandleBlockPlace(wxDC *DC) override
Call after HandleBlockEnd, when a block command needs to be executed after the block is moved to its ...
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:264
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:361
void EditComponentFieldText(SCH_FIELD *aField)
Display the edit field dialog to edit the parameters of aField.
void EndSegment()
Terminate a bus, wire, or line creation.
SCH_ITEM * LocateItem(const wxPoint &aPosition, const KICAD_T aFilterList[]=SCH_COLLECTOR::AllItems, int aHotKeyCommandId=0)
Check 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:78
void PrepareMoveItem(SCH_ITEM *aItem, wxDC *aDC)
Start moving aItem using the mouse.
Definition: schedit.cpp:761
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
void InstallHierarchyFrame(wxPoint &pos)
Definition: hierarch.cpp:139
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.
virtual bool HandleBlockBegin(wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0)
Initialize a block command.
Definition: draw_frame.cpp:840
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
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)
Send a message to Pcbnew via a socket connection.
bool IsBlockActive() const
Definition: base_screen.h:499
wxPoint & GetStoredPos()
virtual wxPoint GetPosition() const =0
Function GetPosition.
int GetConnection(const wxPoint &aPosition, PICKED_ITEMS_LIST &aList, bool aFullConnection)
Adds all of the wires and junctions to aList that make up a connection to the object at aPosition...
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:282
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:498
virtual void SwapData(SCH_ITEM *aItem)
Function SwapData swap the internal data structures aItem with the schematic item.
bool DeleteItemAtCrossHair(wxDC *aDC)
Delete the item found under the cross hair.
Definition: schedit.cpp:643
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:622
void OnRotate(wxCommandEvent &aEvent)
Handle the ID_SCH_ROTATE_CLOCKWISE and ID_SCH_ROTATE_COUNTERCLOCKWISE events used to rotate schematic...
Definition: schedit.cpp:841
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: sch_screen.h:174
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:255
static const KICAD_T CmpFieldFootprintOnly[]
A scan list for a specific editable field: Footprint.
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
static const wxCursor CURSOR_PROBE
Probe cursor, used by circuit simulator
void RotateImage(SCH_BITMAP *aItem)
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:181
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:549
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:339
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
bool m_autoplaceFields
automatically place component fields
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
void OnCancelCurrentCommand(wxCommandEvent &aEvent)
Definition: schedit.cpp:473
static void moveItemWithMouseCursor(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Definition: schedit.cpp:670
static const KICAD_T EditableItems[]
A scan list for all editable schematic items.
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:452
void MoveImage(SCH_BITMAP *aItem, wxDC *aDC)
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:574
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:231
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.
Segment description base class to describe items which have 2 end points (track, wire, draw line ...)
Definition: sch_line.h:41
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()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
#define INSTALL_UNBUFFERED_DC(name, parent)
void OnLeftClick(wxDC *aDC, const wxPoint &aPosition) override
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
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:476
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 SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:182
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
void OnSelectTool(wxCommandEvent &aEvent)
Definition: schedit.cpp:495
void DeleteItemsInList(PICKED_ITEMS_LIST &aItemsList, bool aAppend=false)
Removes all items (and unused junctions that connect to them) and saves each in the undo list...
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:194
void EditImage(SCH_BITMAP *aItem)
virtual wxString GetClass() const override
Function GetClass returns the class name.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:283
BLOCK_COMMAND_T GetCommand() const
void OnDragItem(wxCommandEvent &aEvent)
Handle the ID_SCH_DRAG_ITEM event used to drag schematic items.
Definition: schedit.cpp:1070
SCH_SHEET_PIN * ImportSheetPin(SCH_SHEET *aSheet, wxDC *aDC)
Automatically create a sheet pin from the hierarchical labels in the schematic referenced by aSheet...
Definition: sheetlab.cpp:140
virtual bool HandleBlockEnd(wxDC *aDC) override
Handle the "end" of a block command, i.e.
void OnOrient(wxCommandEvent &aEvent)
Handle the ID_SCH_MIRROR_X, ID_SCH_MIRROR_Y, and ID_SCH_ORIENT_NORMAL events used to orient schematic...
Definition: schedit.cpp:1141
Some functions to handle hotkeys in KiCad.
bool EditSheet(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
Edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:45
void MirrorSheet(SCH_SHEET *aSheet, bool aFromXaxis)
Mirror a hierarchical sheet.
Definition: sheet.cpp:504
void SetUndoItem(const SCH_ITEM *aItem)
Clone aItem which can be used to restore the state of the item being edited when the user cancels the...
Definition for part library class.
bool IsWireImage() const
Definition: base_struct.h:249
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)
Display the dialog for editing the parameters of aSheetPin.
Definition: sheetlab.cpp:61
int GetDefaultCursor() const
Function GetDefaultCursor.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:105
#define VALUE
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:122
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:709
static const KICAD_T OrientableItems[]
A scan list for schematic items that can be mirrored.
void DeleteItem(SCH_ITEM *aItem, bool aAppend=false)
Remove aItem from the current screen and saves it in the undo list.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
void SetCommand(BLOCK_COMMAND_T aCommand)
void SaveWireImage()
Save a copy of the current wire image in the undo list.
void SelectAllFromSheet(wxCommandEvent &aEvent)
Handle the ID_POPUP_SCH_SELECT_ON_PCB event used to select items in Pcbnew based on the sheet they ar...
Definition: schedit.cpp:815
void ConvertPart(SCH_COMPONENT *DrawComponent, wxDC *DC)
Definition: getpart.cpp:390
#define IS_MOVED
Item being moved.
Definition: base_struct.h:126