KiCad PCB EDA Suite
POINT_EDITOR Class Reference

Class POINT_EDITOR. More...

#include <point_editor.h>

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

Protected Member Functions

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

Protected Attributes

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

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 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 203 of file point_editor.cpp.

203  :
204  TOOL_INTERACTIVE( "pcbnew.PointEditor" ), m_selectionTool( NULL ), m_editedPoint( NULL ),
205  m_original( VECTOR2I( 0, 0 ) ), m_altConstrainer( VECTOR2I( 0, 0 ) )
206 {
207 }
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Constructor.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
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 MODULE_EDITOR_TOOLS::CopyItems(), 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(), EDIT_TOOL::MeasureTool(), OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), and ROUTER_TOOL::SettingsDialog().

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:215
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 769 of file point_editor.cpp.

References COMMIT::Add(), EDA_ITEM::ClearSelected(), SEG::Distance(), 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().

770 {
771  EDA_ITEM* item = m_editPoints->GetParent();
772  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
773  const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition();
774  BOARD_COMMIT commit( frame );
775 
776  if( item->Type() == PCB_ZONE_AREA_T )
777  {
778  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
779  SHAPE_POLY_SET* zoneOutline = zone->Outline();
780 
781  commit.Modify( zone );
782 
783  unsigned int nearestIdx = 0;
784  unsigned int nextNearestIdx = 0;
785  unsigned int nearestDist = INT_MAX;
786  unsigned int firstPointInContour = 0;
787 
788  // Search the best outline segment to add a new corner
789  // and therefore break this segment into two segments
790 
791  // Object to iterate through the corners of the outlines (main contour and its holes)
792  SHAPE_POLY_SET::ITERATOR iterator = zoneOutline->Iterate( 0,
793  zoneOutline->OutlineCount()-1, /* IterateHoles */ true );
794  int curr_idx = 0;
795 
796  // Iterate through all the corners of the outlines and search the best segment
797  for( ; iterator; iterator++, curr_idx++ )
798  {
799  int jj = curr_idx+1;
800 
801  if( iterator.IsEndContour() )
802  { // We reach the last point of the current contour (main or hole)
803  jj = firstPointInContour;
804  firstPointInContour = curr_idx+1; // Prepare next contour analysis
805  }
806 
807  SEG curr_segment( zoneOutline->Vertex( curr_idx ), zoneOutline->Vertex( jj ) );
808 
809  unsigned int distance = curr_segment.Distance( cursorPos );
810 
811  if( distance < nearestDist )
812  {
813  nearestDist = distance;
814  nearestIdx = curr_idx;
815  nextNearestIdx = jj;
816  }
817  }
818 
819 
820  // Find the point on the closest segment
821  VECTOR2I sideOrigin = zoneOutline->Vertex( nearestIdx );
822  VECTOR2I sideEnd = zoneOutline->Vertex( nextNearestIdx );
823  SEG nearestSide( sideOrigin, sideEnd );
824  VECTOR2I nearestPoint = nearestSide.NearestPoint( cursorPos );
825 
826  // Do not add points that have the same coordinates as ones that already belong to polygon
827  // instead, add a point in the middle of the side
828  if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
829  nearestPoint = ( sideOrigin + sideEnd ) / 2;
830 
831  // Add corner between nearestIdx and nextNearestIdx:
832  zoneOutline->InsertVertex( nextNearestIdx, nearestPoint );
833  zone->Hatch();
834 
835  commit.Push( _( "Add a zone corner" ) );
836  }
837 
838  else if( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T )
839  {
840  bool moduleEdge = item->Type() == PCB_MODULE_EDGE_T;
841 
842  DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
843 
844  if( segment->GetShape() == S_SEGMENT )
845  {
846  commit.Modify( segment );
847 
848  SEG seg( segment->GetStart(), segment->GetEnd() );
849  VECTOR2I nearestPoint = seg.NearestPoint( cursorPos );
850 
851  // Move the end of the line to the break point..
852  segment->SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) );
853 
854  // and add another one starting from the break point
855  DRAWSEGMENT* newSegment;
856 
857  if( moduleEdge )
858  {
859  EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( segment );
860  assert( edge->Type() == PCB_MODULE_EDGE_T );
861  assert( edge->GetParent()->Type() == PCB_MODULE_T );
862  newSegment = new EDGE_MODULE( *edge );
863  }
864  else
865  {
866  newSegment = new DRAWSEGMENT( *segment );
867  }
868 
869  newSegment->ClearSelected();
870  newSegment->SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
871  newSegment->SetEnd( wxPoint( seg.B.x, seg.B.y ) );
872 
873  commit.Add( newSegment );
874  commit.Push( _( "Split segment" ) );
875  }
876  }
877 
878  updatePoints();
879  return 0;
880 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
BOARD_ITEM_CONTAINER * GetParent() const
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
void ClearSelected()
Definition: base_struct.h:231
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:247
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:106
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:101
STROKE_T GetShape() const
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
Class SHAPE_POLY_SET.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
void SetStart(const wxPoint &aStart)
Definition: seg.h:37
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...
Definition: class_zone.cpp:919
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
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:103
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int Distance(const SEG &aSeg) const
Function Distance()
Definition: seg.h:185
bool POINT_EDITOR::addCornerCondition ( const SELECTION aSelection)
staticprivate

Condition to display "Create corner" context menu entry.

Definition at line 732 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().

733 {
734  if( aSelection.Size() != 1 )
735  return false;
736 
737  auto item = aSelection.Front();
738 
739  // Works only for zones and line segments
740  return item->Type() == PCB_ZONE_AREA_T ||
741  ( ( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T ) &&
742  static_cast<DRAWSEGMENT*>( item )->GetShape() == S_SEGMENT );
743 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
EDA_ITEM * Front() const
Definition: selection.h:144
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
usual segment : line with rounded ends
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:103
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 54 of file tool_base.cpp.

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

Referenced by TOOL_MANAGER::RegisterTool().

55 {
56  m_toolMgr = aManager;
57  m_toolSettings = TOOL_SETTINGS( this );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
friend class TOOL_SETTINGS
Definition: tool_base.h:160
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 ( ) const
private

Applies the last changes to the edited item.

Definition at line 528 of file point_editor.cpp.

References BOARD_ITEM::GetBoard(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD::GetRatsnest(), ZONE_CONTAINER::IsFilled(), m_editPoints, PCB_ZONE_AREA_T, RN_DATA::Recalculate(), and EDA_ITEM::Type().

Referenced by OnSelectionChange().

529 {
530  EDA_ITEM* item = m_editPoints->GetParent();
531 
532  if( item->Type() == PCB_ZONE_AREA_T )
533  {
534  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
535 
536  if( zone->IsFilled() )
537  {
538  getEditFrame<PCB_EDIT_FRAME>()->Fill_Zone( zone );
539  zone->GetBoard()->GetRatsnest()->Recalculate( zone->GetNetCode() );
540  }
541  }
542 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
bool IsFilled() const
Definition: class_zone.h:200
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:73
RN_DATA * GetRatsnest() const
Function GetRatsnest() returns list of missing connections between components/tracks.
Definition: class_board.h:287
void Recalculate(int aNet=-1)
Function Recalculate() Recomputes ratsnest for selected net number or all nets that need updating...
int GetNetCode() const
Function GetNetCode.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
EDIT_POINT POINT_EDITOR::get45DegConstrainer ( ) const
private

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

Definition at line 670 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().

671 {
672  EDA_ITEM* item = m_editPoints->GetParent();
673 
674  switch( item->Type() )
675  {
676  case PCB_LINE_T:
677  case PCB_MODULE_EDGE_T:
678  {
679  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
680  {
681  switch( segment->GetShape() )
682  {
683  case S_SEGMENT:
684  return *( m_editPoints->Next( *m_editedPoint ) ); // select the other end of line
685 
686  case S_ARC:
687  case S_CIRCLE:
688  return m_editPoints->Point( CIRC_CENTER );
689 
690  default: // suppress warnings
691  break;
692  }
693  }
694 
695  break;
696  }
697 
698  case PCB_DIMENSION_T:
699  {
700  // Constraint for crossbar
701  if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
702  return m_editPoints->Point( DIM_FEATUREDO );
703 
704  else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
705  return m_editPoints->Point( DIM_FEATUREGO );
706 
707  else
708  return EDIT_POINT( m_editedPoint->GetPosition() ); // no constraint
709 
710  break;
711  }
712 
713  default:
714  break;
715  }
716 
717  // In any other case we may align item to its original position
718  return m_original;
719 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
usual segment : line with rounded ends
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
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:112
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:151
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:103
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 193 of file tool_base.h.

References TOOL_BASE::getEditFrameInt().

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

194  {
195  return static_cast<T*>( getEditFrameInt() );
196  }
T
enum T contains all this lexer's tokens.
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:42
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:215
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:220
template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 204 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

205  {
206  EDA_ITEM* m = getModelInt();
207 
208  return static_cast<T*>( m );
209  }
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:151
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:48
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:219
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 72 of file tool_base.cpp.

References TOOL_BASE::m_toolSettings.

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

73 {
74  return m_toolSettings;
75 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
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::InvokeTool(), and TOOL_MANAGER::runTool().

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

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

Referenced by PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), PCBNEW_CONTROL::HighContrastMode(), PNS::TOOL_BASE::highlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), EDIT_TOOL::Main(), EDIT_TOOL::MeasureTool(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), EDIT_TOOL::MoveExact(), OnSelectionChange(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PCB_EDITOR_CONTROL::Reset(), PCBNEW_CONTROL::Reset(), MODULE_EDITOR_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), DRAWING_TOOL::Reset(), SELECTION_TOOL::Reset(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PCBNEW_CONTROL::TrackDisplayMode(), updateEditedPoint(), PNS::TOOL_BASE::updateEndItem(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_TOOL::view(), PCBNEW_CONTROL::ZoneDisplayMode(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneFillAll(), PCB_EDITOR_CONTROL::ZoneUnfill(), PCB_EDITOR_CONTROL::ZoneUnfillAll(), COMMON_TOOLS::ZoomFitScreen(), SELECTION_TOOL::zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), and SELECTION_TOOL::~SELECTION_TOOL().

31 {
32  return m_toolMgr->GetView();
33 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:243
KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited
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 122 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

Referenced by LENGTH_TUNER_TOOL::Reset(), ZOOM_TOOL::SetTransitions(), LENGTH_TUNER_TOOL::SetTransitions(), ROUTER_TOOL::SetTransitions(), PAD_TOOL::SetTransitions(), MICROWAVE_TOOL::SetTransitions(), SetTransitions(), COMMON_TOOLS::SetTransitions(), PLACEMENT_TOOL::SetTransitions(), PCBNEW_CONTROL::SetTransitions(), MODULE_EDITOR_TOOLS::SetTransitions(), PICKER_TOOL::SetTransitions(), PCB_EDITOR_CONTROL::SetTransitions(), SELECTION_TOOL::SetTransitions(), EDIT_TOOL::SetTransitions(), and DRAWING_TOOL::SetTransitions().

124 {
125  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
126 
127  goInternal( sptr, aConditions );
128 }
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 217 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().

218 {
219  // Find the selection tool, so they can cooperate
220  m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
221 
222  if( !m_selectionTool )
223  {
224  DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) );
225  return false;
226  }
227 
228  auto& menu = m_selectionTool->GetToolMenu().GetMenu();
231  std::bind( &POINT_EDITOR::removeCornerCondition, this, _1 ) );
232 
233  return true;
234 }
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_MENU & GetToolMenu()
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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:193
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
Definition: pcb_actions.h:196
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:69
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
int POINT_EDITOR::modifiedSelection ( const TOOL_EVENT aEvent)
private

Definition at line 917 of file point_editor.cpp.

References updatePoints().

Referenced by SetTransitions().

918 {
919  updatePoints();
920  return 0;
921 }
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 255 of file point_editor.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::VIEW::Add(), EDIT_POINT::ApplyConstraint(), BUT_LEFT, CHT_MODIFY, SELECTION_TOOL::ClearedEvent, 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, setAltConstraint(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDIT_POINT::SetPosition(), SELECTION::Size(), COMMIT::StageItems(), SELECTION_TOOL::UnselectedEvent, updateEditedPoint(), updateItem(), updatePoints(), and TOOL_INTERACTIVE::Wait().

Referenced by SetTransitions().

256 {
257  const SELECTION& selection = m_selectionTool->GetSelection();
258 
259  if( selection.Size() != 1 )
260  return 0;
261 
262  Activate();
263 
265  KIGFX::VIEW* view = getView();
266  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
267  auto item = selection.Front();
268 
269  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
270 
271  if( !m_editPoints )
272  return 0;
273 
274  view->Add( m_editPoints.get() );
275  m_editedPoint = NULL;
276  bool modified = false;
277 
278  BOARD_COMMIT commit( editFrame );
279 
280  // Main loop: keep receiving events
281  while( OPT_TOOL_EVENT evt = Wait() )
282  {
283  if( !m_editPoints ||
284  evt->Matches( m_selectionTool->ClearedEvent ) ||
285  evt->Matches( m_selectionTool->UnselectedEvent ) ||
286  evt->Matches( m_selectionTool->SelectedEvent ) )
287  {
288  break;
289  }
290 
291  if ( !modified )
292  updateEditedPoint( *evt );
293 
294  if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
295  {
296  if( !modified )
297  {
298  commit.StageItems( selection, CHT_MODIFY );
299 
300  controls->ForceCursorPosition( false );
301  m_original = *m_editedPoint; // Save the original position
302  controls->SetAutoPan( true );
303  modified = true;
304  }
305 
306  bool enableAltConstraint = !!evt->Modifier( MD_CTRL );
307 
308  if( enableAltConstraint != (bool) m_altConstraint ) // alternative constraint
309  setAltConstraint( enableAltConstraint );
310 
312 
313  if( m_altConstraint )
314  m_altConstraint->Apply();
315  else
317 
318  updateItem();
319  updatePoints();
320  }
321 
322  else if( evt->IsMouseUp( BUT_LEFT ) )
323  {
324  controls->SetAutoPan( false );
325  setAltConstraint( false );
326 
327  if( modified )
328  {
329  commit.Push( _( "Drag a line ending" ) );
330  modified = false;
331  }
332 
333  m_toolMgr->PassEvent();
334  }
335 
336  else if( evt->IsCancel() )
337  {
338  if( modified ) // Restore the last change
339  {
340  commit.Revert();
341  updatePoints();
342  modified = false;
343  }
344 
345  // Let the selection tool receive the event too
346  m_toolMgr->PassEvent();
347 
348  break;
349  }
350 
351  else
352  {
353  m_toolMgr->PassEvent();
354  }
355  }
356 
357  if( m_editPoints )
358  {
359  finishItem();
360  view->Remove( m_editPoints.get() );
361  m_editPoints.reset();
362  }
363 
364  return 0;
365 }
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:220
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:341
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:336
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:73
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() 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 (...
Definition: view_controls.h:94
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.
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:36
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
Common, abstract interface for edit frames.
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
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:311
void finishItem() const
Applies the last changes to the edited item.
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
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 883 of file point_editor.cpp.

References EDIT_POINT::GetPosition(), m_editedPoint, m_editPoints, ZONE_CONTAINER::Outline(), PCB_ZONE_AREA_T, SHAPE_POLY_SET::RemoveVertex(), setEditedPoint(), SHAPE_POLY_SET::TotalVertices(), EDA_ITEM::Type(), updatePoints(), and SHAPE_POLY_SET::Vertex().

884 {
885  if( !m_editedPoint )
886  return 0;
887 
888  EDA_ITEM* item = m_editPoints->GetParent();
889 
890  if( item->Type() == PCB_ZONE_AREA_T )
891  {
892  PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
893  BOARD_COMMIT commit( frame );
894 
895  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
896  SHAPE_POLY_SET* zoneOutline = zone->Outline();
897  commit.Modify( zone );
898 
899  for( int i = 0; i < zoneOutline->TotalVertices(); ++i )
900  {
901  if( zoneOutline->Vertex( i ) == m_editedPoint->GetPosition() )
902  {
903  zoneOutline->RemoveVertex( i );
904  setEditedPoint( NULL );
905  commit.Push( _( "Remove a zone corner" ) );
906  break;
907  }
908  }
909 
910  updatePoints();
911  }
912 
913  return 0;
914 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
int TotalVertices() const
Returns total number of vertices stored in the set.
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:247
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 SHAPE_POLY_SET.
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
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:151
void updatePoints()
Updates edit points with item's points.
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...
bool POINT_EDITOR::removeCornerCondition ( const SELECTION aSelection)
private

Condition to display "Remove corner" context menu entry.

Definition at line 746 of file point_editor.cpp.

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

Referenced by Init().

747 {
748  if( !m_editPoints )
749  return false;
750 
751  EDA_ITEM* item = m_editPoints->GetParent();
752 
753  if( item->Type() != PCB_ZONE_AREA_T )
754  return false;
755 
756  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
757 
758  if( zone->GetNumCorners() <= 3 )
759  return false;
760 
761  // Remove corner does not work with lines
762  if( dynamic_cast<EDIT_LINE*>( m_editedPoint ) )
763  return false;
764 
765  return m_editedPoint != NULL;
766 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition: class_zone.h:466
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
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:151
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.

Implements TOOL_BASE.

Definition at line 210 of file point_editor.cpp.

References m_altConstraint, and m_editPoints.

211 {
212  m_editPoints.reset();
213  m_altConstraint.reset();
214 }
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 78 of file tool_interactive.cpp.

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

Referenced by DRAWING_TOOL::PlaceText().

79 {
80  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
81 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
void POINT_EDITOR::setAltConstraint ( bool  aEnabled)
private

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

Definition at line 645 of file point_editor.cpp.

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

Referenced by OnSelectionChange().

646 {
647  if( aEnabled )
648  {
649  EDIT_LINE* line = dynamic_cast<EDIT_LINE*>( m_editedPoint );
650 
651  if( line )
652  {
653  if( m_editPoints->GetParent()->Type() == PCB_ZONE_AREA_T )
655  }
656  else
657  {
658  // Find a proper constraining point for 45 degrees mode
661  }
662  }
663  else
664  {
665  m_altConstraint.reset();
666  }
667 }
Class EC_CONVERGING.
Class EDIT_LINE.
Definition: edit_points.h:189
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
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 67 of file tool_interactive.cpp.

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

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

68 {
69  if( aMenu )
70  aMenu->SetTool( this );
71  else
72  aTrigger = CMENU_OFF;
73 
74  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
75 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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 624 of file point_editor.cpp.

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

625 {
627 
628  if( aPoint )
629  {
630  controls->ForceCursorPosition( true, aPoint->GetPosition() );
631  controls->ShowCursor( true );
632  controls->SetSnapping( true );
633  }
634  else
635  {
636  controls->ShowCursor( false );
637  controls->SetSnapping( false );
638  controls->ForceCursorPosition( false );
639  }
640 
641  m_editedPoint = aPoint;
642 }
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.
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
Definition: view_controls.h:94
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:36
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 POINT_EDITOR::SetTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from TOOL_BASE.

Definition at line 722 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.

723 {
729 }
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:99
static TOOL_ACTION pointEditorAddCorner
Break outline (insert additional points to an edge)
Definition: pcb_actions.h:193
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
Definition: pcb_actions.h:196
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 237 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().

238 {
239  EDIT_POINT* point = m_editedPoint;
240 
241  if( aEvent.IsMotion() )
242  {
243  point = m_editPoints->FindPoint( aEvent.Position(), getView() );
244  }
245  else if( aEvent.IsDrag( BUT_LEFT ) )
246  {
247  point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
248  }
249 
250  if( m_editedPoint != point )
251  setEditedPoint( point );
252 }
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:30
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 368 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(), 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_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().

369 {
370  EDA_ITEM* item = m_editPoints->GetParent();
371 
372  switch( item->Type() )
373  {
374  case PCB_LINE_T:
375  case PCB_MODULE_EDGE_T:
376  {
377  DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
378  switch( segment->GetShape() )
379  {
380  case S_SEGMENT:
381  if( isModified( m_editPoints->Point( SEG_START ) ) )
382  segment->SetStart( wxPoint( m_editPoints->Point( SEG_START ).GetPosition().x,
383  m_editPoints->Point( SEG_START ).GetPosition().y ) );
384 
385  else if( isModified( m_editPoints->Point( SEG_END ) ) )
386  segment->SetEnd( wxPoint( m_editPoints->Point( SEG_END ).GetPosition().x,
387  m_editPoints->Point( SEG_END ).GetPosition().y ) );
388 
389  break;
390 
391  case S_ARC:
392  {
393  const VECTOR2I& center = m_editPoints->Point( ARC_CENTER ).GetPosition();
394  const VECTOR2I& start = m_editPoints->Point( ARC_START ).GetPosition();
395  const VECTOR2I& end = m_editPoints->Point( ARC_END ).GetPosition();
396 
397  if( center != segment->GetCenter() )
398  {
399  wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
400  segment->Move( moveVector );
401 
402  m_editPoints->Point( ARC_START ).SetPosition( segment->GetArcStart() );
403  m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
404  }
405 
406  else
407  {
408  segment->SetArcStart( wxPoint( start.x, start.y ) );
409 
410  VECTOR2D startLine = start - center;
411  VECTOR2I endLine = end - center;
412  double newAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
413 
414  // Adjust the new angle to (counter)clockwise setting
415  bool clockwise = ( segment->GetAngle() > 0 );
416 
417  if( clockwise && newAngle < 0.0 )
418  newAngle += 3600.0;
419  else if( !clockwise && newAngle > 0.0 )
420  newAngle -= 3600.0;
421 
422  segment->SetAngle( newAngle );
423  }
424 
425  break;
426  }
427 
428  case S_CIRCLE:
429  {
430  const VECTOR2I& center = m_editPoints->Point( CIRC_CENTER ).GetPosition();
431  const VECTOR2I& end = m_editPoints->Point( CIRC_END ).GetPosition();
432 
433  if( isModified( m_editPoints->Point( CIRC_CENTER ) ) )
434  {
435  wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
436  segment->Move( moveVector );
437  }
438  else
439  {
440  segment->SetEnd( wxPoint( end.x, end.y ) );
441  }
442 
443  break;
444  }
445 
446  default: // suppress warnings
447  break;
448  }
449 
450  // Update relative coordinates for module edges
451  if( EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item ) )
452  edge->SetLocalCoord();
453 
454  break;
455  }
456 
457  case PCB_ZONE_AREA_T:
458  {
459  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
460  zone->ClearFilledPolysList();
461  SHAPE_POLY_SET* outline = zone->Outline();
462 
463  for( int i = 0; i < outline->TotalVertices(); ++i )
464  {
465  VECTOR2I point = m_editPoints->Point( i ).GetPosition();
466  outline->Vertex( i ) = point;
467  }
468 
469  zone->Hatch();
470 
471  break;
472  }
473 
474  case PCB_DIMENSION_T:
475  {
476  DIMENSION* dimension = static_cast<DIMENSION*>( item );
477 
478  // Check which point is currently modified and updated dimension's points respectively
479  if( isModified( m_editPoints->Point( DIM_CROSSBARO ) ) )
480  {
481  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetOrigin() );
482  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
483 
484  if( featureLine.Cross( crossBar ) > 0 )
485  dimension->SetHeight( -featureLine.EuclideanNorm() );
486  else
487  dimension->SetHeight( featureLine.EuclideanNorm() );
488  }
489 
490  else if( isModified( m_editPoints->Point( DIM_CROSSBARF ) ) )
491  {
492  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetEnd() );
493  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
494 
495  if( featureLine.Cross( crossBar ) > 0 )
496  dimension->SetHeight( -featureLine.EuclideanNorm() );
497  else
498  dimension->SetHeight( featureLine.EuclideanNorm() );
499  }
500 
501  else if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
502  {
504  m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
505  m_editPoints->Point( DIM_FEATUREGO ) ) );
506  m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
507  m_editPoints->Point( DIM_FEATUREDO ) ) );
508  }
509 
510  else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
511  {
513  m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
514  m_editPoints->Point( DIM_FEATUREGO ) ) );
515  m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
516  m_editPoints->Point( DIM_FEATUREDO ) ) );
517  }
518 
519  break;
520  }
521 
522  default:
523  break;
524  }
525 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
const wxPoint GetCenter() const override
Function GetCenter()
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
int TotalVertices() const
Returns total number of vertices stored in the set.
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:247
double RAD2DECIDEG(double rad)
Definition: trigo.h:196
usual segment : line with rounded ends
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
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:309
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
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:112
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...
Definition: class_zone.cpp:919
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
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:103
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:577
void POINT_EDITOR::updatePoints ( )
private

Updates edit points with item's points.

Definition at line 545 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().

546 {
547  if( !m_editPoints )
548  return;
549 
550  EDA_ITEM* item = m_editPoints->GetParent();
551 
552  switch( item->Type() )
553  {
554  case PCB_LINE_T:
555  case PCB_MODULE_EDGE_T:
556  {
557  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
558  {
559  switch( segment->GetShape() )
560  {
561  case S_SEGMENT:
562  m_editPoints->Point( SEG_START ).SetPosition( segment->GetStart() );
563  m_editPoints->Point( SEG_END ).SetPosition( segment->GetEnd() );
564  break;
565 
566  case S_ARC:
567  m_editPoints->Point( ARC_CENTER ).SetPosition( segment->GetCenter() );
568  m_editPoints->Point( ARC_START).SetPosition( segment->GetArcStart() );
569  m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
570  break;
571 
572  case S_CIRCLE:
573  m_editPoints->Point( CIRC_CENTER ).SetPosition( segment->GetCenter() );
574  m_editPoints->Point( CIRC_END ).SetPosition( segment->GetEnd() );
575  break;
576 
577  default: // suppress warnings
578  break;
579  }
580 
581  break;
582  }
583  }
584 
585  case PCB_ZONE_AREA_T:
586  {
587  const ZONE_CONTAINER* zone = static_cast<const ZONE_CONTAINER*>( item );
588  const SHAPE_POLY_SET* outline = zone->Outline();
589 
590  if( m_editPoints->PointsSize() != (unsigned) outline->TotalVertices() )
591  {
592  getView()->Remove( m_editPoints.get() );
593  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
594  getView()->Add( m_editPoints.get() );
595  }
596  else
597  {
598  for( int i = 0; i < outline->TotalVertices(); ++i )
599  m_editPoints->Point( i ).SetPosition( outline->CVertex( i ) );
600  }
601 
602  break;
603  }
604 
605  case PCB_DIMENSION_T:
606  {
607  const DIMENSION* dimension = static_cast<const DIMENSION*>( item );
608 
609  m_editPoints->Point( DIM_CROSSBARO ).SetPosition( dimension->m_crossBarO );
610  m_editPoints->Point( DIM_CROSSBARF ).SetPosition( dimension->m_crossBarF );
611  m_editPoints->Point( DIM_FEATUREGO ).SetPosition( dimension->m_featureLineGO );
612  m_editPoints->Point( DIM_FEATUREDO ).SetPosition( dimension->m_featureLineDO );
613  break;
614  }
615 
616  default:
617  break;
618  }
619 
620  getView()->Update( m_editPoints.get() );
621 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
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:114
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:341
int TotalVertices() const
Returns total number of vertices stored in the set.
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:247
usual segment : line with rounded ends
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
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)
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:112
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1379
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
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:151
wxPoint m_crossBarO
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:311
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:103
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 MODULE_EDITOR_TOOLS::CopyItems(), PCBNEW_CONTROL::DeleteItemCursor(), 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(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::MeasureTool(), OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectPoint(), ZOOM_TOOL::selectRegion(), and DRAWING_TOOL::SetAnchor().

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

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 220 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PCBNEW_CONTROL::AppendBoard(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), SELECTION_TOOL::clearSelection(), MODULE_EDITOR_TOOLS::CopyItems(), PAD_TOOL::copyPadSettings(), 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(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), EDIT_TOOL::getModificationPoint(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::Init(), PLACEMENT_TOOL::Init(), PAD_TOOL::Init(), Init(), PCB_EDITOR_CONTROL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), 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(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Remove(), SELECTION_TOOL::RequestSelection(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SELECTION_TOOL::SanitizeSelection(), SELECTION_TOOL::selectConnection(), SELECTION_TOOL::selectCopper(), SELECTION_TOOL::SelectItem(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), SELECTION_TOOL::UnselectItem(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and PCB_EDITOR_CONTROL::ZoneUnfill().

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

Referenced by TOOL_BASE::GetName().

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

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

Referenced by TOOL_BASE::GetType().


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