KiCad PCB EDA Suite
WS_DATA_ITEM_TEXT Class Reference

#include <ws_data_item.h>

Inheritance diagram for WS_DATA_ITEM_TEXT:
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_TEXT (const wxString &aTextBase)
 
void SyncDrawItems (WS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView) override
 
virtual int GetPenSizeUi () override
 
void MoveTo (DPOINT aPosition)
 move item to a new position More...
 
void IncrementLabel (int aIncr)
 Try to build text wihich is an increment of m_TextBase has meaning only if m_TextBase is a basic text (one char) If the basic char is a digit, build a number If the basic char is a letter, use the letter with ascii code aIncr + (basic char ascc code) More...
 
void SetConstrainedTextSize ()
 Calculates m_ConstrainedTextSize from m_TextSize to keep the X size and the full Y size of the text smaller than m_BoundingBoxSize if m_BoundingBoxSize.x or m_BoundingBoxSize.y > 0 if m_BoundingBoxSize.x or m_BoundingBoxSize.y == 0 the corresponding text size is not constrained. More...
 
bool ReplaceAntiSlashSequence ()
 Replace the '\''n' sequence by EOL and the sequence '\''\' by only one '\' inside m_FullText. More...
 
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 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_TextBase
 
wxString m_FullText
 
double m_Orient
 
EDA_TEXT_HJUSTIFY_T m_Hjustify
 
EDA_TEXT_VJUSTIFY_T m_Vjustify
 
bool m_Italic
 
bool m_Bold
 
DSIZE m_TextSize
 
DSIZE m_BoundingBoxSize
 
DSIZE m_ConstrainedTextSize
 
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

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

WS_DATA_ITEM_TEXT::WS_DATA_ITEM_TEXT ( const wxString &  aTextBase)

Definition at line 532 of file ws_data_item.cpp.

532  :
534 {
535  m_TextBase = aTextBase;
536  m_IncrementLabel = 1;
539  m_Italic = false;
540  m_Bold = false;
541  m_Orient = 0.0;
542  m_LineWidth = 0.0; // 0 means use default value
543 }
EDA_TEXT_HJUSTIFY_T m_Hjustify
Definition: ws_data_item.h:304
WS_DATA_ITEM(WS_ITEM_TYPE aType)
EDA_TEXT_VJUSTIFY_T m_Vjustify
Definition: ws_data_item.h:305
double m_LineWidth
Definition: ws_data_item.h:117
int m_IncrementLabel
Definition: ws_data_item.h:121

References GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, m_Bold, m_Hjustify, WS_DATA_ITEM::m_IncrementLabel, m_Italic, WS_DATA_ITEM::m_LineWidth, m_Orient, m_TextBase, and m_Vjustify.

Member Function Documentation

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

◆ 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_TEXT::GetPenSizeUi ( )
overridevirtual

Reimplemented from WS_DATA_ITEM.

Definition at line 618 of file ws_data_item.cpp.

619 {
621 
622  if( m_LineWidth != 0 )
623  return KiROUND( m_LineWidth * model.m_WSunits2Iu );
624  else
625  return KiROUND( model.m_DefaultTextThickness * model.m_WSunits2Iu );
626 }
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_WSunits2Iu
Definition: ws_data_model.h:51
double m_DefaultTextThickness
Definition: ws_data_model.h:57
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(), WS_DATA_MODEL::m_DefaultTextThickness, WS_DATA_ITEM::m_LineWidth, and WS_DATA_MODEL::m_WSunits2Iu.

Referenced by 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 WS_DATA_ITEM_POLYGONS::GetCornerPosition(), WS_DATA_ITEM::GetStartPosUi(), WS_DATA_ITEM::IsInsidePage(), WS_DATA_ITEM_POLYGONS::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(), WS_DATA_ITEM_POLYGONS::SyncDrawItems(), SyncDrawItems(), and WS_DATA_ITEM_BITMAP::SyncDrawItems().

◆ GetType()

◆ IncrementLabel()

void WS_DATA_ITEM_TEXT::IncrementLabel ( int  aIncr)

Try to build text wihich is an increment of m_TextBase has meaning only if m_TextBase is a basic text (one char) If the basic char is a digit, build a number If the basic char is a letter, use the letter with ascii code aIncr + (basic char ascc code)

Parameters
aIncr= the increment value return the incremented label in m_FullText

Definition at line 629 of file ws_data_item.cpp.

630 {
631  int last = m_TextBase.Len() -1;
632 
633  wxChar lbchar = m_TextBase[last];
635  m_FullText.RemoveLast();
636 
637  if( lbchar >= '0' && lbchar <= '9' )
638  // A number is expected:
639  m_FullText << (int)( aIncr + lbchar - '0' );
640  else
641  m_FullText << (wxChar) ( aIncr + lbchar );
642 }

References m_FullText, and m_TextBase.

Referenced by SyncDrawItems().

◆ IsInsidePage()

bool WS_DATA_ITEM::IsInsidePage ( int  ii) const
virtualinherited
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 354 of file ws_data_item.cpp.

355 {
357 
358  DPOINT pos = GetStartPos( ii );
359 
360  for( int kk = 0; kk < 1; kk++ )
361  {
362  if( model.m_RB_Corner.x < pos.x || model.m_LT_Corner.x > pos.x )
363  return false;
364 
365  if( model.m_RB_Corner.y < pos.y || model.m_LT_Corner.y > pos.y )
366  return false;
367 
368  pos = GetEndPos( ii );
369  }
370 
371  return true;
372 }
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
const DPOINT GetEndPos(int ii=0) const

References WS_DATA_ITEM::GetEndPos(), WS_DATA_ITEM::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 WS_DATA_ITEM::SyncDrawItems(), SyncDrawItems(), and WS_DATA_ITEM_BITMAP::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_TEXT::MoveTo ( DPOINT  aPosition)

move item to a new position

Parameters
aPosition= the new position of item

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

◆ ReplaceAntiSlashSequence()

bool WS_DATA_ITEM_TEXT::ReplaceAntiSlashSequence ( )

Replace the '\''n' sequence by EOL and the sequence '\''\' by only one '\' inside m_FullText.

Returns
true if the EOL symbol is found or is inserted (multiline text)

Definition at line 648 of file ws_data_item.cpp.

649 {
650  bool multiline = false;
651 
652  for( unsigned ii = 0; ii < m_FullText.Len(); ii++ )
653  {
654  if( m_FullText[ii] == '\n' )
655  multiline = true;
656 
657  else if( m_FullText[ii] == '\\' )
658  {
659  if( ++ii >= m_FullText.Len() )
660  break;
661 
662  if( m_FullText[ii] == '\\' )
663  {
664  // a double \\ sequence is replaced by a single \ char
665  m_FullText.Remove(ii, 1);
666  ii--;
667  }
668  else if( m_FullText[ii] == 'n' )
669  {
670  // Replace the "\n" sequence by a EOL char
671  multiline = true;
672  m_FullText[ii] = '\n';
673  m_FullText.Remove(ii-1, 1);
674  ii--;
675  }
676  }
677  }
678 
679  return multiline;
680 }

References m_FullText.

Referenced by PROPERTIES_FRAME::CopyPrmsFromItemToPanel(), and SyncDrawItems().

◆ SetConstrainedTextSize()

void WS_DATA_ITEM_TEXT::SetConstrainedTextSize ( )

Calculates m_ConstrainedTextSize from m_TextSize to keep the X size and the full Y size of the text smaller than m_BoundingBoxSize if m_BoundingBoxSize.x or m_BoundingBoxSize.y > 0 if m_BoundingBoxSize.x or m_BoundingBoxSize.y == 0 the corresponding text size is not constrained.

Definition at line 683 of file ws_data_item.cpp.

684 {
686 
687  if( m_ConstrainedTextSize.x == 0 )
689 
690  if( m_ConstrainedTextSize.y == 0 )
692 
694  {
695  // to know the X and Y size of the line, we should use
696  // EDA_TEXT::GetTextBox()
697  // but this function uses integers
698  // So, to avoid truncations with our unit in mm, use microns.
699  wxSize size_micron;
700  #define FSCALE 1000.0
701  int linewidth = 0;
702  size_micron.x = KiROUND( m_ConstrainedTextSize.x * FSCALE );
703  size_micron.y = KiROUND( m_ConstrainedTextSize.y * FSCALE );
704  WS_DRAW_ITEM_TEXT dummy( WS_DRAW_ITEM_TEXT( this, 0, this->m_FullText, wxPoint( 0, 0 ),
705  size_micron, linewidth, m_Italic, m_Bold ) );
706  dummy.SetMultilineAllowed( true );
707  dummy.SetHorizJustify( m_Hjustify ) ;
708  dummy.SetVertJustify( m_Vjustify );
709  dummy.SetTextAngle( m_Orient * 10 );
710 
711  EDA_RECT rect = dummy.GetTextBox();
712  DSIZE size;
713  size.x = rect.GetWidth() / FSCALE;
714  size.y = rect.GetHeight() / FSCALE;
715 
716  if( m_BoundingBoxSize.x && size.x > m_BoundingBoxSize.x )
718 
719  if( m_BoundingBoxSize.y && size.y > m_BoundingBoxSize.y )
721  }
722 }
int GetWidth() const
Definition: eda_rect.h:119
DSIZE m_DefaultTextSize
Definition: ws_data_model.h:56
EDA_TEXT_HJUSTIFY_T m_Hjustify
Definition: ws_data_item.h:304
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
EDA_TEXT_VJUSTIFY_T m_Vjustify
Definition: ws_data_item.h:305
int GetHeight() const
Definition: eda_rect.h:120
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
DSIZE m_ConstrainedTextSize
Definition: ws_data_item.h:314
#define FSCALE
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 dummy(), FSCALE, EDA_RECT::GetHeight(), WS_DATA_MODEL::GetTheInstance(), EDA_RECT::GetWidth(), KiROUND(), m_Bold, m_BoundingBoxSize, m_ConstrainedTextSize, WS_DATA_MODEL::m_DefaultTextSize, m_FullText, m_Hjustify, m_Italic, m_Orient, m_TextSize, m_Vjustify, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SyncDrawItems().

◆ 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_TEXT::SyncDrawItems ( WS_DRAW_ITEM_LIST aCollector,
KIGFX::VIEW aView 
)
overridevirtual

Reimplemented from WS_DATA_ITEM.

Definition at line 546 of file ws_data_item.cpp.

547 {
548  int pensize = GetPenSizeUi();
549  bool multilines = false;
550 
551  if( WS_DATA_MODEL::GetTheInstance().m_EditMode )
553  else
554  {
555  m_FullText = aCollector ? aCollector->BuildFullText( m_TextBase ) : wxString();
556  multilines = ReplaceAntiSlashSequence();
557  }
558 
559  if( pensize == 0 )
560  pensize = aCollector ? aCollector->GetDefaultPenSize() : 1;
561 
563  wxSize textsize;
564 
567 
568  if( m_Bold )
569  pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
570 
571  std::map<int, STATUS_FLAGS> itemFlags;
572  WS_DRAW_ITEM_TEXT* text = nullptr;
573 
574  for( size_t i = 0; i < m_drawItems.size(); ++i )
575  {
576  text = (WS_DRAW_ITEM_TEXT*) m_drawItems[ i ];
577  itemFlags[ i ] = text->GetFlags();
578 
579  if( aCollector )
580  aCollector->Remove( text );
581 
582  if( aView )
583  aView->Remove( text );
584 
585  delete text;
586  }
587 
588  m_drawItems.clear();
589 
590  for( int j = 0; j < m_RepeatCount; ++j )
591  {
592  if( j > 0 && !IsInsidePage( j ) )
593  continue;
594 
595  text = new WS_DRAW_ITEM_TEXT( this, j, m_FullText, GetStartPosUi( j ), textsize, pensize,
596  m_Italic, m_Bold );
597  text->SetFlags( itemFlags[ j ] );
598  m_drawItems.push_back( text );
599 
600  if( aCollector )
601  aCollector->Append( text );
602 
603  if( aView )
604  aView->Add( text );
605 
606  text->SetHorizJustify( m_Hjustify ) ;
607  text->SetVertJustify( m_Vjustify );
608  text->SetTextAngle( m_Orient * 10 ); // graphic text orient unit = 0.1 degree
609  text->SetMultilineAllowed( multilines );
610 
611  // Increment label for the next text (has no meaning for multiline texts)
612  if( m_RepeatCount > 1 && !multilines )
613  IncrementLabel(( j + 1 ) * m_IncrementLabel );
614  }
615 }
void Remove(WS_DRAW_ITEM_BASE *aItem)
Definition: ws_draw_item.h:460
virtual bool IsInsidePage(int ii) const
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
Definition: gr_text.cpp:49
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
virtual int GetPenSizeUi() override
void IncrementLabel(int aIncr)
Try to build text wihich is an increment of m_TextBase has meaning only if m_TextBase is a basic text...
void Append(WS_DRAW_ITEM_BASE *aItem)
Definition: ws_draw_item.h:455
EDA_TEXT_HJUSTIFY_T m_Hjustify
Definition: ws_data_item.h:304
bool ReplaceAntiSlashSequence()
Replace the '\''n' sequence by EOL and the sequence '\''\' by only one '\' inside m_FullText.
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
const wxPoint GetStartPosUi(int ii=0) const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:265
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:188
EDA_TEXT_VJUSTIFY_T m_Vjustify
Definition: ws_data_item.h:305
std::vector< WS_DRAW_ITEM_BASE * > m_drawItems
Definition: ws_data_item.h:108
void SetMultilineAllowed(bool aAllow)
Function SetMultiLineAllowed.
Definition: eda_text.h:181
void SetTextAngle(double aAngle)
Definition: ws_draw_item.h:295
double m_WSunits2Iu
Definition: ws_data_model.h:51
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:187
wxString BuildFullText(const wxString &aTextbase)
Function BuildFullText returns the full text corresponding to the aTextbase, after replacing format s...
Definition: ws_painter.cpp:75
size_t i
Definition: json11.cpp:649
DSIZE m_ConstrainedTextSize
Definition: ws_data_item.h:314
void SetConstrainedTextSize()
Calculates m_ConstrainedTextSize from m_TextSize to keep the X size and the full Y size of the text s...
int m_IncrementLabel
Definition: ws_data_item.h:121
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 GetDefaultPenSize() const
Definition: ws_draw_item.h:426
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
#define min(a, b)
Definition: auxiliary.h:85

References KIGFX::VIEW::Add(), WS_DRAW_ITEM_LIST::Append(), WS_DRAW_ITEM_LIST::BuildFullText(), WS_DRAW_ITEM_LIST::GetDefaultPenSize(), EDA_ITEM::GetFlags(), GetPenSizeForBold(), GetPenSizeUi(), WS_DATA_ITEM::GetStartPosUi(), WS_DATA_MODEL::GetTheInstance(), i, IncrementLabel(), WS_DATA_ITEM::IsInsidePage(), KiROUND(), m_Bold, m_ConstrainedTextSize, WS_DATA_ITEM::m_drawItems, m_FullText, m_Hjustify, WS_DATA_ITEM::m_IncrementLabel, m_Italic, m_Orient, WS_DATA_ITEM::m_RepeatCount, m_TextBase, m_Vjustify, WS_DATA_MODEL::m_WSunits2Iu, min, KIGFX::VIEW::Remove(), WS_DRAW_ITEM_LIST::Remove(), ReplaceAntiSlashSequence(), SetConstrainedTextSize(), EDA_ITEM::SetFlags(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetMultilineAllowed(), WS_DRAW_ITEM_TEXT::SetTextAngle(), EDA_TEXT::SetVertJustify(), VECTOR2< T >::x, and VECTOR2< T >::y.

Member Data Documentation

◆ m_Bold

◆ m_BoundingBoxSize

◆ m_ConstrainedTextSize

DSIZE WS_DATA_ITEM_TEXT::m_ConstrainedTextSize

Definition at line 314 of file ws_data_item.h.

Referenced by SetConstrainedTextSize(), and SyncDrawItems().

◆ m_drawItems

◆ m_End

◆ m_FullText

wxString WS_DATA_ITEM_TEXT::m_FullText

◆ m_Hjustify

◆ m_IncrementLabel

◆ m_IncrementVector

◆ m_Info

◆ m_Italic

◆ m_LineWidth

◆ m_Name

◆ m_Orient

◆ m_pageOption

PAGE_OPTION WS_DATA_ITEM::m_pageOption
protectedinherited

◆ m_Pos

◆ m_RepeatCount

◆ m_TextBase

◆ m_TextSize

◆ m_type

WS_ITEM_TYPE WS_DATA_ITEM::m_type
protectedinherited

◆ m_Vjustify


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