Import more Alitum parameters.
ADDED CURRENT_DATE titleblock token (to go with existing ISSUE_DATE) ADDED PROJECTNAME schematic token (to go with FILENAME and SHEETNAME) Converts other parameters to project text variables.
This commit is contained in:
parent
c1db5dc0b1
commit
3f165c70e1
|
@ -439,7 +439,8 @@ void DIALOG_PAGES_SETTINGS::OnDateApplyClick( wxCommandEvent& event )
|
|||
{
|
||||
wxDateTime datetime = m_PickDate->GetValue();
|
||||
wxString date =
|
||||
// We can choose different formats. Only one must be uncommented
|
||||
// We can choose different formats. Should probably be kept in sync with CURRENT_DATE
|
||||
// formatting in TITLE_BLOCK.
|
||||
//
|
||||
// datetime.Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
|
||||
// datetime.Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
|
||||
|
|
|
@ -97,6 +97,18 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c
|
|||
*aToken = GetDate();
|
||||
tokenUpdated = true;
|
||||
}
|
||||
else if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) )
|
||||
{
|
||||
// We can choose different formats. Should probably be kept in sync with ISSUE_DATE
|
||||
// formatting in DIALOG_PAGES_SETTINGS.
|
||||
//
|
||||
// *aToken = wxDateTime::Now().Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
|
||||
// *aToken = wxDateTime::Now().Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
|
||||
// *aToken = wxDateTime::Now().Format( wxT("%Y-%b-%d") );
|
||||
*aToken = wxDateTime::Now().FormatISODate();
|
||||
|
||||
tokenUpdated = true;
|
||||
}
|
||||
else if( aToken->IsSameAs( wxT( "REVISION" ) ) )
|
||||
{
|
||||
*aToken = GetRevision();
|
||||
|
|
|
@ -786,21 +786,28 @@ void SCH_ALTIUM_PLUGIN::ParseLabel( const std::map<wxString, wxString>& aPropert
|
|||
{
|
||||
ASCH_LABEL elem( aProperties );
|
||||
|
||||
// TODO: text variable support
|
||||
// TODO: general text variable support
|
||||
|
||||
if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
|
||||
{
|
||||
if( elem.text.StartsWith( "=" ) )
|
||||
{
|
||||
wxString token = elem.text.AfterFirst( '=' ).Lower();
|
||||
wxString token = elem.text.AfterFirst( '=' ).Upper();
|
||||
|
||||
if( token == "sheetnumber" ) elem.text = "${#}";
|
||||
else if( token == "sheettotal" ) elem.text = "${##}";
|
||||
else if( token == "title" ) elem.text = "${TITLE}";
|
||||
else if( token == "projectrev" ) elem.text = "${REVISION}";
|
||||
else if( token == "date" ) elem.text = "${ISSUE_DATE}";
|
||||
else if( token == "companyname" ) elem.text = "${COMPANY}";
|
||||
else if( token == "documentname" ) elem.text = "${FILENAME}";
|
||||
if( token == "SHEETNUMBER" ) elem.text = "${#}";
|
||||
else if( token == "SHEETTOTAL" ) elem.text = "${##}";
|
||||
else if( token == "TITLE" ) elem.text = "${TITLE}";
|
||||
else if( token == "PROJECTREV" ) elem.text = "${REVISION}";
|
||||
else if( token == "DATE" ) elem.text = "${ISSUE_DATE}";
|
||||
else if( token == "CURRENTDATE" ) elem.text = "${CURRENT_DATE}";
|
||||
else if( token == "COMPANYNAME" ) elem.text = "${COMPANY}";
|
||||
else if( token == "DOCUMENTNAME" ) elem.text = "${FILENAME}";
|
||||
else if( token == "PROJECTNAME" ) elem.text = "${PROJECTNAME}";
|
||||
else
|
||||
{
|
||||
if( m_schematic->Prj().GetTextVars().count( token ) )
|
||||
elem.text = wxString::Format( "${%s}", token );
|
||||
}
|
||||
}
|
||||
|
||||
SCH_TEXT* text = new SCH_TEXT( elem.location + m_sheetOffset, elem.text );
|
||||
|
@ -2298,20 +2305,36 @@ void SCH_ALTIUM_PLUGIN::ParseParameter( const std::map<wxString, wxString>& aPro
|
|||
if( elem.text == "*" )
|
||||
return; // indicates parameter not set?
|
||||
|
||||
SCH_SHEET_PATH sheetpath;
|
||||
m_rootSheet->LocatePathOfScreen( m_currentSheet->GetScreen(), &sheetpath );
|
||||
wxString paramName = elem.name.Upper();
|
||||
|
||||
if( paramName == "SHEETNUMBER" )
|
||||
{
|
||||
SCH_SHEET_PATH sheetpath;
|
||||
m_rootSheet->LocatePathOfScreen( m_currentSheet->GetScreen(), &sheetpath );
|
||||
|
||||
if( elem.name == "SheetNumber" )
|
||||
m_rootSheet->SetPageNumber( sheetpath, elem.text );
|
||||
else if( elem.name == "Title" )
|
||||
}
|
||||
else if( paramName == "TITLE" )
|
||||
{
|
||||
m_currentTitleBlock->SetTitle( elem.text );
|
||||
else if( elem.name == "Revision" )
|
||||
}
|
||||
else if( paramName == "REVISION" )
|
||||
{
|
||||
m_currentTitleBlock->SetRevision( elem.text );
|
||||
else if( elem.name == "Date" )
|
||||
}
|
||||
else if( paramName == "DATE" )
|
||||
{
|
||||
m_currentTitleBlock->SetDate( elem.text );
|
||||
else if( elem.name == "CompanyName" )
|
||||
}
|
||||
else if( paramName == "COMPANYNAME" )
|
||||
{
|
||||
m_currentTitleBlock->SetCompany( elem.text );
|
||||
// TODO: parse other parameters
|
||||
}
|
||||
else
|
||||
{
|
||||
m_schematic->Prj().GetTextVars()[ paramName ] = elem.text;
|
||||
}
|
||||
|
||||
// TODO: handle parameters in labels
|
||||
}
|
||||
else
|
||||
|
|
|
@ -145,6 +145,11 @@ bool SCHEMATIC::ResolveTextVar( wxString* token, int aDepth ) const
|
|||
*token = fn.GetFullName();
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "PROJECTNAME" ) ) )
|
||||
{
|
||||
*token = Prj().GetProjectFullName();
|
||||
return true;
|
||||
}
|
||||
|
||||
return CurrentSheet().LastScreen()->GetTitleBlock().TextVarResolver( token, m_project );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue