KiCad PCB EDA Suite
ws_data_item.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
5  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 
27 /*
28  * the class WS_DATA_ITEM (and derived) defines
29  * a basic shape of a page layout ( frame references and title block )
30  * Basic shapes are line, rect and texts
31  * the WS_DATA_ITEM coordinates units is the mm, and are relative to
32  * one of 4 page corners.
33  *
34  * These items cannot be drawn or plot "as this". they should be converted
35  * to a "draw list" (WS_DRAW_ITEM_BASE and derived items)
36 
37  * The list of these items is stored in a WS_DATA_MODEL instance.
38  *
39  * When building the draw list:
40  * the WS_DATA_MODEL is used to create a WS_DRAW_ITEM_LIST
41  * coordinates are converted to draw/plot coordinates.
42  * texts are expanded if they contain format symbols.
43  * Items with m_RepeatCount > 1 are created m_RepeatCount times
44  *
45  * the WS_DATA_MODEL is created only once.
46  * the WS_DRAW_ITEM_LIST is created each time the page layout is plot/drawn
47  *
48  * the WS_DATA_MODEL instance is created from a S expression which
49  * describes the page layout (can be the default page layout or a custom file).
50  */
51 
52 #include <fctsys.h>
53 #include <gr_text.h>
54 #include <eda_rect.h>
55 #include <math/util.h> // for KiROUND
56 #include <view/view.h>
57 #include <ws_painter.h>
58 #include <title_block.h>
59 #include <ws_draw_item.h>
60 #include <ws_data_model.h>
61 
62 using KIGFX::COLOR4D;
63 
64 
65 // The constructor:
67 {
69  m_type = aType;
70  m_RepeatCount = 1;
71  m_IncrementLabel = 1;
72  m_LineWidth = 0;
73 }
74 
75 
77 {
78  int pensize = GetPenSizeUi();
79 
80  if( pensize == 0 )
81  pensize = aCollector ? aCollector->GetDefaultPenSize() : 0;
82 
83  std::map<int, STATUS_FLAGS> itemFlags;
84  WS_DRAW_ITEM_BASE* item = nullptr;
85 
86  for( size_t i = 0; i < m_drawItems.size(); ++i )
87  {
88  item = m_drawItems[ i ];
89  itemFlags[ i ] = item->GetFlags();
90 
91  if( aCollector )
92  aCollector->Remove( item );
93 
94  if( aView )
95  aView->Remove( item );
96 
97  delete item;
98  }
99 
100  m_drawItems.clear();
101 
102  for( int j = 0; j < m_RepeatCount; j++ )
103  {
104  if( j && ! IsInsidePage( j ) )
105  continue;
106 
107  if( m_type == WS_SEGMENT )
108  item = new WS_DRAW_ITEM_LINE( this, j, GetStartPosUi( j ), GetEndPosUi( j ), pensize );
109  else if( m_type == WS_RECT )
110  item = new WS_DRAW_ITEM_RECT( this, j, GetStartPosUi( j ), GetEndPosUi( j ), pensize );
111  else
112  {
113  wxFAIL_MSG( "Unknown worksheet draw item type" );
114  continue;
115  }
116 
117  item->SetFlags( itemFlags[ j ] );
118  m_drawItems.push_back( item );
119 
120  if( aCollector )
121  aCollector->Append( item );
122 
123  if( aView )
124  aView->Add( item );
125  }
126 }
127 
128 
130 {
132 
133  if( m_LineWidth != 0 )
134  return KiROUND( m_LineWidth * model.m_WSunits2Iu );
135  else
136  return KiROUND( model.m_DefaultLineWidth * model.m_WSunits2Iu );
137 }
138 
139 
140 // move item to aPosition
141 // starting point is moved to aPosition
142 // the Ending point is moved to a position which keeps the item size
143 // (if both coordinates have the same corner reference)
144 // MoveToUi and MoveTo takes the graphic position (i.e relative to the left top
145 // paper corner
147 {
148  DPOINT pos_mm;
149  pos_mm.x = aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
150  pos_mm.y = aPosition.y / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
151 
152  MoveTo( pos_mm );
153 }
154 
155 
156 void WS_DATA_ITEM::MoveTo( DPOINT aPosition )
157 {
158  DPOINT vector = aPosition - GetStartPos();
159  DPOINT endpos = vector + GetEndPos();
160 
161  MoveStartPointTo( aPosition );
162  MoveEndPointTo( endpos );
163 
164  for( WS_DRAW_ITEM_BASE* drawItem : m_drawItems )
165  {
166  drawItem->SetPosition( GetStartPosUi( drawItem->GetIndexInPeer() ) );
167  drawItem->SetEnd( GetEndPosUi( drawItem->GetIndexInPeer() ) );
168  }
169 }
170 
171 
172 /* move the starting point of the item to a new position
173  * aPosition = the new position of the starting point, in mm
174  */
176 {
178  DPOINT position;
179 
180  // Calculate the position of the starting point
181  // relative to the reference corner
182  // aPosition is the position relative to the right top paper corner
183  switch( m_Pos.m_Anchor )
184  {
185  case RB_CORNER:
186  position = model.m_RB_Corner - aPosition;
187  break;
188 
189  case RT_CORNER:
190  position.x = model.m_RB_Corner.x - aPosition.x;
191  position.y = aPosition.y - model.m_LT_Corner.y;
192  break;
193 
194  case LB_CORNER:
195  position.x = aPosition.x - model.m_LT_Corner.x;
196  position.y = model.m_RB_Corner.y - aPosition.y;
197  break;
198 
199  case LT_CORNER:
200  position = aPosition - model.m_LT_Corner;
201  break;
202  }
203 
204  m_Pos.m_Pos = position;
205 }
206 
207 
208 /* move the starting point of the item to a new position
209  * aPosition = the new position of the starting point in graphic units
210  */
212 {
213  DPOINT pos_mm( aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu,
215 
216  MoveStartPointTo( pos_mm );
217 }
218 
219 
227 {
229  DPOINT position;
230 
231  // Calculate the position of the starting point
232  // relative to the reference corner
233  // aPosition is the position relative to the right top paper corner
234  switch( m_End.m_Anchor )
235  {
236  case RB_CORNER:
237  position = model.m_RB_Corner - aPosition;
238  break;
239 
240  case RT_CORNER:
241  position.x = model.m_RB_Corner.x - aPosition.x;
242  position.y = aPosition.y - model.m_LT_Corner.y;
243  break;
244 
245  case LB_CORNER:
246  position.x = aPosition.x - model.m_LT_Corner.x;
247  position.y = model.m_RB_Corner.y - aPosition.y;
248  break;
249 
250  case LT_CORNER:
251  position = aPosition - model.m_LT_Corner;
252  break;
253  }
254 
255  // Modify m_End only for items having 2 coordinates
256  switch( GetType() )
257  {
258  case WS_SEGMENT:
259  case WS_RECT:
260  m_End.m_Pos = position;
261  break;
262 
263  default:
264  break;
265  }
266 }
267 
268 
269 /* move the ending point of the item to a new position
270  * has meaning only for items defined by 2 points
271  * (segments and rectangles)
272  * aPosition = the new position of the ending point in graphic units
273  */
275 {
276  DPOINT pos_mm;
277  pos_mm.x = aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
278  pos_mm.y = aPosition.y / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
279 
280  MoveEndPointTo( pos_mm );
281 }
282 
283 
284 const DPOINT WS_DATA_ITEM::GetStartPos( int ii ) const
285 {
287  DPOINT pos( m_Pos.m_Pos.x + ( m_IncrementVector.x * ii ),
288  m_Pos.m_Pos.y + ( m_IncrementVector.y * ii ) );
289 
290  switch( m_Pos.m_Anchor )
291  {
292  case RB_CORNER: // right bottom corner
293  pos = model.m_RB_Corner - pos;
294  break;
295 
296  case RT_CORNER: // right top corner
297  pos.x = model.m_RB_Corner.x - pos.x;
298  pos.y = model.m_LT_Corner.y + pos.y;
299  break;
300 
301  case LB_CORNER: // left bottom corner
302  pos.x = model.m_LT_Corner.x + pos.x;
303  pos.y = model.m_RB_Corner.y - pos.y;
304  break;
305 
306  case LT_CORNER: // left top corner
307  pos = model.m_LT_Corner + pos;
308  break;
309  }
310 
311  return pos;
312 }
313 
314 
316 {
318  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
319 }
320 
321 
322 const DPOINT WS_DATA_ITEM::GetEndPos( int ii ) const
323 {
324  DPOINT pos( m_End.m_Pos.x + ( m_IncrementVector.x * ii ),
325  m_End.m_Pos.y + ( m_IncrementVector.y * ii ) );
326 
327  switch( m_End.m_Anchor )
328  {
329  case RB_CORNER: // right bottom corner
331  break;
332 
333  case RT_CORNER: // right top corner
336  break;
337 
338  case LB_CORNER: // left bottom corner
341  break;
342 
343  case LT_CORNER: // left top corner
345  break;
346  }
347 
348  return pos;
349 }
350 
351 
352 const wxPoint WS_DATA_ITEM::GetEndPosUi( int ii ) const
353 {
354  DPOINT pos = GetEndPos( ii );
356  return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
357 }
358 
359 
360 bool WS_DATA_ITEM::IsInsidePage( int ii ) const
361 {
363 
364  DPOINT pos = GetStartPos( ii );
365 
366  for( int kk = 0; kk < 1; kk++ )
367  {
368  if( model.m_RB_Corner.x < pos.x || model.m_LT_Corner.x > pos.x )
369  return false;
370 
371  if( model.m_RB_Corner.y < pos.y || model.m_LT_Corner.y > pos.y )
372  return false;
373 
374  pos = GetEndPos( ii );
375  }
376 
377  return true;
378 }
379 
380 
381 const wxString WS_DATA_ITEM::GetClassName() const
382 {
383  wxString name;
384 
385  switch( GetType() )
386  {
387  case WS_TEXT: name = wxT( "Text" ); break;
388  case WS_SEGMENT: name = wxT( "Line" ); break;
389  case WS_RECT: name = wxT( "Rectangle" ); break;
390  case WS_POLYPOLYGON: name = wxT( "Imported Shape" ); break;
391  case WS_BITMAP: name = wxT( "Image" ); break;
392  }
393 
394  return name;
395 }
396 
397 
399  WS_DATA_ITEM( WS_POLYPOLYGON )
400 {
401  m_Orient = 0.0;
402 }
403 
404 
406 {
407  std::map<int, STATUS_FLAGS> itemFlags;
408  WS_DRAW_ITEM_BASE* item = nullptr;
409 
410  for( size_t i = 0; i < m_drawItems.size(); ++i )
411  {
412  item = m_drawItems[ i ];
413  itemFlags[ i ] = item->GetFlags();
414 
415  if( aCollector )
416  aCollector->Remove( item );
417 
418  if( aView )
419  aView->Remove( item );
420 
421  delete item;
422  }
423 
424  m_drawItems.clear();
425 
426  for( int j = 0; j < m_RepeatCount; j++ )
427  {
428  if( j && !IsInsidePage( j ) )
429  continue;
430 
431  int pensize = GetPenSizeUi();
432  auto poly_shape = new WS_DRAW_ITEM_POLYPOLYGONS( this, j, GetStartPosUi( j ), pensize );
433  poly_shape->SetFlags( itemFlags[ j ] );
434  m_drawItems.push_back( poly_shape );
435 
436  // Transfer all outlines (basic polygons)
437  SHAPE_POLY_SET& polygons = poly_shape->GetPolygons();
438  for( int kk = 0; kk < GetPolyCount(); kk++ )
439  {
440  // Create new outline
441  unsigned ist = GetPolyIndexStart( kk );
442  unsigned iend = GetPolyIndexEnd( kk );
443 
444  polygons.NewOutline();
445 
446  while( ist <= iend )
447  polygons.Append( GetCornerPositionUi( ist++, j ) );
448  }
449 
450  if( aCollector )
451  aCollector->Append( poly_shape );
452 
453  if( aView )
454  aView->Add( poly_shape );
455  }
456 }
457 
458 
460 {
461  return KiROUND( m_LineWidth * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
462 }
463 
464 
465 const DPOINT WS_DATA_ITEM_POLYGONS::GetCornerPosition( unsigned aIdx, int aRepeat ) const
466 {
467  DPOINT pos = m_Corners[aIdx];
468 
469  // Rotation:
470  RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
471  pos += GetStartPos( aRepeat );
472  return pos;
473 }
474 
475 
477 {
478  if( m_Corners.size() == 0 )
479  {
480  m_minCoord.x = m_maxCoord.x = 0.0;
481  m_minCoord.y = m_maxCoord.y = 0.0;
482  return;
483  }
484 
485  DPOINT pos;
486  pos = m_Corners[0];
487  RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
488  m_minCoord = m_maxCoord = pos;
489 
490  for( unsigned ii = 1; ii < m_Corners.size(); ii++ )
491  {
492  pos = m_Corners[ii];
493  RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
494 
495  if( m_minCoord.x > pos.x )
496  m_minCoord.x = pos.x;
497 
498  if( m_minCoord.y > pos.y )
499  m_minCoord.y = pos.y;
500 
501  if( m_maxCoord.x < pos.x )
502  m_maxCoord.x = pos.x;
503 
504  if( m_maxCoord.y < pos.y )
505  m_maxCoord.y = pos.y;
506  }
507 }
508 
509 
511 {
513 
514  DPOINT pos = GetStartPos( ii );
515  pos += m_minCoord; // left top pos of bounding box
516 
517  if( model.m_LT_Corner.x > pos.x || model.m_LT_Corner.y > pos.y )
518  return false;
519 
520  pos = GetStartPos( ii );
521  pos += m_maxCoord; // rignt bottom pos of bounding box
522 
523  if( model.m_RB_Corner.x < pos.x || model.m_RB_Corner.y < pos.y )
524  return false;
525 
526  return true;
527 }
528 
529 
530 const wxPoint WS_DATA_ITEM_POLYGONS::GetCornerPositionUi( unsigned aIdx, int aRepeat ) const
531 {
532  DPOINT pos = GetCornerPosition( aIdx, aRepeat );
534  return wxPoint( int(pos.x), int(pos.y) );
535 }
536 
537 
538 WS_DATA_ITEM_TEXT::WS_DATA_ITEM_TEXT( const wxString& aTextBase ) :
539  WS_DATA_ITEM( WS_TEXT )
540 {
541  m_TextBase = aTextBase;
542  m_IncrementLabel = 1;
545  m_Italic = false;
546  m_Bold = false;
547  m_Orient = 0.0;
548  m_LineWidth = 0.0; // 0 means use default value
549 }
550 
551 
553 {
554  int pensize = GetPenSizeUi();
555  bool multilines = false;
556 
557  if( WS_DATA_MODEL::GetTheInstance().m_EditMode )
559  else
560  {
561  m_FullText = aCollector ? aCollector->BuildFullText( m_TextBase ) : wxString();
562  multilines = ReplaceAntiSlashSequence();
563  }
564 
565  if( pensize == 0 )
566  pensize = aCollector ? aCollector->GetDefaultPenSize() : 1;
567 
569  wxSize textsize;
570 
573 
574  if( m_Bold )
575  pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
576 
577  std::map<int, STATUS_FLAGS> itemFlags;
578  WS_DRAW_ITEM_TEXT* text = nullptr;
579 
580  for( size_t i = 0; i < m_drawItems.size(); ++i )
581  {
582  text = (WS_DRAW_ITEM_TEXT*) m_drawItems[ i ];
583  itemFlags[ i ] = text->GetFlags();
584 
585  if( aCollector )
586  aCollector->Remove( text );
587 
588  if( aView )
589  aView->Remove( text );
590 
591  delete text;
592  }
593 
594  m_drawItems.clear();
595 
596  for( int j = 0; j < m_RepeatCount; ++j )
597  {
598  if( j > 0 && !IsInsidePage( j ) )
599  continue;
600 
601  text = new WS_DRAW_ITEM_TEXT( this, j, m_FullText, GetStartPosUi( j ), textsize, pensize,
602  m_Italic, m_Bold );
603  text->SetFlags( itemFlags[ j ] );
604  m_drawItems.push_back( text );
605 
606  if( aCollector )
607  aCollector->Append( text );
608 
609  if( aView )
610  aView->Add( text );
611 
612  text->SetHorizJustify( m_Hjustify ) ;
613  text->SetVertJustify( m_Vjustify );
614  text->SetTextAngle( m_Orient * 10 ); // graphic text orient unit = 0.1 degree
615  text->SetMultilineAllowed( multilines );
616 
617  // Increment label for the next text (has no meaning for multiline texts)
618  if( m_RepeatCount > 1 && !multilines )
619  IncrementLabel(( j + 1 ) * m_IncrementLabel );
620  }
621 }
622 
623 
625 {
627 
628  if( m_LineWidth != 0 )
629  return KiROUND( m_LineWidth * model.m_WSunits2Iu );
630  else
631  return KiROUND( model.m_DefaultTextThickness * model.m_WSunits2Iu );
632 }
633 
634 
636 {
637  int last = m_TextBase.Len() -1;
638 
639  wxChar lbchar = m_TextBase[last];
641  m_FullText.RemoveLast();
642 
643  if( lbchar >= '0' && lbchar <= '9' )
644  // A number is expected:
645  m_FullText << (int)( aIncr + lbchar - '0' );
646  else
647  m_FullText << (wxChar) ( aIncr + lbchar );
648 }
649 
650 
651 // Replace the '\''n' sequence by EOL
652 // and the sequence '\''\' by only one '\' in m_FullText
653 // if m_FullText is a multiline text (i.e.contains '\n') return true
655 {
656  bool multiline = false;
657 
658  for( unsigned ii = 0; ii < m_FullText.Len(); ii++ )
659  {
660  if( m_FullText[ii] == '\n' )
661  multiline = true;
662 
663  else if( m_FullText[ii] == '\\' )
664  {
665  if( ++ii >= m_FullText.Len() )
666  break;
667 
668  if( m_FullText[ii] == '\\' )
669  {
670  // a double \\ sequence is replaced by a single \ char
671  m_FullText.Remove(ii, 1);
672  ii--;
673  }
674  else if( m_FullText[ii] == 'n' )
675  {
676  // Replace the "\n" sequence by a EOL char
677  multiline = true;
678  m_FullText[ii] = '\n';
679  m_FullText.Remove(ii-1, 1);
680  ii--;
681  }
682  }
683  }
684 
685  return multiline;
686 }
687 
688 
690 {
692 
693  if( m_ConstrainedTextSize.x == 0 )
695 
696  if( m_ConstrainedTextSize.y == 0 )
698 
700  {
701  // to know the X and Y size of the line, we should use
702  // EDA_TEXT::GetTextBox()
703  // but this function uses integers
704  // So, to avoid truncations with our unit in mm, use microns.
705  wxSize size_micron;
706  #define FSCALE 1000.0
707  int linewidth = 0;
708  size_micron.x = KiROUND( m_ConstrainedTextSize.x * FSCALE );
709  size_micron.y = KiROUND( m_ConstrainedTextSize.y * FSCALE );
710  WS_DRAW_ITEM_TEXT dummy( WS_DRAW_ITEM_TEXT( this, 0, this->m_FullText, wxPoint( 0, 0 ),
711  size_micron, linewidth, m_Italic, m_Bold ) );
712  dummy.SetMultilineAllowed( true );
713  dummy.SetHorizJustify( m_Hjustify ) ;
714  dummy.SetVertJustify( m_Vjustify );
715  dummy.SetTextAngle( m_Orient * 10 );
716 
717  EDA_RECT rect = dummy.GetTextBox();
718  DSIZE size;
719  size.x = rect.GetWidth() / FSCALE;
720  size.y = rect.GetHeight() / FSCALE;
721 
722  if( m_BoundingBoxSize.x && size.x > m_BoundingBoxSize.x )
724 
725  if( m_BoundingBoxSize.y && size.y > m_BoundingBoxSize.y )
727  }
728 }
729 
730 
732 {
733  std::map<int, STATUS_FLAGS> itemFlags;
734  WS_DRAW_ITEM_BASE* item = nullptr;
735 
736  for( size_t i = 0; i < m_drawItems.size(); ++i )
737  {
738  item = m_drawItems[ i ];
739  itemFlags[ i ] = item->GetFlags();
740 
741  if( aCollector )
742  aCollector->Remove( item );
743 
744  if( aView )
745  aView->Remove( item );
746 
747  delete item;
748  }
749 
750  m_drawItems.clear();
751 
752  for( int j = 0; j < m_RepeatCount; j++ )
753  {
754  if( j && !IsInsidePage( j ) )
755  continue;
756 
757  auto bitmap = new WS_DRAW_ITEM_BITMAP( this, j, GetStartPosUi( j ) );
758  bitmap->SetFlags( itemFlags[ j ] );
759  m_drawItems.push_back( bitmap );
760 
761  if( aCollector )
762  aCollector->Append( bitmap );
763 
764  if( aView )
765  aView->Add( bitmap );
766  }
767 }
768 
769 
771 {
772  if( m_ImageBitmap )
774 
775  return 300;
776 }
777 
778 
779 void WS_DATA_ITEM_BITMAP::SetPPI( int aBitmapPPI )
780 {
781  if( m_ImageBitmap )
782  m_ImageBitmap->SetScale( (double) m_ImageBitmap->GetPPI() / aBitmapPPI );
783 }
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
void SyncDrawItems(WS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView) override
void Remove(WS_DRAW_ITEM_BASE *aItem)
Definition: ws_draw_item.h:460
void MoveToUi(wxPoint aPosition)
move item to a new position
void MoveEndPointToUi(wxPoint aPosition)
move the ending point of the item to a new position has meaning only for items defined by 2 points (s...
const DPOINT GetStartPos(int ii=0) const
Work sheet structure type definitions.
Definition: ws_data_item.h:93
virtual bool IsInsidePage(int ii) const
std::vector< DPOINT > m_Corners
Definition: ws_data_item.h:219
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
Definition: gr_text.cpp:66
void SetScale(double aScale)
Definition: bitmap_base.h:93
double GetScale() const
Definition: bitmap_base.h:92
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
bool IsInsidePage(int ii) const override
int GetWidth() const
Definition: eda_rect.h:119
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 MoveEndPointTo(DPOINT aPosition)
move the ending point of the item to a new position has meaning only for items defined by 2 points (s...
BITMAP_BASE * m_ImageBitmap
Definition: ws_data_item.h:366
POINT_COORD m_End
Definition: ws_data_item.h:116
const wxPoint GetCornerPositionUi(unsigned aIdx, int aRepeat=0) const
void SyncDrawItems(WS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView) override
unsigned GetPolyIndexStart(unsigned aContour) const
Definition: ws_data_item.h:260
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
DSIZE m_DefaultTextSize
Definition: ws_data_model.h:56
unsigned GetPolyIndexEnd(unsigned aContour) const
Definition: ws_data_item.h:272
void Append(WS_DRAW_ITEM_BASE *aItem)
Definition: ws_draw_item.h:455
DPOINT m_LT_Corner
Definition: ws_data_model.h:54
EDA_TEXT_HJUSTIFY_T m_Hjustify
Definition: ws_data_item.h:304
void MoveStartPointTo(DPOINT aPosition)
move the starting point of the item to a new position
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
virtual int GetPenSizeUi()
const wxPoint GetStartPosUi(int ii=0) const
const DPOINT GetEndPos(int ii=0) const
WS_DATA_ITEM(WS_ITEM_TYPE aType)
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:257
WS_ITEM_TYPE m_type
Definition: ws_data_item.h:105
SHAPE_POLY_SET.
DPOINT m_Pos
Definition: ws_data_item.h:71
WS_DATA_ITEM_TEXT(const wxString &aTextBase)
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:187
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 SyncDrawItems(WS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView) override
const wxString GetClassName() const
int NewOutline()
Creates a new empty polygon in the set and returns its index
DPOINT m_IncrementVector
Definition: ws_data_item.h:119
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.h:180
int GetHeight() const
Definition: eda_rect.h:120
void SetTextAngle(double aAngle)
Definition: ws_draw_item.h:295
WS_ITEM_TYPE GetType() const
Definition: ws_data_item.h:147
void MoveStartPointToUi(wxPoint aPosition)
move the starting point of the item to a new position
virtual void SyncDrawItems(WS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView)
double m_LineWidth
Definition: ws_data_item.h:117
const wxPoint GetEndPosUi(int ii=0) const
int GetPolyCount() const
Definition: ws_data_item.h:254
const char * name
Definition: DXF_plotter.cpp:60
double m_DefaultLineWidth
Definition: ws_data_model.h:55
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
double m_WSunits2Iu
Definition: ws_data_model.h:51
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:186
wxString BuildFullText(const wxString &aTextbase)
Function BuildFullText returns the full text corresponding to the aTextbase, after replacing format s...
Definition: ws_painter.cpp:90
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual int GetPenSizeUi() override
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:61
DSIZE m_ConstrainedTextSize
Definition: ws_data_item.h:314
double m_DefaultTextThickness
Definition: ws_data_model.h:57
const DPOINT GetCornerPosition(unsigned aIdx, int aRepeat=0) const
void SetBoundingBox()
calculate the bounding box of the set polygons
void MoveTo(DPOINT aPosition)
move item to a new position
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
void SetPPI(int aBitmapPPI)
PAGE_OPTION m_pageOption
Definition: ws_data_item.h:106
VIEW.
Definition: view.h:61
#define FSCALE
POINT_COORD m_Pos
Definition: ws_data_item.h:115
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:259
int GetDefaultPenSize() const
Definition: ws_draw_item.h:426
int GetPPI() const
Definition: bitmap_base.h:153
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40