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 DPOINT &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 DPOINT GetCornerPosition (unsigned aIdx, int aRepeat=0) const
 
const wxPoint 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 wxPoint GetStartPosUi (int ii=0) const
 
const wxPoint GetEndPosUi (int ii=0) const
 
const DPOINT GetStartPos (int ii=0) const
 
const DPOINT GetEndPos (int ii=0) const
 
void MoveTo (const DPOINT &aPosition)
 Move item to a new position. More...
 
void MoveToUi (const wxPoint &aPosition)
 Move item to a new position. More...
 
void MoveStartPointTo (const DPOINT &aPosition)
 Move the starting point of the item to a new position. More...
 
void MoveStartPointToUi (const wxPoint &aPosition)
 Move the starting point of the item to a new position. More...
 
void MoveEndPointTo (const DPOINT &aPosition)
 Move the ending point of the item to a new position. More...
 
void MoveEndPointToUi (const wxPoint &aPosition)
 Move the ending point of the item to a new position. More...
 
const wxString GetClassName () const
 

Public Attributes

double m_Orient
 
std::vector< DPOINTm_Corners
 
wxString m_Name
 
wxString m_Info
 
POINT_COORD m_Pos
 
POINT_COORD m_End
 
double m_LineWidth
 
int m_RepeatCount
 
DPOINT 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
 
DPOINT m_minCoord
 
DPOINT 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 381 of file ds_data_item.cpp.

381  :
383 {
384  m_Orient = 0.0;
385 }
DS_DATA_ITEM(DS_ITEM_TYPE aType)

References m_Orient.

Member Function Documentation

◆ AppendCorner()

void DS_DATA_ITEM_POLYGONS::AppendCorner ( const DPOINT 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< DPOINT > 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< DPOINT > m_Corners
Definition: ds_data_item.h:288
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 364 of file ds_data_item.cpp.

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

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 DPOINT 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 448 of file ds_data_item.cpp.

449 {
450  DPOINT pos = m_Corners[aIdx];
451 
452  // Rotation:
453  RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
454  pos += GetStartPos( aRepeat );
455  return pos;
456 }
const DPOINT GetStartPos(int ii=0) const
std::vector< DPOINT > m_Corners
Definition: ds_data_item.h:288
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229

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

Referenced by GetCornerPositionUi().

◆ GetCornerPositionUi()

const wxPoint 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 513 of file ds_data_item.cpp.

514 {
515  DPOINT pos = GetCornerPosition( aIdx, aRepeat );
517  return wxPoint( int(pos.x), int(pos.y) );
518 }
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu
const DPOINT GetCornerPosition(unsigned aIdx, int aRepeat=0) const

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

Referenced by SyncDrawItems().

◆ GetDrawItems()

const std::vector<DS_DRAW_ITEM_BASE*>& DS_DATA_ITEM::GetDrawItems ( ) const
inlineinherited

◆ GetEndPos()

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

Definition at line 305 of file ds_data_item.cpp.

306 {
307  DPOINT pos( m_End.m_Pos.x + ( m_IncrementVector.x * ii ),
308  m_End.m_Pos.y + ( m_IncrementVector.y * ii ) );
309 
310  switch( m_End.m_Anchor )
311  {
312  case RB_CORNER: // right bottom corner
314  break;
315 
316  case RT_CORNER: // right top corner
317  pos.x = DS_DATA_MODEL::GetTheInstance().m_RB_Corner.x - pos.x;
318  pos.y = DS_DATA_MODEL::GetTheInstance().m_LT_Corner.y + pos.y;
319  break;
320 
321  case LB_CORNER: // left bottom corner
322  pos.x = DS_DATA_MODEL::GetTheInstance().m_LT_Corner.x + pos.x;
323  pos.y = DS_DATA_MODEL::GetTheInstance().m_RB_Corner.y - pos.y;
324  break;
325 
326  case LT_CORNER: // left top corner
328  break;
329  }
330 
331  return pos;
332 }
POINT_COORD m_End
Definition: ds_data_item.h:201
DPOINT m_RB_Corner
DPOINT m_LT_Corner
DPOINT m_IncrementVector
Definition: ds_data_item.h:204
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
DPOINT m_Pos
Definition: ds_data_item.h:80

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 wxPoint DS_DATA_ITEM::GetEndPosUi ( int  ii = 0) const
inherited

Definition at line 335 of file ds_data_item.cpp.

336 {
337  DPOINT pos = GetEndPos( ii );
339  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
340 }
const DPOINT GetEndPos(int ii=0) const
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu
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:73

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 442 of file ds_data_item.cpp.

443 {
444  return KiROUND( m_LineWidth * DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
445 }
double m_LineWidth
Definition: ds_data_item.h:202
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
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:73

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(); }
std::vector< unsigned > m_polyIndexEnd
Definition: ds_data_item.h:291

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  }
std::vector< unsigned > m_polyIndexEnd
Definition: ds_data_item.h:291

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  }
std::vector< unsigned > m_polyIndexEnd
Definition: ds_data_item.h:291

References m_polyIndexEnd.

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

◆ GetStartPos()

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

Definition at line 267 of file ds_data_item.cpp.

268 {
270  DPOINT pos( m_Pos.m_Pos.x + ( m_IncrementVector.x * ii ),
271  m_Pos.m_Pos.y + ( m_IncrementVector.y * ii ) );
272 
273  switch( m_Pos.m_Anchor )
274  {
275  case RB_CORNER: // right bottom corner
276  pos = model.m_RB_Corner - pos;
277  break;
278 
279  case RT_CORNER: // right top corner
280  pos.x = model.m_RB_Corner.x - pos.x;
281  pos.y = model.m_LT_Corner.y + pos.y;
282  break;
283 
284  case LB_CORNER: // left bottom corner
285  pos.x = model.m_LT_Corner.x + pos.x;
286  pos.y = model.m_RB_Corner.y - pos.y;
287  break;
288 
289  case LT_CORNER: // left top corner
290  pos = model.m_LT_Corner + pos;
291  break;
292  }
293 
294  return pos;
295 }
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
DPOINT m_RB_Corner
DPOINT m_LT_Corner
DPOINT m_IncrementVector
Definition: ds_data_item.h:204
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
DPOINT m_Pos
Definition: ds_data_item.h:80
POINT_COORD m_Pos
Definition: ds_data_item.h:200

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()

const wxPoint DS_DATA_ITEM::GetStartPosUi ( int  ii = 0) const
inherited

Definition at line 298 of file ds_data_item.cpp.

299 {
301  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
302 }
const DPOINT GetStartPos(int ii=0) const
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu
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:73

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

Referenced by PL_EDIT_TOOL::moveItem(), DS_DATA_ITEM::MoveTo(), PL_DRAWING_TOOLS::PlaceItem(), DS_DATA_ITEM::SyncDrawItems(), SyncDrawItems(), DS_DATA_ITEM_TEXT::SyncDrawItems(), DS_DATA_ITEM_BITMAP::SyncDrawItems(), and PL_POINT_EDITOR::updateItem().

◆ 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 493 of file ds_data_item.cpp.

494 {
496 
497  DPOINT pos = GetStartPos( ii );
498  pos += m_minCoord; // left top pos of bounding box
499 
500  if( model.m_LT_Corner.x > pos.x || model.m_LT_Corner.y > pos.y )
501  return false;
502 
503  pos = GetStartPos( ii );
504  pos += m_maxCoord; // right bottom pos of bounding box
505 
506  if( model.m_RB_Corner.x < pos.x || model.m_RB_Corner.y < pos.y )
507  return false;
508 
509  return true;
510 }
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
const DPOINT GetStartPos(int ii=0) const
DPOINT m_RB_Corner
DPOINT m_LT_Corner
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application

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 DPOINT 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 214 of file ds_data_item.cpp.

215 {
217  DPOINT position;
218 
219  // Calculate the position of the starting point
220  // relative to the reference corner
221  // aPosition is the position relative to the right top paper corner
222  switch( m_End.m_Anchor )
223  {
224  case RB_CORNER:
225  position = model.m_RB_Corner - aPosition;
226  break;
227 
228  case RT_CORNER:
229  position.x = model.m_RB_Corner.x - aPosition.x;
230  position.y = aPosition.y - model.m_LT_Corner.y;
231  break;
232 
233  case LB_CORNER:
234  position.x = aPosition.x - model.m_LT_Corner.x;
235  position.y = model.m_RB_Corner.y - aPosition.y;
236  break;
237 
238  case LT_CORNER:
239  position = aPosition - model.m_LT_Corner;
240  break;
241  }
242 
243  // Modify m_End only for items having 2 coordinates
244  switch( GetType() )
245  {
246  case DS_SEGMENT:
247  case DS_RECT:
248  m_End.m_Pos = position;
249  break;
250 
251  default:
252  break;
253  }
254 }
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
POINT_COORD m_End
Definition: ds_data_item.h:201
DPOINT m_RB_Corner
DPOINT m_LT_Corner
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
DS_ITEM_TYPE GetType() const
Definition: ds_data_item.h:128
DPOINT m_Pos
Definition: ds_data_item.h:80

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 wxPoint &  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 257 of file ds_data_item.cpp.

258 {
259  DPOINT pos_mm;
260  pos_mm.x = aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
261  pos_mm.y = aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
262 
263  MoveEndPointTo( pos_mm );
264 }
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu
void MoveEndPointTo(const DPOINT &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 DPOINT 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 172 of file ds_data_item.cpp.

173 {
175  DPOINT position;
176 
177  // Calculate the position of the starting point
178  // relative to the reference corner
179  // aPosition is the position relative to the right top paper corner
180  switch( m_Pos.m_Anchor )
181  {
182  case RB_CORNER:
183  position = model.m_RB_Corner - aPosition;
184  break;
185 
186  case RT_CORNER:
187  position.x = model.m_RB_Corner.x - aPosition.x;
188  position.y = aPosition.y - model.m_LT_Corner.y;
189  break;
190 
191  case LB_CORNER:
192  position.x = aPosition.x - model.m_LT_Corner.x;
193  position.y = model.m_RB_Corner.y - aPosition.y;
194  break;
195 
196  case LT_CORNER:
197  position = aPosition - model.m_LT_Corner;
198  break;
199  }
200 
201  m_Pos.m_Pos = position;
202 }
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
DPOINT m_RB_Corner
DPOINT m_LT_Corner
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
DPOINT m_Pos
Definition: ds_data_item.h:80
POINT_COORD m_Pos
Definition: ds_data_item.h:200

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 wxPoint &  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 205 of file ds_data_item.cpp.

206 {
207  DPOINT pos_mm( aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu,
209 
210  MoveStartPointTo( pos_mm );
211 }
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu
void MoveStartPointTo(const DPOINT &aPosition)
Move the starting point of the item to a new position.

References DS_DATA_MODEL::GetTheInstance(), DS_DATA_MODEL::m_WSunits2Iu, and DS_DATA_ITEM::MoveStartPointTo().

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

◆ MoveTo()

void DS_DATA_ITEM::MoveTo ( const DPOINT aPosition)
inherited

Move item to a new position.

Parameters
aPositionthe new position of item, in mm.

Definition at line 156 of file ds_data_item.cpp.

157 {
158  DPOINT vector = aPosition - GetStartPos();
159  DPOINT endpos = vector + GetEndPos();
160 
161  MoveStartPointTo( aPosition );
162  MoveEndPointTo( endpos );
163 
164  for( DS_DRAW_ITEM_BASE* drawItem : m_drawItems )
165  {
166  drawItem->SetPosition( GetStartPosUi( drawItem->GetIndexInPeer() ) );
167  drawItem->SetEnd( GetEndPosUi( drawItem->GetIndexInPeer() ) );
168  }
169 }
const DPOINT GetEndPos(int ii=0) const
const DPOINT GetStartPos(int ii=0) const
const wxPoint GetEndPosUi(int ii=0) const
Base class to handle basic graphic items.
Definition: ds_draw_item.h:58
std::vector< DS_DRAW_ITEM_BASE * > m_drawItems
Definition: ds_data_item.h:211
void MoveStartPointTo(const DPOINT &aPosition)
Move the starting point of the item to a new position.
void MoveEndPointTo(const DPOINT &aPosition)
Move the ending point of the item to a new position.
const wxPoint GetStartPosUi(int ii=0) const

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 wxPoint &  aPosition)
inherited

Move item to a new position.

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

Definition at line 146 of file ds_data_item.cpp.

147 {
148  DPOINT pos_mm;
149  pos_mm.x = aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
150  pos_mm.y = aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
151 
152  MoveTo( pos_mm );
153 }
void MoveTo(const DPOINT &aPosition)
Move item to a new position.
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu

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 459 of file ds_data_item.cpp.

460 {
461  if( m_Corners.size() == 0 )
462  {
463  m_minCoord.x = m_maxCoord.x = 0.0;
464  m_minCoord.y = m_maxCoord.y = 0.0;
465  return;
466  }
467 
468  DPOINT pos;
469  pos = m_Corners[0];
470  RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
471  m_minCoord = m_maxCoord = pos;
472 
473  for( unsigned ii = 1; ii < m_Corners.size(); ii++ )
474  {
475  pos = m_Corners[ii];
476  RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
477 
478  if( m_minCoord.x > pos.x )
479  m_minCoord.x = pos.x;
480 
481  if( m_minCoord.y > pos.y )
482  m_minCoord.y = pos.y;
483 
484  if( m_maxCoord.x < pos.x )
485  m_maxCoord.x = pos.x;
486 
487  if( m_maxCoord.y < pos.y )
488  m_maxCoord.y = pos.y;
489  }
490 }
std::vector< DPOINT > m_Corners
Definition: ds_data_item.h:288
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229

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  }
POINT_COORD m_End
Definition: ds_data_item.h:201
DPOINT m_Pos
Definition: ds_data_item.h:80

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

Definition at line 134 of file ds_data_item.h.

134 { m_pageOption = aChoice; }
PAGE_OPTION m_pageOption
Definition: ds_data_item.h:209

References DS_DATA_ITEM::m_pageOption.

Referenced by PROPERTIES_FRAME::CopyPrmsFromPanelToItem(), and DRAWING_SHEET_PARSER::readOption().

◆ 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  }
DPOINT m_Pos
Definition: ds_data_item.h:80
POINT_COORD m_Pos
Definition: ds_data_item.h:200

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 388 of file ds_data_item.cpp.

389 {
390  std::map<int, EDA_ITEM_FLAGS> itemFlags;
391  DS_DRAW_ITEM_BASE* item = nullptr;
392 
393  for( size_t i = 0; i < m_drawItems.size(); ++i )
394  {
395  item = m_drawItems[ i ];
396  itemFlags[ i ] = item->GetFlags();
397 
398  if( aCollector )
399  aCollector->Remove( item );
400 
401  if( aView )
402  aView->Remove( item );
403 
404  delete item;
405  }
406 
407  m_drawItems.clear();
408 
409  for( int j = 0; j < m_RepeatCount; j++ )
410  {
411  if( j && !IsInsidePage( j ) )
412  continue;
413 
414  int pensize = GetPenSizeUi();
415  auto poly_shape = new DS_DRAW_ITEM_POLYPOLYGONS( this, j, GetStartPosUi( j ), pensize );
416  poly_shape->SetFlags( itemFlags[ j ] );
417  m_drawItems.push_back( poly_shape );
418 
419  // Transfer all outlines (basic polygons)
420  SHAPE_POLY_SET& polygons = poly_shape->GetPolygons();
421  for( int kk = 0; kk < GetPolyCount(); kk++ )
422  {
423  // Create new outline
424  unsigned ist = GetPolyIndexStart( kk );
425  unsigned iend = GetPolyIndexEnd( kk );
426 
427  polygons.NewOutline();
428 
429  while( ist <= iend )
430  polygons.Append( GetCornerPositionUi( ist++, j ) );
431  }
432 
433  if( aCollector )
434  aCollector->Append( poly_shape );
435 
436  if( aView )
437  aView->Add( poly_shape );
438  }
439 }
unsigned GetPolyIndexStart(unsigned aContour) const
Definition: ds_data_item.h:252
bool IsInsidePage(int ii) const override
int GetPolyCount() const
Definition: ds_data_item.h:246
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:348
unsigned GetPolyIndexEnd(unsigned aContour) const
Definition: ds_data_item.h:264
Base class to handle basic graphic items.
Definition: ds_draw_item.h:58
const wxPoint GetCornerPositionUi(unsigned aIdx, int aRepeat=0) const
std::vector< DS_DRAW_ITEM_BASE * > m_drawItems
Definition: ds_data_item.h:211
Represent a set of closed polygons.
int NewOutline()
Creates a new hole in a given outline.
virtual int GetPenSizeUi() override
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:155
void Append(DS_DRAW_ITEM_BASE *aItem)
Definition: ds_draw_item.h:473
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:318
void Remove(DS_DRAW_ITEM_BASE *aItem)
Definition: ds_draw_item.h:478
const wxPoint GetStartPosUi(int ii=0) const
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...

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(), KIGFX::VIEW::Remove(), and DS_DRAW_ITEM_LIST::Remove().

Member Data Documentation

◆ m_Corners

std::vector<DPOINT> DS_DATA_ITEM_POLYGONS::m_Corners

◆ m_drawItems

◆ m_End

◆ m_IncrementLabel

◆ m_IncrementVector

◆ m_Info

◆ m_LineWidth

◆ m_maxCoord

DPOINT DS_DATA_ITEM_POLYGONS::m_maxCoord
private

Definition at line 293 of file ds_data_item.h.

Referenced by IsInsidePage(), and SetBoundingBox().

◆ m_minCoord

DPOINT 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: