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) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008-2017 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 2004-2019 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  /* At this point: Do nothing. these commands do not need to stop the
97  * current command (mainly a block command) or reset the current state
98  * They will be executed later, in next switch structure.
99  */
100  break;
101 
103  case ID_POPUP_SCH_DELETE:
104  // Stop the current command (if any) but keep the current tool
106  break;
107 
108  default:
109  // Stop the current command and deselect the current tool
111  break;
112  }
113 
114  item = screen->GetCurItem(); // Can be modified by previous calls.
115 
116  switch( id )
117  {
118  case ID_HIERARCHY:
119  InstallHierarchyFrame( pos );
120  SetRepeatItem( NULL );
121  break;
122 
123  case wxID_CUT: // save and delete block
124  case ID_POPUP_CUT_BLOCK:
125 
126  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
127  break;
129  screen->m_BlockLocate.SetMessageBlock( this );
130  HandleBlockEnd( nullptr );
131  SetRepeatItem( NULL );
133  break;
134 
135  case wxID_COPY: // really this is a Save block for paste
136  case ID_POPUP_COPY_BLOCK:
138  screen->m_BlockLocate.SetMessageBlock( this );
139  HandleBlockEnd( nullptr );
140  break;
141 
142  case wxID_PASTE:
145  break;
146 
149  SetBusEntryShape( nullptr, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '/' );
150  break;
151 
154  SetBusEntryShape( nullptr, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '\\' );
155  break;
156 
158  if( m_canvas->IsMouseCaptured() )
159  {
161  SetToolID( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString );
162  }
163  else
164  {
166  }
167 
168  break;
169 
170  case ID_POPUP_END_LINE:
172  EndSegment();
173  break;
174 
177  OnLeftClick( nullptr, GetCrossHairPosition() );
178  break;
179 
182  OnLeftClick( nullptr, GetCrossHairPosition() );
183  break;
184 
186  // Not used
187  break;
188 
193  SchematicCleanUp( true );
194  screen->SetCurItem( NULL );
195  SetRepeatItem( NULL );
196 
198  m_canvas->Refresh();
199 
200  break;
201 
203  SaveWireImage();
206 
208  m_canvas->Refresh();
209 
210  break;
211 
213  case ID_POPUP_SCH_DELETE:
214  if( item == NULL )
215  break;
216 
217  DeleteItem( item );
218  SchematicCleanUp( true );
219  screen->SetCurItem( NULL );
220  SetRepeatItem( NULL );
223  GetCanvas()->Refresh();
224  OnModify();
225  break;
226 
230  break;
231 
233  ReSizeSheet( (SCH_SHEET*) item, nullptr );
234  break;
235 
237  if( item != NULL && item->Type() == SCH_SHEET_T )
238  screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item ) );
239  break;
240 
242  if( item != NULL && item->Type() == SCH_SHEET_T )
243  {
244  SCH_SHEET* sheet = (SCH_SHEET*) item;
245 
246  if( !sheet->HasUndefinedPins() )
247  {
248  DisplayInfoMessage( this, _( "There are no undefined labels in this sheet to clean up." ) );
249  return;
250  }
251 
252  if( !IsOK( this, _( "Do you wish to cleanup this sheet?" ) ) )
253  return;
254 
255  /* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */
256  SaveCopyInUndoList( sheet, UR_CHANGED );
257  sheet->CleanupSheet();
258  SyncView();
259  GetCanvas()->Refresh();
260  OnModify();
261  }
262  break;
263 
266  break;
267 
269  // Ensure the struct is a component (could be a struct of a component, like Field, text..)
270  if( item && item->Type() == SCH_COMPONENT_T )
271  {
273  ConvertPart( (SCH_COMPONENT*) item );
274  }
275 
276  break;
277 
279 
280  if( item && (item->Type() == SCH_SHEET_T) )
281  {
282  m_CurrentSheet->push_back( (SCH_SHEET*) item );
284  }
285 
286  break;
287 
289  if( m_CurrentSheet->Last() != g_RootSheet )
290  {
291  m_CurrentSheet->pop_back();
293  }
294 
295  break;
296 
298  m_canvas->SetAutoPanRequest( false );
300  HandleBlockPlace( nullptr );
301  break;
302 
303  case ID_POPUP_ZOOM_BLOCK:
305  screen->m_BlockLocate.SetMessageBlock( this );
306  HandleBlockEnd( nullptr );
307  break;
308 
310  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
311  break;
312 
315  screen->m_BlockLocate.SetMessageBlock( this );
316  HandleBlockEnd( nullptr );
318  break;
319 
321  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
322  break;
323 
326  screen->m_BlockLocate.SetMessageBlock( this );
327  HandleBlockEnd( nullptr );
328  break;
329 
330  case ID_POPUP_DRAG_BLOCK:
331  if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
332  break;
333 
336  screen->m_BlockLocate.SetMessageBlock( this );
337  HandleBlockEnd( nullptr );
338  break;
339 
343 
345  m_canvas->Refresh();
346 
347  screen->SetCurItem( NULL );
348  break;
349 
353  : LAYER_GLOBLABEL ) );
354  item = screen->GetCurItem();
355 
356  if( item )
358 
359  break;
360 
362  if( item && item->Type() == SCH_MARKER_T )
363  ( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
364 
365  break;
366 
367  default: // Log error:
368  wxFAIL_MSG( wxString::Format( "Cannot process command event ID %d", event.GetId() ) );
369  break;
370  }
371 
372  // End switch ( id ) (Command execution)
373 
374  if( GetToolId() == ID_NO_TOOL_SELECTED )
375  SetRepeatItem( NULL );
376 }
377 
378 
379 void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
380 {
381  SCH_SCREEN* screen = GetScreen();
382  SCH_ITEM* item = screen->GetCurItem();
383 
384  if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
385  {
386  // trying to move an item when there is a block at the same time is not acceptable
387  return;
388  }
389 
390  if( item == NULL )
391  {
392  // If we didn't get here by a hot key, then something has gone wrong.
393  if( aEvent.GetInt() == 0 )
394  return;
395 
396  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
397 
398  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
399 
401  aEvent.GetInt() );
402 
403  // Exit if no item found at the current location or the item is already being edited.
404  if( (item == NULL) || (item->GetFlags() != 0) )
405  return;
406  }
407 
409 
410  switch( item->Type() )
411  {
412  case SCH_LINE_T:
413  break;
414 
415  case SCH_JUNCTION_T:
416  case SCH_NO_CONNECT_T:
417  case SCH_BUS_BUS_ENTRY_T:
419  case SCH_LABEL_T:
420  case SCH_GLOBAL_LABEL_T:
422  case SCH_TEXT_T:
423  case SCH_COMPONENT_T:
424  case SCH_SHEET_PIN_T:
425  case SCH_FIELD_T:
426  case SCH_SHEET_T:
427  case SCH_BITMAP_T:
428  PrepareMoveItem( item );
429  break;
430 
431  case SCH_MARKER_T:
432  // Moving a marker has no sense
433  break;
434 
435  default:
436  // Unknown items cannot be moved
437  wxFAIL_MSG( wxString::Format( "Cannot move item type %d", item->Type() ) );
438  break;
439  }
440 
441  if( GetToolId() == ID_NO_TOOL_SELECTED )
442  SetRepeatItem( NULL );
443 }
444 
445 
446 void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
447 {
448  SCH_SCREEN* screen = GetScreen();
449 
450  if( screen->IsBlockActive() )
451  {
452  GetCanvas()->SetCursor( (wxStockCursor) GetGalCanvas()->GetDefaultCursor() );
453  screen->ClearBlockCommand();
454 
455  // Stop the current command (if any) but keep the current tool
457  }
458  else
459  {
460  if( m_canvas->IsMouseCaptured() ) // Stop the current command but keep the current tool
462  else // Deselect current tool
463  m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
464  }
465 
468  GetCanvas()->GetView()->ShowPreview( false );
469 }
470 
471 
472 void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
473 {
474  int id = aEvent.GetId();
475  int lastToolID = GetToolId();
476 
477  // Stop the current command and deselect the current tool.
478  m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
479 
480  switch( id )
481  {
482  case ID_NO_TOOL_SELECTED:
484  break;
485 
486  case ID_HIGHLIGHT:
487  SetToolID( ID_HIGHLIGHT, wxCURSOR_HAND, _("Highlight specific net") );
488  break;
489 
491  case ID_ZOOM_SELECTION:
492  // This tool is located on the main toolbar: switch it on or off on click
493  if( lastToolID != ID_ZOOM_SELECTION )
494  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
495  else
497  break;
498 
499  case ID_MENU_NOCONN_BUTT:
500  case ID_NOCONN_BUTT:
501  SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add no connect" ) );
502  break;
503 
504  case ID_MENU_WIRE_BUTT:
505  case ID_WIRE_BUTT:
506  SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
507  break;
508 
509  case ID_MENU_BUS_BUTT:
510  case ID_BUS_BUTT:
511  SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add bus" ) );
512  break;
513 
516  SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add lines" ) );
517  break;
518 
520  case ID_JUNCTION_BUTT:
521  SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add junction" ) );
522  break;
523 
524  case ID_MENU_LABEL_BUTT:
525  case ID_LABEL_BUTT:
526  SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add label" ) );
527  break;
528 
529  case ID_MENU_GLABEL_BUTT:
530  case ID_GLABEL_BUTT:
531  SetToolID( ID_GLABEL_BUTT, wxCURSOR_PENCIL, _( "Add global label" ) );
532  break;
533 
535  case ID_HIERLABEL_BUTT:
536  SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
537  break;
538 
541  SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) );
542  break;
543 
545  case ID_ADD_IMAGE_BUTT:
546  SetToolID( ID_ADD_IMAGE_BUTT, wxCURSOR_PENCIL, _( "Add image" ) );
547  break;
548 
551  SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
552  break;
553 
556  SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
557  break;
558 
561  SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add sheet" ) );
562  break;
563 
565  case ID_SHEET_PIN_BUTT:
566  SetToolID( ID_SHEET_PIN_BUTT, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
567  break;
568 
571  SetToolID( ID_IMPORT_HLABEL_BUTT, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
572  break;
573 
576  SetToolID( ID_SCH_PLACE_COMPONENT, wxCURSOR_PENCIL, _( "Add component" ) );
577  break;
578 
580  case ID_PLACE_POWER_BUTT:
581  SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add power" ) );
582  break;
583 
586  SetToolID( ID_SCHEMATIC_DELETE_ITEM_BUTT, wxCURSOR_BULLSEYE, _( "Delete item" ) );
587  break;
588 
589 #ifdef KICAD_SPICE
590  case ID_SIM_PROBE:
591  SetToolID( id, -1, _( "Add a simulator probe" ) );
592  //GAL TODO: m_canvas->SetCurrentCursor( CURSOR_PROBE );
593  break;
594 
595  case ID_SIM_TUNE:
596  SetToolID( id, -1, _( "Select a value to be tuned" ) );
597  //GAL TODO: m_canvas->SetCurrentCursor( CURSOR_TUNE );
598  break;
599 #endif /* KICAD_SPICE */
600 
601  default:
602  SetRepeatItem( NULL );
603  }
604 
605  // Simulate left click event if we got here from a hot key.
606  if( aEvent.GetClientObject() != NULL )
607  {
608  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
609 
610  OnLeftClick( nullptr, data->GetPosition() );
611  }
612 }
613 
614 
615 void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
616 {
617  if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar )
618  aEvent.Check( GetToolId() == aEvent.GetId() );
619 }
620 
621 
622 void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
623 {
624  PICKED_ITEMS_LIST pickList;
625  SCH_SCREEN* screen = GetScreen();
626  wxPoint pos = GetCrossHairPosition();
627 
628  if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
629  {
630  DeleteItemsInList( pickList );
631  SchematicCleanUp( true );
632  OnModify();
633  }
634 }
635 
636 
638 {
639  SCH_ITEM* item;
640  SCH_SCREEN* screen = GetScreen();
641 
643 
644  if( item )
645  {
646  bool itemHasConnections = item->IsConnectable();
647 
648  screen->SetCurItem( NULL );
649  SetRepeatItem( NULL );
650  DeleteItem( item );
651 
652  if( itemHasConnections )
654 
655  GetCanvas()->Refresh();
656  OnModify();
657  return true;
658  }
659 
660  return false;
661 }
662 
663 // This function is a callback function, called by the mouse cursor moving event
664 static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
665  const wxPoint& aPosition, bool aErase )
666 {
667  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
668  SCH_ITEM* item = screen->GetCurItem();
669  auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
670  auto view = panel->GetView();
671 
672  wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) );
673 
674  wxPoint cpos = aPanel->GetParent()->GetCrossHairPosition();
675  cpos -= item->GetStoredPos();
676 
677  item->SetPosition( cpos );
678 
679  view->Hide( item );
680  view->ClearPreview();
681  view->AddToPreview( item->Clone() );
682 
683  // Needed when moving a bitmap image to avoid ugly rendering and artifacts,
684  // because a bitmap is drawn only as non cached
685  if( item->Type() == SCH_BITMAP_T )
686  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
687 }
688 
689 
693 static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
694 {
695  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
696  SCH_ITEM* item = screen->GetCurItem();
697  SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
698  auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
699  auto view = panel->GetView();
700 
701  parent->SetRepeatItem( NULL );
702  screen->SetCurItem( NULL );
703  view->ClearPreview();
704  view->ClearHiddenFlags();
705 
706  if( item == NULL ) /* no current item */
707  return;
708 
709  if( item->IsNew() )
710  {
711  delete item;
712  }
713  else
714  {
715  SCH_ITEM* oldItem = parent->GetUndoItem();
716 
717  SCH_ITEM* currentItem;
718 
719  // Items that are children of other objects are undone by swapping the contents
720  // of the parent items.
721  if( (item->Type() == SCH_SHEET_PIN_T) || (item->Type() == SCH_FIELD_T) )
722  currentItem = (SCH_ITEM*) item->GetParent();
723  else
724  currentItem = item;
725 
726  wxCHECK_RET( oldItem != NULL && currentItem->Type() == oldItem->Type(),
727  wxT( "Cannot restore undefined or bad last schematic item." ) );
728 
729  // Never delete existing item, because it can be referenced by an undo/redo command
730  // Just restore its data
731 
732  view->Remove( currentItem );
733  currentItem->SwapData( oldItem );
734  item->ClearFlags();
735  view->Add( currentItem );
736  view->Hide( item, false );
737  }
738 
739  screen->TestDanglingEnds();
740  aPanel->Refresh();
741 }
742 
743 
745 {
746  wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) );
747 
748  SetRepeatItem( NULL );
749 
750  if( !aItem->IsNew() )
751  {
752  if( (aItem->Type() == SCH_SHEET_PIN_T) || (aItem->Type() == SCH_FIELD_T) )
753  SetUndoItem( (SCH_ITEM*) aItem->GetParent() );
754  else
755  SetUndoItem( aItem );
756  }
757 
758  std::vector<DANGLING_END_ITEM> emptySet;
759  aItem->UpdateDanglingState( emptySet );
760 
761  aItem->SetFlags( IS_MOVED );
762 
763  if( aItem->Type() == SCH_FIELD_T && aItem->GetParent()->Type() == SCH_COMPONENT_T )
764  {
765  // Now that we're moving a field, they're no longer autoplaced.
766  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( aItem->GetParent() );
767  parent->ClearFieldsAutoplaced();
768  }
769 
770  // These are owned by their parent, and so their parent must erase them
771  if( aItem->Type() == SCH_SHEET_PIN_T || aItem->Type() == SCH_FIELD_T )
772  RefreshItem( aItem );
773 
774  // For some items, moving the cursor to anchor is not good
775  // (for instance large hierarchical sheets od componants can have
776  // the anchor position outside the canvas)
777  // these items return IsMovableFromAnchorPoint() == false
778  // For these items, do not warp the cursor
779  if( aItem->IsMovableFromAnchorPoint() )
780  {
781  SetCrossHairPosition( aItem->GetPosition() );
783  aItem->SetStoredPos( wxPoint( 0,0 ) );
784  }
785  else
786  {
787  // Round the point under the cursor to a multiple of the grid
788  wxPoint cursorpos = GetCrossHairPosition() - aItem->GetPosition();
789  wxPoint gridsize = GetScreen()->GetGridSize();
790  cursorpos.x = ( cursorpos.x / gridsize.x ) * gridsize.x;
791  cursorpos.y = ( cursorpos.y / gridsize.y ) * gridsize.y;
792 
793  aItem->SetStoredPos( cursorpos );
794  }
795 
796  OnModify();
797 
798  GetScreen()->SetCurItem( aItem );
800  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
801 
802  m_canvas->Refresh();
803 }
804 
805 
806 void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
807 {
808  SCH_SCREEN* screen = GetScreen();
809  SCH_ITEM* item = screen->GetCurItem();
810 
811  if( item != NULL )
812  {
813  item = LocateAndShowItem( item->GetPosition() );
814  SendMessageToPCBNEW( item, NULL );
815  }
816  else
817  {
818  // If we didn't get here by a hot key, then something has gone wrong.
819  if( aEvent.GetInt() == 0 )
820  return;
821 
822  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
823 
824  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
825 
826  item = LocateAndShowItem( data->GetPosition() );
827  SendMessageToPCBNEW( item, NULL );
828  }
829 }
830 
831 
832 void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
833 {
834  SCH_SCREEN* screen = GetScreen();
835  SCH_ITEM* item = screen->GetCurItem();
837 
838  // Allows block rotate operation on hot key.
839  if( block.GetState() != STATE_NO_BLOCK )
840  {
841  // Compute the rotation center and put it on grid:
842  wxPoint rotationPoint = GetNearestGridPosition( block.Centre() );
843 
844  if( block.GetCommand() != BLOCK_DUPLICATE && block.GetCommand() != BLOCK_PASTE )
845  {
846  SaveCopyInUndoList( block.GetItems(), UR_ROTATED, block.AppendUndo(), rotationPoint );
847  block.SetAppendUndo();
848  }
849 
850  RotateListOfItems( block.GetItems(), rotationPoint );
851 
852  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
853  m_canvas->Refresh();
854  return;
855  }
856 
857  if( item == NULL )
858  {
859  // If we didn't get here by a hot key, then something has gone wrong.
860  if( aEvent.GetInt() == 0 )
861  return;
862 
863  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
864 
865  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
866 
868  aEvent.GetInt() );
869 
870  // Exit if no item found at the current location or the item is already being edited.
871  if( (item == NULL) || (item->GetFlags() != 0) )
872  return;
873  }
874 
875  switch( item->Type() )
876  {
877  case SCH_COMPONENT_T:
878  {
879  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
880 
881  if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
883  else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
885  else
886  wxFAIL_MSG( wxT( "Unknown rotate item command ID." ) );
887 
888  if( m_autoplaceFields )
889  component->AutoAutoplaceFields( GetScreen() );
890 
891  break;
892  }
893 
894  case SCH_TEXT_T:
895  case SCH_LABEL_T:
896  case SCH_GLOBAL_LABEL_T:
899  ChangeTextOrient( (SCH_TEXT*) item );
900  break;
901 
902  case SCH_BUS_BUS_ENTRY_T:
907  break;
908 
909  case SCH_FIELD_T:
911  RotateField( (SCH_FIELD*) item );
912  if( item->GetParent()->Type() == SCH_COMPONENT_T )
913  {
914  // Now that we're moving a field, they're no longer autoplaced.
915  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( item->GetParent() );
916  parent->ClearFieldsAutoplaced();
917  }
918  break;
919 
920  case SCH_BITMAP_T:
921  RotateImage( (SCH_BITMAP*) item );
922  // The bitmap is cached in Opengl: clear the cache, because
923  // the cache data is invalid
925  break;
926 
927  case SCH_SHEET_T:
928  if( !item->IsNew() ) // rotate a sheet during its creation has no sense
929  {
930  bool retCCW = ( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE );
931  RotateHierarchicalSheet( static_cast<SCH_SHEET*>( item ), retCCW );
932  }
933 
934  break;
935 
936  case SCH_JUNCTION_T:
937  case SCH_NO_CONNECT_T:
938  // these items are not rotated, because rotation does not change them.
939  break;
940 
941  default:
942  // Other items (wires...) cannot be rotated, at least during creation
943  if( item->IsNew() )
944  break;
945 
946  wxFAIL_MSG( wxString::Format( wxT( "Cannot rotate schematic item type %s." ),
947  GetChars( item->GetClass() ) ) );
948  }
949 
950  RefreshItem( item );
951 
952  if( item->IsMoving() )
953  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
954 
955  if( item->GetFlags() == 0 )
956  screen->SetCurItem( NULL );
957 }
958 
959 
960 void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
961 {
962  SCH_SCREEN* screen = GetScreen();
963  SCH_ITEM* item = screen->GetCurItem();
964 
965  if( item == NULL )
966  {
967  // If we didn't get here by a hot key, then something has gone wrong.
968  if( aEvent.GetInt() == 0 )
969  return;
970 
971  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
972 
973  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
974 
975  // Set the locat filter, according to the edit command
976  const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
977  const KICAD_T* filterListAux = NULL;
978 
979  switch( aEvent.GetId() )
980  {
983  filterListAux = SCH_COLLECTOR::ComponentsOnly;
984  break;
985 
988  filterListAux = SCH_COLLECTOR::ComponentsOnly;
989  break;
990 
993  filterListAux = SCH_COLLECTOR::ComponentsOnly;
994  break;
995 
998  filterListAux = SCH_COLLECTOR::ComponentsOnly;
999 
1000  default:
1001  break;
1002  }
1003 
1004  item = LocateAndShowItem( data->GetPosition(), filterList, aEvent.GetInt() );
1005 
1006  // If no item found, and if an auxiliary filter exists, try to use it
1007  if( !item && filterListAux )
1008  item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
1009 
1010  // Exit if no item found at the current location or the item is already being edited.
1011  if( (item == NULL) || (item->GetFlags() != 0) )
1012  return;
1013  }
1014 
1015  switch( item->Type() )
1016  {
1017  case SCH_COMPONENT_T:
1018  {
1019  switch( aEvent.GetId() )
1020  {
1022  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ) );
1023  break;
1024 
1026  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ) );
1027  break;
1028 
1030  EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ) );
1031  break;
1032 
1034  {
1035  wxString text = static_cast<SCH_COMPONENT*>( item )->GetField( DATASHEET )->GetText();
1036 
1037  if( !text.IsEmpty() )
1038  GetAssociatedDocument( this, text );
1039  }
1040  break;
1041 
1042  case ID_SCH_EDIT_ITEM:
1043  EditComponent( (SCH_COMPONENT*) item );
1044  break;
1045 
1046  default:
1047  wxFAIL_MSG( wxString::Format( wxT( "Invalid schematic component edit command ID %d" ),
1048  aEvent.GetId() ) );
1049  }
1050 
1051  break;
1052  }
1053 
1054  case SCH_SHEET_T:
1055  {
1056  bool doClearAnnotation;
1057  bool doRefresh = false;
1058  // Keep trace of existing sheet paths. EditSheet() can modify this list
1059  SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
1060 
1061  doRefresh = EditSheet( (SCH_SHEET*) item, m_CurrentSheet, &doClearAnnotation );
1062 
1063  if( doClearAnnotation ) // happens when the current sheet load a existing file
1064  { // we must clear "new" components annotation
1065  SCH_SCREENS screensList( g_RootSheet );
1066  // We clear annotation of new sheet paths here:
1067  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1068  // Clear annotation of m_CurrentSheet itself, because its sheetpath
1069  // is not a new path, but components managed by its sheet path must have
1070  // their annotation cleared, becuase they are new:
1071  ((SCH_SHEET*) item)->GetScreen()->ClearAnnotation( m_CurrentSheet );
1072  }
1073 
1074  if( doRefresh )
1075  m_canvas->Refresh();
1076  }
1077  break;
1078 
1079  case SCH_SHEET_PIN_T:
1080  EditSheetPin( (SCH_SHEET_PIN*) item, true );
1081  break;
1082 
1083  case SCH_TEXT_T:
1084  case SCH_LABEL_T:
1085  case SCH_GLOBAL_LABEL_T:
1087  EditSchematicText( (SCH_TEXT*) item );
1088  break;
1089 
1090  case SCH_FIELD_T:
1091  EditComponentFieldText( (SCH_FIELD*) item );
1092  break;
1093 
1094  case SCH_BITMAP_T:
1095 
1096  // The bitmap is cached in Opengl: clear the cache, because
1097  // the cache data is perhaps invalid
1098  if( EditImage( (SCH_BITMAP*) item ) )
1100 
1101  break;
1102 
1103  case SCH_LINE_T: // These items have no param to edit
1104  EditLine( (SCH_LINE*) item, true );
1105  break;
1106  case SCH_MARKER_T:
1107  case SCH_JUNCTION_T:
1108  case SCH_NO_CONNECT_T:
1109  break;
1110 
1111  default: // Unexpected item
1112  wxFAIL_MSG( wxString::Format( wxT( "Cannot edit schematic item type %s." ),
1113  GetChars( item->GetClass() ) ) );
1114  }
1115 
1116  RefreshItem( item );
1117 
1118  if( item->GetFlags() == 0 )
1119  screen->SetCurItem( NULL );
1120 }
1121 
1122 
1123 void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
1124 {
1125  SCH_SCREEN* screen = GetScreen();
1126  SCH_ITEM* item = screen->GetCurItem();
1127 
1128  // The easiest way to handle a menu or a hot key drag command
1129  // is to simulate a block drag command
1130  //
1131  // When a drag item is requested, some items use a BLOCK_DRAG_ITEM drag type
1132  // an some items use a BLOCK_DRAG drag type (mainly a junction)
1133  // a BLOCK_DRAG collects all items in a block (here a 2x2 rect centered on the cursor)
1134  // and BLOCK_DRAG_ITEM drag only the selected item
1135  BLOCK_COMMAND_T dragType = BLOCK_DRAG_ITEM;
1136 
1137  if( item == NULL )
1138  {
1139  // If we didn't get here by a hot key, then something has gone wrong.
1140  if( aEvent.GetInt() == 0 )
1141  return;
1142 
1143  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1144 
1145  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1146 
1148  aEvent.GetInt() );
1149 
1150  // Exit if no item found at the current location or the item is already being edited.
1151  if( (item == NULL) || (item->GetFlags() != 0) )
1152  return;
1153 
1154  // When a junction or a node is found, a BLOCK_DRAG is better
1157  {
1158  dragType = BLOCK_DRAG;
1159  }
1160  }
1161 
1162  switch( item->Type() )
1163  {
1164  case SCH_BUS_BUS_ENTRY_T:
1165  case SCH_BUS_WIRE_ENTRY_T:
1166  case SCH_LINE_T:
1167  case SCH_JUNCTION_T:
1168  case SCH_COMPONENT_T:
1169  case SCH_LABEL_T:
1170  case SCH_GLOBAL_LABEL_T:
1172  case SCH_SHEET_T:
1173  case SCH_TEXT_T:
1175 
1176  if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1177  {
1178  if( !HandleBlockBegin( nullptr, dragType, GetCrossHairPosition() ) )
1179  break;
1180 
1181  // Give a non null size to the search block:
1182  screen->m_BlockLocate.Inflate( 1 );
1184  HandleBlockEnd( nullptr );
1185  }
1186 
1187  break;
1188 
1189  default:
1190  wxFAIL_MSG( wxString::Format( wxT( "Cannot drag schematic item type %s." ),
1191  GetChars( item->GetClass() ) ) );
1192  }
1193 }
1194 
1195 
1196 void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
1197 {
1198  SCH_SCREEN* screen = GetScreen();
1199  SCH_ITEM* item = screen->GetCurItem();
1200  BLOCK_SELECTOR& block = screen->m_BlockLocate;
1201 
1202  // Allows block rotate operation on hot key.
1203  if( block.GetState() != STATE_NO_BLOCK )
1204  {
1205  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1206  {
1207  // Compute the mirror center and put it on grid.
1208  wxPoint mirrorPt = block.Centre();
1209  mirrorPt = GetNearestGridPosition( mirrorPt );
1210  SetCrossHairPosition( mirrorPt );
1211 
1212  if( block.GetCommand() != BLOCK_DUPLICATE && block.GetCommand() != BLOCK_PASTE )
1213  {
1214  SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_X, block.AppendUndo(), mirrorPt );
1215  block.SetAppendUndo();
1216  }
1217 
1218  MirrorX( block.GetItems(), mirrorPt );
1219 
1220  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
1221  m_canvas->Refresh();
1222  return;
1223  }
1224  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1225  {
1226  // Compute the mirror center and put it on grid.
1227  wxPoint mirrorPt = block.Centre();
1228  mirrorPt = GetNearestGridPosition( mirrorPt );
1229  SetCrossHairPosition( mirrorPt );
1230 
1231  if( block.GetCommand() != BLOCK_DUPLICATE && block.GetCommand() != BLOCK_PASTE )
1232  {
1233  SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_Y, block.AppendUndo(), mirrorPt );
1234  block.SetAppendUndo();
1235  }
1236 
1237  MirrorY( block.GetItems(), mirrorPt );
1238 
1239  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
1240  m_canvas->Refresh();
1241  return;
1242  }
1243  else
1244  {
1245  wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
1246  }
1247 
1248  return;
1249  }
1250 
1251  if( item == NULL )
1252  {
1253  // If we didn't get here by a hot key, then something has gone wrong.
1254  if( aEvent.GetInt() == 0 )
1255  return;
1256 
1257  EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
1258 
1259  wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
1260 
1262  aEvent.GetInt() );
1263 
1264  // Exit if no item found at the current location or the item is already being edited.
1265  if( (item == NULL) || (item->GetFlags() != 0) )
1266  return;
1267  }
1268 
1269 
1270  switch( item->Type() )
1271  {
1272  case SCH_COMPONENT_T:
1273  {
1274  SCH_COMPONENT *component = static_cast<SCH_COMPONENT*>( item );
1275  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1277  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1279  else if( aEvent.GetId() == ID_SCH_ORIENT_NORMAL )
1281  else
1282  wxFAIL_MSG( wxT( "Invalid orient schematic component command ID." ) );
1283 
1284  if( m_autoplaceFields )
1285  component->AutoAutoplaceFields( GetScreen() );
1286 
1287  break;
1288  }
1289 
1290  case SCH_BITMAP_T:
1291  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1292  MirrorImage( (SCH_BITMAP*) item, true );
1293  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1294  MirrorImage( (SCH_BITMAP*) item, false );
1295 
1296  // The bitmap is cached in Opengl: clear the cache, because
1297  // the cache data is invalid
1299  break;
1300 
1301  case SCH_SHEET_T:
1302  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1303  MirrorSheet( (SCH_SHEET*) item, true );
1304  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1305  MirrorSheet( (SCH_SHEET*) item, false );
1306 
1307  break;
1308 
1309  case SCH_BUS_BUS_ENTRY_T:
1310  case SCH_BUS_WIRE_ENTRY_T:
1312  SaveCopyInUndoList( item, UR_CHANGED );
1313 
1314  if( aEvent.GetId() == ID_SCH_MIRROR_X )
1316  else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
1318 
1319  break;
1320 
1321  default:
1322  // This object cannot be oriented.
1323  ;
1324  }
1325 
1326  RefreshItem( item );
1327 
1328  if( item->IsMoving() )
1329  m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
1330 
1331  if( item->GetFlags() == 0 )
1332  screen->SetCurItem( NULL );
1333 }
virtual BASE_SCREEN * GetScreen()=0
SCH_ITEM * GetUndoItem() const
Definition of the SCH_SHEET class for Eeschema.
bool DeleteItemAtCrossHair()
Delete the item found under the cross hair.
Definition: schedit.cpp:637
void OrientComponent(COMPONENT_ORIENTATION_T aOrientation=CMP_NORMAL)
Rotate and mirror a component.
Definition: getpart.cpp:279
Class SCH_SHEET_LIST.
SCH_JUNCTION * AddJunction(const wxPoint &aPosition, bool aPutInUndoList=false)
Add a new junction at aPosition.
BLOCK_COMMAND_T GetCommand() const
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:56
void DeleteConnection(bool DeleteFullConnection)
Definition: schedit.cpp:622
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.
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
void RotateField(SCH_FIELD *aField)
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
int EditLine(SCH_LINE *aLine, bool aRedraw)
Function EditLine displays the dialog for editing the parameters of aLine.
Definition: sch_line.cpp:784
BLOCK_STATE_T GetState() const
bool SchematicCleanUp(bool aAppend=false)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_line.h:64
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item.
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:379
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
name of datasheet
static const KICAD_T RotatableItems[]
A scan list for all rotatable schematic items.
bool IsBlockActive() const
Definition: base_screen.h:499
SCH_TEXT * CreateNewText(int aType)
Definition: edit_label.cpp:68
void RotateListOfItems(PICKED_ITEMS_LIST &aItemsList, const wxPoint &rotationPoint)
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...
virtual bool IsMovableFromAnchorPoint()
Virtual function IsMovableFromAnchorPoint.
bool IsDraggableJunction() const
Function IsDraggableJunction tests to see if the collected items form a draggable junction.
This file is part of the common library.
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 ...
This file is part of the common library.
bool IsMoving() const
Definition: base_struct.h:221
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:935
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.
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1401
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...
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:960
void ConvertPart(SCH_COMPONENT *DrawComponent)
Definition: getpart.cpp:351
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
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: sch_screen.h:196
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
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:49
bool IsNew() const
Definition: base_struct.h:219
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.
virtual bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList)
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it's dangling state...
wxPoint & GetStoredPos()
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
bool IsCorner() const
Function IsCorner tests if the collected items forms as corner of two line segments.
#define VALUE
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.
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:744
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.
void OnUpdateSelectTool(wxUpdateUIEvent &aEvent)
Definition: schedit.cpp:615
void OnRotate(wxCommandEvent &aEvent)
Handle the ID_SCH_ROTATE_CLOCKWISE and ID_SCH_ROTATE_COUNTERCLOCKWISE events used to rotate schematic...
Definition: schedit.cpp:832
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...
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
EDA_ITEM * GetParent() const
Definition: base_struct.h:211
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
virtual void MirrorX(int aXaxis_position)=0
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
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.
virtual void MirrorY(int aYaxis_position)=0
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:340
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:160
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
KIGFX::SCH_VIEW * GetView() const
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:446
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:664
static const KICAD_T EditableItems[]
A scan list for all editable schematic items.
void ReSizeSheet(SCH_SHEET *Sheet, wxDC *DC)
Definition: sheet.cpp:434
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Return the nearest aGridSize location to aPosition.
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:126
bool HasUndefinedPins()
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:232
Definition the SCH_COMPONENT class for Eeschema.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
see class PGM_BASE
static const KICAD_T DraggableItems[]
A scan list for all draggable schematic items.
Segment description base class to describe items which have 2 end points (track, wire,...
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
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
bool EditImage(SCH_BITMAP *aItem)
Launches the "Edit Image" dialog to modify an image.
void RefreshItem(SCH_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
void OnLeftClick(wxDC *aDC, const wxPoint &aPosition) override
bool IsNode(bool aIncludePins=true) const
Function IsNode tests if the collected items form a node.
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Definition: sch_screen.cpp:912
static const KICAD_T CmpFieldReferenceOnly[]
A scan list for a specific editable field: Reference.
virtual void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_text.cpp:214
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
void OnSelectTool(wxCommandEvent &aEvent)
Definition: schedit.cpp:472
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
virtual wxString GetClass() const override
Function GetClass returns the class name.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
void OnDragItem(wxCommandEvent &aEvent)
Handle the ID_SCH_DRAG_ITEM event used to drag schematic items.
Definition: schedit.cpp:1123
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:1196
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
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:258
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:275
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_bitmap.h:99
void SetStoredPos(wxPoint aPos)
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:293
static void abortMoveItem(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Callback function called when aborting a move item with mouse cursor command.
Definition: schedit.cpp:693
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.
int GetToolId() const
Definition: draw_frame.h:526
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)
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
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:806
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113