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 <base_struct.h>
36 #include <reporter.h>
37 #include <sch_item.h>
38 #include <sch_component.h>
39 #include <sch_sheet.h>
40 #include <sch_text.h>
41 #include <sch_bitmap.h>
42 #include <sch_view.h>
43 #include <sch_line.h>
44 #include <sch_bus_entry.h>
45 #include <sch_junction.h>
46 #include <sch_edit_frame.h>
47 #include <schematic.h>
48 #include <ws_proxy_view_item.h>
49 #include <eeschema_id.h>
50 #include <status_popup.h>
51 #include <wx/gdicmn.h>
52 #include <invoke_sch_dialog.h>
60 #include "sch_drawing_tools.h"
61 #include <math/util.h> // for KiROUND
62 #include <pgm_base.h>
64 #include <libedit_settings.h>
66 
68 {
69 public:
71  ACTION_MENU( true )
72  {
74  SetTitle( _( "Symbol Unit" ) );
75  }
76 
77 protected:
78  ACTION_MENU* create() const override
79  {
80  return new SYMBOL_UNIT_MENU();
81  }
82 
83 private:
84  void update() override
85  {
87  EE_SELECTION& selection = selTool->GetSelection();
88  SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
89 
90  Clear();
91 
92  if( !component )
93  {
94  Append( ID_POPUP_SCH_UNFOLD_BUS, _( "no symbol selected" ), wxEmptyString );
95  Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
96  return;
97  }
98 
99  int unit = component->GetUnit();
100 
101  if( !component->GetPartRef() || component->GetPartRef()->GetUnitCount() < 2 )
102  {
103  Append( ID_POPUP_SCH_UNFOLD_BUS, _( "symbol is not multi-unit" ), wxEmptyString );
104  Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
105  return;
106  }
107 
108  for( int ii = 0; ii < component->GetPartRef()->GetUnitCount(); ii++ )
109  {
110  wxString num_unit;
111  num_unit.Printf( _( "Unit %s" ), LIB_PART::SubReference( ii + 1, false ) );
112 
113  wxMenuItem * item = Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, num_unit, wxEmptyString,
114  wxITEM_CHECK );
115  if( unit == ii + 1 )
116  item->Check(true);
117 
118  // The ID max for these submenus is ID_POPUP_SCH_SELECT_UNIT_CMP_MAX
119  // See eeschema_id to modify this value.
121  break; // We have used all IDs for these submenus
122  }
123  }
124 };
125 
126 
128  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveEdit" )
129 {
130  m_pickerItem = nullptr;
131 }
132 
133 
135 
137 {
139 
142 
143  wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
144 
145  auto hasElements =
146  [ this ] ( const SELECTION& aSel )
147  {
148  return !m_frame->GetScreen()->Items().empty();
149  };
150 
151  auto sheetTool =
152  [ this ] ( const SELECTION& aSel )
153  {
155  };
156 
157  auto anyTextTool =
158  [ this ] ( const SELECTION& aSel )
159  {
164  };
165 
166  auto duplicateCondition =
167  [] ( const SELECTION& aSel )
168  {
170  return false;
171 
172  return true;
173  };
174 
175  auto orientCondition =
176  [] ( const SELECTION& aSel )
177  {
178  if( aSel.Empty() )
179  return false;
180 
182  return false;
183 
184  SCH_ITEM* item = (SCH_ITEM*) aSel.Front();
185 
186  if( aSel.GetSize() > 1 )
187  return true;
188 
189  switch( item->Type() )
190  {
191  case SCH_MARKER_T:
192  case SCH_JUNCTION_T:
193  case SCH_NO_CONNECT_T:
194  case SCH_LINE_T:
195  case SCH_PIN_T:
196  return false;
197  default:
198  return true;
199  }
200  };
201 
202  auto propertiesCondition =
203  []( const SELECTION& aSel )
204  {
205  if( aSel.GetSize() == 0 )
206  return true; // Show worksheet properties
207 
208  SCH_ITEM* firstItem = dynamic_cast<SCH_ITEM*>( aSel.Front() );
209 
210  wxCHECK( firstItem, false );
211 
212  const EE_SELECTION* eeSelection = dynamic_cast<const EE_SELECTION*>( &aSel );
213 
214  wxCHECK( eeSelection, false );
215 
216  if( aSel.GetSize() != 1
217  && !( aSel.GetSize() >= 1
218  && ( firstItem->Type() == SCH_LINE_T
219  || firstItem->Type() == SCH_BUS_WIRE_ENTRY_T )
220  && eeSelection->AllItemsHaveLineStroke() ) )
221  return false;
222 
223  if( aSel.GetSize() != 1
224  && !( aSel.GetSize() >= 1
225  && ( firstItem->Type() == SCH_JUNCTION_T )
226  && eeSelection->AreAllItemsIdentical() ) )
227  return false;
228 
229  switch( firstItem->Type() )
230  {
231  case SCH_COMPONENT_T:
232  case SCH_SHEET_T:
233  case SCH_SHEET_PIN_T:
234  case SCH_TEXT_T:
235  case SCH_LABEL_T:
236  case SCH_GLOBAL_LABEL_T:
237  case SCH_HIER_LABEL_T:
238  case SCH_FIELD_T:
239  case SCH_BITMAP_T:
240  return aSel.GetSize() == 1;
241 
242  case SCH_LINE_T:
244  for( EDA_ITEM* item : aSel.GetItems() )
245  {
246  SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( item );
247 
248  if( !schItem || !schItem->HasLineStroke() )
249  return false;
250  }
251 
252  return true;
253 
254  case SCH_JUNCTION_T:
255  return true;
256 
257  default:
258  return false;
259  }
260  };
261 
262  static KICAD_T toLabelTypes[] = { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
263  auto toLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toLabelTypes );
264 
265  static KICAD_T toHLableTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_TEXT_T, EOT };
266  auto toHLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toHLableTypes );
267 
268  static KICAD_T toGLableTypes[] = { SCH_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
269  auto toGLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toGLableTypes );
270 
271  static KICAD_T toTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EOT };
272  auto toTextlCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toTextTypes );
273 
274  static KICAD_T entryTypes[] = { SCH_BUS_WIRE_ENTRY_T, SCH_BUS_BUS_ENTRY_T, EOT };
275  auto entryCondition = E_C::MoreThan( 0 ) && E_C::OnlyTypes( entryTypes );
276 
277  auto singleComponentCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_COMPONENT_T );
278  auto wireSelectionCondition = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_WIRE_T );
279  auto busSelectionCondition = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_BUS_T );
280  auto singleSheetCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
281  auto symbolsOnlyCondition = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_COMPONENT_T );
282  //
283  // Add edit actions to the move tool menu
284  //
285  if( moveTool )
286  {
287  CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
288 
289  moveMenu.AddSeparator();
290  moveMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition );
291  moveMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition );
292  moveMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition );
293  moveMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition );
295 
296  moveMenu.AddItem( EE_ACTIONS::properties, propertiesCondition );
297  moveMenu.AddItem( EE_ACTIONS::editReference, singleComponentCondition );
298  moveMenu.AddItem( EE_ACTIONS::editValue, singleComponentCondition );
299  moveMenu.AddItem( EE_ACTIONS::editFootprint, singleComponentCondition );
301 
302  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu = std::make_shared<SYMBOL_UNIT_MENU>();
303  symUnitMenu->SetTool( this );
304  m_menu.AddSubMenu( symUnitMenu );
305  moveMenu.AddMenu( symUnitMenu.get(), E_C::SingleMultiUnitSymbol, 1 );
306 
307  moveMenu.AddSeparator();
310  moveMenu.AddItem( ACTIONS::duplicate, duplicateCondition );
311 
312  moveMenu.AddSeparator();
313  moveMenu.AddItem( ACTIONS::selectAll, hasElements );
314  }
315 
316  //
317  // Add editing actions to the drawing tool menu
318  //
319  CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
320 
321  drawMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
322  drawMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
323  drawMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition, 200 );
324  drawMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition, 200 );
325 
326  drawMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
327  drawMenu.AddItem( EE_ACTIONS::editReference, singleComponentCondition, 200 );
328  drawMenu.AddItem( EE_ACTIONS::editValue, singleComponentCondition, 200 );
329  drawMenu.AddItem( EE_ACTIONS::editFootprint, singleComponentCondition, 200 );
330  drawMenu.AddItem( EE_ACTIONS::autoplaceFields, singleComponentCondition, 200 );
332 
333  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu2 = std::make_shared<SYMBOL_UNIT_MENU>();
334  symUnitMenu2->SetTool( drawingTools );
335  drawingTools->GetToolMenu().AddSubMenu( symUnitMenu2 );
336  drawMenu.AddMenu( symUnitMenu2.get(), E_C::SingleMultiUnitSymbol, 1 );
337 
338  drawMenu.AddItem( EE_ACTIONS::editWithLibEdit, singleComponentCondition && E_C::Idle, 200 );
339 
340  drawMenu.AddItem( EE_ACTIONS::toLabel, anyTextTool && E_C::Idle, 200 );
341  drawMenu.AddItem( EE_ACTIONS::toHLabel, anyTextTool && E_C::Idle, 200 );
342  drawMenu.AddItem( EE_ACTIONS::toGLabel, anyTextTool && E_C::Idle, 200 );
343  drawMenu.AddItem( EE_ACTIONS::toText, anyTextTool && E_C::Idle, 200 );
344  drawMenu.AddItem( EE_ACTIONS::cleanupSheetPins, sheetTool && E_C::Idle, 250 );
345 
346  //
347  // Add editing actions to the selection tool menu
348  //
350 
351  selToolMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
352  selToolMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
353  selToolMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition, 200 );
354  selToolMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition, 200 );
355  selToolMenu.AddItem( ACTIONS::doDelete, E_C::NotEmpty, 200 );
356 
357  selToolMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
359  selToolMenu.AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 );
361  selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, singleComponentCondition, 200 );
363  selToolMenu.AddItem( EE_ACTIONS::refreshSymbolFromLibrary, symbolsOnlyCondition, 200 );
364 
365  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu3 = std::make_shared<SYMBOL_UNIT_MENU>();
366  symUnitMenu3->SetTool( m_selectionTool );
367  m_selectionTool->GetToolMenu().AddSubMenu( symUnitMenu3 );
368  selToolMenu.AddMenu( symUnitMenu3.get(), E_C::SingleMultiUnitSymbol, 1 );
369 
370  selToolMenu.AddItem( EE_ACTIONS::editWithLibEdit, singleComponentCondition && E_C::Idle, 200 );
373 
374  selToolMenu.AddItem( EE_ACTIONS::toLabel, toLabelCondition, 200 );
375  selToolMenu.AddItem( EE_ACTIONS::toHLabel, toHLabelCondition, 200 );
376  selToolMenu.AddItem( EE_ACTIONS::toGLabel, toGLabelCondition, 200 );
377  selToolMenu.AddItem( EE_ACTIONS::toText, toTextlCondition, 200 );
378  selToolMenu.AddItem( EE_ACTIONS::cleanupSheetPins, singleSheetCondition, 250 );
379 
380  selToolMenu.AddSeparator( 300 );
381  selToolMenu.AddItem( ACTIONS::cut, E_C::IdleSelection, 300 );
382  selToolMenu.AddItem( ACTIONS::copy, E_C::IdleSelection, 300 );
383  selToolMenu.AddItem( ACTIONS::paste, E_C::Idle, 300 );
384  selToolMenu.AddItem( ACTIONS::pasteSpecial, E_C::Idle, 300 );
385  selToolMenu.AddItem( ACTIONS::duplicate, duplicateCondition, 300 );
386 
387  selToolMenu.AddSeparator( 400 );
388  selToolMenu.AddItem( ACTIONS::selectAll, hasElements, 400 );
389 
390 
391  return true;
392 }
393 
394 
396  SCH_TEXT_T,
397  SCH_LABEL_T,
400  SCH_FIELD_T,
403  SCH_SHEET_T,
404  SCH_BITMAP_T,
407  SCH_LINE_T,
410  EOT
411 };
412 
413 
414 int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
415 {
417 
418  if( selection.GetSize() == 0 )
419  return 0;
420 
421  wxPoint rotPoint;
422  bool clockwise = ( aEvent.Matches( EE_ACTIONS::rotateCW.MakeEvent() ) );
423  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
424  bool connections = false;
425  bool moving = item->IsMoving();
426 
427  if( selection.GetSize() == 1 )
428  {
429  if( !moving )
431 
432  switch( item->Type() )
433  {
434  case SCH_COMPONENT_T:
435  {
436  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
437 
438  if( clockwise )
439  component->SetOrientation( CMP_ROTATE_CLOCKWISE );
440  else
442 
444  component->AutoAutoplaceFields( m_frame->GetScreen() );
445 
446  break;
447  }
448 
449  case SCH_TEXT_T:
450  case SCH_LABEL_T:
451  case SCH_GLOBAL_LABEL_T:
452  case SCH_HIER_LABEL_T:
453  {
454  SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
455 
456  if( clockwise )
457  textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().RotateCW() );
458  else
459  textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().RotateCCW() );
460 
461  break;
462  }
463 
464  case SCH_SHEET_PIN_T:
465  {
466  // Rotate pin within parent sheet
467  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
468  SCH_SHEET* sheet = pin->GetParent();
469  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
470  {
471  pin->Rotate( sheet->GetBoundingBox().GetCenter() );
472  }
473  break;
474  }
475 
476  case SCH_BUS_BUS_ENTRY_T:
478  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
479  {
480  item->Rotate( item->GetPosition() );
481  }
482  break;
483 
484  case SCH_FIELD_T:
485  {
486  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
487 
488  if( field->GetTextAngle() == TEXT_ANGLE_HORIZ )
489  field->SetTextAngle( TEXT_ANGLE_VERT );
490  else
491  field->SetTextAngle( TEXT_ANGLE_HORIZ );
492 
493  // Now that we're moving a field, they're no longer autoplaced.
494  static_cast<SCH_ITEM*>( item->GetParent() )->ClearFieldsAutoplaced();
495 
496  break;
497  }
498 
499  case SCH_BITMAP_T:
500  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
501  {
502  item->Rotate( item->GetPosition() );
503  }
504  // The bitmap is cached in Opengl: clear the cache to redraw
506  break;
507 
508  case SCH_SHEET_T:
509  {
510  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
511 
512  // Rotate the sheet on itself. Sheets do not have an anchor point.
513  for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
514  {
515  rotPoint = m_frame->GetNearestGridPosition( sheet->GetRotationCenter() );
516  sheet->Rotate( rotPoint );
517  }
518  break;
519  }
520 
521  default:
522  break;
523  }
524 
525  connections = item->IsConnectable();
526  m_frame->UpdateItem( item );
527  }
528  else if( selection.GetSize() > 1 )
529  {
530  rotPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() );
531 
532  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
533  {
534  item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
535 
536  if( !moving )
537  saveCopyInUndoList( item, UNDO_REDO::CHANGED, ii > 0 );
538 
539  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
540  {
541  if( item->Type() == SCH_LINE_T )
542  {
543  SCH_LINE* line = (SCH_LINE*) item;
544 
545  if( item->HasFlag( STARTPOINT ) )
546  line->RotateStart( rotPoint );
547 
548  if( item->HasFlag( ENDPOINT ) )
549  line->RotateEnd( rotPoint );
550  }
551  else if( item->Type() == SCH_SHEET_PIN_T )
552  {
553  if( item->GetParent()->IsSelected() )
554  {
555  // parent will rotate us
556  }
557  else
558  {
559  // rotate within parent
560  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
561  SCH_SHEET* sheet = pin->GetParent();
562 
563  pin->Rotate( sheet->GetBoundingBox().GetCenter() );
564  }
565  }
566  else
567  {
568  item->Rotate( rotPoint );
569  }
570  }
571 
572  connections |= item->IsConnectable();
573  m_frame->UpdateItem( item );
574  }
575  }
576 
578 
579  if( item->IsMoving() )
580  {
582  }
583  else
584  {
585  if( selection.IsHover() )
587 
588  if( connections )
590 
591  m_frame->OnModify();
592  }
593 
594  return 0;
595 }
596 
597 
598 int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
599 {
601 
602  if( selection.GetSize() == 0 )
603  return 0;
604 
605  wxPoint mirrorPoint;
606  bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorX.MakeEvent() ) );
607  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
608  bool connections = false;
609  bool moving = item->IsMoving();
610 
611  if( selection.GetSize() == 1 )
612  {
613  if( !moving )
615 
616  switch( item->Type() )
617  {
618  case SCH_COMPONENT_T:
619  {
620  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
621 
622  if( xAxis )
623  component->SetOrientation( CMP_MIRROR_X );
624  else
625  component->SetOrientation( CMP_MIRROR_Y );
626 
628  component->AutoAutoplaceFields( m_frame->GetScreen() );
629 
630  break;
631  }
632 
633  case SCH_TEXT_T:
634  case SCH_LABEL_T:
635  case SCH_GLOBAL_LABEL_T:
636  case SCH_HIER_LABEL_T:
637  {
638  SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
639 
640  if( xAxis )
641  textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().MirrorX() );
642  else
643  textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().MirrorY() );
644  break;
645  }
646 
647  case SCH_SHEET_PIN_T:
648  {
649  // mirror within parent sheet
650  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
651  SCH_SHEET* sheet = pin->GetParent();
652 
653  if( xAxis )
654  pin->MirrorX( sheet->GetBoundingBox().GetCenter().y );
655  else
656  pin->MirrorY( sheet->GetBoundingBox().GetCenter().x );
657 
658  break;
659  }
660 
661  case SCH_BUS_BUS_ENTRY_T:
663  if( xAxis )
664  item->MirrorX( item->GetPosition().y );
665  else
666  item->MirrorY( item->GetPosition().x );
667  break;
668 
669  case SCH_FIELD_T:
670  {
671  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
672 
673  if( xAxis )
675  else
677 
678  // Now that we're re-justifying a field, they're no longer autoplaced.
679  static_cast<SCH_ITEM*>( item->GetParent() )->ClearFieldsAutoplaced();
680 
681  break;
682  }
683 
684  case SCH_BITMAP_T:
685  if( xAxis )
686  item->MirrorX( item->GetPosition().y );
687  else
688  item->MirrorY( item->GetPosition().x );
689 
690  // The bitmap is cached in Opengl: clear the cache to redraw
692  break;
693 
694  case SCH_SHEET_T:
695  // Mirror the sheet on itself. Sheets do not have a anchor point.
696  mirrorPoint = m_frame->GetNearestGridPosition( item->GetBoundingBox().Centre() );
697 
698  if( xAxis )
699  item->MirrorX( mirrorPoint.y );
700  else
701  item->MirrorY( mirrorPoint.x );
702 
703  break;
704 
705  default:
706  break;
707  }
708 
709  connections = item->IsConnectable();
710  m_frame->UpdateItem( item );
711  }
712  else if( selection.GetSize() > 1 )
713  {
714  mirrorPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() );
715 
716  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
717  {
718  item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
719 
720  if( !moving )
721  saveCopyInUndoList( item, UNDO_REDO::CHANGED, ii > 0 );
722 
723  if( item->Type() == SCH_SHEET_PIN_T )
724  {
725  if( item->GetParent()->IsSelected() )
726  {
727  // parent will mirror us
728  }
729  else
730  {
731  // mirror within parent sheet
732  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
733  SCH_SHEET* sheet = pin->GetParent();
734 
735  if( xAxis )
736  pin->MirrorX( sheet->GetBoundingBox().GetCenter().y );
737  else
738  pin->MirrorY( sheet->GetBoundingBox().GetCenter().x );
739  }
740  }
741  else
742  {
743  if( xAxis )
744  item->MirrorX( mirrorPoint.y );
745  else
746  item->MirrorY( mirrorPoint.x );
747  }
748 
749  connections |= item->IsConnectable();
750  m_frame->UpdateItem( item );
751  }
752  }
753 
755 
756  if( item->IsMoving() )
757  {
759  }
760  else
761  {
762  if( selection.IsHover() )
764 
765  if( connections )
767 
768  m_frame->OnModify();
769  }
770 
771  return 0;
772 }
773 
774 
776 {
778  SCH_LINE_T,
781  SCH_TEXT_T,
782  SCH_LABEL_T,
786  SCH_SHEET_T,
788  EOT
789 };
790 
791 
793 {
795 
796  if( selection.GetSize() == 0 )
797  return 0;
798 
799  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
800  // up dragging around a stack of objects...
801  if( selection.Front()->IsNew() )
802  return 0;
803 
804  EDA_ITEMS newItems;
805 
806  // Keep track of existing sheet paths. Duplicating a selection can modify this list
807  bool copiedSheets = false;
808  SCH_SHEET_LIST initial_sheetpathList = m_frame->Schematic().GetSheets();
809 
810  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
811  {
812  SCH_ITEM* oldItem = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
813  SCH_ITEM* newItem = oldItem->Duplicate();
814  newItem->SetFlags( IS_NEW );
815  newItems.push_back( newItem );
816  saveCopyInUndoList( newItem, UNDO_REDO::NEWITEM, ii > 0 );
817 
818  switch( newItem->Type() )
819  {
820  case SCH_JUNCTION_T:
821  case SCH_LINE_T:
822  case SCH_BUS_BUS_ENTRY_T:
824  case SCH_TEXT_T:
825  case SCH_LABEL_T:
826  case SCH_GLOBAL_LABEL_T:
827  case SCH_HIER_LABEL_T:
828  case SCH_NO_CONNECT_T:
829  newItem->SetParent( m_frame->GetScreen() );
830  m_frame->AddToScreen( newItem, m_frame->GetScreen() );
831  break;
832 
833  case SCH_SHEET_T:
834  {
835  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
836  SCH_SHEET* sheet = (SCH_SHEET*) newItem;
837  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
838  wxString baseName = nameField.GetText();
839  wxString candidateName = baseName;
840  int uniquifier = 1;
841 
842  while( hierarchy.NameExists( candidateName ) )
843  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
844 
845  nameField.SetText( candidateName );
846 
847  sheet->SetParent( m_frame->GetCurrentSheet().Last() );
848  m_frame->AddToScreen( sheet, m_frame->GetScreen() );
849 
850  copiedSheets = true;
851  break;
852  }
853 
854  case SCH_COMPONENT_T:
855  {
856  SCH_COMPONENT* component = (SCH_COMPONENT*) newItem;
857  component->ClearAnnotation( NULL );
858  component->SetParent( m_frame->GetScreen() );
859  m_frame->AddToScreen( component, m_frame->GetScreen() );
860  break;
861  }
862 
863  default:
864  break;
865  }
866  }
867 
868  if( copiedSheets )
869  {
870  // We clear annotation of new sheet paths.
871  // Annotation of new components added in current sheet is already cleared.
872  SCH_SCREENS screensList( &m_frame->Schematic().Root() );
873  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
875  }
876 
878  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
880 
881  return 0;
882 }
883 
884 
886 {
887  SCH_ITEM* sourceItem = m_frame->GetRepeatItem();
888 
889  if( !sourceItem )
890  return 0;
891 
893 
894  SCH_ITEM* newItem = sourceItem->Duplicate();
895  bool performDrag = false;
896 
897  // If cloning a component then put into 'move' mode.
898  if( newItem->Type() == SCH_COMPONENT_T )
899  {
900  wxPoint cursorPos = (wxPoint) getViewControls()->GetCursorPosition( true );
901  newItem->Move( cursorPos - newItem->GetPosition() );
902  performDrag = true;
903  }
904  else
905  {
906  if( m_isLibEdit )
907  {
908  LIBEDIT_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
909 
910  if( dynamic_cast<SCH_TEXT*>( newItem ) )
911  {
912  SCH_TEXT* text = static_cast<SCH_TEXT*>( newItem );
913  text->IncrementLabel( cfg->m_Repeat.label_delta );
914  }
915 
916  newItem->Move( wxPoint( Mils2iu( cfg->m_Repeat.x_step ),
917  Mils2iu( cfg->m_Repeat.y_step ) ) );
918  }
919  else
920  {
921  EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
922 
923  if( dynamic_cast<SCH_TEXT*>( newItem ) )
924  {
925  SCH_TEXT* text = static_cast<SCH_TEXT*>( newItem );
927  }
928 
929  newItem->Move( wxPoint( Mils2iu( cfg->m_Drawing.default_repeat_offset_x ),
930  Mils2iu( cfg->m_Drawing.default_repeat_offset_y ) ) );
931  }
932 
933  }
934 
935  newItem->SetFlags( IS_NEW );
936  m_frame->AddToScreen( newItem, m_frame->GetScreen() );
938 
939  m_selectionTool->AddItemToSel( newItem );
940 
941  if( performDrag )
943 
944  newItem->ClearFlags();
945 
946  if( newItem->IsConnectable() )
947  {
948  auto selection = m_selectionTool->GetSelection();
949 
950  m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selection );
953  }
954 
955  // newItem newItem, now that it has been moved, thus saving new position.
956  m_frame->SaveCopyForRepeatItem( newItem );
957 
958  return 0;
959 }
960 
961 
963 {
964  SCH_MARKER_T,
966  SCH_LINE_T,
969  SCH_TEXT_T,
970  SCH_LABEL_T,
974  SCH_SHEET_T,
977  SCH_BITMAP_T,
978  EOT
979 };
980 
981 
983 {
984  SCH_SCREEN* screen = m_frame->GetScreen();
986  bool appendToUndo = false;
987  std::vector<wxPoint> pts;
988 
989  if( items.empty() )
990  return 0;
991 
992  // Don't leave a freed pointer in the selection
994 
995  for( EDA_ITEM* item : items )
996  item->ClearFlags( STRUCT_DELETED );
997 
998  for( EDA_ITEM* item : items )
999  {
1000  SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
1001 
1002  if( !sch_item )
1003  continue;
1004 
1005  if( sch_item->IsConnectable() )
1006  {
1007  std::vector<wxPoint> tmp_pts = sch_item->GetConnectionPoints();
1008  pts.insert( pts.end(), tmp_pts.begin(), tmp_pts.end() );
1009  }
1010 
1011  if( sch_item->Type() == SCH_JUNCTION_T )
1012  {
1013  sch_item->SetFlags( STRUCT_DELETED );
1014  // clean up junctions at the end
1015  }
1016  else
1017  {
1018  sch_item->SetFlags( STRUCT_DELETED );
1019  saveCopyInUndoList( item, UNDO_REDO::DELETED, appendToUndo );
1020  appendToUndo = true;
1021 
1022  updateView( sch_item );
1023 
1024  if( sch_item->Type() == SCH_SHEET_PIN_T )
1025  {
1026  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) sch_item;
1027  SCH_SHEET* sheet = pin->GetParent();
1028 
1029  sheet->RemovePin( pin );
1030  }
1031  else
1032  {
1033  m_frame->RemoveFromScreen( sch_item, m_frame->GetScreen() );
1034  }
1035 
1036  if( sch_item->Type() == SCH_SHEET_T )
1038  }
1039  }
1040 
1041  for( auto point : pts )
1042  {
1043  SCH_ITEM* junction = screen->GetItem( point, 0, SCH_JUNCTION_T );
1044 
1045  if( !junction )
1046  continue;
1047 
1048  if( junction->HasFlag( STRUCT_DELETED ) || !screen->IsJunctionNeeded( point ) )
1049  m_frame->DeleteJunction( junction, appendToUndo );
1050  }
1051 
1053 
1054  m_frame->GetCanvas()->Refresh();
1055  m_frame->OnModify();
1056 
1057  return 0;
1058 }
1059 
1060 
1061 #define HITTEST_THRESHOLD_PIXELS 5
1062 
1063 
1065 {
1066  std::string tool = aEvent.GetCommandStr().get();
1067  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1068 
1070  m_pickerItem = nullptr;
1071 
1072  // Deactivate other tools; particularly important if another PICKER is currently running
1073  Activate();
1074 
1075  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
1076 
1077  picker->SetClickHandler(
1078  [this] ( const VECTOR2D& aPosition ) -> bool
1079  {
1080  if( m_pickerItem )
1081  {
1082  SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( m_pickerItem );
1083 
1084  if( sch_item && sch_item->IsLocked() )
1085  {
1086  STATUS_TEXT_POPUP statusPopup( m_frame );
1087  statusPopup.SetText( _( "Item locked." ) );
1088  statusPopup.PopupFor( 2000 );
1089  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1090  return true;
1091  }
1092 
1094  selectionTool->UnbrightenItem( m_pickerItem );
1095  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
1097  m_pickerItem = nullptr;
1098  }
1099 
1100  return true;
1101  } );
1102 
1103  picker->SetMotionHandler(
1104  [this] ( const VECTOR2D& aPos )
1105  {
1106  EE_COLLECTOR collector;
1107  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
1108  collector.Collect( m_frame->GetScreen(), deletableItems, (wxPoint) aPos );
1109 
1111  selectionTool->GuessSelectionCandidates( collector, aPos );
1112 
1113  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
1114 
1115  if( m_pickerItem != item )
1116  {
1117  if( m_pickerItem )
1118  selectionTool->UnbrightenItem( m_pickerItem );
1119 
1120  m_pickerItem = item;
1121 
1122  if( m_pickerItem )
1123  selectionTool->BrightenItem( m_pickerItem );
1124  }
1125  } );
1126 
1127  picker->SetFinalizeHandler(
1128  [this] ( const int& aFinalState )
1129  {
1130  if( m_pickerItem )
1132  } );
1133 
1134  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1135 
1136  return 0;
1137 }
1138 
1139 
1141 {
1142  // Save old component in undo list if not already in edit, or moving.
1143  if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
1145 
1146  wxString title = wxString::Format( _( "Edit %s Field" ), aField->GetName() );
1147 
1148  DIALOG_SCH_EDIT_ONE_FIELD dlg( m_frame, title, aField );
1149 
1150  // The footprint field dialog can invoke a KIWAY_PLAYER so we must use a quasi-modal
1151  if( dlg.ShowQuasiModal() != wxID_OK )
1152  return;
1153 
1154  dlg.UpdateField( aField, &m_frame->GetCurrentSheet() );
1155 
1156  if( m_frame->eeconfig()->m_AutoplaceFields.enable || aField->GetParent()->Type() == SCH_SHEET_T )
1157  static_cast<SCH_ITEM*>( aField->GetParent() )->AutoAutoplaceFields( m_frame->GetScreen() );
1158 
1159  m_frame->UpdateItem( aField );
1160  m_frame->OnModify();
1161 
1162  // This must go after OnModify() so that the connectivity graph will have been updated.
1164 }
1165 
1166 
1168 {
1169  static KICAD_T Nothing[] = { EOT };
1170  static KICAD_T CmpOrReference[] = { SCH_FIELD_LOCATE_REFERENCE_T, SCH_COMPONENT_T, EOT };
1171  static KICAD_T CmpOrValue[] = { SCH_FIELD_LOCATE_VALUE_T, SCH_COMPONENT_T, EOT };
1172  static KICAD_T CmpOrFootprint[] = { SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_COMPONENT_T, EOT };
1173 
1174  KICAD_T* filter = Nothing;
1175 
1176  if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1177  filter = CmpOrReference;
1178  else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1179  filter = CmpOrValue;
1180  else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1181  filter = CmpOrFootprint;
1182 
1183  EE_SELECTION& selection = m_selectionTool->RequestSelection( filter );
1184 
1185  if( selection.Empty() )
1186  return 0;
1187 
1188  SCH_ITEM* item = (SCH_ITEM*) selection.Front();
1189 
1190  if( item->Type() == SCH_COMPONENT_T )
1191  {
1192  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1193 
1194  if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1195  editFieldText( component->GetField( REFERENCE ) );
1196  else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1197  editFieldText( component->GetField( VALUE ) );
1198  else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1199  editFieldText( component->GetField( FOOTPRINT ) );
1200  }
1201  else if( item->Type() == SCH_FIELD_T )
1202  {
1203  editFieldText( (SCH_FIELD*) item );
1204  }
1205 
1206  if( selection.IsHover() )
1208 
1209  return 0;
1210 }
1211 
1212 
1214 {
1216 
1217  if( selection.Empty() )
1218  return 0;
1219 
1220  SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front();
1221 
1222  if( !component->IsNew() )
1223  saveCopyInUndoList( component, UNDO_REDO::CHANGED );
1224 
1225  component->AutoplaceFields( m_frame->GetScreen(), /* aManual */ true );
1226 
1227  m_frame->GetScreen()->Update( component );
1228  updateView( component );
1229  m_frame->OnModify();
1230 
1231  if( selection.IsHover() )
1233 
1234  return 0;
1235 }
1236 
1237 
1239 {
1240  if( InvokeDialogUpdateFields( m_frame ) == wxID_OK )
1241  m_frame->GetCanvas()->Refresh();
1242 
1243  return 0;
1244 }
1245 
1246 
1248 {
1249  SCH_COMPONENT* selectedSymbol = nullptr;
1251 
1252  if( !selection.Empty() )
1253  selectedSymbol = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
1254 
1256 
1257  if( aEvent.IsAction( &EE_ACTIONS::changeSymbol )
1258  || aEvent.IsAction( &EE_ACTIONS::changeSymbols ) )
1260 
1261  DIALOG_CHANGE_SYMBOLS dlg( m_frame, selectedSymbol, mode );
1262 
1263  dlg.ShowModal();
1264 
1265  return 0;
1266 }
1267 
1268 
1270 {
1272 
1273  if( selection.Empty() )
1274  return 0;
1275 
1276  SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front();
1277 
1279  && component->GetConvert() == LIB_ITEM::LIB_CONVERT::BASE )
1280  return 0;
1281 
1283  && component->GetConvert() != LIB_ITEM::LIB_CONVERT::DEMORGAN )
1284  return 0;
1285 
1286  if( !component->IsNew() )
1287  saveCopyInUndoList( component, UNDO_REDO::CHANGED );
1288 
1289  m_frame->ConvertPart( component );
1290 
1291  if( component->IsNew() )
1293 
1294  if( selection.IsHover() )
1296 
1297  return 0;
1298 }
1299 
1300 
1302 {
1303  wxString msg;
1304  bool appendToUndo = false;
1306 
1307  if( selection.Empty() )
1308  return 0;
1309 
1310  WX_INFOBAR* infoBar = m_frame->GetInfoBar();
1311 
1312  wxCHECK( infoBar, 0 );
1313 
1314  INFOBAR_REPORTER reporter( infoBar );
1315 
1316  SCH_SCREEN* currentScreen = m_frame->GetScreen();
1317 
1318  wxCHECK( currentScreen, 0 );
1319 
1320  for( auto item : selection )
1321  {
1322  SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( item );
1323 
1324  wxCHECK( symbol, 0 );
1325 
1326  // This needs to be done before the LIB_ID is changed to prevent stale library symbols in
1327  // the schematic file.
1328  currentScreen->Remove( symbol );
1329 
1330  if( !symbol->IsNew() )
1331  {
1332  saveCopyInUndoList( symbol, UNDO_REDO::CHANGED, appendToUndo );
1333  appendToUndo = true;
1334  }
1335 
1336  LIB_ID id = symbol->GetLibId();
1337 
1338  if( !id.IsValid() )
1339  {
1340  msg.Printf( _( "'%s' is not a valid library indentifier." ),
1341  id.GetUniStringLibId() );
1342  reporter.Report( msg, RPT_SEVERITY_WARNING );
1343  continue;
1344  }
1345 
1346  LIB_PART* libSymbol = m_frame->Prj().SchSymbolLibTable()->LoadSymbol( id );
1347 
1348  if( !libSymbol )
1349  {
1350  msg.Printf( _( "Symbol '%s' not found in symbol library '%s'." ),
1351  id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
1352  reporter.Report( msg, RPT_SEVERITY_WARNING );
1353  continue;
1354  }
1355 
1356  symbol->SetLibSymbol( libSymbol->Flatten().release() );
1357  currentScreen->Append( symbol );
1359  updateView( symbol );
1360  }
1361 
1362  if( selection.IsHover() )
1364 
1365  if( reporter.HasMessage() )
1366  reporter.Finalize();
1367 
1368  m_frame->GetCanvas()->Refresh();
1369  m_frame->OnModify();
1370 
1371  return 0;
1372 }
1373 
1374 
1376 {
1378 
1379  if( selection.Empty() )
1380  {
1382  {
1384  VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
1385 
1386  if( worksheet && worksheet->HitTestWorksheetItems( getView(), (wxPoint) cursorPos ) )
1388  }
1389 
1390  return 0;
1391  }
1392 
1393  SCH_ITEM* item = (SCH_ITEM*) selection.Front();
1394 
1395  switch( item->Type() )
1396  {
1397  case SCH_LINE_T:
1398  case SCH_BUS_WIRE_ENTRY_T:
1399  if( !selection.AllItemsHaveLineStroke() )
1400  return 0;
1401 
1402  break;
1403 
1404  case SCH_JUNCTION_T:
1405  if( !selection.AreAllItemsIdentical() )
1406  return 0;
1407 
1408  break;
1409 
1410  default:
1411  if( selection.Size() > 1 )
1412  return 0;
1413 
1414  break;
1415  }
1416 
1417  switch( item->Type() )
1418  {
1419  case SCH_COMPONENT_T:
1420  {
1421  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1422  DIALOG_EDIT_COMPONENT_IN_SCHEMATIC symbolPropsDialog( m_frame, component );
1423 
1424  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
1425  // frame. Therefore this dialog as a modal frame parent, MUST be run under
1426  // quasimodal mode for the quasimodal frame support to work. So don't use
1427  // the QUASIMODAL macros here.
1428  int retval = symbolPropsDialog.ShowQuasiModal();
1429 
1430  if( retval == SYMBOL_PROPS_EDIT_OK )
1431  {
1433  component->AutoAutoplaceFields( m_frame->GetScreen() );
1434 
1436  m_frame->OnModify();
1437  }
1438  else if( retval == SYMBOL_PROPS_EDIT_SCHEMATIC_SYMBOL )
1439  {
1440  auto editor = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
1441 
1442  editor->LoadSymbolFromSchematic( component->GetPartRef(),
1443  component->GetRef( &m_frame->GetCurrentSheet() ),
1444  component->GetUnit(), component->GetConvert() );
1445 
1446  editor->Show( true );
1447  editor->Raise();
1448  }
1449  else if( retval == SYMBOL_PROPS_EDIT_LIBRARY_SYMBOL )
1450  {
1451  auto editor = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
1452 
1453  editor->LoadComponentAndSelectLib( component->GetLibId(), component->GetUnit(),
1454  component->GetConvert() );
1455 
1456  editor->Show( true );
1457  editor->Raise();
1458  }
1459  else if( retval == SYMBOL_PROPS_WANT_UPDATE_SYMBOL )
1460  {
1462  dlg.ShowModal();
1463  }
1464  else if( retval == SYMBOL_PROPS_WANT_EXCHANGE_SYMBOL )
1465  {
1467  dlg.ShowModal();
1468  }
1469  }
1470  break;
1471 
1472  case SCH_SHEET_T:
1473  {
1474  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1475  bool doClearAnnotation;
1476  bool doRefresh = false;
1477  // Keep track of existing sheet paths. EditSheet() can modify this list
1478  SCH_SHEET_LIST initial_sheetpathList = m_frame->Schematic().GetSheets();
1479 
1480  doRefresh = m_frame->EditSheetProperties(
1481  sheet, &m_frame->GetCurrentSheet(), &doClearAnnotation );
1482 
1483  // If the sheet file is changed and new sheet contents are loaded then we have to
1484  // clear the annotations on the new content (as it may have been set from some other
1485  // sheet path reference)
1486  if( doClearAnnotation )
1487  {
1488  SCH_SCREENS screensList( &m_frame->Schematic().Root() );
1489  // We clear annotation of new sheet paths here:
1490  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1491  // Clear annotation of g_CurrentSheet itself, because its sheetpath is not a new
1492  // path, but components managed by its sheet path must have their annotation
1493  // cleared, because they are new:
1495  }
1496 
1497  if( doRefresh )
1498  {
1500  m_frame->GetCanvas()->Refresh();
1502  }
1503 
1504  break;
1505  }
1506 
1507  case SCH_SHEET_PIN_T:
1508  {
1509  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) item;
1510  DIALOG_EDIT_SHEET_PIN dlg( m_frame, pin );
1511 
1512  if( dlg.ShowModal() == wxID_OK )
1513  {
1515  m_frame->OnModify();
1516  }
1517  }
1518  break;
1519 
1520  case SCH_TEXT_T:
1521  case SCH_LABEL_T:
1522  case SCH_GLOBAL_LABEL_T:
1523  case SCH_HIER_LABEL_T:
1524  {
1525  DIALOG_LABEL_EDITOR dlg( m_frame, (SCH_TEXT*) item );
1526 
1527  if( dlg.ShowModal() == wxID_OK )
1528  {
1530  m_frame->OnModify();
1531  }
1532  }
1533  break;
1534 
1535  case SCH_FIELD_T:
1536  editFieldText( (SCH_FIELD*) item );
1537  break;
1538 
1539  case SCH_BITMAP_T:
1540  {
1541  SCH_BITMAP* bitmap = (SCH_BITMAP*) item;
1542  DIALOG_IMAGE_EDITOR dlg( m_frame, bitmap->GetImage() );
1543 
1544  if( dlg.ShowModal() == wxID_OK )
1545  {
1546  // save old image in undo list if not already in edit
1547  if( bitmap->GetEditFlags() == 0 )
1549 
1550  dlg.TransferToImage( bitmap->GetImage() );
1551 
1552  // The bitmap is cached in Opengl: clear the cache in case it has become invalid
1553  getView()->RecacheAllItems();
1555  m_frame->OnModify();
1556  }
1557  }
1558  break;
1559 
1560  case SCH_LINE_T:
1561  case SCH_BUS_WIRE_ENTRY_T:
1562  {
1563  std::deque<SCH_ITEM*> strokeItems;
1564 
1565  for( auto selItem : selection.Items() )
1566  {
1567  SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( selItem );
1568 
1569  if( schItem && schItem->HasLineStroke() )
1570  strokeItems.push_back( schItem );
1571  else
1572  return 0;
1573  }
1574 
1575  DIALOG_EDIT_LINE_STYLE dlg( m_frame, strokeItems );
1576 
1577  if( dlg.ShowModal() == wxID_OK )
1578  {
1580  m_frame->OnModify();
1581  }
1582  }
1583  break;
1584 
1585  case SCH_JUNCTION_T:
1586  {
1587  std::deque<SCH_JUNCTION*> junctions;
1588 
1589  for( auto selItem : selection.Items() )
1590  {
1591  SCH_JUNCTION* junction = dynamic_cast<SCH_JUNCTION*>( selItem );
1592 
1593  wxCHECK( junction, 0 );
1594 
1595  junctions.push_back( junction );
1596  }
1597 
1598  DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
1599 
1600  if( dlg.ShowModal() == wxID_OK )
1601  {
1603  m_frame->OnModify();
1604  }
1605  }
1606  break;
1607 
1608  case SCH_MARKER_T: // These items have no properties to edit
1609  case SCH_NO_CONNECT_T:
1610  break;
1611 
1612  default: // Unexpected item
1613  wxFAIL_MSG( wxString( "Cannot edit schematic item type " ) + item->GetClass() );
1614  }
1615 
1616  m_frame->GetScreen()->Update( item );
1617  updateView( item );
1618 
1619  if( selection.IsHover() )
1621 
1622  return 0;
1623 }
1624 
1625 
1627 {
1628  KICAD_T convertTo = aEvent.Parameter<KICAD_T>();
1630  EE_SELECTION& selection = m_selectionTool->RequestSelection( allTextTypes );
1631 
1632  for( unsigned int i = 0; i < selection.GetSize(); ++i )
1633  {
1634  SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( selection.GetItem( i ) );
1635 
1636  if( text && text->Type() != convertTo )
1637  {
1638  bool selected = text->IsSelected();
1639  SCH_TEXT* newtext = nullptr;
1640  const wxPoint& position = text->GetPosition();
1641  LABEL_SPIN_STYLE orientation = text->GetLabelSpinStyle();
1642  wxString txt = UnescapeString( text->GetText() );
1643 
1644  // There can be characters in a SCH_TEXT object that can break labels so we have to
1645  // fix them here.
1646  if( text->Type() == SCH_TEXT_T )
1647  {
1648  txt.Replace( "\n", "_" );
1649  txt.Replace( "\r", "_" );
1650  txt.Replace( "\t", "_" );
1651  txt.Replace( " ", "_" );
1652  }
1653 
1654  // label strings are "escaped" i.e. a '/' is replaced by "{slash}"
1655  if( convertTo != SCH_TEXT_T )
1656  txt = EscapeString( txt, CTX_NETNAME );
1657 
1658  switch( convertTo )
1659  {
1660  case SCH_LABEL_T: newtext = new SCH_LABEL( position, txt ); break;
1661  case SCH_GLOBAL_LABEL_T: newtext = new SCH_GLOBALLABEL( position, txt ); break;
1662  case SCH_HIER_LABEL_T: newtext = new SCH_HIERLABEL( position, txt ); break;
1663  case SCH_TEXT_T: newtext = new SCH_TEXT( position, txt ); break;
1664 
1665  default:
1666  wxFAIL_MSG( wxString::Format( "Invalid text type: %d.", convertTo ) );
1667  return 0;
1668  }
1669 
1670  // Copy the old text item settings to the new one. Justifications are not copied
1671  // because they are not used in labels. Justifications will be set to default value
1672  // in the new text item type.
1673  //
1674  newtext->SetFlags( text->GetEditFlags() );
1675  newtext->SetShape( text->GetShape() );
1676  newtext->SetLabelSpinStyle( orientation );
1677  newtext->SetTextSize( text->GetTextSize() );
1678  newtext->SetTextThickness( text->GetTextThickness() );
1679  newtext->SetItalic( text->IsItalic() );
1680  newtext->SetBold( text->IsBold() );
1681  newtext->SetIsDangling( text->IsDangling() );
1682 
1683  if( selected )
1685 
1686  if( !text->IsNew() )
1687  {
1689  saveCopyInUndoList( newtext, UNDO_REDO::NEWITEM, true );
1690 
1692  m_frame->AddToScreen( newtext, m_frame->GetScreen() );
1693  }
1694 
1695  if( selected )
1696  m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, newtext );
1697 
1698  // Otherwise, pointer is owned by the undo stack
1699  if( text->IsNew() )
1700  delete text;
1701 
1702  if( convertTo == SCH_TEXT_T )
1703  {
1704  if( newtext->IsDangling() )
1705  {
1706  newtext->SetIsDangling( false );
1707  getView()->Update( newtext, KIGFX::REPAINT );
1708  }
1709  }
1710  else
1712 
1713  m_frame->OnModify();
1714  }
1715  }
1716 
1717  if( selection.IsHover() )
1719 
1720  return 0;
1721 }
1722 
1723 
1725 {
1726  auto cursorPos = wxPoint( getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) ) );
1727 
1728  if( m_frame->BreakSegments( cursorPos ) )
1729  {
1730  if( m_frame->GetScreen()->IsJunctionNeeded( cursorPos, true ) )
1731  m_frame->AddJunction( m_frame->GetScreen(), cursorPos, true, false );
1732 
1734 
1735  m_frame->OnModify();
1736  m_frame->GetCanvas()->Refresh();
1737  }
1738 
1739  return 0;
1740 }
1741 
1742 
1744 {
1746  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1747 
1748  if( !sheet )
1749  return 0;
1750 
1751  if( !sheet->HasUndefinedPins() )
1752  {
1753  DisplayInfoMessage( m_frame, _( "There are no unreferenced pins in this sheet to remove." ) );
1754  return 0;
1755  }
1756 
1757  if( !IsOK( m_frame, _( "Do you wish to delete the unreferenced pins from this sheet?" ) ) )
1758  return 0;
1759 
1761 
1762  sheet->CleanupSheet();
1763 
1764  m_frame->GetScreen()->Update( sheet );
1765  updateView( sheet );
1766  m_frame->OnModify();
1767 
1768  if( selection.IsHover() )
1770 
1771  return 0;
1772 }
1773 
1774 
1776 {
1781  Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorX.MakeEvent() );
1782  Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorY.MakeEvent() );
1783  Go( &SCH_EDIT_TOOL::DoDelete, ACTIONS::doDelete.MakeEvent() );
1785 
1805 
1808 
1811 }
const BITMAP_OPAQUE component_select_unit_xpm[1]
bool IsDangling() const override
Definition: sch_text.h:304
bool HasMessage() const override
Function HasMessage Returns true if the reporter client is non-empty.
Definition: reporter.cpp:173
SCH_SHEET_LIST.
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:183
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: common.h:185
static TOOL_ACTION refreshSymbolFromLibrary
Definition: ee_actions.h:159
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:52
void SetCursor(const wxCursor &aCursor)
Definition: picker_tool.h:65
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:241
#define HITTEST_THRESHOLD_PIXELS
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:243
int m_Threshold
Definition: collector.h:67
void SetLibSymbol(LIB_PART *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
virtual bool IsConnectable() const
Definition: sch_item.h:377
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:48
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:200
bool IsHover() const
Definition: selection.h:71
SCH_SHEET * GetParent() const
Get the parent sheet object of this sheet pin.
Definition: sch_sheet.h:168
bool empty()
Definition: sch_rtree.h:166
std::deque< EDA_ITEM * > & Items()
Definition: selection.h:189
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:89
virtual std::vector< wxPoint > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:386
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:82
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: base_struct.h:203
int RefreshSymbolFromLibrary(const TOOL_EVENT &aEvent)
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
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:373
SCH_DRAWING_TOOLS.
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:72
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:457
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 RotateEnd(wxPoint aPosition)
Definition: sch_line.cpp:361
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.h:138
bool IsMoving() const
Definition: base_struct.h:200
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:179
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static TOOL_ACTION changeSymbol
Definition: ee_actions.h:150
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1395
int BreakWire(const TOOL_EVENT &aEvent)
TOOL_MENU & GetToolMenu()
double GetTextAngle() const
Definition: eda_text.h:174
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
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 TOOL_ACTION autoplaceFields
Definition: ee_actions.h:125
WS_PROXY_VIEW_ITEM * GetWorksheet() const
Definition: sch_view.h:104
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:260
static TOOL_ACTION updateSymbols
Definition: ee_actions.h:149
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:238
int UpdateFields(const TOOL_EVENT &aEvent)
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:47
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
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...
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void setTransitions() override
Sets up handlers for various events.
void SetIsDangling(bool aIsDangling)
Definition: sch_text.h:305
int GetTextThickness() const
Definition: eda_text.h:159
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:282
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.
#define TEXT_ANGLE_VERT
Definition: common.h:186
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
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:211
virtual void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:196
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:355
static TOOL_ACTION breakWire
Definition: ee_actions.h:134
static TOOL_ACTION rotateCW
Definition: ee_actions.h:117
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: base_struct.h:199
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:151
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:180
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
Definition: picker_tool.h:102
virtual void Rotate(wxPoint aPosition)=0
Rotate the item around aPosition 90 degrees in the clockwise direction.
EE_SELECTION & GetSelection()
Function GetSelection()
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
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:268
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:101
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:189
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:289
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: base_struct.h:232
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:199
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:81
#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:343
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:117
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:237
int ShowQuasiModal()
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:588
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
const wxSize & GetTextSize() const
Definition: eda_text.h:239
void SelectHighlightItem(EDA_ITEM *aItem)
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:203
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:151
virtual bool HasLineStroke() const
Check if this schematic item has line stoke properties.
Definition: sch_item.h:472
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:132
static TOOL_ACTION cut
Definition: actions.h:69
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
Define a library symbol object.
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.
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:126
EDA_ITEM * GetParent() const
Definition: base_struct.h:195
const KICAD_T rotatableItems[]
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Function Report is a pure virtual function to override in the derived object.
Definition: reporter.cpp:163
static TOOL_ACTION mirrorX
Definition: ee_actions.h:119
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:160
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:234
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:84
void Finalize()
Update the infobar with the reported text.
Definition: reporter.cpp:179
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
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)
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
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:190
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:453
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:105
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1531
wxPoint GetPosition() const override
Definition: sch_text.h:313
LABEL_SPIN_STYLE MirrorY()
Definition: sch_text.h:129
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:726
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:121
LABEL_SPIN_STYLE RotateCCW()
Definition: sch_text.h:91
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
bool AllItemsHaveLineStroke() const
Checks if all items in the selection support line strokes.
int Mirror(const TOOL_EVENT &aEvent)
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:55
EDA_ITEM * m_pickerItem
Definition: sch_edit_tool.h:90
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:100
virtual bool IsLocked() const
Definition: sch_item.h:269
int RepeatDrawItem(const TOOL_EVENT &aEvent)
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
static TOOL_ACTION updateFieldsFromLibrary
Definition: ee_actions.h:147
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
static TOOL_ACTION placeLabel
Definition: ee_actions.h:85
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
Field Value of part, i.e. "3.3K".
bool HasUndefinedPins()
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:351
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:68
static TOOL_ACTION editValue
Definition: ee_actions.h:123
static KICAD_T deletableItems[]
SCH_SHEET & Root() const
Definition: schematic.h:94
LABEL_SPIN_STYLE MirrorX()
Definition: sch_text.h:110
SCH_ITEM * GetRepeatItem() const
Return the item which is to be repeated with the insert key.
The symbol library editor main window.
void updateView(EDA_ITEM *aItem) const
Similar to getView()->Update(), but handles items that are redrawn by their parents.
Definition: ee_tool_base.h:104
void SetTitle(const wxString &aTitle) override
Sets title for the menu.
Definition: action_menu.cpp:89
LABEL_SPIN_STYLE RotateCW()
Definition: sch_text.h:75
see class PGM_BASE
int AddItemToSel(const TOOL_EVENT &aEvent)
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 Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:131
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:202
#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
Dialog used to edit SCH_COMPONENT objects in a schematic.
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:442
EE_RTREE & Items()
Definition: sch_screen.h:158
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:123
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Creates a functor that tests if the selected items are only of given type.
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the component.
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:127
Schematic symbol object.
Definition: sch_component.h:80
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:148
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_field.h:71
wxPoint Centre() const
Definition: eda_rect.h:62
int ChangeSymbols(const TOOL_EVENT &aEvent)
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
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:464
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
WX_INFOBAR * GetInfoBar()
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:924
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:162
static TOOL_ACTION move
Definition: ee_actions.h:114
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:312
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:158
int GetConvert() const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void Update(SCH_ITEM *aItem)
Updates aItem's bounding box in the tree.
Definition: sch_screen.cpp:236
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:167
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: base_struct.cpp:97
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...
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:235
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:229
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:267
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:273
void SetBold(bool aBold)
Definition: eda_text.h:182
void ConvertPart(SCH_COMPONENT *aComponent)
Definition: getpart.cpp:235
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:283
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127
int ConvertDeMorgan(const TOOL_EVENT &aEvent)
static TOOL_ACTION paste
Definition: actions.h:71
static const KICAD_T EditableItems[]
Definition: ee_collectors.h:46
INFOBAR_REPORTER is a wrapper for reporting to a WX_INFOBAR UI element.
Definition: reporter.h:292
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:515
int InvokeDialogUpdateFields(SCH_EDIT_FRAME *aCaller, SCH_COMPONENT *aSpecificComponent, bool aCreateUndoEntry)
Update symbol fields.
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:184
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:239
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:122
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:405
void IncrementLabel(int aIncrement)
Increment the label text, if it ends with a number.
Definition: sch_text.cpp:149
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
virtual void Move(const wxPoint &aMoveVector)=0
Move the item by aMoveVector to a new position.