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 ()
 
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...
 
TOOL_MENUGetToolMenu ()
 

Get the tool's top-level context menu

More...
 
void Activate ()
 Function Activate() Runs the tool. More...
 
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...
 
OPT_TOOL_EVENT Wait (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...
 
const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
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
 Menu model displayed by the tool. 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 addJunctionsIfNeeded (SELECTION &aSelection)
 

Adds junctions if needed to each item in the list after they have been moved.

More...
 
bool updateModificationPoint (SELECTION &aSelection)
 

Returns the right modification point (e.g.

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

Detailed Description

Definition at line 35 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 80 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ SCH_MOVE_TOOL()

SCH_MOVE_TOOL::SCH_MOVE_TOOL ( )

Definition at line 54 of file sch_move_tool.cpp.

54  :
55  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveMove" ),
56  m_moveInProgress( false ),
57  m_moveOffset( 0, 0 )
58 {
59 }
VECTOR2I m_moveOffset
Used for chaining commands
Definition: sch_move_tool.h:75
bool m_moveInProgress
Flag determining if anything is being dragged right now
Definition: sch_move_tool.h:72

◆ ~SCH_MOVE_TOOL()

SCH_MOVE_TOOL::~SCH_MOVE_TOOL ( )

Definition at line 62 of file sch_move_tool.cpp.

63 {
64 }

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 49 of file tool_interactive.cpp.

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:211
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(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), EDIT_TOOL::doCopyToClipboard(), SCH_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), 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(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SCH_WIRE_BUS_TOOL::StartBus(), SCH_WIRE_BUS_TOOL::StartWire(), and SCH_WIRE_BUS_TOOL::UnfoldBus().

◆ addJunctionsIfNeeded()

void SCH_MOVE_TOOL::addJunctionsIfNeeded ( SELECTION aSelection)
private

Adds junctions if needed to each item in the list after they have been moved.

Definition at line 522 of file sch_move_tool.cpp.

523 {
524  std::vector< wxPoint > pts;
525  std::vector< wxPoint > connections;
526 
527  m_frame->GetSchematicConnections( connections );
528 
529  for( unsigned ii = 0; ii < aSelection.GetSize(); ii++ )
530  {
531  SCH_ITEM* item = static_cast<SCH_ITEM*>( aSelection.GetItem( ii ) );
532  std::vector< wxPoint > new_pts;
533 
534  if( !item->IsConnectable() )
535  continue;
536 
537  item->GetConnectionPoints( new_pts );
538  pts.insert( pts.end(), new_pts.begin(), new_pts.end() );
539 
540  // If the item is a line, we also add any connection points from the rest of the schematic
541  // that terminate on the line after it is moved.
542  if( item->Type() == SCH_LINE_T )
543  {
544  SCH_LINE* line = (SCH_LINE*) item;
545  for( auto i : connections )
546  if( IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), i ) )
547  pts.push_back( i );
548  }
549  else
550  {
551  // Clean up any wires that short non-wire connections in the list
552  for( auto point = new_pts.begin(); point != new_pts.end(); point++ )
553  {
554  for( auto second_point = point + 1; second_point != new_pts.end(); second_point++ )
555  m_frame->TrimWire( *point, *second_point );
556  }
557  }
558  }
559 
560  // We always have some overlapping connection points. Drop duplicates here
561  std::sort( pts.begin(), pts.end(), []( const wxPoint& a, const wxPoint& b ) -> bool
562  { return a.x < b.x || (a.x == b.x && a.y < b.y); } );
563 
564  pts.erase( unique( pts.begin(), pts.end() ), pts.end() );
565 
566  for( auto point : pts )
567  {
568  if( m_frame->GetScreen()->IsJunctionNeeded( point, true ) )
569  m_frame->AddJunction( point, true, false );
570  }
571 }
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Function IsPointOnSegment.
Definition: trigo.cpp:39
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item.
Definition: sch_item.h:299
void GetSchematicConnections(std::vector< wxPoint > &aConnections)
Collects a unique list of all possible connection points in the schematic.
wxPoint GetStartPoint() const
Definition: sch_line.h:90
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:350
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_item.h:309
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_JUNCTION * AddJunction(const wxPoint &aPos, bool aAppendToUndo=false, bool aFinal=true)
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
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
size_t i
Definition: json11.cpp:597
bool TrimWire(const wxPoint &aStart, const wxPoint &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
wxPoint GetEndPoint() const
Definition: sch_line.h:93

References SCH_EDIT_FRAME::AddJunction(), SCH_ITEM::GetConnectionPoints(), SCH_LINE::GetEndPoint(), SELECTION::GetItem(), SCH_EDIT_FRAME::GetSchematicConnections(), SCH_EDIT_FRAME::GetScreen(), SELECTION::GetSize(), SCH_LINE::GetStartPoint(), i, SCH_ITEM::IsConnectable(), SCH_SCREEN::IsJunctionNeeded(), IsPointOnSegment(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_LINE_T, SCH_EDIT_FRAME::TrimWire(), and EDA_ITEM::Type().

Referenced by Main().

◆ 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 59 of file tool_base.cpp.

60 {
61  m_toolMgr = aManager;
62  m_toolSettings = TOOL_SETTINGS( this );
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:217
friend class TOOL_SETTINGS
Definition: tool_base.h:155

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

Referenced by TOOL_MANAGER::RegisterTool().

◆ evActivate()

const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

◆ evButtonDown()

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited

◆ evButtonUp()

const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited

◆ evClick()

const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited

◆ evCommand() [1/2]

const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited

◆ evCommand() [2/2]

const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited

◆ evDrag()

const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited

◆ evMotion()

const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited

◆ 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 426 of file sch_move_tool.cpp.

428 {
429  for( SCH_ITEM* test = m_frame->GetScreen()->GetDrawItems(); test; test = test->Next() )
430  {
431  if( test->IsSelected() || !test->IsConnectable() || !test->CanConnect( aOriginalItem ) )
432  continue;
433 
434  switch( test->Type() )
435  {
436  case SCH_LINE_T:
437  {
438  // Select the connected end of wires/bus connections.
439  SCH_LINE* testLine = (SCH_LINE*) test;
440 
441  if( testLine->GetStartPoint() == aPoint )
442  {
443  if( !( testLine->GetFlags() & SELECTEDNODE ) )
444  aList.push_back( testLine );
445 
446  testLine->SetFlags( STARTPOINT | SELECTEDNODE );
447  }
448  else if( testLine->GetEndPoint() == aPoint )
449  {
450  if( !( testLine->GetFlags() & SELECTEDNODE ) )
451  aList.push_back( testLine );
452 
453  testLine->SetFlags( ENDPOINT | SELECTEDNODE );
454  }
455  break;
456  }
457 
458  case SCH_SHEET_T:
459  // Dragging a sheet just because it's connected to something else feels a bit like
460  // the tail wagging the dog, but this could be moved down to the next case.
461  break;
462 
463  case SCH_COMPONENT_T:
464  case SCH_NO_CONNECT_T:
465  case SCH_JUNCTION_T:
466  if( test->IsConnected( aPoint ) )
467  {
468  // Connected to a wire: anchor the connected end of the wire
469  if( aOriginalItem->Type() == SCH_LINE_T )
470  {
471  SCH_LINE* originalWire = (SCH_LINE*) aOriginalItem;
472 
473  if( originalWire->GetStartPoint() == aPoint )
474  originalWire->ClearFlags( STARTPOINT );
475  else if( originalWire->GetEndPoint() == aPoint )
476  originalWire->ClearFlags( ENDPOINT );
477  }
478  // Connected directly to a component: add a new wire and pick up the end
479  else if( test->Type() == SCH_COMPONENT_T)
480  {
481  SCH_LINE* newWire = new SCH_LINE( aPoint, LAYER_WIRE );
482  newWire->SetFlags( IS_NEW );
483  m_frame->AddToScreen( newWire, m_frame->GetScreen() );
484 
485  newWire->SetFlags( SELECTEDNODE | STARTPOINT );
486  aList.push_back( newWire );
487  }
488  // Connected to a no-connect or junction: pick it up
489  else
490  {
491  aList.push_back( test );
492  }
493  }
494  break;
495 
496  case SCH_LABEL_T:
497  case SCH_GLOBAL_LABEL_T:
498  case SCH_HIER_LABEL_T:
500  case SCH_BUS_BUS_ENTRY_T:
501  // Select labels and bus entries that are connected to a wire being moved.
502  if( aOriginalItem->Type() == SCH_LINE_T )
503  {
504  std::vector<wxPoint> connections;
505  test->GetConnectionPoints( connections );
506 
507  for( wxPoint& point : connections )
508  {
509  if( aOriginalItem->HitTest( point ) )
510  aList.push_back( test );
511  }
512  }
513  break;
514 
515  default:
516  break;
517  }
518  }
519 }
wxPoint GetStartPoint() const
Definition: sch_line.h:90
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,...
SCH_ITEM * Next() const
Definition: sch_item.h:153
#define SELECTEDNODE
flag indicating that the structure has already selected
Definition: base_struct.h:122
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
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:333
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:259
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:120
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:260
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:261
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:119
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:153
wxPoint GetEndPoint() const
Definition: sch_line.h:93

References SCH_BASE_FRAME::AddToScreen(), EDA_ITEM::ClearFlags(), ENDPOINT, SCH_SCREEN::GetDrawItems(), SCH_LINE::GetEndPoint(), EDA_ITEM::GetFlags(), SCH_EDIT_FRAME::GetScreen(), SCH_LINE::GetStartPoint(), EDA_ITEM::HitTest(), IS_NEW, LAYER_WIRE, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_ITEM::Next(), 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, SELECTEDNODE, EDA_ITEM::SetFlags(), STARTPOINT, 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 188 of file tool_base.h.

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47

References TOOL_BASE::getEditFrameInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), 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 122 of file tool_base.h.

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

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 144 of file tool_base.h.

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), 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 199 of file tool_base.h.

200  {
201  EDA_ITEM* m = getModelInt();
202  wxASSERT( dynamic_cast<T*>( m ) );
203 
204  return static_cast<T*>( m );
205  }
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:53
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157

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 133 of file tool_base.h.

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

References TOOL_BASE::m_toolName.

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

◆ GetSettings()

TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:217

References TOOL_BASE::m_toolSettings.

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

◆ GetToolMenu()

TOOL_MENU& EE_TOOL_BASE< SCH_EDIT_FRAME >::GetToolMenu ( )
inlineinherited

Get the tool's top-level context menu

Definition at line 103 of file ee_tool_base.h.

103 { return m_menu; }
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: ee_tool_base.h:147

◆ 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 111 of file tool_base.h.

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

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 35 of file tool_base.cpp.

36 {
37  return m_toolMgr->GetView();
38 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216

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(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), COMMON_TOOLS::doGridPreset(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), EE_POINT_EDITOR::Main(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), 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(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), 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(), 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(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), CVPCB_SELECTION_TOOL::~CVPCB_SELECTION_TOOL(), 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 41 of file tool_base.cpp.

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257

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_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), SCH_WIRE_BUS_TOOL::finishSegments(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), LIB_DRAWING_TOOLS::PlaceAnchor(), 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(), CVPCB_CONTROL::ResetCoords(), GERBVIEW_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), EE_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), LIB_MOVE_TOOL::updateModificationPoint(), 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 135 of file tool_interactive.h.

137 {
138  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
139 
140  goInternal( sptr, aConditions );
141 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), LIB_CONTROL::setTransitions(), LIB_PIN_TOOL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), LIB_MOVE_TOOL::setTransitions(), POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), setTransitions(), LIB_EDIT_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), CVPCB_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), SCH_WIRE_BUS_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), EE_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), SELECTION_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), and EE_SELECTION_TOOL::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 67 of file sch_move_tool.cpp.

68 {
70 
71  auto moveCondition = [] ( const SELECTION& aSel ) {
72  if( aSel.Empty() )
73  return false;
74 
76  return false;
77 
78  return true;
79  };
80 
81  //
82  // Add move actions to the selection tool menu
83  //
85 
86  selToolMenu.AddItem( EE_ACTIONS::move, moveCondition, 150 );
87  selToolMenu.AddItem( EE_ACTIONS::drag, moveCondition, 150 );
88 
89  return true;
90 }
TOOL_MENU & GetToolMenu()
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:143
static TOOL_ACTION drag
Definition: ee_actions.h:117
static TOOL_ACTION move
Definition: ee_actions.h:116
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(), EE_SELECTION_TOOL::GetToolMenu(), EE_TOOL_BASE< T >::Init(), SCH_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 30 of file tool_base.cpp.

31 {
32  return m_toolMgr->IsToolActive( m_toolId );
33 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:211
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 93 of file sch_move_tool.cpp.

94 {
95  const KICAD_T movableItems[] =
96  {
102  SCH_LINE_T,
103  SCH_BITMAP_T,
104  SCH_TEXT_T,
105  SCH_LABEL_T,
108  SCH_FIELD_T,
111  SCH_SHEET_T,
112  EOT
113  };
114 
116 
117  controls->SetSnapping( true );
118  VECTOR2I originalCursorPos = controls->GetCursorPosition();
119 
120  // Be sure that there is at least one item that we can move. If there's no selection try
121  // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
122  SELECTION& selection = m_selectionTool->RequestSelection( movableItems );
123  EDA_ITEMS dragAdditions;
124  bool unselect = selection.IsHover();
125 
126  if( selection.Empty() )
127  return 0;
128 
129  if( aEvent.IsAction( &EE_ACTIONS::move ) )
130  m_frame->SetToolID( ID_SCH_MOVE, wxCURSOR_DEFAULT, _( "Move Items" ) );
131  else
132  m_frame->SetToolID( ID_SCH_DRAG, wxCURSOR_DEFAULT, _( "Drag Items" ) );
133 
134  Activate();
135  controls->ShowCursor( true );
136  controls->SetAutoPan( true );
137 
138  bool restore_state = false;
139  bool chain_commands = false;
140  bool appendUndo = false;
141  OPT_TOOL_EVENT evt = aEvent;
142  VECTOR2I prevPos;
143 
144  if( m_moveInProgress )
145  {
146  // User must have switched from move to drag or vice-versa. Reset the moved items
147  // so we can start again with the current m_isDragOperation and m_moveOffset.
149  m_selectionTool->RemoveItemsFromSel( &dragAdditions, QUIET_MODE );
150  m_moveInProgress = false;
151  // And give it a kick so it doesn't have to wait for the first mouse movement to
152  // refresh.
154  return 0;
155  }
156  else if( selection.Front()->IsNew() )
157  {
158  // New items will already be on the undo list
159  appendUndo = true;
160  }
161 
162  // Main loop: keep receiving events
163  do
164  {
165  controls->SetSnapping( !evt->Modifier( MD_ALT ) );
166 
167  if( evt->IsAction( &EE_ACTIONS::move ) || evt->IsAction( &EE_ACTIONS::drag )
168  || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
169  || evt->IsAction( &EE_ACTIONS::refreshPreview ) )
170  {
171  if( !m_moveInProgress ) // Prepare to start moving/dragging
172  {
173  //------------------------------------------------------------------------
174  // Setup a drag or a move
175  //
176  for( SCH_ITEM* it = m_frame->GetScreen()->GetDrawItems(); it; it = it->Next() )
177  {
178  if( it->IsSelected() )
179  it->SetFlags( STARTPOINT | ENDPOINT | SELECTEDNODE );
180  else
181  it->ClearFlags( STARTPOINT | ENDPOINT | SELECTEDNODE );
182  }
183 
184  // Add connections to the selection for a drag.
185  //
186  if( m_frame->GetToolId() == ID_SCH_DRAG )
187  {
188  for( EDA_ITEM* item : selection )
189  {
190  if( static_cast<SCH_ITEM*>( item )->IsConnectable() )
191  {
192  std::vector<wxPoint> connections;
193  static_cast<SCH_ITEM*>( item )->GetConnectionPoints( connections );
194 
195  for( wxPoint point : connections )
196  getConnectedDragItems( (SCH_ITEM*) item, point, dragAdditions );
197  }
198  }
199 
200  m_selectionTool->AddItemsToSel( &dragAdditions, QUIET_MODE );
201  }
202 
203  // Mark the edges of the block with dangling flags for a move.
204  //
205  if( m_frame->GetToolId() == ID_SCH_MOVE )
206  {
207  std::vector<DANGLING_END_ITEM> internalPoints;
208 
209  for( EDA_ITEM* item : selection )
210  static_cast<SCH_ITEM*>( item )->GetEndPoints( internalPoints );
211 
212  for( EDA_ITEM* item : selection )
213  static_cast<SCH_ITEM*>( item )->UpdateDanglingState( internalPoints );
214  }
215 
216  // Generic setup
217  //
218  for( EDA_ITEM* item : selection )
219  {
220  if( item->IsNew() )
221  {
222  // TODO(snh): Remove extra tooling check after moving to schematic_commit model
223  if( ( item->GetFlags() & SELECTEDNODE ) != 0
224  && ( m_frame->GetToolId() == ID_SCH_DRAG ) )
225  {
226  // Item was added in getConnectedDragItems
227  saveCopyInUndoList( (SCH_ITEM*) item, UR_NEW, appendUndo );
228  appendUndo = true;
229  }
230  else
231  {
232  // Item was added in a previous command (and saved to undo by
233  // that command)
234  }
235  }
236  else if( item->GetParent() && item->GetParent()->IsSelected() )
237  {
238  // Item will be (or has been) saved to undo by parent
239  }
240  else
241  {
242  saveCopyInUndoList( (SCH_ITEM*) item, UR_CHANGED, appendUndo );
243  appendUndo = true;
244  }
245 
246  // Apply any initial offset in case we're coming from a previous command.
247  //
249  }
250 
251  // Set up the starting position and move/drag offset
252  //
253  m_cursor = controls->GetCursorPosition();
254 
255  if( selection.HasReferencePoint() )
256  {
257  VECTOR2I delta = m_cursor - selection.GetReferencePoint();
258 
259  // Drag items to the current cursor position
260  for( EDA_ITEM* item : selection )
261  {
262  // Don't double move pins, fields, etc.
263  if( item->GetParent() && item->GetParent()->IsSelected() )
264  continue;
265 
266  moveItem( item, delta, m_frame->GetToolId() == ID_SCH_DRAG );
267  updateView( item );
268  }
269 
270  selection.SetReferencePoint( m_cursor );
271  }
272  else if( selection.Size() == 1 )
273  {
274  // Set the current cursor position to the first dragged item origin,
275  // so the movement vector can be computed later
276  updateModificationPoint( selection );
277  m_cursor = originalCursorPos;
278  }
279  else
280  {
281  updateModificationPoint( selection );
282  }
283 
284  controls->SetCursorPosition( m_cursor, false );
286 
287  prevPos = m_cursor;
288  controls->SetAutoPan( true );
289  m_moveInProgress = true;
290  }
291 
292  //------------------------------------------------------------------------
293  // Follow the mouse
294  //
295  m_cursor = controls->GetCursorPosition();
296  VECTOR2I delta( m_cursor - prevPos );
297  selection.SetReferencePoint( m_cursor );
298 
299  m_moveOffset += delta;
300  prevPos = m_cursor;
301 
302  for( EDA_ITEM* item : selection )
303  {
304  // Don't double move pins, fields, etc.
305  if( item->GetParent() && item->GetParent()->IsSelected() )
306  continue;
307 
308  moveItem( item, delta, m_frame->GetToolId() == ID_SCH_DRAG );
309 
310  updateView( item );
311  }
312 
315  }
316  //------------------------------------------------------------------------
317  // Handle cancel
318  //
319  else if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
320  {
321  if( m_moveInProgress )
322  restore_state = true;
323 
324  break;
325  }
326  //------------------------------------------------------------------------
327  // Handle TOOL_ACTION special cases
328  //
329  else if( evt->Action() == TA_UNDO_REDO_PRE )
330  {
331  unselect = true;
332  break;
333  }
334  else if( evt->Category() == TC_COMMAND )
335  {
336  if( evt->IsAction( &EE_ACTIONS::doDelete ) )
337  {
338  // Exit on a remove operation; there is no further processing for removed items.
339  break;
340  }
341  else if( evt->IsAction( &EE_ACTIONS::duplicate ) )
342  {
343  if( selection.Front()->IsNew() )
344  {
345  // This doesn't really make sense; we'll just end up dragging a stack of
346  // objects so Duplicate() is going to ignore this and we'll just carry on.
347  continue;
348  }
349 
350  // Move original back and exit. The duplicate will run in its own loop.
351  restore_state = true;
352  unselect = false;
353  chain_commands = true;
354  break;
355  }
356  else if( evt->Action() == TA_CONTEXT_MENU_CHOICE )
357  {
358  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
359  && evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_CMP_MAX )
360  {
361  SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
362  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
363 
364  if( component )
365  {
366  m_frame->SelectUnit( component, unit );
368  }
369  }
370  }
371  }
372  //------------------------------------------------------------------------
373  // Handle context menu
374  //
375  else if( evt->IsClick( BUT_RIGHT ) )
376  {
378  }
379  //------------------------------------------------------------------------
380  // Handle drop
381  //
382  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
383  {
384  break; // Finish
385  }
386 
387  } while( ( evt = Wait() ) ); //Should be assignment not equality test
388 
389  controls->ForceCursorPosition( false );
390  controls->ShowCursor( false );
391  controls->SetSnapping( false );
392  controls->SetAutoPan( false );
393 
394  if( !chain_commands )
395  m_moveOffset = { 0, 0 };
396 
397  m_moveInProgress = false;
399 
400  selection.ClearReferencePoint();
401 
402  for( auto item : selection )
403  item->ClearEditFlags();
404 
405  if( unselect )
407  else
408  m_selectionTool->RemoveItemsFromSel( &dragAdditions, QUIET_MODE );
409 
410  if( restore_state )
411  {
413  }
414  else
415  {
416  addJunctionsIfNeeded( selection );
419  m_frame->OnModify();
420  }
421 
422  return 0;
423 }
void addJunctionsIfNeeded(SELECTION &aSelection)
Adds junctions if needed to each item in the list after they have been moved.
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
bool IsHover() const
Definition: selection.h:69
void getConnectedDragItems(SCH_ITEM *aOriginalItem, wxPoint aPoint, EDA_ITEMS &aList)
Finds additional items for a drag operation.
static TOOL_ACTION duplicate
Definition: ee_actions.h:118
SCH_ITEM * Next() const
Definition: sch_item.h:153
VECTOR2I m_cursor
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).
Definition: sch_move_tool.h:79
VECTOR2I m_moveOffset
Used for chaining commands
Definition: sch_move_tool.h:75
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
#define SELECTEDNODE
flag indicating that the structure has already selected
Definition: base_struct.h:122
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
static TOOL_ACTION refreshPreview
Definition: ee_actions.h:168
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
int AddItemsToSel(const TOOL_EVENT &aEvent)
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:72
static const int delta[8][2]
Definition: solve.cpp:112
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:136
bool IsNew() const
Definition: base_struct.h:222
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:54
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool updateModificationPoint(SELECTION &aSelection)
Returns the right modification point (e.g.
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:588
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
static TOOL_ACTION doDelete
Definition: ee_actions.h:131
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:143
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:57
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
Definition: tool_event.cpp:177
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: ee_tool_base.h:147
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:207
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
void updateView(EDA_ITEM *aItem) const
Similar to getView()->Update(), but handles items that are redrawn by their parents.
Definition: ee_tool_base.h:107
void moveItem(EDA_ITEM *aItem, VECTOR2I aDelta, bool isDrag)
static TOOL_ACTION drag
Definition: ee_actions.h:117
void RollbackSchematicFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:120
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO_T aType, bool aAppend=false)
Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.
Definition: ee_tool_base.h:120
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
void Activate()
Function Activate() Runs the tool.
static TOOL_ACTION move
Definition: ee_actions.h:116
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
#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:238
SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
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 ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
int GetToolId() const
Definition: draw_frame.h:524
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false)=0
Moves cursor to the requested position expressed in world coordinates.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:155
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
virtual void UpdateMsgPanel()
Redraw the message panel.
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:119
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:153

References TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemsToSel(), addJunctionsIfNeeded(), BUT_LEFT, BUT_RIGHT, SELECTION::ClearReferencePoint(), EE_ACTIONS::clearSelection, delta, EE_ACTIONS::doDelete, EE_ACTIONS::drag, EE_ACTIONS::duplicate, SELECTION::Empty(), ENDPOINT, EOT, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), SELECTION::Front(), getConnectedDragItems(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), SCH_SCREEN::GetDrawItems(), SCH_EDIT_FRAME::GetScreen(), EDA_DRAW_FRAME::GetToolId(), TOOL_BASE::getViewControls(), ID_POPUP_SCH_SELECT_UNIT_CMP, ID_POPUP_SCH_SELECT_UNIT_CMP_MAX, ID_SCH_DRAG, ID_SCH_MOVE, TOOL_EVENT::IsAction(), TOOL_EVT_UTILS::IsCancelInteractive(), SELECTION::IsHover(), EDA_ITEM::IsNew(), m_cursor, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_menu, m_moveInProgress, m_moveOffset, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, MD_ALT, EE_ACTIONS::move, moveItem(), SCH_ITEM::Next(), SCH_EDIT_FRAME::OnModify(), TOOL_MANAGER::PostEvent(), QUIET_MODE, EE_ACTIONS::refreshPreview, EE_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RequestSelection(), 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, SELECTEDNODE, SCH_EDIT_FRAME::SelectUnit(), KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), EDA_DRAW_FRAME::SetNoToolSelected(), SELECTION::SetReferencePoint(), KIGFX::VIEW_CONTROLS::SetSnapping(), EDA_DRAW_FRAME::SetToolID(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), STARTPOINT, TA_CONTEXT_MENU_CHOICE, TA_UNDO_REDO_PRE, TC_COMMAND, SCH_EDIT_FRAME::TestDanglingEnds(), updateModificationPoint(), EDA_DRAW_FRAME::UpdateMsgPanel(), EE_TOOL_BASE< SCH_EDIT_FRAME >::updateView(), UR_CHANGED, UR_NEW, and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ moveItem()

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

Definition at line 574 of file sch_move_tool.cpp.

575 {
576  switch( aItem->Type() )
577  {
578  case SCH_LINE_T:
579  if( aItem->GetFlags() & STARTPOINT )
580  static_cast<SCH_LINE*>( aItem )->MoveStart( (wxPoint) aDelta );
581 
582  if( aItem->GetFlags() & ENDPOINT )
583  static_cast<SCH_LINE*>( aItem )->MoveEnd( (wxPoint) aDelta );
584 
585  break;
586 
587  case SCH_PIN_T:
588  case SCH_FIELD_T:
589  {
590  SCH_COMPONENT* component = (SCH_COMPONENT*) aItem->GetParent();
591  TRANSFORM transform = component->GetTransform().InverseTransform();
592  wxPoint transformedDelta = transform.TransformCoordinate( (wxPoint) aDelta );
593 
594  static_cast<SCH_ITEM*>( aItem )->Move( transformedDelta );
595  break;
596  }
597  default:
598  static_cast<SCH_ITEM*>( aItem )->Move( (wxPoint) aDelta );
599  break;
600  }
601 
602  aItem->SetFlags( IS_MOVED );
603 }
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:58
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
TRANSFORM & GetTransform() const
EDA_ITEM * GetParent() const
Definition: base_struct.h:214
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:120
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:261
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:119
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113

References ENDPOINT, EDA_ITEM::GetFlags(), EDA_ITEM::GetParent(), SCH_COMPONENT::GetTransform(), TRANSFORM::InverseTransform(), IS_MOVED, SCH_FIELD_T, SCH_LINE_T, SCH_PIN_T, EDA_ITEM::SetFlags(), 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:83
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35

◆ 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 85 of file tool_interactive.cpp.

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
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 120 of file ee_tool_base.h.

121  {
122  KICAD_T itemType = aItem->Type();
123 
124  if( m_isLibEdit )
125  {
126  LIB_EDIT_FRAME* editFrame = dynamic_cast<LIB_EDIT_FRAME*>( m_frame );
127  editFrame->SaveCopyInUndoList( (LIB_ITEM*) aItem, aType, aAppend );
128  }
129  else
130  {
131  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
132 
133  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
134  editFrame->SaveCopyInUndoList( (SCH_ITEM*) aItem->GetParent(), UR_CHANGED, aAppend );
135  else
136  editFrame->SaveCopyInUndoList( (SCH_ITEM*) aItem, aType, aAppend );
137  }
138  }
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_draw_item.h:67
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:214
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:204

◆ 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 74 of file tool_interactive.cpp.

75 {
76  if( aMenu )
77  aMenu->SetTool( this );
78  else
79  aTrigger = CMENU_OFF;
80 
81  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
82 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
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(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), TOOL_MENU::ShowContextMenu(), and SCH_WIRE_BUS_TOOL::UnfoldBus().

◆ setTransitions()

void SCH_MOVE_TOOL::setTransitions ( )
overrideprivatevirtual

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

Definition at line 635 of file sch_move_tool.cpp.

636 {
637  Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::move.MakeEvent() );
638  Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::drag.MakeEvent() );
639 }
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:117
static TOOL_ACTION move
Definition: ee_actions.h:116

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

◆ updateModificationPoint()

bool SCH_MOVE_TOOL::updateModificationPoint ( SELECTION aSelection)
private

Returns the right modification point (e.g.

for rotation), depending on the number of selected items.

Definition at line 606 of file sch_move_tool.cpp.

607 {
608  if( m_moveInProgress && aSelection.HasReferencePoint() )
609  return false;
610 
611  // When there is only one item selected, the reference point is its position...
612  if( aSelection.Size() == 1 )
613  {
614  SCH_ITEM* item = static_cast<SCH_ITEM*>( aSelection.Front() );
615 
616  // For some items, moving the cursor to anchor is not good (for instance large
617  // hierarchical sheets or components can have the anchor outside the view)
618  if( item->IsMovableFromAnchorPoint() )
619  {
620  wxPoint pos = item->GetPosition();
621  aSelection.SetReferencePoint( pos );
622 
623  return true;
624  }
625  }
626 
627  // ...otherwise modify items with regard to the grid-snapped cursor position
629  aSelection.SetReferencePoint( m_cursor );
630 
631  return true;
632 }
virtual bool IsMovableFromAnchorPoint()
Virtual function IsMovableFromAnchorPoint.
Definition: sch_item.h:172
VECTOR2I m_cursor
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).
Definition: sch_move_tool.h:79
bool m_moveInProgress
Flag determining if anything is being dragged right now
Definition: sch_move_tool.h:72
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:208
virtual wxPoint GetPosition() const =0
Function GetPosition.
bool HasReferencePoint() const
Definition: selection.h:198
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:155

References SELECTION::Front(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), SCH_ITEM::GetPosition(), TOOL_BASE::getViewControls(), SELECTION::HasReferencePoint(), SCH_ITEM::IsMovableFromAnchorPoint(), m_cursor, m_moveInProgress, SELECTION::SetReferencePoint(), and SELECTION::Size().

Referenced by Main().

◆ 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 107 of file ee_tool_base.h.

108  {
109  KICAD_T itemType = aItem->Type();
110 
111  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
112  getView()->Update( aItem->GetParent() );
113 
114  getView()->Update( aItem );
115  }
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:214
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:1539
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

◆ Wait()

OPT_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 55 of file tool_interactive.cpp.

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
OPT< 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 LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_DRAWING_TOOLS::doPlaceComponent(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), GERBVIEW_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(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), and SCH_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ 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 79 of file sch_move_tool.h.

Referenced by Main(), and updateModificationPoint().

◆ m_frame

SCH_EDIT_FRAME * EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame
protectedinherited

Definition at line 141 of file ee_tool_base.h.

◆ m_isLibEdit

bool EE_TOOL_BASE< SCH_EDIT_FRAME >::m_isLibEdit
protectedinherited

Definition at line 144 of file ee_tool_base.h.

◆ m_menu

TOOL_MENU EE_TOOL_BASE< SCH_EDIT_FRAME >::m_menu
protectedinherited

Menu model displayed by the tool.

Definition at line 147 of file ee_tool_base.h.

◆ m_moveInProgress

bool SCH_MOVE_TOOL::m_moveInProgress
private

Flag determining if anything is being dragged right now

Definition at line 72 of file sch_move_tool.h.

Referenced by Main(), and updateModificationPoint().

◆ m_moveOffset

VECTOR2I SCH_MOVE_TOOL::m_moveOffset
private

Used for chaining commands

Definition at line 75 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 143 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 211 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 216 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemToSel(), SCH_DRAWING_TOOLS::AddJunction(), SCH_DRAWING_TOOLS::AddLabel(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDITOR_CONTROL::ClearHighlight(), PCB_EDITOR_CONTROL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), 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_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), SCH_WIRE_BUS_TOOL::DrawBusses(), DRAWING_TOOL::DrawDimension(), SCH_WIRE_BUS_TOOL::DrawLines(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_WIRE_BUS_TOOL::DrawWires(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), SCH_EDITOR_CONTROL::EnterSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), SCH_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), 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(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), EE_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), SELECTION_TOOL::RequestSelection(), CVPCB_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), EE_SELECTION_TOOL::SelectConnection(), SELECTION_TOOL::selectCopper(), PCB_TOOL_BASE::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), EE_SELECTION_TOOL::SelectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SCH_WIRE_BUS_TOOL::StartBus(), SCH_WIRE_BUS_TOOL::StartLine(), SCH_WIRE_BUS_TOOL::StartWire(), GERBVIEW_SELECTION_TOOL::toggleSelection(), EE_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), SCH_EDITOR_CONTROL::Undo(), SCH_WIRE_BUS_TOOL::UnfoldBus(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), PCB_EDITOR_CONTROL::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 215 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 217 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 208 of file tool_base.h.

Referenced by TOOL_BASE::GetType().

◆ m_view

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

Definition at line 142 of file ee_tool_base.h.


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