KiCad PCB EDA Suite
POINT_EDITOR Class Reference

Class 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...
 
void setTransitions () override
 

Sets up handlers for various events.

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

Protected Types

enum  INTERACTIVE_PLACEMENT_OPTIONS {
  IPO_ROTATE = 1, IPO_FLIP = 2, IPO_PROPERTIES = 4, IPO_SINGLE_CLICK = 8,
  IPO_REPEAT = 16
}
 

Protected Member Functions

void doInteractiveItemPlacement (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_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const SELECTIONselection () const
 
SELECTIONselection ()
 
const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

TOOL_MENU m_menu
 Menu model displayed by the tool. More...
 
bool m_editModules
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

void 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 SHAPE_POLY_SET *aOriginal=nullptr) const
 Validates a polygon and restores it to its original version if available. 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...
 
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)
 

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_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
 
std::unique_ptr< STATUS_TEXT_POPUPm_statusPopup
 

Detailed Description

Class 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

Enumerator
IPO_ROTATE 
IPO_FLIP 
IPO_PROPERTIES 
IPO_SINGLE_CLICK 
IPO_REPEAT 

Definition at line 109 of file pcb_tool_base.h.

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 80 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ POINT_EDITOR()

POINT_EDITOR::POINT_EDITOR ( )

Definition at line 241 of file point_editor.cpp.

241  :
242  PCB_TOOL_BASE( "pcbnew.PointEditor" ),
243  m_selectionTool( NULL ),
244  m_editedPoint( NULL ),
245  m_original( VECTOR2I( 0, 0 ) ),
246  m_altConstrainer( VECTOR2I( 0, 0 ) ),
247  m_refill( false )
248 {
249 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: point_editor.h:66
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool_base.h:71
EDIT_POINT m_original
Original position for the current drag point.
Definition: point_editor.h:72
EDIT_POINT m_altConstrainer
Definition: point_editor.h:81
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:69

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 49 of file tool_interactive.cpp.

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

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

Referenced by AUTOPLACE_TOOL::autoplace(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), EDIT_TOOL::doCopyToClipboard(), SCH_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SCH_WIRE_BUS_TOOL::StartBus(), SCH_WIRE_BUS_TOOL::StartWire(), and SCH_WIRE_BUS_TOOL::UnfoldBus().

◆ addCorner()

int POINT_EDITOR::addCorner ( const TOOL_EVENT aEvent)
private

TOOL_ACTION handlers.

Definition at line 993 of file point_editor.cpp.

994 {
995  if( !m_editPoints )
996  return 0;
997 
998  EDA_ITEM* item = m_editPoints->GetParent();
999  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1000  const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition();
1001 
1002  // called without an active edited polygon
1003  if( !item || !canAddCorner( *item ) )
1004  return 0;
1005 
1006  DRAWSEGMENT* graphicItem = dynamic_cast<DRAWSEGMENT*>( item );
1007  BOARD_COMMIT commit( frame );
1008 
1009  if( item->Type() == PCB_ZONE_AREA_T ||
1010  ( graphicItem && graphicItem->GetShape() == S_POLYGON ) )
1011  {
1012  unsigned int nearestIdx = 0;
1013  unsigned int nextNearestIdx = 0;
1014  unsigned int nearestDist = INT_MAX;
1015  unsigned int firstPointInContour = 0;
1016  SHAPE_POLY_SET* zoneOutline;
1017 
1018  if( item->Type() == PCB_ZONE_AREA_T )
1019  {
1020  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
1021  zoneOutline = zone->Outline();
1022  zone->SetNeedRefill( true );
1023  }
1024  else
1025  zoneOutline = &( graphicItem->GetPolyShape() );
1026 
1027  commit.Modify( item );
1028 
1029  // Search the best outline segment to add a new corner
1030  // and therefore break this segment into two segments
1031 
1032  // Object to iterate through the corners of the outlines (main contour and its holes)
1033  SHAPE_POLY_SET::ITERATOR iterator = zoneOutline->Iterate( 0,
1034  zoneOutline->OutlineCount()-1, /* IterateHoles */ true );
1035  int curr_idx = 0;
1036 
1037  // Iterate through all the corners of the outlines and search the best segment
1038  for( ; iterator; iterator++, curr_idx++ )
1039  {
1040  int jj = curr_idx+1;
1041 
1042  if( iterator.IsEndContour() )
1043  { // We reach the last point of the current contour (main or hole)
1044  jj = firstPointInContour;
1045  firstPointInContour = curr_idx+1; // Prepare next contour analysis
1046  }
1047 
1048  SEG curr_segment( zoneOutline->Vertex( curr_idx ), zoneOutline->Vertex( jj ) );
1049 
1050  unsigned int distance = curr_segment.Distance( cursorPos );
1051 
1052  if( distance < nearestDist )
1053  {
1054  nearestDist = distance;
1055  nearestIdx = curr_idx;
1056  nextNearestIdx = jj;
1057  }
1058  }
1059 
1060  // Find the point on the closest segment
1061  VECTOR2I sideOrigin = zoneOutline->Vertex( nearestIdx );
1062  VECTOR2I sideEnd = zoneOutline->Vertex( nextNearestIdx );
1063  SEG nearestSide( sideOrigin, sideEnd );
1064  VECTOR2I nearestPoint = nearestSide.NearestPoint( cursorPos );
1065 
1066  // Do not add points that have the same coordinates as ones that already belong to polygon
1067  // instead, add a point in the middle of the side
1068  if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
1069  nearestPoint = ( sideOrigin + sideEnd ) / 2;
1070 
1071  zoneOutline->InsertVertex( nextNearestIdx, nearestPoint );
1072 
1073  // We re-hatch the filled zones but not polygons
1074  if( item->Type() == PCB_ZONE_AREA_T )
1075  static_cast<ZONE_CONTAINER*>( item )->Hatch();
1076 
1077 
1078  commit.Push( _( "Add a zone corner" ) );
1079  }
1080 
1081  else if( graphicItem && graphicItem->GetShape() == S_SEGMENT )
1082  {
1083  commit.Modify( graphicItem );
1084 
1085  SEG seg( graphicItem->GetStart(), graphicItem->GetEnd() );
1086  VECTOR2I nearestPoint = seg.NearestPoint( cursorPos );
1087 
1088  // Move the end of the line to the break point..
1089  graphicItem->SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) );
1090 
1091  // and add another one starting from the break point
1092  DRAWSEGMENT* newSegment;
1093 
1094  if( item->Type() == PCB_MODULE_EDGE_T )
1095  {
1096  EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( graphicItem );
1097  assert( edge->GetParent()->Type() == PCB_MODULE_T );
1098  newSegment = new EDGE_MODULE( *edge );
1099  }
1100  else
1101  {
1102  newSegment = new DRAWSEGMENT( *graphicItem );
1103  }
1104 
1105  newSegment->ClearSelected();
1106  newSegment->SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
1107  newSegment->SetEnd( wxPoint( seg.B.x, seg.B.y ) );
1108 
1109  commit.Add( newSegment );
1110  commit.Push( _( "Split segment" ) );
1111  }
1112 
1113  updatePoints();
1114  return 0;
1115 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
int OutlineCount() const
Returns the number of outlines in the set
bool IsEndContour() const
Function IsEndContour.
void ClearSelected()
Definition: base_struct.h:237
STROKE_T GetShape() const
polygon (not yet used for tracks, but could be in microwave apps)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:100
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:260
usual segment : line with rounded ends
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...
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
VECTOR2I & Vertex(int aIndex, int aOutline, int aHole)
Returns the index-th vertex in a given hole outline within a given outline
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:75
class MODULE, a footprint
Definition: typeinfo.h:89
Class SHAPE_POLY_SET.
SHAPE_POLY_SET & GetPolyShape()
PCB_EDIT_FRAME * frame() const
void SetStart(const wxPoint &aStart)
Definition: seg.h:36
Common, abstract interface for edit frames.
Class ITERATOR_TEMPLATE.
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
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
void updatePoints()
Updates edit points with item's points.
void SetEnd(const wxPoint &aEnd)
void InsertVertex(int aGlobalIndex, VECTOR2I aNewVertex)
Function InsertVertex Adds a vertex in the globally indexed position aGlobalIndex.
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
BOARD_ITEM_CONTAINER * GetParent() const
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
void SetNeedRefill(bool aNeedRefill)
Definition: class_zone.h:191

References COMMIT::Add(), canAddCorner(), EDA_ITEM::ClearSelected(), distance(), PCB_TOOL_BASE::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), DRAWSEGMENT::GetEnd(), BOARD_ITEM::GetParent(), DRAWSEGMENT::GetPolyShape(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::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_CONTAINER::Outline(), SHAPE_POLY_SET::OutlineCount(), PCB_MODULE_EDGE_T, PCB_MODULE_T, PCB_ZONE_AREA_T, BOARD_COMMIT::Push(), S_POLYGON, S_SEGMENT, DRAWSEGMENT::SetEnd(), ZONE_CONTAINER::SetNeedRefill(), DRAWSEGMENT::SetStart(), EDA_ITEM::Type(), updatePoints(), and SHAPE_POLY_SET::Vertex().

Referenced by setTransitions().

◆ addCornerCondition()

bool POINT_EDITOR::addCornerCondition ( const SELECTION aSelection)
staticprivate

Condition to display "Create corner" context menu entry.

Definition at line 925 of file point_editor.cpp.

926 {
927  if( aSelection.Size() != 1 )
928  return false;
929 
930  const EDA_ITEM* item = aSelection.Front();
931 
932  return ( item != nullptr ) && canAddCorner( *item );
933 }
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:125
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
EDA_ITEM * Front() const
Definition: selection.h:155

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

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

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

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 140 of file pcb_tool_base.h.

140 { return getModel<BOARD>(); }

Referenced by PCBNEW_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), EDIT_TOOL::changeTrackWidthOnClick(), PCB_EDITOR_CONTROL::ClearHighlight(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), EDIT_TOOL::doCopyToClipboard(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), MODULE_EDITOR_TOOLS::EnumeratePads(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), finishItem(), SELECTION_TOOL::getCollectorsGuide(), PCBNEW_CONTROL::GraphicDisplayMode(), PAD_TOOL::haveFootprints(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCB_TOOL_BASE::module(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PasteItemsFromClipboard(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), SELECTION_TOOL::RebuildSelection(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectAllItemsConnectedToItem(), SELECTION_TOOL::selectAllItemsConnectedToTrack(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectPoint(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), PCBNEW_CONTROL::TrackDisplayMode(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCBNEW_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), ZONE_FILLER_TOOL::ZoneFillAll(), 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 913 of file point_editor.cpp.

914 {
915  const auto type = aItem.Type();
916 
917  // Works only for zones and line segments
918  return type == PCB_ZONE_AREA_T ||
919  ( ( type == PCB_LINE_T || type == PCB_MODULE_EDGE_T ) &&
920  ( static_cast<const DRAWSEGMENT&>( aItem ).GetShape() == S_SEGMENT ||
921  static_cast<const DRAWSEGMENT&>( aItem ).GetShape() == S_POLYGON ) );
922 }
polygon (not yet used for tracks, but could be in microwave apps)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:100
usual segment : line with rounded ends
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

References PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_ZONE_AREA_T, S_POLYGON, S_SEGMENT, and EDA_ITEM::Type().

Referenced by addCorner(), and addCornerCondition().

◆ canvas()

◆ controls()

◆ displayOptions()

◆ doInteractiveItemPlacement()

void PCB_TOOL_BASE::doInteractiveItemPlacement ( 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 39 of file pcb_tool_base.cpp.

42 {
43  using namespace std::placeholders;
44  std::unique_ptr<BOARD_ITEM> newItem;
45 
46  Activate();
47 
48  BOARD_COMMIT commit( frame() );
49 
51 
52  // do not capture or auto-pan until we start placing an item
53  controls()->ShowCursor( true );
54  controls()->SetSnapping( true );
55 
56  // Add a VIEW_GROUP that serves as a preview for the new item
57  SELECTION preview;
58  view()->Add( &preview );
59 
60  aPlacer->m_board = board();
61  aPlacer->m_frame = frame();
62  aPlacer->m_modifiers = 0;
63 
64  if( aOptions & IPO_SINGLE_CLICK && !( aOptions & IPO_PROPERTIES ) )
65  {
66  VECTOR2I cursorPos = controls()->GetCursorPosition();
67 
68  newItem = aPlacer->CreateItem();
69 
70  if( newItem )
71  {
72  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
73  preview.Add( newItem.get() );
74  }
75  }
76 
77  // Main loop: keep receiving events
78  while( OPT_TOOL_EVENT evt = Wait() )
79  {
80  VECTOR2I cursorPos = controls()->GetCursorPosition();
81  aPlacer->m_modifiers = evt->Modifier();
82 
84  {
85  if( newItem )
86  {
87  // Delete the old item and have another try
88  newItem = nullptr;
89 
90  preview.Clear();
91 
92  if( aOptions & IPO_SINGLE_CLICK )
93  break;
94 
95  controls()->SetAutoPan( false );
96  controls()->CaptureCursor( false );
97  controls()->ShowCursor( true );
98  }
99  else
100  {
101  break;
102  }
103 
104  if( evt->IsActivate() ) // now finish unconditionally
105  break;
106  }
107  else if( evt->IsClick( BUT_LEFT ) )
108  {
109  if( !newItem )
110  {
111  // create the item if possible
112  newItem = aPlacer->CreateItem();
113 
114  // no item created, so wait for another click
115  if( !newItem )
116  continue;
117 
118  controls()->CaptureCursor( true );
119  controls()->SetAutoPan( true );
120 
121  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
122 
123  preview.Add( newItem.get() );
124 
125  if( newItem->Type() == PCB_MODULE_T )
126  {
127  auto module = dyn_cast<MODULE*>( newItem.get() );
128 
129  // modules have more drawable parts
130  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
131  }
132  }
133  else
134  {
135  auto oldFlags = newItem->GetFlags();
136  newItem->ClearFlags();
137 
138  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
139  {
140  newItem->SetFlags( oldFlags );
141  continue;
142  }
143 
144  preview.Remove( newItem.get() );
145 
146  if( newItem->Type() == PCB_MODULE_T )
147  {
148  auto module = dyn_cast<MODULE*>( newItem.get() );
149  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
150  }
151 
152  newItem.release();
153  commit.Push( aCommitMessage );
154 
155  controls()->CaptureCursor( false );
156  controls()->SetAutoPan( false );
157  controls()->ShowCursor( true );
158 
159  if( !( aOptions & IPO_REPEAT ) )
160  break;
161 
162  if( aOptions & IPO_SINGLE_CLICK && !( aOptions & IPO_PROPERTIES ) )
163  {
165 
166  newItem = aPlacer->CreateItem();
167 
168  if( newItem )
169  {
170  newItem->SetPosition( wxPoint( pos.x, pos.y ) );
171  preview.Add( newItem.get() );
172  }
173  }
174  }
175  }
176  else if( evt->IsClick( BUT_RIGHT ) )
177  {
179  }
180  else if( newItem && evt->Category() == TC_COMMAND )
181  {
182  /*
183  * Handle any events that can affect the item as we move
184  * it around, eg rotate and flip
185  */
186 
187  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
188  {
189  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
190  newItem->Rotate( newItem->GetPosition(), rotationAngle );
191  view()->Update( &preview );
192  }
193  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
194  {
195  newItem->Flip( newItem->GetPosition() );
196  view()->Update( &preview );
197  }
198  }
199 
200  else if( newItem && evt->IsMotion() )
201  {
202  // track the cursor
203  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
204  aPlacer->SnapItem( newItem.get() );
205 
206  // Show a preview of the item
207  view()->Update( &preview );
208  }
209  }
210 
211  view()->Remove( &preview );
212 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
Menu model displayed by the tool.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:93
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Function RunOnChildren.
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
BOARD * board() const
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:91
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
PCB_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:58
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:74
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:144
virtual void SnapItem(BOARD_ITEM *aItem)
class MODULE, a footprint
Definition: typeinfo.h:89
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
KIGFX::PCB_VIEW * view() const
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
Definition: tool_event.cpp:177
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
PCB_EDIT_FRAME * frame() const
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:99
KIGFX::VIEW_CONTROLS * controls() const
MODULE * module() const
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:58
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
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:85

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), 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(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_PROPERTIES, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, INTERACTIVE_PLACER_BASE::m_frame, PCB_TOOL_BASE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, PCB_TOOL_BASE::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), BOARD_COMMIT::Push(), KIGFX::PCB_VIEW::Remove(), KIGFX::VIEW_GROUP::Remove(), SELECTION::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, KIGFX::PCB_VIEW::Update(), PCB_TOOL_BASE::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ EditingModules()

bool PCB_TOOL_BASE::EditingModules ( ) const
inlineinherited

◆ evActivate()

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

functions below are not yet implemented - their interface may change

◆ evButtonDown()

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

◆ evButtonUp()

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

◆ evClick()

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

◆ evCommand() [1/2]

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

◆ evCommand() [2/2]

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

◆ evDrag()

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

◆ evMotion()

const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited

◆ finishItem()

void POINT_EDITOR::finishItem ( )
private

Applies the last changes to the edited item.

Definition at line 645 of file point_editor.cpp.

646 {
647  auto item = m_editPoints->GetParent();
648 
649  if( !item )
650  return;
651 
652  if( item->Type() == PCB_ZONE_AREA_T )
653  {
654  auto zone = static_cast<ZONE_CONTAINER*>( item );
655 
656  if( zone->IsFilled() && m_refill && zone->NeedRefill() )
657  {
658  ZONE_FILLER filler( board() );
659  // A progress reporter can be usefull. However it works fine only on Windows
660  // so enable it only on Windows.
661  // On Linux, the filled areas are incorrectly shown: the insulated islands
662  // remain displayed, although they are removed from the actual filled areas list
663  //
664  // Fix me: try to make it working on Linux.
665  //
666  #ifdef __WINDOWS__
667  WX_PROGRESS_REPORTER reporter( getEditFrame<PCB_BASE_FRAME>(), _( "Refill Zones" ), 4 );
668  filler.SetProgressReporter( &reporter );
669  #endif
670  filler.Fill( { zone } );
671  }
672  }
673 }
BOARD * board() const
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:100
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:75

References PCB_TOOL_BASE::board(), ZONE_FILLER::Fill(), m_editPoints, m_refill, PCB_ZONE_AREA_T, and ZONE_FILLER::SetProgressReporter().

Referenced by OnSelectionChange().

◆ frame()

PCB_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 139 of file pcb_tool_base.h.

139 { return getEditFrame<PCB_EDIT_FRAME>(); }

Referenced by addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), EDIT_TOOL::changeTrackWidthOnClick(), PNS::TOOL_BASE::checkSnap(), PCB_EDITOR_CONTROL::ClearHighlight(), PAD_TOOL::copyPadSettings(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL_BASE::displayOptions(), EDIT_TOOL::doCopyToClipboard(), 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(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), ROUTER_TOOL::finishInteractive(), PAD_TOOL::Init(), EDIT_TOOL::Init(), SELECTION_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MeasureTool(), OnSelectionChange(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PasteItemsFromClipboard(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), MODULE_EDITOR_TOOLS::PlacePad(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::RouteDiffPair(), ROUTER_TOOL::RouteSingleTrace(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ROUTER_TOOL::SettingsDialog(), ROUTER_TOOL::switchLayerOnViaPlacement(), LENGTH_TUNER_TOOL::TuneDiffPair(), LENGTH_TUNER_TOOL::TuneDiffPairSkew(), LENGTH_TUNER_TOOL::TuneSingleTrace(), updateItem(), 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 851 of file point_editor.cpp.

852 {
853  EDA_ITEM* item = m_editPoints->GetParent();
854 
855  switch( item->Type() )
856  {
857  case PCB_LINE_T:
858  case PCB_MODULE_EDGE_T:
859  {
860  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
861  {
862  switch( segment->GetShape() )
863  {
864  case S_SEGMENT:
865  return *( m_editPoints->Next( *m_editedPoint ) ); // select the other end of line
866 
867  case S_ARC:
868  case S_CIRCLE:
869  return m_editPoints->Point( CIRC_CENTER );
870 
871  default: // suppress warnings
872  break;
873  }
874  }
875 
876  break;
877  }
878 
879  case PCB_DIMENSION_T:
880  {
881  // Constraint for crossbar
882  if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
883  return m_editPoints->Point( DIM_FEATUREDO );
884 
885  else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
886  return m_editPoints->Point( DIM_FEATUREGO );
887 
888  else
889  return EDIT_POINT( m_editedPoint->GetPosition() ); // no constraint
890 
891  break;
892  }
893 
894  default:
895  break;
896  }
897 
898  // In any other case we may align item to its original position
899  return m_original;
900 }
STROKE_T GetShape() const
usual segment : line with rounded ends
bool isModified(const EDIT_POINT &aPoint) const
Returns true if aPoint is the currently modified point.
Definition: point_editor.h:112
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:75
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:68
Arcs (with rounded ends)
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:98
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
EDIT_POINT m_original
Original position for the current drag point.
Definition: point_editor.h:72
Class EDIT_POINT.
Definition: edit_points.h:46
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:69
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

References CIRC_CENTER, DIM_FEATUREDO, DIM_FEATUREGO, EDIT_POINT::GetPosition(), DRAWSEGMENT::GetShape(), isModified(), m_editedPoint, m_editPoints, m_original, PCB_DIMENSION_T, PCB_LINE_T, PCB_MODULE_EDGE_T, S_ARC, S_CIRCLE, S_SEGMENT, and EDA_ITEM::Type().

Referenced by setAltConstraint().

◆ getEditFrame()

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

Function getEditFrame()

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

Definition at line 188 of file tool_base.h.

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

References TOOL_BASE::getEditFrameInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), and TOOL_SETTINGS::getConfigBase().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

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

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 144 of file tool_base.h.

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

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), ACTION_MENU::onMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ getModel()

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 199 of file tool_base.h.

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

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Function GetName() Returns the name of the tool.

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

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

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

References TOOL_BASE::m_toolName.

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

◆ GetSettings()

TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

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

References TOOL_BASE::m_toolSettings.

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

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

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

References TOOL_BASE::m_type.

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

◆ getView()

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

Function getView()

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

Returns
The instance of VIEW.

Definition at line 35 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), EE_SELECTION_TOOL::clearSelection(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), COMMON_TOOLS::doGridPreset(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), EE_POINT_EDITOR::Main(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), removeCorner(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), COMMON_TOOLS::ToggleGrid(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), updateEditedPoint(), PCBNEW_CONTROL::updateGrid(), EE_POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_TOOL_BASE::view(), COMMON_TOOLS::ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), CVPCB_SELECTION_TOOL::~CVPCB_SELECTION_TOOL(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

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

Function getViewControls()

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

Returns
The instance of VIEW_CONTROLS.

Definition at line 41 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCorner(), addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), COMMON_TOOLS::CursorControl(), SCH_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), SCH_WIRE_BUS_TOOL::finishSegments(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), OnSelectionChange(), ROUTER_TOOL::performDragging(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), Reset(), DRAWING_TOOL::Reset(), CVPCB_CONTROL::ResetCoords(), GERBVIEW_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), EE_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), setEditedPoint(), LIB_MOVE_TOOL::updateModificationPoint(), SCH_MOVE_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

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

Function Go()

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

Definition at line 135 of file tool_interactive.h.

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

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), LIB_CONTROL::setTransitions(), LIB_PIN_TOOL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), LIB_MOVE_TOOL::setTransitions(), setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), CVPCB_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), SCH_WIRE_BUS_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), EE_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), SELECTION_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ Init()

bool POINT_EDITOR::Init ( )
overridevirtual

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

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

Reimplemented from PCB_TOOL_BASE.

Definition at line 265 of file point_editor.cpp.

266 {
267  // Find the selection tool, so they can cooperate
269 
270  wxASSERT_MSG( m_selectionTool, _( "pcbnew.InteractiveSelection tool is not available" ) );
271 
272  auto& menu = m_selectionTool->GetToolMenu().GetMenu();
275  std::bind( &POINT_EDITOR::removeCornerCondition, this, _1 ) );
276 
277  return true;
278 }
Class SELECTION_TOOL.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
TOOL_MENU & GetToolMenu()
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
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:189
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
Definition: pcb_actions.h:192
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: point_editor.h:66
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
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(), SELECTION_TOOL::GetToolMenu(), m_selectionTool, TOOL_BASE::m_toolMgr, PCB_ACTIONS::pointEditorAddCorner, PCB_ACTIONS::pointEditorRemoveCorner, and removeCornerCondition().

◆ isModified()

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

Returns true if aPoint is the currently modified point.

Definition at line 112 of file point_editor.h.

113  {
114  return m_editedPoint == &aPoint;
115  }
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:69

References m_editedPoint.

Referenced by get45DegConstrainer(), and updateItem().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

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

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

◆ modifiedSelection()

int POINT_EDITOR::modifiedSelection ( const TOOL_EVENT aEvent)
private

Definition at line 1205 of file point_editor.cpp.

1206 {
1207  m_refill = true; // zone has been modified outside the point editor tool
1208  updatePoints();
1209  return 0;
1210 }
void updatePoints()
Updates edit points with item's points.

References m_refill, and updatePoints().

Referenced by setTransitions().

◆ module()

◆ OnSelectionChange()

int POINT_EDITOR::OnSelectionChange ( const TOOL_EVENT aEvent)

Function OnSelected()

Change selection event handler.

Definition at line 299 of file point_editor.cpp.

300 {
301  if( !m_selectionTool )
302  return 0;
303 
305 
306  if( selection.Size() != 1 )
307  return 0;
308 
309  Activate();
310 
312  KIGFX::VIEW* view = getView();
313  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
314 
315  controls->ShowCursor( true );
316 
317  GRID_HELPER grid( editFrame );
318  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
319 
320  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
321 
322  if( !m_editPoints )
323  return 0;
324 
325  view->Add( m_editPoints.get() );
326  setEditedPoint( nullptr );
327  m_refill = false;
328  bool modified = false;
329  bool revert = false;
330 
331  BOARD_COMMIT commit( editFrame );
332  LSET snapLayers = item->GetLayerSet();
333 
334  if( item->Type() == PCB_DIMENSION_T )
335  snapLayers = LSET::AllLayersMask();
336 
337  // Main loop: keep receiving events
338  while( OPT_TOOL_EVENT evt = Wait() )
339  {
340  if( revert )
341  break;
342 
343  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
344  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
345  controls->SetSnapping( !evt->Modifier( MD_ALT ) );
346 
347  if( !m_editPoints ||
348  evt->Matches( EVENTS::ClearedEvent ) ||
349  evt->Matches( EVENTS::UnselectedEvent ) ||
350  evt->Matches( EVENTS::SelectedEvent ) )
351  {
352  break;
353  }
354 
355  if ( !modified )
356  updateEditedPoint( *evt );
357 
358  if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
359  {
360  if( !modified )
361  {
362  commit.StageItems( selection, CHT_MODIFY );
363 
364  controls->ForceCursorPosition( false );
365  m_original = *m_editedPoint; // Save the original position
366  controls->SetAutoPan( true );
367  modified = true;
368  grid.SetAuxAxes( true, m_original.GetPosition(), true );
369  }
370 
371  //TODO: unify the constraints to solve simultaneously instead of sequentially
372  m_editedPoint->SetPosition( grid.BestSnapAnchor( evt->Position(),
373  snapLayers, { item } ) );
374  bool enableAltConstraint = !!evt->Modifier( MD_CTRL );
375 
376  if( enableAltConstraint != (bool) m_altConstraint ) // alternative constraint
377  setAltConstraint( enableAltConstraint );
378 
379  if( m_altConstraint )
380  m_altConstraint->Apply();
381  else
383 
384  m_editedPoint->SetPosition( grid.BestSnapAnchor( m_editedPoint->GetPosition(),
385  snapLayers, { item } ) );
386 
387  updateItem();
388  updatePoints();
389  }
390 
391  else if( evt->IsMouseUp( BUT_LEFT ) )
392  {
393  controls->SetAutoPan( false );
394  setAltConstraint( false );
395 
396  if( modified )
397  {
398  commit.Push( _( "Drag a corner" ) );
399  modified = false;
400  m_refill = true;
401  }
402 
403  m_toolMgr->PassEvent();
404  }
405 
406  else if( evt->IsCancel() )
407  {
408  if( modified ) // Restore the last change
409  revert = true;
410 
411  // Let the selection tool receive the event too
412  m_toolMgr->PassEvent();
413 
414  // Do not exit right now, let the selection clear the selection
415  //break;
416  }
417 
418  else
419  {
420  m_toolMgr->PassEvent();
421  }
422  }
423 
424  if( m_editPoints )
425  {
426  view->Remove( m_editPoints.get() );
427 
428  if( modified && revert )
429  commit.Revert();
430 
431  finishItem();
432  m_editPoints.reset();
433  }
434 
435  frame()->UpdateMsgPanel();
436 
437  return 0;
438 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
Definition: actions.h:132
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
Definition: actions.h:133
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void updateEditedPoint(const TOOL_EVENT &aEvent)
Updates which point is being edited.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
void setAltConstraint(bool aEnabled)
Sets up an alternative constraint (typically enabled upon a modifier key being pressed).
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:74
void updateItem() const
Updates item's points with edit points.
void PassEvent()
Allows a tool to pass the already handled event to the next tool on the stack.
Definition: tool_manager.h:356
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:75
void finishItem()
Applies the last changes to the edited item.
Class LSET is a set of PCB_LAYER_IDs.
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:68
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
Definition: point_editor.h:78
KIGFX::PCB_VIEW * view() const
SELECTION & GetSelection()
Function GetSelection()
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
Definition: actions.h:134
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:713
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: point_editor.h:66
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:98
PCB_EDIT_FRAME * frame() const
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
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.
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
void updatePoints()
Updates edit points with item's points.
EDIT_POINT m_original
Original position for the current drag point.
Definition: point_editor.h:72
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:58
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
Class VIEW.
Definition: view.h:61
void UpdateMsgPanel() override
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:69
const SELECTION & selection() const
void setEditedPoint(EDIT_POINT *aPoint)
Sets the current point being edited. NULL means none.
virtual void ApplyConstraint()
Function ApplyConstraint()
Definition: edit_points.h:173
virtual LSET GetLayerSet() const
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
EDA_ITEM * Front() const
Definition: selection.h:155
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem, KIGFX::GAL *aGal)
virtual void SetPosition(const VECTOR2I &aPosition)
Function SetPosition()
Definition: edit_points.h:105

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), LSET::AllLayersMask(), EDIT_POINT::ApplyConstraint(), GRID_HELPER::BestSnapAnchor(), BUT_LEFT, CHT_MODIFY, EVENTS::ClearedEvent, PCB_TOOL_BASE::controls(), finishItem(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), SELECTION::Front(), BOARD_ITEM::GetLayerSet(), EDIT_POINT::GetPosition(), SELECTION_TOOL::GetSelection(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), m_altConstraint, m_editedPoint, m_editPoints, m_original, m_refill, m_selectionTool, TOOL_BASE::m_toolMgr, EDIT_POINTS_FACTORY::Make(), MD_ALT, MD_CTRL, MD_SHIFT, TOOL_MANAGER::PassEvent(), PCB_DIMENSION_T, BOARD_COMMIT::Push(), KIGFX::PCB_VIEW::Remove(), BOARD_COMMIT::Revert(), EVENTS::SelectedEvent, PCB_TOOL_BASE::selection(), setAltConstraint(), KIGFX::VIEW_CONTROLS::SetAutoPan(), GRID_HELPER::SetAuxAxes(), setEditedPoint(), EDIT_POINT::SetPosition(), GRID_HELPER::SetSnap(), KIGFX::VIEW_CONTROLS::SetSnapping(), GRID_HELPER::SetUseGrid(), KIGFX::VIEW_CONTROLS::ShowCursor(), SELECTION::Size(), COMMIT::StageItems(), EDA_ITEM::Type(), EVENTS::UnselectedEvent, updateEditedPoint(), updateItem(), PCB_BASE_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 1118 of file point_editor.cpp.

1119 {
1120  if( !m_editPoints || !m_editedPoint )
1121  return 0;
1122 
1123  EDA_ITEM* item = m_editPoints->GetParent();
1124 
1125  if( !item )
1126  return 0;
1127 
1128  SHAPE_POLY_SET* polygon = nullptr;
1129 
1130  if( item->Type() == PCB_ZONE_AREA_T)
1131  {
1132  auto zone = static_cast<ZONE_CONTAINER*>( item );
1133  polygon = zone->Outline();
1134  zone->SetNeedRefill( true );
1135  }
1136  else if( (item->Type() == PCB_MODULE_EDGE_T ) || ( item->Type() == PCB_LINE_T ) )
1137  {
1138  auto ds = static_cast<DRAWSEGMENT*>( item );
1139 
1140  if( ds->GetShape() == S_POLYGON )
1141  polygon = &ds->GetPolyShape();
1142  }
1143 
1144  if( !polygon )
1145  return 0;
1146 
1147  PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
1148  BOARD_COMMIT commit( frame );
1149  auto vertex = findVertex( *polygon, *m_editedPoint );
1150 
1151  if( vertex.first )
1152  {
1153  const auto& vertexIdx = vertex.second;
1154  auto& outline = polygon->Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
1155  bool valid = true;
1156 
1157  if( outline.PointCount() > 3 )
1158  {
1159  // the usual case: remove just the corner when there are >3 vertices
1160  commit.Modify( item );
1161  polygon->RemoveVertex( vertexIdx );
1162  valid = validatePolygon( *polygon );
1163  }
1164  else
1165  {
1166  // either remove a hole or the polygon when there are <= 3 corners
1167  if( vertexIdx.m_contour > 0 )
1168  {
1169  // remove hole
1170  commit.Modify( item );
1171  polygon->RemoveContour( vertexIdx.m_contour );
1172  }
1173  else
1174  {
1176  commit.Remove( item );
1177  }
1178  }
1179 
1180  setEditedPoint( nullptr );
1181 
1182  if( valid )
1183  {
1184  commit.Push( _( "Remove a zone/polygon corner" ) );
1185 
1186  // Refresh zone hatching
1187  if( item->Type() == PCB_ZONE_AREA_T)
1188  static_cast<ZONE_CONTAINER*>( item )->Hatch();
1189 
1190  updatePoints();
1191  }
1192  else
1193  {
1195  getView()->Remove( m_editPoints.get() );
1196  commit.Revert();
1197  m_editPoints.reset();
1198  }
1199  }
1200 
1201  return 0;
1202 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
polygon (not yet used for tracks, but could be in microwave apps)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:100
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:75
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
bool validatePolygon(SHAPE_POLY_SET &aModified, const SHAPE_POLY_SET *aOriginal=nullptr) const
Validates a polygon and restores it to its original version if available.
PCB_EDIT_FRAME * frame() const
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
void RemoveVertex(int aGlobalIndex)
Function RemoveVertex deletes the aGlobalIndex-th vertex.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
void 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)
POLYGON & Polygon(int aIndex)
Returns the aIndex-th subpolygon in the set
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:69
void setEditedPoint(EDIT_POINT *aPoint)
Sets the current point being edited. NULL means none.
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
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(), TOOL_BASE::getView(), m_editedPoint, m_editPoints, TOOL_BASE::m_toolMgr, COMMIT::Modify(), SHAPE_POLY_SET::Outline(), PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_ZONE_AREA_T, SHAPE_POLY_SET::Polygon(), BOARD_COMMIT::Push(), COMMIT::Remove(), KIGFX::VIEW::Remove(), SHAPE_POLY_SET::RemoveContour(), SHAPE_POLY_SET::RemoveVertex(), BOARD_COMMIT::Revert(), TOOL_MANAGER::RunAction(), S_POLYGON, PCB_ACTIONS::selectionClear, setEditedPoint(), 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 952 of file point_editor.cpp.

953 {
954  if( !m_editPoints || !m_editedPoint )
955  return false;
956 
957  EDA_ITEM* item = m_editPoints->GetParent();
958 
959  if( !item || !( item->Type() == PCB_ZONE_AREA_T ||
960  ( ( item->Type() == PCB_MODULE_EDGE_T || item->Type() == PCB_LINE_T ) &&
961  static_cast<DRAWSEGMENT*>( item )->GetShape() == S_POLYGON ) ) )
962  return false;
963 
964  SHAPE_POLY_SET *polyset;
965 
966  if( item->Type() == PCB_ZONE_AREA_T )
967  polyset = static_cast<ZONE_CONTAINER*>( item )->Outline();
968  else
969  polyset = &static_cast<DRAWSEGMENT*>( item )->GetPolyShape();
970 
971  auto vertex = findVertex( *polyset, *m_editedPoint );
972 
973  if( !vertex.first )
974  return false;
975 
976  const auto& vertexIdx = vertex.second;
977 
978  // Check if there are enough vertices so one can be removed without
979  // degenerating the polygon.
980  // The first condition allows one to remove all corners from holes (when
981  // there are only 2 vertices left, a hole is removed).
982  if( vertexIdx.m_contour == 0 && polyset->Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour].PointCount() <= 3 )
983  return false;
984 
985  // Remove corner does not work with lines
986  if( dynamic_cast<EDIT_LINE*>( m_editedPoint ) )
987  return false;
988 
989  return m_editedPoint != NULL;
990 }
polygon (not yet used for tracks, but could be in microwave apps)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:100
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:75
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
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
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:69
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

References findVertex(), m_editedPoint, m_editPoints, SHAPE_POLY_SET::Outline(), PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_ZONE_AREA_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 252 of file point_editor.cpp.

253 {
254  m_refill = false;
255  m_editPoints.reset();
256  m_altConstraint.reset();
257  getViewControls()->SetAutoPan( false );
258 
259  m_statusPopup.reset( new STATUS_TEXT_POPUP( getEditFrame<PCB_BASE_EDIT_FRAME>() ) );
260  m_statusPopup->SetTextColor( wxColour( 255, 0, 0 ) );
261  m_statusPopup->SetText( _( "Self-intersecting polygons are not allowed" ) );
262 }
Class STATUS_TEXT_POPUP.
Definition: status_popup.h:79
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
Definition: point_editor.h:86
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:75
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
Definition: point_editor.h:78
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 * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41

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

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

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

Referenced by DRAWING_TOOL::PlaceText().

◆ selection() [1/2]

const SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 251 of file pcb_tool_base.cpp.

252 {
253  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
254  const auto& selection = selTool->GetSelection();
255  return selection;
256 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
const SELECTION & selection() const

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

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), EDIT_TOOL::changeTrackWidthOnClick(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::CreateArray(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), EDIT_TOOL::doCopyToClipboard(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), OnSelectionChange(), PAD_TOOL::pastePadProperties(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Rotate(), SELECTION_TOOL::selectCopper(), PCB_TOOL_BASE::selection(), SELECTION_TOOL::selectNet(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 258 of file pcb_tool_base.cpp.

259 {
260  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
261  auto& selection = selTool->GetSelection();
262  return selection;
263 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
const SELECTION & selection() const

References TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, and PCB_TOOL_BASE::selection().

◆ setAltConstraint()

void POINT_EDITOR::setAltConstraint ( bool  aEnabled)
private

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

Definition at line 827 of file point_editor.cpp.

828 {
829  if( aEnabled )
830  {
831  EDIT_LINE* line = dynamic_cast<EDIT_LINE*>( m_editedPoint );
832 
833  if( line && m_editPoints->GetParent()->Type() == PCB_ZONE_AREA_T )
834  {
836  }
837  else
838  {
839  // Find a proper constraining point for 45 degrees mode
842  }
843  }
844  else
845  {
846  m_altConstraint.reset();
847  }
848 }
Class EC_CONVERGING.
Class EDIT_LINE.
Definition: edit_points.h:207
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:100
Class EC_45DEGREE.
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:75
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
Definition: point_editor.h:78
EDIT_POINT get45DegConstrainer() const
Returns a point that should be used as a constrainer for 45 degrees mode.
EDIT_POINT m_altConstrainer
Definition: point_editor.h:81
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:69

References get45DegConstrainer(), m_altConstrainer, m_altConstraint, m_editedPoint, m_editPoints, and PCB_ZONE_AREA_T.

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

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

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), TOOL_MENU::ShowContextMenu(), and SCH_WIRE_BUS_TOOL::UnfoldBus().

◆ setEditedPoint()

void POINT_EDITOR::setEditedPoint ( EDIT_POINT aPoint)
private

Sets the current point being edited. NULL means none.

Definition at line 808 of file point_editor.cpp.

809 {
811 
812  if( aPoint )
813  {
814  controls->ForceCursorPosition( true, aPoint->GetPosition() );
815  controls->ShowCursor( true );
816  }
817  else
818  {
819  controls->ShowCursor( false );
820  controls->ForceCursorPosition( false );
821  }
822 
823  m_editedPoint = aPoint;
824 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:68
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
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:41
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:69

References PCB_TOOL_BASE::controls(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), EDIT_POINT::GetPosition(), TOOL_BASE::getViewControls(), m_editedPoint, and KIGFX::VIEW_CONTROLS::ShowCursor().

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

◆ SetEditModules()

void PCB_TOOL_BASE::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

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

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 97 of file pcb_tool_base.h.

98  {
99  m_editModules = aEnabled;
100  }

References PCB_TOOL_BASE::m_editModules.

◆ setTransitions()

void POINT_EDITOR::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL_BASE.

Definition at line 903 of file point_editor.cpp.

904 {
910 }
int OnSelectionChange(const TOOL_EVENT &aEvent)
Function OnSelected()
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
Definition: actions.h:132
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
Definition: actions.h:133
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:136
static TOOL_ACTION pointEditorAddCorner
Break outline (insert additional points to an edge)
Definition: pcb_actions.h:189
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
Definition: pcb_actions.h:192
int addCorner(const TOOL_EVENT &aEvent)
TOOL_ACTION handlers.
int modifiedSelection(const TOOL_EVENT &aEvent)

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

◆ updateEditedPoint()

void POINT_EDITOR::updateEditedPoint ( const TOOL_EVENT aEvent)
private

Updates which point is being edited.

Definition at line 281 of file point_editor.cpp.

282 {
283  EDIT_POINT* point = m_editedPoint;
284 
285  if( aEvent.IsMotion() )
286  {
287  point = m_editPoints->FindPoint( aEvent.Position(), getView() );
288  }
289  else if( aEvent.IsDrag( BUT_LEFT ) )
290  {
291  point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
292  }
293 
294  if( m_editedPoint != point )
295  setEditedPoint( point );
296 }
bool IsMotion() const
Definition: tool_event.h:290
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:75
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:280
const VECTOR2D DragOrigin() const
Returns the point where dragging has started.
Definition: tool_event.h:264
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
Class EDIT_POINT.
Definition: edit_points.h:46
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:69
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:258

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

Referenced by OnSelectionChange().

◆ updateItem()

void POINT_EDITOR::updateItem ( ) const
private

Updates item's points with edit points.

Definition at line 441 of file point_editor.cpp.

442 {
443  EDA_ITEM* item = m_editPoints->GetParent();
444 
445  if( !item )
446  return;
447 
448  switch( item->Type() )
449  {
450  case PCB_LINE_T:
451  case PCB_MODULE_EDGE_T:
452  {
453  DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
454  switch( segment->GetShape() )
455  {
456  case S_SEGMENT:
457  if( isModified( m_editPoints->Point( SEG_START ) ) )
458  segment->SetStart( wxPoint( m_editPoints->Point( SEG_START ).GetPosition().x,
459  m_editPoints->Point( SEG_START ).GetPosition().y ) );
460 
461  else if( isModified( m_editPoints->Point( SEG_END ) ) )
462  segment->SetEnd( wxPoint( m_editPoints->Point( SEG_END ).GetPosition().x,
463  m_editPoints->Point( SEG_END ).GetPosition().y ) );
464 
465  break;
466 
467  case S_ARC:
468  {
469  VECTOR2I center = m_editPoints->Point( ARC_CENTER ).GetPosition();
470  VECTOR2I mid = m_editPoints->Point( ARC_MID ).GetPosition();
471  VECTOR2I start = m_editPoints->Point( ARC_START ).GetPosition();
472  VECTOR2I end = m_editPoints->Point( ARC_END ).GetPosition();
473 
474  if( center != segment->GetCenter() )
475  {
476  wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
477  segment->Move( moveVector );
478 
479  m_editPoints->Point( ARC_START ).SetPosition( segment->GetArcStart() );
480  m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
481  m_editPoints->Point( ARC_MID ).SetPosition( segment->GetArcMid() );
482  }
483  else
484  {
485  if( mid != segment->GetArcMid() )
486  {
487  center = GetArcCenter( start, mid, end );
488  segment->SetCenter( wxPoint( center.x, center.y ) );
489  m_editPoints->Point( ARC_CENTER ).SetPosition( center );
490  }
491 
492  segment->SetArcStart( wxPoint( start.x, start.y ) );
493 
494  VECTOR2D startLine = start - center;
495  VECTOR2D endLine = end - center;
496  double newAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
497 
498  // Adjust the new angle to (counter)clockwise setting
499  bool clockwise = ( segment->GetAngle() > 0 );
500 
501  if( clockwise && newAngle < 0.0 )
502  newAngle += 3600.0;
503  else if( !clockwise && newAngle > 0.0 )
504  newAngle -= 3600.0;
505 
506  segment->SetAngle( newAngle );
507  }
508 
509  break;
510  }
511 
512  case S_CIRCLE:
513  {
514  const VECTOR2I& center = m_editPoints->Point( CIRC_CENTER ).GetPosition();
515  const VECTOR2I& end = m_editPoints->Point( CIRC_END ).GetPosition();
516 
517  if( isModified( m_editPoints->Point( CIRC_CENTER ) ) )
518  {
519  wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
520  segment->Move( moveVector );
521  }
522  else
523  {
524  segment->SetEnd( wxPoint( end.x, end.y ) );
525  }
526 
527  break;
528  }
529 
530  case S_POLYGON:
531  {
532  SHAPE_POLY_SET& outline = segment->GetPolyShape();
533 
534  for( int i = 0; i < outline.TotalVertices(); ++i )
535  outline.Vertex( i ) = m_editPoints->Point( i ).GetPosition();
536 
537  validatePolygon( outline );
538  break;
539  }
540 
541  case S_CURVE:
542  if( isModified( m_editPoints->Point( BEZIER_CURVE_START ) ) )
543  segment->SetStart( wxPoint( m_editPoints->Point( BEZIER_CURVE_START ).GetPosition().x,
544  m_editPoints->Point( BEZIER_CURVE_START ).GetPosition().y ) );
545  else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ) ) )
546  segment->SetBezControl1( wxPoint( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition().x,
547  m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).GetPosition().y ) );
548  else if( isModified( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ) ) )
549  segment->SetBezControl2( wxPoint( m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition().x,
550  m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).GetPosition().y ) );
551  else if( isModified( m_editPoints->Point( BEZIER_CURVE_END ) ) )
552  segment->SetEnd( wxPoint( m_editPoints->Point( BEZIER_CURVE_END ).GetPosition().x,
553  m_editPoints->Point( BEZIER_CURVE_END ).GetPosition().y ) );
554 
555  segment->RebuildBezierToSegmentsPointsList( segment->GetWidth() );
556  break;
557 
558  default: // suppress warnings
559  break;
560  }
561 
562  // Update relative coordinates for module edges
563  if( EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item ) )
564  edge->SetLocalCoord();
565 
566  break;
567  }
568 
569  case PCB_ZONE_AREA_T:
570  {
571  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
572  zone->ClearFilledPolysList();
573  SHAPE_POLY_SET& outline = *zone->Outline();
574 
575  for( int i = 0; i < outline.TotalVertices(); ++i )
576  {
577  if( outline.Vertex( i ) != m_editPoints->Point( i ).GetPosition() )
578  zone->SetNeedRefill( true );
579 
580  outline.Vertex( i ) = m_editPoints->Point( i ).GetPosition();
581  }
582 
583  validatePolygon( outline );
584  zone->Hatch();
585  break;
586  }
587 
588  case PCB_DIMENSION_T:
589  {
590  DIMENSION* dimension = static_cast<DIMENSION*>( item );
591 
592  // Check which point is currently modified and updated dimension's points respectively
593  if( isModified( m_editPoints->Point( DIM_CROSSBARO ) ) )
594  {
595  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetOrigin() );
596  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
597 
598  if( featureLine.Cross( crossBar ) > 0 )
599  dimension->SetHeight( -featureLine.EuclideanNorm() );
600  else
601  dimension->SetHeight( featureLine.EuclideanNorm() );
602  }
603 
604  else if( isModified( m_editPoints->Point( DIM_CROSSBARF ) ) )
605  {
606  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetEnd() );
607  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
608 
609  if( featureLine.Cross( crossBar ) > 0 )
610  dimension->SetHeight( -featureLine.EuclideanNorm() );
611  else
612  dimension->SetHeight( featureLine.EuclideanNorm() );
613  }
614 
615  else if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
616  {
617  dimension->SetOrigin( wxPoint( m_editedPoint->GetPosition().x, m_editedPoint->GetPosition().y ) );
618  m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
619  m_editPoints->Point( DIM_FEATUREGO ) ) );
620  m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
621  m_editPoints->Point( DIM_FEATUREDO ) ) );
622  }
623 
624  else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
625  {
626  dimension->SetEnd( wxPoint( m_editedPoint->GetPosition().x, m_editedPoint->GetPosition().y ) );
627  m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
628  m_editPoints->Point( DIM_FEATUREGO ) ) );
629  m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
630  m_editPoints->Point( DIM_FEATUREDO ) ) );
631  }
632 
633  break;
634  }
635 
636  default:
637  break;
638  }
639 
640  if( frame() )
641  frame()->SetMsgPanel( item );
642 }
const wxPoint GetArcMid() const
int TotalVertices() const
Returns total number of vertices stored in the set.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
virtual void Move(const wxPoint &aMoveVector) override
Function Move move this object.
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
const wxPoint GetCenter() const override
Function GetCenter()
STROKE_T GetShape() const
const wxPoint GetArcEnd() const
polygon (not yet used for tracks, but could be in microwave apps)
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments Has me...
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:100
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:260
double RAD2DECIDEG(double rad)
Definition: trigo.h:213
usual segment : line with rounded ends
bool isModified(const EDIT_POINT &aPoint) const
Returns true if aPoint is the currently modified point.
Definition: point_editor.h:112
void SetCenter(const wxPoint &aCenterPoint)
For arcs and circles:
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
void SetBezControl2(const wxPoint &aPoint)
Class EC_LINE.
VECTOR2I & Vertex(int aIndex, int aOutline, int aHole)
Returns the index-th vertex in a given hole outline within a given outline
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:75
void SetOrigin(const wxPoint &aOrigin)
Function SetOrigin Sets a new origin of the crossbar line.
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:68
const wxPoint & GetEnd()
Function GetEnd.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
Class SHAPE_POLY_SET.
void SetEnd(const wxPoint &aEnd)
Function SetEnd Sets a new end of the crossbar line.
Arcs (with rounded ends)
bool validatePolygon(SHAPE_POLY_SET &aModified, const SHAPE_POLY_SET *aOriginal=nullptr) const
Validates a polygon and restores it to its original version if available.
const wxPoint & GetArcStart() const
SHAPE_POLY_SET & GetPolyShape()
Bezier Curve.
const wxPoint & GetOrigin() const
Function GetOrigin.
double Angle() const
Function Angle computes the angle of the vector.
Definition: vector2d.h:306
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:98
PCB_EDIT_FRAME * frame() const
int GetWidth() const
void SetStart(const wxPoint &aStart)
double GetAngle() const
void SetHeight(int aHeight)
Function SetHeight Sets the length of feature lines.
size_t i
Definition: json11.cpp:597
void Hatch()
Function Hatch computes the hatch lines depending on the hatch parameters and stores it in the zone's...
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
void SetEnd(const wxPoint &aEnd)
void SetAngle(double aAngle)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:69
const VECTOR2I GetArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc/circle, given three points on its circumference.
Definition: trigo.cpp:349
Class DIMENSION.
void ClearFilledPolysList()
Function ClearFilledPolysList clears the list of filled polygons.
Definition: class_zone.h:570
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
void SetBezControl1(const wxPoint &aPoint)
void SetNeedRefill(bool aNeedRefill)
Definition: class_zone.h:191

References VECTOR2< T >::Angle(), 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_CONTAINER::ClearFilledPolysList(), DIM_CROSSBARF, DIM_CROSSBARO, DIM_FEATUREDO, DIM_FEATUREGO, PCB_TOOL_BASE::frame(), DRAWSEGMENT::GetAngle(), GetArcCenter(), DRAWSEGMENT::GetArcEnd(), DRAWSEGMENT::GetArcMid(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetCenter(), DIMENSION::GetEnd(), DIMENSION::GetOrigin(), DRAWSEGMENT::GetPolyShape(), EDIT_POINT::GetPosition(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetWidth(), ZONE_CONTAINER::Hatch(), i, isModified(), m_editedPoint, m_editPoints, DRAWSEGMENT::Move(), ZONE_CONTAINER::Outline(), PCB_DIMENSION_T, PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_ZONE_AREA_T, RAD2DECIDEG(), DRAWSEGMENT::RebuildBezierToSegmentsPointsList(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_SEGMENT, SEG_END, SEG_START, DRAWSEGMENT::SetAngle(), DRAWSEGMENT::SetArcStart(), DRAWSEGMENT::SetBezControl1(), DRAWSEGMENT::SetBezControl2(), DRAWSEGMENT::SetCenter(), DRAWSEGMENT::SetEnd(), DIMENSION::SetEnd(), DIMENSION::SetHeight(), EDA_DRAW_FRAME::SetMsgPanel(), ZONE_CONTAINER::SetNeedRefill(), DIMENSION::SetOrigin(), DRAWSEGMENT::SetStart(), SHAPE_POLY_SET::TotalVertices(), EDA_ITEM::Type(), validatePolygon(), SHAPE_POLY_SET::Vertex(), 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 699 of file point_editor.cpp.

700 {
701  if( !m_editPoints )
702  return;
703 
704  EDA_ITEM* item = m_editPoints->GetParent();
705 
706  if( !item )
707  return;
708 
709  switch( item->Type() )
710  {
711  case PCB_LINE_T:
712  case PCB_MODULE_EDGE_T:
713  {
714  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
715 
716  switch( segment->GetShape() )
717  {
718  case S_SEGMENT:
719  m_editPoints->Point( SEG_START ).SetPosition( segment->GetStart() );
720  m_editPoints->Point( SEG_END ).SetPosition( segment->GetEnd() );
721  break;
722 
723  case S_ARC:
724  m_editPoints->Point( ARC_CENTER ).SetPosition( segment->GetCenter() );
725  m_editPoints->Point( ARC_START ).SetPosition( segment->GetArcStart() );
726  m_editPoints->Point( ARC_MID ).SetPosition( segment->GetArcMid() );
727  m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
728  break;
729 
730  case S_CIRCLE:
731  m_editPoints->Point( CIRC_CENTER ).SetPosition( segment->GetCenter() );
732  m_editPoints->Point( CIRC_END ).SetPosition( segment->GetEnd() );
733  break;
734 
735  case S_POLYGON:
736  {
737  const auto& points = segment->BuildPolyPointsList();
738 
739  if( m_editPoints->PointsSize() != (unsigned) points.size() )
740  {
741  getView()->Remove( m_editPoints.get() );
742  m_editedPoint = nullptr;
743  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
744  getView()->Add( m_editPoints.get() );
745  }
746  else
747  {
748  for( unsigned i = 0; i < points.size(); i++ )
749  m_editPoints->Point( i ).SetPosition( points[i] );
750  }
751  break;
752  }
753 
754  case S_CURVE:
755  m_editPoints->Point( BEZIER_CURVE_START ).SetPosition( segment->GetStart() );
756  m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT1 ).SetPosition( segment->GetBezControl1() );
757  m_editPoints->Point( BEZIER_CURVE_CONTROL_POINT2 ).SetPosition( segment->GetBezControl2() );
758  m_editPoints->Point( BEZIER_CURVE_END ).SetPosition( segment->GetEnd() );
759  break;
760 
761  default: // suppress warnings
762  break;
763  }
764 
765  break;
766  }
767 
768  case PCB_ZONE_AREA_T:
769  {
770  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
771  const SHAPE_POLY_SET* outline = zone->Outline();
772 
773  if( m_editPoints->PointsSize() != (unsigned) outline->TotalVertices() )
774  {
775  getView()->Remove( m_editPoints.get() );
776  m_editedPoint = nullptr;
777  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
778  getView()->Add( m_editPoints.get() );
779  }
780  else
781  {
782  for( int i = 0; i < outline->TotalVertices(); ++i )
783  m_editPoints->Point( i ).SetPosition( outline->CVertex( i ) );
784  }
785 
786  break;
787  }
788 
789  case PCB_DIMENSION_T:
790  {
791  const DIMENSION* dimension = static_cast<const DIMENSION*>( item );
792 
793  m_editPoints->Point( DIM_CROSSBARO ).SetPosition( dimension->m_crossBarO );
794  m_editPoints->Point( DIM_CROSSBARF ).SetPosition( dimension->m_crossBarF );
795  m_editPoints->Point( DIM_FEATUREGO ).SetPosition( dimension->m_featureLineGO );
796  m_editPoints->Point( DIM_FEATUREDO ).SetPosition( dimension->m_featureLineDO );
797  break;
798  }
799 
800  default:
801  break;
802  }
803 
804  getView()->Update( m_editPoints.get() );
805 }
const wxPoint GetArcMid() const
int TotalVertices() const
Returns total number of vertices stored in the set.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
wxPoint m_crossBarF
const wxPoint GetCenter() const override
Function GetCenter()
STROKE_T GetShape() const
const wxPoint GetArcEnd() const
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
polygon (not yet used for tracks, but could be in microwave apps)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:100
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:260
usual segment : line with rounded ends
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...
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
wxPoint m_featureLineGO
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:75
Class SHAPE_POLY_SET.
Arcs (with rounded ends)
const wxPoint & GetArcStart() const
Bezier Curve.
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1539
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:98
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
size_t i
Definition: json11.cpp:597
const wxPoint & GetBezControl2() const
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
wxPoint m_crossBarO
const wxPoint & GetBezControl1() const
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:69
wxPoint m_featureLineDO
Class DIMENSION.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem, KIGFX::GAL *aGal)

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, DRAWSEGMENT::BuildPolyPointsList(), CIRC_CENTER, CIRC_END, SHAPE_POLY_SET::CVertex(), DIM_CROSSBARF, DIM_CROSSBARO, DIM_FEATUREDO, DIM_FEATUREGO, DRAWSEGMENT::GetArcEnd(), DRAWSEGMENT::GetArcMid(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetBezControl1(), DRAWSEGMENT::GetBezControl2(), DRAWSEGMENT::GetCenter(), DRAWSEGMENT::GetEnd(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), TOOL_BASE::getView(), i, DIMENSION::m_crossBarF, DIMENSION::m_crossBarO, m_editedPoint, m_editPoints, DIMENSION::m_featureLineDO, DIMENSION::m_featureLineGO, EDIT_POINTS_FACTORY::Make(), ZONE_CONTAINER::Outline(), PCB_DIMENSION_T, PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_ZONE_AREA_T, KIGFX::VIEW::Remove(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_SEGMENT, SEG_END, SEG_START, 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 SHAPE_POLY_SET aOriginal = nullptr 
) const
private

Validates a polygon and restores it to its original version if available.

Parameters
aModifiedis the polygon to be checked.
aOriginalis the original copy that will be used to restore its state.
Returns
True if polygon is valid.

Definition at line 676 of file point_editor.cpp.

677 {
678  if( !aModified.IsSelfIntersecting() )
679  {
680  m_statusPopup->Hide();
681  return true;
682  }
683 
684  if( m_statusPopup )
685  {
686  wxPoint p = wxGetMousePosition() + wxPoint( 20, 20 );
687  m_statusPopup->Move( p );
688  m_statusPopup->Popup( getEditFrame<PCB_BASE_FRAME>() );
689  m_statusPopup->Expire( 1500 );
690  }
691 
692  if( aOriginal )
693  aModified = *aOriginal;
694 
695  return false;
696 }
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
Definition: point_editor.h:86
bool IsSelfIntersecting()
Function IsSelfIntersecting Checks whether any of the polygons in the set is self intersecting.

References SHAPE_POLY_SET::IsSelfIntersecting(), and m_statusPopup.

Referenced by removeCorner(), and updateItem().

◆ view()

◆ Wait()

OPT_TOOL_EVENT TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

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

Definition at line 55 of file tool_interactive.cpp.

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

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

Referenced by LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_DRAWING_TOOLS::doPlaceComponent(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), and SCH_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_altConstrainer

EDIT_POINT POINT_EDITOR::m_altConstrainer
private

Definition at line 81 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 78 of file point_editor.h.

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

◆ m_editedPoint

EDIT_POINT* POINT_EDITOR::m_editedPoint
private

◆ m_editModules

◆ m_editPoints

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

◆ m_menu

◆ m_original

EDIT_POINT POINT_EDITOR::m_original
private

Original position for the current drag point.

Definition at line 72 of file point_editor.h.

Referenced by get45DegConstrainer(), and OnSelectionChange().

◆ m_refill

bool POINT_EDITOR::m_refill
private

Definition at line 84 of file point_editor.h.

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

◆ m_selectionTool

SELECTION_TOOL* POINT_EDITOR::m_selectionTool
private

Selection tool used for obtaining selected items

Definition at line 66 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 86 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 211 of file tool_base.h.

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 216 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemToSel(), SCH_DRAWING_TOOLS::AddJunction(), SCH_DRAWING_TOOLS::AddLabel(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDITOR_CONTROL::ClearHighlight(), PCB_EDITOR_CONTROL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), SCH_EDITOR_CONTROL::Cut(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), SCH_WIRE_BUS_TOOL::DrawBusses(), DRAWING_TOOL::DrawDimension(), SCH_WIRE_BUS_TOOL::DrawLines(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_WIRE_BUS_TOOL::DrawWires(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), SCH_EDITOR_CONTROL::EnterSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), SCH_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PCB_EDITOR_CONTROL::Init(), Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), OnSelectionChange(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), removeCorner(), EE_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), SELECTION_TOOL::RequestSelection(), CVPCB_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), EE_SELECTION_TOOL::SelectConnection(), SELECTION_TOOL::selectCopper(), PCB_TOOL_BASE::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), EE_SELECTION_TOOL::SelectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SCH_WIRE_BUS_TOOL::StartBus(), SCH_WIRE_BUS_TOOL::StartLine(), SCH_WIRE_BUS_TOOL::StartWire(), GERBVIEW_SELECTION_TOOL::toggleSelection(), EE_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), SCH_EDITOR_CONTROL::Undo(), SCH_WIRE_BUS_TOOL::UnfoldBus(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

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

Definition at line 215 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 217 of file tool_base.h.

Referenced by TOOL_BASE::attachManager(), and TOOL_BASE::GetSettings().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 208 of file tool_base.h.

Referenced by TOOL_BASE::GetType().


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