KiCad PCB EDA Suite
POINT_EDITOR Class Reference

Class POINT_EDITOR. More...

#include <point_editor.h>

Inheritance diagram for POINT_EDITOR:
PCB_TOOL 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 (CONTEXT_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

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...
 
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...
 
void addCorner (const VECTOR2I &aPoint)
 

Adds a new edit point on a zone outline/line.

More...
 
void removeCorner (EDIT_POINT *aPoint)
 

Removes a corner.

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

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
 

Detailed Description

Class POINT_EDITOR.

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

Definition at line 41 of file point_editor.h.

Member Enumeration Documentation

enum PCB_TOOL::INTERACTIVE_PLACEMENT_OPTIONS
protectedinherited
Enumerator
IPO_ROTATE 
IPO_FLIP 
IPO_PROPERTIES 
IPO_SINGLE_CLICK 
IPO_REPEAT 

Definition at line 104 of file pcb_tool.h.

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

Definition at line 219 of file point_editor.cpp.

219  :
220  PCB_TOOL( "pcbnew.PointEditor" ), m_selectionTool( NULL ), m_editedPoint( NULL ),
221  m_original( VECTOR2I( 0, 0 ) ), m_altConstrainer( VECTOR2I( 0, 0 ) )
222 {
223 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:589
PCB_TOOL(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool.h:69
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: point_editor.h:64
EDIT_POINT m_original
Original position for the current drag point.
Definition: point_editor.h:70
EDIT_POINT m_altConstrainer
Definition: point_editor.h:79
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:67

Member Function Documentation

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.

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

Referenced by EDIT_TOOL::copyToClipboard(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), ROUTER_TOOL::SettingsDialog(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
void POINT_EDITOR::addCorner ( const VECTOR2I aPoint)
private

Adds a new edit point on a zone outline/line.

Referenced by setTransitions().

int POINT_EDITOR::addCorner ( const TOOL_EVENT aEvent)
private

TOOL_ACTION handlers.

Definition at line 837 of file point_editor.cpp.

References COMMIT::Add(), EDA_ITEM::ClearSelected(), SEG::Distance(), PCB_TOOL::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), DRAWSEGMENT::GetEnd(), BOARD_ITEM::GetParent(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), TOOL_BASE::getViewControls(), ZONE_CONTAINER::Hatch(), 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_LINE_T, PCB_MODULE_EDGE_T, PCB_MODULE_T, PCB_ZONE_AREA_T, BOARD_COMMIT::Push(), S_SEGMENT, DRAWSEGMENT::SetEnd(), DRAWSEGMENT::SetStart(), EDA_ITEM::Type(), updatePoints(), and SHAPE_POLY_SET::Vertex().

838 {
839  EDA_ITEM* item = m_editPoints->GetParent();
840  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
841  const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition();
842  BOARD_COMMIT commit( frame );
843 
844  if( item->Type() == PCB_ZONE_AREA_T )
845  {
846  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
847  SHAPE_POLY_SET* zoneOutline = zone->Outline();
848 
849  commit.Modify( zone );
850 
851  unsigned int nearestIdx = 0;
852  unsigned int nextNearestIdx = 0;
853  unsigned int nearestDist = INT_MAX;
854  unsigned int firstPointInContour = 0;
855 
856  // Search the best outline segment to add a new corner
857  // and therefore break this segment into two segments
858 
859  // Object to iterate through the corners of the outlines (main contour and its holes)
860  SHAPE_POLY_SET::ITERATOR iterator = zoneOutline->Iterate( 0,
861  zoneOutline->OutlineCount()-1, /* IterateHoles */ true );
862  int curr_idx = 0;
863 
864  // Iterate through all the corners of the outlines and search the best segment
865  for( ; iterator; iterator++, curr_idx++ )
866  {
867  int jj = curr_idx+1;
868 
869  if( iterator.IsEndContour() )
870  { // We reach the last point of the current contour (main or hole)
871  jj = firstPointInContour;
872  firstPointInContour = curr_idx+1; // Prepare next contour analysis
873  }
874 
875  SEG curr_segment( zoneOutline->Vertex( curr_idx ), zoneOutline->Vertex( jj ) );
876 
877  unsigned int distance = curr_segment.Distance( cursorPos );
878 
879  if( distance < nearestDist )
880  {
881  nearestDist = distance;
882  nearestIdx = curr_idx;
883  nextNearestIdx = jj;
884  }
885  }
886 
887 
888  // Find the point on the closest segment
889  VECTOR2I sideOrigin = zoneOutline->Vertex( nearestIdx );
890  VECTOR2I sideEnd = zoneOutline->Vertex( nextNearestIdx );
891  SEG nearestSide( sideOrigin, sideEnd );
892  VECTOR2I nearestPoint = nearestSide.NearestPoint( cursorPos );
893 
894  // Do not add points that have the same coordinates as ones that already belong to polygon
895  // instead, add a point in the middle of the side
896  if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
897  nearestPoint = ( sideOrigin + sideEnd ) / 2;
898 
899  // Add corner between nearestIdx and nextNearestIdx:
900  zoneOutline->InsertVertex( nextNearestIdx, nearestPoint );
901  zone->Hatch();
902 
903  commit.Push( _( "Add a zone corner" ) );
904  }
905 
906  else if( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T )
907  {
908  bool moduleEdge = item->Type() == PCB_MODULE_EDGE_T;
909 
910  DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
911 
912  if( segment->GetShape() == S_SEGMENT )
913  {
914  commit.Modify( segment );
915 
916  SEG seg( segment->GetStart(), segment->GetEnd() );
917  VECTOR2I nearestPoint = seg.NearestPoint( cursorPos );
918 
919  // Move the end of the line to the break point..
920  segment->SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) );
921 
922  // and add another one starting from the break point
923  DRAWSEGMENT* newSegment;
924 
925  if( moduleEdge )
926  {
927  EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( segment );
928  assert( edge->Type() == PCB_MODULE_EDGE_T );
929  assert( edge->GetParent()->Type() == PCB_MODULE_T );
930  newSegment = new EDGE_MODULE( *edge );
931  }
932  else
933  {
934  newSegment = new DRAWSEGMENT( *segment );
935  }
936 
937  newSegment->ClearSelected();
938  newSegment->SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
939  newSegment->SetEnd( wxPoint( seg.B.x, seg.B.y ) );
940 
941  commit.Add( newSegment );
942  commit.Push( _( "Split segment" ) );
943  }
944  }
945 
946  updatePoints();
947  return 0;
948 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
BOARD_ITEM_CONTAINER * GetParent() const
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
void ClearSelected()
Definition: base_struct.h:258
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:236
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...
int OutlineCount() const
Returns the number of outlines in the set
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
bool IsEndContour() const
Function IsEndContour.
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:73
class MODULE, a footprint
Definition: typeinfo.h:89
STROKE_T GetShape() const
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Class SHAPE_POLY_SET.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
void SetStart(const wxPoint &aStart)
Definition: seg.h:36
Common, abstract interface for edit frames.
Class ITERATOR_TEMPLATE.
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:178
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.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:195
bool POINT_EDITOR::addCornerCondition ( const SELECTION aSelection)
staticprivate

Condition to display "Create corner" context menu entry.

Definition at line 773 of file point_editor.cpp.

References SELECTION::Front(), PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_ZONE_AREA_T, S_SEGMENT, SELECTION::Size(), and EDA_ITEM::Type().

Referenced by Init().

774 {
775  if( aSelection.Size() != 1 )
776  return false;
777 
778  auto item = aSelection.Front();
779 
780  // Works only for zones and line segments
781  return item->Type() == PCB_ZONE_AREA_T ||
782  ( ( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T ) &&
783  static_cast<DRAWSEGMENT*>( item )->GetShape() == S_SEGMENT );
784 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
EDA_ITEM * Front() const
Definition: selection.h:144
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
usual segment : line with rounded ends
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
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.

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

Referenced by TOOL_MANAGER::RegisterTool().

60 {
61  m_toolMgr = aManager;
62  m_toolSettings = TOOL_SETTINGS( this );
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
friend class TOOL_SETTINGS
Definition: tool_base.h:155
BOARD* PCB_TOOL::board ( ) const
inlineprotectedinherited

Definition at line 135 of file pcb_tool.h.

Referenced by PCBNEW_CONTROL::AppendBoard(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), EDIT_TOOL::changeTrackWidthOnClick(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL::doInteractiveItemPlacement(), MODULE_EDITOR_TOOLS::EnumeratePads(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), finishItem(), SELECTION_TOOL::getCollectorsGuide(), ROUTER_TOOL::getNetclassDimensions(), PCBNEW_CONTROL::GridResetOrigin(), PAD_TOOL::haveFootprints(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), ROUTER_TOOL::mainLoop(), PCB_TOOL::module(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::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(), ROUTER_TOOL::prepareInteractive(), PCBNEW_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectAllItemsConnectedToItem(), SELECTION_TOOL::selectAllItemsConnectedToTrack(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectPoint(), 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().

135 { return getModel<BOARD>(); }
PCB_DRAW_PANEL_GAL * PCB_TOOL::canvas ( ) const
protectedinherited

Definition at line 213 of file pcb_tool.cpp.

References PCB_TOOL::frame(), and EDA_DRAW_FRAME::GetGalCanvas().

Referenced by PCBNEW_CONTROL::HighContrastMode(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::TrackDisplayMode(), PCBNEW_CONTROL::ViaDisplayMode(), PCBNEW_CONTROL::ZoneDisplayMode(), and SELECTION_TOOL::zoomFitSelection().

214 {
215  return static_cast<PCB_DRAW_PANEL_GAL*>( frame()->GetGalCanvas() );
216 }
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:864
PCB_DISPLAY_OPTIONS * PCB_TOOL::displayOptions ( ) const
protectedinherited

Definition at line 208 of file pcb_tool.cpp.

References PCB_TOOL::frame(), and PCB_BASE_FRAME::GetDisplayOptions().

Referenced by PCBNEW_CONTROL::HighContrastMode(), PCBNEW_CONTROL::PadDisplayMode(), PNS::TOOL_BASE::pickSingleItem(), PCBNEW_CONTROL::TrackDisplayMode(), PCBNEW_CONTROL::ViaDisplayMode(), and PCBNEW_CONTROL::ZoneDisplayMode().

209 {
210  return static_cast<PCB_DISPLAY_OPTIONS*>( frame()->GetDisplayOptions() );
211 }
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
void PCB_TOOL::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.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), COMMIT::Add(), PCB_TOOL::board(), BUT_LEFT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), dyn_cast(), PCB_ACTIONS::flip, PCB_TOOL::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_TOOL::IPO_FLIP, PCB_TOOL::IPO_REPEAT, PCB_TOOL::IPO_ROTATE, PCB_TOOL::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, INTERACTIVE_PLACER_BASE::m_frame, PCB_TOOL::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(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, KIGFX::PCB_VIEW::Update(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

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 
63  if( aOptions & IPO_SINGLE_CLICK )
64  {
65  VECTOR2I cursorPos = controls()->GetCursorPosition();
66 
67  newItem = aPlacer->CreateItem();
68  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
69 
70  preview.Add( newItem.get() );
71  }
72 
73  // Main loop: keep receiving events
74  while( OPT_TOOL_EVENT evt = Wait() )
75  {
76  VECTOR2I cursorPos = controls()->GetCursorPosition();
77 
79  {
80  if( newItem )
81  {
82  // Delete the old item and have another try
83  newItem = nullptr;
84 
85  preview.Clear();
86 
87  if( aOptions & IPO_SINGLE_CLICK )
88  break;
89 
90  controls()->SetAutoPan( false );
91  controls()->CaptureCursor( false );
92  controls()->ShowCursor( true );
93  }
94  else
95  {
96  break;
97  }
98 
99  if( evt->IsActivate() ) // now finish unconditionally
100  break;
101  }
102 
103  else if( evt->IsClick( BUT_LEFT ) )
104  {
105  if( !newItem )
106  {
107  // create the item if possible
108  newItem = aPlacer->CreateItem();
109 
110  // no item created, so wait for another click
111  if( !newItem )
112  continue;
113 
114  controls()->CaptureCursor( true );
115  controls()->SetAutoPan( true );
116 
117  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
118 
119  preview.Add( newItem.get() );
120 
121  if( newItem->Type() == PCB_MODULE_T )
122  {
123  auto module = dyn_cast<MODULE*>( newItem.get() );
124 
125  // modules have more drawable parts
126  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
127  }
128  }
129  else
130  {
131  newItem->ClearFlags();
132  preview.Remove( newItem.get() );
133 
134  aPlacer->PlaceItem( newItem.get() );
135 
136  if( newItem->Type() == PCB_MODULE_T )
137  {
138  auto module = dyn_cast<MODULE*>( newItem.get() );
139  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
140  }
141 
142  commit.Add( newItem.release() );
143  commit.Push( aCommitMessage );
144 
145  controls()->CaptureCursor( false );
146  controls()->SetAutoPan( false );
147  controls()->ShowCursor( true );
148 
149  if( !( aOptions & IPO_REPEAT ) )
150  break;
151 
152  if( aOptions & IPO_SINGLE_CLICK )
153  {
155 
156  newItem = aPlacer->CreateItem();
157  newItem->SetPosition( wxPoint( pos.x, pos.y ) );
158 
159  preview.Add( newItem.get() );
160  }
161  }
162  }
163 
164  else if( newItem && evt->Category() == TC_COMMAND )
165  {
166  /*
167  * Handle any events that can affect the item as we move
168  * it around, eg rotate and flip
169  */
170 
171  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
172  {
173  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
174  *frame(), *evt );
175  newItem->Rotate( newItem->GetPosition(), rotationAngle );
176  view()->Update( &preview );
177  }
178  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
179  {
180  newItem->Flip( newItem->GetPosition() );
181  view()->Update( &preview );
182  }
183  }
184 
185  else if( newItem && evt->IsMotion() )
186  {
187  // track the cursor
188  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
189 
190  // Show a preview of the item
191  view()->Update( &preview );
192  }
193  }
194 
195  view()->Remove( &preview );
196 }
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.
void RunOnChildren(std::function< void(BOARD_ITEM *)> aFunction)
Function RunOnChildren.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:81
virtual bool PlaceItem(BOARD_ITEM *aItem)
Definition: pcb_tool.h:55
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:81
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.h:57
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:61
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:64
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:133
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. ...
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
MODULE * module() const
Definition: pcb_tool.h:136
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()
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:99
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool...
Definition: tool_base.h:144
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:48
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:460
BOARD * board() const
Definition: pcb_tool.h:135
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:76
bool PCB_TOOL::EditingModules ( ) const
inlineinherited

Definition at line 97 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), PAD_TOOL::Init(), and EDIT_TOOL::MeasureTool().

98  {
99  return m_editModules;
100  }
bool m_editModules
Definition: pcb_tool.h:142
const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited
void POINT_EDITOR::finishItem ( )
private

Applies the last changes to the edited item.

Definition at line 564 of file point_editor.cpp.

References PCB_TOOL::board(), ZONE_FILLER::Fill(), m_editPoints, and PCB_ZONE_AREA_T.

Referenced by OnSelectionChange().

565 {
566  auto item = m_editPoints->GetParent();
567  if( !item )
568  return;
569 
570  if( item->Type() == PCB_ZONE_AREA_T )
571  {
572  auto zone = static_cast<ZONE_CONTAINER*>( item );
573 
574  if( zone->IsFilled() )
575  {
576  ZONE_FILLER filler( board() );
577  filler.Fill( { zone } );
578  }
579  }
580 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:73
BOARD * board() const
Definition: pcb_tool.h:135
PCB_EDIT_FRAME* PCB_TOOL::frame ( ) const
inlineprotectedinherited

Definition at line 134 of file pcb_tool.h.

Referenced by addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), PAD_TOOL::applyPadSettings(), PCB_TOOL::canvas(), EDIT_TOOL::changeTrackWidthOnClick(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL::displayOptions(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), ROUTER_TOOL::finishInteractive(), SELECTION_TOOL::Init(), ROUTER_TOOL::InlineDrag(), PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MeasureTool(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PasteItemsFromClipboard(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), MODULE_EDITOR_TOOLS::PlacePad(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::RouteDiffPair(), ROUTER_TOOL::RouteSingleTrace(), ROUTER_TOOL::SettingsDialog(), ROUTER_TOOL::switchLayerOnViaPlacement(), LENGTH_TUNER_TOOL::TuneDiffPair(), LENGTH_TUNER_TOOL::TuneDiffPairSkew(), LENGTH_TUNER_TOOL::TuneSingleTrace(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

134 { return getEditFrame<PCB_EDIT_FRAME>(); }
EDIT_POINT POINT_EDITOR::get45DegConstrainer ( ) const
private

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

Definition at line 711 of file point_editor.cpp.

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

712 {
713  EDA_ITEM* item = m_editPoints->GetParent();
714 
715  switch( item->Type() )
716  {
717  case PCB_LINE_T:
718  case PCB_MODULE_EDGE_T:
719  {
720  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
721  {
722  switch( segment->GetShape() )
723  {
724  case S_SEGMENT:
725  return *( m_editPoints->Next( *m_editedPoint ) ); // select the other end of line
726 
727  case S_ARC:
728  case S_CIRCLE:
729  return m_editPoints->Point( CIRC_CENTER );
730 
731  default: // suppress warnings
732  break;
733  }
734  }
735 
736  break;
737  }
738 
739  case PCB_DIMENSION_T:
740  {
741  // Constraint for crossbar
742  if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
743  return m_editPoints->Point( DIM_FEATUREDO );
744 
745  else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
746  return m_editPoints->Point( DIM_FEATUREGO );
747 
748  else
749  return EDIT_POINT( m_editedPoint->GetPosition() ); // no constraint
750 
751  break;
752  }
753 
754  default:
755  break;
756  }
757 
758  // In any other case we may align item to its original position
759  return m_original;
760 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
usual segment : line with rounded ends
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:73
STROKE_T GetShape() const
Arcs (with rounded ends)
bool isModified(const EDIT_POINT &aPoint) const
Returns true if aPoint is the currently modified point.
Definition: point_editor.h:97
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:178
EDIT_POINT m_original
Original position for the current drag point.
Definition: point_editor.h:70
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:67
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.

References TOOL_BASE::getEditFrameInt().

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

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
T
enum T contains all this lexer's tokens.
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47
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.

References TOOL_BASE::m_toolId.

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

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

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), PCB_TOOL::doInteractiveItemPlacement(), CONTEXT_MENU::getToolManager(), EDIT_TOOL::MeasureTool(), and CONTEXT_MENU::onMenuEvent().

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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.

References TOOL_BASE::getModelInt().

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

200  {
201  EDA_ITEM* m = getModelInt();
202 
203  return static_cast<T*>( m );
204  }
T
enum T contains all this lexer's tokens.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:178
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:53
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.

References TOOL_BASE::m_toolName.

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

134  {
135  return m_toolName;
136  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:214
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

References TOOL_BASE::m_toolSettings.

Referenced by GERBVIEW_CONTROL::HighlightControl(), ROUTER_TOOL::Init(), SELECTION_TOOL::selectable(), and ROUTER_TOOL::~ROUTER_TOOL().

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
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.

References TOOL_BASE::m_type.

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

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:207
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.

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

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), EDIT_TOOL::MoveExact(), OnSelectionChange(), PCBNEW_CONTROL::PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PCB_EDITOR_CONTROL::Reset(), PCBNEW_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), DRAWING_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), updateEditedPoint(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_TOOL::view(), COMMON_TOOLS::ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

36 {
37  return m_toolMgr->GetView();
38 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
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.

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

Referenced by addCorner(), PCB_TOOL::controls(), PCBNEW_CONTROL::CursorControl(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawZone(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), PCB_EDITOR_CONTROL::HighlightNet(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), OnSelectionChange(), ROUTER_TOOL::performDragging(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::Reset(), PCBNEW_CONTROL::ResetCoords(), DRAWING_TOOL::runPolygonEventLoop(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PICKER_TOOL::setControls(), setEditedPoint(), EDIT_TOOL::updateModificationPoint(), COMMON_TOOLS::ZoomCenter(), and COMMON_TOOLS::ZoomInOut().

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257
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.

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PAD_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), setTransitions(), COMMON_TOOLS::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SELECTION_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), and DRAWING_TOOL::setTransitions().

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

Definition at line 233 of file point_editor.cpp.

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

234 {
235  // Find the selection tool, so they can cooperate
236  m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
237 
238  if( !m_selectionTool )
239  {
240  DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) );
241  return false;
242  }
243 
244  auto& menu = m_selectionTool->GetToolMenu().GetMenu();
247  std::bind( &POINT_EDITOR::removeCornerCondition, this, _1 ) );
248 
249  return true;
250 }
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
Class SELECTION_TOOL.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:49
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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:213
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
Definition: pcb_actions.h:216
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: point_editor.h:64
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddItem()
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:73
static bool addCornerCondition(const SELECTION &aSelection)
Condition to display "Create corner" context menu entry.
bool POINT_EDITOR::isModified ( const EDIT_POINT aPoint) const
inlineprivate

Returns true if aPoint is the currently modified point.

Definition at line 97 of file point_editor.h.

Referenced by get45DegConstrainer(), and updateItem().

98  {
99  return m_editedPoint == &aPoint;
100  }
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:67
bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

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

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

Definition at line 1019 of file point_editor.cpp.

References updatePoints().

Referenced by setTransitions().

1020 {
1021  updatePoints();
1022  return 0;
1023 }
void updatePoints()
Updates edit points with item's points.
int POINT_EDITOR::OnSelectionChange ( const TOOL_EVENT aEvent)

Function OnSelected()

Change selection event handler.

Definition at line 271 of file point_editor.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::VIEW::Add(), EDIT_POINT::ApplyConstraint(), BUT_LEFT, CHT_MODIFY, SELECTION_TOOL::ClearedEvent, PCB_TOOL::controls(), finishItem(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), SELECTION::Front(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), SELECTION_TOOL::GetSelection(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), m_altConstraint, m_editedPoint, m_editPoints, m_original, m_selectionTool, TOOL_BASE::m_toolMgr, EDIT_POINTS_FACTORY::Make(), MD_CTRL, TOOL_MANAGER::PassEvent(), BOARD_COMMIT::Push(), KIGFX::VIEW::Remove(), BOARD_COMMIT::Revert(), SELECTION_TOOL::SelectedEvent, PCB_TOOL::selection(), setAltConstraint(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDIT_POINT::SetPosition(), SELECTION::Size(), COMMIT::StageItems(), SELECTION_TOOL::UnselectedEvent, updateEditedPoint(), updateItem(), updatePoints(), PCB_TOOL::view(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

272 {
274 
275  if( selection.Size() != 1 )
276  return 0;
277 
278  Activate();
279 
281  KIGFX::VIEW* view = getView();
282  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
283  auto item = selection.Front();
284 
285  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
286 
287  if( !m_editPoints )
288  return 0;
289 
290  view->Add( m_editPoints.get() );
291  m_editedPoint = NULL;
292  bool modified = false;
293  bool revert = false;
294 
295  BOARD_COMMIT commit( editFrame );
296 
297  // Main loop: keep receiving events
298  while( OPT_TOOL_EVENT evt = Wait() )
299  {
300  if( revert )
301  break;
302 
303  if( !m_editPoints ||
304  evt->Matches( m_selectionTool->ClearedEvent ) ||
305  evt->Matches( m_selectionTool->UnselectedEvent ) ||
306  evt->Matches( m_selectionTool->SelectedEvent ) )
307  {
308  break;
309  }
310 
311  if ( !modified )
312  updateEditedPoint( *evt );
313 
314  if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
315  {
316  if( !modified )
317  {
318  commit.StageItems( selection, CHT_MODIFY );
319 
320  controls->ForceCursorPosition( false );
321  m_original = *m_editedPoint; // Save the original position
322  controls->SetAutoPan( true );
323  modified = true;
324  }
325 
326  bool enableAltConstraint = !!evt->Modifier( MD_CTRL );
327 
328  if( enableAltConstraint != (bool) m_altConstraint ) // alternative constraint
329  setAltConstraint( enableAltConstraint );
330 
332 
333  if( m_altConstraint )
334  m_altConstraint->Apply();
335  else
337 
338  updateItem();
339  updatePoints();
340  }
341 
342  else if( evt->IsMouseUp( BUT_LEFT ) )
343  {
344  controls->SetAutoPan( false );
345  setAltConstraint( false );
346 
347  if( modified )
348  {
349  commit.Push( _( "Drag a line ending" ) );
350  modified = false;
351  }
352 
353  m_toolMgr->PassEvent();
354  }
355 
356  else if( evt->IsCancel() )
357  {
358  if( modified ) // Restore the last change
359  revert = true;
360 
361  // Let the selection tool receive the event too
362  m_toolMgr->PassEvent();
363 
364  // Do not exit right now, let the selection clear the selection
365  //break;
366  }
367 
368  else
369  {
370  m_toolMgr->PassEvent();
371  }
372  }
373 
374  if( m_editPoints )
375  {
376  view->Remove( m_editPoints.get() );
377 
378  if( modified && revert )
379  commit.Revert();
380  else
381  finishItem();
382 
383  m_editPoints.reset();
384  }
385 
386  return 0;
387 }
void updateItem() const
Updates item's points with edit points.
void updateEditedPoint(const TOOL_EVENT &aEvent)
Updates which point is being edited.
EDA_ITEM * Front() const
Definition: selection.h:144
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:342
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void setAltConstraint(bool aEnabled)
Sets up an alternative constraint (typically enabled upon a modifier key being pressed).
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
void PassEvent()
Allows a tool to pass the already handled event to the next tool on the stack.
Definition: tool_manager.h:351
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:73
void finishItem()
Applies the last changes to the edited item.
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:133
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
Definition: point_editor.h:76
SELECTION & GetSelection()
Function GetSelection()
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: point_editor.h:64
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
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
Common, abstract interface for edit frames.
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
void updatePoints()
Updates edit points with item's points.
EDIT_POINT m_original
Original position for the current drag point.
Definition: point_editor.h:70
void Activate()
Function Activate() Runs the tool.
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:312
Class VIEW.
Definition: view.h:58
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:67
virtual void ApplyConstraint()
Function ApplyConstraint()
Definition: edit_points.h:159
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:460
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:97
void POINT_EDITOR::removeCorner ( EDIT_POINT aPoint)
private

Removes a corner.

Referenced by setTransitions().

int POINT_EDITOR::removeCorner ( const TOOL_EVENT aEvent)
private

Definition at line 951 of file point_editor.cpp.

References findVertex(), PCB_TOOL::frame(), m_editedPoint, m_editPoints, TOOL_BASE::m_toolMgr, SHAPE_POLY_SET::Outline(), PCB_LINE_T, PCB_ZONE_AREA_T, SHAPE_POLY_SET::Polygon(), SHAPE_POLY_SET::RemoveContour(), SHAPE_POLY_SET::RemoveVertex(), TOOL_MANAGER::RunAction(), S_POLYGON, PCB_ACTIONS::selectionClear, setEditedPoint(), EDA_ITEM::Type(), and updatePoints().

952 {
953  if( !m_editedPoint )
954  return 0;
955 
956  EDA_ITEM* item = m_editPoints->GetParent();
957 
958  if( !item )
959  return 0;
960 
961  SHAPE_POLY_SET* polygon = nullptr;
962 
963  if( item->Type() == PCB_ZONE_AREA_T)
964  {
965  auto zone = static_cast<ZONE_CONTAINER*>( item );
966  polygon = zone->Outline();
967  }
968  else if( item->Type() == PCB_LINE_T )
969  {
970  auto ds = static_cast<DRAWSEGMENT*>( item );
971 
972  if( ds->GetShape() == S_POLYGON )
973  polygon = &ds->GetPolyShape();
974  }
975 
976  if( !polygon )
977  return 0;
978 
979  PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
980  BOARD_COMMIT commit( frame );
981  auto vertex = findVertex( *polygon, *m_editedPoint );
982 
983  if( vertex.first )
984  {
985  const auto& vertexIdx = vertex.second;
986  auto& outline = polygon->Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
987 
988  if( outline.PointCount() > 3 )
989  {
990  // the usual case: remove just the corner when there are >3 vertices
991  commit.Modify( item );
992  polygon->RemoveVertex( vertexIdx );
993  }
994  else
995  {
996  // either remove a hole or the polygon when there are <= 3 corners
997  if( vertexIdx.m_contour > 0 )
998  {
999  // remove hole
1000  commit.Modify( item );
1001  polygon->RemoveContour( vertexIdx.m_contour );
1002  }
1003  else
1004  {
1006  commit.Remove( item );
1007  }
1008  }
1009 
1010  setEditedPoint( nullptr );
1011  commit.Push( _( "Remove a zone/polygon corner" ) );
1012  updatePoints();
1013  }
1014 
1015  return 0;
1016 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
polygon (not yet used for tracks, but could be in microwave apps)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:73
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
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:178
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:67
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...
void RemoveContour(int aContourIdx, int aPolygonIdx=-1)
Function RemoveContour deletes the aContourIdx-th contour of the aPolygonIdx-th polygon in the set...
bool POINT_EDITOR::removeCornerCondition ( const SELECTION aSelection)
private

Condition to display "Remove corner" context menu entry.

Definition at line 803 of file point_editor.cpp.

References findVertex(), m_editedPoint, m_editPoints, ZONE_CONTAINER::Outline(), PCB_ZONE_AREA_T, and EDA_ITEM::Type().

Referenced by Init().

804 {
805  if( !m_editPoints || !m_editedPoint )
806  return false;
807 
808  EDA_ITEM* item = m_editPoints->GetParent();
809 
810  if( !item || item->Type() != PCB_ZONE_AREA_T )
811  return false;
812 
813  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
814  auto& polyset = *zone->Outline();
815  auto vertex = findVertex( polyset, *m_editedPoint );
816 
817  if( !vertex.first )
818  return false;
819 
820  const auto& vertexIdx = vertex.second;
821 
822  // Check if there are enough vertices so one can be removed without
823  // degenerating the polygon.
824  // The first condition allows to remove all corners from holes (when there
825  // are only 2 vertices left, a hole is removed).
826  if( vertexIdx.m_contour == 0 && polyset.Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour].PointCount() <= 3 )
827  return false;
828 
829  // Remove corner does not work with lines
830  if( dynamic_cast<EDIT_LINE*>( m_editedPoint ) )
831  return false;
832 
833  return m_editedPoint != NULL;
834 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:236
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:73
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:178
static std::pair< bool, SHAPE_POLY_SET::VERTEX_INDEX > findVertex(SHAPE_POLY_SET &aPolySet, const EDIT_POINT &aPoint)
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:67
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.

Definition at line 226 of file point_editor.cpp.

References m_altConstraint, and m_editPoints.

227 {
228  m_editPoints.reset();
229  m_altConstraint.reset();
230 }
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:73
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
Definition: point_editor.h:76
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.

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

Referenced by DRAWING_TOOL::PlaceText().

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
const SELECTION & PCB_TOOL::selection ( ) const
protectedinherited

Definition at line 218 of file pcb_tool.cpp.

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

Referenced by PAD_TOOL::applyPadSettings(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), EDIT_TOOL::ExchangeFootprints(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), OnSelectionChange(), PCBNEW_CONTROL::placeBoardItems(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Remove(), EDIT_TOOL::Rotate(), SELECTION_TOOL::selectConnection(), SELECTION_TOOL::selectCopper(), PCB_TOOL::selection(), SELECTION_TOOL::selectNet(), EDIT_TOOL::uniqueSelected(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

219 {
220  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
221  const auto& selection = selTool->GetSelection();
222  return selection;
223 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
SELECTION & PCB_TOOL::selection ( )
protectedinherited

Definition at line 225 of file pcb_tool.cpp.

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

226 {
227  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
228  auto& selection = selTool->GetSelection();
229  return selection;
230 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
void POINT_EDITOR::setAltConstraint ( bool  aEnabled)
private

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

Definition at line 686 of file point_editor.cpp.

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

Referenced by OnSelectionChange().

687 {
688  if( aEnabled )
689  {
690  EDIT_LINE* line = dynamic_cast<EDIT_LINE*>( m_editedPoint );
691 
692  if( line )
693  {
694  if( m_editPoints->GetParent()->Type() == PCB_ZONE_AREA_T )
696  }
697  else
698  {
699  // Find a proper constraining point for 45 degrees mode
702  }
703  }
704  else
705  {
706  m_altConstraint.reset();
707  }
708 }
Class EC_CONVERGING.
Class EDIT_LINE.
Definition: edit_points.h:189
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
Class EC_45DEGREE.
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:73
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
Definition: point_editor.h:76
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:79
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:67
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_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.

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

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

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:215
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool's context popup menu.
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void POINT_EDITOR::setEditedPoint ( EDIT_POINT aPoint)
private

Sets the current point being edited. NULL means none.

Definition at line 665 of file point_editor.cpp.

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

Referenced by removeCorner(), and updateEditedPoint().

666 {
668 
669  if( aPoint )
670  {
671  controls->ForceCursorPosition( true, aPoint->GetPosition() );
672  controls->ShowCursor( true );
673  controls->SetSnapping( true );
674  }
675  else
676  {
677  controls->ShowCursor( false );
678  controls->SetSnapping( false );
679  controls->ForceCursorPosition( false );
680  }
681 
682  m_editedPoint = aPoint;
683 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:133
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 * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:67
void PCB_TOOL::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 92 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

93  {
94  m_editModules = aEnabled;
95  }
bool m_editModules
Definition: pcb_tool.h:142
void POINT_EDITOR::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL.

Definition at line 763 of file point_editor.cpp.

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

764 {
770 }
int OnSelectionChange(const TOOL_EVENT &aEvent)
Function OnSelected()
void addCorner(const VECTOR2I &aPoint)
Adds a new edit point on a zone outline/line.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:108
static TOOL_ACTION pointEditorAddCorner
Break outline (insert additional points to an edge)
Definition: pcb_actions.h:213
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
Definition: pcb_actions.h:216
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
void removeCorner(EDIT_POINT *aPoint)
Removes a corner.
int modifiedSelection(const TOOL_EVENT &aEvent)
void POINT_EDITOR::updateEditedPoint ( const TOOL_EVENT aEvent)
private

Updates which point is being edited.

Definition at line 253 of file point_editor.cpp.

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

254 {
255  EDIT_POINT* point = m_editedPoint;
256 
257  if( aEvent.IsMotion() )
258  {
259  point = m_editPoints->FindPoint( aEvent.Position(), getView() );
260  }
261  else if( aEvent.IsDrag( BUT_LEFT ) )
262  {
263  point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
264  }
265 
266  if( m_editedPoint != point )
267  setEditedPoint( point );
268 }
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:255
bool IsMotion() const
Definition: tool_event.h:290
const VECTOR2D & Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:248
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:73
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:67
void setEditedPoint(EDIT_POINT *aPoint)
Sets the current point being edited. NULL means none.
void POINT_EDITOR::updateItem ( ) const
private

Updates item's points with edit points.

Definition at line 390 of file point_editor.cpp.

References VECTOR2< T >::Angle(), ARC_CENTER, ARC_END, ARC_START, CIRC_CENTER, CIRC_END, ZONE_CONTAINER::ClearFilledPolysList(), DIM_CROSSBARF, DIM_CROSSBARO, DIM_FEATUREDO, DIM_FEATUREGO, DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetArcEnd(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetCenter(), DIMENSION::GetEnd(), DIMENSION::GetOrigin(), DRAWSEGMENT::GetPolyShape(), EDIT_POINT::GetPosition(), DRAWSEGMENT::GetShape(), ZONE_CONTAINER::Hatch(), 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(), S_ARC, S_CIRCLE, S_POLYGON, S_SEGMENT, SEG_END, SEG_START, DRAWSEGMENT::SetAngle(), DRAWSEGMENT::SetArcStart(), DRAWSEGMENT::SetEnd(), DIMENSION::SetEnd(), DIMENSION::SetHeight(), DIMENSION::SetOrigin(), DRAWSEGMENT::SetStart(), SHAPE_POLY_SET::TotalVertices(), EDA_ITEM::Type(), SHAPE_POLY_SET::Vertex(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by OnSelectionChange().

391 {
392  EDA_ITEM* item = m_editPoints->GetParent();
393 
394  if( !item )
395  return;
396 
397  switch( item->Type() )
398  {
399  case PCB_LINE_T:
400  case PCB_MODULE_EDGE_T:
401  {
402  DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
403  switch( segment->GetShape() )
404  {
405  case S_SEGMENT:
406  if( isModified( m_editPoints->Point( SEG_START ) ) )
407  segment->SetStart( wxPoint( m_editPoints->Point( SEG_START ).GetPosition().x,
408  m_editPoints->Point( SEG_START ).GetPosition().y ) );
409 
410  else if( isModified( m_editPoints->Point( SEG_END ) ) )
411  segment->SetEnd( wxPoint( m_editPoints->Point( SEG_END ).GetPosition().x,
412  m_editPoints->Point( SEG_END ).GetPosition().y ) );
413 
414  break;
415 
416  case S_ARC:
417  {
418  const VECTOR2I& center = m_editPoints->Point( ARC_CENTER ).GetPosition();
419  const VECTOR2I& start = m_editPoints->Point( ARC_START ).GetPosition();
420  const VECTOR2I& end = m_editPoints->Point( ARC_END ).GetPosition();
421 
422  if( center != segment->GetCenter() )
423  {
424  wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
425  segment->Move( moveVector );
426 
427  m_editPoints->Point( ARC_START ).SetPosition( segment->GetArcStart() );
428  m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
429  }
430 
431  else
432  {
433  segment->SetArcStart( wxPoint( start.x, start.y ) );
434 
435  VECTOR2D startLine = start - center;
436  VECTOR2I endLine = end - center;
437  double newAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
438 
439  // Adjust the new angle to (counter)clockwise setting
440  bool clockwise = ( segment->GetAngle() > 0 );
441 
442  if( clockwise && newAngle < 0.0 )
443  newAngle += 3600.0;
444  else if( !clockwise && newAngle > 0.0 )
445  newAngle -= 3600.0;
446 
447  segment->SetAngle( newAngle );
448  }
449 
450  break;
451  }
452 
453  case S_CIRCLE:
454  {
455  const VECTOR2I& center = m_editPoints->Point( CIRC_CENTER ).GetPosition();
456  const VECTOR2I& end = m_editPoints->Point( CIRC_END ).GetPosition();
457 
458  if( isModified( m_editPoints->Point( CIRC_CENTER ) ) )
459  {
460  wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
461  segment->Move( moveVector );
462  }
463  else
464  {
465  segment->SetEnd( wxPoint( end.x, end.y ) );
466  }
467 
468  break;
469  }
470 
471  case S_POLYGON:
472  {
473  SHAPE_POLY_SET* outline = &segment->GetPolyShape();
474 
475  for( int i = 0; i < outline->TotalVertices(); ++i )
476  {
477  VECTOR2I point = m_editPoints->Point( i ).GetPosition();
478  outline->Vertex( i ) = point;
479  }
480  }
481 
482  default: // suppress warnings
483  break;
484  }
485 
486  // Update relative coordinates for module edges
487  if( EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item ) )
488  edge->SetLocalCoord();
489 
490  break;
491  }
492 
493  case PCB_ZONE_AREA_T:
494  {
495  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
496  zone->ClearFilledPolysList();
497  SHAPE_POLY_SET* outline = zone->Outline();
498 
499  for( int i = 0; i < outline->TotalVertices(); ++i )
500  {
501  VECTOR2I point = m_editPoints->Point( i ).GetPosition();
502  outline->Vertex( i ) = point;
503  }
504 
505  zone->Hatch();
506 
507  break;
508  }
509 
510  case PCB_DIMENSION_T:
511  {
512  DIMENSION* dimension = static_cast<DIMENSION*>( item );
513 
514  // Check which point is currently modified and updated dimension's points respectively
515  if( isModified( m_editPoints->Point( DIM_CROSSBARO ) ) )
516  {
517  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetOrigin() );
518  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
519 
520  if( featureLine.Cross( crossBar ) > 0 )
521  dimension->SetHeight( -featureLine.EuclideanNorm() );
522  else
523  dimension->SetHeight( featureLine.EuclideanNorm() );
524  }
525 
526  else if( isModified( m_editPoints->Point( DIM_CROSSBARF ) ) )
527  {
528  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetEnd() );
529  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
530 
531  if( featureLine.Cross( crossBar ) > 0 )
532  dimension->SetHeight( -featureLine.EuclideanNorm() );
533  else
534  dimension->SetHeight( featureLine.EuclideanNorm() );
535  }
536 
537  else if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
538  {
540  m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
541  m_editPoints->Point( DIM_FEATUREGO ) ) );
542  m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
543  m_editPoints->Point( DIM_FEATUREDO ) ) );
544  }
545 
546  else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
547  {
549  m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
550  m_editPoints->Point( DIM_FEATUREGO ) ) );
551  m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
552  m_editPoints->Point( DIM_FEATUREDO ) ) );
553  }
554 
555  break;
556  }
557 
558  default:
559  break;
560  }
561 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
const wxPoint GetCenter() const override
Function GetCenter()
polygon (not yet used for tracks, but could be in microwave apps)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
int TotalVertices() const
Returns total number of vertices stored in the set.
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:236
double RAD2DECIDEG(double rad)
Definition: trigo.h:204
usual segment : line with rounded ends
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
Class EC_LINE.
const wxPoint & GetArcStart() const
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:73
double Angle() const
Function Angle computes the angle of the vector.
Definition: vector2d.h:308
STROKE_T GetShape() const
void SetOrigin(const wxPoint &aOrigin)
Function SetOrigin Sets a new origin of the crossbar line.
const wxPoint & GetEnd()
Function GetEnd.
Class SHAPE_POLY_SET.
const wxPoint & GetOrigin() const
Function GetOrigin.
void SetEnd(const wxPoint &aEnd)
Function SetEnd Sets a new end of the crossbar line.
Arcs (with rounded ends)
bool isModified(const EDIT_POINT &aPoint) const
Returns true if aPoint is the currently modified point.
Definition: point_editor.h:97
SHAPE_POLY_SET & GetPolyShape()
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
virtual void Move(const wxPoint &aMoveVector) override
Function Move move this object.
void SetStart(const wxPoint &aStart)
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
double GetAngle() const
void SetHeight(int aHeight)
Function SetHeight Sets the length of feature lines.
const wxPoint GetArcEnd() const
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:178
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:67
Class DIMENSION.
void ClearFilledPolysList()
Function ClearFilledPolysList clears the list of filled polygons.
Definition: class_zone.h:521
void POINT_EDITOR::updatePoints ( )
private

Updates edit points with item's points.

Definition at line 583 of file point_editor.cpp.

References KIGFX::VIEW::Add(), ARC_CENTER, ARC_END, ARC_START, CIRC_CENTER, CIRC_END, SHAPE_POLY_SET::CVertex(), DIM_CROSSBARF, DIM_CROSSBARO, DIM_FEATUREDO, DIM_FEATUREGO, DRAWSEGMENT::GetArcEnd(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetCenter(), DRAWSEGMENT::GetEnd(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), TOOL_BASE::getView(), DIMENSION::m_crossBarF, DIMENSION::m_crossBarO, 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_SEGMENT, SEG_END, SEG_START, SHAPE_POLY_SET::TotalVertices(), EDA_ITEM::Type(), and KIGFX::VIEW::Update().

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

584 {
585  if( !m_editPoints )
586  return;
587 
588  EDA_ITEM* item = m_editPoints->GetParent();
589 
590  if( !item )
591  return;
592 
593  switch( item->Type() )
594  {
595  case PCB_LINE_T:
596  case PCB_MODULE_EDGE_T:
597  {
598  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
599  {
600  switch( segment->GetShape() )
601  {
602  case S_SEGMENT:
603  m_editPoints->Point( SEG_START ).SetPosition( segment->GetStart() );
604  m_editPoints->Point( SEG_END ).SetPosition( segment->GetEnd() );
605  break;
606 
607  case S_ARC:
608  m_editPoints->Point( ARC_CENTER ).SetPosition( segment->GetCenter() );
609  m_editPoints->Point( ARC_START).SetPosition( segment->GetArcStart() );
610  m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
611  break;
612 
613  case S_CIRCLE:
614  m_editPoints->Point( CIRC_CENTER ).SetPosition( segment->GetCenter() );
615  m_editPoints->Point( CIRC_END ).SetPosition( segment->GetEnd() );
616  break;
617 
618  default: // suppress warnings
619  break;
620  }
621 
622  break;
623  }
624  }
625 
626  case PCB_ZONE_AREA_T:
627  {
628  const ZONE_CONTAINER* zone = static_cast<const ZONE_CONTAINER*>( item );
629  const SHAPE_POLY_SET* outline = zone->Outline();
630 
631  if( m_editPoints->PointsSize() != (unsigned) outline->TotalVertices() )
632  {
633  getView()->Remove( m_editPoints.get() );
634  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
635  getView()->Add( m_editPoints.get() );
636  }
637  else
638  {
639  for( int i = 0; i < outline->TotalVertices(); ++i )
640  m_editPoints->Point( i ).SetPosition( outline->CVertex( i ) );
641  }
642 
643  break;
644  }
645 
646  case PCB_DIMENSION_T:
647  {
648  const DIMENSION* dimension = static_cast<const DIMENSION*>( item );
649 
650  m_editPoints->Point( DIM_CROSSBARO ).SetPosition( dimension->m_crossBarO );
651  m_editPoints->Point( DIM_CROSSBARF ).SetPosition( dimension->m_crossBarF );
652  m_editPoints->Point( DIM_FEATUREGO ).SetPosition( dimension->m_featureLineGO );
653  m_editPoints->Point( DIM_FEATUREDO ).SetPosition( dimension->m_featureLineDO );
654  break;
655  }
656 
657  default:
658  break;
659  }
660 
661  getView()->Update( m_editPoints.get() );
662 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
wxPoint m_crossBarF
const wxPoint GetCenter() const override
Function GetCenter()
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:342
int TotalVertices() const
Returns total number of vertices stored in the set.
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:236
usual segment : line with rounded ends
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
const wxPoint & GetArcStart() const
wxPoint m_featureLineGO
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:73
STROKE_T GetShape() const
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Class SHAPE_POLY_SET.
Arcs (with rounded ends)
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:1385
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
const wxPoint GetArcEnd() const
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:178
wxPoint m_crossBarO
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:312
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
wxPoint m_featureLineDO
Class DIMENSION.
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem, KIGFX::GAL *aGal)
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.

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

Referenced by PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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.

Member Data Documentation

EDIT_POINT POINT_EDITOR::m_altConstrainer
private

Definition at line 79 of file point_editor.h.

Referenced by setAltConstraint().

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

Definition at line 76 of file point_editor.h.

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

EDIT_POINT* POINT_EDITOR::m_editedPoint
private

Currently edited point, NULL if there is none.

Definition at line 67 of file point_editor.h.

Referenced by get45DegConstrainer(), OnSelectionChange(), removeCorner(), removeCornerCondition(), setAltConstraint(), setEditedPoint(), updateEditedPoint(), and updateItem().

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

Original position for the current drag point.

Definition at line 70 of file point_editor.h.

Referenced by get45DegConstrainer(), and OnSelectionChange().

SELECTION_TOOL* POINT_EDITOR::m_selectionTool
private

Selection tool used for obtaining selected items

Definition at line 64 of file point_editor.h.

Referenced by Init(), and OnSelectionChange().

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 210 of file tool_base.h.

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), GERBVIEW_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), 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(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), Init(), PCB_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), PCBNEW_CONTROL::placeBoardItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), removeCorner(), GERBVIEW_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), TOOL_INTERACTIVE::resetTransitions(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SELECTION_TOOL::SanitizeSelection(), SELECTION_TOOL::selectConnection(), SELECTION_TOOL::selectCopper(), PCB_TOOL::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), GERBVIEW_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EDIT_TOOL::updateModificationPoint(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

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

Referenced by TOOL_BASE::GetName().

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 of file tool_base.h.

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

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 207 of file tool_base.h.

Referenced by TOOL_BASE::GetType().


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