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 75 of file ws_painter.cpp.

76 {
77  wxString msg;
78 
79  /* Known formats
80  * %% = replaced by %
81  * %K = Kicad version
82  * %Z = paper format name (A4, USLetter)
83  * %Y = company name
84  * %D = date
85  * %R = revision
86  * %S = sheet number
87  * %N = number of sheets
88  * %L = layer name
89  * %Cx = comment (x = 0 to 9 to identify the comment)
90  * %F = filename
91  * %P = sheet path (sheet full name)
92  * %T = title
93  */
94 
95  for( unsigned ii = 0; ii < aTextbase.Len(); ii++ )
96  {
97  if( aTextbase[ii] != '%' )
98  {
99  msg << aTextbase[ii];
100  continue;
101  }
102 
103  if( ++ii >= aTextbase.Len() )
104  break;
105 
106  wxChar format = aTextbase[ii];
107  switch( format )
108  {
109  case '%':
110  msg += '%';
111  break;
112 
113  case 'D':
114  if( m_titleBlock )
115  msg += m_titleBlock->GetDate();
116  break;
117 
118  case 'R':
119  if( m_titleBlock )
120  msg += m_titleBlock->GetRevision();
121  break;
122 
123  case 'K':
124  msg += productName + Pgm().App().GetAppName();
125  msg += wxT( " " ) + GetBuildVersion();
126  break;
127 
128  case 'Z':
129  if( m_paperFormat )
130  msg += *m_paperFormat;
131  break;
132 
133  case 'S':
134  msg << m_sheetNumber;
135  break;
136 
137  case 'N':
138  msg << m_sheetCount;
139  break;
140 
141  case 'F':
142  {
143  wxFileName fn( m_fileName );
144  msg += fn.GetFullName();
145  }
146  break;
147 
148  case 'L':
149  if( m_sheetLayer )
150  msg += *m_sheetLayer;
151  break;
152 
153  case 'P':
154  msg += m_sheetFullName;
155  break;
156 
157  case 'Y':
158  if( m_titleBlock )
159  msg += m_titleBlock->GetCompany();
160  break;
161 
162  case 'T':
163  if( m_titleBlock )
164  msg += m_titleBlock->GetTitle();
165  break;
166 
167  case 'C':
168  format = aTextbase[++ii];
169  switch( format )
170  {
171  case '0':
172  case '1':
173  case '2':
174  case '3':
175  case '4':
176  case '5':
177  case '6':
178  case '7':
179  case '8':
180  case '9':
181  if( m_titleBlock )
182  msg += m_titleBlock->GetComment( format - '0');
183  break;
184 
185  default:
186  break;
187  }
188 
189  default:
190  break;
191  }
192  }
193 
194  return msg;
195 }
const wxString * m_paperFormat
Definition: ws_draw_item.h:365
const wxString & GetComment(int aIdx) const
Definition: title_block.h:110
VTBL_ENTRY wxApp & App()
Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP,...
Definition: pgm_base.cpp:164
const TITLE_BLOCK * m_titleBlock
Definition: ws_draw_item.h:364
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
const wxString * m_sheetLayer
Definition: ws_draw_item.h:368
wxString GetBuildVersion()
Function GetBuildVersion Return the build 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:42

References PGM_BASE::App(), 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  }
std::vector< WS_DRAW_ITEM_BASE * > m_graphicList
Definition: ws_draw_item.h:355

References m_graphicList, and m_idx.

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  }
std::vector< WS_DRAW_ITEM_BASE * > m_graphicList
Definition: ws_draw_item.h:355

References m_graphicList, and m_idx.

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  for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
486  item->PrintWsItem( aDC, aColor );
487 }
WS_DRAW_ITEM_BASE * GetNext()
Definition: ws_draw_item.h:476
WS_DRAW_ITEM_BASE * GetFirst()
Definition: ws_draw_item.h:466

References GetFirst(), and GetNext().

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: