KiCad PCB EDA Suite
POINT_EDITOR Class Reference

POINT_EDITOR. More...

#include <point_editor.h>

Inheritance diagram for POINT_EDITOR:
PCB_TOOL_BASE TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 POINT_EDITOR ()
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
int OnSelectionChange (const TOOL_EVENT &aEvent)
 Function OnSelected() More...
 
bool HasPoint ()
 Indicates the cursor is over an edit point. More...
 
void setTransitions () override
 

Sets up handlers for various events.

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

Protected Types

enum  INTERACTIVE_PLACEMENT_OPTIONS { IPO_ROTATE = 0x01, IPO_FLIP = 0x02, IPO_SINGLE_CLICK = 0x04, IPO_REPEAT = 0x08 }
 Options for placing items interactively. More...
 

Protected Member Functions

void doInteractiveItemPlacement (const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_BASE_EDIT_FRAMEframe () const
 
BOARDboard () const
 
FOOTPRINTfootprint () const
 
const PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const PCBNEW_SELECTIONselection () const
 
PCBNEW_SELECTIONselection ()
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

bool m_isFootprintEditor
 
TOOL_MENU m_menu
 functions below are not yet implemented - their interface may change More...
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 

Private Member Functions

void updateItem () const
 

Updates item's points with edit points.

More...
 
void finishItem ()
 

Applies the last changes to the edited item.

More...
 
bool validatePolygon (SHAPE_POLY_SET &aModified) const
 Validates a polygon and displays a popup warning if invalid. More...
 
void updatePoints ()
 

Updates edit points with item's points.

More...
 
void updateEditedPoint (const TOOL_EVENT &aEvent)
 

Updates which point is being edited.

More...
 
void setEditedPoint (EDIT_POINT *aPoint)
 

Sets the current point being edited. NULL means none.

More...
 
int getEditedPointIndex () const
 
bool isModified (const EDIT_POINT &aPoint) const
 

Returns true if aPoint is the currently modified point.

More...
 
void setAltConstraint (bool aEnabled)
 

Sets up an alternative constraint (typically enabled upon a modifier key being pressed).

More...
 
EDIT_POINT get45DegConstrainer () const
 

Returns a point that should be used as a constrainer for 45 degrees mode.

More...
 
bool removeCornerCondition (const SELECTION &aSelection)
 

Condition to display "Remove corner" context menu entry.

More...
 
int addCorner (const TOOL_EVENT &aEvent)
 TOOL_ACTION handlers. More...
 
int removeCorner (const TOOL_EVENT &aEvent)
 
int modifiedSelection (const TOOL_EVENT &aEvent)
 
void editArcEndpointKeepTangent (PCB_SHAPE *aArc, VECTOR2I aCenter, VECTOR2I aStart, VECTOR2I aMid, VECTOR2I aEnd, const VECTOR2I aCursor) const
 Move an end point of the arc, while keeping the tangent at the other endpoint. More...
 
void editArcEndpointKeepCenter (PCB_SHAPE *aArc, VECTOR2I aCenter, VECTOR2I aStart, VECTOR2I aMid, VECTOR2I aEnd, const VECTOR2I aCursor) const
 Move an end point of the arc, while keeping radius, and the other point position. More...
 
void editArcMidKeepEnpoints (PCB_SHAPE *aArc, VECTOR2I aCenter, VECTOR2I aStart, VECTOR2I aMid, VECTOR2I aEnd, const VECTOR2I aCursor) const
 Move the mid point of the arc, while keeping the two endpoints. More...
 
void editArcMidKeepCenter (PCB_SHAPE *aArc, VECTOR2I aCenter, VECTOR2I aStart, VECTOR2I aMid, VECTOR2I aEnd, const VECTOR2I aCursor) const
 Move the mid point of the arc, while keeping the angle. More...
 
int changeEditMethod (const TOOL_EVENT &aEvent)
 

Change the edit method to an alternative method ( currently, arcs only )

More...
 

Static Private Member Functions

static bool addCornerCondition (const SELECTION &aSelection)
 

Condition to display "Create corner" context menu entry.

More...
 
static bool canAddCorner (const EDA_ITEM &aItem)
 

Determine if the tool can currently add a corner to the given item

More...
 

Private Attributes

SELECTION_TOOLm_selectionTool
 

Selection tool used for obtaining selected items

More...
 
EDIT_POINTm_editedPoint
 

Currently edited point, NULL if there is none.

More...
 
EDIT_POINTm_hoveredPoint
 
EDIT_POINT m_original
 

Original position for the current drag point.

More...
 
std::shared_ptr< EDIT_POINTSm_editPoints
 

Currently available edit points.

More...
 
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
 
EDIT_POINT m_altConstrainer
 
bool m_refill
 
bool m_altEditMethod
 
std::unique_ptr< STATUS_TEXT_POPUPm_statusPopup
 

Detailed Description

POINT_EDITOR.

Tool that displays edit points allowing to modify items by dragging the points.

Definition at line 43 of file point_editor.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

Options for placing items interactively.

Enumerator
IPO_ROTATE 

Handle the rotate action in the loop by calling the item's rotate method.

IPO_FLIP 

Handle flip action in the loop by calling the item's flip method.

IPO_SINGLE_CLICK 

Create an item immediately on placement starting, otherwise show the pencil cursor until the item is created.

IPO_REPEAT 

Allow repeat placement of the item.

Definition at line 111 of file pcb_tool_base.h.

111  {
113  IPO_ROTATE = 0x01,
114 
116  IPO_FLIP = 0x02,
117 
120  IPO_SINGLE_CLICK = 0x04,
121 
123  IPO_REPEAT = 0x08
124  };
Handle flip action in the loop by calling the item's flip method.
Allow repeat placement of the item.
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
Handle the rotate action in the loop by calling the item's rotate method.

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 79 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ POINT_EDITOR()

POINT_EDITOR::POINT_EDITOR ( )

Definition at line 312 of file point_editor.cpp.

312  :
313  PCB_TOOL_BASE( "pcbnew.PointEditor" ),
314  m_selectionTool( nullptr ),
315  m_editedPoint( nullptr ),
316  m_hoveredPoint( nullptr ),
317  m_original( VECTOR2I( 0, 0 ) ),
318  m_altConstrainer( VECTOR2I( 0, 0 ) ),
319  m_refill( false ),
320  m_altEditMethod( false )
321 {
322 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
bool m_altEditMethod
Definition: point_editor.h:95
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: point_editor.h:72
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool_base.h:78
EDIT_POINT * m_hoveredPoint
Definition: point_editor.h:77
EDIT_POINT m_original
Original position for the current drag point.
Definition: point_editor.h:80
EDIT_POINT m_altConstrainer
Definition: point_editor.h:89
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 51 of file tool_interactive.cpp.

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

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

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

◆ addCorner()

int POINT_EDITOR::addCorner ( const TOOL_EVENT aEvent)
private

TOOL_ACTION handlers.

Definition at line 1931 of file point_editor.cpp.

1932 {
1933  if( !m_editPoints )
1934  return 0;
1935 
1936  EDA_ITEM* item = m_editPoints->GetParent();
1937  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1938  const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition();
1939 
1940  // called without an active edited polygon
1941  if( !item || !canAddCorner( *item ) )
1942  return 0;
1943 
1944  PCB_SHAPE* graphicItem = dynamic_cast<PCB_SHAPE*>( item );
1945  BOARD_COMMIT commit( frame );
1946 
1947  if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T
1948  || ( graphicItem && graphicItem->GetShape() == S_POLYGON ) )
1949  {
1950  unsigned int nearestIdx = 0;
1951  unsigned int nextNearestIdx = 0;
1952  unsigned int nearestDist = INT_MAX;
1953  unsigned int firstPointInContour = 0;
1954  SHAPE_POLY_SET* zoneOutline;
1955 
1956  if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
1957  {
1958  ZONE* zone = static_cast<ZONE*>( item );
1959  zoneOutline = zone->Outline();
1960  zone->SetNeedRefill( true );
1961  }
1962  else
1963  zoneOutline = &( graphicItem->GetPolyShape() );
1964 
1965  commit.Modify( item );
1966 
1967  // Search the best outline segment to add a new corner
1968  // and therefore break this segment into two segments
1969 
1970  // Object to iterate through the corners of the outlines (main contour and its holes)
1971  SHAPE_POLY_SET::ITERATOR iterator = zoneOutline->Iterate( 0,
1972  zoneOutline->OutlineCount()-1, /* IterateHoles */ true );
1973  int curr_idx = 0;
1974 
1975  // Iterate through all the corners of the outlines and search the best segment
1976  for( ; iterator; iterator++, curr_idx++ )
1977  {
1978  int jj = curr_idx+1;
1979 
1980  if( iterator.IsEndContour() )
1981  { // We reach the last point of the current contour (main or hole)
1982  jj = firstPointInContour;
1983  firstPointInContour = curr_idx+1; // Prepare next contour analysis
1984  }
1985 
1986  SEG curr_segment( zoneOutline->CVertex( curr_idx ), zoneOutline->CVertex( jj ) );
1987 
1988  unsigned int distance = curr_segment.Distance( cursorPos );
1989 
1990  if( distance < nearestDist )
1991  {
1992  nearestDist = distance;
1993  nearestIdx = curr_idx;
1994  nextNearestIdx = jj;
1995  }
1996  }
1997 
1998  // Find the point on the closest segment
1999  auto& sideOrigin = zoneOutline->CVertex( nearestIdx );
2000  auto& sideEnd = zoneOutline->CVertex( nextNearestIdx );
2001  SEG nearestSide( sideOrigin, sideEnd );
2002  VECTOR2I nearestPoint = nearestSide.NearestPoint( cursorPos );
2003 
2004  // Do not add points that have the same coordinates as ones that already belong to polygon
2005  // instead, add a point in the middle of the side
2006  if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
2007  nearestPoint = ( sideOrigin + sideEnd ) / 2;
2008 
2009  zoneOutline->InsertVertex( nextNearestIdx, nearestPoint );
2010 
2011  // We re-hatch the filled zones but not polygons
2012  if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
2013  static_cast<ZONE*>( item )->HatchBorder();
2014 
2015 
2016  commit.Push( _( "Add a zone corner" ) );
2017  }
2018 
2019  else if( graphicItem && graphicItem->GetShape() == S_SEGMENT )
2020  {
2021  commit.Modify( graphicItem );
2022 
2023  SEG seg( graphicItem->GetStart(), graphicItem->GetEnd() );
2024  VECTOR2I nearestPoint = seg.NearestPoint( cursorPos );
2025 
2026  // Move the end of the line to the break point..
2027  graphicItem->SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) );
2028 
2029  if( graphicItem->Type() == PCB_FP_SHAPE_T )
2030  static_cast<FP_SHAPE*>( graphicItem )->SetLocalCoord();
2031 
2032  // and add another one starting from the break point
2033  PCB_SHAPE* newSegment;
2034 
2035  if( item->Type() == PCB_FP_SHAPE_T )
2036  {
2037  FP_SHAPE* edge = static_cast<FP_SHAPE*>( graphicItem );
2038  assert( edge->GetParent()->Type() == PCB_FOOTPRINT_T );
2039  newSegment = new FP_SHAPE( *edge );
2040  }
2041  else
2042  {
2043  newSegment = new PCB_SHAPE( *graphicItem );
2044  }
2045 
2046  newSegment->ClearSelected();
2047  newSegment->SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
2048  newSegment->SetEnd( wxPoint( seg.B.x, seg.B.y ) );
2049 
2050  if( newSegment->Type() == PCB_FP_SHAPE_T )
2051  static_cast<FP_SHAPE*>( newSegment )->SetLocalCoord();
2052 
2053  commit.Add( newSegment );
2054  commit.Push( _( "Split segment" ) );
2055  }
2056 
2057  updatePoints();
2058  return 0;
2059 }
int OutlineCount() const
Returns the number of outlines in the set
bool IsEndContour() const
Function IsEndContour.
SHAPE_POLY_SET & GetPolyShape()
Definition: pcb_shape.h:259
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Definition: pcb_shape.h:155
void ClearSelected()
Definition: eda_item.h:199
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
SHAPE_POLY_SET * Outline()
Definition: zone.h:318
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Function Iterate returns an object to iterate through the points of the polygons between aFirst and a...
PCB_BASE_EDIT_FRAME * frame() const
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:83
SHAPE_POLY_SET.
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
Definition: pcb_shape.h:144
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
class ZONE, a copper pour area
Definition: typeinfo.h:106
class FOOTPRINT, a footprint
Definition: typeinfo.h:89
Definition: seg.h:39
Common, abstract interface for edit frames.
void SetStart(const wxPoint &aStart)
Definition: pcb_shape.h:147
#define _(s)
Definition: 3d_actions.cpp:33
class ZONE, managed by a footprint
Definition: typeinfo.h:95
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
static bool canAddCorner(const EDA_ITEM &aItem)
Determine if the tool can currently add a corner to the given item
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
void updatePoints()
Updates edit points with item's points.
void InsertVertex(int aGlobalIndex, VECTOR2I aNewVertex)
Function InsertVertex Adds a vertex in the globally indexed position aGlobalIndex.
void SetNeedRefill(bool aNeedRefill)
Definition: zone.h:236
PCB_SHAPE_TYPE_T GetShape() const
Definition: pcb_shape.h:129
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:179
void SetEnd(const wxPoint &aEnd)
Definition: pcb_shape.h:158
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References _, COMMIT::Add(), canAddCorner(), EDA_ITEM::ClearSelected(), SHAPE_POLY_SET::CVertex(), distance(), PCB_TOOL_BASE::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_SHAPE::GetEnd(), BOARD_ITEM::GetParent(), PCB_SHAPE::GetPolyShape(), PCB_SHAPE::GetShape(), PCB_SHAPE::GetStart(), TOOL_BASE::getViewControls(), SHAPE_POLY_SET::InsertVertex(), SHAPE_POLY_SET::ITERATOR_TEMPLATE< T >::IsEndContour(), SHAPE_POLY_SET::Iterate(), m_editPoints, COMMIT::Modify(), SEG::NearestPoint(), ZONE::Outline(), SHAPE_POLY_SET::OutlineCount(), PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_ZONE_T, PCB_ZONE_T, BOARD_COMMIT::Push(), S_POLYGON, S_SEGMENT, PCB_SHAPE::SetEnd(), ZONE::SetNeedRefill(), PCB_SHAPE::SetStart(), EDA_ITEM::Type(), and updatePoints().

Referenced by setTransitions().

◆ addCornerCondition()

bool POINT_EDITOR::addCornerCondition ( const SELECTION aSelection)
staticprivate

Condition to display "Create corner" context menu entry.

Definition at line 1860 of file point_editor.cpp.

1861 {
1862  if( aSelection.Size() != 1 )
1863  return false;
1864 
1865  const EDA_ITEM* item = aSelection.Front();
1866 
1867  return ( item != nullptr ) && canAddCorner( *item );
1868 }
static bool canAddCorner(const EDA_ITEM &aItem)
Determine if the tool can currently add a corner to the given item
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
EDA_ITEM * Front() const
Definition: selection.h:201

References canAddCorner(), SELECTION::Front(), and SELECTION::Size().

Referenced by Init().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

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

Definition at line 60 of file tool_base.cpp.

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

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 160 of file pcb_tool_base.h.

160 { return getModel<BOARD>(); }

Referenced by PCBNEW_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), EDIT_TOOL::ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), PCB_INSPECTION_TOOL::ClearHighlight(), EDIT_TOOL::copyToClipboard(), FOOTPRINT_EDITOR_TOOLS::CreateFootprint(), MICROWAVE_TOOL::createInductorBetween(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), SELECTION_TOOL::filterSelection(), PCB_TOOL_BASE::footprint(), SELECTION_TOOL::GetBoard(), SELECTION_TOOL::getCollectorsGuide(), GROUP_TOOL::Group(), PCB_INSPECTION_TOOL::highlightNet(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), EDIT_TOOL::MoveExact(), FOOTPRINT_EDITOR_TOOLS::NewFootprint(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::Paste(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), PAD_TOOL::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), SELECTION_TOOL::RebuildSelection(), PAD_TOOL::recombinePad(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::RepairBoard(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectConnectedTracks(), SELECTION_TOOL::selectPoint(), PCBNEW_CONTROL::TrackDisplayMode(), GROUP_TOOL::Ungroup(), PCBNEW_CONTROL::ViaDisplayMode(), PCBNEW_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ canAddCorner()

bool POINT_EDITOR::canAddCorner ( const EDA_ITEM aItem)
staticprivate

Determine if the tool can currently add a corner to the given item

Definition at line 1842 of file point_editor.cpp.

1843 {
1844  const auto type = aItem.Type();
1845 
1846  // Works only for zones and line segments
1847  if( type == PCB_ZONE_T || type == PCB_FP_ZONE_T )
1848  return true;
1849 
1850  if( type == PCB_SHAPE_T || type == PCB_FP_SHAPE_T )
1851  {
1852  const PCB_SHAPE& shape = static_cast<const PCB_SHAPE&>( aItem );
1853  return shape.GetShape() == S_SEGMENT || shape.GetShape() == S_POLYGON;
1854  }
1855 
1856  return false;
1857 }
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
class ZONE, a copper pour area
Definition: typeinfo.h:106
class ZONE, managed by a footprint
Definition: typeinfo.h:95
PCB_SHAPE_TYPE_T GetShape() const
Definition: pcb_shape.h:129
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:91
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References PCB_SHAPE::GetShape(), PCB_FP_SHAPE_T, PCB_FP_ZONE_T, PCB_SHAPE_T, PCB_ZONE_T, S_POLYGON, S_SEGMENT, and EDA_ITEM::Type().

Referenced by addCorner(), and addCornerCondition().

◆ canvas()

◆ changeEditMethod()

int POINT_EDITOR::changeEditMethod ( const TOOL_EVENT aEvent)
private

Change the edit method to an alternative method ( currently, arcs only )

Definition at line 2144 of file point_editor.cpp.

2145 {
2147  return 0;
2148 }
bool m_altEditMethod
Definition: point_editor.h:95

References m_altEditMethod.

Referenced by setTransitions().

◆ controls()

◆ displayOptions()

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

◆ doInteractiveItemPlacement()

void PCB_TOOL_BASE::doInteractiveItemPlacement ( const std::string &  aTool,
INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc.

More complex interactive processes are not supported here, you should implement a customised event loop for those.

Parameters
aItemCreatorthe callable that will attempt to create the item
aCommitMessagethe message used on a successful commit

Definition at line 36 of file pcb_tool_base.cpp.

39 {
40  using namespace std::placeholders;
41  std::unique_ptr<BOARD_ITEM> newItem;
42 
43  frame()->PushTool( aTool );
44  Activate();
45 
46  BOARD_COMMIT commit( frame() );
47 
49 
50  // do not capture or auto-pan until we start placing an item
51  controls()->ShowCursor( true );
52 
53  // Add a VIEW_GROUP that serves as a preview for the new item
54  PCBNEW_SELECTION preview;
55  view()->Add( &preview );
56 
57  aPlacer->m_board = board();
58  aPlacer->m_frame = frame();
59  aPlacer->m_modifiers = 0;
60 
61  auto makeNewItem =
62  [&]( VECTOR2I aPosition )
63  {
64  if( frame()->GetModel() )
65  newItem = aPlacer->CreateItem();
66 
67  if( newItem )
68  {
69  newItem->SetPosition( (wxPoint) aPosition );
70  preview.Add( newItem.get() );
71 
72  if( newItem->Type() == PCB_FOOTPRINT_T )
73  {
74  FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( newItem.get() );
75 
76  // footprints have more drawable parts
77  fp->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
78  }
79  }
80  };
81 
82  if( aOptions & IPO_SINGLE_CLICK )
83  makeNewItem( controls()->GetCursorPosition() );
84 
85  auto setCursor =
86  [&]()
87  {
88  if( !newItem )
90  else
92  };
93 
94  // Set initial cursor
95  setCursor();
96 
97  // Main loop: keep receiving events
98  while( TOOL_EVENT* evt = Wait() )
99  {
100  setCursor();
101 
102  VECTOR2I cursorPos = controls()->GetCursorPosition();
103  aPlacer->m_modifiers = evt->Modifier();
104 
105  auto cleanup =
106  [&] ()
107  {
108  newItem = nullptr;
109  preview.Clear();
110  view()->Update( &preview );
111  controls()->SetAutoPan( false );
112  controls()->CaptureCursor( false );
113  controls()->ShowCursor( true );
114  };
115 
116  if( evt->IsCancelInteractive() )
117  {
118  if( aOptions & IPO_SINGLE_CLICK )
119  {
120  cleanup();
121  frame()->PopTool( aTool );
122  break;
123  }
124  else if( newItem )
125  cleanup();
126  else
127  {
128  frame()->PopTool( aTool );
129  break;
130  }
131  }
132  else if( evt->IsActivate() )
133  {
134  if( newItem )
135  cleanup();
136 
137  if( evt->IsPointEditor() )
138  {
139  // don't exit (the point editor runs in the background)
140  }
141  else if( evt->IsMoveTool() )
142  {
143  // leave ourselves on the stack so we come back after the move
144  break;
145  }
146  else
147  {
148  frame()->PopTool( aTool );
149  break;
150  }
151  }
152  else if( evt->IsClick( BUT_LEFT ) )
153  {
154  if( !newItem )
155  {
156  // create the item if possible
157  makeNewItem( cursorPos );
158 
159  // no item created, so wait for another click
160  if( !newItem )
161  continue;
162 
163  controls()->CaptureCursor( true );
164  controls()->SetAutoPan( true );
165  }
166  else
167  {
168  auto oldFlags = newItem->GetFlags();
169  newItem->ClearFlags();
170 
171  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
172  {
173  newItem->SetFlags( oldFlags );
174  continue;
175  }
176 
177  preview.Clear();
178  newItem.release();
179  commit.Push( aCommitMessage );
180 
181  controls()->CaptureCursor( false );
182  controls()->SetAutoPan( false );
183  controls()->ShowCursor( true );
184 
185  if( !( aOptions & IPO_REPEAT ) )
186  break;
187 
188  if( aOptions & IPO_SINGLE_CLICK )
189  makeNewItem( controls()->GetCursorPosition() );
190 
191  setCursor();
192  }
193  }
194  else if( evt->IsClick( BUT_RIGHT ) )
195  {
197  }
198  else if( evt->IsAction( &PCB_ACTIONS::trackViaSizeChanged ) )
199  {
201  }
202  else if( newItem && evt->Category() == TC_COMMAND )
203  {
204  /*
205  * Handle any events that can affect the item as we move it around
206  */
207  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
208  {
209  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
210  newItem->Rotate( newItem->GetPosition(), rotationAngle );
211  view()->Update( &preview );
212  }
213  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
214  {
215  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
216  view()->Update( &preview );
217  }
218  else if( evt->IsAction( &PCB_ACTIONS::viaSizeInc )
219  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
220  {
221  // Refresh preview after event runs
223  }
224  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
225  {
226  preview.Clear();
227  newItem.release();
228 
229  makeNewItem( (wxPoint) cursorPos );
230  aPlacer->SnapItem( newItem.get() );
231  view()->Update( &preview );
232  }
233  }
234  else if( newItem && evt->IsMotion() )
235  {
236  // track the cursor
237  newItem->SetPosition( (wxPoint) cursorPos );
238  aPlacer->SnapItem( newItem.get() );
239 
240  // Show a preview of the item
241  view()->Update( &preview );
242  }
243  else
244  {
245  evt->SetPassEvent();
246  }
247  }
248 
249  view()->Remove( &preview );
251 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:94
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:296
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:299
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
void SetCurrentCursor(KICURSOR cursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:76
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:75
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143
PCB_BASE_EDIT_FRAME * frame() const
virtual void SnapItem(BOARD_ITEM *aItem)
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:94
const PCBNEW_SELECTION & selection() const
Allow repeat placement of the item.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
TOOL_EVENT.
Definition: tool_event.h:171
KIGFX::PCB_VIEW * view() const
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
class FOOTPRINT, a footprint
Definition: typeinfo.h:89
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:108
Handle the rotate action in the loop by calling the item's rotate method.
KIGFX::VIEW_CONTROLS * controls() const
PCBNEW_SETTINGS & Settings()
void Activate()
Function Activate() Runs the tool.
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Function RunOnChildren.
Definition: footprint.cpp:1089
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:59
PCB_BASE_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:65
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:297
static TOOL_ACTION refreshPreview
Definition: actions.h:104
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, PCBNEW_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, TOOL_BASE::m_toolMgr, PCB_FOOTPRINT_T, PENCIL, PLACE, INTERACTIVE_PLACER_BASE::PlaceItem(), TOOLS_HOLDER::PopTool(), BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), FOOTPRINT::RunOnChildren(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, PCB_ACTIONS::trackViaSizeChanged, KIGFX::PCB_VIEW::Update(), PCB_ACTIONS::viaSizeDec, PCB_ACTIONS::viaSizeInc, PCB_TOOL_BASE::view(), and TOOL_INTERACTIVE::Wait().

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint(), DRAWING_TOOL::DrawVia(), and PAD_TOOL::PlacePad().

◆ editArcEndpointKeepCenter()

void POINT_EDITOR::editArcEndpointKeepCenter ( PCB_SHAPE aArc,
VECTOR2I  aCenter,
VECTOR2I  aStart,
VECTOR2I  aMid,
VECTOR2I  aEnd,
const VECTOR2I  aCursor 
) const
private

Move an end point of the arc, while keeping radius, and the other point position.

Definition at line 831 of file point_editor.cpp.

834 {
835  bool clockwise;
836  bool movingStart;
837 
838  VECTOR2I *p1, *p2;
839  VECTOR2I target;
840 
841  // p1 does not move, p2 does.
842 
843  if( aStart != aArc->GetArcStart() )
844  {
845  p1 = &aEnd;
846  p2 = &aStart;
847  movingStart = true;
848  }
849  else
850  {
851  p1 = &aStart;
852  p2 = &aEnd;
853  movingStart = false;
854  }
855 
856  target = *p2 - aCenter;
857 
858  double sqRadius = ( *p1 - aCenter ).SquaredEuclideanNorm();
859 
860  *p1 = *p1 - aCenter;
861  *p2 = *p2 - aCenter;
862 
863  // Circle : x^2 + y^2 = R ^ 2
864  // In this coordinate system, the angular position of the cursor is (r, theta)
865  // The line coming from the center of the circle is y = start.y / start.x * x
866  // The intersection fulfills : x^2 = R^2 / ( 1 + ( start.y / start.x ) ^ 2 )
867 
868  if( target.x == 0 )
869  {
870  p2->x = 0;
871  p2->y = ( target.y > 0 ) ? sqrt( sqRadius ) : -sqrt( sqRadius );
872  }
873  else
874  {
875  double tan = target.y / static_cast<double>( target.x );
876  // The divider is always greater than 1 ( cannot be 0 )
877  double tmp = sqrt( sqRadius / ( 1.0 + tan * tan ) );
878  // Move to the correct quadrant
879  tmp = target.x > 0 ? tmp : -tmp;
880  p2->y = target.y / static_cast<double>( target.x ) * tmp;
881  p2->x = tmp;
882  }
883 
884  *p1 = *p1 + aCenter;
885  *p2 = *p2 + aCenter;
886 
887  clockwise = aArc->GetAngle() > 0;
888 
889  VECTOR2D startLine = aStart - aCenter;
890  VECTOR2D endLine = aEnd - aCenter;
891  double newAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
892 
893  if( clockwise && newAngle < 0.0 )
894  newAngle += 3600.0;
895  else if( !clockwise && newAngle > 0.0 )
896  newAngle -= 3600.0;
897 
898  aArc->SetAngle( newAngle, false );
899  aArc->SetCenter( (wxPoint) aCenter );
900 
901  if( movingStart )
902  aArc->SetArcStart( (wxPoint) aStart );
903  else
904  aArc->SetArcEnd( (wxPoint) aEnd );
905 }
double RAD2DECIDEG(double rad)
Definition: trigo.h:222
wxPoint GetArcStart() const
Definition: pcb_shape.h:178
void SetCenter(const wxPoint &aCenterPoint)
For arcs and circles:
Definition: pcb_shape.h:228
double Angle() const
Function Angle computes the angle of the vector.
Definition: vector2d.h:313
double GetAngle() const
Definition: pcb_shape.h:126
void SetArcEnd(const wxPoint &aArcEndPoint)
Initialize the end arc point.
Definition: pcb_shape.h:221
virtual void SetAngle(double aAngle, bool aUpdateEnd=true)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: pcb_shape.cpp:444
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
Definition: pcb_shape.h:212

References VECTOR2< T >::Angle(), PCB_SHAPE::GetAngle(), PCB_SHAPE::GetArcStart(), RAD2DECIDEG(), PCB_SHAPE::SetAngle(), PCB_SHAPE::SetArcEnd(), PCB_SHAPE::SetArcStart(), PCB_SHAPE::SetCenter(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by updateItem().

◆ editArcEndpointKeepTangent()

void POINT_EDITOR::editArcEndpointKeepTangent ( PCB_SHAPE aArc,
VECTOR2I  aCenter,
VECTOR2I  aStart,
VECTOR2I  aMid,
VECTOR2I  aEnd,
const VECTOR2I  aCursor 
) const
private

Move an end point of the arc, while keeping the tangent at the other endpoint.

Definition at line 563 of file point_editor.cpp.

566 {
567  VECTOR2D startLine = aStart - aCenter;
568  VECTOR2D endLine = aEnd - aCenter;
569  double newAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
570 
571  bool clockwise;
572  bool movingStart;
573  bool arcValid = true;
574 
575  VECTOR2I *p1, *p2, *p3;
576  // p1 does not move, p2 does.
577 
578  if( aStart != aArc->GetArcStart() )
579  {
580  aStart = aCursor;
581  p1 = &aEnd;
582  p2 = &aStart;
583  p3 = &aMid;
584  movingStart = true;
585  }
586  else
587  {
588  aEnd = aCursor;
589  p1 = &aStart;
590  p2 = &aEnd;
591  p3 = &aMid;
592  movingStart = false;
593  }
594 
595  VECTOR2D v1, v2, v3, v4;
596 
597  // Move the coordinate system
598  v1 = *p1 - aCenter;
599  v2 = *p2 - aCenter;
600  v3 = *p3 - aCenter;
601 
602  VECTOR2D u1, u2, u3;
603 
604  // A point cannot be both the center and on the arc.
605  if( ( v1.EuclideanNorm() == 0 ) || ( v2.EuclideanNorm() == 0 ) )
606  return;
607 
608  u1 = v1 / v1.EuclideanNorm();
609  u2 = v3 - ( u1.x * v3.x + u1.y * v3.y ) * u1;
610  u2 = u2 / u2.EuclideanNorm();
611 
612  // [ u1, u3 ] is a base centered on the circle with:
613  // u1 : unit vector toward the point that does not move
614  // u2 : unit vector toward the mid point.
615 
616  // Get vectors v1, and v2 in that coordinate system.
617 
618  double det = u1.x * u2.y - u2.x * u1.y;
619 
620  // u1 and u2 are unit vectors, and perpendicular.
621  // det should not be 0. In case it is, do not change the arc.
622  if( det == 0 )
623  return;
624 
625  double tmpx = v1.x * u2.y - v1.y * u2.x;
626  double tmpy = -v1.x * u1.y + v1.y * u1.x;
627  v1.x = tmpx;
628  v1.y = tmpy;
629  v1 = v1 / det;
630 
631  tmpx = v2.x * u2.y - v2.y * u2.x;
632  tmpy = -v2.x * u1.y + v2.y * u1.x;
633  v2.x = tmpx;
634  v2.y = tmpy;
635  v2 = v2 / det;
636 
637  double R = v1.EuclideanNorm();
638  bool transformCircle = false;
639 
640  /* p2
641  * X***
642  * ** <---- This is the arc
643  * y ^ **
644  * | R *
645  * | <-----------> *
646  * x------x------>--------x p1
647  * C' <----> C x
648  * delta
649  *
650  * p1 does not move, and the tangent at p1 remains the same.
651  * => The new center, C', will be on the C-p1 axis.
652  * p2 moves
653  *
654  * The radius of the new circle is delta + R
655  *
656  * || C' p2 || = || C' P1 ||
657  * is the same as :
658  * ( delta + p2.x ) ^ 2 + p2.y ^ 2 = ( R + delta ) ^ 2
659  *
660  * delta = ( R^2 - p2.x ^ 2 - p2.y ^2 ) / ( 2 * p2.x - 2 * R )
661  *
662  * We can use this equation for any point p2 with p2.x < R
663  */
664 
665  if( v2.x == R )
666  {
667  // Straight line, do nothing
668  }
669  else
670  {
671  if( v2.x > R )
672  {
673  // If we need to invert the curvature.
674  // We modify the input so we can use the same equation
675  transformCircle = true;
676  v2.x = 2 * R - v2.x;
677  }
678  // We can keep the tangent constraint.
679  double delta = ( R * R - v2.x * v2.x - v2.y * v2.y ) / ( 2 * v2.x - 2 * R );
680 
681  // This is just to limit the radius, so nothing overflows later when drawing.
682  if( abs( v2.y / ( R - v2.x ) ) > ADVANCED_CFG::GetCfg().m_DrawArcCenterMaxAngle )
683  {
684  arcValid = false;
685  }
686  // Never recorded a problem, but still checking.
687  if( !std::isfinite( delta ) )
688  {
689  arcValid = false;
690  }
691  // v4 is the new center
692  v4 = ( !transformCircle ) ? VECTOR2D( -delta, 0 ) : VECTOR2D( 2 * R + delta, 0 );
693 
694  clockwise = aArc->GetAngle() > 0;
695 
696  if( transformCircle )
697  clockwise = !clockwise;
698 
699  tmpx = v4.x * u1.x + v4.y * u2.x;
700  tmpy = v4.x * u1.y + v4.y * u2.y;
701  v4.x = tmpx;
702  v4.y = tmpy;
703 
704  aCenter = v4 + aCenter;
705 
706  startLine = aStart - aCenter;
707  endLine = aEnd - aCenter;
708  newAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
709 
710  if( clockwise && newAngle < 0.0 )
711  newAngle += 3600.0;
712  else if( !clockwise && newAngle > 0.0 )
713  newAngle -= 3600.0;
714 
715  if( arcValid )
716  {
717  aArc->SetAngle( newAngle, false );
718  aArc->SetCenter( wxPoint( aCenter.x, aCenter.y ) );
719 
720  if( movingStart )
721  aArc->SetArcStart( wxPoint( aStart.x, aStart.y ) );
722  else
723  aArc->SetArcEnd( wxPoint( aEnd.x, aEnd.y ) );
724  }
725  }
726 }
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
double RAD2DECIDEG(double rad)
Definition: trigo.h:222
double m_DrawArcCenterMaxAngle
When drawing an arc, the angle ( center - start ) - ( start - end ) can be limited to avoid extremely...
wxPoint GetArcStart() const
Definition: pcb_shape.h:178
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
void SetCenter(const wxPoint &aCenterPoint)
For arcs and circles:
Definition: pcb_shape.h:228
double Angle() const
Function Angle computes the angle of the vector.
Definition: vector2d.h:313
double GetAngle() const
Definition: pcb_shape.h:126
void SetArcEnd(const wxPoint &aArcEndPoint)
Initialize the end arc point.
Definition: pcb_shape.h:221
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:299
virtual void SetAngle(double aAngle, bool aUpdateEnd=true)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: pcb_shape.cpp:444
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
Definition: pcb_shape.h:212

References VECTOR2< T >::Angle(), VECTOR2< T >::EuclideanNorm(), PCB_SHAPE::GetAngle(), PCB_SHAPE::GetArcStart(), ADVANCED_CFG::GetCfg(), ADVANCED_CFG::m_DrawArcCenterMaxAngle, RAD2DECIDEG(), PCB_SHAPE::SetAngle(), PCB_SHAPE::SetArcEnd(), PCB_SHAPE::SetArcStart(), PCB_SHAPE::SetCenter(), v2, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by updateItem().

◆ editArcMidKeepCenter()

void POINT_EDITOR::editArcMidKeepCenter ( PCB_SHAPE aArc,
VECTOR2I  aCenter,
VECTOR2I  aStart,
VECTOR2I  aMid,
VECTOR2I  aEnd,
const VECTOR2I  aCursor 
) const
private

Move the mid point of the arc, while keeping the angle.

Definition at line 908 of file point_editor.cpp.

910 {
911  // Now, update the edit point position
912  // Express the point in a cercle-centered coordinate system.
913  aStart = aStart - aCenter;
914  aEnd = aEnd - aCenter;
915 
916  double sqRadius = ( aCursor - aCenter ).SquaredEuclideanNorm();
917 
918  // Special case, because the tangent would lead to +/- infinity
919  if( aStart.x == 0 )
920  {
921  aStart.y = aCursor.y > 0 ? sqrt( sqRadius ) : -sqrt( sqRadius );
922  }
923  else
924  {
925  // Circle : x^2 + y^2 = R ^ 2
926  // In this coordinate system, the angular position of the cursor is (r, theta)
927  // The line coming from the center of the circle is y = start.y / start.x * x
928  // The intersection fulfills : x^2 = R^2 / ( 1 + ( start.y / start.x ) ^ 2 )
929 
930  double tan = aStart.y / static_cast<double>( aStart.x );
931  double tmp = sqrt( sqRadius / ( 1.0 + tan * tan ) );
932  // Move to the correct quadrant
933  tmp = aStart.x > 0 ? tmp : -tmp;
934  aStart.y = aStart.y / static_cast<double>( aStart.x ) * tmp;
935  aStart.x = tmp;
936  }
937 
938  // Special case, because the tangent would lead to +/- infinity
939  if( aEnd.x == 0 )
940  {
941  aEnd.y = aMid.y > 0 ? sqrt( sqRadius ) : -sqrt( sqRadius );
942  }
943  else
944  {
945  // Circle : x^2 + y^2 = R ^ 2
946  // In this coordinate system, the angular position of the cursor is (r, theta)
947  // The line coming from the center of the circle is y = start.y / start.x * x
948  // The intersection fulfills : x^2 = R^2 / ( 1 + ( start.y / start.x ) ^ 2 )
949 
950  double tan = aEnd.y / static_cast<double>( aEnd.x );
951  double tmp = sqrt( sqRadius / ( 1.0 + tan * tan ) );
952  // Move to the correct quadrant
953  tmp = aEnd.x > 0 ? tmp : -tmp;
954  aEnd.y = aEnd.y / static_cast<double>( aEnd.x ) * tmp;
955  aEnd.x = tmp;
956  }
957 
958  aStart = aStart + aCenter;
959  aEnd = aEnd + aCenter;
960 
961  aArc->SetArcStart( (wxPoint) aStart );
962  aArc->SetArcEnd( (wxPoint) aEnd );
963 }
void SetArcEnd(const wxPoint &aArcEndPoint)
Initialize the end arc point.
Definition: pcb_shape.h:221
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
Definition: pcb_shape.h:212

References PCB_SHAPE::SetArcEnd(), PCB_SHAPE::SetArcStart(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by updateItem().

◆ editArcMidKeepEnpoints()

void POINT_EDITOR::editArcMidKeepEnpoints ( PCB_SHAPE aArc,
VECTOR2I  aCenter,
VECTOR2I  aStart,
VECTOR2I  aMid,
VECTOR2I  aEnd,
const VECTOR2I  aCursor 
) const
private

Move the mid point of the arc, while keeping the two endpoints.

Definition at line 966 of file point_editor.cpp.

968 {
969  bool clockwise;
970  VECTOR2I oldCenter = aArc->GetCenter();
971 
972 
973  // This allows the user to go on the sides of the arc
974  aMid = aCursor;
975  // Find the new center
976  aCenter = GetArcCenter( aStart, aMid, aEnd );
977 
978  aArc->SetCenter( (wxPoint) aCenter );
979 
980  // Check if the new arc is CW or CCW
981  VECTOR2D startLine = aStart - aCenter;
982  VECTOR2D endLine = aEnd - aCenter;
983  double newAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
984  VECTOR2D v1, v2;
985 
986  v1 = aStart - aMid;
987  v2 = aEnd - aMid;
988  double theta = RAD2DECIDEG( v1.Angle() );
989  RotatePoint( &( v1.x ), &( v1.y ), theta );
990  RotatePoint( &( v2.x ), &( v2.y ), theta );
991  clockwise = ( ( v1.Angle() - v2.Angle() ) > 0 );
992 
993  // Normalize the angle
994  if( clockwise && newAngle < 0.0 )
995  newAngle += 3600.0;
996  else if( !clockwise && newAngle > 0.0 )
997  newAngle -= 3600.0;
998 
999  // Accuracy test
1000  // First, get the angle
1001  VECTOR2I endTest = aStart;
1002  RotatePoint( &( endTest.x ), &( endTest.y ), aCenter.x, aCenter.y, -newAngle );
1003  double distance = ( endTest - aEnd ).SquaredEuclideanNorm();
1004 
1006  {
1007  // Cancel Everything
1008  // If the accuracy is low, we can't draw precisely the arc.
1009  // It may happen when the radius is *high*
1010  aArc->SetCenter( (wxPoint) oldCenter );
1011  }
1012  else
1013  {
1014  aArc->SetAngle( newAngle, false );
1015  }
1016 
1017  // Now, update the edit point position
1018  // Express the point in a cercle-centered coordinate system.
1019  aMid = aCursor - aCenter;
1020 
1021  double sqRadius = ( aEnd - aCenter ).SquaredEuclideanNorm();
1022 
1023  // Special case, because the tangent would lead to +/- infinity
1024  if( aMid.x == 0 )
1025  {
1026  aMid.y = aMid.y > 0 ? sqrt( sqRadius ) : -sqrt( sqRadius );
1027  }
1028  else
1029  {
1030  // Circle : x^2 + y^2 = R ^ 2
1031  // In this coordinate system, the angular position of the cursor is (r, theta)
1032  // The line coming from the center of the circle is y = start.y / start.x * x
1033  // The intersection fulfills : x^2 = R^2 / ( 1 + ( start.y / start.x ) ^ 2 )
1034 
1035  double tan = aMid.y / static_cast<double>( aMid.x );
1036  double tmp = sqrt( sqRadius / ( 1.0 + tan * tan ) );
1037  // Move to the correct quadrant
1038  tmp = aMid.x > 0 ? tmp : -tmp;
1039  aMid.y = aMid.y / static_cast<double>( aMid.x ) * tmp;
1040  aMid.x = tmp;
1041  }
1042 }
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
double RAD2DECIDEG(double rad)
Definition: trigo.h:222
double m_DrawArcAccuracy
Distance from an arc end point and the estimated end point, when rotating from the start point to the...
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
wxPoint GetCenter() const override
Function GetCenter()
Definition: pcb_shape.cpp:343
void SetCenter(const wxPoint &aCenterPoint)
For arcs and circles:
Definition: pcb_shape.h:228
double Angle() const
Function Angle computes the angle of the vector.
Definition: vector2d.h:313
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
const VECTOR2I GetArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
Definition: trigo.cpp:430
virtual void SetAngle(double aAngle, bool aUpdateEnd=true)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: pcb_shape.cpp:444

References VECTOR2< T >::Angle(), distance(), GetArcCenter(), PCB_SHAPE::GetCenter(), ADVANCED_CFG::GetCfg(), ADVANCED_CFG::m_DrawArcAccuracy, RAD2DECIDEG(), RotatePoint(), PCB_SHAPE::SetAngle(), PCB_SHAPE::SetCenter(), v2, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by updateItem().

◆ finishItem()

void POINT_EDITOR::finishItem ( )
private

Applies the last changes to the edited item.

Definition at line 1478 of file point_editor.cpp.

1479 {
1480  auto item = m_editPoints->GetParent();
1481 
1482  if( !item )
1483  return;
1484 
1485  if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
1486  {
1487  ZONE* zone = static_cast<ZONE*>( item );
1488 
1489  if( zone->IsFilled() && m_refill && zone->NeedRefill() )
1490  m_toolMgr->RunAction( PCB_ACTIONS::zoneFill, true, zone );
1491  }
1492 }
bool NeedRefill() const
Definition: zone.h:235
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
bool IsFilled() const
Definition: zone.h:232
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:302
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:83
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
class ZONE, a copper pour area
Definition: typeinfo.h:106
class ZONE, managed by a footprint
Definition: typeinfo.h:95

References ZONE::IsFilled(), m_editPoints, m_refill, TOOL_BASE::m_toolMgr, ZONE::NeedRefill(), PCB_FP_ZONE_T, PCB_ZONE_T, TOOL_MANAGER::RunAction(), and PCB_ACTIONS::zoneFill.

Referenced by OnSelectionChange().

◆ footprint()

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 155 of file pcb_tool_base.h.

156  {
157  return getEditFrame<PCB_BASE_EDIT_FRAME>();
158  }

Referenced by addCorner(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), ROUTER_TOOL::CustomTrackWidthDialog(), FOOTPRINT_EDITOR_TOOLS::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), PCB_EDITOR_CONTROL::ExportSpecctraDSN(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), ROUTER_TOOL::finishInteractive(), EDIT_TOOL::Flip(), PCB_EDITOR_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PCB_EDITOR_CONTROL::ImportSpecctraSession(), ROUTER_TOOL::Init(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCBNEW_PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MoveExact(), OnSelectionChange(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), PAD_TOOL::recombinePad(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), setEditedPoint(), ROUTER_TOOL::SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), ROUTER_TOOL::switchLayerOnViaPlacement(), PCB_EDITOR_CONTROL::UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ get45DegConstrainer()

EDIT_POINT POINT_EDITOR::get45DegConstrainer ( ) const
private

Returns a point that should be used as a constrainer for 45 degrees mode.

Definition at line 1787 of file point_editor.cpp.

1788 {
1789  EDA_ITEM* item = m_editPoints->GetParent();
1790 
1791  switch( item->Type() )
1792  {
1793  case PCB_SHAPE_T:
1794  case PCB_FP_SHAPE_T:
1795  switch( static_cast<const PCB_SHAPE*>( item )->GetShape() )
1796  {
1797  case S_SEGMENT:
1798  return *( m_editPoints->Next( *m_editedPoint ) ); // select the other end of line
1799 
1800  case S_ARC:
1801  case S_CIRCLE:
1802  return m_editPoints->Point( CIRC_CENTER );
1803 
1804  default: // suppress warnings
1805  break;
1806  }
1807 
1808  break;
1809 
1810  case PCB_DIM_ALIGNED_T:
1811  {
1812  // Constraint for crossbar
1813  if( isModified( m_editPoints->Point( DIM_START ) ) )
1814  return m_editPoints->Point( DIM_END );
1815 
1816  else if( isModified( m_editPoints->Point( DIM_END ) ) )
1817  return m_editPoints->Point( DIM_START );
1818 
1819  else
1820  return EDIT_POINT( m_editedPoint->GetPosition() ); // no constraint
1821 
1822  break;
1823  }
1824 
1825  case PCB_DIM_CENTER_T:
1826  {
1827  if( isModified( m_editPoints->Point( DIM_END ) ) )
1828  return m_editPoints->Point( DIM_START );
1829 
1830  break;
1831  }
1832 
1833  default:
1834  break;
1835  }
1836 
1837  // In any other case we may align item to its original position
1838  return m_original;
1839 }
class ALIGNED_DIMENSION, a linear dimension (graphic item)
Definition: typeinfo.h:101
class CENTER_DIMENSION, a center point marking (graphic item)
Definition: typeinfo.h:103
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
bool isModified(const EDIT_POINT &aPoint) const
Returns true if aPoint is the currently modified point.
Definition: point_editor.h:133
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:83
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:71
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
EDIT_POINT m_original
Original position for the current drag point.
Definition: point_editor.h:80
ring
Definition: board_item.h:55
EDIT_POINT.
Definition: edit_points.h:46
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:91
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References CIRC_CENTER, DIM_END, DIM_START, EDIT_POINT::GetPosition(), isModified(), m_editedPoint, m_editPoints, m_original, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_FP_SHAPE_T, PCB_SHAPE_T, S_ARC, S_CIRCLE, S_SEGMENT, and EDA_ITEM::Type().

Referenced by setAltConstraint().

◆ getEditedPointIndex()

int POINT_EDITOR::getEditedPointIndex ( ) const
inlineprivate

Definition at line 121 of file point_editor.h.

122  {
123  for( unsigned i = 0; i < m_editPoints->PointsSize(); ++i )
124  {
125  if( m_editedPoint == &m_editPoints->Point( i ) )
126  return i;
127  }
128 
129  return wxNOT_FOUND;
130  }
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:83
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75

References m_editedPoint, and m_editPoints.

Referenced by updateItem().

◆ getEditFrame()

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

Function getEditFrame()

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

Definition at line 187 of file tool_base.h.

188  {
189 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
190  wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
191 #endif
192  return static_cast<T*>( getToolHolderInt() );
193  }
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

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 121 of file tool_base.h.

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

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 143 of file tool_base.h.

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

References TOOL_BASE::m_toolMgr.

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

◆ getModel()

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 201 of file tool_base.h.

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

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Function GetName() Returns the name of the tool.

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

Returns
The name of the tool.

Definition at line 132 of file tool_base.h.

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

References TOOL_BASE::m_toolName.

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

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 110 of file tool_base.h.

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

References TOOL_BASE::m_type.

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

◆ getView()

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

Function getView()

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

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::collectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), PL_DRAWING_TOOLS::DrawShape(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindComponentAndItem(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::GuessSelectionCandidates(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectAll(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PL_POINT_EDITOR::updateItem(), updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updateParentItem(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

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

Function getViewControls()

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

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCorner(), 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(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), OnSelectionChange(), LIB_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LENGTH_TUNER_TOOL::performTuning(), LIB_DRAWING_TOOLS::PlaceAnchor(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCBNEW_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), updateEditedPoint(), updateItem(), PL_EDIT_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

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

Function Go()

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

Definition at line 129 of file tool_interactive.h.

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

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), PCB_REANNOTATE_TOOL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), LIB_PIN_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), COMMON_CONTROL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), CONVERT_TOOL::setTransitions(), DRC_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), PAD_TOOL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), LIB_CONTROL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), PL_EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_TOOLS::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), PCBNEW_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ HasPoint()

bool POINT_EDITOR::HasPoint ( )
inline

Indicates the cursor is over an edit point.

Used to coordinate cursor shapes with other tools.

Definition at line 65 of file point_editor.h.

65 { return m_editedPoint != nullptr; }
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75

References m_editedPoint.

◆ Init()

bool POINT_EDITOR::Init ( void  )
overridevirtual

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

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

Reimplemented from PCB_TOOL_BASE.

Definition at line 338 of file point_editor.cpp.

339 {
340  // Find the selection tool, so they can cooperate
342 
343  wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" );
344 
345  auto& menu = m_selectionTool->GetToolMenu().GetMenu();
348  std::bind( &POINT_EDITOR::removeCornerCondition, this, _1 ) );
349 
350  return true;
351 }
SELECTION_TOOL.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_MENU & GetToolMenu()
bool removeCornerCondition(const SELECTION &aSelection)
Condition to display "Remove corner" context menu entry.
static TOOL_ACTION pointEditorAddCorner
Break outline (insert additional points to an edge)
Definition: pcb_actions.h:209
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
Definition: pcb_actions.h:212
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: point_editor.h:72
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Adds a menu entry to run a TOOL_ACTION on selected items.
static bool addCornerCondition(const SELECTION &aSelection)
Condition to display "Create corner" context menu entry.

References addCornerCondition(), CONDITIONAL_MENU::AddItem(), TOOL_MENU::GetMenu(), TOOL_MANAGER::GetTool(), TOOL_INTERACTIVE::GetToolMenu(), m_selectionTool, TOOL_BASE::m_toolMgr, PCB_ACTIONS::pointEditorAddCorner, PCB_ACTIONS::pointEditorRemoveCorner, and removeCornerCondition().

◆ IsFootprintEditor()

bool PCB_TOOL_BASE::IsFootprintEditor ( ) const
inlineinherited

◆ isModified()

bool POINT_EDITOR::isModified ( const EDIT_POINT aPoint) const
inlineprivate

Returns true if aPoint is the currently modified point.

Definition at line 133 of file point_editor.h.

134  {
135  return m_editedPoint == &aPoint;
136  }
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75

References m_editedPoint.

Referenced by get45DegConstrainer(), and updateItem().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

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

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

Referenced by EDIT_TOOL::isRouterActive(), and ROUTER_TOOL::onViaCommand().

◆ modifiedSelection()

int POINT_EDITOR::modifiedSelection ( const TOOL_EVENT aEvent)
private

Definition at line 2138 of file point_editor.cpp.

2139 {
2140  updatePoints();
2141  return 0;
2142 }
void updatePoints()
Updates edit points with item's points.

References updatePoints().

Referenced by setTransitions().

◆ OnSelectionChange()

int POINT_EDITOR::OnSelectionChange ( const TOOL_EVENT aEvent)

Function OnSelected()

Change selection event handler.

Definition at line 395 of file point_editor.cpp.

396 {
398  return 0;
399 
401 
402  if( selection.Size() != 1 || selection.Front()->GetEditFlags() )
403  return 0;
404 
405  Activate();
406 
408  KIGFX::VIEW* view = getView();
409  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
410 
411  controls->ShowCursor( true );
412 
413  GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() );
414  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
415 
416  if( !item )
417  return 0;
418 
419  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
420 
421  if( !m_editPoints )
422  return 0;
423 
424  view->Add( m_editPoints.get() );
425  setEditedPoint( nullptr );
426  updateEditedPoint( aEvent );
427  m_refill = false;
428  bool inDrag = false;
429 
430  BOARD_COMMIT commit( editFrame );
431  LSET snapLayers = item->GetLayerSet();
432 
433  if( BaseType( item->Type() ) == PCB_DIMENSION_T )
434  snapLayers = LSET::AllLayersMask();
435 
436  // Main loop: keep receiving events
437  while( TOOL_EVENT* evt = Wait() )
438  {
439  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
440  grid.SetUseGrid( editFrame->IsGridVisible() );
441 
442  if( !m_editPoints || evt->IsSelectionEvent() ||
443  evt->Matches( EVENTS::InhibitSelectionEditing ) )
444  break;
445 
446  EDIT_POINT* prevHover = m_hoveredPoint;
447 
448  if( !inDrag )
449  updateEditedPoint( *evt );
450 
451  if( prevHover != m_hoveredPoint )
452  getView()->Update( m_editPoints.get() );
453 
454  if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
455  {
456  if( !inDrag )
457  {
458  frame()->UndoRedoBlock( true );
459 
460  commit.StageItems( selection, CHT_MODIFY );
461 
462  controls->ForceCursorPosition( false );
463  m_original = *m_editedPoint; // Save the original position
464  controls->SetAutoPan( true );
465  inDrag = true;
466  grid.SetAuxAxes( true, m_original.GetPosition() );
467  setAltConstraint( true );
469  }
470 
471  //TODO: unify the constraints to solve simultaneously instead of sequentially
472  if( m_editedPoint->IsGridFree() )
473  {
474  m_editedPoint->SetPosition( evt->Position() );
475  }
476  else
477  {
478  m_editedPoint->SetPosition( grid.BestSnapAnchor( evt->Position(), snapLayers,
479  { item } ) );
480  }
481 
482  // The alternative constraint limits to 45°
483  bool enableAltConstraint = !!evt->Modifier( MD_CTRL );
484 
485  if( enableAltConstraint )
486  m_altConstraint->Apply();
487  else
489 
490  if( !m_editedPoint->IsGridFree() )
491  {
492  m_editedPoint->SetPosition( grid.BestSnapAnchor( m_editedPoint->GetPosition(),
493  snapLayers, { item } ) );
494  }
495 
496  updateItem();
497  updatePoints();
498  }
499  else if( m_editedPoint && evt->Action() == TA_MOUSE_DOWN && evt->Buttons() == BUT_LEFT )
500  {
502  getView()->Update( m_editPoints.get() );
503  }
504  else if( inDrag && evt->IsMouseUp( BUT_LEFT ) )
505  {
506  if( m_editedPoint )
507  {
508  m_editedPoint->SetActive( false );
509  getView()->Update( m_editPoints.get() );
510  }
511 
512  controls->SetAutoPan( false );
513  setAltConstraint( false );
514 
515  commit.Push( _( "Drag a corner" ) );
516  inDrag = false;
517  frame()->UndoRedoBlock( false );
518 
519  m_refill = true;
520  }
521 
522  else if( evt->IsCancelInteractive() || evt->IsActivate() )
523  {
524  if( inDrag ) // Restore the last change
525  {
526  commit.Revert();
527  inDrag = false;
528  frame()->UndoRedoBlock( false );
529  }
530  else if( evt->IsCancelInteractive() )
531  {
532  break;
533  }
534 
535  if( evt->IsActivate() && !evt->IsMoveTool() )
536  break;
537  }
538 
539  else if( evt->Action() == TA_UNDO_REDO_POST )
540  {
541  break;
542  }
543 
544  else
545  {
546  evt->SetPassEvent();
547  }
548  }
549 
550  if( m_editPoints )
551  {
552  view->Remove( m_editPoints.get() );
553 
554  finishItem();
555  m_editPoints.reset();
556  }
557 
558  frame()->UpdateMsgPanel();
559 
560  return 0;
561 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
constexpr KICAD_T BaseType(const KICAD_T aType)
Returns the underlying type of the given type.
Definition: typeinfo.h:233
void updateEditedPoint(const TOOL_EVENT &aEvent)
Updates which point is being edited.
bool IsGridFree() const
Definition: edit_points.h:188
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void setAltConstraint(bool aEnabled)
Sets up an alternative constraint (typically enabled upon a modifier key being pressed).
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:76
void updateItem() const
Updates item's points with edit points.
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
PCB_BASE_EDIT_FRAME * frame() const
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:83
void finishItem()
Applies the last changes to the edited item.
void SetActive(bool aActive=true)
Definition: edit_points.h:183
LSET is a set of PCB_LAYER_IDs.
const PCBNEW_SELECTION & selection() const
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:71
bool IsGridVisible() const
STATUS_FLAGS GetEditFlags() const
Definition: eda_item.h:225
TOOL_EVENT.
Definition: tool_event.h:171
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
Definition: point_editor.h:86
KIGFX::PCB_VIEW * view() const
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
static LSET AllLayersMask()
Definition: lset.cpp:787
bool Matches(const TOOL_EVENT &aEvent) const
Function Matches() Tests whether two events match in terms of category & action or command.
Definition: tool_event.h:364
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: point_editor.h:72
class DIMENSION_BASE: abstract dimension meta-type
Definition: typeinfo.h:100
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
KIGFX::VIEW_CONTROLS * controls() const
Common, abstract interface for edit frames.
#define _(s)
Definition: 3d_actions.cpp:33
EDIT_POINT * m_hoveredPoint
Definition: point_editor.h:77
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
static const TOOL_EVENT InhibitSelectionEditing
Used to inform tools that the selection should temporarily be non-editable
Definition: actions.h:219
void updatePoints()
Updates edit points with item's points.
EDIT_POINT m_original
Original position for the current drag point.
Definition: point_editor.h:80
void Activate()
Function Activate() Runs the tool.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:59
EDIT_POINT.
Definition: edit_points.h:46
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VIEW.
Definition: view.h:63
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem, SCH_BASE_FRAME *frame)
void setEditedPoint(EDIT_POINT *aPoint)
Sets the current point being edited. NULL means none.
virtual void ApplyConstraint()
Function ApplyConstraint()
Definition: edit_points.h:176
EDA_ITEM * Front() const
Definition: selection.h:201
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1513
virtual void UpdateMsgPanel()
Redraw the message panel.
virtual void SetPosition(const VECTOR2I &aPosition)
Function SetPosition()
Definition: edit_points.h:108

References _, TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), LSET::AllLayersMask(), EDIT_POINT::ApplyConstraint(), BaseType(), BUT_LEFT, CHT_MODIFY, PCB_TOOL_BASE::controls(), finishItem(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), SELECTION::Front(), EDA_ITEM::GetEditFlags(), PCB_BASE_FRAME::GetMagneticItemsSettings(), EDIT_POINT::GetPosition(), SELECTION_TOOL::GetSelection(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), EVENTS::InhibitSelectionEditing, EDIT_POINT::IsGridFree(), EDA_DRAW_FRAME::IsGridVisible(), m_altConstraint, m_editedPoint, m_editPoints, m_hoveredPoint, m_original, m_refill, m_selectionTool, TOOL_BASE::m_toolMgr, EDIT_POINTS_FACTORY::Make(), TOOL_EVENT::Matches(), MD_CTRL, MD_SHIFT, PCB_DIMENSION_T, BOARD_COMMIT::Push(), KIGFX::PCB_VIEW::Remove(), BOARD_COMMIT::Revert(), PCB_TOOL_BASE::selection(), EDIT_POINT::SetActive(), setAltConstraint(), KIGFX::VIEW_CONTROLS::SetAutoPan(), setEditedPoint(), EDIT_POINT::SetPosition(), KIGFX::VIEW_CONTROLS::ShowCursor(), SELECTION::Size(), COMMIT::StageItems(), TA_MOUSE_DOWN, TA_UNDO_REDO_POST, PCB_BASE_EDIT_FRAME::UndoRedoBlock(), KIGFX::VIEW::Update(), updateEditedPoint(), updateItem(), EDA_DRAW_FRAME::UpdateMsgPanel(), updatePoints(), PCB_TOOL_BASE::view(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ removeCorner()

int POINT_EDITOR::removeCorner ( const TOOL_EVENT aEvent)
private

Definition at line 2062 of file point_editor.cpp.

2063 {
2064  if( !m_editPoints || !m_editedPoint )
2065  return 0;
2066 
2067  EDA_ITEM* item = m_editPoints->GetParent();
2068 
2069  if( !item )
2070  return 0;
2071 
2072  SHAPE_POLY_SET* polygon = nullptr;
2073 
2074  if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
2075  {
2076  ZONE* zone = static_cast<ZONE*>( item );
2077  polygon = zone->Outline();
2078  zone->SetNeedRefill( true );
2079  }
2080  else if( item->Type() == PCB_FP_SHAPE_T || item->Type() == PCB_SHAPE_T )
2081  {
2082  auto ds = static_cast<PCB_SHAPE*>( item );
2083 
2084  if( ds->GetShape() == S_POLYGON )
2085  polygon = &ds->GetPolyShape();
2086  }
2087 
2088  if( !polygon )
2089  return 0;
2090 
2091  PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
2092  BOARD_COMMIT commit( frame );
2093  auto vertex = findVertex( *polygon, *m_editedPoint );
2094 
2095  if( vertex.first )
2096  {
2097  const auto& vertexIdx = vertex.second;
2098  auto& outline = polygon->Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
2099 
2100  if( outline.PointCount() > 3 )
2101  {
2102  // the usual case: remove just the corner when there are >3 vertices
2103  commit.Modify( item );
2104  polygon->RemoveVertex( vertexIdx );
2105  validatePolygon( *polygon );
2106  }
2107  else
2108  {
2109  // either remove a hole or the polygon when there are <= 3 corners
2110  if( vertexIdx.m_contour > 0 )
2111  {
2112  // remove hole
2113  commit.Modify( item );
2114  polygon->RemoveContour( vertexIdx.m_contour );
2115  }
2116  else
2117  {
2119  commit.Remove( item );
2120  }
2121  }
2122 
2123  setEditedPoint( nullptr );
2124 
2125  commit.Push( _( "Remove a zone/polygon corner" ) );
2126 
2127  // Refresh zone hatching
2128  if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
2129  static_cast<ZONE*>( item )->HatchBorder();
2130 
2131  updatePoints();
2132  }
2133 
2134  return 0;
2135 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
SHAPE_POLY_SET * Outline()
Definition: zone.h:318
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
PCB_BASE_EDIT_FRAME * frame() const
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:83
SHAPE_POLY_SET.
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
class ZONE, a copper pour area
Definition: typeinfo.h:106
bool validatePolygon(SHAPE_POLY_SET &aModified) const
Validates a polygon and displays a popup warning if invalid.
#define _(s)
Definition: 3d_actions.cpp:33
void RemoveVertex(int aGlobalIndex)
Function RemoveVertex deletes the aGlobalIndex-th vertex.
class ZONE, managed by a footprint
Definition: typeinfo.h:95
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
void updatePoints()
Updates edit points with item's points.
static std::pair< bool, SHAPE_POLY_SET::VERTEX_INDEX > findVertex(SHAPE_POLY_SET &aPolySet, const EDIT_POINT &aPoint)
void SetNeedRefill(bool aNeedRefill)
Definition: zone.h:236
POLYGON & Polygon(int aIndex)
Returns the aIndex-th subpolygon in the set
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:91
void setEditedPoint(EDIT_POINT *aPoint)
Sets the current point being edited. NULL means none.
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
void RemoveContour(int aContourIdx, int aPolygonIdx=-1)
Function RemoveContour deletes the aContourIdx-th contour of the aPolygonIdx-th polygon in the set.

References _, findVertex(), PCB_TOOL_BASE::frame(), m_editedPoint, m_editPoints, TOOL_BASE::m_toolMgr, COMMIT::Modify(), ZONE::Outline(), PCB_FP_SHAPE_T, PCB_FP_ZONE_T, PCB_SHAPE_T, PCB_ZONE_T, SHAPE_POLY_SET::Polygon(), BOARD_COMMIT::Push(), COMMIT::Remove(), SHAPE_POLY_SET::RemoveContour(), SHAPE_POLY_SET::RemoveVertex(), TOOL_MANAGER::RunAction(), S_POLYGON, PCB_ACTIONS::selectionClear, setEditedPoint(), ZONE::SetNeedRefill(), EDA_ITEM::Type(), updatePoints(), and validatePolygon().

Referenced by setTransitions().

◆ removeCornerCondition()

bool POINT_EDITOR::removeCornerCondition ( const SELECTION aSelection)
private

Condition to display "Remove corner" context menu entry.

Definition at line 1887 of file point_editor.cpp.

1888 {
1889  if( !m_editPoints || !m_editedPoint )
1890  return false;
1891 
1892  EDA_ITEM* item = m_editPoints->GetParent();
1893 
1894  if( !item )
1895  return false;
1896 
1897  if( !( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T
1898  || ( ( item->Type() == PCB_FP_SHAPE_T || item->Type() == PCB_SHAPE_T ) &&
1899  static_cast<PCB_SHAPE*>( item )->GetShape() == S_POLYGON ) ) )
1900  return false;
1901 
1902  SHAPE_POLY_SET *polyset;
1903 
1904  if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
1905  polyset = static_cast<ZONE*>( item )->Outline();
1906  else
1907  polyset = &static_cast<PCB_SHAPE*>( item )->GetPolyShape();
1908 
1909  auto vertex = findVertex( *polyset, *m_editedPoint );
1910 
1911  if( !vertex.first )
1912  return false;
1913 
1914  const auto& vertexIdx = vertex.second;
1915 
1916  // Check if there are enough vertices so one can be removed without
1917  // degenerating the polygon.
1918  // The first condition allows one to remove all corners from holes (when
1919  // there are only 2 vertices left, a hole is removed).
1920  if( vertexIdx.m_contour == 0 && polyset->Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour].PointCount() <= 3 )
1921  return false;
1922 
1923  // Remove corner does not work with lines
1924  if( dynamic_cast<EDIT_LINE*>( m_editedPoint ) )
1925  return false;
1926 
1927  return m_editedPoint != NULL;
1928 }
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:83
#define NULL
SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
class ZONE, a copper pour area
Definition: typeinfo.h:106
class ZONE, managed by a footprint
Definition: typeinfo.h:95
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
static std::pair< bool, SHAPE_POLY_SET::VERTEX_INDEX > findVertex(SHAPE_POLY_SET &aPolySet, const EDIT_POINT &aPoint)
POLYGON & Polygon(int aIndex)
Returns the aIndex-th subpolygon in the set
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:91
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References findVertex(), m_editedPoint, m_editPoints, NULL, SHAPE_POLY_SET::Outline(), PCB_FP_SHAPE_T, PCB_FP_ZONE_T, PCB_SHAPE_T, PCB_ZONE_T, SHAPE_POLY_SET::Polygon(), S_POLYGON, and EDA_ITEM::Type().

Referenced by Init().

◆ Reset()

void POINT_EDITOR::Reset ( RESET_REASON  aReason)
overridevirtual

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

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

Parameters
aReasoncontains information about the reason of tool reset.

Reimplemented from PCB_TOOL_BASE.

Definition at line 325 of file point_editor.cpp.

326 {
327  m_refill = false;
328  m_editPoints.reset();
329  m_altConstraint.reset();
330  getViewControls()->SetAutoPan( false );
331 
332  m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
333  m_statusPopup->SetTextColor( wxColour( 255, 0, 0 ) );
334  m_statusPopup->SetText( _( "Self-intersecting polygons are not allowed." ) );
335 }
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
Definition: point_editor.h:97
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:83
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
Definition: point_editor.h:86
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
#define _(s)
Definition: 3d_actions.cpp:33
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42

References _, TOOL_BASE::getViewControls(), m_altConstraint, m_editPoints, m_refill, m_statusPopup, and KIGFX::VIEW_CONTROLS::SetAutoPan().

◆ RunMainStack()

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

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

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

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

Referenced by DRAWING_TOOL::PlaceText().

◆ selection() [1/2]

const PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 291 of file pcb_tool_base.cpp.

292 {
294 
295  return selTool->GetSelection();
296 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
PCBNEW_SELECTION & GetSelection()
Function GetSelection()

References SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), PCB_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), EDIT_TOOL::Duplicate(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), GROUP_TOOL::EnterGroup(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::FilletTracks(), SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), GROUP_TOOL::Group(), PCB_INSPECTION_TOOL::highlightNet(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::InspectClearance(), PCB_INSPECTION_TOOL::InspectConstraints(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), OnSelectionChange(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), PCBNEW_CONTROL::placeBoardItems(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), GROUP_TOOL::RemoveFromGroup(), GLOBAL_EDIT_TOOL::RemoveUnusedPads(), EDIT_TOOL::Rotate(), SELECTION_TOOL::selectNet(), DRAWING_TOOL::SetAnchor(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), GROUP_TOOL::Ungroup(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCB_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 299 of file pcb_tool_base.cpp.

300 {
302 
303  return selTool->GetSelection();
304 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
PCBNEW_SELECTION & GetSelection()
Function GetSelection()

References SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), and TOOL_BASE::m_toolMgr.

◆ setAltConstraint()

void POINT_EDITOR::setAltConstraint ( bool  aEnabled)
private

Sets up an alternative constraint (typically enabled upon a modifier key being pressed).

Definition at line 1749 of file point_editor.cpp.

1750 {
1751  if( aEnabled )
1752  {
1753  EDIT_LINE* line = dynamic_cast<EDIT_LINE*>( m_editedPoint );
1754  bool isPoly = false;
1755 
1756  if( m_editPoints->GetParent()->Type() == PCB_ZONE_T
1757  || m_editPoints->GetParent()->Type() == PCB_FP_ZONE_T )
1758  {
1759  isPoly = true;
1760  }
1761 
1762  else if( m_editPoints->GetParent()->Type() == PCB_SHAPE_T
1763  || m_editPoints->GetParent()->Type() == PCB_FP_SHAPE_T )
1764  {
1765  PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( m_editPoints->GetParent() );
1766  isPoly = shape->GetShape() == S_POLYGON;
1767  }
1768 
1769  if( line && isPoly )
1770  {
1772  }
1773  else
1774  {
1775  // Find a proper constraining point for 45 degrees mode
1778  }
1779  }
1780  else
1781  {
1782  m_altConstraint.reset();
1783  }
1784 }
EC_CONVERGING.
EDIT_LINE.
Definition: edit_points.h:226
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
EC_45DEGREE.
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:83
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
Definition: point_editor.h:86
class ZONE, a copper pour area
Definition: typeinfo.h:106
EDIT_POINT get45DegConstrainer() const
Returns a point that should be used as a constrainer for 45 degrees mode.
class ZONE, managed by a footprint
Definition: typeinfo.h:95
PCB_SHAPE_TYPE_T GetShape() const
Definition: pcb_shape.h:129
EDIT_POINT m_altConstrainer
Definition: point_editor.h:89
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:91

References get45DegConstrainer(), PCB_SHAPE::GetShape(), m_altConstrainer, m_altConstraint, m_editedPoint, m_editPoints, PCB_FP_SHAPE_T, PCB_FP_ZONE_T, PCB_SHAPE_T, PCB_ZONE_T, and S_POLYGON.

Referenced by OnSelectionChange().

◆ SetContextMenu()

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

Function SetContextMenu()

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

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

Definition at line 76 of file tool_interactive.cpp.

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

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

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

◆ setEditedPoint()

void POINT_EDITOR::setEditedPoint ( EDIT_POINT aPoint)
private

Sets the current point being edited. NULL means none.

Definition at line 1727 of file point_editor.cpp.

1728 {
1730 
1731  if( aPoint )
1732  {
1734  controls->ForceCursorPosition( true, aPoint->GetPosition() );
1735  controls->ShowCursor( true );
1736  }
1737  else
1738  {
1739  if( frame()->ToolStackIsEmpty() )
1740  controls->ShowCursor( false );
1741 
1742  controls->ForceCursorPosition( false );
1743  }
1744 
1745  m_editedPoint = aPoint;
1746 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetCurrentCursor(KICURSOR cursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_BASE_EDIT_FRAME * frame() const
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:71
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * controls() const
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75

References ARROW, PCB_TOOL_BASE::controls(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), EDIT_POINT::GetPosition(), TOOL_BASE::getViewControls(), m_editedPoint, EDA_DRAW_PANEL_GAL::SetCurrentCursor(), and KIGFX::VIEW_CONTROLS::ShowCursor().

Referenced by OnSelectionChange(), removeCorner(), and updateEditedPoint().

◆ SetIsFootprintEditor()

void PCB_TOOL_BASE::SetIsFootprintEditor ( bool  aEnabled)
inlineinherited

Function SetIsFootprintEditor()

Toggles edit footprint mode. When enabled, one may select parts of footprints individually (graphics, pads, etc.), so they can be modified.

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 104 of file pcb_tool_base.h.

104 { m_isFootprintEditor = aEnabled; }
bool m_isFootprintEditor

References PCB_TOOL_BASE::m_isFootprintEditor.

◆ setTransitions()

void POINT_EDITOR::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL_BASE.

Definition at line 2150 of file point_editor.cpp.

2151 {
2161 }
int OnSelectionChange(const TOOL_EVENT &aEvent)
Function OnSelected()
static const TOOL_EVENT SelectedEvent
Definition: actions.h:208
static TOOL_ACTION activatePointEditor
Definition: actions.h:168
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:209
static TOOL_ACTION changeEditMethod
Definition: actions.h:169
int removeCorner(const TOOL_EVENT &aEvent)
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:213
static TOOL_ACTION pointEditorAddCorner
Break outline (insert additional points to an edge)
Definition: pcb_actions.h:209
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
Definition: pcb_actions.h:212
static const TOOL_EVENT UninhibitSelectionEditing
Definition: actions.h:220
int changeEditMethod(const TOOL_EVENT &aEvent)
Change the edit method to an alternative method ( currently, arcs only )
static const TOOL_EVENT InhibitSelectionEditing
Used to inform tools that the selection should temporarily be non-editable
Definition: actions.h:219
int addCorner(const TOOL_EVENT &aEvent)
TOOL_ACTION handlers.
int modifiedSelection(const TOOL_EVENT &aEvent)

References ACTIONS::activatePointEditor, addCorner(), ACTIONS::changeEditMethod, changeEditMethod(), TOOL_INTERACTIVE::Go(), EVENTS::InhibitSelectionEditing, modifiedSelection(), OnSelectionChange(), PCB_ACTIONS::pointEditorAddCorner, PCB_ACTIONS::pointEditorRemoveCorner, removeCorner(), EVENTS::SelectedEvent, EVENTS::SelectedItemsModified, EVENTS::UninhibitSelectionEditing, and EVENTS::UnselectedEvent.

◆ updateEditedPoint()

void POINT_EDITOR::updateEditedPoint ( const TOOL_EVENT aEvent)
private

Updates which point is being edited.

Definition at line 354 of file point_editor.cpp.

355 {
356  EDIT_POINT* point;
357  EDIT_POINT* hovered = nullptr;
358 
359  if( aEvent.IsMotion() )
360  {
361  point = m_editPoints->FindPoint( aEvent.Position(), getView() );
362  hovered = point;
363  }
364  else if( aEvent.IsDrag( BUT_LEFT ) )
365  {
366  point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
367  }
368  else
369  {
370  point = m_editPoints->FindPoint( getViewControls()->GetCursorPosition(), getView() );
371  }
372 
373  if( hovered )
374  {
375  if( m_hoveredPoint != hovered )
376  {
377  if( m_hoveredPoint )
378  m_hoveredPoint->SetHover( false );
379 
380  m_hoveredPoint = hovered;
382  }
383  }
384  else if( m_hoveredPoint )
385  {
386  m_hoveredPoint->SetHover( false );
387  m_hoveredPoint = nullptr;
388  }
389 
390  if( m_editedPoint != point )
391  setEditedPoint( point );
392 }
bool IsMotion() const
Definition: tool_event.h:306
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:83
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:296
const VECTOR2D DragOrigin() const
Returns the point where dragging has started.
Definition: tool_event.h:280
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
EDIT_POINT * m_hoveredPoint
Definition: point_editor.h:77
void SetHover(bool aHover=true)
Definition: edit_points.h:186
EDIT_POINT.
Definition: edit_points.h:46
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75
void setEditedPoint(EDIT_POINT *aPoint)
Sets the current point being edited. NULL means none.
const VECTOR2D Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:274

References BUT_LEFT, TOOL_EVENT::DragOrigin(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_EVENT::IsDrag(), TOOL_EVENT::IsMotion(), m_editedPoint, m_editPoints, m_hoveredPoint, TOOL_EVENT::Position(), setEditedPoint(), and EDIT_POINT::SetHover().

Referenced by OnSelectionChange().

◆ updateItem()

void POINT_EDITOR::updateItem ( ) const
private

Updates item's points with edit points.

Definition at line 1045 of file point_editor.cpp.

1046 {
1047  EDA_ITEM* item = m_editPoints->GetParent();
1048 
1049  if( !item )
1050  return;
1051 
1052  switch( item->Type() )
1053  {
1054  case PCB_SHAPE_T:
1055  case PCB_FP_SHAPE_T:
1056  {
1057  PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
1058 
1059  switch( shape->GetShape() )
1060  {
1061  case S_SEGMENT:
1062  if( isModified( m_editPoints->Point( SEG_START ) ) )
1063  shape->SetStart( wxPoint( m_editPoints->Point( SEG_START ).GetPosition().x,
1064  m_editPoints->Point( SEG_START ).GetPosition().y ) );
1065 
1066  else if( isModified( m_editPoints->Point( SEG_END ) ) )
1067  shape->SetEnd( wxPoint( m_editPoints->Point( SEG_END ).GetPosition().x,
1068  m_editPoints->Point( SEG_END ).GetPosition().y ) );
1069 
1070  break;
1071 
1072  case S_RECT:
1073  {
1074  if( isModified( m_editPoints->Point( RECT_TOP_LEFT ) ) )
1075  {
1076  shape->SetStart((wxPoint) m_editPoints->Point( RECT_TOP_LEFT ).GetPosition() );
1077  }
1078  else if( isModified( m_editPoints->Point( RECT_TOP_RIGHT ) ) )
1079  {
1080  shape->SetStartY( m_editPoints->Point( RECT_TOP_RIGHT ).GetPosition().y );
1081  shape->SetEndX( m_editPoints->Point( RECT_TOP_RIGHT ).GetPosition().x );
1082  }
1083  else if( isModified( m_editPoints->Point( RECT_BOT_RIGHT ) ) )
1084  {
1085  shape->SetEnd((wxPoint) m_editPoints->Point( RECT_BOT_RIGHT ).GetPosition() );
1086  }
1087  else if( isModified( m_editPoints->Point( RECT_BOT_LEFT ) ) )
1088  {
1089  shape->SetStartX( m_editPoints->Point( RECT_BOT_LEFT ).GetPosition().x );
1090  shape->SetEndY( m_editPoints->Point( RECT_BOT_LEFT ).GetPosition().y );
1091  }
1092  }
1093  break;
1094 
1095  case S_ARC:
1096  {
1097  VECTOR2I center = m_editPoints->Point( ARC_CENTER ).GetPosition();
1098  VECTOR2I mid = m_editPoints->Point( ARC_MID ).GetPosition();
1099  VECTOR2I start = m_editPoints->Point( ARC_START ).GetPosition();
1100  VECTOR2I end = m_editPoints->Point( ARC_END ).GetPosition();
1101 
1102  if( isModified( m_editPoints->Point( ARC_CENTER ) ) )
1103  {
1104  wxPoint moveVector = wxPoint( center.x, center.y ) - shape->GetCenter();
1105  shape->Move( moveVector );
1106  }
1107  else if( isModified( m_editPoints->Point( ARC_MID ) ) )
1108  {
1109  const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition( false );
1110 
1111  if( m_altEditMethod )
1112  editArcMidKeepCenter( shape, center, start, mid, end, cursorPos );
1113  else
1114  editArcMidKeepEnpoints( shape, center, start, mid, end, cursorPos );
1115  }
1116  else if( isModified( m_editPoints->Point( ARC_START ) )
1117  || isModified( m_editPoints->Point( ARC_END ) ) )
1118  {
1119  const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition();
1120 
1121  if( m_altEditMethod )
1122  editArcEndpointKeepCenter( shape, center, start, mid, end, cursorPos );
1123  else
1124  editArcEndpointKeepTangent( shape, center, start, mid, end, cursorPos );
1125  }
1126  }
1127  break;
1128 
1129  case S_CIRCLE:
1130  {
1131  const VECTOR2I& center = m_editPoints->Point( CIRC_CENTER ).GetPosition();
1132  const VECTOR2I& end = m_editPoints->Point( CIRC_END ).GetPosition();
1133 
1134  if( isModified( m_editPoints->Point( CIRC_CENTER ) ) )
1135  {
1136  wxPoint moveVector = wxPoint( center.x, center.y ) - shape->GetCenter();
1137  shape->Move( moveVector );
1138  }
1139  else
1140  {
1141  shape->SetEnd( wxPoint( end.x, end.y ) );
1142  }
1143  }
1144  break;
1145 
1146  case S_POLYGON:
1147  {
1148  SHAPE_POLY_SET& outline = shape->GetPolyShape();
1149 
1150  for( int i = 0; i < outline.TotalVertices(); ++i )
1151  outline.SetVertex( i, m_editPoints->Point( i ).GetPosition() );
1152 
1153  for( unsigned i = 0; i < m_editPoints->LinesSize(); ++i )
1154  {
1155  if( !isModified( m_editPoints->Line( i ) ) )
1156  m_editPoints->Line( i ).SetConstraint( new EC_PERPLINE( m_editPoints->Line( i ) ) );
1157  }
1158 
1159  validatePolygon( outline );
1160  }
1161  break;
1162 
1163  case S_CURVE:
1164  if( isModified( m_editPoints->Point( BEZIER_CURVE_START ) ) )
1165  shape->SetStart( (wxPoint) m_editPoints->Point( BEZIER_CURVE_START ).GetPosition() );
1166  else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ) ) )
1167  shape->SetBezControl1( (wxPoint) m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition() );
1168  else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ) ) )
1169  shape->SetBezControl2( (wxPoint) m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition() );
1170  else if( isModified( m_editPoints->Point( BEZIER_CURVE_END ) ) )
1171  shape->SetEnd( (wxPoint) m_editPoints->Point( BEZIER_CURVE_END ).GetPosition() );
1172 
1173  shape->RebuildBezierToSegmentsPointsList( shape->GetWidth() );
1174  break;
1175 
1176  default: // suppress warnings
1177  break;
1178  }
1179 
1180  // Update relative coordinates for footprint shapes
1181  if( FP_SHAPE* fpShape = dyn_cast<FP_SHAPE*>( item ) )
1182  fpShape->SetLocalCoord();
1183 
1184  break;
1185  }
1186 
1187  case PCB_PAD_T:
1188  {
1189  PAD* pad = static_cast<PAD*>( item );
1190 
1191  switch( pad->GetShape() )
1192  {
1193  case PAD_SHAPE_CIRCLE:
1194  {
1195  wxPoint center = (wxPoint) m_editPoints->Point( CIRC_CENTER ).GetPosition();
1196  wxPoint end = (wxPoint) m_editPoints->Point( CIRC_END ).GetPosition();
1197 
1198  if( isModified( m_editPoints->Point( CIRC_CENTER ) ) )
1199  {
1200  wxPoint moveVector = center - pad->ShapePos();
1201  pad->SetOffset( pad->GetOffset() + moveVector );
1202  }
1203  else
1204  {
1205  int diameter = (int) EuclideanNorm( end - center ) * 2;
1206  pad->SetSize( wxSize( diameter, diameter ) );
1207  }
1208  }
1209  break;
1210 
1211  case PAD_SHAPE_OVAL:
1212  case PAD_SHAPE_TRAPEZOID:
1213  case PAD_SHAPE_RECT:
1214  case PAD_SHAPE_ROUNDRECT:
1216  {
1217  VECTOR2I topLeft = m_editPoints->Point( RECT_TOP_LEFT ).GetPosition();
1218  VECTOR2I topRight = m_editPoints->Point( RECT_TOP_RIGHT ).GetPosition();
1219  VECTOR2I botLeft = m_editPoints->Point( RECT_BOT_LEFT ).GetPosition();
1220  VECTOR2I botRight = m_editPoints->Point( RECT_BOT_RIGHT ).GetPosition();
1221 
1222  pinEditedCorner( getEditedPointIndex(), Mils2iu( 1 ), Mils2iu( 1 ), topLeft, topRight,
1223  botLeft, botRight,pad->GetPosition(), pad->GetDrillSize() );
1224 
1225  if( ( pad->GetOffset().x || pad->GetOffset().y )
1226  || ( pad->GetDrillSize().x && pad->GetDrillSize().y ) )
1227  {
1228  // Keep hole pinned at the current location; adjust the pad around the hole
1229 
1230  wxPoint center = pad->GetPosition();
1231  int dist[4];
1232 
1233  if( isModified( m_editPoints->Point( RECT_TOP_LEFT ) )
1234  || isModified( m_editPoints->Point( RECT_BOT_RIGHT ) ) )
1235  {
1236  dist[0] = center.x - m_editPoints->Point( RECT_TOP_LEFT ).GetPosition().x;
1237  dist[1] = center.y - m_editPoints->Point( RECT_TOP_LEFT ).GetPosition().y;
1238  dist[2] = m_editPoints->Point( RECT_BOT_RIGHT ).GetPosition().x - center.x;
1239  dist[3] = m_editPoints->Point( RECT_BOT_RIGHT ).GetPosition().y - center.y;
1240  }
1241  else
1242  {
1243  dist[0] = center.x - m_editPoints->Point( RECT_BOT_LEFT ).GetPosition().x;
1244  dist[1] = center.y - m_editPoints->Point( RECT_TOP_RIGHT ).GetPosition().y;
1245  dist[2] = m_editPoints->Point( RECT_TOP_RIGHT ).GetPosition().x - center.x;
1246  dist[3] = m_editPoints->Point( RECT_BOT_LEFT ).GetPosition().y - center.y;
1247  }
1248 
1249  wxSize padSize( dist[0] + dist[2], dist[1] + dist[3] );
1250  wxPoint deltaOffset( padSize.x / 2 - dist[2], padSize.y / 2 - dist[3] );
1251 
1252  if( pad->GetOrientation() == 900 || pad->GetOrientation() == 2700 )
1253  std::swap( padSize.x, padSize.y );
1254 
1255  RotatePoint( &deltaOffset, -pad->GetOrientation() );
1256 
1257  pad->SetSize( padSize );
1258  pad->SetOffset( -deltaOffset );
1259  }
1260  else
1261  {
1262  // Keep pad position at the center of the pad shape
1263 
1264  int left, top, right, bottom;
1265 
1266  if( isModified( m_editPoints->Point( RECT_TOP_LEFT ) )
1267  || isModified( m_editPoints->Point( RECT_BOT_RIGHT ) ) )
1268  {
1269  left = m_editPoints->Point( RECT_TOP_LEFT ).GetPosition().x;
1270  top = m_editPoints->Point( RECT_TOP_LEFT ).GetPosition().y;
1271  right = m_editPoints->Point( RECT_BOT_RIGHT ).GetPosition().x;
1272  bottom = m_editPoints->Point( RECT_BOT_RIGHT ).GetPosition().y;
1273  }
1274  else
1275  {
1276  left = m_editPoints->Point( RECT_BOT_LEFT ).GetPosition().x;
1277  top = m_editPoints->Point( RECT_TOP_RIGHT ).GetPosition().y;
1278  right = m_editPoints->Point( RECT_TOP_RIGHT ).GetPosition().x;
1279  bottom = m_editPoints->Point( RECT_BOT_LEFT ).GetPosition().y;
1280  }
1281 
1282  wxSize padSize( abs( right - left ), abs( bottom - top ) );
1283 
1284  if( pad->GetOrientation() == 900 || pad->GetOrientation() == 2700 )
1285  std::swap( padSize.x, padSize.y );
1286 
1287  pad->SetSize( padSize );
1288  pad->SetPosition( wxPoint( ( left + right ) / 2, ( top + bottom ) / 2 ) );
1289  }
1290  }
1291  break;
1292 
1293  default: // suppress warnings
1294  break;
1295  }
1296  }
1297  break;
1298 
1299  case PCB_FP_ZONE_T:
1300  case PCB_ZONE_T:
1301  {
1302  ZONE* zone = static_cast<ZONE*>( item );
1303  zone->ClearFilledPolysList();
1304  SHAPE_POLY_SET& outline = *zone->Outline();
1305 
1306  for( int i = 0; i < outline.TotalVertices(); ++i )
1307  {
1308  if( outline.CVertex( i ) != m_editPoints->Point( i ).GetPosition() )
1309  zone->SetNeedRefill( true );
1310 
1311  outline.SetVertex( i, m_editPoints->Point( i ).GetPosition() );
1312  }
1313 
1314  validatePolygon( outline );
1315  zone->HatchBorder();
1316  break;
1317  }
1318 
1319  case PCB_DIM_ALIGNED_T:
1320  {
1321  ALIGNED_DIMENSION* dimension = static_cast<ALIGNED_DIMENSION*>( item );
1322 
1323  // Check which point is currently modified and updated dimension's points respectively
1324  if( isModified( m_editPoints->Point( DIM_CROSSBARSTART ) ) )
1325  {
1326  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetStart() );
1327  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetStart() );
1328 
1329  if( featureLine.Cross( crossBar ) > 0 )
1330  dimension->SetHeight( -featureLine.EuclideanNorm() );
1331  else
1332  dimension->SetHeight( featureLine.EuclideanNorm() );
1333  }
1334 
1335  else if( isModified( m_editPoints->Point( DIM_CROSSBAREND ) ) )
1336  {
1337  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetEnd() );
1338  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetStart() );
1339 
1340  if( featureLine.Cross( crossBar ) > 0 )
1341  dimension->SetHeight( -featureLine.EuclideanNorm() );
1342  else
1343  dimension->SetHeight( featureLine.EuclideanNorm() );
1344  }
1345 
1346  else if( isModified( m_editPoints->Point( DIM_START ) ) )
1347  {
1348  dimension->SetStart( wxPoint( m_editedPoint->GetPosition().x,
1349  m_editedPoint->GetPosition().y ) );
1350  m_editPoints->Point( DIM_CROSSBARSTART ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARSTART ),
1351  m_editPoints->Point( DIM_START ) ) );
1352  m_editPoints->Point( DIM_CROSSBAREND ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBAREND ),
1353  m_editPoints->Point( DIM_END ) ) );
1354  }
1355 
1356  else if( isModified( m_editPoints->Point( DIM_END ) ) )
1357  {
1358  dimension->SetEnd( wxPoint( m_editedPoint->GetPosition().x,
1359  m_editedPoint->GetPosition().y ) );
1360  m_editPoints->Point( DIM_CROSSBARSTART ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARSTART ),
1361  m_editPoints->Point( DIM_START ) ) );
1362  m_editPoints->Point( DIM_CROSSBAREND ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBAREND ),
1363  m_editPoints->Point( DIM_END ) ) );
1364  }
1365 
1366  else if( isModified( m_editPoints->Point(DIM_TEXT ) ) )
1367  {
1368  // Force manual mode if we weren't already in it
1370  dimension->Text().SetPosition( wxPoint( m_editedPoint->GetPosition() ) );
1371  dimension->Update();
1372  }
1373 
1374  break;
1375  }
1376 
1377  case PCB_DIM_ORTHOGONAL_T:
1378  {
1379  ORTHOGONAL_DIMENSION* dimension = static_cast<ORTHOGONAL_DIMENSION*>( item );
1380 
1381  BOX2I bounds( dimension->GetStart(),
1382  dimension->GetEnd() - dimension->GetStart() );
1383 
1384  VECTOR2I direction( m_editedPoint->GetPosition() - bounds.Centre() );
1385  bool vert = std::abs( direction.y ) < std::abs( direction.x );
1386  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetStart() );
1387 
1388  if( isModified( m_editPoints->Point( DIM_CROSSBARSTART ) ) ||
1389  isModified( m_editPoints->Point( DIM_CROSSBAREND ) ) )
1390  {
1391  // Only change the orientation when we move outside the bounds
1392  if( !bounds.Contains( m_editedPoint->GetPosition() ) )
1393  {
1396  }
1397 
1398  vert = dimension->GetOrientation() == ORTHOGONAL_DIMENSION::DIR::VERTICAL;
1399 
1400  dimension->SetHeight( vert ? featureLine.x : featureLine.y );
1401  }
1402  else if( isModified( m_editPoints->Point( DIM_START ) ) )
1403  {
1404  dimension->SetStart( wxPoint( m_editedPoint->GetPosition().x,
1405  m_editedPoint->GetPosition().y ) );
1406  }
1407  else if( isModified( m_editPoints->Point( DIM_END ) ) )
1408  {
1409  dimension->SetEnd( wxPoint( m_editedPoint->GetPosition().x,
1410  m_editedPoint->GetPosition().y ) );
1411  }
1412  else if( isModified( m_editPoints->Point(DIM_TEXT ) ) )
1413  {
1414  // Force manual mode if we weren't already in it
1416  dimension->Text().SetPosition( wxPoint( m_editedPoint->GetPosition() ) );
1417  dimension->Update();
1418  }
1419 
1420  break;
1421  }
1422 
1423  case PCB_DIM_CENTER_T:
1424  {
1425  CENTER_DIMENSION* dimension = static_cast<CENTER_DIMENSION*>( item );
1426 
1427  if( isModified( m_editPoints->Point( DIM_START ) ) )
1428  {
1429  dimension->SetStart( wxPoint( m_editedPoint->GetPosition().x,
1430  m_editedPoint->GetPosition().y ) );
1431  }
1432  else if( isModified( m_editPoints->Point( DIM_END ) ) )
1433  {
1434  dimension->SetEnd( wxPoint( m_editedPoint->GetPosition().x,
1435  m_editedPoint->GetPosition().y ) );
1436  }
1437 
1438  dimension->Update();
1439 
1440  break;
1441  }
1442 
1443  case PCB_DIM_LEADER_T:
1444  {
1445  LEADER* dimension = static_cast<LEADER*>( item );
1446 
1447  if( isModified( m_editPoints->Point( DIM_START ) ) )
1448  {
1449  dimension->SetStart( wxPoint( m_editedPoint->GetPosition().x,
1450  m_editedPoint->GetPosition().y ) );
1451  }
1452  else if( isModified( m_editPoints->Point( DIM_END ) ) )
1453  {
1454  wxPoint newPoint( m_editedPoint->GetPosition().x, m_editedPoint->GetPosition().y );
1455  wxPoint delta = newPoint - dimension->GetEnd();
1456 
1457  dimension->SetEnd( newPoint );
1458  dimension->Text().SetPosition( dimension->Text().GetPosition() + delta );
1459  }
1460  else if( isModified( m_editPoints->Point( DIM_TEXT ) ) )
1461  {
1462  dimension->Text().SetPosition( wxPoint( m_editedPoint->GetPosition() ) );
1463  }
1464 
1465  dimension->Update();
1466 
1467  break;
1468  }
1469 
1470  default:
1471  break;
1472  }
1473 
1474  getView()->Update( item );
1475 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:134
int TotalVertices() const
Returns total number of vertices stored in the set.
void SetStartX(int x)
Definition: pcb_shape.h:149
void SetOffset(const wxPoint &aOffset)
Definition: pad.h:242
class ALIGNED_DIMENSION, a linear dimension (graphic item)
Definition: typeinfo.h:101
class LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:102
SHAPE_POLY_SET & GetPolyShape()
Definition: pcb_shape.h:259
virtual void SetPosition(const wxPoint &aPos) override
Definition: pcb_text.h:77
virtual void SetStart(const wxPoint &aPoint)
Definition: dimension.cpp:296
void SetBezControl2(const wxPoint &aPoint)
Definition: pcb_shape.h:134
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
class CENTER_DIMENSION, a center point marking (graphic item)
Definition: typeinfo.h:103
SHAPE_POLY_SET * Outline()
Definition: zone.h:318
int GetWidth() const
Definition: pcb_shape.h:118
virtual const wxPoint & GetStart() const
The dimension's origin is the first feature point for the dimension.
Definition: dimension.h:121
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
EC_PERPLINE.
void editArcMidKeepCenter(PCB_SHAPE *aArc, VECTOR2I aCenter, VECTOR2I aStart, VECTOR2I aMid, VECTOR2I aEnd, const VECTOR2I aCursor) const
Move the mid point of the arc, while keeping the angle.
void editArcEndpointKeepTangent(PCB_SHAPE *aArc, VECTOR2I aCenter, VECTOR2I aStart, VECTOR2I aMid, VECTOR2I aEnd, const VECTOR2I aCursor) const
Move an end point of the arc, while keeping the tangent at the other endpoint.
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
class PAD, a pad in a footprint
Definition: typeinfo.h:90
PAD_SHAPE_T GetShape() const
Definition: pad.h:159
bool isModified(const EDIT_POINT &aPoint) const
Returns true if aPoint is the currently modified point.
Definition: point_editor.h:133
void SetSize(const wxSize &aSize)
Definition: pad.h:225
void Update()
Updates the dimension's cached text and geometry.
Definition: dimension.h:146
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
segment with non rounded ends
Definition: board_item.h:53
EC_LINE.
void editArcEndpointKeepCenter(PCB_SHAPE *aArc, VECTOR2I aCenter, VECTOR2I aStart, VECTOR2I aMid, VECTOR2I aEnd, const VECTOR2I aCursor) const
Move an end point of the arc, while keeping radius, and the other point position.
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Function SetVertex Accessor function to set the position of a specific point.
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:83
virtual void Move(const wxPoint &aMoveVector) override
Function Move move this object.
Definition: pcb_shape.cpp:112
const wxPoint & GetOffset() const
Definition: pad.h:243
const wxSize & GetDrillSize() const
Definition: pad.h:236
wxPoint ShapePos() const
Definition: pcbnew/pad.cpp:609
void SetHeight(int aHeight)
Sets the distance from the feature points to the crossbar line.
Definition: dimension.cpp:529
void SetEndY(int y)
Definition: pcb_shape.h:159
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:71
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in a variety of units (the basic call r...
Definition: pad.h:334
virtual wxPoint GetPosition() const override
Definition: pcb_text.h:72
A leader is a dimension-like object pointing to a specific point.
Definition: dimension.h:470
void HatchBorder()
Function HatchBorder computes the hatch lines depending on the hatch parameters and stores it in the ...
Definition: zone.cpp:945
SHAPE_POLY_SET.
PCB_TEXT & Text()
Definition: dimension.h:209
wxPoint GetCenter() const override
Function GetCenter()
Definition: pcb_shape.cpp:343
DIR GetOrientation() const
Definition: dimension.h:441
bool m_altEditMethod
Definition: point_editor.h:95
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
Definition: dimension.h:407
Text placement is manually set by the user.
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
class ZONE, a copper pour area
Definition: typeinfo.h:106
void SetBezControl1(const wxPoint &aPoint)
Definition: pcb_shape.h:131
void SetOrientation(DIR aOrientation)
Sets the orientation of the dimension line (so, perpendicular to the feature lines)
Definition: dimension.h:440
void SetEndX(int x)
Definition: pcb_shape.h:160
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
void ClearFilledPolysList()
Function ClearFilledPolysList clears the list of filled polygons.
Definition: zone.h:628
int getEditedPointIndex() const
Definition: point_editor.h:121
bool validatePolygon(SHAPE_POLY_SET &aModified) const
Validates a polygon and displays a popup warning if invalid.
wxPoint GetPosition() const override
Definition: pad.h:167
void SetStart(const wxPoint &aStart)
Definition: pcb_shape.h:147
void SetPosition(const wxPoint &aPos) override
Definition: pad.h:161
class ZONE, managed by a footprint
Definition: typeinfo.h:95
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments Has me...
Definition: pcb_shape.cpp:317
ring
Definition: board_item.h:55
void SetStartY(int y)
Definition: pcb_shape.h:148
class ORTHOGONAL_DIMENSION, a linear dimension constrained to x/y
Definition: typeinfo.h:104
void SetNeedRefill(bool aNeedRefill)
Definition: zone.h:236
PCB_SHAPE_TYPE_T GetShape() const
Definition: pcb_shape.h:129
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
Definition: pad.h:59
For better understanding of the points that make a dimension:
Definition: dimension.h:329
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75
void SetTextPositionMode(DIM_TEXT_POSITION aMode)
Definition: dimension.h:178
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:91
Bezier Curve.
Definition: board_item.h:57
virtual void SetEnd(const wxPoint &aPoint)
Definition: dimension.cpp:303
virtual const wxPoint & GetEnd() const
Definition: dimension.h:124
void editArcMidKeepEnpoints(PCB_SHAPE *aArc, VECTOR2I aCenter, VECTOR2I aStart, VECTOR2I aMid, VECTOR2I aEnd, const VECTOR2I aCursor) const
Move the mid point of the arc, while keeping the two endpoints.
void SetEnd(const wxPoint &aEnd)
Definition: pcb_shape.h:158
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1513
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
static void pinEditedCorner(int aEditedPointIndex, int aMinWidth, int aMinHeight, VECTOR2I &aTopLeft, VECTOR2I &aTopRight, VECTOR2I &aBotLeft, VECTOR2I &aBotRight, VECTOR2I aHole, VECTOR2I aHoleSize)
Update the coordinates of 4 corners of a rectangle, according to pad constraints and the moved corner...
Marks the center of a circle or arc with a cross shape The size and orientation of the cross is adjus...
Definition: dimension.h:509

References ARC_CENTER, ARC_END, ARC_MID, ARC_START, BEZIER_CURVE_CONTROL_POINT1, BEZIER_CURVE_CONTROL_POINT2, BEZIER_CURVE_END, BEZIER_CURVE_START, CIRC_CENTER, CIRC_END, ZONE::ClearFilledPolysList(), SHAPE_POLY_SET::CVertex(), DIM_CROSSBAREND, DIM_CROSSBARSTART, DIM_END, DIM_START, DIM_TEXT, editArcEndpointKeepCenter(), editArcEndpointKeepTangent(), editArcMidKeepCenter(), editArcMidKeepEnpoints(), EuclideanNorm(), PCB_SHAPE::GetCenter(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PAD::GetDrillSize(), getEditedPointIndex(), DIMENSION_BASE::GetEnd(), PAD::GetOffset(), PAD::GetOrientation(), ORTHOGONAL_DIMENSION::GetOrientation(), PCB_SHAPE::GetPolyShape(), EDIT_POINT::GetPosition(), PCB_TEXT::GetPosition(), PAD::GetPosition(), PCB_SHAPE::GetShape(), PAD::GetShape(), DIMENSION_BASE::GetStart(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), PCB_SHAPE::GetWidth(), ZONE::HatchBorder(), ORTHOGONAL_DIMENSION::HORIZONTAL, isModified(), m_altEditMethod, m_editedPoint, m_editPoints, MANUAL, PCB_SHAPE::Move(), ZONE::Outline(), PAD_SHAPE_CHAMFERED_RECT, PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_FP_SHAPE_T, PCB_FP_ZONE_T, PCB_PAD_T, PCB_SHAPE_T, PCB_ZONE_T, pinEditedCorner(), PCB_SHAPE::RebuildBezierToSegmentsPointsList(), RECT_BOT_LEFT, RECT_BOT_RIGHT, RECT_TOP_LEFT, RECT_TOP_RIGHT, RotatePoint(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, SEG_END, SEG_START, PCB_SHAPE::SetBezControl1(), PCB_SHAPE::SetBezControl2(), DIMENSION_BASE::SetEnd(), PCB_SHAPE::SetEnd(), PCB_SHAPE::SetEndX(), PCB_SHAPE::SetEndY(), ALIGNED_DIMENSION::SetHeight(), ZONE::SetNeedRefill(), PAD::SetOffset(), ORTHOGONAL_DIMENSION::SetOrientation(), PCB_TEXT::SetPosition(), PAD::SetPosition(), PAD::SetSize(), DIMENSION_BASE::SetStart(), PCB_SHAPE::SetStart(), PCB_SHAPE::SetStartX(), PCB_SHAPE::SetStartY(), DIMENSION_BASE::SetTextPositionMode(), SHAPE_POLY_SET::SetVertex(), PAD::ShapePos(), DIMENSION_BASE::Text(), SHAPE_POLY_SET::TotalVertices(), EDA_ITEM::Type(), KIGFX::VIEW::Update(), DIMENSION_BASE::Update(), validatePolygon(), ORTHOGONAL_DIMENSION::VERTICAL, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by OnSelectionChange().

◆ updatePoints()

void POINT_EDITOR::updatePoints ( )
private

Updates edit points with item's points.

Definition at line 1517 of file point_editor.cpp.

1518 {
1519  if( !m_editPoints )
1520  return;
1521 
1522  EDA_ITEM* item = m_editPoints->GetParent();
1523 
1524  if( !item )
1525  return;
1526 
1527  switch( item->Type() )
1528  {
1529  case PCB_SHAPE_T:
1530  case PCB_FP_SHAPE_T:
1531  {
1532  const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( item );
1533 
1534  switch( shape->GetShape() )
1535  {
1536  case S_SEGMENT:
1537  m_editPoints->Point( SEG_START ).SetPosition( shape->GetStart() );
1538  m_editPoints->Point( SEG_END ).SetPosition( shape->GetEnd() );
1539  break;
1540 
1541  case S_RECT:
1542  m_editPoints->Point( RECT_TOP_LEFT ).SetPosition( shape->GetStart() );
1543  m_editPoints->Point( RECT_TOP_RIGHT ).SetPosition( shape->GetEnd().x,
1544  shape->GetStart().y );
1545  m_editPoints->Point( RECT_BOT_RIGHT ).SetPosition( shape->GetEnd() );
1546  m_editPoints->Point( RECT_BOT_LEFT ).SetPosition( shape->GetStart().x,
1547  shape->GetEnd().y );
1548  break;
1549 
1550  case S_ARC:
1551  m_editPoints->Point( ARC_CENTER ).SetPosition( shape->GetCenter() );
1552  m_editPoints->Point( ARC_START ).SetPosition( shape->GetArcStart() );
1553  m_editPoints->Point( ARC_MID ).SetPosition( shape->GetArcMid() );
1554  m_editPoints->Point( ARC_END ).SetPosition( shape->GetArcEnd() );
1555  break;
1556 
1557  case S_CIRCLE:
1558  m_editPoints->Point( CIRC_CENTER ).SetPosition( shape->GetCenter() );
1559  m_editPoints->Point( CIRC_END ).SetPosition( shape->GetEnd() );
1560  break;
1561 
1562  case S_POLYGON:
1563  {
1564  const auto& points = shape->BuildPolyPointsList();
1565 
1566  if( m_editPoints->PointsSize() != (unsigned) points.size() )
1567  {
1568  getView()->Remove( m_editPoints.get() );
1569  m_editedPoint = nullptr;
1570  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
1571  getView()->Add( m_editPoints.get() );
1572  }
1573  else
1574  {
1575  for( unsigned i = 0; i < points.size(); i++ )
1576  m_editPoints->Point( i ).SetPosition( points[i] );
1577  }
1578  break;
1579  }
1580 
1581  case S_CURVE:
1582  m_editPoints->Point( BEZIER_CURVE_START ).SetPosition( shape->GetStart() );
1583  m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).SetPosition( shape->GetBezControl1() );
1584  m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).SetPosition( shape->GetBezControl2() );
1585  m_editPoints->Point( BEZIER_CURVE_END ).SetPosition( shape->GetEnd() );
1586  break;
1587 
1588  default: // suppress warnings
1589  break;
1590  }
1591 
1592  break;
1593  }
1594 
1595  case PCB_PAD_T:
1596  {
1597  const PAD* pad = static_cast<const PAD*>( item );
1598  bool locked = pad->GetParent() && pad->GetParent()->PadsLocked();
1599  wxPoint shapePos = pad->ShapePos();
1600  wxPoint halfSize( pad->GetSize().x / 2, pad->GetSize().y / 2 );
1601 
1602  switch( pad->GetShape() )
1603  {
1604  case PAD_SHAPE_CIRCLE:
1605  {
1606  int target = locked ? 0 : 2;
1607 
1608  // Careful; pad shape is mutable...
1609  if( int( m_editPoints->PointsSize() ) != target )
1610  {
1611  getView()->Remove( m_editPoints.get() );
1612  m_editedPoint = nullptr;
1613  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
1614  getView()->Add( m_editPoints.get() );
1615  }
1616  else if( target == 2 )
1617  {
1618  VECTOR2I vec = m_editPoints->Point( CIRC_END ).GetPosition()
1619  - m_editPoints->Point( CIRC_CENTER ).GetPosition();
1620  vec.Resize( halfSize.x );
1621 
1622  m_editPoints->Point( CIRC_CENTER ).SetPosition( shapePos );
1623  m_editPoints->Point( CIRC_END ).SetPosition( vec + shapePos );
1624  }
1625  }
1626  break;
1627 
1628  case PAD_SHAPE_OVAL:
1629  case PAD_SHAPE_TRAPEZOID:
1630  case PAD_SHAPE_RECT:
1631  case PAD_SHAPE_ROUNDRECT:
1633  {
1634  // Careful; pad shape and orientation are mutable...
1635  int target = locked || (int) pad->GetOrientation() % 900 > 0 ? 0 : 4;
1636 
1637  if( int( m_editPoints->PointsSize() ) != target )
1638  {
1639  getView()->Remove( m_editPoints.get() );
1640  m_editedPoint = nullptr;
1641  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
1642  getView()->Add( m_editPoints.get() );
1643  }
1644  else if( target == 4 )
1645  {
1646  if( pad->GetOrientation() == 900 || pad->GetOrientation() == 2700 )
1647  std::swap( halfSize.x, halfSize.y );
1648 
1649  m_editPoints->Point( RECT_TOP_LEFT ).SetPosition( shapePos - halfSize );
1650  m_editPoints->Point( RECT_TOP_RIGHT ).SetPosition( wxPoint( shapePos.x + halfSize.x,
1651  shapePos.y - halfSize.y ) );
1652  m_editPoints->Point( RECT_BOT_RIGHT ).SetPosition( shapePos + halfSize );
1653  m_editPoints->Point( RECT_BOT_LEFT ).SetPosition( wxPoint( shapePos.x - halfSize.x,
1654  shapePos.y + halfSize.y ) );
1655  }
1656  }
1657  break;
1658 
1659  default: // suppress warnings
1660  break;
1661  }
1662  }
1663  break;
1664 
1665  case PCB_FP_ZONE_T:
1666  case PCB_ZONE_T:
1667  {
1668  ZONE* zone = static_cast<ZONE*>( item );
1669  const SHAPE_POLY_SET* outline = zone->Outline();
1670 
1671  if( m_editPoints->PointsSize() != (unsigned) outline->TotalVertices() )
1672  {
1673  getView()->Remove( m_editPoints.get() );
1674  m_editedPoint = nullptr;
1675  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
1676  getView()->Add( m_editPoints.get() );
1677  }
1678  else
1679  {
1680  for( int i = 0; i < outline->TotalVertices(); ++i )
1681  m_editPoints->Point( i ).SetPosition( outline->CVertex( i ) );
1682  }
1683 
1684  break;
1685  }
1686 
1687  case PCB_DIM_ALIGNED_T:
1688  case PCB_DIM_ORTHOGONAL_T:
1689  {
1690  const ALIGNED_DIMENSION* dimension = static_cast<const ALIGNED_DIMENSION*>( item );
1691 
1692  m_editPoints->Point( DIM_START ).SetPosition( dimension->GetStart() );
1693  m_editPoints->Point( DIM_END ).SetPosition( dimension->GetEnd() );
1694  m_editPoints->Point( DIM_TEXT ).SetPosition( dimension->Text().GetPosition() );
1695  m_editPoints->Point( DIM_CROSSBARSTART ).SetPosition( dimension->GetCrossbarStart() );
1696  m_editPoints->Point( DIM_CROSSBAREND ).SetPosition( dimension->GetCrossbarEnd() );
1697  break;
1698  }
1699 
1700  case PCB_DIM_CENTER_T:
1701  {
1702  const CENTER_DIMENSION* dimension = static_cast<const CENTER_DIMENSION*>( item );
1703 
1704  m_editPoints->Point( DIM_START ).SetPosition( dimension->GetStart() );
1705  m_editPoints->Point( DIM_END ).SetPosition( dimension->GetEnd() );
1706  break;
1707  }
1708 
1709  case PCB_DIM_LEADER_T:
1710  {
1711  const LEADER* dimension = static_cast<const LEADER*>( item );
1712 
1713  m_editPoints->Point( DIM_START ).SetPosition( dimension->GetStart() );
1714  m_editPoints->Point( DIM_END ).SetPosition( dimension->GetEnd() );
1715  m_editPoints->Point( DIM_TEXT ).SetPosition( dimension->Text().GetPosition() );
1716  break;
1717  }
1718 
1719  default:
1720  break;
1721  }
1722 
1723  getView()->Update( m_editPoints.get() );
1724 }
int TotalVertices() const
Returns total number of vertices stored in the set.
wxPoint GetArcEnd() const
Definition: pcb_shape.cpp:375
class ALIGNED_DIMENSION, a linear dimension (graphic item)
Definition: typeinfo.h:101
class LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:102
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Definition: pcb_shape.h:155
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
class CENTER_DIMENSION, a center point marking (graphic item)
Definition: typeinfo.h:103
SHAPE_POLY_SET * Outline()
Definition: zone.h:318
virtual const wxPoint & GetStart() const
The dimension's origin is the first feature point for the dimension.
Definition: dimension.h:121
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:357
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
class PAD, a pad in a footprint
Definition: typeinfo.h:90
PAD_SHAPE_T GetShape() const
Definition: pad.h:159
segment with non rounded ends
Definition: board_item.h:53
const wxPoint & GetCrossbarStart() const
Definition: dimension.h:358
const wxPoint & GetCrossbarEnd() const
Definition: dimension.h:360
wxPoint GetArcStart() const
Definition: pcb_shape.h:178
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:83
const std::vector< wxPoint > BuildPolyPointsList() const
Build and return the list of corners in a std::vector<wxPoint> It must be used only to convert the SH...
Definition: pcb_shape.cpp:1177
wxPoint ShapePos() const
Definition: pcbnew/pad.cpp:609
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in a variety of units (the basic call r...
Definition: pad.h:334
virtual wxPoint GetPosition() const override
Definition: pcb_text.h:72
A leader is a dimension-like object pointing to a specific point.
Definition: dimension.h:470
SHAPE_POLY_SET.
const wxSize & GetSize() const
Definition: pad.h:226
PCB_TEXT & Text()
Definition: dimension.h:209
wxPoint GetCenter() const override
Function GetCenter()
Definition: pcb_shape.cpp:343
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
Definition: pcb_shape.h:144
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
class ZONE, a copper pour area
Definition: typeinfo.h:106
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
FOOTPRINT * GetParent() const
VECTOR2< T > Resize(T aNewLength) const
Function Resize returns a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:392
const wxPoint & GetBezControl2() const
Definition: pcb_shape.h:135
class ZONE, managed by a footprint
Definition: typeinfo.h:95
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
ring
Definition: board_item.h:55
class ORTHOGONAL_DIMENSION, a linear dimension constrained to x/y
Definition: typeinfo.h:104
wxPoint GetArcMid() const
Definition: pcb_shape.cpp:393
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:327
PCB_SHAPE_TYPE_T GetShape() const
Definition: pcb_shape.h:129
Definition: pad.h:59
bool PadsLocked() const
Definition: footprint.h:334
For better understanding of the points that make a dimension:
Definition: dimension.h:329
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:75
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:91
Bezier Curve.
Definition: board_item.h:57
virtual const wxPoint & GetEnd() const
Definition: dimension.h:124
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem, SCH_BASE_FRAME *frame)
const wxPoint & GetBezControl1() const
Definition: pcb_shape.h:132
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1513
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
Marks the center of a circle or arc with a cross shape The size and orientation of the cross is adjus...
Definition: dimension.h:509

References KIGFX::VIEW::Add(), ARC_CENTER, ARC_END, ARC_MID, ARC_START, BEZIER_CURVE_CONTROL_POINT1, BEZIER_CURVE_CONTROL_POINT2, BEZIER_CURVE_END, BEZIER_CURVE_START, PCB_SHAPE::BuildPolyPointsList(), CIRC_CENTER, CIRC_END, SHAPE_POLY_SET::CVertex(), DIM_CROSSBAREND, DIM_CROSSBARSTART, DIM_END, DIM_START, DIM_TEXT, PCB_SHAPE::GetArcEnd(), PCB_SHAPE::GetArcMid(), PCB_SHAPE::GetArcStart(), PCB_SHAPE::GetBezControl1(), PCB_SHAPE::GetBezControl2(), PCB_SHAPE::GetCenter(), ALIGNED_DIMENSION::GetCrossbarEnd(), ALIGNED_DIMENSION::GetCrossbarStart(), DIMENSION_BASE::GetEnd(), PCB_SHAPE::GetEnd(), PAD::GetOrientation(), PAD::GetParent(), PCB_TEXT::GetPosition(), PCB_SHAPE::GetShape(), PAD::GetShape(), PAD::GetSize(), DIMENSION_BASE::GetStart(), PCB_SHAPE::GetStart(), TOOL_BASE::getView(), m_editedPoint, m_editPoints, EDIT_POINTS_FACTORY::Make(), ZONE::Outline(), PAD_SHAPE_CHAMFERED_RECT, PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, FOOTPRINT::PadsLocked(), PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_FP_SHAPE_T, PCB_FP_ZONE_T, PCB_PAD_T, PCB_SHAPE_T, PCB_ZONE_T, RECT_BOT_LEFT, RECT_BOT_RIGHT, RECT_TOP_LEFT, RECT_TOP_RIGHT, KIGFX::VIEW::Remove(), VECTOR2< T >::Resize(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, SEG_END, SEG_START, PAD::ShapePos(), DIMENSION_BASE::Text(), SHAPE_POLY_SET::TotalVertices(), EDA_ITEM::Type(), and KIGFX::VIEW::Update().

Referenced by addCorner(), modifiedSelection(), OnSelectionChange(), and removeCorner().

◆ validatePolygon()

bool POINT_EDITOR::validatePolygon ( SHAPE_POLY_SET aModified) const
private

Validates a polygon and displays a popup warning if invalid.

Parameters
aModifiedis the polygon to be checked.
Returns
True if polygon is valid.

Definition at line 1495 of file point_editor.cpp.

1496 {
1497  bool valid = !aPoly.IsSelfIntersecting();
1498 
1499  if( m_statusPopup )
1500  {
1501  if( valid )
1502  {
1503  m_statusPopup->Hide();
1504  }
1505  else
1506  {
1507  wxPoint p = wxGetMousePosition() + wxPoint( 20, 20 );
1508  m_statusPopup->Move( p );
1509  m_statusPopup->PopupFor( 1500 );
1510  }
1511  }
1512 
1513  return valid;
1514 }
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
Definition: point_editor.h:97

References SHAPE_POLY_SET::IsSelfIntersecting(), and m_statusPopup.

Referenced by removeCorner(), and updateItem().

◆ view()

◆ Wait()

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

Function Wait()

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

Definition at line 57 of file tool_interactive.cpp.

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

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

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

Member Data Documentation

◆ m_altConstrainer

EDIT_POINT POINT_EDITOR::m_altConstrainer
private

Definition at line 89 of file point_editor.h.

Referenced by setAltConstraint().

◆ m_altConstraint

std::shared_ptr<EDIT_CONSTRAINT<EDIT_POINT> > POINT_EDITOR::m_altConstraint
private

Definition at line 86 of file point_editor.h.

Referenced by OnSelectionChange(), Reset(), and setAltConstraint().

◆ m_altEditMethod

bool POINT_EDITOR::m_altEditMethod
private

Definition at line 95 of file point_editor.h.

Referenced by changeEditMethod(), and updateItem().

◆ m_editedPoint

EDIT_POINT* POINT_EDITOR::m_editedPoint
private

◆ m_editPoints

std::shared_ptr<EDIT_POINTS> POINT_EDITOR::m_editPoints
private

◆ m_hoveredPoint

EDIT_POINT* POINT_EDITOR::m_hoveredPoint
private

Definition at line 77 of file point_editor.h.

Referenced by OnSelectionChange(), and updateEditedPoint().

◆ m_isFootprintEditor

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

functions below are not yet implemented - their interface may change

Definition at line 108 of file tool_interactive.h.

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

◆ m_original

EDIT_POINT POINT_EDITOR::m_original
private

Original position for the current drag point.

Definition at line 80 of file point_editor.h.

Referenced by get45DegConstrainer(), and OnSelectionChange().

◆ m_refill

bool POINT_EDITOR::m_refill
private

Definition at line 92 of file point_editor.h.

Referenced by finishItem(), OnSelectionChange(), and Reset().

◆ m_selectionTool

SELECTION_TOOL* POINT_EDITOR::m_selectionTool
private

Selection tool used for obtaining selected items

Definition at line 72 of file point_editor.h.

Referenced by Init(), and OnSelectionChange().

◆ m_statusPopup

std::unique_ptr<STATUS_TEXT_POPUP> POINT_EDITOR::m_statusPopup
private

Definition at line 97 of file point_editor.h.

Referenced by Reset(), and validatePolygon().

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 214 of file tool_base.h.

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 219 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), 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(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_CONTROL::ClearAllLayers(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), LIB_EDIT_TOOL::editGraphicProperties(), PAD_TOOL::EditPad(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), finishItem(), SCH_LINE_WIRE_BUS_TOOL::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(), PCBNEW_CONTROL::GridSetOrigin(), GROUP_TOOL::Group(), EE_SELECTION_TOOL::GuessSelectionCandidates(), GERBVIEW_CONTROL::HighlightControl(), PCB_INSPECTION_TOOL::HighlightItem(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), LIB_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), GROUP_TOOL::Init(), CONVERT_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), LIB_CONTROL::Init(), PAD_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), Init(), POSITION_RELATIVE_TOOL::Init(), PCB_INSPECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::InspectClearance(), PCB_INSPECTION_TOOL::InspectConstraints(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), EDIT_TOOL::isRouterActive(), TOOL_BASE::IsToolActive(), GROUP_TOOL::LeaveGroup(), SCH_NAVIGATE_TOOL::LeaveSheet(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), LIB_CONTROL::OnDeMorgan(), COMMON_TOOLS::OnGridChanged(), OnSelectionChange(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCBNEW_CONTROL::Print(), GERBVIEW_CONTROL::Print(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), LIB_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), GERBVIEW_CONTROL::ReloadAllLayers(), EDIT_TOOL::Remove(), removeCorner(), GROUP_TOOL::RemoveFromGroup(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), EDA_3D_CONTROLLER::SetMaterial(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), EDA_3D_CONTROLLER::ToggleVisibility(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), LIB_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GROUP_TOOL::Ungroup(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PNS::TOOL_BASE::updateStartItem(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

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

Definition at line 218 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 211 of file tool_base.h.

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


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