Set up default netclass wire & bus widths.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/17024
This commit is contained in:
parent
c75bb5d01a
commit
2d7f4faf72
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
#include <schematic.h>
|
#include <schematic.h>
|
||||||
#include <project_sch.h>
|
#include <project_sch.h>
|
||||||
|
#include <project/project_file.h>
|
||||||
|
#include <project/net_settings.h>
|
||||||
|
|
||||||
#include <lib_shape.h>
|
#include <lib_shape.h>
|
||||||
#include <lib_id.h>
|
#include <lib_id.h>
|
||||||
|
@ -391,6 +393,36 @@ SCH_SHEET* SCH_IO_ALTIUM::LoadSchematicFile( const wxString& aFileName, SCHEMATI
|
||||||
allSheets.UpdateSymbolLinks(); // Update all symbol library links for all sheets.
|
allSheets.UpdateSymbolLinks(); // Update all symbol library links for all sheets.
|
||||||
allSheets.ClearEditFlags();
|
allSheets.ClearEditFlags();
|
||||||
|
|
||||||
|
// Set up the default netclass wire & bus width based on imported wires & buses.
|
||||||
|
//
|
||||||
|
|
||||||
|
int minWireWidth = std::numeric_limits<int>::max();
|
||||||
|
int minBusWidth = std::numeric_limits<int>::max();
|
||||||
|
|
||||||
|
for( SCH_SCREEN* screen = allSheets.GetFirst(); screen != nullptr; screen = allSheets.GetNext() )
|
||||||
|
{
|
||||||
|
std::vector<SCH_MARKER*> markers;
|
||||||
|
|
||||||
|
for( SCH_ITEM* item : screen->Items().OfType( SCH_LINE_T ) )
|
||||||
|
{
|
||||||
|
SCH_LINE* line = static_cast<SCH_LINE*>( item );
|
||||||
|
|
||||||
|
if( line->IsWire() && line->GetLineWidth() > 0 )
|
||||||
|
minWireWidth = std::min( minWireWidth, line->GetLineWidth() );
|
||||||
|
|
||||||
|
if( line->IsBus() && line->GetLineWidth() > 0 )
|
||||||
|
minBusWidth = std::min( minBusWidth, line->GetLineWidth() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<NET_SETTINGS>& netSettings = m_schematic->Prj().GetProjectFile().NetSettings();
|
||||||
|
|
||||||
|
if( minWireWidth < std::numeric_limits<int>::max() )
|
||||||
|
netSettings->m_DefaultNetClass->SetWireWidth( minWireWidth );
|
||||||
|
|
||||||
|
if( minBusWidth < std::numeric_limits<int>::max() )
|
||||||
|
netSettings->m_DefaultNetClass->SetBusWidth( minBusWidth );
|
||||||
|
|
||||||
return m_rootSheet;
|
return m_rootSheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue