KiCad PCB EDA Suite
DS_DATA_ITEM_TEXT Class Reference

#include <ds_data_item.h>

Inheritance diagram for DS_DATA_ITEM_TEXT:
DS_DATA_ITEM

Public Types

enum  DS_ITEM_TYPE {
  DS_TEXT, DS_SEGMENT, DS_RECT, DS_POLYPOLYGON,
  DS_BITMAP
}
 

Public Member Functions

 DS_DATA_ITEM_TEXT (const wxString &aTextBase)
 
void SyncDrawItems (DS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView) override
 
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 (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 ()
 Calculate 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< DS_DRAW_ITEM_BASE * > & GetDrawItems () const
 
void SetStart (double aPosx, double aPosy, enum CORNER_ANCHOR aAnchor=RB_CORNER)
 
void SetEnd (double aPosx, double aPosy, enum CORNER_ANCHOR aAnchor=RB_CORNER)
 
DS_ITEM_TYPE GetType () const
 
PAGE_OPTION GetPage1Option () const
 
void SetPage1Option (PAGE_OPTION aChoice)
 
const wxPoint GetStartPosUi (int ii=0) const
 
const wxPoint GetEndPosUi (int ii=0) const
 
const DPOINT GetStartPos (int ii=0) const
 
const DPOINT GetEndPos (int ii=0) const
 
void MoveTo (DPOINT aPosition)
 Move item to a new position. More...
 
void MoveToUi (wxPoint aPosition)
 Move item to a new position. More...
 
void MoveStartPointTo (DPOINT aPosition)
 Move the starting point of the item to a new position. More...
 
void MoveStartPointToUi (wxPoint aPosition)
 Move the starting point of the item to a new position. More...
 
void MoveEndPointTo (DPOINT aPosition)
 Move the ending point of the item to a new position. More...
 
void MoveEndPointToUi (wxPoint aPosition)
 Move the ending point of the item to a new position. More...
 
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

DS_ITEM_TYPE m_type
 
PAGE_OPTION m_pageOption
 
std::vector< DS_DRAW_ITEM_BASE * > m_drawItems
 

Detailed Description

Definition at line 301 of file ds_data_item.h.

Member Enumeration Documentation

◆ DS_ITEM_TYPE

Enumerator
DS_TEXT 
DS_SEGMENT 
DS_RECT 
DS_POLYPOLYGON 
DS_BITMAP 

Definition at line 98 of file ds_data_item.h.

Constructor & Destructor Documentation

◆ DS_DATA_ITEM_TEXT()

DS_DATA_ITEM_TEXT::DS_DATA_ITEM_TEXT ( const wxString &  aTextBase)

Definition at line 545 of file ds_data_item.cpp.

545  :
547 {
548  m_TextBase = aTextBase;
549  m_IncrementLabel = 1;
552  m_Italic = false;
553  m_Bold = false;
554  m_Orient = 0.0;
555  m_LineWidth = 0.0; // 0 means use default value
556 }
DS_DATA_ITEM(DS_ITEM_TYPE aType)
EDA_TEXT_VJUSTIFY_T m_Vjustify
Definition: ds_data_item.h:344
EDA_TEXT_HJUSTIFY_T m_Hjustify
Definition: ds_data_item.h:343
double m_LineWidth
Definition: ds_data_item.h:211
int m_IncrementLabel
Definition: ds_data_item.h:215

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

Member Function Documentation

◆ GetClassName()

const wxString DS_DATA_ITEM::GetClassName ( ) const
inherited

Definition at line 388 of file ds_data_item.cpp.

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

References _, DS_DATA_ITEM::DS_BITMAP, DS_DATA_ITEM::DS_POLYPOLYGON, DS_DATA_ITEM::DS_RECT, DS_DATA_ITEM::DS_SEGMENT, DS_DATA_ITEM::DS_TEXT, DS_DATA_ITEM::GetType(), and name.

Referenced by PROPERTIES_FRAME::CopyPrmsFromItemToPanel().

◆ GetDrawItems()

const std::vector<DS_DRAW_ITEM_BASE*>& DS_DATA_ITEM::GetDrawItems ( ) const
inlineinherited

◆ GetEndPos()

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

Definition at line 329 of file ds_data_item.cpp.

330 {
331  DPOINT pos( m_End.m_Pos.x + ( m_IncrementVector.x * ii ),
332  m_End.m_Pos.y + ( m_IncrementVector.y * ii ) );
333 
334  switch( m_End.m_Anchor )
335  {
336  case RB_CORNER: // right bottom corner
338  break;
339 
340  case RT_CORNER: // right top corner
341  pos.x = DS_DATA_MODEL::GetTheInstance().m_RB_Corner.x - pos.x;
342  pos.y = DS_DATA_MODEL::GetTheInstance().m_LT_Corner.y + pos.y;
343  break;
344 
345  case LB_CORNER: // left bottom corner
346  pos.x = DS_DATA_MODEL::GetTheInstance().m_LT_Corner.x + pos.x;
347  pos.y = DS_DATA_MODEL::GetTheInstance().m_RB_Corner.y - pos.y;
348  break;
349 
350  case LT_CORNER: // left top corner
352  break;
353  }
354 
355  return pos;
356 }
POINT_COORD m_End
Definition: ds_data_item.h:210
DPOINT m_RB_Corner
DPOINT m_LT_Corner
DPOINT m_IncrementVector
Definition: ds_data_item.h:213
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
DPOINT m_Pos
Definition: ds_data_item.h:80

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

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

◆ GetEndPosUi()

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

Definition at line 359 of file ds_data_item.cpp.

360 {
361  DPOINT pos = GetEndPos( ii );
363  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
364 }
const DPOINT GetEndPos(int ii=0) const
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68

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

Referenced by DS_DATA_ITEM::MoveTo(), DS_DATA_ITEM::SyncDrawItems(), and PL_POINT_EDITOR::updateItem().

◆ GetPage1Option()

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

Definition at line 134 of file ds_data_item.h.

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

References DS_DATA_ITEM::m_pageOption.

Referenced by PROPERTIES_FRAME::CopyPrmsFromItemToPanel(), DS_DATA_MODEL_IO::formatOptions(), DS_DRAW_ITEM_BASE::GetMsgPanelInfo(), and DS_DRAW_ITEM_BASE::ViewGetLayers().

◆ GetPenSizeUi()

int DS_DATA_ITEM_TEXT::GetPenSizeUi ( )
overridevirtual

Reimplemented from DS_DATA_ITEM.

Definition at line 633 of file ds_data_item.cpp.

634 {
636 
637  if( m_LineWidth != 0 )
638  return KiROUND( m_LineWidth * model.m_WSunits2Iu );
639  else
640  return KiROUND( model.m_DefaultTextThickness * model.m_WSunits2Iu );
641 }
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
double m_DefaultTextThickness
double m_LineWidth
Definition: ds_data_item.h:211
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68

References DS_DATA_MODEL::GetTheInstance(), KiROUND(), DS_DATA_MODEL::m_DefaultTextThickness, DS_DATA_ITEM::m_LineWidth, and DS_DATA_MODEL::m_WSunits2Iu.

Referenced by SyncDrawItems().

◆ GetStartPos()

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

Definition at line 291 of file ds_data_item.cpp.

292 {
294  DPOINT pos( m_Pos.m_Pos.x + ( m_IncrementVector.x * ii ),
295  m_Pos.m_Pos.y + ( m_IncrementVector.y * ii ) );
296 
297  switch( m_Pos.m_Anchor )
298  {
299  case RB_CORNER: // right bottom corner
300  pos = model.m_RB_Corner - pos;
301  break;
302 
303  case RT_CORNER: // right top corner
304  pos.x = model.m_RB_Corner.x - pos.x;
305  pos.y = model.m_LT_Corner.y + pos.y;
306  break;
307 
308  case LB_CORNER: // left bottom corner
309  pos.x = model.m_LT_Corner.x + pos.x;
310  pos.y = model.m_RB_Corner.y - pos.y;
311  break;
312 
313  case LT_CORNER: // left top corner
314  pos = model.m_LT_Corner + pos;
315  break;
316  }
317 
318  return pos;
319 }
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
DPOINT m_RB_Corner
DPOINT m_LT_Corner
DPOINT m_IncrementVector
Definition: ds_data_item.h:213
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
DPOINT m_Pos
Definition: ds_data_item.h:80
POINT_COORD m_Pos
Definition: ds_data_item.h:209

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

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

◆ GetStartPosUi()

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

Definition at line 322 of file ds_data_item.cpp.

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

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

Referenced by PL_EDIT_TOOL::moveItem(), DS_DATA_ITEM::MoveTo(), PL_DRAWING_TOOLS::PlaceItem(), DS_DATA_ITEM::SyncDrawItems(), DS_DATA_ITEM_POLYGONS::SyncDrawItems(), SyncDrawItems(), DS_DATA_ITEM_BITMAP::SyncDrawItems(), and PL_POINT_EDITOR::updateItem().

◆ GetType()

◆ IncrementLabel()

void DS_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 644 of file ds_data_item.cpp.

645 {
646  int last = m_TextBase.Len() -1;
647 
648  wxChar lbchar = m_TextBase[last];
650  m_FullText.RemoveLast();
651 
652  if( lbchar >= '0' && lbchar <= '9' )
653  // A number is expected:
654  m_FullText << (int)( aIncr + lbchar - '0' );
655  else
656  m_FullText << (wxChar) ( aIncr + lbchar );
657 }

References m_FullText, and m_TextBase.

Referenced by SyncDrawItems().

◆ IsInsidePage()

bool DS_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 DS_DATA_ITEM_POLYGONS.

Definition at line 367 of file ds_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 }
const DPOINT GetEndPos(int ii=0) const
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
const DPOINT GetStartPos(int ii=0) const
DPOINT m_RB_Corner
DPOINT m_LT_Corner
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application

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

Referenced by DS_DATA_ITEM::SyncDrawItems(), SyncDrawItems(), and DS_DATA_ITEM_BITMAP::SyncDrawItems().

◆ MoveEndPointTo()

void DS_DATA_ITEM::MoveEndPointTo ( DPOINT  aPosition)
inherited

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

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

This has meaning only for items defined by 2 points (segments and rectangles).

Parameters
aPositionis the new position of the ending point, in mm.

Definition at line 233 of file ds_data_item.cpp.

234 {
236  DPOINT position;
237 
238  // Calculate the position of the starting point
239  // relative to the reference corner
240  // aPosition is the position relative to the right top paper corner
241  switch( m_End.m_Anchor )
242  {
243  case RB_CORNER:
244  position = model.m_RB_Corner - aPosition;
245  break;
246 
247  case RT_CORNER:
248  position.x = model.m_RB_Corner.x - aPosition.x;
249  position.y = aPosition.y - model.m_LT_Corner.y;
250  break;
251 
252  case LB_CORNER:
253  position.x = aPosition.x - model.m_LT_Corner.x;
254  position.y = model.m_RB_Corner.y - aPosition.y;
255  break;
256 
257  case LT_CORNER:
258  position = aPosition - model.m_LT_Corner;
259  break;
260  }
261 
262  // Modify m_End only for items having 2 coordinates
263  switch( GetType() )
264  {
265  case DS_SEGMENT:
266  case DS_RECT:
267  m_End.m_Pos = position;
268  break;
269 
270  default:
271  break;
272  }
273 }
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
POINT_COORD m_End
Definition: ds_data_item.h:210
DPOINT m_RB_Corner
DPOINT m_LT_Corner
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
DS_ITEM_TYPE GetType() const
Definition: ds_data_item.h:129
DPOINT m_Pos
Definition: ds_data_item.h:80

References DS_DATA_ITEM::DS_RECT, DS_DATA_ITEM::DS_SEGMENT, DS_DATA_MODEL::GetTheInstance(), DS_DATA_ITEM::GetType(), LB_CORNER, LT_CORNER, POINT_COORD::m_Anchor, DS_DATA_ITEM::m_End, DS_DATA_MODEL::m_LT_Corner, POINT_COORD::m_Pos, DS_DATA_MODEL::m_RB_Corner, RB_CORNER, RT_CORNER, VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ MoveEndPointToUi()

void DS_DATA_ITEM::MoveEndPointToUi ( wxPoint  aPosition)
inherited

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

This has meaning only for items defined by 2 points (segments and rectangles).

Parameters
aPositionis the new position of the ending point in graphic units

Definition at line 281 of file ds_data_item.cpp.

282 {
283  DPOINT pos_mm;
284  pos_mm.x = aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
285  pos_mm.y = aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
286 
287  MoveEndPointTo( pos_mm );
288 }
void MoveEndPointTo(DPOINT aPosition)
Move the ending point of the item to a new position.
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu

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

Referenced by PL_POINT_EDITOR::updateItem().

◆ MoveStartPointTo()

void DS_DATA_ITEM::MoveStartPointTo ( DPOINT  aPosition)
inherited

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

Parameters
aPositionthe new position of the starting point, in mm.

Definition at line 182 of file ds_data_item.cpp.

183 {
185  DPOINT position;
186 
187  // Calculate the position of the starting point
188  // relative to the reference corner
189  // aPosition is the position relative to the right top paper corner
190  switch( m_Pos.m_Anchor )
191  {
192  case RB_CORNER:
193  position = model.m_RB_Corner - aPosition;
194  break;
195 
196  case RT_CORNER:
197  position.x = model.m_RB_Corner.x - aPosition.x;
198  position.y = aPosition.y - model.m_LT_Corner.y;
199  break;
200 
201  case LB_CORNER:
202  position.x = aPosition.x - model.m_LT_Corner.x;
203  position.y = model.m_RB_Corner.y - aPosition.y;
204  break;
205 
206  case LT_CORNER:
207  position = aPosition - model.m_LT_Corner;
208  break;
209  }
210 
211  m_Pos.m_Pos = position;
212 }
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
DPOINT m_RB_Corner
DPOINT m_LT_Corner
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
DPOINT m_Pos
Definition: ds_data_item.h:80
POINT_COORD m_Pos
Definition: ds_data_item.h:209

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

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

◆ MoveStartPointToUi()

void DS_DATA_ITEM::MoveStartPointToUi ( wxPoint  aPosition)
inherited

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

Parameters
aPositionis the new position of item in graphic units.

Definition at line 218 of file ds_data_item.cpp.

219 {
220  DPOINT pos_mm( aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu,
222 
223  MoveStartPointTo( pos_mm );
224 }
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu
void MoveStartPointTo(DPOINT aPosition)
Move the starting point of the item to a new position.

References DS_DATA_MODEL::GetTheInstance(), DS_DATA_MODEL::m_WSunits2Iu, and DS_DATA_ITEM::MoveStartPointTo().

Referenced by PL_DRAWING_TOOLS::PlaceItem(), and PL_POINT_EDITOR::updateItem().

◆ MoveTo()

void DS_DATA_ITEM::MoveTo ( DPOINT  aPosition)
inherited

Move item to a new position.

Parameters
aPositionthe new position of item, in mm.

Definition at line 163 of file ds_data_item.cpp.

164 {
165  DPOINT vector = aPosition - GetStartPos();
166  DPOINT endpos = vector + GetEndPos();
167 
168  MoveStartPointTo( aPosition );
169  MoveEndPointTo( endpos );
170 
171  for( DS_DRAW_ITEM_BASE* drawItem : m_drawItems )
172  {
173  drawItem->SetPosition( GetStartPosUi( drawItem->GetIndexInPeer() ) );
174  drawItem->SetEnd( GetEndPosUi( drawItem->GetIndexInPeer() ) );
175  }
176 }
const DPOINT GetEndPos(int ii=0) const
const DPOINT GetStartPos(int ii=0) const
const wxPoint GetEndPosUi(int ii=0) const
void MoveEndPointTo(DPOINT aPosition)
Move the ending point of the item to a new position.
Base class to handle basic graphic items.
Definition: ds_draw_item.h:58
std::vector< DS_DRAW_ITEM_BASE * > m_drawItems
Definition: ds_data_item.h:203
void MoveStartPointTo(DPOINT aPosition)
Move the starting point of the item to a new position.
const wxPoint GetStartPosUi(int ii=0) const

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

Referenced by DS_DATA_ITEM::MoveToUi().

◆ MoveToUi()

void DS_DATA_ITEM::MoveToUi ( wxPoint  aPosition)
inherited

Move item to a new position.

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

Definition at line 153 of file ds_data_item.cpp.

154 {
155  DPOINT pos_mm;
156  pos_mm.x = aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
157  pos_mm.y = aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
158 
159  MoveTo( pos_mm );
160 }
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
void MoveTo(DPOINT aPosition)
Move item to a new position.
double m_WSunits2Iu

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

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

◆ ReplaceAntiSlashSequence()

bool DS_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 663 of file ds_data_item.cpp.

664 {
665  bool multiline = false;
666 
667  for( unsigned ii = 0; ii < m_FullText.Len(); ii++ )
668  {
669  if( m_FullText[ii] == '\n' )
670  multiline = true;
671 
672  else if( m_FullText[ii] == '\\' )
673  {
674  if( ++ii >= m_FullText.Len() )
675  break;
676 
677  if( m_FullText[ii] == '\\' )
678  {
679  // a double \\ sequence is replaced by a single \ char
680  m_FullText.Remove(ii, 1);
681  ii--;
682  }
683  else if( m_FullText[ii] == 'n' )
684  {
685  // Replace the "\n" sequence by a EOL char
686  multiline = true;
687  m_FullText[ii] = '\n';
688  m_FullText.Remove(ii-1, 1);
689  ii--;
690  }
691  }
692  }
693 
694  return multiline;
695 }

References m_FullText.

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

◆ SetConstrainedTextSize()

void DS_DATA_ITEM_TEXT::SetConstrainedTextSize ( )

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

699 {
701 
702  if( m_ConstrainedTextSize.x == 0 )
704 
705  if( m_ConstrainedTextSize.y == 0 )
707 
709  {
710  // to know the X and Y size of the line, we should use
711  // EDA_TEXT::GetTextBox()
712  // but this function uses integers
713  // So, to avoid truncations with our unit in mm, use microns.
714  wxSize size_micron;
715  #define FSCALE 1000.0
716  int linewidth = 0;
717  size_micron.x = KiROUND( m_ConstrainedTextSize.x * FSCALE );
718  size_micron.y = KiROUND( m_ConstrainedTextSize.y * FSCALE );
719  DS_DRAW_ITEM_TEXT dummy( DS_DRAW_ITEM_TEXT( this, 0, m_FullText, wxPoint( 0, 0 ),
720  size_micron, linewidth, m_Italic, m_Bold ) );
721  dummy.SetMultilineAllowed( true );
722  dummy.SetHorizJustify( m_Hjustify ) ;
723  dummy.SetVertJustify( m_Vjustify );
724  dummy.SetTextAngle( m_Orient * 10 );
725 
726  EDA_RECT rect = dummy.GetTextBox();
727  DSIZE size;
728  size.x = rect.GetWidth() / FSCALE;
729  size.y = rect.GetHeight() / FSCALE;
730 
731  if( m_BoundingBoxSize.x && size.x > m_BoundingBoxSize.x )
733 
734  if( m_BoundingBoxSize.y && size.y > m_BoundingBoxSize.y )
736  }
737 }
#define FSCALE
EDA_TEXT_VJUSTIFY_T m_Vjustify
Definition: ds_data_item.h:344
int GetWidth() const
Definition: eda_rect.h:114
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
EDA_TEXT_HJUSTIFY_T m_Hjustify
Definition: ds_data_item.h:343
A graphic text.
Definition: ds_draw_item.h:297
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
DSIZE m_DefaultTextSize
int GetHeight() const
Definition: eda_rect.h:115
DSIZE m_ConstrainedTextSize
Definition: ds_data_item.h:351
Handle the component boundary box.
Definition: eda_rect.h:42
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 dummy(), FSCALE, EDA_RECT::GetHeight(), DS_DATA_MODEL::GetTheInstance(), EDA_RECT::GetWidth(), KiROUND(), m_Bold, m_BoundingBoxSize, m_ConstrainedTextSize, DS_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 DS_DATA_ITEM::SetEnd ( double  aPosx,
double  aPosy,
enum CORNER_ANCHOR  aAnchor = RB_CORNER 
)
inlineinherited

Definition at line 122 of file ds_data_item.h.

123  {
124  m_End.m_Pos.x = aPosx;
125  m_End.m_Pos.y = aPosy;
126  m_End.m_Anchor = aAnchor;
127  }
POINT_COORD m_End
Definition: ds_data_item.h:210
DPOINT m_Pos
Definition: ds_data_item.h:80

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

◆ SetPage1Option()

void DS_DATA_ITEM::SetPage1Option ( PAGE_OPTION  aChoice)
inlineinherited

Definition at line 135 of file ds_data_item.h.

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

References DS_DATA_ITEM::m_pageOption.

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

◆ SetStart()

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

Definition at line 115 of file ds_data_item.h.

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

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

◆ SyncDrawItems()

void DS_DATA_ITEM_TEXT::SyncDrawItems ( DS_DRAW_ITEM_LIST aCollector,
KIGFX::VIEW aView 
)
overridevirtual

Reimplemented from DS_DATA_ITEM.

Definition at line 559 of file ds_data_item.cpp.

560 {
561  int pensize = GetPenSizeUi();
562  bool multilines = false;
563 
564  if( DS_DATA_MODEL::GetTheInstance().m_EditMode )
565  {
567  }
568  else
569  {
570  m_FullText = aCollector ? aCollector->BuildFullText( m_TextBase ) : wxString();
571  multilines = ReplaceAntiSlashSequence();
572  }
573 
574  if( pensize == 0 )
575  pensize = aCollector ? aCollector->GetDefaultPenSize() : 1;
576 
578  wxSize textsize;
579 
582 
583  if( m_Bold )
584  pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
585 
586  std::map<int, STATUS_FLAGS> itemFlags;
587  DS_DRAW_ITEM_TEXT* text = nullptr;
588 
589  for( size_t i = 0; i < m_drawItems.size(); ++i )
590  {
592  itemFlags[ i ] = text->GetFlags();
593 
594  if( aCollector )
595  aCollector->Remove( text );
596 
597  if( aView )
598  aView->Remove( text );
599 
600  delete text;
601  }
602 
603  m_drawItems.clear();
604 
605  for( int j = 0; j < m_RepeatCount; ++j )
606  {
607  if( j > 0 && !IsInsidePage( j ) )
608  continue;
609 
610  text = new DS_DRAW_ITEM_TEXT( this, j, m_FullText, GetStartPosUi( j ), textsize, pensize,
611  m_Italic, m_Bold );
612  text->SetFlags( itemFlags[ j ] );
613  m_drawItems.push_back( text );
614 
615  if( aCollector )
616  aCollector->Append( text );
617 
618  if( aView )
619  aView->Add( text );
620 
621  text->SetHorizJustify( m_Hjustify ) ;
622  text->SetVertJustify( m_Vjustify );
623  text->SetTextAngle( m_Orient * 10 ); // graphic text orient unit = 0.1 degree
624  text->SetMultilineAllowed( multilines );
625 
626  // Increment label for the next text (has no meaning for multiline texts)
627  if( m_RepeatCount > 1 && !multilines )
628  IncrementLabel(( j + 1 ) * m_IncrementLabel );
629  }
630 }
void SetConstrainedTextSize()
Calculate m_ConstrainedTextSize from m_TextSize to keep the X size and the full Y size of the text sm...
EDA_TEXT_VJUSTIFY_T m_Vjustify
Definition: ds_data_item.h:344
wxString BuildFullText(const wxString &aTextbase)
Return the full text corresponding to the aTextbase, after replacing format symbols by the correspond...
Definition: ds_painter.cpp:104
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
Definition: gr_text.cpp:48
virtual bool IsInsidePage(int ii) const
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:352
virtual int GetPenSizeUi() override
EDA_TEXT_HJUSTIFY_T m_Hjustify
Definition: ds_data_item.h:343
A graphic text.
Definition: ds_draw_item.h:297
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
int GetDefaultPenSize() const
Definition: ds_draw_item.h:437
std::vector< DS_DRAW_ITEM_BASE * > m_drawItems
Definition: ds_data_item.h:203
int m_IncrementLabel
Definition: ds_data_item.h:215
double m_WSunits2Iu
void Append(DS_DRAW_ITEM_BASE *aItem)
Definition: ds_draw_item.h:473
DSIZE m_ConstrainedTextSize
Definition: ds_data_item.h:351
bool ReplaceAntiSlashSequence()
Replace the '\''n' sequence by EOL and the sequence '\''\' by only one '\' inside m_FullText.
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
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:322
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 Remove(DS_DRAW_ITEM_BASE *aItem)
Definition: ds_draw_item.h:478
const wxPoint GetStartPosUi(int ii=0) const

References KIGFX::VIEW::Add(), DS_DRAW_ITEM_LIST::Append(), DS_DRAW_ITEM_LIST::BuildFullText(), DS_DRAW_ITEM_LIST::GetDefaultPenSize(), GetPenSizeForBold(), GetPenSizeUi(), DS_DATA_ITEM::GetStartPosUi(), DS_DATA_MODEL::GetTheInstance(), IncrementLabel(), DS_DATA_ITEM::IsInsidePage(), KiROUND(), m_Bold, m_ConstrainedTextSize, DS_DATA_ITEM::m_drawItems, m_FullText, m_Hjustify, DS_DATA_ITEM::m_IncrementLabel, m_Italic, m_Orient, DS_DATA_ITEM::m_RepeatCount, m_TextBase, m_Vjustify, DS_DATA_MODEL::m_WSunits2Iu, KIGFX::VIEW::Remove(), DS_DRAW_ITEM_LIST::Remove(), ReplaceAntiSlashSequence(), SetConstrainedTextSize(), text, VECTOR2< T >::x, and VECTOR2< T >::y.

Member Data Documentation

◆ m_Bold

◆ m_BoundingBoxSize

◆ m_ConstrainedTextSize

DSIZE DS_DATA_ITEM_TEXT::m_ConstrainedTextSize

Definition at line 351 of file ds_data_item.h.

Referenced by SetConstrainedTextSize(), and SyncDrawItems().

◆ m_drawItems

◆ m_End

◆ m_FullText

wxString DS_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 DS_DATA_ITEM::m_pageOption
protectedinherited

◆ m_Pos

◆ m_RepeatCount

◆ m_TextBase

◆ m_TextSize

◆ m_type

DS_ITEM_TYPE DS_DATA_ITEM::m_type
protectedinherited

◆ m_Vjustify


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