KiCad PCB EDA Suite
SCH_LINE_WIRE_BUS_TOOL Class Reference

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

#include <sch_line_wire_bus_tool.h>

Inheritance diagram for SCH_LINE_WIRE_BUS_TOOL:
EE_TOOL_BASE< SCH_EDIT_FRAME > TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 SCH_LINE_WIRE_BUS_TOOL ()
 
 ~SCH_LINE_WIRE_BUS_TOOL ()
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
int DrawSegments (const TOOL_EVENT &aEvent)
 
int UnfoldBus (const TOOL_EVENT &aEvent)
 
int AddJunctionsIfNeeded (const TOOL_EVENT &aEvent)
 Handle the addition of junctions to a selection of objects. More...
 
int TrimOverLappingWires (const TOOL_EVENT &aEvent)
 Logic to remove wires when overlapping correct items. More...
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Static Public Member Functions

static bool IsDrawingLine (const SELECTION &aSelection)
 
static bool IsDrawingWire (const SELECTION &aSelection)
 
static bool IsDrawingBus (const SELECTION &aSelection)
 
static bool IsDrawingLineWireOrBus (const SELECTION &aSelection)
 

Protected Member Functions

void updateItem (EDA_ITEM *aItem, bool aUpdateRTree) const
 Similar to getView()->Update(), but handles items that are redrawn by their parents and updating the SCH_SCREEN's RTree. More...
 
void saveCopyInUndoList (EDA_ITEM *aItem, UNDO_REDO aType, bool aAppend=false)
 
void attachManager (TOOL_MANAGER *aManager)
 Set the TOOL_MANAGER the tool will belong to. More...
 
KIGFX::VIEWgetView () const
 Returns the instance of #VIEW object used in the application. More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Return the instance of VIEW_CONTROLS object used in the application. More...
 
template<typename T >
T * getEditFrame () const
 Return the application window object, casted to requested user type. More...
 
template<typename T >
T * getModel () const
 Return the model object if it matches the requested type. More...
 

Protected Attributes

SCH_EDIT_FRAMEm_frame
 
KIGFX::SCH_VIEWm_view
 
EE_SELECTION_TOOLm_selectionTool
 
bool m_isSymbolEditor
 
TOOL_MENU m_menu
 The functions below are not yet implemented - their interface may change. More...
 
TOOL_TYPE m_type
 Unique identifier for the tool, assigned by a TOOL_MANAGER instance. More...
 
TOOL_ID m_toolId
 Name of the tool. More...
 
std::string m_toolName
 
TOOL_MANAGERm_toolMgr
 

Private Member Functions

int doDrawSegments (const std::string &aTool, int aType, bool aQuitOnDraw)
 
SCH_LINEstartSegments (int aType, const VECTOR2D &aPos)
 
SCH_LINEdoUnfoldBus (const wxString &aNet, const wxPoint &aPos=wxDefaultPosition)
 
void finishSegments ()
 
void simplifyWireList ()
 Iterate over the wire list and removes the null segments and overlapping segments to create a simplified wire list. More...
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
const SCH_SHEET_PINgetSheetPin (const wxPoint &aPosition)
 Search for a sheet pin at a location. More...
 
void computeBreakPoint (const std::pair< SCH_LINE *, SCH_LINE * > &aSegments, wxPoint &aPosition)
 Compute the middle coordinate for 2 segments from the start point to aPosition with the segments kept in the horizontal or vertical axis only. More...
 

Private Attributes

bool m_inDrawingTool
 
BUS_UNFOLDING_T m_busUnfold
 
std::vector< SCH_LINE * > m_wires
 

Detailed Description

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

Definition at line 73 of file sch_line_wire_bus_tool.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

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

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

Constructor & Destructor Documentation

◆ SCH_LINE_WIRE_BUS_TOOL()

SCH_LINE_WIRE_BUS_TOOL::SCH_LINE_WIRE_BUS_TOOL ( )

Definition at line 166 of file sch_line_wire_bus_tool.cpp.

166  :
167  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawingLineWireBus" ),
168  m_inDrawingTool( false )
169 {
170  m_busUnfold = {};
171  m_wires.reserve( 16 );
172 }
std::vector< SCH_LINE * > m_wires

References m_busUnfold, and m_wires.

◆ ~SCH_LINE_WIRE_BUS_TOOL()

SCH_LINE_WIRE_BUS_TOOL::~SCH_LINE_WIRE_BUS_TOOL ( )

Definition at line 175 of file sch_line_wire_bus_tool.cpp.

176 {
177 }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run the tool.

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

Definition at line 51 of file tool_interactive.cpp.

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.

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

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_TREE::onContextMenu(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and UnfoldBus().

◆ AddJunctionsIfNeeded()

int SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded ( const TOOL_EVENT aEvent)

Handle the addition of junctions to a selection of objects.

Definition at line 1066 of file sch_line_wire_bus_tool.cpp.

1067 {
1068  EE_SELECTION* aSelection = aEvent.Parameter<EE_SELECTION*>();
1069 
1070  std::vector<wxPoint> pts;
1071  std::vector<wxPoint> connections = m_frame->GetSchematicConnections();
1072 
1073  std::set<SCH_LINE*> lines;
1074  EDA_RECT bb = aSelection->GetBoundingBox();
1075 
1076  for( EDA_ITEM* item : m_frame->GetScreen()->Items().Overlapping( SCH_LINE_T, bb ) )
1077  lines.insert( static_cast<SCH_LINE*>( item ) );
1078 
1079  for( unsigned ii = 0; ii < aSelection->GetSize(); ii++ )
1080  {
1081  SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aSelection->GetItem( ii ) );
1082 
1083  if( !item || !item->IsConnectable() )
1084  continue;
1085 
1086  std::vector<wxPoint> new_pts = item->GetConnectionPoints();
1087  pts.insert( pts.end(), new_pts.begin(), new_pts.end() );
1088 
1089  // If the item is a line, we also add any connection points from the rest of the schematic
1090  // that terminate on the line after it is moved.
1091  if( item->Type() == SCH_LINE_T )
1092  {
1093  SCH_LINE* line = (SCH_LINE*) item;
1094 
1095  for( const wxPoint& pt : connections )
1096  {
1097  if( IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), pt ) )
1098  pts.push_back( pt );
1099  }
1100  }
1101  }
1102 
1103  // We always have some overlapping connection points. Drop duplicates here
1104  std::sort( pts.begin(), pts.end(),
1105  []( const wxPoint& a, const wxPoint& b ) -> bool
1106  {
1107  return a.x < b.x || ( a.x == b.x && a.y < b.y );
1108  } );
1109 
1110  pts.erase( unique( pts.begin(), pts.end() ), pts.end() );
1111 
1112  for( const wxPoint& point : pts )
1113  {
1114  if( m_frame->GetScreen()->IsExplicitJunctionNeeded( point ) )
1115  m_frame->AddJunction( m_frame->GetScreen(), point, true, false );
1116  }
1117 
1118  return 0;
1119 }
virtual bool IsConnectable() const
Definition: sch_item.h:349
virtual std::vector< wxPoint > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:364
wxPoint GetStartPoint() const
Definition: sch_line.h:90
EDA_RECT GetBoundingBox() const override
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
Definition: trigo.cpp:42
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const wxPoint &aPos, bool aAppendToUndo, bool aFinal=true)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
std::vector< wxPoint > GetSchematicConnections()
Collect a unique list of all possible connection points in the schematic.
EE_TYPE Overlapping(const EDA_RECT &aRect) const
Definition: sch_rtree.h:235
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:88
bool IsExplicitJunctionNeeded(const wxPoint &aPosition) const
Indicates that a junction dot is necessary at the given location, and does not yet exist.
Definition: sch_screen.cpp:423
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:53
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
Handle the component boundary box.
Definition: eda_rect.h:42
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
wxPoint GetEndPoint() const
Definition: sch_line.h:93

References SCH_EDIT_FRAME::AddJunction(), EE_SELECTION::GetBoundingBox(), SCH_ITEM::GetConnectionPoints(), SCH_LINE::GetEndPoint(), SELECTION::GetItem(), SCH_EDIT_FRAME::GetSchematicConnections(), SCH_EDIT_FRAME::GetScreen(), SELECTION::GetSize(), SCH_LINE::GetStartPoint(), SCH_ITEM::IsConnectable(), SCH_SCREEN::IsExplicitJunctionNeeded(), IsPointOnSegment(), SCH_SCREEN::Items(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_RTREE::Overlapping(), TOOL_EVENT::Parameter(), SCH_LINE_T, and EDA_ITEM::Type().

Referenced by setTransitions().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Set the TOOL_MANAGER the tool will belong to.

Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

61 {
62  m_toolMgr = aManager;
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ computeBreakPoint()

void SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint ( const std::pair< SCH_LINE *, SCH_LINE * > &  aSegments,
wxPoint &  aPosition 
)
private

Compute the middle coordinate for 2 segments from the start point to aPosition with the segments kept in the horizontal or vertical axis only.

Parameters
aSegmentsA pair of pointers to a SCH_LINE objects containing the first line break point to compute.
aPositionA reference to a wxPoint object containing the coordinates of the position used to calculate the line break point.

Definition at line 422 of file sch_line_wire_bus_tool.cpp.

424 {
425  wxCHECK_RET( aSegments.first && aSegments.second,
426  wxT( "Cannot compute break point of NULL line segment." ) );
427 
428  SCH_LINE* segment = aSegments.first;
429  SCH_LINE* next_segment = aSegments.second;
430 
431  wxPoint midPoint;
432  int iDx = segment->GetEndPoint().x - segment->GetStartPoint().x;
433  int iDy = segment->GetEndPoint().y - segment->GetStartPoint().y;
434 
435  const SCH_SHEET_PIN* connectedPin = getSheetPin( segment->GetStartPoint() );
436  SHEET_SIDE force = connectedPin ? connectedPin->GetSide() : SHEET_SIDE::UNDEFINED;
437 
438  if( force == SHEET_SIDE::LEFT || force == SHEET_SIDE::RIGHT )
439  {
440  if( aPosition.x == connectedPin->GetPosition().x ) // push outside sheet boundary
441  {
442  int direction = ( force == SHEET_SIDE::LEFT ) ? -1 : 1;
443  aPosition.x += KiROUND( getView()->GetGAL()->GetGridSize().x * direction );
444  }
445 
446  midPoint.x = aPosition.x;
447  midPoint.y = segment->GetStartPoint().y; // force horizontal
448  }
449  else if( iDy != 0 ) // keep the first segment orientation (vertical)
450  {
451  midPoint.x = segment->GetStartPoint().x;
452  midPoint.y = aPosition.y;
453  }
454  else if( iDx != 0 ) // keep the first segment orientation (horizontal)
455  {
456  midPoint.x = aPosition.x;
457  midPoint.y = segment->GetStartPoint().y;
458  }
459  else
460  {
461  if( std::abs( aPosition.x - segment->GetStartPoint().x ) <
462  std::abs( aPosition.y - segment->GetStartPoint().y ) )
463  {
464  midPoint.x = segment->GetStartPoint().x;
465  midPoint.y = aPosition.y;
466  }
467  else
468  {
469  midPoint.x = aPosition.x;
470  midPoint.y = segment->GetStartPoint().y;
471  }
472  }
473 
474  segment->SetEndPoint( midPoint );
475  next_segment->SetStartPoint( midPoint );
476  next_segment->SetEndPoint( aPosition );
477 }
wxPoint GetStartPoint() const
Definition: sch_line.h:90
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
const SCH_SHEET_PIN * getSheetPin(const wxPoint &aPosition)
Search for a sheet pin at a location.
SHEET_SIDE GetSide() const
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:91
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
wxPoint GetPosition() const override
Definition: sch_text.h:241
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
SHEET_SIDE
Define the edge of the sheet that the sheet pin is positioned.
Definition: sch_sheet_pin.h:45
wxPoint GetEndPoint() const
Definition: sch_line.h:93

References SCH_LINE::GetEndPoint(), SCH_TEXT::GetPosition(), getSheetPin(), SCH_SHEET_PIN::GetSide(), SCH_LINE::GetStartPoint(), TOOL_BASE::getView(), KiROUND(), LEFT, RIGHT, SCH_LINE::SetEndPoint(), SCH_LINE::SetStartPoint(), and UNDEFINED.

Referenced by doDrawSegments().

◆ doDrawSegments()

int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments ( const std::string &  aTool,
int  aType,
bool  aQuitOnDraw 
)
private

Definition at line 480 of file sch_line_wire_bus_tool.cpp.

481 {
482  SCH_SCREEN* screen = m_frame->GetScreen();
483  SCH_LINE* segment = nullptr;
486  bool forceHV = m_frame->eeconfig()->m_Drawing.hv_lines_only;
487 
488  auto setCursor =
489  [&]()
490  {
491  if( aType == LAYER_WIRE )
493  else if( aType == LAYER_BUS )
495  else if( aType == LAYER_NOTES )
497  else
499  };
500 
501  auto cleanup =
502  [&] ()
503  {
505 
506  for( SCH_LINE* wire : m_wires )
507  delete wire;
508 
509  m_wires.clear();
510  segment = nullptr;
511 
512  if( m_busUnfold.entry )
514 
517 
520 
521  delete m_busUnfold.entry;
522  delete m_busUnfold.label;
523  m_busUnfold = {};
524 
525  m_view->ClearPreview();
526  m_view->ShowPreview( false );
527  };
528 
529  Activate();
530  // Must be done after Activate() so that it gets set into the correct context
531  controls->ShowCursor( true );
532  // Set initial cursor
533  setCursor();
534 
535  // Add the new label to the selection so the rotate command operates on it
536  if( m_busUnfold.label )
538 
539  // Continue the existing wires if we've started (usually by immediate action preference)
540  if( !m_wires.empty() )
541  segment = m_wires.back();
542 
543  wxPoint contextMenuPos;
544 
545  // Main loop: keep receiving events
546  while( TOOL_EVENT* evt = Wait() )
547  {
548  setCursor();
549  grid.SetMask( GRID_HELPER::ALL );
550  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
551  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
552 
553  if( segment )
554  {
555  if( segment->GetStartPoint().x == segment->GetEndPoint().x )
556  grid.ClearMaskFlag( GRID_HELPER::VERTICAL );
557 
558  if( segment->GetStartPoint().y == segment->GetEndPoint().y )
559  grid.ClearMaskFlag( GRID_HELPER::HORIZONTAL );
560  }
561 
562  wxPoint cursorPos = static_cast<wxPoint>( evt->HasPosition() ?
563  evt->Position() :
564  controls->GetMousePosition() );
565 
566  cursorPos = (wxPoint) grid.BestSnapAnchor( cursorPos, LAYER_CONNECTABLE, segment );
567  controls->ForceCursorPosition( true, cursorPos );
568 
569  // Need to handle change in H/V mode while drawing
570  if( forceHV != m_frame->eeconfig()->m_Drawing.hv_lines_only )
571  {
572  forceHV = m_frame->eeconfig()->m_Drawing.hv_lines_only;
573 
574  // Need to delete extra segment if we have one
575  if( !forceHV && m_wires.size() >= 2 && segment != nullptr )
576  {
577  m_wires.pop_back();
579  delete segment;
580 
581  segment = m_wires.back();
582  segment->SetEndPoint( cursorPos );
583  }
584  // Add a segment so we can move orthogonally
585  else if( forceHV && segment )
586  {
587  segment->SetEndPoint( cursorPos );
588 
589  // Create a new segment, and chain it after the current segment.
590  segment = static_cast<SCH_LINE*>( segment->Duplicate() );
591  segment->SetFlags( IS_NEW | IS_MOVING );
592  segment->SetStartPoint( cursorPos );
593  m_wires.push_back( segment );
594 
595  m_selectionTool->AddItemToSel( segment, true /*quiet mode*/ );
596  }
597  }
598 
599 
600  //------------------------------------------------------------------------
601  // Handle cancel:
602  //
603  if( evt->IsCancelInteractive() )
604  {
605  m_frame->GetInfoBar()->Dismiss();
606 
607  if( segment || m_busUnfold.in_progress )
608  {
609  cleanup();
610  }
611  else
612  {
613  m_frame->PopTool( aTool );
614  break;
615  }
616  }
617  else if( evt->IsActivate() )
618  {
619  if( segment || m_busUnfold.in_progress )
620  {
621  m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel drawing." ) );
622  evt->SetPassEvent( false );
623  continue;
624  }
625 
626  if( evt->IsMoveTool() )
627  {
628  // leave ourselves on the stack so we come back after the move
629  break;
630  }
631  else
632  {
633  m_frame->PopTool( aTool );
634  break;
635  }
636  }
637  //------------------------------------------------------------------------
638  // Handle finish:
639  //
640  else if( evt->IsAction( &EE_ACTIONS::finishLineWireOrBus )
641  || evt->IsAction( &EE_ACTIONS::finishWire )
642  || evt->IsAction( &EE_ACTIONS::finishBus )
643  || evt->IsAction( &EE_ACTIONS::finishLine ) )
644  {
645  if( segment || m_busUnfold.in_progress )
646  {
647  finishSegments();
648  segment = nullptr;
649 
650  if( aQuitOnDraw )
651  {
652  m_frame->PopTool( aTool );
653  break;
654  }
655  }
656  }
657  //------------------------------------------------------------------------
658  // Handle click:
659  //
660  else if( evt->IsClick( BUT_LEFT ) || ( segment && evt->IsDblClick( BUT_LEFT ) ) )
661  {
662  // First click when unfolding places the label and wire-to-bus entry
664  {
665  wxASSERT( aType == LAYER_WIRE );
666 
667  m_frame->AddToScreen( m_busUnfold.label, screen );
669  m_busUnfold.label_placed = true;
670  }
671 
672  if( !segment )
673  {
674  segment = startSegments( aType, VECTOR2D( cursorPos ) );
675  }
676  // Create a new segment if we're out of previously-created ones
677  else if( !segment->IsNull() || ( forceHV && !m_wires[ m_wires.size() - 2 ]->IsNull() ) )
678  {
679  // Terminate the command if the end point is on a pin, junction, label, or another
680  // wire or bus.
681  if( screen->IsTerminalPoint( cursorPos, segment->GetLayer() ) )
682  {
683  finishSegments();
684  segment = nullptr;
685 
686  if( aQuitOnDraw )
687  {
688  m_frame->PopTool( aTool );
689  break;
690  }
691  }
692  else
693  {
694  segment->SetEndPoint( cursorPos );
695 
696  // Create a new segment, and chain it after the current segment.
697  segment = static_cast<SCH_LINE*>( segment->Duplicate() );
698  segment->SetFlags( IS_NEW | IS_MOVING );
699  segment->SetStartPoint( cursorPos );
700  m_wires.push_back( segment );
701 
702  m_selectionTool->AddItemToSel( segment, true /*quiet mode*/ );
703  }
704  }
705 
706  if( evt->IsDblClick( BUT_LEFT ) && segment )
707  {
708  if( forceHV && m_wires.size() >= 2 )
709  computeBreakPoint( { m_wires[ m_wires.size() - 2 ], segment }, cursorPos );
710 
711  finishSegments();
712  segment = nullptr;
713 
714  if( aQuitOnDraw )
715  {
716  m_frame->PopTool( aTool );
717  break;
718  }
719  }
720  }
721  //------------------------------------------------------------------------
722  // Handle motion:
723  //
724  else if( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) )
725  {
726  m_view->ClearPreview();
727 
728  // Update the bus unfold posture based on the mouse movement
730  {
731  wxPoint cursor_delta = cursorPos - m_busUnfold.origin;
733 
734  bool flipX = ( cursor_delta.x < 0 );
735  bool flipY = ( cursor_delta.y < 0 );
736 
737  // Erase and redraw if necessary
738  if( flipX != m_busUnfold.flipX || flipY != m_busUnfold.flipY )
739  {
740  wxSize size = entry->GetSize();
741  int ySign = flipY ? -1 : 1;
742  int xSign = flipX ? -1 : 1;
743 
744  size.x = std::abs( size.x ) * xSign;
745  size.y = std::abs( size.y ) * ySign;
746  entry->SetSize( size );
747 
748  m_busUnfold.flipY = flipY;
749  m_busUnfold.flipX = flipX;
750 
751  m_frame->UpdateItem( entry, false, true );
752  m_wires.front()->SetStartPoint( entry->GetEnd() );
753  }
754 
755  // Update the label "ghost" position
756  m_busUnfold.label->SetPosition( cursorPos );
758 
759  // Ensure segment is non-null at the start of bus unfold
760  if( !segment )
761  segment = m_wires.back();
762  }
763 
764  if( segment )
765  {
766  // Coerce the line to vertical or horizontal if necessary
767  if( forceHV && m_wires.size() >= 2 )
768  computeBreakPoint( { m_wires[ m_wires.size() - 2 ], segment }, cursorPos );
769  else
770  segment->SetEndPoint( cursorPos );
771  }
772 
773  for( SCH_LINE* wire : m_wires )
774  {
775  if( !wire->IsNull() )
776  m_view->AddToPreview( wire->Clone() );
777  }
778  }
779  //------------------------------------------------------------------------
780  // Handle context menu:
781  //
782  else if( evt->IsClick( BUT_RIGHT ) )
783  {
784  // Warp after context menu only if dragging...
785  if( !segment )
787 
788  contextMenuPos = cursorPos;
790  }
791  else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
792  {
793  if( evt->GetCommandId().get() >= ID_POPUP_SCH_UNFOLD_BUS
794  && evt->GetCommandId().get() <= ID_POPUP_SCH_UNFOLD_BUS_END )
795  {
796  wxASSERT_MSG( !segment, wxT( "Bus unfold event received when already drawing!" ) );
797 
798  aType = LAYER_WIRE;
799  wxString net = *evt->Parameter<wxString*>();
800  segment = doUnfoldBus( net, contextMenuPos );
801  }
802  }
803  //------------------------------------------------------------------------
804  // Handle TOOL_ACTION special cases
805  //
806  else if( evt->IsAction( &EE_ACTIONS::rotateCW ) || evt->IsAction( &EE_ACTIONS::rotateCCW ) )
807  {
809  {
810  m_busUnfold.label->Rotate90( evt->IsAction( &EE_ACTIONS::rotateCW ) );
812  }
813  else
814  {
815  wxBell();
816  }
817  }
818  else if( evt->IsAction( &ACTIONS::doDelete ) && ( segment || m_busUnfold.in_progress ) )
819  {
820  cleanup();
821  }
822  else
823  {
824  evt->SetPassEvent();
825  }
826 
827  // Enable autopanning and cursor capture only when there is a segment to be placed
828  controls->SetAutoPan( segment != nullptr );
829  controls->CaptureCursor( segment != nullptr );
830  }
831 
832  controls->SetAutoPan( false );
833  controls->CaptureCursor( false );
835  controls->ForceCursorPosition( false );
836  return 0;
837 }
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
bool flipY
True if the bus entry should be flipped in the y-axis.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
wxPoint GetStartPoint() const
Definition: sch_line.h:90
void SetSize(const wxSize &aSize)
Definition: sch_bus_entry.h:76
#define IS_NEW
New item, just created.
static TOOL_ACTION doDelete
Definition: actions.h:72
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1614
bool IsTerminalPoint(const wxPoint &aPosition, int aLayer) const
Test if aPosition is a connection point on aLayer.
Definition: sch_screen.cpp:545
std::vector< SCH_LINE * > m_wires
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
SCH_LINE * startSegments(int aType, const VECTOR2D &aPos)
static TOOL_ACTION finishLineWireOrBus
Definition: ee_actions.h:94
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
static TOOL_ACTION rotateCW
Definition: ee_actions.h:117
static TOOL_ACTION finishLine
Definition: ee_actions.h:97
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
void ShowPreview(bool aShow=true)
Definition: view.cpp:1628
EE_SELECTION & GetSelection()
Return the set of currently selected items.
EESCHEMA_SETTINGS * eeconfig() const
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:118
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:845
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
#define IS_MOVING
Item being moved.
wxPoint origin
Origin (on the bus) of the unfold.
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:85
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
bool IsNull() const
Definition: sch_line.h:88
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:91
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Generic, UI-independent tool event.
Definition: tool_event.h:152
void ClearPreview()
Definition: view.cpp:1592
An interface for classes handling user events controlling the view behavior such as zooming,...
#define _(s)
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
void computeBreakPoint(const std::pair< SCH_LINE *, SCH_LINE * > &aSegments, wxPoint &aPosition)
Compute the middle coordinate for 2 segments from the start point to aPosition with the segments kept...
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
SCH_BUS_WIRE_ENTRY * entry
virtual void Rotate90(bool aClockwise)
Definition: sch_text.cpp:312
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:259
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
wxSize GetSize() const
Definition: sch_bus_entry.h:75
int AddItemToSel(const TOOL_EVENT &aEvent)
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void VetoContextMenuMouseWarp()
Disable mouse warping after the current context menu is closed.
Definition: tool_manager.h:422
Class for a wire to bus entry.
void Activate()
Run the tool.
WX_INFOBAR * GetInfoBar()
bool label_placed
True if user has placed the net label.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
static TOOL_ACTION finishBus
Definition: ee_actions.h:96
void SetPosition(const wxPoint &aPosition) override
Definition: sch_text.h:242
bool flipX
True if the bus entry should be flipped in the x-axis.
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
SCH_LINE * doUnfoldBus(const wxString &aNet, const wxPoint &aPos=wxDefaultPosition)
static TOOL_ACTION finishWire
Definition: ee_actions.h:95
static TOOL_ACTION refreshPreview
Definition: actions.h:106
bool in_progress
True if bus unfold operation is running.
wxPoint GetEnd() const
wxPoint GetEndPoint() const
Definition: sch_line.h:93

References _, TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemToSel(), KIGFX::VIEW::AddToPreview(), SCH_BASE_FRAME::AddToScreen(), GRID_HELPER::ALL, ARROW, BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), KIGFX::VIEW::ClearPreview(), EE_ACTIONS::clearSelection, SCH_LABEL::Clone(), computeBreakPoint(), WX_INFOBAR::Dismiss(), ACTIONS::doDelete, doUnfoldBus(), SCH_ITEM::Duplicate(), SCH_BASE_FRAME::eeconfig(), BUS_UNFOLDING_T::entry, EE_ACTIONS::finishBus, EE_ACTIONS::finishLine, EE_ACTIONS::finishLineWireOrBus, finishSegments(), EE_ACTIONS::finishWire, BUS_UNFOLDING_T::flipX, BUS_UNFOLDING_T::flipY, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), SCH_BASE_FRAME::GetCanvas(), SCH_BUS_ENTRY_BASE::GetEnd(), SCH_LINE::GetEndPoint(), EDA_BASE_FRAME::GetInfoBar(), SCH_ITEM::GetLayer(), KIGFX::VIEW_CONTROLS::GetMousePosition(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), SCH_BUS_ENTRY_BASE::GetSize(), SCH_LINE::GetStartPoint(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), grid, GRID_HELPER::HORIZONTAL, EESCHEMA_SETTINGS::DRAWING::hv_lines_only, ID_POPUP_SCH_UNFOLD_BUS, ID_POPUP_SCH_UNFOLD_BUS_END, BUS_UNFOLDING_T::in_progress, IS_MOVING, IS_NEW, SCH_LINE::IsNull(), SCH_SCREEN::IsTerminalPoint(), BUS_UNFOLDING_T::label, BUS_UNFOLDING_T::label_placed, LAYER_BUS, LAYER_CONNECTABLE, LAYER_NOTES, LAYER_WIRE, LINE_BUS, LINE_GRAPHIC, LINE_WIRE, m_busUnfold, EESCHEMA_SETTINGS::m_Drawing, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_INTERACTIVE::m_menu, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_BASE::m_toolMgr, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view, m_wires, MD_SHIFT, BUS_UNFOLDING_T::origin, TOOLS_HOLDER::PopTool(), ACTIONS::refreshPreview, SCH_BASE_FRAME::RemoveFromScreen(), EE_SELECTION_TOOL::RemoveItemFromSel(), SCH_TEXT::Rotate90(), EE_ACTIONS::rotateCCW, EE_ACTIONS::rotateCW, TOOL_MANAGER::RunAction(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), SCH_LINE::SetEndPoint(), EDA_ITEM::SetFlags(), SCH_TEXT::SetPosition(), SCH_BUS_ENTRY_BASE::SetSize(), SCH_LINE::SetStartPoint(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), EDA_BASE_FRAME::ShowInfoBarMsg(), KIGFX::VIEW::ShowPreview(), startSegments(), TA_CHOICE_MENU_CHOICE, TC_COMMAND, SCH_BASE_FRAME::UpdateItem(), GRID_HELPER::VERTICAL, TOOL_MANAGER::VetoContextMenuMouseWarp(), and TOOL_INTERACTIVE::Wait().

Referenced by DrawSegments(), and UnfoldBus().

◆ doUnfoldBus()

SCH_LINE * SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus ( const wxString &  aNet,
const wxPoint &  aPos = wxDefaultPosition 
)
private

Definition at line 372 of file sch_line_wire_bus_tool.cpp.

373 {
374  SCHEMATIC_SETTINGS& cfg = getModel<SCHEMATIC>()->Settings();
375 
376  wxPoint pos = aPos;
377 
378  if( aPos == wxDefaultPosition )
379  pos = static_cast<wxPoint>( getViewControls()->GetCursorPosition() );
380 
382 
383  m_busUnfold.entry = new SCH_BUS_WIRE_ENTRY( pos );
386 
392 
393  m_busUnfold.in_progress = true;
394  m_busUnfold.origin = pos;
395  m_busUnfold.net_name = aNet;
396 
398 
400 }
#define IS_NEW
New item, just created.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
SCH_LINE * startSegments(int aType, const VECTOR2D &aPos)
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:115
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
#define IS_MOVING
Item being moved.
wxPoint origin
Origin (on the bus) of the unfold.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
wxString net_name
Net label for the unfolding operation.
SCH_BUS_WIRE_ENTRY * entry
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
These settings were stored in SCH_BASE_FRAME previously.
Class for a wire to bus entry.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:330
bool in_progress
True if bus unfold operation is running.
wxPoint GetEnd() const

References SCH_BASE_FRAME::AddToScreen(), EE_ACTIONS::clearSelection, BUS_UNFOLDING_T::entry, SCH_BUS_ENTRY_BASE::GetEnd(), SCH_EDIT_FRAME::GetScreen(), TOOL_BASE::getViewControls(), BUS_UNFOLDING_T::in_progress, IS_MOVING, IS_NEW, BUS_UNFOLDING_T::label, LAYER_WIRE, m_busUnfold, SCHEMATIC_SETTINGS::m_DefaultTextSize, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, BUS_UNFOLDING_T::net_name, BUS_UNFOLDING_T::origin, LABEL_SPIN_STYLE::RIGHT, TOOL_MANAGER::RunAction(), KIGFX::VIEW_CONTROLS::SetCrossHairCursorPosition(), EDA_ITEM::SetFlags(), SCH_TEXT::SetLabelSpinStyle(), EDA_ITEM::SetParent(), EDA_TEXT::SetTextSize(), and startSegments().

Referenced by doDrawSegments(), and UnfoldBus().

◆ DrawSegments()

int SCH_LINE_WIRE_BUS_TOOL::DrawSegments ( const TOOL_EVENT aEvent)

Definition at line 280 of file sch_line_wire_bus_tool.cpp.

281 {
282  if( m_inDrawingTool )
283  return 0;
284 
286 
288 
289  std::string tool = aEvent.GetCommandStr().get();
290  m_frame->PushTool( tool );
292 
293  if( aEvent.HasPosition() )
294  {
296  grid.SetSnap( !aEvent.Modifier( MD_SHIFT ) );
297  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !aEvent.DisableGridSnapping() );
298 
299  VECTOR2D cursorPos = grid.BestSnapAnchor( aEvent.Position(), LAYER_CONNECTABLE, nullptr );
300  startSegments( params->layer, cursorPos );
301  }
302 
303  return doDrawSegments( tool, params->layer, params->quitOnDraw );
304 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
SCH_LINE * startSegments(int aType, const VECTOR2D &aPos)
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
bool DisableGridSnapping() const
Definition: tool_event.h:341
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
int doDrawSegments(const std::string &aTool, int aType, bool aQuitOnDraw)
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:336
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
bool HasPosition() const
Definition: tool_event.h:240
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:263

References EE_ACTIONS::clearSelection, TOOL_EVENT::DisableGridSnapping(), doDrawSegments(), TOOL_EVENT::GetCommandStr(), TOOL_BASE::getView(), grid, TOOL_EVENT::HasPosition(), DRAW_SEGMENT_EVENT_PARAMS::layer, LAYER_CONNECTABLE, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_inDrawingTool, TOOL_BASE::m_toolMgr, MD_SHIFT, TOOL_EVENT::Modifier(), TOOL_EVENT::Parameter(), TOOL_EVENT::Position(), TOOLS_HOLDER::PushTool(), DRAW_SEGMENT_EVENT_PARAMS::quitOnDraw, TOOL_MANAGER::RunAction(), and startSegments().

Referenced by setTransitions().

◆ finishSegments()

void SCH_LINE_WIRE_BUS_TOOL::finishSegments ( )
private

Definition at line 920 of file sch_line_wire_bus_tool.cpp.

921 {
922  // Clear selection when done so that a new wire can be started.
923  // NOTE: this must be done before simplifyWireList is called or we might end up with
924  // freed selected items.
926 
927  SCH_SCREEN* screen = m_frame->GetScreen();
928  PICKED_ITEMS_LIST itemList;
929 
930  // Remove segments backtracking over others
932 
933  // Collect the possible connection points for the new lines
934  std::vector< wxPoint > connections = m_frame->GetSchematicConnections();
935  std::vector< wxPoint > new_ends;
936 
937  // Check each new segment for possible junctions and add/split if needed
938  for( SCH_LINE* wire : m_wires )
939  {
940  if( wire->HasFlag( SKIP_STRUCT ) )
941  continue;
942 
943  std::vector<wxPoint> tmpends = wire->GetConnectionPoints();
944 
945  new_ends.insert( new_ends.end(), tmpends.begin(), tmpends.end() );
946 
947  for( const wxPoint& pt : connections )
948  {
949  if( IsPointOnSegment( wire->GetStartPoint(), wire->GetEndPoint(), pt ) )
950  new_ends.push_back( pt );
951  }
952  itemList.PushItem( ITEM_PICKER( screen, wire, UNDO_REDO::NEWITEM ) );
953  }
954 
956  {
957  wxASSERT( m_busUnfold.entry && m_busUnfold.label );
958 
959  itemList.PushItem( ITEM_PICKER( screen, m_busUnfold.entry, UNDO_REDO::NEWITEM ) );
960  itemList.PushItem( ITEM_PICKER( screen, m_busUnfold.label, UNDO_REDO::NEWITEM ) );
962  }
963 
964  // Get the last non-null wire (this is the last created segment).
965  if( !m_wires.empty() )
967 
968  // Add the new wires
969  for( SCH_LINE* wire : m_wires )
970  {
971  wire->ClearFlags( IS_NEW | IS_MOVING );
972  m_frame->AddToScreen( wire, screen );
973  }
974 
975  m_wires.clear();
976  m_view->ClearPreview();
977  m_view->ShowPreview( false );
978 
979  getViewControls()->CaptureCursor( false );
980  getViewControls()->SetAutoPan( false );
981 
982  m_frame->SaveCopyInUndoList( itemList, UNDO_REDO::NEWITEM, false );
983 
984  // Correct and remove segments that need to be merged.
986 
987  std::vector<SCH_ITEM*> symbols;
988 
989  for( SCH_ITEM* symbol : m_frame->GetScreen()->Items().OfType( SCH_SYMBOL_T ) )
990  symbols.push_back( symbol );
991 
992  for( SCH_ITEM* symbol : symbols )
993  {
994  std::vector<wxPoint> pts = symbol->GetConnectionPoints();
995 
996  if( pts.size() > 2 )
997  continue;
998 
999  for( auto pt = pts.begin(); pt != pts.end(); pt++ )
1000  {
1001  for( auto secondPt = pt + 1; secondPt != pts.end(); secondPt++ )
1002  m_frame->TrimWire( *pt, *secondPt );
1003  }
1004  }
1005 
1006  for( const wxPoint& pt : new_ends )
1007  {
1009  m_frame->AddJunction( m_frame->GetScreen(), pt, true, false );
1010  }
1011 
1012  if( m_busUnfold.in_progress )
1013  m_busUnfold = {};
1014 
1017 
1018  m_frame->OnModify();
1019 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:230
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
void simplifyWireList()
Iterate over the wire list and removes the null segments and overlapping segments to create a simplif...
#define IS_NEW
New item, just created.
std::vector< SCH_LINE * > m_wires
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
Definition: trigo.cpp:42
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:205
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const wxPoint &aPos, bool aAppendToUndo, bool aFinal=true)
void ShowPreview(bool aShow=true)
Definition: view.cpp:1628
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
#define IS_MOVING
Item being moved.
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
void ClearPreview()
Definition: view.cpp:1592
std::vector< wxPoint > GetSchematicConnections()
Collect a unique list of all possible connection points in the schematic.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
A holder to handle information on schematic or board items.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
SCH_BUS_WIRE_ENTRY * entry
bool IsExplicitJunctionNeeded(const wxPoint &aPosition) const
Indicates that a junction dot is necessary at the given location, and does not yet exist.
Definition: sch_screen.cpp:423
#define SKIP_STRUCT
flag indicating that the structure should be ignored
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
bool TrimWire(const wxPoint &aStart, const wxPoint &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
bool label_placed
True if user has placed the net label.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
void ClearEditFlags()
Definition: eda_item.h:171
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
bool in_progress
True if bus unfold operation is running.

References SCH_EDIT_FRAME::AddJunction(), SCH_BASE_FRAME::AddToScreen(), KIGFX::VIEW_CONTROLS::CaptureCursor(), EDA_ITEM::ClearEditFlags(), KIGFX::VIEW::ClearPreview(), EE_ACTIONS::clearSelection, BUS_UNFOLDING_T::entry, SCH_EDIT_FRAME::GetSchematicConnections(), SCH_EDIT_FRAME::GetScreen(), TOOL_BASE::getViewControls(), BUS_UNFOLDING_T::in_progress, IS_MOVING, IS_NEW, SCH_SCREEN::IsExplicitJunctionNeeded(), IsPointOnSegment(), SCH_SCREEN::Items(), BUS_UNFOLDING_T::label, BUS_UNFOLDING_T::label_placed, m_busUnfold, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view, m_wires, NEWITEM, EE_RTREE::OfType(), SCH_EDIT_FRAME::OnModify(), TOOL_MANAGER::PostEvent(), PICKED_ITEMS_LIST::PushItem(), TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_SYMBOL_T, SCH_EDIT_FRAME::SchematicCleanUp(), EVENTS::SelectedItemsModified, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW::ShowPreview(), simplifyWireList(), SKIP_STRUCT, SCH_EDIT_FRAME::TestDanglingEnds(), and SCH_EDIT_FRAME::TrimWire().

Referenced by doDrawSegments().

◆ getEditFrame()

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

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

Definition at line 184 of file tool_base.h.

185  {
186 #if !defined( QA_TEST ) // Dynamic casts give the linker a seizure in the test framework
187  wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
188 #endif
189  return static_cast<T*>( getToolHolderInt() );
190  }
TOOLS_HOLDER * getToolHolderInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 120 of file tool_base.h.

121  {
122  return m_toolId;
123  }
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209

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(), TOOL_MANAGER::saveViewControls(), and TOOL_MANAGER::ShutdownTool().

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Return the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER or NULL if there is no associated tool manager.

Definition at line 143 of file tool_base.h.

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

References TOOL_BASE::m_toolMgr.

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

◆ getModel()

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

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 196 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Return 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
Definition: tool_base.h:213

References TOOL_BASE::m_toolName.

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

◆ getSheetPin()

const SCH_SHEET_PIN * SCH_LINE_WIRE_BUS_TOOL::getSheetPin ( const wxPoint &  aPosition)
private

Search for a sheet pin at a location.

Parameters
aPositiongrid point to search for existing sheet pin
Returns
Pointer to sheet pin or nullptr on failure

Definition at line 403 of file sch_line_wire_bus_tool.cpp.

404 {
405  SCH_SCREEN* screen = m_frame->GetScreen();
406 
407  for( SCH_ITEM* item : screen->Items().Overlapping( SCH_SHEET_T, aPosition ) )
408  {
409  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
410 
411  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
412  {
413  if( pin->GetPosition() == aPosition )
414  return pin;
415  }
416  }
417 
418  return nullptr;
419 }
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
EE_TYPE Overlapping(const EDA_RECT &aRect) const
Definition: sch_rtree.h:235
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:183
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182

References SCH_SHEET::GetPins(), SCH_EDIT_FRAME::GetScreen(), SCH_SCREEN::Items(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_RTREE::Overlapping(), pin, and SCH_SHEET_T.

Referenced by computeBreakPoint().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 108 of file tool_base.h.

109  {
110  return m_type;
111  }
TOOL_TYPE m_type
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:206

References TOOL_BASE::m_type.

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

◆ getView()

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

Returns the instance of #VIEW object used in the application.

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), GERBVIEW_CONTROL::ClearAllLayers(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::CollectHits(), computeBreakPoint(), COMMON_TOOLS::CursorControl(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), ROUTER_TOOL::handleCommonEvents(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), PL_EDIT_TOOL::moveItem(), SCH_MOVE_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), BOARD_EDITOR_CONTROL::PlaceTarget(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), BOARD_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), PCB_SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectAll(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), PCB_SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), PCB_SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL().

◆ getViewControls()

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

Return the instance of VIEW_CONTROLS object used in the application.

It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.).

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), SCH_DRAWING_TOOLS::createSheetPin(), COMMON_TOOLS::CursorControl(), doDrawSegments(), EDIT_TOOL::doMoveSelection(), doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), finishSegments(), SCH_DRAWING_TOOLS::GetCanvasFreeAreaPixels(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), PCB_POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), PCB_SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PCB_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), PL_POINT_EDITOR::setEditedPoint(), EE_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_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

Define which state (aStateFunc) to go when a certain event arrives (aConditions).

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

149 {
150  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
151 
152  goInternal( sptr, aConditions );
153 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by AUTOPLACE_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), PCB_PICKER_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), ROUTER_TOOL::setTransitions(), SCRIPTING_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), CONVERT_TOOL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), PAD_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), SCH_EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), DRC_TOOL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), setTransitions(), CVPCB_CONTROL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ Init()

bool SCH_LINE_WIRE_BUS_TOOL::Init ( )
overridevirtual

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 180 of file sch_line_wire_bus_tool.cpp.

181 {
183 
184  auto wireOrBusTool =
185  [this]( const SELECTION& aSel )
186  {
189  };
190 
191  auto lineTool =
192  [this]( const SELECTION& aSel )
193  {
195  };
196 
197  auto belowRootSheetCondition =
198  [&]( const SELECTION& aSel )
199  {
200  return m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root();
201  };
202 
203  auto busSelection = EE_CONDITIONS::MoreThan( 0 )
205 
206  auto& ctxMenu = m_menu.GetMenu();
207 
208  // Build the tool menu
209  //
210  ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
211 
212  ctxMenu.AddSeparator( 10 );
213  ctxMenu.AddItem( EE_ACTIONS::drawWire, wireOrBusTool && EE_CONDITIONS::Idle, 10 );
214  ctxMenu.AddItem( EE_ACTIONS::drawBus, wireOrBusTool && EE_CONDITIONS::Idle, 10 );
215  ctxMenu.AddItem( EE_ACTIONS::drawLines, lineTool && EE_CONDITIONS::Idle, 10 );
216  ctxMenu.AddItem( EE_ACTIONS::finishWire, IsDrawingWire, 10 );
217  ctxMenu.AddItem( EE_ACTIONS::finishBus, IsDrawingBus, 10 );
218  ctxMenu.AddItem( EE_ACTIONS::finishLine, IsDrawingLine, 10 );
219 
220  std::shared_ptr<BUS_UNFOLD_MENU> busUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>();
221  busUnfoldMenu->SetTool( this );
222  m_menu.AddSubMenu( busUnfoldMenu );
223  ctxMenu.AddMenu( busUnfoldMenu.get(), EE_CONDITIONS::Idle, 10 );
224 
225  ctxMenu.AddSeparator( 100 );
226  ctxMenu.AddItem( EE_ACTIONS::placeJunction, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
227  ctxMenu.AddItem( EE_ACTIONS::placeLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
228  ctxMenu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
229  ctxMenu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
230  ctxMenu.AddItem( EE_ACTIONS::breakWire, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
231  ctxMenu.AddItem( EE_ACTIONS::breakBus, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
232 
233  ctxMenu.AddSeparator( 200 );
234  ctxMenu.AddItem( EE_ACTIONS::selectNode, wireOrBusTool && EE_CONDITIONS::Idle, 200 );
235  ctxMenu.AddItem( EE_ACTIONS::selectConnection, wireOrBusTool && EE_CONDITIONS::Idle, 200 );
236 
237  // Add bus unfolding to the selection tool
238  //
240 
241  std::shared_ptr<BUS_UNFOLD_MENU> selBusUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>();
242  selBusUnfoldMenu->SetTool( m_selectionTool );
243  m_selectionTool->GetToolMenu().AddSubMenu( selBusUnfoldMenu );
244  selToolMenu.AddMenu( selBusUnfoldMenu.get(), busSelection && EE_CONDITIONS::Idle, 100 );
245 
246  return true;
247 }
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Add a submenu to the menu.
bool IsCurrentTool(const TOOL_ACTION &aAction) const
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
static bool IsDrawingWire(const SELECTION &aSelection)
static TOOL_ACTION breakBus
Definition: ee_actions.h:135
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:88
static TOOL_ACTION placeJunction
Definition: ee_actions.h:84
static TOOL_ACTION selectConnection
If current selection is a wire or bus, expand to entire connection.
Definition: ee_actions.h:53
TOOL_MENU & GetToolMenu()
static bool IsDrawingLine(const SELECTION &aSelection)
static TOOL_ACTION breakWire
Definition: ee_actions.h:134
static TOOL_ACTION finishLine
Definition: ee_actions.h:97
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:186
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:66
static TOOL_ACTION drawWire
Definition: ee_actions.h:80
SCHEMATIC & Schematic() const
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
static bool IsDrawingBus(const SELECTION &aSelection)
static TOOL_ACTION drawBus
Definition: ee_actions.h:81
static TOOL_ACTION placeLabel
Definition: ee_actions.h:86
SCH_SHEET & Root() const
Definition: schematic.h:92
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:52
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
static TOOL_ACTION selectNode
Select the junction, wire or bus segment under the cursor.
Definition: ee_actions.h:49
SCH_SHEET_PATH & GetCurrentSheet() const
static TOOL_ACTION drawLines
Definition: ee_actions.h:92
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:87
static TOOL_ACTION finishBus
Definition: ee_actions.h:96
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
static TOOL_ACTION finishWire
Definition: ee_actions.h:95

References CONDITIONAL_MENU::AddItem(), CONDITIONAL_MENU::AddMenu(), TOOL_MENU::AddSubMenu(), EE_ACTIONS::breakBus, EE_ACTIONS::breakWire, EE_ACTIONS::drawBus, EE_ACTIONS::drawLines, EE_ACTIONS::drawWire, EE_ACTIONS::finishBus, EE_ACTIONS::finishLine, EE_ACTIONS::finishWire, SCH_EDIT_FRAME::GetCurrentSheet(), TOOL_MENU::GetMenu(), TOOL_INTERACTIVE::GetToolMenu(), SELECTION_CONDITIONS::Idle(), EE_TOOL_BASE< T >::Init(), TOOLS_HOLDER::IsCurrentTool(), IsDrawingBus(), IsDrawingLine(), IsDrawingWire(), SCH_SHEET_PATH::Last(), EE_ACTIONS::leaveSheet, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_INTERACTIVE::m_menu, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, SELECTION_CONDITIONS::MoreThan(), SELECTION_CONDITIONS::OnlyType(), EE_ACTIONS::placeGlobalLabel, EE_ACTIONS::placeHierLabel, EE_ACTIONS::placeJunction, EE_ACTIONS::placeLabel, SCHEMATIC::Root(), SCH_LINE_LOCATE_BUS_T, SCH_EDIT_FRAME::Schematic(), EE_ACTIONS::selectConnection, and EE_ACTIONS::selectNode.

◆ IsDrawingBus()

bool SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus ( const SELECTION aSelection)
static

Definition at line 264 of file sch_line_wire_bus_tool.cpp.

265 {
266  static KICAD_T busType[] = { SCH_LINE_LOCATE_BUS_T, EOT };
267  return IsDrawingLineWireOrBus( aSelection ) && aSelection.Front()->IsType( busType );
268 }
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:182
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
EDA_ITEM * Front() const
Definition: selection.h:145

References EOT, SELECTION::Front(), IsDrawingLineWireOrBus(), EDA_ITEM::IsType(), and SCH_LINE_LOCATE_BUS_T.

Referenced by EE_SELECTION_TOOL::Init(), and Init().

◆ IsDrawingLine()

bool SCH_LINE_WIRE_BUS_TOOL::IsDrawingLine ( const SELECTION aSelection)
static

Definition at line 250 of file sch_line_wire_bus_tool.cpp.

251 {
252  static KICAD_T graphicLineType[] = { SCH_LINE_LOCATE_GRAPHIC_LINE_T, EOT };
253  return IsDrawingLineWireOrBus( aSelection ) && aSelection.Front()->IsType( graphicLineType );
254 }
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:182
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
EDA_ITEM * Front() const
Definition: selection.h:145

References EOT, SELECTION::Front(), IsDrawingLineWireOrBus(), EDA_ITEM::IsType(), and SCH_LINE_LOCATE_GRAPHIC_LINE_T.

Referenced by Init().

◆ IsDrawingLineWireOrBus()

bool SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus ( const SELECTION aSelection)
static

Definition at line 271 of file sch_line_wire_bus_tool.cpp.

272 {
273  // NOTE: for immediate hotkeys, it is NOT required that the line, wire or bus tool
274  // be selected
275  SCH_ITEM* item = (SCH_ITEM*) aSelection.Front();
276  return item && item->IsNew() && item->Type() == SCH_LINE_T;
277 }
bool IsNew() const
Definition: eda_item.h:118
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
EDA_ITEM * Front() const
Definition: selection.h:145
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References SELECTION::Front(), EDA_ITEM::IsNew(), SCH_LINE_T, and EDA_ITEM::Type().

Referenced by SCH_EDIT_TOOL::Init(), SCH_MOVE_TOOL::Init(), IsDrawingBus(), IsDrawingLine(), and IsDrawingWire().

◆ IsDrawingWire()

bool SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire ( const SELECTION aSelection)
static

Definition at line 257 of file sch_line_wire_bus_tool.cpp.

258 {
259  static KICAD_T wireType[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
260  return IsDrawingLineWireOrBus( aSelection ) && aSelection.Front()->IsType( wireType );
261 }
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:182
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
EDA_ITEM * Front() const
Definition: selection.h:145

References EOT, SELECTION::Front(), IsDrawingLineWireOrBus(), EDA_ITEM::IsType(), and SCH_LINE_LOCATE_WIRE_T.

Referenced by EE_SELECTION_TOOL::Init(), and Init().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32 {
33  return m_toolMgr->IsToolActive( m_toolId );
34 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool IsToolActive(TOOL_ID aId) const
Return true if a tool with given id is active (executing)

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

Referenced by EDIT_TOOL::Drag(), ROUTER_TOOL::handleLayerSwitch(), EDIT_TOOL::isRouterActive(), PCB_SELECTION_TOOL::Main(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ Reset()

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

Bring 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 86 of file ee_tool_base.h.

87  {
88  if( aReason == MODEL_RELOAD )
89  {
90  // Init variables used by every drawing tool
91  m_frame = getEditFrame<T>();
92  m_isSymbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame ) != nullptr;
93  }
94 
95  m_view = static_cast<KIGFX::SCH_VIEW*>( getView() );
96  }
Model changes (required full reload)
Definition: tool_base.h:80
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36

◆ RunMainStack()

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

Call a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

88 {
89  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
90 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
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  aType,
bool  aAppend = false 
)
inlineprotectedinherited

Definition at line 134 of file ee_tool_base.h.

135  {
136  wxASSERT( aItem );
137 
138  KICAD_T itemType = aItem->Type();
139  bool selected = aItem->IsSelected();
140 
141  // IS_SELECTED flag should not be set on undo items which were added for
142  // a drag operation.
143  if( selected && aItem->HasFlag( TEMP_SELECTED ) )
144  aItem->ClearSelected();
145 
146  if( m_isSymbolEditor )
147  {
148  SYMBOL_EDIT_FRAME* editFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
149  wxASSERT( editFrame );
150 
151  editFrame->SaveCopyInUndoList( static_cast<LIB_ITEM*>( aItem ), aType, aAppend );
152  }
153  else
154  {
155  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
156  wxASSERT( editFrame );
157 
158  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
159  {
160  editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
161  static_cast<SCH_ITEM*>( aItem->GetParent() ),
162  UNDO_REDO::CHANGED, aAppend );
163  }
164  else
165  {
166  editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
167  static_cast<SCH_ITEM*>( aItem ),
168  aType, aAppend );
169  }
170  }
171 
172  if( selected && aItem->HasFlag( TEMP_SELECTED ) )
173  aItem->SetSelected();
174  }
bool IsSelected() const
Definition: eda_item.h:122
void ClearSelected()
Definition: eda_item.h:131
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:155
Schematic editor (Eeschema) main window.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetSelected()
Definition: eda_item.h:128
void SaveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT, bool aAppend=false)
Create a copy of the current symbol, and save it in the undo list.
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
#define TEMP_SELECTED
flag indicating that the structure has already selected
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
The symbol library editor main window.

◆ SetContextMenu()

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

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

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

Definition at line 76 of file tool_interactive.cpp.

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

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and UnfoldBus().

◆ setTransitions()

void SCH_LINE_WIRE_BUS_TOOL::setTransitions ( )
overrideprivatevirtual

This method is meant to be overridden in order to specify handlers for events.

It is called every time tool is reset or finished.

Implements TOOL_INTERACTIVE.

Definition at line 1122 of file sch_line_wire_bus_tool.cpp.

1123 {
1129 
1131 }
int AddJunctionsIfNeeded(const TOOL_EVENT &aEvent)
Handle the addition of junctions to a selection of objects.
static TOOL_ACTION unfoldBus
Definition: ee_actions.h:82
int UnfoldBus(const TOOL_EVENT &aEvent)
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
static TOOL_ACTION trimOverlappingWires
Definition: ee_actions.h:76
static TOOL_ACTION drawWire
Definition: ee_actions.h:80
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:75
static TOOL_ACTION drawBus
Definition: ee_actions.h:81
int TrimOverLappingWires(const TOOL_EVENT &aEvent)
Logic to remove wires when overlapping correct items.
static TOOL_ACTION drawLines
Definition: ee_actions.h:92
int DrawSegments(const TOOL_EVENT &aEvent)

References AddJunctionsIfNeeded(), EE_ACTIONS::addNeededJunctions, EE_ACTIONS::drawBus, EE_ACTIONS::drawLines, DrawSegments(), EE_ACTIONS::drawWire, TOOL_INTERACTIVE::Go(), EE_ACTIONS::trimOverlappingWires, TrimOverLappingWires(), EE_ACTIONS::unfoldBus, and UnfoldBus().

◆ simplifyWireList()

void SCH_LINE_WIRE_BUS_TOOL::simplifyWireList ( )
private

Iterate over the wire list and removes the null segments and overlapping segments to create a simplified wire list.

In a contiguous list of wires, remove wires that backtrack over the previous wire.

Set up handlers for various events.

Example:

Wire is added: -------------------------------------—>

A second wire backtracks over it: ----------------—<====================>

simplifyWireList is called: ----------------—>

Definition at line 886 of file sch_line_wire_bus_tool.cpp.

887 {
888  for( auto it = m_wires.begin(); it != m_wires.end(); )
889  {
890  SCH_LINE* line = *it;
891 
892  if( line->IsNull() )
893  {
894  delete line;
895  it = m_wires.erase( it );
896  continue;
897  }
898 
899  auto next_it = it;
900  ++next_it;
901 
902  if( next_it == m_wires.end() )
903  break;
904 
905  SCH_LINE* next_line = *next_it;
906 
907  if( SCH_LINE* merged = line->MergeOverlap( m_frame->GetScreen(), next_line, false ) )
908  {
909  delete line;
910  delete next_line;
911  it = m_wires.erase( it );
912  *it = merged;
913  }
914 
915  ++it;
916  }
917 }
SCH_LINE * MergeOverlap(SCH_SCREEN *aScreen, SCH_LINE *aLine, bool aCheckJunctions)
Check line against aLine to see if it overlaps and merge if it does.
Definition: sch_line.cpp:511
std::vector< SCH_LINE * > m_wires
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool IsNull() const
Definition: sch_line.h:88
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37

References SCH_EDIT_FRAME::GetScreen(), SCH_LINE::IsNull(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_wires, and SCH_LINE::MergeOverlap().

Referenced by finishSegments().

◆ startSegments()

SCH_LINE * SCH_LINE_WIRE_BUS_TOOL::startSegments ( int  aType,
const VECTOR2D aPos 
)
private

Definition at line 840 of file sch_line_wire_bus_tool.cpp.

841 {
842  SCH_LINE* segment = nullptr;
843 
844  switch ( aType )
845  {
846  default: segment = new SCH_LINE( aPos, LAYER_NOTES ); break;
847  case LAYER_WIRE: segment = new SCH_LINE( aPos, LAYER_WIRE ); break;
848  case LAYER_BUS: segment = new SCH_LINE( aPos, LAYER_BUS ); break;
849  }
850 
851  // Give segments a parent so they find the default line/wire/bus widths
852  segment->SetParent( &m_frame->Schematic() );
853  segment->SetFlags( IS_NEW | IS_MOVING );
854  m_wires.push_back( segment );
855 
856  m_selectionTool->AddItemToSel( segment, true /*quiet mode*/ );
857 
858  // We need 2 segments to go from a given start pin to an end point when the
859  // horizontal and vertical lines only switch is on.
861  {
862  segment = static_cast<SCH_LINE*>( segment->Duplicate() );
863  segment->SetFlags( IS_NEW | IS_MOVING );
864  m_wires.push_back( segment );
865 
866  m_selectionTool->AddItemToSel( segment, true /*quiet mode*/ );
867  }
868 
869  return segment;
870 }
#define IS_NEW
New item, just created.
std::vector< SCH_LINE * > m_wires
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:115
EESCHEMA_SETTINGS * eeconfig() const
#define IS_MOVING
Item being moved.
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:85
SCHEMATIC & Schematic() const
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
int AddItemToSel(const TOOL_EVENT &aEvent)
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37

References EE_SELECTION_TOOL::AddItemToSel(), SCH_ITEM::Duplicate(), SCH_BASE_FRAME::eeconfig(), EESCHEMA_SETTINGS::DRAWING::hv_lines_only, IS_MOVING, IS_NEW, LAYER_BUS, LAYER_NOTES, LAYER_WIRE, EESCHEMA_SETTINGS::m_Drawing, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, m_wires, SCH_EDIT_FRAME::Schematic(), EDA_ITEM::SetFlags(), and EDA_ITEM::SetParent().

Referenced by doDrawSegments(), doUnfoldBus(), and DrawSegments().

◆ TrimOverLappingWires()

int SCH_LINE_WIRE_BUS_TOOL::TrimOverLappingWires ( const TOOL_EVENT aEvent)

Logic to remove wires when overlapping correct items.

If the line intersects with an item in the selection at only two points, then we can remove the line between the two points.

Definition at line 1022 of file sch_line_wire_bus_tool.cpp.

1023 {
1024  EE_SELECTION* aSelection = aEvent.Parameter<EE_SELECTION*>();
1025  SCHEMATIC* sch = getModel<SCHEMATIC>();
1026  SCH_SCREEN* screen = sch->CurrentSheet().LastScreen();
1027 
1028  std::set<SCH_LINE*> lines;
1029  EDA_RECT bb = aSelection->GetBoundingBox();
1030 
1031  for( EDA_ITEM* item : screen->Items().Overlapping( SCH_LINE_T, bb ) )
1032  lines.insert( static_cast<SCH_LINE*>( item ) );
1033 
1034  for( unsigned ii = 0; ii < aSelection->GetSize(); ii++ )
1035  {
1036  SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aSelection->GetItem( ii ) );
1037  std::vector<wxPoint> pts = item->GetConnectionPoints();
1038 
1039  if( !item || !item->IsConnectable() || ( item->Type() == SCH_LINE_T ) )
1040  continue;
1041 
1044  for( SCH_LINE* line : lines )
1045  {
1046  std::vector<wxPoint> conn_pts;
1047 
1048  for( wxPoint pt : pts )
1049  {
1050  if( IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), pt ) )
1051  conn_pts.push_back( pt );
1052 
1053  if( conn_pts.size() > 2 )
1054  break;
1055  }
1056 
1057  if( conn_pts.size() == 2 )
1058  m_frame->TrimWire( conn_pts[0], conn_pts[1] );
1059  }
1060  }
1061 
1062  return 0;
1063 }
virtual bool IsConnectable() const
Definition: sch_item.h:349
virtual std::vector< wxPoint > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:364
Holds all the data relating to one schematic.
Definition: schematic.h:59
EDA_RECT GetBoundingBox() const override
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
Definition: trigo.cpp:42
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
EE_TYPE Overlapping(const EDA_RECT &aRect) const
Definition: sch_rtree.h:235
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:88
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:53
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
Handle the component boundary box.
Definition: eda_rect.h:42
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
bool TrimWire(const wxPoint &aStart, const wxPoint &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References EE_SELECTION::GetBoundingBox(), SCH_ITEM::GetConnectionPoints(), SELECTION::GetItem(), SELECTION::GetSize(), SCH_ITEM::IsConnectable(), IsPointOnSegment(), SCH_SCREEN::Items(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_RTREE::Overlapping(), TOOL_EVENT::Parameter(), SCH_LINE_T, SCH_EDIT_FRAME::TrimWire(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ UnfoldBus()

int SCH_LINE_WIRE_BUS_TOOL::UnfoldBus ( const TOOL_EVENT aEvent)

Definition at line 307 of file sch_line_wire_bus_tool.cpp.

308 {
309  if( m_inDrawingTool )
310  return 0;
311 
313 
314  wxString* netPtr = aEvent.Parameter<wxString*>();
315  wxString net;
316  SCH_LINE* segment = nullptr;
317 
318  std::string tool = aEvent.GetCommandStr().get();
319  m_frame->PushTool( tool );
320  Activate();
321 
322  if( netPtr )
323  {
324  net = *netPtr;
325  delete netPtr;
326  }
327  else
328  {
329  BUS_UNFOLD_MENU unfoldMenu;
330  unfoldMenu.SetTool( this );
331  unfoldMenu.SetShowTitle();
332 
333  SetContextMenu( &unfoldMenu, CMENU_NOW );
334 
335  while( TOOL_EVENT* evt = Wait() )
336  {
337  if( evt->Action() == TA_CHOICE_MENU_CHOICE )
338  {
339  OPT<int> id = evt->GetCommandId();
340 
341  if( id && ( *id > 0 ) )
342  net = *evt->Parameter<wxString*>();
343 
344  break;
345  }
346  else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
347  {
348  break;
349  }
350  else
351  {
352  evt->SetPassEvent();
353  }
354  }
355  }
356 
357  // Break a wire for the given net out of the bus
358  if( !net.IsEmpty() )
359  segment = doUnfoldBus( net );
360 
361  // If we have an unfolded wire to draw, then draw it
362  if( segment )
363  return doDrawSegments( tool, LAYER_WIRE, false );
364  else
365  {
366  m_frame->PopTool( tool );
367  return 0;
368  }
369 }
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Assign a context menu and tells when it should be activated.
void SetTool(TOOL_INTERACTIVE *aTool)
Set a tool that is the creator of the menu.
virtual void PopTool(const std::string &actionName)
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
Generic, UI-independent tool event.
Definition: tool_event.h:152
int doDrawSegments(const std::string &aTool, int aType, bool aQuitOnDraw)
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
boost::optional< T > OPT
Definition: optional.h:7
void Activate()
Run the tool.
SCH_LINE * doUnfoldBus(const wxString &aNet, const wxPoint &aPos=wxDefaultPosition)

References TOOL_INTERACTIVE::Activate(), CMENU_NOW, doDrawSegments(), doUnfoldBus(), TOOL_EVENT::GetCommandStr(), LAYER_WIRE, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_inDrawingTool, TOOL_EVENT::Parameter(), TOOLS_HOLDER::PopTool(), TOOLS_HOLDER::PushTool(), TOOL_INTERACTIVE::SetContextMenu(), BUS_UNFOLD_MENU::SetShowTitle(), ACTION_MENU::SetTool(), TA_CHOICE_MENU_CHOICE, TA_CHOICE_MENU_CLOSED, and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ updateItem()

void EE_TOOL_BASE< SCH_EDIT_FRAME >::updateItem ( EDA_ITEM aItem,
bool  aUpdateRTree 
) const
inlineprotectedinherited

Similar to getView()->Update(), but handles items that are redrawn by their parents and updating the SCH_SCREEN's RTree.

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

Definition at line 103 of file ee_tool_base.h.

◆ Wait()

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

Suspend execution of the tool until an event specified in aEventList arrives.

No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

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

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), ZOOM_TOOL::Main(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), CVPCB_CONTROL::Main(), PL_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and UnfoldBus().

Member Data Documentation

◆ m_busUnfold

BUS_UNFOLDING_T SCH_LINE_WIRE_BUS_TOOL::m_busUnfold
private

◆ m_frame

SCH_EDIT_FRAME * EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame
protectedinherited

Definition at line 177 of file ee_tool_base.h.

◆ m_inDrawingTool

bool SCH_LINE_WIRE_BUS_TOOL::m_inDrawingTool
private

Definition at line 136 of file sch_line_wire_bus_tool.h.

Referenced by DrawSegments(), and UnfoldBus().

◆ m_isSymbolEditor

bool EE_TOOL_BASE< SCH_EDIT_FRAME >::m_isSymbolEditor
protectedinherited

Definition at line 180 of file ee_tool_base.h.

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

The functions below are not yet implemented - their interface may change.

Definition at line 125 of file tool_interactive.h.

Referenced by doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), ROUTER_TOOL::Init(), LENGTH_TUNER_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), PL_DRAWING_TOOLS::Init(), SYMBOL_EDITOR_DRAWING_TOOLS::Init(), SYMBOL_EDITOR_CONTROL::Init(), PCB_VIEWER_TOOLS::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), PL_SELECTION_TOOL::Init(), SCH_DRAWING_TOOLS::Init(), BOARD_EDITOR_CONTROL::Init(), GERBVIEW_SELECTION_TOOL::Init(), EDA_3D_CONTROLLER::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), PCB_SELECTION_TOOL::Init(), Init(), PCB_TOOL_BASE::Init(), PICKER_TOOL::Init(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_PICKER_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PL_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_selectionTool

EE_SELECTION_TOOL* EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool
protectedinherited

Definition at line 179 of file ee_tool_base.h.

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Name of the tool.

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

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

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), PCB_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SCH_MOVE_TOOL::AlignElements(), SCH_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), SCH_EDIT_TOOL::BreakWire(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_CONTROL::ClearAllLayers(), BOARD_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), PL_SELECTION_TOOL::ClearSelection(), PCB_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), PL_EDIT_TOOL::Copy(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), MICROWAVE_TOOL::createInductorBetween(), DRC_TOOL::CrossProbe(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), SYMBOL_EDITOR_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), doDrawSegments(), BOARD_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::Drag(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), DrawSegments(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties(), SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), PCB_SELECTION_TOOL::filterSelection(), PCB_SELECTION_TOOL::FindItem(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), PCB_CONTROL::GridSetOrigin(), GROUP_TOOL::Group(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::HighlightItem(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PL_EDIT_TOOL::ImportDrawingSheetContent(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), BOARD_REANNOTATE_TOOL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), GROUP_TOOL::Init(), PAD_TOOL::Init(), CONVERT_TOOL::Init(), PL_DRAWING_TOOLS::Init(), SYMBOL_EDITOR_CONTROL::Init(), GLOBAL_EDIT_TOOL::Init(), PL_POINT_EDITOR::Init(), BOARD_INSPECTION_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PCB_POINT_EDITOR::Init(), BOARD_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isRouterActive(), TOOL_BASE::IsToolActive(), GROUP_TOOL::LeaveGroup(), SCH_NAVIGATE_TOOL::LeaveSheet(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), CVPCB_CONTROL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), SYMBOL_EDITOR_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), SYMBOL_EDITOR_CONTROL::OnDeMorgan(), PL_SELECTION_TOOL::onDisambiguationExpire(), EE_SELECTION_TOOL::onDisambiguationExpire(), PCB_SELECTION_TOOL::onDisambiguationExpire(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), PL_EDIT_TOOL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_EDIT_TOOL::PinTable(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_CONTROL::Print(), GERBVIEW_CONTROL::Print(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::recombinePad(), SYMBOL_EDITOR_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), PCB_SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), PCB_SELECTION_TOOL::RequestSelection(), PAD_TOOL::Reset(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), SYMBOL_EDITOR_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), EE_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), PCB_SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_SELECTION_TOOL::selectSameSheet(), PCB_SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), EDA_3D_CONTROLLER::SetMaterial(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), EDA_3D_CONTROLLER::ToggleVisibility(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GROUP_TOOL::Ungroup(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), PCB_SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCB_CONTROL::UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), EE_POINT_EDITOR::updateParentItem(), BOARD_INSPECTION_TOOL::UpdateSelectionRatsnest(), PNS::TOOL_BASE::updateStartItem(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), and BOARD_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Definition at line 213 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

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

Definition at line 206 of file tool_base.h.

Referenced by TOOL_BASE::GetType(), and BOARD_COMMIT::Push().

◆ m_view

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

Definition at line 178 of file ee_tool_base.h.

◆ m_wires

std::vector<SCH_LINE*> SCH_LINE_WIRE_BUS_TOOL::m_wires
private

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