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_ARC_T,
210  LIB_CIRCLE_T,
211  LIB_TEXT_T,
214  LIB_BEZIER_T,
215  LIB_PIN_T,
216  EOT
217 };
218 
219 
221 {
222  LIB_PART* part = m_frame->GetCurPart();
224 
225  if( items.empty() )
226  return 0;
227 
228  // Don't leave a freed pointer in the selection
230 
232 
233  std::set<LIB_ITEM *> toDelete;
234 
235  for( EDA_ITEM* item : items )
236  {
237  if( item->Type() == LIB_PIN_T )
238  {
239  LIB_PIN* pin = static_cast<LIB_PIN*>( item );
240  wxPoint pos = pin->GetPosition();
241 
242  toDelete.insert( pin );
243 
244  // when pin editing is synchronized, all pins of the same body style are removed:
245  if( m_frame->SynchronizePins() )
246  {
247  int curr_convert = pin->GetConvert();
248  LIB_PIN* next_pin = part->GetNextPin();
249 
250  while( next_pin != NULL )
251  {
252  pin = next_pin;
253  next_pin = part->GetNextPin( pin );
254 
255  if( pin->GetPosition() != pos )
256  continue;
257 
258  if( pin->GetConvert() != curr_convert )
259  continue;
260 
261  toDelete.insert( pin );
262  }
263  }
264  }
265  else
266  {
267  toDelete.insert( (LIB_ITEM*) item );
268  }
269  }
270 
271  for( auto item : toDelete )
272  {
273  part->RemoveDrawItem( item );
274  }
275 
276  m_frame->RebuildView();
277  m_frame->OnModify();
278 
279  return 0;
280 }
281 
282 
283 #define HITTEST_THRESHOLD_PIXELS 5
284 
285 
287 {
288  std::string tool = aEvent.GetCommandStr().get();
290 
292  m_pickerItem = nullptr;
293 
294  // Deactivate other tools; particularly important if another PICKER is currently running
295  Activate();
296 
297  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
298 
299  picker->SetClickHandler(
300  [this] ( const VECTOR2D& aPosition ) -> bool
301  {
302  if( m_pickerItem )
303  {
305  selectionTool->UnbrightenItem( m_pickerItem );
306  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
308  m_pickerItem = nullptr;
309  }
310 
311  return true;
312  } );
313 
314  picker->SetMotionHandler(
315  [this] ( const VECTOR2D& aPos )
316  {
318  EE_COLLECTOR collector;
319  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
320  collector.Collect( m_frame->GetCurPart(), nonFields, (wxPoint) aPos,
322 
323  // Remove unselectable items
324  for( int i = collector.GetCount() - 1; i >= 0; --i )
325  {
326  if( !selectionTool->Selectable( collector[ i ] ) )
327  collector.Remove( i );
328  }
329 
330  if( collector.GetCount() > 1 )
331  selectionTool->GuessSelectionCandidates( collector, aPos );
332 
333  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
334 
335  if( m_pickerItem != item )
336  {
337  if( m_pickerItem )
338  selectionTool->UnbrightenItem( m_pickerItem );
339 
340  m_pickerItem = item;
341 
342  if( m_pickerItem )
343  selectionTool->BrightenItem( m_pickerItem );
344  }
345  } );
346 
347  picker->SetFinalizeHandler(
348  [this] ( const int& aFinalState )
349  {
350  if( m_pickerItem )
352  } );
353 
354  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
355 
356  return 0;
357 }
358 
359 
361 {
363 
364  if( selection.Empty() || aEvent.IsAction( &EE_ACTIONS::symbolProperties ) )
365  {
366  if( m_frame->GetCurPart() )
368  }
369  else if( selection.Size() == 1 )
370  {
371  LIB_ITEM* item = (LIB_ITEM*) selection.Front();
372 
373  // Save copy for undo if not in edit (edit command already handle the save copy)
374  if( item->GetEditFlags() == 0 )
376 
377  switch( item->Type() )
378  {
379  case LIB_PIN_T:
380  {
382 
383  if( pinTool )
384  pinTool->EditPinProperties( (LIB_PIN*) item );
385 
386  break;
387  }
388  case LIB_ARC_T:
389  case LIB_CIRCLE_T:
390  case LIB_RECTANGLE_T:
391  case LIB_POLYLINE_T:
392  editGraphicProperties( item );
393  break;
394 
395  case LIB_TEXT_T:
396  editTextProperties( item );
397  break;
398 
399  case LIB_FIELD_T:
400  editFieldProperties( (LIB_FIELD*) item );
401  break;
402 
403  default:
404  wxFAIL_MSG( wxT( "Unhandled item <" ) + item->GetClass() + wxT( ">" ) );
405  break;
406  }
407  }
408 
410 
411  return 0;
412 }
413 
414 
416 {
417  if( aItem == NULL )
418  return;
419 
420  DIALOG_LIB_EDIT_DRAW_ITEM dialog( m_frame, aItem );
421 
422  if( dialog.ShowModal() != wxID_OK )
423  return;
424 
425  if( aItem->IsFillable() )
426  aItem->SetFillMode( (FILL_T) dialog.GetFillStyle() );
427 
428  aItem->SetWidth( dialog.GetWidth() );
429 
430  if( dialog.GetApplyToAllConversions() )
431  aItem->SetConvert( 0 );
432  else
433  aItem->SetConvert( m_frame->GetConvert() );
434 
435  if( dialog.GetApplyToAllUnits() )
436  aItem->SetUnit( 0 );
437  else
438  aItem->SetUnit( m_frame->GetUnit() );
439 
440  updateView( aItem );
441  m_frame->GetCanvas()->Refresh();
442  m_frame->OnModify( );
443 
444  m_frame->g_LastLineWidth = dialog.GetWidth();
447 
448  MSG_PANEL_ITEMS items;
449  aItem->GetMsgPanelInfo( m_frame->GetUserUnits(), items );
450  m_frame->SetMsgPanel( items );
451 }
452 
453 
455 {
456  if ( ( aItem == NULL ) || ( aItem->Type() != LIB_TEXT_T ) )
457  return;
458 
459  DIALOG_LIB_EDIT_TEXT dlg( m_frame, (LIB_TEXT*) aItem );
460 
461  if( dlg.ShowModal() != wxID_OK )
462  return;
463 
464  updateView( aItem );
465  m_frame->GetCanvas()->Refresh();
466  m_frame->OnModify( );
467 }
468 
469 
471 {
472  if( aField == NULL )
473  return;
474 
475  wxString caption;
476  LIB_PART* parent = aField->GetParent();
477  wxCHECK( parent, /* void */ );
478 
479  // Editing the component value field is equivalent to creating a new component based
480  // on the current component. Set the dialog message to inform the user.
481  if( aField->GetId() == VALUE )
482  caption = _( "Edit Component Name" );
483  else
484  caption.Printf( _( "Edit %s Field" ), GetChars( aField->GetName() ) );
485 
486  DIALOG_LIB_EDIT_ONE_FIELD dlg( m_frame, caption, aField );
487 
488  // The dialog may invoke a kiway player for footprint fields
489  // so we must use a quasimodal dialog.
490  if( dlg.ShowQuasiModal() != wxID_OK )
491  return;
492 
493  wxString newFieldValue = LIB_ID::FixIllegalChars( dlg.GetText(), LIB_ID::ID_SCH );
494  wxString oldFieldValue = aField->GetFullText( m_frame->GetUnit() );
495  bool renamed = aField->GetId() == VALUE && newFieldValue != oldFieldValue;
496 
497  if( renamed )
499  else
500  saveCopyInUndoList( parent, UR_LIBEDIT );
501 
502  dlg.UpdateField( aField );
503 
504  if( renamed )
505  {
506  parent->SetName( newFieldValue );
507  m_frame->UpdateAfterSymbolProperties( &oldFieldValue );
508  }
509  else
510  {
511  updateView( aField );
512  m_frame->GetCanvas()->Refresh();
513  m_frame->OnModify( );
514  }
515 }
516 
517 
519 {
520  LIB_PART* part = m_frame->GetCurPart();
521  bool partLocked = part->UnitsLocked();
522  wxString oldName = part->GetName();
523 
526 
528 
529  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
530  // frame. Therefore this dialog as a modal frame parent, MUST be run under
531  // quasimodal mode for the quasimodal frame support to work. So don't use
532  // the QUASIMODAL macros here.
533  if( dlg.ShowQuasiModal() != wxID_OK )
534  return;
535 
536  m_frame->OnModify();
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 
551 
553 {
554  LIB_PART* part = m_frame->GetCurPart();
555 
556  if( !part )
557  return 0;
558 
560 
562 
563  DIALOG_LIB_EDIT_PIN_TABLE dlg( m_frame, part );
564 
565  if( dlg.ShowModal() == wxID_CANCEL )
566  return -1;
567 
568  m_frame->RebuildView();
569  m_frame->OnModify();
570 
571  return 0;
572 }
573 
574 
575 int LIB_EDIT_TOOL::Undo( const TOOL_EVENT& aEvent )
576 {
578 
580  selTool->RebuildSelection();
581 
582  return 0;
583 }
584 
585 
586 int LIB_EDIT_TOOL::Redo( const TOOL_EVENT& aEvent )
587 {
589 
591  selTool->RebuildSelection();
592 
593  return 0;
594 }
595 
596 
597 int LIB_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
598 {
599  int retVal = Copy( aEvent );
600 
601  if( retVal == 0 )
602  retVal = DoDelete( aEvent );
603 
604  return retVal;
605 }
606 
607 
608 int LIB_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
609 {
610  LIB_PART* part = m_frame->GetCurPart();
612 
613  if( !part || !selection.GetSize() )
614  return 0;
615 
616  for( LIB_ITEM& item : part->GetDrawItems() )
617  {
618  if( item.Type() == LIB_FIELD_T )
619  continue;
620 
621  wxASSERT( !item.HasFlag( STRUCT_DELETED ) );
622 
623  if( !item.IsSelected() )
624  item.SetFlags( STRUCT_DELETED );
625  }
626 
627  LIB_PART* partCopy = new LIB_PART( *part );
628 
629  STRING_FORMATTER formatter;
630  SCH_LEGACY_PLUGIN::FormatPart( partCopy, formatter );
631 
632  delete partCopy;
633 
634  for( LIB_ITEM& item : part->GetDrawItems() )
635  item.ClearFlags( STRUCT_DELETED );
636 
637  if( m_toolMgr->SaveClipboard( formatter.GetString() ) )
638  return 0;
639  else
640  return -1;
641 }
642 
643 
644 int LIB_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
645 {
646  LIB_PART* part = m_frame->GetCurPart();
647 
648  if( !part )
649  return 0;
650 
651  EE_SELECTION& selection = m_selectionTool->GetSelection();
652  std::string text = m_toolMgr->GetClipboard();
653  STRING_LINE_READER reader( text, "Clipboard" );
654  LIB_PART* newPart;
655 
656  try
657  {
658  reader.ReadLine();
659  newPart = SCH_LEGACY_PLUGIN::ParsePart( reader );
660  }
661  catch( IO_ERROR& e )
662  {
663  // If it's not a part then paste as text
664  newPart = new LIB_PART( "dummy_part" );
665  LIB_TEXT* newText = new LIB_TEXT( newPart );
666  newText->SetText( text );
667  newPart->AddDrawItem( newText );
668  }
669 
670  if( !newPart )
671  return -1;
672 
673  m_frame->SaveCopyInUndoList( part );
675 
676  for( LIB_ITEM& item : newPart->GetDrawItems() )
677  {
678  if( item.Type() == LIB_FIELD_T )
679  continue;
680 
681  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
682  newItem->SetParent( part );
683  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
684 
685  newItem->SetUnit( newItem->GetUnit() ? m_frame->GetUnit() : 0 );
686  newItem->SetConvert( newItem->GetConvert() ? m_frame->GetConvert() : 0 );
687 
688  part->GetDrawItems().push_back( newItem );
689  getView()->Add( newItem );
690  }
691 
692  delete newPart;
693 
695 
696  if( !selection.Empty() )
697  {
698  selection.SetReferencePoint( getViewControls()->GetCursorPosition( true ) );
700  }
701 
702  return 0;
703 }
704 
705 
707 {
708  LIB_PART* part = m_frame->GetCurPart();
710 
711  if( selection.GetSize() == 0 )
712  return 0;
713 
714  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
715  // up dragging around a stack of objects...
716  if( selection.Front()->IsNew() )
717  return 0;
718 
719  if( !selection.Front()->IsMoving() )
721 
722  EDA_ITEMS newItems;
723 
724  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
725  {
726  LIB_ITEM* oldItem = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
727  LIB_ITEM* newItem = (LIB_ITEM*) oldItem->Clone();
728  oldItem->ClearFlags( SELECTED );
729  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
730  newItem->SetParent( part );
731  newItems.push_back( newItem );
732 
733  part->GetDrawItems().push_back( newItem );
734  getView()->Add( newItem );
735  }
736 
738  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
739 
740  selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ) ) );
742 
743  return 0;
744 }
745 
746 
748 {
749  Go( &LIB_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() );
750  Go( &LIB_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() );
751  Go( &LIB_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() );
752  Go( &LIB_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() );
753  Go( &LIB_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() );
755 
762 
766 }
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.
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
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: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
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.
LIB_PART * GetCurPart()
Return the current part being edited or NULL if none selected.
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: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: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)
#define SELECTED
Definition: base_struct.h:127
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:243
int GetUnit() const
Definition: lib_item.h:301
#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:642
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: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:130
static TOOL_ACTION cut
Definition: actions.h:69
bool EditPinProperties(LIB_PIN *aPin)
Define a library symbol object.
void UpdateAfterSymbolProperties(wxString *aOldName=nullptr)
Definition: libedit.cpp:508
#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:141
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: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:463
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.
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
size_t i
Definition: json11.cpp:649
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:237
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.