本文整理汇总了C++中ViewProvider::Restore方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewProvider::Restore方法的具体用法?C++ ViewProvider::Restore怎么用?C++ ViewProvider::Restore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewProvider
的用法示例。
在下文中一共展示了ViewProvider::Restore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RestoreDocFile
/**
* Restores the properties of the view providers.
*/
void Document::RestoreDocFile(Base::Reader &reader)
{
// We must create an XML parser to read from the input stream
Base::XMLReader xmlReader("GuiDocument.xml", reader);
int i,Cnt;
xmlReader.readElement("Document");
long scheme = xmlReader.getAttributeAsInteger("SchemaVersion");
// At this stage all the document objects and their associated view providers exist.
// Now we must restore the properties of the view providers only.
//
// SchemeVersion "1"
if (scheme == 1) {
// read the viewproviders itself
xmlReader.readElement("ViewProviderData");
Cnt = xmlReader.getAttributeAsInteger("Count");
for (i=0 ;i<Cnt ;i++) {
xmlReader.readElement("ViewProvider");
std::string name = xmlReader.getAttribute("name");
ViewProvider* pObj = getViewProviderByName(name.c_str());
if (pObj) // check if this feature has been registered
pObj->Restore(xmlReader);
xmlReader.readEndElement("ViewProvider");
}
xmlReader.readEndElement("ViewProviderData");
// read camera settings
xmlReader.readElement("Camera");
const char* ppReturn = xmlReader.getAttribute("settings");
std::string sMsg = "SetCamera ";
sMsg += ppReturn;
if (strcmp(ppReturn, "") != 0) { // non-empty attribute
try {
if (d->_pcAppWnd->sendHasMsgToActiveView("SetCamera"))
d->_pcAppWnd->sendMsgToActiveView(sMsg.c_str());
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
}
}
}
xmlReader.readEndElement("Document");
// In the file GuiDocument.xml new data files might be added
if (!xmlReader.getFilenames().empty())
xmlReader.readFiles(static_cast<zipios::ZipInputStream&>(reader));
// reset modifeid flag
setModified(false);
}
示例2: importObjects
void Document::importObjects(const std::vector<App::DocumentObject*>& obj, Base::Reader& reader)
{
// We must create an XML parser to read from the input stream
Base::XMLReader xmlReader("GuiDocument.xml", reader);
xmlReader.readElement("Document");
long scheme = xmlReader.getAttributeAsInteger("SchemaVersion");
// At this stage all the document objects and their associated view providers exist.
// Now we must restore the properties of the view providers only.
//
// SchemeVersion "1"
if (scheme == 1) {
// read the viewproviders itself
xmlReader.readElement("ViewProviderData");
int Cnt = xmlReader.getAttributeAsInteger("Count");
std::vector<App::DocumentObject*>::const_iterator it = obj.begin();
for (int i=0;i<Cnt&&it!=obj.end();++i,++it) {
// The stored name usually doesn't match with the current name anymore
// thus we try to match by type. This should work because the order of
// objects should not have changed
xmlReader.readElement("ViewProvider");
std::string type = xmlReader.getAttribute("type");
ViewProvider* pObj = getViewProvider(*it);
while (pObj && type != pObj->getTypeId().getName()) {
if (it != obj.end()) {
++it;
pObj = getViewProvider(*it);
}
}
if (pObj && type == pObj->getTypeId().getName())
pObj->Restore(xmlReader);
xmlReader.readEndElement("ViewProvider");
if (it == obj.end())
break;
}
xmlReader.readEndElement("ViewProviderData");
}
xmlReader.readEndElement("Document");
}
示例3: RestoreDocFile
/**
* Restores the properties of the view providers.
*/
void Document::RestoreDocFile(Base::Reader &reader)
{
// We must create an XML parser to read from the input stream
Base::XMLReader xmlReader("GuiDocument.xml", reader);
xmlReader.FileVersion = reader.getFileVersion();
int i,Cnt;
xmlReader.readElement("Document");
long scheme = xmlReader.getAttributeAsInteger("SchemaVersion");
// At this stage all the document objects and their associated view providers exist.
// Now we must restore the properties of the view providers only.
//
// SchemeVersion "1"
if (scheme == 1) {
// read the viewproviders itself
xmlReader.readElement("ViewProviderData");
Cnt = xmlReader.getAttributeAsInteger("Count");
for (i=0 ;i<Cnt ;i++) {
xmlReader.readElement("ViewProvider");
std::string name = xmlReader.getAttribute("name");
bool expanded = false;
if (xmlReader.hasAttribute("expanded")) {
const char* attr = xmlReader.getAttribute("expanded");
if (strcmp(attr,"1") == 0) {
expanded = true;
}
}
ViewProvider* pObj = getViewProviderByName(name.c_str());
if (pObj) // check if this feature has been registered
pObj->Restore(xmlReader);
if (pObj && expanded) {
Gui::ViewProviderDocumentObject* vp = static_cast<Gui::ViewProviderDocumentObject*>(pObj);
this->signalExpandObject(*vp, Gui::Expand);
}
xmlReader.readEndElement("ViewProvider");
}
xmlReader.readEndElement("ViewProviderData");
// read camera settings
xmlReader.readElement("Camera");
const char* ppReturn = xmlReader.getAttribute("settings");
std::string sMsg = "SetCamera ";
sMsg += ppReturn;
if (strcmp(ppReturn, "") != 0) { // non-empty attribute
try {
const char** pReturnIgnore=0;
std::list<MDIView*> mdi = getMDIViews();
for (std::list<MDIView*>::iterator it = mdi.begin(); it != mdi.end(); ++it) {
if ((*it)->onHasMsg("SetCamera"))
(*it)->onMsg(sMsg.c_str(), pReturnIgnore);
}
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
}
}
}
xmlReader.readEndElement("Document");
// In the file GuiDocument.xml new data files might be added
if (!xmlReader.getFilenames().empty())
xmlReader.readFiles(static_cast<zipios::ZipInputStream&>(reader.getStream()));
// reset modified flag
setModified(false);
}