diff --git a/src/app/dialogs/tools/dialogcutspline.cpp b/src/app/dialogs/tools/dialogcutspline.cpp
index 0e96cecd7..c99c3338c 100644
--- a/src/app/dialogs/tools/dialogcutspline.cpp
+++ b/src/app/dialogs/tools/dialogcutspline.cpp
@@ -32,6 +32,7 @@
#include "../../geometry/vspline.h"
#include "../../container/vcontainer.h"
#include "../../xml/vpattern.h"
+#include "../../visualization/vistoolcutspline.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@@ -41,7 +42,7 @@
*/
DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()),
- splineId(NULL_ID), formulaBaseHeight(0)
+ splineId(NULL_ID), formulaBaseHeight(0), path(nullptr)
{
ui->setupUi(this);
InitVariables(ui);
@@ -50,7 +51,7 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
- InitOkCancel(ui);
+ InitOkCancelApply(ui);
flagFormula = false;
CheckState();
@@ -62,11 +63,14 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSpline::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSpline::FormulaChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit);
+
+ path = new VisToolCutSpline(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogCutSpline::~DialogCutSpline()
{
+ delete path;
delete ui;
}
@@ -96,6 +100,7 @@ void DialogCutSpline::setFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
+ path->setLength(formula);
}
//---------------------------------------------------------------------------------------------------------------------
@@ -106,6 +111,7 @@ void DialogCutSpline::setFormula(const QString &value)
void DialogCutSpline::setSplineId(const quint32 &value)
{
setCurrentSplineId(ui->comboBoxSpline, splineId, value, ComboBoxCutSpline::CutSpline);
+ path->setPoint1Id(splineId);
}
//---------------------------------------------------------------------------------------------------------------------
@@ -122,6 +128,8 @@ void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type)
{
if (SetObject(id, ui->comboBoxSpline, ""))
{
+ path->VisualMode(id);
+ prepare = true;
this->setModal(true);
this->show();
}
@@ -136,6 +144,10 @@ void DialogCutSpline::SaveData()
formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
splineId = getCurrentObjectId(ui->comboBoxSpline);
+
+ path->setPoint1Id(splineId);
+ path->setLength(formula);
+ path->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
@@ -143,3 +155,15 @@ void DialogCutSpline::DeployFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogCutSpline::ShowVisualization()
+{
+ if (prepare == false)
+ {
+ VMainGraphicsScene *scene = qApp->getCurrentScene();
+ connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor);
+ scene->addItem(path);
+ path->RefreshGeometry();
+ }
+}
diff --git a/src/app/dialogs/tools/dialogcutspline.h b/src/app/dialogs/tools/dialogcutspline.h
index c541cb58a..257324c54 100644
--- a/src/app/dialogs/tools/dialogcutspline.h
+++ b/src/app/dialogs/tools/dialogcutspline.h
@@ -36,6 +36,8 @@ namespace Ui
class DialogCutSpline;
}
+class VisToolCutSpline;
+
/**
* @brief The DialogCutSpline class dialog for ToolCutSpline.
*/
@@ -61,6 +63,7 @@ public slots:
*/
void DeployFormulaTextEdit();
protected:
+ virtual void ShowVisualization();
/**
* @brief SaveData Put dialog data in local variables
*/
@@ -79,6 +82,8 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
+
+ VisToolCutSpline *path;
};
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/app/dialogs/tools/dialogcutspline.ui b/src/app/dialogs/tools/dialogcutspline.ui
index 4e474569d..c17f5f0c5 100644
--- a/src/app/dialogs/tools/dialogcutspline.ui
+++ b/src/app/dialogs/tools/dialogcutspline.ui
@@ -392,7 +392,7 @@
Qt::Horizontal
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+ QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok
diff --git a/src/app/geometry/vspline.cpp b/src/app/geometry/vspline.cpp
index 978ceec63..ec695751a 100644
--- a/src/app/geometry/vspline.cpp
+++ b/src/app/geometry/vspline.cpp
@@ -241,6 +241,20 @@ QPointF VSpline::CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPo
return p1234;
}
+//---------------------------------------------------------------------------------------------------------------------
+QPointF VSpline::CutSpline(qreal length, VSpline &spl1, VSpline &spl2) const
+{
+ QPointF spl1p2;
+ QPointF spl1p3;
+ QPointF spl2p2;
+ QPointF spl2p3;
+ QPointF cutPoint = CutSpline (length, spl1p2, spl1p3, spl2p2, spl2p3 );
+
+ spl1 = VSpline(GetP1(), spl1p2, spl1p3, cutPoint, GetKcurve());
+ spl2 = VSpline(cutPoint, spl2p2, spl2p3, GetP4(), GetKcurve());
+ return cutPoint;
+}
+
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetPoints return list with spline points.
diff --git a/src/app/geometry/vspline.h b/src/app/geometry/vspline.h
index c70a84b03..cf57a0fe1 100644
--- a/src/app/geometry/vspline.h
+++ b/src/app/geometry/vspline.h
@@ -68,6 +68,7 @@ public:
QLineF::IntersectType CrossingSplLine(const QLineF &line, QPointF *intersectionPoint ) const;
qreal LengthT(qreal t) const;
QPointF CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3) const;
+ QPointF CutSpline ( qreal length, VSpline &spl1, VSpline &spl2) const;
QVector GetPoints () const;
// cppcheck-suppress unusedFunction
static QVector SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp
index d07ce9f11..cbbdd3ba5 100644
--- a/src/app/mainwindow.cpp
+++ b/src/app/mainwindow.cpp
@@ -497,8 +497,10 @@ void MainWindow::ToolSpline(bool checked)
*/
void MainWindow::ToolCutSpline(bool checked)
{
- SetToolButton(checked, Tool::CutSpline, ":/cursor/spline_cut_point_cursor.png",
- tr("Select simple curve"), &MainWindow::ClosedDialog);
+ SetToolButtonWithApply(checked, Tool::CutSpline, ":/cursor/spline_cut_point_cursor.png",
+ tr("Select simple curve"),
+ &MainWindow::ClosedDialogWithApply,
+ &MainWindow::ApplyDialog);
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/app/options.h b/src/app/options.h
index b12d19129..cf4c82516 100644
--- a/src/app/options.h
+++ b/src/app/options.h
@@ -99,7 +99,10 @@ enum class Vis : unsigned char
ToolPointOfIntersection,
ToolShoulderPoint,
ToolSpline,
- ToolTriangle
+ ToolTriangle,
+ ToolCutSpline,
+ ToolSplinePath,
+ ToolCutSplinePath
};
enum class Source : char { FromGui, FromFile, FromTool };
diff --git a/src/app/tools/drawTools/vabstractspline.h b/src/app/tools/drawTools/vabstractspline.h
index f366384de..96ac5d289 100644
--- a/src/app/tools/drawTools/vabstractspline.h
+++ b/src/app/tools/drawTools/vabstractspline.h
@@ -43,6 +43,7 @@ public:
virtual int type() const {return Type;}
enum { Type = UserType + static_cast(Tool::AbstractSpline)};
virtual QString getTagName() const;
+ void ShowFoot(bool show);
public slots:
virtual void FullUpdateFromFile ();
void Disable(bool disable);
@@ -81,7 +82,6 @@ protected:
virtual void keyReleaseEvent(QKeyEvent * event);
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const;
- void ShowFoot(bool show);
};
#endif // VABSTRACTSPLINE_H
diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp
index 2231cbc64..1af6dbb10 100644
--- a/src/app/tools/drawTools/vtoolcutspline.cpp
+++ b/src/app/tools/drawTools/vtoolcutspline.cpp
@@ -30,6 +30,8 @@
#include "../../container/calculator.h"
#include "../../dialogs/tools/dialogcutspline.h"
#include "../../geometry/vpointf.h"
+#include "../../visualization/vistoolcutspline.h"
+#include "vabstractspline.h"
#include
@@ -190,33 +192,38 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa
//---------------------------------------------------------------------------------------------------------------------
void VToolCutSpline::ShowVisualization(bool show)
{
-// if (show)
-// {
-// if (vis == nullptr)
-// {
-// VisTool * visual = new VisTool(getData());
-// VMainGraphicsScene *scene = qApp->getCurrentScene();
-// connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
-// scene->addItem(visual);
+ if (show)
+ {
+ if (vis == nullptr)
+ {
+ VisToolCutSpline * visual = new VisToolCutSpline(getData());
+ VMainGraphicsScene *scene = qApp->getCurrentScene();
+ connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
+ scene->addItem(visual);
-// // add options
-// visual->RefreshGeometry();
-// vis = visual;
-// }
-// else
-// {
-// VisTool * visual = qobject_cast(vis);
-// if (visual != nullptr)
-// {
-// visual->show();
-// }
-// }
-// }
-// else
-// {
-// delete vis;
-// vis = nullptr;
-// }
+ visual->setPoint1Id(curveCutId);
+ visual->setLength(formula);
+ visual->RefreshGeometry();
+ vis = visual;
+ }
+ else
+ {
+ VisToolCutSpline * visual = qobject_cast(vis);
+ if (visual != nullptr)
+ {
+ visual->show();
+ }
+ }
+ }
+ else
+ {
+ delete vis;
+ vis = nullptr;
+ }
+ if (VAbstractSpline *parentCurve = qobject_cast(doc->getTool(curveCutId)))
+ {
+ parentCurve->ShowFoot(show);
+ }
}
//---------------------------------------------------------------------------------------------------------------------
@@ -226,6 +233,14 @@ void VToolCutSpline::ShowVisualization(bool show)
void VToolCutSpline::FullUpdateFromFile()
{
FullUpdateCurveFromFile(AttrSpline);
+
+ if (vis != nullptr)
+ {
+ VisToolCutSpline *visual = qobject_cast(vis);
+ visual->setPoint1Id(curveCutId);
+ visual->setLength(formula);
+ visual->RefreshGeometry();
+ }
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/app/visualization/vistoolcutspline.cpp b/src/app/visualization/vistoolcutspline.cpp
new file mode 100644
index 000000000..6d41865fa
--- /dev/null
+++ b/src/app/visualization/vistoolcutspline.cpp
@@ -0,0 +1,76 @@
+/************************************************************************
+ **
+ ** @file vistoolcutspline.cpp
+ ** @author Roman Telezhynskyi
+ ** @date 6 9, 2014
+ **
+ ** @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) 2014 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 "vistoolcutspline.h"
+#include "../geometry/vspline.h"
+#include "../container/vcontainer.h"
+
+//---------------------------------------------------------------------------------------------------------------------
+VisToolCutSpline::VisToolCutSpline(const VContainer *data, QGraphicsItem *parent)
+ :VisPath(data, parent), point(nullptr), spl1(nullptr), spl2(nullptr), length(0)
+{
+ spl1 = InitItem(Qt::darkGreen, this);
+ spl1->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
+ spl2 = InitItem(Qt::darkRed, this);
+ spl2->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
+
+ point = InitPoint(mainColor, this);
+ point->setZValue(2);
+ point->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+VisToolCutSpline::~VisToolCutSpline()
+{}
+
+//---------------------------------------------------------------------------------------------------------------------
+void VisToolCutSpline::RefreshGeometry()
+{
+ if (point1Id > 0)
+ {
+ const QSharedPointer spl = Visualization::data->GeometricObject(point1Id);
+ DrawPath(this, spl->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap);
+
+ if (qFuzzyCompare(1 + length, 1 + 0) == false)
+ {
+ VSpline sp1;
+ VSpline sp2;
+ QPointF p = spl->CutSpline(length, sp1, sp2);
+ DrawPoint(point, p, mainColor);
+
+ DrawPath(spl1, sp1.GetPath(PathDirection::Show), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap);
+ DrawPath(spl2, sp2.GetPath(PathDirection::Show), Qt::darkRed, Qt::SolidLine, Qt::RoundCap);
+ }
+ }
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void VisToolCutSpline::setLength(const QString &expression)
+{
+ length = FindLength(expression);
+}
diff --git a/src/app/visualization/vistoolcutspline.h b/src/app/visualization/vistoolcutspline.h
new file mode 100644
index 000000000..5967f3ba5
--- /dev/null
+++ b/src/app/visualization/vistoolcutspline.h
@@ -0,0 +1,53 @@
+/************************************************************************
+ **
+ ** @file vistoolcutspline.h
+ ** @author Roman Telezhynskyi
+ ** @date 6 9, 2014
+ **
+ ** @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) 2014 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 VISTOOLCUTSPLINE_H
+#define VISTOOLCUTSPLINE_H
+
+#include "vispath.h"
+
+class VisToolCutSpline : public VisPath
+{
+ Q_OBJECT
+public:
+ VisToolCutSpline(const VContainer *data, QGraphicsItem *parent = 0);
+ virtual ~VisToolCutSpline();
+
+ virtual void RefreshGeometry();
+ void setLength(const QString &expression);
+ virtual int type() const {return Type;}
+ enum { Type = UserType + static_cast(Vis::ToolCutSpline)};
+protected:
+ Q_DISABLE_COPY(VisToolCutSpline)
+ QGraphicsEllipseItem *point;
+ QGraphicsPathItem *spl1;
+ QGraphicsPathItem *spl2;
+ qreal length;
+};
+
+#endif // VISTOOLCUTSPLINE_H
diff --git a/src/app/visualization/visualization.pri b/src/app/visualization/visualization.pri
index f811878f2..996302879 100644
--- a/src/app/visualization/visualization.pri
+++ b/src/app/visualization/visualization.pri
@@ -18,7 +18,8 @@ HEADERS += \
visualization/vistoolarc.h \
visualization/vispath.h \
visualization/vistoolcutarc.h \
- visualization/vistoolspline.h
+ visualization/vistoolspline.h \
+ visualization/vistoolcutspline.h
SOURCES += \
visualization/vgraphicssimpletextitem.cpp \
@@ -40,4 +41,5 @@ SOURCES += \
visualization/vistoolarc.cpp \
visualization/vispath.cpp \
visualization/vistoolcutarc.cpp \
- visualization/vistoolspline.cpp
+ visualization/vistoolspline.cpp \
+ visualization/vistoolcutspline.cpp