KiCad PCB EDA Suite
EDIT_POINTS_FACTORY Class Reference

Static Public Member Functions

static std::shared_ptr< EDIT_POINTSMake (EDA_ITEM *aItem, SCH_BASE_FRAME *frame)
 
static std::shared_ptr< EDIT_POINTSMake (EDA_ITEM *aItem)
 

Private Member Functions

 EDIT_POINTS_FACTORY ()
 
 EDIT_POINTS_FACTORY ()
 

Detailed Description

Definition at line 74 of file ee_point_editor.cpp.

Constructor & Destructor Documentation

◆ EDIT_POINTS_FACTORY() [1/2]

EDIT_POINTS_FACTORY::EDIT_POINTS_FACTORY ( )
inlineprivate

Definition at line 339 of file ee_point_editor.cpp.

339{};

◆ EDIT_POINTS_FACTORY() [2/2]

EDIT_POINTS_FACTORY::EDIT_POINTS_FACTORY ( )
inlineprivate

Definition at line 100 of file pl_point_editor.cpp.

100{};

Member Function Documentation

◆ Make() [1/2]

static std::shared_ptr< EDIT_POINTS > EDIT_POINTS_FACTORY::Make ( EDA_ITEM aItem)
inlinestatic

Definition at line 56 of file pl_point_editor.cpp.

57 {
58 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
59
60 if( !aItem )
61 return points;
62
63 // Generate list of edit points based on the item type
64 switch( aItem->Type() )
65 {
66 case WSG_LINE_T:
67 {
68 DS_DRAW_ITEM_LINE* line = static_cast<DS_DRAW_ITEM_LINE*>( aItem );
69 points->AddPoint( line->GetStart() );
70 points->AddPoint( line->GetEnd() );
71 break;
72 }
73 case WSG_RECT_T:
74 {
75 DS_DRAW_ITEM_RECT* rect = static_cast<DS_DRAW_ITEM_RECT*>( aItem );
76 VECTOR2I topLeft = rect->GetStart();
77 VECTOR2I botRight = rect->GetEnd();
78
79 if( topLeft.y > botRight.y )
80 std::swap( topLeft.y, botRight.y );
81
82 if( topLeft.x > botRight.x )
83 std::swap( topLeft.x, botRight.x );
84
85 points->AddPoint( topLeft );
86 points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) );
87 points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) );
88 points->AddPoint( botRight );
89 break;
90 }
91 default:
92 points.reset();
93 break;
94 }
95
96 return points;
97 }
const VECTOR2I & GetStart() const
Definition: ds_draw_item.h:133
const VECTOR2I & GetEnd() const
Definition: ds_draw_item.h:135
Non filled rectangle with thick segment.
Definition: ds_draw_item.h:207
const VECTOR2I & GetEnd() const
Definition: ds_draw_item.h:222
const VECTOR2I & GetStart() const
Definition: ds_draw_item.h:220
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
@ WSG_LINE_T
Definition: typeinfo.h:212
@ WSG_RECT_T
Definition: typeinfo.h:213
VECTOR2< int > VECTOR2I
Definition: vector2d.h:607

References DS_DRAW_ITEM_LINE::GetEnd(), DS_DRAW_ITEM_RECT::GetEnd(), DS_DRAW_ITEM_LINE::GetStart(), DS_DRAW_ITEM_RECT::GetStart(), EDA_ITEM::Type(), WSG_LINE_T, WSG_RECT_T, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Make() [2/2]

static std::shared_ptr< EDIT_POINTS > EDIT_POINTS_FACTORY::Make ( EDA_ITEM aItem,
SCH_BASE_FRAME frame 
)
inlinestatic

Definition at line 77 of file ee_point_editor.cpp.

78 {
79 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
80
81 if( !aItem )
82 return points;
83
84 // Generate list of edit points based on the item type
85 switch( aItem->Type() )
86 {
87 case LIB_SHAPE_T:
88 {
89 LIB_SHAPE* shape = static_cast<LIB_SHAPE*>( aItem );
90
91 switch( shape->GetShape() )
92 {
93 case SHAPE_T::ARC:
94 points->AddPoint( mapCoords( shape->GetPosition() ) );
95 points->AddPoint( mapCoords( shape->GetStart() ) );
96 points->AddPoint( mapCoords( shape->GetEnd() ) );
97 break;
98
99 case SHAPE_T::CIRCLE:
100 points->AddPoint( mapCoords( shape->GetPosition() ) );
101 points->AddPoint( mapCoords( shape->GetEnd() ) );
102 break;
103
104 case SHAPE_T::RECT:
105 {
106 shape->Normalize();
107
108 VECTOR2I topLeft = mapCoords( shape->GetPosition() );
109 VECTOR2I botRight = mapCoords( shape->GetEnd() );
110
111 points->AddPoint( topLeft );
112 points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) );
113 points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) );
114 points->AddPoint( botRight );
115
116 points->AddLine( points->Point( RECT_TOPLEFT ), points->Point( RECT_TOPRIGHT ) );
117 points->Line( RECT_TOP ).SetConstraint( new EC_PERPLINE( points->Line( RECT_TOP ) ) );
118 points->AddLine( points->Point( RECT_TOPRIGHT ), points->Point( RECT_BOTRIGHT ) );
119 points->Line( RECT_RIGHT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_RIGHT ) ) );
120 points->AddLine( points->Point( RECT_BOTRIGHT ), points->Point( RECT_BOTLEFT ) );
121 points->Line( RECT_BOT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_BOT ) ) );
122 points->AddLine( points->Point( RECT_BOTLEFT ), points->Point( RECT_TOPLEFT ) );
123 points->Line( RECT_LEFT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_LEFT ) ) );
124
125 break;
126 }
127
128 case SHAPE_T::POLY:
129 for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() )
130 points->AddPoint( mapCoords( pt ) );
131
132 break;
133
134 case SHAPE_T::BEZIER:
135 // TODO
136 break;
137
138 default:
140 }
141
142 break;
143 }
144
145 case LIB_TEXTBOX_T:
146 {
147 LIB_TEXTBOX* textBox = static_cast<LIB_TEXTBOX*>( aItem );
148
149 textBox->Normalize();
150
151 VECTOR2I topLeft = mapCoords( textBox->GetPosition() );
152 VECTOR2I botRight = mapCoords( textBox->GetEnd() );
153
154 points->AddPoint( topLeft );
155 points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) );
156 points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) );
157 points->AddPoint( botRight );
158
159 points->AddLine( points->Point( RECT_TOPLEFT ), points->Point( RECT_TOPRIGHT ) );
160 points->Line( RECT_TOP ).SetConstraint( new EC_PERPLINE( points->Line( RECT_TOP ) ) );
161 points->AddLine( points->Point( RECT_TOPRIGHT ), points->Point( RECT_BOTRIGHT ) );
162 points->Line( RECT_RIGHT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_RIGHT ) ) );
163 points->AddLine( points->Point( RECT_BOTRIGHT ), points->Point( RECT_BOTLEFT ) );
164 points->Line( RECT_BOT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_BOT ) ) );
165 points->AddLine( points->Point( RECT_BOTLEFT ), points->Point( RECT_TOPLEFT ) );
166 points->Line( RECT_LEFT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_LEFT ) ) );
167
168 break;
169 }
170
171 case SCH_SHAPE_T:
172 {
173 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem );
174
175 switch( shape->GetShape() )
176 {
177 case SHAPE_T::ARC:
178 points->AddPoint( shape->GetPosition() );
179 points->AddPoint( shape->GetStart() );
180 points->AddPoint( shape->GetEnd() );
181 break;
182
183 case SHAPE_T::CIRCLE:
184 points->AddPoint( shape->GetPosition() );
185 points->AddPoint( shape->GetEnd() );
186 break;
187
188 case SHAPE_T::RECT:
189 {
190 shape->Normalize();
191
192 VECTOR2I topLeft = shape->GetPosition();
193 VECTOR2I botRight = shape->GetEnd();
194
195 points->AddPoint( topLeft );
196 points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) );
197 points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) );
198 points->AddPoint( botRight );
199
200 points->AddLine( points->Point( RECT_TOPLEFT ), points->Point( RECT_TOPRIGHT ) );
201 points->Line( RECT_TOP ).SetConstraint( new EC_PERPLINE( points->Line( RECT_TOP ) ) );
202 points->AddLine( points->Point( RECT_TOPRIGHT ), points->Point( RECT_BOTRIGHT ) );
203 points->Line( RECT_RIGHT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_RIGHT ) ) );
204 points->AddLine( points->Point( RECT_BOTRIGHT ), points->Point( RECT_BOTLEFT ) );
205 points->Line( RECT_BOT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_BOT ) ) );
206 points->AddLine( points->Point( RECT_BOTLEFT ), points->Point( RECT_TOPLEFT ) );
207 points->Line( RECT_LEFT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_LEFT ) ) );
208
209 break;
210 }
211
212 case SHAPE_T::POLY:
213 for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() )
214 points->AddPoint( pt );
215
216 break;
217
218 case SHAPE_T::BEZIER:
219 // TODO
220 break;
221
222 default:
224 }
225
226 break;
227 }
228
229 case SCH_TEXTBOX_T:
230 {
231 SCH_TEXTBOX* textBox = static_cast<SCH_TEXTBOX*>( aItem );
232
233 textBox->Normalize();
234
235 VECTOR2I topLeft = textBox->GetPosition();
236 VECTOR2I botRight = textBox->GetEnd();
237
238 points->AddPoint( topLeft );
239 points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) );
240 points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) );
241 points->AddPoint( botRight );
242
243 points->AddLine( points->Point( RECT_TOPLEFT ), points->Point( RECT_TOPRIGHT ) );
244 points->Line( RECT_TOP ).SetConstraint( new EC_PERPLINE( points->Line( RECT_TOP ) ) );
245 points->AddLine( points->Point( RECT_TOPRIGHT ), points->Point( RECT_BOTRIGHT ) );
246 points->Line( RECT_RIGHT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_RIGHT ) ) );
247 points->AddLine( points->Point( RECT_BOTRIGHT ), points->Point( RECT_BOTLEFT ) );
248 points->Line( RECT_BOT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_BOT ) ) );
249 points->AddLine( points->Point( RECT_BOTLEFT ), points->Point( RECT_TOPLEFT ) );
250 points->Line( RECT_LEFT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_LEFT ) ) );
251
252 break;
253 }
254
255 case SCH_SHEET_T:
256 {
257 SCH_SHEET* sheet = (SCH_SHEET*) aItem;
258 VECTOR2I topLeft = sheet->GetPosition();
259 VECTOR2I botRight = sheet->GetPosition() + sheet->GetSize();
260
261 points->AddPoint( topLeft );
262 points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) );
263 points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) );
264 points->AddPoint( botRight );
265
266 points->AddLine( points->Point( RECT_TOPLEFT ), points->Point( RECT_TOPRIGHT ) );
267 points->Line( RECT_TOP ).SetConstraint( new EC_PERPLINE( points->Line( RECT_TOP ) ) );
268 points->AddLine( points->Point( RECT_TOPRIGHT ), points->Point( RECT_BOTRIGHT ) );
269 points->Line( RECT_RIGHT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_RIGHT ) ) );
270 points->AddLine( points->Point( RECT_BOTRIGHT ), points->Point( RECT_BOTLEFT ) );
271 points->Line( RECT_BOT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_BOT ) ) );
272 points->AddLine( points->Point( RECT_BOTLEFT ), points->Point( RECT_TOPLEFT ) );
273 points->Line( RECT_LEFT ).SetConstraint( new EC_PERPLINE( points->Line( RECT_LEFT ) ) );
274
275 break;
276 }
277
278 case SCH_BITMAP_T:
279 {
280 SCH_BITMAP* bitmap = (SCH_BITMAP*) aItem;
281 VECTOR2I topLeft = bitmap->GetPosition() - bitmap->GetSize() / 2;
282 VECTOR2I botRight = bitmap->GetPosition() + bitmap->GetSize() / 2;
283
284 points->AddPoint( topLeft );
285 points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) );
286 points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) );
287 points->AddPoint( botRight );
288 break;
289 }
290
291 case SCH_LINE_T:
292 {
293 SCH_LINE* line = (SCH_LINE*) aItem;
294 std::pair<EDA_ITEM*, int> connectedStart = { nullptr, STARTPOINT };
295 std::pair<EDA_ITEM*, int> connectedEnd = { nullptr, STARTPOINT };
296
297 for( SCH_ITEM* test : frame->GetScreen()->Items().OfType( SCH_LINE_T ) )
298 {
299 if( test->GetLayer() != LAYER_NOTES )
300 continue;
301
302 if( test == aItem )
303 continue;
304
305 SCH_LINE* testLine = static_cast<SCH_LINE*>( test );
306
307 if( testLine->GetStartPoint() == line->GetStartPoint() )
308 {
309 connectedStart = { testLine, STARTPOINT };
310 }
311 else if( testLine->GetEndPoint() == line->GetStartPoint() )
312 {
313 connectedStart = { testLine, ENDPOINT };
314 }
315 else if( testLine->GetStartPoint() == line->GetEndPoint() )
316 {
317 connectedEnd = { testLine, STARTPOINT };
318 }
319 else if( testLine->GetEndPoint() == line->GetEndPoint() )
320 {
321 connectedEnd = { testLine, ENDPOINT };
322 }
323 }
324
325 points->AddPoint( line->GetStartPoint(), connectedStart );
326 points->AddPoint( line->GetEndPoint(), connectedEnd );
327 break;
328 }
329
330 default:
331 points.reset();
332 break;
333 }
334
335 return points;
336 }
VECTOR2D mapCoords(const VECTOR2D &aSource)
Definition: PS_plotter.cpp:568
EDIT_CONSTRAINT for a EDIT_LINE, that constrains the line to move perpendicular to the line itself.
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:242
SHAPE_T GetShape() const
Definition: eda_shape.h:110
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:140
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:115
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:72
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:235
void Normalize()
Definition: lib_shape.cpp:92
VECTOR2I GetPosition() const override
Definition: lib_shape.h:85
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:41
VECTOR2I GetPosition() const override
Definition: sch_bitmap.h:136
wxSize GetSize() const
Definition: sch_bitmap.cpp:125
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:145
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
VECTOR2I GetEndPoint() const
Definition: sch_line.h:135
VECTOR2I GetStartPoint() const
Definition: sch_line.h:130
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:107
void Normalize()
Definition: sch_shape.cpp:72
VECTOR2I GetPosition() const override
Definition: sch_shape.h:77
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:55
VECTOR2I GetPosition() const override
Definition: sch_sheet.h:367
wxSize GetSize() const
Definition: sch_sheet.h:104
const std::vector< VECTOR2I > & CPoints() const
SHAPE_LINE_CHAIN & Outline(int aIndex)
#define ENDPOINT
ends. (Used to support dragging.)
#define STARTPOINT
When a line is selected, these flags indicate which.
@ RECT_BOTLEFT
@ RECT_TOPLEFT
@ RECT_TOPRIGHT
@ RECT_BOTRIGHT
@ RECT_RIGHT
@ RECT_LEFT
@ RECT_BOT
@ RECT_TOP
@ LAYER_NOTES
Definition: layer_ids.h:358
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
@ SCH_LINE_T
Definition: typeinfo.h:137
@ LIB_TEXTBOX_T
Definition: typeinfo.h:193
@ SCH_SHEET_T
Definition: typeinfo.h:149
@ LIB_SHAPE_T
Definition: typeinfo.h:191
@ SCH_SHAPE_T
Definition: typeinfo.h:138
@ SCH_BITMAP_T
Definition: typeinfo.h:139
@ SCH_TEXTBOX_T
Definition: typeinfo.h:140

References ARC, BEZIER, CIRCLE, SHAPE_LINE_CHAIN::CPoints(), ENDPOINT, EDA_SHAPE::GetEnd(), SCH_LINE::GetEndPoint(), EDA_SHAPE::GetPolyShape(), LIB_SHAPE::GetPosition(), SCH_BITMAP::GetPosition(), SCH_SHAPE::GetPosition(), SCH_SHEET::GetPosition(), SCH_BASE_FRAME::GetScreen(), EDA_SHAPE::GetShape(), SCH_BITMAP::GetSize(), SCH_SHEET::GetSize(), EDA_SHAPE::GetStart(), SCH_LINE::GetStartPoint(), SCH_SCREEN::Items(), LAYER_NOTES, LIB_SHAPE_T, LIB_TEXTBOX_T, mapCoords(), LIB_SHAPE::Normalize(), SCH_SHAPE::Normalize(), EE_RTREE::OfType(), SHAPE_POLY_SET::Outline(), POLY, RECT, RECT_BOT, RECT_BOTLEFT, RECT_BOTRIGHT, RECT_LEFT, RECT_RIGHT, RECT_TOP, RECT_TOPLEFT, RECT_TOPRIGHT, SCH_BITMAP_T, SCH_LINE_T, SCH_SHAPE_T, SCH_SHEET_T, SCH_TEXTBOX_T, EDA_SHAPE::SHAPE_T_asString(), STARTPOINT, EDA_ITEM::Type(), UNIMPLEMENTED_FOR, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), and EE_POINT_EDITOR::updatePoints().


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