KiCad PCB EDA Suite
WS_DATA_ITEM_POLYGONS Class Reference

#include <ws_data_item.h>

Inheritance diagram for WS_DATA_ITEM_POLYGONS:
WS_DATA_ITEM

Public Types

enum  WS_ITEM_TYPE {
  WS_TEXT, WS_SEGMENT, WS_RECT, WS_POLYPOLYGON,
  WS_BITMAP
}
 

Public Member Functions

 WS_DATA_ITEM_POLYGONS ()
 
void SyncDrawItems (WS_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< WS_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)
 
WS_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 has meaning only for items defined by 2 points (segments and rectangles) More...
 
void MoveEndPointToUi (wxPoint aPosition)
 move the ending point of the item to a new position has meaning only for items defined by 2 points (segments and rectangles) 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

WS_ITEM_TYPE m_type
 
PAGE_OPTION m_pageOption
 
std::vector< WS_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 ws_data_item.h.

Member Enumeration Documentation

◆ WS_ITEM_TYPE

Enumerator
WS_TEXT 
WS_SEGMENT 
WS_RECT 
WS_POLYPOLYGON 
WS_BITMAP 

Definition at line 96 of file ws_data_item.h.

Constructor & Destructor Documentation

◆ WS_DATA_ITEM_POLYGONS()

WS_DATA_ITEM_POLYGONS::WS_DATA_ITEM_POLYGONS ( )

Definition at line 392 of file ws_data_item.cpp.

392  :
394 {
395  m_Orient = 0.0;
396 }
WS_DATA_ITEM(WS_ITEM_TYPE aType)

References m_Orient.

Member Function Documentation

◆ AppendCorner()

void WS_DATA_ITEM_POLYGONS::AppendCorner ( const DPOINT aCorner)
inline

add a corner in corner list

Parameters
aCornerthe item to append

Definition at line 237 of file ws_data_item.h.

238  {
239  m_Corners.push_back( aCorner );
240  }
std::vector< DPOINT > m_Corners
Definition: ws_data_item.h:219

References m_Corners.

Referenced by PAGE_LAYOUT_READER_PARSER::parsePolyOutline().

◆ CloseContour()

void WS_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 246 of file ws_data_item.h.

247  {
248  m_polyIndexEnd.push_back( m_Corners.size() -1 );
249  }
std::vector< DPOINT > m_Corners
Definition: ws_data_item.h:219
std::vector< unsigned > m_polyIndexEnd
Definition: ws_data_item.h:222

References m_Corners, and m_polyIndexEnd.

Referenced by PAGE_LAYOUT_READER_PARSER::parsePolygon().

◆ GetClassName()

const wxString WS_DATA_ITEM::GetClassName ( ) const
inherited

Definition at line 375 of file ws_data_item.cpp.

376 {
377  wxString name;
378 
379  switch( GetType() )
380  {
381  case WS_TEXT: name = wxT( "Text" ); break;
382  case WS_SEGMENT: name = wxT( "Line" ); break;
383  case WS_RECT: name = wxT( "Rectangle" ); break;
384  case WS_POLYPOLYGON: name = wxT( "Imported Shape" ); break;
385  case WS_BITMAP: name = wxT( "Image" ); break;
386  }
387 
388  return name;
389 }
WS_ITEM_TYPE GetType() const
Definition: ws_data_item.h:147
const char * name
Definition: DXF_plotter.cpp:61

References WS_DATA_ITEM::GetType(), name, WS_DATA_ITEM::WS_BITMAP, WS_DATA_ITEM::WS_POLYPOLYGON, WS_DATA_ITEM::WS_RECT, WS_DATA_ITEM::WS_SEGMENT, and WS_DATA_ITEM::WS_TEXT.

Referenced by PROPERTIES_FRAME::CopyPrmsFromItemToPanel().

◆ GetCornerPosition()

const DPOINT WS_DATA_ITEM_POLYGONS::GetCornerPosition ( unsigned  aIdx,
int  aRepeat = 0 
) const
Returns
the coordinate (in mm) of the corner aIdx, for the repeated item aRepeat

Definition at line 459 of file ws_data_item.cpp.

460 {
461  DPOINT pos = m_Corners[aIdx];
462 
463  // Rotation:
464  RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
465  pos += GetStartPos( aRepeat );
466  return pos;
467 }
const DPOINT GetStartPos(int ii=0) const
std::vector< DPOINT > m_Corners
Definition: ws_data_item.h:219
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:206

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

Referenced by GetCornerPositionUi().

◆ GetCornerPositionUi()

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

Definition at line 524 of file ws_data_item.cpp.

525 {
526  DPOINT pos = GetCornerPosition( aIdx, aRepeat );
528  return wxPoint( int(pos.x), int(pos.y) );
529 }
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
double m_WSunits2Iu
Definition: ws_data_model.h:51
const DPOINT GetCornerPosition(unsigned aIdx, int aRepeat=0) const

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

Referenced by SyncDrawItems().

◆ GetDrawItems()

const std::vector<WS_DRAW_ITEM_BASE*>& WS_DATA_ITEM::GetDrawItems ( ) const
inlineinherited

◆ GetEndPos()

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

Definition at line 316 of file ws_data_item.cpp.

317 {
318  DPOINT pos( m_End.m_Pos.x + ( m_IncrementVector.x * ii ),
319  m_End.m_Pos.y + ( m_IncrementVector.y * ii ) );
320 
321  switch( m_End.m_Anchor )
322  {
323  case RB_CORNER: // right bottom corner
325  break;
326 
327  case RT_CORNER: // right top corner
328  pos.x = WS_DATA_MODEL::GetTheInstance().m_RB_Corner.x - pos.x;
329  pos.y = WS_DATA_MODEL::GetTheInstance().m_LT_Corner.y + pos.y;
330  break;
331 
332  case LB_CORNER: // left bottom corner
333  pos.x = WS_DATA_MODEL::GetTheInstance().m_LT_Corner.x + pos.x;
334  pos.y = WS_DATA_MODEL::GetTheInstance().m_RB_Corner.y - pos.y;
335  break;
336 
337  case LT_CORNER: // left top corner
339  break;
340  }
341 
342  return pos;
343 }
DPOINT m_RB_Corner
Definition: ws_data_model.h:53
POINT_COORD m_End
Definition: ws_data_item.h:116
DPOINT m_LT_Corner
Definition: ws_data_model.h:54
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
DPOINT m_Pos
Definition: ws_data_item.h:71
DPOINT m_IncrementVector
Definition: ws_data_item.h:119

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

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

◆ GetEndPosUi()

const wxPoint WS_DATA_ITEM::GetEndPosUi ( int  ii = 0) const
inherited

Definition at line 346 of file ws_data_item.cpp.

347 {
348  DPOINT pos = GetEndPos( ii );
350  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
351 }
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
const DPOINT GetEndPos(int ii=0) const
double m_WSunits2Iu
Definition: ws_data_model.h:51
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114

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

Referenced by WS_DATA_ITEM::MoveTo(), and WS_DATA_ITEM::SyncDrawItems().

◆ GetPage1Option()

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

Definition at line 153 of file ws_data_item.h.

153 { return m_pageOption; }
PAGE_OPTION m_pageOption
Definition: ws_data_item.h:106

References WS_DATA_ITEM::m_pageOption.

Referenced by PROPERTIES_FRAME::CopyPrmsFromItemToPanel(), WS_DATA_MODEL_IO::formatOptions(), WS_DRAW_ITEM_BASE::GetMsgPanelInfo(), and WS_DRAW_ITEM_BASE::ViewGetLayers().

◆ GetPenSizeUi()

int WS_DATA_ITEM_POLYGONS::GetPenSizeUi ( )
overridevirtual

Reimplemented from WS_DATA_ITEM.

Definition at line 453 of file ws_data_item.cpp.

454 {
455  return KiROUND( m_LineWidth * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
456 }
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
double m_LineWidth
Definition: ws_data_item.h:117
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114

References WS_DATA_MODEL::GetTheInstance(), KiROUND(), and WS_DATA_ITEM::m_LineWidth.

Referenced by SyncDrawItems().

◆ GetPolyCount()

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

Definition at line 254 of file ws_data_item.h.

254 { return (int) m_polyIndexEnd.size(); }
std::vector< unsigned > m_polyIndexEnd
Definition: ws_data_item.h:222

References m_polyIndexEnd.

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

◆ GetPolyIndexEnd()

unsigned WS_DATA_ITEM_POLYGONS::GetPolyIndexEnd ( unsigned  aContour) const
inline
Returns
the index of the last corner of the contour aCountour
Parameters
aContour= the index of the contour

Definition at line 272 of file ws_data_item.h.

273  {
274  return m_polyIndexEnd[aContour];
275  }
std::vector< unsigned > m_polyIndexEnd
Definition: ws_data_item.h:222

References m_polyIndexEnd.

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

◆ GetPolyIndexStart()

unsigned WS_DATA_ITEM_POLYGONS::GetPolyIndexStart ( unsigned  aContour) const
inline
Returns
the index of the first corner of the contour aCountour
Parameters
aContour= the index of the contour

Definition at line 260 of file ws_data_item.h.

261  {
262  if( aContour == 0 )
263  return 0;
264  else
265  return m_polyIndexEnd[aContour-1] + 1;
266  }
std::vector< unsigned > m_polyIndexEnd
Definition: ws_data_item.h:222

References m_polyIndexEnd.

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

◆ GetStartPos()

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

Definition at line 278 of file ws_data_item.cpp.

279 {
281  DPOINT pos( m_Pos.m_Pos.x + ( m_IncrementVector.x * ii ),
282  m_Pos.m_Pos.y + ( m_IncrementVector.y * ii ) );
283 
284  switch( m_Pos.m_Anchor )
285  {
286  case RB_CORNER: // right bottom corner
287  pos = model.m_RB_Corner - pos;
288  break;
289 
290  case RT_CORNER: // right top corner
291  pos.x = model.m_RB_Corner.x - pos.x;
292  pos.y = model.m_LT_Corner.y + pos.y;
293  break;
294 
295  case LB_CORNER: // left bottom corner
296  pos.x = model.m_LT_Corner.x + pos.x;
297  pos.y = model.m_RB_Corner.y - pos.y;
298  break;
299 
300  case LT_CORNER: // left top corner
301  pos = model.m_LT_Corner + pos;
302  break;
303  }
304 
305  return pos;
306 }
WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block.
Definition: ws_data_model.h:39
DPOINT m_RB_Corner
Definition: ws_data_model.h:53
DPOINT m_LT_Corner
Definition: ws_data_model.h:54
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
DPOINT m_Pos
Definition: ws_data_item.h:71
DPOINT m_IncrementVector
Definition: ws_data_item.h:119
POINT_COORD m_Pos
Definition: ws_data_item.h:115

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

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

◆ GetStartPosUi()

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

Definition at line 309 of file ws_data_item.cpp.

310 {
312  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
313 }
const DPOINT GetStartPos(int ii=0) const
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
double m_WSunits2Iu
Definition: ws_data_model.h:51
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114

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

Referenced by PL_EDIT_TOOL::moveItem(), WS_DATA_ITEM::MoveTo(), PL_DRAWING_TOOLS::PlaceItem(), WS_DATA_ITEM::SyncDrawItems(), SyncDrawItems(), WS_DATA_ITEM_TEXT::SyncDrawItems(), and WS_DATA_ITEM_BITMAP::SyncDrawItems().

◆ GetType()

◆ IsInsidePage()

bool WS_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 WS_DATA_ITEM.

Definition at line 504 of file ws_data_item.cpp.

505 {
507 
508  DPOINT pos = GetStartPos( ii );
509  pos += m_minCoord; // left top pos of bounding box
510 
511  if( model.m_LT_Corner.x > pos.x || model.m_LT_Corner.y > pos.y )
512  return false;
513 
514  pos = GetStartPos( ii );
515  pos += m_maxCoord; // rignt bottom pos of bounding box
516 
517  if( model.m_RB_Corner.x < pos.x || model.m_RB_Corner.y < pos.y )
518  return false;
519 
520  return true;
521 }
WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block.
Definition: ws_data_model.h:39
DPOINT m_RB_Corner
Definition: ws_data_model.h:53
const DPOINT GetStartPos(int ii=0) const
DPOINT m_LT_Corner
Definition: ws_data_model.h:54
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application

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

Referenced by SyncDrawItems().

◆ MoveEndPointTo()

void WS_DATA_ITEM::MoveEndPointTo ( DPOINT  aPosition)
inherited

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

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

Parameters
aPosition= the new position of the ending point, in mm

Definition at line 220 of file ws_data_item.cpp.

221 {
223  DPOINT position;
224 
225  // Calculate the position of the starting point
226  // relative to the reference corner
227  // aPosition is the position relative to the right top paper corner
228  switch( m_End.m_Anchor )
229  {
230  case RB_CORNER:
231  position = model.m_RB_Corner - aPosition;
232  break;
233 
234  case RT_CORNER:
235  position.x = model.m_RB_Corner.x - aPosition.x;
236  position.y = aPosition.y - model.m_LT_Corner.y;
237  break;
238 
239  case LB_CORNER:
240  position.x = aPosition.x - model.m_LT_Corner.x;
241  position.y = model.m_RB_Corner.y - aPosition.y;
242  break;
243 
244  case LT_CORNER:
245  position = aPosition - model.m_LT_Corner;
246  break;
247  }
248 
249  // Modify m_End only for items having 2 coordinates
250  switch( GetType() )
251  {
252  case WS_SEGMENT:
253  case WS_RECT:
254  m_End.m_Pos = position;
255  break;
256 
257  default:
258  break;
259  }
260 }
WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block.
Definition: ws_data_model.h:39
DPOINT m_RB_Corner
Definition: ws_data_model.h:53
POINT_COORD m_End
Definition: ws_data_item.h:116
DPOINT m_LT_Corner
Definition: ws_data_model.h:54
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
DPOINT m_Pos
Definition: ws_data_item.h:71
WS_ITEM_TYPE GetType() const
Definition: ws_data_item.h:147

References WS_DATA_MODEL::GetTheInstance(), WS_DATA_ITEM::GetType(), LB_CORNER, LT_CORNER, POINT_COORD::m_Anchor, WS_DATA_ITEM::m_End, WS_DATA_MODEL::m_LT_Corner, POINT_COORD::m_Pos, WS_DATA_MODEL::m_RB_Corner, RB_CORNER, RT_CORNER, WS_DATA_ITEM::WS_RECT, WS_DATA_ITEM::WS_SEGMENT, VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ MoveEndPointToUi()

void WS_DATA_ITEM::MoveEndPointToUi ( wxPoint  aPosition)
inherited

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

Parameters
aPosition= the new position of the ending point in graphic units

Definition at line 268 of file ws_data_item.cpp.

269 {
270  DPOINT pos_mm;
271  pos_mm.x = aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
272  pos_mm.y = aPosition.y / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
273 
274  MoveEndPointTo( pos_mm );
275 }
void MoveEndPointTo(DPOINT aPosition)
move the ending point of the item to a new position has meaning only for items defined by 2 points (s...
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
double m_WSunits2Iu
Definition: ws_data_model.h:51

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

◆ MoveStartPointTo()

void WS_DATA_ITEM::MoveStartPointTo ( DPOINT  aPosition)
inherited

move the starting point of the item to a new position

Parameters
aPosition= the new position of the starting point, in mm

Definition at line 169 of file ws_data_item.cpp.

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

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

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

◆ MoveStartPointToUi()

void WS_DATA_ITEM::MoveStartPointToUi ( wxPoint  aPosition)
inherited

move the starting point of the item to a new position

Parameters
aPosition= the new position of item in graphic units

Definition at line 205 of file ws_data_item.cpp.

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

References WS_DATA_MODEL::GetTheInstance(), WS_DATA_MODEL::m_WSunits2Iu, and WS_DATA_ITEM::MoveStartPointTo().

Referenced by PL_DRAWING_TOOLS::PlaceItem().

◆ MoveTo()

void WS_DATA_ITEM::MoveTo ( DPOINT  aPosition)
inherited

move item to a new position

Parameters
aPosition= the new position of item, in mm

Definition at line 150 of file ws_data_item.cpp.

151 {
152  DPOINT vector = aPosition - GetStartPos();
153  DPOINT endpos = vector + GetEndPos();
154 
155  MoveStartPointTo( aPosition );
156  MoveEndPointTo( endpos );
157 
158  for( WS_DRAW_ITEM_BASE* drawItem : m_drawItems )
159  {
160  drawItem->SetPosition( GetStartPosUi( drawItem->GetIndexInPeer() ) );
161  drawItem->SetEnd( GetEndPosUi( drawItem->GetIndexInPeer() ) );
162  }
163 }
const DPOINT GetStartPos(int ii=0) const
void MoveEndPointTo(DPOINT aPosition)
move the ending point of the item to a new position has meaning only for items defined by 2 points (s...
void MoveStartPointTo(DPOINT aPosition)
move the starting point of the item to a new position
const wxPoint GetStartPosUi(int ii=0) const
const DPOINT GetEndPos(int ii=0) const
std::vector< WS_DRAW_ITEM_BASE * > m_drawItems
Definition: ws_data_item.h:108
const wxPoint GetEndPosUi(int ii=0) const

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

Referenced by WS_DATA_ITEM::MoveToUi().

◆ MoveToUi()

void WS_DATA_ITEM::MoveToUi ( wxPoint  aPosition)
inherited

move item to a new position

Parameters
aPosition= the new position of the starting point in graphic units

Definition at line 140 of file ws_data_item.cpp.

141 {
142  DPOINT pos_mm;
143  pos_mm.x = aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
144  pos_mm.y = aPosition.y / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
145 
146  MoveTo( pos_mm );
147 }
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
double m_WSunits2Iu
Definition: ws_data_model.h:51
void MoveTo(DPOINT aPosition)
move item to a new position

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

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

◆ SetBoundingBox()

void WS_DATA_ITEM_POLYGONS::SetBoundingBox ( )

calculate the bounding box of the set polygons

Definition at line 470 of file ws_data_item.cpp.

471 {
472  if( m_Corners.size() == 0 )
473  {
474  m_minCoord.x = m_maxCoord.x = 0.0;
475  m_minCoord.y = m_maxCoord.y = 0.0;
476  return;
477  }
478 
479  DPOINT pos;
480  pos = m_Corners[0];
481  RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
482  m_minCoord = m_maxCoord = pos;
483 
484  for( unsigned ii = 1; ii < m_Corners.size(); ii++ )
485  {
486  pos = m_Corners[ii];
487  RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
488 
489  if( m_minCoord.x > pos.x )
490  m_minCoord.x = pos.x;
491 
492  if( m_minCoord.y > pos.y )
493  m_minCoord.y = pos.y;
494 
495  if( m_maxCoord.x < pos.x )
496  m_maxCoord.x = pos.x;
497 
498  if( m_maxCoord.y < pos.y )
499  m_maxCoord.y = pos.y;
500  }
501 }
std::vector< DPOINT > m_Corners
Definition: ws_data_item.h:219
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:206

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

Referenced by PAGE_LAYOUT_READER_PARSER::parsePolygon().

◆ SetEnd()

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

Definition at line 139 of file ws_data_item.h.

140  {
141  m_End.m_Pos.x = aPosx;
142  m_End.m_Pos.y = aPosy;
143  m_End.m_Anchor = aAnchor;
144  }
POINT_COORD m_End
Definition: ws_data_item.h:116
DPOINT m_Pos
Definition: ws_data_item.h:71

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

◆ SetPage1Option()

void WS_DATA_ITEM::SetPage1Option ( PAGE_OPTION  aChoice)
inlineinherited

Definition at line 154 of file ws_data_item.h.

154 { m_pageOption = aChoice; }
PAGE_OPTION m_pageOption
Definition: ws_data_item.h:106

References WS_DATA_ITEM::m_pageOption.

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

◆ SetStart()

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

Definition at line 132 of file ws_data_item.h.

133  {
134  m_Pos.m_Pos.x = aPosx;
135  m_Pos.m_Pos.y = aPosy;
136  m_Pos.m_Anchor = aAnchor;
137  }
DPOINT m_Pos
Definition: ws_data_item.h:71
POINT_COORD m_Pos
Definition: ws_data_item.h:115

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

◆ SyncDrawItems()

void WS_DATA_ITEM_POLYGONS::SyncDrawItems ( WS_DRAW_ITEM_LIST aCollector,
KIGFX::VIEW aView 
)
overridevirtual

Reimplemented from WS_DATA_ITEM.

Definition at line 399 of file ws_data_item.cpp.

400 {
401  std::map<int, STATUS_FLAGS> itemFlags;
402  WS_DRAW_ITEM_BASE* item = nullptr;
403 
404  for( size_t i = 0; i < m_drawItems.size(); ++i )
405  {
406  item = m_drawItems[ i ];
407  itemFlags[ i ] = item->GetFlags();
408 
409  if( aCollector )
410  aCollector->Remove( item );
411 
412  if( aView )
413  aView->Remove( item );
414 
415  delete item;
416  }
417 
418  m_drawItems.clear();
419 
420  for( int j = 0; j < m_RepeatCount; j++ )
421  {
422  if( j && !IsInsidePage( j ) )
423  continue;
424 
425  int pensize = GetPenSizeUi();
426  auto poly_shape = new WS_DRAW_ITEM_POLYPOLYGONS( this, j, GetStartPosUi( j ), pensize );
427  poly_shape->SetFlags( itemFlags[ j ] );
428  m_drawItems.push_back( poly_shape );
429 
430  // Transfer all outlines (basic polygons)
431  SHAPE_POLY_SET& polygons = poly_shape->GetPolygons();
432  for( int kk = 0; kk < GetPolyCount(); kk++ )
433  {
434  // Create new outline
435  unsigned ist = GetPolyIndexStart( kk );
436  unsigned iend = GetPolyIndexEnd( kk );
437 
438  polygons.NewOutline();
439 
440  while( ist <= iend )
441  polygons.Append( GetCornerPositionUi( ist++, j ) );
442  }
443 
444  if( aCollector )
445  aCollector->Append( poly_shape );
446 
447  if( aView )
448  aView->Add( poly_shape );
449  }
450 }
void Remove(WS_DRAW_ITEM_BASE *aItem)
Definition: ws_draw_item.h:460
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
bool IsInsidePage(int ii) const override
const wxPoint GetCornerPositionUi(unsigned aIdx, int aRepeat=0) const
unsigned GetPolyIndexStart(unsigned aContour) const
Definition: ws_data_item.h:260
unsigned GetPolyIndexEnd(unsigned aContour) const
Definition: ws_data_item.h:272
void Append(WS_DRAW_ITEM_BASE *aItem)
Definition: ws_draw_item.h:455
const wxPoint GetStartPosUi(int ii=0) const
Class SHAPE_POLY_SET.
std::vector< WS_DRAW_ITEM_BASE * > m_drawItems
Definition: ws_data_item.h:108
int NewOutline()
Creates a new empty polygon in the set and returns its index
int GetPolyCount() const
Definition: ws_data_item.h:254
size_t i
Definition: json11.cpp:649
virtual int GetPenSizeUi() override
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:267
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

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

Member Data Documentation

◆ m_Corners

std::vector<DPOINT> WS_DATA_ITEM_POLYGONS::m_Corners

◆ m_drawItems

◆ m_End

◆ m_IncrementLabel

◆ m_IncrementVector

◆ m_Info

◆ m_LineWidth

◆ m_maxCoord

DPOINT WS_DATA_ITEM_POLYGONS::m_maxCoord
private

Definition at line 224 of file ws_data_item.h.

Referenced by IsInsidePage(), and SetBoundingBox().

◆ m_minCoord

DPOINT WS_DATA_ITEM_POLYGONS::m_minCoord
private

Definition at line 223 of file ws_data_item.h.

Referenced by IsInsidePage(), and SetBoundingBox().

◆ m_Name

◆ m_Orient

◆ m_pageOption

PAGE_OPTION WS_DATA_ITEM::m_pageOption
protectedinherited

◆ m_polyIndexEnd

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

Definition at line 222 of file ws_data_item.h.

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

◆ m_Pos

◆ m_RepeatCount

◆ m_type

WS_ITEM_TYPE WS_DATA_ITEM::m_type
protectedinherited

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