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 which 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 (const DPOINT &aPosition)
 Move item to a new position. More...
 
void MoveToUi (const wxPoint &aPosition)
 Move item to a new position. More...
 
void MoveStartPointTo (const DPOINT &aPosition)
 Move the starting point of the item to a new position. More...
 
void MoveStartPointToUi (const wxPoint &aPosition)
 Move the starting point of the item to a new position. More...
 
void MoveEndPointTo (const DPOINT &aPosition)
 Move the ending point of the item to a new position. More...
 
void MoveEndPointToUi (const 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 297 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 521 of file ds_data_item.cpp.

521  :
523 {
524  m_TextBase = aTextBase;
525  m_IncrementLabel = 1;
528  m_Italic = false;
529  m_Bold = false;
530  m_Orient = 0.0;
531  m_LineWidth = 0.0; // 0 means use default value
532 }
DS_DATA_ITEM(DS_ITEM_TYPE aType)
EDA_TEXT_VJUSTIFY_T m_Vjustify
Definition: ds_data_item.h:339
EDA_TEXT_HJUSTIFY_T m_Hjustify
Definition: ds_data_item.h:338
double m_LineWidth
Definition: ds_data_item.h:202
int m_IncrementLabel
Definition: ds_data_item.h:205

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

365 {
366  wxString name;
367 
368  switch( GetType() )
369  {
370  case DS_TEXT: name = _( "Text" ); break;
371  case DS_SEGMENT: name = _( "Line" ); break;
372  case DS_RECT: name = _( "Rectangle" ); break;
373  case DS_POLYPOLYGON: name = _( "Imported Shape" ); break;
374  case DS_BITMAP: name = _( "Image" ); break;
375  }
376 
377  return name;
378 }
DS_ITEM_TYPE GetType() const
Definition: ds_data_item.h:128
#define _(s)
const char * name
Definition: DXF_plotter.cpp:56

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

306 {
307  DPOINT pos( m_End.m_Pos.x + ( m_IncrementVector.x * ii ),
308  m_End.m_Pos.y + ( m_IncrementVector.y * ii ) );
309 
310  switch( m_End.m_Anchor )
311  {
312  case RB_CORNER: // right bottom corner
314  break;
315 
316  case RT_CORNER: // right top corner
317  pos.x = DS_DATA_MODEL::GetTheInstance().m_RB_Corner.x - pos.x;
318  pos.y = DS_DATA_MODEL::GetTheInstance().m_LT_Corner.y + pos.y;
319  break;
320 
321  case LB_CORNER: // left bottom corner
322  pos.x = DS_DATA_MODEL::GetTheInstance().m_LT_Corner.x + pos.x;
323  pos.y = DS_DATA_MODEL::GetTheInstance().m_RB_Corner.y - pos.y;
324  break;
325 
326  case LT_CORNER: // left top corner
328  break;
329  }
330 
331  return pos;
332 }
POINT_COORD m_End
Definition: ds_data_item.h:201
DPOINT m_RB_Corner
DPOINT m_LT_Corner
DPOINT m_IncrementVector
Definition: ds_data_item.h:204
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 335 of file ds_data_item.cpp.

336 {
337  DPOINT pos = GetEndPos( ii );
339  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
340 }
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:73

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 133 of file ds_data_item.h.

133 { return m_pageOption; }
PAGE_OPTION m_pageOption
Definition: ds_data_item.h:209

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

610 {
612 
613  if( m_LineWidth != 0 )
614  return KiROUND( m_LineWidth * model.m_WSunits2Iu );
615  else
616  return KiROUND( model.m_DefaultTextThickness * model.m_WSunits2Iu );
617 }
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:202
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:73

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

268 {
270  DPOINT pos( m_Pos.m_Pos.x + ( m_IncrementVector.x * ii ),
271  m_Pos.m_Pos.y + ( m_IncrementVector.y * ii ) );
272 
273  switch( m_Pos.m_Anchor )
274  {
275  case RB_CORNER: // right bottom corner
276  pos = model.m_RB_Corner - pos;
277  break;
278 
279  case RT_CORNER: // right top corner
280  pos.x = model.m_RB_Corner.x - pos.x;
281  pos.y = model.m_LT_Corner.y + pos.y;
282  break;
283 
284  case LB_CORNER: // left bottom corner
285  pos.x = model.m_LT_Corner.x + pos.x;
286  pos.y = model.m_RB_Corner.y - pos.y;
287  break;
288 
289  case LT_CORNER: // left top corner
290  pos = model.m_LT_Corner + pos;
291  break;
292  }
293 
294  return pos;
295 }
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:204
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:200

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

299 {
301  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
302 }
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:73

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 which 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 620 of file ds_data_item.cpp.

621 {
622  int last = m_TextBase.Len() -1;
623 
624  wxChar lbchar = m_TextBase[last];
626  m_FullText.RemoveLast();
627 
628  if( lbchar >= '0' && lbchar <= '9' )
629  // A number is expected:
630  m_FullText << (int)( aIncr + lbchar - '0' );
631  else
632  m_FullText << (wxChar) ( aIncr + lbchar );
633 }

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

344 {
346 
347  DPOINT pos = GetStartPos( ii );
348 
349  for( int kk = 0; kk < 1; kk++ )
350  {
351  if( model.m_RB_Corner.x < pos.x || model.m_LT_Corner.x > pos.x )
352  return false;
353 
354  if( model.m_RB_Corner.y < pos.y || model.m_LT_Corner.y > pos.y )
355  return false;
356 
357  pos = GetEndPos( ii );
358  }
359 
360  return true;
361 }
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 ( const DPOINT 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 mm.

Definition at line 214 of file ds_data_item.cpp.

215 {
217  DPOINT position;
218 
219  // Calculate the position of the starting point
220  // relative to the reference corner
221  // aPosition is the position relative to the right top paper corner
222  switch( m_End.m_Anchor )
223  {
224  case RB_CORNER:
225  position = model.m_RB_Corner - aPosition;
226  break;
227 
228  case RT_CORNER:
229  position.x = model.m_RB_Corner.x - aPosition.x;
230  position.y = aPosition.y - model.m_LT_Corner.y;
231  break;
232 
233  case LB_CORNER:
234  position.x = aPosition.x - model.m_LT_Corner.x;
235  position.y = model.m_RB_Corner.y - aPosition.y;
236  break;
237 
238  case LT_CORNER:
239  position = aPosition - model.m_LT_Corner;
240  break;
241  }
242 
243  // Modify m_End only for items having 2 coordinates
244  switch( GetType() )
245  {
246  case DS_SEGMENT:
247  case DS_RECT:
248  m_End.m_Pos = position;
249  break;
250 
251  default:
252  break;
253  }
254 }
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:201
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:128
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 ( const 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 257 of file ds_data_item.cpp.

258 {
259  DPOINT pos_mm;
260  pos_mm.x = aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
261  pos_mm.y = aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
262 
263  MoveEndPointTo( pos_mm );
264 }
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu
void MoveEndPointTo(const DPOINT &aPosition)
Move the ending point of the item to a new position.

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 ( const 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 172 of file ds_data_item.cpp.

173 {
175  DPOINT position;
176 
177  // Calculate the position of the starting point
178  // relative to the reference corner
179  // aPosition is the position relative to the right top paper corner
180  switch( m_Pos.m_Anchor )
181  {
182  case RB_CORNER:
183  position = model.m_RB_Corner - aPosition;
184  break;
185 
186  case RT_CORNER:
187  position.x = model.m_RB_Corner.x - aPosition.x;
188  position.y = aPosition.y - model.m_LT_Corner.y;
189  break;
190 
191  case LB_CORNER:
192  position.x = aPosition.x - model.m_LT_Corner.x;
193  position.y = model.m_RB_Corner.y - aPosition.y;
194  break;
195 
196  case LT_CORNER:
197  position = aPosition - model.m_LT_Corner;
198  break;
199  }
200 
201  m_Pos.m_Pos = position;
202 }
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:200

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 ( const 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 205 of file ds_data_item.cpp.

206 {
207  DPOINT pos_mm( aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu,
209 
210  MoveStartPointTo( pos_mm );
211 }
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double m_WSunits2Iu
void MoveStartPointTo(const 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 ( const DPOINT aPosition)
inherited

Move item to a new position.

Parameters
aPositionthe new position of item, in mm.

Definition at line 156 of file ds_data_item.cpp.

157 {
158  DPOINT vector = aPosition - GetStartPos();
159  DPOINT endpos = vector + GetEndPos();
160 
161  MoveStartPointTo( aPosition );
162  MoveEndPointTo( endpos );
163 
164  for( DS_DRAW_ITEM_BASE* drawItem : m_drawItems )
165  {
166  drawItem->SetPosition( GetStartPosUi( drawItem->GetIndexInPeer() ) );
167  drawItem->SetEnd( GetEndPosUi( drawItem->GetIndexInPeer() ) );
168  }
169 }
const DPOINT GetEndPos(int ii=0) const
const DPOINT GetStartPos(int ii=0) const
const wxPoint GetEndPosUi(int ii=0) const
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:211
void MoveStartPointTo(const DPOINT &aPosition)
Move the starting point of the item to a new position.
void MoveEndPointTo(const DPOINT &aPosition)
Move the ending 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 ( const wxPoint &  aPosition)
inherited

Move item to a new position.

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

Definition at line 146 of file ds_data_item.cpp.

147 {
148  DPOINT pos_mm;
149  pos_mm.x = aPosition.x / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
150  pos_mm.y = aPosition.y / DS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
151 
152  MoveTo( pos_mm );
153 }
void MoveTo(const DPOINT &aPosition)
Move 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::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 639 of file ds_data_item.cpp.

640 {
641  bool multiline = false;
642 
643  for( unsigned ii = 0; ii < m_FullText.Len(); ii++ )
644  {
645  if( m_FullText[ii] == '\n' )
646  multiline = true;
647 
648  else if( m_FullText[ii] == '\\' )
649  {
650  if( ++ii >= m_FullText.Len() )
651  break;
652 
653  if( m_FullText[ii] == '\\' )
654  {
655  // a double \\ sequence is replaced by a single \ char
656  m_FullText.Remove(ii, 1);
657  ii--;
658  }
659  else if( m_FullText[ii] == 'n' )
660  {
661  // Replace the "\n" sequence by a EOL char
662  multiline = true;
663  m_FullText[ii] = '\n';
664  m_FullText.Remove(ii-1, 1);
665  ii--;
666  }
667  }
668  }
669 
670  return multiline;
671 }

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

675 {
677 
678  if( m_ConstrainedTextSize.x == 0 )
680 
681  if( m_ConstrainedTextSize.y == 0 )
683 
685  {
686  // to know the X and Y size of the line, we should use
687  // EDA_TEXT::GetTextBox()
688  // but this function uses integers
689  // So, to avoid truncations with our unit in mm, use microns.
690  wxSize size_micron;
691  #define FSCALE 1000.0
692  int linewidth = 0;
693  size_micron.x = KiROUND( m_ConstrainedTextSize.x * FSCALE );
694  size_micron.y = KiROUND( m_ConstrainedTextSize.y * FSCALE );
695  DS_DRAW_ITEM_TEXT dummy( DS_DRAW_ITEM_TEXT( this, 0, m_FullText, wxPoint( 0, 0 ),
696  size_micron, linewidth, m_Italic, m_Bold ) );
697  dummy.SetMultilineAllowed( true );
698  dummy.SetHorizJustify( m_Hjustify ) ;
699  dummy.SetVertJustify( m_Vjustify );
700  dummy.SetTextAngle( m_Orient * 10 );
701 
702  EDA_RECT rect = dummy.GetTextBox();
703  DSIZE size;
704  size.x = rect.GetWidth() / FSCALE;
705  size.y = rect.GetHeight() / FSCALE;
706 
707  if( m_BoundingBoxSize.x && size.x > m_BoundingBoxSize.x )
709 
710  if( m_BoundingBoxSize.y && size.y > m_BoundingBoxSize.y )
712  }
713 }
#define FSCALE
EDA_TEXT_VJUSTIFY_T m_Vjustify
Definition: ds_data_item.h:339
int GetWidth() const
Definition: eda_rect.h:109
EDA_TEXT_HJUSTIFY_T m_Hjustify
Definition: ds_data_item.h:338
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
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:110
DSIZE m_ConstrainedTextSize
Definition: ds_data_item.h:346
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:73

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 121 of file ds_data_item.h.

122  {
123  m_End.m_Pos.x = aPosx;
124  m_End.m_Pos.y = aPosy;
125  m_End.m_Anchor = aAnchor;
126  }
POINT_COORD m_End
Definition: ds_data_item.h:201
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 134 of file ds_data_item.h.

134 { m_pageOption = aChoice; }
PAGE_OPTION m_pageOption
Definition: ds_data_item.h:209

References DS_DATA_ITEM::m_pageOption.

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

◆ SetStart()

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

Definition at line 114 of file ds_data_item.h.

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

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

536 {
537  int pensize = GetPenSizeUi();
538  bool multilines = false;
539 
540  if( DS_DATA_MODEL::GetTheInstance().m_EditMode )
541  {
543  }
544  else
545  {
546  m_FullText = aCollector ? aCollector->BuildFullText( m_TextBase ) : wxString();
547  multilines = ReplaceAntiSlashSequence();
548  }
549 
550  if( pensize == 0 )
551  pensize = aCollector ? aCollector->GetDefaultPenSize() : 1;
552 
554  wxSize textsize;
555 
558 
559  if( m_Bold )
560  pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
561 
562  std::map<size_t, EDA_ITEM_FLAGS> itemFlags;
563  DS_DRAW_ITEM_TEXT* text = nullptr;
564 
565  for( size_t i = 0; i < m_drawItems.size(); ++i )
566  {
568  itemFlags[ i ] = text->GetFlags();
569 
570  if( aCollector )
571  aCollector->Remove( text );
572 
573  if( aView )
574  aView->Remove( text );
575 
576  delete text;
577  }
578 
579  m_drawItems.clear();
580 
581  for( int j = 0; j < m_RepeatCount; ++j )
582  {
583  if( j > 0 && !IsInsidePage( j ) )
584  continue;
585 
586  text = new DS_DRAW_ITEM_TEXT( this, j, m_FullText, GetStartPosUi( j ), textsize, pensize,
587  m_Italic, m_Bold );
588  text->SetFlags( itemFlags[ j ] );
589  m_drawItems.push_back( text );
590 
591  if( aCollector )
592  aCollector->Append( text );
593 
594  if( aView )
595  aView->Add( text );
596 
597  text->SetHorizJustify( m_Hjustify ) ;
598  text->SetVertJustify( m_Vjustify );
599  text->SetTextAngle( m_Orient * 10 ); // graphic text orient unit = 0.1 degree
600  text->SetMultilineAllowed( multilines );
601 
602  // Increment label for the next text (has no meaning for multiline texts)
603  if( m_RepeatCount > 1 && !multilines )
604  IncrementLabel(( j + 1 ) * m_IncrementLabel );
605  }
606 }
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:339
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)
Definition: gr_text.cpp:46
virtual bool IsInsidePage(int ii) const
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:348
virtual int GetPenSizeUi() override
EDA_TEXT_HJUSTIFY_T m_Hjustify
Definition: ds_data_item.h:338
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:211
int m_IncrementLabel
Definition: ds_data_item.h:205
double m_WSunits2Iu
void Append(DS_DRAW_ITEM_BASE *aItem)
Definition: ds_draw_item.h:473
DSIZE m_ConstrainedTextSize
Definition: ds_data_item.h:346
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:73
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:318
void IncrementLabel(int aIncr)
Try to build text which 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 346 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: