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 )->GetField( DATASHEET )->GetText();
289  text = ResolveUriByEnvVars( text );
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_HIGHLIGHT, wxCURSOR_HAND, _("Highlight specific net") );
511  break;
512 
514  case ID_ZOOM_SELECTION:
515  // This tool is located on the main toolbar: switch it on or off on click
516  if( lastToolID != ID_ZOOM_SELECTION )
517  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
518  else
520  break;
521 
522  case ID_MENU_NOCONN_BUTT:
523  case ID_NOCONN_BUTT:
524  SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add no connect" ) );
525  break;
526 
527  case ID_MENU_WIRE_BUTT:
528  case ID_WIRE_BUTT:
529  SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
530  break;
531 
532  case ID_MENU_BUS_BUTT:
533  case ID_BUS_BUTT:
534  SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add bus" ) );
535  break;
536 
539  SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add lines" ) );
540  break;
541 
543  case ID_JUNCTION_BUTT:
544  SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add junction" ) );
545  break;
546 
547  case ID_MENU_LABEL_BUTT:
548  case ID_LABEL_BUTT:
549  SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add label" ) );
550  break;
551 
552  case ID_MENU_GLABEL_BUTT:
553  case ID_GLABEL_BUTT:
554  SetToolID( ID_GLABEL_BUTT, wxCURSOR_PENCIL, _( "Add global label" ) );
555  break;
556 
558  case ID_HIERLABEL_BUTT:
559  SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
560  break;
561 
564  SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) );
565  break;
566 
568  case ID_ADD_IMAGE_BUTT:
569  SetToolID( ID_ADD_IMAGE_BUTT, wxCURSOR_PENCIL, _( "Add image" ) );
570  break;
571 
574  SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
575  break;
576 
579  SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
580  break;
581 
584  SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add sheet" ) );
585  break;
586 
588  case ID_SHEET_PIN_BUTT:
589  SetToolID( ID_SHEET_PIN_BUTT, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
590  break;
591 
594  SetToolID( ID_IMPORT_HLABEL_BUTT, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
595  break;
596 
599  SetToolID( ID_SCH_PLACE_COMPONENT, wxCURSOR_PENCIL, _( "Add component" ) );
600  break;
601 
603  case ID_PLACE_POWER_BUTT:
604  SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add power" ) );
605  break;
606 
609  SetToolID( ID_SCHEMATIC_DELETE_ITEM_BUTT, wxCURSOR_BULLSEYE, _( "Delete item" ) );
610  break;
611 
612 #ifdef KICAD_SPICE
613  case ID_SIM_PROBE:
614  SetToolID( id, -1, _( "Add a simulator probe" ) );
615  m_canvas->SetCursor( CURSOR_PROBE );
616  break;
617 
618  case ID_SIM_TUNE:
619  SetToolID( id, -1, _( "Select a value to be tuned" ) );
620  m_canvas->SetCursor( CURSOR_TUNE );
621  break;
622 #endif /* KICAD_SPICE */
623 
624  default:
625  SetRepeatItem( NULL );
626  }
627 
628  // Simulate left click event if we got here from a hot key.
629  if( aEvent.GetClientObject() != NULL )
630  {
631  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
632 
633  wxPoint pos = data->GetPosition();
634 
636  OnLeftClick( &dc, pos );
637  }
638 }
639 
640 
641 void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
642 {
643  if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar )
644  aEvent.Check( GetToolId() == aEvent.GetId() );
645 }
646 
647 
648 void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
649 {
650  PICKED_ITEMS_LIST pickList;
651  SCH_SCREEN* screen = GetScreen();
653 
654  if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
655  {
656  DeleteItemsInList( pickList );
657  SchematicCleanUp( true );
658  OnModify();
659  }
660 }
661 
662 
664 {
665  SCH_ITEM* item;
666  SCH_SCREEN* screen = GetScreen();
667 
669 
670  if( item )
671  {
672  bool itemHasConnections = item->IsConnectable();
673 
674  screen->SetCurItem( NULL );
675  SetRepeatItem( NULL );
676  DeleteItem( item );
677 
678  if( itemHasConnections && screen->TestDanglingEnds() )
679  m_canvas->Refresh();
680 
681  OnModify();
682  return true;
683  }
684 
685  return false;
686 }
687 
688 // This function is a callback function, called by the mouse cursor movin event
689 // when an item is currently moved
690 static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
691  const wxPoint& aPosition, bool aErase )
692 {
693  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
694  SCH_ITEM* item = screen->GetCurItem();
695 
696  wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) );
697 
698  SCH_COMPONENT* cmp = NULL;
699 
700  if( item->Type() == SCH_COMPONENT_T )
701  cmp = static_cast< SCH_COMPONENT* >( item );
702 
703 #ifndef USE_WX_OVERLAY
704  // Erase the current item at its current position.
705  if( aErase )
706  {
707  if( cmp ) // Use fast mode (do not draw pin texts)
708  cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, COLOR4D::UNSPECIFIED, false );
709  else
710  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
711  }
712 #endif
713 
714  wxPoint cpos = aPanel->GetParent()->GetCrossHairPosition();
715  cpos -= item->GetStoredPos();
716 
717  item->SetPosition( cpos );
718 
719  // Draw the item item at it's new position.
720  item->SetWireImage(); // While moving, the item may choose to render differently
721 
722  if( cmp ) // Use fast mode (do not draw pin texts)
723  cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, COLOR4D::UNSPECIFIED, false );
724  else
725  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
726 }
727 
728 
729 static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
730 {
731  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
732  SCH_ITEM* item = screen->GetCurItem();
733  SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
734 
735  parent->SetRepeatItem( NULL );
736  screen->SetCurItem( NULL );
737 
738  if( item == NULL ) /* no current item */
739  return;
740 
741  if( item->IsNew() )
742  {
743  delete item;
744  item = NULL;
745  }
746  else
747  {
748  SCH_ITEM* oldItem = parent->GetUndoItem();
749 
750  SCH_ITEM* currentItem;
751 
752  // Items that are children of other objects are undone by swapping the contents
753  // of the parent items.
754  if( (item->Type() == SCH_SHEET_PIN_T) || (item->Type() == SCH_FIELD_T) )
755  {
756  currentItem = (SCH_ITEM*) item->GetParent();
757  }
758  else
759  {
760  currentItem = item;
761  }
762 
763  wxCHECK_RET( oldItem != NULL && currentItem->Type() == oldItem->Type(),
764  wxT( "Cannot restore undefined or bad last schematic item." ) );
765 
766  // Never delete existing item, because it can be referenced by an undo/redo command
767  // Just restore its data
768  currentItem->SwapData( oldItem );
769 
770  // Erase the wire representation before the 'normal' view is drawn.
771  if ( item->IsWireImage() )
772  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
773 
774  item->ClearFlags();
775  }
776 
777  aPanel->Refresh();
778 }
779 
780 
781 void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC )
782 {
783  wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) );
784 
785  SetRepeatItem( NULL );
786 
787  if( !aItem->IsNew() )
788  {
789  if( (aItem->Type() == SCH_SHEET_PIN_T) || (aItem->Type() == SCH_FIELD_T) )
790  SetUndoItem( (SCH_ITEM*) aItem->GetParent() );
791  else
792  SetUndoItem( aItem );
793  }
794 
795  if( aItem->Type() == SCH_FIELD_T && aItem->GetParent()->Type() == SCH_COMPONENT_T )
796  {
797  // Now that we're moving a field, they're no longer autoplaced.
798  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( aItem->GetParent() );
799  parent->ClearFieldsAutoplaced();
800  }
801 
802  aItem->SetFlags( IS_MOVED );
803 
804  // For some items, moving the cursor to anchor is not good
805  // (for instance large hierarchical sheets od componants can have
806  // the anchor position outside the canvas)
807  // these items return IsMovableFromAnchorPoint() == false
808  // For these items, do not wrap the cursor
809  if( aItem->IsMovableFromAnchorPoint() )
810  {
811  SetCrossHairPosition( aItem->GetPosition() );
813  aItem->SetStoredPos( wxPoint( 0,0 ) );
814  }
815  else
816  {
817  // Round the point under the cursor to a multiple of the grid
818  wxPoint cursorpos = GetCrossHairPosition() - aItem->GetPosition();
819  wxPoint gridsize = GetScreen()->GetGridSize();
820  cursorpos.x = ( cursorpos.x / gridsize.x ) * gridsize.x;
821  cursorpos.y = ( cursorpos.y / gridsize.y ) * gridsize.y;
822 
823  aItem->SetStoredPos( cursorpos );
824  }
825 
826  OnModify();
827 
828  GetScreen()->SetCurItem( aItem );
830 
831  m_canvas->Refresh();
832 }
833 
834 
835 void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
836 {
837  SCH_SCREEN* screen = GetScreen();
838  SCH_ITEM* item = screen->GetCurItem();
839 
840  if( item != NULL )
841  {
842  item = LocateAndShowItem( item->GetPosition() );
843  SendMessageToPCBNEW( item, NULL );
844  }
845  else
846  {
847  // If we didn't get here by a hot key, then something has gone wrong.
848  if( aEvent.GetInt() == 0 )
849  return;
850 
851  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
852 
853  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
854 
855  item = LocateAndShowItem( data->GetPosition() );
856  SendMessageToPCBNEW( item, NULL );
857  }
858 }
859 
860 
861 void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
862 {
863  SCH_SCREEN* screen = GetScreen();
864  SCH_ITEM* item = screen->GetCurItem();
865 
867 
868  // Allows block rotate operation on hot key.
869  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
870  {
872  HandleBlockEnd( &dc );
873  return;
874  }
875 
876  if( item == NULL )
877  {
878  // If we didn't get here by a hot key, then something has gone wrong.
879  if( aEvent.GetInt() == 0 )
880  return;
881 
882  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
883 
884  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
885 
887  aEvent.GetInt() );
888 
889  // Exit if no item found at the current location or the item is already being edited.
890  if( (item == NULL) || (item->GetFlags() != 0) )
891  return;
892  }
893 
894  switch( item->Type() )
895  {
896  case SCH_COMPONENT_T:
897  {
898  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
899  if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
901  else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
903  else
904  wxFAIL_MSG( wxT( "Unknown rotate item command ID." ) );
905 
906  if( m_autoplaceFields )
907  component->AutoAutoplaceFields( GetScreen() );
908 
909  m_canvas->Refresh();
910 
911  break;
912  }
913 
914  case SCH_TEXT_T:
915  case SCH_LABEL_T:
916  case SCH_GLOBAL_LABEL_T:
919  ChangeTextOrient( (SCH_TEXT*) item );
920  m_canvas->Refresh();
921  break;
922 
923  case SCH_FIELD_T:
925  RotateField( (SCH_FIELD*) item );
926  if( item->GetParent()->Type() == SCH_COMPONENT_T )
927  {
928  // Now that we're moving a field, they're no longer autoplaced.
929  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( item->GetParent() );
930  parent->ClearFieldsAutoplaced();
931  }
932  m_canvas->Refresh();
933  break;
934 
935  case SCH_BITMAP_T:
936  RotateImage( (SCH_BITMAP*) item );
937  break;
938 
939  case SCH_SHEET_T:
940  if( !item->IsNew() ) // rotate a sheet during its creation has no sense
941  {
942  bool retCCW = ( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE );
943  RotateHierarchicalSheet( static_cast<SCH_SHEET*>( item ), retCCW );
944  }
945 
946  break;
947 
948  case SCH_JUNCTION_T:
949  case SCH_NO_CONNECT_T:
950  // these items are not rotated, because rotation does not change them.
951  break;
952 
953  default:
954  // Other items (wires...) cannot be rotated, at least during creation
955  if( item->IsNew() )
956  break;
957 
958  wxFAIL_MSG( wxString::Format( wxT( "Cannot rotate schematic item type %s." ),
959  GetChars( item->GetClass() ) ) );
960  }
961 
962  if( item->GetFlags() == 0 )
963  screen->SetCurItem( NULL );
964 }
965 
966 
967 void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
968 {
969  SCH_SCREEN* screen = GetScreen();
970  SCH_ITEM* item = screen->GetCurItem();
971 
972  if( item == NULL )
973  {
974  // If we didn't get here by a hot key, then something has gone wrong.
975  if( aEvent.GetInt() == 0 )
976  return;
977 
978  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
979 
980  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
981 
982  // Set the locat filter, according to the edit command
983  const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
984  const KICAD_T* filterListAux = NULL;
985 
986  switch( aEvent.GetId() )
987  {
990  filterListAux = SCH_COLLECTOR::ComponentsOnly;
991  break;
992 
995  filterListAux = SCH_COLLECTOR::ComponentsOnly;
996  break;
997 
1000  filterListAux = SCH_COLLECTOR::ComponentsOnly;
1001  break;
1002 
1003  default:
1004  break;
1005  }
1006 
1007  item = LocateAndShowItem( data->GetPosition(), filterList, aEvent.GetInt() );
1008 
1009  // If no item found, and if an auxiliary filter exists, try to use it
1010  if( !item && filterListAux )
1011  item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
1012 
1013  // Exit if no item found at the current location or the item is already being edited.
1014  if( (item == NULL) || (item->GetFlags() != 0) )
1015  return;
1016  }
1017 
1018  switch( item->Type() )
1019  {
1020  case SCH_COMPONENT_T:
1021  {
1022  switch( aEvent.GetId() )
1023  {
1025  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ) );
1026  break;
1027 
1029  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ) );
1030  break;
1031 
1033  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ) );
1034  break;
1035 
1036  case ID_SCH_EDIT_ITEM:
1037  EditComponent( (SCH_COMPONENT*) item );
1038  break;
1039 
1040  default:
1041  wxFAIL_MSG( wxString::Format( wxT( "Invalid schematic component edit command ID %d" ),
1042  aEvent.GetId() ) );
1043  }
1044 
1045  break;
1046  }
1047 
1048  case SCH_SHEET_T:
1049  if( EditSheet( (SCH_SHEET*) item, m_CurrentSheet ) )
1050  m_canvas->Refresh();
1051  break;
1052 
1053  case SCH_SHEET_PIN_T:
1054  EditSheetPin( (SCH_SHEET_PIN*) item, true );
1055  break;
1056 
1057  case SCH_TEXT_T:
1058  case SCH_LABEL_T:
1059  case SCH_GLOBAL_LABEL_T:
1061  EditSchematicText( (SCH_TEXT*) item );
1062  break;
1063 
1064  case SCH_FIELD_T:
1065  EditComponentFieldText( (SCH_FIELD*) item );
1066  break;
1067 
1068  case SCH_BITMAP_T:
1069  EditImage( (SCH_BITMAP*) item );
1070  break;
1071 
1072  case SCH_LINE_T: // These items have no param to edit
1073  EditLine( (SCH_LINE*) item, true );
1074  break;
1075  case SCH_MARKER_T:
1076  case SCH_JUNCTION_T:
1077  case SCH_NO_CONNECT_T:
1078  break;
1079 
1080  default: // Unexpected item
1081  wxFAIL_MSG( wxString::Format( wxT( "Cannot edit schematic item type %s." ),
1082  GetChars( item->GetClass() ) ) );
1083  }
1084 
1085  if( item->GetFlags() == 0 )
1086  screen->SetCurItem( NULL );
1087 }
1088 
1089 
1090 void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
1091 {
1092  SCH_SCREEN* screen = GetScreen();
1093  SCH_ITEM* item = screen->GetCurItem();
1094 
1095  // The easiest way to handle a menu or a hot key drag command
1096  // is to simulate a block drag command
1097  //
1098  // When a drag item is requested, some items use a BLOCK_DRAG_ITEM drag type
1099  // an some items use a BLOCK_DRAG drag type (mainly a junction)
1100  // a BLOCK_DRAG collects all items in a block (here a 2x2 rect centered on the cursor)
1101  // and BLOCK_DRAG_ITEM drag only the selected item
1102  BLOCK_COMMAND_T dragType = BLOCK_DRAG_ITEM;
1103 
1104  if( item == NULL )
1105  {
1106  // If we didn't get here by a hot key, then something has gone wrong.
1107  if( aEvent.GetInt() == 0 )
1108  return;
1109 
1110  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1111 
1112  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1113 
1115  aEvent.GetInt() );
1116 
1117  // Exit if no item found at the current location or the item is already being edited.
1118  if( (item == NULL) || (item->GetFlags() != 0) )
1119  return;
1120 
1121  // When a junction or a node is found, a BLOCK_DRAG is better
1124  dragType = BLOCK_DRAG;
1125  }
1126 
1127  switch( item->Type() )
1128  {
1129  case SCH_BUS_BUS_ENTRY_T:
1130  case SCH_BUS_WIRE_ENTRY_T:
1131  case SCH_LINE_T:
1132  case SCH_JUNCTION_T:
1133  case SCH_COMPONENT_T:
1134  case SCH_LABEL_T:
1135  case SCH_GLOBAL_LABEL_T:
1137  case SCH_SHEET_T:
1139 
1140  if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1141  {
1143 
1144  if( !HandleBlockBegin( &dc, dragType, GetCrossHairPosition() ) )
1145  break;
1146 
1147  // Give a non null size to the search block:
1148  screen->m_BlockLocate.Inflate( 1 );
1149  HandleBlockEnd( &dc );
1150  }
1151 
1152  break;
1153 
1154  default:
1155  wxFAIL_MSG( wxString::Format( wxT( "Cannot drag schematic item type %s." ),
1156  GetChars( item->GetClass() ) ) );
1157  }
1158 }
1159 
1160 
1161 void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
1162 {
1163  SCH_SCREEN* screen = GetScreen();
1164  SCH_ITEM* item = screen->GetCurItem();
1165 
1167 
1168  // Allows block rotate operation on hot key.
1169  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
1170  {
1171  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1172  {
1174  screen->m_BlockLocate.SetMessageBlock( this );
1176  HandleBlockEnd( &dc );
1177  }
1178  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1179  {
1181  screen->m_BlockLocate.SetMessageBlock( this );
1183  HandleBlockEnd( &dc );
1184  }
1185  else
1186  {
1187  wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
1188  }
1189 
1190  return;
1191  }
1192 
1193  if( item == NULL )
1194  {
1195  // If we didn't get here by a hot key, then something has gone wrong.
1196  if( aEvent.GetInt() == 0 )
1197  return;
1198 
1199  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1200 
1201  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1202 
1204  aEvent.GetInt() );
1205 
1206  // Exit if no item found at the current location or the item is already being edited.
1207  if( (item == NULL) || (item->GetFlags() != 0) )
1208  return;
1209  }
1210 
1211 
1212  switch( item->Type() )
1213  {
1214  case SCH_COMPONENT_T:
1215  {
1216  SCH_COMPONENT *component = static_cast<SCH_COMPONENT*>( item );
1217  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1219  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1221  else if( aEvent.GetId() == ID_SCH_ORIENT_NORMAL )
1223  else
1224  wxFAIL_MSG( wxT( "Invalid orient schematic component command ID." ) );
1225 
1226  if( m_autoplaceFields )
1227  component->AutoAutoplaceFields( GetScreen() );
1228 
1229  m_canvas->Refresh();
1230 
1231  break;
1232  }
1233 
1234  case SCH_BITMAP_T:
1235  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1236  MirrorImage( (SCH_BITMAP*) item, true );
1237  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1238  MirrorImage( (SCH_BITMAP*) item, false );
1239 
1240  break;
1241 
1242  case SCH_SHEET_T:
1243  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1244  MirrorSheet( (SCH_SHEET*) item, true );
1245  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1246  MirrorSheet( (SCH_SHEET*) item, false );
1247 
1248  break;
1249 
1250  default:
1251  // This object cannot be oriented.
1252  ;
1253  }
1254 
1255  if( item->GetFlags() == 0 )
1256  screen->SetCurItem( NULL );
1257 }
Definition of the SCH_SHEET class for Eeschema.
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
void OrientComponent(COMPONENT_ORIENTATION_T aOrientation=CMP_NORMAL)
Rotate and mirror a component.
Definition: getpart.cpp:302
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:209
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:648
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:266
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.
const wxString ResolveUriByEnvVars(const wxString &aUri)
Function ResolveUriByEnvVars replaces any environment variables in file-path uris (leaving network-pa...
Definition: common.cpp:269
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:338
virtual bool IsMovableFromAnchorPoint()
Virtual function IsMovableFromAnchorPoint.
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:227
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:219
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:87
void RefreshDrawingRect(const EDA_RECT &aRect, bool aEraseBackground=true)
Function RefreshDrawingRect redraws the contents of aRect in drawing units.
Definition: draw_panel.cpp:318
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:967
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:360
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:781
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:882
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:264
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:499
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:663
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:641
void OnRotate(wxCommandEvent &aEvent)
Handle the ID_SCH_ROTATE_CLOCKWISE and ID_SCH_ROTATE_COUNTERCLOCKWISE events used to rotate schematic...
Definition: schedit.cpp:861
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:237
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:180
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:591
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:340
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:135
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
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:690
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:616
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:98
bool HasUndefinedPins()
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:232
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:913
static const KICAD_T CmpFieldReferenceOnly[]
A scan list for a specific editable field: Reference.
int GetToolId() const
Definition: draw_frame.h:488
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:193
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:265
BLOCK_COMMAND_T GetCommand() const
void OnDragItem(wxCommandEvent &aEvent)
Handle the ID_SCH_DRAG_ITEM event used to drag schematic items.
Definition: schedit.cpp:1090
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:1161
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:508
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:231
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:216
#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:233
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:729
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:835
void ConvertPart(SCH_COMPONENT *DrawComponent, wxDC *DC)
Definition: getpart.cpp:395
#define IS_MOVED
Item being moved.
Definition: base_struct.h:108