diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp index 0856b33b55..ef155a1f99 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp @@ -869,7 +869,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_DIMENSION_BASE* aDimension, int aNest formatLayer( aDimension->GetLayer() ); - if(!m_no_generate_uuid) { + if(!this->m_no_generate_uuid) { KICAD_FORMAT::FormatUuid( m_out, aDimension->m_Uuid ); } @@ -1031,7 +1031,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_SHAPE* aShape, int aNestLevel ) const if( aShape->GetNetCode() > 0 ) m_out->Print( 0, " (net %d)", m_mapping->Translate( aShape->GetNetCode() ) ); - if(!m_no_generate_uuid) { + if(!this->m_no_generate_uuid) { KICAD_FORMAT::FormatUuid( m_out, aShape->m_Uuid, 0 ); } @@ -1079,7 +1079,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_REFERENCE_IMAGE* aBitmap, int aNestLe m_out->Print( 0, "\n" ); m_out->Print( aNestLevel + 1, ")\n" ); // Closes data token. - if(!m_no_generate_uuid) { + if(!this->m_no_generate_uuid) { KICAD_FORMAT::FormatUuid( m_out, aBitmap->m_Uuid, 0 ); } @@ -1099,7 +1099,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TARGET* aTarget, int aNestLevel ) con formatLayer( aTarget->GetLayer() ); - if(!m_no_generate_uuid) { + if(!this->m_no_generate_uuid) { KICAD_FORMAT::FormatUuid( m_out, aTarget->m_Uuid, 0 ); } @@ -1151,7 +1151,7 @@ void PCB_IO_KICAD_SEXPR::format( const FOOTPRINT* aFootprint, int aNestLevel ) c m_out->Print( 0, "\n" ); - if( !( m_ctl & CTL_OMIT_UUIDS ) && !m_no_generate_uuid ) + if( !( m_ctl & CTL_OMIT_UUIDS ) && !this->m_no_generate_uuid ) KICAD_FORMAT::FormatUuid( m_out, aFootprint->m_Uuid ); if( !( m_ctl & CTL_OMIT_AT ) ) @@ -1830,7 +1830,7 @@ void PCB_IO_KICAD_SEXPR::format( const PAD* aPad, int aNestLevel ) const } m_out->Print( 0, "\n" ); - if(!m_no_generate_uuid) { + if(!this->m_no_generate_uuid) { KICAD_FORMAT::FormatUuid( m_out, aPad->m_Uuid ); } m_out->Print( aNestLevel, ")\n" ); @@ -1887,7 +1887,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TEXT* aText, int aNestLevel ) const if( parentFP && !aText->IsVisible() ) KICAD_FORMAT::FormatBool( m_out, 0, "hide", !aText->IsVisible() ); - if(!m_no_generate_uuid) { + if(!this->m_no_generate_uuid) { KICAD_FORMAT::FormatUuid( m_out, aText->m_Uuid ); } @@ -1955,7 +1955,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) c formatLayer( aTextBox->GetLayer() ); m_out->Print( 0, "\n" ); - if(!m_no_generate_uuid) { + if(!this->m_no_generate_uuid) { KICAD_FORMAT::FormatUuid( m_out, aTextBox->m_Uuid ); } @@ -2044,7 +2044,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_GROUP* aGroup, int aNestLevel ) const m_out->Print( aNestLevel, "(group %s\n", m_out->Quotew( aGroup->GetName() ).c_str() ); - if(!m_no_generate_uuid) { + if(!this->m_no_generate_uuid) { KICAD_FORMAT::FormatUuid( m_out, aGroup->m_Uuid ); } @@ -2072,7 +2072,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_GENERATOR* aGenerator, int aNestLevel { m_out->Print( aNestLevel, "(generated\n" ); - if(!m_no_generate_uuid) { + if(!this->m_no_generate_uuid) { KICAD_FORMAT::FormatUuid( m_out, aGenerator->m_Uuid ); } @@ -2288,7 +2288,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TRACK* aTrack, int aNestLevel ) const m_out->Print( 0, " (net %d)", m_mapping->Translate( aTrack->GetNetCode() ) ); - if(!m_no_generate_uuid) { + if(!this->m_no_generate_uuid) { KICAD_FORMAT::FormatUuid( m_out, aTrack->m_Uuid ); } @@ -2326,7 +2326,7 @@ void PCB_IO_KICAD_SEXPR::format( const ZONE* aZone, int aNestLevel ) const formatLayer( aZone->GetFirstLayer() ); } - if(!m_no_generate_uuid) { + if(!this->m_no_generate_uuid) { KICAD_FORMAT::FormatUuid( m_out, aZone->m_Uuid ); } diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h index 635f16d339..d0823f4d6a 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h @@ -220,8 +220,6 @@ class FP_CACHE // m_cache_timestamp against all the files. long long m_cache_timestamp; // A hash of the timestamps for all the footprint // files. - - bool m_no_generate_uuid; ///< Flag: Do not generate UUIDs for footprints public: FP_CACHE( PCB_IO_KICAD_SEXPR* aOwner, const wxString& aLibraryPath ); @@ -378,6 +376,8 @@ public: return ret; } + inline void SetUUIDDisabled( bool aDisabled ) { m_no_generate_uuid = aDisabled; } + void SetOutputFormatter( OUTPUTFORMATTER* aFormatter ) { m_out = aFormatter; } BOARD_ITEM* Parse( const wxString& aClipboardSourceInput ); @@ -463,6 +463,8 @@ protected: NETINFO_MAPPING* m_mapping; ///< mapping for net codes, so only not empty net codes ///< are stored with consecutive integers as net codes + bool m_no_generate_uuid; ///< Flag: Do not generate UUIDs for footprints + std::function m_queryUserCallback; }; diff --git a/pcbnew/pcb_io/pcb_io_mgr.cpp b/pcbnew/pcb_io/pcb_io_mgr.cpp index 7a59d88117..e2b991ebce 100644 --- a/pcbnew/pcb_io/pcb_io_mgr.cpp +++ b/pcbnew/pcb_io/pcb_io_mgr.cpp @@ -29,6 +29,8 @@ #include #include +#include + #include #include @@ -219,13 +221,13 @@ bool PCB_IO_MGR::ConvertLibrary( STRING_UTF8_MAP* aOldFileProps, const wxString& std::unique_ptr fp( oldFilePI->GetEnumeratedFootprint( aOldFilePath, fpName, aOldFileProps ) ); // Set options PCB_IO_KICAD_SEXPR* kicad_sexpr_parser = dynamic_cast( kicadPI.get() ); - if(kicad_sexpr_parser !== nullptr) { - kicad_sexpr_parser->m_no_generate_uuid = - aOldFileProps->Exists( "no_uuid_gen" ) && - aOldFileProps->at( "no_uuid_gen" ) == "true"; + if(kicad_sexpr_parser != nullptr) { + UTF8 value; + bool exists = aOldFileProps->Value( "no_uuid_gen", &value ); + kicad_sexpr_parser->SetUUIDDisabled( + exists && value == "true" + ); } - - kicadPI->FootprintSave( aNewFilePath, fp.get() ); } diff --git a/pcbnew/pcbnew_jobs_handler.cpp b/pcbnew/pcbnew_jobs_handler.cpp index b8cd5b8328..4ae08db672 100644 --- a/pcbnew/pcbnew_jobs_handler.cpp +++ b/pcbnew/pcbnew_jobs_handler.cpp @@ -1131,7 +1131,7 @@ int PCBNEW_JOBS_HANDLER::JobExportFpUpgrade( JOB* aJob ) else { STRING_UTF8_MAP properties; - properties.insert("no_uuid_gen", upgradeJob->m_no_uuid_gen ? "true" : "false"); + properties.emplace("no_uuid_gen", upgradeJob->m_no_uuid_gen ? UTF8("true") : UTF8("false")); if( !PCB_IO_MGR::ConvertLibrary( &properties, upgradeJob->m_libraryPath, upgradeJob->m_outputLibraryPath ) ) { m_reporter->Report( ( "Unable to convert library\n" ), RPT_SEVERITY_ERROR );