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  auto havePartCondition =
64  [&]( const SELECTION& sel )
65  {
66  return m_isLibEdit && static_cast<LIB_EDIT_FRAME*>( m_frame )->GetCurPart();
67  };
68 
69  // Add edit actions to the move tool menu
70  //
71  if( moveTool )
72  {
73  CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
74 
75  moveMenu.AddSeparator( 200 );
81 
83 
84  moveMenu.AddSeparator( 300 );
88 
89  moveMenu.AddSeparator( 400 );
90  moveMenu.AddItem( ACTIONS::selectAll, havePartCondition, 400 );
91  }
92 
93  // Add editing actions to the drawing tool menu
94  //
95  CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
96 
97  drawMenu.AddSeparator( 200 );
102 
103  drawMenu.AddItem( EE_ACTIONS::properties, EE_CONDITIONS::Count( 1 ), 200 );
104 
105  // Add editing actions to the selection tool menu
106  //
108 
114 
115  selToolMenu.AddItem( EE_ACTIONS::properties, EE_CONDITIONS::Count( 1 ), 200 );
116 
117  selToolMenu.AddSeparator( 300 );
120  selToolMenu.AddItem( ACTIONS::paste, EE_CONDITIONS::Idle, 300 );
122 
123  selToolMenu.AddSeparator( 400 );
124  selToolMenu.AddItem( ACTIONS::selectAll, havePartCondition, 400 );
125 
126  return true;
127 }
128 
129 
130 int LIB_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
131 {
133 
134  if( selection.GetSize() == 0 )
135  return 0;
136 
137  wxPoint rotPoint;
138  bool ccw = ( aEvent.Matches( EE_ACTIONS::rotateCCW.MakeEvent() ) );
139  LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
140 
141  if( !item->IsMoving() )
143 
144  if( selection.GetSize() == 1 )
145  rotPoint = item->GetPosition();
146  else
147  rotPoint = m_frame->GetNearestGridPosition( mapCoords( selection.GetCenter() ) );
148 
149  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
150  {
151  item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
152  item->Rotate( rotPoint, ccw );
153  m_frame->UpdateItem( item );
154  }
155 
156  if( item->IsMoving() )
158  else
159  {
161 
162  if( selection.IsHover() )
164 
165  m_frame->OnModify();
166  }
167 
168  return 0;
169 }
170 
171 
172 int LIB_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
173 {
175 
176  if( selection.GetSize() == 0 )
177  return 0;
178 
179  wxPoint mirrorPoint;
180  bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorX.MakeEvent() ) );
181  LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
182 
183  if( !item->IsMoving() )
185 
186  if( selection.GetSize() == 1 )
187  mirrorPoint = item->GetPosition();
188  else
189  mirrorPoint = m_frame->GetNearestGridPosition( mapCoords( selection.GetCenter() ) );
190 
191  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
192  {
193  item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
194 
195  if( xAxis )
196  item->MirrorVertical( mirrorPoint );
197  else
198  item->MirrorHorizontal( mirrorPoint );
199 
200  m_frame->UpdateItem( item );
201  }
202 
204 
205  if( item->IsMoving() )
207  else
208  {
209  if( selection.IsHover() )
211 
212  m_frame->OnModify();
213  }
214 
215  return 0;
216 }
217 
218 
219 static KICAD_T nonFields[] =
220 {
221  LIB_PART_T,
222  LIB_ARC_T,
223  LIB_CIRCLE_T,
224  LIB_TEXT_T,
227  LIB_BEZIER_T,
228  LIB_PIN_T,
229  EOT
230 };
231 
232 
234 {
235  LIB_PART* part = m_frame->GetCurPart();
237 
238  if( items.empty() )
239  return 0;
240 
241  // Don't leave a freed pointer in the selection
243 
245 
246  std::set<LIB_ITEM *> toDelete;
247 
248  for( EDA_ITEM* item : items )
249  {
250  if( item->Type() == LIB_PIN_T )
251  {
252  LIB_PIN* pin = static_cast<LIB_PIN*>( item );
253  wxPoint pos = pin->GetPosition();
254 
255  toDelete.insert( pin );
256 
257  // when pin editing is synchronized, all pins of the same body style are removed:
258  if( m_frame->SynchronizePins() )
259  {
260  int curr_convert = pin->GetConvert();
261  LIB_PIN* next_pin = part->GetNextPin();
262 
263  while( next_pin != NULL )
264  {
265  pin = next_pin;
266  next_pin = part->GetNextPin( pin );
267 
268  if( pin->GetPosition() != pos )
269  continue;
270 
271  if( pin->GetConvert() != curr_convert )
272  continue;
273 
274  toDelete.insert( pin );
275  }
276  }
277  }
278  else
279  {
280  toDelete.insert( (LIB_ITEM*) item );
281  }
282  }
283 
284  for( auto item : toDelete )
285  {
286  part->RemoveDrawItem( item );
287  }
288 
289  m_frame->RebuildView();
290  m_frame->OnModify();
291 
292  return 0;
293 }
294 
295 
296 #define HITTEST_THRESHOLD_PIXELS 5
297 
298 
300 {
301  std::string tool = aEvent.GetCommandStr().get();
303 
305  m_pickerItem = nullptr;
306 
307  // Deactivate other tools; particularly important if another PICKER is currently running
308  Activate();
309 
310  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
311 
312  picker->SetClickHandler(
313  [this] ( const VECTOR2D& aPosition ) -> bool
314  {
315  if( m_pickerItem )
316  {
318  selectionTool->UnbrightenItem( m_pickerItem );
319  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
321  m_pickerItem = nullptr;
322  }
323 
324  return true;
325  } );
326 
327  picker->SetMotionHandler(
328  [this] ( const VECTOR2D& aPos )
329  {
331  EE_COLLECTOR collector;
332  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
333  collector.Collect( m_frame->GetScreen(), nonFields, (wxPoint) aPos, m_frame->GetUnit(),
334  m_frame->GetConvert() );
335 
336  // Remove unselectable items
337  for( int i = collector.GetCount() - 1; i >= 0; --i )
338  {
339  if( !selectionTool->Selectable( collector[ i ] ) )
340  collector.Remove( i );
341  }
342 
343  if( collector.GetCount() > 1 )
344  selectionTool->GuessSelectionCandidates( collector, aPos );
345 
346  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
347 
348  if( m_pickerItem != item )
349  {
350  if( m_pickerItem )
351  selectionTool->UnbrightenItem( m_pickerItem );
352 
353  m_pickerItem = item;
354 
355  if( m_pickerItem )
356  selectionTool->BrightenItem( m_pickerItem );
357  }
358  } );
359 
360  picker->SetFinalizeHandler(
361  [this] ( const int& aFinalState )
362  {
363  if( m_pickerItem )
365  } );
366 
367  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
368 
369  return 0;
370 }
371 
372 
374 {
376 
377  if( selection.Empty() || aEvent.IsAction( &EE_ACTIONS::symbolProperties ) )
378  {
379  if( m_frame->GetCurPart() )
381  }
382  else if( selection.Size() == 1 )
383  {
384  LIB_ITEM* item = (LIB_ITEM*) selection.Front();
385 
386  // Save copy for undo if not in edit (edit command already handle the save copy)
387  if( item->GetEditFlags() == 0 )
389 
390  switch( item->Type() )
391  {
392  case LIB_PIN_T:
393  {
395 
396  if( pinTool )
397  pinTool->EditPinProperties( (LIB_PIN*) item );
398 
399  break;
400  }
401  case LIB_ARC_T:
402  case LIB_CIRCLE_T:
403  case LIB_RECTANGLE_T:
404  case LIB_POLYLINE_T:
405  editGraphicProperties( item );
406  break;
407 
408  case LIB_TEXT_T:
409  editTextProperties( item );
410  break;
411 
412  case LIB_FIELD_T:
413  editFieldProperties( (LIB_FIELD*) item );
414  break;
415 
416  default:
417  wxFAIL_MSG( wxT( "Unhandled item <" ) + item->GetClass() + wxT( ">" ) );
418  break;
419  }
420  }
421 
423 
424  return 0;
425 }
426 
427 
429 {
430  if( aItem == NULL )
431  return;
432 
433  DIALOG_LIB_EDIT_DRAW_ITEM dialog( m_frame, aItem );
434 
435  if( dialog.ShowModal() != wxID_OK )
436  return;
437 
438  if( aItem->IsFillable() )
439  aItem->SetFillMode( (FILL_T) dialog.GetFillStyle() );
440 
441  aItem->SetWidth( dialog.GetWidth() );
442 
443  if( dialog.GetApplyToAllConversions() )
444  aItem->SetConvert( 0 );
445  else
446  aItem->SetConvert( m_frame->GetConvert() );
447 
448  if( dialog.GetApplyToAllUnits() )
449  aItem->SetUnit( 0 );
450  else
451  aItem->SetUnit( m_frame->GetUnit() );
452 
453  updateView( aItem );
454  m_frame->GetCanvas()->Refresh();
455  m_frame->OnModify( );
456 
458  drawingTools->SetDrawSpecificConvert( !dialog.GetApplyToAllConversions() );
459  drawingTools->SetDrawSpecificUnit( !dialog.GetApplyToAllUnits() );
460 
461  MSG_PANEL_ITEMS items;
462  aItem->GetMsgPanelInfo( m_frame, items );
463  m_frame->SetMsgPanel( items );
464 }
465 
466 
468 {
469  if ( ( aItem == NULL ) || ( aItem->Type() != LIB_TEXT_T ) )
470  return;
471 
472  DIALOG_LIB_EDIT_TEXT dlg( m_frame, (LIB_TEXT*) aItem );
473 
474  if( dlg.ShowModal() != wxID_OK )
475  return;
476 
477  updateView( aItem );
478  m_frame->GetCanvas()->Refresh();
479  m_frame->OnModify( );
480 }
481 
482 
484 {
485  if( aField == NULL )
486  return;
487 
488  wxString caption;
489  LIB_PART* parent = aField->GetParent();
490  wxCHECK( parent, /* void */ );
491 
492  // Editing the component value field is equivalent to creating a new component based
493  // on the current component. Set the dialog message to inform the user.
494  if( aField->GetId() == VALUE )
495  caption = _( "Edit Component Name" );
496  else
497  caption.Printf( _( "Edit %s Field" ), aField->GetName() );
498 
499  DIALOG_LIB_EDIT_ONE_FIELD dlg( m_frame, caption, aField );
500 
501  // The dialog may invoke a kiway player for footprint fields
502  // so we must use a quasimodal dialog.
503  if( dlg.ShowQuasiModal() != wxID_OK )
504  return;
505 
506  wxString newFieldValue = LIB_ID::FixIllegalChars( dlg.GetText(), LIB_ID::ID_SCH );
507  wxString oldFieldValue = aField->GetFullText( m_frame->GetUnit() );
508  bool renamed = aField->GetId() == VALUE && newFieldValue != oldFieldValue;
509 
510  if( renamed )
512  else
514 
515  dlg.UpdateField( aField );
516 
517  if( renamed )
518  {
519  parent->SetName( newFieldValue );
520  m_frame->UpdateAfterSymbolProperties( &oldFieldValue );
521  }
522  else
523  {
524  updateView( aField );
525  m_frame->GetCanvas()->Refresh();
526  m_frame->OnModify();
528  }
529 }
530 
531 
533 {
534  LIB_PART* part = m_frame->GetCurPart();
535  bool partLocked = part->UnitsLocked();
536  wxString oldName = part->GetName();
537 
540 
542 
543  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
544  // frame. Therefore this dialog as a modal frame parent, MUST be run under
545  // quasimodal mode for the quasimodal frame support to work. So don't use
546  // the QUASIMODAL macros here.
547  if( dlg.ShowQuasiModal() != wxID_OK )
548  return;
549 
550  m_frame->OnModify();
551 
552  // if m_UnitSelectionLocked has changed, set some edit options or defaults
553  // to the best value
554  if( partLocked != part->UnitsLocked() )
555  {
557 
558  // Enable synchronized pin edit mode for symbols with interchangeable units
559  m_frame->m_SyncPinEdit = !part->UnitsLocked();
560 
561  // also set default edit options to the better value
562  // Usually if units are locked, graphic items are specific to each unit
563  // and if units are interchangeable, graphic items are common to units
564  tools->SetDrawSpecificUnit( part->UnitsLocked() );
565  }
566 }
567 
568 
570 {
571  LIB_PART* part = m_frame->GetCurPart();
572 
573  if( !part )
574  return 0;
575 
577 
579 
580  DIALOG_LIB_EDIT_PIN_TABLE dlg( m_frame, part );
581 
582  if( dlg.ShowModal() == wxID_CANCEL )
583  return -1;
584 
585  m_frame->RebuildView();
586  m_frame->OnModify();
587 
588  return 0;
589 }
590 
591 
592 int LIB_EDIT_TOOL::Undo( const TOOL_EVENT& aEvent )
593 {
595 
597  selTool->RebuildSelection();
598 
599  return 0;
600 }
601 
602 
603 int LIB_EDIT_TOOL::Redo( const TOOL_EVENT& aEvent )
604 {
606 
608  selTool->RebuildSelection();
609 
610  return 0;
611 }
612 
613 
614 int LIB_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
615 {
616  int retVal = Copy( aEvent );
617 
618  if( retVal == 0 )
619  retVal = DoDelete( aEvent );
620 
621  return retVal;
622 }
623 
624 
625 int LIB_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
626 {
627  LIB_PART* part = m_frame->GetCurPart();
629 
630  if( !part || !selection.GetSize() )
631  return 0;
632 
633  for( LIB_ITEM& item : part->GetDrawItems() )
634  {
635  if( item.Type() == LIB_FIELD_T )
636  continue;
637 
638  wxASSERT( !item.HasFlag( STRUCT_DELETED ) );
639 
640  if( !item.IsSelected() )
641  item.SetFlags( STRUCT_DELETED );
642  }
643 
644  LIB_PART* partCopy = new LIB_PART( *part );
645 
646  STRING_FORMATTER formatter;
647  SCH_SEXPR_PLUGIN::FormatPart( partCopy, formatter );
648 
649  delete partCopy;
650 
651  for( LIB_ITEM& item : part->GetDrawItems() )
652  item.ClearFlags( STRUCT_DELETED );
653 
654  if( m_toolMgr->SaveClipboard( formatter.GetString() ) )
655  return 0;
656  else
657  return -1;
658 }
659 
660 
661 int LIB_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
662 {
663  LIB_PART* part = m_frame->GetCurPart();
664 
665  if( !part )
666  return 0;
667 
668  std::string text = m_toolMgr->GetClipboard();
669  STRING_LINE_READER reader( text, "Clipboard" );
670  LIB_PART* newPart;
671 
672  try
673  {
674  newPart = SCH_SEXPR_PLUGIN::ParsePart( reader );
675  }
676  catch( IO_ERROR& )
677  {
678  // If it's not a part then paste as text
679  newPart = new LIB_PART( "dummy_part" );
680  LIB_TEXT* newText = new LIB_TEXT( newPart );
681  newText->SetText( text );
682  newPart->AddDrawItem( newText );
683  }
684 
685  if( !newPart )
686  return -1;
687 
688  m_frame->SaveCopyInUndoList( part );
690 
691  for( LIB_ITEM& item : part->GetDrawItems() )
692  item.ClearFlags( IS_NEW | IS_PASTED | SELECTED );
693 
694  for( LIB_ITEM& item : newPart->GetDrawItems() )
695  {
696  if( item.Type() == LIB_FIELD_T )
697  continue;
698 
699  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
700  newItem->SetParent( part );
701  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
702 
703  newItem->SetUnit( newItem->GetUnit() ? m_frame->GetUnit() : 0 );
704  newItem->SetConvert( newItem->GetConvert() ? m_frame->GetConvert() : 0 );
705 
706  part->GetDrawItems().push_back( newItem );
707  getView()->Add( newItem );
708  }
709 
710  delete newPart;
711 
713 
714  EE_SELECTION& selection = m_selectionTool->GetSelection();
715 
716  if( !selection.Empty() )
717  {
718  selection.SetReferencePoint( getViewControls()->GetCursorPosition( true ) );
720  }
721 
722  return 0;
723 }
724 
725 
727 {
728  LIB_PART* part = m_frame->GetCurPart();
730 
731  if( selection.GetSize() == 0 )
732  return 0;
733 
734  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
735  // up dragging around a stack of objects...
736  if( selection.Front()->IsNew() )
737  return 0;
738 
739  if( !selection.Front()->IsMoving() )
741 
742  EDA_ITEMS newItems;
743 
744  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
745  {
746  LIB_ITEM* oldItem = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
747  LIB_ITEM* newItem = (LIB_ITEM*) oldItem->Clone();
748  oldItem->ClearFlags( IS_NEW | IS_PASTED | SELECTED );
749  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
750  newItem->SetParent( part );
751  newItems.push_back( newItem );
752 
753  part->GetDrawItems().push_back( newItem );
754  getView()->Add( newItem );
755  }
756 
758  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
759 
760  selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ) ) );
762 
763  return 0;
764 }
765 
766 
768 {
769  Go( &LIB_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() );
770  Go( &LIB_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() );
771  Go( &LIB_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() );
772  Go( &LIB_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() );
773  Go( &LIB_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() );
775 
782 
786 }
static TOOL_ACTION pinTable
Definition: ee_actions.h:146
static TOOL_ACTION properties
Definition: ee_actions.h:121
void SetCursor(const wxCursor &aCursor)
Definition: picker_tool.h:65
int m_Threshold
Definition: collector.h:67
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
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:75
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
void SaveCopyInUndoList(EDA_ITEM *ItemToCopy, UNDO_REDO undoType=UNDO_REDO::LIBEDIT, bool aAppend=false)
Create a copy of the current component, and save it in the undo list.
LIB_DRAWING_TOOLS.
static bool Idle(const SELECTION &aSelection)
Tests if there no items selected or being edited.
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:120
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.
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
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
static SELECTION_CONDITION Count(int aNumber)
Creates a functor that tests if the number of selected items is equal to the value given as parameter...
static bool IdleSelection(const SELECTION &aSelection)
Tests if all selected items are not being edited.
static bool NotEmpty(const SELECTION &aSelection)
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:211
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:117
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
static TOOL_ACTION pickerTool
Definition: actions.h:151
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
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:118
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:121
#define NULL
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aType, bool aAppend=false)
Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.
Definition: ee_tool_base.h:117
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:588
void push_back(T *aItem)
Definition: multivector.h:169
void SetDrawSpecificUnit(bool aSpecific)
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:145
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:119
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:160
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.
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 DisplayCmpDoc()
Display the documentation of the selected component.
Definition: symbedit.cpp:204
void AddSeparator(int aOrder=ANY_ORDER)
Adds a separator to the menu.
void SetConvert(int aConvert)
Definition: lib_item.h:297
wxPoint GetPosition() const override
Definition: lib_pin.h:254
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
Field Value of part, i.e. "3.3K".
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)
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
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:76
static TOOL_ACTION move
Definition: ee_actions.h:114
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:345
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:273
int Copy(const TOOL_EVENT &aEvent)
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Adds a menu entry to run a TOOL_ACTION on selected items.
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 selectAll
Definition: actions.h:73
static TOOL_ACTION paste
Definition: actions.h:71
bool UnitsLocked() const
Check whether part units are interchangeable.
static TOOL_ACTION duplicate
Definition: actions.h:74
void editFieldProperties(LIB_FIELD *aField)
static TOOL_ACTION refreshPreview
Definition: actions.h:104
#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.