Remove magic number and hard type enums in DrawBrokenView.h
- Remove currently present magic numbers - Hard type enums, so magic numbers can no longer be introduced. We don't want people to introduce magic numbers.
This commit is contained in:
committed by
WandererFan
parent
79fdfb2cad
commit
e2446c4076
@@ -60,8 +60,7 @@ class TechDrawExport DrawBrokenView: public TechDraw::DrawViewPart
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(TechDraw::DrawBrokenView);
|
||||
|
||||
public:
|
||||
enum BreakType
|
||||
{
|
||||
enum class BreakType : int {
|
||||
NONE,
|
||||
ZIGZAG,
|
||||
SIMPLE
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include "Preferences.h"
|
||||
#include "DrawBrokenView.h"
|
||||
#include "LineGenerator.h"
|
||||
|
||||
//getters for parameters used in multiple places.
|
||||
@@ -593,9 +594,10 @@ bool Preferences::useExactMatchOnDims()
|
||||
return getPreferenceGroup("Dimensions")->GetBool("UseMatcher", true);
|
||||
}
|
||||
|
||||
int Preferences::BreakType()
|
||||
DrawBrokenView::BreakType Preferences::BreakType()
|
||||
{
|
||||
return getPreferenceGroup("Decorations")->GetInt("BreakType", 2);
|
||||
int temp = getPreferenceGroup("Decorations")->GetInt("BreakType", 2);
|
||||
return static_cast<DrawBrokenView::BreakType>(temp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <Base/Parameter.h>
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include "DrawBrokenView.h"
|
||||
|
||||
class QColor;
|
||||
class QString;
|
||||
@@ -136,7 +137,7 @@ public:
|
||||
static bool showSectionLine();
|
||||
static bool includeCutLine();
|
||||
|
||||
static int BreakType();
|
||||
static DrawBrokenView::BreakType BreakType();
|
||||
|
||||
static bool useExactMatchOnDims();
|
||||
|
||||
|
||||
@@ -71,21 +71,21 @@ QGIBreakLine::QGIBreakLine()
|
||||
|
||||
void QGIBreakLine::draw()
|
||||
{
|
||||
if (breakType() == 0) {
|
||||
if (breakType() == DrawBrokenView::BreakType::NONE) {
|
||||
// none
|
||||
m_background->hide();
|
||||
m_line0->hide();
|
||||
m_line1->hide();
|
||||
}
|
||||
|
||||
if (breakType() == 1) {
|
||||
if (breakType() == DrawBrokenView::BreakType::ZIGZAG) {
|
||||
drawLargeZigZag();
|
||||
m_background->show();
|
||||
m_line0->show();
|
||||
m_line1->show();
|
||||
}
|
||||
|
||||
if (breakType() == 2) {
|
||||
if (breakType() == DrawBrokenView::BreakType::SIMPLE) {
|
||||
// simple line from pref
|
||||
drawSimpleLines();
|
||||
m_background->hide();
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "QGCustomText.h"
|
||||
#include "QGIDecoration.h"
|
||||
|
||||
using BreakType = TechDraw::DrawBrokenView::BreakType;
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
@@ -59,8 +60,8 @@ public:
|
||||
void setLinePen(QPen isoPen);
|
||||
void setBreakColor(QColor c);
|
||||
|
||||
void setBreakType(int style) { m_breakType = style; }
|
||||
int breakType() const { return m_breakType; }
|
||||
void setBreakType(BreakType style) { m_breakType = style; }
|
||||
BreakType breakType() const { return m_breakType; }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -84,7 +85,7 @@ private:
|
||||
double m_left;
|
||||
double m_right;
|
||||
|
||||
int m_breakType{0};
|
||||
BreakType m_breakType = BreakType::NONE;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1043,7 +1043,7 @@ void QGIViewPart::drawBreakLines()
|
||||
return;
|
||||
}
|
||||
|
||||
auto breakType = vp->BreakLineType.getValue();
|
||||
DrawBrokenView::BreakType breakType = static_cast<DrawBrokenView::BreakType>(vp->BreakLineType.getValue());
|
||||
auto breaks = dbv->Breaks.getValues();
|
||||
for (auto& breakObj : breaks) {
|
||||
QGIBreakLine* breakLine = new QGIBreakLine();
|
||||
|
||||
@@ -132,7 +132,7 @@ ViewProviderViewPart::ViewProviderViewPart()
|
||||
|
||||
// properties that affect BrokenViews
|
||||
BreakLineType.setEnums(DrawBrokenView::BreakTypeEnums);
|
||||
ADD_PROPERTY_TYPE(BreakLineType, (Preferences::BreakType()), bvgroup, App::Prop_None,
|
||||
ADD_PROPERTY_TYPE(BreakLineType, (static_cast<int>(Preferences::BreakType())), bvgroup, App::Prop_None,
|
||||
"Adjusts the type of break line depiction on broken views");
|
||||
ADD_PROPERTY_TYPE(BreakLineStyle, (Preferences::BreakLineStyle()), bvgroup, App::Prop_None,
|
||||
"Set break line style if applicable");
|
||||
|
||||
Reference in New Issue
Block a user