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

202 {};

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