TechDraw: Link related changes
* Support link and group objects * Support view sync by implementing view provider API getMDIView() * Use handleChangedPropertyType() for object migration instead of reimplementing Restore() because of a lots of changes in PropertyContainer::Restore(). * Various other small fixes.
This commit is contained in:
@@ -80,7 +80,7 @@ DrawPage::DrawPage(void)
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
bool autoUpdate = hGrp->GetBool("KeepPagesUpToDate", 1l);
|
||||
|
||||
ADD_PROPERTY_TYPE(KeepUpdated, (autoUpdate), group, (App::PropertyType)(App::Prop_None), "Keep page in sync with model");
|
||||
ADD_PROPERTY_TYPE(KeepUpdated, (autoUpdate), group, (App::PropertyType)(App::Prop_Output), "Keep page in sync with model");
|
||||
ADD_PROPERTY_TYPE(Template, (0), group, (App::PropertyType)(App::Prop_None), "Attached Template");
|
||||
Template.setScope(App::LinkScope::Global);
|
||||
ADD_PROPERTY_TYPE(Views, (0), group, (App::PropertyType)(App::Prop_None), "Attached Views");
|
||||
@@ -417,68 +417,26 @@ int DrawPage::getNextBalloonIndex(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawPage::Restore(Base::XMLReader &reader)
|
||||
void DrawPage::handleChangedPropertyType(
|
||||
Base::XMLReader &reader, const char * TypeName, App::Property * prop)
|
||||
{
|
||||
reader.readElement("Properties");
|
||||
int Cnt = reader.getAttributeAsInteger("Count");
|
||||
|
||||
for (int i=0 ;i<Cnt ;i++) {
|
||||
reader.readElement("Property");
|
||||
const char* PropName = reader.getAttribute("name");
|
||||
const char* TypeName = reader.getAttribute("type");
|
||||
App::Property* schemaProp = getPropertyByName(PropName);
|
||||
try {
|
||||
if(schemaProp){
|
||||
if (strcmp(schemaProp->getTypeId().getName(), TypeName) == 0){ //if the property type in obj == type in schema
|
||||
schemaProp->Restore(reader); //nothing special to do
|
||||
} else {
|
||||
if (strcmp(PropName, "Scale") == 0) {
|
||||
if (schemaProp->isDerivedFrom(App::PropertyFloatConstraint::getClassTypeId())){ //right property type
|
||||
schemaProp->Restore(reader); //nothing special to do
|
||||
} else { //Scale, but not PropertyFloatConstraint
|
||||
App::PropertyFloat tmp;
|
||||
if (strcmp(tmp.getTypeId().getName(),TypeName)) { //property in file is Float
|
||||
tmp.setContainer(this);
|
||||
tmp.Restore(reader);
|
||||
double tmpValue = tmp.getValue();
|
||||
if (tmpValue > 0.0) {
|
||||
static_cast<App::PropertyFloatConstraint*>(schemaProp)->setValue(tmpValue);
|
||||
} else {
|
||||
static_cast<App::PropertyFloatConstraint*>(schemaProp)->setValue(1.0);
|
||||
}
|
||||
} else {
|
||||
// has Scale prop that isn't Float!
|
||||
Base::Console().Log("DrawPage::Restore - old Document Scale is Not Float!\n");
|
||||
// no idea
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Base::Console().Log("DrawPage::Restore - old Document has unknown Property\n");
|
||||
}
|
||||
}
|
||||
if (prop == &Scale) {
|
||||
App::PropertyFloat tmp;
|
||||
if (strcmp(tmp.getTypeId().getName(),TypeName)==0) { //property in file is Float
|
||||
tmp.setContainer(this);
|
||||
tmp.Restore(reader);
|
||||
double tmpValue = tmp.getValue();
|
||||
if (tmpValue > 0.0) {
|
||||
Scale.setValue(tmpValue);
|
||||
} else {
|
||||
Scale.setValue(1.0);
|
||||
}
|
||||
} else {
|
||||
// has Scale prop that isn't Float!
|
||||
Base::Console().Log("DrawPage::Restore - old Document Scale is Not Float!\n");
|
||||
// no idea
|
||||
}
|
||||
catch (const Base::XMLParseException&) {
|
||||
throw; // re-throw
|
||||
}
|
||||
catch (const Base::Exception &e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
}
|
||||
catch (const std::exception &e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
}
|
||||
catch (const char* e) {
|
||||
Base::Console().Error("%s\n", e);
|
||||
}
|
||||
#ifndef FC_DEBUG
|
||||
catch (...) {
|
||||
Base::Console().Error("PropertyContainer::Restore: Unknown C++ exception thrown\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
reader.readEndElement("Property");
|
||||
}
|
||||
reader.readEndElement("Properties");
|
||||
}
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user