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 ()
 
bool IsToolActive () const
 

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

217  :
218  TOOL_INTERACTIVE( "pcbnew.PointEditor" ), m_selectionTool( NULL ), m_editedPoint( NULL ),
219  m_original( VECTOR2I( 0, 0 ) ), m_altConstrainer( VECTOR2I( 0, 0 ) )
220 {
221 }
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 EDIT_TOOL::copyToClipboard(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), ROUTER_TOOL::SettingsDialog(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

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

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

Referenced by setTransitions().

int POINT_EDITOR::addCorner ( const TOOL_EVENT aEvent)
private

TOOL_ACTION handlers.

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

810 {
811  EDA_ITEM* item = m_editPoints->GetParent();
812  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
813  const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition();
814  BOARD_COMMIT commit( frame );
815 
816  if( item->Type() == PCB_ZONE_AREA_T )
817  {
818  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
819  SHAPE_POLY_SET* zoneOutline = zone->Outline();
820 
821  commit.Modify( zone );
822 
823  unsigned int nearestIdx = 0;
824  unsigned int nextNearestIdx = 0;
825  unsigned int nearestDist = INT_MAX;
826  unsigned int firstPointInContour = 0;
827 
828  // Search the best outline segment to add a new corner
829  // and therefore break this segment into two segments
830 
831  // Object to iterate through the corners of the outlines (main contour and its holes)
832  SHAPE_POLY_SET::ITERATOR iterator = zoneOutline->Iterate( 0,
833  zoneOutline->OutlineCount()-1, /* IterateHoles */ true );
834  int curr_idx = 0;
835 
836  // Iterate through all the corners of the outlines and search the best segment
837  for( ; iterator; iterator++, curr_idx++ )
838  {
839  int jj = curr_idx+1;
840 
841  if( iterator.IsEndContour() )
842  { // We reach the last point of the current contour (main or hole)
843  jj = firstPointInContour;
844  firstPointInContour = curr_idx+1; // Prepare next contour analysis
845  }
846 
847  SEG curr_segment( zoneOutline->Vertex( curr_idx ), zoneOutline->Vertex( jj ) );
848 
849  unsigned int distance = curr_segment.Distance( cursorPos );
850 
851  if( distance < nearestDist )
852  {
853  nearestDist = distance;
854  nearestIdx = curr_idx;
855  nextNearestIdx = jj;
856  }
857  }
858 
859 
860  // Find the point on the closest segment
861  VECTOR2I sideOrigin = zoneOutline->Vertex( nearestIdx );
862  VECTOR2I sideEnd = zoneOutline->Vertex( nextNearestIdx );
863  SEG nearestSide( sideOrigin, sideEnd );
864  VECTOR2I nearestPoint = nearestSide.NearestPoint( cursorPos );
865 
866  // Do not add points that have the same coordinates as ones that already belong to polygon
867  // instead, add a point in the middle of the side
868  if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
869  nearestPoint = ( sideOrigin + sideEnd ) / 2;
870 
871  // Add corner between nearestIdx and nextNearestIdx:
872  zoneOutline->InsertVertex( nextNearestIdx, nearestPoint );
873  zone->Hatch();
874 
875  commit.Push( _( "Add a zone corner" ) );
876  }
877 
878  else if( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T )
879  {
880  bool moduleEdge = item->Type() == PCB_MODULE_EDGE_T;
881 
882  DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
883 
884  if( segment->GetShape() == S_SEGMENT )
885  {
886  commit.Modify( segment );
887 
888  SEG seg( segment->GetStart(), segment->GetEnd() );
889  VECTOR2I nearestPoint = seg.NearestPoint( cursorPos );
890 
891  // Move the end of the line to the break point..
892  segment->SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) );
893 
894  // and add another one starting from the break point
895  DRAWSEGMENT* newSegment;
896 
897  if( moduleEdge )
898  {
899  EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( segment );
900  assert( edge->Type() == PCB_MODULE_EDGE_T );
901  assert( edge->GetParent()->Type() == PCB_MODULE_T );
902  newSegment = new EDGE_MODULE( *edge );
903  }
904  else
905  {
906  newSegment = new DRAWSEGMENT( *segment );
907  }
908 
909  newSegment->ClearSelected();
910  newSegment->SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
911  newSegment->SetEnd( wxPoint( seg.B.x, seg.B.y ) );
912 
913  commit.Add( newSegment );
914  commit.Push( _( "Split segment" ) );
915  }
916  }
917 
918  updatePoints();
919  return 0;
920 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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:245
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:262
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.
Class SHAPE_POLY_SET.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
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...
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
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 772 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().

773 {
774  if( aSelection.Size() != 1 )
775  return false;
776 
777  auto item = aSelection.Front();
778 
779  // Works only for zones and line segments
780  return item->Type() == PCB_ZONE_AREA_T ||
781  ( ( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T ) &&
782  static_cast<DRAWSEGMENT*>( item )->GetShape() == S_SEGMENT );
783 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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 59 of file tool_base.cpp.

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

Referenced by TOOL_MANAGER::RegisterTool().

60 {
61  m_toolMgr = aManager;
62  m_toolSettings = TOOL_SETTINGS( this );
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
friend class TOOL_SETTINGS
Definition: tool_base.h:155
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 562 of file point_editor.cpp.

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

Referenced by OnSelectionChange().

563 {
564  EDA_ITEM* item = m_editPoints->GetParent();
565 
566  if( !item )
567  return;
568 
569  if( item->Type() == PCB_ZONE_AREA_T )
570  {
571  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
572 
573  if( zone->IsFilled() )
574  {
575  getEditFrame<PCB_EDIT_FRAME>()->Fill_Zone( zone );
576 // zone->GetBoard()->GetRatsnest()->Recalculate( zone->GetNetCode() );
577  }
578  }
579 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
bool IsFilled() const
Definition: class_zone.h:215
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:165
EDIT_POINT POINT_EDITOR::get45DegConstrainer ( ) const
private

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

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

711 {
712  EDA_ITEM* item = m_editPoints->GetParent();
713 
714  switch( item->Type() )
715  {
716  case PCB_LINE_T:
717  case PCB_MODULE_EDGE_T:
718  {
719  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
720  {
721  switch( segment->GetShape() )
722  {
723  case S_SEGMENT:
724  return *( m_editPoints->Next( *m_editedPoint ) ); // select the other end of line
725 
726  case S_ARC:
727  case S_CIRCLE:
728  return m_editPoints->Point( CIRC_CENTER );
729 
730  default: // suppress warnings
731  break;
732  }
733  }
734 
735  break;
736  }
737 
738  case PCB_DIMENSION_T:
739  {
740  // Constraint for crossbar
741  if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
742  return m_editPoints->Point( DIM_FEATUREDO );
743 
744  else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
745  return m_editPoints->Point( DIM_FEATUREGO );
746 
747  else
748  return EDIT_POINT( m_editedPoint->GetPosition() ); // no constraint
749 
750  break;
751  }
752 
753  default:
754  break;
755  }
756 
757  // In any other case we may align item to its original position
758  return m_original;
759 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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:165
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 188 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().

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
T
enum T contains all this lexer's tokens.
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47
TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

References TOOL_BASE::m_toolId.

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

123  {
124  return m_toolId;
125  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 144 of file tool_base.h.

References TOOL_BASE::m_toolMgr.

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

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 199 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

200  {
201  EDA_ITEM* m = getModelInt();
202 
203  return static_cast<T*>( m );
204  }
T
enum T contains all this lexer's tokens.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:53
const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Function GetName() Returns the name of the tool.

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

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

References TOOL_BASE::m_toolName.

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

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

Definition at line 77 of file tool_base.cpp.

References TOOL_BASE::m_toolSettings.

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

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

References TOOL_BASE::m_type.

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

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:207
KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Function getView()

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

Returns
The instance of VIEW.

Definition at line 35 of file tool_base.cpp.

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

Referenced by PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), PCBNEW_CONTROL::HighContrastMode(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), EDIT_TOOL::MoveExact(), OnSelectionChange(), PCBNEW_CONTROL::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(), GERBVIEW_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), PCBNEW_CONTROL::TrackDisplayMode(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), 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(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

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

Function getViewControls()

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

Returns
The instance of VIEW_CONTROLS.

Definition at line 41 of file tool_base.cpp.

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

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

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257
template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Function Go()

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

Definition at line 135 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

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

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

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

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

Reimplemented from TOOL_BASE.

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

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

Returns true if aPoint is the currently modified point.

Definition at line 97 of file point_editor.h.

Referenced by get45DegConstrainer(), and updateItem().

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

Definition at line 30 of file tool_base.cpp.

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

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

Definition at line 975 of file point_editor.cpp.

References updatePoints().

Referenced by setTransitions().

976 {
977  updatePoints();
978  return 0;
979 }
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 269 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().

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

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

924 {
925  if( !m_editedPoint )
926  return 0;
927 
928  EDA_ITEM* item = m_editPoints->GetParent();
929 
930  if( !item )
931  return 0;
932 
933  SHAPE_POLY_SET *outline = nullptr;
934 
935  if( item->Type() == PCB_ZONE_AREA_T)
936  {
937  auto zone = static_cast<ZONE_CONTAINER*>( item );
938  outline = zone->Outline();
939  }
940  else if ( item->Type() == PCB_LINE_T )
941  {
942  auto ds = static_cast<DRAWSEGMENT*>( item );
943  if( ds->GetShape() == S_POLYGON )
944  {
945  outline = &ds->GetPolyShape();
946  }
947  }
948 
949  if( !outline )
950  return 0;
951 
952  PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
953  BOARD_COMMIT commit( frame );
954 
955  commit.Modify( item );
956 
957  for( int i = 0; i < outline->TotalVertices(); ++i )
958  {
959  if( outline->Vertex( i ) == m_editedPoint->GetPosition() )
960  {
961  outline->RemoveVertex( i );
962  setEditedPoint( NULL );
963  commit.Push( _( "Remove a zone/polygon corner" ) );
964  break;
965  }
966  }
967 
968  updatePoints();
969 
970 
971  return 0;
972 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
polygon (not yet used for tracks, but could be in microwave apps)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
int TotalVertices() const
Returns total number of vertices stored in the set.
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.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the 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:165
void updatePoints()
Updates edit points with item's points.
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
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 786 of file point_editor.cpp.

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

Referenced by Init().

787 {
788  if( !m_editPoints )
789  return false;
790 
791  EDA_ITEM* item = m_editPoints->GetParent();
792 
793  if( item->Type() != PCB_ZONE_AREA_T )
794  return false;
795 
796  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
797 
798  if( zone->GetNumCorners() <= 3 )
799  return false;
800 
801  // Remove corner does not work with lines
802  if( dynamic_cast<EDIT_LINE*>( m_editedPoint ) )
803  return false;
804 
805  return m_editedPoint != NULL;
806 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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:480
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:165
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 224 of file point_editor.cpp.

References m_altConstraint, and m_editPoints.

225 {
226  m_editPoints.reset();
227  m_altConstraint.reset();
228 }
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:73
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
Definition: point_editor.h:76
void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 85 of file tool_interactive.cpp.

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

Referenced by DRAWING_TOOL::PlaceText().

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

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

Definition at line 685 of file point_editor.cpp.

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

Referenced by OnSelectionChange().

686 {
687  if( aEnabled )
688  {
689  EDIT_LINE* line = dynamic_cast<EDIT_LINE*>( m_editedPoint );
690 
691  if( line )
692  {
693  if( m_editPoints->GetParent()->Type() == PCB_ZONE_AREA_T )
695  }
696  else
697  {
698  // Find a proper constraining point for 45 degrees mode
701  }
702  }
703  else
704  {
705  m_altConstraint.reset();
706  }
707 }
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 74 of file tool_interactive.cpp.

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

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

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

Sets the current point being edited. NULL means none.

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

665 {
667 
668  if( aPoint )
669  {
670  controls->ForceCursorPosition( true, aPoint->GetPosition() );
671  controls->ShowCursor( true );
672  controls->SetSnapping( true );
673  }
674  else
675  {
676  controls->ShowCursor( false );
677  controls->SetSnapping( false );
678  controls->ForceCursorPosition( false );
679  }
680 
681  m_editedPoint = aPoint;
682 }
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 (...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:65
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:67
void POINT_EDITOR::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

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

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

Updates which point is being edited.

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

252 {
253  EDIT_POINT* point = m_editedPoint;
254 
255  if( aEvent.IsMotion() )
256  {
257  point = m_editPoints->FindPoint( aEvent.Position(), getView() );
258  }
259  else if( aEvent.IsDrag( BUT_LEFT ) )
260  {
261  point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
262  }
263 
264  if( m_editedPoint != point )
265  setEditedPoint( point );
266 }
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:280
const VECTOR2D & DragOrigin() const
Returns the point where dragging has started.
Definition: tool_event.h:255
bool IsMotion() const
Definition: tool_event.h:290
const VECTOR2D & Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:248
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
Definition: point_editor.h:73
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
Class EDIT_POINT.
Definition: edit_points.h:46
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
Definition: point_editor.h:67
void setEditedPoint(EDIT_POINT *aPoint)
Sets the current point being edited. NULL means none.
void POINT_EDITOR::updateItem ( ) const
private

Updates item's points with edit points.

Definition at line 388 of file point_editor.cpp.

References VECTOR2< T >::Angle(), ARC_CENTER, ARC_END, ARC_START, CIRC_CENTER, CIRC_END, ZONE_CONTAINER::ClearFilledPolysList(), DIM_CROSSBARF, DIM_CROSSBARO, DIM_FEATUREDO, DIM_FEATUREGO, DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetArcEnd(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetCenter(), DIMENSION::GetEnd(), DIMENSION::GetOrigin(), DRAWSEGMENT::GetPolyShape(), EDIT_POINT::GetPosition(), DRAWSEGMENT::GetShape(), ZONE_CONTAINER::Hatch(), isModified(), m_editedPoint, m_editPoints, DRAWSEGMENT::Move(), ZONE_CONTAINER::Outline(), PCB_DIMENSION_T, PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_ZONE_AREA_T, RAD2DECIDEG(), S_ARC, S_CIRCLE, S_POLYGON, S_SEGMENT, SEG_END, SEG_START, DRAWSEGMENT::SetAngle(), DRAWSEGMENT::SetArcStart(), DRAWSEGMENT::SetEnd(), DIMENSION::SetEnd(), DIMENSION::SetHeight(), DIMENSION::SetOrigin(), DRAWSEGMENT::SetStart(), SHAPE_POLY_SET::TotalVertices(), EDA_ITEM::Type(), SHAPE_POLY_SET::Vertex(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by OnSelectionChange().

389 {
390  EDA_ITEM* item = m_editPoints->GetParent();
391 
392  if( !item )
393  return;
394 
395  switch( item->Type() )
396  {
397  case PCB_LINE_T:
398  case PCB_MODULE_EDGE_T:
399  {
400  DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
401  switch( segment->GetShape() )
402  {
403  case S_SEGMENT:
404  if( isModified( m_editPoints->Point( SEG_START ) ) )
405  segment->SetStart( wxPoint( m_editPoints->Point( SEG_START ).GetPosition().x,
406  m_editPoints->Point( SEG_START ).GetPosition().y ) );
407 
408  else if( isModified( m_editPoints->Point( SEG_END ) ) )
409  segment->SetEnd( wxPoint( m_editPoints->Point( SEG_END ).GetPosition().x,
410  m_editPoints->Point( SEG_END ).GetPosition().y ) );
411 
412  break;
413 
414  case S_ARC:
415  {
416  const VECTOR2I& center = m_editPoints->Point( ARC_CENTER ).GetPosition();
417  const VECTOR2I& start = m_editPoints->Point( ARC_START ).GetPosition();
418  const VECTOR2I& end = m_editPoints->Point( ARC_END ).GetPosition();
419 
420  if( center != segment->GetCenter() )
421  {
422  wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
423  segment->Move( moveVector );
424 
425  m_editPoints->Point( ARC_START ).SetPosition( segment->GetArcStart() );
426  m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
427  }
428 
429  else
430  {
431  segment->SetArcStart( wxPoint( start.x, start.y ) );
432 
433  VECTOR2D startLine = start - center;
434  VECTOR2I endLine = end - center;
435  double newAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
436 
437  // Adjust the new angle to (counter)clockwise setting
438  bool clockwise = ( segment->GetAngle() > 0 );
439 
440  if( clockwise && newAngle < 0.0 )
441  newAngle += 3600.0;
442  else if( !clockwise && newAngle > 0.0 )
443  newAngle -= 3600.0;
444 
445  segment->SetAngle( newAngle );
446  }
447 
448  break;
449  }
450 
451  case S_CIRCLE:
452  {
453  const VECTOR2I& center = m_editPoints->Point( CIRC_CENTER ).GetPosition();
454  const VECTOR2I& end = m_editPoints->Point( CIRC_END ).GetPosition();
455 
456  if( isModified( m_editPoints->Point( CIRC_CENTER ) ) )
457  {
458  wxPoint moveVector = wxPoint( center.x, center.y ) - segment->GetCenter();
459  segment->Move( moveVector );
460  }
461  else
462  {
463  segment->SetEnd( wxPoint( end.x, end.y ) );
464  }
465 
466  break;
467  }
468 
469  case S_POLYGON:
470  {
471  SHAPE_POLY_SET* outline = &segment->GetPolyShape();
472 
473  for( int i = 0; i < outline->TotalVertices(); ++i )
474  {
475  VECTOR2I point = m_editPoints->Point( i ).GetPosition();
476  outline->Vertex( i ) = point;
477  }
478  }
479 
480  default: // suppress warnings
481  break;
482  }
483 
484  // Update relative coordinates for module edges
485  if( EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item ) )
486  edge->SetLocalCoord();
487 
488  break;
489  }
490 
491  case PCB_ZONE_AREA_T:
492  {
493  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
494  zone->ClearFilledPolysList();
495  SHAPE_POLY_SET* outline = zone->Outline();
496 
497  for( int i = 0; i < outline->TotalVertices(); ++i )
498  {
499  VECTOR2I point = m_editPoints->Point( i ).GetPosition();
500  outline->Vertex( i ) = point;
501  }
502 
503  zone->Hatch();
504 
505  break;
506  }
507 
508  case PCB_DIMENSION_T:
509  {
510  DIMENSION* dimension = static_cast<DIMENSION*>( item );
511 
512  // Check which point is currently modified and updated dimension's points respectively
513  if( isModified( m_editPoints->Point( DIM_CROSSBARO ) ) )
514  {
515  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetOrigin() );
516  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
517 
518  if( featureLine.Cross( crossBar ) > 0 )
519  dimension->SetHeight( -featureLine.EuclideanNorm() );
520  else
521  dimension->SetHeight( featureLine.EuclideanNorm() );
522  }
523 
524  else if( isModified( m_editPoints->Point( DIM_CROSSBARF ) ) )
525  {
526  VECTOR2D featureLine( m_editedPoint->GetPosition() - dimension->GetEnd() );
527  VECTOR2D crossBar( dimension->GetEnd() - dimension->GetOrigin() );
528 
529  if( featureLine.Cross( crossBar ) > 0 )
530  dimension->SetHeight( -featureLine.EuclideanNorm() );
531  else
532  dimension->SetHeight( featureLine.EuclideanNorm() );
533  }
534 
535  else if( isModified( m_editPoints->Point( DIM_FEATUREGO ) ) )
536  {
538  m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
539  m_editPoints->Point( DIM_FEATUREGO ) ) );
540  m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
541  m_editPoints->Point( DIM_FEATUREDO ) ) );
542  }
543 
544  else if( isModified( m_editPoints->Point( DIM_FEATUREDO ) ) )
545  {
547  m_editPoints->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARO ),
548  m_editPoints->Point( DIM_FEATUREGO ) ) );
549  m_editPoints->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_CROSSBARF ),
550  m_editPoints->Point( DIM_FEATUREDO ) ) );
551  }
552 
553  break;
554  }
555 
556  default:
557  break;
558  }
559 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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()
polygon (not yet used for tracks, but could be in microwave apps)
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:262
double RAD2DECIDEG(double rad)
Definition: trigo.h:204
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
SHAPE_POLY_SET & GetPolyShape()
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...
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
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:587
void POINT_EDITOR::updatePoints ( )
private

Updates edit points with item's points.

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

583 {
584  if( !m_editPoints )
585  return;
586 
587  EDA_ITEM* item = m_editPoints->GetParent();
588 
589  if( !item )
590  return;
591 
592  switch( item->Type() )
593  {
594  case PCB_LINE_T:
595  case PCB_MODULE_EDGE_T:
596  {
597  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( item );
598  {
599  switch( segment->GetShape() )
600  {
601  case S_SEGMENT:
602  m_editPoints->Point( SEG_START ).SetPosition( segment->GetStart() );
603  m_editPoints->Point( SEG_END ).SetPosition( segment->GetEnd() );
604  break;
605 
606  case S_ARC:
607  m_editPoints->Point( ARC_CENTER ).SetPosition( segment->GetCenter() );
608  m_editPoints->Point( ARC_START).SetPosition( segment->GetArcStart() );
609  m_editPoints->Point( ARC_END ).SetPosition( segment->GetArcEnd() );
610  break;
611 
612  case S_CIRCLE:
613  m_editPoints->Point( CIRC_CENTER ).SetPosition( segment->GetCenter() );
614  m_editPoints->Point( CIRC_END ).SetPosition( segment->GetEnd() );
615  break;
616 
617  default: // suppress warnings
618  break;
619  }
620 
621  break;
622  }
623  }
624 
625  case PCB_ZONE_AREA_T:
626  {
627  const ZONE_CONTAINER* zone = static_cast<const ZONE_CONTAINER*>( item );
628  const SHAPE_POLY_SET* outline = zone->Outline();
629 
630  if( m_editPoints->PointsSize() != (unsigned) outline->TotalVertices() )
631  {
632  getView()->Remove( m_editPoints.get() );
633  m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
634  getView()->Add( m_editPoints.get() );
635  }
636  else
637  {
638  for( int i = 0; i < outline->TotalVertices(); ++i )
639  m_editPoints->Point( i ).SetPosition( outline->CVertex( i ) );
640  }
641 
642  break;
643  }
644 
645  case PCB_DIMENSION_T:
646  {
647  const DIMENSION* dimension = static_cast<const DIMENSION*>( item );
648 
649  m_editPoints->Point( DIM_CROSSBARO ).SetPosition( dimension->m_crossBarO );
650  m_editPoints->Point( DIM_CROSSBARF ).SetPosition( dimension->m_crossBarF );
651  m_editPoints->Point( DIM_FEATUREGO ).SetPosition( dimension->m_featureLineGO );
652  m_editPoints->Point( DIM_FEATUREDO ).SetPosition( dimension->m_featureLineDO );
653  break;
654  }
655 
656  default:
657  break;
658  }
659 
660  getView()->Update( m_editPoints.get() );
661 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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:342
int TotalVertices() const
Returns total number of vertices stored in the set.
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:262
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:35
const wxPoint GetArcEnd() const
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
wxPoint m_crossBarO
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:312
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h: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 PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

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

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

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

Referenced by TOOL_BASE::GetName().

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 of file tool_base.h.

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

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 207 of file tool_base.h.

Referenced by TOOL_BASE::GetType().


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