Visualization for VToolCutSpline.
--HG-- branch : feature
This commit is contained in:
parent
d2e5be50b4
commit
2a4eef7695
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -392,7 +392,7 @@
|
|||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<QPointF> GetPoints () const;
|
||||
// cppcheck-suppress unusedFunction
|
||||
static QVector<QPointF> SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
|
||||
|
|
|
@ -497,8 +497,10 @@ void MainWindow::ToolSpline(bool checked)
|
|||
*/
|
||||
void MainWindow::ToolCutSpline(bool checked)
|
||||
{
|
||||
SetToolButton<DialogCutSpline>(checked, Tool::CutSpline, ":/cursor/spline_cut_point_cursor.png",
|
||||
tr("Select simple curve"), &MainWindow::ClosedDialog<VToolCutSpline>);
|
||||
SetToolButtonWithApply<DialogCutSpline>(checked, Tool::CutSpline, ":/cursor/spline_cut_point_cursor.png",
|
||||
tr("Select simple curve"),
|
||||
&MainWindow::ClosedDialogWithApply<VToolCutSpline>,
|
||||
&MainWindow::ApplyDialog<VToolCutSpline>);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -99,7 +99,10 @@ enum class Vis : unsigned char
|
|||
ToolPointOfIntersection,
|
||||
ToolShoulderPoint,
|
||||
ToolSpline,
|
||||
ToolTriangle
|
||||
ToolTriangle,
|
||||
ToolCutSpline,
|
||||
ToolSplinePath,
|
||||
ToolCutSplinePath
|
||||
};
|
||||
|
||||
enum class Source : char { FromGui, FromFile, FromTool };
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(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
|
||||
|
|
|
@ -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 <geometry/vspline.h>
|
||||
|
||||
|
@ -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<VisTool *>(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<VisToolCutSpline *>(vis);
|
||||
if (visual != nullptr)
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete vis;
|
||||
vis = nullptr;
|
||||
}
|
||||
if (VAbstractSpline *parentCurve = qobject_cast<VAbstractSpline *>(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<VisToolCutSpline *>(vis);
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(formula);
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
76
src/app/visualization/vistoolcutspline.cpp
Normal file
76
src/app/visualization/vistoolcutspline.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vistoolcutspline.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @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
|
||||
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#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<QGraphicsPathItem>(Qt::darkGreen, this);
|
||||
spl1->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
|
||||
spl2 = InitItem<QGraphicsPathItem>(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<VSpline> spl = Visualization::data->GeometricObject<VSpline>(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);
|
||||
}
|
53
src/app/visualization/vistoolcutspline.h
Normal file
53
src/app/visualization/vistoolcutspline.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vistoolcutspline.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @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
|
||||
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#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<int>(Vis::ToolCutSpline)};
|
||||
protected:
|
||||
Q_DISABLE_COPY(VisToolCutSpline)
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsPathItem *spl1;
|
||||
QGraphicsPathItem *spl2;
|
||||
qreal length;
|
||||
};
|
||||
|
||||
#endif // VISTOOLCUTSPLINE_H
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user