KiCad PCB EDA Suite
TITLE_BLOCK Class Reference

Hold the information shown in the lower right corner of a plot, printout, or editing view. More...

#include <title_block.h>

Public Member Functions

 TITLE_BLOCK ()
 
virtual ~TITLE_BLOCK ()
 
void SetTitle (const wxString &aTitle)
 
const wxString & GetTitle () const
 
void SetDate (const wxString &aDate)
 Set the date field, and defaults to the current time and date. More...
 
const wxString & GetDate () const
 
void SetRevision (const wxString &aRevision)
 
const wxString & GetRevision () const
 
void SetCompany (const wxString &aCompany)
 
const wxString & GetCompany () const
 
void SetComment (int aIdx, const wxString &aComment)
 
const wxString & GetComment (int aIdx) const
 
void Clear ()
 
bool TextVarResolver (wxString *aToken, const PROJECT *aProject) const
 
virtual void Format (OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
 Output the object to aFormatter in s-expression form. More...
 

Static Public Member Functions

static void GetContextualTextVars (wxArrayString *aVars)
 

Private Types

enum  TEXTS_IDX {
  TITLE_IDX = 0 , DATE_IDX , REVISION_IDX , COMPANY_IDX ,
  COMMENT1_IDX
}
 

Private Member Functions

void setTbText (int aIdx, const wxString &aText)
 
const wxString & getTbText (int aIdx) const
 

Private Attributes

wxArrayString m_tbTexts
 

Detailed Description

Hold the information shown in the lower right corner of a plot, printout, or editing view.

Definition at line 40 of file title_block.h.

Member Enumeration Documentation

◆ TEXTS_IDX

enum TITLE_BLOCK::TEXTS_IDX
private
Enumerator
TITLE_IDX 
DATE_IDX 
REVISION_IDX 
COMPANY_IDX 
COMMENT1_IDX 

Definition at line 44 of file title_block.h.

45 {
46 TITLE_IDX = 0,
50 COMMENT1_IDX // idx of the first comment: one can have more than 1 comment
51 };

Constructor & Destructor Documentation

◆ TITLE_BLOCK()

TITLE_BLOCK::TITLE_BLOCK ( )
inline

Definition at line 54 of file title_block.h.

54{};

◆ ~TITLE_BLOCK()

virtual TITLE_BLOCK::~TITLE_BLOCK ( )
inlinevirtual

Definition at line 55 of file title_block.h.

55{}; // a virtual dtor seems needed to build

Member Function Documentation

◆ Clear()

void TITLE_BLOCK::Clear ( )
inline

Definition at line 113 of file title_block.h.

114 {
115 m_tbTexts.Clear();
116 }
wxArrayString m_tbTexts
Definition: title_block.h:132

References m_tbTexts.

Referenced by SCH_SCREEN::Clear().

◆ Format()

void TITLE_BLOCK::Format ( OUTPUTFORMATTER aFormatter,
int  aNestLevel,
int  aControlBits 
) const
virtual

Output the object to aFormatter in s-expression form.

Parameters
aFormatterThe OUTPUTFORMATTER object to write to.
aNestLevelThe indentation next level.
aControlBitsThe control bit definition for object specific formatting.
Exceptions
IO_ERRORon write error.

Definition at line 30 of file title_block.cpp.

31{
32 // Don't write the title block information if there is nothing to write.
33 bool isempty = true;
34 for( unsigned idx = 0; idx < m_tbTexts.GetCount(); idx++ )
35 {
36 if( ! m_tbTexts[idx].IsEmpty() )
37 {
38 isempty = false;
39 break;
40 }
41 }
42
43 if( !isempty )
44 {
45 aFormatter->Print( aNestLevel, "(title_block\n" );
46
47 if( !GetTitle().IsEmpty() )
48 aFormatter->Print( aNestLevel+1, "(title %s)\n",
49 aFormatter->Quotew( GetTitle() ).c_str() );
50
51 if( !GetDate().IsEmpty() )
52 aFormatter->Print( aNestLevel+1, "(date %s)\n",
53 aFormatter->Quotew( GetDate() ).c_str() );
54
55 if( !GetRevision().IsEmpty() )
56 aFormatter->Print( aNestLevel+1, "(rev %s)\n",
57 aFormatter->Quotew( GetRevision() ).c_str() );
58
59 if( !GetCompany().IsEmpty() )
60 aFormatter->Print( aNestLevel+1, "(company %s)\n",
61 aFormatter->Quotew( GetCompany() ).c_str() );
62
63 for( int ii = 0; ii < 9; ii++ )
64 {
65 if( !GetComment(ii).IsEmpty() )
66 aFormatter->Print( aNestLevel+1, "(comment %d %s)\n", ii+1,
67 aFormatter->Quotew( GetComment(ii) ).c_str() );
68 }
69
70 aFormatter->Print( aNestLevel, ")\n\n" );
71 }
72}
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:499
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:431
const wxString & GetCompany() const
Definition: title_block.h:96
const wxString & GetRevision() const
Definition: title_block.h:86
const wxString & GetDate() const
Definition: title_block.h:76
const wxString & GetComment(int aIdx) const
Definition: title_block.h:107
const wxString & GetTitle() const
Definition: title_block.h:63

References GetComment(), GetCompany(), GetDate(), GetRevision(), GetTitle(), m_tbTexts, OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

Referenced by SCH_SEXPR_PLUGIN::Format(), and PCB_PLUGIN::formatGeneral().

◆ GetComment()

const wxString & TITLE_BLOCK::GetComment ( int  aIdx) const
inline

◆ GetCompany()

const wxString & TITLE_BLOCK::GetCompany ( ) const
inline

◆ GetContextualTextVars()

void TITLE_BLOCK::GetContextualTextVars ( wxArrayString *  aVars)
static

Definition at line 74 of file title_block.cpp.

75{
76 if( !alg::contains( *aVars, wxT( "ISSUE_DATE" ) ) )
77 {
78 aVars->push_back( wxT( "ISSUE_DATE" ) );
79 aVars->push_back( wxT( "REVISION" ) );
80 aVars->push_back( wxT( "TITLE" ) );
81 aVars->push_back( wxT( "COMPANY" ) );
82 aVars->push_back( wxT( "COMMENT1" ) );
83 aVars->push_back( wxT( "COMMENT2" ) );
84 aVars->push_back( wxT( "COMMENT3" ) );
85 aVars->push_back( wxT( "COMMENT4" ) );
86 aVars->push_back( wxT( "COMMENT5" ) );
87 aVars->push_back( wxT( "COMMENT6" ) );
88 aVars->push_back( wxT( "COMMENT7" ) );
89 aVars->push_back( wxT( "COMMENT8" ) );
90 aVars->push_back( wxT( "COMMENT9" ) );
91 }
92}
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99

References alg::contains().

Referenced by SCH_SHEET::GetContextualTextVars(), and DS_DRAW_ITEM_LIST::GetTextVars().

◆ GetDate()

◆ GetRevision()

◆ getTbText()

const wxString & TITLE_BLOCK::getTbText ( int  aIdx) const
inlineprivate

Definition at line 142 of file title_block.h.

143 {
144 static const wxString m_emptytext;
145
146 if( (int)m_tbTexts.GetCount() > aIdx )
147 return m_tbTexts[aIdx];
148 else
149 return m_emptytext;
150 }

References m_tbTexts.

Referenced by GetComment(), GetCompany(), GetDate(), GetRevision(), and GetTitle().

◆ GetTitle()

◆ SetComment()

◆ SetCompany()

◆ SetDate()

◆ SetRevision()

◆ setTbText()

void TITLE_BLOCK::setTbText ( int  aIdx,
const wxString &  aText 
)
inlineprivate

Definition at line 134 of file title_block.h.

135 {
136 if( (int)m_tbTexts.GetCount() <= aIdx )
137 m_tbTexts.Add( wxEmptyString, aIdx + 1 - m_tbTexts.GetCount() );
138
139 m_tbTexts[aIdx] = aText;
140 }

References m_tbTexts.

Referenced by SetComment(), SetCompany(), SetDate(), SetRevision(), and SetTitle().

◆ SetTitle()

◆ TextVarResolver()

bool TITLE_BLOCK::TextVarResolver ( wxString *  aToken,
const PROJECT aProject 
) const

Definition at line 95 of file title_block.cpp.

96{
97 bool tokenUpdated = false;
98 wxString originalToken = *aToken;
99
100 if( aToken->IsSameAs( wxT( "ISSUE_DATE" ) ) )
101 {
102 *aToken = GetDate();
103 tokenUpdated = true;
104 }
105 else if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) )
106 {
107 // We can choose different formats. Should probably be kept in sync with ISSUE_DATE
108 // formatting in DIALOG_PAGES_SETTINGS.
109 //
110 // *aToken = wxDateTime::Now().Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
111 // *aToken = wxDateTime::Now().Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
112 // *aToken = wxDateTime::Now().Format( wxT("%Y-%b-%d") );
113 *aToken = wxDateTime::Now().FormatISODate();
114
115 tokenUpdated = true;
116 }
117 else if( aToken->IsSameAs( wxT( "REVISION" ) ) )
118 {
119 *aToken = GetRevision();
120 tokenUpdated = true;
121 }
122 else if( aToken->IsSameAs( wxT( "TITLE" ) ) )
123 {
124 *aToken = GetTitle();
125 tokenUpdated = true;
126 }
127 else if( aToken->IsSameAs( wxT( "COMPANY" ) ) )
128 {
129 *aToken = GetCompany();
130 tokenUpdated = true;
131 }
132 else if( aToken->Left( aToken->Len() - 1 ).IsSameAs( wxT( "COMMENT" ) ) )
133 {
134 wxChar c = aToken->Last();
135
136 switch( c )
137 {
138 case '1':
139 case '2':
140 case '3':
141 case '4':
142 case '5':
143 case '6':
144 case '7':
145 case '8':
146 case '9':
147 *aToken = GetComment( c - '1' );
148 tokenUpdated = true;
149 }
150 }
151
152 if( tokenUpdated )
153 {
154 *aToken = ExpandTextVars( *aToken, aProject );
155
156 // This is the default fallback, so don't claim we resolved it
157 if( *aToken == wxT( "${" ) + originalToken + wxT( "}" ) )
158 return false;
159
160 return true;
161 }
162
163 return false;
164}
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:57

References ExpandTextVars(), GetComment(), GetCompany(), GetDate(), GetRevision(), and GetTitle().

Referenced by SCHEMATIC::ResolveTextVar(), and SCH_SHEET::ResolveTextVar().

Member Data Documentation

◆ m_tbTexts

wxArrayString TITLE_BLOCK::m_tbTexts
private

Definition at line 132 of file title_block.h.

Referenced by Clear(), Format(), getTbText(), and setTbText().


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