KiCad PCB EDA Suite
WS_DRAW_ITEM_LIST Class Reference

#include <ws_draw_item.h>

Public Member Functions

 WS_DRAW_ITEM_LIST ()
 
 ~WS_DRAW_ITEM_LIST ()
 
void SetTitleBlock (const TITLE_BLOCK *aTblock)
 Set the title block (mainly for page layout editor) More...
 
void SetPaperFormat (const wxString *aFormatName)
 Set the paper format name (mainly for page layout editor) More...
 
void SetFileName (const wxString &aFileName)
 Set the filename to draw/plot. More...
 
void SetSheetName (const wxString &aSheetName)
 Set the sheet name to draw/plot. More...
 
void SetSheetLayer (const wxString &aSheetLayer)
 Set the sheet layer to draw/plot. More...
 
void SetDefaultPenSize (int aPenSize)
 
int GetDefaultPenSize () const
 
void SetMilsToIUfactor (double aScale)
 Function SetMilsToIUfactor Set the scalar to convert pages units (mils) to draw/plot units. More...
 
void SetSheetNumber (int aSheetNumber)
 Function SetSheetNumber Set the value of the sheet number, for basic inscriptions. More...
 
void SetSheetCount (int aSheetCount)
 Function SetSheetCount Set the value of the count of sheets, for basic inscriptions. More...
 
void Append (WS_DRAW_ITEM_BASE *aItem)
 
void Remove (WS_DRAW_ITEM_BASE *aItem)
 
WS_DRAW_ITEM_BASEGetFirst ()
 
WS_DRAW_ITEM_BASEGetNext ()
 
void GetAllItems (std::vector< WS_DRAW_ITEM_BASE * > *aList)
 
void Print (wxDC *aDC, COLOR4D aColor)
 Draws the item list created by BuildWorkSheetGraphicList. More...
 
void BuildWorkSheetGraphicList (const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
 Function BuildWorkSheetGraphicList is a core function for drawing or plotting the page layout with the frame and the basic inscriptions. More...
 
wxString BuildFullText (const wxString &aTextbase)
 Function BuildFullText returns the full text corresponding to the aTextbase, after replacing format symbols by the corresponding value. More...
 

Protected Attributes

std::vector< WS_DRAW_ITEM_BASE * > m_graphicList
 
unsigned m_idx
 
double m_milsToIu
 
int m_penSize
 
int m_sheetNumber
 
int m_sheetCount
 
const TITLE_BLOCKm_titleBlock
 
const wxString * m_paperFormat
 
wxString m_fileName
 
wxString m_sheetFullName
 
const wxString * m_sheetLayer
 

Detailed Description

Definition at line 352 of file ws_draw_item.h.

Constructor & Destructor Documentation

◆ WS_DRAW_ITEM_LIST()

WS_DRAW_ITEM_LIST::WS_DRAW_ITEM_LIST ( )
inline

Definition at line 372 of file ws_draw_item.h.

373  {
374  m_idx = 0;
375  m_milsToIu = 1.0;
376  m_penSize = 1;
377  m_sheetNumber = 1;
378  m_sheetCount = 1;
379  m_sheetLayer = nullptr;
380  m_titleBlock = nullptr;
381  m_paperFormat = nullptr;
382  }
const wxString * m_paperFormat
Definition: ws_draw_item.h:365
const TITLE_BLOCK * m_titleBlock
Definition: ws_draw_item.h:364
const wxString * m_sheetLayer
Definition: ws_draw_item.h:368

References m_idx, m_milsToIu, m_paperFormat, m_penSize, m_sheetCount, m_sheetLayer, m_sheetNumber, and m_titleBlock.

◆ ~WS_DRAW_ITEM_LIST()

WS_DRAW_ITEM_LIST::~WS_DRAW_ITEM_LIST ( )
inline

Definition at line 384 of file ws_draw_item.h.

385  {
386  // Items in the m_graphicList are owned by their respective WORKSHEET_DATAITEMs.
387  // for( WS_DRAW_ITEM_BASE* item : m_graphicList )
388  // delete item;
389  }

Member Function Documentation

◆ Append()

void WS_DRAW_ITEM_LIST::Append ( WS_DRAW_ITEM_BASE aItem)
inline

Definition at line 455 of file ws_draw_item.h.

456  {
457  m_graphicList.push_back( aItem );
458  }
std::vector< WS_DRAW_ITEM_BASE * > m_graphicList
Definition: ws_draw_item.h:355

References m_graphicList.

Referenced by WS_DATA_ITEM::SyncDrawItems(), WS_DATA_ITEM_POLYGONS::SyncDrawItems(), WS_DATA_ITEM_TEXT::SyncDrawItems(), and WS_DATA_ITEM_BITMAP::SyncDrawItems().

◆ BuildFullText()

wxString WS_DRAW_ITEM_LIST::BuildFullText ( const wxString &  aTextbase)

Function BuildFullText returns the full text corresponding to the aTextbase, after replacing format symbols by the corresponding value.

Basic texts in Ki_WorkSheetData struct use format notation like "Title %T" to identify at run time the full text to display. Currently format identifier is % followed by a letter or 2 letters

%% = replaced by % K = Kicad version Z = paper format name (A4, USLetter) Y = company name D = date R = revision S = sheet number N = number of sheets Cx = comment (x = 0 to 9 to identify the comment) F = filename P = sheet path or sheet full name T = title Other fields like Developer, Verifier, Approver could use Cx and are seen as comments for format

Parameters
aTextbase= the text with format symbols
Returns
the text, after replacing the format symbols by the actual value

Definition at line 90 of file ws_painter.cpp.

91 {
92  wxString msg;
93 
94  /* Known formats
95  * %% = replaced by %
96  * %K = Kicad version
97  * %Z = paper format name (A4, USLetter)
98  * %Y = company name
99  * %D = date
100  * %R = revision
101  * %S = sheet number
102  * %N = number of sheets
103  * %L = layer name
104  * %Cx = comment (x = 0 to 9 to identify the comment)
105  * %F = filename
106  * %P = sheet path (sheet full name)
107  * %T = title
108  */
109 
110  for( unsigned ii = 0; ii < aTextbase.Len(); ii++ )
111  {
112  if( aTextbase[ii] != '%' )
113  {
114  msg << aTextbase[ii];
115  continue;
116  }
117 
118  if( ++ii >= aTextbase.Len() )
119  break;
120 
121  wxChar format = aTextbase[ii];
122  switch( format )
123  {
124  case '%':
125  msg += '%';
126  break;
127 
128  case 'D':
129  if( m_titleBlock )
130  msg += m_titleBlock->GetDate();
131  break;
132 
133  case 'R':
134  if( m_titleBlock )
135  msg += m_titleBlock->GetRevision();
136  break;
137 
138  case 'K':
139  msg += productName + Pgm().App().GetAppName();
140  msg += wxT( " " ) + GetBuildVersion();
141  break;
142 
143  case 'Z':
144  if( m_paperFormat )
145  msg += *m_paperFormat;
146  break;
147 
148  case 'S':
149  msg << m_sheetNumber;
150  break;
151 
152  case 'N':
153  msg << m_sheetCount;
154  break;
155 
156  case 'F':
157  {
158  wxFileName fn( m_fileName );
159  msg += fn.GetFullName();
160  }
161  break;
162 
163  case 'L':
164  if( m_sheetLayer )
165  msg += *m_sheetLayer;
166  break;
167 
168  case 'P':
169  msg += m_sheetFullName;
170  break;
171 
172  case 'Y':
173  if( m_titleBlock )
174  msg += m_titleBlock->GetCompany();
175  break;
176 
177  case 'T':
178  if( m_titleBlock )
179  msg += m_titleBlock->GetTitle();
180  break;
181 
182  case 'C':
183  format = aTextbase[++ii];
184  switch( format )
185  {
186  case '0':
187  case '1':
188  case '2':
189  case '3':
190  case '4':
191  case '5':
192  case '6':
193  case '7':
194  case '8':
195  case '9':
196  if( m_titleBlock )
197  msg += m_titleBlock->GetComment( format - '0');
198  break;
199 
200  default:
201  break;
202  }
203 
204  default:
205  break;
206  }
207  }
208 
209  return msg;
210 }
const wxString * m_paperFormat
Definition: ws_draw_item.h:365
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
const wxString & GetComment(int aIdx) const
Definition: title_block.h:110
const TITLE_BLOCK * m_titleBlock
Definition: ws_draw_item.h:364
const wxString * m_sheetLayer
Definition: ws_draw_item.h:368
wxString GetBuildVersion()
Get the full KiCad version string.
const wxString & GetRevision() const
Definition: title_block.h:89
const wxString & GetCompany() const
Definition: title_block.h:99
wxString m_sheetFullName
Definition: ws_draw_item.h:367
const wxString & GetDate() const
Definition: title_block.h:79
const wxString & GetTitle() const
Definition: title_block.h:65
static const wxString productName
Definition: ws_painter.cpp:43

References GetBuildVersion(), Pgm(), and productName.

Referenced by WS_DATA_ITEM_TEXT::SyncDrawItems().

◆ BuildWorkSheetGraphicList()

void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList ( const PAGE_INFO aPageInfo,
const TITLE_BLOCK aTitleBlock 
)

Function BuildWorkSheetGraphicList is a core function for drawing or plotting the page layout with the frame and the basic inscriptions.

Before calling this function, some parameters should be initialized by calling: SetPenSize( aPenWidth ); SetMilsToIUfactor( aScalar ); SetSheetNumber( aSheetNumber ); SetSheetCount( aSheetCount ); SetFileName( aFileName ); SetSheetName( aFullSheetName );

Parameters
aPageInfoThe PAGE_INFO, for page size, margins...
aTitleBlockThe sheet title block, for basic inscriptions.
aColorThe color for drawing.
aAltColorThe color for items which need to be "highlighted".

Definition at line 450 of file ws_draw_item.cpp.

452 {
454 
455  m_titleBlock = &aTitleBlock;
456  m_paperFormat = &aPageInfo.GetType();
457 
458  // Build the basic layout shape, if the layout list is empty
459  if( model.GetCount() == 0 && !model.VoidListAllowed() )
460  model.SetPageLayout();
461 
462  model.SetupDrawEnvironment( aPageInfo, m_milsToIu );
463 
464  for( WS_DATA_ITEM* wsItem : model.GetItems() )
465  {
466  // Generate it only if the page option allows this
467  if( wsItem->GetPage1Option() == FIRST_PAGE_ONLY && m_sheetNumber != 1 )
468  continue;
469  else if( wsItem->GetPage1Option() == SUBSEQUENT_PAGES && m_sheetNumber == 1 )
470  continue;
471 
472  wsItem->SyncDrawItems( this, nullptr );
473  }
474 }
WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block.
Definition: ws_data_model.h:39
const wxString * m_paperFormat
Definition: ws_draw_item.h:365
Work sheet structure type definitions.
Definition: ws_data_item.h:93
const TITLE_BLOCK * m_titleBlock
Definition: ws_draw_item.h:364
void SetPageLayout(const wxString &aFullFileName=wxEmptyString, bool Append=false)
Populates the list with a custom layout, or the default layout, if no custom layout available.
const wxString & GetType() const
Definition: page_info.h:97
std::vector< WS_DATA_ITEM * > & GetItems()
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
void SetupDrawEnvironment(const PAGE_INFO &aPageInfo, double aMilsToIU)
bool VoidListAllowed()
unsigned GetCount() const

References FIRST_PAGE_ONLY, WS_DATA_MODEL::GetCount(), WS_DATA_MODEL::GetItems(), WS_DATA_MODEL::GetTheInstance(), PAGE_INFO::GetType(), m_milsToIu, m_paperFormat, m_sheetNumber, m_titleBlock, WS_DATA_MODEL::SetPageLayout(), WS_DATA_MODEL::SetupDrawEnvironment(), SUBSEQUENT_PAGES, and WS_DATA_MODEL::VoidListAllowed().

Referenced by PlotWorkSheet(), and PrintPageLayout().

◆ GetAllItems()

void WS_DRAW_ITEM_LIST::GetAllItems ( std::vector< WS_DRAW_ITEM_BASE * > *  aList)
inline

Definition at line 486 of file ws_draw_item.h.

487  {
488  *aList = m_graphicList;
489  }
std::vector< WS_DRAW_ITEM_BASE * > m_graphicList
Definition: ws_draw_item.h:355

References m_graphicList.

◆ GetDefaultPenSize()

int WS_DRAW_ITEM_LIST::GetDefaultPenSize ( ) const
inline

Definition at line 426 of file ws_draw_item.h.

426 { return m_penSize; }

References m_penSize.

Referenced by WS_DATA_ITEM::SyncDrawItems(), and WS_DATA_ITEM_TEXT::SyncDrawItems().

◆ GetFirst()

WS_DRAW_ITEM_BASE* WS_DRAW_ITEM_LIST::GetFirst ( )
inline

Definition at line 466 of file ws_draw_item.h.

467  {
468  m_idx = 0;
469 
470  if( m_graphicList.size() )
471  return m_graphicList[0];
472  else
473  return NULL;
474  }
#define NULL
std::vector< WS_DRAW_ITEM_BASE * > m_graphicList
Definition: ws_draw_item.h:355

References m_graphicList, m_idx, and NULL.

Referenced by PlotWorkSheet(), and Print().

◆ GetNext()

WS_DRAW_ITEM_BASE* WS_DRAW_ITEM_LIST::GetNext ( )
inline

Definition at line 476 of file ws_draw_item.h.

477  {
478  m_idx++;
479 
480  if( m_graphicList.size() > m_idx )
481  return m_graphicList[m_idx];
482  else
483  return NULL;
484  }
#define NULL
std::vector< WS_DRAW_ITEM_BASE * > m_graphicList
Definition: ws_draw_item.h:355

References m_graphicList, m_idx, and NULL.

Referenced by PlotWorkSheet(), and Print().

◆ Print()

void WS_DRAW_ITEM_LIST::Print ( wxDC *  aDC,
COLOR4D  aColor 
)

Draws the item list created by BuildWorkSheetGraphicList.

Parameters
aDC= the current Device Context

Definition at line 483 of file ws_draw_item.cpp.

484 {
485  std::vector<WS_DRAW_ITEM_BASE*> second_items;
486 
487  for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
488  {
489  if( item->Type() == WSG_BITMAP_T )
490  item->PrintWsItem( aDC, aColor );
491  else
492  second_items.push_back( item );
493  }
494 
495  for( auto item : second_items )
496  item->PrintWsItem( aDC, aColor );
497 }
WS_DRAW_ITEM_BASE * GetNext()
Definition: ws_draw_item.h:476
WS_DRAW_ITEM_BASE * GetFirst()
Definition: ws_draw_item.h:466

References GetFirst(), GetNext(), and WSG_BITMAP_T.

Referenced by PrintPageLayout().

◆ Remove()

void WS_DRAW_ITEM_LIST::Remove ( WS_DRAW_ITEM_BASE aItem)
inline

Definition at line 460 of file ws_draw_item.h.

461  {
462  auto newEnd = std::remove( m_graphicList.begin(), m_graphicList.end(), aItem );
463  m_graphicList.erase( newEnd, m_graphicList.end() );
464  }
std::vector< WS_DRAW_ITEM_BASE * > m_graphicList
Definition: ws_draw_item.h:355

References m_graphicList.

Referenced by WS_DATA_ITEM::SyncDrawItems(), WS_DATA_ITEM_POLYGONS::SyncDrawItems(), WS_DATA_ITEM_TEXT::SyncDrawItems(), and WS_DATA_ITEM_BITMAP::SyncDrawItems().

◆ SetDefaultPenSize()

void WS_DRAW_ITEM_LIST::SetDefaultPenSize ( int  aPenSize)
inline

Definition at line 425 of file ws_draw_item.h.

425 { m_penSize = aPenSize; }

References m_penSize.

Referenced by PlotWorkSheet(), PrintPageLayout(), and KIGFX::WS_PROXY_VIEW_ITEM::ViewDraw().

◆ SetFileName()

void WS_DRAW_ITEM_LIST::SetFileName ( const wxString &  aFileName)
inline

Set the filename to draw/plot.

Definition at line 404 of file ws_draw_item.h.

405  {
406  m_fileName = aFileName;
407  }

References m_fileName.

Referenced by PlotWorkSheet(), and PrintPageLayout().

◆ SetMilsToIUfactor()

void WS_DRAW_ITEM_LIST::SetMilsToIUfactor ( double  aScale)
inline

Function SetMilsToIUfactor Set the scalar to convert pages units (mils) to draw/plot units.

Definition at line 432 of file ws_draw_item.h.

433  {
434  m_milsToIu = aScale;
435  }

References m_milsToIu.

Referenced by PlotWorkSheet(), and PrintPageLayout().

◆ SetPaperFormat()

void WS_DRAW_ITEM_LIST::SetPaperFormat ( const wxString *  aFormatName)
inline

Set the paper format name (mainly for page layout editor)

Definition at line 399 of file ws_draw_item.h.

399 { m_paperFormat = aFormatName; }
const wxString * m_paperFormat
Definition: ws_draw_item.h:365

References m_paperFormat.

◆ SetSheetCount()

void WS_DRAW_ITEM_LIST::SetSheetCount ( int  aSheetCount)
inline

Function SetSheetCount Set the value of the count of sheets, for basic inscriptions.

Definition at line 450 of file ws_draw_item.h.

451  {
452  m_sheetCount = aSheetCount;
453  }

References m_sheetCount.

Referenced by PlotWorkSheet(), and PrintPageLayout().

◆ SetSheetLayer()

void WS_DRAW_ITEM_LIST::SetSheetLayer ( const wxString &  aSheetLayer)
inline

Set the sheet layer to draw/plot.

Definition at line 420 of file ws_draw_item.h.

421  {
422  m_sheetLayer = &aSheetLayer;
423  }
const wxString * m_sheetLayer
Definition: ws_draw_item.h:368

References m_sheetLayer.

Referenced by PrintPageLayout().

◆ SetSheetName()

void WS_DRAW_ITEM_LIST::SetSheetName ( const wxString &  aSheetName)
inline

Set the sheet name to draw/plot.

Definition at line 412 of file ws_draw_item.h.

413  {
414  m_sheetFullName = aSheetName;
415  }
wxString m_sheetFullName
Definition: ws_draw_item.h:367

References m_sheetFullName.

Referenced by PlotWorkSheet(), and PrintPageLayout().

◆ SetSheetNumber()

void WS_DRAW_ITEM_LIST::SetSheetNumber ( int  aSheetNumber)
inline

Function SetSheetNumber Set the value of the sheet number, for basic inscriptions.

Definition at line 441 of file ws_draw_item.h.

442  {
443  m_sheetNumber = aSheetNumber;
444  }

References m_sheetNumber.

Referenced by PlotWorkSheet(), and PrintPageLayout().

◆ SetTitleBlock()

void WS_DRAW_ITEM_LIST::SetTitleBlock ( const TITLE_BLOCK aTblock)
inline

Set the title block (mainly for page layout editor)

Definition at line 394 of file ws_draw_item.h.

394 { m_titleBlock = aTblock; }
const TITLE_BLOCK * m_titleBlock
Definition: ws_draw_item.h:364

References m_titleBlock.

Member Data Documentation

◆ m_fileName

wxString WS_DRAW_ITEM_LIST::m_fileName
protected

Definition at line 366 of file ws_draw_item.h.

Referenced by SetFileName().

◆ m_graphicList

std::vector<WS_DRAW_ITEM_BASE*> WS_DRAW_ITEM_LIST::m_graphicList
protected

Definition at line 355 of file ws_draw_item.h.

Referenced by Append(), GetAllItems(), GetFirst(), GetNext(), and Remove().

◆ m_idx

unsigned WS_DRAW_ITEM_LIST::m_idx
protected

Definition at line 356 of file ws_draw_item.h.

Referenced by GetFirst(), GetNext(), and WS_DRAW_ITEM_LIST().

◆ m_milsToIu

double WS_DRAW_ITEM_LIST::m_milsToIu
protected

Definition at line 357 of file ws_draw_item.h.

Referenced by BuildWorkSheetGraphicList(), SetMilsToIUfactor(), and WS_DRAW_ITEM_LIST().

◆ m_paperFormat

const wxString* WS_DRAW_ITEM_LIST::m_paperFormat
protected

Definition at line 365 of file ws_draw_item.h.

Referenced by BuildWorkSheetGraphicList(), SetPaperFormat(), and WS_DRAW_ITEM_LIST().

◆ m_penSize

int WS_DRAW_ITEM_LIST::m_penSize
protected

Definition at line 359 of file ws_draw_item.h.

Referenced by GetDefaultPenSize(), SetDefaultPenSize(), and WS_DRAW_ITEM_LIST().

◆ m_sheetCount

int WS_DRAW_ITEM_LIST::m_sheetCount
protected

Definition at line 362 of file ws_draw_item.h.

Referenced by SetSheetCount(), and WS_DRAW_ITEM_LIST().

◆ m_sheetFullName

wxString WS_DRAW_ITEM_LIST::m_sheetFullName
protected

Definition at line 367 of file ws_draw_item.h.

Referenced by SetSheetName().

◆ m_sheetLayer

const wxString* WS_DRAW_ITEM_LIST::m_sheetLayer
protected

Definition at line 368 of file ws_draw_item.h.

Referenced by SetSheetLayer(), and WS_DRAW_ITEM_LIST().

◆ m_sheetNumber

int WS_DRAW_ITEM_LIST::m_sheetNumber
protected

Definition at line 361 of file ws_draw_item.h.

Referenced by BuildWorkSheetGraphicList(), SetSheetNumber(), and WS_DRAW_ITEM_LIST().

◆ m_titleBlock

const TITLE_BLOCK* WS_DRAW_ITEM_LIST::m_titleBlock
protected

Definition at line 364 of file ws_draw_item.h.

Referenced by BuildWorkSheetGraphicList(), SetTitleBlock(), and WS_DRAW_ITEM_LIST().


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