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 ()
 Closes 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 (DPOINT aPosition)
 Move item to a new position. More...
 
void MoveToUi (wxPoint aPosition)
 Move item to a new position. More...
 
void MoveStartPointTo (DPOINT aPosition)
 Move the starting point of the item to a new position. More...
 
void MoveStartPointToUi (wxPoint aPosition)
 Move the starting point of the item to a new position. More...
 
void MoveEndPointTo (DPOINT aPosition)
 Move the ending point of the item to a new position. More...
 
void MoveEndPointToUi (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 219 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 405 of file ds_data_item.cpp.

405  :
407 {
408  m_Orient = 0.0;
409 }
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 233 of file ds_data_item.h.

234  {
235  m_Corners.push_back( aCorner );
236  }
std::vector< DPOINT > m_Corners
Definition: ds_data_item.h:292

References m_Corners.

Referenced by DRAWING_SHEET_READER_PARSER::parsePolyOutline().

◆ CloseContour()

void DS_DATA_ITEM_POLYGONS::CloseContour ( )
inline

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

Definition at line 242 of file ds_data_item.h.

243  {
244  m_polyIndexEnd.push_back( m_Corners.size() -1 );
245  }
std::vector< DPOINT > m_Corners
Definition: ds_data_item.h:292
std::vector< unsigned > m_polyIndexEnd
Definition: ds_data_item.h:295

References m_Corners, and m_polyIndexEnd.

Referenced by DRAWING_SHEET_READER_PARSER::parsePolygon().

◆ GetClassName()

const wxString DS_DATA_ITEM::GetClassName ( ) const
inherited

Definition at line 388 of file ds_data_item.cpp.

389 {
390  wxString name;
391 
392  switch( GetType() )
393  {
394  case DS_TEXT: name = _( "Text" ); break;
395  case DS_SEGMENT: name = _( "Line" ); break;
396  case DS_RECT: name = _( "Rectangle" ); break;
397  case DS_POLYPOLYGON: name = _( "Imported Shape" ); break;
398  case DS_BITMAP: name = _( "Image" ); break;
399  }
400 
401  return name;
402 }
DS_ITEM_TYPE GetType() const
Definition: ds_data_item.h:129
const char * name
Definition: DXF_plotter.cpp:59
#define _(s)
Definition: 3d_actions.cpp:33

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

473 {
474  DPOINT pos = m_Corners[aIdx];
475 
476  // Rotation:
477  RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
478  pos += GetStartPos( aRepeat );
479  return pos;
480 }
const DPOINT GetStartPos(int ii=0) const
std::vector< DPOINT > m_Corners
Definition: ds_data_item.h:292
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228

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

538 {
539  DPOINT pos = GetCornerPosition( aIdx, aRepeat );
541  return wxPoint( int(pos.x), int(pos.y) );
542 }
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 329 of file ds_data_item.cpp.

330 {
331  DPOINT pos( m_End.m_Pos.x + ( m_IncrementVector.x * ii ),
332  m_End.m_Pos.y + ( m_IncrementVector.y * ii ) );
333 
334  switch( m_End.m_Anchor )
335  {
336  case RB_CORNER: // right bottom corner
338  break;
339 
340  case RT_CORNER: // right top corner
341  pos.x = DS_DATA_MODEL::GetTheInstance().m_RB_Corner.x - pos.x;
342  pos.y = DS_DATA_MODEL::GetTheInstance().m_LT_Corner.y + pos.y;
343  break;
344 
345  case LB_CORNER: // left bottom corner
346  pos.x = DS_DATA_MODEL::GetTheInstance().m_LT_Corner.x + pos.x;
347  pos.y = DS_DATA_MODEL::GetTheInstance().m_RB_Corner.y - pos.y;
348  break;
349 
350  case LT_CORNER: // left top corner
352  break;
353  }
354 
355  return pos;
356 }
POINT_COORD m_End
Definition: ds_data_item.h:210
DPOINT m_RB_Corner
DPOINT m_LT_Corner
DPOINT m_IncrementVector
Definition: ds_data_item.h:213
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 359 of file ds_data_item.cpp.

360 {
361  DPOINT pos = GetEndPos( ii );
363  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
364 }
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:68

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 134 of file ds_data_item.h.

134 { return m_pageOption; }
PAGE_OPTION m_pageOption
Definition: ds_data_item.h:201

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

467 {
468  return KiROUND( m_LineWidth * DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
469 }
double m_LineWidth
Definition: ds_data_item.h:211
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:68

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 250 of file ds_data_item.h.

250 { return (int) m_polyIndexEnd.size(); }
std::vector< unsigned > m_polyIndexEnd
Definition: ds_data_item.h:295

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 268 of file ds_data_item.h.

269  {
270  return m_polyIndexEnd[aContour];
271  }
std::vector< unsigned > m_polyIndexEnd
Definition: ds_data_item.h:295

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 256 of file ds_data_item.h.

257  {
258  if( aContour == 0 )
259  return 0;
260  else
261  return m_polyIndexEnd[aContour-1] + 1;
262  }
std::vector< unsigned > m_polyIndexEnd
Definition: ds_data_item.h:295

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

292 {
294  DPOINT pos( m_Pos.m_Pos.x + ( m_IncrementVector.x * ii ),
295  m_Pos.m_Pos.y + ( m_IncrementVector.y * ii ) );
296 
297  switch( m_Pos.m_Anchor )
298  {
299  case RB_CORNER: // right bottom corner
300  pos = model.m_RB_Corner - pos;
301  break;
302 
303  case RT_CORNER: // right top corner
304  pos.x = model.m_RB_Corner.x - pos.x;
305  pos.y = model.m_LT_Corner.y + pos.y;
306  break;
307 
308  case LB_CORNER: // left bottom corner
309  pos.x = model.m_LT_Corner.x + pos.x;
310  pos.y = model.m_RB_Corner.y - pos.y;
311  break;
312 
313  case LT_CORNER: // left top corner
314  pos = model.m_LT_Corner + pos;
315  break;
316  }
317 
318  return pos;
319 }
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:213
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:209

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

323 {
325  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
326 }
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:68

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

518 {
520 
521  DPOINT pos = GetStartPos( ii );
522  pos += m_minCoord; // left top pos of bounding box
523 
524  if( model.m_LT_Corner.x > pos.x || model.m_LT_Corner.y > pos.y )
525  return false;
526 
527  pos = GetStartPos( ii );
528  pos += m_maxCoord; // right bottom pos of bounding box
529 
530  if( model.m_RB_Corner.x < pos.x || model.m_RB_Corner.y < pos.y )
531  return false;
532 
533  return true;
534 }
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 ( DPOINT  aPosition)
inherited

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

move the ending point of the item to a new position has meaning only for items defined by 2 points (segments and rectangles) aPosition = the new position of the ending point, in mm

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

234 {
236  DPOINT position;
237 
238  // Calculate the position of the starting point
239  // relative to the reference corner
240  // aPosition is the position relative to the right top paper corner
241  switch( m_End.m_Anchor )
242  {
243  case RB_CORNER:
244  position = model.m_RB_Corner - aPosition;
245  break;
246 
247  case RT_CORNER:
248  position.x = model.m_RB_Corner.x - aPosition.x;
249  position.y = aPosition.y - model.m_LT_Corner.y;
250  break;
251 
252  case LB_CORNER:
253  position.x = aPosition.x - model.m_LT_Corner.x;
254  position.y = model.m_RB_Corner.y - aPosition.y;
255  break;
256 
257  case LT_CORNER:
258  position = aPosition - model.m_LT_Corner;
259  break;
260  }
261 
262  // Modify m_End only for items having 2 coordinates
263  switch( GetType() )
264  {
265  case DS_SEGMENT:
266  case DS_RECT:
267  m_End.m_Pos = position;
268  break;
269 
270  default:
271  break;
272  }
273 }
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:210
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:129
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 ( 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 281 of file ds_data_item.cpp.

282 {
283  DPOINT pos_mm;
284  pos_mm.x = aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
285  pos_mm.y = aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
286 
287  MoveEndPointTo( pos_mm );
288 }
void MoveEndPointTo(DPOINT aPosition)
Move the ending point of the 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::MoveEndPointTo(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PL_POINT_EDITOR::updateItem().

◆ MoveStartPointTo()

void DS_DATA_ITEM::MoveStartPointTo ( 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 182 of file ds_data_item.cpp.

183 {
185  DPOINT position;
186 
187  // Calculate the position of the starting point
188  // relative to the reference corner
189  // aPosition is the position relative to the right top paper corner
190  switch( m_Pos.m_Anchor )
191  {
192  case RB_CORNER:
193  position = model.m_RB_Corner - aPosition;
194  break;
195 
196  case RT_CORNER:
197  position.x = model.m_RB_Corner.x - aPosition.x;
198  position.y = aPosition.y - model.m_LT_Corner.y;
199  break;
200 
201  case LB_CORNER:
202  position.x = aPosition.x - model.m_LT_Corner.x;
203  position.y = model.m_RB_Corner.y - aPosition.y;
204  break;
205 
206  case LT_CORNER:
207  position = aPosition - model.m_LT_Corner;
208  break;
209  }
210 
211  m_Pos.m_Pos = position;
212 }
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:209

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

219 {
220  DPOINT pos_mm( aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu,
222 
223  MoveStartPointTo( pos_mm );
224 }
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu
void MoveStartPointTo(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 ( DPOINT  aPosition)
inherited

Move item to a new position.

Parameters
aPositionthe new position of item, in mm.

Definition at line 163 of file ds_data_item.cpp.

164 {
165  DPOINT vector = aPosition - GetStartPos();
166  DPOINT endpos = vector + GetEndPos();
167 
168  MoveStartPointTo( aPosition );
169  MoveEndPointTo( endpos );
170 
171  for( DS_DRAW_ITEM_BASE* drawItem : m_drawItems )
172  {
173  drawItem->SetPosition( GetStartPosUi( drawItem->GetIndexInPeer() ) );
174  drawItem->SetEnd( GetEndPosUi( drawItem->GetIndexInPeer() ) );
175  }
176 }
const DPOINT GetEndPos(int ii=0) const
const DPOINT GetStartPos(int ii=0) const
const wxPoint GetEndPosUi(int ii=0) const
void MoveEndPointTo(DPOINT aPosition)
Move the ending point of the item to a new position.
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:203
void MoveStartPointTo(DPOINT aPosition)
Move the starting 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 ( wxPoint  aPosition)
inherited

Move item to a new position.

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

Definition at line 153 of file ds_data_item.cpp.

154 {
155  DPOINT pos_mm;
156  pos_mm.x = aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
157  pos_mm.y = aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
158 
159  MoveTo( pos_mm );
160 }
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
void MoveTo(DPOINT aPosition)
Move item to a new position.
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 483 of file ds_data_item.cpp.

484 {
485  if( m_Corners.size() == 0 )
486  {
487  m_minCoord.x = m_maxCoord.x = 0.0;
488  m_minCoord.y = m_maxCoord.y = 0.0;
489  return;
490  }
491 
492  DPOINT pos;
493  pos = m_Corners[0];
494  RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
495  m_minCoord = m_maxCoord = pos;
496 
497  for( unsigned ii = 1; ii < m_Corners.size(); ii++ )
498  {
499  pos = m_Corners[ii];
500  RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
501 
502  if( m_minCoord.x > pos.x )
503  m_minCoord.x = pos.x;
504 
505  if( m_minCoord.y > pos.y )
506  m_minCoord.y = pos.y;
507 
508  if( m_maxCoord.x < pos.x )
509  m_maxCoord.x = pos.x;
510 
511  if( m_maxCoord.y < pos.y )
512  m_maxCoord.y = pos.y;
513  }
514 }
std::vector< DPOINT > m_Corners
Definition: ds_data_item.h:292
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228

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

Referenced by DRAWING_SHEET_READER_PARSER::parsePolygon().

◆ SetEnd()

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

Definition at line 122 of file ds_data_item.h.

123  {
124  m_End.m_Pos.x = aPosx;
125  m_End.m_Pos.y = aPosy;
126  m_End.m_Anchor = aAnchor;
127  }
POINT_COORD m_End
Definition: ds_data_item.h:210
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 135 of file ds_data_item.h.

135 { m_pageOption = aChoice; }
PAGE_OPTION m_pageOption
Definition: ds_data_item.h:201

References DS_DATA_ITEM::m_pageOption.

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

◆ SetStart()

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

Definition at line 115 of file ds_data_item.h.

116  {
117  m_Pos.m_Pos.x = aPosx;
118  m_Pos.m_Pos.y = aPosy;
119  m_Pos.m_Anchor = aAnchor;
120  }
DPOINT m_Pos
Definition: ds_data_item.h:80
POINT_COORD m_Pos
Definition: ds_data_item.h:209

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

413 {
414  std::map<int, STATUS_FLAGS> itemFlags;
415  DS_DRAW_ITEM_BASE* item = nullptr;
416 
417  for( size_t i = 0; i < m_drawItems.size(); ++i )
418  {
419  item = m_drawItems[ i ];
420  itemFlags[ i ] = item->GetFlags();
421 
422  if( aCollector )
423  aCollector->Remove( item );
424 
425  if( aView )
426  aView->Remove( item );
427 
428  delete item;
429  }
430 
431  m_drawItems.clear();
432 
433  for( int j = 0; j < m_RepeatCount; j++ )
434  {
435  if( j && !IsInsidePage( j ) )
436  continue;
437 
438  int pensize = GetPenSizeUi();
439  auto poly_shape = new DS_DRAW_ITEM_POLYPOLYGONS( this, j, GetStartPosUi( j ), pensize );
440  poly_shape->SetFlags( itemFlags[ j ] );
441  m_drawItems.push_back( poly_shape );
442 
443  // Transfer all outlines (basic polygons)
444  SHAPE_POLY_SET& polygons = poly_shape->GetPolygons();
445  for( int kk = 0; kk < GetPolyCount(); kk++ )
446  {
447  // Create new outline
448  unsigned ist = GetPolyIndexStart( kk );
449  unsigned iend = GetPolyIndexEnd( kk );
450 
451  polygons.NewOutline();
452 
453  while( ist <= iend )
454  polygons.Append( GetCornerPositionUi( ist++, j ) );
455  }
456 
457  if( aCollector )
458  aCollector->Append( poly_shape );
459 
460  if( aView )
461  aView->Add( poly_shape );
462  }
463 }
unsigned GetPolyIndexStart(unsigned aContour) const
Definition: ds_data_item.h:256
bool IsInsidePage(int ii) const override
int GetPolyCount() const
Definition: ds_data_item.h:250
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:352
unsigned GetPolyIndexEnd(unsigned aContour) const
Definition: ds_data_item.h:268
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:203
Represent a set of closed polygons.
int NewOutline()
Creates a new hole in a given outline.
virtual int GetPenSizeUi() override
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:322
STATUS_FLAGS GetFlags() const
Definition: eda_item.h:205
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 297 of file ds_data_item.h.

Referenced by IsInsidePage(), and SetBoundingBox().

◆ m_minCoord

DPOINT DS_DATA_ITEM_POLYGONS::m_minCoord
private

Definition at line 296 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 295 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: