Parent class for all visualizations.

--HG--
branch : develop
This commit is contained in:
dismine 2014-08-15 13:48:11 +03:00
parent 3f582123db
commit 198b73a40f
16 changed files with 258 additions and 141 deletions

View File

@ -33,42 +33,16 @@
//---------------------------------------------------------------------------------------------------------------------
VisLine::VisLine(const VContainer *data, QGraphicsItem *parent)
:QObject(), QGraphicsLineItem(parent), data(data), factor(VDrawTool::factor), scenePos(QPointF()),
mainColor(Qt::red), supportColor(Qt::magenta), lineStyle(Qt::SolidLine), point1Id(0), toolTip(QString())
:Visualization(data), QGraphicsLineItem(parent)
{
this->setZValue(1);// Show on top real tool
this->setPen(QPen(mainColor, qApp->toPixel(qApp->widthHairLine())/factor, lineStyle));
InitPen();
}
//---------------------------------------------------------------------------------------------------------------------
VisLine::~VisLine()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisLine::SetFactor(qreal factor)
{
VApplication::CheckFactor(this->factor, factor);
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void VisLine::setLineStyle(const Qt::PenStyle &value)
{
lineStyle = value;
this->setPen(QPen(mainColor, qApp->toPixel(qApp->widthHairLine())/factor, lineStyle));
}
//---------------------------------------------------------------------------------------------------------------------
void VisLine::MousePos(const QPointF &scenePos)
{
this->scenePos = scenePos;
RefreshGeometry();
if (toolTip.isEmpty() == false)
{
emit ToolTip(toolTip);
}
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisLine::PointRect(const qreal &radius)
{
@ -93,7 +67,7 @@ qreal VisLine::FindLength(const QString &expression)
QString formula = expression;
formula.replace("\n", " ");
formula = qApp->FormulaFromUser(formula);
Calculator *cal = new Calculator(data);
Calculator *cal = new Calculator(Visualization::data);
length = cal->EvalFormula(formula);
delete cal;
}
@ -127,7 +101,7 @@ qreal VisLine::FindVal(const QString &expression)
QString formula = expression;
formula.replace("\n", " ");
formula = qApp->FormulaFromUser(formula);
Calculator *cal = new Calculator(data);
Calculator *cal = new Calculator(Visualization::data);
val = cal->EvalFormula(formula);
delete cal;
}
@ -223,7 +197,7 @@ QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const
{
if(this->scene() == nullptr)
{
QLineF line = QLineF(firstPoint, scenePos);
QLineF line = QLineF(firstPoint, Visualization::scenePos);
line.setAngle(angle);
return line.p2();// We can't find ray because item doesn't have scene. We will return cursor position on scene.
}
@ -245,44 +219,10 @@ QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const
//---------------------------------------------------------------------------------------------------------------------
QPointF VisLine::Ray(const QPointF &firstPoint) const
{
QLineF line = QLineF(firstPoint, scenePos);
QLineF line = QLineF(firstPoint, Visualization::scenePos);
return Ray(firstPoint, line.angle());
}
//---------------------------------------------------------------------------------------------------------------------
void VisLine::setMainColor(const QColor &value)
{
mainColor = value;
this->setPen(QPen(mainColor, qApp->toPixel(qApp->widthHairLine())/factor, lineStyle));
}
//---------------------------------------------------------------------------------------------------------------------
void VisLine::setScenePos(const QPointF &value)
{
scenePos = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisLine::VisualMode(const quint32 &pointId)
{
VMainGraphicsScene *scene = qApp->getCurrentScene();
SCASSERT(scene != nullptr);
this->point1Id = pointId;
this->scenePos = scene->getScenePos();
RefreshGeometry();
scene->addItem(this);
connect(scene, &VMainGraphicsScene::NewFactor, this, &VisLine::SetFactor);
connect(scene, &VMainGraphicsScene::mouseMove, this, &VisLine::MousePos);
}
//---------------------------------------------------------------------------------------------------------------------
void VisLine::setPoint1Id(const quint32 &value)
{
point1Id = value;
}
//---------------------------------------------------------------------------------------------------------------------
QLineF VisLine::Axis(const QPointF &p, const qreal &angle) const
{
@ -297,3 +237,15 @@ QLineF VisLine::Axis(const QPointF &p1, const QPointF &p2) const
QLineF line(p1, p2);
return Axis(p1, line.angle());
}
//---------------------------------------------------------------------------------------------------------------------
void VisLine::InitPen()
{
this->setPen(QPen(mainColor, qApp->toPixel(qApp->widthHairLine())/factor, lineStyle));
}
//---------------------------------------------------------------------------------------------------------------------
void VisLine::AddOnScene()
{
AddItem(this);
}

View File

@ -29,41 +29,20 @@
#ifndef VISLINE_H
#define VISLINE_H
#include <QObject>
#include "visualization.h"
#include <QGraphicsLineItem>
#include <QPointF>
#include "../widgets/vapplication.h"
class VContainer;
class VisLine: public QObject, public QGraphicsLineItem
class VisLine: public Visualization, public QGraphicsLineItem
{
Q_OBJECT
public:
VisLine(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisLine();
void setPoint1Id(const quint32 &value);
void setLineStyle(const Qt::PenStyle &value);
virtual void RefreshGeometry()=0;
void setScenePos(const QPointF &value);
void VisualMode(const quint32 &pointId);
void setMainColor(const QColor &value);
signals:
void ToolTip(const QString &toolTip);
public slots:
void SetFactor(qreal factor);
void MousePos(const QPointF &scenePos);
protected:
const VContainer *data;
qreal factor;
QPointF scenePos;
QColor mainColor;
QColor supportColor;
Qt::PenStyle lineStyle;
quint32 point1Id;
QString toolTip;
QRectF PointRect(const qreal &radius);
qreal FindLength(const QString &expression);
qreal FindVal(const QString &expression);
@ -89,6 +68,8 @@ protected:
QPointF Ray(const QPointF &firstPoint) const;
QLineF Axis(const QPointF &p, const qreal &angle) const;
QLineF Axis(const QPointF &p1, const QPointF &p2) const;
virtual void InitPen();
virtual void AddOnScene();
private:
Q_DISABLE_COPY(VisLine)
};

View File

@ -64,16 +64,16 @@ void VisToolAlongLine::RefreshGeometry()
{
if (point1Id > 0)
{
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
const VPointF *first = Visualization::data->GeometricObject<const VPointF *>(point1Id);
DrawPoint(lineP1, first->toQPointF(), supportColor);
if (point2Id <= 0)
{
DrawLine(line, QLineF(first->toQPointF(), scenePos), supportColor);
DrawLine(line, QLineF(first->toQPointF(), Visualization::scenePos), supportColor);
}
else
{
const VPointF *second = data->GeometricObject<const VPointF *>(point2Id);
const VPointF *second = Visualization::data->GeometricObject<const VPointF *>(point2Id);
DrawPoint(lineP2, second->toQPointF(), supportColor);
DrawLine(line, QLineF(first->toQPointF(), second->toQPointF()), supportColor);

View File

@ -73,27 +73,27 @@ void VisToolBisector::RefreshGeometry()
{
if (point1Id > 0)
{
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
const VPointF *first = Visualization::data->GeometricObject<const VPointF *>(point1Id);
DrawPoint(line1P1, first->toQPointF(), supportColor);
if (point2Id <= 0)
{
DrawLine(line1, QLineF(first->toQPointF(), scenePos), supportColor);
DrawLine(line1, QLineF(first->toQPointF(), Visualization::scenePos), supportColor);
}
else
{
const VPointF *second = data->GeometricObject<const VPointF *>(point2Id);
const VPointF *second = Visualization::data->GeometricObject<const VPointF *>(point2Id);
DrawPoint(line1P2, second->toQPointF(), supportColor);
DrawLine(line1, QLineF(first->toQPointF(), second->toQPointF()), supportColor);
if (point3Id <= 0)
{
DrawLine(line2, QLineF(second->toQPointF(), scenePos), supportColor);
DrawLine(line2, QLineF(second->toQPointF(), Visualization::scenePos), supportColor);
}
else
{
const VPointF *third = data->GeometricObject<const VPointF *>(point3Id);
const VPointF *third = Visualization::data->GeometricObject<const VPointF *>(point3Id);
DrawPoint(line2P2, third->toQPointF(), supportColor);
DrawLine(line2, QLineF(second->toQPointF(), third->toQPointF()), supportColor);

View File

@ -50,7 +50,7 @@ VisToolEndLine::~VisToolEndLine()
//---------------------------------------------------------------------------------------------------------------------
void VisToolEndLine::RefreshGeometry()
{
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
const VPointF *first = Visualization::data->GeometricObject<const VPointF *>(point1Id);
QLineF line;
if (qFuzzyCompare(1 + length, 1 + 0))
{
@ -62,8 +62,8 @@ void VisToolEndLine::RefreshGeometry()
DrawPoint(point, line.p2(), mainColor);
}
DrawLine(this, line, mainColor, lineStyle);
toolTip = QString(tr("<b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - sticking angle, "
"<b>Enter</b> - finish creation")).arg(this->line().angle());
Visualization::toolTip = QString(tr("<b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - "
"sticking angle, <b>Enter</b> - finish creation")).arg(this->line().angle());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -53,27 +53,27 @@ void VisToolHeight::RefreshGeometry()
{
if (point1Id > 0)
{
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
const VPointF *first = Visualization::data->GeometricObject<const VPointF *>(point1Id);
DrawPoint(base_point, first->toQPointF(), supportColor);
if (lineP1Id <= 0)
{
DrawLine(this, QLineF(first->toQPointF(), scenePos), mainColor);
DrawLine(this, QLineF(first->toQPointF(), Visualization::scenePos), mainColor);
}
else
{
const VPointF *second = data->GeometricObject<const VPointF *>(lineP1Id);
const VPointF *second = Visualization::data->GeometricObject<const VPointF *>(lineP1Id);
DrawPoint(lineP1, second->toQPointF(), supportColor);
QLineF base_line;
if (lineP2Id <= 0)
{
base_line = QLineF(second->toQPointF(), scenePos);
base_line = QLineF(second->toQPointF(), Visualization::scenePos);
DrawLine(line, base_line, supportColor);
}
else
{
const VPointF *third = data->GeometricObject<const VPointF *>(lineP2Id);
const VPointF *third = Visualization::data->GeometricObject<const VPointF *>(lineP2Id);
DrawPoint(lineP2, third->toQPointF(), supportColor);
base_line = QLineF(second->toQPointF(), third->toQPointF());

View File

@ -46,14 +46,14 @@ VisToolLine::~VisToolLine()
void VisToolLine::RefreshGeometry()
{
QLineF line;
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
const VPointF *first = Visualization::data->GeometricObject<const VPointF *>(point1Id);
if (point2Id == 0)
{
line = QLineF(first->toQPointF(), scenePos);
line = QLineF(first->toQPointF(), Visualization::scenePos);
}
else
{
const VPointF *second = data->GeometricObject<const VPointF *>(point2Id);
const VPointF *second = Visualization::data->GeometricObject<const VPointF *>(point2Id);
line = QLineF(first->toQPointF(), second->toQPointF());
}
DrawLine(this, line, mainColor, lineStyle);

View File

@ -54,16 +54,16 @@ void VisToolLineIntersect::RefreshGeometry()
{
if (point1Id > 0)
{
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
const VPointF *first = Visualization::data->GeometricObject<const VPointF *>(point1Id);
DrawPoint(line1P1, first->toQPointF(), supportColor);
if (line1P2Id <= 0)
{
DrawLine(line1, QLineF(first->toQPointF(), scenePos), supportColor);
DrawLine(line1, QLineF(first->toQPointF(), Visualization::scenePos), supportColor);
}
else
{
const VPointF *second = data->GeometricObject<const VPointF *>(line1P2Id);
const VPointF *second = Visualization::data->GeometricObject<const VPointF *>(line1P2Id);
DrawPoint(line1P2, second->toQPointF(), supportColor);
DrawLine(line1, QLineF(first->toQPointF(), second->toQPointF()), supportColor);
@ -74,15 +74,15 @@ void VisToolLineIntersect::RefreshGeometry()
}
else
{
const VPointF *third = data->GeometricObject<const VPointF *>(line2P1Id);
const VPointF *third = Visualization::data->GeometricObject<const VPointF *>(line2P1Id);
DrawPoint(line2P1, third->toQPointF(), supportColor);
if (line2P2Id <= 0)
{
DrawLine(this, QLineF(third->toQPointF(), scenePos), supportColor);
DrawLine(this, QLineF(third->toQPointF(), Visualization::scenePos), supportColor);
QLineF l1(first->toQPointF(), second->toQPointF());
QLineF l2(third->toQPointF(), scenePos);
QLineF l2(third->toQPointF(), Visualization::scenePos);
QPointF fPoint;
QLineF::IntersectType intersect = l1.intersect(l2, &fPoint);
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
@ -92,7 +92,7 @@ void VisToolLineIntersect::RefreshGeometry()
}
else
{
const VPointF *forth = data->GeometricObject<const VPointF *>(line2P2Id);
const VPointF *forth = Visualization::data->GeometricObject<const VPointF *>(line2P2Id);
DrawPoint(line2P2, forth->toQPointF(), supportColor);
DrawLine(this, QLineF(third->toQPointF(), forth->toQPointF()), supportColor);

View File

@ -53,12 +53,12 @@ void VisToolNormal::RefreshGeometry()
{
if (point1Id > 0)
{
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
const VPointF *first = Visualization::data->GeometricObject<const VPointF *>(point1Id);
DrawPoint(lineP1, first->toQPointF(), supportColor);
if (point2Id <= 0)
{
QLineF line_mouse(first->toQPointF(), scenePos);
QLineF line_mouse(first->toQPointF(), Visualization::scenePos);
DrawLine(line, line_mouse, supportColor);
QLineF normal = line_mouse.normalVector();
@ -67,7 +67,7 @@ void VisToolNormal::RefreshGeometry()
}
else
{
const VPointF *second = data->GeometricObject<const VPointF *>(point2Id);
const VPointF *second = Visualization::data->GeometricObject<const VPointF *>(point2Id);
DrawPoint(lineP2, second->toQPointF(), supportColor);
QLineF line_mouse(first->toQPointF(), second->toQPointF());

View File

@ -52,16 +52,16 @@ void VisToolPointOfContact::RefreshGeometry()
{
if (point1Id > 0)
{
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
const VPointF *first = Visualization::data->GeometricObject<const VPointF *>(point1Id);
DrawPoint(lineP1, first->toQPointF(), supportColor);
if (lineP2Id <= 0)
{
DrawLine(this, QLineF(first->toQPointF(), scenePos), supportColor);
DrawLine(this, QLineF(first->toQPointF(), Visualization::scenePos), supportColor);
}
else
{
const VPointF *second = data->GeometricObject<const VPointF *>(lineP2Id);
const VPointF *second = Visualization::data->GeometricObject<const VPointF *>(lineP2Id);
DrawPoint(lineP2, second->toQPointF(), supportColor);
DrawLine(this, QLineF(first->toQPointF(), second->toQPointF()), supportColor);
@ -71,7 +71,7 @@ void VisToolPointOfContact::RefreshGeometry()
}
else
{
const VPointF *third = data->GeometricObject<const VPointF *>(radiusId);
const VPointF *third = Visualization::data->GeometricObject<const VPointF *>(radiusId);
DrawPoint(arc_point, third->toQPointF(), supportColor);
if (qFuzzyCompare(1 + radius, 1 + 0) == false)

View File

@ -50,7 +50,7 @@ void VisToolPointOfIntersection::RefreshGeometry()
{
if (point1Id > 0)
{
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
const VPointF *first = Visualization::data->GeometricObject<const VPointF *>(point1Id);
DrawPoint(axisP1, first->toQPointF(), supportColor);
QLineF axisL1 = Axis(first->toQPointF(), 90);
@ -59,11 +59,11 @@ void VisToolPointOfIntersection::RefreshGeometry()
QLineF axisL2;
if (point2Id <= 0)
{
axisL2 = Axis(scenePos, 180);
axisL2 = Axis(Visualization::scenePos, 180);
}
else
{
const VPointF *second = data->GeometricObject<const VPointF *>(point2Id);
const VPointF *second = Visualization::data->GeometricObject<const VPointF *>(point2Id);
DrawPoint(axisP2, second->toQPointF(), supportColor);
axisL2 = Axis(second->toQPointF(), 180);
ShowIntersection(axisL1, axisL2);

View File

@ -55,27 +55,27 @@ void VisToolShoulderPoint::RefreshGeometry()
{
if (point1Id > 0)
{
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
const VPointF *first = Visualization::data->GeometricObject<const VPointF *>(point1Id);
DrawPoint(line1P1, first->toQPointF(), supportColor);
if (lineP1Id <= 0)
{
DrawLine(line1, QLineF(first->toQPointF(), scenePos), supportColor);
DrawLine(line1, QLineF(first->toQPointF(), Visualization::scenePos), supportColor);
}
else
{
const VPointF *second = data->GeometricObject<const VPointF *>(lineP1Id);
const VPointF *second = Visualization::data->GeometricObject<const VPointF *>(lineP1Id);
DrawPoint(line1P2, second->toQPointF(), supportColor);
DrawLine(line1, QLineF(first->toQPointF(), second->toQPointF()), supportColor);
if (lineP2Id <= 0)
{
DrawLine(line2, QLineF(second->toQPointF(), scenePos), supportColor);
DrawLine(line2, QLineF(second->toQPointF(), Visualization::scenePos), supportColor);
}
else
{
const VPointF *third = data->GeometricObject<const VPointF *>(lineP2Id);
const VPointF *third = Visualization::data->GeometricObject<const VPointF *>(lineP2Id);
DrawPoint(line2P2, third->toQPointF(), supportColor);
DrawLine(line2, QLineF(second->toQPointF(), third->toQPointF()), supportColor);

View File

@ -30,7 +30,7 @@
#include "../geometry/vpointf.h"
#include "../container/vcontainer.h"
#include "../tools/drawTools/vtooltriangle.h"
#include "QtMath"
#include <QtMath>
//---------------------------------------------------------------------------------------------------------------------
VisToolTriangle::VisToolTriangle(const VContainer *data, QGraphicsItem *parent)
@ -57,16 +57,16 @@ void VisToolTriangle::RefreshGeometry()
{
if (point1Id > 0)
{
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
const VPointF *first = Visualization::data->GeometricObject<const VPointF *>(point1Id);
DrawPoint(axisP1, first->toQPointF(), supportColor);
if (point2Id <= 0)
{
DrawAimedAxis(axis, QLineF(first->toQPointF(), scenePos), supportColor);
DrawAimedAxis(axis, QLineF(first->toQPointF(), Visualization::scenePos), supportColor);
}
else
{
const VPointF *second = data->GeometricObject<const VPointF *>(point2Id);
const VPointF *second = Visualization::data->GeometricObject<const VPointF *>(point2Id);
DrawPoint(axisP2, second->toQPointF(), supportColor);
DrawAimedAxis(axis, QLineF(first->toQPointF(), second->toQPointF()), supportColor);
@ -77,23 +77,23 @@ void VisToolTriangle::RefreshGeometry()
}
else
{
const VPointF *third = data->GeometricObject<const VPointF *>(hypotenuseP1Id);
const VPointF *third = Visualization::data->GeometricObject<const VPointF *>(hypotenuseP1Id);
DrawPoint(hypotenuseP1, third->toQPointF(), supportColor);
if (hypotenuseP2Id <= 0)
{
DrawLine(this, QLineF(third->toQPointF(), scenePos), supportColor, Qt::DashLine);
DrawLine(this, QLineF(third->toQPointF(), Visualization::scenePos), supportColor, Qt::DashLine);
QPointF trPoint = VToolTriangle::FindPoint(first->toQPointF(), second->toQPointF(),
third->toQPointF(), scenePos);
third->toQPointF(), Visualization::scenePos);
DrawPoint(point, trPoint, mainColor);
DrawLine(foot1, QLineF(third->toQPointF(), trPoint), supportColor, Qt::DashLine);
DrawLine(foot2, QLineF(scenePos, trPoint), supportColor, Qt::DashLine);
DrawLine(foot2, QLineF(Visualization::scenePos, trPoint), supportColor, Qt::DashLine);
}
else
{
const VPointF *forth = data->GeometricObject<const VPointF *>(hypotenuseP2Id);
const VPointF *forth = Visualization::data->GeometricObject<const VPointF *>(hypotenuseP2Id);
DrawPoint(hypotenuseP2, forth->toQPointF(), supportColor);
DrawLine(this, QLineF(third->toQPointF(), forth->toQPointF()), supportColor, Qt::DashLine);

View File

@ -0,0 +1,97 @@
/************************************************************************
**
** @file visualization.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 "visualization.h"
#include "../tools/drawTools/vdrawtool.h"
//---------------------------------------------------------------------------------------------------------------------
Visualization::Visualization(const VContainer *data)
:QObject(), data(data), factor(VDrawTool::factor), scenePos(QPointF()),
mainColor(Qt::red), supportColor(Qt::magenta), lineStyle(Qt::SolidLine), point1Id(0), toolTip(QString())
{}
//---------------------------------------------------------------------------------------------------------------------
Visualization::~Visualization()
{}
//---------------------------------------------------------------------------------------------------------------------
void Visualization::setPoint1Id(const quint32 &value)
{
point1Id = value;
}
//---------------------------------------------------------------------------------------------------------------------
void Visualization::setLineStyle(const Qt::PenStyle &value)
{
lineStyle = value;
InitPen();
}
//---------------------------------------------------------------------------------------------------------------------
void Visualization::setScenePos(const QPointF &value)
{
scenePos = value;
}
//---------------------------------------------------------------------------------------------------------------------
void Visualization::VisualMode(const quint32 &pointId)
{
VMainGraphicsScene *scene = qApp->getCurrentScene();
SCASSERT(scene != nullptr);
this->point1Id = pointId;
this->scenePos = scene->getScenePos();
RefreshGeometry();
AddOnScene();
}
//---------------------------------------------------------------------------------------------------------------------
void Visualization::setMainColor(const QColor &value)
{
mainColor = value;
InitPen();
}
//---------------------------------------------------------------------------------------------------------------------
void Visualization::SetFactor(qreal factor)
{
VApplication::CheckFactor(this->factor, factor);
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void Visualization::MousePos(const QPointF &scenePos)
{
this->scenePos = scenePos;
RefreshGeometry();
if (toolTip.isEmpty() == false)
{
emit ToolTip(toolTip);
}
}

View File

@ -0,0 +1,85 @@
/************************************************************************
**
** @file visualization.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 VISUALIZATION_H
#define VISUALIZATION_H
#include <QObject>
#include "../widgets/vapplication.h"
#include "../widgets/vmaingraphicsscene.h"
class VContainer;
class Visualization : public QObject
{
Q_OBJECT
public:
Visualization(const VContainer *data);
virtual ~Visualization();
virtual void RefreshGeometry()=0;
void setPoint1Id(const quint32 &value);
void setLineStyle(const Qt::PenStyle &value);
void setScenePos(const QPointF &value);
void VisualMode(const quint32 &pointId);
void setMainColor(const QColor &value);
signals:
void ToolTip(const QString &toolTip);
public slots:
void SetFactor(qreal factor);
void MousePos(const QPointF &scenePos);
protected:
const VContainer *data;
qreal factor;
QPointF scenePos;
QColor mainColor;
QColor supportColor;
Qt::PenStyle lineStyle;
quint32 point1Id;
QString toolTip;
virtual void InitPen()=0;
virtual void AddOnScene()=0;
template <typename Item>
void AddItem(Item *item)
{
SCASSERT(item != nullptr);
VMainGraphicsScene *scene = qApp->getCurrentScene();
SCASSERT(scene != nullptr);
scene->addItem(item);
connect(scene, &VMainGraphicsScene::NewFactor, item, &Visualization::SetFactor);
connect(scene, &VMainGraphicsScene::mouseMove, item, &Visualization::MousePos);
}
private:
Q_DISABLE_COPY(Visualization)
};
#endif // VISUALIZATION_H

View File

@ -14,7 +14,8 @@ HEADERS += \
visualization/vistoolpointofintersection.h \
visualization/vistooltriangle.h \
visualization/vistoolpointofcontact.h \
visualization/vistoollineintersect.h
visualization/vistoollineintersect.h \
visualization/visualization.h
SOURCES += \
visualization/vgraphicssimpletextitem.cpp \
@ -32,4 +33,5 @@ SOURCES += \
visualization/vistoolpointofintersection.cpp \
visualization/vistooltriangle.cpp \
visualization/vistoolpointofcontact.cpp \
visualization/vistoollineintersect.cpp
visualization/vistoollineintersect.cpp \
visualization/visualization.cpp