KiCad PCB EDA Suite
sch_edit_tool.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 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include <tool/tool_manager.h>
25 #include <tools/sch_edit_tool.h>
28 #include <tools/ee_picker_tool.h>
29 #include <tools/sch_move_tool.h>
30 #include <ee_actions.h>
31 #include <ee_hotkeys.h>
32 #include <bitmaps.h>
33 #include <confirm.h>
34 #include <eda_doc.h>
35 #include <base_struct.h>
36 #include <sch_item.h>
37 #include <sch_component.h>
38 #include <sch_sheet.h>
39 #include <sch_text.h>
40 #include <sch_bitmap.h>
41 #include <sch_view.h>
42 #include <sch_line.h>
43 #include <sch_item.h>
44 #include <sch_bus_entry.h>
45 #include <sch_edit_frame.h>
46 #include <eeschema_id.h>
47 #include <status_popup.h>
48 #include <wx/gdicmn.h>
49 #include "sch_drawing_tools.h"
50 
51 
52 TOOL_ACTION EE_ACTIONS::duplicate( "eeschema.InteractiveEdit.duplicate",
54  _( "Duplicate" ), _( "Duplicates the selected item(s)" ),
55  duplicate_xpm );
56 
57 TOOL_ACTION EE_ACTIONS::repeatDrawItem( "eeschema.InteractiveEdit.repeatDrawItem",
59  _( "Repeat Last Item" ), _( "Duplicates the last drawn item" ),
60  nullptr );
61 
62 TOOL_ACTION EE_ACTIONS::rotateCW( "eeschema.InteractiveEdit.rotateCW",
63  AS_GLOBAL, 0,
64  _( "Rotate Clockwise" ), _( "Rotates selected item(s) clockwise" ),
65  rotate_cw_xpm );
66 
67 TOOL_ACTION EE_ACTIONS::rotateCCW( "eeschema.InteractiveEdit.rotateCCW",
69  _( "Rotate" ), _( "Rotates selected item(s) counter-clockwise" ),
70  rotate_ccw_xpm );
71 
72 TOOL_ACTION EE_ACTIONS::mirrorX( "eeschema.InteractiveEdit.mirrorX",
74  _( "Mirror Around Horizontal Axis" ), _( "Flips selected item(s) from top to bottom" ),
75  mirror_h_xpm );
76 
77 TOOL_ACTION EE_ACTIONS::mirrorY( "eeschema.InteractiveEdit.mirrorY",
79  _( "Mirror Around Vertical Axis" ), _( "Flips selected item(s) from left to right" ),
80  mirror_v_xpm );
81 
82 TOOL_ACTION EE_ACTIONS::properties( "eeschema.InteractiveEdit.properties",
84  _( "Properties..." ), _( "Displays item properties dialog" ),
85  edit_xpm );
86 
87 TOOL_ACTION EE_ACTIONS::editReference( "eeschema.InteractiveEdit.editReference",
89  _( "Edit Reference..." ), _( "Displays reference field dialog" ),
90  edit_comp_ref_xpm );
91 
92 TOOL_ACTION EE_ACTIONS::editValue( "eeschema.InteractiveEdit.editValue",
94  _( "Edit Value..." ), _( "Displays value field dialog" ),
95  edit_comp_value_xpm );
96 
97 TOOL_ACTION EE_ACTIONS::editFootprint( "eeschema.InteractiveEdit.editFootprint",
99  _( "Edit Footprint..." ), _( "Displays footprint field dialog" ),
100  edit_comp_footprint_xpm );
101 
102 TOOL_ACTION EE_ACTIONS::autoplaceFields( "eeschema.InteractiveEdit.autoplaceFields",
104  _( "Autoplace Fields" ), _( "Runs the automatic placement algorithm on the symbol's fields" ),
105  autoplace_fields_xpm );
106 
107 TOOL_ACTION EE_ACTIONS::convertDeMorgan( "eeschema.InteractiveEdit.convertDeMorgan",
108  AS_GLOBAL, 0,
109  _( "DeMorgan Conversion" ), _( "Switch between DeMorgan representations" ),
110  morgan2_xpm );
111 
112 TOOL_ACTION EE_ACTIONS::toShapeSlash( "eeschema.InteractiveEdit.toShapeSlash",
113  AS_GLOBAL, 0,
114  _( "Set Bus Entry Shape /" ), _( "Change the bus entry shape to /" ),
115  change_entry_orient_xpm );
116 
117 TOOL_ACTION EE_ACTIONS::toShapeBackslash( "eeschema.InteractiveEdit.toShapeBackslash",
118  AS_GLOBAL, 0,
119  _( "Set Bus Entry Shape \\" ), _( "Change the bus entry shape to \\" ),
120  change_entry_orient_xpm );
121 
122 TOOL_ACTION EE_ACTIONS::toLabel( "eeschema.InteractiveEdit.toLabel",
123  AS_GLOBAL, 0,
124  _( "Change to Label" ), _( "Change existing item to a label" ),
125  add_line_label_xpm );
126 
127 TOOL_ACTION EE_ACTIONS::toHLabel( "eeschema.InteractiveEdit.toHLabel",
128  AS_GLOBAL, 0,
129  _( "Change to Hierarchical Label" ), _( "Change existing item to a hierarchical label" ),
130  add_hierarchical_label_xpm );
131 
132 TOOL_ACTION EE_ACTIONS::toGLabel( "eeschema.InteractiveEdit.toGLabel",
133  AS_GLOBAL, 0,
134  _( "Change to Global Label" ), _( "Change existing item to a global label" ),
135  add_glabel_xpm );
136 
137 TOOL_ACTION EE_ACTIONS::toText( "eeschema.InteractiveEdit.toText",
138  AS_GLOBAL, 0,
139  _( "Change to Text" ), _( "Change existing item to a text comment" ),
140  text_xpm );
141 
142 TOOL_ACTION EE_ACTIONS::cleanupSheetPins( "eeschema.InteractiveEdit.cleanupSheetPins",
143  AS_GLOBAL, 0,
144  _( "Cleanup Sheet Pins" ), _( "Delete unreferenced sheet pins" ),
145  nullptr );
146 
147 TOOL_ACTION EE_ACTIONS::symbolProperties( "eeschema.InteractiveEdit.symbolProperties",
148  AS_GLOBAL, 0,
149  _( "Symbol Properties..." ), _( "Displays symbol properties dialog" ),
150  part_properties_xpm );
151 
152 TOOL_ACTION EE_ACTIONS::pinTable( "eeschema.InteractiveEdit.pinTable",
153  AS_GLOBAL, 0,
154  _( "Pin Table..." ), _( "Displays pin table for bulk editing of pins" ),
155  pin_table_xpm );
156 
157 TOOL_ACTION EE_ACTIONS::doDelete( "eeschema.InteractiveEdit.doDelete",
159  _( "Delete" ), _( "Deletes selected item(s)" ),
160  delete_xpm );
161 
162 TOOL_ACTION EE_ACTIONS::deleteItemCursor( "eeschema.InteractiveEdit.deleteItemCursor",
163  AS_GLOBAL, 0,
164  _( "DoDelete Items" ), _( "DoDelete clicked items" ),
165  delete_xpm, AF_ACTIVATE );
166 
167 TOOL_ACTION EE_ACTIONS::breakWire( "eeschema.InteractiveEdit.breakWire",
168  AS_GLOBAL, 0,
169  _( "Break Wire" ), _( "Divide a wire into segments which can be dragged independently" ),
170  break_line_xpm );
171 
172 TOOL_ACTION EE_ACTIONS::breakBus( "eeschema.InteractiveEdit.breakBus",
173  AS_GLOBAL, 0,
174  _( "Break Bus" ), _( "Divide a bus into segments which can be dragged independently" ),
175  break_line_xpm );
176 
177 
179 {
180 public:
182  {
183  SetIcon( component_select_unit_xpm );
184  SetTitle( _( "Symbol Unit" ) );
185  }
186 
187 
188 protected:
189  ACTION_MENU* create() const override
190  {
191  return new SYMBOL_UNIT_MENU();
192  }
193 
194 private:
195  void update() override
196  {
198  SELECTION& selection = selTool->GetSelection();
199  SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
200 
201  if( !component )
202  {
203  Append( ID_POPUP_SCH_UNFOLD_BUS, _( "no symbol selected" ), wxEmptyString );
204  Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
205  return;
206  }
207 
208  int unit = component->GetUnit();
209  auto partRef = component->GetPartRef().lock();
210 
211  if( !partRef || partRef->GetUnitCount() < 2 )
212  {
213  Append( ID_POPUP_SCH_UNFOLD_BUS, _( "symbol is not multi-unit" ), wxEmptyString );
214  Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
215  return;
216  }
217 
218  for( int ii = 0; ii < partRef->GetUnitCount(); ii++ )
219  {
220  wxString num_unit;
221  num_unit.Printf( _( "Unit %s" ), LIB_PART::SubReference( ii + 1, false ) );
222 
223  wxMenuItem * item = Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, num_unit, wxEmptyString,
224  wxITEM_CHECK );
225  if( unit == ii + 1 )
226  item->Check(true);
227 
228  // The ID max for these submenus is ID_POPUP_SCH_SELECT_UNIT_CMP_MAX
229  // See eeschema_id to modify this value.
231  break; // We have used all IDs for these submenus
232  }
233  }
234 };
235 
236 
238  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveEdit" )
239 {
240 }
241 
242 
244 {
245 }
246 
247 
249 {
251 
254 
255  wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
256 
257  auto sheetTool = [ this ] ( const SELECTION& aSel ) {
258  return ( m_frame->GetToolId() == ID_SHEET_TOOL );
259  };
260 
261  auto anyTextTool = [ this ] ( const SELECTION& aSel ) {
262  return ( m_frame->GetToolId() == ID_LABEL_TOOL
266  };
267 
268  auto duplicateCondition = [] ( const SELECTION& aSel ) {
270  return false;
271 
272  return true;
273  };
274 
275  auto orientCondition = [] ( const SELECTION& aSel ) {
276  if( aSel.Empty() )
277  return false;
278 
280  return false;
281 
282  SCH_ITEM* item = (SCH_ITEM*) aSel.Front();
283 
284  if( aSel.GetSize() > 1 )
285  return true;
286 
287  switch( item->Type() )
288  {
289  case SCH_MARKER_T:
290  case SCH_JUNCTION_T:
291  case SCH_NO_CONNECT_T:
293  case SCH_BUS_BUS_ENTRY_T:
294  case SCH_LINE_T:
295  case SCH_SHEET_PIN_T:
296  case SCH_PIN_T:
297  return false;
298  default:
299  return true;
300  }
301  };
302 
303  auto propertiesCondition = [] ( const SELECTION& aSel ) {
304  if( aSel.GetSize() != 1 )
305  return false;
306 
307  switch( static_cast<EDA_ITEM*>( aSel.Front() )->Type() )
308  {
309  case SCH_MARKER_T:
310  case SCH_JUNCTION_T:
311  case SCH_NO_CONNECT_T:
313  case SCH_BUS_BUS_ENTRY_T:
314  case SCH_LINE_T:
315  case SCH_SHEET_PIN_T:
316  case SCH_PIN_T:
317  return false;
318  default:
319  return true;
320  }
321  };
322 
323  KICAD_T toLabelTypes[] = { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
324  auto toLabelCondition = EE_CONDITIONS::Count( 1 )
325  && EE_CONDITIONS::OnlyTypes( toLabelTypes );
326 
327  KICAD_T toHLableTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_TEXT_T, EOT };
328  auto toHLabelCondition = EE_CONDITIONS::Count( 1 )
329  && EE_CONDITIONS::OnlyTypes( toHLableTypes);
330 
331  KICAD_T toGLableTypes[] = { SCH_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
332  auto toGLabelCondition = EE_CONDITIONS::Count( 1 )
333  && EE_CONDITIONS::OnlyTypes( toGLableTypes);
334 
336  auto toTextlCondition = EE_CONDITIONS::Count( 1 )
337  && EE_CONDITIONS::OnlyTypes( toTextTypes);
338 
340  auto entryCondition = EE_CONDITIONS::MoreThan( 0 )
341  && EE_CONDITIONS::OnlyTypes( entryTypes );
342 
343  auto singleComponentCondition = EE_CONDITIONS::Count( 1 )
345 
346  auto wireSelectionCondition = EE_CONDITIONS::MoreThan( 0 )
348 
349  auto busSelectionCondition = EE_CONDITIONS::MoreThan( 0 )
351 
352  auto singleSheetCondition = EE_CONDITIONS::Count( 1 )
354 
355  //
356  // Add edit actions to the move tool menu
357  //
358  if( moveTool )
359  {
360  CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
361 
363  moveMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition );
364  moveMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition );
365  moveMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition );
366  moveMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition );
367  moveMenu.AddItem( EE_ACTIONS::duplicate, duplicateCondition );
369 
370  moveMenu.AddItem( EE_ACTIONS::properties, propertiesCondition );
371  moveMenu.AddItem( EE_ACTIONS::editReference, singleComponentCondition );
372  moveMenu.AddItem( EE_ACTIONS::editValue, singleComponentCondition );
373  moveMenu.AddItem( EE_ACTIONS::editFootprint, singleComponentCondition );
375 
376  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu = std::make_shared<SYMBOL_UNIT_MENU>();
377  symUnitMenu->SetTool( this );
378  m_menu.AddSubMenu( symUnitMenu );
379  moveMenu.AddMenu( symUnitMenu.get(), EE_CONDITIONS::SingleMultiUnitSymbol, 1 );
380 
384  }
385 
386  //
387  // Add editing actions to the drawing tool menu
388  //
389  CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
390 
391  drawMenu.AddSeparator( EE_CONDITIONS::NotEmpty, 200 );
392  drawMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
393  drawMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
394  drawMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition, 200 );
395  drawMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition, 200 );
396 
397  drawMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
398  drawMenu.AddItem( EE_ACTIONS::editReference, singleComponentCondition, 200 );
399  drawMenu.AddItem( EE_ACTIONS::editValue, singleComponentCondition, 200 );
400  drawMenu.AddItem( EE_ACTIONS::editFootprint, singleComponentCondition, 200 );
402 
403  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu2 = std::make_shared<SYMBOL_UNIT_MENU>();
404  symUnitMenu2->SetTool( drawingTools );
405  drawingTools->GetToolMenu().AddSubMenu( symUnitMenu2 );
406  drawMenu.AddMenu( symUnitMenu2.get(), EE_CONDITIONS::SingleMultiUnitSymbol, 1 );
407 
409  singleComponentCondition && EE_CONDITIONS::Idle, 200 );
410 
411  drawMenu.AddItem( EE_ACTIONS::toShapeSlash, entryCondition, 200 );
412  drawMenu.AddItem( EE_ACTIONS::toShapeBackslash, entryCondition, 200 );
413  drawMenu.AddItem( EE_ACTIONS::toLabel, anyTextTool && EE_CONDITIONS::Idle, 200 );
414  drawMenu.AddItem( EE_ACTIONS::toHLabel, anyTextTool && EE_CONDITIONS::Idle, 200 );
415  drawMenu.AddItem( EE_ACTIONS::toGLabel, anyTextTool && EE_CONDITIONS::Idle, 200 );
416  drawMenu.AddItem( EE_ACTIONS::toText, anyTextTool && EE_CONDITIONS::Idle, 200 );
417  drawMenu.AddItem( EE_ACTIONS::cleanupSheetPins, sheetTool && EE_CONDITIONS::Idle, 200 );
418 
419  //
420  // Add editing actions to the selection tool menu
421  //
423 
424  selToolMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
425  selToolMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
426  selToolMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition, 200 );
427  selToolMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition, 200 );
428  selToolMenu.AddItem( EE_ACTIONS::duplicate, duplicateCondition, 200 );
430 
431  selToolMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
435  selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, singleComponentCondition, 200 );
437 
438  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu3 = std::make_shared<SYMBOL_UNIT_MENU>();
439  symUnitMenu3->SetTool( m_selectionTool );
440  m_selectionTool->GetToolMenu().AddSubMenu( symUnitMenu3 );
441  selToolMenu.AddMenu( symUnitMenu3.get(), EE_CONDITIONS::SingleMultiUnitSymbol, 1 );
442 
444  singleComponentCondition && EE_CONDITIONS::Idle, 200 );
445 
446  selToolMenu.AddItem( EE_ACTIONS::toShapeSlash, entryCondition, 200 );
447  selToolMenu.AddItem( EE_ACTIONS::toShapeBackslash, entryCondition, 200 );
448  selToolMenu.AddItem( EE_ACTIONS::toLabel, toLabelCondition, 200 );
449  selToolMenu.AddItem( EE_ACTIONS::toHLabel, toHLabelCondition, 200 );
450  selToolMenu.AddItem( EE_ACTIONS::toGLabel, toGLabelCondition, 200 );
451  selToolMenu.AddItem( EE_ACTIONS::toText, toTextlCondition, 200 );
452  selToolMenu.AddItem( EE_ACTIONS::cleanupSheetPins, singleSheetCondition, 200 );
453 
454  selToolMenu.AddSeparator( EE_CONDITIONS::Idle, 200 );
457  selToolMenu.AddItem( ACTIONS::paste, EE_CONDITIONS::Idle, 200 );
458 
459  return true;
460 }
461 
462 
463 int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
464 {
466 
467  if( selection.GetSize() == 0 )
468  return 0;
469 
470  wxPoint rotPoint;
471  bool clockwise = ( aEvent.Matches( EE_ACTIONS::rotateCW.MakeEvent() ) );
472  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
473  bool connections = false;
474  bool moving = item->IsMoving();
475 
476  if( selection.GetSize() == 1 )
477  {
478  if( !moving )
480 
481  switch( item->Type() )
482  {
483  case SCH_COMPONENT_T:
484  {
485  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
486 
487  if( clockwise )
488  component->SetOrientation( CMP_ROTATE_CLOCKWISE );
489  else
491 
492  if( m_frame->GetAutoplaceFields() )
493  component->AutoAutoplaceFields( m_frame->GetScreen() );
494 
495  break;
496  }
497 
498  case SCH_TEXT_T:
499  case SCH_LABEL_T:
500  case SCH_GLOBAL_LABEL_T:
501  case SCH_HIER_LABEL_T:
502  {
503  SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
504  textItem->SetLabelSpinStyle( ( textItem->GetLabelSpinStyle() + 1 ) & 3 );
505  break;
506  }
507 
508  case SCH_BUS_BUS_ENTRY_T:
510  item->Rotate( item->GetPosition() );
511  break;
512 
513  case SCH_FIELD_T:
514  {
515  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
516 
517  if( field->GetTextAngle() == TEXT_ANGLE_HORIZ )
518  field->SetTextAngle( TEXT_ANGLE_VERT );
519  else
520  field->SetTextAngle( TEXT_ANGLE_HORIZ );
521 
522  // Now that we're moving a field, they're no longer autoplaced.
523  if( item->GetParent()->Type() == SCH_COMPONENT_T )
524  {
525  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( item->GetParent() );
526  parent->ClearFieldsAutoplaced();
527  }
528 
529  break;
530  }
531 
532  case SCH_BITMAP_T:
533  item->Rotate( item->GetPosition() );
534 
535  // The bitmap is cached in Opengl: clear the cache to redraw
537  break;
538 
539  case SCH_SHEET_T:
540  // Rotate the sheet on itself. Sheets do not have a anchor point.
541  rotPoint = m_frame->GetNearestGridPosition( item->GetBoundingBox().Centre() );
542 
543  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
544  item->Rotate( rotPoint );
545 
546  break;
547 
548  default:
549  break;
550  }
551 
552  connections = item->IsConnectable();
553  m_frame->RefreshItem( item );
554  }
555  else if( selection.GetSize() > 1 )
556  {
557  rotPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() );
558 
559  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
560  {
561  item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
562 
563  if( !moving )
564  saveCopyInUndoList( item, UR_CHANGED, ii > 0 );
565 
566  if( item->Type() == SCH_LINE_T )
567  {
568  SCH_LINE* line = (SCH_LINE*) item;
569 
570  if( item->GetFlags() & STARTPOINT )
571  line->RotateStart( rotPoint );
572 
573  if( item->GetFlags() & ENDPOINT )
574  line->RotateEnd( rotPoint );
575  }
576  else
577  {
578  item->Rotate( rotPoint );
579  }
580 
581  connections |= item->IsConnectable();
582  m_frame->RefreshItem( item );
583  }
584  }
585 
587 
588  if( !item->IsMoving() )
589  {
590  if( selection.IsHover() )
592 
593  if( connections )
595 
596  m_frame->OnModify();
597  }
598 
599  return 0;
600 }
601 
602 
603 int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
604 {
606 
607  if( selection.GetSize() == 0 )
608  return 0;
609 
610  wxPoint mirrorPoint;
611  bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorX.MakeEvent() ) );
612  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
613  bool connections = false;
614  bool moving = item->IsMoving();
615 
616  if( selection.GetSize() == 1 )
617  {
618  if( !moving )
620 
621  switch( item->Type() )
622  {
623  case SCH_COMPONENT_T:
624  {
625  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
626 
627  if( xAxis )
628  component->SetOrientation( CMP_MIRROR_X );
629  else
630  component->SetOrientation( CMP_MIRROR_Y );
631 
632  if( m_frame->GetAutoplaceFields() )
633  component->AutoAutoplaceFields( m_frame->GetScreen() );
634 
635  break;
636  }
637 
638  case SCH_TEXT_T:
639  case SCH_LABEL_T:
640  case SCH_GLOBAL_LABEL_T:
641  case SCH_HIER_LABEL_T:
642  {
643  SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
644  int spin = textItem->GetLabelSpinStyle();
645 
646  if( xAxis && spin % 2 )
647  textItem->SetLabelSpinStyle( ( spin + 2 ) % 4 );
648  else if ( !xAxis && !( spin % 2 ) )
649  textItem->SetLabelSpinStyle( ( spin + 2 ) % 4 );
650  break;
651  }
652 
653  case SCH_BUS_BUS_ENTRY_T:
655  if( xAxis )
656  item->MirrorX( item->GetPosition().y );
657  else
658  item->MirrorY( item->GetPosition().x );
659  break;
660 
661  case SCH_FIELD_T:
662  {
663  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
664 
665  if( xAxis )
667  else
669 
670  // Now that we're re-justifying a field, they're no longer autoplaced.
671  if( item->GetParent()->Type() == SCH_COMPONENT_T )
672  {
673  SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( item->GetParent() );
674  parent->ClearFieldsAutoplaced();
675  }
676 
677  break;
678  }
679 
680  case SCH_BITMAP_T:
681  if( xAxis )
682  item->MirrorX( item->GetPosition().y );
683  else
684  item->MirrorY( item->GetPosition().x );
685 
686  // The bitmap is cached in Opengl: clear the cache to redraw
688  break;
689 
690  case SCH_SHEET_T:
691  // Mirror the sheet on itself. Sheets do not have a anchor point.
692  mirrorPoint = m_frame->GetNearestGridPosition( item->GetBoundingBox().Centre() );
693 
694  if( xAxis )
695  item->MirrorX( mirrorPoint.y );
696  else
697  item->MirrorY( mirrorPoint.x );
698 
699  break;
700 
701  default:
702  break;
703  }
704 
705  connections = item->IsConnectable();
706  m_frame->RefreshItem( item );
707  }
708  else if( selection.GetSize() > 1 )
709  {
710  mirrorPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() );
711 
712  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
713  {
714  item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
715 
716  if( !moving )
717  saveCopyInUndoList( item, UR_CHANGED, ii > 0 );
718 
719  if( xAxis )
720  item->MirrorX( mirrorPoint.y );
721  else
722  item->MirrorY( mirrorPoint.x );
723 
724  connections |= item->IsConnectable();
725  m_frame->RefreshItem( item );
726  }
727  }
728 
730 
731  if( !item->IsMoving() )
732  {
733  if( selection.IsHover() )
735 
736  if( connections )
738 
739  m_frame->OnModify();
740  }
741 
742  return 0;
743 }
744 
745 
747 {
748  static KICAD_T duplicatableItems[] =
749  {
751  SCH_LINE_T,
754  SCH_TEXT_T,
755  SCH_LABEL_T,
759  SCH_SHEET_T,
761  EOT
762  };
763 
764  SELECTION& selection = m_selectionTool->RequestSelection( duplicatableItems );
765 
766  if( selection.GetSize() == 0 )
767  return 0;
768 
769  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
770  // up dragging around a stack of objects...
771  if( selection.Front()->IsNew() )
772  return 0;
773 
774  EDA_ITEMS newItems;
775 
776  // Keep track of existing sheet paths. Duplicating a selection can modify this list
777  bool copiedSheets = false;
778  SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
779 
780  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
781  {
782  SCH_ITEM* oldItem = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
783  SCH_ITEM* newItem = oldItem->Duplicate();
784  newItem->SetFlags( IS_NEW );
785  newItems.push_back( newItem );
786  saveCopyInUndoList( newItem, UR_NEW, ii > 0 );
787 
788  switch( newItem->Type() )
789  {
790  case SCH_JUNCTION_T:
791  case SCH_LINE_T:
792  case SCH_BUS_BUS_ENTRY_T:
794  case SCH_TEXT_T:
795  case SCH_LABEL_T:
796  case SCH_GLOBAL_LABEL_T:
797  case SCH_HIER_LABEL_T:
798  case SCH_NO_CONNECT_T:
799  newItem->SetParent( m_frame->GetScreen() );
800  m_frame->AddToScreen( newItem );
801  break;
802 
803  case SCH_SHEET_T:
804  {
805  SCH_SHEET* sheet = (SCH_SHEET*) newItem;
806  // Duplicate sheet names and sheet time stamps are not valid. Use a time stamp
807  // based sheet name and update the time stamp for each sheet in the block.
808  timestamp_t timeStamp = GetNewTimeStamp();
809 
810  sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), (unsigned long)timeStamp ) );
811  sheet->SetTimeStamp( timeStamp );
812 
813  sheet->SetParent( m_frame->GetScreen() );
814  m_frame->AddToScreen( sheet );
815 
816  copiedSheets = true;
817  break;
818  }
819 
820  case SCH_COMPONENT_T:
821  {
822  SCH_COMPONENT* component = (SCH_COMPONENT*) newItem;
823 
824  component->SetTimeStamp( GetNewTimeStamp() );
825  component->ClearAnnotation( NULL );
826 
827  component->SetParent( m_frame->GetScreen() );
828  m_frame->AddToScreen( component );
829  break;
830  }
831 
832  default:
833  break;
834  }
835  }
836 
837  if( copiedSheets )
838  {
839  // We clear annotation of new sheet paths.
840  // Annotation of new components added in current sheet is already cleared.
841  SCH_SCREENS screensList( g_RootSheet );
842  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
844  }
845 
847  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
849 
850  return 0;
851 }
852 
853 
855 {
856  SCH_ITEM* sourceItem = m_frame->GetRepeatItem();
857 
858  if( !sourceItem )
859  return 0;
860 
862 
863  SCH_ITEM* newItem = (SCH_ITEM*) sourceItem->Clone();
864  bool performDrag = false;
865 
866  // If cloning a component then put into 'move' mode.
867  if( newItem->Type() == SCH_COMPONENT_T )
868  {
869  ( (SCH_COMPONENT*) newItem )->SetTimeStamp( GetNewTimeStamp() );
870 
871  wxPoint cursorPos = (wxPoint) getViewControls()->GetCursorPosition( true );
872  newItem->Move( cursorPos - newItem->GetPosition() );
873  performDrag = true;
874  }
875  else
876  {
877  if( newItem->CanIncrementLabel() )
878  ( (SCH_TEXT*) newItem )->IncrementLabel( m_frame->GetRepeatDeltaLabel() );
879 
880  newItem->Move( m_frame->GetRepeatStep() );
881  }
882 
883  newItem->SetFlags( IS_NEW );
884  m_frame->AddToScreen( newItem );
885  m_frame->SaveCopyInUndoList( newItem, UR_NEW );
886 
887  m_selectionTool->AddItemToSel( newItem );
888 
889  if( performDrag )
891 
892  newItem->ClearFlags();
893 
894  if( newItem->IsConnectable() )
896 
897  // newItem newItem, now that it has been moved, thus saving new position.
898  m_frame->SaveCopyForRepeatItem( newItem );
899 
900  return 0;
901 }
902 
903 
905 {
906  SCH_SCREEN* screen = m_frame->GetScreen();
907  auto items = m_selectionTool->RequestSelection().GetItems();
908  bool appendToUndo = false;
909 
910  if( items.empty() )
911  return 0;
912 
913  // Don't leave a freed pointer in the selection
915 
916  for( EDA_ITEM* item : items )
917  {
918  // Junctions, in particular, may have already been deleted if deleting wires made
919  // them redundant
920  if( item->GetEditFlags() & STRUCT_DELETED )
921  continue;
922 
923  if( item->Type() == SCH_JUNCTION_T )
924  {
925  m_frame->DeleteJunction( (SCH_ITEM*) item, appendToUndo );
926  appendToUndo = true;
927  }
928  else
929  {
930  item->SetFlags( STRUCT_DELETED );
931  saveCopyInUndoList( item, UR_DELETED, appendToUndo );
932  appendToUndo = true;
933 
934  updateView( item );
935 
936  SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
937 
938  if( sch_item && sch_item->IsConnectable() )
939  {
940  std::vector< wxPoint > pts;
941  sch_item->GetConnectionPoints( pts );
942 
943  for( auto point : pts )
944  {
945  SCH_ITEM* junction = screen->GetItem( point, 0, SCH_JUNCTION_T );
946  if( junction && !screen->IsJunctionNeeded( point ) )
947  m_frame->DeleteJunction( junction, appendToUndo );
948  }
949  }
950 
951  if( item->Type() == SCH_SHEET_PIN_T )
952  static_cast<SCH_SHEET*>( item->GetParent() )->RemovePin( (SCH_SHEET_PIN*) item );
953  else
954  m_frame->RemoveFromScreen( item );
955  }
956  }
957 
959 
960  m_frame->GetCanvas()->Refresh();
961  m_frame->OnModify();
962 
963  return 0;
964 }
965 
966 
967 static bool deleteItem( SCH_BASE_FRAME* aFrame, const VECTOR2D& aPosition )
968 {
969  EE_SELECTION_TOOL* selectionTool = aFrame->GetToolManager()->GetTool<EE_SELECTION_TOOL>();
970  wxCHECK( selectionTool, false );
971 
973 
974  EDA_ITEM* item = selectionTool->SelectPoint( aPosition );
975  SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
976 
977  if( sch_item && sch_item->IsLocked() )
978  {
979  STATUS_TEXT_POPUP statusPopup( aFrame );
980  statusPopup.SetText( _( "Item locked." ) );
981  statusPopup.Expire( 2000 );
982  statusPopup.Popup();
983  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
984  return true;
985  }
986 
987  if( item )
988  aFrame->GetToolManager()->RunAction( EE_ACTIONS::doDelete, true );
989 
990  return true;
991 }
992 
993 
995 {
996  Activate();
997 
999  wxCHECK( picker, 0 );
1000 
1001  m_frame->SetToolID( ID_DELETE_TOOL, wxCURSOR_BULLSEYE, _( "Delete item" ) );
1002  picker->SetClickHandler( std::bind( deleteItem, m_frame, std::placeholders::_1 ) );
1003  picker->Activate();
1004  Wait();
1005 
1006  return 0;
1007 }
1008 
1009 
1011 {
1012  static KICAD_T Nothing[] = { EOT };
1013  static KICAD_T CmpOrReference[] = { SCH_FIELD_LOCATE_REFERENCE_T, SCH_COMPONENT_T, EOT };
1014  static KICAD_T CmpOrValue[] = { SCH_FIELD_LOCATE_VALUE_T, SCH_COMPONENT_T, EOT };
1015  static KICAD_T CmpOrFootprint[] = { SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_COMPONENT_T, EOT };
1016 
1017  KICAD_T* filter = Nothing;
1018 
1019  if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1020  filter = CmpOrReference;
1021  else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1022  filter = CmpOrValue;
1023  else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1024  filter = CmpOrFootprint;
1025 
1026  SELECTION& selection = m_selectionTool->RequestSelection( filter );
1027 
1028  if( selection.Empty() )
1029  return 0;
1030 
1031  SCH_ITEM* item = (SCH_ITEM*) selection.Front();
1032 
1033  if( item->Type() == SCH_COMPONENT_T )
1034  {
1035  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1036 
1037  if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1039  else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1040  m_frame->EditComponentFieldText( component->GetField( VALUE ) );
1041  else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1043  }
1044  else if( item->Type() == SCH_FIELD_T )
1045  {
1047  }
1048 
1049  return 0;
1050 }
1051 
1052 
1054 {
1056 
1057  if( selection.Empty() )
1058  return 0;
1059 
1060  SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front();
1061 
1062  if( !component->IsNew() )
1063  m_frame->SaveCopyInUndoList( component, UR_CHANGED );
1064 
1065  component->AutoplaceFields( m_frame->GetScreen(), /* aManual */ true );
1066 
1067  updateView( component );
1068  m_frame->OnModify();
1069 
1070  return 0;
1071 }
1072 
1073 
1075 {
1077 
1078  if( selection.Empty() )
1079  return 0;
1080 
1081  SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front();
1082 
1083  if( component->IsNew() )
1085  else
1086  m_frame->SaveCopyInUndoList( component, UR_CHANGED );
1087 
1088  m_frame->ConvertPart( component );
1089 
1090  return 0;
1091 }
1092 
1093 
1095 {
1097 
1098  if( selection.Empty() )
1099  return 0;
1100 
1101  SCH_ITEM* item = (SCH_ITEM*) selection.Front();
1102 
1103  switch( item->Type() )
1104  {
1105  case SCH_COMPONENT_T:
1106  m_frame->EditComponent( (SCH_COMPONENT*) item );
1107  break;
1108 
1109  case SCH_SHEET_T:
1110  {
1111  bool doClearAnnotation;
1112  bool doRefresh = false;
1113  // Keep track of existing sheet paths. EditSheet() can modify this list
1114  SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
1115 
1116  doRefresh = m_frame->EditSheet( (SCH_SHEET*) item, g_CurrentSheet, &doClearAnnotation );
1117 
1118  if( doClearAnnotation ) // happens when the current sheet load a existing file
1119  { // we must clear "new" components annotation
1120  SCH_SCREENS screensList( g_RootSheet );
1121  // We clear annotation of new sheet paths here:
1122  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1123  // Clear annotation of g_CurrentSheet itself, because its sheetpath
1124  // is not a new path, but components managed by its sheet path must have
1125  // their annotation cleared, becuase they are new:
1126  ((SCH_SHEET*) item)->GetScreen()->ClearAnnotation( g_CurrentSheet );
1127  }
1128 
1129  if( doRefresh )
1130  {
1132  m_frame->GetCanvas()->Refresh();
1133  }
1134 
1135  break;
1136  }
1137 
1138  case SCH_SHEET_PIN_T:
1139  m_frame->EditSheetPin( (SCH_SHEET_PIN*) item, true );
1140  break;
1141 
1142  case SCH_TEXT_T:
1143  case SCH_LABEL_T:
1144  case SCH_GLOBAL_LABEL_T:
1145  case SCH_HIER_LABEL_T:
1146  m_frame->EditSchematicText( (SCH_TEXT*) item );
1147  break;
1148 
1149  case SCH_FIELD_T:
1151  break;
1152 
1153  case SCH_BITMAP_T:
1154  if( m_frame->EditImage( (SCH_BITMAP*) item ) )
1155  {
1156  // The bitmap is cached in Opengl: clear the cache in case it has become invalid
1157  getView()->RecacheAllItems();
1158  }
1159 
1160  break;
1161 
1162  case SCH_LINE_T:
1163  m_frame->EditLine( (SCH_LINE*) item, true );
1164  break;
1165 
1166  case SCH_MARKER_T: // These items have no properties to edit
1167  case SCH_JUNCTION_T:
1168  case SCH_NO_CONNECT_T:
1169  break;
1170 
1171  default: // Unexpected item
1172  wxFAIL_MSG( wxString( "Cannot edit schematic item type " ) + item->GetClass() );
1173  }
1174 
1175  updateView( item );
1176 
1177  return 0;
1178 }
1179 
1180 
1182 {
1183  SELECTION& selection = m_selectionTool->GetSelection();
1184  char shape;
1185 
1186  if( aEvent.IsAction( &EE_ACTIONS::toShapeSlash ) )
1187  shape = '/';
1188  else if( aEvent.IsAction( &EE_ACTIONS::toShapeBackslash ) )
1189  shape = '\\';
1190  else
1191  return 0;
1192 
1193  for( unsigned int i = 0; i < selection.GetSize(); ++i )
1194  {
1195  SCH_BUS_ENTRY_BASE* entry = dynamic_cast<SCH_BUS_ENTRY_BASE*>( selection.GetItem( i ) );
1196 
1197  if( entry )
1198  {
1199  if( entry->GetEditFlags() == 0 )
1201 
1202  entry->SetBusEntryShape( shape );
1204 
1205  updateView( entry );
1206  m_frame->OnModify( );
1207  }
1208  }
1209 
1210  g_lastBusEntryShape = shape;
1211 
1212  return 0;
1213 }
1214 
1215 
1217 {
1219  SELECTION& selection = m_selectionTool->RequestSelection( allTextTypes );
1220  KICAD_T convertTo;
1221 
1222  if( aEvent.IsAction( &EE_ACTIONS::toLabel ) )
1223  convertTo = SCH_LABEL_T;
1224  else if( aEvent.IsAction( &EE_ACTIONS::toHLabel ) )
1225  convertTo = SCH_HIER_LABEL_T;
1226  else if( aEvent.IsAction( &EE_ACTIONS::toGLabel ) )
1227  convertTo = SCH_GLOBAL_LABEL_T;
1228  else if( aEvent.IsAction( &EE_ACTIONS::toText ) )
1229  convertTo = SCH_TEXT_T;
1230  else
1231  return 0;
1232 
1233  for( unsigned int i = 0; i < selection.GetSize(); ++i )
1234  {
1235  SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( selection.GetItem( i ) );
1236 
1237  if( text )
1238  m_frame->ConvertTextType( text, convertTo );
1239  }
1240 
1241  return 0;
1242 }
1243 
1244 
1246 {
1247  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
1248 
1249  if( m_frame->BreakSegments( (wxPoint) cursorPos ) )
1250  {
1252 
1253  m_frame->OnModify();
1254  m_frame->GetCanvas()->Refresh();
1255  }
1256 
1257  return 0;
1258 }
1259 
1260 
1262 {
1264  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1265 
1266  if( !sheet )
1267  return 0;
1268 
1269  if( !sheet->HasUndefinedPins() )
1270  {
1271  DisplayInfoMessage( m_frame, _( "There are no unreferenced pins in this sheet to remove." ) );
1272  return 0;
1273  }
1274 
1275  if( !IsOK( m_frame, _( "Do you wish to delete the unreferenced pins from this sheet?" ) ) )
1276  return 0;
1277 
1279 
1280  sheet->CleanupSheet();
1281 
1282  updateView( sheet );
1283  m_frame->OnModify();
1284 
1285  return 0;
1286 }
1287 
1288 
1290 {
1295  Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorX.MakeEvent() );
1296  Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorY.MakeEvent() );
1299 
1306 
1313 
1316 
1318 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:173
#define TEXT_ANGLE_HORIZ
SELECTION & GetSelection()
Function GetSelection()
Class SCH_SHEET_LIST.
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
static TOOL_ACTION pinTable
Definition: ee_actions.h:166
void SetTimeStamp(timestamp_t aNewTimeStamp)
Change the time stamp to aNewTimeStamp and updates the reference path.
static TOOL_ACTION properties
Definition: ee_actions.h:124
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
void EditComponent(SCH_COMPONENT *aComponent)
Display the edit component dialog to edit the parameters of aComponent.
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:816
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_line.h:60
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item.
Definition: sch_item.h:299
VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:63
PART_REF & GetPartRef()
static TOOL_ACTION deleteItemCursor
Definition: ee_actions.h:167
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:208
bool IsHover() const
Definition: selection.h:69
SCH_ITEM * Duplicate(bool doClone=false)
Routine to create a new copy of given item.
Definition: sch_item.cpp:75
char g_lastBusEntryShape
Definition: ee_actions.cpp:29
static TOOL_ACTION breakBus
Definition: ee_actions.h:143
static SELECTION_CONDITION SingleSymbol
#define TEXT_ANGLE_VERT
static TOOL_ACTION duplicate
Definition: ee_actions.h:118
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
TOOL_MENU & GetToolMenu()
Class ACTION_MENU.
Definition: action_menu.h:43
This file is part of the common library.
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:350
Class SCH_DRAWING_TOOLS.
static TOOL_ACTION toShapeBackslash
Definition: ee_actions.h:137
bool BreakSegments(const wxPoint &aPoint, SCH_SCREEN *aScreen=nullptr)
Checks every wire and bus for a intersection at aPoint and break into two segments at aPoint if an in...
static SELECTION_CONDITION MoreThan(int aNumber)
Function MoreThan Creates a functor that tests if the number of selected items is greater than the va...
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:64
void AddSeparator(const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddSeparator()
This file is part of the common library.
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Function OnlyTypes Creates a functor that tests if the selected items are only of given types.
void RotateEnd(wxPoint aPosition)
Definition: sch_line.cpp:361
Class STATUS_TEXT_POPUP.
Definition: status_popup.h:79
virtual void SetLabelSpinStyle(int aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:248
bool IsMoving() const
Definition: base_struct.h:224
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
int Rotate(const TOOL_EVENT &aEvent)
static TOOL_ACTION mirrorY
Definition: ee_actions.h:123
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1401
int BreakWire(const TOOL_EVENT &aEvent)
static SELECTION_CONDITION IdleSelection
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_item.h:309
virtual bool CanIncrementLabel() const
Definition: sch_item.h:360
double GetTextAngle() const
Definition: eda_text.h:181
static TOOL_ACTION refreshPreview
Definition: ee_actions.h:168
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static int LegacyHotKey(int aHotKey)
Creates a hot key code that refers to a legacy hot key setting, instead of a particular key.
Definition: tool_action.h:165
static TOOL_ACTION toText
Definition: ee_actions.h:141
static TOOL_ACTION autoplaceFields
Definition: ee_actions.h:128
Schematic editor (Eeschema) main window.
int Properties(const TOOL_EVENT &aEvent)
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:44
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...
static SELECTION_CONDITION Idle
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:45
static SELECTION_CONDITION Count(int aNumber)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
void setTransitions() override
Sets up handlers for various events.
void update() override
Update menu state stub.
void EditComponentFieldText(SCH_FIELD *aField)
Display the edit field dialog to edit the parameters of aField.
TOOL_MENU & GetToolMenu()
Get the tool's top-level context menu
Definition: ee_tool_base.h:103
bool GetAutoplaceFields() const
static TOOL_ACTION convertDeMorgan
Definition: ee_actions.h:129
static bool NotEmpty(const SELECTION &aSelection)
Function NotEmpty Tests if there are any items selected.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
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:49
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:136
void RotateStart(wxPoint aPosition)
Definition: sch_line.cpp:355
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
static TOOL_ACTION breakWire
Definition: ee_actions.h:142
static TOOL_ACTION rotateCW
Definition: ee_actions.h:120
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:54
bool IsNew() const
Definition: base_struct.h:222
void ClearFieldsAutoplaced()
Set fields automatically placed flag false.
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
virtual void Rotate(wxPoint aPosition)=0
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
int Duplicate(const TOOL_EVENT &aEvent)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
int GetLabelSpinStyle() const
Definition: sch_text.h:119
static SELECTION_CONDITION SingleDeMorganSymbol
static TOOL_ACTION copy
Definition: actions.h:53
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
static TOOL_ACTION cleanupSheetPins
Definition: ee_actions.h:163
#define VALUE
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:121
int GetUnit() const
virtual wxPoint GetPosition() const =0
Function GetPosition.
static TOOL_ACTION editFootprint
Definition: ee_actions.h:127
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:207
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
static bool deleteItem(SCH_BASE_FRAME *aFrame, const VECTOR2D &aPosition)
void SetName(const wxString &aName)
Definition: sch_sheet.h:260
int ChangeShape(const TOOL_EVENT &aEvent)
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:219
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:263
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:588
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:211
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:165
TOOL_MANAGER * GetToolManager() const override
Return the tool manager instance, if any.
Definition: draw_frame.h:937
SCH_DRAW_PANEL * GetCanvas() const override
void SetIcon(const BITMAP_OPAQUE *aIcon)
Function SetIcon() Assigns an icon for the entry.
Definition: action_menu.cpp:82
Class TOOL_EVENT.
Definition: tool_event.h:167
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.
int AutoplaceFields(const TOOL_EVENT &aEvent)
ACTION_MENU * create() const override
Returns an instance of this class. It has to be overridden in inheriting classes.
static TOOL_ACTION repeatDrawItem
Definition: ee_actions.h:119
SCH_ITEM * GetItem(const wxPoint &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T) const
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:237
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:130
static TOOL_ACTION cut
Definition: actions.h:52
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
const wxPoint GetRepeatStep() const
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:123
EDA_ITEM * GetParent() const
Definition: base_struct.h:214
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
virtual void Popup(wxWindow *aFocus=nullptr)
static TOOL_ACTION mirrorX
Definition: ee_actions.h:122
static TOOL_ACTION doDelete
Definition: ee_actions.h:131
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:143
bool Matches(const TOOL_EVENT &aEvent) const
Function Matches() Tests whether two events match in terms of category & action or command.
Definition: tool_event.h:338
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:56
virtual void MirrorX(int aXaxis_position)=0
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:57
void SetBusEntryShape(char aShape)
function SetBusEntryShape
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
virtual void Move(const wxPoint &aWhere)
void ConvertTextType(SCH_TEXT *aText, KICAD_T aType)
Change a text type to another one.
Definition: edit_label.cpp:105
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
int CleanupSheetPins(const TOOL_EVENT &aEvent)
static SELECTION_CONDITION SingleMultiUnitSymbol
virtual void MirrorY(int aYaxis_position)=0
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear exiting component annotation.
All active tools
Definition: tool_event.h:143
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:340
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:103
void Expire(int aMsecs)
Hides the popup after a specified time.
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: ee_tool_base.h:147
int DeleteItemCursor(const TOOL_EVENT &aEvent)
Runs the deletion tool.
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:201
int Mirror(const TOOL_EVENT &aEvent)
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:70
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:98
virtual bool IsLocked() const
Function IsLocked.
Definition: sch_item.h:181
int RepeatDrawItem(const TOOL_EVENT &aEvent)
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:316
static const KICAD_T RotatableItems[]
Definition: ee_collectors.h:43
void EditSchematicText(SCH_TEXT *aText)
Launches the "Edit Text/Label" dialog.
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Return the nearest aGridSize location to aPosition.
bool HasUndefinedPins()
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:232
static TOOL_ACTION editValue
Definition: ee_actions.h:126
SCH_ITEM * GetRepeatItem() const
Return the item which is to be repeated with the insert key.
void updateView(EDA_ITEM *aItem) const
Similar to getView()->Update(), but handles items that are redrawn by their parents.
Definition: ee_tool_base.h:107
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the menu.
Definition: action_menu.cpp:96
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Automatically orient all the fields in the component.
int AddItemToSel(const TOOL_EVENT &aEvent)
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
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.
Definition: edit_bitmap.cpp:35
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:210
TOOL_MANAGER * getToolManager() const
Returns an instance of TOOL_MANAGER class.
void DeleteJunction(SCH_ITEM *aItem, bool aAppend=false)
Removes a given junction and heals any wire segments under the junction.
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Function CreateSubMenu.
Definition: tool_menu.cpp:52
Class TOOL_ACTION.
Definition: tool_action.h:46
size_t i
Definition: json11.cpp:597
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:120
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Function OnlyType Creates a functor that tests if the selected items are only of given type.
static wxString SubReference(int aUnit, bool aAddSeparator=true)
int EditField(const TOOL_EVENT &aEvent)
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
int GetRepeatDeltaLabel() const
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO_T aType, bool aAppend=false)
Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.
Definition: ee_tool_base.h:120
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
wxPoint Centre() const
Definition: eda_rect.h:60
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:260
void Activate()
Function Activate() Runs the tool.
static TOOL_ACTION move
Definition: ee_actions.h:116
Class EE_TOOL_BASE.
Definition: ee_tool_base.h:49
static TOOL_ACTION toLabel
Definition: ee_actions.h:138
static const char * text_xpm[]
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: common.h:53
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
static TOOL_ACTION toHLabel
Definition: ee_actions.h:139
EDA_ITEM * SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, bool *aSelectionCancelledFlag=NULL, bool aCheckLocked=false)
Function selectPoint() Selects an item pointed by the parameter aWhere.
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Basic classes for most KiCad items.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
static TOOL_ACTION editReference
Definition: ee_actions.h:125
void ClearAnnotationOfNewSheetPaths(SCH_SHEET_LIST &aInitialSheetPathList)
Clear the annotation for the components inside new sheetpaths when a complex hierarchy is modified an...
int DoDelete(const TOOL_EVENT &aEvent)
Function DoDelete()
int EditSheetPin(SCH_SHEET_PIN *aSheetPin, bool aRedraw)
Display the dialog for editing the parameters of aSheetPin.
Definition: sheet.cpp:328
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:261
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:276
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:238
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
void ConvertPart(SCH_COMPONENT *aComponent)
Definition: getpart.cpp:248
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
static TOOL_ACTION toGLabel
Definition: ee_actions.h:140
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:294
Implementation of the label properties dialog.
int ConvertDeMorgan(const TOOL_EVENT &aEvent)
static TOOL_ACTION editWithSymbolEditor
Definition: ee_actions.h:151
static TOOL_ACTION paste
Definition: actions.h:54
static const KICAD_T EditableItems[]
Definition: ee_collectors.h:42
int ChangeTextType(const TOOL_EVENT &aEvent)
void SetText(const wxString &aText)
Display a text.
int GetToolId() const
Definition: draw_frame.h:524
static TOOL_ACTION toShapeSlash
Definition: ee_actions.h:136
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:493
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:155
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:209
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:119
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
virtual void Move(const wxPoint &aMoveVector)=0
Function Move moves the item by aMoveVector to a new position.