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 <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 
128  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
129  break;
131  screen->m_BlockLocate.SetMessageBlock( this );
132  HandleBlockEnd( &dc );
133  SetRepeatItem( NULL );
135  break;
136 
137  case wxID_COPY: // really this is a Save block for paste
139  screen->m_BlockLocate.SetMessageBlock( this );
140  HandleBlockEnd( &dc );
141  break;
142 
143  case wxID_PASTE:
145  break;
146 
149  SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '/' );
150  break;
151 
154  SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '\\' );
155  break;
156 
158  if( m_canvas->IsMouseCaptured() )
159  {
161  SetToolID( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString );
162  }
163  else
164  {
166  }
167 
168  break;
169 
170  case ID_POPUP_END_LINE:
172  EndSegment();
173  break;
174 
178  break;
179 
183  break;
184 
186  // Not used
187  break;
188 
193  SchematicCleanUp( true );
194  screen->SetCurItem( NULL );
195  SetRepeatItem( NULL );
196 
197  screen->TestDanglingEnds();
198  m_canvas->Refresh();
199 
200  break;
201 
203  {
204  SaveWireImage();
207  if( screen->TestDanglingEnds() )
208  m_canvas->Refresh();
209  }
210  break;
211 
213  case ID_POPUP_SCH_DELETE:
214  if( item == NULL )
215  break;
216 
217  DeleteItem( item );
218  SchematicCleanUp( true );
219  screen->SetCurItem( NULL );
220  SetRepeatItem( NULL );
221  screen->TestDanglingEnds();
223  m_canvas->Refresh();
224  OnModify();
225  break;
226 
230  break;
231 
233  ReSizeSheet( (SCH_SHEET*) item, &dc );
234 
235  if( screen->TestDanglingEnds() )
236  m_canvas->Refresh();
237 
238  break;
239 
241  if( item != NULL && item->Type() == SCH_SHEET_T )
242  screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, &dc ) );
243  break;
244 
246  if( item != NULL && item->Type() == SCH_SHEET_T )
247  {
248  SCH_SHEET* sheet = (SCH_SHEET*) item;
249 
250  if( !sheet->HasUndefinedPins() )
251  {
252  DisplayInfoMessage( this,
253  _( "There are no undefined labels in this sheet to clean up." ) );
254  return;
255  }
256 
257  if( !IsOK( this, _( "Do you wish to cleanup this sheet?" ) ) )
258  return;
259 
260  /* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */
261  SaveCopyInUndoList( sheet, UR_CHANGED );
262  sheet->CleanupSheet();
263  OnModify();
265  }
266  break;
267 
270  break;
271 
273  // Ensure the struct is a component (could be a struct of a component, like Field, text..)
274  if( item && item->Type() == SCH_COMPONENT_T )
275  {
277  ConvertPart( (SCH_COMPONENT*) item, &dc );
278  }
279 
280  break;
281 
283  // Ensure the struct is a component (could be a piece of a component, like Field, text..)
284  if( item && item->Type() == SCH_COMPONENT_T )
285  {
286  wxString text = static_cast<SCH_COMPONENT*>( item )->
287  GetField( DATASHEET )->GetFullyQualifiedText();
288 
289  if( !text.IsEmpty() )
290  GetAssociatedDocument( this, text );
291  }
292  break;
293 
295 
296  if( item && (item->Type() == SCH_SHEET_T) )
297  {
298  m_CurrentSheet->push_back( (SCH_SHEET*) item );
300  }
301 
302  break;
303 
305  if( m_CurrentSheet->Last() != g_RootSheet )
306  {
307  m_CurrentSheet->pop_back();
309  }
310 
311  break;
312 
314  m_canvas->SetAutoPanRequest( false );
316  HandleBlockPlace( &dc );
317  break;
318 
319  case ID_POPUP_ZOOM_BLOCK:
321  screen->m_BlockLocate.SetMessageBlock( this );
322  HandleBlockEnd( &dc );
323  break;
324 
326  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
327  break;
328 
331  screen->m_BlockLocate.SetMessageBlock( this );
332  HandleBlockEnd( &dc );
334  break;
335 
337  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
338  break;
339 
342  screen->m_BlockLocate.SetMessageBlock( this );
343  HandleBlockEnd( &dc );
344  break;
345 
346  case ID_POPUP_DRAG_BLOCK:
347  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
348  break;
349 
352  screen->m_BlockLocate.SetMessageBlock( this );
353  HandleBlockEnd( &dc );
354  break;
355 
359 
360  if( screen->TestDanglingEnds() )
361  m_canvas->Refresh();
362 
363  screen->SetCurItem( NULL );
364  break;
365 
368  screen->SetCurItem( CreateNewText( &dc, id == ID_POPUP_SCH_ADD_LABEL ?
370  item = screen->GetCurItem();
371 
372  if( item )
374 
375  break;
376 
378  if( item && item->Type() == SCH_MARKER_T )
379  ( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
380 
381  break;
382 
383  default: // Log error:
384  wxFAIL_MSG( wxString::Format( wxT( "Cannot process command event ID %d" ),
385  event.GetId() ) );
386  break;
387  }
388 
389  // End switch ( id ) (Command execution)
390 
391  if( GetToolId() == ID_NO_TOOL_SELECTED )
392  SetRepeatItem( NULL );
393 }
394 
395 
396 void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
397 {
398  SCH_SCREEN* screen = GetScreen();
399  SCH_ITEM* item = screen->GetCurItem();
400 
401  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
402  {
403  // trying to move an item when there is a block at the same time is not acceptable
404  return;
405  }
406 
407  if( item == NULL )
408  {
409  // If we didn't get here by a hot key, then something has gone wrong.
410  if( aEvent.GetInt() == 0 )
411  return;
412 
413  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
414 
415  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
416 
418  aEvent.GetInt() );
419 
420  // Exit if no item found at the current location or the item is already being edited.
421  if( (item == NULL) || (item->GetFlags() != 0) )
422  return;
423  }
424 
426 
427  switch( item->Type() )
428  {
429  case SCH_LINE_T:
430  break;
431 
432  case SCH_JUNCTION_T:
433  case SCH_NO_CONNECT_T:
434  case SCH_BUS_BUS_ENTRY_T:
436  case SCH_LABEL_T:
437  case SCH_GLOBAL_LABEL_T:
439  case SCH_TEXT_T:
440  case SCH_COMPONENT_T:
441  case SCH_SHEET_PIN_T:
442  case SCH_FIELD_T:
443  case SCH_SHEET_T:
444  PrepareMoveItem( item, &dc );
445  break;
446 
447  case SCH_BITMAP_T:
448  // move an image is a special case:
449  // we cannot undraw/redraw a bitmap just using our xor mode
450  // the MoveImage function handle this undraw/redraw difficulty
451  // By redrawing the full bounding box
452  MoveImage( (SCH_BITMAP*) item, &dc );
453  break;
454 
455  case SCH_MARKER_T:
456  // Moving a marker has no sense
457  break;
458 
459  default:
460  // Unknown items cannot be moved
461  wxFAIL_MSG( wxString::Format(
462  wxT( "Cannot move item type %d" ), item->Type() ) );
463  break;
464  }
465 
466  if( GetToolId() == ID_NO_TOOL_SELECTED )
467  SetRepeatItem( NULL );
468 }
469 
470 
471 void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
472 {
473  SCH_SCREEN* screen = GetScreen();
474 
475  if( screen->IsBlockActive() )
476  {
477  m_canvas->SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() );
478  screen->ClearBlockCommand();
479 
480  // Stop the current command (if any) but keep the current tool
482  }
483  else
484  {
485  if( m_canvas->IsMouseCaptured() ) // Stop the current command but keep the current tool
487  else // Deselect current tool
489  }
490 }
491 
492 
493 void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
494 {
495  int id = aEvent.GetId();
496  int lastToolID = GetToolId();
497 
498  // Stop the current command and deselect the current tool.
500 
501  switch( id )
502  {
503  case ID_NO_TOOL_SELECTED:
505  break;
506 
507  case ID_HIGHLIGHT:
508  SetToolID( id, wxCURSOR_HAND, _("Highlight specific net") );
509  break;
510 
511  case ID_ZOOM_SELECTION:
512  // This tool is located on the main toolbar: switch it on or off on click
513  if( lastToolID != ID_ZOOM_SELECTION )
514  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
515  else
517  break;
518 
519  case ID_NOCONN_BUTT:
520  SetToolID( id, wxCURSOR_PENCIL, _( "Add no connect" ) );
521  break;
522 
523  case ID_WIRE_BUTT:
524  SetToolID( id, wxCURSOR_PENCIL, _( "Add wire" ) );
525  break;
526 
527  case ID_BUS_BUTT:
528  SetToolID( id, wxCURSOR_PENCIL, _( "Add bus" ) );
529  break;
530 
532  SetToolID( id, wxCURSOR_PENCIL, _( "Add lines" ) );
533  break;
534 
535  case ID_JUNCTION_BUTT:
536  SetToolID( id, wxCURSOR_PENCIL, _( "Add junction" ) );
537  break;
538 
539  case ID_LABEL_BUTT:
540  SetToolID( id, wxCURSOR_PENCIL, _( "Add label" ) );
541  break;
542 
543  case ID_GLABEL_BUTT:
544  SetToolID( id, wxCURSOR_PENCIL, _( "Add global label" ) );
545  break;
546 
547  case ID_HIERLABEL_BUTT:
548  SetToolID( id, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
549  break;
550 
552  SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
553  break;
554 
555  case ID_ADD_IMAGE_BUTT:
556  SetToolID( id, wxCURSOR_PENCIL, _( "Add image" ) );
557  break;
558 
560  SetToolID( id, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
561  break;
562 
564  SetToolID( id, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
565  break;
566 
568  SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet" ) );
569  break;
570 
571  case ID_SHEET_PIN_BUTT:
572  SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
573  break;
574 
576  SetToolID( id, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
577  break;
578 
580  SetToolID( id, wxCURSOR_PENCIL, _( "Add component" ) );
581  break;
582 
583  case ID_PLACE_POWER_BUTT:
584  SetToolID( id, wxCURSOR_PENCIL, _( "Add power" ) );
585  break;
586 
588  SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
589  break;
590 
591 #ifdef KICAD_SPICE
592  case ID_SIM_PROBE:
593  SetToolID( id, -1, _( "Add a simulator probe" ) );
594  m_canvas->SetCursor( CURSOR_PROBE );
595  break;
596 
597  case ID_SIM_TUNE:
598  SetToolID( id, -1, _( "Select a value to be tuned" ) );
599  m_canvas->SetCursor( CURSOR_TUNE );
600  break;
601 #endif /* KICAD_SPICE */
602 
603  default:
604  SetRepeatItem( NULL );
605  }
606 
607  // Simulate left click event if we got here from a hot key.
608  if( aEvent.GetClientObject() != NULL )
609  {
610  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
611 
612  wxPoint pos = data->GetPosition();
613 
615  OnLeftClick( &dc, pos );
616  }
617 }
618 
619 
620 void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
621 {
622  aEvent.Check( GetToolId() == aEvent.GetId() );
623 }
624 
625 
626 void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
627 {
628  PICKED_ITEMS_LIST pickList;
629  SCH_SCREEN* screen = GetScreen();
631 
632  if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
633  {
634  DeleteItemsInList( pickList );
635  SchematicCleanUp( true );
636  OnModify();
637  }
638 }
639 
640 
642 {
643  SCH_ITEM* item;
644  SCH_SCREEN* screen = GetScreen();
645 
647 
648  if( item )
649  {
650  bool itemHasConnections = item->IsConnectable();
651 
652  screen->SetCurItem( NULL );
653  SetRepeatItem( NULL );
654  DeleteItem( item );
655 
656  if( itemHasConnections && screen->TestDanglingEnds() )
657  m_canvas->Refresh();
658 
659  OnModify();
660  return true;
661  }
662 
663  return false;
664 }
665 
666 // This function is a callback function, called by the mouse cursor movin event
667 // when an item is currently moved
668 static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
669  const wxPoint& aPosition, bool aErase )
670 {
671  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
672  SCH_ITEM* item = screen->GetCurItem();
673 
674  wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) );
675 
676  SCH_COMPONENT* cmp = NULL;
677 
678  if( item->Type() == SCH_COMPONENT_T )
679  cmp = static_cast< SCH_COMPONENT* >( item );
680 
681 #ifndef USE_WX_OVERLAY
682  // Erase the current item at its current position.
683  if( aErase )
684  {
685  if( cmp ) // Use fast mode (do not draw pin texts)
686  cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, COLOR4D::UNSPECIFIED, false );
687  else
688  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
689  }
690 #endif
691 
692  wxPoint cpos = aPanel->GetParent()->GetCrossHairPosition();
693  cpos -= item->GetStoredPos();
694 
695  item->SetPosition( cpos );
696 
697  // Draw the item item at it's new position.
698  item->SetWireImage(); // While moving, the item may choose to render differently
699 
700  if( cmp ) // Use fast mode (do not draw pin texts)
701  cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, COLOR4D::UNSPECIFIED, false );
702  else
703  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
704 }
705 
706 
707 static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
708 {
709  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
710  SCH_ITEM* item = screen->GetCurItem();
711  SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
712 
713  parent->SetRepeatItem( NULL );
714  screen->SetCurItem( NULL );
715 
716  if( item == NULL ) /* no current item */
717  return;
718 
719  if( item->IsNew() )
720  {
721  delete item;
722  item = NULL;
723  }
724  else
725  {
726  SCH_ITEM* oldItem = parent->GetUndoItem();
727 
728  SCH_ITEM* currentItem;
729 
730  // Items that are children of other objects are undone by swapping the contents
731  // of the parent items.
732  if( (item->Type() == SCH_SHEET_PIN_T) || (item->Type() == SCH_FIELD_T) )
733  {
734  currentItem = (SCH_ITEM*) item->GetParent();
735  }
736  else
737  {
738  currentItem = item;
739  }
740 
741  wxCHECK_RET( oldItem != NULL && currentItem->Type() == oldItem->Type(),
742  wxT( "Cannot restore undefined or bad last schematic item." ) );
743 
744  // Never delete existing item, because it can be referenced by an undo/redo command
745  // Just restore its data
746  currentItem->SwapData( oldItem );
747 
748  // Erase the wire representation before the 'normal' view is drawn.
749  if ( item->IsWireImage() )
750  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
751 
752  item->ClearFlags();
753  }
754 
755  aPanel->Refresh();
756 }
757 
758 
759 void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC )
760 {
761  wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) );
762 
763  SetRepeatItem( NULL );
764 
765  if( !aItem->IsNew() )
766  {
767  if( (aItem->Type() == SCH_SHEET_PIN_T) || (aItem->Type() == SCH_FIELD_T) )
768  SetUndoItem( (SCH_ITEM*) aItem->GetParent() );
769  else
770  SetUndoItem( aItem );
771  }
772 
773  if( aItem->Type() == SCH_FIELD_T && aItem->GetParent()->Type() == SCH_COMPONENT_T )
774  {
775  // Now that we're moving a field, they're no longer autoplaced.
776  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( aItem->GetParent() );
777  parent->ClearFieldsAutoplaced();
778  }
779 
780  aItem->SetFlags( IS_MOVED );
781 
782  // For some items, moving the cursor to anchor is not good
783  // (for instance large hierarchical sheets od componants can have
784  // the anchor position outside the canvas)
785  // these items return IsMovableFromAnchorPoint() == false
786  // For these items, do not wrap the cursor
787  if( aItem->IsMovableFromAnchorPoint() )
788  {
789  SetCrossHairPosition( aItem->GetPosition() );
791  aItem->SetStoredPos( wxPoint( 0,0 ) );
792  }
793  else
794  {
795  // Round the point under the cursor to a multiple of the grid
796  wxPoint cursorpos = GetCrossHairPosition() - aItem->GetPosition();
797  wxPoint gridsize = GetScreen()->GetGridSize();
798  cursorpos.x = ( cursorpos.x / gridsize.x ) * gridsize.x;
799  cursorpos.y = ( cursorpos.y / gridsize.y ) * gridsize.y;
800 
801  aItem->SetStoredPos( cursorpos );
802  }
803 
804  OnModify();
805 
806  GetScreen()->SetCurItem( aItem );
808 
809  m_canvas->Refresh();
810 }
811 
812 
813 void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
814 {
815  SCH_SCREEN* screen = GetScreen();
816  SCH_ITEM* item = screen->GetCurItem();
817 
818  if( item != NULL )
819  {
820  item = LocateAndShowItem( item->GetPosition() );
821  SendMessageToPCBNEW( item, NULL );
822  }
823  else
824  {
825  // If we didn't get here by a hot key, then something has gone wrong.
826  if( aEvent.GetInt() == 0 )
827  return;
828 
829  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
830 
831  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
832 
833  item = LocateAndShowItem( data->GetPosition() );
834  SendMessageToPCBNEW( item, NULL );
835  }
836 }
837 
838 
839 void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
840 {
841  SCH_SCREEN* screen = GetScreen();
842  SCH_ITEM* item = screen->GetCurItem();
843 
845 
846  // Allows block rotate operation on hot key.
847  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
848  {
850  HandleBlockEnd( &dc );
851  return;
852  }
853 
854  if( item == NULL )
855  {
856  // If we didn't get here by a hot key, then something has gone wrong.
857  if( aEvent.GetInt() == 0 )
858  return;
859 
860  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
861 
862  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
863 
865  aEvent.GetInt() );
866 
867  // Exit if no item found at the current location or the item is already being edited.
868  if( (item == NULL) || (item->GetFlags() != 0) )
869  return;
870  }
871 
872  switch( item->Type() )
873  {
874  case SCH_COMPONENT_T:
875  {
876  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
877  if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
879  else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
881  else
882  wxFAIL_MSG( wxT( "Unknown rotate item command ID." ) );
883 
884  if( m_autoplaceFields )
885  component->AutoAutoplaceFields( GetScreen() );
886 
887  m_canvas->Refresh();
888 
889  break;
890  }
891 
892  case SCH_TEXT_T:
893  case SCH_LABEL_T:
894  case SCH_GLOBAL_LABEL_T:
897  ChangeTextOrient( (SCH_TEXT*) item );
898  m_canvas->Refresh();
899  break;
900 
901  case SCH_FIELD_T:
903  RotateField( (SCH_FIELD*) item );
904  if( item->GetParent()->Type() == SCH_COMPONENT_T )
905  {
906  // Now that we're moving a field, they're no longer autoplaced.
907  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( item->GetParent() );
908  parent->ClearFieldsAutoplaced();
909  }
910  m_canvas->Refresh();
911  break;
912 
913  case SCH_BITMAP_T:
914  RotateImage( (SCH_BITMAP*) item );
915  break;
916 
917  case SCH_SHEET_T:
918  if( !item->IsNew() ) // rotate a sheet during its creation has no sense
919  {
920  bool retCCW = ( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE );
921  RotateHierarchicalSheet( static_cast<SCH_SHEET*>( item ), retCCW );
922  }
923 
924  break;
925 
926  case SCH_JUNCTION_T:
927  case SCH_NO_CONNECT_T:
928  // these items are not rotated, because rotation does not change them.
929  break;
930 
931  default:
932  // Other items (wires...) cannot be rotated, at least during creation
933  if( item->IsNew() )
934  break;
935 
936  wxFAIL_MSG( wxString::Format( wxT( "Cannot rotate schematic item type %s." ),
937  GetChars( item->GetClass() ) ) );
938  }
939 
940  if( item->GetFlags() == 0 )
941  screen->SetCurItem( NULL );
942 }
943 
944 
945 void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
946 {
947  SCH_SCREEN* screen = GetScreen();
948  SCH_ITEM* item = screen->GetCurItem();
949 
950  if( item == NULL )
951  {
952  // If we didn't get here by a hot key, then something has gone wrong.
953  if( aEvent.GetInt() == 0 )
954  return;
955 
956  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
957 
958  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
959 
960  // Set the locat filter, according to the edit command
961  const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
962  const KICAD_T* filterListAux = NULL;
963 
964  switch( aEvent.GetId() )
965  {
968  filterListAux = SCH_COLLECTOR::ComponentsOnly;
969  break;
970 
973  filterListAux = SCH_COLLECTOR::ComponentsOnly;
974  break;
975 
978  filterListAux = SCH_COLLECTOR::ComponentsOnly;
979  break;
980 
981  default:
982  break;
983  }
984 
985  item = LocateAndShowItem( data->GetPosition(), filterList, aEvent.GetInt() );
986 
987  // If no item found, and if an auxiliary filter exists, try to use it
988  if( !item && filterListAux )
989  item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
990 
991  // Exit if no item found at the current location or the item is already being edited.
992  if( (item == NULL) || (item->GetFlags() != 0) )
993  return;
994  }
995 
996  switch( item->Type() )
997  {
998  case SCH_COMPONENT_T:
999  {
1000  switch( aEvent.GetId() )
1001  {
1003  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ) );
1004  break;
1005 
1007  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ) );
1008  break;
1009 
1011  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ) );
1012  break;
1013 
1014  case ID_SCH_EDIT_ITEM:
1015  EditComponent( (SCH_COMPONENT*) item );
1016  break;
1017 
1018  default:
1019  wxFAIL_MSG( wxString::Format( wxT( "Invalid schematic component edit command ID %d" ),
1020  aEvent.GetId() ) );
1021  }
1022 
1023  break;
1024  }
1025 
1026  case SCH_SHEET_T:
1027  if( EditSheet( (SCH_SHEET*) item, m_CurrentSheet ) )
1028  m_canvas->Refresh();
1029  break;
1030 
1031  case SCH_SHEET_PIN_T:
1032  EditSheetPin( (SCH_SHEET_PIN*) item, true );
1033  break;
1034 
1035  case SCH_TEXT_T:
1036  case SCH_LABEL_T:
1037  case SCH_GLOBAL_LABEL_T:
1039  EditSchematicText( (SCH_TEXT*) item );
1040  break;
1041 
1042  case SCH_FIELD_T:
1043  EditComponentFieldText( (SCH_FIELD*) item );
1044  break;
1045 
1046  case SCH_BITMAP_T:
1047  EditImage( (SCH_BITMAP*) item );
1048  break;
1049 
1050  case SCH_LINE_T: // These items have no param to edit
1051  EditLine( (SCH_LINE*) item, true );
1052  break;
1053  case SCH_MARKER_T:
1054  case SCH_JUNCTION_T:
1055  case SCH_NO_CONNECT_T:
1056  break;
1057 
1058  default: // Unexpected item
1059  wxFAIL_MSG( wxString::Format( wxT( "Cannot edit schematic item type %s." ),
1060  GetChars( item->GetClass() ) ) );
1061  }
1062 
1063  if( item->GetFlags() == 0 )
1064  screen->SetCurItem( NULL );
1065 }
1066 
1067 
1068 void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
1069 {
1070  SCH_SCREEN* screen = GetScreen();
1071  SCH_ITEM* item = screen->GetCurItem();
1072 
1073  // The easiest way to handle a menu or a hot key drag command
1074  // is to simulate a block drag command
1075  //
1076  // When a drag item is requested, some items use a BLOCK_DRAG_ITEM drag type
1077  // an some items use a BLOCK_DRAG drag type (mainly a junction)
1078  // a BLOCK_DRAG collects all items in a block (here a 2x2 rect centered on the cursor)
1079  // and BLOCK_DRAG_ITEM drag only the selected item
1080  BLOCK_COMMAND_T dragType = BLOCK_DRAG_ITEM;
1081 
1082  if( item == NULL )
1083  {
1084  // If we didn't get here by a hot key, then something has gone wrong.
1085  if( aEvent.GetInt() == 0 )
1086  return;
1087 
1088  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1089 
1090  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1091 
1093  aEvent.GetInt() );
1094 
1095  // Exit if no item found at the current location or the item is already being edited.
1096  if( (item == NULL) || (item->GetFlags() != 0) )
1097  return;
1098 
1099  // When a junction or a node is found, a BLOCK_DRAG is better
1102  dragType = BLOCK_DRAG;
1103  }
1104 
1105  switch( item->Type() )
1106  {
1107  case SCH_BUS_BUS_ENTRY_T:
1108  case SCH_BUS_WIRE_ENTRY_T:
1109  case SCH_LINE_T:
1110  case SCH_JUNCTION_T:
1111  case SCH_COMPONENT_T:
1112  case SCH_LABEL_T:
1113  case SCH_GLOBAL_LABEL_T:
1115  case SCH_SHEET_T:
1117 
1118  if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1119  {
1121 
1122  if( !HandleBlockBegin( &dc, dragType, GetCrossHairPosition() ) )
1123  break;
1124 
1125  // Give a non null size to the search block:
1126  screen->m_BlockLocate.Inflate( 1 );
1127  HandleBlockEnd( &dc );
1128  }
1129 
1130  break;
1131 
1132  default:
1133  wxFAIL_MSG( wxString::Format( wxT( "Cannot drag schematic item type %s." ),
1134  GetChars( item->GetClass() ) ) );
1135  }
1136 }
1137 
1138 
1139 void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
1140 {
1141  SCH_SCREEN* screen = GetScreen();
1142  SCH_ITEM* item = screen->GetCurItem();
1143 
1145 
1146  // Allows block rotate operation on hot key.
1147  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
1148  {
1149  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1150  {
1152  screen->m_BlockLocate.SetMessageBlock( this );
1154  HandleBlockEnd( &dc );
1155  }
1156  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1157  {
1159  screen->m_BlockLocate.SetMessageBlock( this );
1161  HandleBlockEnd( &dc );
1162  }
1163  else
1164  {
1165  wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
1166  }
1167 
1168  return;
1169  }
1170 
1171  if( item == NULL )
1172  {
1173  // If we didn't get here by a hot key, then something has gone wrong.
1174  if( aEvent.GetInt() == 0 )
1175  return;
1176 
1177  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1178 
1179  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1180 
1182  aEvent.GetInt() );
1183 
1184  // Exit if no item found at the current location or the item is already being edited.
1185  if( (item == NULL) || (item->GetFlags() != 0) )
1186  return;
1187  }
1188 
1189 
1190  switch( item->Type() )
1191  {
1192  case SCH_COMPONENT_T:
1193  {
1194  SCH_COMPONENT *component = static_cast<SCH_COMPONENT*>( item );
1195  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1197  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1199  else if( aEvent.GetId() == ID_SCH_ORIENT_NORMAL )
1201  else
1202  wxFAIL_MSG( wxT( "Invalid orient schematic component command ID." ) );
1203 
1204  if( m_autoplaceFields )
1205  component->AutoAutoplaceFields( GetScreen() );
1206 
1207  m_canvas->Refresh();
1208 
1209  break;
1210  }
1211 
1212  case SCH_BITMAP_T:
1213  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1214  MirrorImage( (SCH_BITMAP*) item, true );
1215  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1216  MirrorImage( (SCH_BITMAP*) item, false );
1217 
1218  break;
1219 
1220  case SCH_SHEET_T:
1221  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1222  MirrorSheet( (SCH_SHEET*) item, true );
1223  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1224  MirrorSheet( (SCH_SHEET*) item, false );
1225 
1226  break;
1227 
1228  default:
1229  // This object cannot be oriented.
1230  ;
1231  }
1232 
1233  if( item->GetFlags() == 0 )
1234  screen->SetCurItem( NULL );
1235 }
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)
Rotate and mirror a component.
Definition: getpart.cpp:291
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:225
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:626
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:282
int EditLine(SCH_LINE *aLine, bool aRedraw)
Function EditLine displays the dialog for editing the parameters of aLine.
Definition: sch_line.cpp:763
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.
void OnMoveItem(wxCommandEvent &aEvent)
Handle the ID_SCH_MOVE_ITEM event used to move schematic items.
Definition: schedit.cpp:396
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:325
virtual bool IsMovableFromAnchorPoint()
Virtual function IsMovableFromAnchorPoint.
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:243
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Definition: schframe.cpp:773
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
Definition: schframe.h:1471
void addCurrentItemToList(bool aRedraw=true)
Add the item currently being edited to the schematic and adds the changes to the undo/redo container...
Definition: schframe.cpp:1356
EDA_ITEM * GetParent() const
Definition: base_struct.h:235
void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
BLOCK_COMMAND_T
static const KICAD_T ComponentsOnly[]
A scan list for schematic component items only.
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, const wxPathList *aPaths)
Function GetAssociatedDocument open a document (file) with the suitable browser.
Definition: eda_doc.cpp:86
void RefreshDrawingRect(const EDA_RECT &aRect, bool aEraseBackground=true)
Function RefreshDrawingRect redraws the contents of aRect in drawing units.
Definition: draw_panel.cpp:305
void RotateHierarchicalSheet(SCH_SHEET *aSheet, bool aRotCCW)
Rotate a sheet object.
Definition: sheet.cpp:464
void OnEditItem(wxCommandEvent &aEvent)
Handle the ID_SCH_EDIT_ITEM event used to edit schematic items.
Definition: schedit.cpp:945
SCH_ITEM * GetUndoItem() const
Definition: schframe.h:1379
Schematic editor (Eeschema) main window.
Definition: schframe.h:118
void ClearBlockCommand()
SCH_COLLECTOR m_collectedItems
List of collected items.
Definition: schframe.h:143
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:347
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:759
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Definition: schframe.cpp:471
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.
Definition: schframe.cpp:532
virtual bool HandleBlockBegin(wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0)
Initialize a block command.
Definition: draw_frame.cpp:834
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
Definition: schframe.h:121
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
SCH_ITEM * LocateAndShowItem(const wxPoint &aPosition, const KICAD_T aFilterList[]=SCH_COLLECTOR::AllItems, int aHotKeyCommandId=0)
Check the schematic at aPosition in logical (drawing) units for a item matching the types in aFilterL...
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:280
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:641
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:620
void OnRotate(wxCommandEvent &aEvent)
Handle the ID_SCH_ROTATE_CLOCKWISE and ID_SCH_ROTATE_COUNTERCLOCKWISE events used to rotate schematic...
Definition: schedit.cpp:839
SCH_ITEM * GetCurItem() const
Return 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:253
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
Definition: schframe.h:1468
void RotateImage(SCH_BITMAP *aItem)
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:104
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:174
void SetAutoPanRequest(bool aEnable)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
Definition: draw_frame.cpp:546
void EditSchematicText(SCH_TEXT *TextStruct)
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp: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
Definition: schframe.h:155
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:471
static void moveItemWithMouseCursor(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Definition: schedit.cpp:668
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:439
void MoveImage(SCH_BITMAP *aItem, wxDC *aDC)
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:571
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
bool HasUndefinedPins()
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp: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.
Definition: schframe.cpp:497
#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:877
static const KICAD_T CmpFieldReferenceOnly[]
A scan list for a specific editable field: Reference.
int GetToolId() const
Definition: draw_frame.h:465
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.
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
void OnSelectTool(wxCommandEvent &aEvent)
Definition: schedit.cpp:493
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:187
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:281
BLOCK_COMMAND_T GetCommand() const
void OnDragItem(wxCommandEvent &aEvent)
Handle the ID_SCH_DRAG_ITEM event used to drag schematic items.
Definition: schedit.cpp:1068
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:1139
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:491
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: schframe.cpp:591
Definition for part library class.
bool IsWireImage() const
Definition: base_struct.h:247
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.
#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:131
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:707
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:813
void ConvertPart(SCH_COMPONENT *DrawComponent, wxDC *DC)
Definition: getpart.cpp:381
#define IS_MOVED
Item being moved.
Definition: base_struct.h:126