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 <tool/picker_tool.h>
26 #include <tools/sch_edit_tool.h>
29 #include <tools/sch_move_tool.h>
30 #include <widgets/infobar.h>
31 #include <ee_actions.h>
32 #include <bitmaps.h>
33 #include <confirm.h>
34 #include <base_struct.h>
35 #include <reporter.h>
36 #include <sch_item.h>
37 #include <sch_component.h>
38 #include <sch_sheet.h>
39 #include <sch_text.h>
40 #include <sch_bitmap.h>
41 #include <sch_view.h>
42 #include <sch_line.h>
43 #include <sch_bus_entry.h>
44 #include <sch_junction.h>
45 #include <sch_edit_frame.h>
46 #include <schematic.h>
47 #include <ws_proxy_view_item.h>
48 #include <eeschema_id.h>
49 #include <status_popup.h>
50 #include <wx/gdicmn.h>
51 #include <invoke_sch_dialog.h>
58 #include "sch_drawing_tools.h"
59 #include <math/util.h> // for KiROUND
60 #include <pgm_base.h>
62 #include <libedit_settings.h>
64 
66 {
67 public:
69  ACTION_MENU( true )
70  {
72  SetTitle( _( "Symbol Unit" ) );
73  }
74 
75 protected:
76  ACTION_MENU* create() const override
77  {
78  return new SYMBOL_UNIT_MENU();
79  }
80 
81 private:
82  void update() override
83  {
85  EE_SELECTION& selection = selTool->GetSelection();
86  SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
87 
88  Clear();
89 
90  if( !component )
91  {
92  Append( ID_POPUP_SCH_UNFOLD_BUS, _( "no symbol selected" ), wxEmptyString );
93  Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
94  return;
95  }
96 
97  int unit = component->GetUnit();
98 
99  if( !component->GetPartRef() || component->GetPartRef()->GetUnitCount() < 2 )
100  {
101  Append( ID_POPUP_SCH_UNFOLD_BUS, _( "symbol is not multi-unit" ), wxEmptyString );
102  Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
103  return;
104  }
105 
106  for( int ii = 0; ii < component->GetPartRef()->GetUnitCount(); ii++ )
107  {
108  wxString num_unit;
109  num_unit.Printf( _( "Unit %s" ), LIB_PART::SubReference( ii + 1, false ) );
110 
111  wxMenuItem * item = Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, num_unit, wxEmptyString,
112  wxITEM_CHECK );
113  if( unit == ii + 1 )
114  item->Check(true);
115 
116  // The ID max for these submenus is ID_POPUP_SCH_SELECT_UNIT_CMP_MAX
117  // See eeschema_id to modify this value.
119  break; // We have used all IDs for these submenus
120  }
121  }
122 };
123 
124 
126  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveEdit" )
127 {
128  m_pickerItem = nullptr;
129 }
130 
131 
133 
135 {
137 
140 
141  wxASSERT_MSG( drawingTools, "eeshema.InteractiveDrawing tool is not available" );
142 
143  auto sheetTool =
144  [ this ] ( const SELECTION& aSel )
145  {
147  };
148 
149  auto anyTextTool =
150  [ this ] ( const SELECTION& aSel )
151  {
156  };
157 
158  auto duplicateCondition =
159  [] ( const SELECTION& aSel )
160  {
162  return false;
163 
164  return true;
165  };
166 
167  auto orientCondition =
168  [] ( const SELECTION& aSel )
169  {
170  if( aSel.Empty() )
171  return false;
172 
174  return false;
175 
176  SCH_ITEM* item = (SCH_ITEM*) aSel.Front();
177 
178  if( aSel.GetSize() > 1 )
179  return true;
180 
181  switch( item->Type() )
182  {
183  case SCH_MARKER_T:
184  case SCH_JUNCTION_T:
185  case SCH_NO_CONNECT_T:
186  case SCH_LINE_T:
187  case SCH_PIN_T:
188  return false;
189  default:
190  return true;
191  }
192  };
193 
194  auto propertiesCondition =
195  []( const SELECTION& aSel )
196  {
197  if( aSel.GetSize() == 0 )
198  return true; // Show worksheet properties
199 
200  SCH_ITEM* firstItem = dynamic_cast<SCH_ITEM*>( aSel.Front() );
201 
202  wxCHECK( firstItem, false );
203 
204  const EE_SELECTION* eeSelection = dynamic_cast<const EE_SELECTION*>( &aSel );
205 
206  wxCHECK( eeSelection, false );
207 
208  if( aSel.GetSize() != 1
209  && !( aSel.GetSize() >= 1
210  && ( firstItem->Type() == SCH_LINE_T
211  || firstItem->Type() == SCH_BUS_WIRE_ENTRY_T )
212  && eeSelection->AllItemsHaveLineStroke() ) )
213  return false;
214 
215  if( aSel.GetSize() != 1
216  && !( aSel.GetSize() >= 1
217  && ( firstItem->Type() == SCH_JUNCTION_T )
218  && eeSelection->AreAllItemsIdentical() ) )
219  return false;
220 
221  switch( firstItem->Type() )
222  {
223  case SCH_COMPONENT_T:
224  case SCH_SHEET_T:
225  case SCH_SHEET_PIN_T:
226  case SCH_TEXT_T:
227  case SCH_LABEL_T:
228  case SCH_GLOBAL_LABEL_T:
229  case SCH_HIER_LABEL_T:
230  case SCH_FIELD_T:
231  case SCH_BITMAP_T:
232  return aSel.GetSize() == 1;
233 
234  case SCH_LINE_T:
236  for( EDA_ITEM* item : aSel.GetItems() )
237  {
238  SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( item );
239 
240  if( !schItem || !schItem->HasLineStroke() )
241  return false;
242  }
243 
244  return true;
245 
246  case SCH_JUNCTION_T:
247  return true;
248 
249  default:
250  return false;
251  }
252  };
253 
254  static KICAD_T toLabelTypes[] = { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
255  auto toLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toLabelTypes );
256 
257  static KICAD_T toHLableTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_TEXT_T, EOT };
258  auto toHLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toHLableTypes );
259 
260  static KICAD_T toGLableTypes[] = { SCH_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
261  auto toGLabelCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toGLableTypes );
262 
263  static KICAD_T toTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EOT };
264  auto toTextlCondition = E_C::Count( 1 ) && E_C::OnlyTypes( toTextTypes );
265 
266  static KICAD_T entryTypes[] = { SCH_BUS_WIRE_ENTRY_T, SCH_BUS_BUS_ENTRY_T, EOT };
267  auto entryCondition = E_C::MoreThan( 0 ) && E_C::OnlyTypes( entryTypes );
268 
269  auto singleComponentCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_COMPONENT_T );
270  auto wireSelectionCondition = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_WIRE_T );
271  auto busSelectionCondition = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_BUS_T );
272  auto singleSheetCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
273  auto symbolsOnlyCondition = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_COMPONENT_T );
274  //
275  // Add edit actions to the move tool menu
276  //
277  if( moveTool )
278  {
279  CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
280 
281  moveMenu.AddSeparator();
282  moveMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition );
283  moveMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition );
284  moveMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition );
285  moveMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition );
287 
288  moveMenu.AddItem( EE_ACTIONS::properties, propertiesCondition );
289  moveMenu.AddItem( EE_ACTIONS::editReference, singleComponentCondition );
290  moveMenu.AddItem( EE_ACTIONS::editValue, singleComponentCondition );
291  moveMenu.AddItem( EE_ACTIONS::editFootprint, singleComponentCondition );
293 
294  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu = std::make_shared<SYMBOL_UNIT_MENU>();
295  symUnitMenu->SetTool( this );
296  m_menu.AddSubMenu( symUnitMenu );
297  moveMenu.AddMenu( symUnitMenu.get(), E_C::SingleMultiUnitSymbol, 1 );
298 
299  moveMenu.AddSeparator();
302  moveMenu.AddItem( ACTIONS::duplicate, duplicateCondition );
303  }
304 
305  //
306  // Add editing actions to the drawing tool menu
307  //
308  CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
309 
310  drawMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
311  drawMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
312  drawMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition, 200 );
313  drawMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition, 200 );
314 
315  drawMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
316  drawMenu.AddItem( EE_ACTIONS::editReference, singleComponentCondition, 200 );
317  drawMenu.AddItem( EE_ACTIONS::editValue, singleComponentCondition, 200 );
318  drawMenu.AddItem( EE_ACTIONS::editFootprint, singleComponentCondition, 200 );
319  drawMenu.AddItem( EE_ACTIONS::autoplaceFields, singleComponentCondition, 200 );
321 
322  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu2 = std::make_shared<SYMBOL_UNIT_MENU>();
323  symUnitMenu2->SetTool( drawingTools );
324  drawingTools->GetToolMenu().AddSubMenu( symUnitMenu2 );
325  drawMenu.AddMenu( symUnitMenu2.get(), E_C::SingleMultiUnitSymbol, 1 );
326 
327  drawMenu.AddItem( EE_ACTIONS::editWithLibEdit, singleComponentCondition && E_C::Idle, 200 );
328 
329  drawMenu.AddItem( EE_ACTIONS::toLabel, anyTextTool && E_C::Idle, 200 );
330  drawMenu.AddItem( EE_ACTIONS::toHLabel, anyTextTool && E_C::Idle, 200 );
331  drawMenu.AddItem( EE_ACTIONS::toGLabel, anyTextTool && E_C::Idle, 200 );
332  drawMenu.AddItem( EE_ACTIONS::toText, anyTextTool && E_C::Idle, 200 );
333  drawMenu.AddItem( EE_ACTIONS::cleanupSheetPins, sheetTool && E_C::Idle, 250 );
334 
335  //
336  // Add editing actions to the selection tool menu
337  //
339 
340  selToolMenu.AddItem( EE_ACTIONS::rotateCCW, orientCondition, 200 );
341  selToolMenu.AddItem( EE_ACTIONS::rotateCW, orientCondition, 200 );
342  selToolMenu.AddItem( EE_ACTIONS::mirrorX, orientCondition, 200 );
343  selToolMenu.AddItem( EE_ACTIONS::mirrorY, orientCondition, 200 );
344  selToolMenu.AddItem( ACTIONS::doDelete, E_C::NotEmpty, 200 );
345 
346  selToolMenu.AddItem( EE_ACTIONS::properties, propertiesCondition, 200 );
348  selToolMenu.AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 );
350  selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, singleComponentCondition, 200 );
352  selToolMenu.AddItem( EE_ACTIONS::refreshSymbolFromLibrary, symbolsOnlyCondition, 200 );
353 
354  std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu3 = std::make_shared<SYMBOL_UNIT_MENU>();
355  symUnitMenu3->SetTool( m_selectionTool );
356  m_selectionTool->GetToolMenu().AddSubMenu( symUnitMenu3 );
357  selToolMenu.AddMenu( symUnitMenu3.get(), E_C::SingleMultiUnitSymbol, 1 );
358 
359  selToolMenu.AddItem( EE_ACTIONS::editWithLibEdit, singleComponentCondition && E_C::Idle, 200 );
360 
361  selToolMenu.AddItem( EE_ACTIONS::toLabel, toLabelCondition, 200 );
362  selToolMenu.AddItem( EE_ACTIONS::toHLabel, toHLabelCondition, 200 );
363  selToolMenu.AddItem( EE_ACTIONS::toGLabel, toGLabelCondition, 200 );
364  selToolMenu.AddItem( EE_ACTIONS::toText, toTextlCondition, 200 );
365  selToolMenu.AddItem( EE_ACTIONS::cleanupSheetPins, singleSheetCondition, 250 );
366 
367  selToolMenu.AddSeparator( 300 );
368  selToolMenu.AddItem( ACTIONS::cut, E_C::IdleSelection, 300 );
369  selToolMenu.AddItem( ACTIONS::copy, E_C::IdleSelection, 300 );
370  selToolMenu.AddItem( ACTIONS::paste, E_C::Idle, 300 );
371  selToolMenu.AddItem( ACTIONS::pasteSpecial, E_C::Idle, 300 );
372  selToolMenu.AddItem( ACTIONS::duplicate, duplicateCondition, 300 );
373 
374  return true;
375 }
376 
377 
379  SCH_TEXT_T,
380  SCH_LABEL_T,
383  SCH_FIELD_T,
386  SCH_SHEET_T,
387  SCH_BITMAP_T,
390  SCH_LINE_T,
393  EOT
394 };
395 
396 
397 int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
398 {
400 
401  if( selection.GetSize() == 0 )
402  return 0;
403 
404  wxPoint rotPoint;
405  bool clockwise = ( aEvent.Matches( EE_ACTIONS::rotateCW.MakeEvent() ) );
406  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
407  bool connections = false;
408  bool moving = item->IsMoving();
409 
410  if( selection.GetSize() == 1 )
411  {
412  if( !moving )
414 
415  switch( item->Type() )
416  {
417  case SCH_COMPONENT_T:
418  {
419  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
420 
421  if( clockwise )
422  component->SetOrientation( CMP_ROTATE_CLOCKWISE );
423  else
425 
427  component->AutoAutoplaceFields( m_frame->GetScreen() );
428 
429  break;
430  }
431 
432  case SCH_TEXT_T:
433  case SCH_LABEL_T:
434  case SCH_GLOBAL_LABEL_T:
435  case SCH_HIER_LABEL_T:
436  {
437  SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
438 
439  if( clockwise )
440  textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().RotateCW() );
441  else
442  textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().RotateCCW() );
443 
444  break;
445  }
446 
447  case SCH_SHEET_PIN_T:
448  {
449  // Rotate pin within parent sheet
450  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
451  SCH_SHEET* sheet = pin->GetParent();
452  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
453  {
454  pin->Rotate( sheet->GetBoundingBox().GetCenter() );
455  }
456  break;
457  }
458 
459  case SCH_BUS_BUS_ENTRY_T:
461  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
462  {
463  item->Rotate( item->GetPosition() );
464  }
465  break;
466 
467  case SCH_FIELD_T:
468  {
469  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
470 
471  if( field->GetTextAngle() == TEXT_ANGLE_HORIZ )
472  field->SetTextAngle( TEXT_ANGLE_VERT );
473  else
474  field->SetTextAngle( TEXT_ANGLE_HORIZ );
475 
476  // Now that we're moving a field, they're no longer autoplaced.
477  static_cast<SCH_ITEM*>( item->GetParent() )->ClearFieldsAutoplaced();
478 
479  break;
480  }
481 
482  case SCH_BITMAP_T:
483  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
484  {
485  item->Rotate( item->GetPosition() );
486  }
487  // The bitmap is cached in Opengl: clear the cache to redraw
489  break;
490 
491  case SCH_SHEET_T:
492  {
493  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
494 
495  // Rotate the sheet on itself. Sheets do not have an anchor point.
496  for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
497  {
498  rotPoint = m_frame->GetNearestGridPosition( sheet->GetRotationCenter() );
499  sheet->Rotate( rotPoint );
500  }
501  break;
502  }
503 
504  default:
505  break;
506  }
507 
508  connections = item->IsConnectable();
509  m_frame->RefreshItem( item );
510  }
511  else if( selection.GetSize() > 1 )
512  {
513  rotPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() );
514 
515  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
516  {
517  item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
518 
519  if( !moving )
520  saveCopyInUndoList( item, UR_CHANGED, ii > 0 );
521 
522  for( int i = 0; clockwise ? i < 1 : i < 3; ++i )
523  {
524  if( item->Type() == SCH_LINE_T )
525  {
526  SCH_LINE* line = (SCH_LINE*) item;
527 
528  if( item->HasFlag( STARTPOINT ) )
529  line->RotateStart( rotPoint );
530 
531  if( item->HasFlag( ENDPOINT ) )
532  line->RotateEnd( rotPoint );
533  }
534  else if( item->Type() == SCH_SHEET_PIN_T )
535  {
536  if( item->GetParent()->IsSelected() )
537  {
538  // parent will rotate us
539  }
540  else
541  {
542  // rotate within parent
543  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
544  SCH_SHEET* sheet = pin->GetParent();
545 
546  pin->Rotate( sheet->GetBoundingBox().GetCenter() );
547  }
548  }
549  else
550  {
551  item->Rotate( rotPoint );
552  }
553  }
554 
555  connections |= item->IsConnectable();
556  m_frame->RefreshItem( item );
557  }
558  }
559 
561 
562  if( item->IsMoving() )
563  {
565  }
566  else
567  {
568  if( selection.IsHover() )
570 
571  if( connections )
573 
574  m_frame->OnModify();
575  }
576 
577  return 0;
578 }
579 
580 
581 int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
582 {
584 
585  if( selection.GetSize() == 0 )
586  return 0;
587 
588  wxPoint mirrorPoint;
589  bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorX.MakeEvent() ) );
590  SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.Front() );
591  bool connections = false;
592  bool moving = item->IsMoving();
593 
594  if( selection.GetSize() == 1 )
595  {
596  if( !moving )
598 
599  switch( item->Type() )
600  {
601  case SCH_COMPONENT_T:
602  {
603  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
604 
605  if( xAxis )
606  component->SetOrientation( CMP_MIRROR_X );
607  else
608  component->SetOrientation( CMP_MIRROR_Y );
609 
611  component->AutoAutoplaceFields( m_frame->GetScreen() );
612 
613  break;
614  }
615 
616  case SCH_TEXT_T:
617  case SCH_LABEL_T:
618  case SCH_GLOBAL_LABEL_T:
619  case SCH_HIER_LABEL_T:
620  {
621  SCH_TEXT* textItem = static_cast<SCH_TEXT*>( item );
622 
623  if( xAxis )
624  textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().MirrorX() );
625  else
626  textItem->SetLabelSpinStyle( textItem->GetLabelSpinStyle().MirrorY() );
627  break;
628  }
629 
630  case SCH_SHEET_PIN_T:
631  {
632  // mirror within parent sheet
633  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
634  SCH_SHEET* sheet = pin->GetParent();
635 
636  if( xAxis )
637  pin->MirrorX( sheet->GetBoundingBox().GetCenter().y );
638  else
639  pin->MirrorY( sheet->GetBoundingBox().GetCenter().x );
640 
641  break;
642  }
643 
644  case SCH_BUS_BUS_ENTRY_T:
646  if( xAxis )
647  item->MirrorX( item->GetPosition().y );
648  else
649  item->MirrorY( item->GetPosition().x );
650  break;
651 
652  case SCH_FIELD_T:
653  {
654  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
655 
656  if( xAxis )
658  else
660 
661  // Now that we're re-justifying a field, they're no longer autoplaced.
662  static_cast<SCH_ITEM*>( item->GetParent() )->ClearFieldsAutoplaced();
663 
664  break;
665  }
666 
667  case SCH_BITMAP_T:
668  if( xAxis )
669  item->MirrorX( item->GetPosition().y );
670  else
671  item->MirrorY( item->GetPosition().x );
672 
673  // The bitmap is cached in Opengl: clear the cache to redraw
675  break;
676 
677  case SCH_SHEET_T:
678  // Mirror the sheet on itself. Sheets do not have a anchor point.
679  mirrorPoint = m_frame->GetNearestGridPosition( item->GetBoundingBox().Centre() );
680 
681  if( xAxis )
682  item->MirrorX( mirrorPoint.y );
683  else
684  item->MirrorY( mirrorPoint.x );
685 
686  break;
687 
688  default:
689  break;
690  }
691 
692  connections = item->IsConnectable();
693  m_frame->RefreshItem( item );
694  }
695  else if( selection.GetSize() > 1 )
696  {
697  mirrorPoint = m_frame->GetNearestGridPosition( (wxPoint)selection.GetCenter() );
698 
699  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
700  {
701  item = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
702 
703  if( !moving )
704  saveCopyInUndoList( item, UR_CHANGED, ii > 0 );
705 
706  if( item->Type() == SCH_SHEET_PIN_T )
707  {
708  if( item->GetParent()->IsSelected() )
709  {
710  // parent will mirror us
711  }
712  else
713  {
714  // mirror within parent sheet
715  SCH_SHEET_PIN* pin = static_cast<SCH_SHEET_PIN*>( item );
716  SCH_SHEET* sheet = pin->GetParent();
717 
718  if( xAxis )
719  pin->MirrorX( sheet->GetBoundingBox().GetCenter().y );
720  else
721  pin->MirrorY( sheet->GetBoundingBox().GetCenter().x );
722  }
723  }
724  else
725  {
726  if( xAxis )
727  item->MirrorX( mirrorPoint.y );
728  else
729  item->MirrorY( mirrorPoint.x );
730  }
731 
732  connections |= item->IsConnectable();
733  m_frame->RefreshItem( item );
734  }
735  }
736 
738 
739  if( item->IsMoving() )
740  {
742  }
743  else
744  {
745  if( selection.IsHover() )
747 
748  if( connections )
750 
751  m_frame->OnModify();
752  }
753 
754  return 0;
755 }
756 
757 
759 {
761  SCH_LINE_T,
764  SCH_TEXT_T,
765  SCH_LABEL_T,
769  SCH_SHEET_T,
771  EOT
772 };
773 
774 
776 {
778 
779  if( selection.GetSize() == 0 )
780  return 0;
781 
782  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
783  // up dragging around a stack of objects...
784  if( selection.Front()->IsNew() )
785  return 0;
786 
787  EDA_ITEMS newItems;
788 
789  // Keep track of existing sheet paths. Duplicating a selection can modify this list
790  bool copiedSheets = false;
791  SCH_SHEET_LIST initial_sheetpathList = m_frame->Schematic().GetSheets();
792 
793  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
794  {
795  SCH_ITEM* oldItem = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
796  SCH_ITEM* newItem = oldItem->Duplicate();
797  newItem->SetFlags( IS_NEW );
798  newItems.push_back( newItem );
799  saveCopyInUndoList( newItem, UR_NEW, ii > 0 );
800 
801  switch( newItem->Type() )
802  {
803  case SCH_JUNCTION_T:
804  case SCH_LINE_T:
805  case SCH_BUS_BUS_ENTRY_T:
807  case SCH_TEXT_T:
808  case SCH_LABEL_T:
809  case SCH_GLOBAL_LABEL_T:
810  case SCH_HIER_LABEL_T:
811  case SCH_NO_CONNECT_T:
812  newItem->SetParent( m_frame->GetScreen() );
813  m_frame->AddToScreen( newItem );
814  break;
815 
816  case SCH_SHEET_T:
817  {
818  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
819  SCH_SHEET* sheet = (SCH_SHEET*) newItem;
820  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
821  wxString baseName = nameField.GetText();
822  wxString candidateName = baseName;
823  int uniquifier = 1;
824 
825  while( hierarchy.NameExists( candidateName ) )
826  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
827 
828  nameField.SetText( candidateName );
829 
830  sheet->SetParent( m_frame->GetCurrentSheet().Last() );
831  m_frame->AddToScreen( sheet );
832 
833  copiedSheets = true;
834  break;
835  }
836 
837  case SCH_COMPONENT_T:
838  {
839  SCH_COMPONENT* component = (SCH_COMPONENT*) newItem;
840  component->ClearAnnotation( NULL );
841  component->SetParent( m_frame->GetScreen() );
842  m_frame->AddToScreen( component );
843  break;
844  }
845 
846  default:
847  break;
848  }
849  }
850 
851  if( copiedSheets )
852  {
853  // We clear annotation of new sheet paths.
854  // Annotation of new components added in current sheet is already cleared.
855  SCH_SCREENS screensList( &m_frame->Schematic().Root() );
856  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
858  }
859 
861  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
863 
864  return 0;
865 }
866 
867 
869 {
870  SCH_ITEM* sourceItem = m_frame->GetRepeatItem();
871 
872  if( !sourceItem )
873  return 0;
874 
876 
877  SCH_ITEM* newItem = sourceItem->Duplicate();
878  bool performDrag = false;
879 
880  // If cloning a component then put into 'move' mode.
881  if( newItem->Type() == SCH_COMPONENT_T )
882  {
883  wxPoint cursorPos = (wxPoint) getViewControls()->GetCursorPosition( true );
884  newItem->Move( cursorPos - newItem->GetPosition() );
885  performDrag = true;
886  }
887  else
888  {
889  if( m_isLibEdit )
890  {
891  LIBEDIT_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
892 
893  if( dynamic_cast<SCH_TEXT*>( newItem ) )
894  {
895  SCH_TEXT* text = static_cast<SCH_TEXT*>( newItem );
896  text->IncrementLabel( cfg->m_Repeat.label_delta );
897  }
898 
899  newItem->Move( wxPoint( Mils2iu( cfg->m_Repeat.x_step ),
900  Mils2iu( cfg->m_Repeat.y_step ) ) );
901  }
902  else
903  {
904  EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
905 
906  if( dynamic_cast<SCH_TEXT*>( newItem ) )
907  {
908  SCH_TEXT* text = static_cast<SCH_TEXT*>( newItem );
910  }
911 
912  newItem->Move( wxPoint( Mils2iu( cfg->m_Drawing.default_repeat_offset_x ),
913  Mils2iu( cfg->m_Drawing.default_repeat_offset_y ) ) );
914  }
915 
916  }
917 
918  newItem->SetFlags( IS_NEW );
919  m_frame->AddToScreen( newItem );
920  m_frame->SaveCopyInUndoList( newItem, UR_NEW );
921 
922  m_selectionTool->AddItemToSel( newItem );
923 
924  if( performDrag )
926 
927  newItem->ClearFlags();
928 
929  if( newItem->IsConnectable() )
930  {
931  auto selection = m_selectionTool->GetSelection();
932 
933  m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selection );
936  }
937 
938  // newItem newItem, now that it has been moved, thus saving new position.
939  m_frame->SaveCopyForRepeatItem( newItem );
940 
941  return 0;
942 }
943 
944 
946 {
947  SCH_MARKER_T,
949  SCH_LINE_T,
952  SCH_TEXT_T,
953  SCH_LABEL_T,
957  SCH_SHEET_T,
960  SCH_BITMAP_T,
961  EOT
962 };
963 
964 
966 {
967  SCH_SCREEN* screen = m_frame->GetScreen();
969  bool appendToUndo = false;
970  std::vector<wxPoint> pts;
971 
972  if( items.empty() )
973  return 0;
974 
975  // Don't leave a freed pointer in the selection
977 
978  for( EDA_ITEM* item : items )
979  item->ClearFlags( STRUCT_DELETED );
980 
981  for( EDA_ITEM* item : items )
982  {
983  SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
984 
985  if( !sch_item )
986  continue;
987 
988  if( sch_item->Type() == SCH_JUNCTION_T )
989  {
990  sch_item->SetFlags( STRUCT_DELETED );
991  sch_item->GetConnectionPoints( pts );
992 
993  // clean up junctions at the end
994  }
995  else
996  {
997  sch_item->SetFlags( STRUCT_DELETED );
998  saveCopyInUndoList( item, UR_DELETED, appendToUndo );
999  appendToUndo = true;
1000 
1001  if( sch_item && sch_item->IsConnectable() )
1002  sch_item->GetConnectionPoints( pts );
1003 
1004  updateView( sch_item );
1005 
1006  if( sch_item->Type() == SCH_SHEET_PIN_T )
1007  {
1008  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) sch_item;
1009  SCH_SHEET* sheet = pin->GetParent();
1010 
1011  sheet->RemovePin( pin );
1012  }
1013  else
1014  m_frame->RemoveFromScreen( sch_item );
1015 
1016  if( sch_item->Type() == SCH_SHEET_T )
1018  }
1019  }
1020 
1021  for( auto point : pts )
1022  {
1023  SCH_ITEM* junction = screen->GetItem( point, 0, SCH_JUNCTION_T );
1024 
1025  if( !junction )
1026  continue;
1027 
1028  if( junction->HasFlag( STRUCT_DELETED ) || !screen->IsJunctionNeeded( point ) )
1029  m_frame->DeleteJunction( junction, appendToUndo );
1030  }
1031 
1033 
1034  m_frame->GetCanvas()->Refresh();
1035  m_frame->OnModify();
1036 
1037  return 0;
1038 }
1039 
1040 
1041 #define HITTEST_THRESHOLD_PIXELS 5
1042 
1043 
1045 {
1046  std::string tool = aEvent.GetCommandStr().get();
1047  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1048 
1050  m_pickerItem = nullptr;
1051 
1052  // Deactivate other tools; particularly important if another PICKER is currently running
1053  Activate();
1054 
1055  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
1056 
1057  picker->SetClickHandler(
1058  [this] ( const VECTOR2D& aPosition ) -> bool
1059  {
1060  if( m_pickerItem )
1061  {
1062  SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( m_pickerItem );
1063 
1064  if( sch_item && sch_item->IsLocked() )
1065  {
1066  STATUS_TEXT_POPUP statusPopup( m_frame );
1067  statusPopup.SetText( _( "Item locked." ) );
1068  statusPopup.PopupFor( 2000 );
1069  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1070  return true;
1071  }
1072 
1074  selectionTool->UnbrightenItem( m_pickerItem );
1075  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
1077  m_pickerItem = nullptr;
1078  }
1079 
1080  return true;
1081  } );
1082 
1083  picker->SetMotionHandler(
1084  [this] ( const VECTOR2D& aPos )
1085  {
1086  EE_COLLECTOR collector;
1087  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
1088  collector.Collect( m_frame->GetScreen(), deletableItems, (wxPoint) aPos );
1089 
1091  selectionTool->GuessSelectionCandidates( collector, aPos );
1092 
1093  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
1094 
1095  if( m_pickerItem != item )
1096  {
1097  if( m_pickerItem )
1098  selectionTool->UnbrightenItem( m_pickerItem );
1099 
1100  m_pickerItem = item;
1101 
1102  if( m_pickerItem )
1103  selectionTool->BrightenItem( m_pickerItem );
1104  }
1105  } );
1106 
1107  picker->SetFinalizeHandler(
1108  [this] ( const int& aFinalState )
1109  {
1110  if( m_pickerItem )
1112  } );
1113 
1114  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1115 
1116  return 0;
1117 }
1118 
1119 
1121 {
1122  // Save old component in undo list if not already in edit, or moving.
1123  if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
1125 
1126  wxString title = wxString::Format( _( "Edit %s Field" ), aField->GetName() );
1127 
1128  DIALOG_SCH_EDIT_ONE_FIELD dlg( m_frame, title, aField );
1129 
1130  // The footprint field dialog can invoke a KIWAY_PLAYER so we must use a quasi-modal
1131  if( dlg.ShowQuasiModal() != wxID_OK )
1132  return;
1133 
1134  dlg.UpdateField( aField, &m_frame->GetCurrentSheet() );
1135 
1136  if( m_frame->eeconfig()->m_AutoplaceFields.enable || aField->GetParent()->Type() == SCH_SHEET_T )
1137  static_cast<SCH_ITEM*>( aField->GetParent() )->AutoAutoplaceFields( m_frame->GetScreen() );
1138 
1140  m_frame->RefreshItem( aField );
1141  m_frame->OnModify();
1142 }
1143 
1144 
1146 {
1147  static KICAD_T Nothing[] = { EOT };
1148  static KICAD_T CmpOrReference[] = { SCH_FIELD_LOCATE_REFERENCE_T, SCH_COMPONENT_T, EOT };
1149  static KICAD_T CmpOrValue[] = { SCH_FIELD_LOCATE_VALUE_T, SCH_COMPONENT_T, EOT };
1150  static KICAD_T CmpOrFootprint[] = { SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_COMPONENT_T, EOT };
1151 
1152  KICAD_T* filter = Nothing;
1153 
1154  if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1155  filter = CmpOrReference;
1156  else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1157  filter = CmpOrValue;
1158  else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1159  filter = CmpOrFootprint;
1160 
1161  EE_SELECTION& selection = m_selectionTool->RequestSelection( filter );
1162 
1163  if( selection.Empty() )
1164  return 0;
1165 
1166  SCH_ITEM* item = (SCH_ITEM*) selection.Front();
1167 
1168  if( item->Type() == SCH_COMPONENT_T )
1169  {
1170  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1171 
1172  if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
1173  editFieldText( component->GetField( REFERENCE ) );
1174  else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
1175  editFieldText( component->GetField( VALUE ) );
1176  else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
1177  editFieldText( component->GetField( FOOTPRINT ) );
1178  }
1179  else if( item->Type() == SCH_FIELD_T )
1180  {
1181  editFieldText( (SCH_FIELD*) item );
1182  }
1183 
1184  if( selection.IsHover() )
1186 
1187  return 0;
1188 }
1189 
1190 
1192 {
1194 
1195  if( selection.Empty() )
1196  return 0;
1197 
1198  SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front();
1199 
1200  if( !component->IsNew() )
1201  m_frame->SaveCopyInUndoList( component, UR_CHANGED );
1202 
1203  component->AutoplaceFields( m_frame->GetScreen(), /* aManual */ true );
1204 
1205  m_frame->GetScreen()->Update( component );
1206  updateView( component );
1207  m_frame->OnModify();
1208 
1209  if( selection.IsHover() )
1211 
1212  return 0;
1213 }
1214 
1215 
1217 {
1218  std::list<SCH_COMPONENT*> components;
1219 
1220  for( auto item : m_frame->GetScreen()->Items().OfType( SCH_COMPONENT_T ) )
1221  components.push_back( static_cast<SCH_COMPONENT*>( item ) );
1222 
1223  if( InvokeDialogUpdateFields( m_frame, components, true ) == wxID_OK )
1224  m_frame->GetCanvas()->Refresh();
1225 
1226  return 0;
1227 }
1228 
1229 
1231 {
1233 
1234  if( selection.Empty() )
1235  return 0;
1236 
1237  SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front();
1238 
1240  && component->GetConvert() == LIB_ITEM::LIB_CONVERT::BASE )
1241  return 0;
1242 
1244  && component->GetConvert() != LIB_ITEM::LIB_CONVERT::DEMORGAN )
1245  return 0;
1246 
1247  if( !component->IsNew() )
1248  m_frame->SaveCopyInUndoList( component, UR_CHANGED );
1249 
1250  m_frame->ConvertPart( component );
1251 
1252  if( component->IsNew() )
1254 
1255  if( selection.IsHover() )
1257 
1258  return 0;
1259 }
1260 
1261 
1263 {
1264  wxString msg;
1265  bool appendToUndo = false;
1267 
1268  if( selection.Empty() )
1269  return 0;
1270 
1271  WX_INFOBAR* infoBar = m_frame->GetInfoBar();
1272 
1273  wxCHECK( infoBar, 0 );
1274 
1275  INFOBAR_REPORTER reporter( infoBar );
1276 
1277  SCH_SCREEN* currentScreen = m_frame->GetScreen();
1278 
1279  wxCHECK( currentScreen, 0 );
1280 
1281  for( auto item : selection )
1282  {
1283  SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( item );
1284 
1285  wxCHECK( symbol, 0 );
1286 
1287  // This needs to be done before the LIB_ID is changed to prevent stale library symbols in
1288  // the schematic file.
1289  currentScreen->Remove( symbol );
1290 
1291  if( !symbol->IsNew() )
1292  {
1293  m_frame->SaveCopyInUndoList( symbol, UR_CHANGED, appendToUndo );
1294  appendToUndo = true;
1295  }
1296 
1297  LIB_ID id = symbol->GetLibId();
1298 
1299  if( !id.IsValid() )
1300  {
1301  msg.Printf( _( "'%s' is not a valid library indentifier." ),
1302  id.GetUniStringLibId() );
1303  reporter.Report( msg, RPT_SEVERITY_WARNING );
1304  continue;
1305  }
1306 
1307  LIB_PART* libSymbol = m_frame->Prj().SchSymbolLibTable()->LoadSymbol( id );
1308 
1309  if( !libSymbol )
1310  {
1311  msg.Printf( _( "Symbol '%s' not found in symbol library '%s'." ),
1312  id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
1313  reporter.Report( msg, RPT_SEVERITY_WARNING );
1314  continue;
1315  }
1316 
1317  symbol->SetLibSymbol( libSymbol->Flatten().release() );
1318  currentScreen->Append( symbol );
1320  updateView( symbol );
1321  }
1322 
1323  if( selection.IsHover() )
1325 
1326  if( reporter.HasMessage() )
1327  reporter.Finalize();
1328 
1329  m_frame->GetCanvas()->Refresh();
1330  m_frame->OnModify();
1331 
1332  return 0;
1333 }
1334 
1335 
1337 {
1339 
1340  if( selection.Empty() )
1341  {
1343  {
1345  VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
1346 
1347  if( worksheet && worksheet->HitTestWorksheetItems( getView(), (wxPoint) cursorPos ) )
1349  }
1350 
1351  return 0;
1352  }
1353 
1354  SCH_ITEM* item = (SCH_ITEM*) selection.Front();
1355 
1356  switch( item->Type() )
1357  {
1358  case SCH_LINE_T:
1359  case SCH_BUS_WIRE_ENTRY_T:
1360  if( !selection.AllItemsHaveLineStroke() )
1361  return 0;
1362 
1363  break;
1364 
1365  case SCH_JUNCTION_T:
1366  if( !selection.AreAllItemsIdentical() )
1367  return 0;
1368 
1369  break;
1370 
1371  default:
1372  if( selection.Size() > 1 )
1373  return 0;
1374 
1375  break;
1376  }
1377 
1378  switch( item->Type() )
1379  {
1380  case SCH_COMPONENT_T:
1381  {
1382  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1383  DIALOG_EDIT_COMPONENT_IN_SCHEMATIC dlg( m_frame, component );
1384 
1385  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
1386  // frame. Therefore this dialog as a modal frame parent, MUST be run under
1387  // quasimodal mode for the quasimodal frame support to work. So don't use
1388  // the QUASIMODAL macros here.
1389  if( dlg.ShowQuasiModal() == wxID_OK )
1390  {
1392  component->AutoAutoplaceFields( m_frame->GetScreen() );
1393 
1395  m_frame->OnModify();
1396  }
1397  }
1398  break;
1399 
1400  case SCH_SHEET_T:
1401  {
1402  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1403  bool doClearAnnotation;
1404  bool doRefresh = false;
1405  // Keep track of existing sheet paths. EditSheet() can modify this list
1406  SCH_SHEET_LIST initial_sheetpathList = m_frame->Schematic().GetSheets();
1407 
1408  doRefresh = m_frame->EditSheetProperties(
1409  sheet, &m_frame->GetCurrentSheet(), &doClearAnnotation );
1410 
1411  // If the sheet file is changed and new sheet contents are loaded then we have to
1412  // clear the annotations on the new content (as it may have been set from some other
1413  // sheet path reference)
1414  if( doClearAnnotation )
1415  {
1416  SCH_SCREENS screensList( &m_frame->Schematic().Root() );
1417  // We clear annotation of new sheet paths here:
1418  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
1419  // Clear annotation of g_CurrentSheet itself, because its sheetpath is not a new
1420  // path, but components managed by its sheet path must have their annotation
1421  // cleared, because they are new:
1423  }
1424 
1425  if( doRefresh )
1426  {
1428  m_frame->GetCanvas()->Refresh();
1430  }
1431 
1432  break;
1433  }
1434 
1435  case SCH_SHEET_PIN_T:
1436  {
1437  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) item;
1438  DIALOG_EDIT_SHEET_PIN dlg( m_frame, pin );
1439 
1440  if( dlg.ShowModal() == wxID_OK )
1441  {
1443  m_frame->OnModify();
1444  }
1445  }
1446  break;
1447 
1448  case SCH_TEXT_T:
1449  case SCH_LABEL_T:
1450  case SCH_GLOBAL_LABEL_T:
1451  case SCH_HIER_LABEL_T:
1452  {
1453  DIALOG_LABEL_EDITOR dlg( m_frame, (SCH_TEXT*) item );
1454 
1455  if( dlg.ShowModal() == wxID_OK )
1456  {
1458  m_frame->OnModify();
1459  }
1460  }
1461  break;
1462 
1463  case SCH_FIELD_T:
1464  editFieldText( (SCH_FIELD*) item );
1465  break;
1466 
1467  case SCH_BITMAP_T:
1468  {
1469  SCH_BITMAP* bitmap = (SCH_BITMAP*) item;
1470  DIALOG_IMAGE_EDITOR dlg( m_frame, bitmap->GetImage() );
1471 
1472  if( dlg.ShowModal() == wxID_OK )
1473  {
1474  // save old image in undo list if not already in edit
1475  if( bitmap->GetEditFlags() == 0 )
1477 
1478  dlg.TransferToImage( bitmap->GetImage() );
1479 
1480  // The bitmap is cached in Opengl: clear the cache in case it has become invalid
1481  getView()->RecacheAllItems();
1483  m_frame->OnModify();
1484  }
1485  }
1486  break;
1487 
1488  case SCH_LINE_T:
1489  case SCH_BUS_WIRE_ENTRY_T:
1490  {
1491  std::deque<SCH_ITEM*> strokeItems;
1492 
1493  for( auto selItem : selection.Items() )
1494  {
1495  SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( selItem );
1496 
1497  if( schItem && schItem->HasLineStroke() )
1498  strokeItems.push_back( schItem );
1499  else
1500  return 0;
1501  }
1502 
1503  DIALOG_EDIT_LINE_STYLE dlg( m_frame, strokeItems );
1504 
1505  if( dlg.ShowModal() == wxID_OK )
1506  {
1508  m_frame->OnModify();
1509  }
1510  }
1511  break;
1512 
1513  case SCH_JUNCTION_T:
1514  {
1515  std::deque<SCH_JUNCTION*> junctions;
1516 
1517  for( auto selItem : selection.Items() )
1518  {
1519  SCH_JUNCTION* junction = dynamic_cast<SCH_JUNCTION*>( selItem );
1520 
1521  wxCHECK( junction, 0 );
1522 
1523  junctions.push_back( junction );
1524  }
1525 
1526  DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
1527 
1528  if( dlg.ShowModal() == wxID_OK )
1529  {
1531  m_frame->OnModify();
1532  }
1533  }
1534  break;
1535 
1536  case SCH_MARKER_T: // These items have no properties to edit
1537  case SCH_NO_CONNECT_T:
1538  break;
1539 
1540  default: // Unexpected item
1541  wxFAIL_MSG( wxString( "Cannot edit schematic item type " ) + item->GetClass() );
1542  }
1543 
1544  m_frame->GetScreen()->Update( item );
1545  updateView( item );
1546 
1547  if( selection.IsHover() )
1549 
1550  return 0;
1551 }
1552 
1553 
1555 {
1556  KICAD_T convertTo = aEvent.Parameter<KICAD_T>();
1558  EE_SELECTION& selection = m_selectionTool->RequestSelection( allTextTypes );
1559 
1560  for( unsigned int i = 0; i < selection.GetSize(); ++i )
1561  {
1562  SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( selection.GetItem( i ) );
1563 
1564  if( text && text->Type() != convertTo )
1565  {
1566  bool selected = text->IsSelected();
1567  SCH_TEXT* newtext = nullptr;
1568  const wxPoint& position = text->GetPosition();
1569  LABEL_SPIN_STYLE orientation = text->GetLabelSpinStyle();
1570  wxString txt = UnescapeString( text->GetText() );
1571 
1572  // There can be characters in a SCH_TEXT object that can break labels so we have to
1573  // fix them here.
1574  if( text->Type() == SCH_TEXT_T )
1575  {
1576  txt.Replace( "\n", "_" );
1577  txt.Replace( "\r", "_" );
1578  txt.Replace( "\t", "_" );
1579  txt.Replace( " ", "_" );
1580  }
1581 
1582  // label strings are "escaped" i.e. a '/' is replaced by "{slash}"
1583  if( convertTo != SCH_TEXT_T )
1584  txt = EscapeString( txt, CTX_NETNAME );
1585 
1586  switch( convertTo )
1587  {
1588  case SCH_LABEL_T: newtext = new SCH_LABEL( position, txt ); break;
1589  case SCH_GLOBAL_LABEL_T: newtext = new SCH_GLOBALLABEL( position, txt ); break;
1590  case SCH_HIER_LABEL_T: newtext = new SCH_HIERLABEL( position, txt ); break;
1591  case SCH_TEXT_T: newtext = new SCH_TEXT( position, txt ); break;
1592 
1593  default:
1594  wxFAIL_MSG( wxString::Format( "Invalid text type: %d.", convertTo ) );
1595  return 0;
1596  }
1597 
1598  // Copy the old text item settings to the new one. Justifications are not copied
1599  // because they are not used in labels. Justifications will be set to default value
1600  // in the new text item type.
1601  //
1602  newtext->SetFlags( text->GetEditFlags() );
1603  newtext->SetShape( text->GetShape() );
1604  newtext->SetLabelSpinStyle( orientation );
1605  newtext->SetTextSize( text->GetTextSize() );
1606  newtext->SetTextThickness( text->GetTextThickness() );
1607  newtext->SetItalic( text->IsItalic() );
1608  newtext->SetBold( text->IsBold() );
1609  newtext->SetIsDangling( text->IsDangling() );
1610 
1611  if( selected )
1613 
1614  if( !text->IsNew() )
1615  {
1617  m_frame->SaveCopyInUndoList( newtext, UR_NEW, true );
1618 
1619  m_frame->RemoveFromScreen( text );
1620  m_frame->AddToScreen( newtext );
1621  }
1622 
1623  if( selected )
1624  m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, newtext );
1625 
1626  // Otherwise, pointer is owned by the undo stack
1627  if( text->IsNew() )
1628  delete text;
1629 
1630  if( convertTo == SCH_TEXT_T )
1631  {
1632  if( newtext->IsDangling() )
1633  {
1634  newtext->SetIsDangling( false );
1635  getView()->Update( newtext, KIGFX::REPAINT );
1636  }
1637  }
1638  else
1640 
1641  m_frame->OnModify();
1642  }
1643  }
1644 
1645  if( selection.IsHover() )
1647 
1648  return 0;
1649 }
1650 
1651 
1653 {
1654  auto cursorPos = wxPoint( getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) ) );
1655 
1656  if( m_frame->BreakSegments( cursorPos ) )
1657  {
1658  if( m_frame->GetScreen()->IsJunctionNeeded( cursorPos, true ) )
1659  m_frame->AddJunction( cursorPos, true, false );
1660 
1662 
1663  m_frame->OnModify();
1664  m_frame->GetCanvas()->Refresh();
1665  }
1666 
1667  return 0;
1668 }
1669 
1670 
1672 {
1674  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1675 
1676  if( !sheet )
1677  return 0;
1678 
1679  if( !sheet->HasUndefinedPins() )
1680  {
1681  DisplayInfoMessage( m_frame, _( "There are no unreferenced pins in this sheet to remove." ) );
1682  return 0;
1683  }
1684 
1685  if( !IsOK( m_frame, _( "Do you wish to delete the unreferenced pins from this sheet?" ) ) )
1686  return 0;
1687 
1689 
1690  sheet->CleanupSheet();
1691 
1692  m_frame->GetScreen()->Update( sheet );
1693  updateView( sheet );
1694  m_frame->OnModify();
1695 
1696  if( selection.IsHover() )
1698 
1699  return 0;
1700 }
1701 
1702 
1704 {
1709  Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorX.MakeEvent() );
1710  Go( &SCH_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorY.MakeEvent() );
1711  Go( &SCH_EDIT_TOOL::DoDelete, ACTIONS::doDelete.MakeEvent() );
1713 
1729 
1732 
1735 }
const BITMAP_OPAQUE component_select_unit_xpm[1]
bool IsDangling() const override
Definition: sch_text.h:302
#define TEXT_ANGLE_HORIZ
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)
Function AddMenu()
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:182
static TOOL_ACTION refreshSymbolFromLibrary
Definition: ee_actions.h:154
static TOOL_ACTION properties
Definition: ee_actions.h:120
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:239
#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:245
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:370
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:47
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:199
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
std::deque< EDA_ITEM * > & Items()
Definition: selection.h:189
static TOOL_ACTION toggleDeMorgan
Definition: ee_actions.h:125
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:92
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:134
static TOOL_ACTION pageSettings
Definition: actions.h:59
static SELECTION_CONDITION SingleSymbol
static KICAD_T duplicatableItems[]
bool IsSelected() const
Definition: base_struct.h:203
#define TEXT_ANGLE_VERT
int RefreshSymbolFromLibrary(const TOOL_EVENT &aEvent)
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
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...
ACTION_MENU.
Definition: action_menu.h:44
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:74
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:372
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)
Function MoreThan Creates a functor that tests if the number of selected items is greater than the va...
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:450
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Function OnlyTypes Creates a functor that tests if the selected items are only of given types.
void RotateEnd(wxPoint aPosition)
Definition: sch_line.cpp:327
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:119
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:87
void SetItalic(bool isItalic)
Definition: eda_text.h:178
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1402
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
int BreakWire(const TOOL_EVENT &aEvent)
static SELECTION_CONDITION IdleSelection
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:379
TOOL_MENU & GetToolMenu()
double GetTextAngle() const
Definition: eda_text.h:173
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
EE_COLLECTOR.
Definition: ee_collectors.h:42
static TOOL_ACTION toText
Definition: ee_actions.h:132
static TOOL_ACTION autoplaceFields
Definition: ee_actions.h:124
WS_PROXY_VIEW_ITEM * GetWorksheet() const
Definition: sch_view.h:101
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
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:237
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 SELECTION_CONDITION Idle
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)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
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:303
int GetTextThickness() const
Definition: eda_text.h:158
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:127
static bool NotEmpty(const SELECTION &aSelection)
Function NotEmpty Tests if there are any items selected.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
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:207
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:321
static TOOL_ACTION breakWire
Definition: ee_actions.h:133
static TOOL_ACTION rotateCW
Definition: ee_actions.h:116
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
bool clockwise(const Point &p0, const Point &p1, const Point &p2)
Definition: delauney.h:217
static TOOL_ACTION removeItemFromSel
Definition: ee_actions.h:60
static TOOL_ACTION pickerTool
Definition: actions.h:149
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:179
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:181
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:117
int GetUnit() const
void BrightenItem(EDA_ITEM *aItem)
void RemovePin(SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:287
static TOOL_ACTION editFootprint
Definition: ee_actions.h:123
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:198
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:116
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:592
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
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:587
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:238
void SelectHighlightItem(EDA_ITEM *aItem)
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:202
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)
Function SetIcon() Assigns an icon for the entry.
Definition: action_menu.cpp:70
TOOL_EVENT.
Definition: tool_event.h:171
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
virtual bool HasLineStroke() const
Check if this schematic item has line stoke properties.
Definition: sch_item.h:465
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:115
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 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
SCH_JUNCTION * AddJunction(const wxPoint &aPos, bool aAppendToUndo=false, bool aFinal=true)
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:118
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:232
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:182
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear exiting component annotation.
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:454
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:1540
wxPoint GetPosition() const override
Definition: sch_text.h:313
LABEL_SPIN_STYLE MirrorY()
Definition: sch_text.h:127
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:727
int DeleteItemCursor(const TOOL_EVENT &aEvent)
Runs the deletion tool.
void UnbrightenItem(EDA_ITEM *aItem)
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:126
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
int InvokeDialogUpdateFields(SCH_EDIT_FRAME *aCaller, const list< SCH_COMPONENT * > aComponents, bool aCreateUndoEntry)
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:89
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)
Function AddSeparator()
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:54
EDA_ITEM * m_pickerItem
Definition: sch_edit_tool.h:89
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:262
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:146
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:352
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:68
static TOOL_ACTION editValue
Definition: ee_actions.h:122
static KICAD_T deletableItems[]
SCH_SHEET & Root() const
Definition: schematic.h:97
LABEL_SPIN_STYLE MirrorX()
Definition: sch_text.h:108
SCH_ITEM * GetRepeatItem() const
Return the item which is to be repeated with the insert key.
void updateView(EDA_ITEM *aItem) const
Similar to getView()->Update(), but handles items that are redrawn by their parents.
Definition: ee_tool_base.h:104
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the menu.
Definition: action_menu.cpp:88
LABEL_SPIN_STYLE RotateCW()
Definition: sch_text.h:73
see class PGM_BASE
int AddItemToSel(const TOOL_EVENT &aEvent)
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:133
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:201
#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:131
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:50
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:420
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)
Function OnlyType 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()
Function 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:88
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
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO_T aType, bool aAppend=false)
Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.
Definition: ee_tool_base.h:117
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
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:482
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:603
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:75
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:909
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:157
static TOOL_ACTION move
Definition: ee_actions.h:113
EE_TOOL_BASE.
Definition: ee_tool_base.h:50
SCH_ITEM * GetItem(const wxPoint &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T)
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:310
static TOOL_ACTION toLabel
Definition: ee_actions.h:129
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:157
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:238
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:166
static TOOL_ACTION toHLabel
Definition: ee_actions.h:130
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:121
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:230
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.
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:268
void SetBold(bool aBold)
Definition: eda_text.h:181
void ConvertPart(SCH_COMPONENT *aComponent)
Definition: getpart.cpp:235
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:187
static TOOL_ACTION toGLabel
Definition: ee_actions.h:131
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:126
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:286
static TOOL_ACTION duplicate
Definition: actions.h:73
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:546
static TOOL_ACTION refreshPreview
Definition: actions.h:102
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:237
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
#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:416
void IncrementLabel(int aIncrement)
Increment the label text, if it ends with a number.
Definition: sch_text.cpp:150
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.