KiCad PCB EDA Suite
SCH_DRAWING_TOOLS Class Reference

Class SCH_DRAWING_TOOLS. More...

#include <sch_drawing_tools.h>

Inheritance diagram for SCH_DRAWING_TOOLS:
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_DRAWING_TOOLS ()
 
 ~SCH_DRAWING_TOOLS ()
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
int AddJunction (const TOOL_EVENT &aEvent)
 
int AddLabel (const TOOL_EVENT &aEvent)
 
int PlaceSymbol (const TOOL_EVENT &aEvent)
 
int PlacePower (const TOOL_EVENT &aEvent)
 
int PlaceNoConnect (const TOOL_EVENT &aEvent)
 
int PlaceJunction (const TOOL_EVENT &aEvent)
 
int PlaceBusWireEntry (const TOOL_EVENT &aEvent)
 
int PlaceBusBusEntry (const TOOL_EVENT &aEvent)
 
int PlaceLabel (const TOOL_EVENT &aEvent)
 
int PlaceGlobalLabel (const TOOL_EVENT &aEvent)
 
int PlaceHierarchicalLabel (const TOOL_EVENT &aEvent)
 
int DrawSheet (const TOOL_EVENT &aEvent)
 
int PlaceSheetPin (const TOOL_EVENT &aEvent)
 
int ImportSheetPin (const TOOL_EVENT &aEvent)
 
int PlaceSchematicText (const TOOL_EVENT &aEvent)
 
int PlaceImage (const TOOL_EVENT &aEvent)
 
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

int doPlaceComponent (SCH_COMPONENT *aComponent, SCHLIB_FILTER *aFilter, SCH_BASE_FRAME::HISTORY_LIST aHistoryList)
 
int doSingleClickPlace (KICAD_T aType)
 
int doTwoClickPlace (KICAD_T aType)
 
void sizeSheet (SCH_SHEET *aSheet, VECTOR2I aPos)
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 

Detailed Description

Class SCH_DRAWING_TOOLS.

Tool responsible for drawing/placing items (symbols, wires, busses, labels, etc.)

Definition at line 45 of file sch_drawing_tools.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_DRAWING_TOOLS()

SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS ( )

Definition at line 139 of file sch_drawing_tools.cpp.

139  :
140  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" )
141 {
142 }

◆ ~SCH_DRAWING_TOOLS()

SCH_DRAWING_TOOLS::~SCH_DRAWING_TOOLS ( )

Definition at line 145 of file sch_drawing_tools.cpp.

146 {
147 }

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(), doPlaceComponent(), doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), doTwoClickPlace(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), 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(), SCH_MOVE_TOOL::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(), 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().

◆ AddJunction()

int SCH_DRAWING_TOOLS::AddJunction ( const TOOL_EVENT aEvent)

Definition at line 165 of file sch_drawing_tools.cpp.

166 {
168 
171 
172  return 0;
173 }
virtual void MoveCursorToCrossHair() override
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SCH_DRAW_PANEL * GetCanvas() const override
SCH_JUNCTION * AddJunction(const wxPoint &aPos, bool aAppendToUndo=false, bool aFinal=true)
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:57
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.

References SCH_EDIT_FRAME::AddJunction(), EE_ACTIONS::clearSelection, SCH_BASE_FRAME::GetCanvas(), EDA_DRAW_FRAME::GetCrossHairPosition(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, SCH_DRAW_PANEL::MoveCursorToCrossHair(), and TOOL_MANAGER::RunAction().

Referenced by setTransitions().

◆ AddLabel()

int SCH_DRAWING_TOOLS::AddLabel ( const TOOL_EVENT aEvent)

Definition at line 176 of file sch_drawing_tools.cpp.

177 {
179 
180  int layer = LAYER_NOTES;
181 
182  if( aEvent.IsAction( &EE_ACTIONS::addLabel ) )
183  layer = LAYER_LOCLABEL;
184  else if( aEvent.IsAction( &EE_ACTIONS::addGlobalLabel ) )
185  layer = LAYER_GLOBLABEL;
186  else if( aEvent.IsAction( &EE_ACTIONS::addHierLabel ) )
187  layer = LAYER_HIERLABEL;
188 
189  SCH_ITEM* item = m_frame->CreateNewText( layer );
191 
192  return 0;
193 }
static TOOL_ACTION addHierLabel
Definition: ee_actions.h:135
SCH_TEXT * CreateNewText(int aType)
Definition: edit_label.cpp:47
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
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
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:57
static TOOL_ACTION addLabel
Definition: ee_actions.h:133
static TOOL_ACTION addGlobalLabel
Definition: ee_actions.h:134
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 AddItemToScreenAndUndoList(SCH_ITEM *aItem, bool aUndoAppend=false)
Add an item to the schematic and adds the changes to the undo/redo container.

References EE_ACTIONS::addGlobalLabel, EE_ACTIONS::addHierLabel, SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), EE_ACTIONS::addLabel, EE_ACTIONS::clearSelection, SCH_EDIT_FRAME::CreateNewText(), TOOL_EVENT::IsAction(), LAYER_GLOBLABEL, LAYER_HIERLABEL, LAYER_LOCLABEL, LAYER_NOTES, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, and TOOL_MANAGER::RunAction().

Referenced by setTransitions().

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

◆ doPlaceComponent()

int SCH_DRAWING_TOOLS::doPlaceComponent ( SCH_COMPONENT aComponent,
SCHLIB_FILTER aFilter,
SCH_BASE_FRAME::HISTORY_LIST  aHistoryList 
)
private

Definition at line 223 of file sch_drawing_tools.cpp.

225 {
226  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
227  getViewControls()->ShowCursor( true );
228 
229  Activate();
230 
231  // If a component was passed in get it ready for placement.
232  if( aComponent )
233  {
234  aComponent->SetFlags( IS_NEW | IS_MOVED );
235 
237  m_selectionTool->AddItemToSel( aComponent );
238 
239  // Queue up a refresh event so we don't have to wait for the next mouse-moved event
241  }
242 
243  // Main loop: keep receiving events
244  while( OPT_TOOL_EVENT evt = Wait() )
245  {
246  cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
247 
248  if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
249  {
250  if( aComponent )
251  {
253  m_view->ClearPreview();
254  delete aComponent;
255  aComponent = nullptr;
256 
257  if( !evt->IsActivate() )
258  continue;
259  }
260 
261  break;
262  }
263  else if( evt->IsClick( BUT_LEFT ) )
264  {
265  if( !aComponent )
266  {
268 
269  // Pick the module to be placed
271 
272  auto sel = m_frame->SelectCompFromLibTree( aFilter, aHistoryList, true, 1, 1,
274 
276 
277  // Restore cursor after dialog
279 
280  LIB_PART* part = sel.LibId.IsValid() ? m_frame->GetLibPart( sel.LibId ) : nullptr;
281 
282  if( !part )
283  continue;
284 
285  aComponent = new SCH_COMPONENT( *part, g_CurrentSheet, sel, (wxPoint) cursorPos );
286  aComponent->SetFlags( IS_NEW | IS_MOVED );
287 
288  // Be sure the link to the corresponding LIB_PART is OK:
289  aComponent->Resolve( *m_frame->Prj().SchSymbolLibTable() );
290 
291  if( m_frame->GetAutoplaceFields() )
292  aComponent->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
293 
294  m_frame->SaveCopyForRepeatItem( aComponent );
295 
296  m_view->ClearPreview();
297  m_view->AddToPreview( aComponent->Clone() );
298  m_selectionTool->AddItemToSel( aComponent );
299  }
300  else
301  {
302  m_frame->AddItemToScreenAndUndoList( aComponent );
303  aComponent = nullptr;
304 
305  m_view->ClearPreview();
306  }
307  }
308  else if( evt->IsClick( BUT_RIGHT ) )
309  {
310  // Warp after context menu only if dragging...
311  if( !aComponent )
313 
315  }
316  else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CONTEXT_MENU_CHOICE )
317  {
318  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
319  && evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_CMP_MAX )
320  {
321  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
322 
323  if( aComponent )
324  {
325  m_frame->SelectUnit( aComponent, unit );
327  }
328  }
329  }
330  else if( aComponent && ( evt->IsAction( &EE_ACTIONS::refreshPreview )
331  || evt->IsMotion() ) )
332  {
333  aComponent->SetPosition( (wxPoint)cursorPos );
334  m_view->ClearPreview();
335  m_view->AddToPreview( aComponent->Clone() );
336  }
337 
338  // Enable autopanning and cursor capture only when there is a module to be placed
339  getViewControls()->SetAutoPan( !!aComponent );
340  getViewControls()->CaptureCursor( !!aComponent );
341  }
342 
344 
345  return 0;
346 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: sch_view.cpp:145
bool Resolve(PART_LIBS *aLibs)
Assigns the current LIB_PART from aLibs which this symbol is based on.
virtual void MoveCursorToCrossHair() override
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
bool GetShowFootprintPreviews() const
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
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
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
bool GetAutoplaceFields() const
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
COMPONENT_SELECTION SelectCompFromLibTree(const SCHLIB_FILTER *aFilter, std::vector< COMPONENT_SELECTION > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Function SelectComponentFromLib Calls the library viewer to select component to import into schematic...
Definition: getpart.cpp:95
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
SCH_DRAW_PANEL * GetCanvas() const override
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
void ClearPreview()
Definition: sch_view.cpp:133
Define a library symbol object.
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:143
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:57
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
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Automatically orient all the fields in the component.
int AddItemToSel(const TOOL_EVENT &aEvent)
void SetIgnoreMouseEvents(bool aIgnore)
void VetoContextMenuMouseWarp()
Disables mouse warping after the current context menu is closed.
Definition: tool_manager.h:385
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
void Activate()
Function Activate() Runs the tool.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
void AddItemToScreenAndUndoList(SCH_ITEM *aItem, bool aUndoAppend=false)
Add an item to the schematic and adds the changes to the undo/redo container.
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113

References TOOL_INTERACTIVE::Activate(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), EE_SELECTION_TOOL::AddItemToSel(), KIGFX::SCH_VIEW::AddToPreview(), SCH_COMPONENT::AutoplaceFields(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), KIGFX::SCH_VIEW::ClearPreview(), EE_ACTIONS::clearSelection, SCH_COMPONENT::Clone(), g_CurrentSheet, SCH_EDIT_FRAME::GetAutoplaceFields(), SCH_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), SCH_BASE_FRAME::GetLibPart(), SCH_EDIT_FRAME::GetShowFootprintPreviews(), TOOL_BASE::getViewControls(), ID_POPUP_SCH_SELECT_UNIT_CMP, ID_POPUP_SCH_SELECT_UNIT_CMP_MAX, IS_MOVED, IS_NEW, TOOL_EVT_UTILS::IsCancelInteractive(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_menu, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view, MD_ALT, SCH_DRAW_PANEL::MoveCursorToCrossHair(), KIWAY_HOLDER::Prj(), EE_ACTIONS::refreshPreview, SCH_COMPONENT::Resolve(), TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), SCH_BASE_FRAME::SelectCompFromLibTree(), SCH_EDIT_FRAME::SelectUnit(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_ITEM::SetFlags(), EDA_DRAW_PANEL::SetIgnoreMouseEvents(), EDA_DRAW_FRAME::SetNoToolSelected(), SCH_COMPONENT::SetPosition(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), TA_CONTEXT_MENU_CHOICE, TC_COMMAND, TOOL_MANAGER::VetoContextMenuMouseWarp(), and TOOL_INTERACTIVE::Wait().

Referenced by PlacePower(), and PlaceSymbol().

◆ doSingleClickPlace()

int SCH_DRAWING_TOOLS::doSingleClickPlace ( KICAD_T  aType)
private

Definition at line 498 of file sch_drawing_tools.cpp.

499 {
500  wxPoint cursorPos;
501 
503  getViewControls()->ShowCursor( true );
504  getViewControls()->SetSnapping( true );
505 
506  Activate();
507 
508  // Main loop: keep receiving events
509  while( OPT_TOOL_EVENT evt = Wait() )
510  {
511  cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
512 
513  if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
514  {
515  break;
516  }
517  else if( evt->IsClick( BUT_LEFT ) )
518  {
519  SCH_ITEM* item = nullptr;
520 
521  if( !m_frame->GetScreen()->GetItem( cursorPos, 0, aType ) )
522  {
523  switch( aType )
524  {
525  case SCH_NO_CONNECT_T:
526  item = new SCH_NO_CONNECT( cursorPos );
527  break;
528  case SCH_JUNCTION_T:
529  item = m_frame->AddJunction( cursorPos );
530  break;
532  item = new SCH_BUS_WIRE_ENTRY( cursorPos, g_lastBusEntryShape );
533  break;
534  case SCH_BUS_BUS_ENTRY_T:
535  item = new SCH_BUS_BUS_ENTRY( cursorPos, g_lastBusEntryShape );
536  break;
537  default:
538  wxFAIL_MSG( "doSingleClickPlace(): unknown type" );
539  }
540  }
541 
542  if( item )
543  {
544  item->SetFlags( IS_NEW );
546 
548 
551  m_frame->OnModify();
552  }
553  }
554  else if( evt->IsClick( BUT_RIGHT ) )
555  {
557  }
558  }
559 
561 
562  return 0;
563 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
Class for a bus to bus entry.
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
char g_lastBusEntryShape
Definition: ee_actions.cpp:29
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
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.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
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
SCH_ITEM * GetItem(const wxPoint &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T) const
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:237
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
SCH_JUNCTION * AddJunction(const wxPoint &aPos, bool aAppendToUndo=false, bool aFinal=true)
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:57
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 SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Class for a wire to bus entry.
void Activate()
Function Activate() Runs the tool.
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
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
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
void AddItemToScreenAndUndoList(SCH_ITEM *aItem, bool aUndoAppend=false)
Add an item to the schematic and adds the changes to the undo/redo container.

References TOOL_INTERACTIVE::Activate(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_EDIT_FRAME::AddJunction(), BUT_LEFT, BUT_RIGHT, EE_ACTIONS::clearSelection, g_lastBusEntryShape, KIGFX::VIEW_CONTROLS::GetCursorPosition(), SCH_SCREEN::GetItem(), SCH_EDIT_FRAME::GetScreen(), TOOL_BASE::getViewControls(), IS_NEW, TOOL_EVT_UTILS::IsCancelInteractive(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_menu, TOOL_BASE::m_toolMgr, MD_ALT, SCH_EDIT_FRAME::OnModify(), TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_JUNCTION_T, SCH_NO_CONNECT_T, SCH_EDIT_FRAME::SchematicCleanUp(), EDA_ITEM::SetFlags(), EDA_DRAW_FRAME::SetNoToolSelected(), KIGFX::VIEW_CONTROLS::SetSnapping(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), SCH_EDIT_FRAME::TestDanglingEnds(), and TOOL_INTERACTIVE::Wait().

Referenced by PlaceBusBusEntry(), PlaceBusWireEntry(), PlaceJunction(), and PlaceNoConnect().

◆ doTwoClickPlace()

int SCH_DRAWING_TOOLS::doTwoClickPlace ( KICAD_T  aType)
private

Definition at line 608 of file sch_drawing_tools.cpp.

609 {
610  VECTOR2I cursorPos;
611  EDA_ITEM* item = nullptr;
612 
614  getViewControls()->ShowCursor( true );
615 
616  Activate();
617 
618  // Main loop: keep receiving events
619  while( OPT_TOOL_EVENT evt = Wait() )
620  {
621  cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
622 
623  if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
624  {
625  if( item )
626  {
628  m_view->ClearPreview();
629  delete item;
630  item = nullptr;
631 
632  if( !evt->IsActivate() )
633  continue;
634  }
635 
636  break;
637  }
638  else if( evt->IsClick( BUT_LEFT ) )
639  {
640  // First click creates...
641  if( !item )
642  {
645 
646  switch( aType )
647  {
648  case SCH_LABEL_T:
650  break;
651  case SCH_HIER_LABEL_T:
653  break;
654  case SCH_GLOBAL_LABEL_T:
656  break;
657  case SCH_TEXT_T:
658  item = m_frame->CreateNewText( LAYER_NOTES );
659  break;
660  case SCH_SHEET_PIN_T:
662 
663  if( item )
664  {
666  item = m_frame->ImportSheetPin( (SCH_SHEET*) item );
667  else
668  item = m_frame->CreateSheetPin( (SCH_SHEET*) item );
669  }
670  break;
671  default:
672  wxFAIL_MSG( "doTwoClickPlace(): unknown type" );
673  }
674 
676 
677  // Restore cursor after dialog
679 
680  if( item )
681  {
682  item->SetFlags( IS_NEW | IS_MOVED );
683  m_view->ClearPreview();
684  m_view->AddToPreview( item->Clone() );
685  m_selectionTool->AddItemToSel( item );
686  }
687 
688  getViewControls()->SetCursorPosition( cursorPos, false );
689  }
690 
691  // ... and second click places:
692  else
693  {
695  item = nullptr;
696 
697  m_view->ClearPreview();
698  }
699  }
700  else if( evt->IsClick( BUT_RIGHT ) )
701  {
702  // Warp after context menu only if dragging...
703  if( !item )
705 
707  }
708  else if( item && TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) )
709  {
710  // This happens if our text was replaced out from under us by ConvertTextType()
711  SELECTION& selection = m_selectionTool->GetSelection();
712 
713  if( selection.GetSize() == 1 )
714  {
715  item = (SCH_ITEM*) selection.Front();
716  m_view->ClearPreview();
717  m_view->AddToPreview( item->Clone() );
718  }
719  else
720  item = nullptr;
721  }
722  else if( item && ( evt->IsAction( &EE_ACTIONS::refreshPreview )
723  || evt->IsMotion() ) )
724  {
725  static_cast<SCH_ITEM*>( item )->SetPosition( (wxPoint)cursorPos );
726  m_view->ClearPreview();
727  m_view->AddToPreview( item->Clone() );
728  }
729 
730  // Enable autopanning and cursor capture only when there is a module to be placed
731  getViewControls()->SetAutoPan( !!item );
732  getViewControls()->CaptureCursor( !!item );
733  }
734 
736 
737  return 0;
738 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
SELECTION & GetSelection()
Function GetSelection()
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: sch_view.cpp:145
SCH_TEXT * CreateNewText(int aType)
Definition: edit_label.cpp:47
virtual void MoveCursorToCrossHair() override
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
static const KICAD_T SheetsAndSheetLabels[]
Definition: ee_collectors.h:46
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
SCH_SHEET_PIN * CreateSheetPin(SCH_SHEET *aSheet)
Create a new SCH_SHEET_PIN object and add it to aSheet at the current cursor position.
Definition: sheet.cpp:345
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
bool IsSelectionEvent(const TOOL_EVENT &aEvt)
Function IsSelectionEvent()
Definition: tool_event.cpp:185
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
SCH_DRAW_PANEL * GetCanvas() const override
void ClearPreview()
Definition: sch_view.cpp:133
SCH_SHEET_PIN * ImportSheetPin(SCH_SHEET *aSheet)
Automatically create a sheet pin from the hierarchical labels in the schematic referenced by aSheet.
Definition: sheet.cpp:372
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:143
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:57
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.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:201
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:98
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_sheet.cpp:98
int AddItemToSel(const TOOL_EVENT &aEvent)
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_sheet.cpp:693
void SetIgnoreMouseEvents(bool aIgnore)
void VetoContextMenuMouseWarp()
Disables mouse warping after the current context menu is closed.
Definition: tool_manager.h:385
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.
EDA_ITEM * SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, bool *aSelectionCancelledFlag=NULL, bool aCheckLocked=false)
Function selectPoint() Selects an item pointed by the parameter aWhere.
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
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
void AddItemToScreenAndUndoList(SCH_ITEM *aItem, bool aUndoAppend=false)
Add an item to the schematic and adds the changes to the undo/redo container.
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113

References TOOL_INTERACTIVE::Activate(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), EE_SELECTION_TOOL::AddItemToSel(), KIGFX::SCH_VIEW::AddToPreview(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), KIGFX::SCH_VIEW::ClearPreview(), EE_ACTIONS::clearSelection, EDA_ITEM::Clone(), SCH_EDIT_FRAME::CreateNewText(), SCH_EDIT_FRAME::CreateSheetPin(), SELECTION::Front(), SCH_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), EE_SELECTION_TOOL::GetSelection(), SELECTION::GetSize(), EDA_DRAW_FRAME::GetToolId(), TOOL_BASE::getViewControls(), ID_IMPORT_SHEETPIN_TOOL, SCH_EDIT_FRAME::ImportSheetPin(), IS_MOVED, IS_NEW, TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsSelectionEvent(), LAYER_GLOBLABEL, LAYER_HIERLABEL, LAYER_LOCLABEL, LAYER_NOTES, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_menu, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view, MD_ALT, SCH_DRAW_PANEL::MoveCursorToCrossHair(), EE_ACTIONS::refreshPreview, TOOL_MANAGER::RunAction(), SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_SHEET_PIN_T, SCH_TEXT_T, EE_SELECTION_TOOL::SelectPoint(), KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), EDA_ITEM::SetFlags(), EDA_DRAW_PANEL::SetIgnoreMouseEvents(), EDA_DRAW_FRAME::SetNoToolSelected(), EE_COLLECTOR::SheetsAndSheetLabels, TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), TOOL_MANAGER::VetoContextMenuMouseWarp(), and TOOL_INTERACTIVE::Wait().

Referenced by ImportSheetPin(), PlaceGlobalLabel(), PlaceHierarchicalLabel(), PlaceLabel(), PlaceSchematicText(), and PlaceSheetPin().

◆ DrawSheet()

int SCH_DRAWING_TOOLS::DrawSheet ( const TOOL_EVENT aEvent)

Definition at line 741 of file sch_drawing_tools.cpp.

742 {
743  m_frame->SetToolID( ID_SHEET_TOOL, wxCURSOR_PENCIL, _( "Add sheet" ) );
745  getViewControls()->ShowCursor( true );
746 
747  SCH_SHEET* sheet = nullptr;
748 
749  Activate();
750 
751  // Main loop: keep receiving events
752  while( auto evt = Wait() )
753  {
754  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
755 
756  if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
757  {
759  m_view->ClearPreview();
760 
761  if( sheet )
762  {
763  delete sheet;
764  sheet = nullptr;
765 
766  if( !evt->IsActivate() )
767  continue;
768  }
769 
770  break;
771  }
772 
773  else if( evt->IsClick( BUT_LEFT ) && !sheet )
774  {
776 
777  sheet = new SCH_SHEET( (wxPoint) cursorPos );
778  sheet->SetFlags( IS_NEW | IS_RESIZED );
779  sheet->SetTimeStamp( GetNewTimeStamp() );
780  sheet->SetParent( m_frame->GetScreen() );
781  sheet->SetScreen( NULL );
782  sizeSheet( sheet, cursorPos );
783 
784  m_selectionTool->AddItemToSel( sheet );
785  m_view->ClearPreview();
786  m_view->AddToPreview( sheet->Clone() );
787  }
788 
789  else if( sheet && ( evt->IsClick( BUT_LEFT )
790  || evt->IsAction( &EE_ACTIONS::finishSheet ) ) )
791  {
792  m_view->ClearPreview();
793 
794  if( m_frame->EditSheet( (SCH_SHEET*)sheet, g_CurrentSheet, nullptr ) )
796  else
797  delete sheet;
798 
799  sheet = nullptr;
800  }
801 
802  else if( sheet && ( evt->IsAction( &EE_ACTIONS::refreshPreview )
803  || evt->IsMotion() ) )
804  {
805  sizeSheet( sheet, cursorPos );
806  m_view->ClearPreview();
807  m_view->AddToPreview( sheet->Clone() );
808  }
809 
810  else if( evt->IsClick( BUT_RIGHT ) )
811  {
812  // Warp after context menu only if dragging...
813  if( !sheet )
815 
817  }
818 
819  // Enable autopanning and cursor capture only when there is a sheet to be placed
820  getViewControls()->SetAutoPan( !!sheet );
821  getViewControls()->CaptureCursor( !!sheet );
822  }
823 
825 
826  return 0;
827 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: sch_view.cpp:145
static TOOL_ACTION finishSheet
Definition: ee_actions.h:103
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:104
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
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
bool EditSheet(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
Edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:49
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:219
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
void ClearPreview()
Definition: sch_view.cpp:133
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:143
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.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:201
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_sheet.cpp:98
int AddItemToSel(const TOOL_EVENT &aEvent)
void VetoContextMenuMouseWarp()
Disables mouse warping after the current context menu is closed.
Definition: tool_manager.h:385
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:115
void Activate()
Function Activate() Runs the tool.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:209
void sizeSheet(SCH_SHEET *aSheet, VECTOR2I aPos)
void AddItemToScreenAndUndoList(SCH_ITEM *aItem, bool aUndoAppend=false)
Add an item to the schematic and adds the changes to the undo/redo container.

References TOOL_INTERACTIVE::Activate(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), EE_SELECTION_TOOL::AddItemToSel(), KIGFX::SCH_VIEW::AddToPreview(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), KIGFX::SCH_VIEW::ClearPreview(), EE_ACTIONS::clearSelection, SCH_SHEET::Clone(), SCH_EDIT_FRAME::EditSheet(), EE_ACTIONS::finishSheet, g_CurrentSheet, KIGFX::VIEW_CONTROLS::GetCursorPosition(), GetNewTimeStamp(), SCH_EDIT_FRAME::GetScreen(), TOOL_BASE::getViewControls(), ID_SHEET_TOOL, IS_NEW, IS_RESIZED, TOOL_EVT_UTILS::IsCancelInteractive(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_menu, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view, MD_ALT, EE_ACTIONS::refreshPreview, TOOL_MANAGER::RunAction(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_ITEM::SetFlags(), EDA_DRAW_FRAME::SetNoToolSelected(), EDA_ITEM::SetParent(), SCH_SHEET::SetScreen(), EDA_ITEM::SetTimeStamp(), EDA_DRAW_FRAME::SetToolID(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), sizeSheet(), TOOL_MANAGER::VetoContextMenuMouseWarp(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ 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

◆ 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(), doPlaceComponent(), doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), doTwoClickPlace(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), LIB_DRAWING_TOOLS::DrawShape(), 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(), SCH_MOVE_TOOL::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(), 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(), SCH_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 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(), SCH_MOVE_TOOL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), CVPCB_SELECTION_TOOL::setTransitions(), setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), SCH_WIRE_BUS_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), GERBVIEW_SELECTION_TOOL::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().

◆ ImportSheetPin()

int SCH_DRAWING_TOOLS::ImportSheetPin ( const TOOL_EVENT aEvent)

Definition at line 594 of file sch_drawing_tools.cpp.

595 {
596  m_frame->SetToolID( ID_IMPORT_SHEETPIN_TOOL, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
598 }
int doTwoClickPlace(KICAD_T aType)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.

References doTwoClickPlace(), ID_IMPORT_SHEETPIN_TOOL, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_SHEET_PIN_T, and EDA_DRAW_FRAME::SetToolID().

Referenced by setTransitions().

◆ Init()

bool SCH_DRAWING_TOOLS::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 150 of file sch_drawing_tools.cpp.

151 {
153 
154  auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
155  return g_CurrentSheet->Last() != g_RootSheet;
156  };
157 
158  auto& ctxMenu = m_menu.GetMenu();
159  ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
160 
161  return true;
162 }
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:161
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: ee_tool_base.h:147
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()

References CONDITIONAL_MENU::AddItem(), g_CurrentSheet, g_RootSheet, TOOL_MENU::GetMenu(), EE_TOOL_BASE< T >::Init(), SCH_SHEET_PATH::Last(), EE_ACTIONS::leaveSheet, and EE_TOOL_BASE< SCH_EDIT_FRAME >::m_menu.

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

◆ PlaceBusBusEntry()

int SCH_DRAWING_TOOLS::PlaceBusBusEntry ( const TOOL_EVENT aEvent)

Definition at line 491 of file sch_drawing_tools.cpp.

492 {
493  m_frame->SetToolID( ID_BUSTOBUS_ENTRY_TOOL, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
495 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
int doSingleClickPlace(KICAD_T aType)

References doSingleClickPlace(), ID_BUSTOBUS_ENTRY_TOOL, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_BUS_BUS_ENTRY_T, and EDA_DRAW_FRAME::SetToolID().

Referenced by setTransitions().

◆ PlaceBusWireEntry()

int SCH_DRAWING_TOOLS::PlaceBusWireEntry ( const TOOL_EVENT aEvent)

Definition at line 484 of file sch_drawing_tools.cpp.

485 {
486  m_frame->SetToolID( ID_WIRETOBUS_ENTRY_TOOL, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
488 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
int doSingleClickPlace(KICAD_T aType)

References doSingleClickPlace(), ID_WIRETOBUS_ENTRY_TOOL, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_BUS_WIRE_ENTRY_T, and EDA_DRAW_FRAME::SetToolID().

Referenced by setTransitions().

◆ PlaceGlobalLabel()

int SCH_DRAWING_TOOLS::PlaceGlobalLabel ( const TOOL_EVENT aEvent)

Definition at line 573 of file sch_drawing_tools.cpp.

574 {
575  m_frame->SetToolID( ID_GLOBALLABEL_TOOL, wxCURSOR_PENCIL, _( "Add global label" ) );
577 }
int doTwoClickPlace(KICAD_T aType)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.

References doTwoClickPlace(), ID_GLOBALLABEL_TOOL, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_GLOBAL_LABEL_T, and EDA_DRAW_FRAME::SetToolID().

Referenced by setTransitions().

◆ PlaceHierarchicalLabel()

int SCH_DRAWING_TOOLS::PlaceHierarchicalLabel ( const TOOL_EVENT aEvent)

Definition at line 580 of file sch_drawing_tools.cpp.

581 {
582  m_frame->SetToolID( ID_HIERLABEL_TOOL, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
584 }
int doTwoClickPlace(KICAD_T aType)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.

References doTwoClickPlace(), ID_HIERLABEL_TOOL, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_HIER_LABEL_T, and EDA_DRAW_FRAME::SetToolID().

Referenced by setTransitions().

◆ PlaceImage()

int SCH_DRAWING_TOOLS::PlaceImage ( const TOOL_EVENT aEvent)

Definition at line 349 of file sch_drawing_tools.cpp.

350 {
351  SCH_BITMAP* image = aEvent.Parameter<SCH_BITMAP*>();
352 
353  m_frame->SetToolID( ID_PLACE_IMAGE_TOOL, wxCURSOR_PENCIL, _( "Add image" ) );
354 
355  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
356 
358  getViewControls()->ShowCursor( true );
359 
360  Activate();
361 
362  // Add all the drawable parts to preview
363  if( image )
364  {
365  image->SetPosition( (wxPoint)cursorPos );
366  m_view->ClearPreview();
367  m_view->AddToPreview( image->Clone() );
368  }
369 
370  // Main loop: keep receiving events
371  while( OPT_TOOL_EVENT evt = Wait() )
372  {
373  cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
374 
375  if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
376  {
377  if( image )
378  {
380  m_view->ClearPreview();
381  delete image;
382  image = nullptr;
383 
384  if( !evt->IsActivate() )
385  continue;
386  }
387 
388  break;
389  }
390  else if( evt->IsClick( BUT_LEFT ) )
391  {
392  if( !image )
393  {
395 
397 
398  wxFileDialog dlg( m_frame, _( "Choose Image" ), wxEmptyString, wxEmptyString,
399  _( "Image Files " ) + wxImage::GetImageExtWildcard(), wxFD_OPEN );
400 
401  if( dlg.ShowModal() != wxID_OK )
402  continue;
403 
405 
406  // Restore cursor after dialog
408 
409  wxString fullFilename = dlg.GetPath();
410 
411  if( wxFileExists( fullFilename ) )
412  image = new SCH_BITMAP( (wxPoint)cursorPos );
413 
414  if( !image || !image->ReadImageFile( fullFilename ) )
415  {
416  wxMessageBox( _( "Couldn't load image from \"%s\"" ), fullFilename );
417  delete image;
418  image = nullptr;
419  continue;
420  }
421 
422  image->SetFlags( IS_NEW | IS_MOVED );
423 
424  m_frame->SaveCopyForRepeatItem( image );
425 
426  m_view->ClearPreview();
427  m_view->AddToPreview( image->Clone() );
428  m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
429 
430  m_selectionTool->AddItemToSel( image );
431 
432  getViewControls()->SetCursorPosition( cursorPos, false );
433  }
434  else
435  {
437  image = nullptr;
438 
439  m_view->ClearPreview();
440  }
441  }
442  else if( evt->IsClick( BUT_RIGHT ) )
443  {
444  // Warp after context menu only if dragging...
445  if( !image )
447 
449  }
450  else if( image && ( evt->IsAction( &EE_ACTIONS::refreshPreview )
451  || evt->IsMotion() ) )
452  {
453  image->SetPosition( (wxPoint)cursorPos );
454  m_view->ClearPreview();
455  m_view->AddToPreview( image->Clone() );
456  m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
457  }
458 
459  // Enable autopanning and cursor capture only when there is a module to be placed
460  getViewControls()->SetAutoPan( !!image );
461  getViewControls()->CaptureCursor( !!image );
462  }
463 
465 
466  return 0;
467 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: sch_view.cpp:145
virtual void MoveCursorToCrossHair() override
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1401
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
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
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
SCH_DRAW_PANEL * GetCanvas() const override
void ClearPreview()
Definition: sch_view.cpp:133
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:143
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
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
int AddItemToSel(const TOOL_EVENT &aEvent)
void SetIgnoreMouseEvents(bool aIgnore)
void VetoContextMenuMouseWarp()
Disables mouse warping after the current context menu is closed.
Definition: tool_manager.h:385
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_bitmap.cpp:86
void Activate()
Function Activate() Runs the tool.
bool ReadImageFile(const wxString &aFullFilename)
Reads and stores an image file.
Definition: sch_bitmap.cpp:80
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_bitmap.h:153
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.
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
void AddItemToScreenAndUndoList(SCH_ITEM *aItem, bool aUndoAppend=false)
Add an item to the schematic and adds the changes to the undo/redo container.
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113

References TOOL_INTERACTIVE::Activate(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), EE_SELECTION_TOOL::AddItemToSel(), KIGFX::SCH_VIEW::AddToPreview(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), KIGFX::SCH_VIEW::ClearPreview(), EE_ACTIONS::clearSelection, SCH_BITMAP::Clone(), SCH_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getViewControls(), ID_PLACE_IMAGE_TOOL, IS_MOVED, IS_NEW, TOOL_EVT_UTILS::IsCancelInteractive(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_menu, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view, MD_ALT, SCH_DRAW_PANEL::MoveCursorToCrossHair(), TOOL_EVENT::Parameter(), SCH_BITMAP::ReadImageFile(), KIGFX::VIEW::RecacheAllItems(), EE_ACTIONS::refreshPreview, TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), EDA_ITEM::SetFlags(), EDA_DRAW_PANEL::SetIgnoreMouseEvents(), EDA_DRAW_FRAME::SetNoToolSelected(), SCH_BITMAP::SetPosition(), EDA_DRAW_FRAME::SetToolID(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), TOOL_MANAGER::VetoContextMenuMouseWarp(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ PlaceJunction()

int SCH_DRAWING_TOOLS::PlaceJunction ( const TOOL_EVENT aEvent)

Definition at line 477 of file sch_drawing_tools.cpp.

478 {
479  m_frame->SetToolID( ID_JUNCTION_TOOL, wxCURSOR_PENCIL, _( "Add junction" ) );
481 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
int doSingleClickPlace(KICAD_T aType)

References doSingleClickPlace(), ID_JUNCTION_TOOL, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_JUNCTION_T, and EDA_DRAW_FRAME::SetToolID().

Referenced by setTransitions().

◆ PlaceLabel()

int SCH_DRAWING_TOOLS::PlaceLabel ( const TOOL_EVENT aEvent)

Definition at line 566 of file sch_drawing_tools.cpp.

567 {
568  m_frame->SetToolID( ID_LABEL_TOOL, wxCURSOR_PENCIL, _( "Add net label" ) );
569  return doTwoClickPlace( SCH_LABEL_T );
570 }
int doTwoClickPlace(KICAD_T aType)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.

References doTwoClickPlace(), ID_LABEL_TOOL, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_LABEL_T, and EDA_DRAW_FRAME::SetToolID().

Referenced by setTransitions().

◆ PlaceNoConnect()

int SCH_DRAWING_TOOLS::PlaceNoConnect ( const TOOL_EVENT aEvent)

Definition at line 470 of file sch_drawing_tools.cpp.

471 {
472  m_frame->SetToolID( ID_NOCONNECT_TOOL, wxCURSOR_PENCIL, _( "Add no connect" ) );
474 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
int doSingleClickPlace(KICAD_T aType)

References doSingleClickPlace(), ID_NOCONNECT_TOOL, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_NO_CONNECT_T, and EDA_DRAW_FRAME::SetToolID().

Referenced by setTransitions().

◆ PlacePower()

int SCH_DRAWING_TOOLS::PlacePower ( const TOOL_EVENT aEvent)

Definition at line 211 of file sch_drawing_tools.cpp.

212 {
213  SCH_COMPONENT* component = aEvent.Parameter<SCH_COMPONENT*>();
214  SCHLIB_FILTER filter;
215 
216  filter.FilterPowerParts( true );
217  m_frame->SetToolID( ID_PLACE_POWER_TOOL, wxCURSOR_PENCIL, _( "Add Power" ) );
218 
219  return doPlaceComponent( component, &filter, s_PowerHistoryList );
220 }
void FilterPowerParts(bool aFilterEnable)
set the filtering of power parts
static SCH_BASE_FRAME::HISTORY_LIST s_PowerHistoryList
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
int doPlaceComponent(SCH_COMPONENT *aComponent, SCHLIB_FILTER *aFilter, SCH_BASE_FRAME::HISTORY_LIST aHistoryList)

References doPlaceComponent(), SCHLIB_FILTER::FilterPowerParts(), ID_PLACE_POWER_TOOL, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_EVENT::Parameter(), s_PowerHistoryList, and EDA_DRAW_FRAME::SetToolID().

Referenced by setTransitions().

◆ PlaceSchematicText()

int SCH_DRAWING_TOOLS::PlaceSchematicText ( const TOOL_EVENT aEvent)

Definition at line 601 of file sch_drawing_tools.cpp.

602 {
603  m_frame->SetToolID( ID_SCHEMATIC_TEXT_TOOL, wxCURSOR_PENCIL, _( "Add text" ) );
604  return doTwoClickPlace( SCH_TEXT_T );
605 }
int doTwoClickPlace(KICAD_T aType)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.

References doTwoClickPlace(), ID_SCHEMATIC_TEXT_TOOL, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_TEXT_T, and EDA_DRAW_FRAME::SetToolID().

Referenced by setTransitions().

◆ PlaceSheetPin()

int SCH_DRAWING_TOOLS::PlaceSheetPin ( const TOOL_EVENT aEvent)

Definition at line 587 of file sch_drawing_tools.cpp.

588 {
589  m_frame->SetToolID( ID_SHEETPIN_TOOL, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
591 }
int doTwoClickPlace(KICAD_T aType)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.

References doTwoClickPlace(), ID_SHEETPIN_TOOL, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_SHEET_PIN_T, and EDA_DRAW_FRAME::SetToolID().

Referenced by setTransitions().

◆ PlaceSymbol()

int SCH_DRAWING_TOOLS::PlaceSymbol ( const TOOL_EVENT aEvent)

Definition at line 201 of file sch_drawing_tools.cpp.

202 {
203  SCH_COMPONENT* component = aEvent.Parameter<SCH_COMPONENT*>();
204 
205  m_frame->SetToolID( ID_PLACE_SYMBOL_TOOL, wxCURSOR_PENCIL, _( "Add Symbol" ) );
206 
207  return doPlaceComponent( component, nullptr, s_SymbolHistoryList );
208 }
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
int doPlaceComponent(SCH_COMPONENT *aComponent, SCHLIB_FILTER *aFilter, SCH_BASE_FRAME::HISTORY_LIST aHistoryList)
static SCH_BASE_FRAME::HISTORY_LIST s_SymbolHistoryList

References doPlaceComponent(), ID_PLACE_SYMBOL_TOOL, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_EVENT::Parameter(), s_SymbolHistoryList, and EDA_DRAW_FRAME::SetToolID().

Referenced by setTransitions().

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

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

Definition at line 843 of file sch_drawing_tools.cpp.

844 {
859 
864 }
int PlaceSchematicText(const TOOL_EVENT &aEvent)
static TOOL_ACTION addHierLabel
Definition: ee_actions.h:135
int PlaceBusBusEntry(const TOOL_EVENT &aEvent)
static TOOL_ACTION placeJunction
Definition: ee_actions.h:86
int PlaceLabel(const TOOL_EVENT &aEvent)
int PlaceBusWireEntry(const TOOL_EVENT &aEvent)
static TOOL_ACTION placeBusBusEntry
Definition: ee_actions.h:88
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:87
int ImportSheetPin(const TOOL_EVENT &aEvent)
int PlaceImage(const TOOL_EVENT &aEvent)
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION drawSheet
Definition: ee_actions.h:92
int PlaceSymbol(const TOOL_EVENT &aEvent)
static TOOL_ACTION placePower
Definition: ee_actions.h:79
static TOOL_ACTION placeSheetPin
Definition: ee_actions.h:93
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:95
static TOOL_ACTION placeImage
Definition: ee_actions.h:98
int PlaceHierarchicalLabel(const TOOL_EVENT &aEvent)
static TOOL_ACTION addJunction
Definition: ee_actions.h:132
int PlacePower(const TOOL_EVENT &aEvent)
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:94
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:78
static TOOL_ACTION placeHierarchicalLabel
Definition: ee_actions.h:91
int PlaceJunction(const TOOL_EVENT &aEvent)
static TOOL_ACTION placeLabel
Definition: ee_actions.h:89
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:85
int PlaceGlobalLabel(const TOOL_EVENT &aEvent)
int PlaceSheetPin(const TOOL_EVENT &aEvent)
int AddLabel(const TOOL_EVENT &aEvent)
int PlaceNoConnect(const TOOL_EVENT &aEvent)
static TOOL_ACTION addLabel
Definition: ee_actions.h:133
static TOOL_ACTION addGlobalLabel
Definition: ee_actions.h:134
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:90
int DrawSheet(const TOOL_EVENT &aEvent)
int AddJunction(const TOOL_EVENT &aEvent)

References EE_ACTIONS::addGlobalLabel, EE_ACTIONS::addHierLabel, AddJunction(), EE_ACTIONS::addJunction, AddLabel(), EE_ACTIONS::addLabel, DrawSheet(), EE_ACTIONS::drawSheet, TOOL_INTERACTIVE::Go(), ImportSheetPin(), EE_ACTIONS::importSheetPin, PlaceBusBusEntry(), EE_ACTIONS::placeBusBusEntry, PlaceBusWireEntry(), EE_ACTIONS::placeBusWireEntry, PlaceGlobalLabel(), EE_ACTIONS::placeGlobalLabel, PlaceHierarchicalLabel(), EE_ACTIONS::placeHierarchicalLabel, PlaceImage(), EE_ACTIONS::placeImage, PlaceJunction(), EE_ACTIONS::placeJunction, PlaceLabel(), EE_ACTIONS::placeLabel, PlaceNoConnect(), EE_ACTIONS::placeNoConnect, PlacePower(), EE_ACTIONS::placePower, PlaceSchematicText(), EE_ACTIONS::placeSchematicText, PlaceSheetPin(), EE_ACTIONS::placeSheetPin, PlaceSymbol(), and EE_ACTIONS::placeSymbol.

◆ sizeSheet()

void SCH_DRAWING_TOOLS::sizeSheet ( SCH_SHEET aSheet,
VECTOR2I  aPos 
)
private

Definition at line 830 of file sch_drawing_tools.cpp.

831 {
832  wxPoint pos = aSheet->GetPosition();
833  wxPoint size = (wxPoint) aPos - pos;
834 
835  size.x = std::max( size.x, MIN_SHEET_WIDTH );
836  size.y = std::max( size.y, MIN_SHEET_HEIGHT );
837 
838  wxPoint grid = m_frame->GetNearestGridPosition( pos + size );
839  aSheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
840 }
#define MIN_SHEET_WIDTH
Definition: sch_sheet.h:42
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:530
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Return the nearest aGridSize location to aPosition.
#define max(a, b)
Definition: auxiliary.h:86
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:43
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:702

References EDA_DRAW_FRAME::GetNearestGridPosition(), SCH_SHEET::GetPosition(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, max, MIN_SHEET_HEIGHT, MIN_SHEET_WIDTH, SCH_SHEET::Resize(), and VECTOR2< T >::x.

Referenced by DrawSheet().

◆ 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(), doPlaceComponent(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), doTwoClickPlace(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), 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(), SCH_MOVE_TOOL::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(), 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_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_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(), AddJunction(), 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(), doPlaceComponent(), doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), doTwoClickPlace(), DRAWING_TOOL::drawArc(), SCH_WIRE_BUS_TOOL::DrawBusses(), DRAWING_TOOL::DrawDimension(), SCH_WIRE_BUS_TOOL::DrawLines(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), 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(), SCH_MOVE_TOOL::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(), 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: