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  break;
239 
241  if( item != NULL && item->Type() == SCH_SHEET_T )
242  screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item ) );
243  break;
244 
246  if( item != NULL && item->Type() == SCH_SHEET_T )
247  {
248  SCH_SHEET* sheet = (SCH_SHEET*) item;
249 
250  if( !sheet->HasUndefinedPins() )
251  {
252  DisplayInfoMessage( this, _( "There are no undefined labels in this sheet to clean up." ) );
253  return;
254  }
255 
256  if( !IsOK( this, _( "Do you wish to cleanup this sheet?" ) ) )
257  return;
258 
259  /* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */
260  SaveCopyInUndoList( sheet, UR_CHANGED );
261  sheet->CleanupSheet();
262  SyncView();
263  GetCanvas()->Refresh();
264  OnModify();
265  }
266  break;
267 
270  break;
271 
273  // Ensure the struct is a component (could be a struct of a component, like Field, text..)
274  if( item && item->Type() == SCH_COMPONENT_T )
275  {
277  ConvertPart( (SCH_COMPONENT*) item );
278  }
279 
280  break;
281 
283 
284  if( item && (item->Type() == SCH_SHEET_T) )
285  {
286  m_CurrentSheet->push_back( (SCH_SHEET*) item );
288  }
289 
290  break;
291 
293  if( m_CurrentSheet->Last() != g_RootSheet )
294  {
295  m_CurrentSheet->pop_back();
297  }
298 
299  break;
300 
302  m_canvas->SetAutoPanRequest( false );
304  HandleBlockPlace( nullptr );
305  break;
306 
307  case ID_POPUP_ZOOM_BLOCK:
309  screen->m_BlockLocate.SetMessageBlock( this );
310  HandleBlockEnd( nullptr );
311  break;
312 
314  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
315  break;
316 
319  screen->m_BlockLocate.SetMessageBlock( this );
320  HandleBlockEnd( nullptr );
322  break;
323 
325  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
326  break;
327 
330  screen->m_BlockLocate.SetMessageBlock( this );
331  HandleBlockEnd( nullptr );
332  break;
333 
334  case ID_POPUP_DRAG_BLOCK:
335  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
336  break;
337 
340  screen->m_BlockLocate.SetMessageBlock( this );
341  HandleBlockEnd( nullptr );
342  break;
343 
347 
349  m_canvas->Refresh();
350 
351  screen->SetCurItem( NULL );
352  break;
353 
357  : LAYER_GLOBLABEL ) );
358  item = screen->GetCurItem();
359 
360  if( item )
362 
363  break;
364 
366  if( item && item->Type() == SCH_MARKER_T )
367  ( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
368 
369  break;
370 
371  default: // Log error:
372  wxFAIL_MSG( wxString::Format( "Cannot process command event ID %d", event.GetId() ) );
373  break;
374  }
375 
376  // End switch ( id ) (Command execution)
377 
378  if( GetToolId() == ID_NO_TOOL_SELECTED )
379  SetRepeatItem( NULL );
380 }
381 
382 
383 void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
384 {
385  SCH_SCREEN* screen = GetScreen();
386  SCH_ITEM* item = screen->GetCurItem();
387 
388  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
389  {
390  // trying to move an item when there is a block at the same time is not acceptable
391  return;
392  }
393 
394  if( item == NULL )
395  {
396  // If we didn't get here by a hot key, then something has gone wrong.
397  if( aEvent.GetInt() == 0 )
398  return;
399 
400  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
401 
402  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
403 
405  aEvent.GetInt() );
406 
407  // Exit if no item found at the current location or the item is already being edited.
408  if( (item == NULL) || (item->GetFlags() != 0) )
409  return;
410  }
411 
413 
414  switch( item->Type() )
415  {
416  case SCH_LINE_T:
417  break;
418 
419  case SCH_JUNCTION_T:
420  case SCH_NO_CONNECT_T:
421  case SCH_BUS_BUS_ENTRY_T:
423  case SCH_LABEL_T:
424  case SCH_GLOBAL_LABEL_T:
426  case SCH_TEXT_T:
427  case SCH_COMPONENT_T:
428  case SCH_SHEET_PIN_T:
429  case SCH_FIELD_T:
430  case SCH_SHEET_T:
431  case SCH_BITMAP_T:
432  PrepareMoveItem( item );
433  break;
434 
435 /* case SCH_BITMAP_T:
436  // move an image is a special case:
437  // we cannot undraw/redraw a bitmap just using our xor mode
438  // the MoveImage function handle this undraw/redraw difficulty
439  // By redrawing the full bounding box
440  MoveImage( (SCH_BITMAP*) item, &dc );
441  break;
442 */
443  case SCH_MARKER_T:
444  // Moving a marker has no sense
445  break;
446 
447  default:
448  // Unknown items cannot be moved
449  wxFAIL_MSG( wxString::Format( "Cannot move item type %d", item->Type() ) );
450  break;
451  }
452 
453  if( GetToolId() == ID_NO_TOOL_SELECTED )
454  SetRepeatItem( NULL );
455 }
456 
457 
458 void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
459 {
460  SCH_SCREEN* screen = GetScreen();
461 
462  if( screen->IsBlockActive() )
463  {
464  GetCanvas()->SetCursor( (wxStockCursor) GetGalCanvas()->GetDefaultCursor() );
465  screen->ClearBlockCommand();
466 
467  // Stop the current command (if any) but keep the current tool
469  }
470  else
471  {
472  if( m_canvas->IsMouseCaptured() ) // Stop the current command but keep the current tool
474  else // Deselect current tool
475  m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
476  }
477 
480  GetCanvas()->GetView()->ShowPreview( false );
481 }
482 
483 
484 void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
485 {
486  int id = aEvent.GetId();
487  int lastToolID = GetToolId();
488 
489  // Stop the current command and deselect the current tool.
490  m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
491 
492  switch( id )
493  {
494  case ID_NO_TOOL_SELECTED:
496  break;
497 
498  case ID_HIGHLIGHT:
499  SetToolID( ID_HIGHLIGHT, wxCURSOR_HAND, _("Highlight specific net") );
500  break;
501 
503  case ID_ZOOM_SELECTION:
504  // This tool is located on the main toolbar: switch it on or off on click
505  if( lastToolID != ID_ZOOM_SELECTION )
506  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
507  else
509  break;
510 
511  case ID_MENU_NOCONN_BUTT:
512  case ID_NOCONN_BUTT:
513  SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add no connect" ) );
514  break;
515 
516  case ID_MENU_WIRE_BUTT:
517  case ID_WIRE_BUTT:
518  SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
519  break;
520 
521  case ID_MENU_BUS_BUTT:
522  case ID_BUS_BUTT:
523  SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add bus" ) );
524  break;
525 
528  SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add lines" ) );
529  break;
530 
532  case ID_JUNCTION_BUTT:
533  SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add junction" ) );
534  break;
535 
536  case ID_MENU_LABEL_BUTT:
537  case ID_LABEL_BUTT:
538  SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add label" ) );
539  break;
540 
541  case ID_MENU_GLABEL_BUTT:
542  case ID_GLABEL_BUTT:
543  SetToolID( ID_GLABEL_BUTT, wxCURSOR_PENCIL, _( "Add global label" ) );
544  break;
545 
547  case ID_HIERLABEL_BUTT:
548  SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
549  break;
550 
553  SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) );
554  break;
555 
557  case ID_ADD_IMAGE_BUTT:
558  SetToolID( ID_ADD_IMAGE_BUTT, wxCURSOR_PENCIL, _( "Add image" ) );
559  break;
560 
563  SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
564  break;
565 
568  SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
569  break;
570 
573  SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add sheet" ) );
574  break;
575 
577  case ID_SHEET_PIN_BUTT:
578  SetToolID( ID_SHEET_PIN_BUTT, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
579  break;
580 
583  SetToolID( ID_IMPORT_HLABEL_BUTT, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
584  break;
585 
588  SetToolID( ID_SCH_PLACE_COMPONENT, wxCURSOR_PENCIL, _( "Add component" ) );
589  break;
590 
592  case ID_PLACE_POWER_BUTT:
593  SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add power" ) );
594  break;
595 
598  SetToolID( ID_SCHEMATIC_DELETE_ITEM_BUTT, wxCURSOR_BULLSEYE, _( "Delete item" ) );
599  break;
600 
601 #ifdef KICAD_SPICE
602  case ID_SIM_PROBE:
603  SetToolID( id, -1, _( "Add a simulator probe" ) );
604  //GAL TODO: m_canvas->SetCurrentCursor( CURSOR_PROBE );
605  break;
606 
607  case ID_SIM_TUNE:
608  SetToolID( id, -1, _( "Select a value to be tuned" ) );
609  //GAL TODO: m_canvas->SetCurrentCursor( CURSOR_TUNE );
610  break;
611 #endif /* KICAD_SPICE */
612 
613  default:
614  SetRepeatItem( NULL );
615  }
616 
617  // Simulate left click event if we got here from a hot key.
618  if( aEvent.GetClientObject() != NULL )
619  {
620  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
621 
622  OnLeftClick( nullptr, data->GetPosition() );
623  }
624 }
625 
626 
627 void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
628 {
629  if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar )
630  aEvent.Check( GetToolId() == aEvent.GetId() );
631 }
632 
633 
634 void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
635 {
636  PICKED_ITEMS_LIST pickList;
637  SCH_SCREEN* screen = GetScreen();
638  wxPoint pos = GetCrossHairPosition();
639 
640  if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
641  {
642  DeleteItemsInList( pickList );
643  SchematicCleanUp( true );
644  OnModify();
645  }
646 }
647 
648 
650 {
651  SCH_ITEM* item;
652  SCH_SCREEN* screen = GetScreen();
653 
655 
656  if( item )
657  {
658  bool itemHasConnections = item->IsConnectable();
659 
660  screen->SetCurItem( NULL );
661  SetRepeatItem( NULL );
662  DeleteItem( item );
663 
664  if( itemHasConnections )
666 
667  GetCanvas()->Refresh();
668  OnModify();
669  return true;
670  }
671 
672  return false;
673 }
674 
675 // This function is a callback function, called by the mouse cursor moving event
676 static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
677  const wxPoint& aPosition, bool aErase )
678 {
679  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
680  SCH_ITEM* item = screen->GetCurItem();
681  auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
682  auto view = panel->GetView();
683 
684  wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) );
685 
686  wxPoint cpos = aPanel->GetParent()->GetCrossHairPosition();
687  cpos -= item->GetStoredPos();
688 
689  item->SetPosition( cpos );
690 
691  view->Hide( item );
692  view->ClearPreview();
693  view->AddToPreview( item->Clone() );
694 
695  // Needed when moving a bitmap image to avoid ugly rendering and artifacts,
696  // because a bitmap is drawn only as non cached
697  if( item->Type() == SCH_BITMAP_T )
698  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
699 }
700 
701 
705 static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
706 {
707  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
708  SCH_ITEM* item = screen->GetCurItem();
709  SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
710  auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
711  auto view = panel->GetView();
712 
713  parent->SetRepeatItem( NULL );
714  screen->SetCurItem( NULL );
715  view->ClearPreview();
716  view->ClearHiddenFlags();
717 
718  if( item == NULL ) /* no current item */
719  return;
720 
721  if( item->IsNew() )
722  {
723  delete item;
724  }
725  else
726  {
727  SCH_ITEM* oldItem = parent->GetUndoItem();
728 
729  SCH_ITEM* currentItem;
730 
731  // Items that are children of other objects are undone by swapping the contents
732  // of the parent items.
733  if( (item->Type() == SCH_SHEET_PIN_T) || (item->Type() == SCH_FIELD_T) )
734  currentItem = (SCH_ITEM*) item->GetParent();
735  else
736  currentItem = item;
737 
738  wxCHECK_RET( oldItem != NULL && currentItem->Type() == oldItem->Type(),
739  wxT( "Cannot restore undefined or bad last schematic item." ) );
740 
741  // Never delete existing item, because it can be referenced by an undo/redo command
742  // Just restore its data
743 
744  view->Remove( currentItem );
745  currentItem->SwapData( oldItem );
746  item->ClearFlags();
747  view->Add( currentItem );
748  view->Hide( item, false );
749  }
750 
751  screen->TestDanglingEnds();
752  aPanel->Refresh();
753 }
754 
755 
757 {
758  wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) );
759 
760  SetRepeatItem( NULL );
761 
762  if( !aItem->IsNew() )
763  {
764  if( (aItem->Type() == SCH_SHEET_PIN_T) || (aItem->Type() == SCH_FIELD_T) )
765  SetUndoItem( (SCH_ITEM*) aItem->GetParent() );
766  else
767  SetUndoItem( aItem );
768  }
769 
770  std::vector<DANGLING_END_ITEM> emptySet;
771  aItem->UpdateDanglingState( emptySet );
772 
773  aItem->SetFlags( IS_MOVED );
774 
775  if( aItem->Type() == SCH_FIELD_T && aItem->GetParent()->Type() == SCH_COMPONENT_T )
776  {
777  // Now that we're moving a field, they're no longer autoplaced.
778  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( aItem->GetParent() );
779  parent->ClearFieldsAutoplaced();
780  }
781 
782  // These are owned by their parent, and so their parent must erase them
783  if( aItem->Type() == SCH_SHEET_PIN_T || aItem->Type() == SCH_FIELD_T )
784  RefreshItem( aItem );
785 
786  // For some items, moving the cursor to anchor is not good
787  // (for instance large hierarchical sheets od componants can have
788  // the anchor position outside the canvas)
789  // these items return IsMovableFromAnchorPoint() == false
790  // For these items, do not warp the cursor
791  if( aItem->IsMovableFromAnchorPoint() )
792  {
793  SetCrossHairPosition( aItem->GetPosition() );
795  aItem->SetStoredPos( wxPoint( 0,0 ) );
796  }
797  else
798  {
799  // Round the point under the cursor to a multiple of the grid
800  wxPoint cursorpos = GetCrossHairPosition() - aItem->GetPosition();
801  wxPoint gridsize = GetScreen()->GetGridSize();
802  cursorpos.x = ( cursorpos.x / gridsize.x ) * gridsize.x;
803  cursorpos.y = ( cursorpos.y / gridsize.y ) * gridsize.y;
804 
805  aItem->SetStoredPos( cursorpos );
806  }
807 
808  OnModify();
809 
810  GetScreen()->SetCurItem( aItem );
812  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
813 
814  m_canvas->Refresh();
815 }
816 
817 
818 void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
819 {
820  SCH_SCREEN* screen = GetScreen();
821  SCH_ITEM* item = screen->GetCurItem();
822 
823  if( item != NULL )
824  {
825  item = LocateAndShowItem( item->GetPosition() );
826  SendMessageToPCBNEW( item, NULL );
827  }
828  else
829  {
830  // If we didn't get here by a hot key, then something has gone wrong.
831  if( aEvent.GetInt() == 0 )
832  return;
833 
834  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
835 
836  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
837 
838  item = LocateAndShowItem( data->GetPosition() );
839  SendMessageToPCBNEW( item, NULL );
840  }
841 }
842 
843 
844 void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
845 {
846  SCH_SCREEN* screen = GetScreen();
847  SCH_ITEM* item = screen->GetCurItem();
849 
850  // Allows block rotate operation on hot key.
851  if( block.GetState() != STATE_NO_BLOCK )
852  {
853  // Compute the rotation center and put it on grid:
854  wxPoint rotationPoint = GetNearestGridPosition( block.Centre() );
855 
856  if( block.GetCommand() != BLOCK_DUPLICATE )
857  {
858  SaveCopyInUndoList( block.GetItems(), UR_ROTATED, block.AppendUndo(), rotationPoint );
859  block.SetAppendUndo();
860  }
861 
862  RotateListOfItems( block.GetItems(), rotationPoint );
863 
864  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
865  return;
866  }
867 
868  if( item == NULL )
869  {
870  // If we didn't get here by a hot key, then something has gone wrong.
871  if( aEvent.GetInt() == 0 )
872  return;
873 
874  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
875 
876  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
877 
879  aEvent.GetInt() );
880 
881  DBG(printf("Rotate Item %p", item);)
882 
883  // Exit if no item found at the current location or the item is already being edited.
884  if( (item == NULL) || (item->GetFlags() != 0) )
885  return;
886  }
887 
888  switch( item->Type() )
889  {
890  case SCH_COMPONENT_T:
891  {
892  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
893 
894  if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
896  else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
898  else
899  wxFAIL_MSG( wxT( "Unknown rotate item command ID." ) );
900 
901  if( m_autoplaceFields )
902  component->AutoAutoplaceFields( GetScreen() );
903 
904  break;
905  }
906 
907  case SCH_TEXT_T:
908  case SCH_LABEL_T:
909  case SCH_GLOBAL_LABEL_T:
912  ChangeTextOrient( (SCH_TEXT*) item );
913  break;
914 
915  case SCH_FIELD_T:
917  RotateField( (SCH_FIELD*) item );
918  if( item->GetParent()->Type() == SCH_COMPONENT_T )
919  {
920  // Now that we're moving a field, they're no longer autoplaced.
921  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( item->GetParent() );
922  parent->ClearFieldsAutoplaced();
923  }
924  break;
925 
926  case SCH_BITMAP_T:
927  RotateImage( (SCH_BITMAP*) item );
928  // The bitmap is cached in Opengl: clear the cache, because
929  // the cache data is invalid
930  GetCanvas()->GetGAL()->ClearCache();
931  break;
932 
933  case SCH_SHEET_T:
934  if( !item->IsNew() ) // rotate a sheet during its creation has no sense
935  {
936  bool retCCW = ( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE );
937  RotateHierarchicalSheet( static_cast<SCH_SHEET*>( item ), retCCW );
938  }
939 
940  break;
941 
942  case SCH_JUNCTION_T:
943  case SCH_NO_CONNECT_T:
944  // these items are not rotated, because rotation does not change them.
945  break;
946 
947  default:
948  // Other items (wires...) cannot be rotated, at least during creation
949  if( item->IsNew() )
950  break;
951 
952  wxFAIL_MSG( wxString::Format( wxT( "Cannot rotate schematic item type %s." ),
953  GetChars( item->GetClass() ) ) );
954  }
955 
956  RefreshItem( item );
957 
958  if( item->IsMoving() )
959  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
960 
961  if( item->GetFlags() == 0 )
962  screen->SetCurItem( NULL );
963 }
964 
965 
966 void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
967 {
968  SCH_SCREEN* screen = GetScreen();
969  SCH_ITEM* item = screen->GetCurItem();
970 
971  if( item == NULL )
972  {
973  // If we didn't get here by a hot key, then something has gone wrong.
974  if( aEvent.GetInt() == 0 )
975  return;
976 
977  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
978 
979  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
980 
981  // Set the locat filter, according to the edit command
982  const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
983  const KICAD_T* filterListAux = NULL;
984 
985  switch( aEvent.GetId() )
986  {
989  filterListAux = SCH_COLLECTOR::ComponentsOnly;
990  break;
991 
994  filterListAux = SCH_COLLECTOR::ComponentsOnly;
995  break;
996 
999  filterListAux = SCH_COLLECTOR::ComponentsOnly;
1000  break;
1001 
1004  filterListAux = SCH_COLLECTOR::ComponentsOnly;
1005 
1006  default:
1007  break;
1008  }
1009 
1010  item = LocateAndShowItem( data->GetPosition(), filterList, aEvent.GetInt() );
1011 
1012  // If no item found, and if an auxiliary filter exists, try to use it
1013  if( !item && filterListAux )
1014  item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
1015 
1016  // Exit if no item found at the current location or the item is already being edited.
1017  if( (item == NULL) || (item->GetFlags() != 0) )
1018  return;
1019  }
1020 
1021  switch( item->Type() )
1022  {
1023  case SCH_COMPONENT_T:
1024  {
1025  switch( aEvent.GetId() )
1026  {
1028  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ) );
1029  break;
1030 
1032  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ) );
1033  break;
1034 
1036  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ) );
1037  break;
1038 
1040  {
1041  wxString text = static_cast<SCH_COMPONENT*>( item )->GetField( DATASHEET )->GetText();
1042  text = ResolveUriByEnvVars( text );
1043 
1044  if( !text.IsEmpty() )
1045  GetAssociatedDocument( this, text );
1046  }
1047  break;
1048 
1049  case ID_SCH_EDIT_ITEM:
1050  EditComponent( (SCH_COMPONENT*) item );
1051  break;
1052 
1053  default:
1054  wxFAIL_MSG( wxString::Format( wxT( "Invalid schematic component edit command ID %d" ),
1055  aEvent.GetId() ) );
1056  }
1057 
1058  break;
1059  }
1060 
1061  case SCH_SHEET_T:
1062  {
1063  bool doClearAnnotation;
1064  bool doRefresh = false;
1065  // Keep trace of existing sheet paths. EditSheet() can modify this list
1066  SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
1067 
1068  doRefresh = EditSheet( (SCH_SHEET*) item, m_CurrentSheet, &doClearAnnotation );
1069 
1070  if( doClearAnnotation ) // happens when the current sheet load a existing file
1071  { // we must clear "new" components annotation
1072  SCH_SCREENS screensList( g_RootSheet );
1073  // We clear annotation of new sheet paths here:
1074  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1075  // Clear annotation of m_CurrentSheet itself, because its sheetpath
1076  // is not a new path, but components managed by its sheet path must have
1077  // their annotation cleared, becuase they are new:
1078  ((SCH_SHEET*) item)->GetScreen()->ClearAnnotation( m_CurrentSheet );
1079  }
1080 
1081  if( doRefresh )
1082  m_canvas->Refresh();
1083  }
1084  break;
1085 
1086  case SCH_SHEET_PIN_T:
1087  EditSheetPin( (SCH_SHEET_PIN*) item, true );
1088  break;
1089 
1090  case SCH_TEXT_T:
1091  case SCH_LABEL_T:
1092  case SCH_GLOBAL_LABEL_T:
1094  EditSchematicText( (SCH_TEXT*) item );
1095  break;
1096 
1097  case SCH_FIELD_T:
1098  EditComponentFieldText( (SCH_FIELD*) item );
1099  break;
1100 
1101  case SCH_BITMAP_T:
1102  EditImage( (SCH_BITMAP*) item );
1103  // The bitmap is cached in Opengl: clear the cache, because
1104  // the cache data is perhaps invalid
1105  GetCanvas()->GetGAL()->ClearCache();
1106  break;
1107 
1108  case SCH_LINE_T: // These items have no param to edit
1109  EditLine( (SCH_LINE*) item, true );
1110  break;
1111  case SCH_MARKER_T:
1112  case SCH_JUNCTION_T:
1113  case SCH_NO_CONNECT_T:
1114  break;
1115 
1116  default: // Unexpected item
1117  wxFAIL_MSG( wxString::Format( wxT( "Cannot edit schematic item type %s." ),
1118  GetChars( item->GetClass() ) ) );
1119  }
1120 
1121  RefreshItem( item );
1122 
1123  if( item->GetFlags() == 0 )
1124  screen->SetCurItem( NULL );
1125 }
1126 
1127 
1128 void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
1129 {
1130  SCH_SCREEN* screen = GetScreen();
1131  SCH_ITEM* item = screen->GetCurItem();
1132 
1133  // The easiest way to handle a menu or a hot key drag command
1134  // is to simulate a block drag command
1135  //
1136  // When a drag item is requested, some items use a BLOCK_DRAG_ITEM drag type
1137  // an some items use a BLOCK_DRAG drag type (mainly a junction)
1138  // a BLOCK_DRAG collects all items in a block (here a 2x2 rect centered on the cursor)
1139  // and BLOCK_DRAG_ITEM drag only the selected item
1140  BLOCK_COMMAND_T dragType = BLOCK_DRAG_ITEM;
1141 
1142  if( item == NULL )
1143  {
1144  // If we didn't get here by a hot key, then something has gone wrong.
1145  if( aEvent.GetInt() == 0 )
1146  return;
1147 
1148  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1149 
1150  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1151 
1153  aEvent.GetInt() );
1154 
1155  // Exit if no item found at the current location or the item is already being edited.
1156  if( (item == NULL) || (item->GetFlags() != 0) )
1157  return;
1158 
1159  // When a junction or a node is found, a BLOCK_DRAG is better
1162  {
1163  dragType = BLOCK_DRAG;
1164  }
1165  }
1166 
1167  switch( item->Type() )
1168  {
1169  case SCH_BUS_BUS_ENTRY_T:
1170  case SCH_BUS_WIRE_ENTRY_T:
1171  case SCH_LINE_T:
1172  case SCH_JUNCTION_T:
1173  case SCH_COMPONENT_T:
1174  case SCH_LABEL_T:
1175  case SCH_GLOBAL_LABEL_T:
1177  case SCH_SHEET_T:
1178  case SCH_TEXT_T:
1180 
1181  if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1182  {
1183  if( !HandleBlockBegin( nullptr, dragType, GetCrossHairPosition() ) )
1184  break;
1185 
1186  // Give a non null size to the search block:
1187  screen->m_BlockLocate.Inflate( 1 );
1189  HandleBlockEnd( nullptr );
1190  }
1191 
1192  break;
1193 
1194  default:
1195  wxFAIL_MSG( wxString::Format( wxT( "Cannot drag schematic item type %s." ),
1196  GetChars( item->GetClass() ) ) );
1197  }
1198 }
1199 
1200 
1201 void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
1202 {
1203  SCH_SCREEN* screen = GetScreen();
1204  SCH_ITEM* item = screen->GetCurItem();
1205  BLOCK_SELECTOR& block = screen->m_BlockLocate;
1206 
1207  // Allows block rotate operation on hot key.
1208  if( block.GetState() != STATE_NO_BLOCK )
1209  {
1210  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1211  {
1212  // Compute the mirror center and put it on grid.
1213  wxPoint mirrorPt = block.Centre();
1214  mirrorPt = GetNearestGridPosition( mirrorPt );
1215  SetCrossHairPosition( mirrorPt );
1216 
1217  if( block.GetCommand() != BLOCK_DUPLICATE )
1218  {
1219  SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_X, block.AppendUndo(), mirrorPt );
1220  block.SetAppendUndo();
1221  }
1222 
1223  MirrorX( block.GetItems(), mirrorPt );
1224 
1225  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
1226  return;
1227  }
1228  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1229  {
1230  // Compute the mirror center and put it on grid.
1231  wxPoint mirrorPt = block.Centre();
1232  mirrorPt = GetNearestGridPosition( mirrorPt );
1233  SetCrossHairPosition( mirrorPt );
1234 
1235  if( block.GetCommand() != BLOCK_DUPLICATE )
1236  {
1237  SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_Y, block.AppendUndo(), mirrorPt );
1238  block.SetAppendUndo();
1239  }
1240 
1241  MirrorY( block.GetItems(), mirrorPt );
1242 
1243  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
1244  return;
1245  }
1246  else
1247  {
1248  wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
1249  }
1250 
1251  return;
1252  }
1253 
1254  if( item == NULL )
1255  {
1256  // If we didn't get here by a hot key, then something has gone wrong.
1257  if( aEvent.GetInt() == 0 )
1258  return;
1259 
1260  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1261 
1262  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1263 
1265  aEvent.GetInt() );
1266 
1267  // Exit if no item found at the current location or the item is already being edited.
1268  if( (item == NULL) || (item->GetFlags() != 0) )
1269  return;
1270  }
1271 
1272 
1273  switch( item->Type() )
1274  {
1275  case SCH_COMPONENT_T:
1276  {
1277  SCH_COMPONENT *component = static_cast<SCH_COMPONENT*>( item );
1278  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1280  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1282  else if( aEvent.GetId() == ID_SCH_ORIENT_NORMAL )
1284  else
1285  wxFAIL_MSG( wxT( "Invalid orient schematic component command ID." ) );
1286 
1287  if( m_autoplaceFields )
1288  component->AutoAutoplaceFields( GetScreen() );
1289 
1290  break;
1291  }
1292 
1293  case SCH_BITMAP_T:
1294  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1295  MirrorImage( (SCH_BITMAP*) item, true );
1296  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1297  MirrorImage( (SCH_BITMAP*) item, false );
1298 
1299  // The bitmap is cached in Opengl: clear the cache, because
1300  // the cache data is invalid
1301  GetCanvas()->GetGAL()->ClearCache();
1302 
1303  break;
1304 
1305  case SCH_SHEET_T:
1306  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1307  MirrorSheet( (SCH_SHEET*) item, true );
1308  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1309  MirrorSheet( (SCH_SHEET*) item, false );
1310 
1311  break;
1312 
1313  default:
1314  // This object cannot be oriented.
1315  ;
1316  }
1317 
1318  RefreshItem( item );
1319 
1320  if( item->IsMoving() )
1321  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
1322 
1323  if( item->GetFlags() == 0 )
1324  screen->SetCurItem( NULL );
1325 }
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:649
void OrientComponent(COMPONENT_ORIENTATION_T aOrientation=CMP_NORMAL)
Rotate and mirror a component.
Definition: getpart.cpp:281
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:634
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:784
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()
Clear the hide flag of all items in the view.
Definition: sch_view.cpp:179
void OnMoveItem(wxCommandEvent &aEvent)
Handle the ID_SCH_MOVE_ITEM event used to move schematic items.
Definition: schedit.cpp:383
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:455
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
SCH_MARKER class definition.
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:462
void OnEditItem(wxCommandEvent &aEvent)
Handle the ID_SCH_EDIT_ITEM event used to edit schematic items.
Definition: schedit.cpp:966
void ConvertPart(SCH_COMPONENT *DrawComponent)
Definition: getpart.cpp:353
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 ...
virtual void SetAutoPanRequest(bool aEnable)=0
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 (.
#define VALUE
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:756
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:627
void OnRotate(wxCommandEvent &aEvent)
Handle the ID_SCH_ROTATE_CLOCKWISE and ID_SCH_ROTATE_COUNTERCLOCKWISE events used to rotate schematic...
Definition: schedit.cpp:844
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:173
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:133
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
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:458
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:676
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:516
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:484
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:70
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:925
void OnDragItem(wxCommandEvent &aEvent)
Handle the ID_SCH_DRAG_ITEM event used to drag schematic items.
Definition: schedit.cpp:1128
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:1201
#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:493
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
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:705
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:818
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113