void PropertyFileIncluded::Save (Base::Writer &writer) const { if (writer.isForceXML()) { if (!_cValue.empty()) { Base::FileInfo file(_cValue.c_str()); writer.Stream() << writer.ind() << "<FileIncluded data=\"" << file.fileName() << "\">" << std::endl; // write the file in the XML stream writer.incInd(); writer.insertBinFile(_cValue.c_str()); writer.decInd(); writer.Stream() << writer.ind() <<"</FileIncluded>" << endl; } else writer.Stream() << writer.ind() << "<FileIncluded data=\"\"/>" << std::endl; } else { // instead initiate an extra file if (!_cValue.empty()) { Base::FileInfo file(_cValue.c_str()); writer.Stream() << writer.ind() << "<FileIncluded file=\"" << writer.addFile(file.fileName().c_str(), this) << "\"/>" << std::endl; } else writer.Stream() << writer.ind() << "<FileIncluded file=\"\"/>" << std::endl; } }
void PropertyCurvatureList::Save (Base::Writer &writer) const { if (!writer.isForceXML()) { writer.Stream() << writer.ind() << "<CurvatureList file=\"" << writer.addFile(getName(), this) << "\"/>" << std::endl; } }
void PointKernel::Save (Base::Writer &writer) const { if (!writer.isForceXML()) { writer.Stream() << writer.ind() << "<Points file=\"" << writer.addFile(writer.ObjectName.c_str(), this) << "\" " << "mtrx=\"" << _Mtrx.toString() << "\"/>" << std::endl; } }
void PropertyPartShape::Save (Base::Writer &writer) const { if(!writer.isForceXML()) { //See SaveDocFile(), RestoreDocFile() writer.Stream() << writer.ind() << "<Part file=\"" << writer.addFile("PartShape.brp", this) << "\"/>" << std::endl; } }
/** * Saves the properties of the view providers. */ void Document::SaveDocFile (Base::Writer &writer) const { writer.Stream() << "<?xml version='1.0' encoding='utf-8'?>" << std::endl << "<!--" << std::endl << " FreeCAD Document, see http://free-cad.sourceforge.net for more information..." << std::endl << "-->" << std::endl; writer.Stream() << "<Document SchemaVersion=\"1\">" << std::endl; std::map<const App::DocumentObject*,ViewProviderDocumentObject*>::const_iterator it; // writing the view provider names itself writer.incInd(); // indention for 'ViewProviderData Count' writer.Stream() << writer.ind() << "<ViewProviderData Count=\"" << d->_ViewProviderMap.size() <<"\">" << std::endl; bool xml = writer.isForceXML(); //writer.setForceXML(true); writer.incInd(); // indention for 'ViewProvider name' for(it = d->_ViewProviderMap.begin(); it != d->_ViewProviderMap.end(); ++it) { const App::DocumentObject* doc = it->first; ViewProvider* obj = it->second; writer.Stream() << writer.ind() << "<ViewProvider name=\"" << doc->getNameInDocument() << "\" " << "expanded=\"" << (doc->testStatus(App::Expand) ? 1:0) << "\">" << std::endl; obj->Save(writer); writer.Stream() << writer.ind() << "</ViewProvider>" << std::endl; } writer.setForceXML(xml); writer.decInd(); // indention for 'ViewProvider name' writer.Stream() << writer.ind() << "</ViewProviderData>" << std::endl; writer.decInd(); // indention for 'ViewProviderData Count' // set camera settings QString viewPos; if (d->_pcAppWnd->sendHasMsgToActiveView("GetCamera")) { const char* ppReturn=0; d->_pcAppWnd->sendMsgToActiveView("GetCamera",&ppReturn); // remove the first line because it's a comment like '#Inventor V2.1 ascii' QStringList lines = QString(QString::fromAscii(ppReturn)).split(QLatin1String("\n")); if (lines.size() > 1) { lines.pop_front(); viewPos = lines.join(QLatin1String(" ")); } } writer.incInd(); // indention for camera settings writer.Stream() << writer.ind() << "<Camera settings=\"" << (const char*)viewPos.toAscii() <<"\"/>" << std::endl; writer.decInd(); // indention for camera settings writer.Stream() << "</Document>" << std::endl; }
void PropertyMeshKernel::Save (Base::Writer &writer) const { if (writer.isForceXML()) { writer.Stream() << writer.ind() << "<Mesh>" << std::endl; MeshCore::MeshOutput saver(_meshObject->getKernel()); saver.SaveXML(writer); } else { writer.Stream() << writer.ind() << "<Mesh file=\"" << writer.addFile("MeshKernel.bms", this) << "\"/>" << std::endl; } }
void PropertyGreyValueList::Save (Base::Writer &writer) const { if (writer.isForceXML()) { writer.Stream() << writer.ind() << "<FloatList count=\"" << getSize() <<"\">" << endl; writer.incInd(); for(int i = 0;i<getSize(); i++) writer.Stream() << writer.ind() << "<F v=\"" << _lValueList[i] <<"\"/>" << endl; ; writer.decInd(); writer.Stream() << writer.ind() <<"</FloatList>" << endl ; } else { writer.Stream() << writer.ind() << "<FloatList file=\"" << writer.addFile(getName(), this) << "\"/>" << std::endl; } }
void Document::exportObjects(const std::vector<App::DocumentObject*>& obj, Base::Writer& writer) { writer.Stream() << "<?xml version='1.0' encoding='utf-8'?>" << std::endl; writer.Stream() << "<Document SchemaVersion=\"1\">" << std::endl; std::map<const App::DocumentObject*,ViewProvider*> views; for (std::vector<App::DocumentObject*>::const_iterator it = obj.begin(); it != obj.end(); ++it) { Document* doc = Application::Instance->getDocument((*it)->getDocument()); if (doc) { ViewProvider* vp = doc->getViewProvider(*it); if (vp) views[*it] = vp; } } // writing the view provider names itself writer.incInd(); // indention for 'ViewProviderData Count' writer.Stream() << writer.ind() << "<ViewProviderData Count=\"" << views.size() <<"\">" << std::endl; bool xml = writer.isForceXML(); //writer.setForceXML(true); writer.incInd(); // indention for 'ViewProvider name' std::map<const App::DocumentObject*,ViewProvider*>::const_iterator jt; for (jt = views.begin(); jt != views.end(); ++jt) { const App::DocumentObject* doc = jt->first; ViewProvider* obj = jt->second; writer.Stream() << writer.ind() << "<ViewProvider name=\"" << doc->getNameInDocument() << "\" type=\"" << obj->getTypeId().getName() << "\">" << std::endl; obj->Save(writer); writer.Stream() << writer.ind() << "</ViewProvider>" << std::endl; } writer.setForceXML(xml); writer.decInd(); // indention for 'ViewProvider name' writer.Stream() << writer.ind() << "</ViewProviderData>" << std::endl; writer.decInd(); // indention for 'ViewProviderData Count' writer.incInd(); // indention for camera settings writer.Stream() << writer.ind() << "<Camera settings=\"\"/>" << std::endl; writer.decInd(); // indention for camera settings writer.Stream() << "</Document>" << std::endl; }
/** * Adds a separate XML file to the projects file that contains information about the view providers. */ void Document::Save (Base::Writer &writer) const { // It's only possible to add extra information if force of XML is disabled if (writer.isForceXML() == false) { writer.addFile("GuiDocument.xml", this); if (App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/Document")->GetBool("SaveThumbnail",false)) { std::list<MDIView*> mdi = getMDIViews(); for (std::list<MDIView*>::iterator it = mdi.begin(); it != mdi.end(); ++it) { if ((*it)->getTypeId().isDerivedFrom(View3DInventor::getClassTypeId())) { View3DInventorViewer* view = static_cast<View3DInventor*>(*it)->getViewer(); d->thumb.setFileName(d->_pcDocument->FileName.getValue()); d->thumb.setSize(128); d->thumb.setViewer(view); d->thumb.Save(writer); break; } } } } }
void PropertyFileIncluded::Save (Base::Writer &writer) const { // when saving a document under a new file name the transient directory // name changes and thus the stored file name doesn't work any more. if (!_cValue.empty() && !Base::FileInfo(_cValue).exists()) { Base::FileInfo fi(getDocTransientPath() + "/" + _BaseFileName); if (fi.exists()) _cValue = fi.filePath(); } if (writer.isForceXML()) { if (!_cValue.empty()) { Base::FileInfo file(_cValue.c_str()); writer.Stream() << writer.ind() << "<FileIncluded data=\"" << file.fileName() << "\">" << std::endl; // write the file in the XML stream writer.incInd(); writer.insertBinFile(_cValue.c_str()); writer.decInd(); writer.Stream() << writer.ind() <<"</FileIncluded>" << endl; } else { writer.Stream() << writer.ind() << "<FileIncluded data=\"\"/>" << std::endl; } } else { // instead initiate an extra file if (!_cValue.empty()) { Base::FileInfo file(_cValue.c_str()); writer.Stream() << writer.ind() << "<FileIncluded file=\"" << writer.addFile(file.fileName().c_str(), this) << "\"/>" << std::endl; } else { writer.Stream() << writer.ind() << "<FileIncluded file=\"\"/>" << std::endl; } } }
void PropertyFilletEdges::Save (Base::Writer &writer) const { if (!writer.isForceXML()) { writer.Stream() << writer.ind() << "<FilletEdges file=\"" << writer.addFile(getName(), this) << "\"/>" << std::endl; } }
void Thumbnail::Save (Base::Writer &writer) const { // It's only possible to add extra information if force of XML is disabled if (writer.isForceXML() == false) writer.addFile("thumbnails/Thumbnail.png", this); }