KiCad PCB EDA Suite
lib_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 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>
28 #include <tools/lib_pin_tool.h>
30 #include <tools/lib_move_tool.h>
31 #include <ee_actions.h>
32 #include <bitmaps.h>
33 #include <confirm.h>
34 #include <sch_view.h>
35 #include <lib_edit_frame.h>
41 #include <sch_sexpr_plugin.h>
42 #include <lib_text.h>
43 #include "lib_edit_tool.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  // Add edit actions to the move tool menu
64  //
65  if( moveTool )
66  {
67  CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
68 
69  moveMenu.AddSeparator( 200 );
75 
77 
78  moveMenu.AddSeparator( 300 );
82  }
83 
84  // Add editing actions to the drawing tool menu
85  //
86  CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
87 
88  drawMenu.AddSeparator( 200 );
93 
95 
96  // Add editing actions to the selection tool menu
97  //
99 
105 
106  selToolMenu.AddItem( EE_ACTIONS::properties, EE_CONDITIONS::Count( 1 ), 200 );
107 
108  selToolMenu.AddSeparator( 300 );
111  selToolMenu.AddItem( ACTIONS::paste, EE_CONDITIONS::Idle, 300 );
113 
114  return true;
115 }
116 
117 
118 int LIB_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
119 {
121 
122  if( selection.GetSize() == 0 )
123  return 0;
124 
125  wxPoint rotPoint;
126  bool ccw = ( aEvent.Matches( EE_ACTIONS::rotateCCW.MakeEvent() ) );
127  LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
128 
129  if( !item->IsMoving() )
131 
132  if( selection.GetSize() == 1 )
133  rotPoint = item->GetPosition();
134  else
135  rotPoint = m_frame->GetNearestGridPosition( mapCoords( selection.GetCenter() ) );
136 
137  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
138  {
139  item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
140  item->Rotate( rotPoint, ccw );
141  m_frame->RefreshItem( item );
142  }
143 
144  if( item->IsMoving() )
146  else
147  {
149 
150  if( selection.IsHover() )
152 
153  m_frame->OnModify();
154  }
155 
156  return 0;
157 }
158 
159 
160 int LIB_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
161 {
163 
164  if( selection.GetSize() == 0 )
165  return 0;
166 
167  wxPoint mirrorPoint;
168  bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorX.MakeEvent() ) );
169  LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
170 
171  if( !item->IsMoving() )
173 
174  if( selection.GetSize() == 1 )
175  mirrorPoint = item->GetPosition();
176  else
177  mirrorPoint = m_frame->GetNearestGridPosition( mapCoords( selection.GetCenter() ) );
178 
179  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
180  {
181  item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
182 
183  if( xAxis )
184  item->MirrorVertical( mirrorPoint );
185  else
186  item->MirrorHorizontal( mirrorPoint );
187 
188  m_frame->RefreshItem( item );
189  }
190 
192 
193  if( item->IsMoving() )
195  else
196  {
197  if( selection.IsHover() )
199 
200  m_frame->OnModify();
201  }
202 
203  return 0;
204 }
205 
206 
207 static KICAD_T nonFields[] =
208 {
209  LIB_PART_T,
210  LIB_ARC_T,
211  LIB_CIRCLE_T,
212  LIB_TEXT_T,
215  LIB_BEZIER_T,
216  LIB_PIN_T,
217  EOT
218 };
219 
220 
222 {
223  LIB_PART* part = m_frame->GetCurPart();
225 
226  if( items.empty() )
227  return 0;
228 
229  // Don't leave a freed pointer in the selection
231 
233 
234  std::set<LIB_ITEM *> toDelete;
235 
236  for( EDA_ITEM* item : items )
237  {
238  if( item->Type() == LIB_PIN_T )
239  {
240  LIB_PIN* pin = static_cast<LIB_PIN*>( item );
241  wxPoint pos = pin->GetPosition();
242 
243  toDelete.insert( pin );
244 
245  // when pin editing is synchronized, all pins of the same body style are removed:
246  if( m_frame->SynchronizePins() )
247  {
248  int curr_convert = pin->GetConvert();
249  LIB_PIN* next_pin = part->GetNextPin();
250 
251  while( next_pin != NULL )
252  {
253  pin = next_pin;
254  next_pin = part->GetNextPin( pin );
255 
256  if( pin->GetPosition() != pos )
257  continue;
258 
259  if( pin->GetConvert() != curr_convert )
260  continue;
261 
262  toDelete.insert( pin );
263  }
264  }
265  }
266  else
267  {
268  toDelete.insert( (LIB_ITEM*) item );
269  }
270  }
271 
272  for( auto item : toDelete )
273  {
274  part->RemoveDrawItem( item );
275  }
276 
277  m_frame->RebuildView();
278  m_frame->OnModify();
279 
280  return 0;
281 }
282 
283 
284 #define HITTEST_THRESHOLD_PIXELS 5
285 
286 
288 {
289  std::string tool = aEvent.GetCommandStr().get();
291 
293  m_pickerItem = nullptr;
294 
295  // Deactivate other tools; particularly important if another PICKER is currently running
296  Activate();
297 
298  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
299 
300  picker->SetClickHandler(
301  [this] ( const VECTOR2D& aPosition ) -> bool
302  {
303  if( m_pickerItem )
304  {
306  selectionTool->UnbrightenItem( m_pickerItem );
307  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
309  m_pickerItem = nullptr;
310  }
311 
312  return true;
313  } );
314 
315  picker->SetMotionHandler(
316  [this] ( const VECTOR2D& aPos )
317  {
319  EE_COLLECTOR collector;
320  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
321  collector.Collect( m_frame->GetScreen(), nonFields, (wxPoint) aPos, m_frame->GetUnit(),
322  m_frame->GetConvert() );
323 
324  // Remove unselectable items
325  for( int i = collector.GetCount() - 1; i >= 0; --i )
326  {
327  if( !selectionTool->Selectable( collector[ i ] ) )
328  collector.Remove( i );
329  }
330 
331  if( collector.GetCount() > 1 )
332  selectionTool->GuessSelectionCandidates( collector, aPos );
333 
334  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
335 
336  if( m_pickerItem != item )
337  {
338  if( m_pickerItem )
339  selectionTool->UnbrightenItem( m_pickerItem );
340 
341  m_pickerItem = item;
342 
343  if( m_pickerItem )
344  selectionTool->BrightenItem( m_pickerItem );
345  }
346  } );
347 
348  picker->SetFinalizeHandler(
349  [this] ( const int& aFinalState )
350  {
351  if( m_pickerItem )
353  } );
354 
355  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
356 
357  return 0;
358 }
359 
360 
362 {
364 
365  if( selection.Empty() || aEvent.IsAction( &EE_ACTIONS::symbolProperties ) )
366  {
367  if( m_frame->GetCurPart() )
369  }
370  else if( selection.Size() == 1 )
371  {
372  LIB_ITEM* item = (LIB_ITEM*) selection.Front();
373 
374  // Save copy for undo if not in edit (edit command already handle the save copy)
375  if( item->GetEditFlags() == 0 )
377 
378  switch( item->Type() )
379  {
380  case LIB_PIN_T:
381  {
383 
384  if( pinTool )
385  pinTool->EditPinProperties( (LIB_PIN*) item );
386 
387  break;
388  }
389  case LIB_ARC_T:
390  case LIB_CIRCLE_T:
391  case LIB_RECTANGLE_T:
392  case LIB_POLYLINE_T:
393  editGraphicProperties( item );
394  break;
395 
396  case LIB_TEXT_T:
397  editTextProperties( item );
398  break;
399 
400  case LIB_FIELD_T:
401  editFieldProperties( (LIB_FIELD*) item );
402  break;
403 
404  default:
405  wxFAIL_MSG( wxT( "Unhandled item <" ) + item->GetClass() + wxT( ">" ) );
406  break;
407  }
408  }
409 
411 
412  return 0;
413 }
414 
415 
417 {
418  if( aItem == NULL )
419  return;
420 
421  DIALOG_LIB_EDIT_DRAW_ITEM dialog( m_frame, aItem );
422 
423  if( dialog.ShowModal() != wxID_OK )
424  return;
425 
426  if( aItem->IsFillable() )
427  aItem->SetFillMode( (FILL_T) dialog.GetFillStyle() );
428 
429  aItem->SetWidth( dialog.GetWidth() );
430 
431  if( dialog.GetApplyToAllConversions() )
432  aItem->SetConvert( 0 );
433  else
434  aItem->SetConvert( m_frame->GetConvert() );
435 
436  if( dialog.GetApplyToAllUnits() )
437  aItem->SetUnit( 0 );
438  else
439  aItem->SetUnit( m_frame->GetUnit() );
440 
441  updateView( aItem );
442  m_frame->GetCanvas()->Refresh();
443  m_frame->OnModify( );
444 
446  drawingTools->SetDrawSpecificConvert( !dialog.GetApplyToAllConversions() );
447  drawingTools->SetDrawSpecificUnit( !dialog.GetApplyToAllUnits() );
448 
449  MSG_PANEL_ITEMS items;
450  aItem->GetMsgPanelInfo( m_frame, items );
451  m_frame->SetMsgPanel( items );
452 }
453 
454 
456 {
457  if ( ( aItem == NULL ) || ( aItem->Type() != LIB_TEXT_T ) )
458  return;
459 
460  DIALOG_LIB_EDIT_TEXT dlg( m_frame, (LIB_TEXT*) aItem );
461 
462  if( dlg.ShowModal() != wxID_OK )
463  return;
464 
465  updateView( aItem );
466  m_frame->GetCanvas()->Refresh();
467  m_frame->OnModify( );
468 }
469 
470 
472 {
473  if( aField == NULL )
474  return;
475 
476  wxString caption;
477  LIB_PART* parent = aField->GetParent();
478  wxCHECK( parent, /* void */ );
479 
480  // Editing the component value field is equivalent to creating a new component based
481  // on the current component. Set the dialog message to inform the user.
482  if( aField->GetId() == VALUE )
483  caption = _( "Edit Component Name" );
484  else
485  caption.Printf( _( "Edit %s Field" ), aField->GetName() );
486 
487  DIALOG_LIB_EDIT_ONE_FIELD dlg( m_frame, caption, aField );
488 
489  // The dialog may invoke a kiway player for footprint fields
490  // so we must use a quasimodal dialog.
491  if( dlg.ShowQuasiModal() != wxID_OK )
492  return;
493 
494  wxString newFieldValue = LIB_ID::FixIllegalChars( dlg.GetText(), LIB_ID::ID_SCH );
495  wxString oldFieldValue = aField->GetFullText( m_frame->GetUnit() );
496  bool renamed = aField->GetId() == VALUE && newFieldValue != oldFieldValue;
497 
498  if( renamed )
500  else
501  saveCopyInUndoList( parent, UR_LIBEDIT );
502 
503  dlg.UpdateField( aField );
504 
505  if( renamed )
506  {
507  parent->SetName( newFieldValue );
508  m_frame->UpdateAfterSymbolProperties( &oldFieldValue );
509  }
510  else
511  {
512  updateView( aField );
513  m_frame->GetCanvas()->Refresh();
514  m_frame->OnModify( );
515  }
516 }
517 
518 
520 {
521  LIB_PART* part = m_frame->GetCurPart();
522  bool partLocked = part->UnitsLocked();
523  wxString oldName = part->GetName();
524 
527 
529 
530  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
531  // frame. Therefore this dialog as a modal frame parent, MUST be run under
532  // quasimodal mode for the quasimodal frame support to work. So don't use
533  // the QUASIMODAL macros here.
534  if( dlg.ShowQuasiModal() != wxID_OK )
535  return;
536 
537  m_frame->OnModify();
538 
539  // if m_UnitSelectionLocked has changed, set some edit options or defaults
540  // to the best value
541  if( partLocked != part->UnitsLocked() )
542  {
544 
545  // Enable synchronized pin edit mode for symbols with interchangeable units
546  m_frame->m_SyncPinEdit = !part->UnitsLocked();
547 
548  // also set default edit options to the better value
549  // Usually if units are locked, graphic items are specific to each unit
550  // and if units are interchangeable, graphic items are common to units
551  tools->SetDrawSpecificUnit( part->UnitsLocked() );
552  }
553 }
554 
555 
557 {
558  LIB_PART* part = m_frame->GetCurPart();
559 
560  if( !part )
561  return 0;
562 
564 
566 
567  DIALOG_LIB_EDIT_PIN_TABLE dlg( m_frame, part );
568 
569  if( dlg.ShowModal() == wxID_CANCEL )
570  return -1;
571 
572  m_frame->RebuildView();
573  m_frame->OnModify();
574 
575  return 0;
576 }
577 
578 
579 int LIB_EDIT_TOOL::Undo( const TOOL_EVENT& aEvent )
580 {
582 
584  selTool->RebuildSelection();
585 
586  return 0;
587 }
588 
589 
590 int LIB_EDIT_TOOL::Redo( const TOOL_EVENT& aEvent )
591 {
593 
595  selTool->RebuildSelection();
596 
597  return 0;
598 }
599 
600 
601 int LIB_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
602 {
603  int retVal = Copy( aEvent );
604 
605  if( retVal == 0 )
606  retVal = DoDelete( aEvent );
607 
608  return retVal;
609 }
610 
611 
612 int LIB_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
613 {
614  LIB_PART* part = m_frame->GetCurPart();
616 
617  if( !part || !selection.GetSize() )
618  return 0;
619 
620  for( LIB_ITEM& item : part->GetDrawItems() )
621  {
622  if( item.Type() == LIB_FIELD_T )
623  continue;
624 
625  wxASSERT( !item.HasFlag( STRUCT_DELETED ) );
626 
627  if( !item.IsSelected() )
628  item.SetFlags( STRUCT_DELETED );
629  }
630 
631  LIB_PART* partCopy = new LIB_PART( *part );
632 
633  STRING_FORMATTER formatter;
634  SCH_SEXPR_PLUGIN::FormatPart( partCopy, formatter );
635 
636  delete partCopy;
637 
638  for( LIB_ITEM& item : part->GetDrawItems() )
639  item.ClearFlags( STRUCT_DELETED );
640 
641  if( m_toolMgr->SaveClipboard( formatter.GetString() ) )
642  return 0;
643  else
644  return -1;
645 }
646 
647 
648 int LIB_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
649 {
650  LIB_PART* part = m_frame->GetCurPart();
651 
652  if( !part )
653  return 0;
654 
655  std::string text = m_toolMgr->GetClipboard();
656  STRING_LINE_READER reader( text, "Clipboard" );
657  LIB_PART* newPart;
658 
659  try
660  {
661  newPart = SCH_SEXPR_PLUGIN::ParsePart( reader );
662  }
663  catch( IO_ERROR& )
664  {
665  // If it's not a part then paste as text
666  newPart = new LIB_PART( "dummy_part" );
667  LIB_TEXT* newText = new LIB_TEXT( newPart );
668  newText->SetText( text );
669  newPart->AddDrawItem( newText );
670  }
671 
672  if( !newPart )
673  return -1;
674 
675  m_frame->SaveCopyInUndoList( part );
677 
678  for( LIB_ITEM& item : part->GetDrawItems() )
679  item.ClearFlags( IS_NEW | IS_PASTED | SELECTED );
680 
681  for( LIB_ITEM& item : newPart->GetDrawItems() )
682  {
683  if( item.Type() == LIB_FIELD_T )
684  continue;
685 
686  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
687  newItem->SetParent( part );
688  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
689 
690  newItem->SetUnit( newItem->GetUnit() ? m_frame->GetUnit() : 0 );
691  newItem->SetConvert( newItem->GetConvert() ? m_frame->GetConvert() : 0 );
692 
693  part->GetDrawItems().push_back( newItem );
694  getView()->Add( newItem );
695  }
696 
697  delete newPart;
698 
700 
701  EE_SELECTION& selection = m_selectionTool->GetSelection();
702 
703  if( !selection.Empty() )
704  {
705  selection.SetReferencePoint( getViewControls()->GetCursorPosition( true ) );
707  }
708 
709  return 0;
710 }
711 
712 
714 {
715  LIB_PART* part = m_frame->GetCurPart();
717 
718  if( selection.GetSize() == 0 )
719  return 0;
720 
721  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
722  // up dragging around a stack of objects...
723  if( selection.Front()->IsNew() )
724  return 0;
725 
726  if( !selection.Front()->IsMoving() )
728 
729  EDA_ITEMS newItems;
730 
731  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
732  {
733  LIB_ITEM* oldItem = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
734  LIB_ITEM* newItem = (LIB_ITEM*) oldItem->Clone();
735  oldItem->ClearFlags( IS_NEW | IS_PASTED | SELECTED );
736  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
737  newItem->SetParent( part );
738  newItems.push_back( newItem );
739 
740  part->GetDrawItems().push_back( newItem );
741  getView()->Add( newItem );
742  }
743 
745  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
746 
747  selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ) ) );
749 
750  return 0;
751 }
752 
753 
755 {
756  Go( &LIB_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() );
757  Go( &LIB_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() );
758  Go( &LIB_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() );
759  Go( &LIB_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() );
760  Go( &LIB_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() );
762 
769 
773 }
static TOOL_ACTION pinTable
Definition: ee_actions.h:145
static TOOL_ACTION properties
Definition: ee_actions.h:120
void SetCursor(const wxCursor &aCursor)
Definition: picker_tool.h:65
int m_Threshold
Definition: collector.h:66
bool IsHover() const
Definition: selection.h:71
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:82
int GetConvert() const
wxString GetName() const override
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:74
void setTransitions() override
Sets up handlers for various events.
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:72
Define a symbol library graphical text item.
Definition: lib_text.h:40
bool SaveClipboard(const std::string &aText)
Stores an information to the system clipboard.
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:63
LIB_PART * GetParent() const
Definition: lib_item.h:182
virtual void SetWidth(int aWidth)=0
LIB_DRAWING_TOOLS.
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
static TOOL_ACTION mirrorY
Definition: ee_actions.h:119
EDA_ITEM * m_pickerItem
Definition: lib_edit_tool.h:77
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
Field object used in symbol libraries.
Definition: lib_field.h:59
void UpdateField(LIB_FIELD *aField)
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
static SELECTION_CONDITION IdleSelection
TOOL_MENU & GetToolMenu()
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
bool Selectable(const EDA_ITEM *aItem, bool checkVisibilityOnly=false) const
Function Selectable() Checks conditions for an item to be selected.
int Properties(const TOOL_EVENT &aEvent)
virtual void MirrorHorizontal(const wxPoint &aCenter)=0
Mirror the draw object along the horizontal (X) axis about aCenter point.
LIB_PART * GetCurPart()
Return the current part being edited or NULL if none selected.
static void FormatPart(LIB_PART *aPart, OUTPUTFORMATTER &aFormatter)
int GetId() const
Definition: lib_field.h:138
static SELECTION_CONDITION Idle
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...
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()
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:206
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.
wxString GetName(bool aUseDefaultName=true) const
Returns the field name.
Definition: lib_field.cpp:366
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
The base class for drawable items used by schematic library components.
Definition: lib_item.h:61
static TOOL_ACTION rotateCW
Definition: ee_actions.h:116
bool IsNew() const
Definition: base_struct.h:199
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
virtual const wxPoint GetPosition() const
Definition: base_struct.h:337
static TOOL_ACTION pickerTool
Definition: actions.h:148
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
void AddDrawItem(LIB_ITEM *aItem)
Add a new draw aItem to the draw object list.
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
Definition: picker_tool.h:102
EE_SELECTION & GetSelection()
Function GetSelection()
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
void editTextProperties(LIB_ITEM *aItem)
#define SELECTED
Definition: base_struct.h:124
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:245
int GetUnit() const
Definition: lib_item.h:295
#define VALUE
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:117
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 editSymbolProperties()
int DoDelete(const TOOL_EVENT &aEvent)
Function DoDelete()
int Mirror(const TOOL_EVENT &aEvent)
int GetUnit() const
void editGraphicProperties(LIB_ITEM *aItem)
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:116
#define NULL
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:237
int Duplicate(const TOOL_EVENT &aEvent)
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
int ShowQuasiModal()
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:587
void push_back(T *aItem)
Definition: multivector.h:169
void SetDrawSpecificUnit(bool aSpecific)
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:144
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_field.h:95
TOOL_EVENT.
Definition: tool_event.h:171
int Undo(const TOOL_EVENT &aEvent)
virtual void Rotate(const wxPoint &aCenter, bool aRotateCCW=true)=0
Rotate the object about aCenter point.
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:132
static TOOL_ACTION cut
Definition: actions.h:69
bool EditPinProperties(LIB_PIN *aPin)
Define a library symbol object.
void UpdateAfterSymbolProperties(wxString *aOldName=nullptr)
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:126
static TOOL_ACTION mirrorX
Definition: ee_actions.h:118
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
int Redo(const TOOL_EVENT &aEvent)
const std::string & GetString()
Definition: richio.h:475
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
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:56
#define HITTEST_THRESHOLD_PIXELS
void GetComponentFromRedoList()
int DeleteItemCursor(const TOOL_EVENT &aEvent)
Runs the deletion tool.
const wxPoint GetPosition() const override
Definition: lib_pin.h:430
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:105
const wxString & GetText() const
int GetConvert() const
Definition: lib_item.h:298
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:52
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...
void SetFillMode(FILL_T aFillMode)
Definition: lib_item.h:300
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
void SetConvert(int aConvert)
Definition: lib_item.h:297
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:100
LIB_PIN * GetNextPin(LIB_PIN *aItem=NULL)
Return the next pin object from the draw list.
Dialog to edit library component graphic items.
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
void SetUnit(int aUnit)
Definition: lib_item.h:294
static TOOL_ACTION redo
Definition: actions.h:68
int PinTable(const TOOL_EVENT &aEvent)
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
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
int AddItemToSel(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
#define _(s)
Definition: 3d_actions.cpp:33
std::string GetClipboard() const
Returns the information currently stored in the system clipboard.
void RebuildSelection()
Rebuilds the selection from the EDA_ITEMs' selection flags.
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:298
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
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
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, LIB_ID_TYPE aType, bool aLib=false)
Replace illegal LIB_ID item name characters with underscores '_'.
Definition: lib_id.cpp:352
FILL_T
Enum FILL_T is the set of fill types used in plotting or drawing enclosed areas.
Definition: base_struct.h:42
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
void Activate()
Function Activate() Runs the tool.
virtual void SetName(const wxString &aName)
static KICAD_T nonFields[]
static TOOL_ACTION deleteTool
Definition: actions.h:75
static TOOL_ACTION move
Definition: ee_actions.h:113
EE_TOOL_BASE.
Definition: ee_tool_base.h:50
bool IsFillable() const
Check if draw object can be filled.
Definition: lib_item.h:292
static TOOL_ACTION undo
Definition: actions.h:67
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
int Cut(const TOOL_EVENT &aEvent)
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
void SetDrawSpecificConvert(bool aSpecific)
STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
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
int Copy(const TOOL_EVENT &aEvent)
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
static TOOL_ACTION paste
Definition: actions.h:71
bool UnitsLocked() const
Check whether part units are interchangeable.
void SaveCopyInUndoList(EDA_ITEM *ItemToCopy, UNDO_REDO_T undoType=UR_LIBEDIT, bool aAppend=false)
Create a copy of the current component, and save it in the undo list.
static TOOL_ACTION duplicate
Definition: actions.h:73
void editFieldProperties(LIB_FIELD *aField)
static TOOL_ACTION refreshPreview
Definition: actions.h:101
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: base_struct.h:130
EDA_ITEM * Front() const
Definition: selection.h:184
int Rotate(const TOOL_EVENT &aEvent)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
void RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.