diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp
index b818b2744..dbf57e8b6 100644
--- a/src/app/dialogs/tools/dialogalongline.cpp
+++ b/src/app/dialogs/tools/dialogalongline.cpp
@@ -60,7 +60,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId,
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
- FillComboBoxTypeLine(ui->comboBoxLineType);
+ FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
ui->comboBoxLineType->setCurrentIndex(0);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere);
@@ -189,7 +189,7 @@ void DialogAlongLine::SaveData()
line->setPoint1Id(firstPointId);
line->setPoint2Id(secondPointId);
line->setLength(formula);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
line->RefreshGeometry();
}
@@ -249,7 +249,7 @@ void DialogAlongLine::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/app/dialogs/tools/dialogalongline.ui b/src/app/dialogs/tools/dialogalongline.ui
index ccefaa068..a2e13e7e6 100644
--- a/src/app/dialogs/tools/dialogalongline.ui
+++ b/src/app/dialogs/tools/dialogalongline.ui
@@ -276,9 +276,27 @@
0
+
+
+ 80
+ 0
+
+
+
+
+ 110
+ 16777215
+
+
Show line from first point to this point
+
+
+ 80
+ 14
+
+
diff --git a/src/app/dialogs/tools/dialogbisector.cpp b/src/app/dialogs/tools/dialogbisector.cpp
index 791ca123c..90c4449ed 100644
--- a/src/app/dialogs/tools/dialogbisector.cpp
+++ b/src/app/dialogs/tools/dialogbisector.cpp
@@ -60,7 +60,7 @@ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QW
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
- FillComboBoxTypeLine(ui->comboBoxLineType);
+ FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
FillComboBoxPoints(ui->comboBoxThirdPoint);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogBisector::PutHere);
@@ -218,7 +218,7 @@ void DialogBisector::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
}
//---------------------------------------------------------------------------------------------------------------------
@@ -287,7 +287,7 @@ void DialogBisector::SaveData()
line->setPoint2Id(secondPointId);
line->setPoint3Id(thirdPointId);
line->setLength(formula);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
line->RefreshGeometry();
}
diff --git a/src/app/dialogs/tools/dialogbisector.ui b/src/app/dialogs/tools/dialogbisector.ui
index 3f81fc51f..c4ad6001a 100644
--- a/src/app/dialogs/tools/dialogbisector.ui
+++ b/src/app/dialogs/tools/dialogbisector.ui
@@ -302,9 +302,27 @@
-
+
+
+ 80
+ 0
+
+
+
+
+ 110
+ 16777215
+
+
Show line from second point to this point
+
+
+ 80
+ 14
+
+
diff --git a/src/app/dialogs/tools/dialogcurveintersectaxis.cpp b/src/app/dialogs/tools/dialogcurveintersectaxis.cpp
index 17c5f87bd..43eefe4a4 100644
--- a/src/app/dialogs/tools/dialogcurveintersectaxis.cpp
+++ b/src/app/dialogs/tools/dialogcurveintersectaxis.cpp
@@ -56,7 +56,7 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const
FillComboBoxPoints(ui->comboBoxAxisPoint);
FillComboBoxCurves(ui->comboBoxCurve);
- FillComboBoxTypeLine(ui->comboBoxLineType);
+ FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::PutAngle);
connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogCurveIntersectAxis::PutVal);
@@ -103,7 +103,7 @@ void DialogCurveIntersectAxis::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
}
//---------------------------------------------------------------------------------------------------------------------
@@ -269,7 +269,7 @@ void DialogCurveIntersectAxis::SaveData()
line->setPoint1Id(curveId);
line->setAxisPointId(basePointId);
line->setAngle(formulaAngle);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
line->RefreshGeometry();
}
diff --git a/src/app/dialogs/tools/dialogcurveintersectaxis.ui b/src/app/dialogs/tools/dialogcurveintersectaxis.ui
index 4fe305a4f..39a9ccba9 100644
--- a/src/app/dialogs/tools/dialogcurveintersectaxis.ui
+++ b/src/app/dialogs/tools/dialogcurveintersectaxis.ui
@@ -285,9 +285,27 @@
-
+
+
+ 80
+ 0
+
+
+
+
+ 110
+ 16777215
+
+
Show line from first point to this point
+
+
+ 80
+ 14
+
+
diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp
index 8da548990..e450a5659 100644
--- a/src/app/dialogs/tools/dialogendline.cpp
+++ b/src/app/dialogs/tools/dialogendline.cpp
@@ -63,7 +63,7 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid
CheckState();
FillComboBoxPoints(ui->comboBoxBasePoint);
- FillComboBoxTypeLine(ui->comboBoxLineType);
+ FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
connect(ui->toolButtonPutHereLength, &QPushButton::clicked, this, &DialogEndLine::PutHere);
connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogEndLine::PutAngle);
@@ -173,7 +173,7 @@ void DialogEndLine::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
}
//---------------------------------------------------------------------------------------------------------------------
@@ -287,7 +287,7 @@ void DialogEndLine::SaveData()
line->setPoint1Id(basePointId);
line->setLength(formulaLength);
line->setAngle(formulaAngle);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
line->RefreshGeometry();
}
diff --git a/src/app/dialogs/tools/dialogendline.ui b/src/app/dialogs/tools/dialogendline.ui
index a34de47cc..a5e8259f5 100644
--- a/src/app/dialogs/tools/dialogendline.ui
+++ b/src/app/dialogs/tools/dialogendline.ui
@@ -454,9 +454,27 @@
-
+
+
+ 80
+ 0
+
+
+
+
+ 110
+ 16777215
+
+
Show line from first point to this point
+
+
+ 80
+ 14
+
+
diff --git a/src/app/dialogs/tools/dialogheight.cpp b/src/app/dialogs/tools/dialogheight.cpp
index 573906e79..b4f80756a 100644
--- a/src/app/dialogs/tools/dialogheight.cpp
+++ b/src/app/dialogs/tools/dialogheight.cpp
@@ -54,7 +54,7 @@ DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidge
FillComboBoxPoints(ui->comboBoxBasePoint);
FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line);
- FillComboBoxTypeLine(ui->comboBoxLineType);
+ FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged);
connect(ui->comboBoxBasePoint, static_cast(&QComboBox::currentIndexChanged),
this, &DialogHeight::PointNameChanged);
@@ -96,7 +96,7 @@ void DialogHeight::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
}
//---------------------------------------------------------------------------------------------------------------------
@@ -203,7 +203,7 @@ void DialogHeight::SaveData()
line->setPoint1Id(basePointId);
line->setLineP1Id(p1LineId);
line->setLineP2Id(p2LineId);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
line->RefreshGeometry();
}
diff --git a/src/app/dialogs/tools/dialogheight.ui b/src/app/dialogs/tools/dialogheight.ui
index be8edb8cf..4338c7de7 100644
--- a/src/app/dialogs/tools/dialogheight.ui
+++ b/src/app/dialogs/tools/dialogheight.ui
@@ -111,9 +111,27 @@
-
+
+
+ 80
+ 0
+
+
+
+
+ 110
+ 16777215
+
+
Show line from first point to our point
+
+
+ 80
+ 14
+
+
diff --git a/src/app/dialogs/tools/dialogline.cpp b/src/app/dialogs/tools/dialogline.cpp
index 287055246..1e62d1290 100644
--- a/src/app/dialogs/tools/dialogline.cpp
+++ b/src/app/dialogs/tools/dialogline.cpp
@@ -51,7 +51,10 @@ DialogLine::DialogLine(const VContainer *data, const quint32 &toolId, QWidget *p
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
- FillComboBoxTypeLine(ui->comboBoxLineType);
+
+ QMap stylesPics = VAbstractTool::LineStylesPics();
+ stylesPics.remove(VAbstractTool::TypeLineNone);// Prevent hiding line
+ FillComboBoxTypeLine(ui->comboBoxLineType, stylesPics);
number = 0;
@@ -93,7 +96,7 @@ void DialogLine::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
}
//---------------------------------------------------------------------------------------------------------------------
@@ -158,7 +161,7 @@ void DialogLine::SaveData()
line->setPoint1Id(firstPoint);
line->setPoint2Id(secondPoint);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
line->RefreshGeometry();
}
diff --git a/src/app/dialogs/tools/dialogline.ui b/src/app/dialogs/tools/dialogline.ui
index b02ea2911..50dc4afe7 100644
--- a/src/app/dialogs/tools/dialogline.ui
+++ b/src/app/dialogs/tools/dialogline.ui
@@ -122,13 +122,25 @@
- 0
+ 80
0
+
+
+ 110
+ 16777215
+
+
Show line from first point to this point
+
+
+ 80
+ 14
+
+
diff --git a/src/app/dialogs/tools/dialoglineintersectaxis.cpp b/src/app/dialogs/tools/dialoglineintersectaxis.cpp
index 7264e2a31..a7b77c1b1 100644
--- a/src/app/dialogs/tools/dialoglineintersectaxis.cpp
+++ b/src/app/dialogs/tools/dialoglineintersectaxis.cpp
@@ -57,7 +57,7 @@ DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const q
FillComboBoxPoints(ui->comboBoxAxisPoint);
FillComboBoxPoints(ui->comboBoxFirstLinePoint);
FillComboBoxPoints(ui->comboBoxSecondLinePoint);
- FillComboBoxTypeLine(ui->comboBoxLineType);
+ FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::PutAngle);
connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogLineIntersectAxis::PutVal);
@@ -112,7 +112,7 @@ void DialogLineIntersectAxis::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
}
//---------------------------------------------------------------------------------------------------------------------
@@ -336,7 +336,7 @@ void DialogLineIntersectAxis::SaveData()
line->setPoint2Id(secondPointId);
line->setAxisPointId(basePointId);
line->setAngle(formulaAngle);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
line->RefreshGeometry();
}
diff --git a/src/app/dialogs/tools/dialoglineintersectaxis.ui b/src/app/dialogs/tools/dialoglineintersectaxis.ui
index 31909167f..2ad7bac18 100644
--- a/src/app/dialogs/tools/dialoglineintersectaxis.ui
+++ b/src/app/dialogs/tools/dialoglineintersectaxis.ui
@@ -302,9 +302,27 @@
-
+
+
+ 80
+ 0
+
+
+
+
+ 110
+ 16777215
+
+
Show line from first point to this point
+
+
+ 80
+ 14
+
+
diff --git a/src/app/dialogs/tools/dialognormal.cpp b/src/app/dialogs/tools/dialognormal.cpp
index 2901361aa..1461259cd 100644
--- a/src/app/dialogs/tools/dialognormal.cpp
+++ b/src/app/dialogs/tools/dialognormal.cpp
@@ -56,7 +56,7 @@ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidge
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
- FillComboBoxTypeLine(ui->comboBoxLineType);
+ FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
InitArrow(ui);
@@ -183,7 +183,7 @@ void DialogNormal::SaveData()
line->setPoint2Id(secondPointId);
line->setLength(formula);
line->setAngle(angle);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
line->RefreshGeometry();
}
@@ -255,7 +255,7 @@ void DialogNormal::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/app/dialogs/tools/dialognormal.ui b/src/app/dialogs/tools/dialognormal.ui
index 492531abe..959714a6d 100644
--- a/src/app/dialogs/tools/dialognormal.ui
+++ b/src/app/dialogs/tools/dialognormal.ui
@@ -483,9 +483,27 @@
-
+
+
+ 80
+ 0
+
+
+
+
+ 110
+ 16777215
+
+
Show line from first point to this point
+
+
+ 80
+ 14
+
+
diff --git a/src/app/dialogs/tools/dialogpointofcontact.ui b/src/app/dialogs/tools/dialogpointofcontact.ui
index 5d9d5101d..3b5b1c350 100644
--- a/src/app/dialogs/tools/dialogpointofcontact.ui
+++ b/src/app/dialogs/tools/dialogpointofcontact.ui
@@ -317,10 +317,22 @@
- 145
+ 80
0
+
+
+ 110
+ 16777215
+
+
+
+
+ 80
+ 14
+
+
diff --git a/src/app/dialogs/tools/dialogshoulderpoint.cpp b/src/app/dialogs/tools/dialogshoulderpoint.cpp
index d2c5d4521..1ef046f91 100644
--- a/src/app/dialogs/tools/dialogshoulderpoint.cpp
+++ b/src/app/dialogs/tools/dialogshoulderpoint.cpp
@@ -58,7 +58,7 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &
flagFormula = false;
CheckState();
- FillComboBoxTypeLine(ui->comboBoxLineType);
+ FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line);
FillComboBoxPoints(ui->comboBoxP3);
@@ -212,7 +212,7 @@ void DialogShoulderPoint::SaveData()
line->setLineP1Id(p1Line);
line->setLineP2Id(p2Line);
line->setLength(formula);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
line->RefreshGeometry();
}
@@ -283,7 +283,7 @@ void DialogShoulderPoint::setTypeLine(const QString &value)
{
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
- line->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/app/dialogs/tools/dialogshoulderpoint.ui b/src/app/dialogs/tools/dialogshoulderpoint.ui
index 996d5cbee..8c306b556 100644
--- a/src/app/dialogs/tools/dialogshoulderpoint.ui
+++ b/src/app/dialogs/tools/dialogshoulderpoint.ui
@@ -341,9 +341,27 @@
0
+
+
+ 80
+ 0
+
+
+
+
+ 110
+ 16777215
+
+
Show line from first point to our point
+
+
+ 80
+ 14
+
+
diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp
index 2a0c7ae72..872a12c20 100644
--- a/src/app/dialogs/tools/dialogtool.cpp
+++ b/src/app/dialogs/tools/dialogtool.cpp
@@ -66,7 +66,7 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), checkBoxHideEmpty(nullptr),
- lineStyles(VAbstractTool::Styles()), okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr),
+ okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr),
toolId(toolId), prepare(false), pointName(QString())
{
SCASSERT(data != nullptr);
@@ -288,10 +288,16 @@ void DialogTool::FillComboBoxCurves(QComboBox *box) const
* @brief FillComboBoxTypeLine fill comboBox list of type lines
* @param box comboBox
*/
-void DialogTool::FillComboBoxTypeLine(QComboBox *box) const
+void DialogTool::FillComboBoxTypeLine(QComboBox *box, const QMap &stylesPics) const
{
SCASSERT(box != nullptr);
- box->addItems(lineStyles);
+ QMap::const_iterator i = stylesPics.constBegin();
+ while (i != stylesPics.constEnd())
+ {
+ box->addItem(i.value(), "", QVariant(i.key()));
+ ++i;
+ }
+
box->setCurrentIndex(1);
}
@@ -303,30 +309,13 @@ void DialogTool::FillComboBoxTypeLine(QComboBox *box) const
*/
QString DialogTool::GetTypeLine(const QComboBox *box) const
{
- switch (lineStyles.indexOf(box->currentText()))
+ SCASSERT(box != nullptr)
+ QString value = box->currentData().toString();
+ if (value.isEmpty())
{
- case 0: //No line
- return VAbstractTool::TypeLineNone;
- break;
- case 1: //Line
- return VAbstractTool::TypeLineLine;
- break;
- case 2: //Dash Line
- return VAbstractTool::TypeLineDashLine;
- break;
- case 3: //Dot Line
- return VAbstractTool::TypeLineDotLine;
- break;
- case 4: //Dash Dot Line
- return VAbstractTool::TypeLineDashDotLine;
- break;
- case 5: //Dash Dot Dot Line
- return VAbstractTool::TypeLineDashDotDotLine;
- break;
- default:
- return VAbstractTool::TypeLineLine;
- break;
+ value = VAbstractTool::TypeLineLine;
}
+ return value;
}
//---------------------------------------------------------------------------------------------------------------------
@@ -337,8 +326,8 @@ QString DialogTool::GetTypeLine(const QComboBox *box) const
*/
void DialogTool::SetupTypeLine(QComboBox *box, const QString &value)
{
- QStringList styles = VAbstractTool::Styles();
- qint32 index = box->findText(lineStyles.at(styles.indexOf(value)));
+ SCASSERT(box != nullptr)
+ const qint32 index = box->findData(value);
if (index != -1)
{
box->setCurrentIndex(index);
@@ -353,7 +342,8 @@ void DialogTool::SetupTypeLine(QComboBox *box, const QString &value)
*/
void DialogTool::ChangeCurrentData(QComboBox *box, const quint32 &value) const
{
- qint32 index = box->findData(value);
+ SCASSERT(box != nullptr)
+ const qint32 index = box->findData(value);
if (index != -1)
{
box->setCurrentIndex(index);
diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h
index 7bb48c2e3..7366a862e 100644
--- a/src/app/dialogs/tools/dialogtool.h
+++ b/src/app/dialogs/tools/dialogtool.h
@@ -193,8 +193,6 @@ protected:
QCheckBox *checkBoxHideEmpty;
- /** @brief lineStyles list supported line styles. */
- QStringList lineStyles;
const QColor okColor;
const QColor errorColor;
/**
@@ -217,7 +215,7 @@ protected:
void FillComboBoxSplinesPath(QComboBox *box,
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const;
void FillComboBoxCurves(QComboBox *box)const;
- void FillComboBoxTypeLine(QComboBox *box) const;
+ void FillComboBoxTypeLine(QComboBox *box, const QMap &stylesPics) const;
virtual void CheckState();
QString GetTypeLine(const QComboBox *box)const;
template
diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp
index 597618386..442e8d69a 100644
--- a/src/app/tools/drawTools/vtoolalongline.cpp
+++ b/src/app/tools/drawTools/vtoolalongline.cpp
@@ -87,7 +87,7 @@ void VToolAlongLine::FullUpdateFromFile()
visual->setPoint1Id(basePointId);
visual->setPoint2Id(secondPointId);
visual->setLength(qApp->FormulaToUser(formulaLength));
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
}
}
@@ -201,7 +201,7 @@ void VToolAlongLine::ShowVisualization(bool show)
visual->setPoint1Id(basePointId);
visual->setPoint2Id(secondPointId);
visual->setLength(qApp->FormulaToUser(formulaLength));
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp
index 3a4eefa53..96b42eadc 100644
--- a/src/app/tools/drawTools/vtoolbisector.cpp
+++ b/src/app/tools/drawTools/vtoolbisector.cpp
@@ -239,7 +239,7 @@ void VToolBisector::FullUpdateFromFile()
visual->setPoint2Id(basePointId);
visual->setPoint3Id(thirdPointId);
visual->setLength(qApp->FormulaToUser(formulaLength));
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
}
}
@@ -356,7 +356,7 @@ void VToolBisector::ShowVisualization(bool show)
visual->setPoint2Id(basePointId);
visual->setPoint3Id(thirdPointId);
visual->setLength(qApp->FormulaToUser(formulaLength));
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
diff --git a/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp b/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp
index ad60c3af9..3aa46c33f 100644
--- a/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp
+++ b/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp
@@ -227,7 +227,7 @@ void VToolCurveIntersectAxis::ShowVisualization(bool show)
visual->setPoint1Id(curveId);
visual->setAxisPointId(basePointId);
visual->setAngle(qApp->FormulaToUser(formulaAngle));
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
@@ -266,7 +266,7 @@ void VToolCurveIntersectAxis::FullUpdateFromFile()
visual->setPoint1Id(curveId);
visual->setAxisPointId(basePointId);
visual->setAngle(qApp->FormulaToUser(formulaAngle));
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
}
}
diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp
index 4a41806f3..3bc0fc2f8 100644
--- a/src/app/tools/drawTools/vtoolendline.cpp
+++ b/src/app/tools/drawTools/vtoolendline.cpp
@@ -197,7 +197,7 @@ void VToolEndLine::FullUpdateFromFile()
visual->setPoint1Id(basePointId);
visual->setLength(qApp->FormulaToUser(formulaLength));
visual->setAngle(qApp->FormulaToUser(formulaAngle));
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
}
}
@@ -293,7 +293,7 @@ void VToolEndLine::ShowVisualization(bool show)
visual->setPoint1Id(basePointId);
visual->setLength(qApp->FormulaToUser(formulaLength));
visual->setAngle(qApp->FormulaToUser(formulaAngle));
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
diff --git a/src/app/tools/drawTools/vtoolheight.cpp b/src/app/tools/drawTools/vtoolheight.cpp
index 25ea2a864..fd878a4ee 100644
--- a/src/app/tools/drawTools/vtoolheight.cpp
+++ b/src/app/tools/drawTools/vtoolheight.cpp
@@ -209,7 +209,7 @@ void VToolHeight::FullUpdateFromFile()
visual->setPoint1Id(basePointId);
visual->setLineP1Id(p1LineId);
visual->setLineP2Id(p2LineId);
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
}
}
@@ -301,7 +301,7 @@ void VToolHeight::ShowVisualization(bool show)
visual->setPoint1Id(basePointId);
visual->setLineP1Id(p1LineId);
visual->setLineP2Id(p2LineId);
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp
index ec85c2b29..a38daf2d5 100644
--- a/src/app/tools/drawTools/vtoolline.cpp
+++ b/src/app/tools/drawTools/vtoolline.cpp
@@ -61,7 +61,7 @@ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstP
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
- this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
+ this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
if (typeCreation == Source::FromGui)
{
@@ -196,7 +196,7 @@ void VToolLine::FullUpdateFromFile()
VisToolLine *visual = qobject_cast(vis);
visual->setPoint1Id(firstPoint);
visual->setPoint2Id(secondPoint);
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
}
}
@@ -239,7 +239,7 @@ void VToolLine::ChangedActivDraw(const QString &newName)
{
VDrawTool::ChangedActivDraw(newName);
this->setEnabled(nameActivDraw == newName);
- this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
+ this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
}
//---------------------------------------------------------------------------------------------------------------------
@@ -290,7 +290,7 @@ void VToolLine::RefreshDataInFile()
void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
- this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, LineStyle(typeLine)));
+ this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, LineStyleToPenStyle(typeLine)));
}
//---------------------------------------------------------------------------------------------------------------------
@@ -301,7 +301,7 @@ void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
- this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
+ this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
}
//---------------------------------------------------------------------------------------------------------------------
@@ -414,7 +414,7 @@ void VToolLine::ShowVisualization(bool show)
visual->setPoint1Id(firstPoint);
visual->setPoint2Id(secondPoint);
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
@@ -477,5 +477,5 @@ void VToolLine::RefreshGeometry()
const QSharedPointer first = VAbstractTool::data.GeometricObject(firstPoint);
const QSharedPointer second = VAbstractTool::data.GeometricObject(secondPoint);
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
- this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
+ this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
}
diff --git a/src/app/tools/drawTools/vtoollineintersectaxis.cpp b/src/app/tools/drawTools/vtoollineintersectaxis.cpp
index c9f28c18e..53f88fb5a 100644
--- a/src/app/tools/drawTools/vtoollineintersectaxis.cpp
+++ b/src/app/tools/drawTools/vtoollineintersectaxis.cpp
@@ -243,7 +243,7 @@ void VToolLineIntersectAxis::ShowVisualization(bool show)
visual->setPoint2Id(secondPointId);
visual->setAxisPointId(basePointId);
visual->setAngle(qApp->FormulaToUser(formulaAngle));
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
@@ -284,7 +284,7 @@ void VToolLineIntersectAxis::FullUpdateFromFile()
visual->setPoint2Id(secondPointId);
visual->setAxisPointId(basePointId);
visual->setAngle(qApp->FormulaToUser(formulaAngle));
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
}
}
diff --git a/src/app/tools/drawTools/vtoollinepoint.cpp b/src/app/tools/drawTools/vtoollinepoint.cpp
index 67983917c..1213c85ca 100644
--- a/src/app/tools/drawTools/vtoollinepoint.cpp
+++ b/src/app/tools/drawTools/vtoollinepoint.cpp
@@ -52,7 +52,7 @@ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &i
QPointF point1 = data->GeometricObject(basePointId)->toQPointF();
QPointF point2 = data->GeometricObject(id)->toQPointF();
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this);
- mainLine->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
+ mainLine->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
}
@@ -71,7 +71,7 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
{
VToolPoint::ChangedActivDraw(newName);
this->setEnabled(nameActivDraw == newName);
- mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
+ mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
}
//---------------------------------------------------------------------------------------------------------------------
@@ -80,7 +80,7 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
*/
void VToolLinePoint::RefreshGeometry()
{
- mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
+ mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id));
QPointF point = VDrawTool::data.GeometricObject(id)->toQPointF();
QPointF basePoint = VDrawTool::data.GeometricObject(basePointId)->toQPointF();
diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp
index abf347a7f..c4d9f9268 100644
--- a/src/app/tools/drawTools/vtoolnormal.cpp
+++ b/src/app/tools/drawTools/vtoolnormal.cpp
@@ -218,7 +218,7 @@ void VToolNormal::FullUpdateFromFile()
visual->setPoint2Id(secondPointId);
visual->setLength(qApp->FormulaToUser(formulaLength));
visual->setAngle(angle);
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
}
}
@@ -334,7 +334,7 @@ void VToolNormal::ShowVisualization(bool show)
visual->setPoint2Id(secondPointId);
visual->setLength(qApp->FormulaToUser(formulaLength));
visual->setAngle(angle);
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp
index 33d29bae5..312aa5d9d 100644
--- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp
+++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp
@@ -243,7 +243,7 @@ void VToolShoulderPoint::FullUpdateFromFile()
visual->setLineP1Id(basePointId);
visual->setLineP2Id(p2Line);
visual->setLength(qApp->FormulaToUser(formulaLength));
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
}
}
@@ -360,7 +360,7 @@ void VToolShoulderPoint::ShowVisualization(bool show)
visual->setLineP1Id(basePointId);
visual->setLineP2Id(p2Line);
visual->setLength(qApp->FormulaToUser(formulaLength));
- visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
+ visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp
index 67037a51a..92fc3de7e 100644
--- a/src/app/tools/vabstracttool.cpp
+++ b/src/app/tools/vabstracttool.cpp
@@ -161,9 +161,9 @@ void VAbstractTool::DeleteTool(bool ask)
* @brief LineStyle return pen style for current line style.
* @return pen style.
*/
-Qt::PenStyle VAbstractTool::LineStyle(const QString &typeLine)
+Qt::PenStyle VAbstractTool::LineStyleToPenStyle(const QString &typeLine)
{
- QStringList styles = Styles();
+ const QStringList styles = StylesList();
switch (styles.indexOf(typeLine))
{
case 0: // TypeLineNone
@@ -190,6 +190,30 @@ Qt::PenStyle VAbstractTool::LineStyle(const QString &typeLine)
}
}
+//---------------------------------------------------------------------------------------------------------------------
+QMap VAbstractTool::LineStylesPics()
+{
+ QMap map;
+ const QStringList styles = StylesList();
+
+ for (int i=0; i < styles.size(); ++i)
+ {
+ const Qt::PenStyle style = LineStyleToPenStyle(styles.at(i));
+ QPixmap pix(80, 14);
+ pix.fill(Qt::white);
+
+ QBrush brush(Qt::black);
+ QPen pen(brush, 2.5, style);
+
+ QPainter painter(&pix);
+ painter.setPen(pen);
+ painter.drawLine(2, 7, 78, 7);
+
+ map.insert(styles.at(i), QIcon(pix));
+ }
+ return map;
+}
+
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractTool::getLineType() const
{
@@ -264,7 +288,7 @@ void VAbstractTool::SaveOption(QSharedPointer &obj)
* @brief Styles return list of all line styles.
* @return list of all line styles.
*/
-const QStringList VAbstractTool::Styles()
+const QStringList VAbstractTool::StylesList()
{
QStringList styles = QStringList() << TypeLineNone << TypeLineLine << TypeLineDashLine << TypeLineDotLine <<
TypeLineDashDotLine << TypeLineDashDotDotLine;
diff --git a/src/app/tools/vabstracttool.h b/src/app/tools/vabstracttool.h
index f69a1339b..3667f9377 100644
--- a/src/app/tools/vabstracttool.h
+++ b/src/app/tools/vabstracttool.h
@@ -92,9 +92,13 @@ public:
static const QString TypeLineDotLine;
static const QString TypeLineDashDotLine;
static const QString TypeLineDashDotDotLine;
- static const QStringList Styles();
+
+ static const QStringList StylesList();
+ static Qt::PenStyle LineStyleToPenStyle(const QString &typeLine);
+ static QMap LineStylesPics();
+
static void AddRecord(const quint32 id, const Tool &toolType, VPattern *doc);
- static Qt::PenStyle LineStyle(const QString &typeLine);
+
const VContainer *getData() const;
QString getLineType() const;
diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp
index b3cae144e..178d6c6f3 100644
--- a/src/app/widgets/vtooloptionspropertybrowser.cpp
+++ b/src/app/widgets/vtooloptionspropertybrowser.cpp
@@ -382,12 +382,12 @@ void VToolOptionsPropertyBrowser::AddPropertyPointName(Tool *i, const QString &p
//---------------------------------------------------------------------------------------------------------------------
template
-void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &propertyName)
+void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &propertyName,
+ const QMap &styles)
{
- VEnumProperty *lineTypeProperty = new VEnumProperty(propertyName);
- QStringList styles = VAbstractTool::Styles();
- lineTypeProperty->setLiterals(styles);
- qint32 index = styles.indexOf(i->getLineType());
+ VLineTypeProperty *lineTypeProperty = new VLineTypeProperty(propertyName);
+ lineTypeProperty->setStyles(styles);
+ const qint32 index = VLineTypeProperty::IndexOfStyle(styles, i->getLineType());
if (index == -1)
{
qWarning()<<"Can't find line style" << i->getLineType()<<"in list";
@@ -945,7 +945,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolEndLine(QGraphicsItem *item)
formView->setTitle(tr("Point at distance and angle"));
AddPropertyPointName(i, tr("Point label"));
- AddPropertyLineType(i, tr("Line type"));
+ AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength);
AddPropertyFormula(tr("Angle"), i->getFormulaAngle(), VAbstractTool::AttrAngle);
}
@@ -958,7 +958,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolAlongLine(QGraphicsItem *item)
formView->setTitle(tr("Point at distance along line"));
AddPropertyPointName(i, tr("Point label"));
- AddPropertyLineType(i, tr("Line type"));
+ AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength);
}
@@ -982,7 +982,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolBisector(QGraphicsItem *item)
formView->setTitle(tr("Point along bisector"));
AddPropertyPointName(i, tr("Point label"));
- AddPropertyLineType(i, tr("Line type"));
+ AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength);
}
@@ -1027,7 +1027,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolHeight(QGraphicsItem *item)
formView->setTitle(tr("Perpendicular point along line"));
AddPropertyPointName(i, tr("Point label"));
- AddPropertyLineType(i, tr("Line type"));
+ AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
}
//---------------------------------------------------------------------------------------------------------------------
@@ -1037,7 +1037,9 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolLine(QGraphicsItem *item)
i->ShowVisualization(true);
formView->setTitle(tr("Line between points"));
- AddPropertyLineType(i, tr("Line type"));
+ QMap styles = VAbstractTool::LineStylesPics();
+ styles.remove(VAbstractTool::TypeLineNone);
+ AddPropertyLineType(i, tr("Line type"), styles);
}
//---------------------------------------------------------------------------------------------------------------------
@@ -1059,7 +1061,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolNormal(QGraphicsItem *item)
AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength);
AddPropertyPointName(i, tr("Point label"));
- AddPropertyLineType(i, tr("Line type"));
+ AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
VDoubleProperty* itemAngle = new VDoubleProperty(tr("Additional angle degrees"));
itemAngle->setValue(i->getAngle());
@@ -1098,7 +1100,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *it
formView->setTitle(tr("Special point on shoulder"));
AddPropertyPointName(i, tr("Point label"));
- AddPropertyLineType(i, tr("Line type"));
+ AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength);
}
@@ -1154,7 +1156,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolLineIntersectAxis(QGraphicsItem
formView->setTitle(tr("Point intersection line and axis"));
AddPropertyPointName(i, tr("Point label"));
- AddPropertyLineType(i, tr("Line type"));
+ AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyFormula(tr("Angle"), i->getFormulaAngle(), VAbstractTool::AttrAngle);
}
@@ -1166,7 +1168,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCurveIntersectAxis(QGraphicsIte
formView->setTitle(tr("Point intersection line and axis"));
AddPropertyPointName(i, tr("Point label"));
- AddPropertyLineType(i, tr("Line type"));
+ AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyFormula(tr("Angle"), i->getFormulaAngle(), VAbstractTool::AttrAngle);
}
@@ -1184,8 +1186,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolEndLine()
VToolEndLine *i = qgraphicsitem_cast(currentItem);
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
- QStringList styles = VAbstractTool::Styles();
- qint32 index = styles.indexOf(i->getLineType());
+ const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType());
idToProperty[VAbstractTool::AttrTypeLine]->setValue(index);
QVariant valueFormula;
@@ -1203,8 +1204,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolAlongLine()
VToolAlongLine *i = qgraphicsitem_cast(currentItem);
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
- QStringList styles = VAbstractTool::Styles();
- qint32 index = styles.indexOf(i->getLineType());
+ const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType());
idToProperty[VAbstractTool::AttrTypeLine]->setValue(index);
QVariant valueFormula;
@@ -1242,8 +1242,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolBisector()
valueFormula.setValue(i->getFormulaLength());
idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula);
- QStringList styles = VAbstractTool::Styles();
- qint32 index = styles.indexOf(i->getLineType());
+ const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType());
idToProperty[VAbstractTool::AttrTypeLine]->setValue(index);
}
@@ -1290,8 +1289,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolHeight()
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
- QStringList styles = VAbstractTool::Styles();
- qint32 index = styles.indexOf(i->getLineType());
+ const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType());
idToProperty[VAbstractTool::AttrTypeLine]->setValue(index);
}
@@ -1300,8 +1298,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolLine()
{
VToolLine *i = qgraphicsitem_cast(currentItem);
- QStringList styles = VAbstractTool::Styles();
- qint32 index = styles.indexOf(i->getLineType());
+ const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType());
idToProperty[VAbstractTool::AttrTypeLine]->setValue(index);
}
@@ -1326,8 +1323,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolNormal()
idToProperty[VAbstractTool::AttrAngle]->setValue( i->getAngle());
- QStringList styles = VAbstractTool::Styles();
- qint32 index = styles.indexOf(i->getLineType());
+ const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType());
idToProperty[VAbstractTool::AttrTypeLine]->setValue(index);
}
@@ -1362,8 +1358,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint()
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
- QStringList styles = VAbstractTool::Styles();
- qint32 index = styles.indexOf(i->getLineType());
+ const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType());
idToProperty[VAbstractTool::AttrTypeLine]->setValue(index);
}
@@ -1399,8 +1394,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolLineIntersectAxis()
VToolLineIntersectAxis *i = qgraphicsitem_cast(currentItem);
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
- QStringList styles = VAbstractTool::Styles();
- qint32 index = styles.indexOf(i->getLineType());
+ const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType());
idToProperty[VAbstractTool::AttrTypeLine]->setValue(index);
QVariant valueAngle;
@@ -1414,8 +1408,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCurveIntersectAxis()
VToolCurveIntersectAxis *i = qgraphicsitem_cast(currentItem);
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
- QStringList styles = VAbstractTool::Styles();
- qint32 index = styles.indexOf(i->getLineType());
+ const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType());
idToProperty[VAbstractTool::AttrTypeLine]->setValue(index);
QVariant valueAngle;
diff --git a/src/app/widgets/vtooloptionspropertybrowser.h b/src/app/widgets/vtooloptionspropertybrowser.h
index 1c4c65fa1..b2b918e99 100644
--- a/src/app/widgets/vtooloptionspropertybrowser.h
+++ b/src/app/widgets/vtooloptionspropertybrowser.h
@@ -71,7 +71,7 @@ private:
void AddPropertyPointName(Tool *i, const QString &propertyName);
template
- void AddPropertyLineType(Tool *i, const QString &propertyName);
+ void AddPropertyLineType(Tool *i, const QString &propertyName, const QMap &styles);
void AddPropertyFormula(const QString &propertyName, const VFormula &formula, const QString &attrName);
diff --git a/src/libs/vpropertyexplorer/plugins/venumproperty.h b/src/libs/vpropertyexplorer/plugins/venumproperty.h
index b15a04cd5..1fae1a975 100644
--- a/src/libs/vpropertyexplorer/plugins/venumproperty.h
+++ b/src/libs/vpropertyexplorer/plugins/venumproperty.h
@@ -86,7 +86,7 @@ public slots:
void currentIndexChanged(int index);
protected:
- //! The list of possible options to choose frome
+ //! The list of possible options to choose from
QStringList EnumerationLiterals;
// No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other
//members by reimplementing the VPropertyPrivate class without touching this header file.
diff --git a/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp
new file mode 100644
index 000000000..a5305dbee
--- /dev/null
+++ b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp
@@ -0,0 +1,171 @@
+/************************************************************************
+ **
+ ** @file vlinetypeproperty.cpp
+ ** @author Roman Telezhynskyi
+ ** @date 29 1, 2015
+ **
+ ** @brief
+ ** @copyright
+ ** This source code is part of the Valentine project, a pattern making
+ ** program, whose allow create and modeling patterns of clothing.
+ ** Copyright (C) 2015 Valentina project
+ ** All Rights Reserved.
+ **
+ ** Valentina is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Valentina is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with Valentina. If not, see .
+ **
+ *************************************************************************/
+
+#include "vlinetypeproperty.h"
+#include "../vproperty_p.h"
+
+#include
+#include
+
+using namespace VPE;
+
+VLineTypeProperty::VLineTypeProperty(const QString &name)
+ : VProperty(name, QVariant::Int), styles(), indexList()
+{
+ VProperty::d_ptr->VariantValue = 0;
+ VProperty::d_ptr->VariantValue.convert(QVariant::Int);
+}
+
+QVariant VLineTypeProperty::data(int column, int role) const
+{
+ if (styles.empty())
+ {
+ return QVariant();
+ }
+
+ int tmpIndex = VProperty::d_ptr->VariantValue.toInt();
+
+ if (tmpIndex < 0 || tmpIndex >= indexList.count())
+ {
+ tmpIndex = 0;
+ }
+
+ if (column == DPC_Data && Qt::DisplayRole == role)
+ {
+ return indexList.at(tmpIndex);
+ }
+ else if (column == DPC_Data && Qt::EditRole == role)
+ {
+ return tmpIndex;
+ }
+ else
+ {
+ return VProperty::data(column, role);
+ }
+}
+
+QWidget *VLineTypeProperty::createEditor(QWidget *parent, const QStyleOptionViewItem &options,
+ const QAbstractItemDelegate *delegate)
+{
+ Q_UNUSED(options);
+ Q_UNUSED(delegate);
+ QComboBox* tmpEditor = new QComboBox(parent);
+ tmpEditor->clear();
+ tmpEditor->setIconSize(QSize(80, 14));
+ tmpEditor->setMinimumWidth(80);
+ tmpEditor->setMaximumWidth(110);
+
+ QMap::const_iterator i = styles.constBegin();
+ while (i != styles.constEnd())
+ {
+ tmpEditor->addItem(i.value(), "", QVariant(i.key()));
+ ++i;
+ }
+
+ tmpEditor->setCurrentIndex(VProperty::d_ptr->VariantValue.toInt());
+ connect(tmpEditor, static_cast(&QComboBox::currentIndexChanged), this,
+ &VLineTypeProperty::currentIndexChanged);
+
+ VProperty::d_ptr->editor = tmpEditor;
+ return VProperty::d_ptr->editor;
+}
+
+QVariant VLineTypeProperty::getEditorData(const QWidget *editor) const
+{
+ const QComboBox* tmpEditor = qobject_cast(editor);
+ if (tmpEditor)
+ {
+ return tmpEditor->currentIndex();
+ }
+
+ return QVariant(0);
+}
+
+void VLineTypeProperty::setStyles(const QMap &styles)
+{
+ this->styles = styles;
+ indexList.clear();
+ QMap::const_iterator i = styles.constBegin();
+ while (i != styles.constEnd())
+ {
+ indexList.append(i.key());
+ ++i;
+ }
+}
+
+QMap VLineTypeProperty::getStyles() const
+{
+ return styles;
+}
+
+void VLineTypeProperty::setValue(const QVariant &value)
+{
+ int tmpIndex = value.toInt();
+
+ if (tmpIndex < 0 || tmpIndex >= indexList.count())
+ {
+ tmpIndex = 0;
+ }
+
+ VProperty::d_ptr->VariantValue = tmpIndex;
+ VProperty::d_ptr->VariantValue.convert(QVariant::Int);
+
+ if (VProperty::d_ptr->editor != nullptr)
+ {
+ setEditorData(VProperty::d_ptr->editor);
+ }
+}
+
+QString VLineTypeProperty::type() const
+{
+ return QStringLiteral("lineType");
+}
+
+VProperty *VLineTypeProperty::clone(bool include_children, VProperty *container) const
+{
+ return VProperty::clone(include_children, container ? container : new VLineTypeProperty(getName()));
+}
+
+int VLineTypeProperty::IndexOfStyle(const QMap &styles, const QString &style)
+{
+ QVector indexList;
+ QMap::const_iterator i = styles.constBegin();
+ while (i != styles.constEnd())
+ {
+ indexList.append(i.key());
+ ++i;
+ }
+ return indexList.indexOf(style);
+}
+
+void VLineTypeProperty::currentIndexChanged(int index)
+{
+ Q_UNUSED(index)
+ UserChangeEvent *event = new UserChangeEvent();
+ QCoreApplication::postEvent ( VProperty::d_ptr->editor, event );
+}
diff --git a/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.h b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.h
new file mode 100644
index 000000000..335ac481d
--- /dev/null
+++ b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.h
@@ -0,0 +1,101 @@
+/************************************************************************
+ **
+ ** @file vlinetypeproperty.h
+ ** @author Roman Telezhynskyi
+ ** @date 29 1, 2015
+ **
+ ** @brief
+ ** @copyright
+ ** This source code is part of the Valentine project, a pattern making
+ ** program, whose allow create and modeling patterns of clothing.
+ ** Copyright (C) 2015 Valentina project
+ ** All Rights Reserved.
+ **
+ ** Valentina is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Valentina is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with Valentina. If not, see .
+ **
+ *************************************************************************/
+
+#ifndef VLINETYPEPROPERTY_H
+#define VLINETYPEPROPERTY_H
+
+#include "../vproperty.h"
+
+#include
+#include
+#include
+
+namespace VPE
+{
+
+class VPROPERTYEXPLORERSHARED_EXPORT VLineTypeProperty : public VProperty
+{
+ Q_OBJECT
+public:
+ //! Constructor
+ VLineTypeProperty(const QString& name);
+
+ //! Destructor
+ ~VLineTypeProperty() {}
+
+ //! Get the data how it should be displayed
+ virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const;
+
+ //! Returns an editor widget, or NULL if it doesn't supply one
+ //! \param parent The widget to which the editor will be added as a child
+ //! \options Render options
+ //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
+ //! slots.
+ virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
+ const QAbstractItemDelegate* delegate);
+
+ //! Gets the data from the widget
+ virtual QVariant getEditorData(const QWidget* editor) const;
+
+ //! Sets the line styles
+ virtual void setStyles(const QMap &styles);
+
+ //! Get the settings. This function has to be implemented in a subclass in order to have an effect
+ virtual QMap getStyles() const;
+
+ //! Sets the value of the property
+ virtual void setValue(const QVariant& value);
+
+ //! Returns a string containing the type of the property
+ virtual QString type() const;
+
+ //! Clones this property
+ //! \param include_children Indicates whether to also clone the children
+ //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
+ //! to fill all the data into container. This can also be used when subclassing this function.
+ //! \return Returns the newly created property (or container, if it was not NULL)
+ virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
+
+ static int IndexOfStyle(const QMap &styles, const QString &style);
+
+public slots:
+ void currentIndexChanged(int index);
+
+protected:
+ //! The list of possible options to choose from
+ QMap styles;
+ QVector indexList;
+ // No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other
+ //members by reimplementing the VPropertyPrivate class without touching this header file.
+private:
+ Q_DISABLE_COPY(VLineTypeProperty)
+};
+
+}
+
+#endif // VLINETYPEPROPERTY_H
diff --git a/src/libs/vpropertyexplorer/vproperties.h b/src/libs/vpropertyexplorer/vproperties.h
index f1c531f27..0c8467d4d 100644
--- a/src/libs/vpropertyexplorer/vproperties.h
+++ b/src/libs/vpropertyexplorer/vproperties.h
@@ -26,6 +26,7 @@
#include "plugins/vcolorproperty.h"
#include "plugins/Vector3d/vvector3dproperty.h"
#include "plugins/vemptyproperty.h"
+#include "plugins/vlinetypeproperty.h"
#include "plugins/venumproperty.h"
#include "plugins/vfileproperty.h"
#include "plugins/vnumberproperty.h"
diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer.pri b/src/libs/vpropertyexplorer/vpropertyexplorer.pri
index d5ab89175..871cff6d3 100644
--- a/src/libs/vpropertyexplorer/vpropertyexplorer.pri
+++ b/src/libs/vpropertyexplorer/vpropertyexplorer.pri
@@ -27,7 +27,8 @@ SOURCES += \
$$PWD/plugins/vstringproperty.cpp \
$$PWD/plugins/vpointfproperty.cpp \
$$PWD/plugins/vobjectproperty.cpp \
- $$PWD/stable.cpp
+ $$PWD/stable.cpp \
+ $$PWD/plugins/vlinetypeproperty.cpp
HEADERS +=\
$$PWD/vpropertyexplorer_global.h \
@@ -67,4 +68,5 @@ HEADERS +=\
$$PWD/plugins/vpointfproperty.h \
$$PWD/plugins/vobjectproperty.h \
$$PWD/vproperties.h \
- $$PWD/stable.h
+ $$PWD/stable.h \
+ $$PWD/plugins/vlinetypeproperty.h