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-2021 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_symbol.h>
40 #include <sch_sheet.h>
41 #include <sch_sheet_pin.h>
42 #include <sch_text.h>
43 #include <sch_bitmap.h>
44 #include <sch_view.h>
45 #include <sch_line.h>
46 #include <sch_bus_entry.h>
47 #include <sch_junction.h>
48 #include <sch_edit_frame.h>
49 #include <schematic.h>
52 #include <eeschema_id.h>
53 #include <status_popup.h>
54 #include <wx/gdicmn.h>
62 #include "sch_drawing_tools.h"
63 #include <math/util.h> // for KiROUND
64 #include <pgm_base.h>
66 #include <symbol_editor_settings.h>
68 #include <core/kicad_algo.h>
69 //#include <wx/filedlg.h>
70 #include <wx/textdlg.h>
71 
72 
73 
75 {
76 public:
78  ACTION_MENU( true )
79  {
81  SetTitle( _( "Symbol Unit" ) );
82  }
83 
84 protected:
85  ACTION_MENU* create() const override
86  {
87  return new SYMBOL_UNIT_MENU();
88  }
89 
90 private:
91  void update() override
92  {
94  EE_SELECTION& selection = selTool->GetSelection();
95  SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( selection.Front() );
96 
97  Clear();
98 
99  if( !symbol )
100  {
101  Append( ID_POPUP_SCH_UNFOLD_BUS, _( "no symbol selected" ), wxEmptyString );
102  Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
103  return;
104  }
105 
106  int unit = symbol->GetUnit();
107 
108  if( !symbol->GetLibSymbolRef() || symbol->GetLibSymbolRef()->GetUnitCount() < 2 )
109  {
110  Append( ID_POPUP_SCH_UNFOLD_BUS, _( "symbol is not multi-unit" ), wxEmptyString );
111  Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
112  return;
113  }
114 
115  for( int ii = 0; ii < symbol->GetLibSymbolRef()->GetUnitCount(); ii++ )
116  {
117  wxString num_unit;
118  num_unit.Printf( _( "Unit %s" ), LIB_SYMBOL::SubReference( ii + 1, false ) );
119 
120  wxMenuItem * item = Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, num_unit, wxEmptyString,
121  wxITEM_CHECK );
122  if( unit == ii + 1 )
123  item->Check(true);
124 
125  // The ID max for these submenus is ID_POPUP_SCH_SELECT_UNIT_SYM_MAX
126  // See eeschema_id to modify this value.
128  break; // We have used all IDs for these submenus
129  }
130  }
131 };
132 
133 
135  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveEdit" )
136 {
137  m_pickerItem = nullptr;
138 }
139 
140 
142 
144 {
146 
149 
150  wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
151 
152  auto hasElements =
153  [ this ] ( const SELECTION& aSel )
154  {
155  return !m_frame->GetScreen()->Items().empty();
156  };
157 
158  auto sheetTool =
159  [ this ] ( const SELECTION& aSel )
160  {
162  };
163 
164  auto anyTextTool =
165  [ this ] ( const SELECTION& aSel )
166  {
171  };
172 
173  auto duplicateCondition =
174  [] ( const SELECTION& aSel )
175  {
177  return false;
178 
179  return true;
180  };
181 
182  auto orientCondition =
183  [] ( const SELECTION& aSel )
184  {
185  if( aSel.Empty() )
186  return false;
187 
189  return false;
190 
191  SCH_ITEM* item = (SCH_ITEM*) aSel.Front();
192 
193  if( aSel.GetSize() > 1 )
194  return true;
195 
196  switch( item->Type() )
197  {
198  case SCH_MARKER_T:
199  case SCH_JUNCTION_T:
200  case SCH_NO_CONNECT_T:
201  case SCH_PIN_T:
202  return false;
203  case SCH_LINE_T:
204  return item->GetLayer() != LAYER_WIRE && item->GetLayer() != LAYER_BUS;
205  default:
206  return true;
207  }
208  };
209 
210  auto propertiesCondition =
211  [&]( const SELECTION& aSel )
212  {
213  if( aSel.GetSize() == 0 )
214  {
216  {
219 
220  if( ds && ds->HitTestDrawingSheetItems( getView(), (wxPoint) cursor ) )
221  return true;
222  }
223 
224  return false;
225  }
226 
227  SCH_ITEM* firstItem = dynamic_cast<SCH_ITEM*>( aSel.Front() );
228  const EE_SELECTION* eeSelection = dynamic_cast<const EE_SELECTION*>( &aSel );
229 
230  if( !firstItem || !eeSelection )
231  return false;
232 
233  switch( firstItem->Type() )
234  {
235  case SCH_SYMBOL_T:
236  case SCH_SHEET_T:
237  case SCH_SHEET_PIN_T:
238  case SCH_TEXT_T:
239  case SCH_LABEL_T:
240  case SCH_GLOBAL_LABEL_T:
241  case SCH_HIER_LABEL_T:
242  case SCH_FIELD_T:
243  case SCH_BITMAP_T:
244  return aSel.GetSize() == 1;
245 
246  case SCH_LINE_T:
248  return eeSelection->AllItemsHaveLineStroke();
249 
250  case SCH_JUNCTION_T:
251  return eeSelection->AreAllItemsIdentical();
252 
253  default:
254  return false;
255  }
256  };
257 
258  static KICAD_T toLabelTypes[] = { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
259  auto toLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toLabelTypes );
260 
261  static KICAD_T toHLableTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_TEXT_T, EOT };
262  auto toHLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toHLableTypes );
263 
264  static KICAD_T toGLableTypes[] = { SCH_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
265  auto toGLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toGLableTypes );
266 
267  static KICAD_T toTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EOT };
268  auto toTextlCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toTextTypes );
269 
270  static KICAD_T entryTypes[] = { SCH_BUS_WIRE_ENTRY_T, SCH_BUS_BUS_ENTRY_T, EOT };
271  auto entryCondition = E_C::MoreThan( 0 ) && E_C::OnlyTypes( entryTypes );
272 
273  static KICAD_T fieldParentTypes[] = { SCH_SYMBOL_T, SCH_SHEET_T, SCH_GLOBAL_LABEL_T, EOT };
274  auto singleFieldParentCondition = E_C::Count( 1 ) && E_C::OnlyTypes( fieldParentTypes );
275 
276  auto singleSheetCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
277 
278  //
279  // Add edit actions to the move tool menu
280  //
281  if( moveTool )
282  {
283  CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
284 
285  moveMenu.AddSeparator();
286  moveMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition );
287  moveMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition );
288  moveMenu.AddItem( EE_ACTIONS::mirrorV, orientCondition );
289  moveMenu.AddItem( EE_ACTIONS::mirrorH, orientCondition );
290 
291  moveMenu.AddItem( EE_ACTIONS::properties, propertiesCondition );
296 
297  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu = std::make_shared<SYMBOL_UNIT_MENU>();
298  symUnitMenu->SetTool( this );
299  m_menu.AddSubMenu( symUnitMenu );
300  moveMenu.AddMenu( symUnitMenu.get(), E_C::SingleMultiUnitSymbol, 1 );
301 
302  moveMenu.AddSeparator();
306  moveMenu.AddItem( ACTIONS::duplicate, duplicateCondition );
307 
308  moveMenu.AddSeparator();
309  moveMenu.AddItem( ACTIONS::selectAll, hasElements );
310  }
311 
312  //
313  // Add editing actions to the drawing tool menu
314  //
315  CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
316 
317  drawMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
318  drawMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
319  drawMenu.AddItem( EE_ACTIONS::mirrorV, orientCondition, 200 );
320  drawMenu.AddItem( EE_ACTIONS::mirrorH, orientCondition, 200 );
321 
322  drawMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
326  drawMenu.AddItem( EE_ACTIONS::autoplaceFields, singleFieldParentCondition, 200 );
328 
329  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu2 = std::make_shared<SYMBOL_UNIT_MENU>();
330  symUnitMenu2->SetTool( drawingTools );
331  drawingTools->GetToolMenu().AddSubMenu( symUnitMenu2 );
332  drawMenu.AddMenu( symUnitMenu2.get(), E_C::SingleMultiUnitSymbol, 1 );
333 
335 
336  drawMenu.AddItem( EE_ACTIONS::toLabel, anyTextTool && E_C::Idle, 200 );
337  drawMenu.AddItem( EE_ACTIONS::toHLabel, anyTextTool && E_C::Idle, 200 );
338  drawMenu.AddItem( EE_ACTIONS::toGLabel, anyTextTool && E_C::Idle, 200 );
339  drawMenu.AddItem( EE_ACTIONS::toText, anyTextTool && E_C::Idle, 200 );
340  drawMenu.AddItem( EE_ACTIONS::cleanupSheetPins, sheetTool && E_C::Idle, 250 );
341 
342  //
343  // Add editing actions to the selection tool menu
344  //
346 
347  selToolMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
348  selToolMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
349  selToolMenu.AddItem( EE_ACTIONS::mirrorV, orientCondition, 200 );
350  selToolMenu.AddItem( EE_ACTIONS::mirrorH, orientCondition, 200 );
351 
352  selToolMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
354  selToolMenu.AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 );
356  selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, singleFieldParentCondition, 200 );
358 
359  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu3 = std::make_shared<SYMBOL_UNIT_MENU>();
360  symUnitMenu3->SetTool( m_selectionTool );
361  m_selectionTool->GetToolMenu().AddSubMenu( symUnitMenu3 );
362  selToolMenu.AddMenu( symUnitMenu3.get(), E_C::SingleMultiUnitSymbol, 1 );
363 
367 
368  selToolMenu.AddItem( EE_ACTIONS::toLabel, toLabelCondition, 200 );
369  selToolMenu.AddItem( EE_ACTIONS::toHLabel, toHLabelCondition, 200 );
370  selToolMenu.AddItem( EE_ACTIONS::toGLabel, toGLabelCondition, 200 );
371  selToolMenu.AddItem( EE_ACTIONS::toText, toTextlCondition, 200 );
372  selToolMenu.AddItem( EE_ACTIONS::cleanupSheetPins, singleSheetCondition, 250 );
373 
374  selToolMenu.AddSeparator( 300 );
375  selToolMenu.AddItem( ACTIONS::cut, E_C::IdleSelection, 300 );
376  selToolMenu.AddItem( ACTIONS::copy, E_C::IdleSelection, 300 );
377  selToolMenu.AddItem( ACTIONS::paste, E_C::Idle, 300 );
378  selToolMenu.AddItem( ACTIONS::pasteSpecial, E_C::Idle, 300 );
379  selToolMenu.AddItem( ACTIONS::doDelete, E_C::NotEmpty, 300 );
380  selToolMenu.AddItem( ACTIONS::duplicate, duplicateCondition, 300 );
381 
382  selToolMenu.AddSeparator( 400 );
383  selToolMenu.AddItem( ACTIONS::selectAll, hasElements, 400 );
384 
385 
386  return true;
387 }
388 
389 
391  SCH_TEXT_T,
392  SCH_LABEL_T,
395  SCH_FIELD_T,
396  SCH_SYMBOL_T,
398  SCH_SHEET_T,
399  SCH_BITMAP_T,
402  SCH_LINE_T,
405  EOT
406 };
407 
408 
409 int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
410 {
411  bool clockwise = ( aEvent.Matches( EE_ACTIONS::rotateCW.MakeEvent() ) );
413 
414  if( selection.GetSize() == 0 )
415  return 0;
416 
417  SCH_ITEM* head = nullptr;
418  int principalItemCount = 0; // User-selected items (as opposed to connected wires)
419  wxPoint rotPoint;
420  bool moving = false;
421  bool connections = false;
422 
423  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
424  {
425  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
426 
427  if( item->HasFlag( TEMP_SELECTED ) )
428  continue;
429 
430  principalItemCount++;
431 
432  if( !head )
433  head = item;
434  }
435 
436  if( head && head->IsMoving() )
437  moving = true;
438 
439  if( principalItemCount == 1 )
440  {
441  rotPoint = head->GetPosition();
442 
443  if( !moving )
445 
446  switch( head->Type() )
447  {
448  case SCH_SYMBOL_T:
449  {
450  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( head );
451 
452  if( clockwise )
454  else
456 
458  symbol->AutoAutoplaceFields( m_frame->GetScreen() );
459 
460  break;
461  }
462 
463  case SCH_TEXT_T:
464  case SCH_LABEL_T:
465  case SCH_GLOBAL_LABEL_T:
466  case SCH_HIER_LABEL_T:
467  {
468  SCH_TEXT* textItem = static_cast<SCH_TEXT*>( head );
469  textItem->Rotate90( clockwise );
470  break;
471  }
472 
473  case SCH_SHEET_PIN_T:
474  {
475  // Rotate pin within parent sheet
476  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( head );
477  SCH_SHEET* sheet = pin->GetParent();
478 
479  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
480  pin->Rotate( sheet->GetBoundingBox().GetCenter() );
481 
482  break;
483  }
484 
485  case SCH_LINE_T:
486  case SCH_BUS_BUS_ENTRY_T:
488  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
489  head->Rotate( rotPoint );
490 
491  break;
492 
493  case SCH_FIELD_T:
494  {
495  SCH_FIELD* field = static_cast<SCH_FIELD*>( head );
496 
497  if( field->GetTextAngle() == TEXT_ANGLE_HORIZ )
498  field->SetTextAngle( TEXT_ANGLE_VERT );
499  else
500  field->SetTextAngle( TEXT_ANGLE_HORIZ );
501 
502  // Now that we're moving a field, they're no longer autoplaced.
503  static_cast<SCH_ITEM*>( head->GetParent() )->ClearFieldsAutoplaced();
504 
505  break;
506  }
507 
508  case SCH_BITMAP_T:
509  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
510  head->Rotate( rotPoint );
511 
512  // The bitmap is cached in Opengl: clear the cache to redraw
514  break;
515 
516  case SCH_SHEET_T:
517  {
518  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( head );
519  rotPoint = m_frame->GetNearestGridPosition( sheet->GetRotationCenter() );
520 
521  // Rotate the sheet on itself. Sheets do not have an anchor point.
522  for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
523  sheet->Rotate( rotPoint );
524 
525  break;
526  }
527 
528  default:
529  break;
530  }
531 
532  connections = head->IsConnectable();
533  m_frame->UpdateItem( head );
534  }
535  else
536  {
537  rotPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() );
538  }
539 
540  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
541  {
542  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
543 
544  // We've already rotated the user selected item if there was only one. We're just
545  // here to rotate the ends of wires that were attached to it.
546  if( principalItemCount == 1 && !item->HasFlag( TEMP_SELECTED ) )
547  continue;
548 
549  if( !moving )
550  saveCopyInUndoList( item, UNDO_REDO::CHANGED, ii > 0 );
551 
552  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
553  {
554  if( item->Type() == SCH_LINE_T )
555  {
556  SCH_LINE* line = (SCH_LINE*) item;
557 
558  if( item->HasFlag( STARTPOINT ) )
559  line->RotateStart( rotPoint );
560 
561  if( item->HasFlag( ENDPOINT ) )
562  line->RotateEnd( rotPoint );
563  }
564  else if( item->Type() == SCH_SHEET_PIN_T )
565  {
566  if( item->GetParent()->IsSelected() )
567  {
568  // parent will rotate us
569  }
570  else
571  {
572  // rotate within parent
573  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
574  SCH_SHEET* sheet = pin->GetParent();
575 
576  pin->Rotate( sheet->GetBoundingBox().GetCenter() );
577  }
578  }
579  else if( item->Type() == SCH_FIELD_T )
580  {
581  if( item->GetParent()->IsSelected() )
582  {
583  // parent will rotate us
584  }
585  else
586  {
587  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
588 
589  field->Rotate( rotPoint );
590 
591  if( field->GetTextAngle() == TEXT_ANGLE_HORIZ )
592  field->SetTextAngle( TEXT_ANGLE_VERT );
593  else
594  field->SetTextAngle( TEXT_ANGLE_HORIZ );
595 
596  // Now that we're moving a field, they're no longer autoplaced.
597  static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
598  }
599  }
600  else
601  {
602  item->Rotate( rotPoint );
603  }
604  }
605 
606  connections |= item->IsConnectable();
607  m_frame->UpdateItem( item );
608  }
609 
611 
612  if( moving )
613  {
615  }
616  else
617  {
618  if( selection.IsHover() )
620 
621  if( connections )
623 
624  m_frame->OnModify();
625  }
626 
627  return 0;
628 }
629 
630 
631 int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
632 {
634 
635  if( selection.GetSize() == 0 )
636  return 0;
637 
638  wxPoint mirrorPoint;
639  bool vertical = ( aEvent.Matches( EE_ACTIONS::mirrorV.MakeEvent() ) );
640  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
641  bool connections = false;
642  bool moving = item->IsMoving();
643 
644  if( selection.GetSize() == 1 )
645  {
646  if( !moving )
648 
649  switch( item->Type() )
650  {
651  case SCH_SYMBOL_T:
652  {
653  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
654 
655  if( vertical )
656  symbol->SetOrientation( SYM_MIRROR_X );
657  else
658  symbol->SetOrientation( SYM_MIRROR_Y );
659 
661  symbol->AutoAutoplaceFields( m_frame->GetScreen() );
662 
663  break;
664  }
665 
666  case SCH_TEXT_T:
667  case SCH_LABEL_T:
668  case SCH_GLOBAL_LABEL_T:
669  case SCH_HIER_LABEL_T:
670  {
671  SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
672  textItem->MirrorSpinStyle( !vertical );
673  break;
674  }
675 
676  case SCH_SHEET_PIN_T:
677  {
678  // mirror within parent sheet
679  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
680  SCH_SHEET* sheet = pin->GetParent();
681 
682  if( vertical )
683  pin->MirrorVertically( sheet->GetBoundingBox().GetCenter().y );
684  else
685  pin->MirrorHorizontally( sheet->GetBoundingBox().GetCenter().x );
686 
687  break;
688  }
689 
690  case SCH_BUS_BUS_ENTRY_T:
692  if( vertical )
693  item->MirrorVertically( item->GetPosition().y );
694  else
695  item->MirrorHorizontally( item->GetPosition().x );
696  break;
697 
698  case SCH_FIELD_T:
699  {
700  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
701 
702  if( vertical )
704  else
706 
707  // Now that we're re-justifying a field, they're no longer autoplaced.
708  static_cast<SCH_ITEM*>( item->GetParent() )->ClearFieldsAutoplaced();
709 
710  break;
711  }
712 
713  case SCH_BITMAP_T:
714  if( vertical )
715  item->MirrorVertically( item->GetPosition().y );
716  else
717  item->MirrorHorizontally( item->GetPosition().x );
718 
719  // The bitmap is cached in Opengl: clear the cache to redraw
721  break;
722 
723  case SCH_SHEET_T:
724  // Mirror the sheet on itself. Sheets do not have a anchor point.
725  mirrorPoint = m_frame->GetNearestHalfGridPosition( item->GetBoundingBox().Centre() );
726 
727  if( vertical )
728  item->MirrorVertically( mirrorPoint.y );
729  else
730  item->MirrorHorizontally( mirrorPoint.x );
731 
732  break;
733 
734  default:
735  break;
736  }
737 
738  connections = item->IsConnectable();
739  m_frame->UpdateItem( item );
740  }
741  else if( selection.GetSize() > 1 )
742  {
743  mirrorPoint = m_frame->GetNearestHalfGridPosition( (wxPoint)selection.GetCenter() );
744 
745  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
746  {
747  item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
748 
749  if( !moving )
750  saveCopyInUndoList( item, UNDO_REDO::CHANGED, ii > 0 );
751 
752  if( item->Type() == SCH_SHEET_PIN_T )
753  {
754  if( item->GetParent()->IsSelected() )
755  {
756  // parent will mirror us
757  }
758  else
759  {
760  // mirror within parent sheet
761  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
762  SCH_SHEET* sheet = pin->GetParent();
763 
764  if( vertical )
765  pin->MirrorVertically( sheet->GetBoundingBox().GetCenter().y );
766  else
767  pin->MirrorHorizontally( sheet->GetBoundingBox().GetCenter().x );
768  }
769  }
770  else
771  {
772  if( vertical )
773  item->MirrorVertically( mirrorPoint.y );
774  else
775  item->MirrorHorizontally( mirrorPoint.x );
776  }
777 
778  connections |= item->IsConnectable();
779  m_frame->UpdateItem( item );
780  }
781  }
782 
784 
785  // Update R-Tree for modified items
786  for( EDA_ITEM* selected : selection )
787  updateItem( selected, true );
788 
789  if( item->IsMoving() )
790  {
792  }
793  else
794  {
795  if( selection.IsHover() )
797 
798  if( connections )
800 
801  m_frame->OnModify();
802  }
803 
804  return 0;
805 }
806 
807 
809 {
810  SCH_ITEM* sourceItem = m_frame->GetRepeatItem();
811 
812  if( !sourceItem )
813  return 0;
814 
816 
817  SCH_ITEM* newItem = sourceItem->Duplicate();
818  bool performDrag = false;
819 
820  // If cloning a symbol then put into 'move' mode.
821  if( newItem->Type() == SCH_SYMBOL_T )
822  {
823  wxPoint cursorPos = (wxPoint) getViewControls()->GetCursorPosition( true );
824  newItem->Move( cursorPos - newItem->GetPosition() );
825  performDrag = true;
826  }
827  else
828  {
829  if( m_isSymbolEditor )
830  {
831  auto* cfg = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
832 
833  if( dynamic_cast<SCH_TEXT*>( newItem ) )
834  {
835  SCH_TEXT* text = static_cast<SCH_TEXT*>( newItem );
836  text->IncrementLabel( cfg->m_Repeat.label_delta );
837  }
838 
839  newItem->Move( wxPoint( Mils2iu( cfg->m_Repeat.x_step ),
840  Mils2iu( cfg->m_Repeat.y_step ) ) );
841  }
842  else
843  {
844  EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
845 
846  if( dynamic_cast<SCH_TEXT*>( newItem ) )
847  {
848  SCH_TEXT* text = static_cast<SCH_TEXT*>( newItem );
849 
850  // If incrementing tries to go below zero, tell user why the value is repeated
851 
852  if( !text->IncrementLabel( cfg->m_Drawing.repeat_label_increment ) )
853  m_frame->ShowInfoBarWarning( _( "Label value cannot go below zero" ), true );
854  }
855 
856  newItem->Move( wxPoint( Mils2iu( cfg->m_Drawing.default_repeat_offset_x ),
857  Mils2iu( cfg->m_Drawing.default_repeat_offset_y ) ) );
858  }
859  }
860 
861  newItem->SetFlags( IS_NEW );
862  m_frame->AddToScreen( newItem, m_frame->GetScreen() );
864 
865  // Symbols need to be handled by the move tool. The move tool will handle schematic
866  // cleanup routines
867  if( performDrag )
869 
870  newItem->ClearFlags();
871 
872  if( !performDrag && newItem->IsConnectable() )
873  {
874  EE_SELECTION new_sel;
875  new_sel.Add( newItem );
876 
878 
881  }
882 
883  m_frame->GetCanvas()->Refresh();
884  m_frame->OnModify();
885 
886  // Save newItem at the new position.
887  m_frame->SaveCopyForRepeatItem( newItem );
888 
889  return 0;
890 }
891 
892 
894 {
895  SCH_MARKER_T,
897  SCH_LINE_T,
900  SCH_TEXT_T,
901  SCH_LABEL_T,
905  SCH_SHEET_T,
907  SCH_SYMBOL_T,
908  SCH_BITMAP_T,
909  EOT
910 };
911 
912 
914 {
915  SCH_SCREEN* screen = m_frame->GetScreen();
917  bool appendToUndo = false;
918  std::vector<wxPoint> pts;
919 
920  if( items.empty() )
921  return 0;
922 
923  // Don't leave a freed pointer in the selection
925 
926  for( EDA_ITEM* item : items )
927  item->ClearFlags( STRUCT_DELETED );
928 
929  for( EDA_ITEM* item : items )
930  {
931  SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
932 
933  if( !sch_item )
934  continue;
935 
936  if( sch_item->IsConnectable() )
937  {
938  std::vector<wxPoint> tmp_pts = sch_item->GetConnectionPoints();
939  pts.insert( pts.end(), tmp_pts.begin(), tmp_pts.end() );
940  }
941 
942  if( sch_item->Type() == SCH_JUNCTION_T )
943  {
944  sch_item->SetFlags( STRUCT_DELETED );
945  // clean up junctions at the end
946  }
947  else if( sch_item->Type() == SCH_SHEET_PIN_T )
948  {
949  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) sch_item;
950  SCH_SHEET* sheet = pin->GetParent();
951 
952  if( !alg::contains( items, sheet ) )
953  {
954  pin->SetFlags( STRUCT_DELETED );
955  saveCopyInUndoList( item, UNDO_REDO::DELETED, appendToUndo );
956  appendToUndo = true;
957 
958  updateItem( pin, false );
959 
960  sheet->RemovePin( pin );
961  }
962  }
963  else
964  {
965  sch_item->SetFlags( STRUCT_DELETED );
966  saveCopyInUndoList( item, UNDO_REDO::DELETED, appendToUndo );
967  appendToUndo = true;
968 
969  updateItem( sch_item, false );
970 
971  m_frame->RemoveFromScreen( sch_item, m_frame->GetScreen() );
972 
973  if( sch_item->Type() == SCH_SHEET_T )
975  }
976  }
977 
978  for( auto point : pts )
979  {
980  SCH_ITEM* junction = screen->GetItem( point, 0, SCH_JUNCTION_T );
981 
982  if( !junction )
983  continue;
984 
985  if( junction->HasFlag( STRUCT_DELETED ) || !screen->IsJunctionNeeded( point ) )
986  m_frame->DeleteJunction( junction, appendToUndo );
987  }
988 
990 
991  m_frame->GetCanvas()->Refresh();
992  m_frame->OnModify();
993 
994  return 0;
995 }
996 
997 
998 #define HITTEST_THRESHOLD_PIXELS 5
999 
1000 
1002 {
1003  std::string tool = aEvent.GetCommandStr().get();
1004  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1005 
1007  m_pickerItem = nullptr;
1008 
1009  // Deactivate other tools; particularly important if another PICKER is currently running
1010  Activate();
1011 
1012  picker->SetCursor( KICURSOR::REMOVE );
1013  picker->SetSnapping( false );
1014 
1015  picker->SetClickHandler(
1016  [this]( const VECTOR2D& aPosition ) -> bool
1017  {
1018  if( m_pickerItem )
1019  {
1021  selectionTool->UnbrightenItem( m_pickerItem );
1022  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
1024  m_pickerItem = nullptr;
1025  }
1026 
1027  return true;
1028  } );
1029 
1030  picker->SetMotionHandler(
1031  [this]( const VECTOR2D& aPos )
1032  {
1033  EE_COLLECTOR collector;
1034  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
1035  collector.Collect( m_frame->GetScreen(), deletableItems, (wxPoint) aPos );
1036 
1038  selectionTool->GuessSelectionCandidates( collector, aPos );
1039 
1040  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
1041 
1042  if( m_pickerItem != item )
1043  {
1044  if( m_pickerItem )
1045  selectionTool->UnbrightenItem( m_pickerItem );
1046 
1047  m_pickerItem = item;
1048 
1049  if( m_pickerItem )
1050  selectionTool->BrightenItem( m_pickerItem );
1051  }
1052  } );
1053 
1054  picker->SetFinalizeHandler(
1055  [this]( const int& aFinalState )
1056  {
1057  if( m_pickerItem )
1059 
1060  // Wake the selection tool after exiting to ensure the cursor gets updated
1062  } );
1063 
1064  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1065 
1066  return 0;
1067 }
1068 
1069 
1071 {
1072  // Save old symbol in undo list if not already in edit, or moving.
1073  if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
1075 
1076  KICAD_T parentType = aField->GetParent() ? aField->GetParent()->Type() : SCHEMATIC_T;
1077  wxString caption;
1078 
1079  // Use title caps for mandatory fields. "Edit Sheet name Field" looks dorky.
1080  if( parentType == SCH_SYMBOL_T && aField->GetId() < MANDATORY_FIELDS )
1081  caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
1082  else if( parentType == SCH_SHEET_T && aField->GetId() < SHEET_MANDATORY_FIELDS )
1083  caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
1084  else
1085  caption.Printf( _( "Edit '%s' Field" ), aField->GetName() );
1086 
1087  DIALOG_SCH_EDIT_ONE_FIELD dlg( m_frame, caption, aField );
1088 
1089  // The footprint field dialog can invoke a KIWAY_PLAYER so we must use a quasi-modal
1090  if( dlg.ShowQuasiModal() != wxID_OK )
1091  return;
1092 
1093  dlg.UpdateField( aField, &m_frame->GetCurrentSheet() );
1094 
1095  if( m_frame->eeconfig()->m_AutoplaceFields.enable || parentType == SCH_SHEET_T )
1096  static_cast<SCH_ITEM*>( aField->GetParent() )->AutoAutoplaceFields( m_frame->GetScreen() );
1097 
1098  m_frame->UpdateItem( aField );
1099  m_frame->OnModify();
1100 
1101  // This must go after OnModify() so that the connectivity graph will have been updated.
1103 }
1104 
1105 
1107 {
1108  static KICAD_T Nothing[] = { EOT };
1109  static KICAD_T CmpOrReference[] = { SCH_FIELD_LOCATE_REFERENCE_T, SCH_SYMBOL_T, EOT };
1110  static KICAD_T CmpOrValue[] = { SCH_FIELD_LOCATE_VALUE_T, SCH_SYMBOL_T, EOT };
1111  static KICAD_T CmpOrFootprint[] = { SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_SYMBOL_T, EOT };
1112 
1113  KICAD_T* filter = Nothing;
1114 
1115  if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1116  filter = CmpOrReference;
1117  else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1118  filter = CmpOrValue;
1119  else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1120  filter = CmpOrFootprint;
1121 
1123 
1124  if( selection.Size() != 1 )
1125  return 0;
1126 
1127  SCH_ITEM* item = (SCH_ITEM*) selection.Front();
1128 
1129  if( item->Type() == SCH_SYMBOL_T )
1130  {
1131  SCH_SYMBOL* symbol = (SCH_SYMBOL*) item;
1132 
1133  if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1134  editFieldText( symbol->GetField( REFERENCE_FIELD ) );
1135  else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1136  editFieldText( symbol->GetField( VALUE_FIELD ) );
1137  else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1138  editFieldText( symbol->GetField( FOOTPRINT_FIELD ) );
1139  }
1140  else if( item->Type() == SCH_FIELD_T )
1141  {
1142  editFieldText( (SCH_FIELD*) item );
1143  }
1144 
1145  if( selection.IsHover() )
1147 
1148  return 0;
1149 }
1150 
1151 
1153 {
1155 
1156  if( selection.Empty() )
1157  return 0;
1158 
1159  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
1160 
1161  if( !item->IsNew() )
1163 
1164  item->AutoplaceFields( m_frame->GetScreen(), /* aManual */ true );
1165 
1166  updateItem( item, true );
1167  m_frame->OnModify();
1168 
1169  if( selection.IsHover() )
1171 
1172  return 0;
1173 }
1174 
1175 
1177 {
1178  SCH_SYMBOL* selectedSymbol = nullptr;
1180 
1181  if( !selection.Empty() )
1182  selectedSymbol = dynamic_cast<SCH_SYMBOL*>( selection.Front() );
1183 
1185 
1186  if( aEvent.IsAction( &EE_ACTIONS::changeSymbol )
1187  || aEvent.IsAction( &EE_ACTIONS::changeSymbols ) )
1188  {
1190  }
1191 
1192  DIALOG_CHANGE_SYMBOLS dlg( m_frame, selectedSymbol, mode );
1193 
1194  dlg.ShowQuasiModal();
1195 
1196  return 0;
1197 }
1198 
1199 
1201 {
1203 
1204  if( selection.Empty() )
1205  return 0;
1206 
1207  SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front();
1208 
1210  && symbol->GetConvert() == LIB_ITEM::LIB_CONVERT::BASE )
1211  {
1212  return 0;
1213  }
1214 
1216  && symbol->GetConvert() != LIB_ITEM::LIB_CONVERT::DEMORGAN )
1217  {
1218  return 0;
1219  }
1220 
1221  if( !symbol->IsNew() )
1223 
1224  m_frame->ConvertPart( symbol );
1225 
1226  if( symbol->IsNew() )
1228 
1229  if( selection.IsHover() )
1231 
1232  return 0;
1233 }
1234 
1235 
1237 {
1239 
1240  if( selection.Empty() )
1241  {
1243  {
1245  VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
1246 
1247  if( ds && ds->HitTestDrawingSheetItems( getView(), (wxPoint) cursorPos ) )
1249  }
1250 
1251  return 0;
1252  }
1253 
1254  SCH_ITEM* item = (SCH_ITEM*) selection.Front();
1255 
1256  switch( item->Type() )
1257  {
1258  case SCH_LINE_T:
1259  case SCH_BUS_WIRE_ENTRY_T:
1260  if( !selection.AllItemsHaveLineStroke() )
1261  return 0;
1262 
1263  break;
1264 
1265  case SCH_JUNCTION_T:
1266  if( !selection.AreAllItemsIdentical() )
1267  return 0;
1268 
1269  break;
1270 
1271  default:
1272  if( selection.Size() > 1 )
1273  return 0;
1274 
1275  break;
1276  }
1277 
1278  switch( item->Type() )
1279  {
1280  case SCH_SYMBOL_T:
1281  {
1282  SCH_SYMBOL* symbol = (SCH_SYMBOL*) item;
1283  DIALOG_SYMBOL_PROPERTIES symbolPropsDialog( m_frame, symbol );
1284 
1285  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
1286  // frame. Therefore this dialog as a modal frame parent, MUST be run under
1287  // quasimodal mode for the quasimodal frame support to work. So don't use
1288  // the QUASIMODAL macros here.
1289  int retval = symbolPropsDialog.ShowQuasiModal();
1290 
1291  if( retval == SYMBOL_PROPS_EDIT_OK )
1292  {
1294  symbol->AutoAutoplaceFields( m_frame->GetScreen() );
1295 
1297  m_frame->OnModify();
1298  }
1299  else if( retval == SYMBOL_PROPS_EDIT_SCHEMATIC_SYMBOL )
1300  {
1302  true );
1303 
1304  editor->LoadSymbolFromSchematic( symbol );
1305 
1306  editor->Show( true );
1307  editor->Raise();
1308  }
1309  else if( retval == SYMBOL_PROPS_EDIT_LIBRARY_SYMBOL )
1310  {
1312  true );
1313 
1314  editor->LoadSymbol( symbol->GetLibId(), symbol->GetUnit(), symbol->GetConvert() );
1315 
1316  editor->Show( true );
1317  editor->Raise();
1318  }
1319  else if( retval == SYMBOL_PROPS_WANT_UPDATE_SYMBOL )
1320  {
1322  dlg.ShowQuasiModal();
1323  }
1324  else if( retval == SYMBOL_PROPS_WANT_EXCHANGE_SYMBOL )
1325  {
1327  dlg.ShowQuasiModal();
1328  }
1329  }
1330  break;
1331 
1332  case SCH_SHEET_T:
1333  {
1334  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1335  bool doClearAnnotation;
1336  bool doRefresh = false;
1337 
1338  // Keep track of existing sheet paths. EditSheet() can modify this list.
1339  // Note that we use the validity checking/repairing version here just to make sure
1340  // we've got a valid hierarchy to begin with.
1341  SCH_SHEET_LIST initial_sheetpathList( &m_frame->Schematic().Root(), true );
1342 
1343  doRefresh = m_frame->EditSheetProperties( sheet, &m_frame->GetCurrentSheet(),
1344  &doClearAnnotation );
1345 
1346  // If the sheet file is changed and new sheet contents are loaded then we have to
1347  // clear the annotations on the new content (as it may have been set from some other
1348  // sheet path reference)
1349  if( doClearAnnotation )
1350  {
1351  SCH_SCREENS screensList( &m_frame->Schematic().Root() );
1352  // We clear annotation of new sheet paths here:
1353  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1354  // Clear annotation of g_CurrentSheet itself, because its sheetpath is not a new
1355  // path, but symbols managed by its sheet path must have their annotation cleared
1356  // because they are new:
1358  }
1359 
1360  if( doRefresh )
1361  {
1363  m_frame->GetCanvas()->Refresh();
1365  }
1366 
1367  break;
1368  }
1369 
1370  case SCH_SHEET_PIN_T:
1371  {
1372  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) item;
1374 
1375  // QuasiModal required for help dialog
1376  if( dlg.ShowQuasiModal() == wxID_OK )
1377  {
1379  m_frame->OnModify();
1380  }
1381  }
1382  break;
1383 
1384  case SCH_TEXT_T:
1385  case SCH_LABEL_T:
1386  case SCH_GLOBAL_LABEL_T:
1387  case SCH_HIER_LABEL_T:
1388  {
1389  DIALOG_LABEL_EDITOR dlg( m_frame, (SCH_TEXT*) item );
1390 
1391  // Must be quasi modal for syntax help
1392  if( dlg.ShowQuasiModal() == wxID_OK )
1393  {
1395  m_frame->OnModify();
1396  }
1397  }
1398  break;
1399 
1400  case SCH_FIELD_T:
1401  editFieldText( (SCH_FIELD*) item );
1402  break;
1403 
1404  case SCH_BITMAP_T:
1405  {
1406  SCH_BITMAP* bitmap = (SCH_BITMAP*) item;
1407  DIALOG_IMAGE_EDITOR dlg( m_frame, bitmap->GetImage() );
1408 
1409  if( dlg.ShowModal() == wxID_OK )
1410  {
1411  // save old image in undo list if not already in edit
1412  if( bitmap->GetEditFlags() == 0 )
1414 
1415  dlg.TransferToImage( bitmap->GetImage() );
1416 
1417  // The bitmap is cached in Opengl: clear the cache in case it has become invalid
1418  getView()->RecacheAllItems();
1420  m_frame->OnModify();
1421  }
1422  }
1423  break;
1424 
1425  case SCH_LINE_T:
1426  case SCH_BUS_WIRE_ENTRY_T:
1427  {
1428  std::deque<SCH_ITEM*> strokeItems;
1429 
1430  for( auto selItem : selection.Items() )
1431  {
1432  SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( selItem );
1433 
1434  if( schItem && schItem->HasLineStroke() )
1435  strokeItems.push_back( schItem );
1436  else
1437  return 0;
1438  }
1439 
1440  DIALOG_LINE_WIRE_BUS_PROPERTIES dlg( m_frame, strokeItems );
1441 
1442  if( dlg.ShowModal() == wxID_OK )
1443  {
1445  m_frame->OnModify();
1446  }
1447  }
1448  break;
1449 
1450  case SCH_JUNCTION_T:
1451  {
1452  std::deque<SCH_JUNCTION*> junctions;
1453 
1454  for( auto selItem : selection.Items() )
1455  {
1456  SCH_JUNCTION* junction = dynamic_cast<SCH_JUNCTION*>( selItem );
1457 
1458  wxCHECK( junction, 0 );
1459 
1460  junctions.push_back( junction );
1461  }
1462 
1463  DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
1464 
1465  if( dlg.ShowModal() == wxID_OK )
1466  {
1468  m_frame->OnModify();
1469  }
1470  }
1471  break;
1472 
1473  case SCH_MARKER_T: // These items have no properties to edit
1474  case SCH_NO_CONNECT_T:
1475  break;
1476 
1477  default: // Unexpected item
1478  wxFAIL_MSG( wxString( "Cannot edit schematic item type " ) + item->GetClass() );
1479  }
1480 
1481  updateItem( item, true );
1482 
1483  if( selection.IsHover() )
1485 
1486  return 0;
1487 }
1488 
1489 
1491 {
1492  KICAD_T convertTo = aEvent.Parameter<KICAD_T>();
1494  EE_SELECTION& selection = m_selectionTool->RequestSelection( allTextTypes );
1495 
1496  for( unsigned int i = 0; i < selection.GetSize(); ++i )
1497  {
1498  SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( selection.GetItem( i ) );
1499 
1500  if( text && text->Type() != convertTo )
1501  {
1502  bool selected = text->IsSelected();
1503  SCH_TEXT* newtext = nullptr;
1504  const wxPoint& position = text->GetPosition();
1505  LABEL_SPIN_STYLE orientation = text->GetLabelSpinStyle();
1506  wxString txt = UnescapeString( text->GetText() );
1507 
1508  // There can be characters in a SCH_TEXT object that can break labels so we have to
1509  // fix them here.
1510  if( text->Type() == SCH_TEXT_T )
1511  {
1512  txt.Replace( "\n", "_" );
1513  txt.Replace( "\r", "_" );
1514  txt.Replace( "\t", "_" );
1515  txt.Replace( " ", "_" );
1516  }
1517 
1518  // label strings are "escaped" i.e. a '/' is replaced by "{slash}"
1519  if( convertTo != SCH_TEXT_T )
1520  txt = EscapeString( txt, CTX_NETNAME );
1521 
1522  switch( convertTo )
1523  {
1524  case SCH_LABEL_T: newtext = new SCH_LABEL( position, txt ); break;
1525  case SCH_GLOBAL_LABEL_T: newtext = new SCH_GLOBALLABEL( position, txt ); break;
1526  case SCH_HIER_LABEL_T: newtext = new SCH_HIERLABEL( position, txt ); break;
1527  case SCH_TEXT_T: newtext = new SCH_TEXT( position, txt ); break;
1528 
1529  default:
1530  wxFAIL_MSG( wxString::Format( "Invalid text type: %d.", convertTo ) );
1531  return 0;
1532  }
1533 
1534  // Copy the old text item settings to the new one. Justifications are not copied
1535  // because they are not used in labels. Justifications will be set to default value
1536  // in the new text item type.
1537  //
1538  newtext->SetFlags( text->GetEditFlags() );
1539  newtext->SetShape( text->GetShape() );
1540  newtext->SetLabelSpinStyle( orientation );
1541  newtext->SetTextSize( text->GetTextSize() );
1542  newtext->SetTextThickness( text->GetTextThickness() );
1543  newtext->SetItalic( text->IsItalic() );
1544  newtext->SetBold( text->IsBold() );
1545  newtext->SetIsDangling( text->IsDangling() );
1546 
1547  if( selected )
1549 
1550  if( !text->IsNew() )
1551  {
1553  saveCopyInUndoList( newtext, UNDO_REDO::NEWITEM, true );
1554 
1556  m_frame->AddToScreen( newtext, m_frame->GetScreen() );
1557 
1558  if( convertTo == SCH_GLOBAL_LABEL_T )
1559  static_cast<SCH_GLOBALLABEL*>( newtext )->UpdateIntersheetRefProps();
1560  }
1561 
1562  if( selected )
1563  m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, newtext );
1564 
1565  // Otherwise, pointer is owned by the undo stack
1566  if( text->IsNew() )
1567  delete text;
1568 
1569  if( convertTo == SCH_TEXT_T )
1570  {
1571  if( newtext->IsDangling() )
1572  {
1573  newtext->SetIsDangling( false );
1574  getView()->Update( newtext, KIGFX::REPAINT );
1575  }
1576  }
1577  else
1579 
1580  m_frame->OnModify();
1581  }
1582  }
1583 
1584  if( selection.IsHover() )
1586 
1587  return 0;
1588 }
1589 
1590 
1592 {
1593  wxPoint cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
1595 
1596  std::vector<SCH_LINE*> lines;
1597 
1598  for( auto& item : selection )
1599  {
1600  if( SCH_LINE* line = dyn_cast<SCH_LINE*>( item ) )
1601  {
1602  if( !line->IsEndPoint( cursorPos ) )
1603  lines.push_back( line );
1604  }
1605  }
1606 
1608  m_frame->StartNewUndo();
1609 
1610  for( SCH_LINE* line : lines )
1611  m_frame->BreakSegment( line, cursorPos );
1612 
1613  if( !lines.empty() )
1614  {
1615  if( m_frame->GetScreen()->IsJunctionNeeded( cursorPos, true ) )
1616  m_frame->AddJunction( m_frame->GetScreen(), cursorPos, true, false );
1617 
1619 
1620  m_frame->OnModify();
1621  m_frame->GetCanvas()->Refresh();
1622 
1624  }
1625 
1626  return 0;
1627 }
1628 
1629 
1631 {
1633  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1634 
1635  if( !sheet )
1636  return 0;
1637 
1638  if( !sheet->HasUndefinedPins() )
1639  {
1640  DisplayInfoMessage( m_frame, _( "There are no unreferenced pins in this sheet to remove." ) );
1641  return 0;
1642  }
1643 
1644  if( !IsOK( m_frame, _( "Do you wish to delete the unreferenced pins from this sheet?" ) ) )
1645  return 0;
1646 
1648 
1649  sheet->CleanupSheet();
1650 
1651  updateItem( sheet, true );
1652  m_frame->OnModify();
1653 
1654  if( selection.IsHover() )
1656 
1657  return 0;
1658 }
1659 
1660 
1662 {
1664 
1665  if( selection.GetSize() > 1 )
1666  return 0;
1667 
1668  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1669 
1670  SCH_SHEET_PATH instance = m_frame->GetCurrentSheet();
1671 
1672  SCH_SCREEN* screen;
1673 
1674  if( sheet )
1675  {
1676  // When changing the page number of a selected sheet, the current screen owns the sheet.
1677  screen = m_frame->GetScreen();
1678 
1679  instance.push_back( sheet );
1680  }
1681  else
1682  {
1683  SCH_SHEET_PATH prevInstance = instance;
1684 
1685  // When change the page number in the screen, the previous screen owns the sheet.
1686  if( prevInstance.size() )
1687  {
1688  prevInstance.pop_back();
1689  screen = prevInstance.LastScreen();
1690  }
1691  else
1692  {
1693  // The root sheet and root screen are effectively the same thing.
1694  screen = m_frame->GetScreen();
1695  }
1696 
1697  sheet = m_frame->GetCurrentSheet().Last();
1698  }
1699 
1700  wxString msg;
1701  wxString sheetPath = instance.PathHumanReadable( false );
1702  wxString pageNumber = instance.GetPageNumber();
1703 
1704  msg.Printf( _( "Enter page number for sheet path%s" ),
1705  ( sheetPath.Length() > 20 ) ? "\n" + sheetPath : " " + sheetPath );
1706 
1707  wxTextEntryDialog dlg( m_frame, msg, _( "Edit Sheet Page Number" ), pageNumber );
1708 
1709  dlg.SetTextValidator( wxFILTER_ALPHANUMERIC ); // No white space.
1710 
1711  if( dlg.ShowModal() == wxID_CANCEL || dlg.GetValue() == instance.GetPageNumber() )
1712  return 0;
1713 
1714  m_frame->SaveCopyInUndoList( screen, sheet, UNDO_REDO::CHANGED, false );
1715 
1716  instance.SetPageNumber( dlg.GetValue() );
1717 
1718  if( instance == m_frame->GetCurrentSheet() )
1719  {
1720  m_frame->GetScreen()->SetPageNumber( dlg.GetValue() );
1722  }
1723 
1724  m_frame->OnModify();
1725 
1726  return 0;
1727 }
1728 
1729 
1731 {
1735  Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorV.MakeEvent() );
1736  Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorH.MakeEvent() );
1737  Go( &SCH_EDIT_TOOL::DoDelete, ACTIONS::doDelete.MakeEvent() );
1739 
1756 
1759 
1763 }
Field Reference of part, i.e. "IC21".
static TOOL_ACTION editPageNumber
Definition: ee_actions.h:151
bool IsDangling() const override
Definition: sch_text.h:228
bool empty() const
Definition: sch_rtree.h:163
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)
Add a submenu to the menu.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
static TOOL_ACTION properties
Definition: ee_actions.h:117
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
bool IsCurrentTool(const TOOL_ACTION &aAction) const
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:163
#define HITTEST_THRESHOLD_PIXELS
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
int m_Threshold
Definition: collector.h:248
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
virtual bool IsConnectable() const
Definition: sch_item.h:362
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.cpp:70
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:61
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:199
bool IsHover() const
Definition: selection.h:73
#define STARTPOINT
When a line is selected, these flags indicate which.
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
std::deque< EDA_ITEM * > & Items()
Definition: selection.h:149
static TOOL_ACTION toggleDeMorgan
Definition: ee_actions.h:122
virtual std::vector< wxPoint > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:377
static TOOL_ACTION breakBus
Definition: ee_actions.h:131
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
static TOOL_ACTION pageSettings
Definition: actions.h:56
static SELECTION_CONDITION SingleSymbol
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
bool IsSelected() const
Definition: eda_item.h:123
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:666
#define IS_NEW
New item, just created.
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:47
void StartNewUndo()
Create a new, blank stack for future Undo commands to be pushed to.
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:48
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:72
void ConvertPart(SCH_SYMBOL *aSymbol)
Definition: getpart.cpp:237
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:31
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.).
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:73
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
void Collect(SCH_SCREEN *aScreen, const KICAD_T aFilterList[], const wxPoint &aPos, int aUnit=0, int aConvert=0)
Scan a EDA_ITEM using this class's Inspector method which does the collection.
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
Definition: sch_item.h:445
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create a functor that tests if the selected items are only of given types.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
wxString PathHumanReadable(bool aUseShortRootName=true) const
Return the sheet path in a human readable form made from the sheet names.
bool IsMoving() const
Definition: eda_item.h:120
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
int Rotate(const TOOL_EVENT &aEvent)
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:84
void SetItalic(bool isItalic)
Definition: eda_text.h:179
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
static TOOL_ACTION changeSymbol
Definition: ee_actions.h:145
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1380
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:156
int EditPageNumber(const TOOL_EVENT &aEvent)
int BreakWire(const TOOL_EVENT &aEvent)
virtual void MirrorVertically(int aCenter)=0
Mirror item vertically about aCenter.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
TOOL_MENU & GetToolMenu()
double GetTextAngle() const
Definition: eda_text.h:174
int GetId() const
Definition: sch_field.h:113
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void UpdateField(SCH_FIELD *aField, SCH_SHEET_PATH *aSheetPath)
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,...
bool HasUndefinedPins() const
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:373
static TOOL_ACTION toText
Definition: ee_actions.h:129
static const KICAD_T FieldOwners[]
Definition: ee_collectors.h:48
static TOOL_ACTION autoplaceFields
Definition: ee_actions.h:121
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:382
wxPoint GetNearestHalfGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize / 2 location to aPosition.
Schematic editor (Eeschema) main window.
bool HitTestDrawingSheetItems(KIGFX::VIEW *aView, const wxPoint &aPosition)
int Properties(const TOOL_EVENT &aEvent)
bool AreAllItemsIdentical() const
Checks if all items in the selection are the same KICAD_T type.
Definition: selection.cpp:133
void OnPageSettingsChange() override
Called when modifying the page settings.
static TOOL_ACTION updateSymbols
Definition: ee_actions.h:144
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:237
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:102
#define ENDPOINT
ends. (Used to support dragging.)
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:445
virtual wxPoint GetPosition() const
Definition: eda_item.h:252
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:46
static TOOL_ACTION mirrorH
Definition: ee_actions.h:116
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
void SetIsDangling(bool aIsDangling)
Definition: sch_text.h:229
void update() override
Update menu state stub.
virtual void Rotate(const wxPoint &aCenter)=0
Rotate the item around aCenter 90 degrees in the clockwise direction.
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:124
static bool IdleSelection(const SELECTION &aSelection)
Test if all selected items are not being edited.
Dialog to update or change schematic library symbols.
static bool NotEmpty(const SELECTION &aSelection)
Test 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))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
void ShowInfoBarWarning(const wxString &aWarningMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and a warning icon on the left ...
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:204
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
static TOOL_ACTION breakWire
Definition: ee_actions.h:130
void Rotate(const wxPoint &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_sheet.cpp:734
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:164
static TOOL_ACTION mirrorV
Definition: ee_actions.h:115
static TOOL_ACTION rotateCW
Definition: ee_actions.h:113
bool IsNew() const
Definition: eda_item.h:119
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
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:57
static TOOL_ACTION pickerTool
Definition: actions.h:155
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:66
EE_SELECTION & GetSelection()
Return the set of currently selected items.
EESCHEMA_SETTINGS * eeconfig() const
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
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:85
static SELECTION_CONDITION SingleDeMorganSymbol
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
static TOOL_ACTION copy
Definition: actions.h:67
void editFieldText(SCH_FIELD *aField)
Set up handlers for various events.
static TOOL_ACTION cleanupSheetPins
Definition: ee_actions.h:187
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:114
void BrightenItem(EDA_ITEM *aItem)
int GlobalEdit(const TOOL_EVENT &aEvent)
Delete the selected items, or the item under the cursor.
static TOOL_ACTION editFootprint
Definition: ee_actions.h:120
AUTOPLACE_FIELDS m_AutoplaceFields
Item needs to be redrawn.
Definition: view_item.h:57
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:198
Field Value of part, i.e. "3.3K".
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:56
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_sheet.cpp:590
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:78
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
BITMAP_BASE * GetImage() const
Definition: sch_bitmap.h:54
size_t size() const
Forwarded method from std::vector.
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aType, bool aAppend=false)
Definition: ee_tool_base.h:134
wxString TitleCaps(const wxString &aString)
Capitalize the first letter in each word.
Definition: string.cpp:290
int ShowQuasiModal()
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:427
wxString GetPageNumber() const
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:451
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:202
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:87
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Generic, UI-independent tool event.
Definition: tool_event.h:152
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
static TOOL_ACTION updateSymbol
Definition: ee_actions.h:146
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:82
virtual bool HasLineStroke() const
Check if this schematic item has line stoke properties.
Definition: sch_item.h:462
int AutoplaceFields(const TOOL_EVENT &aEvent)
ACTION_MENU * create() const override
< Return an instance of this class. It has to be overridden in inheriting classes.
static TOOL_ACTION repeatDrawItem
Definition: ee_actions.h:112
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:329
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:108
static TOOL_ACTION cut
Definition: actions.h:66
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
EDA_ITEM * GetParent() const
Definition: eda_item.h:115
const KICAD_T rotatableItems[]
#define STRUCT_DELETED
flag indication structures to be erased
#define _(s)
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:154
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:177
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:43
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:357
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
bool DisableGridSnapping() const
Definition: tool_event.h:336
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:158
bool Init() override
Init() is called once upon a registration of the tool.
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:72
int CleanupSheetPins(const TOOL_EVENT &aEvent)
static SELECTION_CONDITION SingleMultiUnitSymbol
virtual void MirrorHorizontally(int aCenter)=0
Mirror item horizontally about aCenter.
static TOOL_ACTION editTextAndGraphics
Definition: ee_actions.h:188
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:472
int DeleteItemCursor(const TOOL_EVENT &aEvent)
void UnbrightenItem(EDA_ITEM *aItem)
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:123
Handle editing a single symbol field in the schematic editor.
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:40
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:98
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
void Rotate(const wxPoint &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_field.cpp:467
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:62
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:103
void RemovePin(const SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:311
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
bool AllItemsHaveLineStroke() const
Checks if all items in the selection support line strokes.
int Mirror(const TOOL_EVENT &aEvent)
virtual void Rotate90(bool aClockwise)
Definition: sch_text.cpp:300
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
static TOOL_ACTION pasteSpecial
Definition: actions.h:69
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:68
EDA_ITEM * m_pickerItem
Definition: sch_edit_tool.h:87
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:87
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:272
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:71
int RepeatDrawItem(const TOOL_EVENT &aEvent)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
static TOOL_ACTION placeLabel
Definition: ee_actions.h:82
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:455
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
static TOOL_ACTION editValue
Definition: ee_actions.h:119
static KICAD_T deletableItems[]
bool BreakSegment(SCH_LINE *aSegment, const wxPoint &aPoint, SCH_LINE **aNewSegment=nullptr, SCH_SCREEN *aScreen=nullptr)
Break a single segment into two at the specified point.
SCH_SHEET & Root() const
Definition: schematic.h:92
SCH_ITEM * GetRepeatItem() const
Return the item which is to be repeated with the insert key.
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:87
see class PGM_BASE
Schematic symbol object.
Definition: sch_symbol.h:78
int AddItemToSel(const TOOL_EVENT &aEvent)
SCH_SCREEN * LastScreen()
#define TEMP_SELECTED
flag indicating that the structure has already selected
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
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:52
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:201
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
TOOL_MANAGER * getToolManager() const
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:222
static TOOL_ACTION drag
Definition: ee_actions.h:111
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
Definition: string.cpp:141
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)
Store a submenu of this menu model.
Definition: tool_menu.cpp:52
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
Definition: sch_field.cpp:545
EE_RTREE & Items()
Definition: sch_screen.h:102
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
int EditField(const TOOL_EVENT &aEvent)
void Clear()
Remove all the entries from the menu (as well as its title).
int Size() const
Returns the number of selected parts.
Definition: selection.h:103
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:73
static TOOL_ACTION changeSymbols
Definition: ee_actions.h:143
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false) const
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:390
wxString GetClass() const override
Return the class name.
Definition: sch_field.h:64
wxPoint Centre() const
Definition: eda_rect.h:55
int ChangeSymbols(const TOOL_EVENT &aEvent)
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:458
void Activate()
Run the tool.
void RotateEnd(const wxPoint &aCenter)
Definition: sch_line.cpp:408
wxPoint GetRotationCenter() const
Rotating around the boundingBox's center can cause walking when the sheetname or filename is longer t...
Definition: sch_sheet.cpp:601
static SELECTION_CONDITION SingleSymbolOrPower
SCH_SHEET_PATH & GetCurrentSheet() const
static TOOL_ACTION deleteTool
Definition: actions.h:73
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the symbols in aSheetPath on the screen.
Definition: sch_screen.cpp:916
static const KICAD_T SymbolsOnly[]
Definition: ee_collectors.h:45
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:158
static TOOL_ACTION move
Definition: ee_actions.h:110
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:49
static TOOL_ACTION toLabel
Definition: ee_actions.h:126
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:159
void SetSnapping(bool aSnap)
Definition: picker_tool.h:64
virtual void MirrorSpinStyle(bool aLeftRight)
Definition: sch_text.cpp:309
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition: sch_view.h:97
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:167
static TOOL_ACTION toHLabel
Definition: ee_actions.h:127
virtual const EDA_RECT GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:75
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
static TOOL_ACTION editReference
Definition: ee_actions.h:118
void ClearAnnotationOfNewSheetPaths(SCH_SHEET_LIST &aInitialSheetPathList)
Clear the annotation for the symbols inside new sheetpaths when a complex hierarchy is modified and n...
int GetUnit() const
Definition: sch_symbol.h:195
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:318
void RotateStart(const wxPoint &aCenter)
Definition: sch_line.cpp:402
const wxPoint GetCenter() const
Definition: eda_rect.h:104
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:83
int DoDelete(const TOOL_EVENT &aEvent)
Run the deletion tool.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:275
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
void SetBold(bool aBold)
Definition: eda_text.h:182
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
int GetConvert() const
Definition: sch_symbol.h:223
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
static TOOL_ACTION selectAll
Definition: actions.h:70
static TOOL_ACTION toGLabel
Definition: ee_actions.h:128
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:291
int ConvertDeMorgan(const TOOL_EVENT &aEvent)
static TOOL_ACTION paste
Definition: actions.h:68
static const KICAD_T EditableItems[]
Definition: ee_collectors.h:43
static TOOL_ACTION duplicate
Definition: actions.h:71
int ChangeTextType(const TOOL_EVENT &aEvent)
Change a text type to another one.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:551
static TOOL_ACTION refreshPreview
Definition: actions.h:106
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:144
Dialog used to edit SCH_SYMBOL objects in a schematic.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1503
static const KICAD_T WiresOnly[]
Definition: ee_collectors.h:47
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:147
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:404
Field Name Module PCB, i.e. "16DIP300".
The symbol library editor main window.
virtual void Move(const wxPoint &aMoveVector)=0
Move the item by aMoveVector to a new position.