KiCad PCB EDA Suite
symbol_editor_edit_tool.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2019 CERN
5  * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <tool/tool_manager.h>
26 #include <tool/picker_tool.h>
31 #include <ee_actions.h>
32 #include <bitmaps.h>
33 #include <confirm.h>
34 #include <symbol_edit_frame.h>
42 #include <lib_text.h>
44 #include <math/util.h> // for KiROUND
45 
46 
48  EE_TOOL_BASE( "eeschema.SymbolEditTool" ),
49  m_pickerItem( nullptr )
50 {
51 }
52 
53 
55 {
57 
60 
61  wxASSERT_MSG( drawingTools, "eeschema.SymbolDrawing tool is not available" );
62 
63  auto havePartCondition =
64  [&]( const SELECTION& sel )
65  {
66  return m_isSymbolEditor && static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurPart();
67  };
68 
69  auto canEdit =
70  [&]( const SELECTION& sel )
71  {
72  SYMBOL_EDIT_FRAME* editor = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
73  wxCHECK( editor, false );
74 
75  if( !editor->IsSymbolEditable() )
76  return false;
77 
78  if( editor->IsSymbolAlias() )
79  {
80  for( EDA_ITEM* item : sel )
81  {
82  if( item->Type() != LIB_FIELD_T )
83  return false;
84  }
85  }
86 
87  return true;
88  };
89 
90  // Add edit actions to the move tool menu
91  if( moveTool )
92  {
93  CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
94 
95  moveMenu.AddSeparator( 200 );
96  moveMenu.AddItem( EE_ACTIONS::rotateCCW, canEdit && EE_CONDITIONS::NotEmpty, 200 );
97  moveMenu.AddItem( EE_ACTIONS::rotateCW, canEdit && EE_CONDITIONS::NotEmpty, 200 );
98  moveMenu.AddItem( EE_ACTIONS::mirrorV, canEdit && EE_CONDITIONS::NotEmpty, 200 );
99  moveMenu.AddItem( EE_ACTIONS::mirrorH, canEdit && EE_CONDITIONS::NotEmpty, 200 );
100 
101  moveMenu.AddItem( EE_ACTIONS::properties, canEdit && EE_CONDITIONS::Count( 1 ), 200 );
102 
103  moveMenu.AddSeparator( 300 );
106  moveMenu.AddItem( ACTIONS::duplicate, canEdit && EE_CONDITIONS::NotEmpty, 300 );
107  moveMenu.AddItem( ACTIONS::doDelete, canEdit && EE_CONDITIONS::NotEmpty, 200 );
108 
109  moveMenu.AddSeparator( 400 );
110  moveMenu.AddItem( ACTIONS::selectAll, havePartCondition, 400 );
111  }
112 
113  // Add editing actions to the drawing tool menu
114  CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
115 
116  drawMenu.AddSeparator( 200 );
117  drawMenu.AddItem( EE_ACTIONS::rotateCCW, canEdit && EE_CONDITIONS::IdleSelection, 200 );
118  drawMenu.AddItem( EE_ACTIONS::rotateCW, canEdit && EE_CONDITIONS::IdleSelection, 200 );
119  drawMenu.AddItem( EE_ACTIONS::mirrorV, canEdit && EE_CONDITIONS::IdleSelection, 200 );
120  drawMenu.AddItem( EE_ACTIONS::mirrorH, canEdit && EE_CONDITIONS::IdleSelection, 200 );
121 
122  drawMenu.AddItem( EE_ACTIONS::properties, canEdit && EE_CONDITIONS::Count( 1 ), 200 );
123 
124  // Add editing actions to the selection tool menu
126 
127  selToolMenu.AddItem( EE_ACTIONS::rotateCCW, canEdit && EE_CONDITIONS::NotEmpty, 200 );
128  selToolMenu.AddItem( EE_ACTIONS::rotateCW, canEdit && EE_CONDITIONS::NotEmpty, 200 );
129  selToolMenu.AddItem( EE_ACTIONS::mirrorV, canEdit && EE_CONDITIONS::NotEmpty, 200 );
130  selToolMenu.AddItem( EE_ACTIONS::mirrorH, canEdit && EE_CONDITIONS::NotEmpty, 200 );
131 
132  selToolMenu.AddItem( EE_ACTIONS::properties, canEdit && EE_CONDITIONS::Count( 1 ), 200 );
133 
134  selToolMenu.AddSeparator( 300 );
137  selToolMenu.AddItem( ACTIONS::paste, canEdit && EE_CONDITIONS::Idle, 300 );
138  selToolMenu.AddItem( ACTIONS::duplicate, canEdit && EE_CONDITIONS::NotEmpty, 300 );
139  selToolMenu.AddItem( ACTIONS::doDelete, canEdit && EE_CONDITIONS::NotEmpty, 300 );
140 
141  selToolMenu.AddSeparator( 400 );
142  selToolMenu.AddItem( ACTIONS::selectAll, havePartCondition, 400 );
143 
144  return true;
145 }
146 
147 
149 {
151 
152  if( selection.GetSize() == 0 )
153  return 0;
154 
155  wxPoint rotPoint;
156  bool ccw = ( aEvent.Matches( EE_ACTIONS::rotateCCW.MakeEvent() ) );
157  LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
158 
159  if( !item->IsMoving() )
161 
162  if( selection.GetSize() == 1 )
163  rotPoint = item->GetPosition();
164  else
165  rotPoint = m_frame->GetNearestGridPosition( mapCoords( selection.GetCenter() ) );
166 
167  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
168  {
169  item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
170  item->Rotate( rotPoint, ccw );
171  m_frame->UpdateItem( item );
172  }
173 
174  if( item->IsMoving() )
175  {
177  }
178  else
179  {
181 
182  if( selection.IsHover() )
184 
185  m_frame->OnModify();
186  }
187 
188  return 0;
189 }
190 
191 
193 {
195 
196  if( selection.GetSize() == 0 )
197  return 0;
198 
199  wxPoint mirrorPoint;
200  bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorV.MakeEvent() ) );
201  LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
202 
203  if( !item->IsMoving() )
205 
206  if( selection.GetSize() == 1 )
207  mirrorPoint = item->GetPosition();
208  else
209  mirrorPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter() ) );
210 
211  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
212  {
213  item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
214 
215  if( xAxis )
216  item->MirrorVertical( mirrorPoint );
217  else
218  item->MirrorHorizontal( mirrorPoint );
219 
220  m_frame->UpdateItem( item );
221  }
222 
224 
225  if( item->IsMoving() )
226  {
228  }
229  else
230  {
231  if( selection.IsHover() )
233 
234  m_frame->OnModify();
235  }
236 
237  return 0;
238 }
239 
240 
241 static KICAD_T nonFields[] =
242 {
243  LIB_PART_T,
244  LIB_ARC_T,
245  LIB_CIRCLE_T,
246  LIB_TEXT_T,
249  LIB_BEZIER_T,
250  LIB_PIN_T,
251  EOT
252 };
253 
254 
256 {
257  LIB_PART* part = m_frame->GetCurPart();
259 
260  if( items.empty() )
261  return 0;
262 
263  // Don't leave a freed pointer in the selection
265 
267 
268  std::set<LIB_ITEM *> toDelete;
269 
270  for( EDA_ITEM* item : items )
271  {
272  if( item->Type() == LIB_PIN_T )
273  {
274  LIB_PIN* pin = static_cast<LIB_PIN*>( item );
275  wxPoint pos = pin->GetPosition();
276 
277  toDelete.insert( pin );
278 
279  // when pin editing is synchronized, pins in the same position, with the same name
280  // in different units are also removed. But only one pin per unit (matching)
281  if( m_frame->SynchronizePins() )
282  {
283  std::vector<bool> got_unit( part->GetUnitCount() );
284 
285  got_unit[pin->GetUnit()] = true;
286 
287  int curr_convert = pin->GetConvert();
288  ELECTRICAL_PINTYPE etype = pin->GetType();
289  wxString name = pin->GetName();
290  LIB_PIN* next_pin = part->GetNextPin();
291 
292  while( next_pin != NULL )
293  {
294  pin = next_pin;
295  next_pin = part->GetNextPin( pin );
296 
297  if( got_unit[pin->GetUnit()] )
298  continue;
299 
300  if( pin->GetPosition() != pos )
301  continue;
302 
303  if( pin->GetConvert() != curr_convert )
304  continue;
305 
306  if( pin->GetType() != etype )
307  continue;
308 
309  if( pin->GetName() != name )
310  continue;
311 
312  toDelete.insert( pin );
313  got_unit[pin->GetUnit()] = true;
314  }
315  }
316  }
317  else
318  {
319  toDelete.insert( (LIB_ITEM*) item );
320  }
321  }
322 
323  for( LIB_ITEM* item : toDelete )
324  part->RemoveDrawItem( item );
325 
326  m_frame->RebuildView();
327  m_frame->OnModify();
328 
329  return 0;
330 }
331 
332 
333 #define HITTEST_THRESHOLD_PIXELS 5
334 
335 
337 {
338  std::string tool = aEvent.GetCommandStr().get();
340 
342  m_pickerItem = nullptr;
343 
344  // Deactivate other tools; particularly important if another PICKER is currently running
345  Activate();
346 
347  picker->SetCursor( KICURSOR::REMOVE );
348 
349  picker->SetClickHandler(
350  [this]( const VECTOR2D& aPosition ) -> bool
351  {
352  if( m_pickerItem )
353  {
355  selectionTool->UnbrightenItem( m_pickerItem );
356  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
358  m_pickerItem = nullptr;
359  }
360 
361  return true;
362  } );
363 
364  picker->SetMotionHandler(
365  [this]( const VECTOR2D& aPos )
366  {
368  EE_COLLECTOR collector;
369 
370  selectionTool->CollectHits( collector, aPos, nonFields );
371 
372  // Remove unselectable items
373  for( int i = collector.GetCount() - 1; i >= 0; --i )
374  {
375  if( !selectionTool->Selectable( collector[ i ] ) )
376  collector.Remove( i );
377  }
378 
379  if( collector.GetCount() > 1 )
380  selectionTool->GuessSelectionCandidates( collector, aPos );
381 
382  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
383 
384  if( m_pickerItem != item )
385  {
386  if( m_pickerItem )
387  selectionTool->UnbrightenItem( m_pickerItem );
388 
389  m_pickerItem = item;
390 
391  if( m_pickerItem )
392  selectionTool->BrightenItem( m_pickerItem );
393  }
394  } );
395 
396  picker->SetFinalizeHandler(
397  [this]( const int& aFinalState )
398  {
399  if( m_pickerItem )
401 
402  // Wake the selection tool after exiting to ensure the cursor gets updated
404  } );
405 
406  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
407 
408  return 0;
409 }
410 
411 
413 {
415 
416  if( selection.Empty() || aEvent.IsAction( &EE_ACTIONS::symbolProperties ) )
417  {
418  if( m_frame->GetCurPart() )
420  }
421  else if( selection.Size() == 1 )
422  {
423  LIB_ITEM* item = (LIB_ITEM*) selection.Front();
424 
425  // Save copy for undo if not in edit (edit command already handle the save copy)
426  if( item->GetEditFlags() == 0 )
428 
429  switch( item->Type() )
430  {
431  case LIB_PIN_T:
432  {
434 
435  if( pinTool )
436  pinTool->EditPinProperties( (LIB_PIN*) item );
437 
438  break;
439  }
440  case LIB_ARC_T:
441  case LIB_CIRCLE_T:
442  case LIB_RECTANGLE_T:
443  case LIB_POLYLINE_T:
444  editGraphicProperties( item );
445  break;
446 
447  case LIB_TEXT_T:
448  editTextProperties( item );
449  break;
450 
451  case LIB_FIELD_T:
452  editFieldProperties( (LIB_FIELD*) item );
453  break;
454 
455  default:
456  wxFAIL_MSG( wxT( "Unhandled item <" ) + item->GetClass() + wxT( ">" ) );
457  break;
458  }
459  }
460 
461  if( selection.IsHover() )
463  else
465 
466  return 0;
467 }
468 
469 
471 {
472  if( aItem == NULL )
473  return;
474 
475  DIALOG_LIB_EDIT_DRAW_ITEM dialog( m_frame, aItem );
476 
477  if( dialog.ShowModal() != wxID_OK )
478  return;
479 
480  if( aItem->IsFillable() )
481  aItem->SetFillMode( (FILL_TYPE) dialog.GetFillStyle() );
482 
483  aItem->SetWidth( dialog.GetWidth() );
484 
485  if( dialog.GetApplyToAllConversions() )
486  aItem->SetConvert( 0 );
487  else
488  aItem->SetConvert( m_frame->GetConvert() );
489 
490  if( dialog.GetApplyToAllUnits() )
491  aItem->SetUnit( 0 );
492  else
493  aItem->SetUnit( m_frame->GetUnit() );
494 
495  updateItem( aItem, true );
496  m_frame->GetCanvas()->Refresh();
497  m_frame->OnModify( );
498 
500  drawingTools->SetDrawSpecificConvert( !dialog.GetApplyToAllConversions() );
501  drawingTools->SetDrawSpecificUnit( !dialog.GetApplyToAllUnits() );
502 
503  MSG_PANEL_ITEMS items;
504  aItem->GetMsgPanelInfo( m_frame, items );
505  m_frame->SetMsgPanel( items );
506 }
507 
508 
510 {
511  if ( ( aItem == NULL ) || ( aItem->Type() != LIB_TEXT_T ) )
512  return;
513 
514  DIALOG_LIB_EDIT_TEXT dlg( m_frame, (LIB_TEXT*) aItem );
515 
516  if( dlg.ShowModal() != wxID_OK )
517  return;
518 
519  updateItem( aItem, true );
520  m_frame->GetCanvas()->Refresh();
521  m_frame->OnModify( );
522 }
523 
524 
526 {
527  if( aField == NULL )
528  return;
529 
530  wxString caption;
531  LIB_PART* parent = aField->GetParent();
532  wxCHECK( parent, /* void */ );
533 
534  // Editing the component value field is equivalent to creating a new component based
535  // on the current component. Set the dialog message to inform the user.
536  if( aField->GetId() == VALUE_FIELD )
537  caption = _( "Edit Symbol Name" );
538  else
539  caption.Printf( _( "Edit %s Field" ), aField->GetName() );
540 
541  DIALOG_LIB_EDIT_ONE_FIELD dlg( m_frame, caption, aField );
542 
543  // The dialog may invoke a kiway player for footprint fields
544  // so we must use a quasimodal dialog.
545  if( dlg.ShowQuasiModal() != wxID_OK )
546  return;
547 
548  wxString newFieldValue = LIB_ID::FixIllegalChars( dlg.GetText() );
549  wxString oldFieldValue = aField->GetFullText( m_frame->GetUnit() );
550  bool renamed = aField->GetId() == VALUE_FIELD && newFieldValue != oldFieldValue;
551 
552  if( renamed )
554  else
556 
557  dlg.UpdateField( aField );
558 
559  if( renamed )
560  {
561  parent->SetName( newFieldValue );
562  m_frame->UpdateAfterSymbolProperties( &oldFieldValue );
563  }
564  else
565  {
566  updateItem( aField, true );
567  m_frame->GetCanvas()->Refresh();
568  m_frame->OnModify();
570  }
571 }
572 
573 
575 {
576  LIB_PART* part = m_frame->GetCurPart();
577  bool partLocked = part->UnitsLocked();
578  wxString oldName = part->GetName();
579 
582 
584 
585  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
586  // frame. Therefore this dialog as a modal frame parent, MUST be run under
587  // quasimodal mode for the quasimodal frame support to work. So don't use
588  // the QUASIMODAL macros here.
589  if( dlg.ShowQuasiModal() != wxID_OK )
590  return;
591 
592  m_frame->OnModify();
593 
594  // if m_UnitSelectionLocked has changed, set some edit options or defaults
595  // to the best value
596  if( partLocked != part->UnitsLocked() )
597  {
599 
600  // Enable synchronized pin edit mode for symbols with interchangeable units
601  m_frame->m_SyncPinEdit = !part->UnitsLocked();
602 
603  // also set default edit options to the better value
604  // Usually if units are locked, graphic items are specific to each unit
605  // and if units are interchangeable, graphic items are common to units
606  tools->SetDrawSpecificUnit( part->UnitsLocked() );
607  }
608 }
609 
610 
612 {
613  LIB_PART* part = m_frame->GetCurPart();
614 
615  if( !part )
616  return 0;
617 
619 
621 
622  DIALOG_LIB_EDIT_PIN_TABLE dlg( m_frame, part );
623 
624  if( dlg.ShowModal() == wxID_CANCEL )
625  return -1;
626 
627  m_frame->RebuildView();
628  m_frame->OnModify();
629 
630  return 0;
631 }
632 
633 
635 {
636  LIB_PART* part = m_frame->GetCurPart();
637 
638  if( !part )
639  return 0;
640 
641  if( !part->IsAlias() )
642  {
643  m_frame->ShowInfoBarError( _( "Symbol is not derived from another symbol." ) );
644  }
645  else
646  {
648 
649  if( dlg.ShowModal() == wxID_CANCEL )
650  return -1;
651  }
652 
653  return 0;
654 }
655 
656 
658 {
660 
662  selTool->RebuildSelection();
663 
664  return 0;
665 }
666 
667 
669 {
671 
673  selTool->RebuildSelection();
674 
675  return 0;
676 }
677 
678 
680 {
681  int retVal = Copy( aEvent );
682 
683  if( retVal == 0 )
684  retVal = DoDelete( aEvent );
685 
686  return retVal;
687 }
688 
689 
691 {
692  LIB_PART* part = m_frame->GetCurPart();
694 
695  if( !part || !selection.GetSize() )
696  return 0;
697 
698  for( LIB_ITEM& item : part->GetDrawItems() )
699  {
700  if( item.Type() == LIB_FIELD_T )
701  continue;
702 
703  wxASSERT( !item.HasFlag( STRUCT_DELETED ) );
704 
705  if( !item.IsSelected() )
706  item.SetFlags( STRUCT_DELETED );
707  }
708 
709  LIB_PART* partCopy = new LIB_PART( *part );
710 
711  STRING_FORMATTER formatter;
712  SCH_SEXPR_PLUGIN::FormatPart( partCopy, formatter );
713 
714  delete partCopy;
715 
716  for( LIB_ITEM& item : part->GetDrawItems() )
717  item.ClearFlags( STRUCT_DELETED );
718 
719  if( m_toolMgr->SaveClipboard( formatter.GetString() ) )
720  return 0;
721  else
722  return -1;
723 }
724 
725 
727 {
728  LIB_PART* part = m_frame->GetCurPart();
729 
730  if( !part || part->IsAlias() )
731  return 0;
732 
733  std::string text_utf8 = m_toolMgr->GetClipboardUTF8();
734  STRING_LINE_READER reader( text_utf8, "Clipboard" );
735  LIB_PART* newPart;
736 
737  try
738  {
739  newPart = SCH_SEXPR_PLUGIN::ParsePart( reader );
740  }
741  catch( IO_ERROR& )
742  {
743  // If it's not a part then paste as text
744  newPart = new LIB_PART( "dummy_part" );
745  LIB_TEXT* newText = new LIB_TEXT( newPart );
746  newText->SetText( wxString::FromUTF8( text_utf8.c_str() ) );
747  newPart->AddDrawItem( newText );
748  }
749 
750  if( !newPart )
751  return -1;
752 
753  m_frame->SaveCopyInUndoList( part );
755 
756  for( LIB_ITEM& item : part->GetDrawItems() )
757  item.ClearFlags( IS_NEW | IS_PASTED | SELECTED );
758 
759  for( LIB_ITEM& item : newPart->GetDrawItems() )
760  {
761  if( item.Type() == LIB_FIELD_T )
762  continue;
763 
764  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
765  newItem->SetParent( part );
766  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
767 
768  newItem->SetUnit( newItem->GetUnit() ? m_frame->GetUnit() : 0 );
769  newItem->SetConvert( newItem->GetConvert() ? m_frame->GetConvert() : 0 );
770 
771  part->AddDrawItem( newItem );
772  getView()->Add( newItem );
773  }
774 
775  delete newPart;
776 
778 
779  EE_SELECTION& selection = m_selectionTool->GetSelection();
780 
781  if( !selection.Empty() )
782  {
783  selection.SetReferencePoint( getViewControls()->GetCursorPosition( true ) );
785  }
786 
787  return 0;
788 }
789 
790 
792 {
793  LIB_PART* part = m_frame->GetCurPart();
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  if( !selection.Front()->IsMoving() )
806 
807  EDA_ITEMS newItems;
808 
809  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
810  {
811  LIB_ITEM* oldItem = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
812  LIB_ITEM* newItem = (LIB_ITEM*) oldItem->Clone();
813  oldItem->ClearFlags( IS_NEW | IS_PASTED | SELECTED );
814  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
815  newItem->SetParent( part );
816  newItems.push_back( newItem );
817 
818  part->AddDrawItem( newItem );
819  getView()->Add( newItem );
820  }
821 
823  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
824 
825  selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ) ) );
827 
828  return 0;
829 }
830 
831 
833 {
840 
847 
852 }
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
static TOOL_ACTION pinTable
Definition: ee_actions.h:143
static TOOL_ACTION properties
Definition: ee_actions.h:118
void editGraphicProperties(LIB_ITEM *aItem)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib=false)
Replace illegal LIB_ID item name characters with underscores '_'.
Definition: lib_id.cpp:347
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
int UpdateSymbolFields(const TOOL_EVENT &aEvent)
bool IsHover() const
Definition: selection.h:72
void editSymbolProperties()
Set up handlers for various events.
FILL_TYPE
The set of fill types used in plotting or drawing enclosed areas.
Definition: fill_type.h:28
wxString GetName() const override
Definition: lib_symbol.h:129
static LIB_PART * ParsePart(LINE_READER &aReader, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:75
Define a symbol library graphical text item.
Definition: lib_text.h:40
int Copy(const TOOL_EVENT &aEvent)
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:61
LIB_PART * GetParent() const
Definition: lib_item.h:149
virtual void SetWidth(int aWidth)=0
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
void editFieldProperties(LIB_FIELD *aField)
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.h:139
bool IsMoving() const
Definition: eda_item.h:169
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
Field object used in symbol libraries.
Definition: lib_field.h:59
void SetFillMode(FILL_TYPE aFillMode)
Definition: lib_item.h:267
void UpdateField(LIB_FIELD *aField)
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
TOOL_MENU & GetToolMenu()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
EE_COLLECTOR.
Definition: ee_collectors.h:42
bool Selectable(const EDA_ITEM *aItem, bool checkVisibilityOnly=false) const
Check conditions for an item to be selected.
wxPoint GetNearestHalfGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize / 2 location to aPosition.
virtual void MirrorHorizontal(const wxPoint &aCenter)=0
Mirror the draw object along the horizontal (X) axis about aCenter point.
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:100
static void FormatPart(LIB_PART *aPart, OUTPUTFORMATTER &aFormatter)
int GetId() const
Definition: lib_field.h:138
virtual wxPoint GetPosition() const
Definition: eda_item.h:301
static TOOL_ACTION mirrorH
Definition: ee_actions.h:117
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
static TOOL_ACTION updateSymbolFields
Definition: ee_actions.h:178
static bool IdleSelection(const SELECTION &aSelection)
Test if all selected items are not being edited.
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:214
static KICAD_T nonFields[]
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:165
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
wxString GetName(bool aUseDefaultName=true) const
Returns the field name.
Definition: lib_field.cpp:364
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:97
The base class for drawable items used by schematic library components.
Definition: lib_item.h:62
static TOOL_ACTION mirrorV
Definition: ee_actions.h:116
static TOOL_ACTION rotateCW
Definition: ee_actions.h:114
bool IsNew() const
Definition: eda_item.h:168
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:70
static TOOL_ACTION pickerTool
Definition: actions.h:158
void UpdateAfterSymbolProperties(wxString *aOldName=nullptr)
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:65
EE_SELECTION & GetSelection()
Return the set of currently selected items.
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:264
int GetUnit() const
Definition: lib_item.h:262
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:115
void BrightenItem(EDA_ITEM *aItem)
DIALOG_LIB_EDIT_ONE_FIELD is a the class to handle editing a single component field in the library ed...
void DisplaySymbolDatasheet()
Display the documentation of the selected symbol.
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:202
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
int Redo(const TOOL_EVENT &aEvent)
#define NULL
int GetUnitCount() const override
For items with units, return the number of units.
bool IsSymbolAlias() const
Restore the empty editor screen, without any part or library selected.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aType, bool aAppend=false)
Definition: ee_tool_base.h:133
Dialog to update or change schematic library symbols.
STATUS_FLAGS GetEditFlags() const
Definition: eda_item.h:207
const wxString & GetName() const
Definition: lib_pin.h:156
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Definition: lib_symbol.cpp:655
std::string GetClipboardUTF8() const
Return the information currently stored in the system clipboard.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:467
int ShowQuasiModal()
int Properties(const TOOL_EVENT &aEvent)
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:142
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SaveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT, bool aAppend=false)
Create a copy of the current symbol, and save it in the undo list.
#define SELECTED
Definition: eda_item.h:113
wxString GetClass() const override
Return the class name.
Definition: lib_field.h:95
Generic, UI-independent tool event.
Definition: tool_event.h:173
virtual void Rotate(const wxPoint &aCenter, bool aRotateCCW=true)=0
Rotate the object about aCenter point.
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:80
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:133
static TOOL_ACTION cut
Definition: actions.h:69
Define a library symbol object.
Definition: lib_symbol.h:93
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:176
const std::string & GetString()
Definition: richio.h:435
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:44
#define STRUCT_DELETED
flag indication structures to be erased
Definition: eda_item.h:115
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:373
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:556
virtual void MirrorVertical(const wxPoint &aCenter)=0
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:54
bool CollectHits(EE_COLLECTOR &aCollector, const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Select one or more items at the location given by parameter aWhere.
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:106
const wxString & GetText() const
int GetConvert() const
Definition: lib_item.h:265
int DeleteItemCursor(const TOOL_EVENT &aEvent)
LIB_PART * GetCurPart()
Return the current part being edited or NULL if none selected.
void UnbrightenItem(EDA_ITEM *aItem)
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_item.cpp:50
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
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 Empty() const
Checks if there is anything selected.
Definition: selection.h:122
int Mirror(const TOOL_EVENT &aEvent)
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:60
void updateItem(EDA_ITEM *aItem, bool aUpdateRTree) const
Similar to getView()->Update(), but handles items that are redrawn by their parents and updating the ...
Definition: ee_tool_base.h:102
int Duplicate(const TOOL_EVENT &aEvent)
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
void SetConvert(int aConvert)
Definition: lib_item.h:264
wxPoint GetPosition() const override
Definition: lib_pin.h:258
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:101
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:69
LIB_PIN * GetNextPin(LIB_PIN *aItem=NULL)
Return the next pin object from the draw list.
Definition: lib_symbol.h:366
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: eda_item.h:119
Dialog to edit library component graphic items.
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:471
ELECTRICAL_PINTYPE GetType() const
Definition: lib_pin.h:134
void SetUnit(int aUnit)
Definition: lib_item.h:261
static TOOL_ACTION redo
Definition: actions.h:68
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
bool IsSymbolEditable() const
Test if a symbol is loaded and can be edited.
int AddItemToSel(const TOOL_EVENT &aEvent)
const char * name
Definition: DXF_plotter.cpp:59
int PinTable(const TOOL_EVENT &aEvent)
ELECTRICAL_PINTYPE
The component library pin object electrical types used in ERC tests.
Definition: pin_type.h:34
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
#define _(s)
Definition: 3d_actions.cpp:33
bool Init() override
Init() is called once upon a registration of the tool.
bool IsAlias() const
Definition: lib_symbol.h:168
void RebuildSelection()
Rebuild the selection from the EDA_ITEMs' selection flags.
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:296
int Size() const
Returns the number of selected parts.
Definition: selection.h:128
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
int Rotate(const TOOL_EVENT &aEvent)
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:203
void Activate()
Run the tool.
void editTextProperties(LIB_ITEM *aItem)
virtual void SetName(const wxString &aName)
Definition: lib_symbol.cpp:314
static TOOL_ACTION deleteTool
Definition: actions.h:76
static TOOL_ACTION move
Definition: ee_actions.h:111
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:48
bool IsFillable() const
Check if draw object can be filled.
Definition: lib_item.h:259
int Paste(const TOOL_EVENT &aEvent)
static TOOL_ACTION undo
Definition: actions.h:67
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:321
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
int Undo(const TOOL_EVENT &aEvent)
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:237
bool EditPinProperties(LIB_PIN *aPin)
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:411
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:267
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
static TOOL_ACTION selectAll
Definition: actions.h:73
#define IS_NEW
New item, just created.
Definition: eda_item.h:106
static TOOL_ACTION paste
Definition: actions.h:71
bool UnitsLocked() const
Check whether part units are interchangeable.
Definition: lib_symbol.h:237
static TOOL_ACTION duplicate
Definition: actions.h:74
int Cut(const TOOL_EVENT &aEvent)
static TOOL_ACTION refreshPreview
Definition: actions.h:109
EDA_ITEM * Front() const
Definition: selection.h:203
SYMBOL_EDITOR_DRAWING_TOOLS.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162
int DoDelete(const TOOL_EVENT &aEvent)
Delete the selected items, or the item under the cursor.
void RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.
Definition: lib_symbol.cpp:629
The symbol library editor main window.