From 951fd2d6935bbc95055e07f92ff7f86abe716b09 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Mon, 11 Sep 2023 18:33:34 +0300 Subject: [PATCH] Altium schematic: support Line dash styles and colors. Master commit: a2b7bf97b9ef24d51b8d6f30ddeb5afa473149df --- .../sch_plugins/altium/altium_parser_sch.cpp | 19 +++++++------------ .../sch_plugins/altium/altium_parser_sch.h | 5 ++++- .../sch_plugins/altium/sch_altium_plugin.cpp | 9 +++++++-- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/eeschema/sch_plugins/altium/altium_parser_sch.cpp b/eeschema/sch_plugins/altium/altium_parser_sch.cpp index 1b207f16ca..64ab567675 100644 --- a/eeschema/sch_plugins/altium/altium_parser_sch.cpp +++ b/eeschema/sch_plugins/altium/altium_parser_sch.cpp @@ -331,13 +331,8 @@ ASCH_POLYLINE::ASCH_POLYLINE( const std::map& aProps ) LineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" ); Color = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 ); - int linestyleVar = ALTIUM_PARSER::ReadInt( aProps, "LINESTYLEEXT", 0 ); - - // overwrite if present. - linestyleVar = ALTIUM_PARSER::ReadInt( aProps, "LINESTYLE", linestyleVar ); - LineStyle = linestyleVar >= 0 && linestyleVar <= 3 ? - static_cast( linestyleVar ) : - ASCH_POLYLINE_LINESTYLE::SOLID; + auto lineStyleExt = ReadEnum( aProps, "LINESTYLEEXT", 0, 3, ASCH_POLYLINE_LINESTYLE::SOLID ); + LineStyle = ReadEnum( aProps, "LINESTYLE", 0, 3, lineStyleExt ); // overwrite if present. } @@ -447,7 +442,11 @@ ASCH_LINE::ASCH_LINE( const std::map& aProps ) point2 = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ), -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) ); - lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" ); + LineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" ); + Color = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 ); + + auto lineStyleExt = ReadEnum( aProps, "LINESTYLEEXT", 0, 3, ASCH_POLYLINE_LINESTYLE::SOLID ); + LineStyle = ReadEnum( aProps, "LINESTYLE", 0, 3, lineStyleExt ); // overwrite if present. } @@ -679,8 +678,6 @@ ASCH_BUS::ASCH_BUS( const std::map& aProps ) { wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BUS ); - indexinsheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 ); - int locationcount = ALTIUM_PARSER::ReadInt( aProps, "LOCATIONCOUNT", 0 ); for( int i = 1; i <= locationcount; i++ ) @@ -698,8 +695,6 @@ ASCH_WIRE::ASCH_WIRE( const std::map& aProps ) { wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::WIRE ); - indexinsheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 ); - int locationcount = ALTIUM_PARSER::ReadInt( aProps, "LOCATIONCOUNT", 0 ); for( int i = 1; i <= locationcount; i++ ) diff --git a/eeschema/sch_plugins/altium/altium_parser_sch.h b/eeschema/sch_plugins/altium/altium_parser_sch.h index 864ae3618f..6e832e8f5b 100644 --- a/eeschema/sch_plugins/altium/altium_parser_sch.h +++ b/eeschema/sch_plugins/altium/altium_parser_sch.h @@ -437,7 +437,10 @@ struct ASCH_LINE VECTOR2I point1; VECTOR2I point2; - int lineWidth; + int LineWidth; + int Color; + + ASCH_POLYLINE_LINESTYLE LineStyle; explicit ASCH_LINE( const std::map& aProps ); }; diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index 5d37654c46..c94a136ca5 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -1743,7 +1743,10 @@ void SCH_ALTIUM_PLUGIN::ParseLine( const std::map& aProperti // close polygon SCH_LINE* line = new SCH_LINE( elem.point1 + m_sheetOffset, SCH_LAYER_ID::LAYER_NOTES ); line->SetEndPoint( elem.point2 + m_sheetOffset ); - line->SetStroke( STROKE_PARAMS( elem.lineWidth, PLOT_DASH_TYPE::SOLID ) ); // TODO? + + COLOR4D color = GetColorFromInt( elem.Color ); + line->SetStroke( STROKE_PARAMS( elem.LineWidth, GetPlotDashType( elem.LineStyle ), + color == PUREBLUE ? COLOR4D::UNSPECIFIED : color ) ); line->SetFlags( IS_NEW ); screen->Append( line ); @@ -1773,7 +1776,9 @@ void SCH_ALTIUM_PLUGIN::ParseLine( const std::map& aProperti line->AddPoint( GetRelativePosition( elem.point1 + m_sheetOffset, symbol ) ); line->AddPoint( GetRelativePosition( elem.point2 + m_sheetOffset, symbol ) ); - line->SetStroke( STROKE_PARAMS( elem.lineWidth, PLOT_DASH_TYPE::SOLID ) ); + COLOR4D color = GetColorFromInt( elem.Color ); + line->SetStroke( STROKE_PARAMS( elem.LineWidth, GetPlotDashType( elem.LineStyle ), + color == PUREBLUE ? COLOR4D::UNSPECIFIED : color ) ); } }