diff --git a/share/resources/schema/pattern.xsd b/share/resources/schema/pattern.xsd
index 4bed79202..76237f457 100644
--- a/share/resources/schema/pattern.xsd
+++ b/share/resources/schema/pattern.xsd
@@ -64,6 +64,7 @@
+
diff --git a/src/dialogs/dialogline.cpp b/src/dialogs/dialogline.cpp
index 123210e31..ccbb31eb8 100644
--- a/src/dialogs/dialogline.cpp
+++ b/src/dialogs/dialogline.cpp
@@ -32,7 +32,7 @@
#include
DialogLine::DialogLine(const VContainer *data, QWidget *parent)
- :DialogTool(data, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0)
+ :DialogTool(data, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0), typeLine(QString())
{
ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
@@ -42,6 +42,7 @@ DialogLine::DialogLine(const VContainer *data, QWidget *parent)
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
+ FillComboBoxTypeLine(ui->comboBoxLineType);
number = 0;
}
@@ -62,6 +63,12 @@ void DialogLine::setSecondPoint(const qint64 &value)
}
}
+void DialogLine::setTypeLine(const QString &value)
+{
+ typeLine = value;
+ SetupTypeLine(ui->comboBoxLineType, value);
+}
+
void DialogLine::setFirstPoint(const qint64 &value)
{
firstPoint = value;
@@ -80,6 +87,7 @@ void DialogLine::DialogAccepted()
firstPoint = qvariant_cast(ui->comboBoxFirstPoint->itemData(index));
index = ui->comboBoxSecondPoint->currentIndex();
secondPoint = qvariant_cast(ui->comboBoxSecondPoint->itemData(index));
+ typeLine = GetTypeLine(ui->comboBoxLineType);
DialogClosed(QDialog::Accepted);
}
diff --git a/src/dialogs/dialogline.h b/src/dialogs/dialogline.h
index 8f14e2c18..1ec7d59a3 100644
--- a/src/dialogs/dialogline.h
+++ b/src/dialogs/dialogline.h
@@ -70,6 +70,16 @@ public:
* @param value id
*/
void setSecondPoint(const qint64 &value);
+ /**
+ * @brief getTypeLine return type of line
+ * @return type
+ */
+ inline QString getTypeLine() const {return typeLine;}
+ /**
+ * @brief setTypeLine set type of line
+ * @param value type
+ */
+ void setTypeLine(const QString &value);
public slots:
/**
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
@@ -99,6 +109,10 @@ private:
* @brief secondPoint id second point
*/
qint64 secondPoint;
+ /**
+ * @brief typeLine type of line
+ */
+ QString typeLine;
};
#endif // DIALOGLINE_H
diff --git a/src/dialogs/dialogline.ui b/src/dialogs/dialogline.ui
index b575f1d52..70511e663 100644
--- a/src/dialogs/dialogline.ui
+++ b/src/dialogs/dialogline.ui
@@ -6,68 +6,151 @@
0
0
- 217
- 137
+ 267
+ 154
Line
-
+
:/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png
-
- -
-
-
-
-
-
- First point
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
- Second point
-
-
-
- -
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
-
-
+
+
+
+ 9
+ 9
+ 255
+ 134
+
+
+
+ -
+
+
-
+
+
+
+ 90
+ 0
+
+
+
+ First point
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 90
+ 0
+
+
+
+ Second point
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 90
+ 0
+
+
+
+ Type of line
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+ Show line from first point to this point
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
comboBoxFirstPoint
comboBoxSecondPoint
- buttonBox
-
+
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b0bceff9d..e2fcd4b09 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -902,7 +902,15 @@ void MainWindow::ActionDetails(bool checked)
bool MainWindow::SaveAs()
{
QString filters(tr("Pattern files (*.val)"));
- QString dir = QFileInfo(curFile).absolutePath() + tr("/pattern.val");
+ QString dir;
+ if (curFile.isEmpty())
+ {
+ dir = QDir::homePath() + tr("/pattern.val");
+ }
+ else
+ {
+ dir = QFileInfo(curFile).absolutePath() + tr("/pattern.val");
+ }
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir, filters);
if (fileName.isEmpty())
diff --git a/src/tools/drawTools/vtoolline.cpp b/src/tools/drawTools/vtoolline.cpp
index a0ff4868b..c9fece4ca 100644
--- a/src/tools/drawTools/vtoolline.cpp
+++ b/src/tools/drawTools/vtoolline.cpp
@@ -32,9 +32,10 @@
const QString VToolLine::TagName = QStringLiteral("line");
VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint,
- const Tool::Sources &typeCreation, QGraphicsItem *parent)
+ const QString &typeLine, const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint)
{
+ this->typeLine = typeLine;
ignoreFullUpdate = true;
//Line
const VPointF *first = data->GeometricObject(firstPoint);
@@ -44,7 +45,7 @@ VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firs
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
- this->setPen(QPen(Qt::black, widthHairLine/factor));
+ this->setPen(QPen(Qt::black, widthHairLine/factor, LineStyle()));
if (typeCreation == Tool::FromGui)
{
@@ -63,6 +64,7 @@ void VToolLine::setDialog()
Q_CHECK_PTR(dialogTool);
dialogTool->setFirstPoint(firstPoint);
dialogTool->setSecondPoint(secondPoint);
+ dialogTool->setTypeLine(typeLine);
}
void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data)
@@ -72,10 +74,11 @@ void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocume
Q_CHECK_PTR(dialogTool);
qint64 firstPoint = dialogTool->getFirstPoint();
qint64 secondPoint = dialogTool->getSecondPoint();
- Create(0, firstPoint, secondPoint, scene, doc, data, Document::FullParse, Tool::FromGui);
+ QString typeLine = dialogTool->getTypeLine();
+ Create(0, firstPoint, secondPoint, typeLine, scene, doc, data, Document::FullParse, Tool::FromGui);
}
-void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint,
+void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, const QString &typeLine,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation)
{
@@ -100,7 +103,7 @@ void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64
VDrawTool::AddRecord(id, Tool::LineTool, doc);
if (parse == Document::FullParse)
{
- VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeCreation);
+ VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeLine, typeCreation);
Q_CHECK_PTR(line);
scene->addItem(line);
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
@@ -140,7 +143,7 @@ void VToolLine::ChangedActivDraw(const QString &newName)
selectable = false;
currentColor = Qt::gray;
}
- this->setPen(QPen(currentColor, widthHairLine/factor));
+ this->setPen(QPen(currentColor, widthHairLine/factor, LineStyle()));
this->setAcceptHoverEvents (selectable);
VDrawTool::ChangedActivDraw(newName);
}
@@ -156,6 +159,7 @@ void VToolLine::AddToFile()
SetAttribute(domElement, AttrId, id);
SetAttribute(domElement, AttrFirstPoint, firstPoint);
SetAttribute(domElement, AttrSecondPoint, secondPoint);
+ SetAttribute(domElement, AttrTypeLine, typeLine);
AddToCalculation(domElement);
}
@@ -167,19 +171,20 @@ void VToolLine::RefreshDataInFile()
{
SetAttribute(domElement, AttrFirstPoint, firstPoint);
SetAttribute(domElement, AttrSecondPoint, secondPoint);
+ SetAttribute(domElement, AttrTypeLine, typeLine);
}
}
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
- this->setPen(QPen(currentColor, widthMainLine/factor));
+ this->setPen(QPen(currentColor, widthMainLine/factor, LineStyle()));
}
void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
- this->setPen(QPen(currentColor, widthHairLine/factor));
+ this->setPen(QPen(currentColor, widthHairLine/factor, LineStyle()));
}
void VToolLine::RemoveReferens()
@@ -226,6 +231,7 @@ void VToolLine::SaveDialog(QDomElement &domElement)
Q_CHECK_PTR(dialogTool);
SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint()));
SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint()));
+ SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine());
}
void VToolLine::RefreshGeometry()
@@ -233,11 +239,12 @@ void VToolLine::RefreshGeometry()
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
- firstPoint = domElement.attribute(AttrFirstPoint, "").toLongLong();
- secondPoint = domElement.attribute(AttrSecondPoint, "").toLongLong();
+ firstPoint = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
+ secondPoint = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
+ typeLine = doc->GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
}
const VPointF *first = VAbstractTool::data.GeometricObject(firstPoint);
const VPointF *second = VAbstractTool::data.GeometricObject(secondPoint);
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
- this->setPen(QPen(currentColor, widthHairLine/factor));
+ this->setPen(QPen(currentColor, widthHairLine/factor, LineStyle()));
}
diff --git a/src/tools/drawTools/vtoolline.h b/src/tools/drawTools/vtoolline.h
index 2ddd978ae..169cc77f0 100644
--- a/src/tools/drawTools/vtoolline.h
+++ b/src/tools/drawTools/vtoolline.h
@@ -47,11 +47,13 @@ public:
* @param id object id in container.
* @param firstPoint id first line point.
* @param secondPoint id second line point.
+ * @param typeLine line type.
* @param typeCreation way we create this tool.
* @param parent parent object.
*/
VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
- qint64 secondPoint, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
+ qint64 secondPoint, const QString &typeLine, const Tool::Sources &typeCreation,
+ QGraphicsItem * parent = 0);
/**
* @brief setDialog set dialog when user want change tool option.
*/
@@ -69,13 +71,14 @@ public:
* @param _id tool id, 0 if tool doesn't exist yet.
* @param firstPoint id first line point.
* @param secondPoint id second line point.
+ * @param typeLine line type.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
- static void Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint,
+ static void Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, const QString &typeLine,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation);
static const QString TagName;
diff --git a/src/xml/vdomdocument.cpp b/src/xml/vdomdocument.cpp
index f588ad57d..c08d1b4ad 100644
--- a/src/xml/vdomdocument.cpp
+++ b/src/xml/vdomdocument.cpp
@@ -1100,8 +1100,9 @@ void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement
qint64 id = GetParametrId(domElement);
qint64 firstPoint = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
qint64 secondPoint = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
+ QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
- VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile);
+ VToolLine::Create(id, firstPoint, secondPoint, typeLine, scene, this, data, parse, Tool::FromFile);
}
catch (const VExceptionBadId &e)
{