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 CERN
5  * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <kiway.h>
26 #include <tool/picker_tool.h>
27 #include <tools/sch_edit_tool.h>
30 #include <tools/sch_move_tool.h>
31 #include <widgets/infobar.h>
32 #include <ee_actions.h>
33 #include <bitmaps.h>
34 #include <confirm.h>
35 #include <eda_item.h>
36 #include <reporter.h>
37 #include <kicad_string.h>
38 #include <sch_item.h>
39 #include <sch_component.h>
40 #include <sch_sheet.h>
41 #include <sch_text.h>
42 #include <sch_bitmap.h>
43 #include <sch_view.h>
44 #include <sch_line.h>
45 #include <sch_bus_entry.h>
46 #include <sch_junction.h>
47 #include <sch_edit_frame.h>
48 #include <schematic.h>
51 #include <eeschema_id.h>
52 #include <status_popup.h>
53 #include <wx/gdicmn.h>
61 #include "sch_drawing_tools.h"
62 #include <math/util.h> // for KiROUND
63 #include <pgm_base.h>
65 #include <symbol_editor_settings.h>
67 
69 {
70 public:
72  ACTION_MENU( true )
73  {
75  SetTitle( _( "Symbol Unit" ) );
76  }
77 
78 protected:
79  ACTION_MENU* create() const override
80  {
81  return new SYMBOL_UNIT_MENU();
82  }
83 
84 private:
85  void update() override
86  {
88  EE_SELECTION& selection = selTool->GetSelection();
89  SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
90 
91  Clear();
92 
93  if( !component )
94  {
95  Append( ID_POPUP_SCH_UNFOLD_BUS, _( "no symbol selected" ), wxEmptyString );
96  Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
97  return;
98  }
99 
100  int unit = component->GetUnit();
101 
102  if( !component->GetPartRef() || component->GetPartRef()->GetUnitCount() < 2 )
103  {
104  Append( ID_POPUP_SCH_UNFOLD_BUS, _( "symbol is not multi-unit" ), wxEmptyString );
105  Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
106  return;
107  }
108 
109  for( int ii = 0; ii < component->GetPartRef()->GetUnitCount(); ii++ )
110  {
111  wxString num_unit;
112  num_unit.Printf( _( "Unit %s" ), LIB_PART::SubReference( ii + 1, false ) );
113 
114  wxMenuItem * item = Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, num_unit, wxEmptyString,
115  wxITEM_CHECK );
116  if( unit == ii + 1 )
117  item->Check(true);
118 
119  // The ID max for these submenus is ID_POPUP_SCH_SELECT_UNIT_CMP_MAX
120  // See eeschema_id to modify this value.
122  break; // We have used all IDs for these submenus
123  }
124  }
125 };
126 
127 
129  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveEdit" )
130 {
131  m_pickerItem = nullptr;
132 }
133 
134 
136 
138 {
140 
143 
144  wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
145 
146  auto hasElements =
147  [ this ] ( const SELECTION& aSel )
148  {
149  return !m_frame->GetScreen()->Items().empty();
150  };
151 
152  auto sheetTool =
153  [ this ] ( const SELECTION& aSel )
154  {
156  };
157 
158  auto anyTextTool =
159  [ this ] ( const SELECTION& aSel )
160  {
165  };
166 
167  auto duplicateCondition =
168  [] ( const SELECTION& aSel )
169  {
171  return false;
172 
173  return true;
174  };
175 
176  auto orientCondition =
177  [] ( const SELECTION& aSel )
178  {
179  if( aSel.Empty() )
180  return false;
181 
183  return false;
184 
185  SCH_ITEM* item = (SCH_ITEM*) aSel.Front();
186 
187  if( aSel.GetSize() > 1 )
188  return true;
189 
190  switch( item->Type() )
191  {
192  case SCH_MARKER_T:
193  case SCH_JUNCTION_T:
194  case SCH_NO_CONNECT_T:
195  case SCH_PIN_T:
196  return false;
197  case SCH_LINE_T:
198  return item->GetLayer() != LAYER_WIRE && item->GetLayer() != LAYER_BUS;
199  default:
200  return true;
201  }
202  };
203 
204  auto propertiesCondition =
205  []( const SELECTION& aSel )
206  {
207  if( aSel.GetSize() == 0 )
208  return true; // Show worksheet properties
209 
210  SCH_ITEM* firstItem = dynamic_cast<SCH_ITEM*>( aSel.Front() );
211  const EE_SELECTION* eeSelection = dynamic_cast<const EE_SELECTION*>( &aSel );
212 
213  if( !firstItem || !eeSelection )
214  return false;
215 
216  switch( firstItem->Type() )
217  {
218  case SCH_COMPONENT_T:
219  case SCH_SHEET_T:
220  case SCH_SHEET_PIN_T:
221  case SCH_TEXT_T:
222  case SCH_LABEL_T:
223  case SCH_GLOBAL_LABEL_T:
224  case SCH_HIER_LABEL_T:
225  case SCH_FIELD_T:
226  case SCH_BITMAP_T:
227  return aSel.GetSize() == 1;
228 
229  case SCH_LINE_T:
231  return eeSelection->AllItemsHaveLineStroke();
232 
233  case SCH_JUNCTION_T:
234  return eeSelection->AreAllItemsIdentical();
235 
236  default:
237  return false;
238  }
239  };
240 
241  static KICAD_T toLabelTypes[] = { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
242  auto toLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toLabelTypes );
243 
244  static KICAD_T toHLableTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_TEXT_T, EOT };
245  auto toHLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toHLableTypes );
246 
247  static KICAD_T toGLableTypes[] = { SCH_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
248  auto toGLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toGLableTypes );
249 
250  static KICAD_T toTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EOT };
251  auto toTextlCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toTextTypes );
252 
253  static KICAD_T entryTypes[] = { SCH_BUS_WIRE_ENTRY_T, SCH_BUS_BUS_ENTRY_T, EOT };
254  auto entryCondition = E_C::MoreThan( 0 ) && E_C::OnlyTypes( entryTypes );
255 
256  static KICAD_T fieldParentTypes[] = { SCH_COMPONENT_T, SCH_SHEET_T, SCH_GLOBAL_LABEL_T, EOT };
257  auto singleFieldParentCondition = E_C::Count( 1 ) && E_C::OnlyTypes( fieldParentTypes );
258 
259  auto singleSymbolCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_COMPONENT_T );
260 
261  auto singleSheetCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
262  //
263  // Add edit actions to the move tool menu
264  //
265  if( moveTool )
266  {
267  CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
268 
269  moveMenu.AddSeparator();
270  moveMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition );
271  moveMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition );
272  moveMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition );
273  moveMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition );
275 
276  moveMenu.AddItem( EE_ACTIONS::properties, propertiesCondition );
277  moveMenu.AddItem( EE_ACTIONS::editReference, singleSymbolCondition );
278  moveMenu.AddItem( EE_ACTIONS::editValue, singleSymbolCondition );
279  moveMenu.AddItem( EE_ACTIONS::editFootprint, singleSymbolCondition );
281 
282  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu = std::make_shared<SYMBOL_UNIT_MENU>();
283  symUnitMenu->SetTool( this );
284  m_menu.AddSubMenu( symUnitMenu );
285  moveMenu.AddMenu( symUnitMenu.get(), E_C::SingleMultiUnitSymbol, 1 );
286 
287  moveMenu.AddSeparator();
290  moveMenu.AddItem( ACTIONS::duplicate, duplicateCondition );
291 
292  moveMenu.AddSeparator();
293  moveMenu.AddItem( ACTIONS::selectAll, hasElements );
294  }
295 
296  //
297  // Add editing actions to the drawing tool menu
298  //
299  CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
300 
301  drawMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
302  drawMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
303  drawMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition, 200 );
304  drawMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition, 200 );
305 
306  drawMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
307  drawMenu.AddItem( EE_ACTIONS::editReference, singleSymbolCondition, 200 );
308  drawMenu.AddItem( EE_ACTIONS::editValue, singleSymbolCondition, 200 );
309  drawMenu.AddItem( EE_ACTIONS::editFootprint, singleSymbolCondition, 200 );
310  drawMenu.AddItem( EE_ACTIONS::autoplaceFields, singleFieldParentCondition, 200 );
312 
313  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu2 = std::make_shared<SYMBOL_UNIT_MENU>();
314  symUnitMenu2->SetTool( drawingTools );
315  drawingTools->GetToolMenu().AddSubMenu( symUnitMenu2 );
316  drawMenu.AddMenu( symUnitMenu2.get(), E_C::SingleMultiUnitSymbol, 1 );
317 
318  drawMenu.AddItem( EE_ACTIONS::editWithLibEdit, singleSymbolCondition && E_C::Idle, 200 );
319 
320  drawMenu.AddItem( EE_ACTIONS::toLabel, anyTextTool && E_C::Idle, 200 );
321  drawMenu.AddItem( EE_ACTIONS::toHLabel, anyTextTool && E_C::Idle, 200 );
322  drawMenu.AddItem( EE_ACTIONS::toGLabel, anyTextTool && E_C::Idle, 200 );
323  drawMenu.AddItem( EE_ACTIONS::toText, anyTextTool && E_C::Idle, 200 );
324  drawMenu.AddItem( EE_ACTIONS::cleanupSheetPins, sheetTool && E_C::Idle, 250 );
325 
326  //
327  // Add editing actions to the selection tool menu
328  //
330 
331  selToolMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
332  selToolMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
333  selToolMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition, 200 );
334  selToolMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition, 200 );
335  selToolMenu.AddItem( ACTIONS::doDelete, E_C::NotEmpty, 200 );
336 
337  selToolMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
339  selToolMenu.AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 );
341  selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, singleFieldParentCondition, 200 );
343 
344  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu3 = std::make_shared<SYMBOL_UNIT_MENU>();
345  symUnitMenu3->SetTool( m_selectionTool );
346  m_selectionTool->GetToolMenu().AddSubMenu( symUnitMenu3 );
347  selToolMenu.AddMenu( symUnitMenu3.get(), E_C::SingleMultiUnitSymbol, 1 );
348 
349  selToolMenu.AddItem( EE_ACTIONS::editWithLibEdit, singleSymbolCondition && E_C::Idle, 200 );
352 
353  selToolMenu.AddItem( EE_ACTIONS::toLabel, toLabelCondition, 200 );
354  selToolMenu.AddItem( EE_ACTIONS::toHLabel, toHLabelCondition, 200 );
355  selToolMenu.AddItem( EE_ACTIONS::toGLabel, toGLabelCondition, 200 );
356  selToolMenu.AddItem( EE_ACTIONS::toText, toTextlCondition, 200 );
357  selToolMenu.AddItem( EE_ACTIONS::cleanupSheetPins, singleSheetCondition, 250 );
358 
359  selToolMenu.AddSeparator( 300 );
360  selToolMenu.AddItem( ACTIONS::cut, E_C::IdleSelection, 300 );
361  selToolMenu.AddItem( ACTIONS::copy, E_C::IdleSelection, 300 );
362  selToolMenu.AddItem( ACTIONS::paste, E_C::Idle, 300 );
363  selToolMenu.AddItem( ACTIONS::pasteSpecial, E_C::Idle, 300 );
364  selToolMenu.AddItem( ACTIONS::duplicate, duplicateCondition, 300 );
365 
366  selToolMenu.AddSeparator( 400 );
367  selToolMenu.AddItem( ACTIONS::selectAll, hasElements, 400 );
368 
369 
370  return true;
371 }
372 
373 
375  SCH_TEXT_T,
376  SCH_LABEL_T,
379  SCH_FIELD_T,
382  SCH_SHEET_T,
383  SCH_BITMAP_T,
386  SCH_LINE_T,
389  EOT
390 };
391 
392 
393 int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
394 {
396 
397  if( selection.GetSize() == 0 )
398  return 0;
399 
400  wxPoint rotPoint;
401  bool clockwise = ( aEvent.Matches( EE_ACTIONS::rotateCW.MakeEvent() ) );
402  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
403  bool connections = false;
404  bool moving = item->IsMoving();
405 
406  if( selection.GetSize() == 1 )
407  {
408  if( !moving )
410 
411  switch( item->Type() )
412  {
413  case SCH_COMPONENT_T:
414  {
415  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
416 
417  if( clockwise )
418  component->SetOrientation( CMP_ROTATE_CLOCKWISE );
419  else
421 
423  component->AutoAutoplaceFields( m_frame->GetScreen() );
424 
425  break;
426  }
427 
428  case SCH_TEXT_T:
429  case SCH_LABEL_T:
430  case SCH_GLOBAL_LABEL_T:
431  case SCH_HIER_LABEL_T:
432  {
433  SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
434  textItem->Rotate90( clockwise );
435  break;
436  }
437 
438  case SCH_SHEET_PIN_T:
439  {
440  // Rotate pin within parent sheet
441  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
442  SCH_SHEET* sheet = pin->GetParent();
443 
444  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
445  pin->Rotate( sheet->GetBoundingBox().GetCenter() );
446 
447  break;
448  }
449 
450  case SCH_LINE_T:
451  case SCH_BUS_BUS_ENTRY_T:
453  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
454  item->Rotate( item->GetPosition() );
455 
456  break;
457 
458  case SCH_FIELD_T:
459  {
460  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
461 
462  if( field->GetTextAngle() == TEXT_ANGLE_HORIZ )
463  field->SetTextAngle( TEXT_ANGLE_VERT );
464  else
465  field->SetTextAngle( TEXT_ANGLE_HORIZ );
466 
467  // Now that we're moving a field, they're no longer autoplaced.
468  static_cast<SCH_ITEM*>( item->GetParent() )->ClearFieldsAutoplaced();
469 
470  break;
471  }
472 
473  case SCH_BITMAP_T:
474  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
475  item->Rotate( item->GetPosition() );
476 
477  // The bitmap is cached in Opengl: clear the cache to redraw
479  break;
480 
481  case SCH_SHEET_T:
482  {
483  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
484 
485  // Rotate the sheet on itself. Sheets do not have an anchor point.
486  for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
487  {
488  rotPoint = m_frame->GetNearestGridPosition( sheet->GetRotationCenter() );
489  sheet->Rotate( rotPoint );
490  }
491  break;
492  }
493 
494  default:
495  break;
496  }
497 
498  connections = item->IsConnectable();
499  m_frame->UpdateItem( item );
500  }
501  else if( selection.GetSize() > 1 )
502  {
503  rotPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() );
504 
505  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
506  {
507  item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
508 
509  if( !moving )
510  saveCopyInUndoList( item, UNDO_REDO::CHANGED, ii > 0 );
511 
512  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
513  {
514  if( item->Type() == SCH_LINE_T )
515  {
516  SCH_LINE* line = (SCH_LINE*) item;
517 
518  if( item->HasFlag( STARTPOINT ) )
519  line->RotateStart( rotPoint );
520 
521  if( item->HasFlag( ENDPOINT ) )
522  line->RotateEnd( rotPoint );
523  }
524  else if( item->Type() == SCH_SHEET_PIN_T )
525  {
526  if( item->GetParent()->IsSelected() )
527  {
528  // parent will rotate us
529  }
530  else
531  {
532  // rotate within parent
533  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
534  SCH_SHEET* sheet = pin->GetParent();
535 
536  pin->Rotate( sheet->GetBoundingBox().GetCenter() );
537  }
538  }
539  else
540  {
541  item->Rotate( rotPoint );
542  }
543  }
544 
545  connections |= item->IsConnectable();
546  m_frame->UpdateItem( item );
547  }
548  }
549 
551 
552  if( item->IsMoving() )
553  {
555  }
556  else
557  {
558  if( selection.IsHover() )
560 
561  if( connections )
563 
564  m_frame->OnModify();
565  }
566 
567  return 0;
568 }
569 
570 
571 int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
572 {
574 
575  if( selection.GetSize() == 0 )
576  return 0;
577 
578  wxPoint mirrorPoint;
579  bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorX.MakeEvent() ) );
580  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
581  bool connections = false;
582  bool moving = item->IsMoving();
583 
584  if( selection.GetSize() == 1 )
585  {
586  if( !moving )
588 
589  switch( item->Type() )
590  {
591  case SCH_COMPONENT_T:
592  {
593  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
594 
595  if( xAxis )
596  component->SetOrientation( CMP_MIRROR_X );
597  else
598  component->SetOrientation( CMP_MIRROR_Y );
599 
601  component->AutoAutoplaceFields( m_frame->GetScreen() );
602 
603  break;
604  }
605 
606  case SCH_TEXT_T:
607  case SCH_LABEL_T:
608  case SCH_GLOBAL_LABEL_T:
609  case SCH_HIER_LABEL_T:
610  {
611  SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
612  textItem->MirrorSpinStyle( !xAxis );
613  break;
614  }
615 
616  case SCH_SHEET_PIN_T:
617  {
618  // mirror within parent sheet
619  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
620  SCH_SHEET* sheet = pin->GetParent();
621 
622  if( xAxis )
623  pin->MirrorX( sheet->GetBoundingBox().GetCenter().y );
624  else
625  pin->MirrorY( sheet->GetBoundingBox().GetCenter().x );
626 
627  break;
628  }
629 
630  case SCH_BUS_BUS_ENTRY_T:
632  if( xAxis )
633  item->MirrorX( item->GetPosition().y );
634  else
635  item->MirrorY( item->GetPosition().x );
636  break;
637 
638  case SCH_FIELD_T:
639  {
640  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
641 
642  if( xAxis )
644  else
646 
647  // Now that we're re-justifying a field, they're no longer autoplaced.
648  static_cast<SCH_ITEM*>( item->GetParent() )->ClearFieldsAutoplaced();
649 
650  break;
651  }
652 
653  case SCH_BITMAP_T:
654  if( xAxis )
655  item->MirrorX( item->GetPosition().y );
656  else
657  item->MirrorY( item->GetPosition().x );
658 
659  // The bitmap is cached in Opengl: clear the cache to redraw
661  break;
662 
663  case SCH_SHEET_T:
664  // Mirror the sheet on itself. Sheets do not have a anchor point.
665  mirrorPoint = m_frame->GetNearestGridPosition( item->GetBoundingBox().Centre() );
666 
667  if( xAxis )
668  item->MirrorX( mirrorPoint.y );
669  else
670  item->MirrorY( mirrorPoint.x );
671 
672  break;
673 
674  default:
675  break;
676  }
677 
678  connections = item->IsConnectable();
679  m_frame->UpdateItem( item );
680  }
681  else if( selection.GetSize() > 1 )
682  {
683  mirrorPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() );
684 
685  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
686  {
687  item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
688 
689  if( !moving )
690  saveCopyInUndoList( item, UNDO_REDO::CHANGED, ii > 0 );
691 
692  if( item->Type() == SCH_SHEET_PIN_T )
693  {
694  if( item->GetParent()->IsSelected() )
695  {
696  // parent will mirror us
697  }
698  else
699  {
700  // mirror within parent sheet
701  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
702  SCH_SHEET* sheet = pin->GetParent();
703 
704  if( xAxis )
705  pin->MirrorX( sheet->GetBoundingBox().GetCenter().y );
706  else
707  pin->MirrorY( sheet->GetBoundingBox().GetCenter().x );
708  }
709  }
710  else
711  {
712  if( xAxis )
713  item->MirrorX( mirrorPoint.y );
714  else
715  item->MirrorY( mirrorPoint.x );
716  }
717 
718  connections |= item->IsConnectable();
719  m_frame->UpdateItem( item );
720  }
721  }
722 
724 
725  if( item->IsMoving() )
726  {
728  }
729  else
730  {
731  if( selection.IsHover() )
733 
734  if( connections )
736 
737  m_frame->OnModify();
738  }
739 
740  return 0;
741 }
742 
743 
745 {
747  SCH_LINE_T,
750  SCH_TEXT_T,
751  SCH_LABEL_T,
755  SCH_SHEET_T,
757  EOT
758 };
759 
760 
762 {
764 
765  if( selection.GetSize() == 0 )
766  return 0;
767 
768  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
769  // up dragging around a stack of objects...
770  if( selection.Front()->IsNew() )
771  return 0;
772 
773  EDA_ITEMS newItems;
774 
775  // Keep track of existing sheet paths. Duplicating a selection can modify this list
776  bool copiedSheets = false;
777  SCH_SHEET_LIST initial_sheetpathList = m_frame->Schematic().GetSheets();
778 
779  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
780  {
781  SCH_ITEM* oldItem = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
782  SCH_ITEM* newItem = oldItem->Duplicate();
783  newItem->SetFlags( IS_NEW );
784  newItems.push_back( newItem );
785  saveCopyInUndoList( newItem, UNDO_REDO::NEWITEM, ii > 0 );
786 
787  switch( newItem->Type() )
788  {
789  case SCH_JUNCTION_T:
790  case SCH_LINE_T:
791  case SCH_BUS_BUS_ENTRY_T:
793  case SCH_TEXT_T:
794  case SCH_LABEL_T:
795  case SCH_GLOBAL_LABEL_T:
796  case SCH_HIER_LABEL_T:
797  case SCH_NO_CONNECT_T:
798  newItem->SetParent( m_frame->GetScreen() );
799  m_frame->AddToScreen( newItem, m_frame->GetScreen() );
800  break;
801 
802  case SCH_SHEET_T:
803  {
804  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
805  SCH_SHEET* sheet = (SCH_SHEET*) newItem;
806  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
807  wxString baseName = nameField.GetText();
808  wxString number;
809 
810  while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
811  {
812  number = baseName.Last() + number;
813  baseName.RemoveLast();
814  }
815 
816  int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
817  wxString candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
818 
819  while( hierarchy.NameExists( candidateName ) )
820  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
821 
822  nameField.SetText( candidateName );
823 
824  sheet->SetParent( m_frame->GetCurrentSheet().Last() );
825  m_frame->AddToScreen( sheet, m_frame->GetScreen() );
826 
827  copiedSheets = true;
828  break;
829  }
830 
831  case SCH_COMPONENT_T:
832  {
833  SCH_COMPONENT* component = (SCH_COMPONENT*) newItem;
834  component->ClearAnnotation( NULL );
835  component->SetParent( m_frame->GetScreen() );
836  m_frame->AddToScreen( component, m_frame->GetScreen() );
837  break;
838  }
839 
840  default:
841  break;
842  }
843  }
844 
845  if( copiedSheets )
846  {
847  // We clear annotation of new sheet paths.
848  // Annotation of new components added in current sheet is already cleared.
849  SCH_SCREENS screensList( &m_frame->Schematic().Root() );
850  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
852  }
853 
855  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
857 
858  return 0;
859 }
860 
861 
863 {
864  SCH_ITEM* sourceItem = m_frame->GetRepeatItem();
865 
866  if( !sourceItem )
867  return 0;
868 
870 
871  SCH_ITEM* newItem = sourceItem->Duplicate();
872  bool performDrag = false;
873 
874  // If cloning a component then put into 'move' mode.
875  if( newItem->Type() == SCH_COMPONENT_T )
876  {
877  wxPoint cursorPos = (wxPoint) getViewControls()->GetCursorPosition( true );
878  newItem->Move( cursorPos - newItem->GetPosition() );
879  performDrag = true;
880  }
881  else
882  {
883  if( m_isSymbolEditor )
884  {
885  auto* cfg = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
886 
887  if( dynamic_cast<SCH_TEXT*>( newItem ) )
888  {
889  SCH_TEXT* text = static_cast<SCH_TEXT*>( newItem );
890  text->IncrementLabel( cfg->m_Repeat.label_delta );
891  }
892 
893  newItem->Move( wxPoint( Mils2iu( cfg->m_Repeat.x_step ),
894  Mils2iu( cfg->m_Repeat.y_step ) ) );
895  }
896  else
897  {
898  EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
899 
900  if( dynamic_cast<SCH_TEXT*>( newItem ) )
901  {
902  SCH_TEXT* text = static_cast<SCH_TEXT*>( newItem );
904  }
905 
906  newItem->Move( wxPoint( Mils2iu( cfg->m_Drawing.default_repeat_offset_x ),
907  Mils2iu( cfg->m_Drawing.default_repeat_offset_y ) ) );
908  }
909 
910  }
911 
912  newItem->SetFlags( IS_NEW );
913  m_frame->AddToScreen( newItem, m_frame->GetScreen() );
915 
916  m_selectionTool->AddItemToSel( newItem );
917 
918  if( performDrag )
920 
921  newItem->ClearFlags();
922 
923  if( newItem->IsConnectable() )
924  {
925  auto selection = m_selectionTool->GetSelection();
926 
927  m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selection );
930  }
931 
932  // newItem newItem, now that it has been moved, thus saving new position.
933  m_frame->SaveCopyForRepeatItem( newItem );
934 
935  return 0;
936 }
937 
938 
940 {
941  SCH_MARKER_T,
943  SCH_LINE_T,
946  SCH_TEXT_T,
947  SCH_LABEL_T,
951  SCH_SHEET_T,
954  SCH_BITMAP_T,
955  EOT
956 };
957 
958 
960 {
961  SCH_SCREEN* screen = m_frame->GetScreen();
963  bool appendToUndo = false;
964  std::vector<wxPoint> pts;
965 
966  if( items.empty() )
967  return 0;
968 
969  // Don't leave a freed pointer in the selection
971 
972  for( EDA_ITEM* item : items )
973  item->ClearFlags( STRUCT_DELETED );
974 
975  for( EDA_ITEM* item : items )
976  {
977  SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
978 
979  if( !sch_item )
980  continue;
981 
982  if( sch_item->IsConnectable() )
983  {
984  std::vector<wxPoint> tmp_pts = sch_item->GetConnectionPoints();
985  pts.insert( pts.end(), tmp_pts.begin(), tmp_pts.end() );
986  }
987 
988  if( sch_item->Type() == SCH_JUNCTION_T )
989  {
990  sch_item->SetFlags( STRUCT_DELETED );
991  // clean up junctions at the end
992  }
993  else
994  {
995  sch_item->SetFlags( STRUCT_DELETED );
996  saveCopyInUndoList( item, UNDO_REDO::DELETED, appendToUndo );
997  appendToUndo = true;
998 
999  updateItem( sch_item, false );
1000 
1001  if( sch_item->Type() == SCH_SHEET_PIN_T )
1002  {
1003  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) sch_item;
1004  SCH_SHEET* sheet = pin->GetParent();
1005 
1006  sheet->RemovePin( pin );
1007  }
1008  else
1009  {
1010  m_frame->RemoveFromScreen( sch_item, m_frame->GetScreen() );
1011  }
1012 
1013  if( sch_item->Type() == SCH_SHEET_T )
1015  }
1016  }
1017 
1018  for( auto point : pts )
1019  {
1020  SCH_ITEM* junction = screen->GetItem( point, 0, SCH_JUNCTION_T );
1021 
1022  if( !junction )
1023  continue;
1024 
1025  if( junction->HasFlag( STRUCT_DELETED ) || !screen->IsJunctionNeeded( point ) )
1026  m_frame->DeleteJunction( junction, appendToUndo );
1027  }
1028 
1030 
1031  m_frame->GetCanvas()->Refresh();
1032  m_frame->OnModify();
1033 
1034  return 0;
1035 }
1036 
1037 
1038 #define HITTEST_THRESHOLD_PIXELS 5
1039 
1040 
1042 {
1043  std::string tool = aEvent.GetCommandStr().get();
1044  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1045 
1047  m_pickerItem = nullptr;
1048 
1049  // Deactivate other tools; particularly important if another PICKER is currently running
1050  Activate();
1051 
1052  picker->SetCursor( KICURSOR::REMOVE );
1053 
1054  picker->SetClickHandler(
1055  [this]( const VECTOR2D& aPosition ) -> bool
1056  {
1057  if( m_pickerItem )
1058  {
1059  SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( m_pickerItem );
1060 
1061  if( sch_item && sch_item->IsLocked() )
1062  {
1063  STATUS_TEXT_POPUP statusPopup( m_frame );
1064  statusPopup.SetText( _( "Item locked." ) );
1065  statusPopup.PopupFor( 2000 );
1066  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1067  return true;
1068  }
1069 
1071  selectionTool->UnbrightenItem( m_pickerItem );
1072  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
1074  m_pickerItem = nullptr;
1075  }
1076 
1077  return true;
1078  } );
1079 
1080  picker->SetMotionHandler(
1081  [this]( const VECTOR2D& aPos )
1082  {
1083  EE_COLLECTOR collector;
1084  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
1085  collector.Collect( m_frame->GetScreen(), deletableItems, (wxPoint) aPos );
1086 
1088  selectionTool->GuessSelectionCandidates( collector, aPos );
1089 
1090  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
1091 
1092  if( m_pickerItem != item )
1093  {
1094  if( m_pickerItem )
1095  selectionTool->UnbrightenItem( m_pickerItem );
1096 
1097  m_pickerItem = item;
1098 
1099  if( m_pickerItem )
1100  selectionTool->BrightenItem( m_pickerItem );
1101  }
1102  } );
1103 
1104  picker->SetFinalizeHandler(
1105  [this]( const int& aFinalState )
1106  {
1107  if( m_pickerItem )
1109 
1110  // Wake the selection tool after exiting to ensure the cursor gets updated
1112  } );
1113 
1114  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1115 
1116  return 0;
1117 }
1118 
1119 
1121 {
1122  // Save old component in undo list if not already in edit, or moving.
1123  if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
1125 
1126  wxString title = wxString::Format( _( "Edit %s Field" ), aField->GetName() );
1127 
1128  DIALOG_SCH_EDIT_ONE_FIELD dlg( m_frame, title, aField );
1129 
1130  // The footprint field dialog can invoke a KIWAY_PLAYER so we must use a quasi-modal
1131  if( dlg.ShowQuasiModal() != wxID_OK )
1132  return;
1133 
1134  dlg.UpdateField( aField, &m_frame->GetCurrentSheet() );
1135 
1136  if( m_frame->eeconfig()->m_AutoplaceFields.enable || aField->GetParent()->Type() == SCH_SHEET_T )
1137  static_cast<SCH_ITEM*>( aField->GetParent() )->AutoAutoplaceFields( m_frame->GetScreen() );
1138 
1139  m_frame->UpdateItem( aField );
1140  m_frame->OnModify();
1141 
1142  // This must go after OnModify() so that the connectivity graph will have been updated.
1144 }
1145 
1146 
1148 {
1149  static KICAD_T Nothing[] = { EOT };
1150  static KICAD_T CmpOrReference[] = { SCH_FIELD_LOCATE_REFERENCE_T, SCH_COMPONENT_T, EOT };
1151  static KICAD_T CmpOrValue[] = { SCH_FIELD_LOCATE_VALUE_T, SCH_COMPONENT_T, EOT };
1152  static KICAD_T CmpOrFootprint[] = { SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_COMPONENT_T, EOT };
1153 
1154  KICAD_T* filter = Nothing;
1155 
1156  if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1157  filter = CmpOrReference;
1158  else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1159  filter = CmpOrValue;
1160  else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1161  filter = CmpOrFootprint;
1162 
1163  EE_SELECTION& selection = m_selectionTool->RequestSelection( filter );
1164 
1165  if( selection.Empty() )
1166  return 0;
1167 
1168  SCH_ITEM* item = (SCH_ITEM*) selection.Front();
1169 
1170  if( item->Type() == SCH_COMPONENT_T )
1171  {
1172  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1173 
1174  if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1175  editFieldText( component->GetField( REFERENCE_FIELD ) );
1176  else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1177  editFieldText( component->GetField( VALUE_FIELD ) );
1178  else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1179  editFieldText( component->GetField( FOOTPRINT_FIELD ) );
1180  }
1181  else if( item->Type() == SCH_FIELD_T )
1182  {
1183  editFieldText( (SCH_FIELD*) item );
1184  }
1185 
1186  if( selection.IsHover() )
1188 
1189  return 0;
1190 }
1191 
1192 
1194 {
1196 
1197  if( selection.Empty() )
1198  return 0;
1199 
1200  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
1201 
1202  if( !item->IsNew() )
1204 
1205  item->AutoplaceFields( m_frame->GetScreen(), /* aManual */ true );
1206 
1207  updateItem( item, true );
1208  m_frame->OnModify();
1209 
1210  if( selection.IsHover() )
1212 
1213  return 0;
1214 }
1215 
1216 
1218 {
1219  SCH_COMPONENT* selectedSymbol = nullptr;
1221 
1222  if( !selection.Empty() )
1223  selectedSymbol = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
1224 
1226 
1227  if( aEvent.IsAction( &EE_ACTIONS::changeSymbol )
1228  || aEvent.IsAction( &EE_ACTIONS::changeSymbols ) )
1229  {
1231  }
1232 
1233  DIALOG_CHANGE_SYMBOLS dlg( m_frame, selectedSymbol, mode );
1234 
1235  dlg.ShowModal();
1236 
1237  return 0;
1238 }
1239 
1240 
1242 {
1244 
1245  if( selection.Empty() )
1246  return 0;
1247 
1248  SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front();
1249 
1251  && component->GetConvert() == LIB_ITEM::LIB_CONVERT::BASE )
1252  {
1253  return 0;
1254  }
1255 
1257  && component->GetConvert() != LIB_ITEM::LIB_CONVERT::DEMORGAN )
1258  {
1259  return 0;
1260  }
1261 
1262  if( !component->IsNew() )
1263  saveCopyInUndoList( component, UNDO_REDO::CHANGED );
1264 
1265  m_frame->ConvertPart( component );
1266 
1267  if( component->IsNew() )
1269 
1270  if( selection.IsHover() )
1272 
1273  return 0;
1274 }
1275 
1276 
1278 {
1280 
1281  if( selection.Empty() )
1282  {
1284  {
1286  VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
1287 
1288  if( worksheet && worksheet->HitTestWorksheetItems( getView(), (wxPoint) cursorPos ) )
1290  }
1291 
1292  return 0;
1293  }
1294 
1295  SCH_ITEM* item = (SCH_ITEM*) selection.Front();
1296 
1297  switch( item->Type() )
1298  {
1299  case SCH_LINE_T:
1300  case SCH_BUS_WIRE_ENTRY_T:
1301  if( !selection.AllItemsHaveLineStroke() )
1302  return 0;
1303 
1304  break;
1305 
1306  case SCH_JUNCTION_T:
1307  if( !selection.AreAllItemsIdentical() )
1308  return 0;
1309 
1310  break;
1311 
1312  default:
1313  if( selection.Size() > 1 )
1314  return 0;
1315 
1316  break;
1317  }
1318 
1319  switch( item->Type() )
1320  {
1321  case SCH_COMPONENT_T:
1322  {
1323  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1324  DIALOG_SYMBOL_PROPERTIES symbolPropsDialog( m_frame, component );
1325 
1326  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
1327  // frame. Therefore this dialog as a modal frame parent, MUST be run under
1328  // quasimodal mode for the quasimodal frame support to work. So don't use
1329  // the QUASIMODAL macros here.
1330  int retval = symbolPropsDialog.ShowQuasiModal();
1331 
1332  if( retval == SYMBOL_PROPS_EDIT_OK )
1333  {
1335  component->AutoAutoplaceFields( m_frame->GetScreen() );
1336 
1338  m_frame->OnModify();
1339  }
1340  else if( retval == SYMBOL_PROPS_EDIT_SCHEMATIC_SYMBOL )
1341  {
1342  auto editor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, true );
1343 
1344  editor->LoadSymbolFromSchematic( component->GetPartRef(),
1345  component->GetRef( &m_frame->GetCurrentSheet() ),
1346  component->GetUnit(), component->GetConvert() );
1347 
1348  editor->Show( true );
1349  editor->Raise();
1350  }
1351  else if( retval == SYMBOL_PROPS_EDIT_LIBRARY_SYMBOL )
1352  {
1353  auto editor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, true );
1354 
1355  editor->LoadSymbolAndSelectLib( component->GetLibId(), component->GetUnit(),
1356  component->GetConvert() );
1357 
1358  editor->Show( true );
1359  editor->Raise();
1360  }
1361  else if( retval == SYMBOL_PROPS_WANT_UPDATE_SYMBOL )
1362  {
1364  dlg.ShowModal();
1365  }
1366  else if( retval == SYMBOL_PROPS_WANT_EXCHANGE_SYMBOL )
1367  {
1369  dlg.ShowModal();
1370  }
1371  }
1372  break;
1373 
1374  case SCH_SHEET_T:
1375  {
1376  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1377  bool doClearAnnotation;
1378  bool doRefresh = false;
1379 
1380  // Keep track of existing sheet paths. EditSheet() can modify this list.
1381  // Note that we use the validity checking/repairing version here just to make sure
1382  // we've got a valid hierarchy to begin with.
1383  SCH_SHEET_LIST initial_sheetpathList( &m_frame->Schematic().Root(), true );
1384 
1385  doRefresh = m_frame->EditSheetProperties( sheet, &m_frame->GetCurrentSheet(),
1386  &doClearAnnotation );
1387 
1388  // If the sheet file is changed and new sheet contents are loaded then we have to
1389  // clear the annotations on the new content (as it may have been set from some other
1390  // sheet path reference)
1391  if( doClearAnnotation )
1392  {
1393  SCH_SCREENS screensList( &m_frame->Schematic().Root() );
1394  // We clear annotation of new sheet paths here:
1395  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1396  // Clear annotation of g_CurrentSheet itself, because its sheetpath is not a new
1397  // path, but components managed by its sheet path must have their annotation
1398  // cleared, because they are new:
1400  }
1401 
1402  if( doRefresh )
1403  {
1405  m_frame->GetCanvas()->Refresh();
1407  }
1408 
1409  break;
1410  }
1411 
1412  case SCH_SHEET_PIN_T:
1413  {
1414  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) item;
1416 
1417  // QuasiModal required for help dialog
1418  if( dlg.ShowQuasiModal() == wxID_OK )
1419  {
1421  m_frame->OnModify();
1422  }
1423  }
1424  break;
1425 
1426  case SCH_TEXT_T:
1427  case SCH_LABEL_T:
1428  case SCH_GLOBAL_LABEL_T:
1429  case SCH_HIER_LABEL_T:
1430  {
1431  DIALOG_LABEL_EDITOR dlg( m_frame, (SCH_TEXT*) item );
1432 
1433  // Must be quasi modal for syntax help
1434  if( dlg.ShowQuasiModal() == wxID_OK )
1435  {
1437  m_frame->OnModify();
1438  }
1439  }
1440  break;
1441 
1442  case SCH_FIELD_T:
1443  editFieldText( (SCH_FIELD*) item );
1444  break;
1445 
1446  case SCH_BITMAP_T:
1447  {
1448  SCH_BITMAP* bitmap = (SCH_BITMAP*) item;
1449  DIALOG_IMAGE_EDITOR dlg( m_frame, bitmap->GetImage() );
1450 
1451  if( dlg.ShowModal() == wxID_OK )
1452  {
1453  // save old image in undo list if not already in edit
1454  if( bitmap->GetEditFlags() == 0 )
1456 
1457  dlg.TransferToImage( bitmap->GetImage() );
1458 
1459  // The bitmap is cached in Opengl: clear the cache in case it has become invalid
1460  getView()->RecacheAllItems();
1462  m_frame->OnModify();
1463  }
1464  }
1465  break;
1466 
1467  case SCH_LINE_T:
1468  case SCH_BUS_WIRE_ENTRY_T:
1469  {
1470  std::deque<SCH_ITEM*> strokeItems;
1471 
1472  for( auto selItem : selection.Items() )
1473  {
1474  SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( selItem );
1475 
1476  if( schItem && schItem->HasLineStroke() )
1477  strokeItems.push_back( schItem );
1478  else
1479  return 0;
1480  }
1481 
1482  DIALOG_EDIT_LINE_STYLE dlg( m_frame, strokeItems );
1483 
1484  if( dlg.ShowModal() == wxID_OK )
1485  {
1487  m_frame->OnModify();
1488  }
1489  }
1490  break;
1491 
1492  case SCH_JUNCTION_T:
1493  {
1494  std::deque<SCH_JUNCTION*> junctions;
1495 
1496  for( auto selItem : selection.Items() )
1497  {
1498  SCH_JUNCTION* junction = dynamic_cast<SCH_JUNCTION*>( selItem );
1499 
1500  wxCHECK( junction, 0 );
1501 
1502  junctions.push_back( junction );
1503  }
1504 
1505  DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
1506 
1507  if( dlg.ShowModal() == wxID_OK )
1508  {
1510  m_frame->OnModify();
1511  }
1512  }
1513  break;
1514 
1515  case SCH_MARKER_T: // These items have no properties to edit
1516  case SCH_NO_CONNECT_T:
1517  break;
1518 
1519  default: // Unexpected item
1520  wxFAIL_MSG( wxString( "Cannot edit schematic item type " ) + item->GetClass() );
1521  }
1522 
1523  updateItem( item, true );
1524 
1525  if( selection.IsHover() )
1527 
1528  return 0;
1529 }
1530 
1531 
1533 {
1534  KICAD_T convertTo = aEvent.Parameter<KICAD_T>();
1536  EE_SELECTION& selection = m_selectionTool->RequestSelection( allTextTypes );
1537 
1538  for( unsigned int i = 0; i < selection.GetSize(); ++i )
1539  {
1540  SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( selection.GetItem( i ) );
1541 
1542  if( text && text->Type() != convertTo )
1543  {
1544  bool selected = text->IsSelected();
1545  SCH_TEXT* newtext = nullptr;
1546  const wxPoint& position = text->GetPosition();
1547  LABEL_SPIN_STYLE orientation = text->GetLabelSpinStyle();
1548  wxString txt = UnescapeString( text->GetText() );
1549 
1550  // There can be characters in a SCH_TEXT object that can break labels so we have to
1551  // fix them here.
1552  if( text->Type() == SCH_TEXT_T )
1553  {
1554  txt.Replace( "\n", "_" );
1555  txt.Replace( "\r", "_" );
1556  txt.Replace( "\t", "_" );
1557  txt.Replace( " ", "_" );
1558  }
1559 
1560  // label strings are "escaped" i.e. a '/' is replaced by "{slash}"
1561  if( convertTo != SCH_TEXT_T )
1562  txt = EscapeString( txt, CTX_NETNAME );
1563 
1564  switch( convertTo )
1565  {
1566  case SCH_LABEL_T: newtext = new SCH_LABEL( position, txt ); break;
1567  case SCH_GLOBAL_LABEL_T: newtext = new SCH_GLOBALLABEL( position, txt ); break;
1568  case SCH_HIER_LABEL_T: newtext = new SCH_HIERLABEL( position, txt ); break;
1569  case SCH_TEXT_T: newtext = new SCH_TEXT( position, txt ); break;
1570 
1571  default:
1572  wxFAIL_MSG( wxString::Format( "Invalid text type: %d.", convertTo ) );
1573  return 0;
1574  }
1575 
1576  // Copy the old text item settings to the new one. Justifications are not copied
1577  // because they are not used in labels. Justifications will be set to default value
1578  // in the new text item type.
1579  //
1580  newtext->SetFlags( text->GetEditFlags() );
1581  newtext->SetShape( text->GetShape() );
1582  newtext->SetLabelSpinStyle( orientation );
1583  newtext->SetTextSize( text->GetTextSize() );
1584  newtext->SetTextThickness( text->GetTextThickness() );
1585  newtext->SetItalic( text->IsItalic() );
1586  newtext->SetBold( text->IsBold() );
1587  newtext->SetIsDangling( text->IsDangling() );
1588 
1589  if( selected )
1591 
1592  if( !text->IsNew() )
1593  {
1595  saveCopyInUndoList( newtext, UNDO_REDO::NEWITEM, true );
1596 
1598  m_frame->AddToScreen( newtext, m_frame->GetScreen() );
1599  }
1600 
1601  if( selected )
1602  m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, newtext );
1603 
1604  // Otherwise, pointer is owned by the undo stack
1605  if( text->IsNew() )
1606  delete text;
1607 
1608  if( convertTo == SCH_TEXT_T )
1609  {
1610  if( newtext->IsDangling() )
1611  {
1612  newtext->SetIsDangling( false );
1613  getView()->Update( newtext, KIGFX::REPAINT );
1614  }
1615  }
1616  else
1618 
1619  m_frame->OnModify();
1620  }
1621  }
1622 
1623  if( selection.IsHover() )
1625 
1626  return 0;
1627 }
1628 
1629 
1631 {
1632  auto cursorPos = wxPoint( getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) ) );
1633 
1634  if( m_frame->BreakSegments( cursorPos ) )
1635  {
1636  if( m_frame->GetScreen()->IsJunctionNeeded( cursorPos, true ) )
1637  m_frame->AddJunction( m_frame->GetScreen(), cursorPos, true, false );
1638 
1640 
1641  m_frame->OnModify();
1642  m_frame->GetCanvas()->Refresh();
1643  }
1644 
1645  return 0;
1646 }
1647 
1648 
1650 {
1652  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1653 
1654  if( !sheet )
1655  return 0;
1656 
1657  if( !sheet->HasUndefinedPins() )
1658  {
1659  DisplayInfoMessage( m_frame, _( "There are no unreferenced pins in this sheet to remove." ) );
1660  return 0;
1661  }
1662 
1663  if( !IsOK( m_frame, _( "Do you wish to delete the unreferenced pins from this sheet?" ) ) )
1664  return 0;
1665 
1667 
1668  sheet->CleanupSheet();
1669 
1670  updateItem( sheet, true );
1671  m_frame->OnModify();
1672 
1673  if( selection.IsHover() )
1675 
1676  return 0;
1677 }
1678 
1679 
1681 {
1683 
1684  if( selection.GetSize() > 1 )
1685  return 0;
1686 
1687  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1688 
1689  SCH_SHEET_PATH instance = m_frame->GetCurrentSheet();
1690 
1691  SCH_SCREEN* screen;
1692 
1693  if( sheet )
1694  {
1695  // When changing the page number of a selected sheet, the current screen owns the sheet.
1696  screen = m_frame->GetScreen();
1697 
1698  instance.push_back( sheet );
1699  }
1700  else
1701  {
1702  SCH_SHEET_PATH prevInstance = instance;
1703 
1704  // When change the page number in the screen, the previous screen owns the sheet.
1705  if( prevInstance.size() )
1706  {
1707  prevInstance.pop_back();
1708  screen = prevInstance.LastScreen();
1709  }
1710  else
1711  {
1712  // The root sheet and root screen are effectively the same thing.
1713  screen = m_frame->GetScreen();
1714  }
1715 
1716  sheet = m_frame->GetCurrentSheet().Last();
1717  }
1718 
1719  wxString msg;
1720  wxString sheetPath = instance.PathAsString();
1721  wxString pageNumber = instance.GetPageNumber();
1722 
1723  msg.Printf( _( "Enter page number for sheet path%s" ),
1724  ( sheetPath.Length() > 20 ) ? "\n" + sheetPath : " " + sheetPath );
1725 
1726  wxTextEntryDialog dlg( m_frame, msg, _( "Edit Page Number" ), pageNumber );
1727 
1728  dlg.SetTextValidator( wxFILTER_ALPHANUMERIC ); // No white space.
1729 
1730  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetValue() == instance.GetPageNumber() )
1731  return 0;
1732 
1733  m_frame->SaveCopyInUndoList( screen, sheet, UNDO_REDO::CHANGED, false );
1734 
1735  instance.SetPageNumber( dlg.GetValue() );
1736 
1737  if( instance == m_frame->GetCurrentSheet() )
1738  {
1739  m_frame->GetScreen()->SetPageNumber( dlg.GetValue() );
1741  }
1742 
1743  m_frame->OnModify();
1744 
1745  return 0;
1746 }
1747 
1748 
1750 {
1755  Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorX.MakeEvent() );
1756  Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorY.MakeEvent() );
1757  Go( &SCH_EDIT_TOOL::DoDelete, ACTIONS::doDelete.MakeEvent() );
1759 
1776 
1779 
1783 }
static TOOL_ACTION editPageNumber
Definition: ee_actions.h:155
const BITMAP_OPAQUE component_select_unit_xpm[1]
bool IsDangling() const override
Definition: sch_text.h:303
bool empty() const
Definition: sch_rtree.h:166
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: eda_text.h:50
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Adds a submenu to the menu.
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
bool IsBold() const
Definition: eda_text.h:189
static TOOL_ACTION properties
Definition: ee_actions.h:121
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
bool IsCurrentTool(const TOOL_ACTION &aAction) const
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:237
#define HITTEST_THRESHOLD_PIXELS
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
int m_Threshold
Definition: collector.h:66
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
virtual bool IsConnectable() const
Definition: sch_item.h:383
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:61
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:206
bool IsHover() const
Definition: selection.h:70
SCH_SHEET * GetParent() const
Get the parent sheet object of this sheet pin.
Definition: sch_sheet.h:169
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:144
std::deque< EDA_ITEM * > & Items()
Definition: selection.h:206
static TOOL_ACTION toggleDeMorgan
Definition: ee_actions.h:126
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:97
virtual std::vector< wxPoint > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:397
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:83
static TOOL_ACTION breakBus
Definition: ee_actions.h:135
static TOOL_ACTION pageSettings
Definition: actions.h:59
static SELECTION_CONDITION SingleSymbol
static KICAD_T duplicatableItems[]
bool IsSelected() const
Definition: eda_item.h:191
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:43
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:75
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:371
SCH_DRAWING_TOOLS.
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:73
void MirrorY(int aYaxis_position) override
Mirror item relative to the Y axis about aYaxis_position.
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)
Creates a functor that tests if the number of selected items is greater than the value given as param...
void Collect(SCH_SCREEN *aScreen, const KICAD_T aFilterList[], const wxPoint &aPos, int aUnit=0, int aConvert=0)
Function Collect scans a EDA_ITEM using this class's Inspector method, which does the collection.
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:63
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
Definition: sch_item.h:467
static bool Idle(const SELECTION &aSelection)
Tests if there no items selected or being edited.
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Creates a functor that tests if the selected items are only of given types.
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:66
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void RotateEnd(wxPoint aPosition)
Definition: sch_line.cpp:362
STATUS_TEXT_POPUP.
Definition: status_popup.h:82
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.h:137
bool IsMoving() const
Definition: eda_item.h:188
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
int Rotate(const TOOL_EVENT &aEvent)
static TOOL_ACTION mirrorY
Definition: ee_actions.h:120
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:87
void SetItalic(bool isItalic)
Definition: eda_text.h:185
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static TOOL_ACTION changeSymbol
Definition: ee_actions.h:149
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1377
int EditPageNumber(const TOOL_EVENT &aEvent)
int BreakWire(const TOOL_EVENT &aEvent)
TOOL_MENU & GetToolMenu()
double GetTextAngle() const
Definition: eda_text.h:180
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
EE_COLLECTOR.
Definition: ee_collectors.h:42
static TOOL_ACTION toText
Definition: ee_actions.h:133
static const KICAD_T FieldOwners[]
Definition: ee_collectors.h:49
static TOOL_ACTION autoplaceFields
Definition: ee_actions.h:125
WS_PROXY_VIEW_ITEM * GetWorksheet() const
Definition: sch_view.h:98
wxString PathAsString() const
Return the path of time stamps which do not changes even when editing sheet parameters.
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.
bool AreAllItemsIdentical() const
Checks if all items in the selection are the same KICAD_T type.
Definition: selection.h:277
void OnPageSettingsChange() override
Called when modifying the page settings.
static TOOL_ACTION updateSymbols
Definition: ee_actions.h:148
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:244
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:47
virtual wxPoint GetPosition() const
Definition: eda_item.h:325
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:48
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
static SELECTION_CONDITION Count(int aNumber)
Creates a functor that tests if the number of selected items is equal to the value given as parameter...
void setTransitions() override
Sets up handlers for various events.
void SetIsDangling(bool aIsDangling)
Definition: sch_text.h:304
int GetTextThickness() const
Definition: eda_text.h:165
void update() override
Update menu state stub.
void MirrorX(int aXaxis_position) override
Mirror item relative to the X axis about aXaxis_position.
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:284
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:128
static bool IdleSelection(const SELECTION &aSelection)
Tests if all selected items are not being edited.
Dialog to update or change schematic library symbols.
static bool NotEmpty(const SELECTION &aSelection)
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()
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:213
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:184
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
void RotateStart(wxPoint aPosition)
Definition: sch_line.cpp:356
static TOOL_ACTION breakWire
Definition: ee_actions.h:134
static TOOL_ACTION rotateCW
Definition: ee_actions.h:117
Field Value of part, i.e. "3.3K".
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:67
bool IsNew() const
Definition: eda_item.h:187
void pop_back()
Forwarded method from std::vector.
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const wxPoint &aPos, bool aAppendToUndo, bool aFinal=true)
static TOOL_ACTION removeItemFromSel
Definition: ee_actions.h:60
static TOOL_ACTION pickerTool
Definition: actions.h:153
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
bool IsItalic() const
Definition: eda_text.h:186
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
Definition: picker_tool.h:103
virtual void Rotate(wxPoint aPosition)=0
Rotate the item around aPosition 90 degrees in the clockwise direction.
EE_SELECTION & GetSelection()
Function GetSelection()
EESCHEMA_SETTINGS * eeconfig() const
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:270
int Duplicate(const TOOL_EVENT &aEvent)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
static TOOL_ACTION drawSheet
Definition: ee_actions.h:88
static SELECTION_CONDITION SingleDeMorganSymbol
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:104
static TOOL_ACTION copy
Definition: actions.h:70
void editFieldText(SCH_FIELD *aField)
bool HitTestWorksheetItems(VIEW *aView, const wxPoint &aPosition)
static TOOL_ACTION cleanupSheetPins
Definition: ee_actions.h:190
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:118
int GetUnit() const
void BrightenItem(EDA_ITEM *aItem)
void RemovePin(SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:291
static TOOL_ACTION editFootprint
Definition: ee_actions.h:124
AUTOPLACE_FIELDS m_AutoplaceFields
Item is being added to the view.
Definition: view_item.h:62
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:220
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:205
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:59
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_sheet.cpp:591
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:78
#define NULL
BITMAP_BASE * GetImage()
Definition: sch_bitmap.h:59
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:345
size_t size() const
Forwarded method from std::vector.
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aType, bool aAppend=false)
Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.
Definition: ee_tool_base.h:138
STATUS_FLAGS GetEditFlags() const
Definition: eda_item.h:225
int ShowQuasiModal()
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
wxString GetPageNumber() const
const wxSize & GetTextSize() const
Definition: eda_text.h:245
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:473
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:209
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:91
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetIcon(const BITMAP_OPAQUE *aIcon)
Assigns an icon for the entry.
Definition: action_menu.cpp:71
TOOL_EVENT.
Definition: tool_event.h:171
static TOOL_ACTION updateSymbol
Definition: ee_actions.h:150
virtual bool HasLineStroke() const
Check if this schematic item has line stoke properties.
Definition: sch_item.h:484
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:116
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:131
static TOOL_ACTION cut
Definition: actions.h:69
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
EDA_ITEM * GetParent() const
Definition: eda_item.h:183
const KICAD_T rotatableItems[]
static TOOL_ACTION mirrorX
Definition: ee_actions.h:119
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:181
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:233
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
#define STRUCT_DELETED
flag indication structures to be erased
Definition: eda_item.h:115
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:364
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:85
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:576
virtual void MirrorX(int aXaxis_position)=0
Mirror item relative to the X axis about aXaxis_position.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::unique_ptr< LIB_PART > & GetPartRef()
virtual void Move(const wxPoint &aWhere)
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:75
int CleanupSheetPins(const TOOL_EVENT &aEvent)
static SELECTION_CONDITION SingleMultiUnitSymbol
virtual void MirrorY(int aYaxis_position)=0
Mirror item relative to the Y axis about aYaxis_position.
static TOOL_ACTION editTextAndGraphics
Definition: ee_actions.h:191
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:455
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:104
wxPoint GetPosition() const override
Definition: sch_text.h:312
virtual void PopupFor(int aMsecs)
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_sheet.cpp:723
int DeleteItemCursor(const TOOL_EVENT &aEvent)
Runs the deletion tool.
void UnbrightenItem(EDA_ITEM *aItem)
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:127
DIALOG_SCH_EDIT_ONE_FIELD is a the class to handle editing a single component field in the schematic ...
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:36
virtual 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...
bool NameExists(const wxString &aSheetName)
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
void updateItem(EDA_ITEM *aItem, bool aUpdateRTree) const
Similar to getView()->Update(), but handles items that are redrawn by their parents and updating the ...
Definition: ee_tool_base.h:107
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219
bool AllItemsHaveLineStroke() const
Checks if all items in the selection support line strokes.
Field Name Module PCB, i.e. "16DIP300".
int Mirror(const TOOL_EVENT &aEvent)
virtual void Rotate90(bool aClockwise)
Definition: sch_text.cpp:214
void AddSeparator(int aOrder=ANY_ORDER)
Adds a separator to the menu.
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:68
EDA_ITEM * m_pickerItem
Definition: sch_edit_tool.h:88
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:99
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:285
virtual bool IsLocked() const
Definition: sch_item.h:268
int RepeatDrawItem(const TOOL_EVENT &aEvent)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
static TOOL_ACTION placeLabel
Definition: ee_actions.h:85
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: eda_item.h:111
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
bool HasUndefinedPins()
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:353
static TOOL_ACTION editValue
Definition: ee_actions.h:123
static KICAD_T deletableItems[]
SCH_SHEET & Root() const
Definition: schematic.h:102
SCH_ITEM * GetRepeatItem() const
Return the item which is to be repeated with the insert key.
void SetTitle(const wxString &aTitle) override
Sets title for the menu.
Definition: action_menu.cpp:89
see class PGM_BASE
int AddItemToSel(const TOOL_EVENT &aEvent)
SCH_SCREEN * LastScreen()
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:208
#define _(s)
Definition: 3d_actions.cpp:33
TOOL_MANAGER * getToolManager() const
Returns an instance of TOOL_MANAGER class.
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:152
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
These Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which ar...
Definition: string.cpp:77
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
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:504
EE_RTREE & Items()
Definition: sch_screen.h:159
static SELECTION_CONDITION OnlyType(KICAD_T aType)
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)
void Clear()
Removes all the entries from the menu (as well as its title).
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
Schematic symbol object.
Definition: sch_component.h:79
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
static TOOL_ACTION changeSymbols
Definition: ee_actions.h:147
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_field.h:70
wxPoint Centre() const
Definition: eda_rect.h:62
int ChangeSymbols(const TOOL_EVENT &aEvent)
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:221
bool EditSheetProperties(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
Edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:465
void Activate()
Function Activate() Runs the tool.
wxPoint GetRotationCenter() const
Rotating around the boundingBox's center can cause walking when the sheetname or filename is longer t...
Definition: sch_sheet.cpp:602
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
SCH_SHEET_PATH & GetCurrentSheet() const
static TOOL_ACTION deleteTool
Definition: actions.h:76
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:922
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:162
static TOOL_ACTION move
Definition: ee_actions.h:114
#define ENDPOINT
ends. (Used to support dragging.)
Definition: eda_item.h:112
EE_TOOL_BASE.
Definition: ee_tool_base.h:50
SCH_ITEM * GetItem(const wxPoint &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T)
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:310
static TOOL_ACTION toLabel
Definition: ee_actions.h:130
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:164
int GetConvert() const
virtual void MirrorSpinStyle(bool aLeftRight)
Definition: sch_text.cpp:223
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
#define TEXT_ANGLE_VERT
Definition: eda_text.h:51
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:173
static TOOL_ACTION toHLabel
Definition: ee_actions.h:131
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: eda_item.cpp:89
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
static TOOL_ACTION editReference
Definition: ee_actions.h:122
void ClearAnnotationOfNewSheetPaths(SCH_SHEET_LIST &aInitialSheetPathList)
Clear the annotation for the components inside new sheetpaths when a complex hierarchy is modified an...
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:232
bool HasFlag(STATUS_FLAGS aFlag)
Definition: eda_item.h:223
const wxPoint GetCenter() const
Definition: eda_rect.h:117
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:86
int DoDelete(const TOOL_EVENT &aEvent)
Deletes the selected items, or the item under the cursor.
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath)
Clear exiting component annotation.
const LIB_ID & GetLibId() const
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:268
Field Reference of part, i.e. "IC21".
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:274
void SetBold(bool aBold)
Definition: eda_text.h:188
void ConvertPart(SCH_COMPONENT *aComponent)
Definition: getpart.cpp:237
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Adds a menu entry to run a TOOL_ACTION on selected items.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
static TOOL_ACTION selectAll
Definition: actions.h:73
static TOOL_ACTION toGLabel
Definition: ee_actions.h:132
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:284
#define IS_NEW
New item, just created.
Definition: eda_item.h:106
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
int ConvertDeMorgan(const TOOL_EVENT &aEvent)
static TOOL_ACTION paste
Definition: actions.h:71
static const KICAD_T EditableItems[]
Definition: ee_collectors.h:46
static TOOL_ACTION duplicate
Definition: actions.h:74
int ChangeTextType(const TOOL_EVENT &aEvent)
Change a text type to another one.
void SetText(const wxString &aText)
Display a text.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:521
static TOOL_ACTION refreshPreview
Definition: actions.h:104
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:201
Dialog used to edit SCH_COMPONENT objects in a schematic.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1513
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:235
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:402
void IncrementLabel(int aIncrement)
Increment the label text, if it ends with a number.
Definition: sch_text.cpp:152
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
The symbol library editor main window.
virtual void Move(const wxPoint &aMoveVector)=0
Move the item by aMoveVector to a new position.