Formatting.
This commit is contained in:
parent
df8f043c16
commit
c75bb5d01a
|
@ -57,13 +57,11 @@
|
||||||
#include <geometry/ellipse.h>
|
#include <geometry/ellipse.h>
|
||||||
#include <string_utils.h>
|
#include <string_utils.h>
|
||||||
#include <sch_edit_frame.h>
|
#include <sch_edit_frame.h>
|
||||||
#include <trigo.h>
|
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
#include <wx/mstream.h>
|
#include <wx/mstream.h>
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
#include <wx/zstream.h>
|
#include <wx/zstream.h>
|
||||||
#include <wx/wfstream.h>
|
#include <wx/wfstream.h>
|
||||||
#include <trigo.h>
|
|
||||||
#include <magic_enum.hpp>
|
#include <magic_enum.hpp>
|
||||||
|
|
||||||
// Harness port object itself does not contain color information about itself
|
// Harness port object itself does not contain color information about itself
|
||||||
|
@ -134,46 +132,28 @@ static void SetSchShapeFillAndColor( const ASCH_FILL_INTERFACE& elem, SCH_SHAPE*
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void SetLibShapeLine( const ASCH_BORDER_INTERFACE& elem, LIB_SHAPE* shape, ALTIUM_SCH_RECORD aType )
|
static void SetLibShapeLine( const ASCH_BORDER_INTERFACE& elem, LIB_SHAPE* shape,
|
||||||
|
ALTIUM_SCH_RECORD aType )
|
||||||
{
|
{
|
||||||
COLOR4D color = GetColorFromInt( elem.Color );
|
COLOR4D color = GetColorFromInt( elem.Color );
|
||||||
COLOR4D default_color;
|
COLOR4D default_color;
|
||||||
COLOR4D alt_default_color = COLOR4D( PUREBLUE ); // PUREBLUE is used for many objects, so if it is used,
|
COLOR4D alt_default_color = COLOR4D( PUREBLUE ); // PUREBLUE is used for many objects, so if
|
||||||
// we will assume that it should blend with the others
|
// it is used, we will assume that it should
|
||||||
|
// blend with the others
|
||||||
STROKE_PARAMS stroke;
|
STROKE_PARAMS stroke;
|
||||||
|
|
||||||
switch( aType )
|
switch( aType )
|
||||||
{
|
{
|
||||||
case ALTIUM_SCH_RECORD::ARC:
|
case ALTIUM_SCH_RECORD::ARC: default_color = COLOR4D( PUREBLUE ); break;
|
||||||
default_color = COLOR4D( PUREBLUE );
|
case ALTIUM_SCH_RECORD::BEZIER: default_color = COLOR4D( PURERED ); break;
|
||||||
break;
|
case ALTIUM_SCH_RECORD::ELLIPSE: default_color = COLOR4D( PUREBLUE ); break;
|
||||||
case ALTIUM_SCH_RECORD::BEZIER:
|
case ALTIUM_SCH_RECORD::ELLIPTICAL_ARC: default_color = COLOR4D( PUREBLUE ); break;
|
||||||
default_color = COLOR4D( PURERED );
|
case ALTIUM_SCH_RECORD::LINE: default_color = COLOR4D( PUREBLUE ); break;
|
||||||
break;
|
case ALTIUM_SCH_RECORD::POLYGON: default_color = COLOR4D( PUREBLUE ); break;
|
||||||
case ALTIUM_SCH_RECORD::ELLIPSE:
|
case ALTIUM_SCH_RECORD::POLYLINE: default_color = COLOR4D( BLACK ); break;
|
||||||
default_color = COLOR4D( PUREBLUE );
|
case ALTIUM_SCH_RECORD::RECTANGLE: default_color = COLOR4D( 0.5, 0, 0, 1.0 ); break;
|
||||||
break;
|
case ALTIUM_SCH_RECORD::ROUND_RECTANGLE: default_color = COLOR4D( PUREBLUE ); break;
|
||||||
case ALTIUM_SCH_RECORD::ELLIPTICAL_ARC:
|
default: default_color = COLOR4D( PUREBLUE ); break;
|
||||||
default_color = COLOR4D( PUREBLUE );
|
|
||||||
break;
|
|
||||||
case ALTIUM_SCH_RECORD::LINE:
|
|
||||||
default_color = COLOR4D( PUREBLUE );
|
|
||||||
break;
|
|
||||||
case ALTIUM_SCH_RECORD::POLYGON:
|
|
||||||
default_color = COLOR4D( PUREBLUE );
|
|
||||||
break;
|
|
||||||
case ALTIUM_SCH_RECORD::POLYLINE:
|
|
||||||
default_color = COLOR4D( BLACK );
|
|
||||||
break;
|
|
||||||
case ALTIUM_SCH_RECORD::RECTANGLE:
|
|
||||||
default_color = COLOR4D( 0.5, 0, 0, 1.0 );
|
|
||||||
break;
|
|
||||||
case ALTIUM_SCH_RECORD::ROUND_RECTANGLE:
|
|
||||||
default_color = COLOR4D( PUREBLUE );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
default_color = COLOR4D( PUREBLUE );
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( color == default_color || color == alt_default_color )
|
if( color == default_color || color == alt_default_color )
|
||||||
|
@ -202,7 +182,9 @@ static void SetLibShapeFillAndColor( const ASCH_FILL_INTERFACE& elem, LIB_SHAPE*
|
||||||
bgcolor = bgcolor.WithAlpha( 0.5 );
|
bgcolor = bgcolor.WithAlpha( 0.5 );
|
||||||
|
|
||||||
if( !elem.IsSolid )
|
if( !elem.IsSolid )
|
||||||
|
{
|
||||||
shape->SetFillMode( FILL_T::NO_FILL );
|
shape->SetFillMode( FILL_T::NO_FILL );
|
||||||
|
}
|
||||||
else if( elem.AreaColor == aStrokeColor )
|
else if( elem.AreaColor == aStrokeColor )
|
||||||
{
|
{
|
||||||
bgcolor = shape->GetStroke().GetColor();
|
bgcolor = shape->GetStroke().GetColor();
|
||||||
|
@ -210,14 +192,18 @@ static void SetLibShapeFillAndColor( const ASCH_FILL_INTERFACE& elem, LIB_SHAPE*
|
||||||
shape->SetFillMode( FILL_T::FILLED_SHAPE );
|
shape->SetFillMode( FILL_T::FILLED_SHAPE );
|
||||||
}
|
}
|
||||||
else if( bgcolor.WithAlpha( 1.0 ) == default_bgcolor )
|
else if( bgcolor.WithAlpha( 1.0 ) == default_bgcolor )
|
||||||
|
{
|
||||||
shape->SetFillMode( FILL_T::FILLED_WITH_BG_BODYCOLOR );
|
shape->SetFillMode( FILL_T::FILLED_WITH_BG_BODYCOLOR );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
shape->SetFillMode( FILL_T::FILLED_WITH_COLOR );
|
shape->SetFillMode( FILL_T::FILLED_WITH_COLOR );
|
||||||
|
}
|
||||||
|
|
||||||
shape->SetFillColor( bgcolor );
|
shape->SetFillColor( bgcolor );
|
||||||
|
|
||||||
if( elem.AreaColor == aStrokeColor
|
if( elem.AreaColor == aStrokeColor
|
||||||
&& shape->GetStroke().GetWidth() == schIUScale.MilsToIU( 1 ) )
|
&& shape->GetStroke().GetWidth() == schIUScale.MilsToIU( 1 ) )
|
||||||
{
|
{
|
||||||
STROKE_PARAMS stroke = shape->GetStroke();
|
STROKE_PARAMS stroke = shape->GetStroke();
|
||||||
stroke.SetWidth( -1 );
|
stroke.SetWidth( -1 );
|
||||||
|
@ -243,9 +229,7 @@ SCH_IO_ALTIUM::~SCH_IO_ALTIUM()
|
||||||
for( auto& [libName, lib] : m_libCache )
|
for( auto& [libName, lib] : m_libCache )
|
||||||
{
|
{
|
||||||
for( auto& [name, symbol] : lib )
|
for( auto& [name, symbol] : lib )
|
||||||
{
|
|
||||||
delete symbol;
|
delete symbol;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +299,7 @@ wxFileName SCH_IO_ALTIUM::getLibFileName()
|
||||||
|
|
||||||
|
|
||||||
SCH_SHEET* SCH_IO_ALTIUM::LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
|
SCH_SHEET* SCH_IO_ALTIUM::LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
|
||||||
SCH_SHEET* aAppendToMe,
|
SCH_SHEET* aAppendToMe,
|
||||||
const STRING_UTF8_MAP* aProperties )
|
const STRING_UTF8_MAP* aProperties )
|
||||||
{
|
{
|
||||||
wxCHECK( !aFileName.IsEmpty() && aSchematic, nullptr );
|
wxCHECK( !aFileName.IsEmpty() && aSchematic, nullptr );
|
||||||
|
@ -467,7 +451,8 @@ void SCH_IO_ALTIUM::ParseAltiumSch( const wxString& aFileName )
|
||||||
{
|
{
|
||||||
// Try case-insensitive search
|
// Try case-insensitive search
|
||||||
wxArrayString files;
|
wxArrayString files;
|
||||||
wxDir::GetAllFiles( parentFileName.GetPath(), &files, wxEmptyString, wxDIR_FILES | wxDIR_HIDDEN );
|
wxDir::GetAllFiles( parentFileName.GetPath(), &files, wxEmptyString,
|
||||||
|
wxDIR_FILES | wxDIR_HIDDEN );
|
||||||
|
|
||||||
for( const wxString& candidate : files )
|
for( const wxString& candidate : files )
|
||||||
{
|
{
|
||||||
|
@ -543,9 +528,7 @@ void SCH_IO_ALTIUM::ParseStorage( const ALTIUM_COMPOUND_FILE& aAltiumSchFile )
|
||||||
THROW_IO_ERROR( "Storage weight is negative!" );
|
THROW_IO_ERROR( "Storage weight is negative!" );
|
||||||
|
|
||||||
for( int i = 0; i < weight; i++ )
|
for( int i = 0; i < weight; i++ )
|
||||||
{
|
|
||||||
m_altiumStorage.emplace_back( reader );
|
m_altiumStorage.emplace_back( reader );
|
||||||
}
|
|
||||||
|
|
||||||
if( reader.HasParsingError() )
|
if( reader.HasParsingError() )
|
||||||
THROW_IO_ERROR( "stream was not parsed correctly!" );
|
THROW_IO_ERROR( "stream was not parsed correctly!" );
|
||||||
|
@ -692,8 +675,7 @@ void SCH_IO_ALTIUM::ParseFileHeader( const ALTIUM_COMPOUND_FILE& aAltiumSchFile
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ALTIUM_SCH_RECORD::IEEE_SYMBOL:
|
case ALTIUM_SCH_RECORD::IEEE_SYMBOL:
|
||||||
m_reporter->Report( _( "Record 'IEEE_SYMBOL' not handled." ),
|
m_reporter->Report( _( "Record 'IEEE_SYMBOL' not handled." ), RPT_SEVERITY_INFO );
|
||||||
RPT_SEVERITY_INFO );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ALTIUM_SCH_RECORD::LABEL:
|
case ALTIUM_SCH_RECORD::LABEL:
|
||||||
|
@ -717,8 +699,7 @@ void SCH_IO_ALTIUM::ParseFileHeader( const ALTIUM_COMPOUND_FILE& aAltiumSchFile
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ALTIUM_SCH_RECORD::PIECHART:
|
case ALTIUM_SCH_RECORD::PIECHART:
|
||||||
m_reporter->Report( _( "Record 'PIECHART' not handled." ),
|
m_reporter->Report( _( "Record 'PIECHART' not handled." ), RPT_SEVERITY_INFO );
|
||||||
RPT_SEVERITY_INFO );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ALTIUM_SCH_RECORD::ROUND_RECTANGLE:
|
case ALTIUM_SCH_RECORD::ROUND_RECTANGLE:
|
||||||
|
@ -933,8 +914,7 @@ const ASCH_STORAGE_FILE* SCH_IO_ALTIUM::GetFileFromStorage( const wxString& aFil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_IO_ALTIUM::ParseComponent( int aIndex,
|
void SCH_IO_ALTIUM::ParseComponent( int aIndex, const std::map<wxString, wxString>& aProperties )
|
||||||
const std::map<wxString, wxString>& aProperties )
|
|
||||||
{
|
{
|
||||||
SCH_SHEET* currentSheet = m_sheetPath.Last();
|
SCH_SHEET* currentSheet = m_sheetPath.Last();
|
||||||
wxCHECK( currentSheet, /* void */ );
|
wxCHECK( currentSheet, /* void */ );
|
||||||
|
@ -2141,7 +2121,7 @@ void SCH_IO_ALTIUM::ParseEllipticalArc( const std::map<wxString, wxString>& aPro
|
||||||
// TODO: e.g. can depend on Template (RECORD=39
|
// TODO: e.g. can depend on Template (RECORD=39
|
||||||
m_reporter->Report( wxString::Format( wxT( "Elliptical Arc's owner (%d) not found." ),
|
m_reporter->Report( wxString::Format( wxT( "Elliptical Arc's owner (%d) not found." ),
|
||||||
elem.ownerindex ),
|
elem.ownerindex ),
|
||||||
RPT_SEVERITY_DEBUG );
|
RPT_SEVERITY_DEBUG );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3064,8 +3044,8 @@ void SCH_IO_ALTIUM::ParsePowerPort( const std::map<wxString, wxString>& aPropert
|
||||||
pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
|
pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
|
||||||
pin->SetVisible( false );
|
pin->SetVisible( false );
|
||||||
|
|
||||||
VECTOR2I valueFieldPos =
|
VECTOR2I valueFieldPos = HelperGeneratePowerPortGraphics( libSymbol, elem.style,
|
||||||
HelperGeneratePowerPortGraphics( libSymbol, elem.style, m_reporter );
|
m_reporter );
|
||||||
|
|
||||||
libSymbol->GetValueField().SetPosition( valueFieldPos );
|
libSymbol->GetValueField().SetPosition( valueFieldPos );
|
||||||
|
|
||||||
|
@ -3249,32 +3229,21 @@ void SCH_IO_ALTIUM::ParsePort( const ASCH_PORT& aElem )
|
||||||
SCH_LABEL_BASE* label;
|
SCH_LABEL_BASE* label;
|
||||||
|
|
||||||
// TODO: detect correct label type depending on sheet settings, etc.
|
// TODO: detect correct label type depending on sheet settings, etc.
|
||||||
#if 1 // Set to 1 to use SCH_HIERLABEL label, 0 to use SCH_GLOBALLABEL
|
#if 1 // Set to 1 to use SCH_HIERLABEL label, 0 to use SCH_GLOBALLABEL
|
||||||
{
|
{
|
||||||
label = new SCH_HIERLABEL( position, aElem.Name );
|
label = new SCH_HIERLABEL( position, aElem.Name );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
label = new SCH_GLOBALLABEL( position, aElem.Name );
|
label = new SCH_GLOBALLABEL( position, aElem.Name );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch( aElem.IOtype )
|
switch( aElem.IOtype )
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ASCH_PORT_IOTYPE::UNSPECIFIED:
|
case ASCH_PORT_IOTYPE::UNSPECIFIED: label->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); break;
|
||||||
label->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
|
case ASCH_PORT_IOTYPE::OUTPUT: label->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT ); break;
|
||||||
break;
|
case ASCH_PORT_IOTYPE::INPUT: label->SetShape( LABEL_FLAG_SHAPE::L_INPUT ); break;
|
||||||
|
case ASCH_PORT_IOTYPE::BIDI: label->SetShape( LABEL_FLAG_SHAPE::L_BIDI ); break;
|
||||||
case ASCH_PORT_IOTYPE::OUTPUT:
|
|
||||||
label->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ASCH_PORT_IOTYPE::INPUT:
|
|
||||||
label->SetShape( LABEL_FLAG_SHAPE::L_INPUT );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ASCH_PORT_IOTYPE::BIDI:
|
|
||||||
label->SetShape( LABEL_FLAG_SHAPE::L_BIDI );
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( aElem.Style )
|
switch( aElem.Style )
|
||||||
|
@ -3288,6 +3257,7 @@ void SCH_IO_ALTIUM::ParsePort( const ASCH_PORT& aElem )
|
||||||
label->SetSpinStyle( SPIN_STYLE::RIGHT );
|
label->SetSpinStyle( SPIN_STYLE::RIGHT );
|
||||||
else
|
else
|
||||||
label->SetSpinStyle( SPIN_STYLE::LEFT );
|
label->SetSpinStyle( SPIN_STYLE::LEFT );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ASCH_PORT_STYLE::NONE_VERTICAL:
|
case ASCH_PORT_STYLE::NONE_VERTICAL:
|
||||||
|
@ -3298,6 +3268,7 @@ void SCH_IO_ALTIUM::ParsePort( const ASCH_PORT& aElem )
|
||||||
label->SetSpinStyle( SPIN_STYLE::UP );
|
label->SetSpinStyle( SPIN_STYLE::UP );
|
||||||
else
|
else
|
||||||
label->SetSpinStyle( SPIN_STYLE::BOTTOM );
|
label->SetSpinStyle( SPIN_STYLE::BOTTOM );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3393,8 +3364,8 @@ void SCH_IO_ALTIUM::ParseWire( const std::map<wxString, wxString>& aProperties )
|
||||||
|
|
||||||
for( size_t i = 0; i + 1 < elem.points.size(); i++ )
|
for( size_t i = 0; i + 1 < elem.points.size(); i++ )
|
||||||
{
|
{
|
||||||
SCH_LINE* wire =
|
SCH_LINE* wire = new SCH_LINE( elem.points.at( i ) + m_sheetOffset,
|
||||||
new SCH_LINE( elem.points.at( i ) + m_sheetOffset, SCH_LAYER_ID::LAYER_WIRE );
|
SCH_LAYER_ID::LAYER_WIRE );
|
||||||
wire->SetEndPoint( elem.points.at( i + 1 ) + m_sheetOffset );
|
wire->SetEndPoint( elem.points.at( i + 1 ) + m_sheetOffset );
|
||||||
wire->SetLineWidth( elem.lineWidth );
|
wire->SetLineWidth( elem.lineWidth );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue