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

Constructor & Destructor Documentation

EDIT_POINTS_FACTORY::EDIT_POINTS_FACTORY ( )
inlineprivate

Definition at line 213 of file point_editor.cpp.

213 {};

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

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

87  {
88 
89  int cornersCount = aOutline->TotalVertices();
90 
91  for( auto iterator = aOutline->CIterateWithHoles(); iterator; iterator++ )
92  {
93  points->AddPoint( *iterator );
94 
95  if( iterator.IsEndContour() )
96  points->AddBreak();
97  }
98 
99  // Lines have to be added after creating edit points,
100  // as they use EDIT_POINT references
101  for( int i = 0; i < cornersCount - 1; ++i )
102  {
103  if( points->IsContourEnd( i ) )
104  {
105  points->AddLine( points->Point( i ),
106  points->Point( points->GetContourStartIdx( i ) ) );
107  }
108  else
109  {
110  points->AddLine( points->Point( i ), points->Point( i + 1 ) );
111  }
112 
113  points->Line( i ).SetConstraint( new EC_SNAPLINE( points->Line( i ),
114  std::bind( &KIGFX::GAL::GetGridPoint, aGal, _1 ) ) );
115  }
116 
117  // The last missing line, connecting the last and the first polygon point
118  points->AddLine( points->Point( cornersCount - 1 ),
119  points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
120 
121  points->Line( points->LinesSize() - 1 ).SetConstraint(
122  new EC_SNAPLINE( points->Line( points->LinesSize() - 1 ),
123  std::bind( &KIGFX::GAL::GetGridPoint, aGal, _1 ) ) );
124  }
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...
Class EC_SNAPLINE.
static std::shared_ptr<EDIT_POINTS> EDIT_POINTS_FACTORY::Make ( EDA_ITEM aItem,
KIGFX::GAL aGal 
)
inlinestatic

Definition at line 127 of file point_editor.cpp.

References ARC_CENTER, ARC_END, ARC_START, DIM_CROSSBARF, DIM_CROSSBARO, DIM_FEATUREDO, DIM_FEATUREGO, DRAWSEGMENT::GetArcEnd(), DRAWSEGMENT::GetArcStart(), 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_POLYGON, S_SEGMENT, and EDA_ITEM::Type().

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

128  {
129  std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
130 
131  if( !aItem )
132  return points;
133 
134  // Generate list of edit points basing on the item type
135  switch( aItem->Type() )
136  {
137  case PCB_LINE_T:
138  case PCB_MODULE_EDGE_T:
139  {
140  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( aItem );
141 
142  switch( segment->GetShape() )
143  {
144  case S_SEGMENT:
145  points->AddPoint( segment->GetStart() );
146  points->AddPoint( segment->GetEnd() );
147  break;
148 
149  case S_ARC:
150  points->AddPoint( segment->GetCenter() );
151  points->AddPoint( segment->GetArcStart() );
152  points->AddPoint( segment->GetArcEnd() );
153 
154  // Set constraints
155  // Arc end has to stay at the same radius as the start
156  points->Point( ARC_END ).SetConstraint( new EC_CIRCLE( points->Point( ARC_END ),
157  points->Point( ARC_CENTER ),
158  points->Point( ARC_START ) ) );
159  break;
160 
161  case S_CIRCLE:
162  points->AddPoint( segment->GetCenter() );
163  points->AddPoint( segment->GetEnd() );
164  break;
165 
166  case S_POLYGON:
167  {
168  buildForPolyOutline( points, &segment->GetPolyShape(), aGal );
169  break;
170  }
171 
172  default: // suppress warnings
173  break;
174  }
175 
176  break;
177  }
178 
179  case PCB_ZONE_AREA_T:
180  {
181  auto zone = static_cast<const ZONE_CONTAINER*>( aItem );
182  buildForPolyOutline( points, zone->Outline(), aGal );
183  break;
184  }
185 
186  case PCB_DIMENSION_T:
187  {
188  const DIMENSION* dimension = static_cast<const DIMENSION*>( aItem );
189 
190  points->AddPoint( dimension->m_crossBarO );
191  points->AddPoint( dimension->m_crossBarF );
192  points->AddPoint( dimension->m_featureLineGO );
193  points->AddPoint( dimension->m_featureLineDO );
194 
195  // Dimension height setting - edit points should move only along the feature lines
196  points->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBARO ),
197  points->Point( DIM_FEATUREGO ) ) );
198  points->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBARF ),
199  points->Point( DIM_FEATUREDO ) ) );
200 
201  break;
202  }
203 
204  default:
205  points.reset();
206  break;
207  }
208 
209  return points;
210  }
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
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:114
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.
Arcs (with rounded ends)
SHAPE_POLY_SET & GetPolyShape()
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:112
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
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: