KiCad PCB EDA Suite
WORKSHEET_DATAITEM Class Reference

#include <class_worksheet_dataitem.h>

Inheritance diagram for WORKSHEET_DATAITEM:
WORKSHEET_DATAITEM_BITMAP WORKSHEET_DATAITEM_POLYPOLYGON WORKSHEET_DATAITEM_TEXT

Public Types

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

Public Member Functions

 WORKSHEET_DATAITEM (WS_ItemType aType)
 
virtual ~WORKSHEET_DATAITEM ()
 
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_ItemType GetType () const
 
int GetFlags () const
 
void SetFlags (int aMask)
 
void ClearFlags (int aMask)
 
virtual bool HasEndPoint ()
 
int GetPage1Option ()
 
void SetPage1Option (int aChoice)
 Set the option for page 1. More...
 
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
 
bool IsSelected ()
 
void SetSelected (bool aState)
 Function SetSelected Toggles on/off the selected flag (used in edition functions. More...
 
bool UseAltColor ()
 
COLOR4D GetItemColor ()
 

Static Public Member Functions

static int GetMarkerSizeUi ()
 

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
 

Static Public Attributes

static double m_WSunits2Iu = 1.0
 
static DPOINT m_RB_Corner
 
static DPOINT m_LT_Corner
 
static double m_DefaultLineWidth = 0.0
 
static DSIZE m_DefaultTextSize
 
static double m_DefaultTextThickness = 0.0
 
static bool m_SpecialMode = false
 
static COLOR4D m_Color = COLOR4D( RED )
 
static COLOR4D m_AltColor = COLOR4D( RED )
 
static COLOR4D m_SelectedColor = COLOR4D( BROWN )
 

Protected Attributes

WS_ItemType m_type
 
int m_flags
 

Detailed Description

Definition at line 96 of file class_worksheet_dataitem.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

WORKSHEET_DATAITEM::WORKSHEET_DATAITEM ( WS_ItemType  aType)
virtual WORKSHEET_DATAITEM::~WORKSHEET_DATAITEM ( )
inlinevirtual

Definition at line 152 of file class_worksheet_dataitem.h.

152 {}

Member Function Documentation

void WORKSHEET_DATAITEM::ClearFlags ( int  aMask)
inline
const wxString WORKSHEET_DATAITEM::GetClassName ( ) const

Definition at line 326 of file class_worksheet_dataitem.cpp.

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

Referenced by PROPERTIES_FRAME::CopyPrmsFromItemToPanel(), and PL_EDITOR_FRAME::RebuildDesignTree().

327 {
328  wxString name;
329 
330  switch( GetType() )
331  {
332  case WS_TEXT: name = wxT( "Text" ); break;
333  case WS_SEGMENT: name = wxT( "Line" ); break;
334  case WS_RECT: name = wxT( "Rect" ); break;
335  case WS_POLYPOLYGON: name = wxT( "Poly" ); break;
336  case WS_BITMAP: name = wxT( "Bitmap" ); break;
337  }
338 
339  return name;
340 }
WS_ItemType GetType() const
const char * name
const DPOINT WORKSHEET_DATAITEM::GetEndPos ( int  ii = 0) const

Definition at line 268 of file class_worksheet_dataitem.cpp.

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

Referenced by GetEndPosUi(), IsInsidePage(), PL_EDITOR_FRAME::MoveItem(), MoveTo(), and PL_EDITOR_FRAME::PlaceItem().

269 {
270  DPOINT pos;
271  pos.x = m_End.m_Pos.x + ( m_IncrementVector.x * ii );
272  pos.y = m_End.m_Pos.y + ( m_IncrementVector.y * ii );
273 
274  switch( m_End.m_Anchor )
275  {
276  case RB_CORNER: // right bottom corner
277  pos = m_RB_Corner - pos;
278  break;
279 
280  case RT_CORNER: // right top corner
281  pos.x = m_RB_Corner.x - pos.x;
282  pos.y = m_LT_Corner.y + pos.y;
283  break;
284 
285  case LB_CORNER: // left bottom corner
286  pos.x = m_LT_Corner.x + pos.x;
287  pos.y = m_RB_Corner.y - pos.y;
288  break;
289 
290  case LT_CORNER: // left top corner
291  pos = m_LT_Corner + pos;
292  break;
293  }
294 
295  return pos;
296 }
const wxPoint WORKSHEET_DATAITEM::GetEndPosUi ( int  ii = 0) const

Definition at line 299 of file class_worksheet_dataitem.cpp.

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

Referenced by WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), moveItem(), and PL_EDITOR_FRAME::MoveItem().

300 {
301  DPOINT pos = GetEndPos( ii );
302  pos = pos * m_WSunits2Iu;
303  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
304 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
const DPOINT GetEndPos(int ii=0) const
int WORKSHEET_DATAITEM::GetFlags ( ) const
inline
COLOR4D WORKSHEET_DATAITEM::GetItemColor ( )
inline

Definition at line 282 of file class_worksheet_dataitem.h.

References IsSelected(), m_AltColor, m_Color, m_SelectedColor, and UseAltColor().

Referenced by WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList().

283  {
284  if( IsSelected() )
285  return m_SelectedColor;
286 
287  if( UseAltColor() )
288  return m_AltColor;
289 
290  return m_Color;
291  }
static int WORKSHEET_DATAITEM::GetMarkerSizeUi ( )
inlinestatic

Definition at line 208 of file class_worksheet_dataitem.h.

References KiROUND().

Referenced by WS_DRAW_ITEM_LIST::Draw(), WS_DRAW_ITEM_LINE::HitTestEndPoint(), WS_DRAW_ITEM_RECT::HitTestEndPoint(), WS_DRAW_ITEM_LINE::HitTestStartPoint(), WS_DRAW_ITEM_POLYGON::HitTestStartPoint(), WS_DRAW_ITEM_RECT::HitTestStartPoint(), WS_DRAW_ITEM_TEXT::HitTestStartPoint(), and WS_DRAW_ITEM_BITMAP::HitTestStartPoint().

209  {
210  return KiROUND( 0.5 * m_WSunits2Iu );
211  }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
int WORKSHEET_DATAITEM::GetPage1Option ( )
Returns
0 if the item has no specific option for page 1 1 if the item is only on page 1 -1 if the item is not on page 1

Definition at line 347 of file class_worksheet_dataitem.cpp.

References m_flags, PAGE1OPTION, PAGE1OPTION_NOTONPAGE1, and PAGE1OPTION_PAGE1ONLY.

Referenced by WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), and PROPERTIES_FRAME::CopyPrmsFromItemToPanel().

348 {
350  return -1;
351 
352  if(( m_flags & PAGE1OPTION) == PAGE1OPTION_PAGE1ONLY )
353  return 1;
354 
355  return 0;
356 }
#define PAGE1OPTION_NOTONPAGE1
#define PAGE1OPTION_PAGE1ONLY
#define PAGE1OPTION
virtual int WORKSHEET_DATAITEM::GetPenSizeUi ( )
inlinevirtual

Reimplemented in WORKSHEET_DATAITEM_TEXT, and WORKSHEET_DATAITEM_POLYPOLYGON.

Definition at line 200 of file class_worksheet_dataitem.h.

References KiROUND().

Referenced by WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList().

201  {
202  if( m_LineWidth )
203  return KiROUND( m_LineWidth * m_WSunits2Iu );
204  else
206  }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
const DPOINT WORKSHEET_DATAITEM::GetStartPos ( int  ii = 0) const

Definition at line 229 of file class_worksheet_dataitem.cpp.

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

Referenced by WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPosition(), GetStartPosUi(), IsInsidePage(), WORKSHEET_DATAITEM_POLYPOLYGON::IsInsidePage(), PL_EDITOR_FRAME::MoveItem(), MoveTo(), and PL_EDITOR_FRAME::PlaceItem().

230 {
231  DPOINT pos;
232  pos.x = m_Pos.m_Pos.x + ( m_IncrementVector.x * ii );
233  pos.y = m_Pos.m_Pos.y + ( m_IncrementVector.y * ii );
234 
235  switch( m_Pos.m_Anchor )
236  {
237  case RB_CORNER: // right bottom corner
238  pos = m_RB_Corner - pos;
239  break;
240 
241  case RT_CORNER: // right top corner
242  pos.x = m_RB_Corner.x - pos.x;
243  pos.y = m_LT_Corner.y + pos.y;
244  break;
245 
246  case LB_CORNER: // left bottom corner
247  pos.x = m_LT_Corner.x + pos.x;
248  pos.y = m_RB_Corner.y - pos.y;
249  break;
250 
251  case LT_CORNER: // left top corner
252  pos = m_LT_Corner + pos;
253  break;
254  }
255 
256  return pos;
257 }
const wxPoint WORKSHEET_DATAITEM::GetStartPosUi ( int  ii = 0) const

Definition at line 260 of file class_worksheet_dataitem.cpp.

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

Referenced by WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), EVT_MENU_RANGE(), moveItem(), PL_EDITOR_FRAME::MoveItem(), and PL_EDITOR_FRAME::UpdateStatusBar().

261 {
262  DPOINT pos = GetStartPos( ii );
263  pos = pos * m_WSunits2Iu;
264  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
265 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
const DPOINT GetStartPos(int ii=0) const
virtual bool WORKSHEET_DATAITEM::HasEndPoint ( )
inlinevirtual
Returns
true if the item has a end point (segment; rect) of false (text, polugon)

Reimplemented in WORKSHEET_DATAITEM_BITMAP, WORKSHEET_DATAITEM_TEXT, and WORKSHEET_DATAITEM_POLYPOLYGON.

Definition at line 178 of file class_worksheet_dataitem.h.

Referenced by PL_EDITOR_FRAME::OnHotKey().

178 { return true; }
bool WORKSHEET_DATAITEM::IsInsidePage ( int  ii) const
virtual
Returns
true if the item is inside the rectangle defined by the 4 corners, false otherwise.

Reimplemented in WORKSHEET_DATAITEM_POLYPOLYGON.

Definition at line 307 of file class_worksheet_dataitem.cpp.

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

Referenced by WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList().

308 {
309  DPOINT pos = GetStartPos( ii );
310 
311  for( int kk = 0; kk < 1; kk++ )
312  {
313  if( m_RB_Corner.x < pos.x || m_LT_Corner.x > pos.x )
314  return false;
315 
316  if( m_RB_Corner.y < pos.y || m_LT_Corner.y > pos.y )
317  return false;
318 
319  pos = GetEndPos( ii );
320  }
321 
322  return true;
323 }
const DPOINT GetStartPos(int ii=0) const
const DPOINT GetEndPos(int ii=0) const
bool WORKSHEET_DATAITEM::IsSelected ( )
inline
Returns
true if the selected state on ON

Definition at line 265 of file class_worksheet_dataitem.h.

References SELECTED_STATE.

Referenced by GetItemColor().

265 { return (m_flags & SELECTED_STATE) != 0; }
#define SELECTED_STATE
void WORKSHEET_DATAITEM::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 172 of file class_worksheet_dataitem.cpp.

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

Referenced by abortMoveItem(), MoveEndPointToUi(), MoveTo(), and PL_EDITOR_FRAME::PlaceItem().

173 {
174  DPOINT position;
175 
176  // Calculate the position of the starting point
177  // relative to the reference corner
178  // aPosition is the position relative to the right top paper corner
179  switch( m_End.m_Anchor )
180  {
181  case RB_CORNER:
182  position = m_RB_Corner - aPosition;
183  break;
184 
185  case RT_CORNER:
186  position.x = m_RB_Corner.x - aPosition.x;
187  position.y = aPosition.y - m_LT_Corner.y;
188  break;
189 
190  case LB_CORNER:
191  position.x = aPosition.x - m_LT_Corner.x;
192  position.y = m_RB_Corner.y - aPosition.y;
193  break;
194 
195  case LT_CORNER:
196  position = aPosition - m_LT_Corner;
197  break;
198  }
199 
200  // Modify m_End only for items having 2 coordinates
201  switch( GetType() )
202  {
203  case WS_SEGMENT:
204  case WS_RECT:
205  m_End.m_Pos = position;
206  break;
207 
208  default:
209  break;
210  }
211 }
WS_ItemType GetType() const
void WORKSHEET_DATAITEM::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 219 of file class_worksheet_dataitem.cpp.

References m_WSunits2Iu, MoveEndPointTo(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by moveItem().

220 {
221  DPOINT pos_mm;
222  pos_mm.x = aPosition.x / m_WSunits2Iu;
223  pos_mm.y = aPosition.y / m_WSunits2Iu;
224 
225  MoveEndPointTo( pos_mm );
226 }
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 WORKSHEET_DATAITEM::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 121 of file class_worksheet_dataitem.cpp.

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

Referenced by abortMoveItem(), MoveStartPointToUi(), MoveTo(), and PL_EDITOR_FRAME::PlaceItem().

122 {
123  DPOINT position;
124 
125  // Calculate the position of the starting point
126  // relative to the reference corner
127  // aPosition is the position relative to the right top paper corner
128  switch( m_Pos.m_Anchor )
129  {
130  case RB_CORNER:
131  position = m_RB_Corner - aPosition;
132  break;
133 
134  case RT_CORNER:
135  position.x = m_RB_Corner.x - aPosition.x;
136  position.y = aPosition.y - m_LT_Corner.y;
137  break;
138 
139  case LB_CORNER:
140  position.x = aPosition.x - m_LT_Corner.x;
141  position.y = m_RB_Corner.y - aPosition.y;
142  break;
143 
144  case LT_CORNER:
145  position = aPosition - m_LT_Corner;
146  break;
147  }
148 
149  m_Pos.m_Pos = position;
150 }
void WORKSHEET_DATAITEM::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 156 of file class_worksheet_dataitem.cpp.

References m_WSunits2Iu, MoveStartPointTo(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by moveItem().

157 {
158  DPOINT pos_mm;
159  pos_mm.x = aPosition.x / m_WSunits2Iu;
160  pos_mm.y = aPosition.y / m_WSunits2Iu;
161 
162  MoveStartPointTo( pos_mm );
163 }
void MoveStartPointTo(DPOINT aPosition)
move the starting point of the item to a new position
void WORKSHEET_DATAITEM::MoveTo ( DPOINT  aPosition)

move item to a new position

Parameters
aPosition= the new position of item, in mm

Definition at line 108 of file class_worksheet_dataitem.cpp.

References GetEndPos(), GetStartPos(), MoveEndPointTo(), and MoveStartPointTo().

Referenced by abortMoveItem(), MoveToUi(), and PL_EDITOR_FRAME::PlaceItem().

109 {
110  DPOINT vector = aPosition - GetStartPos();
111  DPOINT endpos = vector + GetEndPos();
112 
113  MoveStartPointTo( aPosition );
114  MoveEndPointTo( endpos );
115 }
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 DPOINT GetEndPos(int ii=0) const
void WORKSHEET_DATAITEM::MoveToUi ( wxPoint  aPosition)

move item to a new position

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

Definition at line 98 of file class_worksheet_dataitem.cpp.

References m_WSunits2Iu, MoveTo(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by moveItem().

99 {
100  DPOINT pos_mm;
101  pos_mm.x = aPosition.x / m_WSunits2Iu;
102  pos_mm.y = aPosition.y / m_WSunits2Iu;
103 
104  MoveTo( pos_mm );
105 }
void MoveTo(DPOINT aPosition)
move item to a new position
void WORKSHEET_DATAITEM::SetEnd ( double  aPosx,
double  aPosy,
enum corner_anchor  aAnchor = RB_CORNER 
)
inline

Definition at line 161 of file class_worksheet_dataitem.h.

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

162  {
163  m_End.m_Pos.x = aPosx;
164  m_End.m_Pos.y = aPosy;
165  m_End.m_Anchor = aAnchor;
166  }
void WORKSHEET_DATAITEM::SetFlags ( int  aMask)
inline
void WORKSHEET_DATAITEM::SetPage1Option ( int  aChoice)

Set the option for page 1.

Parameters
aChoice= 0 if the item has no specific option for page 1

0 if the item is only on page 1

< 0 if the item is not on page 1

Definition at line 364 of file class_worksheet_dataitem.cpp.

References ClearFlags(), PAGE1OPTION, PAGE1OPTION_NOTONPAGE1, PAGE1OPTION_PAGE1ONLY, and SetFlags().

Referenced by PROPERTIES_FRAME::CopyPrmsFromPanelToItem().

365 {
367 
368  if( aChoice > 0 )
370 
371  else if( aChoice < 0 )
373 
374 }
#define PAGE1OPTION_NOTONPAGE1
#define PAGE1OPTION_PAGE1ONLY
#define PAGE1OPTION
void WORKSHEET_DATAITEM::SetSelected ( bool  aState)
inline

Function SetSelected Toggles on/off the selected flag (used in edition functions.

Parameters
aState= the flag value

Definition at line 272 of file class_worksheet_dataitem.h.

References SELECTED_STATE.

Referenced by PL_EDITOR_FRAME::RedrawActiveWindow().

273  {
274  if( aState )
276  else
278  }
#define SELECTED_STATE
void WORKSHEET_DATAITEM::SetStart ( double  aPosx,
double  aPosy,
enum corner_anchor  aAnchor = RB_CORNER 
)
inline

Definition at line 154 of file class_worksheet_dataitem.h.

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

Referenced by PL_EDITOR_FRAME::UpdateStatusBar().

155  {
156  m_Pos.m_Pos.x = aPosx;
157  m_Pos.m_Pos.y = aPosy;
158  m_Pos.m_Anchor = aAnchor;
159  }
bool WORKSHEET_DATAITEM::UseAltColor ( )
inline

Definition at line 280 of file class_worksheet_dataitem.h.

References USE_ALT_COLOR.

Referenced by GetItemColor().

Member Data Documentation

COLOR4D WORKSHEET_DATAITEM::m_AltColor = COLOR4D( RED )
static
COLOR4D WORKSHEET_DATAITEM::m_Color = COLOR4D( RED )
static
wxString WORKSHEET_DATAITEM::m_Name
COLOR4D WORKSHEET_DATAITEM::m_SelectedColor = COLOR4D( BROWN )
static
WS_ItemType WORKSHEET_DATAITEM::m_type
protected

Definition at line 108 of file class_worksheet_dataitem.h.

Referenced by GetType(), and WORKSHEET_DATAITEM().


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