From e81171147ac2c52dcfc91b18ce65eda6b5f253bd Mon Sep 17 00:00:00 2001 From: wandererfan Date: Fri, 10 Jan 2020 14:07:45 -0500 Subject: [PATCH] [TD]use new PropertyFileIncluded.isEmpty() --- src/Mod/TechDraw/App/DrawViewSection.cpp | 38 +++++++++++++----------- src/Mod/TechDraw/App/DrawViewSection.h | 1 - 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 44cc4dbb6f..589c2b81f8 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -130,8 +130,10 @@ DrawViewSection::DrawViewSection() ADD_PROPERTY_TYPE(CutSurfaceDisplay,((long)2),fgroup, App::Prop_None, "Appearance of Cut Surface"); ADD_PROPERTY_TYPE(FileHatchPattern ,(""),fgroup,App::Prop_None,"The hatch pattern file for the cut surface"); ADD_PROPERTY_TYPE(FileGeomPattern ,(""),fgroup,App::Prop_None,"The PAT pattern file for geometric hatching"); - ADD_PROPERTY_TYPE(SvgIncluded ,(""),fgroup,App::Prop_None,"Embedded Svg hatch file"); // n/a to end users - ADD_PROPERTY_TYPE(PatIncluded ,(""),fgroup,App::Prop_None,"Embedded Pat pattern file"); // n/a to end users + ADD_PROPERTY_TYPE(SvgIncluded ,(""),fgroup,App::Prop_None, + "Embedded Svg hatch file. System use only."); // n/a to end users + ADD_PROPERTY_TYPE(PatIncluded ,(""),fgroup,App::Prop_None, + "Embedded Pat pattern file. System use only."); // n/a to end users ADD_PROPERTY_TYPE(NameGeomPattern ,(""),fgroup,App::Prop_None,"The pattern name for geometric hatching"); ADD_PROPERTY_TYPE(HatchScale,(1.0),fgroup,App::Prop_None,"Hatch pattern size adjustment"); @@ -142,8 +144,8 @@ DrawViewSection::DrawViewSection() hatchFilter = ("PAT files (*.pat *.PAT);;All files (*)"); FileGeomPattern.setFilter(hatchFilter); -// SvgIncluded.setStatus(App::Property::ReadOnly,true); -// PatIncluded.setStatus(App::Property::ReadOnly,true); + SvgIncluded.setStatus(App::Property::ReadOnly,true); + PatIncluded.setStatus(App::Property::ReadOnly,true); } DrawViewSection::~DrawViewSection() @@ -237,9 +239,7 @@ void DrawViewSection::onChanged(const App::Property* prop) void DrawViewSection::replaceSvgIncluded(std::string newSvgFile) { // Base::Console().Message("DVS::replaceSvgHatch(%s)\n", newSvgFile.c_str()); - const char* temp = SvgIncluded.getValue(); - //if (SvgIncluded.isEmpty()) { - if (temp[0] == '\0') { + if (SvgIncluded.isEmpty()) { setupSvgIncluded(); } else { std::string tempName = SvgIncluded.getExchangeTempFile(); @@ -251,8 +251,7 @@ void DrawViewSection::replaceSvgIncluded(std::string newSvgFile) void DrawViewSection::replacePatIncluded(std::string newPatFile) { // Base::Console().Message("DVS::replacePatHatch(%s)\n", newPatFile.c_str()); - const char* temp = PatIncluded.getValue(); - if (temp[0] == '\0') { + if (PatIncluded.isEmpty()) { setupPatIncluded(); } else { std::string tempName = PatIncluded.getExchangeTempFile(); @@ -889,14 +888,21 @@ void DrawViewSection::onDocumentRestored() std::string svgFileName = FileHatchPattern.getValue(); Base::FileInfo tfi(svgFileName); if (tfi.isReadable()) { - const char* svg = SvgIncluded.getValue(); -// if (SvgIncluded.isEmpty()) { - if (svg[0] == '\0') { + if (SvgIncluded.isEmpty()) { setupSvgIncluded(); } } } + if (!FileGeomPattern.isEmpty()) { + std::string patFileName = FileGeomPattern.getValue(); + Base::FileInfo tfi(patFileName); + if (tfi.isReadable()) { + if (PatIncluded.isEmpty()) { + setupPatIncluded(); + } + } + } DrawViewPart::onDocumentRestored(); } @@ -918,9 +924,7 @@ void DrawViewSection::setupSvgIncluded(void) std::string dir = doc->TransientDir.getValue(); std::string svgName = dir + special; - const char* includedName = SvgIncluded.getValue(); - //if (SvgIncluded.isEmpty()) { -// if (includedName[0] == '\0') { + if (SvgIncluded.isEmpty()) { copyFile(std::string(), svgName); SvgIncluded.setValue(svgName.c_str()); } @@ -940,9 +944,7 @@ void DrawViewSection::setupPatIncluded(void) special += "PatHatch.pat"; std::string dir = doc->TransientDir.getValue(); std::string patName = dir + special; - //if (PatIncluded.isEmpty()) { - const char* includedName = PatIncluded.getValue(); - if (includedName[0] == '\0') { + if (PatIncluded.isEmpty()) { copyFile(std::string(), patName); PatIncluded.setValue(patName.c_str()); } diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index 2fe2a6168e..181723dc6a 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -89,7 +89,6 @@ public: } virtual void unsetupObject() override; virtual short mustExecute() const override; - virtual void onSettingDocument() override; std::vector getFaceGeometry();