CADSTAR Schematic Archive Importer: Fix Loading of page numbers
Need to keep track of the hierarchy path in order to assign the page number
This commit is contained in:
parent
cba45ea257
commit
a058e26ddc
|
@ -38,6 +38,7 @@
|
||||||
#include <sch_line.h>
|
#include <sch_line.h>
|
||||||
#include <sch_screen.h>
|
#include <sch_screen.h>
|
||||||
#include <sch_sheet.h>
|
#include <sch_sheet.h>
|
||||||
|
#include <sch_sheet_path.h>
|
||||||
#include <sch_text.h>
|
#include <sch_text.h>
|
||||||
#include <schematic.h>
|
#include <schematic.h>
|
||||||
#include <trigo.h>
|
#include <trigo.h>
|
||||||
|
@ -173,6 +174,10 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( ::SCHEMATIC* aSchematic, ::SCH_SHEET* aRo
|
||||||
void CADSTAR_SCH_ARCHIVE_LOADER::loadSheets()
|
void CADSTAR_SCH_ARCHIVE_LOADER::loadSheets()
|
||||||
{
|
{
|
||||||
const std::vector<LAYER_ID>& orphanSheets = findOrphanSheets();
|
const std::vector<LAYER_ID>& orphanSheets = findOrphanSheets();
|
||||||
|
SCH_SHEET_PATH rootPath;
|
||||||
|
rootPath.push_back( mRootSheet );
|
||||||
|
mRootSheet->AddInstance( rootPath.Path() );
|
||||||
|
mRootSheet->SetPageNumber( rootPath, wxT( "1" ) );
|
||||||
|
|
||||||
if( orphanSheets.size() > 1 )
|
if( orphanSheets.size() > 1 )
|
||||||
{
|
{
|
||||||
|
@ -184,7 +189,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheets()
|
||||||
wxPoint pos( x * Mils2iu( 1000 ), y * Mils2iu( 1000 ) );
|
wxPoint pos( x * Mils2iu( 1000 ), y * Mils2iu( 1000 ) );
|
||||||
wxSize siz( Mils2iu( 1000 ), Mils2iu( 1000 ) );
|
wxSize siz( Mils2iu( 1000 ), Mils2iu( 1000 ) );
|
||||||
|
|
||||||
loadSheetAndChildSheets( sheetID, pos, siz, mRootSheet );
|
loadSheetAndChildSheets( sheetID, pos, siz, rootPath );
|
||||||
|
|
||||||
x += 2;
|
x += 2;
|
||||||
|
|
||||||
|
@ -211,7 +216,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheets()
|
||||||
mRootSheet->GetScreen()->SetFileName( fn.GetFullPath() );
|
mRootSheet->GetScreen()->SetFileName( fn.GetFullPath() );
|
||||||
|
|
||||||
mSheetMap.insert( { rootSheetID, mRootSheet } );
|
mSheetMap.insert( { rootSheetID, mRootSheet } );
|
||||||
loadChildSheets( rootSheetID );
|
loadChildSheets( rootSheetID, rootPath );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1300,12 +1305,13 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadFigure( const FIGURE& aCadstarFigure,
|
||||||
|
|
||||||
|
|
||||||
void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(
|
void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(
|
||||||
LAYER_ID aCadstarSheetID, wxPoint aPosition, wxSize aSheetSize, SCH_SHEET* aParentSheet )
|
LAYER_ID aCadstarSheetID, wxPoint aPosition, wxSize aSheetSize, const SCH_SHEET_PATH& aParentSheet )
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( mSheetMap.find( aCadstarSheetID ) == mSheetMap.end(), , "Sheet already loaded!" );
|
wxCHECK_MSG( mSheetMap.find( aCadstarSheetID ) == mSheetMap.end(), , "Sheet already loaded!" );
|
||||||
|
|
||||||
SCH_SHEET* sheet = new SCH_SHEET( aParentSheet, aPosition );
|
SCH_SHEET* sheet = new SCH_SHEET( aParentSheet.Last(), aPosition );
|
||||||
SCH_SCREEN* screen = new SCH_SCREEN( mSchematic );
|
SCH_SCREEN* screen = new SCH_SCREEN( mSchematic );
|
||||||
|
SCH_SHEET_PATH instance( aParentSheet );
|
||||||
|
|
||||||
sheet->SetSize( aSheetSize );
|
sheet->SetSize( aSheetSize );
|
||||||
sheet->SetScreen( screen );
|
sheet->SetScreen( screen );
|
||||||
|
@ -1317,10 +1323,9 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(
|
||||||
|
|
||||||
sheetNameField.SetText( name );
|
sheetNameField.SetText( name );
|
||||||
|
|
||||||
wxFileName loadedFilePath = wxFileName( Filename );
|
int sheetNum = getSheetNumber( aCadstarSheetID );
|
||||||
std::string filename = wxString::Format(
|
wxString loadedFilename = wxFileName( Filename ).GetName();
|
||||||
"%s_%02d", loadedFilePath.GetName(), getSheetNumber( aCadstarSheetID ) )
|
std::string filename = wxString::Format( "%s_%02d", loadedFilename, sheetNum ).ToStdString();
|
||||||
.ToStdString();
|
|
||||||
|
|
||||||
ReplaceIllegalFileNameChars( &filename );
|
ReplaceIllegalFileNameChars( &filename );
|
||||||
filename += wxT( "." ) + KiCadSchematicFileExtension;
|
filename += wxT( "." ) + KiCadSchematicFileExtension;
|
||||||
|
@ -1328,15 +1333,21 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(
|
||||||
filenameField.SetText( filename );
|
filenameField.SetText( filename );
|
||||||
wxFileName fn( filename );
|
wxFileName fn( filename );
|
||||||
sheet->GetScreen()->SetFileName( fn.GetFullPath() );
|
sheet->GetScreen()->SetFileName( fn.GetFullPath() );
|
||||||
aParentSheet->GetScreen()->Append( sheet );
|
aParentSheet.Last()->GetScreen()->Append( sheet );
|
||||||
|
instance.push_back( sheet );
|
||||||
|
sheet->AddInstance( instance.Path() );
|
||||||
|
|
||||||
|
wxString pageNumStr = wxString::Format( "%d", getSheetNumber( aCadstarSheetID ) );
|
||||||
|
sheet->SetPageNumber( instance, pageNumStr );
|
||||||
|
|
||||||
mSheetMap.insert( { aCadstarSheetID, sheet } );
|
mSheetMap.insert( { aCadstarSheetID, sheet } );
|
||||||
|
|
||||||
loadChildSheets( aCadstarSheetID );
|
loadChildSheets( aCadstarSheetID, instance );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets( LAYER_ID aCadstarSheetID )
|
void CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets(
|
||||||
|
LAYER_ID aCadstarSheetID, const SCH_SHEET_PATH& aSheet )
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( mSheetMap.find( aCadstarSheetID ) != mSheetMap.end(), ,
|
wxCHECK_MSG( mSheetMap.find( aCadstarSheetID ) != mSheetMap.end(), ,
|
||||||
"FIXME! Parent sheet should be loaded before attempting to load subsheets" );
|
"FIXME! Parent sheet should be loaded before attempting to load subsheets" );
|
||||||
|
@ -1364,8 +1375,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets( LAYER_ID aCadstarSheetID )
|
||||||
block.ID ) );
|
block.ID ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSheetAndChildSheets( block.AssocLayerID, blockExtents.first, blockExtents.second,
|
loadSheetAndChildSheets( block.AssocLayerID, blockExtents.first, blockExtents.second, aSheet );
|
||||||
mSheetMap.at( aCadstarSheetID ) );
|
|
||||||
|
|
||||||
if( block.HasBlockLabel )
|
if( block.HasBlockLabel )
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,7 @@ class SCH_FIELD;
|
||||||
class SCH_GLOBALLABEL;
|
class SCH_GLOBALLABEL;
|
||||||
class SCH_HIERLABEL;
|
class SCH_HIERLABEL;
|
||||||
class SCH_SHEET;
|
class SCH_SHEET;
|
||||||
|
class SCH_SHEET_PATH;
|
||||||
class SCH_TEXT;
|
class SCH_TEXT;
|
||||||
class SCHEMATIC;
|
class SCHEMATIC;
|
||||||
|
|
||||||
|
@ -108,9 +109,9 @@ private:
|
||||||
|
|
||||||
//Helper Functions for loading sheets
|
//Helper Functions for loading sheets
|
||||||
void loadSheetAndChildSheets( LAYER_ID aCadstarSheetID, wxPoint aPosition, wxSize aSheetSize,
|
void loadSheetAndChildSheets( LAYER_ID aCadstarSheetID, wxPoint aPosition, wxSize aSheetSize,
|
||||||
SCH_SHEET* aParentSheet );
|
const SCH_SHEET_PATH& aParentSheet );
|
||||||
|
|
||||||
void loadChildSheets( LAYER_ID aCadstarSheetID );
|
void loadChildSheets( LAYER_ID aCadstarSheetID, const SCH_SHEET_PATH& aSheet );
|
||||||
|
|
||||||
std::vector<LAYER_ID> findOrphanSheets();
|
std::vector<LAYER_ID> findOrphanSheets();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue