TD: add units for line widths

- this also prevents negative values
- also fix an issue in DrawViewBalloon introduced by me recently
This commit is contained in:
donovaly
2019-12-07 04:26:15 +01:00
committed by WandererFan
parent 70be2a2bff
commit bb2db008ad
3 changed files with 38 additions and 6 deletions

View File

@@ -136,8 +136,8 @@ void DrawViewBalloon::handleChangedPropertyType(Base::XMLReader &reader, const c
// property OriginX had the App::PropertyFloat and was changed to App::PropertyLength
if (prop == &OriginX && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyInteger OriginXProperty;
// restore the PropertyInteger to be able to set its value
App::PropertyFloat OriginXProperty;
// restore the PropertyFloat to be able to set its value
OriginXProperty.Restore(reader);
OriginX.setValue(OriginXProperty.getValue());
}

View File

@@ -215,3 +215,33 @@ TechDraw::DrawViewPart* ViewProviderViewPart::getViewPart() const
{
return getViewObject();
}
void ViewProviderViewPart::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop)
// transforms properties that had been changed
{
// property LineWidth had the App::PropertyFloat and was changed to App::PropertyLength
if (prop == &LineWidth && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat LineWidthProperty;
// restore the PropertyFloat to be able to set its value
LineWidthProperty.Restore(reader);
LineWidth.setValue(LineWidthProperty.getValue());
}
// property HiddenWidth had the App::PropertyFloat and was changed to App::PropertyLength
else if (prop == &HiddenWidth && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat HiddenWidthProperty;
HiddenWidthProperty.Restore(reader);
HiddenWidth.setValue(HiddenWidthProperty.getValue());
}
// property IsoWidth had the App::PropertyFloat and was changed to App::PropertyLength
else if (prop == &IsoWidth && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat IsoWidthProperty;
IsoWidthProperty.Restore(reader);
IsoWidth.setValue(IsoWidthProperty.getValue());
}
// property ExtraWidth had the App::PropertyFloat and was changed to App::PropertyLength
else if (prop == &ExtraWidth && strcmp(TypeName, "App::PropertyFloat") == 0) {
App::PropertyFloat ExtraWidthProperty;
ExtraWidthProperty.Restore(reader);
ExtraWidth.setValue(ExtraWidthProperty.getValue());
}
}

View File

@@ -43,10 +43,10 @@ public:
/// destructor
virtual ~ViewProviderViewPart();
App::PropertyFloat LineWidth;
App::PropertyFloat HiddenWidth;
App::PropertyFloat IsoWidth;
App::PropertyFloat ExtraWidth;
App::PropertyLength LineWidth;
App::PropertyLength HiddenWidth;
App::PropertyLength IsoWidth;
App::PropertyLength ExtraWidth;
App::PropertyBool ArcCenterMarks;
App::PropertyFloat CenterScale;
App::PropertyBool HorizCenterLine;
@@ -64,6 +64,8 @@ public:
public:
virtual void onChanged(const App::Property *prop);
virtual void updateData(const App::Property*);
virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop);
virtual std::vector<App::DocumentObject*> claimChildren(void) const;