KiCad PCB EDA Suite
SCH_MOVE_TOOL Class Reference

#include <sch_move_tool.h>

Inheritance diagram for SCH_MOVE_TOOL:
EE_TOOL_BASE< SCH_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

 SCH_MOVE_TOOL ()
 
 ~SCH_MOVE_TOOL () override
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
int Main (const TOOL_EVENT &aEvent)
 Function Main() 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

SCH_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 moveItem (EDA_ITEM *aItem, VECTOR2I aDelta, bool isDrag)
 
void getConnectedDragItems (SCH_ITEM *aOriginalItem, wxPoint aPoint, EDA_ITEMS &aList)
 

Finds additional items for a drag operation.

More...
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 

Private Attributes

bool m_moveInProgress
 

Flag determining if anything is being dragged right now

More...
 
bool m_isDragOperation
 
EDA_ITEMS m_dragAdditions
 

Items (such as wires) which were added to the selection for a drag

More...
 
VECTOR2I m_moveOffset
 

Used for chaining commands

More...
 
VECTOR2I m_cursor
 

Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).

More...
 
boost::optional< VECTOR2Im_anchorPos
 

Detailed Description

Definition at line 36 of file sch_move_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

◆ SCH_MOVE_TOOL()

SCH_MOVE_TOOL::SCH_MOVE_TOOL ( )

Definition at line 45 of file sch_move_tool.cpp.

45  :
46  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveMove" ),
47  m_moveInProgress( false ),
48  m_isDragOperation( false ),
49  m_moveOffset( 0, 0 )
50 {
51 }
VECTOR2I m_moveOffset
Used for chaining commands
Definition: sch_move_tool.h:72
bool m_moveInProgress
Flag determining if anything is being dragged right now
Definition: sch_move_tool.h:65
bool m_isDragOperation
Definition: sch_move_tool.h:66

◆ ~SCH_MOVE_TOOL()

SCH_MOVE_TOOL::~SCH_MOVE_TOOL ( )
inlineoverride

Definition at line 40 of file sch_move_tool.h.

40 { }

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(), LIB_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(), 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(), Main(), EE_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(), 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().

◆ getConnectedDragItems()

void SCH_MOVE_TOOL::getConnectedDragItems ( SCH_ITEM aOriginalItem,
wxPoint  aPoint,
EDA_ITEMS aList 
)
private

Finds additional items for a drag operation.

Connected items with no wire are included (as there is no wire to adjust for the drag). Connected wires are included with any un-connected ends flagged (STARTPOINT or ENDPOINT).

Definition at line 476 of file sch_move_tool.cpp.

478 {
479  for( auto test : m_frame->GetScreen()->Items() )
480  {
481  if( test->IsSelected() || !test->IsConnectable() || !test->CanConnect( aOriginalItem ) )
482  continue;
483 
484  KICAD_T testType = test->Type();
485 
486  switch( testType )
487  {
488  case SCH_LINE_T:
489  {
490  // Select the connected end of wires/bus connections.
491  SCH_LINE* testLine = static_cast<SCH_LINE*>( test );
492 
493  if( testLine->GetStartPoint() == aPoint )
494  {
495  if( !testLine->HasFlag( TEMP_SELECTED ) )
496  aList.push_back( testLine );
497 
498  testLine->SetFlags( STARTPOINT | TEMP_SELECTED );
499  }
500  else if( testLine->GetEndPoint() == aPoint )
501  {
502  if( !testLine->HasFlag( TEMP_SELECTED ) )
503  aList.push_back( testLine );
504 
505  testLine->SetFlags( ENDPOINT | TEMP_SELECTED );
506  }
507  break;
508  }
509 
510  case SCH_SHEET_T:
511  // Dragging a sheet just because it's connected to something else feels a bit like
512  // the tail wagging the dog, but this could be moved down to the next case.
513  break;
514 
515  case SCH_COMPONENT_T:
516  if( test->IsConnected( aPoint ) )
517  {
518  // Add a new wire between the component and the selected item so the selected
519  // item can be dragged.
520  SCH_LINE* newWire = new SCH_LINE( aPoint, LAYER_WIRE );
521  newWire->SetFlags( IS_NEW );
522  m_frame->AddToScreen( newWire, m_frame->GetScreen() );
523 
524  newWire->SetFlags( TEMP_SELECTED | STARTPOINT );
525  aList.push_back( newWire );
526  }
527  break;
528 
529  case SCH_NO_CONNECT_T:
530  case SCH_JUNCTION_T:
531  // Select no-connects and junctions that are connected to items being moved.
532  if( !test->HasFlag( TEMP_SELECTED ) && test->IsConnected( aPoint ) )
533  {
534  aList.push_back( test );
535  test->SetFlags( TEMP_SELECTED );
536  }
537 
538  break;
539 
540  case SCH_LABEL_T:
541  case SCH_GLOBAL_LABEL_T:
542  case SCH_HIER_LABEL_T:
544  case SCH_BUS_BUS_ENTRY_T:
545  // Performance optimization:
546  if( test->HasFlag( TEMP_SELECTED ) )
547  break;
548 
549  // Select labels and bus entries that are connected to a wire being moved.
550  if( aOriginalItem->Type() == SCH_LINE_T )
551  {
552  std::vector<wxPoint> connections;
553  test->GetConnectionPoints( connections );
554 
555  for( wxPoint& point : connections )
556  {
557  if( aOriginalItem->HitTest( point ) )
558  {
559  test->SetFlags( TEMP_SELECTED );
560  aList.push_back( test );
561 
562  // A bus entry needs its wire & label as well
563  if( testType == SCH_BUS_WIRE_ENTRY_T || testType == SCH_BUS_BUS_ENTRY_T )
564  {
565  std::vector<wxPoint> ends;
566  wxPoint otherEnd;
567 
568  test->GetConnectionPoints( ends );
569 
570  if( ends[0] == point )
571  otherEnd = ends[1];
572  else
573  otherEnd = ends[0];
574 
575  getConnectedDragItems( (SCH_ITEM*) test, otherEnd, m_dragAdditions );
576  }
577  break;
578  }
579  }
580  }
581 
582  break;
583 
584  default:
585  break;
586  }
587  }
588 }
#define TEMP_SELECTED
flag indicating that the structure has already selected
Definition: base_struct.h:128
void getConnectedDragItems(SCH_ITEM *aOriginalItem, wxPoint aPoint, EDA_ITEMS &aList)
Finds additional items for a drag operation.
wxPoint GetStartPoint() const
Definition: sch_line.h:97
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
EDA_ITEMS m_dragAdditions
Items (such as wires) which were added to the selection for a drag
Definition: sch_move_tool.h:69
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: base_struct.h:330
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:255
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
EE_RTREE & Items()
Definition: sch_screen.h:127
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:258
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:136
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:125
wxPoint GetEndPoint() const
Definition: sch_line.h:100

References SCH_BASE_FRAME::AddToScreen(), ENDPOINT, SCH_LINE::GetEndPoint(), SCH_EDIT_FRAME::GetScreen(), SCH_LINE::GetStartPoint(), EDA_ITEM::HasFlag(), EDA_ITEM::HitTest(), IS_NEW, SCH_SCREEN::Items(), LAYER_WIRE, m_dragAdditions, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_COMPONENT_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_T, SCH_NO_CONNECT_T, SCH_SHEET_T, EDA_ITEM::SetFlags(), STARTPOINT, TEMP_SELECTED, and EDA_ITEM::Type().

Referenced by Main().

◆ 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
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
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:250
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(), EE_SELECTION_TOOL::ClearSelection(), COMMON_TOOLS::CursorControl(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), COMMON_TOOLS::GridPreset(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::GuessSelectionCandidates(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), moveItem(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), 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(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), COMMON_TOOLS::ToggleGrid(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PCBNEW_CONTROL::updateGrid(), EE_POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_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:255

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(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_EDIT_TOOL::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(), Main(), EE_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(), LIB_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LIB_DRAWING_TOOLS::PlaceAnchor(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), 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(), POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), LIB_MOVE_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(), ZONE_FILLER_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), setTransitions(), LIB_MOVE_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), POINT_EDITOR::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), LIB_CONTROL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::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(), EE_SELECTION_TOOL::setTransitions(), and DRC::setTransitions().

◆ Init()

bool SCH_MOVE_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 54 of file sch_move_tool.cpp.

55 {
57 
58  auto moveCondition = [] ( const SELECTION& aSel ) {
59  if( aSel.Empty() )
60  return false;
61 
63  return false;
64 
65  return true;
66  };
67 
68  // Add move actions to the selection tool menu
69  //
71 
72  selToolMenu.AddItem( EE_ACTIONS::move, moveCondition, 150 );
73  selToolMenu.AddItem( EE_ACTIONS::drag, moveCondition, 150 );
74 
75  return true;
76 }
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
TOOL_MENU & GetToolMenu()
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
static TOOL_ACTION drag
Definition: ee_actions.h:116
static TOOL_ACTION move
Definition: ee_actions.h:115
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()

References CONDITIONAL_MENU::AddItem(), EE_ACTIONS::drag, TOOL_MENU::GetMenu(), TOOL_INTERACTIVE::GetToolMenu(), EE_TOOL_BASE< T >::Init(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, and EE_ACTIONS::move.

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

◆ Main()

int SCH_MOVE_TOOL::Main ( const TOOL_EVENT aEvent)

Function Main()

Runs an interactive move of the selected items, or the item under the cursor.

Definition at line 86 of file sch_move_tool.cpp.

87 {
88  const KICAD_T movableItems[] =
89  {
95  SCH_LINE_T,
97  SCH_TEXT_T,
101  SCH_FIELD_T,
104  SCH_SHEET_T,
105  EOT
106  };
107 
109  controls->SetSnapping( true );
110 
111  m_anchorPos.reset();
112 
113  if( aEvent.IsAction( &EE_ACTIONS::move ) )
114  m_isDragOperation = false;
115  else if( aEvent.IsAction( &EE_ACTIONS::drag ) )
116  m_isDragOperation = true;
117  else if( aEvent.IsAction( &EE_ACTIONS::moveActivate ) )
119  else
120  return 0;
121 
122  if( m_moveInProgress )
123  {
124  auto sel = m_selectionTool->GetSelection().Front();
125 
126  if( sel && !sel->IsNew() )
127  {
128  // User must have switched from move to drag or vice-versa. Reset the selected
129  // items so we can start again with the current m_isDragOperation.
133  m_moveInProgress = false;
134  controls->SetAutoPan( false );
135 
136  // And give it a kick so it doesn't have to wait for the first mouse movement to
137  // refresh.
139  }
140 
141  return 0;
142  }
143 
144  // Be sure that there is at least one item that we can move. If there's no selection try
145  // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
146  EE_SELECTION& selection = m_selectionTool->RequestSelection( movableItems );
147  bool unselect = selection.IsHover();
148 
149  // Keep an original copy of the starting points for cleanup after the move
150  std::vector<DANGLING_END_ITEM> internalPoints;
151 
152  if( selection.Empty() )
153  return 0;
154 
155  Activate();
156  controls->ShowCursor( true );
157 
158  bool restore_state = false;
159  bool chain_commands = false;
160  TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
161  VECTOR2I prevPos;
162 
163  std::string tool = aEvent.GetCommandStr().get();
164  m_frame->PushTool( tool );
165  m_cursor = controls->GetCursorPosition();
166 
167  // Main loop: keep receiving events
168  do
169  {
170  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
171  controls->SetSnapping( !evt->Modifier( MD_ALT ) );
172 
174  || evt->IsAction( &EE_ACTIONS::move ) || evt->IsAction( &EE_ACTIONS::drag )
175  || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
176  || evt->IsAction( &ACTIONS::refreshPreview ) )
177  {
178  if( !m_moveInProgress ) // Prepare to start moving/dragging
179  {
180  SCH_ITEM* sch_item = (SCH_ITEM*) selection.Front();
181  bool appendUndo = sch_item && sch_item->IsNew();
182  bool placingNewItems = sch_item && sch_item->IsNew();
183 
184  //------------------------------------------------------------------------
185  // Setup a drag or a move
186  //
187  m_dragAdditions.clear();
188  internalPoints.clear();
189 
190 
191  for( auto it : m_frame->GetScreen()->Items() )
192  {
193  it->ClearFlags( TEMP_SELECTED );
194 
195  if( !it->IsSelected() )
196  it->ClearFlags( STARTPOINT | ENDPOINT );
197 
198  if( !selection.IsHover() && it->IsSelected() )
199  it->SetFlags( STARTPOINT | ENDPOINT );
200  }
201 
202  if( m_isDragOperation )
203  {
204  // Add connections to the selection for a drag.
205  //
206  for( EDA_ITEM* item : selection )
207  {
208  if( static_cast<SCH_ITEM*>( item )->IsConnectable() )
209  {
210  std::vector<wxPoint> connections;
211 
212  if( item->Type() == SCH_LINE_T )
213  static_cast<SCH_LINE*>( item )->GetSelectedPoints( connections );
214  else
215  static_cast<SCH_ITEM*>( item )->GetConnectionPoints( connections );
216 
217  for( wxPoint point : connections )
219  }
220  }
221 
223  }
224  else
225  {
226  // Mark the edges of the block with dangling flags for a move.
227  for( EDA_ITEM* item : selection )
228  static_cast<SCH_ITEM*>( item )->GetEndPoints( internalPoints );
229 
230  for( EDA_ITEM* item : selection )
231  static_cast<SCH_ITEM*>( item )->UpdateDanglingState( internalPoints );
232  }
233  // Generic setup
234  //
235  for( EDA_ITEM* item : selection )
236  {
237  if( item->IsNew() )
238  {
239  if( item->HasFlag( TEMP_SELECTED ) && m_isDragOperation )
240  {
241  // Item was added in getConnectedDragItems
242  saveCopyInUndoList( (SCH_ITEM*) item, UR_NEW, appendUndo );
243  appendUndo = true;
244  }
245  else
246  {
247  // Item was added in a previous command (and saved to undo by
248  // that command)
249  }
250  }
251  else if( item->GetParent() && item->GetParent()->IsSelected() )
252  {
253  // Item will be (or has been) saved to undo by parent
254  }
255  else
256  {
257  saveCopyInUndoList( (SCH_ITEM*) item, UR_CHANGED, appendUndo );
258  appendUndo = true;
259  }
260 
261  SCH_ITEM* schItem = (SCH_ITEM*) item;
262  schItem->SetStoredPos( schItem->GetPosition() );
263  }
264 
265  // Set up the starting position and move/drag offset
266  //
267  m_cursor = controls->GetCursorPosition();
268 
269  if( evt->IsAction( &EE_ACTIONS::restartMove ) )
270  {
271  wxASSERT_MSG( m_anchorPos, "Should be already set from previous cmd" );
272  }
273  else if( placingNewItems )
274  {
275  m_anchorPos = selection.GetReferencePoint();
276  }
277 
278  if( m_anchorPos )
279  {
280  VECTOR2I delta = m_cursor - (*m_anchorPos);
281 
282  // Drag items to the current cursor position
283  for( EDA_ITEM* item : selection )
284  {
285  // Don't double move pins, fields, etc.
286  if( item->GetParent() && item->GetParent()->IsSelected() )
287  continue;
288 
289  moveItem( item, delta, m_isDragOperation );
290  updateView( item );
291  }
292 
294  }
295  // For some items, moving the cursor to anchor is not good (for instance large
296  // hierarchical sheets or components can have the anchor outside the view)
297  else if( selection.Size() == 1 && sch_item->IsMovableFromAnchorPoint()
299  {
300  if( sch_item->Type() == SCH_LINE_T && !sch_item->HasFlag( STARTPOINT ) )
301  m_anchorPos = static_cast<SCH_LINE*>( sch_item )->GetEndPoint();
302  else
303  m_anchorPos = sch_item->GetPosition();
304 
305  getViewControls()->WarpCursor( *m_anchorPos, true, true );
307  }
308  // ...otherwise modify items with regard to the grid-snapped cursor position
309  else
310  {
313  }
314 
315  controls->SetCursorPosition( m_cursor, false );
317 
318  prevPos = m_cursor;
319  controls->SetAutoPan( true );
320  m_moveInProgress = true;
321  }
322 
323  //------------------------------------------------------------------------
324  // Follow the mouse
325  //
326  m_cursor = controls->GetCursorPosition();
327  VECTOR2I delta( m_cursor - prevPos );
329 
330  m_moveOffset += delta;
331  prevPos = m_cursor;
332 
333  for( EDA_ITEM* item : selection )
334  {
335  // Don't double move pins, fields, etc.
336  if( item->GetParent() && item->GetParent()->IsSelected() )
337  continue;
338 
339  moveItem( item, delta, m_isDragOperation );
340  updateView( item );
341  }
342 
345  }
346  //------------------------------------------------------------------------
347  // Handle cancel
348  //
349  else if( evt->IsCancelInteractive() )
350  {
351  if( m_moveInProgress )
352  restore_state = true;
353 
354  break;
355  }
356  //------------------------------------------------------------------------
357  // Handle TOOL_ACTION special cases
358  //
359  else if( evt->Action() == TA_UNDO_REDO_PRE )
360  {
361  unselect = true;
362  break;
363  }
364  else if( evt->Category() == TC_COMMAND )
365  {
366  if( evt->IsAction( &ACTIONS::doDelete ) )
367  {
368  // Exit on a remove operation; there is no further processing for removed items.
369  break;
370  }
371  else if( evt->IsAction( &ACTIONS::duplicate ) )
372  {
373  if( selection.Front()->IsNew() )
374  {
375  // This doesn't really make sense; we'll just end up dragging a stack of
376  // objects so Duplicate() is going to ignore this and we'll just carry on.
377  continue;
378  }
379 
380  // Move original back and exit. The duplicate will run in its own loop.
381  restore_state = true;
382  unselect = false;
383  chain_commands = true;
384  break;
385  }
386  else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
387  {
388  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
390  {
391  SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
392  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
393 
394  if( component )
395  {
396  m_frame->SelectUnit( component, unit );
398  }
399  }
400  }
401  }
402  //------------------------------------------------------------------------
403  // Handle context menu
404  //
405  else if( evt->IsClick( BUT_RIGHT ) )
406  {
408  }
409  //------------------------------------------------------------------------
410  // Handle drop
411  //
412  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
413  {
414  break; // Finish
415  }
416  else
417  evt->SetPassEvent();
418 
419  controls->SetAutoPan( m_moveInProgress );
420 
421  } while( ( evt = Wait() ) ); //Should be assignment not equality test
422 
423  controls->ForceCursorPosition( false );
424  controls->ShowCursor( false );
425  controls->SetSnapping( false );
426  controls->SetAutoPan( false );
427 
428  if( !chain_commands )
429  m_moveOffset = { 0, 0 };
430 
431  m_anchorPos.reset();
432 
433  for( EDA_ITEM* item : selection )
434  item->ClearEditFlags();
435 
436  if( restore_state )
437  {
440  }
441  else
442  {
443  // Moving items changes the RTree box bounds.
444  for( auto item : selection )
445  m_frame->GetScreen()->Update( static_cast<SCH_ITEM*>( item ) );
446 
447  // If we move items away from a junction, we _may_ want to add a junction there
448  // to denote the state.
449  for( auto it : internalPoints )
450  {
451  if( m_frame->GetScreen()->IsJunctionNeeded( it.GetPosition(), true ) )
452  m_frame->AddJunction( it.GetPosition(), true, false );
453  }
454 
455  m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selection );
457 
460 
461  m_frame->OnModify();
462  }
463 
464  if( unselect )
466  else
467  m_selectionTool->RebuildSelection(); // Schematic cleanup might have merged lines, etc.
468 
469  m_dragAdditions.clear();
470  m_moveInProgress = false;
471  m_frame->PopTool( tool );
472  return 0;
473 }
static TOOL_ACTION moveActivate
Definition: ee_actions.h:114
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
OPT< int > GetCommandId() const
Definition: tool_event.h:458
#define TEMP_SELECTED
flag indicating that the structure has already selected
Definition: base_struct.h:128
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
bool IsHover() const
Definition: selection.h:70
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void getConnectedDragItems(SCH_ITEM *aOriginalItem, wxPoint aPoint, EDA_ITEMS &aList)
Finds additional items for a drag operation.
virtual bool IsMovableFromAnchorPoint()
Virtual function IsMovableFromAnchorPoint.
Definition: sch_item.h:191
static TOOL_ACTION doDelete
Definition: actions.h:74
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:332
VECTOR2I m_cursor
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).
Definition: sch_move_tool.h:76
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition: tool_event.h:250
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:178
VECTOR2I m_moveOffset
Used for chaining commands
Definition: sch_move_tool.h:72
static TOOL_ACTION restartMove
Definition: ee_actions.h:185
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool IsMotion() const
Definition: tool_event.h:306
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
int AddItemsToSel(const TOOL_EVENT &aEvent)
TOOL_EVENT_CATEGORY Category() const
Returns the category (eg. mouse/keyboard/action) of an event..
Definition: tool_event.h:247
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Moves cursor to the requested position expressed in world coordinates.
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
bool m_moveInProgress
Flag determining if anything is being dragged right now
Definition: sch_move_tool.h:65
EDA_ITEMS m_dragAdditions
Items (such as wires) which were added to the selection for a drag
Definition: sch_move_tool.h:69
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:201
bool IsNew() const
Definition: base_struct.h:218
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
EE_SELECTION & GetSelection()
Function GetSelection()
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
virtual wxPoint GetPosition() const =0
Function GetPosition.
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:296
bool GetDragActionIsMove() const
boost::optional< VECTOR2I > m_anchorPos
Definition: sch_move_tool.h:78
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_EVENT.
Definition: tool_event.h:171
SCH_JUNCTION * AddJunction(const wxPoint &aPos, bool aAppendToUndo=false, bool aFinal=true)
void SetPassEvent()
Definition: tool_event.h:256
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
bool m_isDragOperation
Definition: sch_move_tool.h:66
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:77
bool IsMouseUp(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:301
bool IsCancelInteractive()
Function IsCancelInteractive()
Definition: tool_event.cpp:190
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
void SelectUnit(SCH_COMPONENT *aComponent, int aUnit)
Definition: getpart.cpp:204
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
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 moveItem(EDA_ITEM *aItem, VECTOR2I aDelta, bool isDrag)
static TOOL_ACTION drag
Definition: ee_actions.h:116
void RollbackSchematicFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
EE_RTREE & Items()
Definition: sch_screen.h:127
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
void RebuildSelection()
Rebuilds the selection from the EDA_ITEMs' selection flags.
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:89
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
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
bool GetMoveWarpsCursor() const
Indicates that a move operation should warp the mouse pointer to the origin of the move object.
virtual void PopTool(const std::string &actionName)
void Activate()
Function Activate() Runs the tool.
static TOOL_ACTION move
Definition: ee_actions.h:115
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void Update(SCH_ITEM *aItem)
Updates aItem's bounding box in the tree.
Definition: sch_screen.cpp:228
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:258
#define QUIET_MODE
int RemoveItemsFromSel(const TOOL_EVENT &aEvent)
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:237
void SetStoredPos(wxPoint aPos)
Definition: sch_item.h:194
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:136
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION duplicate
Definition: actions.h:73
static TOOL_ACTION refreshPreview
Definition: actions.h:101
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:183
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
virtual void UpdateMsgPanel()
Redraw the message panel.
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:125

References TOOL_EVENT::Action(), TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemsToSel(), SCH_EDIT_FRAME::AddJunction(), EE_ACTIONS::addNeededJunctions, BUT_LEFT, BUT_RIGHT, TOOL_EVENT::Category(), EE_ACTIONS::clearSelection, ACTIONS::doDelete, EE_ACTIONS::drag, ACTIONS::duplicate, SELECTION::Empty(), ENDPOINT, EOT, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), SELECTION::Front(), SCH_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandId(), TOOL_EVENT::GetCommandStr(), getConnectedDragItems(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), SCH_BASE_FRAME::GetDragActionIsMove(), EDA_BASE_FRAME::GetMoveWarpsCursor(), SCH_ITEM::GetPosition(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), TOOL_BASE::getViewControls(), EDA_ITEM::HasFlag(), ID_POPUP_SCH_SELECT_UNIT_CMP, ID_POPUP_SCH_SELECT_UNIT_CMP_MAX, TOOL_EVENT::IsAction(), TOOL_EVENT::IsCancelInteractive(), TOOL_EVENT::IsClick(), TOOL_EVENT::IsDrag(), SELECTION::IsHover(), SCH_SCREEN::IsJunctionNeeded(), TOOL_EVENT::IsMotion(), TOOL_EVENT::IsMouseUp(), SCH_ITEM::IsMovableFromAnchorPoint(), EDA_ITEM::IsNew(), SCH_SCREEN::Items(), m_anchorPos, m_cursor, m_dragAdditions, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_isDragOperation, TOOL_INTERACTIVE::m_menu, m_moveInProgress, m_moveOffset, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, MD_ALT, TOOL_EVENT::Modifier(), EE_ACTIONS::move, EE_ACTIONS::moveActivate, moveItem(), SCH_EDIT_FRAME::OnModify(), EDA_BASE_FRAME::PopTool(), TOOL_MANAGER::PostEvent(), EDA_BASE_FRAME::PushTool(), QUIET_MODE, EE_SELECTION_TOOL::RebuildSelection(), ACTIONS::refreshPreview, EE_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RequestSelection(), EE_ACTIONS::restartMove, SCH_EDIT_FRAME::RollbackSchematicFromUndo(), TOOL_MANAGER::RunAction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList(), SCH_BITMAP_T, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_COMPONENT_T, SCH_FIELD_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_T, SCH_MARKER_T, SCH_NO_CONNECT_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_TEXT_T, SCH_EDIT_FRAME::SchematicCleanUp(), EVENTS::SelectedItemsModified, SCH_EDIT_FRAME::SelectUnit(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), TOOL_EVENT::SetPassEvent(), KIGFX::VIEW_CONTROLS::SetSnapping(), SCH_ITEM::SetStoredPos(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), STARTPOINT, TA_CHOICE_MENU_CHOICE, TA_UNDO_REDO_PRE, TC_COMMAND, TEMP_SELECTED, SCH_EDIT_FRAME::TestDanglingEnds(), EDA_ITEM::Type(), SCH_SCREEN::Update(), EDA_DRAW_FRAME::UpdateMsgPanel(), EE_TOOL_BASE< SCH_EDIT_FRAME >::updateView(), UR_CHANGED, UR_NEW, TOOL_INTERACTIVE::Wait(), and KIGFX::VIEW_CONTROLS::WarpCursor().

Referenced by setTransitions().

◆ moveItem()

void SCH_MOVE_TOOL::moveItem ( EDA_ITEM aItem,
VECTOR2I  aDelta,
bool  isDrag 
)
private

Definition at line 591 of file sch_move_tool.cpp.

592 {
593  switch( aItem->Type() )
594  {
595  case SCH_LINE_T:
596  if( aItem->HasFlag( STARTPOINT ) )
597  static_cast<SCH_LINE*>( aItem )->MoveStart( (wxPoint) aDelta );
598 
599  if( aItem->HasFlag( ENDPOINT ) )
600  static_cast<SCH_LINE*>( aItem )->MoveEnd( (wxPoint) aDelta );
601 
602  break;
603 
604  case SCH_PIN_T:
605  case SCH_FIELD_T:
606  {
607  SCH_COMPONENT* component = (SCH_COMPONENT*) aItem->GetParent();
608  TRANSFORM transform = component->GetTransform().InverseTransform();
609  wxPoint transformedDelta = transform.TransformCoordinate( (wxPoint) aDelta );
610 
611  static_cast<SCH_ITEM*>( aItem )->Move( transformedDelta );
612 
613  // If we're moving a field with respect to its parent then it's no longer auto-placed
614  if( aItem->Type() == SCH_FIELD_T && !component->IsSelected() )
615  component->ClearFieldsAutoplaced();
616 
617  break;
618  }
619  case SCH_SHEET_PIN_T:
620  {
621  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) aItem;
622  pin->SetStoredPos( pin->GetStoredPos() + (wxPoint) aDelta );
623  pin->ConstrainOnEdge( pin->GetStoredPos() );
624  break;
625  }
626  default:
627  static_cast<SCH_ITEM*>( aItem )->Move( (wxPoint) aDelta );
628  break;
629  }
630 
631  getView()->Hide( aItem, false );
632  aItem->SetFlags( IS_MOVED );
633 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1507
bool IsSelected() const
Definition: base_struct.h:223
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:59
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
void ClearFieldsAutoplaced()
Set fields automatically placed flag false.
wxPoint & GetStoredPos()
Definition: sch_item.h:193
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:255
TRANSFORM & GetTransform() const
EDA_ITEM * GetParent() const
Definition: base_struct.h:215
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:75
void ConstrainOnEdge(wxPoint Pos)
Adjust label position to edge based on proximity to vertical or horizontal edge of the parent sheet.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:89
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:258
void SetStoredPos(wxPoint aPos)
Definition: sch_item.h:194
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:125
#define IS_MOVED
Item being moved.
Definition: base_struct.h:119

References SCH_COMPONENT::ClearFieldsAutoplaced(), SCH_SHEET_PIN::ConstrainOnEdge(), ENDPOINT, EDA_ITEM::GetParent(), SCH_ITEM::GetStoredPos(), SCH_COMPONENT::GetTransform(), TOOL_BASE::getView(), EDA_ITEM::HasFlag(), KIGFX::VIEW::Hide(), TRANSFORM::InverseTransform(), IS_MOVED, EDA_ITEM::IsSelected(), SCH_FIELD_T, SCH_LINE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EDA_ITEM::SetFlags(), SCH_ITEM::SetStoredPos(), STARTPOINT, TRANSFORM::TransformCoordinate(), and EDA_ITEM::Type().

Referenced by Main().

◆ Reset()

void EE_TOOL_BASE< SCH_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

◆ 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< SCH_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  bool selected = aItem->IsSelected();
121 
122  // IS_SELECTED flag should not be set on undo items which were added for
123  // a drag operation.
124  if( selected && aItem->HasFlag( TEMP_SELECTED ))
125  aItem->ClearSelected();
126 
127  if( m_isLibEdit )
128  {
129  LIB_EDIT_FRAME* editFrame = dynamic_cast<LIB_EDIT_FRAME*>( m_frame );
130  wxASSERT( editFrame );
131 
132  editFrame->SaveCopyInUndoList( static_cast<LIB_ITEM*>( aItem ), aType, aAppend );
133  }
134  else
135  {
136  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
137  wxASSERT( editFrame );
138 
139  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
140  editFrame->SaveCopyInUndoList(
141  static_cast<SCH_ITEM*>( aItem->GetParent() ), UR_CHANGED, aAppend );
142  else
143  editFrame->SaveCopyInUndoList( static_cast<SCH_ITEM*>( aItem ), aType, aAppend );
144  }
145 
146  if( selected && aItem->HasFlag( TEMP_SELECTED ) )
147  aItem->SetSelected();
148  }
#define TEMP_SELECTED
flag indicating that the structure has already selected
Definition: base_struct.h:128
bool IsSelected() const
Definition: base_struct.h:223
void ClearSelected()
Definition: base_struct.h:233
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
void SetSelected()
Definition: base_struct.h:229
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:215
The symbol library editor main window.
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:258
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:207

◆ 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(), 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 SCH_MOVE_TOOL::setTransitions ( )
overrideprivatevirtual

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

Definition at line 636 of file sch_move_tool.cpp.

637 {
639  Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::move.MakeEvent() );
640  Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::drag.MakeEvent() );
641 }
static TOOL_ACTION moveActivate
Definition: ee_actions.h:114
int Main(const TOOL_EVENT &aEvent)
Function Main()
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION drag
Definition: ee_actions.h:116
static TOOL_ACTION move
Definition: ee_actions.h:115

References EE_ACTIONS::drag, TOOL_INTERACTIVE::Go(), Main(), EE_ACTIONS::move, and EE_ACTIONS::moveActivate.

◆ updateView()

void EE_TOOL_BASE< SCH_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:215
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:207

◆ 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(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), CVPCB_CONTROL::Main(), Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_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(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), 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_anchorPos

boost::optional<VECTOR2I> SCH_MOVE_TOOL::m_anchorPos
private

Definition at line 78 of file sch_move_tool.h.

Referenced by Main().

◆ m_cursor

VECTOR2I SCH_MOVE_TOOL::m_cursor
private

Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).

Definition at line 76 of file sch_move_tool.h.

Referenced by Main().

◆ m_dragAdditions

EDA_ITEMS SCH_MOVE_TOOL::m_dragAdditions
private

Items (such as wires) which were added to the selection for a drag

Definition at line 69 of file sch_move_tool.h.

Referenced by getConnectedDragItems(), and Main().

◆ m_frame

SCH_EDIT_FRAME * EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame
protectedinherited

Definition at line 151 of file ee_tool_base.h.

◆ m_isDragOperation

bool SCH_MOVE_TOOL::m_isDragOperation
private

Definition at line 66 of file sch_move_tool.h.

Referenced by Main().

◆ m_isLibEdit

bool EE_TOOL_BASE< SCH_EDIT_FRAME >::m_isLibEdit
protectedinherited

Definition at line 154 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(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), PICKER_TOOL::Init(), SCH_EDIT_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), LIB_DRAWING_TOOLS::Init(), MODULE_EDITOR_TOOLS::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), EDIT_TOOL::Init(), PCB_TOOL_BASE::Init(), Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_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(), 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_moveInProgress

bool SCH_MOVE_TOOL::m_moveInProgress
private

Flag determining if anything is being dragged right now

Definition at line 65 of file sch_move_tool.h.

Referenced by Main().

◆ m_moveOffset

VECTOR2I SCH_MOVE_TOOL::m_moveOffset
private

Used for chaining commands

Definition at line 72 of file sch_move_tool.h.

Referenced by Main().

◆ m_selectionTool

EE_SELECTION_TOOL* EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool
protectedinherited

Definition at line 153 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(), EE_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_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(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), 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(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::editComponentFieldText(), EDIT_TOOL::EditFpInFpEditor(), LIB_EDIT_TOOL::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(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::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(), Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), LIB_CONTROL::OnDeMorgan(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCBNEW_CONTROL::Print(), GERBVIEW_CONTROL::Print(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), LIB_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), EE_SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemFromSel(), 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(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC::RunTests(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), 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(), LIB_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_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(), and BOARD_COMMIT::Push().

◆ m_view

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

Definition at line 152 of file ee_tool_base.h.


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