Skip to content

Commit

Permalink
TD: add units for line widths
Browse files Browse the repository at this point in the history
- this also prevents negative values
- also fix an issue in DrawViewBalloon introduced by me recently
  • Loading branch information
donovaly authored and WandererFan committed Dec 7, 2019
1 parent 2fa9369 commit de1be3b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Mod/TechDraw/App/DrawViewBalloon.cpp
Expand Up @@ -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());
}
Expand Down
30 changes: 30 additions & 0 deletions src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp
Expand Up @@ -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());
}
}
10 changes: 6 additions & 4 deletions src/Mod/TechDraw/Gui/ViewProviderViewPart.h
Expand Up @@ -43,10 +43,10 @@ class TechDrawGuiExport ViewProviderViewPart : public ViewProviderDrawingView
/// 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;
Expand All @@ -64,6 +64,8 @@ class TechDrawGuiExport ViewProviderViewPart : public ViewProviderDrawingView
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;

Expand Down

0 comments on commit de1be3b

Please sign in to comment.