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

Static Private Member Functions

static void buildForPolyOutline (std::shared_ptr< EDIT_POINTS > points, const SHAPE_POLY_SET *aOutline, KIGFX::GAL *aGal)
 

Detailed Description

Definition at line 94 of file point_editor.cpp.

Constructor & Destructor Documentation

EDIT_POINTS_FACTORY::EDIT_POINTS_FACTORY ( )
inlineprivate

Definition at line 232 of file point_editor.cpp.

232 {};

Member Function Documentation

static void EDIT_POINTS_FACTORY::buildForPolyOutline ( std::shared_ptr< EDIT_POINTS points,
const SHAPE_POLY_SET aOutline,
KIGFX::GAL aGal 
)
inlinestaticprivate

Definition at line 98 of file point_editor.cpp.

References SHAPE_POLY_SET::CIterateWithHoles(), KIGFX::GAL::GetGridPoint(), i, and SHAPE_POLY_SET::TotalVertices().

100  {
101 
102  int cornersCount = aOutline->TotalVertices();
103 
104  for( auto iterator = aOutline->CIterateWithHoles(); iterator; iterator++ )
105  {
106  points->AddPoint( *iterator );
107 
108  if( iterator.IsEndContour() )
109  points->AddBreak();
110  }
111 
112  // Lines have to be added after creating edit points,
113  // as they use EDIT_POINT references
114  for( int i = 0; i < cornersCount - 1; ++i )
115  {
116  if( points->IsContourEnd( i ) )
117  {
118  points->AddLine( points->Point( i ),
119  points->Point( points->GetContourStartIdx( i ) ) );
120  }
121  else
122  {
123  points->AddLine( points->Point( i ), points->Point( i + 1 ) );
124  }
125 
126  points->Line( i ).SetConstraint( new EC_SNAPLINE( points->Line( i ),
127  std::bind( &KIGFX::GAL::GetGridPoint, aGal, _1 ) ) );
128  }
129 
130  // The last missing line, connecting the last and the first polygon point
131  points->AddLine( points->Point( cornersCount - 1 ),
132  points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
133 
134  points->Line( points->LinesSize() - 1 ).SetConstraint(
135  new EC_SNAPLINE( points->Line( points->LinesSize() - 1 ),
136  std::bind( &KIGFX::GAL::GetGridPoint, aGal, _1 ) ) );
137  }
CONST_ITERATOR CIterateWithHoles(int aOutline) const
int TotalVertices() const
Returns total number of vertices stored in the set.
VECTOR2D GetGridPoint(const VECTOR2D &aPoint) const
Function GetGridPoint() For a given point it returns the nearest point belonging to the grid in world...
size_t i
Definition: json11.cpp:597
Class EC_SNAPLINE.
static std::shared_ptr<EDIT_POINTS> EDIT_POINTS_FACTORY::Make ( EDA_ITEM aItem,
KIGFX::GAL aGal 
)
inlinestatic

Definition at line 140 of file point_editor.cpp.

References ARC_CENTER, ARC_START, DIM_CROSSBARF, DIM_CROSSBARO, DIM_FEATUREDO, DIM_FEATUREGO, DRAWSEGMENT::GetArcEnd(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetBezControl1(), DRAWSEGMENT::GetBezControl2(), DRAWSEGMENT::GetCenter(), DRAWSEGMENT::GetEnd(), DRAWSEGMENT::GetPolyShape(), 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_CURVE, S_POLYGON, S_SEGMENT, and EDA_ITEM::Type().

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

141  {
142  std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
143 
144  if( !aItem )
145  return points;
146 
147  // Generate list of edit points basing on the item type
148  switch( aItem->Type() )
149  {
150  case PCB_LINE_T:
151  case PCB_MODULE_EDGE_T:
152  {
153  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( aItem );
154 
155  switch( segment->GetShape() )
156  {
157  case S_SEGMENT:
158  points->AddPoint( segment->GetStart() );
159  points->AddPoint( segment->GetEnd() );
160  break;
161 
162  case S_ARC:
163  points->AddPoint( segment->GetCenter() );
164  points->AddPoint( segment->GetArcStart() );
165  points->AddPoint( segment->GetArcEnd() );
166 
167  // Set constraints
168  // Arc end has to stay at the same radius as the start
169  points->Point( ARC_END ).SetConstraint( new EC_CIRCLE( points->Point( ARC_END ),
170  points->Point( ARC_CENTER ),
171  points->Point( ARC_START ) ) );
172  break;
173 
174  case S_CIRCLE:
175  points->AddPoint( segment->GetCenter() );
176  points->AddPoint( segment->GetEnd() );
177 
178  break;
179 
180  case S_POLYGON:
181  buildForPolyOutline( points, &segment->GetPolyShape(), aGal );
182  break;
183 
184  case S_CURVE:
185  points->AddPoint( segment->GetStart() );
186  points->AddPoint( segment->GetBezControl1() );
187  points->AddPoint( segment->GetBezControl2() );
188  points->AddPoint( segment->GetEnd() );
189  break;
190 
191  default: // suppress warnings
192  break;
193  }
194 
195  break;
196  }
197 
198  case PCB_ZONE_AREA_T:
199  {
200  auto zone = static_cast<const ZONE_CONTAINER*>( aItem );
201  buildForPolyOutline( points, zone->Outline(), aGal );
202  break;
203  }
204 
205  case PCB_DIMENSION_T:
206  {
207  const DIMENSION* dimension = static_cast<const DIMENSION*>( aItem );
208 
209  points->AddPoint( dimension->m_crossBarO );
210  points->AddPoint( dimension->m_crossBarF );
211  points->AddPoint( dimension->m_featureLineGO );
212  points->AddPoint( dimension->m_featureLineDO );
213 
214  // Dimension height setting - edit points should move only along the feature lines
215  points->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBARO ),
216  points->Point( DIM_FEATUREGO ) ) );
217  points->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBARF ),
218  points->Point( DIM_FEATUREDO ) ) );
219 
220  break;
221  }
222 
223  default:
224  points.reset();
225  break;
226  }
227 
228  return points;
229  }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
const wxPoint & GetBezControl2() const
wxPoint m_crossBarF
const wxPoint GetCenter() const override
Function GetCenter()
polygon (not yet used for tracks, but could be in microwave apps)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
usual segment : line with rounded ends
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
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.
Arcs (with rounded ends)
const wxPoint & GetBezControl1() const
SHAPE_POLY_SET & GetPolyShape()
Bezier Curve.
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
const wxPoint GetArcEnd() const
wxPoint m_crossBarO
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
wxPoint m_featureLineDO
static void buildForPolyOutline(std::shared_ptr< EDIT_POINTS > points, const SHAPE_POLY_SET *aOutline, KIGFX::GAL *aGal)
Class DIMENSION.

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