Visualization for VToolCutArc.

--HG--
branch : develop
This commit is contained in:
dismine 2014-08-15 17:37:22 +03:00
parent 3546c2a557
commit e9dc8d7b98
8 changed files with 160 additions and 6 deletions

View file

@ -31,6 +31,8 @@
#include "../../geometry/varc.h"
#include "../../container/vcontainer.h"
#include "../../visualization/vistoolcutarc.h"
#include "../../widgets/vmaingraphicsscene.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -40,7 +42,7 @@
*/
DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
: DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), pointName(QString()), formula(QString()), arcId(0),
formulaBaseHeight(0)
formulaBaseHeight(0), path(nullptr)
{
ui->setupUi(this);
InitVariables(ui);
@ -62,6 +64,8 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutArc::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutArc::FormulaTextChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutArc::DeployFormulaTextEdit);
path = new VisToolCutArc(data);
}
//---------------------------------------------------------------------------------------------------------------------
@ -70,6 +74,18 @@ void DialogCutArc::FormulaTextChanged()
this->FormulaChangedPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor);
scene->addItem(path);
path->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::DeployFormulaTextEdit()
{
@ -79,6 +95,7 @@ void DialogCutArc::DeployFormulaTextEdit()
//---------------------------------------------------------------------------------------------------------------------
DialogCutArc::~DialogCutArc()
{
delete path;
delete ui;
}
@ -94,6 +111,8 @@ void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type)
{
const VArc *arc = data->GeometricObject<const VArc *>(id);
ChangeCurrentText(ui->comboBoxArc, arc->name());
path->VisualMode(id);
prepare = true;
emit ToolTip("");
this->setModal(true);
this->show();
@ -107,6 +126,10 @@ void DialogCutArc::SaveData()
formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
arcId = getCurrentObjectId(ui->comboBoxArc);
path->setPoint1Id(arcId);
path->setLength(formula);
path->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
@ -117,6 +140,7 @@ void DialogCutArc::SaveData()
void DialogCutArc::setArcId(const quint32 &value)
{
setCurrentArcId(ui->comboBoxArc, arcId, value, ComboBoxCutArc::CutArc);
path->setPoint1Id(arcId);
}
//---------------------------------------------------------------------------------------------------------------------
@ -133,6 +157,7 @@ void DialogCutArc::setFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
path->setLength(formula);
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -36,6 +36,8 @@ namespace Ui
class DialogCutArc;
}
class VisToolCutArc;
/**
* @brief The DialogCutArc class dialog for ToolCutArc.
*/
@ -66,6 +68,7 @@ public slots:
*/
void FormulaTextChanged();
protected:
virtual void ShowVisualization();
/**
* @brief SaveData Put dialog data in local variables
*/
@ -82,11 +85,12 @@ private:
QString formula;
/** @brief arcId keep id of arc */
quint32 arcId;
quint32 arcId;
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
int formulaBaseHeight;
VisToolCutArc *path;
};
//---------------------------------------------------------------------------------------------------------------------

View file

@ -222,6 +222,15 @@ QPointF VArc::CutArc(const qreal &length, VArc &arc1, VArc &arc2) const
return line.p2();
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VArc::CutArc(const qreal &length) const
{
VArc arc1;
VArc arc2;
return this->CutArc(length, arc1, arc2);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setId keep id arc in data.

View file

@ -61,6 +61,7 @@ public:
qreal AngleArc() const;
QVector<QPointF> GetPoints () const;
QPointF CutArc (const qreal &length, VArc &arc1, VArc &arc2) const;
QPointF CutArc (const qreal &length) const;
virtual void setId(const quint32 &id);
private:
/** @brief f1 start angle in degree. */

View file

@ -57,6 +57,6 @@ void VisPath::DrawPath(QGraphicsPathItem *pathItem, const QPainterPath &path, co
{
SCASSERT (pathItem != nullptr);
pathItem->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor, style));
pathItem->setPen(QPen(color, qApp->toPixel(qApp->widthMainLine())/factor, style));
pathItem->setPath(path);
}

View file

@ -0,0 +1,64 @@
/************************************************************************
**
** @file vistoolcutarc.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 15 8, 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 "vistoolcutarc.h"
#include "../geometry/varc.h"
#include "../container/vcontainer.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent)
:VisPath(data, parent), point(nullptr), length(0)
{
point = InitPoint(mainColor, this);
point->setZValue(2);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolCutArc::~VisToolCutArc()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolCutArc::RefreshGeometry()
{
if (point1Id > 0)
{
const VArc *arc = Visualization::data->GeometricObject<const VArc *>(point1Id);
DrawPath(this, arc->GetPath(), supportColor);
if (qFuzzyCompare(1 + length, 1 + 0) == false)
{
DrawPoint(point, arc->CutArc(length), mainColor);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolCutArc::setLength(const QString &expression)
{
length = FindLength(expression);
}

View file

@ -0,0 +1,49 @@
/************************************************************************
**
** @file vistoolcutarc.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 15 8, 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 VISTOOLCUTARC_H
#define VISTOOLCUTARC_H
#include "vispath.h"
class VisToolCutArc : public VisPath
{
Q_OBJECT
public:
VisToolCutArc(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolCutArc();
virtual void RefreshGeometry();
void setLength(const QString &expression);
protected:
Q_DISABLE_COPY(VisToolCutArc)
QGraphicsEllipseItem *point;
qreal length;
};
#endif // VISTOOLCUTARC_H

View file

@ -17,7 +17,8 @@ HEADERS += \
visualization/vistoollineintersect.h \
visualization/visualization.h \
visualization/vistoolarc.h \
visualization/vispath.h
visualization/vispath.h \
visualization/vistoolcutarc.h
SOURCES += \
visualization/vgraphicssimpletextitem.cpp \
@ -38,4 +39,5 @@ SOURCES += \
visualization/vistoollineintersect.cpp \
visualization/visualization.cpp \
visualization/vistoolarc.cpp \
visualization/vispath.cpp
visualization/vispath.cpp \
visualization/vistoolcutarc.cpp