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-2020 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 <symbol_edit_frame.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_isSymbolEditor && static_cast<SYMBOL_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() )
157  {
159  }
160  else
161  {
163 
164  if( selection.IsHover() )
166 
167  m_frame->OnModify();
168  }
169 
170  return 0;
171 }
172 
173 
174 int LIB_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
175 {
177 
178  if( selection.GetSize() == 0 )
179  return 0;
180 
181  wxPoint mirrorPoint;
182  bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorX.MakeEvent() ) );
183  LIB_ITEM* item = static_cast<LIB_ITEM*>( selection.Front() );
184 
185  if( !item->IsMoving() )
187 
188  if( selection.GetSize() == 1 )
189  mirrorPoint = item->GetPosition();
190  else
191  mirrorPoint = m_frame->GetNearestGridPosition( mapCoords( selection.GetCenter() ) );
192 
193  for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
194  {
195  item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
196 
197  if( xAxis )
198  item->MirrorVertical( mirrorPoint );
199  else
200  item->MirrorHorizontal( mirrorPoint );
201 
202  m_frame->UpdateItem( item );
203  }
204 
206 
207  if( item->IsMoving() )
208  {
210  }
211  else
212  {
213  if( selection.IsHover() )
215 
216  m_frame->OnModify();
217  }
218 
219  return 0;
220 }
221 
222 
223 static KICAD_T nonFields[] =
224 {
225  LIB_PART_T,
226  LIB_ARC_T,
227  LIB_CIRCLE_T,
228  LIB_TEXT_T,
231  LIB_BEZIER_T,
232  LIB_PIN_T,
233  EOT
234 };
235 
236 
238 {
239  LIB_PART* part = m_frame->GetCurPart();
241 
242  if( items.empty() )
243  return 0;
244 
245  // Don't leave a freed pointer in the selection
247 
249 
250  std::set<LIB_ITEM *> toDelete;
251 
252  for( EDA_ITEM* item : items )
253  {
254  if( item->Type() == LIB_PIN_T )
255  {
256  LIB_PIN* pin = static_cast<LIB_PIN*>( item );
257  wxPoint pos = pin->GetPosition();
258 
259  toDelete.insert( pin );
260 
261  // when pin editing is synchronized, all pins of the same body style are removed:
262  if( m_frame->SynchronizePins() )
263  {
264  int curr_convert = pin->GetConvert();
265  LIB_PIN* next_pin = part->GetNextPin();
266 
267  while( next_pin != NULL )
268  {
269  pin = next_pin;
270  next_pin = part->GetNextPin( pin );
271 
272  if( pin->GetPosition() != pos )
273  continue;
274 
275  if( pin->GetConvert() != curr_convert )
276  continue;
277 
278  toDelete.insert( pin );
279  }
280  }
281  }
282  else
283  {
284  toDelete.insert( (LIB_ITEM*) item );
285  }
286  }
287 
288  for( LIB_ITEM* item : toDelete )
289  part->RemoveDrawItem( item );
290 
291  m_frame->RebuildView();
292  m_frame->OnModify();
293 
294  return 0;
295 }
296 
297 
298 #define HITTEST_THRESHOLD_PIXELS 5
299 
300 
302 {
303  std::string tool = aEvent.GetCommandStr().get();
305 
307  m_pickerItem = nullptr;
308 
309  // Deactivate other tools; particularly important if another PICKER is currently running
310  Activate();
311 
312  picker->SetCursor( KICURSOR::REMOVE );
313 
314  picker->SetClickHandler(
315  [this]( const VECTOR2D& aPosition ) -> bool
316  {
317  if( m_pickerItem )
318  {
320  selectionTool->UnbrightenItem( m_pickerItem );
321  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
323  m_pickerItem = nullptr;
324  }
325 
326  return true;
327  } );
328 
329  picker->SetMotionHandler(
330  [this]( const VECTOR2D& aPos )
331  {
333  EE_COLLECTOR collector;
334 
335  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
336  collector.Collect( m_frame->GetScreen(), nonFields, (wxPoint) aPos,
338 
339  // Remove unselectable items
340  for( int i = collector.GetCount() - 1; i >= 0; --i )
341  {
342  if( !selectionTool->Selectable( collector[ i ] ) )
343  collector.Remove( i );
344  }
345 
346  if( collector.GetCount() > 1 )
347  selectionTool->GuessSelectionCandidates( collector, aPos );
348 
349  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
350 
351  if( m_pickerItem != item )
352  {
353  if( m_pickerItem )
354  selectionTool->UnbrightenItem( m_pickerItem );
355 
356  m_pickerItem = item;
357 
358  if( m_pickerItem )
359  selectionTool->BrightenItem( m_pickerItem );
360  }
361  } );
362 
363  picker->SetFinalizeHandler(
364  [this]( const int& aFinalState )
365  {
366  if( m_pickerItem )
368 
369  // Wake the selection tool after exiting to ensure the cursor gets updated
371  } );
372 
373  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
374 
375  return 0;
376 }
377 
378 
380 {
382 
383  if( selection.Empty() || aEvent.IsAction( &EE_ACTIONS::symbolProperties ) )
384  {
385  if( m_frame->GetCurPart() )
387  }
388  else if( selection.Size() == 1 )
389  {
390  LIB_ITEM* item = (LIB_ITEM*) selection.Front();
391 
392  // Save copy for undo if not in edit (edit command already handle the save copy)
393  if( item->GetEditFlags() == 0 )
395 
396  switch( item->Type() )
397  {
398  case LIB_PIN_T:
399  {
401 
402  if( pinTool )
403  pinTool->EditPinProperties( (LIB_PIN*) item );
404 
405  break;
406  }
407  case LIB_ARC_T:
408  case LIB_CIRCLE_T:
409  case LIB_RECTANGLE_T:
410  case LIB_POLYLINE_T:
411  editGraphicProperties( item );
412  break;
413 
414  case LIB_TEXT_T:
415  editTextProperties( item );
416  break;
417 
418  case LIB_FIELD_T:
419  editFieldProperties( (LIB_FIELD*) item );
420  break;
421 
422  default:
423  wxFAIL_MSG( wxT( "Unhandled item <" ) + item->GetClass() + wxT( ">" ) );
424  break;
425  }
426  }
427 
429 
430  return 0;
431 }
432 
433 
435 {
436  if( aItem == NULL )
437  return;
438 
439  DIALOG_LIB_EDIT_DRAW_ITEM dialog( m_frame, aItem );
440 
441  if( dialog.ShowModal() != wxID_OK )
442  return;
443 
444  if( aItem->IsFillable() )
445  aItem->SetFillMode( (FILL_TYPE) dialog.GetFillStyle() );
446 
447  aItem->SetWidth( dialog.GetWidth() );
448 
449  if( dialog.GetApplyToAllConversions() )
450  aItem->SetConvert( 0 );
451  else
452  aItem->SetConvert( m_frame->GetConvert() );
453 
454  if( dialog.GetApplyToAllUnits() )
455  aItem->SetUnit( 0 );
456  else
457  aItem->SetUnit( m_frame->GetUnit() );
458 
459  updateItem( aItem, true );
460  m_frame->GetCanvas()->Refresh();
461  m_frame->OnModify( );
462 
464  drawingTools->SetDrawSpecificConvert( !dialog.GetApplyToAllConversions() );
465  drawingTools->SetDrawSpecificUnit( !dialog.GetApplyToAllUnits() );
466 
467  MSG_PANEL_ITEMS items;
468  aItem->GetMsgPanelInfo( m_frame, items );
469  m_frame->SetMsgPanel( items );
470 }
471 
472 
474 {
475  if ( ( aItem == NULL ) || ( aItem->Type() != LIB_TEXT_T ) )
476  return;
477 
478  DIALOG_LIB_EDIT_TEXT dlg( m_frame, (LIB_TEXT*) aItem );
479 
480  if( dlg.ShowModal() != wxID_OK )
481  return;
482 
483  updateItem( aItem, true );
484  m_frame->GetCanvas()->Refresh();
485  m_frame->OnModify( );
486 }
487 
488 
490 {
491  if( aField == NULL )
492  return;
493 
494  wxString caption;
495  LIB_PART* parent = aField->GetParent();
496  wxCHECK( parent, /* void */ );
497 
498  // Editing the component value field is equivalent to creating a new component based
499  // on the current component. Set the dialog message to inform the user.
500  if( aField->GetId() == VALUE_FIELD )
501  caption = _( "Edit Component Name" );
502  else
503  caption.Printf( _( "Edit %s Field" ), aField->GetName() );
504 
505  DIALOG_LIB_EDIT_ONE_FIELD dlg( m_frame, caption, aField );
506 
507  // The dialog may invoke a kiway player for footprint fields
508  // so we must use a quasimodal dialog.
509  if( dlg.ShowQuasiModal() != wxID_OK )
510  return;
511 
512  wxString newFieldValue = LIB_ID::FixIllegalChars( dlg.GetText(), LIB_ID::ID_SCH );
513  wxString oldFieldValue = aField->GetFullText( m_frame->GetUnit() );
514  bool renamed = aField->GetId() == VALUE_FIELD && newFieldValue != oldFieldValue;
515 
516  if( renamed )
518  else
520 
521  dlg.UpdateField( aField );
522 
523  if( renamed )
524  {
525  parent->SetName( newFieldValue );
526  m_frame->UpdateAfterSymbolProperties( &oldFieldValue );
527  }
528  else
529  {
530  updateItem( aField, true );
531  m_frame->GetCanvas()->Refresh();
532  m_frame->OnModify();
534  }
535 }
536 
537 
539 {
540  LIB_PART* part = m_frame->GetCurPart();
541  bool partLocked = part->UnitsLocked();
542  wxString oldName = part->GetName();
543 
546 
548 
549  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
550  // frame. Therefore this dialog as a modal frame parent, MUST be run under
551  // quasimodal mode for the quasimodal frame support to work. So don't use
552  // the QUASIMODAL macros here.
553  if( dlg.ShowQuasiModal() != wxID_OK )
554  return;
555 
556  m_frame->OnModify();
557 
558  // if m_UnitSelectionLocked has changed, set some edit options or defaults
559  // to the best value
560  if( partLocked != part->UnitsLocked() )
561  {
563 
564  // Enable synchronized pin edit mode for symbols with interchangeable units
565  m_frame->m_SyncPinEdit = !part->UnitsLocked();
566 
567  // also set default edit options to the better value
568  // Usually if units are locked, graphic items are specific to each unit
569  // and if units are interchangeable, graphic items are common to units
570  tools->SetDrawSpecificUnit( part->UnitsLocked() );
571  }
572 }
573 
574 
576 {
577  LIB_PART* part = m_frame->GetCurPart();
578 
579  if( !part )
580  return 0;
581 
583 
585 
586  DIALOG_LIB_EDIT_PIN_TABLE dlg( m_frame, part );
587 
588  if( dlg.ShowModal() == wxID_CANCEL )
589  return -1;
590 
591  m_frame->RebuildView();
592  m_frame->OnModify();
593 
594  return 0;
595 }
596 
597 
598 int LIB_EDIT_TOOL::Undo( const TOOL_EVENT& aEvent )
599 {
601 
603  selTool->RebuildSelection();
604 
605  return 0;
606 }
607 
608 
609 int LIB_EDIT_TOOL::Redo( const TOOL_EVENT& aEvent )
610 {
612 
614  selTool->RebuildSelection();
615 
616  return 0;
617 }
618 
619 
620 int LIB_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
621 {
622  int retVal = Copy( aEvent );
623 
624  if( retVal == 0 )
625  retVal = DoDelete( aEvent );
626 
627  return retVal;
628 }
629 
630 
631 int LIB_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
632 {
633  LIB_PART* part = m_frame->GetCurPart();
635 
636  if( !part || !selection.GetSize() )
637  return 0;
638 
639  for( LIB_ITEM& item : part->GetDrawItems() )
640  {
641  if( item.Type() == LIB_FIELD_T )
642  continue;
643 
644  wxASSERT( !item.HasFlag( STRUCT_DELETED ) );
645 
646  if( !item.IsSelected() )
647  item.SetFlags( STRUCT_DELETED );
648  }
649 
650  LIB_PART* partCopy = new LIB_PART( *part );
651 
652  STRING_FORMATTER formatter;
653  SCH_SEXPR_PLUGIN::FormatPart( partCopy, formatter );
654 
655  delete partCopy;
656 
657  for( LIB_ITEM& item : part->GetDrawItems() )
658  item.ClearFlags( STRUCT_DELETED );
659 
660  if( m_toolMgr->SaveClipboard( formatter.GetString() ) )
661  return 0;
662  else
663  return -1;
664 }
665 
666 
667 int LIB_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
668 {
669  LIB_PART* part = m_frame->GetCurPart();
670 
671  if( !part || part->IsAlias() )
672  return 0;
673 
674  std::string text_utf8 = m_toolMgr->GetClipboardUTF8();
675  STRING_LINE_READER reader( text_utf8, "Clipboard" );
676  LIB_PART* newPart;
677 
678  try
679  {
680  newPart = SCH_SEXPR_PLUGIN::ParsePart( reader );
681  }
682  catch( IO_ERROR& )
683  {
684  // If it's not a part then paste as text
685  newPart = new LIB_PART( "dummy_part" );
686  LIB_TEXT* newText = new LIB_TEXT( newPart );
687  newText->SetText( wxString::FromUTF8( text_utf8.c_str() ) );
688  newPart->AddDrawItem( newText );
689  }
690 
691  if( !newPart )
692  return -1;
693 
694  m_frame->SaveCopyInUndoList( part );
696 
697  for( LIB_ITEM& item : part->GetDrawItems() )
698  item.ClearFlags( IS_NEW | IS_PASTED | SELECTED );
699 
700  for( LIB_ITEM& item : newPart->GetDrawItems() )
701  {
702  if( item.Type() == LIB_FIELD_T )
703  continue;
704 
705  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
706  newItem->SetParent( part );
707  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
708 
709  newItem->SetUnit( newItem->GetUnit() ? m_frame->GetUnit() : 0 );
710  newItem->SetConvert( newItem->GetConvert() ? m_frame->GetConvert() : 0 );
711 
712  part->GetDrawItems().push_back( newItem );
713  getView()->Add( newItem );
714  }
715 
716  delete newPart;
717 
719 
720  EE_SELECTION& selection = m_selectionTool->GetSelection();
721 
722  if( !selection.Empty() )
723  {
724  selection.SetReferencePoint( getViewControls()->GetCursorPosition( true ) );
726  }
727 
728  return 0;
729 }
730 
731 
733 {
734  LIB_PART* part = m_frame->GetCurPart();
736 
737  if( selection.GetSize() == 0 )
738  return 0;
739 
740  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
741  // up dragging around a stack of objects...
742  if( selection.Front()->IsNew() )
743  return 0;
744 
745  if( !selection.Front()->IsMoving() )
747 
748  EDA_ITEMS newItems;
749 
750  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
751  {
752  LIB_ITEM* oldItem = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
753  LIB_ITEM* newItem = (LIB_ITEM*) oldItem->Clone();
754  oldItem->ClearFlags( IS_NEW | IS_PASTED | SELECTED );
755  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
756  newItem->SetParent( part );
757  newItems.push_back( newItem );
758 
759  part->GetDrawItems().push_back( newItem );
760  getView()->Add( newItem );
761  }
762 
764  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
765 
766  selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ) ) );
768 
769  return 0;
770 }
771 
772 
774 {
775  Go( &LIB_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() );
776  Go( &LIB_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() );
777  Go( &LIB_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() );
778  Go( &LIB_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() );
779  Go( &LIB_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() );
781 
788 
792 }
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
static TOOL_ACTION pinTable
Definition: ee_actions.h:146
static TOOL_ACTION properties
Definition: ee_actions.h:121
int m_Threshold
Definition: collector.h:66
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
bool IsHover() const
Definition: selection.h:70
FILL_TYPE
Enum class FILL_TYPE is the set of fill types used in plotting or drawing enclosed areas.
Definition: fill_type.h:29
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:83
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:73
Define a symbol library graphical text item.
Definition: lib_text.h:40
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:183
virtual void SetWidth(int aWidth)=0
LIB_DRAWING_TOOLS.
static bool Idle(const SELECTION &aSelection)
Tests if there no items selected or being edited.
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:66
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
Definition: selection.h:137
bool IsMoving() const
Definition: eda_item.h:188
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 SetFillMode(FILL_TYPE aFillMode)
Definition: lib_item.h:301
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.
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
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:141
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.
static void FormatPart(LIB_PART *aPart, OUTPUTFORMATTER &aFormatter)
int GetId() const
Definition: lib_field.h:138
virtual wxPoint GetPosition() const
Definition: eda_item.h:325
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:213
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:184
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:365
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:97
The base class for drawable items used by schematic library components.
Definition: lib_item.h:62
static TOOL_ACTION rotateCW
Definition: ee_actions.h:117
Field Value of part, i.e. "3.3K".
bool IsNew() const
Definition: eda_item.h:187
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:153
void UpdateAfterSymbolProperties(wxString *aOldName=nullptr)
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:103
EE_SELECTION & GetSelection()
Function GetSelection()
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
void editTextProperties(LIB_ITEM *aItem)
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:262
int GetUnit() const
Definition: lib_item.h:296
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 DisplaySymbolDatasheet()
Display the documentation of the selected symbol.
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: eda_item.h:220
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:138
STATUS_FLAGS GetEditFlags() const
Definition: eda_item.h:225
std::string GetClipboardUTF8() const
Returns the information currently stored in the system clipboard.
int Duplicate(const TOOL_EVENT &aEvent)
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
int ShowQuasiModal()
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.
void SaveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT, bool aAppend=false)
Create a copy of the current symbol, and save it in the undo list.
#define SELECTED
Definition: eda_item.h:113
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_field.h:95
TOOL_EVENT.
Definition: tool_event.h:171
int Undo(const TOOL_EVENT &aEvent)
virtual void Rotate(const wxPoint &aCenter, bool aRotateCCW=true)=0
Rotate the object about aCenter point.
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:131
static TOOL_ACTION cut
Definition: actions.h:69
bool EditPinProperties(LIB_PIN *aPin)
Define a library symbol object.
static TOOL_ACTION mirrorX
Definition: ee_actions.h:119
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:181
int Redo(const TOOL_EVENT &aEvent)
const std::string & GetString()
Definition: richio.h:476
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
#define STRUCT_DELETED
flag indication structures to be erased
Definition: eda_item.h:115
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
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:576
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
int DeleteItemCursor(const TOOL_EVENT &aEvent)
Runs the deletion tool.
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:104
const wxString & GetText() const
int GetConvert() const
Definition: lib_item.h:299
LIB_PART * GetCurPart()
Return the current part being edited or NULL if none selected.
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:50
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...
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
void updateItem(EDA_ITEM *aItem, bool aUpdateRTree) const
Similar to getView()->Update(), but handles items that are redrawn by their parents and updating the ...
Definition: ee_tool_base.h:107
void AddSeparator(int aOrder=ANY_ORDER)
Adds a separator to the menu.
void SetConvert(int aConvert)
Definition: lib_item.h:298
wxPoint GetPosition() const override
Definition: lib_pin.h:258
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:99
LIB_PIN * GetNextPin(LIB_PIN *aItem=NULL)
Return the next pin object from the draw list.
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: eda_item.h:119
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:295
static TOOL_ACTION redo
Definition: actions.h:68
bool SaveClipboard(const std::string &aTextUTF8)
Stores an information to the system clipboard.
int PinTable(const TOOL_EVENT &aEvent)
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
bool IsAlias() const
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:297
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
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
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:221
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:293
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:327
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:255
void SetDrawSpecificConvert(bool aSpecific)
STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:446
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:274
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
#define IS_NEW
New item, just created.
Definition: eda_item.h:106
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
EDA_ITEM * Front() const
Definition: selection.h:201
int Rotate(const TOOL_EVENT &aEvent)
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
void RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.