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