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 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include <tool/tool_manager.h>
26 #include <tools/ee_picker_tool.h>
27 #include <tools/lib_pin_tool.h>
29 #include <tools/lib_move_tool.h>
30 #include <ee_actions.h>
31 #include <ee_hotkeys.h>
32 #include <bitmaps.h>
33 #include <confirm.h>
34 #include <base_struct.h>
35 #include <sch_view.h>
36 #include <lib_edit_frame.h>
37 #include <eeschema_id.h>
43 #include <sch_legacy_plugin.h>
44 #include "lib_edit_tool.h"
45 
46 
48  EE_TOOL_BASE( "libedit.InteractiveEdit" )
49 {
50 }
51 
52 
54 {
55 }
56 
57 
59 {
61 
64 
65  wxASSERT_MSG( drawingTools, "libedit.InteractiveDrawing tool is not available" );
66 
67  //
68  // Add edit actions to the move tool menu
69  //
70  if( moveTool )
71  {
72  CONDITIONAL_MENU& moveMenu = moveTool->GetToolMenu().GetMenu();
73 
81 
83 
87  }
88 
89  //
90  // Add editing actions to the drawing tool menu
91  //
92  CONDITIONAL_MENU& drawMenu = drawingTools->GetToolMenu().GetMenu();
93 
94  drawMenu.AddSeparator( EE_CONDITIONS::NotEmpty, 200 );
99 
100  drawMenu.AddItem( EE_ACTIONS::properties, EE_CONDITIONS::Count( 1 ), 200 );
101 
102  //
103  // Add editing actions to the selection tool menu
104  //
106 
113 
114  selToolMenu.AddItem( EE_ACTIONS::properties, EE_CONDITIONS::Count( 1 ), 200 );
115 
116  selToolMenu.AddSeparator( EE_CONDITIONS::Idle, 300 );
119  selToolMenu.AddItem( ACTIONS::paste, EE_CONDITIONS::Idle, 300 );
120 
121  return true;
122 }
123 
124 
125 int LIB_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
126 {
128 
129  if( selection.GetSize() == 0 )
130  return 0;
131 
132  wxPoint rotPoint;
133  bool ccw = ( aEvent.Matches( EE_ACTIONS::rotateCCW.MakeEvent() ) );
134  LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
135 
136  if( !item->IsMoving() )
138 
139  if( selection.GetSize() == 1 )
140  rotPoint = item->GetPosition();
141  else
142  rotPoint = m_frame->GetNearestGridPosition( mapCoords( selection.GetCenter() ) );
143 
144  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
145  {
146  item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
147  item->Rotate( rotPoint, ccw );
148  m_frame->RefreshItem( item );
149  }
150 
152 
153  if( !item->IsMoving() )
154  {
155  if( selection.IsHover() )
157 
158  m_frame->OnModify();
159  }
160 
161  return 0;
162 }
163 
164 
165 int LIB_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
166 {
168 
169  if( selection.GetSize() == 0 )
170  return 0;
171 
172  wxPoint mirrorPoint;
173  bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorX.MakeEvent() ) );
174  LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
175 
176  if( !item->IsMoving() )
178 
179  if( selection.GetSize() == 1 )
180  mirrorPoint = item->GetPosition();
181  else
182  mirrorPoint = m_frame->GetNearestGridPosition( mapCoords( selection.GetCenter() ) );
183 
184  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
185  {
186  item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
187 
188  if( xAxis )
189  item->MirrorVertical( mirrorPoint );
190  else
191  item->MirrorHorizontal( mirrorPoint );
192 
193  m_frame->RefreshItem( item );
194  }
195 
197 
198  if( !item->IsMoving() )
199  {
200  if( selection.IsHover() )
202 
203  m_frame->OnModify();
204  }
205 
206  return 0;
207 }
208 
209 
210 static KICAD_T nonFields[] =
211 {
212  LIB_PART_T,
213  LIB_ALIAS_T,
214  LIB_ARC_T,
215  LIB_CIRCLE_T,
216  LIB_TEXT_T,
219  LIB_BEZIER_T,
220  LIB_PIN_T,
221  EOT
222 };
223 
224 
226 {
227  LIB_PART* part = m_frame->GetCurPart();
229 
230  if( selection.GetSize() == 0 )
231  return 0;
232 
233  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
234  // up dragging around a stack of objects...
235  if( selection.Front()->IsNew() )
236  return 0;
237 
238  if( !selection.Front()->IsMoving() )
240 
241  EDA_ITEMS newItems;
242 
243  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
244  {
245  LIB_ITEM* oldItem = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
246  LIB_ITEM* newItem = (LIB_ITEM*) oldItem->Clone();
247  newItem->SetFlags( IS_NEW );
248  newItems.push_back( newItem );
249 
250  part->GetDrawItems().push_back( newItem );
251  getView()->Add( newItem );
252  }
253 
255  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
257 
258  return 0;
259 }
260 
261 
263 {
264  LIB_PART* part = m_frame->GetCurPart();
266 
267  if( items.empty() )
268  return 0;
269 
270  // Don't leave a freed pointer in the selection
272 
274 
275  for( EDA_ITEM* item : items )
276  {
277  if( item->Type() == LIB_PIN_T )
278  {
279  LIB_PIN* pin = static_cast<LIB_PIN*>( item );
280  wxPoint pos = pin->GetPosition();
281 
282  part->RemoveDrawItem( pin );
283 
284  // when pin editing is synchronized, all pins of the same body style are removed:
285  if( m_frame->SynchronizePins() )
286  {
287  int curr_convert = pin->GetConvert();
288  LIB_PIN* next_pin = part->GetNextPin();
289 
290  while( next_pin != NULL )
291  {
292  pin = next_pin;
293  next_pin = part->GetNextPin( pin );
294 
295  if( pin->GetPosition() != pos )
296  continue;
297 
298  if( pin->GetConvert() != curr_convert )
299  continue;
300 
301  part->RemoveDrawItem( pin );
302  }
303  }
304  }
305  else
306  {
307  part->RemoveDrawItem( (LIB_ITEM*) item );
308  }
309  }
310 
311  m_frame->RebuildView();
312  m_frame->OnModify();
313 
314  return 0;
315 }
316 
317 
318 static bool deleteItem( SCH_BASE_FRAME* aFrame, const VECTOR2D& aPosition )
319 {
320  EE_SELECTION_TOOL* selectionTool = aFrame->GetToolManager()->GetTool<EE_SELECTION_TOOL>();
321  wxCHECK( selectionTool, false );
322 
324 
325  EDA_ITEM* item = selectionTool->SelectPoint( aPosition );
326 
327  if( item )
328  aFrame->GetToolManager()->RunAction( EE_ACTIONS::doDelete, true );
329 
330  return true;
331 }
332 
333 
335 {
336  Activate();
337 
339  wxCHECK( picker, 0 );
340 
341  m_frame->SetToolID( ID_LIBEDIT_DELETE_ITEM_BUTT, wxCURSOR_BULLSEYE, _( "Delete item" ) );
342  picker->SetClickHandler( std::bind( deleteItem, m_frame, std::placeholders::_1 ) );
343  picker->Activate();
344  Wait();
345 
346  return 0;
347 }
348 
349 
351 {
353 
354  if( selection.Empty() || aEvent.IsAction( &EE_ACTIONS::symbolProperties ) )
355  {
356  if( m_frame->GetCurPart() )
358  }
359  else if( selection.Size() == 1 )
360  {
361  LIB_ITEM* item = (LIB_ITEM*) selection.Front();
362 
363  // Save copy for undo if not in edit (edit command already handle the save copy)
364  if( !item->InEditMode() )
366 
367  switch( item->Type() )
368  {
369  case LIB_PIN_T:
370  {
372 
373  if( pinTool )
374  pinTool->EditPinProperties( (LIB_PIN*) item );
375 
376  break;
377  }
378  case LIB_ARC_T:
379  case LIB_CIRCLE_T:
380  case LIB_RECTANGLE_T:
381  case LIB_POLYLINE_T:
382  editGraphicProperties( item );
383  break;
384 
385  case LIB_TEXT_T:
386  editTextProperties( item );
387  break;
388 
389  case LIB_FIELD_T:
390  editFieldProperties( (LIB_FIELD*) item );
391  break;
392 
393  default:
394  wxFAIL_MSG( wxT( "Unhandled item <" ) + item->GetClass() + wxT( ">" ) );
395  break;
396  }
397  }
398 
400 
401  return 0;
402 }
403 
404 
406 {
407  if( aItem == NULL )
408  return;
409 
410  DIALOG_LIB_EDIT_DRAW_ITEM dialog( m_frame, aItem );
411 
412  if( dialog.ShowModal() != wxID_OK )
413  return;
414 
415  if( aItem->IsFillable() )
416  aItem->SetFillMode( (FILL_T) dialog.GetFillStyle() );
417 
418  aItem->SetWidth( dialog.GetWidth() );
419 
420  updateView( aItem );
421  m_frame->GetCanvas()->Refresh();
422  m_frame->OnModify( );
423 
424  m_frame->g_LastLineWidth = dialog.GetWidth();
427 
428  MSG_PANEL_ITEMS items;
429  aItem->GetMsgPanelInfo( m_frame->GetUserUnits(), items );
430  m_frame->SetMsgPanel( items );
431 }
432 
433 
435 {
436  if ( ( aItem == NULL ) || ( aItem->Type() != LIB_TEXT_T ) )
437  return;
438 
439  DIALOG_LIB_EDIT_TEXT dlg( m_frame, (LIB_TEXT*) aItem );
440 
441  if( dlg.ShowModal() != wxID_OK )
442  return;
443 
444  updateView( aItem );
445  m_frame->GetCanvas()->Refresh();
446  m_frame->OnModify( );
447 }
448 
449 
451 {
452  if( aField == NULL )
453  return;
454 
455  wxString caption;
456  LIB_PART* parent = aField->GetParent();
457  wxCHECK( parent, /* void */ );
458 
459  // Editing the component value field is equivalent to creating a new component based
460  // on the current component. Set the dialog message to inform the user.
461  if( aField->GetId() == VALUE )
462  caption = _( "Edit Component Name" );
463  else
464  caption.Printf( _( "Edit %s Field" ), GetChars( aField->GetName() ) );
465 
466  DIALOG_LIB_EDIT_ONE_FIELD dlg( m_frame, caption, aField );
467 
468  // The dialog may invoke a kiway player for footprint fields
469  // so we must use a quasimodal dialog.
470  if( dlg.ShowQuasiModal() != wxID_OK )
471  return;
472 
473  wxString newFieldValue = LIB_ID::FixIllegalChars( dlg.GetText(), LIB_ID::ID_SCH );
474  wxString oldFieldValue = aField->GetFullText( m_frame->GetUnit() );
475  bool renamed = aField->GetId() == VALUE && newFieldValue != oldFieldValue;
476 
477  if( renamed )
479  else
480  saveCopyInUndoList( parent, UR_LIBEDIT );
481 
482  dlg.UpdateField( aField );
483 
484  if( renamed )
485  {
486  parent->SetName( newFieldValue );
487  m_frame->UpdateAfterSymbolProperties( &oldFieldValue, nullptr );
488  }
489  else
490  {
491  updateView( aField );
492  m_frame->GetCanvas()->Refresh();
493  m_frame->OnModify( );
494  }
495 }
496 
497 
499 {
500  LIB_PART* part = m_frame->GetCurPart();
501  bool partLocked = part->UnitsLocked();
502  wxString oldName = part->GetName();
503  wxArrayString oldAliases = part->GetAliasNames( false );
504 
507 
509 
510  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
511  // frame. Therefore this dialog as a modal frame parent, MUST be run under
512  // quasimodal mode for the quasimodal frame support to work. So don't use
513  // the QUASIMODAL macros here.
514  if( dlg.ShowQuasiModal() != wxID_OK )
515  return;
516 
517  // if m_UnitSelectionLocked has changed, set some edit options or defaults
518  // to the best value
519  if( partLocked != part->UnitsLocked() )
520  {
521  // Enable synchronized pin edit mode for symbols with interchangeable units
522  m_frame->m_SyncPinEdit = !part->UnitsLocked();
523  // also set default edit options to the better value
524  // Usually if units are locked, graphic items are specific to each unit
525  // and if units are interchangeable, graphic items are common to units
527  }
528 
529  m_frame->UpdateAfterSymbolProperties( &oldName, &oldAliases );
530 }
531 
532 
534 {
535  LIB_PART* part = m_frame->GetCurPart();
536 
538 
540 
541  DIALOG_LIB_EDIT_PIN_TABLE dlg( m_frame, part );
542 
543  if( dlg.ShowModal() == wxID_CANCEL )
544  return -1;
545 
546  m_frame->RebuildView();
547  m_frame->OnModify();
548 
549  return 0;
550 }
551 
552 
553 int LIB_EDIT_TOOL::Undo( const TOOL_EVENT& aEvent )
554 {
556  return 0;
557 }
558 
559 
560 int LIB_EDIT_TOOL::Redo( const TOOL_EVENT& aEvent )
561 {
563  return 0;
564 }
565 
566 
567 int LIB_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
568 {
569  int retVal = Copy( aEvent );
570 
571  if( retVal == 0 )
572  retVal = DoDelete( aEvent );
573 
574  return retVal;
575 }
576 
577 
578 int LIB_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
579 {
580  LIB_PART* part = m_frame->GetCurPart();
582 
583  if( !part || !selection.GetSize() )
584  return 0;
585 
586  for( LIB_ITEM& item : part->GetDrawItems() )
587  {
588  if( item.Type() == LIB_FIELD_T )
589  continue;
590 
591  wxASSERT( ( item.GetFlags() & STRUCT_DELETED ) == 0 );
592 
593  if( !item.IsSelected() )
594  item.SetFlags( STRUCT_DELETED );
595  }
596 
597  LIB_PART* partCopy = new LIB_PART( *part );
598 
599  STRING_FORMATTER formatter;
600  SCH_LEGACY_PLUGIN::FormatPart( partCopy, formatter );
601 
602  delete partCopy;
603 
604  for( LIB_ITEM& item : part->GetDrawItems() )
605  item.ClearFlags( STRUCT_DELETED );
606 
607  if( m_toolMgr->SaveClipboard( formatter.GetString() ) )
608  return 0;
609  else
610  return -1;
611 }
612 
613 
614 int LIB_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
615 {
616  LIB_PART* part = m_frame->GetCurPart();
617 
618  if( !part )
619  return 0;
620 
621  std::string text = m_toolMgr->GetClipboard();
622  STRING_LINE_READER reader( text, "Clipboard" );
623  LIB_PART* newPart;
624  EDA_ITEMS newItems;
625 
626  try
627  {
628  reader.ReadLine();
629  newPart = SCH_LEGACY_PLUGIN::ParsePart( reader );
630  }
631  catch( IO_ERROR& e )
632  {
633  wxLogError( wxString::Format( "Malformed clipboard: %s" ), GetChars( e.What() ) );
634  return -1;
635  }
636 
637  for( LIB_ITEM& item : newPart->GetDrawItems() )
638  {
639  if( item.Type() == LIB_FIELD_T )
640  continue;
641 
642  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
643  newItem->SetFlags( IS_NEW );
644  newItems.push_back( newItem );
645 
646  part->GetDrawItems().push_back( newItem );
647  getView()->Add( newItem );
648  }
649 
650  delete newPart;
651 
653  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
655 
656  return 0;
657 }
658 
659 
661 {
669 
673 
674  Go( &LIB_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() );
675  Go( &LIB_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() );
676  Go( &LIB_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() );
677  Go( &LIB_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() );
678  Go( &LIB_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() );
679 }
virtual wxPoint GetPosition() const =0
Return the current draw object position.
wxString GetName(bool aTranslate=true) const
Returns the field name.
Definition: lib_field.cpp:408
static TOOL_ACTION pinTable
Definition: ee_actions.h:166
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.
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:124
VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
static TOOL_ACTION deleteItemCursor
Definition: ee_actions.h:167
bool IsHover() const
Definition: selection.h:69
static TOOL_ACTION duplicate
Definition: ee_actions.h:118
TOOL_MENU & GetToolMenu()
This file is part of the common library.
void setTransitions() override
Sets up handlers for various events.
Define a symbol library graphical text item.
Definition: lib_text.h:44
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:64
LIB_PART * GetParent() const
void AddSeparator(const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddSeparator()
virtual void SetWidth(int aWidth)=0
Set the width of the draw item to aWidth.
Class LIB_DRAWING_TOOLS.
bool IsMoving() const
Definition: base_struct.h:224
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION mirrorY
Definition: ee_actions.h:123
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
Field object used in symbol libraries.
Definition: lib_field.h:59
void UpdateField(LIB_FIELD *aField)
static TOOL_ACTION cancelInteractive
Definition: actions.h:45
Class VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
static SELECTION_CONDITION IdleSelection
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void UpdateAfterSymbolProperties(wxString *aOldName, wxArrayString *aOldAliases)
Definition: libedit.cpp:549
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static int g_LastLineWidth
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:139
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...
static SELECTION_CONDITION Idle
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...
TOOL_MENU & GetToolMenu()
Get the tool's top-level context menu
Definition: ee_tool_base.h:103
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:136
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_draw_item.h:67
static TOOL_ACTION rotateCW
Definition: ee_actions.h:120
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:54
bool IsNew() const
Definition: base_struct.h:222
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.
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
void editTextProperties(LIB_ITEM *aItem)
wxArrayString GetAliasNames(bool aIncludeRoot=true) const
static TOOL_ACTION copy
Definition: actions.h:53
#define VALUE
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:121
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)
void editGraphicProperties(LIB_ITEM *aItem)
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
bool InEditMode() const
Return the draw item editing mode status.
int Duplicate(const TOOL_EVENT &aEvent)
int ShowQuasiModal()
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:588
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:289
void push_back(T *aItem)
Definition: multivector.h:169
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:165
TOOL_MANAGER * GetToolManager() const override
Return the tool manager instance, if any.
Definition: draw_frame.h:937
SCH_DRAW_PANEL * GetCanvas() const override
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_field.h:99
Class TOOL_EVENT.
Definition: tool_event.h:167
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:52
bool EditPinProperties(LIB_PIN *aPin)
Define a library symbol object.
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:123
static TOOL_ACTION mirrorX
Definition: ee_actions.h:122
static TOOL_ACTION doDelete
Definition: ee_actions.h:131
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:143
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:338
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:57
static void FormatPart(LIB_PART *aPart, OUTPUTFORMATTER &aFormatter)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
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
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
void SetFillMode(FILL_T aFillMode)
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_pin.h:432
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.
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Return the nearest aGridSize location to aPosition.
static TOOL_ACTION redo
Definition: actions.h:51
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:107
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:100
bool m_SyncPinEdit
Set to true to not synchronize pins at the same position when editing symbols with multiple units or ...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
int Paste(const TOOL_EVENT &aEvent)
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
const wxString & GetName() const
std::string GetClipboard() const
Returns the information currently stored in the system clipboard.
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:331
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
void RemoveDrawItem(LIB_ITEM *aItem, EDA_DRAW_PANEL *aPanel=NULL, wxDC *aDc=NULL)
Remove draw aItem from list.
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:120
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
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:54
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:260
void Activate()
Function Activate() Runs the tool.
bool SynchronizePins()
Pin editing (add, delete, move...) can be synchronized between units when units are interchangeable b...
virtual void SetName(const wxString &aName)
static KICAD_T nonFields[]
static TOOL_ACTION move
Definition: ee_actions.h:116
Class EE_TOOL_BASE.
Definition: ee_tool_base.h:49
bool IsFillable() const
Check if draw object can be filled.
static TOOL_ACTION undo
Definition: actions.h:50
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
EDA_ITEM * SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, bool *aSelectionCancelledFlag=NULL, bool aCheckLocked=false)
Function selectPoint() Selects an item pointed by the parameter aWhere.
Basic classes for most KiCad items.
int Cut(const TOOL_EVENT &aEvent)
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:238
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
int Copy(const TOOL_EVENT &aEvent)
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
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:54
bool UnitsLocked() const
Check whether part units are interchangeable.
static bool deleteItem(SCH_BASE_FRAME *aFrame, const VECTOR2D &aPosition)
void editFieldProperties(LIB_FIELD *aField)
EDA_ITEM * Front() const
Definition: selection.h:155
int Rotate(const TOOL_EVENT &aEvent)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204