[TechDraw] Simplify code getting default line weights
This commit is contained in:
committed by
WandererFan
parent
750fa24b2e
commit
86dfd0a862
@@ -104,12 +104,7 @@ std::string LineFormat::toString(void) const
|
||||
//static preference getters.
|
||||
double LineFormat::getDefEdgeWidth()
|
||||
{
|
||||
int lgNumber = Preferences::lineGroup();
|
||||
auto lg = TechDraw::LineGroup::lineGroupFactory(lgNumber);
|
||||
|
||||
double width = lg->getWeight("Graphic");
|
||||
delete lg;
|
||||
return width;
|
||||
return TechDraw::LineGroup::getDefaultWidth("Graphic");
|
||||
}
|
||||
|
||||
App::Color LineFormat::getDefEdgeColor()
|
||||
@@ -136,7 +131,7 @@ CosmeticVertex::CosmeticVertex() : TechDraw::Vertex()
|
||||
linkGeom = -1;
|
||||
color = Preferences::vertexColor();
|
||||
size = Preferences::vertexScale() *
|
||||
LineGroup::getDefaultWidth("Thick", Preferences::lineGroup());
|
||||
LineGroup::getDefaultWidth("Thick");
|
||||
style = 1;
|
||||
visible = true;
|
||||
hlrVisible = true;
|
||||
@@ -165,7 +160,7 @@ CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
|
||||
linkGeom = -1;
|
||||
color = Preferences::vertexColor();
|
||||
size = Preferences::vertexScale() *
|
||||
LineGroup::getDefaultWidth("Thick", Preferences::lineGroup());
|
||||
LineGroup::getDefaultWidth("Thick");
|
||||
style = 1; //TODO: implement styled vertexes
|
||||
visible = true;
|
||||
hlrVisible = true;
|
||||
|
||||
@@ -522,12 +522,7 @@ double DrawUtil::sensibleScale(double working_scale)
|
||||
|
||||
double DrawUtil::getDefaultLineWeight(std::string lineType)
|
||||
{
|
||||
int lgNumber = Preferences::lineGroup();
|
||||
auto lg = LineGroup::lineGroupFactory(lgNumber);
|
||||
|
||||
double weight = lg->getWeight(lineType);
|
||||
delete lg; //Coverity CID 174671
|
||||
return weight;
|
||||
return TechDraw::LineGroup::getDefaultWidth(lineType);
|
||||
}
|
||||
|
||||
bool DrawUtil::isBetween(const Base::Vector3d pt, const Base::Vector3d end1, const Base::Vector3d end2)
|
||||
|
||||
@@ -178,15 +178,19 @@ LineGroup* LineGroup::lineGroupFactory(int groupNumber)
|
||||
return lg;
|
||||
}
|
||||
|
||||
//valid weight names: Thick, Thin, Graphic, Extra
|
||||
double LineGroup::getDefaultWidth(std::string weightName, int groupNumber)
|
||||
/**
|
||||
* @brief Returns the default line width given a weight name and group number.
|
||||
*
|
||||
* @param weightName can be "Thick", "Thin", "Graphic" or "Extra"
|
||||
* @param lineGroupNumber if -1 will then use groupNumber in preferences. Default value is -1.
|
||||
* @return the default line width.
|
||||
*/
|
||||
double LineGroup::getDefaultWidth(std::string weightName, int lineGroupNumber)
|
||||
{
|
||||
//default line weights
|
||||
int lgNumber = groupNumber;
|
||||
if (lgNumber == -1) {
|
||||
lgNumber = Preferences::lineGroup();
|
||||
if (lineGroupNumber == -1) {
|
||||
lineGroupNumber = Preferences::lineGroup();
|
||||
}
|
||||
auto lg = TechDraw::LineGroup::lineGroupFactory(lgNumber);
|
||||
auto lg = TechDraw::LineGroup::lineGroupFactory(lineGroupNumber);
|
||||
|
||||
double weight = lg->getWeight(weightName);
|
||||
delete lg;
|
||||
|
||||
Reference in New Issue
Block a user