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>
36 #include <eeschema_id.h>
42 #include <sch_legacy_plugin.h>
43 #include <lib_text.h>
44 #include "lib_edit_tool.h"
45 
46 
48  EE_TOOL_BASE( "eeschema.SymbolEditTool" )
49 {
50 }
51 
52 
54 {
56 
59 
60  wxASSERT_MSG( drawingTools, "eeschema.SymbolDrawing tool is not available" );
61 
62  // Add edit actions to the move tool menu
63  //
64  if( moveTool )
65  {
66  CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
67 
68  moveMenu.AddSeparator( 200 );
74 
76 
77  moveMenu.AddSeparator( 300 );
81  }
82 
83  // Add editing actions to the drawing tool menu
84  //
85  CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
86 
87  drawMenu.AddSeparator( 200 );
92 
94 
95  // Add editing actions to the selection tool menu
96  //
98 
104 
105  selToolMenu.AddItem( EE_ACTIONS::properties, EE_CONDITIONS::Count( 1 ), 200 );
106 
107  selToolMenu.AddSeparator( 300 );
110  selToolMenu.AddItem( ACTIONS::paste, EE_CONDITIONS::Idle, 300 );
112 
113  return true;
114 }
115 
116 
117 int LIB_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
118 {
120 
121  if( selection.GetSize() == 0 )
122  return 0;
123 
124  wxPoint rotPoint;
125  bool ccw = ( aEvent.Matches( EE_ACTIONS::rotateCCW.MakeEvent() ) );
126  LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
127 
128  if( !item->IsMoving() )
130 
131  if( selection.GetSize() == 1 )
132  rotPoint = item->GetPosition();
133  else
134  rotPoint = m_frame->GetNearestGridPosition( mapCoords( selection.GetCenter() ) );
135 
136  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
137  {
138  item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
139  item->Rotate( rotPoint, ccw );
140  m_frame->RefreshItem( item );
141  }
142 
143  if( item->IsMoving() )
145  else
146  {
148 
149  if( selection.IsHover() )
151 
152  m_frame->OnModify();
153  }
154 
155  return 0;
156 }
157 
158 
159 int LIB_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
160 {
162 
163  if( selection.GetSize() == 0 )
164  return 0;
165 
166  wxPoint mirrorPoint;
167  bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorX.MakeEvent() ) );
168  LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
169 
170  if( !item->IsMoving() )
172 
173  if( selection.GetSize() == 1 )
174  mirrorPoint = item->GetPosition();
175  else
176  mirrorPoint = m_frame->GetNearestGridPosition( mapCoords( selection.GetCenter() ) );
177 
178  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
179  {
180  item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
181 
182  if( xAxis )
183  item->MirrorVertical( mirrorPoint );
184  else
185  item->MirrorHorizontal( mirrorPoint );
186 
187  m_frame->RefreshItem( item );
188  }
189 
191 
192  if( item->IsMoving() )
194  else
195  {
196  if( selection.IsHover() )
198 
199  m_frame->OnModify();
200  }
201 
202  return 0;
203 }
204 
205 
206 static KICAD_T nonFields[] =
207 {
208  LIB_PART_T,
209  LIB_ALIAS_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->GetCurPart(), nonFields, (wxPoint) aPos,
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" ), GetChars( 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, nullptr );
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  wxArrayString oldAliases = part->GetAliasNames( false );
525 
528 
530 
531  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
532  // frame. Therefore this dialog as a modal frame parent, MUST be run under
533  // quasimodal mode for the quasimodal frame support to work. So don't use
534  // the QUASIMODAL macros here.
535  if( dlg.ShowQuasiModal() != wxID_OK )
536  return;
537 
538  // if m_UnitSelectionLocked has changed, set some edit options or defaults
539  // to the best value
540  if( partLocked != part->UnitsLocked() )
541  {
542  // Enable synchronized pin edit mode for symbols with interchangeable units
543  m_frame->m_SyncPinEdit = !part->UnitsLocked();
544  // also set default edit options to the better value
545  // Usually if units are locked, graphic items are specific to each unit
546  // and if units are interchangeable, graphic items are common to units
548  }
549 
550  m_frame->UpdateAfterSymbolProperties( &oldName, &oldAliases );
551 }
552 
553 
555 {
556  LIB_PART* part = m_frame->GetCurPart();
557 
558  if( !part )
559  return 0;
560 
562 
564 
565  DIALOG_LIB_EDIT_PIN_TABLE dlg( m_frame, part );
566 
567  if( dlg.ShowModal() == wxID_CANCEL )
568  return -1;
569 
570  m_frame->RebuildView();
571  m_frame->OnModify();
572 
573  return 0;
574 }
575 
576 
577 int LIB_EDIT_TOOL::Undo( const TOOL_EVENT& aEvent )
578 {
580 
582  selTool->RebuildSelection();
583 
584  return 0;
585 }
586 
587 
588 int LIB_EDIT_TOOL::Redo( const TOOL_EVENT& aEvent )
589 {
591 
593  selTool->RebuildSelection();
594 
595  return 0;
596 }
597 
598 
599 int LIB_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
600 {
601  int retVal = Copy( aEvent );
602 
603  if( retVal == 0 )
604  retVal = DoDelete( aEvent );
605 
606  return retVal;
607 }
608 
609 
610 int LIB_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
611 {
612  LIB_PART* part = m_frame->GetCurPart();
614 
615  if( !part || !selection.GetSize() )
616  return 0;
617 
618  for( LIB_ITEM& item : part->GetDrawItems() )
619  {
620  if( item.Type() == LIB_FIELD_T )
621  continue;
622 
623  wxASSERT( !item.HasFlag( STRUCT_DELETED ) );
624 
625  if( !item.IsSelected() )
626  item.SetFlags( STRUCT_DELETED );
627  }
628 
629  LIB_PART* partCopy = new LIB_PART( *part );
630 
631  STRING_FORMATTER formatter;
632  SCH_LEGACY_PLUGIN::FormatPart( partCopy, formatter );
633 
634  delete partCopy;
635 
636  for( LIB_ITEM& item : part->GetDrawItems() )
637  item.ClearFlags( STRUCT_DELETED );
638 
639  if( m_toolMgr->SaveClipboard( formatter.GetString() ) )
640  return 0;
641  else
642  return -1;
643 }
644 
645 
646 int LIB_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
647 {
648  LIB_PART* part = m_frame->GetCurPart();
649 
650  if( !part )
651  return 0;
652 
653  EE_SELECTION& selection = m_selectionTool->GetSelection();
654  std::string text = m_toolMgr->GetClipboard();
655  STRING_LINE_READER reader( text, "Clipboard" );
656  LIB_PART* newPart;
657 
658  try
659  {
660  reader.ReadLine();
661  newPart = SCH_LEGACY_PLUGIN::ParsePart( reader );
662  }
663  catch( IO_ERROR& e )
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 : newPart->GetDrawItems() )
679  {
680  if( item.Type() == LIB_FIELD_T )
681  continue;
682 
683  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
684  newItem->SetParent( part );
685  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
686 
687  newItem->SetUnit( m_frame->m_DrawSpecificUnit ? m_frame->GetUnit() : 0 );
689 
690  part->GetDrawItems().push_back( newItem );
691  getView()->Add( newItem );
692  }
693 
694  delete newPart;
695 
697 
698  if( !selection.Empty() )
699  {
700  selection.SetReferencePoint( getViewControls()->GetCursorPosition( true ) );
702  }
703 
704  return 0;
705 }
706 
707 
709 {
710  LIB_PART* part = m_frame->GetCurPart();
712 
713  if( selection.GetSize() == 0 )
714  return 0;
715 
716  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
717  // up dragging around a stack of objects...
718  if( selection.Front()->IsNew() )
719  return 0;
720 
721  if( !selection.Front()->IsMoving() )
723 
724  EDA_ITEMS newItems;
725 
726  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
727  {
728  LIB_ITEM* oldItem = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
729  LIB_ITEM* newItem = (LIB_ITEM*) oldItem->Clone();
730  oldItem->ClearFlags( SELECTED );
731  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
732  newItem->SetParent( part );
733  newItems.push_back( newItem );
734 
735  part->GetDrawItems().push_back( newItem );
736  getView()->Add( newItem );
737  }
738 
740  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
741 
742  selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ) ) );
744 
745  return 0;
746 }
747 
748 
750 {
751  Go( &LIB_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() );
752  Go( &LIB_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() );
753  Go( &LIB_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() );
754  Go( &LIB_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() );
755  Go( &LIB_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() );
757 
764 
768 }
virtual wxPoint GetPosition() const =0
wxString GetName(bool aTranslate=true) const
Returns the field name.
Definition: lib_field.cpp:366
static TOOL_ACTION pinTable
Definition: ee_actions.h:150
void GetMsgPanelInfo(EDA_UNITS_T 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
bool m_DrawSpecificUnit
Specify which component parts the current draw item applies to.
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
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:68
bool IsHover() const
Definition: selection.h:69
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:82
int GetConvert() const
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:177
virtual void SetWidth(int aWidth)=0
Class LIB_DRAWING_TOOLS.
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.h:136
bool IsMoving() const
Definition: base_struct.h:230
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: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
static SELECTION_CONDITION IdleSelection
void UpdateAfterSymbolProperties(wxString *aOldName, wxArrayString *aOldAliases)
Definition: libedit.cpp:486
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:109
static int g_LastLineWidth
Class 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.
int GetId() const
Definition: lib_field.h:135
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.
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:201
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:61
static TOOL_ACTION rotateCW
Definition: ee_actions.h:118
bool IsNew() const
Definition: base_struct.h:228
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:63
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:145
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)
wxArrayString GetAliasNames(bool aIncludeRoot=true) const
#define SELECTED
Definition: base_struct.h:127
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:243
#define VALUE
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:119
void BrightenItem(EDA_ITEM *aItem)
Class DIALOG_LIB_EDIT_ONE_FIELD is a the class to handle editing a single component field in the libr...
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:265
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:126
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:225
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:270
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:623
void push_back(T *aItem)
Definition: multivector.h:169
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:149
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
Class TOOL_EVENT.
Definition: tool_event.h:168
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:130
static TOOL_ACTION cut
Definition: actions.h:69
bool EditPinProperties(LIB_PIN *aPin)
Define a library symbol object.
#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:140
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:356
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:103
const wxString & GetText() const
int GetConvert() const
Definition: lib_item.h:304
#define _(s)
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:306
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
void SetConvert(int aConvert)
Definition: lib_item.h:303
wxPoint GetPosition() const override
Definition: lib_pin.h:427
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:98
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:455
void SetUnit(int aUnit)
Definition: lib_item.h:300
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
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101
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)
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
int Paste(const TOOL_EVENT &aEvent)
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
const wxString & GetName() const
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
size_t i
Definition: json11.cpp:597
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:300
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
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
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
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:266
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
Class EE_TOOL_BASE.
Definition: ee_tool_base.h:50
bool IsFillable() const
Check if draw object can be filled.
Definition: lib_item.h:296
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.
Class STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
Class 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:228
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:133
EDA_ITEM * Front() const
Definition: selection.h:182
int Rotate(const TOOL_EVENT &aEvent)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114
void RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.