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 <sch_draw_panel.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 #include <sch_view.h>
53 
54 
55 void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
56 {
57  int id = event.GetId();
58  wxPoint pos;
59  SCH_SCREEN* screen = GetScreen();
60  SCH_ITEM* item = screen->GetCurItem();
61 
62  pos = wxGetMousePosition();
63 
64  pos.y += 20;
65 
66  // If needed, stop the current command and deselect current tool
67  switch( id )
68  {
69  case wxID_CUT:
70  case wxID_COPY:
76  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 
116 
117  //INSTALL_UNBUFFERED_DC( dc, m_canvas );
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: // save and delete block
128  case ID_POPUP_CUT_BLOCK:
129 
130  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
131  break;
133  screen->m_BlockLocate.SetMessageBlock( this );
134  HandleBlockEnd( nullptr );
135  SetRepeatItem( NULL );
137  break;
138 
139  case wxID_COPY: // really this is a Save block for paste
140  case ID_POPUP_COPY_BLOCK:
142  screen->m_BlockLocate.SetMessageBlock( this );
143  HandleBlockEnd( nullptr );
144  break;
145 
146  case wxID_PASTE:
149  break;
150 
153  SetBusEntryShape( nullptr, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '/' );
154  break;
155 
158  SetBusEntryShape( nullptr, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '\\' );
159  break;
160 
162  if( m_canvas->IsMouseCaptured() )
163  {
165  SetToolID( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString );
166  }
167  else
168  {
170  }
171 
172  break;
173 
174  case ID_POPUP_END_LINE:
176  EndSegment();
177  break;
178 
181  OnLeftClick( nullptr, GetCrossHairPosition() );
182  break;
183 
186  OnLeftClick( nullptr, GetCrossHairPosition() );
187  break;
188 
190  // Not used
191  break;
192 
197  SchematicCleanUp( true );
198  screen->SetCurItem( NULL );
199  SetRepeatItem( NULL );
200 
202  m_canvas->Refresh();
203 
204  break;
205 
207  SaveWireImage();
210 
212  m_canvas->Refresh();
213 
214  break;
215 
217  case ID_POPUP_SCH_DELETE:
218  if( item == NULL )
219  break;
220 
221  DeleteItem( item );
222  SchematicCleanUp( true );
223  screen->SetCurItem( NULL );
224  SetRepeatItem( NULL );
227  GetCanvas()->Refresh();
228  OnModify();
229  break;
230 
234  break;
235 
237  ReSizeSheet( (SCH_SHEET*) item, nullptr );
238 
240  m_canvas->Refresh();
241 
242  break;
243 
245  if( item != NULL && item->Type() == SCH_SHEET_T )
246  screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item ) );
247  break;
248 
250  if( item != NULL && item->Type() == SCH_SHEET_T )
251  {
252  SCH_SHEET* sheet = (SCH_SHEET*) item;
253 
254  if( !sheet->HasUndefinedPins() )
255  {
256  DisplayInfoMessage( this, _( "There are no undefined labels in this sheet to clean up." ) );
257  return;
258  }
259 
260  if( !IsOK( this, _( "Do you wish to cleanup this sheet?" ) ) )
261  return;
262 
263  /* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */
264  SaveCopyInUndoList( sheet, UR_CHANGED );
265  sheet->CleanupSheet();
266  SyncView();
267  GetCanvas()->Refresh();
268  OnModify();
269  }
270  break;
271 
274  break;
275 
277  // Ensure the struct is a component (could be a struct of a component, like Field, text..)
278  if( item && item->Type() == SCH_COMPONENT_T )
279  {
281  ConvertPart( (SCH_COMPONENT*) item );
282  }
283 
284  break;
285 
287 
288  if( item && (item->Type() == SCH_SHEET_T) )
289  {
290  m_CurrentSheet->push_back( (SCH_SHEET*) item );
292  }
293 
294  break;
295 
297  if( m_CurrentSheet->Last() != g_RootSheet )
298  {
299  m_CurrentSheet->pop_back();
301  }
302 
303  break;
304 
306  m_canvas->SetAutoPanRequest( false );
308  HandleBlockPlace( nullptr );
309  break;
310 
311  case ID_POPUP_ZOOM_BLOCK:
313  screen->m_BlockLocate.SetMessageBlock( this );
314  HandleBlockEnd( nullptr );
315  break;
316 
318  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
319  break;
320 
323  screen->m_BlockLocate.SetMessageBlock( this );
324  HandleBlockEnd( nullptr );
326  break;
327 
329  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
330  break;
331 
334  screen->m_BlockLocate.SetMessageBlock( this );
335  HandleBlockEnd( nullptr );
336  break;
337 
338  case ID_POPUP_DRAG_BLOCK:
339  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
340  break;
341 
344  screen->m_BlockLocate.SetMessageBlock( this );
345  HandleBlockEnd( nullptr );
346  break;
347 
351 
353  m_canvas->Refresh();
354 
355  screen->SetCurItem( NULL );
356  break;
357 
361  : LAYER_GLOBLABEL ) );
362  item = screen->GetCurItem();
363 
364  if( item )
366 
367  break;
368 
370  if( item && item->Type() == SCH_MARKER_T )
371  ( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
372 
373  break;
374 
375  default: // Log error:
376  wxFAIL_MSG( wxString::Format( "Cannot process command event ID %d", event.GetId() ) );
377  break;
378  }
379 
380  // End switch ( id ) (Command execution)
381 
382  if( GetToolId() == ID_NO_TOOL_SELECTED )
383  SetRepeatItem( NULL );
384 }
385 
386 
387 void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
388 {
389  SCH_SCREEN* screen = GetScreen();
390  SCH_ITEM* item = screen->GetCurItem();
391 
392  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
393  {
394  // trying to move an item when there is a block at the same time is not acceptable
395  return;
396  }
397 
398  if( item == NULL )
399  {
400  // If we didn't get here by a hot key, then something has gone wrong.
401  if( aEvent.GetInt() == 0 )
402  return;
403 
404  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
405 
406  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
407 
409  aEvent.GetInt() );
410 
411  // Exit if no item found at the current location or the item is already being edited.
412  if( (item == NULL) || (item->GetFlags() != 0) )
413  return;
414  }
415 
417 
418  switch( item->Type() )
419  {
420  case SCH_LINE_T:
421  break;
422 
423  case SCH_JUNCTION_T:
424  case SCH_NO_CONNECT_T:
425  case SCH_BUS_BUS_ENTRY_T:
427  case SCH_LABEL_T:
428  case SCH_GLOBAL_LABEL_T:
430  case SCH_TEXT_T:
431  case SCH_COMPONENT_T:
432  case SCH_SHEET_PIN_T:
433  case SCH_FIELD_T:
434  case SCH_SHEET_T:
435  case SCH_BITMAP_T:
436  PrepareMoveItem( item );
437  break;
438 
439 /* case SCH_BITMAP_T:
440  // move an image is a special case:
441  // we cannot undraw/redraw a bitmap just using our xor mode
442  // the MoveImage function handle this undraw/redraw difficulty
443  // By redrawing the full bounding box
444  MoveImage( (SCH_BITMAP*) item, &dc );
445  break;
446 */
447  case SCH_MARKER_T:
448  // Moving a marker has no sense
449  break;
450 
451  default:
452  // Unknown items cannot be moved
453  wxFAIL_MSG( wxString::Format( "Cannot move item type %d", item->Type() ) );
454  break;
455  }
456 
457  if( GetToolId() == ID_NO_TOOL_SELECTED )
458  SetRepeatItem( NULL );
459 }
460 
461 
462 void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
463 {
464  SCH_SCREEN* screen = GetScreen();
465 
466  if( screen->IsBlockActive() )
467  {
468  GetCanvas()->SetCursor( (wxStockCursor) GetGalCanvas()->GetDefaultCursor() );
469  screen->ClearBlockCommand();
470 
471  // Stop the current command (if any) but keep the current tool
473  }
474  else
475  {
476  if( m_canvas->IsMouseCaptured() ) // Stop the current command but keep the current tool
478  else // Deselect current tool
479  m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
480  }
481 
484  GetCanvas()->GetView()->ShowPreview( false );
485 }
486 
487 
488 void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
489 {
490  int id = aEvent.GetId();
491  int lastToolID = GetToolId();
492 
493  // Stop the current command and deselect the current tool.
494  m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
495 
496  switch( id )
497  {
498  case ID_NO_TOOL_SELECTED:
500  break;
501 
502  case ID_HIGHLIGHT:
503  SetToolID( ID_HIGHLIGHT, wxCURSOR_HAND, _("Highlight specific net") );
504  break;
505 
507  case ID_ZOOM_SELECTION:
508  // This tool is located on the main toolbar: switch it on or off on click
509  if( lastToolID != ID_ZOOM_SELECTION )
510  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
511  else
513  break;
514 
515  case ID_MENU_NOCONN_BUTT:
516  case ID_NOCONN_BUTT:
517  SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add no connect" ) );
518  break;
519 
520  case ID_MENU_WIRE_BUTT:
521  case ID_WIRE_BUTT:
522  SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
523  break;
524 
525  case ID_MENU_BUS_BUTT:
526  case ID_BUS_BUTT:
527  SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add bus" ) );
528  break;
529 
532  SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add lines" ) );
533  break;
534 
536  case ID_JUNCTION_BUTT:
537  SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add junction" ) );
538  break;
539 
540  case ID_MENU_LABEL_BUTT:
541  case ID_LABEL_BUTT:
542  SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add label" ) );
543  break;
544 
545  case ID_MENU_GLABEL_BUTT:
546  case ID_GLABEL_BUTT:
547  SetToolID( ID_GLABEL_BUTT, wxCURSOR_PENCIL, _( "Add global label" ) );
548  break;
549 
551  case ID_HIERLABEL_BUTT:
552  SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
553  break;
554 
557  SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) );
558  break;
559 
561  case ID_ADD_IMAGE_BUTT:
562  SetToolID( ID_ADD_IMAGE_BUTT, wxCURSOR_PENCIL, _( "Add image" ) );
563  break;
564 
567  SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
568  break;
569 
572  SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
573  break;
574 
577  SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add sheet" ) );
578  break;
579 
581  case ID_SHEET_PIN_BUTT:
582  SetToolID( ID_SHEET_PIN_BUTT, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
583  break;
584 
587  SetToolID( ID_IMPORT_HLABEL_BUTT, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
588  break;
589 
592  SetToolID( ID_SCH_PLACE_COMPONENT, wxCURSOR_PENCIL, _( "Add component" ) );
593  break;
594 
596  case ID_PLACE_POWER_BUTT:
597  SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add power" ) );
598  break;
599 
602  SetToolID( ID_SCHEMATIC_DELETE_ITEM_BUTT, wxCURSOR_BULLSEYE, _( "Delete item" ) );
603  break;
604 
605 #ifdef KICAD_SPICE
606  case ID_SIM_PROBE:
607  SetToolID( id, -1, _( "Add a simulator probe" ) );
608  //GAL TODO: m_canvas->SetCurrentCursor( CURSOR_PROBE );
609  break;
610 
611  case ID_SIM_TUNE:
612  SetToolID( id, -1, _( "Select a value to be tuned" ) );
613  //GAL TODO: m_canvas->SetCurrentCursor( CURSOR_TUNE );
614  break;
615 #endif /* KICAD_SPICE */
616 
617  default:
618  SetRepeatItem( NULL );
619  }
620 
621  // Simulate left click event if we got here from a hot key.
622  if( aEvent.GetClientObject() != NULL )
623  {
624  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
625 
626  OnLeftClick( nullptr, data->GetPosition() );
627  }
628 }
629 
630 
631 void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
632 {
633  if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar )
634  aEvent.Check( GetToolId() == aEvent.GetId() );
635 }
636 
637 
638 void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
639 {
640  PICKED_ITEMS_LIST pickList;
641  SCH_SCREEN* screen = GetScreen();
643 
644  if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
645  {
646  DeleteItemsInList( pickList );
647  SchematicCleanUp( true );
648  OnModify();
649  }
650 }
651 
652 
654 {
655  SCH_ITEM* item;
656  SCH_SCREEN* screen = GetScreen();
657 
659 
660  if( item )
661  {
662  bool itemHasConnections = item->IsConnectable();
663 
664  screen->SetCurItem( NULL );
665  SetRepeatItem( NULL );
666  DeleteItem( item );
667 
668  if( itemHasConnections )
670 
671  GetCanvas()->Refresh();
672  OnModify();
673  return true;
674  }
675 
676  return false;
677 }
678 
679 // This function is a callback function, called by the mouse cursor moving event
680 static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
681  const wxPoint& aPosition, bool aErase )
682 {
683  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
684  SCH_ITEM* item = screen->GetCurItem();
685  auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
686  auto view = panel->GetView();
687 
688  wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) );
689 
690  wxPoint cpos = aPanel->GetParent()->GetCrossHairPosition();
691  cpos -= item->GetStoredPos();
692 
693  item->SetPosition( cpos );
694 
695  view->Hide( item );
696  view->ClearPreview();
697  view->AddToPreview( item->Clone() );
698 
699  // Needed when moving a bitmap image to avoid ugly rendering and artifacts,
700  // because a bitmap is drawn only as non cached
701  if( item->Type() == SCH_BITMAP_T )
702  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
703 }
704 
705 
709 static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
710 {
711  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
712  SCH_ITEM* item = screen->GetCurItem();
713  SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
714  auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
715  auto view = panel->GetView();
716 
717  parent->SetRepeatItem( NULL );
718  screen->SetCurItem( NULL );
719  view->ClearPreview();
720  view->ClearHiddenFlags();
721 
722  if( item == NULL ) /* no current item */
723  return;
724 
725  if( item->IsNew() )
726  {
727  delete item;
728  }
729  else
730  {
731  SCH_ITEM* oldItem = parent->GetUndoItem();
732 
733  SCH_ITEM* currentItem;
734 
735  // Items that are children of other objects are undone by swapping the contents
736  // of the parent items.
737  if( (item->Type() == SCH_SHEET_PIN_T) || (item->Type() == SCH_FIELD_T) )
738  currentItem = (SCH_ITEM*) item->GetParent();
739  else
740  currentItem = item;
741 
742  wxCHECK_RET( oldItem != NULL && currentItem->Type() == oldItem->Type(),
743  wxT( "Cannot restore undefined or bad last schematic item." ) );
744 
745  // Never delete existing item, because it can be referenced by an undo/redo command
746  // Just restore its data
747  currentItem->SwapData( oldItem );
748  view->Hide( item, false );
749  item->ClearFlags();
750 
751  // for items managed by their parent, we have to refresh
752  // the parent drawings (scheet or symbol)
753  if( currentItem != item )
754  parent->RefreshItem( currentItem );
755  }
756 
757  screen->TestDanglingEnds();
758  aPanel->Refresh();
759 }
760 
761 
763 {
764  wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) );
765 
766  SetRepeatItem( NULL );
767 
768  if( !aItem->IsNew() )
769  {
770  if( (aItem->Type() == SCH_SHEET_PIN_T) || (aItem->Type() == SCH_FIELD_T) )
771  SetUndoItem( (SCH_ITEM*) aItem->GetParent() );
772  else
773  SetUndoItem( aItem );
774  }
775 
776  std::vector<DANGLING_END_ITEM> emptySet;
777  aItem->UpdateDanglingState( emptySet );
778 
779  aItem->SetFlags( IS_MOVED );
780 
781  if( aItem->Type() == SCH_FIELD_T && aItem->GetParent()->Type() == SCH_COMPONENT_T )
782  {
783  // Now that we're moving a field, they're no longer autoplaced.
784  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( aItem->GetParent() );
785  parent->ClearFieldsAutoplaced();
786  }
787 
788  // These are owned by their parent, and so their parent must erase them
789  if( aItem->Type() == SCH_SHEET_PIN_T || aItem->Type() == SCH_FIELD_T )
790  RefreshItem( aItem );
791 
792  // For some items, moving the cursor to anchor is not good
793  // (for instance large hierarchical sheets od componants can have
794  // the anchor position outside the canvas)
795  // these items return IsMovableFromAnchorPoint() == false
796  // For these items, do not warp the cursor
797  if( aItem->IsMovableFromAnchorPoint() )
798  {
799  SetCrossHairPosition( aItem->GetPosition() );
801  aItem->SetStoredPos( wxPoint( 0,0 ) );
802  }
803  else
804  {
805  // Round the point under the cursor to a multiple of the grid
806  wxPoint cursorpos = GetCrossHairPosition() - aItem->GetPosition();
807  wxPoint gridsize = GetScreen()->GetGridSize();
808  cursorpos.x = ( cursorpos.x / gridsize.x ) * gridsize.x;
809  cursorpos.y = ( cursorpos.y / gridsize.y ) * gridsize.y;
810 
811  aItem->SetStoredPos( cursorpos );
812  }
813 
814  OnModify();
815 
816  GetScreen()->SetCurItem( aItem );
818  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
819 
820  m_canvas->Refresh();
821 }
822 
823 
824 void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
825 {
826  SCH_SCREEN* screen = GetScreen();
827  SCH_ITEM* item = screen->GetCurItem();
828 
829  if( item != NULL )
830  {
831  item = LocateAndShowItem( item->GetPosition() );
832  SendMessageToPCBNEW( item, NULL );
833  }
834  else
835  {
836  // If we didn't get here by a hot key, then something has gone wrong.
837  if( aEvent.GetInt() == 0 )
838  return;
839 
840  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
841 
842  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
843 
844  item = LocateAndShowItem( data->GetPosition() );
845  SendMessageToPCBNEW( item, NULL );
846  }
847 }
848 
849 
850 void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
851 {
852  SCH_SCREEN* screen = GetScreen();
853  SCH_ITEM* item = screen->GetCurItem();
855 
856  // Allows block rotate operation on hot key.
857  if( block.GetState() != STATE_NO_BLOCK )
858  {
859  // Compute the rotation center and put it on grid:
860  wxPoint rotationPoint = GetNearestGridPosition( block.Centre() );
861 
862  if( block.GetCommand() != BLOCK_DUPLICATE )
863  {
864  SaveCopyInUndoList( block.GetItems(), UR_ROTATED, block.AppendUndo(), rotationPoint );
865  block.SetAppendUndo();
866  }
867 
868  RotateListOfItems( block.GetItems(), rotationPoint );
869 
870  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
871  return;
872  }
873 
874  if( item == NULL )
875  {
876  // If we didn't get here by a hot key, then something has gone wrong.
877  if( aEvent.GetInt() == 0 )
878  return;
879 
880  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
881 
882  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
883 
885  aEvent.GetInt() );
886 
887  DBG(printf("Rotate Item %p", item);)
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 
900  if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
902  else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
904  else
905  wxFAIL_MSG( wxT( "Unknown rotate item command ID." ) );
906 
907  if( m_autoplaceFields )
908  component->AutoAutoplaceFields( GetScreen() );
909 
910  break;
911  }
912 
913  case SCH_TEXT_T:
914  case SCH_LABEL_T:
915  case SCH_GLOBAL_LABEL_T:
918  ChangeTextOrient( (SCH_TEXT*) item );
919  break;
920 
921  case SCH_FIELD_T:
923  RotateField( (SCH_FIELD*) item );
924  if( item->GetParent()->Type() == SCH_COMPONENT_T )
925  {
926  // Now that we're moving a field, they're no longer autoplaced.
927  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( item->GetParent() );
928  parent->ClearFieldsAutoplaced();
929  }
930  break;
931 
932  case SCH_BITMAP_T:
933  RotateImage( (SCH_BITMAP*) item );
934  // The bitmap is cached in Opengl: clear the cache, because
935  // the cache data is invalid
936  GetCanvas()->GetGAL()->ClearCache();
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  RefreshItem( item );
963 
964  if( item->IsMoving() )
965  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
966 
967  if( item->GetFlags() == 0 )
968  screen->SetCurItem( NULL );
969 }
970 
971 
972 void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
973 {
974  SCH_SCREEN* screen = GetScreen();
975  SCH_ITEM* item = screen->GetCurItem();
976 
977  if( item == NULL )
978  {
979  // If we didn't get here by a hot key, then something has gone wrong.
980  if( aEvent.GetInt() == 0 )
981  return;
982 
983  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
984 
985  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
986 
987  // Set the locat filter, according to the edit command
988  const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
989  const KICAD_T* filterListAux = NULL;
990 
991  switch( aEvent.GetId() )
992  {
995  filterListAux = SCH_COLLECTOR::ComponentsOnly;
996  break;
997 
1000  filterListAux = SCH_COLLECTOR::ComponentsOnly;
1001  break;
1002 
1005  filterListAux = SCH_COLLECTOR::ComponentsOnly;
1006  break;
1007 
1010  filterListAux = SCH_COLLECTOR::ComponentsOnly;
1011 
1012  default:
1013  break;
1014  }
1015 
1016  item = LocateAndShowItem( data->GetPosition(), filterList, aEvent.GetInt() );
1017 
1018  // If no item found, and if an auxiliary filter exists, try to use it
1019  if( !item && filterListAux )
1020  item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
1021 
1022  // Exit if no item found at the current location or the item is already being edited.
1023  if( (item == NULL) || (item->GetFlags() != 0) )
1024  return;
1025  }
1026 
1027  switch( item->Type() )
1028  {
1029  case SCH_COMPONENT_T:
1030  {
1031  switch( aEvent.GetId() )
1032  {
1034  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ) );
1035  break;
1036 
1038  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ) );
1039  break;
1040 
1042  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ) );
1043  break;
1044 
1046  {
1047  wxString text = static_cast<SCH_COMPONENT*>( item )->GetField( DATASHEET )->GetText();
1048  text = ResolveUriByEnvVars( text );
1049 
1050  if( !text.IsEmpty() )
1051  GetAssociatedDocument( this, text );
1052  }
1053  break;
1054 
1055  case ID_SCH_EDIT_ITEM:
1056  EditComponent( (SCH_COMPONENT*) item );
1057  break;
1058 
1059  default:
1060  wxFAIL_MSG( wxString::Format( wxT( "Invalid schematic component edit command ID %d" ),
1061  aEvent.GetId() ) );
1062  }
1063 
1064  break;
1065  }
1066 
1067  case SCH_SHEET_T:
1068  {
1069  bool doClearAnnotation;
1070  bool doRefresh = false;
1071  // Keep trace of existing sheet paths. EditSheet() can modify this list
1072  SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
1073 
1074  doRefresh = EditSheet( (SCH_SHEET*) item, m_CurrentSheet, &doClearAnnotation );
1075 
1076  if( doClearAnnotation ) // happens when the current sheet load a existing file
1077  { // we must clear "new" components annotation
1078  SCH_SCREENS screensList( g_RootSheet );
1079  // We clear annotation of new sheet paths here:
1080  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1081  // Clear annotation of m_CurrentSheet itself, because its sheetpath
1082  // is not a new path, but components managed by its sheet path must have
1083  // their annotation cleared, becuase they are new:
1084  ((SCH_SHEET*) item)->GetScreen()->ClearAnnotation( m_CurrentSheet );
1085  }
1086 
1087  if( doRefresh )
1088  m_canvas->Refresh();
1089  }
1090  break;
1091 
1092  case SCH_SHEET_PIN_T:
1093  EditSheetPin( (SCH_SHEET_PIN*) item, true );
1094  break;
1095 
1096  case SCH_TEXT_T:
1097  case SCH_LABEL_T:
1098  case SCH_GLOBAL_LABEL_T:
1100  EditSchematicText( (SCH_TEXT*) item );
1101  break;
1102 
1103  case SCH_FIELD_T:
1104  EditComponentFieldText( (SCH_FIELD*) item );
1105  break;
1106 
1107  case SCH_BITMAP_T:
1108  EditImage( (SCH_BITMAP*) item );
1109  // The bitmap is cached in Opengl: clear the cache, because
1110  // the cache data is perhaps invalid
1111  GetCanvas()->GetGAL()->ClearCache();
1112  break;
1113 
1114  case SCH_LINE_T: // These items have no param to edit
1115  EditLine( (SCH_LINE*) item, true );
1116  break;
1117  case SCH_MARKER_T:
1118  case SCH_JUNCTION_T:
1119  case SCH_NO_CONNECT_T:
1120  break;
1121 
1122  default: // Unexpected item
1123  wxFAIL_MSG( wxString::Format( wxT( "Cannot edit schematic item type %s." ),
1124  GetChars( item->GetClass() ) ) );
1125  }
1126 
1127  RefreshItem( item );
1128 
1129  if( item->GetFlags() == 0 )
1130  screen->SetCurItem( NULL );
1131 }
1132 
1133 
1134 void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
1135 {
1136  SCH_SCREEN* screen = GetScreen();
1137  SCH_ITEM* item = screen->GetCurItem();
1138 
1139  // The easiest way to handle a menu or a hot key drag command
1140  // is to simulate a block drag command
1141  //
1142  // When a drag item is requested, some items use a BLOCK_DRAG_ITEM drag type
1143  // an some items use a BLOCK_DRAG drag type (mainly a junction)
1144  // a BLOCK_DRAG collects all items in a block (here a 2x2 rect centered on the cursor)
1145  // and BLOCK_DRAG_ITEM drag only the selected item
1146  BLOCK_COMMAND_T dragType = BLOCK_DRAG_ITEM;
1147 
1148  if( item == NULL )
1149  {
1150  // If we didn't get here by a hot key, then something has gone wrong.
1151  if( aEvent.GetInt() == 0 )
1152  return;
1153 
1154  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1155 
1156  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1157 
1159  aEvent.GetInt() );
1160 
1161  // Exit if no item found at the current location or the item is already being edited.
1162  if( (item == NULL) || (item->GetFlags() != 0) )
1163  return;
1164 
1165  // When a junction or a node is found, a BLOCK_DRAG is better
1168  {
1169  dragType = BLOCK_DRAG;
1170  }
1171  }
1172 
1173  switch( item->Type() )
1174  {
1175  case SCH_BUS_BUS_ENTRY_T:
1176  case SCH_BUS_WIRE_ENTRY_T:
1177  case SCH_LINE_T:
1178  case SCH_JUNCTION_T:
1179  case SCH_COMPONENT_T:
1180  case SCH_LABEL_T:
1181  case SCH_GLOBAL_LABEL_T:
1183  case SCH_SHEET_T:
1184  case SCH_TEXT_T:
1186 
1187  if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1188  {
1189  if( !HandleBlockBegin( nullptr, dragType, GetCrossHairPosition() ) )
1190  break;
1191 
1192  // Give a non null size to the search block:
1193  screen->m_BlockLocate.Inflate( 1 );
1195  HandleBlockEnd( nullptr );
1196  }
1197 
1198  break;
1199 
1200  default:
1201  wxFAIL_MSG( wxString::Format( wxT( "Cannot drag schematic item type %s." ),
1202  GetChars( item->GetClass() ) ) );
1203  }
1204 }
1205 
1206 
1207 void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
1208 {
1209  SCH_SCREEN* screen = GetScreen();
1210  SCH_ITEM* item = screen->GetCurItem();
1211  BLOCK_SELECTOR& block = screen->m_BlockLocate;
1212 
1213  // Allows block rotate operation on hot key.
1214  if( block.GetState() != STATE_NO_BLOCK )
1215  {
1216  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1217  {
1218  // Compute the mirror center and put it on grid.
1219  wxPoint mirrorPt = block.Centre();
1220  mirrorPt = GetNearestGridPosition( mirrorPt );
1221  SetCrossHairPosition( mirrorPt );
1222 
1223  if( block.GetCommand() != BLOCK_DUPLICATE )
1224  {
1225  SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_X, block.AppendUndo(), mirrorPt );
1226  block.SetAppendUndo();
1227  }
1228 
1229  MirrorX( block.GetItems(), mirrorPt );
1230 
1231  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
1232  return;
1233  }
1234  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1235  {
1236  // Compute the mirror center and put it on grid.
1237  wxPoint mirrorPt = block.Centre();
1238  mirrorPt = GetNearestGridPosition( mirrorPt );
1239  SetCrossHairPosition( mirrorPt );
1240 
1241  if( block.GetCommand() != BLOCK_DUPLICATE )
1242  {
1243  SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_Y, block.AppendUndo(), mirrorPt );
1244  block.SetAppendUndo();
1245  }
1246 
1247  MirrorY( block.GetItems(), mirrorPt );
1248 
1249  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
1250  return;
1251  }
1252  else
1253  {
1254  wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
1255  }
1256 
1257  return;
1258  }
1259 
1260  if( item == NULL )
1261  {
1262  // If we didn't get here by a hot key, then something has gone wrong.
1263  if( aEvent.GetInt() == 0 )
1264  return;
1265 
1266  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1267 
1268  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1269 
1271  aEvent.GetInt() );
1272 
1273  // Exit if no item found at the current location or the item is already being edited.
1274  if( (item == NULL) || (item->GetFlags() != 0) )
1275  return;
1276  }
1277 
1278 
1279  switch( item->Type() )
1280  {
1281  case SCH_COMPONENT_T:
1282  {
1283  SCH_COMPONENT *component = static_cast<SCH_COMPONENT*>( item );
1284  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1286  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1288  else if( aEvent.GetId() == ID_SCH_ORIENT_NORMAL )
1290  else
1291  wxFAIL_MSG( wxT( "Invalid orient schematic component command ID." ) );
1292 
1293  if( m_autoplaceFields )
1294  component->AutoAutoplaceFields( GetScreen() );
1295 
1296  break;
1297  }
1298 
1299  case SCH_BITMAP_T:
1300  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1301  MirrorImage( (SCH_BITMAP*) item, true );
1302  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1303  MirrorImage( (SCH_BITMAP*) item, false );
1304 
1305  // The bitmap is cached in Opengl: clear the cache, because
1306  // the cache data is invalid
1307  GetCanvas()->GetGAL()->ClearCache();
1308 
1309  break;
1310 
1311  case SCH_SHEET_T:
1312  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1313  MirrorSheet( (SCH_SHEET*) item, true );
1314  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1315  MirrorSheet( (SCH_SHEET*) item, false );
1316 
1317  break;
1318 
1319  default:
1320  // This object cannot be oriented.
1321  ;
1322  }
1323 
1324  RefreshItem( item );
1325 
1326  if( item->IsMoving() )
1327  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
1328 
1329  if( item->GetFlags() == 0 )
1330  screen->SetCurItem( NULL );
1331 }
virtual BASE_SCREEN * GetScreen()=0
Definition of the SCH_SHEET class for Eeschema.
bool DeleteItemAtCrossHair()
Delete the item found under the cross hair.
Definition: schedit.cpp:653
void OrientComponent(COMPONENT_ORIENTATION_T aOrientation=CMP_NORMAL)
Rotate and mirror a component.
Definition: getpart.cpp:299
Class SCH_SHEET_LIST.
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:201
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:638
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:258
int EditLine(SCH_LINE *aLine, bool aRedraw)
Function EditLine displays the dialog for editing the parameters of aLine.
Definition: sch_line.cpp:785
bool SchematicCleanUp(bool aAppend=false)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
bool IsMoving() const
Definition: base_struct.h:221
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
virtual bool HandleBlockBegin(wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0) override
Initialize a block command.
void ClearHiddenFlags()
Definition: sch_view.cpp:144
void OnMoveItem(wxCommandEvent &aEvent)
Handle the ID_SCH_MOVE_ITEM event used to move schematic items.
Definition: schedit.cpp:387
name of datasheet
static const KICAD_T RotatableItems[]
A scan list for all rotatable schematic items.
SCH_TEXT * CreateNewText(int aType)
Definition: edit_label.cpp:68
bool AppendUndo() const
void RotateListOfItems(PICKED_ITEMS_LIST &aItemsList, const wxPoint &rotationPoint)
const wxString ResolveUriByEnvVars(const wxString &aUri)
Replace any environment variables in file-path uris (leaving network-path URIs alone).
Definition: common.cpp:456
virtual bool IsMovableFromAnchorPoint()
Virtual function IsMovableFromAnchorPoint.
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:219
void MirrorX(PICKED_ITEMS_LIST &aItemsList, const wxPoint &aMirrorPoint)
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
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...
EDA_ITEM * GetParent() const
Definition: base_struct.h:211
virtual 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
static const KICAD_T CmpFieldDatasheetOnly[]
A scan list for a specific editable field: Datasheet.
void RotateHierarchicalSheet(SCH_SHEET *aSheet, bool aRotCCW)
Rotate a sheet object.
Definition: sheet.cpp:459
void OnEditItem(wxCommandEvent &aEvent)
Handle the ID_SCH_EDIT_ITEM event used to edit schematic items.
Definition: schedit.cpp:972
void ConvertPart(SCH_COMPONENT *DrawComponent)
Definition: getpart.cpp:371
SCH_ITEM * GetUndoItem() const
Schematic editor (Eeschema) main window.
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void ClearBlockCommand()
Definition: base_screen.h:501
SCH_COLLECTOR m_collectedItems
List of collected items.
void MirrorImage(SCH_BITMAP *aItem, bool Is_X_axis)
Mirror a bitmap.
Definition: edit_bitmap.cpp:87
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
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:265
static const KICAD_T MovableItems[]
A scan list for all movable schematic items.
virtual void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
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".
bool EditSheet(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
Edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:45
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
void InstallHierarchyFrame(wxPoint &pos)
Definition: hierarch.cpp:140
Auxiliary rendering target (noncached)
Definition: definitions.h:42
void ClearFieldsAutoplaced()
Set fields automatically placed flag false.
virtual EDA_DRAW_FRAME * GetParent() const =0
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
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
virtual bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList)
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it&#39;s dangling state...
wxPoint & GetStoredPos()
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
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 PrepareMoveItem(SCH_ITEM *aItem)
Start moving aItem using the mouse.
Definition: schedit.cpp:762
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
virtual void SwapData(SCH_ITEM *aItem)
Function SwapData swap the internal data structures aItem with the schematic item.
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:631
void OnRotate(wxCommandEvent &aEvent)
Handle the ID_SCH_ROTATE_CLOCKWISE and ID_SCH_ROTATE_COUNTERCLOCKWISE events used to rotate schematic...
Definition: schedit.cpp:850
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: sch_screen.h:196
void SyncView()
Mark all items for refresh.
void ShowPreview(bool aShow=true)
Definition: sch_view.cpp:138
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item...
SCH_DRAW_PANEL * GetCanvas() const override
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.
void ClearPreview()
Definition: sch_view.cpp:98
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
SCH_SHEET_PIN * ImportSheetPin(SCH_SHEET *aSheet)
Automatically create a sheet pin from the hierarchical labels in the schematic referenced by aSheet...
Definition: sheetlab.cpp:106
void RotateImage(SCH_BITMAP *aItem)
Definition: edit_bitmap.cpp:75
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
wxPoint Centre() const
Definition: eda_rect.h:60
void SetAutoPanRequest(bool aEnable)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
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
KIGFX::SCH_VIEW * GetView() const
SCH_ITEM * LocateAndShowItem(const wxPoint &aPosition, const KICAD_T aFilterList[]=SCH_COLLECTOR::AllItems, int aHotKeyCommandId=0, bool *aClarifySelectionMenuCancelled=nullptr)
Check the schematic at aPosition in logical (drawing) units for a item matching the types in aFilterL...
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:157
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
Definition: solve.cpp:178
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:462
void MirrorY(PICKED_ITEMS_LIST &aItemsList, const wxPoint &aMirrorPoint)
static void moveItemWithMouseCursor(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Definition: schedit.cpp:680
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:434
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
bool HasUndefinedPins()
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:232
Definition the SCH_COMPONENT class for Eeschema.
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Return the nearest aGridSize location to aPosition.
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.
void RefreshItem(SCH_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
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:910
static const KICAD_T CmpFieldReferenceOnly[]
A scan list for a specific editable field: Reference.
int GetToolId() const
Definition: draw_frame.h:519
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
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:488
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
void EditImage(SCH_BITMAP *aItem)
PICKED_ITEMS_LIST & GetItems()
virtual wxString GetClass() const override
Function GetClass returns the class name.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel...
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
BLOCK_COMMAND_T GetCommand() const
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:918
void OnDragItem(wxCommandEvent &aEvent)
Handle the ID_SCH_DRAG_ITEM event used to drag schematic items.
Definition: schedit.cpp:1134
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:1207
#define DBG(x)
Definition: fctsys.h:33
Some functions to handle hotkeys in KiCad.
void MirrorSheet(SCH_SHEET *aSheet, bool aFromXaxis)
Mirror a hierarchical sheet.
Definition: sheet.cpp:490
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.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
void ClearAnnotationOfNewSheetPaths(SCH_SHEET_LIST &aInitialSheetPathList)
Clear the annotation for the components inside new sheetpaths when a complex hierarchy is modified an...
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Set the screen cross hair position to aPosition in logical (drawing) units.
void addCurrentItemToScreen()
Add the item currently being edited to the schematic and adds the changes to the undo/redo container...
int EditSheetPin(SCH_SHEET_PIN *aSheetPin, bool aRedraw)
Display the dialog for editing the parameters of aSheetPin.
Definition: sheetlab.cpp:60
void SetLastCursorPosition(const wxPoint &aPosition)
Function SetLastCursorPosition sets the last cursor position to aPosition.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:277
#define VALUE
void SetStoredPos(wxPoint aPos)
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
void Process_Special_Functions(wxCommandEvent &event)
Definition: schedit.cpp:55
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:295
virtual void ClearCache()
Delete all data created during caching of graphic items.
static void abortMoveItem(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Callback function called when aborting a move item with mouse cursor command.
Definition: schedit.cpp:709
static const KICAD_T OrientableItems[]
A scan list for schematic items that can be mirrored.
void DeleteItem(SCH_ITEM *aItem, bool aAppend=false)
Remove aItem from the current screen and saves it in the undo list.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
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:824
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113