[TD] Use PropertyLength for LineWidths
- contributed by @uwe - also assure that the LineStyle is restricted to the range 0-5 fix another conversion routine mistake
This commit is contained in:
@@ -71,17 +71,15 @@ ViewProviderBalloon::ViewProviderBalloon()
|
||||
hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
double fontSize = hGrp->GetFloat("FontSize", QGIView::DefaultFontSizeInMM);
|
||||
ADD_PROPERTY_TYPE(Font ,(fontName.c_str()),group,App::Prop_None, "The name of the font to use");
|
||||
ADD_PROPERTY_TYPE(Fontsize,(fontSize) ,group,(App::PropertyType)(App::Prop_None),"Dimension text size in units");
|
||||
|
||||
|
||||
ADD_PROPERTY_TYPE(Font,(fontName.c_str()),group,App::Prop_None, "The name of the font to use");
|
||||
ADD_PROPERTY_TYPE(Fontsize,(fontSize),group,(App::PropertyType)(App::Prop_None),"Dimension text size in units");
|
||||
|
||||
hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
|
||||
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
|
||||
double weight = lg->getWeight("Thin");
|
||||
delete lg; //Coverity CID 174670
|
||||
ADD_PROPERTY_TYPE(LineWidth,(weight) ,group,(App::PropertyType)(App::Prop_None),"Dimension line weight");
|
||||
|
||||
ADD_PROPERTY_TYPE(LineWidth,(weight),group,(App::PropertyType)(App::Prop_None),"Balloon line width");
|
||||
|
||||
hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
@@ -170,3 +168,15 @@ TechDraw::DrawViewBalloon* ViewProviderBalloon::getViewObject() const
|
||||
{
|
||||
return dynamic_cast<TechDraw::DrawViewBalloon*>(pcObject);
|
||||
}
|
||||
|
||||
void ViewProviderBalloon::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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,11 +45,10 @@ public:
|
||||
/// destructor
|
||||
virtual ~ViewProviderBalloon();
|
||||
|
||||
App::PropertyFont Font;
|
||||
App::PropertyLength Fontsize;
|
||||
App::PropertyFloat LineWidth;
|
||||
App::PropertyColor Color;
|
||||
|
||||
App::PropertyFont Font;
|
||||
App::PropertyLength Fontsize;
|
||||
App::PropertyLength LineWidth;
|
||||
App::PropertyColor Color;
|
||||
|
||||
virtual void attach(App::DocumentObject *);
|
||||
virtual void setDisplayMode(const char* ModeName);
|
||||
@@ -63,6 +62,10 @@ public:
|
||||
virtual bool doubleClicked(void);
|
||||
|
||||
virtual TechDraw::DrawViewBalloon* getViewObject() const;
|
||||
|
||||
protected:
|
||||
virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop);
|
||||
|
||||
};
|
||||
|
||||
} // namespace TechDrawGui
|
||||
|
||||
@@ -67,7 +67,7 @@ ViewProviderDimension::ViewProviderDimension()
|
||||
ADD_PROPERTY_TYPE(Fontsize, (prefFontSize()), group, (App::PropertyType)(App::Prop_None),
|
||||
"Dimension text size in units");
|
||||
ADD_PROPERTY_TYPE(LineWidth, (prefWeight()), group, (App::PropertyType)(App::Prop_None),
|
||||
"Dimension line weight");
|
||||
"Dimension line width");
|
||||
ADD_PROPERTY_TYPE(Color,(prefColor()),group,App::Prop_None,"The color of the Dimension");
|
||||
ADD_PROPERTY_TYPE(StandardAndStyle, (prefStandardAndStyle()), group, App::Prop_None,
|
||||
"Specifies the standard according to which this dimension is drawn");
|
||||
@@ -203,3 +203,15 @@ int ViewProviderDimension::prefStandardAndStyle() const
|
||||
int standardStyle = hGrp->GetInt("StandardAndStyle", STD_STYLE_ISO_ORIENTED);
|
||||
return standardStyle;
|
||||
}
|
||||
|
||||
void ViewProviderDimension::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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* Copyright (c) 2012 Luke Parry <l.parry@warwick.ac.uk> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
@@ -44,10 +44,10 @@ public:
|
||||
/// destructor
|
||||
virtual ~ViewProviderDimension();
|
||||
|
||||
App::PropertyFont Font;
|
||||
App::PropertyLength Fontsize;
|
||||
App::PropertyFloat LineWidth;
|
||||
App::PropertyColor Color;
|
||||
App::PropertyFont Font;
|
||||
App::PropertyLength Fontsize;
|
||||
App::PropertyLength LineWidth;
|
||||
App::PropertyColor Color;
|
||||
|
||||
static const int STD_STYLE_ISO_ORIENTED = 0;
|
||||
static const int STD_STYLE_ISO_REFERENCING = 1;
|
||||
@@ -81,8 +81,10 @@ public:
|
||||
double prefWeight() const;
|
||||
int prefStandardAndStyle() const;
|
||||
|
||||
private:
|
||||
protected:
|
||||
virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop);
|
||||
|
||||
private:
|
||||
static const char *StandardAndStyleEnums[];
|
||||
static const char *RenderingExtentEnums[];
|
||||
|
||||
|
||||
@@ -59,6 +59,9 @@
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
// there are only 5 line styles
|
||||
App::PropertyIntegerConstraint::Constraints ViewProviderLeader::LineStyleRange = { 0, 5, 1 };
|
||||
|
||||
PROPERTY_SOURCE(TechDrawGui::ViewProviderLeader, TechDrawGui::ViewProviderDrawingView)
|
||||
|
||||
//**************************************************************************
|
||||
@@ -70,9 +73,11 @@ ViewProviderLeader::ViewProviderLeader()
|
||||
|
||||
static const char *group = "Line Format";
|
||||
|
||||
ADD_PROPERTY_TYPE(LineWidth,(getDefLineWeight()) ,group,(App::PropertyType)(App::Prop_None),"Line weight");
|
||||
ADD_PROPERTY_TYPE(LineStyle,(1) ,group,(App::PropertyType)(App::Prop_None),"Line style");
|
||||
ADD_PROPERTY_TYPE(LineWidth,(getDefLineWeight()),group,(App::PropertyType)(App::Prop_None),"Line width");
|
||||
ADD_PROPERTY_TYPE(LineStyle,(1),group,(App::PropertyType)(App::Prop_None),"Line style");
|
||||
ADD_PROPERTY_TYPE(Color,(getDefLineColor()),group,App::Prop_None,"The color of the Markup");
|
||||
|
||||
LineStyle.setConstraints(&LineStyleRange);
|
||||
}
|
||||
|
||||
ViewProviderLeader::~ViewProviderLeader()
|
||||
@@ -204,4 +209,23 @@ App::Color ViewProviderLeader::getDefLineColor(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
void ViewProviderLeader::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 LineStyle had the App::PropertyInteger and was changed to App::PropertyIntegerConstraint
|
||||
if (prop == &LineStyle && strcmp(TypeName, "App::PropertyInteger") == 0) {
|
||||
App::PropertyInteger LineStyleProperty;
|
||||
// restore the PropertyInteger to be able to set its value
|
||||
LineStyleProperty.Restore(reader);
|
||||
LineStyle.setValue(LineStyleProperty.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,9 +48,9 @@ public:
|
||||
/// destructor
|
||||
virtual ~ViewProviderLeader();
|
||||
|
||||
App::PropertyFloat LineWidth;
|
||||
App::PropertyInteger LineStyle;
|
||||
App::PropertyColor Color;
|
||||
App::PropertyLength LineWidth;
|
||||
App::PropertyIntegerConstraint LineStyle;
|
||||
App::PropertyColor Color;
|
||||
|
||||
virtual void attach(App::DocumentObject *);
|
||||
/* virtual void setDisplayMode(const char* ModeName);*/
|
||||
@@ -70,6 +70,11 @@ public:
|
||||
protected:
|
||||
double getDefLineWeight(void);
|
||||
App::Color getDefLineColor(void);
|
||||
virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop);
|
||||
|
||||
private:
|
||||
static App::PropertyIntegerConstraint::Constraints LineStyleRange;
|
||||
|
||||
};
|
||||
|
||||
} // namespace TechDrawGui
|
||||
|
||||
@@ -57,6 +57,9 @@
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
// there are only 5 frame line styles
|
||||
App::PropertyIntegerConstraint::Constraints ViewProviderRichAnno::LineStyleRange = {0, 5, 1};
|
||||
|
||||
PROPERTY_SOURCE(TechDrawGui::ViewProviderRichAnno, TechDrawGui::ViewProviderDrawingView)
|
||||
|
||||
//**************************************************************************
|
||||
@@ -68,9 +71,11 @@ ViewProviderRichAnno::ViewProviderRichAnno()
|
||||
|
||||
static const char *group = "Frame Format";
|
||||
|
||||
ADD_PROPERTY_TYPE(LineWidth,(getDefLineWeight()), group,(App::PropertyType)(App::Prop_None),"Frame line weight");
|
||||
ADD_PROPERTY_TYPE(LineStyle,(1), group,(App::PropertyType)(App::Prop_None),"Frame line style");
|
||||
ADD_PROPERTY_TYPE(LineWidth,(getDefLineWeight()), group,(App::PropertyType)(App::Prop_None),"Frame line width");
|
||||
ADD_PROPERTY_TYPE(LineStyle,(1),group,(App::PropertyType)(App::Prop_None),"Frame line style");
|
||||
ADD_PROPERTY_TYPE(LineColor,(getDefLineColor()),group,App::Prop_None,"The color of the frame");
|
||||
|
||||
LineStyle.setConstraints(&LineStyleRange);
|
||||
}
|
||||
|
||||
ViewProviderRichAnno::~ViewProviderRichAnno()
|
||||
@@ -175,4 +180,23 @@ double ViewProviderRichAnno::getDefLineWeight(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
void ViewProviderRichAnno::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 LineStyle had the App::PropertyInteger and was changed to App::PropertyIntegerConstraint
|
||||
if (prop == &LineStyle && strcmp(TypeName, "App::PropertyInteger") == 0) {
|
||||
App::PropertyInteger LineStyleProperty;
|
||||
// restore the PropertyInteger to be able to set its value
|
||||
LineStyleProperty.Restore(reader);
|
||||
LineStyle.setValue(LineStyleProperty.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ public:
|
||||
/// destructor
|
||||
virtual ~ViewProviderRichAnno();
|
||||
|
||||
App::PropertyFloat LineWidth;
|
||||
App::PropertyInteger LineStyle;
|
||||
App::PropertyColor LineColor;
|
||||
App::PropertyLength LineWidth;
|
||||
App::PropertyIntegerConstraint LineStyle;
|
||||
App::PropertyColor LineColor;
|
||||
|
||||
virtual void attach(App::DocumentObject *);
|
||||
virtual bool useNewSelectionModel(void) const {return false;}
|
||||
@@ -67,6 +67,10 @@ protected:
|
||||
std::string getDefFont(void);
|
||||
double getDefFontSize(void);
|
||||
double getDefLineWeight(void);
|
||||
virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop);
|
||||
|
||||
private:
|
||||
static App::PropertyIntegerConstraint::Constraints LineStyleRange;
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user