KiCad PCB EDA Suite
DS_DATA_ITEM_POLYGONS Class Reference

#include <ds_data_item.h>

Inheritance diagram for DS_DATA_ITEM_POLYGONS:
DS_DATA_ITEM

Public Types

enum  DS_ITEM_TYPE {
  DS_TEXT , DS_SEGMENT , DS_RECT , DS_POLYPOLYGON ,
  DS_BITMAP
}
 

Public Member Functions

 DS_DATA_ITEM_POLYGONS ()
 
void SyncDrawItems (DS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView) override
 
virtual int GetPenSizeUi () override
 
void AppendCorner (const VECTOR2D &aCorner)
 Add a corner in corner list. More...
 
void CloseContour ()
 Close the current contour, by storing the index of the last corner of the current polygon in m_polyIndexEnd. More...
 
int GetPolyCount () const
 
unsigned GetPolyIndexStart (unsigned aContour) const
 
unsigned GetPolyIndexEnd (unsigned aContour) const
 
const VECTOR2D GetCornerPosition (unsigned aIdx, int aRepeat=0) const
 
const VECTOR2I GetCornerPositionUi (unsigned aIdx, int aRepeat=0) const
 
void SetBoundingBox ()
 Calculate the bounding box of the set polygons. More...
 
bool IsInsidePage (int ii) const override
 
const std::vector< DS_DRAW_ITEM_BASE * > & GetDrawItems () const
 
void SetStart (double aPosx, double aPosy, enum CORNER_ANCHOR aAnchor=RB_CORNER)
 
void SetEnd (double aPosx, double aPosy, enum CORNER_ANCHOR aAnchor=RB_CORNER)
 
DS_ITEM_TYPE GetType () const
 
PAGE_OPTION GetPage1Option () const
 
void SetPage1Option (PAGE_OPTION aChoice)
 
const VECTOR2I GetStartPosUi (int ii=0) const
 
const VECTOR2I GetEndPosUi (int ii=0) const
 
const VECTOR2D GetStartPos (int ii=0) const
 
const VECTOR2D GetEndPos (int ii=0) const
 
void MoveTo (const VECTOR2D &aPosition)
 Move item to a new position. More...
 
void MoveToUi (const VECTOR2I &aPosition)
 Move item to a new position. More...
 
void MoveStartPointTo (const VECTOR2D &aPosition)
 Move the starting point of the item to a new position. More...
 
void MoveStartPointToUi (const VECTOR2I &aPosition)
 Move the starting point of the item to a new position. More...
 
void MoveEndPointTo (const VECTOR2D &aPosition)
 Move the ending point of the item to a new position. More...
 
void MoveEndPointToUi (const VECTOR2I &aPosition)
 Move the ending point of the item to a new position. More...
 
const wxString GetClassName () const
 

Public Attributes

EDA_ANGLE m_Orient
 
std::vector< VECTOR2Dm_Corners
 
wxString m_Name
 
wxString m_Info
 
POINT_COORD m_Pos
 
POINT_COORD m_End
 
double m_LineWidth
 
int m_RepeatCount
 
VECTOR2D m_IncrementVector
 
int m_IncrementLabel
 

Protected Attributes

DS_ITEM_TYPE m_type
 
PAGE_OPTION m_pageOption
 
std::vector< DS_DRAW_ITEM_BASE * > m_drawItems
 

Private Attributes

std::vector< unsigned > m_polyIndexEnd
 
VECTOR2D m_minCoord
 
VECTOR2D m_maxCoord
 

Detailed Description

Definition at line 215 of file ds_data_item.h.

Member Enumeration Documentation

◆ DS_ITEM_TYPE

Enumerator
DS_TEXT 
DS_SEGMENT 
DS_RECT 
DS_POLYPOLYGON 
DS_BITMAP 

Definition at line 98 of file ds_data_item.h.

Constructor & Destructor Documentation

◆ DS_DATA_ITEM_POLYGONS()

DS_DATA_ITEM_POLYGONS::DS_DATA_ITEM_POLYGONS ( )

Definition at line 380 of file ds_data_item.cpp.

380 :
382{
383}
DS_DATA_ITEM(DS_ITEM_TYPE aType)

Member Function Documentation

◆ AppendCorner()

void DS_DATA_ITEM_POLYGONS::AppendCorner ( const VECTOR2D aCorner)
inline

Add a corner in corner list.

Parameters
aCorneris the item to append.

Definition at line 229 of file ds_data_item.h.

230 {
231 m_Corners.push_back( aCorner );
232 }
std::vector< VECTOR2D > m_Corners
Definition: ds_data_item.h:288

References m_Corners.

Referenced by DRAWING_SHEET_PARSER::parsePolyOutline().

◆ CloseContour()

void DS_DATA_ITEM_POLYGONS::CloseContour ( )
inline

Close the current contour, by storing the index of the last corner of the current polygon in m_polyIndexEnd.

Definition at line 238 of file ds_data_item.h.

239 {
240 m_polyIndexEnd.push_back( m_Corners.size() -1 );
241 }
std::vector< unsigned > m_polyIndexEnd
Definition: ds_data_item.h:291

References m_Corners, and m_polyIndexEnd.

Referenced by DRAWING_SHEET_PARSER::parsePolygon().

◆ GetClassName()

const wxString DS_DATA_ITEM::GetClassName ( ) const
inherited

Definition at line 363 of file ds_data_item.cpp.

364{
365 wxString name;
366
367 switch( GetType() )
368 {
369 case DS_TEXT: name = _( "Text" ); break;
370 case DS_SEGMENT: name = _( "Line" ); break;
371 case DS_RECT: name = _( "Rectangle" ); break;
372 case DS_POLYPOLYGON: name = _( "Imported Shape" ); break;
373 case DS_BITMAP: name = _( "Image" ); break;
374 }
375
376 return name;
377}
const char * name
Definition: DXF_plotter.cpp:56
DS_ITEM_TYPE GetType() const
Definition: ds_data_item.h:128
#define _(s)

References _, DS_DATA_ITEM::DS_BITMAP, DS_DATA_ITEM::DS_POLYPOLYGON, DS_DATA_ITEM::DS_RECT, DS_DATA_ITEM::DS_SEGMENT, DS_DATA_ITEM::DS_TEXT, DS_DATA_ITEM::GetType(), and name.

Referenced by PROPERTIES_FRAME::CopyPrmsFromItemToPanel().

◆ GetCornerPosition()

const VECTOR2D DS_DATA_ITEM_POLYGONS::GetCornerPosition ( unsigned  aIdx,
int  aRepeat = 0 
) const
Returns
the coordinate (in mm) of the corner aIdx and the repeated item aRepeat

Definition at line 447 of file ds_data_item.cpp.

448{
449 VECTOR2D pos = m_Corners[aIdx];
450
451 // Rotation:
452 RotatePoint( &pos.x, &pos.y, m_Orient );
453 pos += GetStartPos( aRepeat );
454 return pos;
455}
const VECTOR2D GetStartPos(int ii=0) const
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

References DS_DATA_ITEM::GetStartPos(), m_Corners, m_Orient, RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GetCornerPositionUi().

◆ GetCornerPositionUi()

const VECTOR2I DS_DATA_ITEM_POLYGONS::GetCornerPositionUi ( unsigned  aIdx,
int  aRepeat = 0 
) const
Returns
the coordinate (in draw/plot units) of the corner aIdx and the repeated item aRepeat

Definition at line 512 of file ds_data_item.cpp.

513{
514 VECTOR2D pos = GetCornerPosition( aIdx, aRepeat );
516 return VECTOR2I( int( pos.x ), int( pos.y ) );
517}
const VECTOR2D GetCornerPosition(unsigned aIdx, int aRepeat=0) const
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References GetCornerPosition(), DS_DATA_MODEL::GetTheInstance(), DS_DATA_MODEL::m_WSunits2Iu, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SyncDrawItems().

◆ GetDrawItems()

◆ GetEndPos()

const VECTOR2D DS_DATA_ITEM::GetEndPos ( int  ii = 0) const
inherited

Definition at line 304 of file ds_data_item.cpp.

305{
306 VECTOR2D pos( m_End.m_Pos.x + ( m_IncrementVector.x * ii ),
307 m_End.m_Pos.y + ( m_IncrementVector.y * ii ) );
308
309 switch( m_End.m_Anchor )
310 {
311 case RB_CORNER: // right bottom corner
313 break;
314
315 case RT_CORNER: // right top corner
318 break;
319
320 case LB_CORNER: // left bottom corner
323 break;
324
325 case LT_CORNER: // left top corner
327 break;
328 }
329
330 return pos;
331}
VECTOR2D m_IncrementVector
Definition: ds_data_item.h:204
POINT_COORD m_End
Definition: ds_data_item.h:201
VECTOR2D m_RB_Corner
VECTOR2D m_LT_Corner
VECTOR2D m_Pos
Definition: ds_data_item.h:80
@ RB_CORNER
Definition: ds_data_item.h:49
@ RT_CORNER
Definition: ds_data_item.h:50
@ LT_CORNER
Definition: ds_data_item.h:52
@ LB_CORNER
Definition: ds_data_item.h:51

References DS_DATA_MODEL::GetTheInstance(), LB_CORNER, LT_CORNER, POINT_COORD::m_Anchor, DS_DATA_ITEM::m_End, DS_DATA_ITEM::m_IncrementVector, DS_DATA_MODEL::m_LT_Corner, POINT_COORD::m_Pos, DS_DATA_MODEL::m_RB_Corner, RB_CORNER, RT_CORNER, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DS_DATA_ITEM::GetEndPosUi(), DS_DATA_ITEM::IsInsidePage(), and DS_DATA_ITEM::MoveTo().

◆ GetEndPosUi()

const VECTOR2I DS_DATA_ITEM::GetEndPosUi ( int  ii = 0) const
inherited

Definition at line 334 of file ds_data_item.cpp.

335{
336 VECTOR2D pos = GetEndPos( ii );
338 return VECTOR2I( KiROUND( pos.x ), KiROUND( pos.y ) );
339}
const VECTOR2D GetEndPos(int ii=0) const
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References DS_DATA_ITEM::GetEndPos(), DS_DATA_MODEL::GetTheInstance(), KiROUND(), DS_DATA_MODEL::m_WSunits2Iu, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DS_DATA_ITEM::MoveTo(), DS_DATA_ITEM::SyncDrawItems(), and PL_POINT_EDITOR::updateItem().

◆ GetPage1Option()

PAGE_OPTION DS_DATA_ITEM::GetPage1Option ( ) const
inlineinherited
Returns
true if the item has a end point (segment; rect) of false (text, polygon).

Definition at line 133 of file ds_data_item.h.

133{ return m_pageOption; }
PAGE_OPTION m_pageOption
Definition: ds_data_item.h:209

References DS_DATA_ITEM::m_pageOption.

Referenced by PROPERTIES_FRAME::CopyPrmsFromItemToPanel(), DS_DATA_MODEL_IO::formatOptions(), DS_DRAW_ITEM_BASE::GetMsgPanelInfo(), and DS_DRAW_ITEM_BASE::ViewGetLayers().

◆ GetPenSizeUi()

int DS_DATA_ITEM_POLYGONS::GetPenSizeUi ( )
overridevirtual

Reimplemented from DS_DATA_ITEM.

Definition at line 441 of file ds_data_item.cpp.

442{
443 return KiROUND( m_LineWidth * DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
444}
double m_LineWidth
Definition: ds_data_item.h:202

References DS_DATA_MODEL::GetTheInstance(), KiROUND(), and DS_DATA_ITEM::m_LineWidth.

Referenced by SyncDrawItems().

◆ GetPolyCount()

int DS_DATA_ITEM_POLYGONS::GetPolyCount ( ) const
inline
Returns
the count of contours in the poly polygon.

Definition at line 246 of file ds_data_item.h.

246{ return (int) m_polyIndexEnd.size(); }

References m_polyIndexEnd.

Referenced by DS_DATA_MODEL_IO::format(), and SyncDrawItems().

◆ GetPolyIndexEnd()

unsigned DS_DATA_ITEM_POLYGONS::GetPolyIndexEnd ( unsigned  aContour) const
inline
Parameters
aContouris the index of the contour.
Returns
the index of the last corner of the contour aCountour.

Definition at line 264 of file ds_data_item.h.

265 {
266 return m_polyIndexEnd[aContour];
267 }

References m_polyIndexEnd.

Referenced by DS_DATA_MODEL_IO::format(), and SyncDrawItems().

◆ GetPolyIndexStart()

unsigned DS_DATA_ITEM_POLYGONS::GetPolyIndexStart ( unsigned  aContour) const
inline
Parameters
aContouris the index of the contour.
Returns
the index of the first corner of the contour aCountour.

Definition at line 252 of file ds_data_item.h.

253 {
254 if( aContour == 0 )
255 return 0;
256 else
257 return m_polyIndexEnd[aContour-1] + 1;
258 }

References m_polyIndexEnd.

Referenced by DS_DATA_MODEL_IO::format(), and SyncDrawItems().

◆ GetStartPos()

const VECTOR2D DS_DATA_ITEM::GetStartPos ( int  ii = 0) const
inherited

Definition at line 266 of file ds_data_item.cpp.

267{
269 VECTOR2D pos( m_Pos.m_Pos.x + ( m_IncrementVector.x * ii ),
270 m_Pos.m_Pos.y + ( m_IncrementVector.y * ii ) );
271
272 switch( m_Pos.m_Anchor )
273 {
274 case RB_CORNER: // right bottom corner
275 pos = model.m_RB_Corner - pos;
276 break;
277
278 case RT_CORNER: // right top corner
279 pos.x = model.m_RB_Corner.x - pos.x;
280 pos.y = model.m_LT_Corner.y + pos.y;
281 break;
282
283 case LB_CORNER: // left bottom corner
284 pos.x = model.m_LT_Corner.x + pos.x;
285 pos.y = model.m_RB_Corner.y - pos.y;
286 break;
287
288 case LT_CORNER: // left top corner
289 pos = model.m_LT_Corner + pos;
290 break;
291 }
292
293 return pos;
294}
POINT_COORD m_Pos
Definition: ds_data_item.h:200
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:39

References DS_DATA_MODEL::GetTheInstance(), LB_CORNER, LT_CORNER, POINT_COORD::m_Anchor, DS_DATA_ITEM::m_IncrementVector, DS_DATA_MODEL::m_LT_Corner, POINT_COORD::m_Pos, DS_DATA_ITEM::m_Pos, DS_DATA_MODEL::m_RB_Corner, RB_CORNER, RT_CORNER, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GetCornerPosition(), DS_DATA_ITEM::GetStartPosUi(), DS_DATA_ITEM::IsInsidePage(), IsInsidePage(), and DS_DATA_ITEM::MoveTo().

◆ GetStartPosUi()

◆ GetType()

◆ IsInsidePage()

bool DS_DATA_ITEM_POLYGONS::IsInsidePage ( int  ii) const
overridevirtual
Returns
true if the item is inside the rectangle defined by the 4 corners, false otherwise.

Reimplemented from DS_DATA_ITEM.

Definition at line 492 of file ds_data_item.cpp.

493{
495
496 VECTOR2D pos = GetStartPos( ii );
497 pos += m_minCoord; // left top pos of bounding box
498
499 if( model.m_LT_Corner.x > pos.x || model.m_LT_Corner.y > pos.y )
500 return false;
501
502 pos = GetStartPos( ii );
503 pos += m_maxCoord; // right bottom pos of bounding box
504
505 if( model.m_RB_Corner.x < pos.x || model.m_RB_Corner.y < pos.y )
506 return false;
507
508 return true;
509}

References DS_DATA_ITEM::GetStartPos(), DS_DATA_MODEL::GetTheInstance(), DS_DATA_MODEL::m_LT_Corner, m_maxCoord, m_minCoord, DS_DATA_MODEL::m_RB_Corner, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SyncDrawItems().

◆ MoveEndPointTo()

void DS_DATA_ITEM::MoveEndPointTo ( const VECTOR2D aPosition)
inherited

Move the ending point of the item to a new position.

This has meaning only for items defined by 2 points (segments and rectangles).

Parameters
aPositionis the new position of the ending point, in mm.

Definition at line 213 of file ds_data_item.cpp.

214{
216 VECTOR2D position;
217
218 // Calculate the position of the starting point
219 // relative to the reference corner
220 // aPosition is the position relative to the right top paper corner
221 switch( m_End.m_Anchor )
222 {
223 case RB_CORNER:
224 position = model.m_RB_Corner - aPosition;
225 break;
226
227 case RT_CORNER:
228 position.x = model.m_RB_Corner.x - aPosition.x;
229 position.y = aPosition.y - model.m_LT_Corner.y;
230 break;
231
232 case LB_CORNER:
233 position.x = aPosition.x - model.m_LT_Corner.x;
234 position.y = model.m_RB_Corner.y - aPosition.y;
235 break;
236
237 case LT_CORNER:
238 position = aPosition - model.m_LT_Corner;
239 break;
240 }
241
242 // Modify m_End only for items having 2 coordinates
243 switch( GetType() )
244 {
245 case DS_SEGMENT:
246 case DS_RECT:
247 m_End.m_Pos = position;
248 break;
249
250 default:
251 break;
252 }
253}

References DS_DATA_ITEM::DS_RECT, DS_DATA_ITEM::DS_SEGMENT, DS_DATA_MODEL::GetTheInstance(), DS_DATA_ITEM::GetType(), LB_CORNER, LT_CORNER, POINT_COORD::m_Anchor, DS_DATA_ITEM::m_End, DS_DATA_MODEL::m_LT_Corner, POINT_COORD::m_Pos, DS_DATA_MODEL::m_RB_Corner, RB_CORNER, RT_CORNER, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DS_DATA_ITEM::MoveEndPointToUi(), and DS_DATA_ITEM::MoveTo().

◆ MoveEndPointToUi()

void DS_DATA_ITEM::MoveEndPointToUi ( const VECTOR2I aPosition)
inherited

Move the ending point of the item to a new position.

This has meaning only for items defined by 2 points (segments and rectangles).

Parameters
aPositionis the new position of the ending point in graphic units

Definition at line 256 of file ds_data_item.cpp.

257{
258 VECTOR2D pos_mm;
259 pos_mm.x = aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
260 pos_mm.y = aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
261
262 MoveEndPointTo( pos_mm );
263}
void MoveEndPointTo(const VECTOR2D &aPosition)
Move the ending point of the item to a new position.

References DS_DATA_MODEL::GetTheInstance(), DS_DATA_MODEL::m_WSunits2Iu, DS_DATA_ITEM::MoveEndPointTo(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PL_POINT_EDITOR::updateItem().

◆ MoveStartPointTo()

void DS_DATA_ITEM::MoveStartPointTo ( const VECTOR2D aPosition)
inherited

Move the starting point of the item to a new position.

Parameters
aPositionthe new position of the starting point, in mm.

Definition at line 171 of file ds_data_item.cpp.

172{
174 VECTOR2D position;
175
176 // Calculate the position of the starting point
177 // relative to the reference corner
178 // aPosition is the position relative to the right top paper corner
179 switch( m_Pos.m_Anchor )
180 {
181 case RB_CORNER:
182 position = model.m_RB_Corner - aPosition;
183 break;
184
185 case RT_CORNER:
186 position.x = model.m_RB_Corner.x - aPosition.x;
187 position.y = aPosition.y - model.m_LT_Corner.y;
188 break;
189
190 case LB_CORNER:
191 position.x = aPosition.x - model.m_LT_Corner.x;
192 position.y = model.m_RB_Corner.y - aPosition.y;
193 break;
194
195 case LT_CORNER:
196 position = aPosition - model.m_LT_Corner;
197 break;
198 }
199
200 m_Pos.m_Pos = position;
201}

References DS_DATA_MODEL::GetTheInstance(), LB_CORNER, LT_CORNER, POINT_COORD::m_Anchor, DS_DATA_MODEL::m_LT_Corner, POINT_COORD::m_Pos, DS_DATA_ITEM::m_Pos, DS_DATA_MODEL::m_RB_Corner, RB_CORNER, RT_CORNER, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DS_DATA_ITEM::MoveStartPointToUi(), and DS_DATA_ITEM::MoveTo().

◆ MoveStartPointToUi()

void DS_DATA_ITEM::MoveStartPointToUi ( const VECTOR2I aPosition)
inherited

Move the starting point of the item to a new position.

Parameters
aPositionis the new position of item in graphic units.

Definition at line 204 of file ds_data_item.cpp.

205{
208
209 MoveStartPointTo( pos_mm );
210}
void MoveStartPointTo(const VECTOR2D &aPosition)
Move the starting point of the item to a new position.

References DS_DATA_MODEL::GetTheInstance(), DS_DATA_MODEL::m_WSunits2Iu, DS_DATA_ITEM::MoveStartPointTo(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PL_DRAWING_TOOLS::PlaceItem(), and PL_POINT_EDITOR::updateItem().

◆ MoveTo()

void DS_DATA_ITEM::MoveTo ( const VECTOR2D aPosition)
inherited

Move item to a new position.

Parameters
aPositionthe new position of item, in mm.

Definition at line 155 of file ds_data_item.cpp.

156{
157 VECTOR2D vector = aPosition - GetStartPos();
158 VECTOR2D endpos = vector + GetEndPos();
159
160 MoveStartPointTo( aPosition );
161 MoveEndPointTo( endpos );
162
163 for( DS_DRAW_ITEM_BASE* drawItem : m_drawItems )
164 {
165 drawItem->SetPosition( GetStartPosUi( drawItem->GetIndexInPeer() ) );
166 drawItem->SetEnd( GetEndPosUi( drawItem->GetIndexInPeer() ) );
167 }
168}
const VECTOR2I GetStartPosUi(int ii=0) const
const VECTOR2I GetEndPosUi(int ii=0) const
Base class to handle basic graphic items.
Definition: ds_draw_item.h:59

References DS_DATA_ITEM::GetEndPos(), DS_DATA_ITEM::GetEndPosUi(), DS_DATA_ITEM::GetStartPos(), DS_DATA_ITEM::GetStartPosUi(), DS_DATA_ITEM::m_drawItems, DS_DATA_ITEM::MoveEndPointTo(), and DS_DATA_ITEM::MoveStartPointTo().

Referenced by DS_DATA_ITEM::MoveToUi().

◆ MoveToUi()

void DS_DATA_ITEM::MoveToUi ( const VECTOR2I aPosition)
inherited

Move item to a new position.

Parameters
aPositionthe new position of the starting point in graphic units.

Definition at line 145 of file ds_data_item.cpp.

146{
147 VECTOR2D pos_mm;
148 pos_mm.x = aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
149 pos_mm.y = aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
150
151 MoveTo( pos_mm );
152}
void MoveTo(const VECTOR2D &aPosition)
Move item to a new position.

References DS_DATA_MODEL::GetTheInstance(), DS_DATA_MODEL::m_WSunits2Iu, DS_DATA_ITEM::MoveTo(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PL_DRAWING_TOOLS::DrawShape(), and PL_EDIT_TOOL::moveItem().

◆ SetBoundingBox()

void DS_DATA_ITEM_POLYGONS::SetBoundingBox ( )

Calculate the bounding box of the set polygons.

Definition at line 458 of file ds_data_item.cpp.

459{
460 if( m_Corners.size() == 0 )
461 {
462 m_minCoord.x = m_maxCoord.x = 0.0;
463 m_minCoord.y = m_maxCoord.y = 0.0;
464 return;
465 }
466
467 VECTOR2I pos;
468 pos = m_Corners[0];
469 RotatePoint( &pos.x, &pos.y, m_Orient );
470 m_minCoord = m_maxCoord = pos;
471
472 for( unsigned ii = 1; ii < m_Corners.size(); ii++ )
473 {
474 pos = m_Corners[ii];
475 RotatePoint( &pos.x, &pos.y, m_Orient );
476
477 if( m_minCoord.x > pos.x )
478 m_minCoord.x = pos.x;
479
480 if( m_minCoord.y > pos.y )
481 m_minCoord.y = pos.y;
482
483 if( m_maxCoord.x < pos.x )
484 m_maxCoord.x = pos.x;
485
486 if( m_maxCoord.y < pos.y )
487 m_maxCoord.y = pos.y;
488 }
489}

References m_Corners, m_maxCoord, m_minCoord, m_Orient, RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DRAWING_SHEET_PARSER::parsePolygon().

◆ SetEnd()

void DS_DATA_ITEM::SetEnd ( double  aPosx,
double  aPosy,
enum CORNER_ANCHOR  aAnchor = RB_CORNER 
)
inlineinherited

Definition at line 121 of file ds_data_item.h.

122 {
123 m_End.m_Pos.x = aPosx;
124 m_End.m_Pos.y = aPosy;
125 m_End.m_Anchor = aAnchor;
126 }

References POINT_COORD::m_Anchor, DS_DATA_ITEM::m_End, POINT_COORD::m_Pos, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ SetPage1Option()

void DS_DATA_ITEM::SetPage1Option ( PAGE_OPTION  aChoice)
inlineinherited

◆ SetStart()

void DS_DATA_ITEM::SetStart ( double  aPosx,
double  aPosy,
enum CORNER_ANCHOR  aAnchor = RB_CORNER 
)
inlineinherited

Definition at line 114 of file ds_data_item.h.

115 {
116 m_Pos.m_Pos.x = aPosx;
117 m_Pos.m_Pos.y = aPosy;
118 m_Pos.m_Anchor = aAnchor;
119 }

References POINT_COORD::m_Anchor, POINT_COORD::m_Pos, DS_DATA_ITEM::m_Pos, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ SyncDrawItems()

void DS_DATA_ITEM_POLYGONS::SyncDrawItems ( DS_DRAW_ITEM_LIST aCollector,
KIGFX::VIEW aView 
)
overridevirtual

Reimplemented from DS_DATA_ITEM.

Definition at line 386 of file ds_data_item.cpp.

387{
388 std::map<int, EDA_ITEM_FLAGS> itemFlags;
389 DS_DRAW_ITEM_BASE* item = nullptr;
390
391 for( size_t i = 0; i < m_drawItems.size(); ++i )
392 {
393 item = m_drawItems[ i ];
394 itemFlags[ i ] = item->GetFlags();
395
396 if( aCollector )
397 aCollector->Remove( item );
398
399 if( aView )
400 aView->Remove( item );
401
402 delete item;
403 }
404
405 m_drawItems.clear();
406
407 for( int j = 0; j < m_RepeatCount; j++ )
408 {
409 if( j && !IsInsidePage( j ) )
410 continue;
411
412 int pensize = GetPenSizeUi();
413 auto poly_shape = new DS_DRAW_ITEM_POLYPOLYGONS( this, j, GetStartPosUi( j ), pensize );
414 poly_shape->SetFlags( itemFlags[ j ] );
415 m_drawItems.push_back( poly_shape );
416
417 // Transfer all outlines (basic polygons)
418 SHAPE_POLY_SET& polygons = poly_shape->GetPolygons();
419
420 for( int kk = 0; kk < GetPolyCount(); kk++ )
421 {
422 // Create new outline
423 unsigned ist = GetPolyIndexStart( kk );
424 unsigned iend = GetPolyIndexEnd( kk );
425
426 polygons.NewOutline();
427
428 while( ist <= iend )
429 polygons.Append( GetCornerPositionUi( ist++, j ) );
430 }
431
432 if( aCollector )
433 aCollector->Append( poly_shape );
434
435 if( aView )
436 aView->Add( poly_shape );
437 }
438}
unsigned GetPolyIndexStart(unsigned aContour) const
Definition: ds_data_item.h:252
unsigned GetPolyIndexEnd(unsigned aContour) const
Definition: ds_data_item.h:264
int GetPolyCount() const
Definition: ds_data_item.h:246
const VECTOR2I GetCornerPositionUi(unsigned aIdx, int aRepeat=0) const
bool IsInsidePage(int ii) const override
virtual int GetPenSizeUi() override
void Append(DS_DRAW_ITEM_BASE *aItem)
Definition: ds_draw_item.h:472
void Remove(DS_DRAW_ITEM_BASE *aItem)
Definition: ds_draw_item.h:477
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:142
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:316
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:349
Represent a set of closed polygons.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
int NewOutline()
Creates a new hole in a given outline.

References KIGFX::VIEW::Add(), DS_DRAW_ITEM_LIST::Append(), SHAPE_POLY_SET::Append(), GetCornerPositionUi(), EDA_ITEM::GetFlags(), GetPenSizeUi(), GetPolyCount(), GetPolyIndexEnd(), GetPolyIndexStart(), DS_DATA_ITEM::GetStartPosUi(), IsInsidePage(), DS_DATA_ITEM::m_drawItems, DS_DATA_ITEM::m_RepeatCount, SHAPE_POLY_SET::NewOutline(), DS_DRAW_ITEM_LIST::Remove(), and KIGFX::VIEW::Remove().

Member Data Documentation

◆ m_Corners

std::vector<VECTOR2D> DS_DATA_ITEM_POLYGONS::m_Corners

◆ m_drawItems

◆ m_End

◆ m_IncrementLabel

◆ m_IncrementVector

◆ m_Info

◆ m_LineWidth

◆ m_maxCoord

VECTOR2D DS_DATA_ITEM_POLYGONS::m_maxCoord
private

Definition at line 293 of file ds_data_item.h.

Referenced by IsInsidePage(), and SetBoundingBox().

◆ m_minCoord

VECTOR2D DS_DATA_ITEM_POLYGONS::m_minCoord
private

Definition at line 292 of file ds_data_item.h.

Referenced by IsInsidePage(), and SetBoundingBox().

◆ m_Name

◆ m_Orient

◆ m_pageOption

PAGE_OPTION DS_DATA_ITEM::m_pageOption
protectedinherited

◆ m_polyIndexEnd

std::vector<unsigned> DS_DATA_ITEM_POLYGONS::m_polyIndexEnd
private

Definition at line 291 of file ds_data_item.h.

Referenced by CloseContour(), GetPolyCount(), GetPolyIndexEnd(), and GetPolyIndexStart().

◆ m_Pos

◆ m_RepeatCount

◆ m_type

DS_ITEM_TYPE DS_DATA_ITEM::m_type
protectedinherited

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