diff --git a/src/Mod/TechDraw/App/DrawViewArch.cpp b/src/Mod/TechDraw/App/DrawViewArch.cpp index e0f9228a5d..8c0cbb7f6d 100644 --- a/src/Mod/TechDraw/App/DrawViewArch.cpp +++ b/src/Mod/TechDraw/App/DrawViewArch.cpp @@ -55,7 +55,7 @@ DrawViewArch::DrawViewArch(void) static const char *group = "Arch view"; ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"Section Plane object for this view"); - Source.setScope(App::LinkScope::Global); + Source.setScope(App::LinkScope::Global); ADD_PROPERTY_TYPE(AllOn ,(false),group,App::Prop_None,"If hidden objects must be shown or not"); RenderMode.setEnums(RenderModeEnums); ADD_PROPERTY_TYPE(RenderMode, ((long)0),group,App::Prop_None,"The render mode to use"); @@ -140,3 +140,72 @@ std::string DrawViewArch::getSVGTail(void) std::string tail = "\\n"; return tail; } + +//DVA is still Source PropertyLink so needs different logic vs DV::Restore +void DrawViewArch::Restore(Base::XMLReader &reader) +{ +// this is temporary code for backwards compat (within v0.17). can probably be deleted once there are no development +// fcstd files with old property types in use. + reader.readElement("Properties"); + int Cnt = reader.getAttributeAsInteger("Count"); + + for (int i=0 ;igetTypeId().getName(), TypeName) == 0){ //if the property type in obj == type in schema + schemaProp->Restore(reader); //nothing special to do + } else if (strcmp(PropName, "Source") == 0) { + App::PropertyLinkGlobal glink; + App::PropertyLink link; + if (strcmp(glink.getTypeId().getName(),TypeName) == 0) { //property in file is plg + glink.setContainer(this); + glink.Restore(reader); + if (glink.getValue() != nullptr) { + static_cast(schemaProp)->setScope(App::LinkScope::Global); + static_cast(schemaProp)->setValue(glink.getValue()); + } + } else if (strcmp(link.getTypeId().getName(),TypeName) == 0) { //property in file is pl + link.setContainer(this); + link.Restore(reader); + if (link.getValue() != nullptr) { + static_cast(schemaProp)->setScope(App::LinkScope::Global); + static_cast(schemaProp)->setValue(link.getValue()); + } + + } else { + // has Source prop isn't PropertyLink or PropertyLinkGlobal! + Base::Console().Log("DrawViewArch::Restore - old Document Source is weird: %s\n", TypeName); + // no idea + } + } else { + Base::Console().Log("DrawViewArch::Restore - old Document has unknown Property\n"); + } + } + } + catch (const Base::XMLParseException&) { + throw; // re-throw + } + catch (const Base::Exception &e) { + Base::Console().Error("%s\n", e.what()); + } + catch (const std::exception &e) { + Base::Console().Error("%s\n", e.what()); + } + catch (const char* e) { + Base::Console().Error("%s\n", e); + } +#ifndef FC_DEBUG + catch (...) { + Base::Console().Error("PropertyContainer::Restore: Unknown C++ exception thrown"); + } +#endif + + reader.readEndElement("Property"); + } + reader.readEndElement("Properties"); + +} diff --git a/src/Mod/TechDraw/App/DrawViewArch.h b/src/Mod/TechDraw/App/DrawViewArch.h index 826b8ed33b..87826ebeed 100644 --- a/src/Mod/TechDraw/App/DrawViewArch.h +++ b/src/Mod/TechDraw/App/DrawViewArch.h @@ -60,6 +60,8 @@ public: virtual const char* getViewProviderName(void) const { return "TechDrawGui::ViewProviderArch"; } + void Restore(Base::XMLReader &reader) override; + protected: virtual void onChanged(const App::Property* prop); diff --git a/src/Mod/TechDraw/App/DrawViewDraft.cpp b/src/Mod/TechDraw/App/DrawViewDraft.cpp index 167537308e..874755dca3 100644 --- a/src/Mod/TechDraw/App/DrawViewDraft.cpp +++ b/src/Mod/TechDraw/App/DrawViewDraft.cpp @@ -52,7 +52,7 @@ DrawViewDraft::DrawViewDraft(void) static const char *group = "Draft view"; ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"Draft object for this view"); - Source.setScope(App::LinkScope::Global); + Source.setScope(App::LinkScope::Global); ADD_PROPERTY_TYPE(LineWidth,(0.35),group,App::Prop_None,"Line width of this view"); ADD_PROPERTY_TYPE(FontSize,(12.0),group,App::Prop_None,"Text size for this view"); ADD_PROPERTY_TYPE(Direction ,(0,0,1.0),group,App::Prop_None,"Projection direction. The direction you are looking from."); @@ -143,6 +143,75 @@ std::string DrawViewDraft::getSVGTail(void) return tail; } +//DVD is still compatible with old Source PropertyLink so doesn't need DV::Restore logic +void DrawViewDraft::Restore(Base::XMLReader &reader) +{ +// this is temporary code for backwards compat (within v0.17). can probably be deleted once there are no development +// fcstd files with old property types in use. + reader.readElement("Properties"); + int Cnt = reader.getAttributeAsInteger("Count"); + + for (int i=0 ;igetTypeId().getName(), TypeName) == 0){ //if the property type in obj == type in schema + schemaProp->Restore(reader); //nothing special to do + } else if (strcmp(PropName, "Source") == 0) { + App::PropertyLinkGlobal glink; + App::PropertyLink link; + if (strcmp(glink.getTypeId().getName(),TypeName) == 0) { //property in file is plg + glink.setContainer(this); + glink.Restore(reader); + if (glink.getValue() != nullptr) { + static_cast(schemaProp)->setScope(App::LinkScope::Global); + static_cast(schemaProp)->setValue(glink.getValue()); + } + } else if (strcmp(link.getTypeId().getName(),TypeName) == 0) { //property in file is pl + link.setContainer(this); + link.Restore(reader); + if (link.getValue() != nullptr) { + static_cast(schemaProp)->setScope(App::LinkScope::Global); + static_cast(schemaProp)->setValue(link.getValue()); + } + + } else { + // has Source prop isn't PropertyLink or PropertyLinkGlobal! + Base::Console().Log("DrawViewDraft::Restore - old Document Source is weird: %s\n", TypeName); + // no idea + } + } else { + Base::Console().Log("DrawViewDraft::Restore - old Document has unknown Property\n"); + } + } + } + catch (const Base::XMLParseException&) { + throw; // re-throw + } + catch (const Base::Exception &e) { + Base::Console().Error("%s\n", e.what()); + } + catch (const std::exception &e) { + Base::Console().Error("%s\n", e.what()); + } + catch (const char* e) { + Base::Console().Error("%s\n", e); + } +#ifndef FC_DEBUG + catch (...) { + Base::Console().Error("PropertyContainer::Restore: Unknown C++ exception thrown"); + } +#endif + + reader.readEndElement("Property"); + } + reader.readEndElement("Properties"); + +} + // Python Drawing feature --------------------------------------------------------- namespace App { diff --git a/src/Mod/TechDraw/App/DrawViewDraft.h b/src/Mod/TechDraw/App/DrawViewDraft.h index 5557dad654..ba759be310 100644 --- a/src/Mod/TechDraw/App/DrawViewDraft.h +++ b/src/Mod/TechDraw/App/DrawViewDraft.h @@ -61,6 +61,8 @@ public: virtual const char* getViewProviderName(void) const { return "TechDrawGui::ViewProviderDraft"; } + void Restore(Base::XMLReader &reader) override; + protected: virtual void onChanged(const App::Property* prop);