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

Constructor & Destructor Documentation

EDIT_POINTS_FACTORY::EDIT_POINTS_FACTORY ( )
inlineprivate

Definition at line 215 of file point_editor.cpp.

215 {};

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

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

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

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