+ small fixes to the Drawing Page
This commit is contained in:
parent
c6b0c86989
commit
529b92cbfe
|
@ -76,34 +76,11 @@ void FeaturePage::onChanged(const App::Property* prop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (prop == &Template) {
|
if (prop == &Template) {
|
||||||
// getting editable texts from "freecad:editable" tags in SVG template
|
|
||||||
if (!this->isRestoring()) {
|
if (!this->isRestoring()) {
|
||||||
if (Template.getValue() != "") {
|
cout << "setting template " << Template.getValue() << endl;
|
||||||
Base::FileInfo tfi(Template.getValue());
|
EditableTexts.setValues(getEditableTexts());
|
||||||
if (tfi.isReadable()) {
|
|
||||||
string tline, tfrag;
|
|
||||||
ifstream tfile (tfi.filePath().c_str());
|
|
||||||
while (!tfile.eof()) {
|
|
||||||
getline (tfile,tline);
|
|
||||||
tfrag += tline;
|
|
||||||
tfrag += "--endOfLine--";
|
|
||||||
}
|
|
||||||
tfile.close();
|
|
||||||
boost::regex e ("<text.*?freecad:editable=\"(.*?)\".*?<tspan.*?>(.*?)</tspan>");
|
|
||||||
string::const_iterator tbegin, tend;
|
|
||||||
tbegin = tfrag.begin();
|
|
||||||
tend = tfrag.end();
|
|
||||||
boost::match_results<std::string::const_iterator> twhat;
|
|
||||||
std::vector<string> eds;
|
|
||||||
while (boost::regex_search(tbegin, tend, twhat, e)) {
|
|
||||||
printf(twhat[1].str().c_str());
|
|
||||||
eds.push_back(twhat[2]);
|
|
||||||
tbegin = twhat[0].second;
|
|
||||||
}
|
|
||||||
EditableTexts.setValues(eds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else cout << "restoring" << endl;
|
||||||
}
|
}
|
||||||
App::DocumentObjectGroup::onChanged(prop);
|
App::DocumentObjectGroup::onChanged(prop);
|
||||||
}
|
}
|
||||||
|
@ -199,3 +176,40 @@ App::DocumentObjectExecReturn *FeaturePage::execute(void)
|
||||||
//}
|
//}
|
||||||
return App::DocumentObject::StdReturn;
|
return App::DocumentObject::StdReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> FeaturePage::getEditableTexts(void) const {
|
||||||
|
//getting editable texts from "freecad:editable" tags in SVG template
|
||||||
|
|
||||||
|
std::vector<string> eds;
|
||||||
|
|
||||||
|
if (Template.getValue() != "") {
|
||||||
|
Base::FileInfo tfi(Template.getValue());
|
||||||
|
if (!tfi.isReadable()) {
|
||||||
|
// if there is a old absolute template file set use a redirect
|
||||||
|
tfi.setFile(App::Application::getResourceDir() + "Mod/Drawing/Templates/" + tfi.fileName());
|
||||||
|
// try the redirect
|
||||||
|
if (!tfi.isReadable()) {
|
||||||
|
return eds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string tline, tfrag;
|
||||||
|
ifstream tfile (tfi.filePath().c_str());
|
||||||
|
while (!tfile.eof()) {
|
||||||
|
getline (tfile,tline);
|
||||||
|
tfrag += tline;
|
||||||
|
tfrag += "--endOfLine--";
|
||||||
|
}
|
||||||
|
tfile.close();
|
||||||
|
boost::regex e ("<text.*?freecad:editable=\"(.*?)\".*?<tspan.*?>(.*?)</tspan>");
|
||||||
|
string::const_iterator tbegin, tend;
|
||||||
|
tbegin = tfrag.begin();
|
||||||
|
tend = tfrag.end();
|
||||||
|
boost::match_results<std::string::const_iterator> twhat;
|
||||||
|
while (boost::regex_search(tbegin, tend, twhat, e)) {
|
||||||
|
printf(twhat[1].str().c_str());
|
||||||
|
eds.push_back(twhat[2]);
|
||||||
|
tbegin = twhat[0].second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return eds;
|
||||||
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
virtual const char* getViewProviderName(void) const {
|
virtual const char* getViewProviderName(void) const {
|
||||||
return "DrawingGui::ViewProviderDrawingPage";
|
return "DrawingGui::ViewProviderDrawingPage";
|
||||||
}
|
}
|
||||||
|
virtual std::vector<std::string> getEditableTexts(void) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onChanged(const App::Property* prop);
|
void onChanged(const App::Property* prop);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user