Altium schematic: case-insensitive search for subsheet files.

Also fixes open polylines on sheet.
Also prevents adding polylines with less than 2 points.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16829

(cherry picked from commit 7f29ac39d8)
This commit is contained in:
Alex Shvartzkop 2024-01-31 17:57:05 +03:00
parent 93a63a61ec
commit 6c4734c370
1 changed files with 33 additions and 7 deletions

View File

@ -60,6 +60,7 @@
#include <wx/log.h>
#include <wx/zstream.h>
#include <wx/wfstream.h>
#include <wx/dir.h>
#include <trigo.h>
// Harness port object itself does not contain color information about itself
@ -367,6 +368,24 @@ void SCH_ALTIUM_PLUGIN::ParseAltiumSch( const wxString& aFileName )
// path as the parent sheet path.
wxFileName loadAltiumFileName( parentFileName.GetPath(), sheet->GetFileName() );
if( !loadAltiumFileName.IsFileReadable() )
{
// Try case-insensitive search
wxArrayString files;
wxDir::GetAllFiles( parentFileName.GetPath(), &files, wxEmptyString, wxDIR_FILES | wxDIR_HIDDEN );
for( const wxString& candidate : files )
{
wxFileName candidateFname( candidate );
if( candidateFname.GetFullName().IsSameAs( sheet->GetFileName(), false ) )
{
loadAltiumFileName = candidateFname;
break;
}
}
}
if( loadAltiumFileName.GetFullName().IsEmpty() || !loadAltiumFileName.IsFileReadable() )
{
wxString msg;
@ -1411,21 +1430,28 @@ void SCH_ALTIUM_PLUGIN::ParsePolyline( const std::map<wxString, wxString>& aProp
{
ASCH_POLYLINE elem( aProperties );
if( elem.Points.size() < 2 )
return;
SCH_SCREEN* screen = getCurrentScreen();
wxCHECK( screen, /* void */ );
if( elem.OwnerPartID == ALTIUM_COMPONENT_NONE )
{
SCH_SHAPE* poly = new SCH_SHAPE( SHAPE_T::POLY );
for( size_t i = 1; i < elem.Points.size(); i++ )
{
SCH_LINE* line = new SCH_LINE;
for( VECTOR2I& point : elem.Points )
poly->AddPoint( point + m_sheetOffset );
line->SetStartPoint( elem.Points[i - 1] + m_sheetOffset );
line->SetEndPoint( elem.Points[i] + m_sheetOffset );
poly->SetStroke( STROKE_PARAMS( elem.LineWidth, GetPlotDashType( elem.LineStyle ),
GetColorFromInt( elem.Color ) ) );
poly->SetFlags( IS_NEW );
line->SetStroke( STROKE_PARAMS( elem.LineWidth, GetPlotDashType( elem.LineStyle ),
GetColorFromInt( elem.Color ) ) );
screen->Append( poly );
line->SetFlags( IS_NEW );
screen->Append( line );
}
}
else
{