void PropertyMeshKernel::Restore(Base::XMLReader &reader) { reader.readElement("Mesh"); std::string file (reader.getAttribute("file") ); if (file.empty()) { // read XML MeshCore::MeshKernel kernel; MeshCore::MeshInput restorer(kernel); restorer.LoadXML(reader); // avoid to duplicate the mesh in memory MeshCore::MeshPointArray points; MeshCore::MeshFacetArray facets; kernel.Adopt(points, facets); aboutToSetValue(); _meshObject->getKernel().Adopt(points, facets); hasSetValue(); } else { // initate a file read reader.addFile(file.c_str(),this); } }
void PropertyFileIncluded::Restore(Base::XMLReader &reader) { reader.readElement("FileIncluded"); if (reader.hasAttribute("file")) { string file (reader.getAttribute("file") ); if (!file.empty()) { // initate a file read reader.addFile(file.c_str(),this); // is in the document transient path aboutToSetValue(); _cValue = getDocTransientPath() + "/" + file; _BaseFileName = file; hasSetValue(); } } // section is XML stream else if (reader.hasAttribute("data")) { string file (reader.getAttribute("data") ); if (!file.empty()) { // is in the document transient path aboutToSetValue(); _cValue = getDocTransientPath() + "/" + file; reader.readBinFile(_cValue.c_str()); reader.readEndElement("FileIncluded"); _BaseFileName = file; hasSetValue(); } } }
void PropertyFilletEdges::Restore(Base::XMLReader &reader) { reader.readElement("FilletEdges"); std::string file (reader.getAttribute("file") ); if (!file.empty()) { // initate a file read reader.addFile(file.c_str(),this); } }
void PropertyNormalList::Restore(Base::XMLReader &reader) { reader.readElement("VectorList"); std::string file (reader.getAttribute("file") ); if (!file.empty()) { // initate a file read reader.addFile(file.c_str(),this); } }
void PropertyGreyValueList::Restore(Base::XMLReader &reader) { reader.readElement("FloatList"); string file (reader.getAttribute("file") ); if (!file.empty()) { // initate a file read reader.addFile(file.c_str(),this); } }
/** * Loads a separate XML file from the projects file with information about the view providers. */ void Document::Restore(Base::XMLReader &reader) { reader.addFile("GuiDocument.xml",this); // hide all elements to avoid to update the 3d view when loading data files // RestoreDocFile then restores the visibility status again std::map<const App::DocumentObject*,ViewProviderDocumentObject*>::iterator it; for (it = d->_ViewProviderMap.begin(); it != d->_ViewProviderMap.end(); ++it) { it->second->startRestoring(); } }
void PointKernel::Restore(Base::XMLReader &reader) { clear(); reader.readElement("Points"); std::string file (reader.getAttribute("file") ); if (!file.empty()) { // initiate a file read reader.addFile(file.c_str(),this); } if (reader.DocumentSchema > 3) { std::string Matrix (reader.getAttribute("mtrx") ); _Mtrx.fromString(Matrix); } }
void PropertyPointKernel::Restore(Base::XMLReader &reader) { reader.readElement("Points"); std::string file (reader.getAttribute("file") ); if (!file.empty()) { // initate a file read reader.addFile(file.c_str(),this); } if(reader.DocumentSchema > 3) { std::string Matrix (reader.getAttribute("mtrx") ); Base::Matrix4D mtrx; mtrx.fromString(Matrix); aboutToSetValue(); _cPoints->setTransform(mtrx); hasSetValue(); } }
void PropertyPythonObject::Restore(Base::XMLReader &reader) { reader.readElement("Python"); if (reader.hasAttribute("file")) { std::string file(reader.getAttribute("file")); reader.addFile(file.c_str(),this); } else { bool load_json=false; bool load_pickle=false; bool load_failed=false; std::string buffer = reader.getAttribute("value"); if (reader.hasAttribute("encoded") && strcmp(reader.getAttribute("encoded"),"yes") == 0) { buffer = Base::base64_decode(buffer); } else { buffer = decodeValue(buffer); } Base::PyGILStateLocker lock; try { boost::regex pickle("^\\(i(\\w+)\\n(\\w+)\\n"); boost::match_results<std::string::const_iterator> what; std::string::const_iterator start, end; start = buffer.begin(); end = buffer.end(); if (reader.hasAttribute("module") && reader.hasAttribute("class")) { Py::Module mod(PyImport_ImportModule(reader.getAttribute("module")),true); PyObject* cls = mod.getAttr(reader.getAttribute("class")).ptr(); #if PY_MAJOR_VERSION >= 3 if (PyType_Check(cls)) { #else if (PyClass_Check(cls)) { this->object = PyInstance_NewRaw(cls, 0); } else if (PyType_Check(cls)) { #endif this->object = PyType_GenericAlloc((PyTypeObject*)cls, 0); } else { throw Py::TypeError("neither class nor type object"); } load_json = true; } else if (boost::regex_search(start, end, what, pickle)) { std::string nam = std::string(what[1].first, what[1].second); std::string cls = std::string(what[2].first, what[2].second); Py::Module mod(PyImport_ImportModule(nam.c_str()),true); #if PY_MAJOR_VERSION >= 3 this->object = PyObject_CallObject(mod.getAttr(cls).ptr(), NULL); #else this->object = PyInstance_NewRaw(mod.getAttr(cls).ptr(), 0); #endif load_pickle = true; buffer = std::string(what[2].second, end); } else if (reader.hasAttribute("json")) { load_json = true; } } catch (Py::Exception&) { Base::PyException e; // extract the Python error text e.ReportException(); this->object = Py::None(); load_failed = true; } aboutToSetValue(); if (load_json) this->fromString(buffer); else if (load_pickle) this->loadPickle(buffer); else if (!load_failed) Base::Console().Warning("PropertyPythonObject::Restore: unsupported serialisation: %s\n", buffer.c_str()); restoreObject(reader); hasSetValue(); } }
void MergeDocuments::Restore(Base::XMLReader &r) { r.addFile("GuiDocument.xml", this); }