KiCad PCB EDA Suite
WS_DATA_ITEM Class Reference

Work sheet structure type definitions. More...

#include <ws_data_item.h>

Inheritance diagram for WS_DATA_ITEM:
WS_DATA_ITEM_BITMAP WS_DATA_ITEM_POLYGONS WS_DATA_ITEM_TEXT

Public Types

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

Public Member Functions

 WS_DATA_ITEM (WS_ITEM_TYPE aType)
 
virtual ~WS_DATA_ITEM ()
 
const std::vector< WS_DRAW_ITEM_BASE * > & GetDrawItems () const
 
virtual void SyncDrawItems (WS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView)
 
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
 
virtual int GetPenSizeUi ()
 
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...
 
virtual bool IsInsidePage (int ii) const
 
const wxString GetClassName () const
 

Public Attributes

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
 

Detailed Description

Work sheet structure type definitions.

Basic items are:

  • segment and rect (defined by 2 points)
  • text (defined by a coordinate), the text and its justifications
  • poly polygon defined by a coordinate, and a set of list of corners ( because we use it for logos, there are more than one polygon in this description

Definition at line 93 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()

WS_DATA_ITEM::WS_DATA_ITEM ( WS_ITEM_TYPE  aType)

Definition at line 66 of file ws_data_item.cpp.

67 {
69  m_type = aType;
70  m_RepeatCount = 1;
71  m_IncrementLabel = 1;
72  m_LineWidth = 0;
73 }
WS_ITEM_TYPE m_type
Definition: ws_data_item.h:105
double m_LineWidth
Definition: ws_data_item.h:117
int m_IncrementLabel
Definition: ws_data_item.h:121
PAGE_OPTION m_pageOption
Definition: ws_data_item.h:106

References ALL_PAGES, m_IncrementLabel, m_LineWidth, m_pageOption, m_RepeatCount, and m_type.

◆ ~WS_DATA_ITEM()

WS_DATA_ITEM::~WS_DATA_ITEM ( )
virtual

Definition at line 76 of file ws_data_item.cpp.

77 {
78  for( WS_DRAW_ITEM_BASE* item : m_drawItems )
79  delete item;
80 }
std::vector< WS_DRAW_ITEM_BASE * > m_drawItems
Definition: ws_data_item.h:108

References m_drawItems.

Member Function Documentation

◆ GetClassName()

const wxString WS_DATA_ITEM::GetClassName ( ) const

Definition at line 388 of file ws_data_item.cpp.

389 {
390  wxString name;
391 
392  switch( GetType() )
393  {
394  case WS_TEXT: name = wxT( "Text" ); break;
395  case WS_SEGMENT: name = wxT( "Line" ); break;
396  case WS_RECT: name = wxT( "Rectangle" ); break;
397  case WS_POLYPOLYGON: name = wxT( "Imported Shape" ); break;
398  case WS_BITMAP: name = wxT( "Image" ); break;
399  }
400 
401  return name;
402 }
WS_ITEM_TYPE GetType() const
Definition: ws_data_item.h:147
const char * name
Definition: DXF_plotter.cpp:60

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

Referenced by PROPERTIES_FRAME::CopyPrmsFromItemToPanel().

◆ GetDrawItems()

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

◆ GetEndPos()

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

Definition at line 329 of file ws_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 = WS_DATA_MODEL::GetTheInstance().m_RB_Corner.x - pos.x;
342  pos.y = WS_DATA_MODEL::GetTheInstance().m_LT_Corner.y + pos.y;
343  break;
344 
345  case LB_CORNER: // left bottom corner
346  pos.x = WS_DATA_MODEL::GetTheInstance().m_LT_Corner.x + pos.x;
347  pos.y = WS_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 }
DPOINT m_RB_Corner
Definition: ws_data_model.h:53
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
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, m_End, 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 GetEndPosUi(), IsInsidePage(), and MoveTo().

◆ GetEndPosUi()

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

Definition at line 359 of file ws_data_item.cpp.

360 {
361  DPOINT pos = GetEndPos( ii );
363  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
364 }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
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: util.h:68

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

Referenced by MoveTo(), and SyncDrawItems().

◆ GetPage1Option()

PAGE_OPTION WS_DATA_ITEM::GetPage1Option ( ) const
inline
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 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::GetPenSizeUi ( )
virtual

Reimplemented in WS_DATA_ITEM_TEXT, and WS_DATA_ITEM_POLYGONS.

Definition at line 136 of file ws_data_item.cpp.

137 {
139 
140  if( m_LineWidth != 0 )
141  return KiROUND( m_LineWidth * model.m_WSunits2Iu );
142  else
143  return KiROUND( model.m_DefaultLineWidth * model.m_WSunits2Iu );
144 }
WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block.
Definition: ws_data_model.h:39
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
double m_DefaultLineWidth
Definition: ws_data_model.h:55
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: util.h:68

References WS_DATA_MODEL::GetTheInstance(), KiROUND(), WS_DATA_MODEL::m_DefaultLineWidth, m_LineWidth, and WS_DATA_MODEL::m_WSunits2Iu.

Referenced by SyncDrawItems().

◆ GetStartPos()

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

Definition at line 291 of file ws_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 }
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
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
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, m_IncrementVector, WS_DATA_MODEL::m_LT_Corner, POINT_COORD::m_Pos, m_Pos, WS_DATA_MODEL::m_RB_Corner, RB_CORNER, RT_CORNER, VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ GetStartPosUi()

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

Definition at line 322 of file ws_data_item.cpp.

323 {
325  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
326 }
const DPOINT GetStartPos(int ii=0) const
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
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: util.h:68

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

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

◆ GetType()

◆ IsInsidePage()

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

Reimplemented in WS_DATA_ITEM_POLYGONS.

Definition at line 367 of file ws_data_item.cpp.

368 {
370 
371  DPOINT pos = GetStartPos( ii );
372 
373  for( int kk = 0; kk < 1; kk++ )
374  {
375  if( model.m_RB_Corner.x < pos.x || model.m_LT_Corner.x > pos.x )
376  return false;
377 
378  if( model.m_RB_Corner.y < pos.y || model.m_LT_Corner.y > pos.y )
379  return false;
380 
381  pos = GetEndPos( ii );
382  }
383 
384  return true;
385 }
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
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
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
const DPOINT GetEndPos(int ii=0) const

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

Referenced by SyncDrawItems(), WS_DATA_ITEM_TEXT::SyncDrawItems(), and WS_DATA_ITEM_BITMAP::SyncDrawItems().

◆ MoveEndPointTo()

void WS_DATA_ITEM::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)

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 233 of file ws_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 WS_SEGMENT:
266  case WS_RECT:
267  m_End.m_Pos = position;
268  break;
269 
270  default:
271  break;
272  }
273 }
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
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
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(), GetType(), LB_CORNER, LT_CORNER, POINT_COORD::m_Anchor, m_End, WS_DATA_MODEL::m_LT_Corner, POINT_COORD::m_Pos, WS_DATA_MODEL::m_RB_Corner, RB_CORNER, RT_CORNER, WS_RECT, WS_SEGMENT, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by MoveEndPointToUi(), and MoveTo().

◆ MoveEndPointToUi()

void WS_DATA_ITEM::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)

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

Definition at line 281 of file ws_data_item.cpp.

282 {
283  DPOINT pos_mm;
284  pos_mm.x = aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
285  pos_mm.y = aPosition.y / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
286 
287  MoveEndPointTo( pos_mm );
288 }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
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, MoveEndPointTo(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

◆ MoveStartPointTo()

void WS_DATA_ITEM::MoveStartPointTo ( DPOINT  aPosition)

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 182 of file ws_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 }
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
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
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, m_Pos, WS_DATA_MODEL::m_RB_Corner, RB_CORNER, RT_CORNER, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by MoveStartPointToUi(), and MoveTo().

◆ MoveStartPointToUi()

void WS_DATA_ITEM::MoveStartPointToUi ( wxPoint  aPosition)

move the starting point of the item to a new position

Parameters
aPosition= the new position of item in graphic units

Definition at line 218 of file ws_data_item.cpp.

219 {
220  DPOINT pos_mm( aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu,
222 
223  MoveStartPointTo( pos_mm );
224 }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
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, MoveStartPointTo(), wxPoint::x, and wxPoint::y.

Referenced by PL_DRAWING_TOOLS::PlaceItem().

◆ MoveTo()

void WS_DATA_ITEM::MoveTo ( DPOINT  aPosition)

move item to a new position

Parameters
aPosition= the new position of item, in mm

Definition at line 163 of file ws_data_item.cpp.

164 {
165  DPOINT vector = aPosition - GetStartPos();
166  DPOINT endpos = vector + GetEndPos();
167 
168  MoveStartPointTo( aPosition );
169  MoveEndPointTo( endpos );
170 
171  for( WS_DRAW_ITEM_BASE* drawItem : m_drawItems )
172  {
173  drawItem->SetPosition( GetStartPosUi( drawItem->GetIndexInPeer() ) );
174  drawItem->SetEnd( GetEndPosUi( drawItem->GetIndexInPeer() ) );
175  }
176 }
const DPOINT GetStartPos(int ii=0) const
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
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 GetEndPos(), GetEndPosUi(), GetStartPos(), GetStartPosUi(), m_drawItems, MoveEndPointTo(), and MoveStartPointTo().

Referenced by MoveToUi().

◆ MoveToUi()

void WS_DATA_ITEM::MoveToUi ( wxPoint  aPosition)

move item to a new position

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

Definition at line 153 of file ws_data_item.cpp.

154 {
155  DPOINT pos_mm;
156  pos_mm.x = aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
157  pos_mm.y = aPosition.y / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
158 
159  MoveTo( pos_mm );
160 }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
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, MoveTo(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

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

◆ SetEnd()

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

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, m_End, POINT_COORD::m_Pos, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ SetPage1Option()

void WS_DATA_ITEM::SetPage1Option ( PAGE_OPTION  aChoice)
inline

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

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, m_Pos, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ SyncDrawItems()

void WS_DATA_ITEM::SyncDrawItems ( WS_DRAW_ITEM_LIST aCollector,
KIGFX::VIEW aView 
)
virtual

Reimplemented in WS_DATA_ITEM_BITMAP, WS_DATA_ITEM_TEXT, and WS_DATA_ITEM_POLYGONS.

Definition at line 83 of file ws_data_item.cpp.

84 {
85  int pensize = GetPenSizeUi();
86 
87  if( pensize == 0 )
88  pensize = aCollector ? aCollector->GetDefaultPenSize() : 0;
89 
90  std::map<int, STATUS_FLAGS> itemFlags;
91  WS_DRAW_ITEM_BASE* item = nullptr;
92 
93  for( size_t i = 0; i < m_drawItems.size(); ++i )
94  {
95  item = m_drawItems[ i ];
96  itemFlags[ i ] = item->GetFlags();
97 
98  if( aCollector )
99  aCollector->Remove( item );
100 
101  if( aView )
102  aView->Remove( item );
103 
104  delete item;
105  }
106 
107  m_drawItems.clear();
108 
109  for( int j = 0; j < m_RepeatCount; j++ )
110  {
111  if( j && ! IsInsidePage( j ) )
112  continue;
113 
114  if( m_type == WS_SEGMENT )
115  item = new WS_DRAW_ITEM_LINE( this, j, GetStartPosUi( j ), GetEndPosUi( j ), pensize );
116  else if( m_type == WS_RECT )
117  item = new WS_DRAW_ITEM_RECT( this, j, GetStartPosUi( j ), GetEndPosUi( j ), pensize );
118  else
119  {
120  wxFAIL_MSG( "Unknown worksheet draw item type" );
121  continue;
122  }
123 
124  item->SetFlags( itemFlags[ j ] );
125  m_drawItems.push_back( item );
126 
127  if( aCollector )
128  aCollector->Append( item );
129 
130  if( aView )
131  aView->Add( item );
132  }
133 }
void Remove(WS_DRAW_ITEM_BASE *aItem)
Definition: ws_draw_item.h:464
virtual bool IsInsidePage(int ii) const
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:375
void Append(WS_DRAW_ITEM_BASE *aItem)
Definition: ws_draw_item.h:459
virtual int GetPenSizeUi()
const wxPoint GetStartPosUi(int ii=0) const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
WS_ITEM_TYPE m_type
Definition: ws_data_item.h:105
std::vector< WS_DRAW_ITEM_BASE * > m_drawItems
Definition: ws_data_item.h:108
const wxPoint GetEndPosUi(int ii=0) const
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:345
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:234
int GetDefaultPenSize() const
Definition: ws_draw_item.h:430

References KIGFX::VIEW::Add(), WS_DRAW_ITEM_LIST::Append(), WS_DRAW_ITEM_LIST::GetDefaultPenSize(), GetEndPosUi(), EDA_ITEM::GetFlags(), GetPenSizeUi(), GetStartPosUi(), IsInsidePage(), m_drawItems, m_RepeatCount, m_type, KIGFX::VIEW::Remove(), WS_DRAW_ITEM_LIST::Remove(), EDA_ITEM::SetFlags(), WS_RECT, and WS_SEGMENT.

Referenced by PL_EDITOR_FRAME::AddPageLayoutItem(), and WS_PROXY_UNDO_ITEM::Restore().

Member Data Documentation

◆ m_drawItems

◆ m_End

◆ m_IncrementLabel

◆ m_IncrementVector

◆ m_Info

◆ m_LineWidth

◆ m_Name

◆ m_pageOption

PAGE_OPTION WS_DATA_ITEM::m_pageOption
protected

Definition at line 106 of file ws_data_item.h.

Referenced by GetPage1Option(), SetPage1Option(), and WS_DATA_ITEM().

◆ m_Pos

◆ m_RepeatCount

◆ m_type

WS_ITEM_TYPE WS_DATA_ITEM::m_type
protected

Definition at line 105 of file ws_data_item.h.

Referenced by GetType(), SyncDrawItems(), and WS_DATA_ITEM().


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