KiCad PCB EDA Suite
EDIT_POINTS_FACTORY Class Reference

Static Public Member Functions

static std::shared_ptr< EDIT_POINTSMake (EDA_ITEM *aItem, KIGFX::GAL *aGal)
 

Private Member Functions

 EDIT_POINTS_FACTORY ()
 

Detailed Description

Definition at line 83 of file point_editor.cpp.

Constructor & Destructor Documentation

EDIT_POINTS_FACTORY::EDIT_POINTS_FACTORY ( )
inlineprivate

Definition at line 199 of file point_editor.cpp.

199 {};

Member Function Documentation

static std::shared_ptr<EDIT_POINTS> EDIT_POINTS_FACTORY::Make ( EDA_ITEM aItem,
KIGFX::GAL aGal 
)
inlinestatic

Definition at line 86 of file point_editor.cpp.

References ARC_CENTER, ARC_END, ARC_START, SHAPE_POLY_SET::CIterateWithHoles(), DIM_CROSSBARF, DIM_CROSSBARO, DIM_FEATUREDO, DIM_FEATUREGO, DRAWSEGMENT::GetArcEnd(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetCenter(), DRAWSEGMENT::GetEnd(), KIGFX::GAL::GetGridPoint(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), DIMENSION::m_crossBarF, DIMENSION::m_crossBarO, DIMENSION::m_featureLineDO, DIMENSION::m_featureLineGO, PCB_DIMENSION_T, PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_ZONE_AREA_T, S_ARC, S_CIRCLE, S_SEGMENT, SHAPE_POLY_SET::TotalVertices(), and EDA_ITEM::Type().

Referenced by POINT_EDITOR::OnSelectionChange(), and POINT_EDITOR::updatePoints().

87  {
88  std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
89 
90  // Generate list of edit points basing on the item type
91  switch( aItem->Type() )
92  {
93  case PCB_LINE_T:
94  case PCB_MODULE_EDGE_T:
95  {
96  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( aItem );
97 
98  switch( segment->GetShape() )
99  {
100  case S_SEGMENT:
101  points->AddPoint( segment->GetStart() );
102  points->AddPoint( segment->GetEnd() );
103  break;
104 
105  case S_ARC:
106  points->AddPoint( segment->GetCenter() );
107  points->AddPoint( segment->GetArcStart() );
108  points->AddPoint( segment->GetArcEnd() );
109 
110  // Set constraints
111  // Arc end has to stay at the same radius as the start
112  points->Point( ARC_END ).SetConstraint( new EC_CIRCLE( points->Point( ARC_END ),
113  points->Point( ARC_CENTER ),
114  points->Point( ARC_START ) ) );
115  break;
116 
117  case S_CIRCLE:
118  points->AddPoint( segment->GetCenter() );
119  points->AddPoint( segment->GetEnd() );
120  break;
121 
122  default: // suppress warnings
123  break;
124  }
125 
126  break;
127  }
128 
129  case PCB_ZONE_AREA_T:
130  {
131  const SHAPE_POLY_SET* outline;
132  outline = static_cast<const ZONE_CONTAINER*>( aItem )->Outline();
133 
134  int cornersCount = outline->TotalVertices();
135 
136  for( auto iterator = outline->CIterateWithHoles(); iterator; iterator++ )
137  {
138  points->AddPoint( *iterator );
139 
140  if( iterator.IsEndContour() )
141  points->AddBreak();
142  }
143 
144  // Lines have to be added after creating edit points,
145  // as they use EDIT_POINT references
146  for( int i = 0; i < cornersCount - 1; ++i )
147  {
148  if( points->IsContourEnd( i ) )
149  {
150  points->AddLine( points->Point( i ),
151  points->Point( points->GetContourStartIdx( i ) ) );
152  }
153  else
154  {
155  points->AddLine( points->Point( i ), points->Point( i + 1 ) );
156  }
157 
158  points->Line( i ).SetConstraint( new EC_SNAPLINE( points->Line( i ),
159  std::bind( &KIGFX::GAL::GetGridPoint, aGal, _1 ) ) );
160  }
161 
162  // The last missing line, connecting the last and the first polygon point
163  points->AddLine( points->Point( cornersCount - 1 ),
164  points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
165 
166  points->Line( points->LinesSize() - 1 ).SetConstraint(
167  new EC_SNAPLINE( points->Line( points->LinesSize() - 1 ),
168  std::bind( &KIGFX::GAL::GetGridPoint, aGal, _1 ) ) );
169  break;
170  }
171 
172  case PCB_DIMENSION_T:
173  {
174  const DIMENSION* dimension = static_cast<const DIMENSION*>( aItem );
175 
176  points->AddPoint( dimension->m_crossBarO );
177  points->AddPoint( dimension->m_crossBarF );
178  points->AddPoint( dimension->m_featureLineGO );
179  points->AddPoint( dimension->m_featureLineDO );
180 
181  // Dimension height setting - edit points should move only along the feature lines
182  points->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBARO ),
183  points->Point( DIM_FEATUREGO ) ) );
184  points->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBARF ),
185  points->Point( DIM_FEATUREDO ) ) );
186 
187  break;
188  }
189 
190  default:
191  points.reset();
192  break;
193  }
194 
195  return points;
196  }
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
wxPoint m_crossBarF
const wxPoint GetCenter() const override
Function GetCenter()
CONST_ITERATOR CIterateWithHoles(int aOutline) const
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
int TotalVertices() const
Returns total number of vertices stored in the set.
usual segment : line with rounded ends
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
Class EC_LINE.
const wxPoint & GetArcStart() const
Class EC_CIRCLE.
wxPoint m_featureLineGO
STROKE_T GetShape() const
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Class SHAPE_POLY_SET.
Arcs (with rounded ends)
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:112
VECTOR2D GetGridPoint(const VECTOR2D &aPoint) const
Function GetGridPoint() For a given point it returns the nearest point belonging to the grid in world...
const wxPoint GetArcEnd() const
wxPoint m_crossBarO
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 EC_SNAPLINE.
Class DIMENSION.

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