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_legacy_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 
445  m_frame->g_LastLineWidth = dialog.GetWidth();
448 
449  MSG_PANEL_ITEMS items;
450  aItem->GetMsgPanelInfo( m_frame->GetUserUnits(), 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( TRANSLATE_FIELD_NAME ) );
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  {
543  // Enable synchronized pin edit mode for symbols with interchangeable units
544  m_frame->m_SyncPinEdit = !part->UnitsLocked();
545  // also set default edit options to the better value
546  // Usually if units are locked, graphic items are specific to each unit
547  // and if units are interchangeable, graphic items are common to units
549  }
550 }
551 
552 
554 {
555  LIB_PART* part = m_frame->GetCurPart();
556 
557  if( !part )
558  return 0;
559 
561 
563 
564  DIALOG_LIB_EDIT_PIN_TABLE dlg( m_frame, part );
565 
566  if( dlg.ShowModal() == wxID_CANCEL )
567  return -1;
568 
569  m_frame->RebuildView();
570  m_frame->OnModify();
571 
572  return 0;
573 }
574 
575 
576 int LIB_EDIT_TOOL::Undo( const TOOL_EVENT& aEvent )
577 {
579 
581  selTool->RebuildSelection();
582 
583  return 0;
584 }
585 
586 
587 int LIB_EDIT_TOOL::Redo( const TOOL_EVENT& aEvent )
588 {
590 
592  selTool->RebuildSelection();
593 
594  return 0;
595 }
596 
597 
598 int LIB_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
599 {
600  int retVal = Copy( aEvent );
601 
602  if( retVal == 0 )
603  retVal = DoDelete( aEvent );
604 
605  return retVal;
606 }
607 
608 
609 int LIB_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
610 {
611  LIB_PART* part = m_frame->GetCurPart();
613 
614  if( !part || !selection.GetSize() )
615  return 0;
616 
617  for( LIB_ITEM& item : part->GetDrawItems() )
618  {
619  if( item.Type() == LIB_FIELD_T )
620  continue;
621 
622  wxASSERT( !item.HasFlag( STRUCT_DELETED ) );
623 
624  if( !item.IsSelected() )
625  item.SetFlags( STRUCT_DELETED );
626  }
627 
628  LIB_PART* partCopy = new LIB_PART( *part );
629 
630  STRING_FORMATTER formatter;
631  SCH_LEGACY_PLUGIN::FormatPart( partCopy, formatter );
632 
633  delete partCopy;
634 
635  for( LIB_ITEM& item : part->GetDrawItems() )
636  item.ClearFlags( STRUCT_DELETED );
637 
638  if( m_toolMgr->SaveClipboard( formatter.GetString() ) )
639  return 0;
640  else
641  return -1;
642 }
643 
644 
645 int LIB_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
646 {
647  LIB_PART* part = m_frame->GetCurPart();
648 
649  if( !part )
650  return 0;
651 
652  EE_SELECTION& selection = m_selectionTool->GetSelection();
653  std::string text = m_toolMgr->GetClipboard();
654  STRING_LINE_READER reader( text, "Clipboard" );
655  LIB_PART* newPart;
656 
657  try
658  {
659  reader.ReadLine();
660  newPart = SCH_LEGACY_PLUGIN::ParsePart( reader );
661  }
662  catch( IO_ERROR& )
663  {
664  // If it's not a part then paste as text
665  newPart = new LIB_PART( "dummy_part" );
666  LIB_TEXT* newText = new LIB_TEXT( newPart );
667  newText->SetText( text );
668  newPart->AddDrawItem( newText );
669  }
670 
671  if( !newPart )
672  return -1;
673 
674  m_frame->SaveCopyInUndoList( part );
676 
677  for( LIB_ITEM& item : newPart->GetDrawItems() )
678  {
679  if( item.Type() == LIB_FIELD_T )
680  continue;
681 
682  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
683  newItem->SetParent( part );
684  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
685 
686  newItem->SetUnit( newItem->GetUnit() ? m_frame->GetUnit() : 0 );
687  newItem->SetConvert( newItem->GetConvert() ? m_frame->GetConvert() : 0 );
688 
689  part->GetDrawItems().push_back( newItem );
690  getView()->Add( newItem );
691  }
692 
693  delete newPart;
694 
696 
697  if( !selection.Empty() )
698  {
699  selection.SetReferencePoint( getViewControls()->GetCursorPosition( true ) );
701  }
702 
703  return 0;
704 }
705 
706 
708 {
709  LIB_PART* part = m_frame->GetCurPart();
711 
712  if( selection.GetSize() == 0 )
713  return 0;
714 
715  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
716  // up dragging around a stack of objects...
717  if( selection.Front()->IsNew() )
718  return 0;
719 
720  if( !selection.Front()->IsMoving() )
722 
723  EDA_ITEMS newItems;
724 
725  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
726  {
727  LIB_ITEM* oldItem = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
728  LIB_ITEM* newItem = (LIB_ITEM*) oldItem->Clone();
729  oldItem->ClearFlags( SELECTED );
730  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
731  newItem->SetParent( part );
732  newItems.push_back( newItem );
733 
734  part->GetDrawItems().push_back( newItem );
735  getView()->Add( newItem );
736  }
737 
739  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
740 
741  selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ) ) );
743 
744  return 0;
745 }
746 
747 
749 {
750  Go( &LIB_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() );
751  Go( &LIB_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() );
752  Go( &LIB_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() );
753  Go( &LIB_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() );
754  Go( &LIB_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() );
756 
763 
767 }
virtual wxPoint GetPosition() const =0
static TOOL_ACTION pinTable
Definition: ee_actions.h:149
bool m_DrawSpecificUnit
Specify which component parts the current draw item applies to.
static TOOL_ACTION properties
Definition: ee_actions.h:122
void SetCursor(const wxCursor &aCursor)
Definition: picker_tool.h:65
int m_Threshold
Definition: collector.h:66
bool IsHover() const
Definition: selection.h:70
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:82
void GetMsgPanelInfo(EDA_UNITS aUnits, 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
int GetConvert() const
wxString GetName() const override
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:65
LIB_PART * GetParent() const
Definition: lib_item.h:185
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:137
bool IsMoving() const
Definition: base_struct.h:222
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION mirrorY
Definition: ee_actions.h:121
EDA_ITEM * m_pickerItem
Definition: lib_edit_tool.h:77
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
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:139
static int g_LastLineWidth
EE_COLLECTOR.
Definition: ee_collectors.h:39
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.
int GetId() const
Definition: lib_field.h:139
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 LIB_PART * ParsePart(LINE_READER &aReader, int majorVersion=0, int minorVersion=0)
static bool NotEmpty(const SELECTION &aSelection)
Function NotEmpty Tests if there are any items selected.
#define TRANSLATE_FIELD_NAME
Returns the field name.
Definition: lib_field.h:124
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:205
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
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:60
static TOOL_ACTION rotateCW
Definition: ee_actions.h:118
bool IsNew() const
Definition: base_struct.h:220
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
char * ReadLine() override
Function ReadLine reads a line of text into the buffer and increments the line number counter.
Definition: richio.cpp:251
bool m_DrawSpecificConvert
Convert of the item currently being drawn.
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:120
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
void editTextProperties(LIB_ITEM *aItem)
#define SELECTED
Definition: base_struct.h:127
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:244
int GetUnit() const
Definition: lib_item.h:309
#define VALUE
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:119
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:257
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:111
#define NULL
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:218
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:262
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:603
void push_back(T *aItem)
Definition: multivector.h:169
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:148
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:131
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:129
static TOOL_ACTION mirrorX
Definition: ee_actions.h:120
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:58
static void FormatPart(LIB_PART *aPart, OUTPUTFORMATTER &aFormatter)
#define HITTEST_THRESHOLD_PIXELS
void GetComponentFromRedoList()
int DeleteItemCursor(const TOOL_EVENT &aEvent)
Runs the deletion tool.
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:104
const wxString & GetText() const
int GetConvert() const
Definition: lib_item.h:312
void UnbrightenItem(EDA_ITEM *aItem)
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:314
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
void SetConvert(int aConvert)
Definition: lib_item.h:311
wxPoint GetPosition() const override
Definition: lib_pin.h:432
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:99
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:308
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)
wxString GetName(bool aTranslate) const
Definition: lib_field.cpp:387
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:315
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
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:61
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:166
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:258
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:115
EE_TOOL_BASE.
Definition: ee_tool_base.h:50
bool IsFillable() const
Check if draw object can be filled.
Definition: lib_item.h:304
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
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:267
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
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
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:133
EDA_ITEM * Front() const
Definition: selection.h:183
int Rotate(const TOOL_EVENT &aEvent)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
void RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.