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

206  :
207  TOOL_INTERACTIVE( "pcbnew.PointEditor" ), m_selectionTool( NULL ), m_editedPoint( NULL ),
208  m_original( VECTOR2I( 0, 0 ) ), m_altConstrainer( VECTOR2I( 0, 0 ) )
209 {
210 }
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(), 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: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 787 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().

788 {
789  EDA_ITEM* item = m_editPoints->GetParent();
790  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
791  const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition();
792  BOARD_COMMIT commit( frame );
793 
794  if( item->Type() == PCB_ZONE_AREA_T )
795  {
796  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
797  SHAPE_POLY_SET* zoneOutline = zone->Outline();
798 
799  commit.Modify( zone );
800 
801  unsigned int nearestIdx = 0;
802  unsigned int nextNearestIdx = 0;
803  unsigned int nearestDist = INT_MAX;
804  unsigned int firstPointInContour = 0;
805 
806  // Search the best outline segment to add a new corner
807  // and therefore break this segment into two segments
808 
809  // Object to iterate through the corners of the outlines (main contour and its holes)
810  SHAPE_POLY_SET::ITERATOR iterator = zoneOutline->Iterate( 0,
811  zoneOutline->OutlineCount()-1, /* IterateHoles */ true );
812  int curr_idx = 0;
813 
814  // Iterate through all the corners of the outlines and search the best segment
815  for( ; iterator; iterator++, curr_idx++ )
816  {
817  int jj = curr_idx+1;
818 
819  if( iterator.IsEndContour() )
820  { // We reach the last point of the current contour (main or hole)
821  jj = firstPointInContour;
822  firstPointInContour = curr_idx+1; // Prepare next contour analysis
823  }
824 
825  SEG curr_segment( zoneOutline->Vertex( curr_idx ), zoneOutline->Vertex( jj ) );
826 
827  unsigned int distance = curr_segment.Distance( cursorPos );
828 
829  if( distance < nearestDist )
830  {
831  nearestDist = distance;
832  nearestIdx = curr_idx;
833  nextNearestIdx = jj;
834  }
835  }
836 
837 
838  // Find the point on the closest segment
839  VECTOR2I sideOrigin = zoneOutline->Vertex( nearestIdx );
840  VECTOR2I sideEnd = zoneOutline->Vertex( nextNearestIdx );
841  SEG nearestSide( sideOrigin, sideEnd );
842  VECTOR2I nearestPoint = nearestSide.NearestPoint( cursorPos );
843 
844  // Do not add points that have the same coordinates as ones that already belong to polygon
845  // instead, add a point in the middle of the side
846  if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
847  nearestPoint = ( sideOrigin + sideEnd ) / 2;
848 
849  // Add corner between nearestIdx and nextNearestIdx:
850  zoneOutline->InsertVertex( nextNearestIdx, nearestPoint );
851  zone->Hatch();
852 
853  commit.Push( _( "Add a zone corner" ) );
854  }
855 
856  else if( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T )
857  {
858  bool moduleEdge = item->Type() == PCB_MODULE_EDGE_T;
859 
860  DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
861 
862  if( segment->GetShape() == S_SEGMENT )
863  {
864  commit.Modify( segment );
865 
866  SEG seg( segment->GetStart(), segment->GetEnd() );
867  VECTOR2I nearestPoint = seg.NearestPoint( cursorPos );
868 
869  // Move the end of the line to the break point..
870  segment->SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) );
871 
872  // and add another one starting from the break point
873  DRAWSEGMENT* newSegment;
874 
875  if( moduleEdge )
876  {
877  EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( segment );
878  assert( edge->Type() == PCB_MODULE_EDGE_T );
879  assert( edge->GetParent()->Type() == PCB_MODULE_T );
880  newSegment = new EDGE_MODULE( *edge );
881  }
882  else
883  {
884  newSegment = new DRAWSEGMENT( *segment );
885  }
886 
887  newSegment->ClearSelected();
888  newSegment->SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
889  newSegment->SetEnd( wxPoint( seg.B.x, seg.B.y ) );
890 
891  commit.Add( newSegment );
892  commit.Push( _( "Split segment" ) );
893  }
894  }
895 
896  updatePoints();
897  return 0;
898 }
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:950
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:186
bool POINT_EDITOR::addCornerCondition ( const SELECTION aSelection)
staticprivate

Condition to display "Create corner" context menu entry.

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

751 {
752  if( aSelection.Size() != 1 )
753  return false;
754 
755  auto item = aSelection.Front();
756 
757  // Works only for zones and line segments
758  return item->Type() == PCB_ZONE_AREA_T ||
759  ( ( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T ) &&
760  static_cast<DRAWSEGMENT*>( item )->GetShape() == S_SEGMENT );
761 }
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 540 of file point_editor.cpp.

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

Referenced by OnSelectionChange().

541 {
542  EDA_ITEM* item = m_editPoints->GetParent();
543 
544  if( !item )
545  return;
546 
547  if( item->Type() == PCB_ZONE_AREA_T )
548  {
549  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
550 
551  if( zone->IsFilled() )
552  {
553  getEditFrame<PCB_EDIT_FRAME>()->Fill_Zone( zone );
554 // zone->GetBoard()->GetRatsnest()->Recalculate( zone->GetNetCode() );
555  }
556  }
557 }
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
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 POINT_EDITOR::get45DegConstrainer ( ) const
private

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

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

689 {
690  EDA_ITEM* item = m_editPoints->GetParent();
691 
692  switch( item->Type() )
693  {
694  case PCB_LINE_T:
695  case PCB_MODULE_EDGE_T:
696  {
697  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
698  {
699  switch( segment->GetShape() )
700  {
701  case S_SEGMENT:
702  return *( m_editPoints->Next( *m_editedPoint ) ); // select the other end of line
703 
704  case S_ARC:
705  case S_CIRCLE:
706  return m_editPoints->Point( CIRC_CENTER );
707 
708  default: // suppress warnings
709  break;
710  }
711  }
712 
713  break;
714  }
715 
716  case PCB_DIMENSION_T:
717  {
718  // Constraint for crossbar
719  if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
720  return m_editPoints->Point( DIM_FEATUREDO );
721 
722  else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
723  return m_editPoints->Point( DIM_FEATUREGO );
724 
725  else
726  return EDIT_POINT( m_editedPoint->GetPosition() ); // no constraint
727 
728  break;
729  }
730 
731  default:
732  break;
733  }
734 
735  // In any other case we may align item to its original position
736  return m_original;
737 }
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(), 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(), 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(), 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(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_TOOL::view(), PCBNEW_CONTROL::ZoneDisplayMode(), 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

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

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

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

37 {
38  return m_toolMgr->GetViewControls();
39 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:248
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(), ALIGN_DISTRIBUTE_TOOL::SetTransitions(), PCBNEW_CONTROL::SetTransitions(), POSITION_RELATIVE_TOOL::SetTransitions(), MODULE_EDITOR_TOOLS::SetTransitions(), PICKER_TOOL::SetTransitions(), PCB_EDITOR_CONTROL::SetTransitions(), EDIT_TOOL::SetTransitions(), SELECTION_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 220 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().

221 {
222  // Find the selection tool, so they can cooperate
223  m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
224 
225  if( !m_selectionTool )
226  {
227  DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) );
228  return false;
229  }
230 
231  auto& menu = m_selectionTool->GetToolMenu().GetMenu();
234  std::bind( &POINT_EDITOR::removeCornerCondition, this, _1 ) );
235 
236  return true;
237 }
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:202
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
Definition: pcb_actions.h:205
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 938 of file point_editor.cpp.

References updatePoints().

Referenced by SetTransitions().

939 {
940  updatePoints();
941  return 0;
942 }
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 258 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().

259 {
260  const SELECTION& selection = m_selectionTool->GetSelection();
261 
262  if( selection.Size() != 1 )
263  return 0;
264 
265  Activate();
266 
268  KIGFX::VIEW* view = getView();
269  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
270  auto item = selection.Front();
271 
272  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
273 
274  if( !m_editPoints )
275  return 0;
276 
277  view->Add( m_editPoints.get() );
278  m_editedPoint = NULL;
279  bool modified = false;
280  bool revert = false;
281 
282  BOARD_COMMIT commit( editFrame );
283 
284  // Main loop: keep receiving events
285  while( OPT_TOOL_EVENT evt = Wait() )
286  {
287  if( revert )
288  break;
289 
290  if( !m_editPoints ||
291  evt->Matches( m_selectionTool->ClearedEvent ) ||
292  evt->Matches( m_selectionTool->UnselectedEvent ) ||
293  evt->Matches( m_selectionTool->SelectedEvent ) )
294  {
295  break;
296  }
297 
298  if ( !modified )
299  updateEditedPoint( *evt );
300 
301  if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
302  {
303  if( !modified )
304  {
305  commit.StageItems( selection, CHT_MODIFY );
306 
307  controls->ForceCursorPosition( false );
308  m_original = *m_editedPoint; // Save the original position
309  controls->SetAutoPan( true );
310  modified = true;
311  }
312 
313  bool enableAltConstraint = !!evt->Modifier( MD_CTRL );
314 
315  if( enableAltConstraint != (bool) m_altConstraint ) // alternative constraint
316  setAltConstraint( enableAltConstraint );
317 
319 
320  if( m_altConstraint )
321  m_altConstraint->Apply();
322  else
324 
325  updateItem();
326  updatePoints();
327  }
328 
329  else if( evt->IsMouseUp( BUT_LEFT ) )
330  {
331  controls->SetAutoPan( false );
332  setAltConstraint( false );
333 
334  if( modified )
335  {
336  commit.Push( _( "Drag a line ending" ) );
337  modified = false;
338  }
339 
340  m_toolMgr->PassEvent();
341  }
342 
343  else if( evt->IsCancel() )
344  {
345  if( modified ) // Restore the last change
346  revert = true;
347 
348  // Let the selection tool receive the event too
349  m_toolMgr->PassEvent();
350 
351  // Do not exit right now, let the selection clear the selection
352  //break;
353  }
354 
355  else
356  {
357  m_toolMgr->PassEvent();
358  }
359  }
360 
361  if( m_editPoints )
362  {
363  view->Remove( m_editPoints.get() );
364 
365  if( modified && revert )
366  commit.Revert();
367  else
368  finishItem();
369 
370  m_editPoints.reset();
371  }
372 
373  return 0;
374 }
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 901 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().

902 {
903  if( !m_editedPoint )
904  return 0;
905 
906  EDA_ITEM* item = m_editPoints->GetParent();
907 
908  if( !item )
909  return 0;
910 
911  if( item->Type() == PCB_ZONE_AREA_T )
912  {
913  PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
914  BOARD_COMMIT commit( frame );
915 
916  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
917  SHAPE_POLY_SET* zoneOutline = zone->Outline();
918  commit.Modify( zone );
919 
920  for( int i = 0; i < zoneOutline->TotalVertices(); ++i )
921  {
922  if( zoneOutline->Vertex( i ) == m_editedPoint->GetPosition() )
923  {
924  zoneOutline->RemoveVertex( i );
925  setEditedPoint( NULL );
926  commit.Push( _( "Remove a zone corner" ) );
927  break;
928  }
929  }
930 
931  updatePoints();
932  }
933 
934  return 0;
935 }
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 764 of file point_editor.cpp.

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

Referenced by Init().

765 {
766  if( !m_editPoints )
767  return false;
768 
769  EDA_ITEM* item = m_editPoints->GetParent();
770 
771  if( item->Type() != PCB_ZONE_AREA_T )
772  return false;
773 
774  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
775 
776  if( zone->GetNumCorners() <= 3 )
777  return false;
778 
779  // Remove corner does not work with lines
780  if( dynamic_cast<EDIT_LINE*>( m_editedPoint ) )
781  return false;
782 
783  return m_editedPoint != NULL;
784 }
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:465
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 213 of file point_editor.cpp.

References m_altConstraint, and m_editPoints.

214 {
215  m_editPoints.reset();
216  m_altConstraint.reset();
217 }
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 663 of file point_editor.cpp.

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

Referenced by OnSelectionChange().

664 {
665  if( aEnabled )
666  {
667  EDIT_LINE* line = dynamic_cast<EDIT_LINE*>( m_editedPoint );
668 
669  if( line )
670  {
671  if( m_editPoints->GetParent()->Type() == PCB_ZONE_AREA_T )
673  }
674  else
675  {
676  // Find a proper constraining point for 45 degrees mode
679  }
680  }
681  else
682  {
683  m_altConstraint.reset();
684  }
685 }
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 642 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().

643 {
645 
646  if( aPoint )
647  {
648  controls->ForceCursorPosition( true, aPoint->GetPosition() );
649  controls->ShowCursor( true );
650  controls->SetSnapping( true );
651  }
652  else
653  {
654  controls->ShowCursor( false );
655  controls->SetSnapping( false );
656  controls->ForceCursorPosition( false );
657  }
658 
659  m_editedPoint = aPoint;
660 }
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 740 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.

741 {
747 }
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:105
static TOOL_ACTION pointEditorAddCorner
Break outline (insert additional points to an edge)
Definition: pcb_actions.h:202
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
Definition: pcb_actions.h:205
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 240 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().

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

378 {
379  EDA_ITEM* item = m_editPoints->GetParent();
380 
381  if( !item )
382  return;
383 
384  switch( item->Type() )
385  {
386  case PCB_LINE_T:
387  case PCB_MODULE_EDGE_T:
388  {
389  DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
390  switch( segment->GetShape() )
391  {
392  case S_SEGMENT:
393  if( isModified( m_editPoints->Point( SEG_START ) ) )
394  segment->SetStart( wxPoint( m_editPoints->Point( SEG_START ).GetPosition().x,
395  m_editPoints->Point( SEG_START ).GetPosition().y ) );
396 
397  else if( isModified( m_editPoints->Point( SEG_END ) ) )
398  segment->SetEnd( wxPoint( m_editPoints->Point( SEG_END ).GetPosition().x,
399  m_editPoints->Point( SEG_END ).GetPosition().y ) );
400 
401  break;
402 
403  case S_ARC:
404  {
405  const VECTOR2I& center = m_editPoints->Point( ARC_CENTER ).GetPosition();
406  const VECTOR2I& start = m_editPoints->Point( ARC_START ).GetPosition();
407  const VECTOR2I& end = m_editPoints->Point( ARC_END ).GetPosition();
408 
409  if( center != segment->GetCenter() )
410  {
411  wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
412  segment->Move( moveVector );
413 
414  m_editPoints->Point( ARC_START ).SetPosition( segment->GetArcStart() );
415  m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
416  }
417 
418  else
419  {
420  segment->SetArcStart( wxPoint( start.x, start.y ) );
421 
422  VECTOR2D startLine = start - center;
423  VECTOR2I endLine = end - center;
424  double newAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
425 
426  // Adjust the new angle to (counter)clockwise setting
427  bool clockwise = ( segment->GetAngle() > 0 );
428 
429  if( clockwise && newAngle < 0.0 )
430  newAngle += 3600.0;
431  else if( !clockwise && newAngle > 0.0 )
432  newAngle -= 3600.0;
433 
434  segment->SetAngle( newAngle );
435  }
436 
437  break;
438  }
439 
440  case S_CIRCLE:
441  {
442  const VECTOR2I& center = m_editPoints->Point( CIRC_CENTER ).GetPosition();
443  const VECTOR2I& end = m_editPoints->Point( CIRC_END ).GetPosition();
444 
445  if( isModified( m_editPoints->Point( CIRC_CENTER ) ) )
446  {
447  wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
448  segment->Move( moveVector );
449  }
450  else
451  {
452  segment->SetEnd( wxPoint( end.x, end.y ) );
453  }
454 
455  break;
456  }
457 
458  default: // suppress warnings
459  break;
460  }
461 
462  // Update relative coordinates for module edges
463  if( EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item ) )
464  edge->SetLocalCoord();
465 
466  break;
467  }
468 
469  case PCB_ZONE_AREA_T:
470  {
471  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
472  zone->ClearFilledPolysList();
473  SHAPE_POLY_SET* outline = zone->Outline();
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  zone->Hatch();
482 
483  break;
484  }
485 
486  case PCB_DIMENSION_T:
487  {
488  DIMENSION* dimension = static_cast<DIMENSION*>( item );
489 
490  // Check which point is currently modified and updated dimension's points respectively
491  if( isModified( m_editPoints->Point( DIM_CROSSBARO ) ) )
492  {
493  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetOrigin() );
494  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
495 
496  if( featureLine.Cross( crossBar ) > 0 )
497  dimension->SetHeight( -featureLine.EuclideanNorm() );
498  else
499  dimension->SetHeight( featureLine.EuclideanNorm() );
500  }
501 
502  else if( isModified( m_editPoints->Point( DIM_CROSSBARF ) ) )
503  {
504  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetEnd() );
505  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
506 
507  if( featureLine.Cross( crossBar ) > 0 )
508  dimension->SetHeight( -featureLine.EuclideanNorm() );
509  else
510  dimension->SetHeight( featureLine.EuclideanNorm() );
511  }
512 
513  else if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
514  {
516  m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
517  m_editPoints->Point( DIM_FEATUREGO ) ) );
518  m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
519  m_editPoints->Point( DIM_FEATUREDO ) ) );
520  }
521 
522  else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
523  {
525  m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
526  m_editPoints->Point( DIM_FEATUREGO ) ) );
527  m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
528  m_editPoints->Point( DIM_FEATUREDO ) ) );
529  }
530 
531  break;
532  }
533 
534  default:
535  break;
536  }
537 }
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:950
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:572
void POINT_EDITOR::updatePoints ( )
private

Updates edit points with item's points.

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

561 {
562  if( !m_editPoints )
563  return;
564 
565  EDA_ITEM* item = m_editPoints->GetParent();
566 
567  if( !item )
568  return;
569 
570  switch( item->Type() )
571  {
572  case PCB_LINE_T:
573  case PCB_MODULE_EDGE_T:
574  {
575  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
576  {
577  switch( segment->GetShape() )
578  {
579  case S_SEGMENT:
580  m_editPoints->Point( SEG_START ).SetPosition( segment->GetStart() );
581  m_editPoints->Point( SEG_END ).SetPosition( segment->GetEnd() );
582  break;
583 
584  case S_ARC:
585  m_editPoints->Point( ARC_CENTER ).SetPosition( segment->GetCenter() );
586  m_editPoints->Point( ARC_START).SetPosition( segment->GetArcStart() );
587  m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
588  break;
589 
590  case S_CIRCLE:
591  m_editPoints->Point( CIRC_CENTER ).SetPosition( segment->GetCenter() );
592  m_editPoints->Point( CIRC_END ).SetPosition( segment->GetEnd() );
593  break;
594 
595  default: // suppress warnings
596  break;
597  }
598 
599  break;
600  }
601  }
602 
603  case PCB_ZONE_AREA_T:
604  {
605  const ZONE_CONTAINER* zone = static_cast<const ZONE_CONTAINER*>( item );
606  const SHAPE_POLY_SET* outline = zone->Outline();
607 
608  if( m_editPoints->PointsSize() != (unsigned) outline->TotalVertices() )
609  {
610  getView()->Remove( m_editPoints.get() );
611  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
612  getView()->Add( m_editPoints.get() );
613  }
614  else
615  {
616  for( int i = 0; i < outline->TotalVertices(); ++i )
617  m_editPoints->Point( i ).SetPosition( outline->CVertex( i ) );
618  }
619 
620  break;
621  }
622 
623  case PCB_DIMENSION_T:
624  {
625  const DIMENSION* dimension = static_cast<const DIMENSION*>( item );
626 
627  m_editPoints->Point( DIM_CROSSBARO ).SetPosition( dimension->m_crossBarO );
628  m_editPoints->Point( DIM_CROSSBARF ).SetPosition( dimension->m_crossBarF );
629  m_editPoints->Point( DIM_FEATUREGO ).SetPosition( dimension->m_featureLineGO );
630  m_editPoints->Point( DIM_FEATUREDO ).SetPosition( dimension->m_featureLineDO );
631  break;
632  }
633 
634  default:
635  break;
636  }
637 
638  getView()->Update( m_editPoints.get() );
639 }
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)
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:112
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(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), SELECTION_TOOL::selectMultiple(), 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: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(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), Init(), PCB_EDITOR_CONTROL::Init(), EDIT_TOOL::Init(), POSITION_RELATIVE_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(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), 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::SelectItems(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItems(), 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: