Use explicit booleans for schematic format
This commit is contained in:
parent
ae13a46ace
commit
786a4ce675
|
@ -904,10 +904,10 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
|
|||
}
|
||||
|
||||
if( IsBold() )
|
||||
aFormatter->Print( 0, " bold" );
|
||||
aFormatter->Print( 0, " (bold yes)" );
|
||||
|
||||
if( IsItalic() )
|
||||
aFormatter->Print( 0, " italic" );
|
||||
aFormatter->Print( 0, " (italic yes)" );
|
||||
|
||||
if( GetTextColor() != COLOR4D::UNSPECIFIED )
|
||||
{
|
||||
|
@ -938,7 +938,7 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
|
|||
}
|
||||
|
||||
if( !( aControlBits & CTL_OMIT_HIDE ) && !IsVisible() )
|
||||
aFormatter->Print( 0, " hide" );
|
||||
aFormatter->Print( 0, " (hide yes)" );
|
||||
|
||||
if( HasHyperlink() )
|
||||
{
|
||||
|
|
|
@ -134,6 +134,40 @@ bool SCH_SEXPR_PARSER::parseBool()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* e.g. "hide", "hide)", "(hide yes)"
|
||||
*/
|
||||
bool SCH_SEXPR_PARSER::parseMaybeAbsentBool( bool aDefaultValue )
|
||||
{
|
||||
bool ret = aDefaultValue;
|
||||
|
||||
if( PrevTok() == T_LEFT )
|
||||
{
|
||||
T token = NextTok();
|
||||
|
||||
// "hide)"
|
||||
if( static_cast<int>( token ) == DSN_RIGHT )
|
||||
return aDefaultValue;
|
||||
|
||||
if( token == T_yes )
|
||||
ret = true;
|
||||
else if( token == T_no )
|
||||
ret = false;
|
||||
else
|
||||
Expecting( "yes or no" );
|
||||
|
||||
NeedRIGHT();
|
||||
}
|
||||
else
|
||||
{
|
||||
// "hide"
|
||||
return aDefaultValue;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void SCH_SEXPR_PARSER::ParseLib( LIB_SYMBOL_MAP& aSymbolLibMap )
|
||||
{
|
||||
T token;
|
||||
|
@ -699,12 +733,18 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta
|
|||
break;
|
||||
|
||||
case T_bold:
|
||||
aText->SetBold( true );
|
||||
{
|
||||
bool bold = parseMaybeAbsentBool( true );
|
||||
aText->SetBold( bold );
|
||||
break;
|
||||
}
|
||||
|
||||
case T_italic:
|
||||
aText->SetItalic( true );
|
||||
{
|
||||
bool italic = parseMaybeAbsentBool( true );
|
||||
aText->SetItalic( italic );
|
||||
break;
|
||||
}
|
||||
|
||||
case T_color:
|
||||
color.r = parseInt( "red" ) / 255.0;
|
||||
|
@ -770,8 +810,11 @@ void SCH_SEXPR_PARSER::parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSynta
|
|||
break;
|
||||
|
||||
case T_hide:
|
||||
aText->SetVisible( false );
|
||||
{
|
||||
bool hide = parseMaybeAbsentBool( true );
|
||||
aText->SetVisible( !hide );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
Expecting( "font, justify, hide or href" );
|
||||
|
@ -917,14 +960,18 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol
|
|||
break;
|
||||
|
||||
case T_show_name:
|
||||
field->SetNameShown();
|
||||
NeedRIGHT();
|
||||
{
|
||||
bool show = parseMaybeAbsentBool( true );
|
||||
field->SetNameShown( show );
|
||||
break;
|
||||
}
|
||||
|
||||
case T_do_not_autoplace:
|
||||
field->SetCanAutoplace( false );
|
||||
NeedRIGHT();
|
||||
{
|
||||
bool doNotAutoplace = parseMaybeAbsentBool( true );
|
||||
field->SetCanAutoplace( !doNotAutoplace );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
Expecting( "id, at, show_name, do_not_autoplace, or effects" );
|
||||
|
@ -2121,14 +2168,18 @@ SCH_FIELD* SCH_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent )
|
|||
break;
|
||||
|
||||
case T_show_name:
|
||||
field->SetNameShown();
|
||||
NeedRIGHT();
|
||||
{
|
||||
bool show = parseMaybeAbsentBool( true );
|
||||
field->SetNameShown( show );
|
||||
break;
|
||||
}
|
||||
|
||||
case T_do_not_autoplace:
|
||||
field->SetCanAutoplace( false );
|
||||
NeedRIGHT();
|
||||
{
|
||||
bool doNotAutoplace = parseMaybeAbsentBool( true );
|
||||
field->SetCanAutoplace( !doNotAutoplace );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
Expecting( "id, at, show_name, do_not_autoplace or effects" );
|
||||
|
@ -2862,8 +2913,9 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol()
|
|||
break;
|
||||
|
||||
case T_fields_autoplaced:
|
||||
symbol->SetFieldsAutoplaced();
|
||||
NeedRIGHT();
|
||||
if( parseMaybeAbsentBool( true ) )
|
||||
symbol->SetFieldsAutoplaced();
|
||||
|
||||
break;
|
||||
|
||||
case T_uuid:
|
||||
|
@ -3225,8 +3277,9 @@ SCH_SHEET* SCH_SEXPR_PARSER::parseSheet()
|
|||
}
|
||||
|
||||
case T_fields_autoplaced:
|
||||
sheet->SetFieldsAutoplaced();
|
||||
NeedRIGHT();
|
||||
if( parseMaybeAbsentBool( true ) )
|
||||
sheet->SetFieldsAutoplaced();
|
||||
|
||||
break;
|
||||
|
||||
case T_stroke:
|
||||
|
@ -3994,8 +4047,9 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
|
|||
break;
|
||||
|
||||
case T_fields_autoplaced:
|
||||
text->SetFieldsAutoplaced();
|
||||
NeedRIGHT();
|
||||
if( parseMaybeAbsentBool( true ) )
|
||||
text->SetFieldsAutoplaced();
|
||||
|
||||
break;
|
||||
|
||||
case T_effects:
|
||||
|
|
|
@ -158,6 +158,18 @@ private:
|
|||
|
||||
bool parseBool();
|
||||
|
||||
/**
|
||||
* Parses a boolean flag inside a list that existed before boolean normalization.
|
||||
*
|
||||
* For example, this will handle both (legacy_teardrops) and (legacy_teardrops yes).
|
||||
* Call this after parsing the T_legacy_teardrops, and aDefaultValue will be returned for the
|
||||
* first case, or true will be returned for the second case.
|
||||
*
|
||||
* @param aDefaultValue will be returned if the end of the list is encountered as the next token
|
||||
* @return the parsed boolean
|
||||
*/
|
||||
bool parseMaybeAbsentBool( bool aDefaultValue );
|
||||
|
||||
LIB_SYMBOL* parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLibMap );
|
||||
|
||||
/**
|
||||
|
|
|
@ -735,7 +735,7 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSchema
|
|||
m_out->Print( 0, " (dnp %s)", ( aSymbol->GetDNP() ) ? "yes" : "no" );
|
||||
|
||||
if( aSymbol->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
|
||||
m_out->Print( 0, " (fields_autoplaced)" );
|
||||
m_out->Print( 0, " (fields_autoplaced yes)" );
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
|
||||
|
@ -902,10 +902,10 @@ void SCH_SEXPR_PLUGIN::saveField( SCH_FIELD* aField, int aNestLevel )
|
|||
EDA_UNIT_UTILS::FormatAngle( aField->GetTextAngle() ).c_str() );
|
||||
|
||||
if( aField->IsNameShown() )
|
||||
m_out->Print( 0, " (show_name)" );
|
||||
m_out->Print( 0, " (show_name yes)" );
|
||||
|
||||
if( !aField->CanAutoplace() )
|
||||
m_out->Print( 0, " (do_not_autoplace)" );
|
||||
m_out->Print( 0, " (do_not_autoplace yes)" );
|
||||
|
||||
if( !aField->IsDefaultFormatting()
|
||||
|| ( aField->GetTextHeight() != schIUScale.MilsToIU( DEFAULT_SIZE_TEXT ) ) )
|
||||
|
@ -990,7 +990,7 @@ void SCH_SEXPR_PLUGIN::saveSheet( SCH_SHEET* aSheet, int aNestLevel )
|
|||
aSheet->GetSize().y ).c_str() );
|
||||
|
||||
if( aSheet->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
|
||||
m_out->Print( 0, " (fields_autoplaced)" );
|
||||
m_out->Print( 0, " (fields_autoplaced yes)" );
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
|
||||
|
@ -1325,7 +1325,7 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel )
|
|||
}
|
||||
|
||||
if( aText->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
|
||||
m_out->Print( 0, " (fields_autoplaced)" );
|
||||
m_out->Print( 0, " (fields_autoplaced yes)" );
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
aText->EDA_TEXT::Format( m_out, aNestLevel, 0 );
|
||||
|
|
Loading…
Reference in New Issue