Gui::Document: fix saving of camera setting
This commit is contained in:
@@ -1360,27 +1360,20 @@ void Document::SaveDocFile (Base::Writer &writer) const
|
||||
writer.Stream() << writer.ind() << "</ViewProviderData>" << std::endl;
|
||||
writer.decInd(); // indentation for 'ViewProviderData Count'
|
||||
|
||||
// set camera settings
|
||||
QString viewPos;
|
||||
// save camera settings
|
||||
std::list<MDIView*> mdi = getMDIViews();
|
||||
for (std::list<MDIView*>::iterator it = mdi.begin(); it != mdi.end(); ++it) {
|
||||
if ((*it)->onHasMsg("GetCamera")) {
|
||||
const char* ppReturn=0;
|
||||
(*it)->onMsg("GetCamera",&ppReturn);
|
||||
|
||||
// remove the first line because it's a comment like '#Inventor V2.1 ascii'
|
||||
QStringList lines = QString(QString::fromLatin1(ppReturn)).split(QLatin1String("\n"));
|
||||
if (lines.size() > 1) {
|
||||
lines.pop_front();
|
||||
viewPos = lines.join(QLatin1String(" "));
|
||||
if(saveCameraSettings(ppReturn))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writer.incInd(); // indentation for camera settings
|
||||
writer.Stream() << writer.ind() << "<Camera settings=\""
|
||||
<< (const char*)viewPos.toLatin1() <<"\"/>" << std::endl;
|
||||
<< encodeAttribute(getCameraSettings()) << "\"/>\n";
|
||||
writer.decInd(); // indentation for camera settings
|
||||
writer.Stream() << "</Document>" << std::endl;
|
||||
}
|
||||
@@ -1621,13 +1614,32 @@ Gui::MDIView* Document::cloneView(Gui::MDIView* oldview)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const std::string &Document::getCameraSettings() const {
|
||||
return cameraSettings;
|
||||
const char *Document::getCameraSettings() const {
|
||||
return cameraSettings.size()>10?cameraSettings.c_str()+10:cameraSettings.c_str();
|
||||
}
|
||||
|
||||
void Document::saveCameraSettings(const char *settings) {
|
||||
if(settings && settings[0])
|
||||
cameraSettings = std::string("SetCamera ") + settings;
|
||||
bool Document::saveCameraSettings(const char *settings) const {
|
||||
if(!settings)
|
||||
return false;
|
||||
|
||||
// skip starting comment lines
|
||||
bool skipping = false;
|
||||
char c = *settings;
|
||||
for(;c;c=*(++settings)) {
|
||||
if(skipping) {
|
||||
if(c == '\n')
|
||||
skipping = false;
|
||||
} else if(c == '#')
|
||||
skipping = true;
|
||||
else if(!std::isspace(c))
|
||||
break;
|
||||
}
|
||||
|
||||
if(!c)
|
||||
return false;
|
||||
|
||||
cameraSettings = std::string("SetCamera ") + settings;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Document::attachView(Gui::BaseView* pcView, bool bPassiv)
|
||||
|
||||
@@ -293,8 +293,8 @@ public:
|
||||
|
||||
virtual PyObject *getPyObject(void);
|
||||
|
||||
const std::string &getCameraSettings() const;
|
||||
void saveCameraSettings(const char *);
|
||||
const char *getCameraSettings() const;
|
||||
bool saveCameraSettings(const char *) const;
|
||||
|
||||
protected:
|
||||
// pointer to the python class
|
||||
@@ -310,7 +310,7 @@ private:
|
||||
struct DocumentP* d;
|
||||
static int _iDocCount;
|
||||
|
||||
std::string cameraSettings;
|
||||
mutable std::string cameraSettings;
|
||||
|
||||
/** @name attributes for the UNDO REDO facility
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user