KiCad PCB EDA Suite
LIB_EDIT_TOOL Class Reference

#include <lib_edit_tool.h>

Inheritance diagram for LIB_EDIT_TOOL:
EE_TOOL_BASE< LIB_EDIT_FRAME > TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 LIB_EDIT_TOOL ()
 
 ~LIB_EDIT_TOOL () override
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
int Rotate (const TOOL_EVENT &aEvent)
 
int Mirror (const TOOL_EVENT &aEvent)
 
int Duplicate (const TOOL_EVENT &aEvent)
 
int Properties (const TOOL_EVENT &aEvent)
 
int PinTable (const TOOL_EVENT &aEvent)
 
int Undo (const TOOL_EVENT &aEvent)
 
int Redo (const TOOL_EVENT &aEvent)
 
int Cut (const TOOL_EVENT &aEvent)
 
int Copy (const TOOL_EVENT &aEvent)
 
int Paste (const TOOL_EVENT &aEvent)
 
int DoDelete (const TOOL_EVENT &aEvent)
 Function DoDelete() More...
 
int DeleteItemCursor (const TOOL_EVENT &aEvent)
 

Runs the deletion tool.

More...
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
void Activate ()
 Function Activate() Runs the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Protected Member Functions

void updateView (EDA_ITEM *aItem) const
 

Similar to getView()->Update(), but handles items that are redrawn by their parents.

More...
 
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.

More...
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

LIB_EDIT_FRAMEm_frame
 
KIGFX::SCH_VIEWm_view
 
EE_SELECTION_TOOLm_selectionTool
 
bool m_isLibEdit
 
TOOL_MENU m_menu
 functions below are not yet implemented - their interface may change More...
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

void editGraphicProperties (LIB_ITEM *aItem)
 
void editTextProperties (LIB_ITEM *aItem)
 
void editFieldProperties (LIB_FIELD *aField)
 
void editSymbolProperties ()
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 

Private Attributes

EDA_ITEMm_pickerItem
 

Detailed Description

Definition at line 34 of file lib_edit_tool.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 79 of file tool_base.h.

80  {
81  RUN,
82  MODEL_RELOAD,
83  GAL_SWITCH
84  };
Model changes (required full reload)
Definition: tool_base.h:82
Tool is invoked after being inactive.
Definition: tool_base.h:81
Rendering engine changes.
Definition: tool_base.h:83

Constructor & Destructor Documentation

◆ LIB_EDIT_TOOL()

LIB_EDIT_TOOL::LIB_EDIT_TOOL ( )

Definition at line 47 of file lib_edit_tool.cpp.

47  :
48  EE_TOOL_BASE( "eeschema.SymbolEditTool" )
49 {
50 }
EE_TOOL_BASE(const std::string &aName)
Constructor.
Definition: ee_tool_base.h:58

◆ ~LIB_EDIT_TOOL()

LIB_EDIT_TOOL::~LIB_EDIT_TOOL ( )
inlineoverride

Definition at line 38 of file lib_edit_tool.h.

38 { }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

After activation, the tool starts receiving events until it is finished.

Definition at line 51 of file tool_interactive.cpp.

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.

References TOOL_MANAGER::InvokeTool(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), LIB_TREE::onContextMenu(), POINT_EDITOR::OnSelectionChange(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

Sets the TOOL_MANAGER the tool will belong to. Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

61 {
62  m_toolMgr = aManager;
63  m_toolSettings = TOOL_SETTINGS( this );
64 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:220
friend class TOOL_SETTINGS
Definition: tool_base.h:154

References TOOL_BASE::m_toolMgr, TOOL_BASE::m_toolSettings, and TOOL_BASE::TOOL_SETTINGS.

Referenced by TOOL_MANAGER::RegisterTool().

◆ Copy()

int LIB_EDIT_TOOL::Copy ( const TOOL_EVENT aEvent)

Definition at line 610 of file lib_edit_tool.cpp.

611 {
612  LIB_PART* part = m_frame->GetCurPart();
614 
615  if( !part || !selection.GetSize() )
616  return 0;
617 
618  for( LIB_ITEM& item : part->GetDrawItems() )
619  {
620  if( item.Type() == LIB_FIELD_T )
621  continue;
622 
623  wxASSERT( !item.HasFlag( STRUCT_DELETED ) );
624 
625  if( !item.IsSelected() )
626  item.SetFlags( STRUCT_DELETED );
627  }
628 
629  LIB_PART* partCopy = new LIB_PART( *part );
630 
631  STRING_FORMATTER formatter;
632  SCH_LEGACY_PLUGIN::FormatPart( partCopy, formatter );
633 
634  delete partCopy;
635 
636  for( LIB_ITEM& item : part->GetDrawItems() )
637  item.ClearFlags( STRUCT_DELETED );
638 
639  if( m_toolMgr->SaveClipboard( formatter.GetString() ) )
640  return 0;
641  else
642  return -1;
643 }
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
bool SaveClipboard(const std::string &aText)
Stores an information to the system clipboard.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
The base class for drawable items used by schematic library components.
Definition: lib_item.h:61
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Define a library symbol object.
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:129
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:140
const std::string & GetString()
Definition: richio.h:475
static void FormatPart(LIB_PART *aPart, OUTPUTFORMATTER &aFormatter)
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:98
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:266
static KICAD_T nonFields[]
Class STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445

References EDA_ITEM::ClearFlags(), SCH_LEGACY_PLUGIN::FormatPart(), LIB_EDIT_FRAME::GetCurPart(), LIB_PART::GetDrawItems(), SELECTION::GetSize(), STRING_FORMATTER::GetString(), LIB_FIELD_T, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, nonFields, EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::SaveClipboard(), and STRUCT_DELETED.

Referenced by Cut(), and setTransitions().

◆ Cut()

int LIB_EDIT_TOOL::Cut ( const TOOL_EVENT aEvent)

Definition at line 599 of file lib_edit_tool.cpp.

600 {
601  int retVal = Copy( aEvent );
602 
603  if( retVal == 0 )
604  retVal = DoDelete( aEvent );
605 
606  return retVal;
607 }
int DoDelete(const TOOL_EVENT &aEvent)
Function DoDelete()
int Copy(const TOOL_EVENT &aEvent)

References Copy(), and DoDelete().

Referenced by setTransitions().

◆ DeleteItemCursor()

int LIB_EDIT_TOOL::DeleteItemCursor ( const TOOL_EVENT aEvent)

Runs the deletion tool.

Definition at line 287 of file lib_edit_tool.cpp.

288 {
289  std::string tool = aEvent.GetCommandStr().get();
291 
293  m_pickerItem = nullptr;
294 
295  // Deactivate other tools; particularly important if another PICKER is currently running
296  Activate();
297 
298  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
299 
300  picker->SetClickHandler(
301  [this] ( const VECTOR2D& aPosition ) -> bool
302  {
303  if( m_pickerItem )
304  {
306  selectionTool->UnbrightenItem( m_pickerItem );
307  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
309  m_pickerItem = nullptr;
310  }
311 
312  return true;
313  } );
314 
315  picker->SetMotionHandler(
316  [this] ( const VECTOR2D& aPos )
317  {
319  EE_COLLECTOR collector;
320  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
321  collector.Collect( m_frame->GetCurPart(), nonFields, (wxPoint) aPos,
323 
324  // Remove unselectable items
325  for( int i = collector.GetCount() - 1; i >= 0; --i )
326  {
327  if( !selectionTool->Selectable( collector[ i ] ) )
328  collector.Remove( i );
329  }
330 
331  if( collector.GetCount() > 1 )
332  selectionTool->GuessSelectionCandidates( collector, aPos );
333 
334  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
335 
336  if( m_pickerItem != item )
337  {
338  if( m_pickerItem )
339  selectionTool->UnbrightenItem( m_pickerItem );
340 
341  m_pickerItem = item;
342 
343  if( m_pickerItem )
344  selectionTool->BrightenItem( m_pickerItem );
345  }
346  } );
347 
348  picker->SetFinalizeHandler(
349  [this] ( const int& aFinalState )
350  {
351  if( m_pickerItem )
353  } );
354 
355  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
356 
357  return 0;
358 }
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
void SetCursor(const wxCursor &aCursor)
Definition: picker_tool.h:65
int m_Threshold
Definition: collector.h:68
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:82
int GetConvert() const
static TOOL_ACTION doDelete
Definition: actions.h:74
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:72
EDA_ITEM * m_pickerItem
Definition: lib_edit_tool.h:77
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
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.
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
static TOOL_ACTION pickerTool
Definition: actions.h:145
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
Definition: picker_tool.h:102
void BrightenItem(EDA_ITEM *aItem)
int GetUnit() const
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
#define HITTEST_THRESHOLD_PIXELS
void UnbrightenItem(EDA_ITEM *aItem)
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:455
int AddItemToSel(const TOOL_EVENT &aEvent)
size_t i
Definition: json11.cpp:597
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 Activate()
Function Activate() Runs the tool.
static KICAD_T nonFields[]
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

References TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::BrightenItem(), EE_ACTIONS::clearSelection, ACTIONS::doDelete, TOOL_EVENT::GetCommandStr(), LIB_EDIT_FRAME::GetConvert(), LIB_EDIT_FRAME::GetCurPart(), TOOL_MANAGER::GetTool(), LIB_EDIT_FRAME::GetUnit(), TOOL_BASE::getView(), EE_SELECTION_TOOL::GuessSelectionCandidates(), HITTEST_THRESHOLD_PIXELS, i, KiROUND(), EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, m_pickerItem, COLLECTOR::m_Threshold, TOOL_BASE::m_toolMgr, nonFields, ACTIONS::pickerTool, TOOL_MANAGER::RunAction(), EE_SELECTION_TOOL::Selectable(), PICKER_TOOL::SetClickHandler(), PICKER_TOOL::SetCursor(), PICKER_TOOL::SetFinalizeHandler(), PICKER_TOOL::SetMotionHandler(), and EE_SELECTION_TOOL::UnbrightenItem().

Referenced by setTransitions().

◆ DoDelete()

int LIB_EDIT_TOOL::DoDelete ( const TOOL_EVENT aEvent)

Function DoDelete()

Deletes the selected items, or the item under the cursor.

Definition at line 221 of file lib_edit_tool.cpp.

222 {
223  LIB_PART* part = m_frame->GetCurPart();
225 
226  if( items.empty() )
227  return 0;
228 
229  // Don't leave a freed pointer in the selection
231 
233 
234  std::set<LIB_ITEM *> toDelete;
235 
236  for( EDA_ITEM* item : items )
237  {
238  if( item->Type() == LIB_PIN_T )
239  {
240  LIB_PIN* pin = static_cast<LIB_PIN*>( item );
241  wxPoint pos = pin->GetPosition();
242 
243  toDelete.insert( pin );
244 
245  // when pin editing is synchronized, all pins of the same body style are removed:
246  if( m_frame->SynchronizePins() )
247  {
248  int curr_convert = pin->GetConvert();
249  LIB_PIN* next_pin = part->GetNextPin();
250 
251  while( next_pin != NULL )
252  {
253  pin = next_pin;
254  next_pin = part->GetNextPin( pin );
255 
256  if( pin->GetPosition() != pos )
257  continue;
258 
259  if( pin->GetConvert() != curr_convert )
260  continue;
261 
262  toDelete.insert( pin );
263  }
264  }
265  }
266  else
267  {
268  toDelete.insert( (LIB_ITEM*) item );
269  }
270  }
271 
272  for( auto item : toDelete )
273  {
274  part->RemoveDrawItem( item );
275  }
276 
277  m_frame->RebuildView();
278  m_frame->OnModify();
279 
280  return 0;
281 }
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
The base class for drawable items used by schematic library components.
Definition: lib_item.h:61
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:130
Define a library symbol object.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:140
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
int GetConvert() const
Definition: lib_item.h:304
wxPoint GetPosition() const override
Definition: lib_pin.h:427
LIB_PIN * GetNextPin(LIB_PIN *aItem=NULL)
Return the next pin object from the draw 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: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.
static KICAD_T nonFields[]
void RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.

References EE_ACTIONS::clearSelection, LIB_ITEM::GetConvert(), LIB_EDIT_FRAME::GetCurPart(), SELECTION::GetItems(), LIB_PART::GetNextPin(), LIB_PIN::GetPosition(), LIB_PIN_T, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, nonFields, LIB_EDIT_FRAME::OnModify(), LIB_EDIT_FRAME::RebuildView(), LIB_PART::RemoveDrawItem(), EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EE_TOOL_BASE< LIB_EDIT_FRAME >::saveCopyInUndoList(), LIB_EDIT_FRAME::SynchronizePins(), and UR_LIBEDIT.

Referenced by Cut(), and setTransitions().

◆ Duplicate()

int LIB_EDIT_TOOL::Duplicate ( const TOOL_EVENT aEvent)

Definition at line 708 of file lib_edit_tool.cpp.

709 {
710  LIB_PART* part = m_frame->GetCurPart();
712 
713  if( selection.GetSize() == 0 )
714  return 0;
715 
716  // Doing a duplicate of a new object doesn't really make any sense; we'd just end
717  // up dragging around a stack of objects...
718  if( selection.Front()->IsNew() )
719  return 0;
720 
721  if( !selection.Front()->IsMoving() )
723 
724  EDA_ITEMS newItems;
725 
726  for( unsigned ii = 0; ii < selection.GetSize(); ++ii )
727  {
728  LIB_ITEM* oldItem = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
729  LIB_ITEM* newItem = (LIB_ITEM*) oldItem->Clone();
730  oldItem->ClearFlags( SELECTED );
731  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
732  newItem->SetParent( part );
733  newItems.push_back( newItem );
734 
735  part->GetDrawItems().push_back( newItem );
736  getView()->Add( newItem );
737  }
738 
740  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &newItems );
741 
742  selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ) ) );
744 
745  return 0;
746 }
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:65
bool IsMoving() const
Definition: base_struct.h:230
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
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
bool IsNew() const
Definition: base_struct.h:228
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
#define SELECTED
Definition: base_struct.h:127
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:243
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:623
void push_back(T *aItem)
Definition: multivector.h:169
Define a library symbol object.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:140
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:103
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:98
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
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:266
static KICAD_T nonFields[]
static TOOL_ACTION move
Definition: ee_actions.h:115
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
#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

References KIGFX::VIEW::Add(), EE_ACTIONS::addItemsToSel, EDA_ITEM::ClearFlags(), EE_ACTIONS::clearSelection, EDA_ITEM::Clone(), SELECTION::Front(), LIB_EDIT_FRAME::GetCurPart(), LIB_PART::GetDrawItems(), SELECTION::GetItem(), SELECTION::GetSize(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), IS_NEW, IS_PASTED, EDA_ITEM::IsMoving(), EDA_ITEM::IsNew(), EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, KIGFX::mapCoords(), EE_ACTIONS::move, nonFields, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::push_back(), EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EE_TOOL_BASE< LIB_EDIT_FRAME >::saveCopyInUndoList(), SELECTED, SELECTION::SetReferencePoint(), and UR_LIBEDIT.

Referenced by setTransitions().

◆ editFieldProperties()

void LIB_EDIT_TOOL::editFieldProperties ( LIB_FIELD aField)
private

Definition at line 471 of file lib_edit_tool.cpp.

472 {
473  if( aField == NULL )
474  return;
475 
476  wxString caption;
477  LIB_PART* parent = aField->GetParent();
478  wxCHECK( parent, /* void */ );
479 
480  // Editing the component value field is equivalent to creating a new component based
481  // on the current component. Set the dialog message to inform the user.
482  if( aField->GetId() == VALUE )
483  caption = _( "Edit Component Name" );
484  else
485  caption.Printf( _( "Edit %s Field" ), GetChars( aField->GetName() ) );
486 
487  DIALOG_LIB_EDIT_ONE_FIELD dlg( m_frame, caption, aField );
488 
489  // The dialog may invoke a kiway player for footprint fields
490  // so we must use a quasimodal dialog.
491  if( dlg.ShowQuasiModal() != wxID_OK )
492  return;
493 
494  wxString newFieldValue = LIB_ID::FixIllegalChars( dlg.GetText(), LIB_ID::ID_SCH );
495  wxString oldFieldValue = aField->GetFullText( m_frame->GetUnit() );
496  bool renamed = aField->GetId() == VALUE && newFieldValue != oldFieldValue;
497 
498  if( renamed )
500  else
501  saveCopyInUndoList( parent, UR_LIBEDIT );
502 
503  dlg.UpdateField( aField );
504 
505  if( renamed )
506  {
507  parent->SetName( newFieldValue );
508  m_frame->UpdateAfterSymbolProperties( &oldFieldValue, nullptr );
509  }
510  else
511  {
512  updateView( aField );
513  m_frame->GetCanvas()->Refresh();
514  m_frame->OnModify( );
515  }
516 }
wxString GetName(bool aTranslate=true) const
Returns the field name.
Definition: lib_field.cpp:366
LIB_PART * GetParent() const
Definition: lib_item.h:177
void UpdateAfterSymbolProperties(wxString *aOldName, wxArrayString *aOldAliases)
Definition: libedit.cpp:486
int GetId() const
Definition: lib_field.h:135
#define VALUE
Class DIALOG_LIB_EDIT_ONE_FIELD is a the class to handle editing a single component field in the libr...
int GetUnit() const
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Define a library symbol object.
#define _(s)
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 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
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:300
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
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
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
virtual void SetName(const wxString &aName)

References _, LIB_ID::FixIllegalChars(), SCH_BASE_FRAME::GetCanvas(), GetChars(), LIB_FIELD::GetFullText(), LIB_FIELD::GetId(), LIB_FIELD::GetName(), LIB_ITEM::GetParent(), DIALOG_EDIT_ONE_FIELD::GetText(), LIB_EDIT_FRAME::GetUnit(), LIB_ID::ID_SCH, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, LIB_EDIT_FRAME::OnModify(), EDA_DRAW_PANEL_GAL::Refresh(), EE_TOOL_BASE< LIB_EDIT_FRAME >::saveCopyInUndoList(), LIB_PART::SetName(), DIALOG_SHIM::ShowQuasiModal(), LIB_EDIT_FRAME::UpdateAfterSymbolProperties(), DIALOG_LIB_EDIT_ONE_FIELD::UpdateField(), EE_TOOL_BASE< LIB_EDIT_FRAME >::updateView(), UR_LIB_RENAME, UR_LIBEDIT, and VALUE.

Referenced by Properties().

◆ editGraphicProperties()

void LIB_EDIT_TOOL::editGraphicProperties ( LIB_ITEM aItem)
private

Definition at line 416 of file lib_edit_tool.cpp.

417 {
418  if( aItem == NULL )
419  return;
420 
421  DIALOG_LIB_EDIT_DRAW_ITEM dialog( m_frame, aItem );
422 
423  if( dialog.ShowModal() != wxID_OK )
424  return;
425 
426  if( aItem->IsFillable() )
427  aItem->SetFillMode( (FILL_T) dialog.GetFillStyle() );
428 
429  aItem->SetWidth( dialog.GetWidth() );
430 
431  if( dialog.GetApplyToAllConversions() )
432  aItem->SetConvert( 0 );
433  else
434  aItem->SetConvert( m_frame->GetConvert() );
435 
436  if( dialog.GetApplyToAllUnits() )
437  aItem->SetUnit( 0 );
438  else
439  aItem->SetUnit( m_frame->GetUnit() );
440 
441  updateView( aItem );
442  m_frame->GetCanvas()->Refresh();
443  m_frame->OnModify( );
444 
445  m_frame->g_LastLineWidth = dialog.GetWidth();
446  m_frame->m_DrawSpecificConvert = !dialog.GetApplyToAllConversions();
447  m_frame->m_DrawSpecificUnit = !dialog.GetApplyToAllUnits();
448 
449  MSG_PANEL_ITEMS items;
450  aItem->GetMsgPanelInfo( m_frame->GetUserUnits(), items );
451  m_frame->SetMsgPanel( items );
452 }
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.
int GetConvert() const
virtual void SetWidth(int aWidth)=0
static int g_LastLineWidth
bool m_DrawSpecificConvert
Convert of the item currently being drawn.
int GetUnit() const
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
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
void SetConvert(int aConvert)
Definition: lib_item.h:303
Dialog to edit library component graphic items.
void SetUnit(int aUnit)
Definition: lib_item.h:300
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
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
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
FILL_T
Enum FILL_T is the set of fill types used in plotting or drawing enclosed areas.
Definition: base_struct.h:42
bool IsFillable() const
Check if draw object can be filled.
Definition: lib_item.h:296

References LIB_EDIT_FRAME::g_LastLineWidth, DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllConversions(), DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllUnits(), SCH_BASE_FRAME::GetCanvas(), LIB_EDIT_FRAME::GetConvert(), DIALOG_LIB_EDIT_DRAW_ITEM::GetFillStyle(), LIB_ITEM::GetMsgPanelInfo(), LIB_EDIT_FRAME::GetUnit(), EDA_BASE_FRAME::GetUserUnits(), DIALOG_LIB_EDIT_DRAW_ITEM::GetWidth(), LIB_ITEM::IsFillable(), LIB_EDIT_FRAME::m_DrawSpecificConvert, LIB_EDIT_FRAME::m_DrawSpecificUnit, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, LIB_EDIT_FRAME::OnModify(), EDA_DRAW_PANEL_GAL::Refresh(), LIB_ITEM::SetConvert(), LIB_ITEM::SetFillMode(), EDA_DRAW_FRAME::SetMsgPanel(), LIB_ITEM::SetUnit(), LIB_ITEM::SetWidth(), and EE_TOOL_BASE< LIB_EDIT_FRAME >::updateView().

Referenced by Properties().

◆ editSymbolProperties()

void LIB_EDIT_TOOL::editSymbolProperties ( )
private

Definition at line 519 of file lib_edit_tool.cpp.

520 {
521  LIB_PART* part = m_frame->GetCurPart();
522  bool partLocked = part->UnitsLocked();
523  wxString oldName = part->GetName();
524  wxArrayString oldAliases = part->GetAliasNames( false );
525 
528 
530 
531  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
532  // frame. Therefore this dialog as a modal frame parent, MUST be run under
533  // quasimodal mode for the quasimodal frame support to work. So don't use
534  // the QUASIMODAL macros here.
535  if( dlg.ShowQuasiModal() != wxID_OK )
536  return;
537 
538  // if m_UnitSelectionLocked has changed, set some edit options or defaults
539  // to the best value
540  if( partLocked != part->UnitsLocked() )
541  {
542  // Enable synchronized pin edit mode for symbols with interchangeable units
543  m_frame->m_SyncPinEdit = !part->UnitsLocked();
544  // also set default edit options to the better value
545  // Usually if units are locked, graphic items are specific to each unit
546  // and if units are interchangeable, graphic items are common to units
548  }
549 
550  m_frame->UpdateAfterSymbolProperties( &oldName, &oldAliases );
551 }
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.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
void UpdateAfterSymbolProperties(wxString *aOldName, wxArrayString *aOldAliases)
Definition: libedit.cpp:486
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
wxArrayString GetAliasNames(bool aIncludeRoot=true) const
Define a library symbol object.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
const wxString & GetName() const
bool UnitsLocked() const
Check whether part units are interchangeable.

References ACTIONS::cancelInteractive, EE_ACTIONS::clearSelection, LIB_PART::GetAliasNames(), LIB_EDIT_FRAME::GetCurPart(), LIB_PART::GetName(), LIB_EDIT_FRAME::m_DrawSpecificUnit, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, LIB_EDIT_FRAME::m_SyncPinEdit, TOOL_BASE::m_toolMgr, TOOL_MANAGER::RunAction(), DIALOG_SHIM::ShowQuasiModal(), LIB_PART::UnitsLocked(), and LIB_EDIT_FRAME::UpdateAfterSymbolProperties().

Referenced by Properties().

◆ editTextProperties()

void LIB_EDIT_TOOL::editTextProperties ( LIB_ITEM aItem)
private

Definition at line 455 of file lib_edit_tool.cpp.

456 {
457  if ( ( aItem == NULL ) || ( aItem->Type() != LIB_TEXT_T ) )
458  return;
459 
460  DIALOG_LIB_EDIT_TEXT dlg( m_frame, (LIB_TEXT*) aItem );
461 
462  if( dlg.ShowModal() != wxID_OK )
463  return;
464 
465  updateView( aItem );
466  m_frame->GetCanvas()->Refresh();
467  m_frame->OnModify( );
468 }
Define a symbol library graphical text item.
Definition: lib_text.h:40
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
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 updateView(EDA_ITEM *aItem) const
Similar to getView()->Update(), but handles items that are redrawn by their parents.
Definition: ee_tool_base.h:104
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

References SCH_BASE_FRAME::GetCanvas(), LIB_TEXT_T, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, LIB_EDIT_FRAME::OnModify(), EDA_DRAW_PANEL_GAL::Refresh(), EDA_ITEM::Type(), and EE_TOOL_BASE< LIB_EDIT_FRAME >::updateView().

Referenced by Properties().

◆ getEditFrame()

template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

Returns the application window object, casted to requested user type.

Definition at line 187 of file tool_base.h.

188  {
189 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
190  wxASSERT( dynamic_cast<T*>( getEditFrameInt() ) );
191 #endif
192  return static_cast<T*>( getEditFrameInt() );
193  }
EDA_BASE_FRAME * getEditFrameInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getEditFrameInt().

Referenced by ZONE_CREATE_HELPER::createNewZone(), and TOOL_SETTINGS::getConfigBase().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Function GetId() Returns the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 121 of file tool_base.h.

122  {
123  return m_toolId;
124  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214

References TOOL_BASE::m_toolId.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::saveViewControls().

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER. If there is no TOOL_MANAGER associated, it returns NULL.

Definition at line 143 of file tool_base.h.

144  {
145  return m_toolMgr;
146  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), LIB_TREE::onContextMenu(), ZONE_CREATE_HELPER::OnFirstPoint(), ACTION_MENU::OnMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ getModel()

template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 201 of file tool_base.h.

202  {
203  EDA_ITEM* m = getModelInt();
204 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
205  wxASSERT( dynamic_cast<T*>( m ) );
206 #endif
207  return static_cast<T*>( m );
208  }
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:54
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163

References TOOL_BASE::getModelInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), ZONE_CREATE_HELPER::createZoneFromExisting(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ GetName()

const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Function GetName() Returns the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 132 of file tool_base.h.

133  {
134  return m_toolName;
135  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:218

References TOOL_BASE::m_toolName.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_SETTINGS::getKeyName(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), and TOOL_MANAGER::RegisterTool().

◆ GetSettings()

TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 78 of file tool_base.cpp.

79 {
80  return m_toolSettings;
81 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:220

References TOOL_BASE::m_toolSettings.

Referenced by ROUTER_TOOL::Init(), GERBVIEW_SELECTION_TOOL::selectable(), and ROUTER_TOOL::~ROUTER_TOOL().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 110 of file tool_base.h.

111  {
112  return m_type;
113  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:211

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), and TOOL_MANAGER::runTool().

◆ getView()

KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Function getView()

Returns the instance of VIEW object used in the application. It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

37 {
38  return m_toolMgr->GetView();
39 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:241
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219

References TOOL_MANAGER::GetView(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), COMMON_TOOLS::CursorControl(), DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PL_DRAWING_TOOLS::DrawShape(), PCB_EDITOR_CONTROL::DrillOrigin(), Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), COMMON_TOOLS::GridPreset(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::GuessSelectionCandidates(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), SELECTION_TOOL::Selectable(), GERBVIEW_SELECTION_TOOL::selectable(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), PL_EDITOR_CONTROL::ToggleBackgroundColor(), COMMON_TOOLS::ToggleGrid(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PCBNEW_CONTROL::updateGrid(), EE_POINT_EDITOR::updateItem(), PL_POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_TOOL_BASE::view(), COMMON_TOOLS::ZoomFitScreen(), SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited

Function getViewControls()

Returns the instance of VIEW_CONTROLS object used in the application. It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.)

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

43 {
44  return m_toolMgr->GetViewControls();
45 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:246

References TOOL_MANAGER::GetViewControls(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCorner(), POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), COMMON_TOOLS::GridPreset(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::HighlightNetTool(), MODULE_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), Paste(), ROUTER_TOOL::performDragging(), LIB_DRAWING_TOOLS::PlaceAnchor(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCBNEW_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), LIB_MOVE_TOOL::updateModificationPoint(), PL_EDIT_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Function Go()

Defines which state (aStateFunc) to go when a certain event arrives (aConditions). No conditions means any event.

Definition at line 129 of file tool_interactive.h.

131 {
132  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
133 
134  goInternal( sptr, aConditions );
135 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by LENGTH_TUNER_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_CONTROL::setTransitions(), LIB_PIN_TOOL::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), COMMON_CONTROL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), SCH_MOVE_TOOL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), POINT_EDITOR::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), LIB_CONTROL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), setTransitions(), SCH_EDIT_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), PCBNEW_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), EE_SELECTION_TOOL::setTransitions(), and DRC::setTransitions().

◆ Init()

bool LIB_EDIT_TOOL::Init ( )
overridevirtual

Function Init() Init() is called once upon a registration of the tool.

Returns
True if the initialization went fine, false - otherwise.

Reimplemented from TOOL_BASE.

Definition at line 53 of file lib_edit_tool.cpp.

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 }
static TOOL_ACTION properties
Definition: ee_actions.h:122
static TOOL_ACTION doDelete
Definition: actions.h:74
Class LIB_DRAWING_TOOLS.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION mirrorY
Definition: ee_actions.h:121
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static SELECTION_CONDITION IdleSelection
TOOL_MENU & GetToolMenu()
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...
static bool NotEmpty(const SELECTION &aSelection)
Function NotEmpty Tests if there are any items selected.
static TOOL_ACTION rotateCW
Definition: ee_actions.h:118
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
static TOOL_ACTION copy
Definition: actions.h:70
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:119
static TOOL_ACTION cut
Definition: actions.h:69
static TOOL_ACTION mirrorX
Definition: ee_actions.h:120
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:140
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
static TOOL_ACTION paste
Definition: actions.h:71
static TOOL_ACTION duplicate
Definition: actions.h:73

References CONDITIONAL_MENU::AddItem(), CONDITIONAL_MENU::AddSeparator(), ACTIONS::copy, SELECTION_CONDITIONS::Count(), ACTIONS::cut, ACTIONS::doDelete, ACTIONS::duplicate, TOOL_MENU::GetMenu(), TOOL_MANAGER::GetTool(), TOOL_INTERACTIVE::GetToolMenu(), EE_CONDITIONS::Idle, EE_CONDITIONS::IdleSelection, EE_TOOL_BASE< T >::Init(), EE_TOOL_BASE< LIB_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, EE_ACTIONS::mirrorX, EE_ACTIONS::mirrorY, SELECTION_CONDITIONS::NotEmpty(), ACTIONS::paste, EE_ACTIONS::properties, EE_ACTIONS::rotateCCW, and EE_ACTIONS::rotateCW.

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32 {
33  return m_toolMgr->IsToolActive( m_toolId );
34 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
bool IsToolActive(TOOL_ID aId) const
Function IsToolActive() Returns true if a tool with given id is active (executing)

References TOOL_MANAGER::IsToolActive(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

◆ Mirror()

int LIB_EDIT_TOOL::Mirror ( const TOOL_EVENT aEvent)

Definition at line 159 of file lib_edit_tool.cpp.

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 }
virtual wxPoint GetPosition() const =0
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
bool IsHover() const
Definition: selection.h:69
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
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
virtual void MirrorHorizontal(const wxPoint &aCenter)=0
Mirror the draw object along the horizontal (X) axis about aCenter point.
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:201
The base class for drawable items used by schematic library components.
Definition: lib_item.h:61
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
static TOOL_ACTION mirrorX
Definition: ee_actions.h:120
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:140
bool Matches(const TOOL_EVENT &aEvent) const
Function Matches() Tests whether two events match in terms of category & action or command.
Definition: tool_event.h:356
virtual void MirrorVertical(const wxPoint &aCenter)=0
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:103
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:98
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
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
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:228
static TOOL_ACTION refreshPreview
Definition: actions.h:101
EDA_ITEM * Front() const
Definition: selection.h:182

References EE_ACTIONS::clearSelection, SELECTION::Front(), SELECTION::GetCenter(), LIB_EDIT_FRAME::GetCurPart(), SELECTION::GetItem(), EDA_DRAW_FRAME::GetNearestGridPosition(), LIB_ITEM::GetPosition(), SELECTION::GetSize(), SELECTION::IsHover(), EDA_ITEM::IsMoving(), EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, KIGFX::mapCoords(), TOOL_EVENT::Matches(), LIB_ITEM::MirrorHorizontal(), LIB_ITEM::MirrorVertical(), EE_ACTIONS::mirrorX, LIB_EDIT_FRAME::OnModify(), TOOL_MANAGER::PostEvent(), SCH_BASE_FRAME::RefreshItem(), ACTIONS::refreshPreview, EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), EE_TOOL_BASE< LIB_EDIT_FRAME >::saveCopyInUndoList(), EVENTS::SelectedItemsModified, and UR_LIBEDIT.

Referenced by setTransitions().

◆ Paste()

int LIB_EDIT_TOOL::Paste ( const TOOL_EVENT aEvent)

Definition at line 646 of file lib_edit_tool.cpp.

647 {
648  LIB_PART* part = m_frame->GetCurPart();
649 
650  if( !part )
651  return 0;
652 
653  EE_SELECTION& selection = m_selectionTool->GetSelection();
654  std::string text = m_toolMgr->GetClipboard();
655  STRING_LINE_READER reader( text, "Clipboard" );
656  LIB_PART* newPart;
657 
658  try
659  {
660  reader.ReadLine();
661  newPart = SCH_LEGACY_PLUGIN::ParsePart( reader );
662  }
663  catch( IO_ERROR& e )
664  {
665  // If it's not a part then paste as text
666  newPart = new LIB_PART( "dummy_part" );
667  LIB_TEXT* newText = new LIB_TEXT( newPart );
668  newText->SetText( text );
669  newPart->AddDrawItem( newText );
670  }
671 
672  if( !newPart )
673  return -1;
674 
675  m_frame->SaveCopyInUndoList( part );
677 
678  for( LIB_ITEM& item : newPart->GetDrawItems() )
679  {
680  if( item.Type() == LIB_FIELD_T )
681  continue;
682 
683  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
684  newItem->SetParent( part );
685  newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED );
686 
687  newItem->SetUnit( m_frame->m_DrawSpecificUnit ? m_frame->GetUnit() : 0 );
689 
690  part->GetDrawItems().push_back( newItem );
691  getView()->Add( newItem );
692  }
693 
694  delete newPart;
695 
697 
698  if( !selection.Empty() )
699  {
700  selection.SetReferencePoint( getViewControls()->GetCursorPosition( true ) );
702  }
703 
704  return 0;
705 }
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.
int GetConvert() const
Define a symbol library graphical text item.
Definition: lib_text.h:40
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
static LIB_PART * ParsePart(LINE_READER &aReader, int majorVersion=0, int minorVersion=0)
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
bool m_DrawSpecificConvert
Convert of the item currently being drawn.
void AddDrawItem(LIB_ITEM *aItem)
Add a new draw aItem to the draw object list.
EE_SELECTION & GetSelection()
Function GetSelection()
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
#define SELECTED
Definition: base_struct.h:127
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:243
int GetUnit() const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:265
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:126
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:225
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
void push_back(T *aItem)
Definition: multivector.h:169
Define a library symbol object.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:140
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
void SetConvert(int aConvert)
Definition: lib_item.h:303
void SetUnit(int aUnit)
Definition: lib_item.h:300
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
std::string GetClipboard() const
Returns the information currently stored in the system clipboard.
void RebuildSelection()
Rebuilds the selection from the EDA_ITEMs' selection flags.
static TOOL_ACTION move
Definition: ee_actions.h:115
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
Class STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
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
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.
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: base_struct.h:133

References KIGFX::VIEW::Add(), LIB_PART::AddDrawItem(), EE_SELECTION_TOOL::ClearSelection(), EDA_ITEM::Clone(), SELECTION::Empty(), TOOL_MANAGER::GetClipboard(), LIB_EDIT_FRAME::GetConvert(), LIB_EDIT_FRAME::GetCurPart(), LIB_PART::GetDrawItems(), EE_SELECTION_TOOL::GetSelection(), LIB_EDIT_FRAME::GetUnit(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), IS_NEW, IS_PASTED, LIB_FIELD_T, LIB_EDIT_FRAME::m_DrawSpecificConvert, LIB_EDIT_FRAME::m_DrawSpecificUnit, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, EE_ACTIONS::move, SCH_LEGACY_PLUGIN::ParsePart(), MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::push_back(), STRING_LINE_READER::ReadLine(), EE_SELECTION_TOOL::RebuildSelection(), TOOL_MANAGER::RunAction(), LIB_EDIT_FRAME::SaveCopyInUndoList(), SELECTED, LIB_ITEM::SetConvert(), EDA_ITEM::SetFlags(), EDA_ITEM::SetParent(), SELECTION::SetReferencePoint(), EDA_TEXT::SetText(), and LIB_ITEM::SetUnit().

Referenced by setTransitions().

◆ PinTable()

int LIB_EDIT_TOOL::PinTable ( const TOOL_EVENT aEvent)

Definition at line 554 of file lib_edit_tool.cpp.

555 {
556  LIB_PART* part = m_frame->GetCurPart();
557 
558  if( !part )
559  return 0;
560 
562 
564 
565  DIALOG_LIB_EDIT_PIN_TABLE dlg( m_frame, part );
566 
567  if( dlg.ShowModal() == wxID_CANCEL )
568  return -1;
569 
570  m_frame->RebuildView();
571  m_frame->OnModify();
572 
573  return 0;
574 }
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
Define a library symbol object.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
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
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.

References EE_ACTIONS::clearSelection, LIB_EDIT_FRAME::GetCurPart(), EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, LIB_EDIT_FRAME::OnModify(), LIB_EDIT_FRAME::RebuildView(), TOOL_MANAGER::RunAction(), EE_TOOL_BASE< LIB_EDIT_FRAME >::saveCopyInUndoList(), and UR_LIBEDIT.

Referenced by setTransitions().

◆ Properties()

int LIB_EDIT_TOOL::Properties ( const TOOL_EVENT aEvent)

Definition at line 361 of file lib_edit_tool.cpp.

362 {
364 
365  if( selection.Empty() || aEvent.IsAction( &EE_ACTIONS::symbolProperties ) )
366  {
367  if( m_frame->GetCurPart() )
369  }
370  else if( selection.Size() == 1 )
371  {
372  LIB_ITEM* item = (LIB_ITEM*) selection.Front();
373 
374  // Save copy for undo if not in edit (edit command already handle the save copy)
375  if( item->GetEditFlags() == 0 )
377 
378  switch( item->Type() )
379  {
380  case LIB_PIN_T:
381  {
383 
384  if( pinTool )
385  pinTool->EditPinProperties( (LIB_PIN*) item );
386 
387  break;
388  }
389  case LIB_ARC_T:
390  case LIB_CIRCLE_T:
391  case LIB_RECTANGLE_T:
392  case LIB_POLYLINE_T:
393  editGraphicProperties( item );
394  break;
395 
396  case LIB_TEXT_T:
397  editTextProperties( item );
398  break;
399 
400  case LIB_FIELD_T:
401  editFieldProperties( (LIB_FIELD*) item );
402  break;
403 
404  default:
405  wxFAIL_MSG( wxT( "Unhandled item <" ) + item->GetClass() + wxT( ">" ) );
406  break;
407  }
408  }
409 
411 
412  return 0;
413 }
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
LIB_PART * GetParent() const
Definition: lib_item.h:177
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
Field object used in symbol libraries.
Definition: lib_field.h:59
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:201
The base class for drawable items used by schematic library components.
Definition: lib_item.h:61
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:63
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
void editTextProperties(LIB_ITEM *aItem)
void editSymbolProperties()
void editGraphicProperties(LIB_ITEM *aItem)
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:270
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:149
bool EditPinProperties(LIB_PIN *aPin)
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:140
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
virtual wxString GetClass() const =0
Function GetClass returns the class name.
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
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:228
void editFieldProperties(LIB_FIELD *aField)
EDA_ITEM * Front() const
Definition: selection.h:182
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

References editFieldProperties(), editGraphicProperties(), LIB_PIN_TOOL::EditPinProperties(), editSymbolProperties(), editTextProperties(), SELECTION::Empty(), SELECTION::Front(), LIB_FIELD::GetClass(), LIB_EDIT_FRAME::GetCurPart(), EDA_ITEM::GetEditFlags(), LIB_ITEM::GetParent(), TOOL_MANAGER::GetTool(), TOOL_EVENT::IsAction(), LIB_ARC_T, LIB_CIRCLE_T, LIB_FIELD_T, LIB_PIN_T, LIB_POLYLINE_T, LIB_RECTANGLE_T, LIB_TEXT_T, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, TOOL_MANAGER::PostEvent(), EE_SELECTION_TOOL::RequestSelection(), EE_TOOL_BASE< LIB_EDIT_FRAME >::saveCopyInUndoList(), EVENTS::SelectedItemsModified, SELECTION::Size(), EE_ACTIONS::symbolProperties, EDA_ITEM::Type(), and UR_LIBEDIT.

Referenced by setTransitions().

◆ Redo()

int LIB_EDIT_TOOL::Redo ( const TOOL_EVENT aEvent)

Definition at line 588 of file lib_edit_tool.cpp.

589 {
591 
593  selTool->RebuildSelection();
594 
595  return 0;
596 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void GetComponentFromRedoList()
void RebuildSelection()
Rebuilds the selection from the EDA_ITEMs' selection flags.

References LIB_EDIT_FRAME::GetComponentFromRedoList(), TOOL_MANAGER::GetTool(), EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, and EE_SELECTION_TOOL::RebuildSelection().

Referenced by setTransitions().

◆ Reset()

void EE_TOOL_BASE< LIB_EDIT_FRAME >::Reset ( RESET_REASON  aReason)
inlineoverridevirtualinherited

Function Reset() Brings the tool to a known, initial state.

If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Implements TOOL_BASE.

Definition at line 90 of file ee_tool_base.h.

91  {
92  if( aReason == MODEL_RELOAD )
93  {
94  // Init variables used by every drawing tool
95  m_frame = getEditFrame<T>();
96  m_isLibEdit = dynamic_cast<LIB_EDIT_FRAME*>( m_frame ) != nullptr;
97  }
98 
99  m_view = static_cast<KIGFX::SCH_VIEW*>( getView() );
100  }
Model changes (required full reload)
Definition: tool_base.h:82
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36

◆ Rotate()

int LIB_EDIT_TOOL::Rotate ( const TOOL_EVENT aEvent)

Definition at line 117 of file lib_edit_tool.cpp.

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 }
virtual wxPoint GetPosition() const =0
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
bool IsHover() const
Definition: selection.h:69
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
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:201
The base class for drawable items used by schematic library components.
Definition: lib_item.h:61
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:119
virtual void Rotate(const wxPoint &aCenter, bool aRotateCCW=true)=0
Rotate the object about aCenter point.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:140
bool Matches(const TOOL_EVENT &aEvent) const
Function Matches() Tests whether two events match in terms of category & action or command.
Definition: tool_event.h:356
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:103
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:98
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
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
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:228
static TOOL_ACTION refreshPreview
Definition: actions.h:101
EDA_ITEM * Front() const
Definition: selection.h:182

References EE_ACTIONS::clearSelection, SELECTION::Front(), SELECTION::GetCenter(), LIB_EDIT_FRAME::GetCurPart(), SELECTION::GetItem(), EDA_DRAW_FRAME::GetNearestGridPosition(), LIB_ITEM::GetPosition(), SELECTION::GetSize(), SELECTION::IsHover(), EDA_ITEM::IsMoving(), EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, EE_TOOL_BASE< LIB_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, KIGFX::mapCoords(), TOOL_EVENT::Matches(), LIB_EDIT_FRAME::OnModify(), TOOL_MANAGER::PostEvent(), SCH_BASE_FRAME::RefreshItem(), ACTIONS::refreshPreview, EE_SELECTION_TOOL::RequestSelection(), LIB_ITEM::Rotate(), EE_ACTIONS::rotateCCW, TOOL_MANAGER::RunAction(), EE_TOOL_BASE< LIB_EDIT_FRAME >::saveCopyInUndoList(), EVENTS::SelectedItemsModified, and UR_LIBEDIT.

Referenced by setTransitions().

◆ RunMainStack()

void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

88 {
89  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
90 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::RunMainStack().

Referenced by DRAWING_TOOL::PlaceText().

◆ saveCopyInUndoList()

void EE_TOOL_BASE< LIB_EDIT_FRAME >::saveCopyInUndoList ( EDA_ITEM aItem,
UNDO_REDO_T  aType,
bool  aAppend = false 
)
inlineprotectedinherited

Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.

Definition at line 117 of file ee_tool_base.h.

118  {
119  KICAD_T itemType = aItem->Type();
120 
121  if( m_isLibEdit )
122  {
123  LIB_EDIT_FRAME* editFrame = dynamic_cast<LIB_EDIT_FRAME*>( m_frame );
124  editFrame->SaveCopyInUndoList( (LIB_ITEM*) aItem, aType, aAppend );
125  }
126  else
127  {
128  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
129 
130  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
131  editFrame->SaveCopyInUndoList( (SCH_ITEM*) aItem->GetParent(), UR_CHANGED, aAppend );
132  else
133  editFrame->SaveCopyInUndoList( (SCH_ITEM*) aItem, aType, aAppend );
134  }
135  }
Schematic editor (Eeschema) main window.
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
The base class for drawable items used by schematic library components.
Definition: lib_item.h:61
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
EDA_ITEM * GetParent() const
Definition: base_struct.h:220
The symbol library editor main window.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
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.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

◆ SetContextMenu()

void TOOL_INTERACTIVE::SetContextMenu ( ACTION_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Function SetContextMenu()

Assigns a context menu and tells when it should be activated.

Parameters
aMenuis the menu to be assigned.
aTriggerdetermines conditions upon which the context menu is activated.

Definition at line 76 of file tool_interactive.cpp.

77 {
78  if( aMenu )
79  aMenu->SetTool( this );
80  else
81  aTrigger = CMENU_OFF;
82 
83  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
84 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool's context popup menu.

References CMENU_OFF, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ScheduleContextMenu(), and ACTION_MENU::SetTool().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ setTransitions()

void LIB_EDIT_TOOL::setTransitions ( )
overrideprivatevirtual

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

Definition at line 749 of file lib_edit_tool.cpp.

750 {
751  Go( &LIB_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() );
752  Go( &LIB_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() );
753  Go( &LIB_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() );
754  Go( &LIB_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() );
755  Go( &LIB_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() );
757 
764 
768 }
static TOOL_ACTION pinTable
Definition: ee_actions.h:150
static TOOL_ACTION properties
Definition: ee_actions.h:122
static TOOL_ACTION doDelete
Definition: actions.h:74
static TOOL_ACTION mirrorY
Definition: ee_actions.h:121
int Properties(const TOOL_EVENT &aEvent)
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION rotateCW
Definition: ee_actions.h:118
static TOOL_ACTION copy
Definition: actions.h:70
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:119
int DoDelete(const TOOL_EVENT &aEvent)
Function DoDelete()
int Mirror(const TOOL_EVENT &aEvent)
int Duplicate(const TOOL_EVENT &aEvent)
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:149
int Undo(const TOOL_EVENT &aEvent)
static TOOL_ACTION cut
Definition: actions.h:69
static TOOL_ACTION mirrorX
Definition: ee_actions.h:120
int Redo(const TOOL_EVENT &aEvent)
int DeleteItemCursor(const TOOL_EVENT &aEvent)
Runs the deletion tool.
static TOOL_ACTION redo
Definition: actions.h:68
int PinTable(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
static TOOL_ACTION deleteTool
Definition: actions.h:75
static TOOL_ACTION undo
Definition: actions.h:67
int Cut(const TOOL_EVENT &aEvent)
int Copy(const TOOL_EVENT &aEvent)
static TOOL_ACTION paste
Definition: actions.h:71
static TOOL_ACTION duplicate
Definition: actions.h:73
int Rotate(const TOOL_EVENT &aEvent)

References Copy(), ACTIONS::copy, Cut(), ACTIONS::cut, DeleteItemCursor(), ACTIONS::deleteTool, DoDelete(), ACTIONS::doDelete, Duplicate(), ACTIONS::duplicate, TOOL_INTERACTIVE::Go(), Mirror(), EE_ACTIONS::mirrorX, EE_ACTIONS::mirrorY, Paste(), ACTIONS::paste, PinTable(), EE_ACTIONS::pinTable, Properties(), EE_ACTIONS::properties, Redo(), ACTIONS::redo, Rotate(), EE_ACTIONS::rotateCCW, EE_ACTIONS::rotateCW, EE_ACTIONS::symbolProperties, Undo(), and ACTIONS::undo.

◆ Undo()

int LIB_EDIT_TOOL::Undo ( const TOOL_EVENT aEvent)

Definition at line 577 of file lib_edit_tool.cpp.

578 {
580 
582  selTool->RebuildSelection();
583 
584  return 0;
585 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void RebuildSelection()
Rebuilds the selection from the EDA_ITEMs' selection flags.

References LIB_EDIT_FRAME::GetComponentFromUndoList(), TOOL_MANAGER::GetTool(), EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, and EE_SELECTION_TOOL::RebuildSelection().

Referenced by setTransitions().

◆ updateView()

void EE_TOOL_BASE< LIB_EDIT_FRAME >::updateView ( EDA_ITEM aItem) const
inlineprotectedinherited

Similar to getView()->Update(), but handles items that are redrawn by their parents.

Definition at line 104 of file ee_tool_base.h.

105  {
106  KICAD_T itemType = aItem->Type();
107 
108  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
109  getView()->Update( aItem->GetParent() );
110 
111  getView()->Update( aItem );
112  }
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
EDA_ITEM * GetParent() const
Definition: base_struct.h:220
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

◆ Wait()

TOOL_EVENT * TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

Suspends execution of the tool until an event specified in aEventList arrives. No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

58 {
59  return m_toolMgr->ScheduleWait( this, aEventList );
60 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_EVENT * ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pauses execution of a given tool until one or more events matching aConditions arrives.

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::ScheduleWait().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_frame

LIB_EDIT_FRAME * EE_TOOL_BASE< LIB_EDIT_FRAME >::m_frame
protectedinherited

Definition at line 138 of file ee_tool_base.h.

◆ m_isLibEdit

bool EE_TOOL_BASE< LIB_EDIT_FRAME >::m_isLibEdit
protectedinherited

Definition at line 141 of file ee_tool_base.h.

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

functions below are not yet implemented - their interface may change

Definition at line 108 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), PICKER_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), LIB_DRAWING_TOOLS::Init(), MODULE_EDITOR_TOOLS::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), DRAWING_TOOL::Init(), PL_SELECTION_TOOL::Init(), EE_SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), PCB_TOOL_BASE::Init(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_pickerItem

EDA_ITEM* LIB_EDIT_TOOL::m_pickerItem
private

Definition at line 77 of file lib_edit_tool.h.

Referenced by DeleteItemCursor().

◆ m_selectionTool

EE_SELECTION_TOOL* EE_TOOL_BASE< LIB_EDIT_FRAME >::m_selectionTool
protectedinherited

Definition at line 140 of file ee_tool_base.h.

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

Definition at line 214 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::GetId(), and TOOL_BASE::IsToolActive().

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 219 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), SCH_EDITOR_CONTROL::Cut(), DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::editComponentFieldText(), EDIT_TOOL::EditFpInFpEditor(), editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), POINT_EDITOR::finishItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_INSPECTION_TOOL::HighlightItem(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), MODULE_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), Init(), SCH_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), PAD_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::Init(), PL_POINT_EDITOR::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), LIB_CONTROL::OnDeMorgan(), Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCBNEW_CONTROL::Print(), GERBVIEW_CONTROL::Print(), Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC::RunTests(), EE_SELECTION_TOOL::SelectConnection(), SELECTION_TOOL::selectCopper(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::SelectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), Undo(), SCH_EDITOR_CONTROL::Undo(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName (eg. pcbnew.InteractiveSelection).

Definition at line 218 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 220 of file tool_base.h.

Referenced by TOOL_BASE::attachManager(), and TOOL_BASE::GetSettings().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 211 of file tool_base.h.

Referenced by TOOL_BASE::GetType().

◆ m_view

KIGFX::SCH_VIEW* EE_TOOL_BASE< LIB_EDIT_FRAME >::m_view
protectedinherited

Definition at line 139 of file ee_tool_base.h.


The documentation for this class was generated from the following files: