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

Constructor & Destructor Documentation

EDIT_POINTS_FACTORY::EDIT_POINTS_FACTORY ( )
inlineprivate

Definition at line 216 of file point_editor.cpp.

216 {};

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

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

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

References ARC_CENTER, 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().

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