We no need anymore VModeling* tools.

--HG--
branch : feature
This commit is contained in:
dismine 2013-12-21 13:36:51 +02:00
parent 028f913f5c
commit 66c9e35e0b
113 changed files with 382 additions and 7741 deletions

View File

@ -35,14 +35,10 @@ qint64 VContainer::_id = 0;
VContainer::VContainer()
:base(QHash<QString, qint32>()), points(QHash<qint64, VPointF>()),
pointsModeling(QHash<qint64, VPointF>()),
standartTable(QHash<QString, VStandartTableRow>()), incrementTable(QHash<QString, VIncrementTableRow>()),
standartTable(QHash<QString, VStandartTableRow>()), incrementTable(QHash<QString, VIncrementTableRow>()),
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), splines(QHash<qint64, VSpline>()),
splinesModeling(QHash<qint64, VSpline>()),
lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), arcsModeling(QHash<qint64, VArc>()),
lengthArcs(QHash<QString, qreal>()),
splinePaths(QHash<qint64, VSplinePath>()), splinePathsModeling(QHash<qint64, VSplinePath>()),
details(QHash<qint64, VDetail>())
lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), lengthArcs(QHash<QString, qreal>()),
splinePaths(QHash<qint64, VSplinePath>()), details(QHash<qint64, VDetail>())
{
SetSize(500);
SetGrowth(1760);
@ -57,14 +53,10 @@ VContainer &VContainer::operator =(const VContainer &data)
VContainer::VContainer(const VContainer &data)
:base(QHash<QString, qint32>()), points(QHash<qint64, VPointF>()),
pointsModeling(QHash<qint64, VPointF>()),
standartTable(QHash<QString, VStandartTableRow>()), incrementTable(QHash<QString, VIncrementTableRow>()),
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), splines(QHash<qint64, VSpline>()),
splinesModeling(QHash<qint64, VSpline>()),
lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), arcsModeling(QHash<qint64, VArc>()),
lengthArcs(QHash<QString, qreal>()),
splinePaths(QHash<qint64, VSplinePath>()), splinePathsModeling(QHash<qint64, VSplinePath>()),
details(QHash<qint64, VDetail>())
lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), lengthArcs(QHash<QString, qreal>()),
splinePaths(QHash<qint64, VSplinePath>()), details(QHash<qint64, VDetail>())
{
setData(data);
}
@ -73,19 +65,15 @@ void VContainer::setData(const VContainer &data)
{
base = *data.DataBase();
points = *data.DataPoints();
pointsModeling = *data.DataPointsModeling();
standartTable = *data.DataStandartTable();
incrementTable = *data.DataIncrementTable();
lengthLines = *data.DataLengthLines();
lineAngles = *data.DataLineAngles();
splines = *data.DataSplines();
splinesModeling = *data.DataSplinesModeling();
lengthSplines = *data.DataLengthSplines();
arcs = *data.DataArcs();
arcsModeling = *data.DataArcsModeling();
lengthArcs = *data.DataLengthArcs();
splinePaths = *data.DataSplinePaths();
splinePathsModeling = *data.DataSplinePathsModeling();
details = *data.DataDetails();
}
@ -94,11 +82,6 @@ VPointF VContainer::GetPoint(qint64 id) const
return GetObject(points, id);
}
VPointF VContainer::GetPointModeling(qint64 id) const
{
return GetObject(pointsModeling, id);
}
template <typename key, typename val>
val VContainer::GetObject(const QHash<key, val> &obj, key id)
{
@ -153,31 +136,16 @@ VSpline VContainer::GetSpline(qint64 id) const
return GetObject(splines, id);
}
VSpline VContainer::GetSplineModeling(qint64 id) const
{
return GetObject(splinesModeling, id);
}
VArc VContainer::GetArc(qint64 id) const
{
return GetObject(arcs, id);
}
VArc VContainer::GetArcModeling(qint64 id) const
{
return GetObject(arcsModeling, id);
}
VSplinePath VContainer::GetSplinePath(qint64 id) const
{
return GetObject(splinePaths, id);
}
VSplinePath VContainer::GetSplinePathModeling(qint64 id) const
{
return GetObject(splinePathsModeling, id);
}
VDetail VContainer::GetDetail(qint64 id) const
{
return GetObject(details, id);
@ -188,11 +156,6 @@ qint64 VContainer::AddPoint(const VPointF &point)
return AddObject(points, point);
}
qint64 VContainer::AddPointModeling(const VPointF &point)
{
return AddObject(pointsModeling, point);
}
qint64 VContainer::AddDetail(const VDetail &detail)
{
return AddObject(details, detail);
@ -223,7 +186,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
{
case (Tool::NodePoint):
{
VPointF point = GetPointModeling(detail[i].getId());
VPointF point = GetPoint(detail[i].getId());
points.append(point.toQPointF());
if (detail.getSupplement() == true)
{
@ -236,7 +199,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
break;
case (Tool::NodeArc):
{
VArc arc = GetArcModeling(detail[i].getId());
VArc arc = GetArc(detail[i].getId());
qreal len1 = GetLengthContour(points, arc.GetPoints());
qreal lenReverse = GetLengthContour(points, GetReversePoint(arc.GetPoints()));
if (len1 <= lenReverse)
@ -259,7 +222,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
break;
case (Tool::NodeSpline):
{
VSpline spline = GetSplineModeling(detail[i].getId());
VSpline spline = GetSpline(detail[i].getId());
qreal len1 = GetLengthContour(points, spline.GetPoints());
qreal lenReverse = GetLengthContour(points, GetReversePoint(spline.GetPoints()));
if (len1 <= lenReverse)
@ -283,7 +246,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
break;
case (Tool::NodeSplinePath):
{
VSplinePath splinePath = GetSplinePathModeling(detail[i].getId());
VSplinePath splinePath = GetSplinePath(detail[i].getId());
qreal len1 = GetLengthContour(points, splinePath.GetPathPoints());
qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath.GetPathPoints()));
if (len1 <= lenReverse)
@ -553,21 +516,6 @@ void VContainer::PrepareDetails(QVector<VItem *> &list) const
}
}
qint64 VContainer::PointConvertToModeling(qint64 id)
{
QHashIterator<qint64, VPointF> pModeling(pointsModeling);
while (pModeling.hasNext())
{
pModeling.next();
VPointF p = pModeling.value();
if(p.getIdObject() == id)
{
return pModeling.key();
}
}
return 0;
}
template <typename val>
void VContainer::UpdateObject(QHash<qint64, val> &obj, const qint64 &id, const val& point)
{
@ -626,10 +574,6 @@ void VContainer::Clear()
lengthArcs.clear();
lineAngles.clear();
details.clear();
arcsModeling.clear();
pointsModeling.clear();
splinePathsModeling.clear();
splinesModeling.clear();
ClearObject();
CreateManTableIGroup ();
}
@ -684,23 +628,13 @@ qreal VContainer::FindVar(const QString &name, bool *ok)const
return 0;
}
void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId, const Draw::Draws &mode)
void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId)
{
QString nameLine = GetNameLine(firstPointId, secondPointId, mode);
VPointF first;
VPointF second;
if (mode == Draw::Calculation)
{
first = GetPoint(firstPointId);
second = GetPoint(secondPointId);
}
else
{
first = GetPointModeling(firstPointId);
second = GetPointModeling(secondPointId);
}
QString nameLine = GetNameLine(firstPointId, secondPointId);
VPointF first = GetPoint(firstPointId);
VPointF second = GetPoint(secondPointId);
AddLengthLine(nameLine, toMM(QLineF(first.toQPointF(), second.toQPointF()).length()));
nameLine = GetNameLineAngle(firstPointId, secondPointId, mode);
nameLine = GetNameLineAngle(firstPointId, secondPointId);
AddLineAngle(nameLine, QLineF(first.toQPointF(), second.toQPointF()).angle());
}
@ -709,31 +643,16 @@ qint64 VContainer::AddSpline(const VSpline &spl)
return AddObject(splines, spl);
}
qint64 VContainer::AddSplineModeling(const VSpline &spl)
{
return AddObject(splinesModeling, spl);
}
qint64 VContainer::AddSplinePath(const VSplinePath &splPath)
{
return AddObject(splinePaths, splPath);
}
qint64 VContainer::AddSplinePathModeling(const VSplinePath &splPath)
{
return AddObject(splinePathsModeling, splPath);
}
qint64 VContainer::AddArc(const VArc &arc)
{
return AddObject(arcs, arc);
}
qint64 VContainer::AddArcModeling(const VArc &arc)
{
return AddObject(arcsModeling, arc);
}
template <typename key, typename val>
qint64 VContainer::AddObject(QHash<key, val> &obj, const val& value)
{
@ -742,37 +661,19 @@ qint64 VContainer::AddObject(QHash<key, val> &obj, const val& value)
return id;
}
QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, const Draw::Draws &mode) const
QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const
{
VPointF first;
VPointF second;
if (mode == Draw::Calculation)
{
first = GetPoint(firstPoint);
second = GetPoint(secondPoint);
}
else
{
first = GetPointModeling(firstPoint);
second = GetPointModeling(secondPoint);
}
VPointF first = GetPoint(firstPoint);
VPointF second = GetPoint(secondPoint);
return QString("Line_%1_%2").arg(first.name(), second.name());
}
QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint, const Draw::Draws &mode) const
QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint) const
{
VPointF first;
VPointF second;
if (mode == Draw::Calculation)
{
first = GetPoint(firstPoint);
second = GetPoint(secondPoint);
}
else
{
first = GetPointModeling(firstPoint);
second = GetPointModeling(secondPoint);
}
VPointF first = GetPoint(firstPoint);
VPointF second = GetPoint(secondPoint);
return QString("AngleLine_%1_%2").arg(first.name(), second.name());
}
@ -781,11 +682,6 @@ void VContainer::UpdatePoint(qint64 id, const VPointF &point)
UpdateObject(points, id, point);
}
void VContainer::UpdatePointModeling(qint64 id, const VPointF &point)
{
UpdateObject(pointsModeling, id, point);
}
void VContainer::UpdateDetail(qint64 id, const VDetail &detail)
{
UpdateObject(details, id, detail);
@ -796,31 +692,16 @@ void VContainer::UpdateSpline(qint64 id, const VSpline &spl)
UpdateObject(splines, id, spl);
}
void VContainer::UpdateSplineModeling(qint64 id, const VSpline &spl)
{
UpdateObject(splinesModeling, id, spl);
}
void VContainer::UpdateSplinePath(qint64 id, const VSplinePath &splPath)
{
UpdateObject(splinePaths, id, splPath);
}
void VContainer::UpdateSplinePathModeling(qint64 id, const VSplinePath &splPath)
{
UpdateObject(splinePathsModeling, id, splPath);
}
void VContainer::UpdateArc(qint64 id, const VArc &arc)
{
UpdateObject(arcs, id, arc);
}
void VContainer::UpdateArcModeling(qint64 id, const VArc &arc)
{
UpdateObject(arcsModeling, id, arc);
}
void VContainer::AddLengthLine(const QString &name, const qreal &value)
{
Q_ASSERT(name.isEmpty() == false);

View File

@ -69,12 +69,6 @@ public:
* @return point
*/
VPointF GetPoint(qint64 id) const;
/**
* @brief GetPointModeling return a point modeling by id
* @param id id of point modeling
* @return point modeling
*/
VPointF GetPointModeling(qint64 id) const;
/**
* @brief GetStandartTableCell return standart table row by name
* @param name name of standart table row
@ -117,36 +111,18 @@ public:
* @return spline
*/
VSpline GetSpline(qint64 id) const;
/**
* @brief GetSplineModeling return spline modeling by id
* @param id id of spline modeling
* @return spline modeling
*/
VSpline GetSplineModeling(qint64 id) const;
/**
* @brief GetArc return arc by id
* @param id id of arc
* @return arc
*/
VArc GetArc(qint64 id) const;
/**
* @brief GetArcModeling return arc modeling by id
* @param id id of arc modeling
* @return arc modeling
*/
VArc GetArcModeling(qint64 id) const;
/**
* @brief GetSplinePath return spline path by id
* @param id id of spline path
* @return spline path
*/
VSplinePath GetSplinePath(qint64 id) const;
/**
* @brief GetSplinePathModeling return spline path modeling by id
* @param id id of spline modeling path
* @return spline modeling path
*/
VSplinePath GetSplinePathModeling(qint64 id) const;
/**
* @brief GetDetail return detail by id
* @param id id of detail
@ -164,12 +140,6 @@ public:
* @return return id of new point in container
*/
qint64 AddPoint(const VPointF& point);
/**
* @brief AddPointModeling add new point modeling to container
* @param point new point modeling
* @return return id of new point modeling in container
*/
qint64 AddPointModeling(const VPointF& point);
/**
* @brief AddDetail add new detail to container
* @param detail new detail
@ -225,32 +195,19 @@ public:
* @param secondPointId id of second point of line
* @param mode mode of line
*/
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId,
const Draw::Draws &mode = Draw::Calculation);
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId);
/**
* @brief AddSpline add spline to container
* @param spl new spline
* @return id of spline in container
*/
qint64 AddSpline(const VSpline& spl);
/**
* @brief AddSplineModeling add spline modeling to container
* @param spl new spline modeling
* @return id of spline modeling in container
*/
qint64 AddSplineModeling(const VSpline& spl);
/**
* @brief AddSplinePath add spline path to container
* @param splPath new spline path
* @return id of spline path in container
*/
qint64 AddSplinePath(const VSplinePath& splPath);
/**
* @brief AddSplinePathModeling add spline path modeling to container
* @param splPath new spline path
* @return id of spline path in container
*/
qint64 AddSplinePathModeling(const VSplinePath& splPath);
/**
* @brief AddArc add arc to container
* @param arc new arc
@ -267,32 +224,22 @@ public:
* @brief GetNameLine return name of line
* @param firstPoint id of first point of line
* @param secondPoint id of second point of line
* @param mode mode of line
* @return name of line
*/
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint,
const Draw::Draws &mode = Draw::Calculation) const;
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const;
/**
* @brief GetNameLineAngle return name of line angle
* @param firstPoint id of first point of line
* @param secondPoint id of second point of line
* @param mode mode of line
* @return name of angle of line
*/
QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint,
const Draw::Draws &mode = Draw::Calculation) const;
QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint) const;
/**
* @brief UpdatePoint update point by id
* @param id id of existing point
* @param point point
*/
void UpdatePoint(qint64 id, const VPointF& point);
/**
* @brief UpdatePointModeling update point modeling by id
* @param id id of existing point modeling
* @param point point modeling
*/
void UpdatePointModeling(qint64 id, const VPointF& point);
/**
* @brief UpdateDetail update detail by id
* @param id id of existing detail
@ -305,24 +252,12 @@ public:
* @param spl spline
*/
void UpdateSpline(qint64 id, const VSpline& spl);
/**
* @brief UpdateSplineModeling update spline modeling by id
* @param id id of existing spline modeling
* @param spl spline modeling
*/
void UpdateSplineModeling(qint64 id, const VSpline& spl);
/**
* @brief UpdateSplinePath update spline path by id
* @param id id of existing spline path
* @param splPath spline path
*/
void UpdateSplinePath(qint64 id, const VSplinePath& splPath);
/**
* @brief UpdateSplinePathModeling update spline path modeling by id
* @param id id of existing spline path modeling
* @param splPath spline path modeling
*/
void UpdateSplinePathModeling(qint64 id, const VSplinePath& splPath);
/**
* @brief UpdateArc update arc by id
* @param id id of existing arc
@ -437,31 +372,16 @@ public:
* @return pointer on container of points
*/
inline const QHash<qint64, VPointF> *DataPoints() const {return &points;}
/**
* @brief data container with dataPointsModeling return container of points modeling
* @return pointer on container of points modeling
*/
inline const QHash<qint64, VPointF> *DataPointsModeling() const {return &pointsModeling;}
/**
* @brief data container with dataSplines return container of splines
* @return pointer on container of splines
*/
inline const QHash<qint64, VSpline> *DataSplines() const {return &splines;}
/**
* @brief data container with dataSplinesModeling return container of splines modeling
* @return pointer on container of splines modeling
*/
inline const QHash<qint64, VSpline> *DataSplinesModeling() const {return &splinesModeling;}
/**
* @brief data container with dataArcs return container of arcs
* @return pointer on container of arcs
*/
inline const QHash<qint64, VArc> *DataArcs() const {return &arcs;}
/**
* @brief data container with dataArcsModeling return container of arcs modeling
* @return pointer on container of arcs modeling
*/
inline const QHash<qint64, VArc> *DataArcsModeling() const {return &arcsModeling;}
/**
* @brief data container with dataBase return container of data
* @return pointer on container of base data
@ -502,11 +422,6 @@ public:
* @return pointer on container of spline paths
*/
inline const QHash<qint64, VSplinePath> *DataSplinePaths() const {return &splinePaths;}
/**
* @brief data container with dataSplinePathsModeling return container of spline paths modeling
* @return pointer on container of spline paths modeling
*/
inline const QHash<qint64, VSplinePath> *DataSplinePathsModeling() const {return &splinePathsModeling;}
/**
* @brief data container with dataDetails return container of details
* @return pointer on container of details
@ -573,7 +488,6 @@ public:
* @param list list of details
*/
void PrepareDetails(QVector<VItem *> & list) const;
qint64 PointConvertToModeling(qint64 id);
private:
/**
* @brief _id current id. New object will have value +1. For full class equal 0.
@ -587,10 +501,6 @@ private:
* @brief points container of points
*/
QHash<qint64, VPointF> points;
/**
* @brief pointsModeling container of points modeling
*/
QHash<qint64, VPointF> pointsModeling;
/**
* @brief standartTable container of standart table rows
*/
@ -611,10 +521,6 @@ private:
* @brief splines container of splines
*/
QHash<qint64, VSpline> splines;
/**
* @brief splinesModeling container of splines modeling
*/
QHash<qint64, VSpline> splinesModeling;
/**
* @brief lengthSplines container of splines length
*/
@ -623,10 +529,6 @@ private:
* @brief arcs container of arcs
*/
QHash<qint64, VArc> arcs;
/**
* @brief arcsModeling container of arcs modeling
*/
QHash<qint64, VArc> arcsModeling;
/**
* @brief lengthArcs container of arcs length
*/
@ -635,10 +537,6 @@ private:
* @brief splinePaths container of spline paths
*/
QHash<qint64, VSplinePath> splinePaths;
/**
* @brief splinePathsModeling container of spline paths modeling
*/
QHash<qint64, VSplinePath> splinePathsModeling;
/**
* @brief details container of details
*/

View File

@ -35,7 +35,6 @@ VPointF &VPointF::operator =(const VPointF &point)
_my = point.my();
_x = point.x();
_y = point.y();
mode = point.getMode();
idObject = point.getIdObject();
return *this;
}

View File

@ -43,14 +43,14 @@ public:
* @brief VPointF creat empty point
*/
inline VPointF ()
:_name(QString()), _mx(0), _my(0), _x(0), _y(0), mode(Draw::Calculation), idObject(0){}
:_name(QString()), _mx(0), _my(0), _x(0), _y(0), idObject(0){}
/**
* @brief VPointF copy constructor
* @param point
*/
inline VPointF (const VPointF &point )
:_name(point.name()), _mx(point.mx()), _my(point.my()), _x(point.x()), _y(point.y()),
mode(point.getMode()), idObject(point.getIdObject()){}
idObject(point.getIdObject()){}
/**
* @brief VPointF create new point
* @param x x coordinate
@ -58,12 +58,10 @@ public:
* @param name name of point
* @param mx offset name respect to x
* @param my offset name respect to y
* @param mode mode of draw
* @param idObject point modeling keep here id of parent point
*/
inline VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my,
Draw::Draws mode = Draw::Calculation, qint64 idObject = 0)
:_name(name), _mx(mx), _my(my), _x(x), _y(y), mode(mode), idObject(idObject){}
inline VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my, qint64 idObject = 0)
:_name(name), _mx(mx), _my(my), _x(x), _y(y), idObject(idObject){}
/**
* @brief operator = assignment operator
* @param point point
@ -126,16 +124,6 @@ public:
* @param value y coordinate
*/
inline void setY(const qreal &value){_y = value;}
/**
* @brief getMode return mode of point
* @return mode
*/
inline Draw::Draws getMode() const{return mode;}
/**
* @brief setMode set mode for point
* @param value mode
*/
inline void setMode(const Draw::Draws &value) {mode = value;}
/**
* @brief getIdObject return id of parrent.
* @return id
@ -167,10 +155,6 @@ private:
* @brief _y y coordinate
*/
qreal _y;
/**
* @brief mode mode of point
*/
Draw::Draws mode;
/**
* @brief idObject id of parent. Only for point modeling. All another return 0.
*/

View File

@ -31,8 +31,8 @@
#include <QPushButton>
DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()),
DialogAlongLine::DialogAlongLine(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0)
{
ui->setupUi(this);
@ -57,11 +57,8 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidg
connect(bCansel, &QPushButton::clicked, this, &DialogAlongLine::DialogRejected);
FillComboBoxTypeLine(ui->comboBoxLineType);
ui->comboBoxLineType->setCurrentIndex(1);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
}
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogAlongLine::PutVal);
@ -86,34 +83,9 @@ DialogAlongLine::~DialogAlongLine()
void DialogAlongLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name());

View File

@ -46,11 +46,9 @@ public:
/**
* @brief DialogAlongLine create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogAlongLine(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
DialogAlongLine(const VContainer *data, QWidget *parent = 0);
~DialogAlongLine();
/**
* @brief getPointName return name of point

View File

@ -32,8 +32,8 @@
#include <QPushButton>
#include <QtWidgets>
DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
DialogArc::DialogArc(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
timerRadius(0), timerF1(0), timerF2(0), center(0), radius(QString()), f1(QString()), f2(QString())
{
ui->setupUi(this);
@ -52,10 +52,8 @@ DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent)
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogArc::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxBasePoint);
}
FillComboBoxPoints(ui->comboBoxBasePoint);
CheckState();
@ -122,33 +120,10 @@ void DialogArc::SetRadius(const QString &value)
void DialogArc::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxBasePoint);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id)==false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
ChangeCurrentText(ui->comboBoxBasePoint, point.name());
emit ToolTip("");
this->show();

View File

@ -46,10 +46,9 @@ public:
/**
* @brief DialogArc create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogArc(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
DialogArc(const VContainer *data, QWidget *parent = 0);
~DialogArc();
/**
* @brief GetCenter return id of center point

View File

@ -31,8 +31,8 @@
#include <QPushButton>
DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()),
DialogBisector::DialogBisector(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0)
{
ui->setupUi(this);
@ -55,12 +55,10 @@ DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogBisector::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
FillComboBoxPoints(ui->comboBoxThirdPoint);
}
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
FillComboBoxPoints(ui->comboBoxThirdPoint);
FillComboBoxTypeLine(ui->comboBoxLineType);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogBisector::PutHere);
@ -86,35 +84,9 @@ DialogBisector::~DialogBisector()
void DialogBisector::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
FillComboBoxPoints(ui->comboBoxThirdPoint);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name());

View File

@ -46,11 +46,9 @@ public:
/**
* @brief DialogBisector create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogBisector(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
DialogBisector(const VContainer *data, QWidget *parent = 0);
~DialogBisector();
/**
* @brief getPointName return name of point

View File

@ -29,9 +29,8 @@
#include "dialogcutspline.h"
#include "ui_dialogcutspline.h"
DialogCutSpline::DialogCutSpline(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogCutSpline), pointName(QString()), formula(QString()),
splineId(0)
DialogCutSpline::DialogCutSpline(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogCutSpline), pointName(QString()), formula(QString()), splineId(0)
{
ui->setupUi(this);
listWidget = ui->listWidget;
@ -53,10 +52,8 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, Draw::Draws mode, QWidg
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogCutSpline::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxSplines(ui->comboBoxSpline);
}
FillComboBoxSplines(ui->comboBoxSpline);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSpline::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSpline::PutVal);
@ -98,33 +95,9 @@ void DialogCutSpline::setSplineId(const qint64 &value, const qint64 &id)
void DialogCutSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxSplines(ui->comboBoxSpline);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Spline)
{
VSpline spl;
if (mode == Draw::Calculation)
{
spl = data->GetSpline(id);
}
else
{
spl = data->GetSplineModeling(id);
}
VSpline spl = data->GetSpline(id);
ChangeCurrentText(ui->comboBoxSpline, spl.name());
emit ToolTip("");
this->show();

View File

@ -39,7 +39,7 @@ class DialogCutSpline : public DialogTool
{
Q_OBJECT
public:
DialogCutSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
DialogCutSpline(const VContainer *data, QWidget *parent = 0);
~DialogCutSpline();
/**
* @brief getPointName return name of point

View File

@ -29,8 +29,8 @@
#include "dialogcutsplinepath.h"
#include "ui_dialogcutsplinepath.h"
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogCutSplinePath), pointName(QString()), formula(QString()),
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogCutSplinePath), pointName(QString()), formula(QString()),
splinePathId(0)
{
ui->setupUi(this);
@ -53,10 +53,8 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, Draw::Draws mod
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogCutSplinePath::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxSplinesPath(ui->comboBoxSplinePath);
}
FillComboBoxSplinesPath(ui->comboBoxSplinePath);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSplinePath::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSplinePath::PutVal);
@ -98,33 +96,9 @@ void DialogCutSplinePath::setSplinePathId(const qint64 &value, const qint64 &id)
void DialogCutSplinePath::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxSplines(ui->comboBoxSplinePath);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::SplinePath)
{
VSplinePath splPath;
if (mode == Draw::Calculation)
{
splPath = data->GetSplinePath(id);
}
else
{
splPath = data->GetSplinePathModeling(id);
}
VSplinePath splPath = data->GetSplinePath(id);
ChangeCurrentText(ui->comboBoxSplinePath, splPath.name());
emit ToolTip("");
this->show();

View File

@ -39,7 +39,7 @@ class DialogCutSplinePath : public DialogTool
{
Q_OBJECT
public:
DialogCutSplinePath(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
DialogCutSplinePath(const VContainer *data, QWidget *parent = 0);
~DialogCutSplinePath();
/**
* @brief getPointName return name of point

View File

@ -31,8 +31,8 @@
#include <QPushButton>
#include <QDebug>
DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(), details(VDetail()), supplement(true), closed(true)
DialogDetail::DialogDetail(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(), details(VDetail()), supplement(true), closed(true)
{
ui.setupUi(this);
labelEditNamePoint = ui.labelEditNameDetail;
@ -55,37 +55,21 @@ DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *pa
void DialogDetail::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
qDebug()<<"false";
return;
}
}
if (type != Scene::Line && type != Scene::Detail)
{
switch (type)
{
case (Scene::Arc):
NewItem(id, Tool::NodeArc, mode, NodeDetail::Contour);
NewItem(id, Tool::NodeArc, NodeDetail::Contour);
break;
case (Scene::Point):
NewItem(id, Tool::NodePoint, mode, NodeDetail::Contour);
NewItem(id, Tool::NodePoint, NodeDetail::Contour);
break;
case (Scene::Spline):
NewItem(id, Tool::NodeSpline, mode, NodeDetail::Contour);
NewItem(id, Tool::NodeSpline, NodeDetail::Contour);
break;
case (Scene::SplinePath):
NewItem(id, Tool::NodeSplinePath, mode, NodeDetail::Contour);
NewItem(id, Tool::NodeSplinePath, NodeDetail::Contour);
break;
default:
qWarning()<<tr("Get wrong scene object. Ignore.");
@ -111,65 +95,33 @@ void DialogDetail::DialogAccepted()
emit DialogClosed(QDialog::Accepted);
}
void DialogDetail::NewItem(qint64 id, const Tool::Tools &typeTool, const Draw::Draws &mode,
const NodeDetail::NodeDetails &typeNode, qreal mx, qreal my)
void DialogDetail::NewItem(qint64 id, const Tool::Tools &typeTool, const NodeDetail::NodeDetails &typeNode, qreal mx,
qreal my)
{
QString name;
switch (typeTool)
{
case (Tool::NodePoint):
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
name = point.name();
break;
}
case (Tool::NodeArc):
{
VArc arc;
if (mode == Draw::Calculation)
{
arc = data->GetArc(id);
}
else
{
arc = data->GetArcModeling(id);
}
VArc arc = data->GetArc(id);
name = arc.name();
break;
}
case (Tool::NodeSpline):
{
VSpline spl;
if (mode == Draw::Calculation)
{
spl = data->GetSpline(id);
}
else
{
spl = data->GetSplineModeling(id);
}
VSpline spl = data->GetSpline(id);
name = spl.GetName();
break;
}
case (Tool::NodeSplinePath):
{
VSplinePath splPath;
if (mode == Draw::Calculation)
{
splPath = data->GetSplinePath(id);
}
else
{
splPath = data->GetSplinePathModeling(id);
}
VSplinePath splPath = data->GetSplinePath(id);
name = splPath.name();
break;
}
@ -180,7 +132,7 @@ void DialogDetail::NewItem(qint64 id, const Tool::Tools &typeTool, const Draw::D
QListWidgetItem *item = new QListWidgetItem(name);
item->setFont(QFont("Times", 12, QFont::Bold));
VNodeDetail node(id, typeTool, mode, typeNode, mx, my);
VNodeDetail node(id, typeTool, typeNode, mx, my);
item->setData(Qt::UserRole, QVariant::fromValue(node));
ui.listWidget->addItem(item);
disconnect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
@ -201,8 +153,8 @@ void DialogDetail::setDetails(const VDetail &value)
ui.listWidget->clear();
for (ptrdiff_t i = 0; i < details.CountNode(); ++i)
{
NewItem(details[i].getId(), details[i].getTypeTool(), details[i].getMode(), details[i].getTypeNode(),
details[i].getMx(), details[i].getMy());
NewItem(details[i].getId(), details[i].getTypeTool(), details[i].getTypeNode(), details[i].getMx(),
details[i].getMy());
}
ui.lineEditNameDetail->setText(details.getName());
ui.checkBoxSeams->setChecked(details.getSupplement());

View File

@ -42,10 +42,9 @@ public:
/**
* @brief DialogDetail create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent = 0);
DialogDetail(const VContainer *data, QWidget *parent = 0);
/**
* @brief getDetails return detail
* @return detail
@ -118,8 +117,8 @@ private:
* @param mx offset respect to x
* @param my offset respect to y
*/
void NewItem(qint64 id, const Tool::Tools &typeTool, const Draw::Draws &mode,
const NodeDetail::NodeDetails &typeNode, qreal mx = 0, qreal my = 0);
void NewItem(qint64 id, const Tool::Tools &typeTool, const NodeDetail::NodeDetails &typeNode,
qreal mx = 0, qreal my = 0);
};
#endif // DIALOGDETAIL_H

View File

@ -31,8 +31,8 @@
#include <QPushButton>
DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()),
DialogEndLine::DialogEndLine(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()),
formula(QString()), angle(0), basePointId(0)
{
ui->setupUi(this);
@ -56,10 +56,9 @@ DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogEndLine::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxBasePoint);
}
FillComboBoxPoints(ui->comboBoxBasePoint);
FillComboBoxTypeLine(ui->comboBoxLineType);
connect(ui->toolButtonArrowDown, &QPushButton::clicked, this,
@ -96,33 +95,9 @@ DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *
void DialogEndLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxBasePoint);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
ChangeCurrentText(ui->comboBoxBasePoint, point.name());
emit ToolTip("");
this->show();

View File

@ -46,10 +46,9 @@ public:
/**
* @brief DialogEndLine create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogEndLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
DialogEndLine(const VContainer *data, QWidget *parent = 0);
~DialogEndLine();
/**
* @brief getPointName return name of point

View File

@ -31,8 +31,8 @@
#include <QPushButton>
DialogHeight::DialogHeight(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogHeight), number(0), pointName(QString()),
DialogHeight::DialogHeight(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogHeight), number(0), pointName(QString()),
typeLine(QString()), basePointId(0), p1LineId(0), p2LineId(0)
{
ui->setupUi(this);
@ -43,12 +43,10 @@ DialogHeight::DialogHeight(const VContainer *data, Draw::Draws mode, QWidget *pa
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogHeight::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxBasePoint);
FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line);
}
FillComboBoxPoints(ui->comboBoxBasePoint);
FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line);
FillComboBoxTypeLine(ui->comboBoxLineType);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged);
}
@ -90,35 +88,9 @@ void DialogHeight::setP2LineId(const qint64 &value, const qint64 &id)
void DialogHeight::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxBasePoint);
FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
switch (number)
{
case (0):

View File

@ -46,11 +46,9 @@ public:
/**
* @brief DialogHeight create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogHeight(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
DialogHeight(const VContainer *data, QWidget *parent = 0);
~DialogHeight();
/**
* @brief getPointName return name of point

View File

@ -35,7 +35,7 @@
#include <QPushButton>
DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent)
:DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0),
:DialogTool(data, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0),
cursorToolRecordRow(0)
{
ui->setupUi(this);

View File

@ -34,7 +34,7 @@
#include <QPushButton>
DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent)
:DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0)
:DialogTool(data, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0)
{
ui->setupUi(this);
InitialStandartTable();

View File

@ -31,19 +31,18 @@
#include <QPushButton>
DialogLine::DialogLine(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0)
DialogLine::DialogLine(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0)
{
ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted);
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogLine::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
}
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
number = 0;
}
@ -86,34 +85,9 @@ void DialogLine::DialogAccepted()
void DialogLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name());

View File

@ -46,10 +46,9 @@ public:
/**
* @brief DialogLine create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogLine(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
DialogLine(const VContainer *data, QWidget *parent = 0);
~DialogLine();
/**
* @brief getFirstPoint return id first point

View File

@ -31,8 +31,8 @@
#include <QPushButton>
DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()),
DialogLineIntersect::DialogLineIntersect(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()),
p1Line1(0), p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true)
{
ui->setupUi(this);
@ -43,13 +43,11 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Draws mod
flagName = false;
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogLineIntersect::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxP1Line1);
FillComboBoxPoints(ui->comboBoxP2Line1);
FillComboBoxPoints(ui->comboBoxP1Line2);
FillComboBoxPoints(ui->comboBoxP2Line2);
}
FillComboBoxPoints(ui->comboBoxP1Line1);
FillComboBoxPoints(ui->comboBoxP2Line1);
FillComboBoxPoints(ui->comboBoxP1Line2);
FillComboBoxPoints(ui->comboBoxP2Line2);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged);
}
@ -61,36 +59,9 @@ DialogLineIntersect::~DialogLineIntersect()
void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxP1Line1);
FillComboBoxPoints(ui->comboBoxP2Line1);
FillComboBoxPoints(ui->comboBoxP1Line2);
FillComboBoxPoints(ui->comboBoxP2Line2);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
if (number == 0)
{
qint32 index = ui->comboBoxP1Line1->findText(point.name());

View File

@ -46,11 +46,9 @@ public:
/**
* @brief DialogLineIntersect create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogLineIntersect(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
DialogLineIntersect(const VContainer *data, QWidget *parent = 0);
~DialogLineIntersect();
/**
* @brief getP1Line1 return id first point of first line

View File

@ -31,8 +31,8 @@
#include <QPushButton>
DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()),
DialogNormal::DialogNormal(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), angle(0), firstPointId(0), secondPointId(0)
{
ui->setupUi(this);
@ -56,11 +56,9 @@ DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *pa
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogNormal::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
}
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
FillComboBoxTypeLine(ui->comboBoxLineType);
connect(ui->toolButtonArrowDown, &QPushButton::clicked, this,
@ -102,34 +100,9 @@ DialogNormal::~DialogNormal()
void DialogNormal::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name());

View File

@ -46,10 +46,9 @@ public:
/**
* @brief DialogNormal create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogNormal(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
DialogNormal(const VContainer *data, QWidget *parent = 0);
~DialogNormal();
/**
* @brief getPointName return name of point

View File

@ -30,8 +30,8 @@
#include <QPushButton>
DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0),
DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0),
firstPoint(0), secondPoint(0)
{
ui.setupUi(this);
@ -54,12 +54,10 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws m
CheckState();
QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogPointOfContact::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui.comboBoxCenter);
FillComboBoxPoints(ui.comboBoxFirstPoint);
FillComboBoxPoints(ui.comboBoxSecondPoint);
}
FillComboBoxPoints(ui.comboBoxCenter);
FillComboBoxPoints(ui.comboBoxFirstPoint);
FillComboBoxPoints(ui.comboBoxSecondPoint);
connect(ui.toolButtonPutHere, &QPushButton::clicked, this, &DialogPointOfContact::PutHere);
connect(ui.listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal);
@ -79,35 +77,9 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws m
void DialogPointOfContact::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui.comboBoxCenter);
FillComboBoxPoints(ui.comboBoxFirstPoint);
FillComboBoxPoints(ui.comboBoxSecondPoint);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
if (number == 0)
{
qint32 index = ui.comboBoxFirstPoint->findText(point.name());

View File

@ -42,11 +42,9 @@ public:
/**
* @brief DialogPointOfContact create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogPointOfContact(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
DialogPointOfContact(const VContainer *data, QWidget *parent = 0);
/**
* @brief getPointName return name of point
* @return name

View File

@ -31,8 +31,8 @@
#include <QPushButton>
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogPointOfIntersection), number(0), pointName(QString()),
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogPointOfIntersection), number(0), pointName(QString()),
firstPointId(0), secondPointId(0)
{
ui->setupUi(this);
@ -43,11 +43,10 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, Dra
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogPointOfIntersection::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
}
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersection::NamePointChanged);
}
@ -64,34 +63,9 @@ void DialogPointOfIntersection::setSecondPointId(const qint64 &value, const qint
void DialogPointOfIntersection::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
if (number == 0)
{
qint32 index = ui->comboBoxFirstPoint->findText(point.name());

View File

@ -46,11 +46,9 @@ public:
/**
* @brief DialogPointOfIntersection create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogPointOfIntersection(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
DialogPointOfIntersection(const VContainer *data, QWidget *parent = 0);
~DialogPointOfIntersection();
/**
* @brief getPointName return name of point

View File

@ -31,8 +31,8 @@
#include <QPushButton>
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0)
{
ui->setupUi(this);
@ -57,12 +57,10 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mod
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogShoulderPoint::DialogRejected);
FillComboBoxTypeLine(ui->comboBoxLineType);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line);
FillComboBoxPoints(ui->comboBoxPShoulder);
}
FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line);
FillComboBoxPoints(ui->comboBoxPShoulder);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogShoulderPoint::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogShoulderPoint::PutVal);
@ -87,35 +85,9 @@ DialogShoulderPoint::~DialogShoulderPoint()
void DialogShoulderPoint::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line);
FillComboBoxPoints(ui->comboBoxPShoulder);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
if (number == 0)
{
qint32 index = ui->comboBoxP1Line->findText(point.name());

View File

@ -46,11 +46,9 @@ public:
/**
* @brief DialogShoulderPoint create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogShoulderPoint(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
DialogShoulderPoint(const VContainer *data, QWidget *parent = 0);
~DialogShoulderPoint();
/**
* @brief getPointName return name of point

View File

@ -32,7 +32,7 @@
#include <QPushButton>
DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent)
:DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogSinglePoint), name(QString()),
:DialogTool(data, parent), ui(new Ui::DialogSinglePoint), name(QString()),
point(QPointF())
{
ui->setupUi(this);

View File

@ -31,8 +31,8 @@
#include <QPushButton>
DialogSpline::DialogSpline(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0),
DialogSpline::DialogSpline(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0),
kAsm1(1), kAsm2(1), kCurve(1)
{
ui->setupUi(this);
@ -41,11 +41,9 @@ DialogSpline::DialogSpline(const VContainer *data, Draw::Draws mode, QWidget *pa
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogSpline::DialogRejected);
if (mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxP1);
FillComboBoxPoints(ui->comboBoxP4);
}
FillComboBoxPoints(ui->comboBoxP1);
FillComboBoxPoints(ui->comboBoxP4);
}
DialogSpline::~DialogSpline()
@ -55,34 +53,9 @@ DialogSpline::~DialogSpline()
void DialogSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxP1);
FillComboBoxPoints(ui->comboBoxP4);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
if (number == 0)
{
qint32 index = ui->comboBoxP1->findText(point.name());
@ -104,18 +77,10 @@ void DialogSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
emit ToolTip("");
index = ui->comboBoxP1->currentIndex();
qint64 p1Id = qvariant_cast<qint64>(ui->comboBoxP1->itemData(index));
QPointF p1;
QPointF p4;
if (mode == Draw::Calculation)
{
p1 = data->GetPoint(p1Id).toQPointF();
p4 = data->GetPoint(id).toQPointF();
}
else
{
p1 = data->GetPointModeling(p1Id).toQPointF();
p4 = data->GetPointModeling(id).toQPointF();
}
QPointF p1 = data->GetPoint(p1Id).toQPointF();
QPointF p4 = data->GetPoint(id).toQPointF();
ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle()));
ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle()));
}

View File

@ -46,10 +46,9 @@ public:
/**
* @brief DialogSpline create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
DialogSpline(const VContainer *data, QWidget *parent = 0);
~DialogSpline();
/**
* @brief getP1 return id first point of spline

View File

@ -32,8 +32,8 @@
#include <QPushButton>
DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogSplinePath), path(VSplinePath())
DialogSplinePath::DialogSplinePath(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogSplinePath), path(VSplinePath())
{
ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
@ -41,10 +41,8 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Draws mode, QWi
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogSplinePath::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxPoint);
}
FillComboBoxPoints(ui->comboBoxPoint);
path = VSplinePath(data->DataPoints());
@ -81,22 +79,6 @@ void DialogSplinePath::SetPath(const VSplinePath &value)
void DialogSplinePath::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxPoint);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
NewItem(id, 1, 0, 1);
@ -172,15 +154,7 @@ void DialogSplinePath::KAsm2Changed(qreal d)
void DialogSplinePath::NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
QListWidgetItem *item = new QListWidgetItem(point.name());
item->setFont(QFont("Times", 12, QFont::Bold));
VSplinePoint p(id, kAsm1, angle, kAsm2);

View File

@ -47,11 +47,9 @@ public:
/**
* @brief DialogSplinePath create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogSplinePath(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
DialogSplinePath(const VContainer *data, QWidget *parent = 0);
~DialogSplinePath();
/**
* @brief GetPath return spline path

View File

@ -31,12 +31,11 @@
#include <QtWidgets>
DialogTool::DialogTool(const VContainer *data, Draw::Draws mode, QWidget *parent)
DialogTool::DialogTool(const VContainer *data, QWidget *parent)
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0),
spinBoxAngle(0), lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0),
labelEditNamePoint(0), labelEditFormula(0), radioButtonSizeGrowth(0), radioButtonStandartTable(0),
radioButtonIncrements(0), radioButtonLengthLine(0), radioButtonLengthArc(0), radioButtonLengthCurve(0),
idDetail(0), mode(mode)
radioButtonIncrements(0), radioButtonLengthLine(0), radioButtonLengthArc(0), radioButtonLengthCurve(0)
{
Q_ASSERT(data != 0);
timerFormula = new QTimer(this);
@ -67,45 +66,15 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const
{
Q_ASSERT(box != 0);
box->clear();
if (mode == Draw::Calculation)
const QHash<qint64, VPointF> *points = data->DataPoints();
QHashIterator<qint64, VPointF> i(*points);
while (i.hasNext())
{
const QHash<qint64, VPointF> *points = data->DataPoints();
QHashIterator<qint64, VPointF> i(*points);
while (i.hasNext())
i.next();
if (i.key() != id)
{
i.next();
if (i.key() != id)
{
VPointF point = i.value();
box->addItem(point.name(), i.key());
}
}
}
else
{
if (idDetail <= 0)
{
qWarning()<<tr("Wrong details id.")<<Q_FUNC_INFO;
return;
}
VDetail det = data->GetDetail(idDetail);
for (ptrdiff_t i = 0; i< det.CountNode(); ++i)
{
if (det[i].getTypeTool() == Tool::NodePoint ||
det[i].getTypeTool() == Tool::AlongLineTool ||
det[i].getTypeTool() == Tool::BisectorTool ||
det[i].getTypeTool() == Tool::EndLineTool ||
det[i].getTypeTool() == Tool::LineIntersectTool ||
det[i].getTypeTool() == Tool::NormalTool ||
det[i].getTypeTool() == Tool::PointOfContact ||
det[i].getTypeTool() == Tool::ShoulderPointTool)
{
if (det[i].getId() != id)
{
VPointF point = data->GetPointModeling(det[i].getId());
box->addItem(point.name(), det[i].getId());
}
}
VPointF point = i.value();
box->addItem(point.name(), i.key());
}
}
}
@ -114,60 +83,25 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, const qint64 &id, ComboMode
{
Q_ASSERT(box != 0);
box->clear();
if (mode == Draw::Calculation)
const QHash<qint64, VSpline> *spls = data->DataSplines();
QHashIterator<qint64, VSpline> i(*spls);
while (i.hasNext())
{
const QHash<qint64, VSpline> *spls = data->DataSplines();
QHashIterator<qint64, VSpline> i(*spls);
while (i.hasNext())
i.next();
if(cut == ComboMode::CutSpline)
{
i.next();
if(cut == ComboMode::CutSpline)
if (i.key() != id + 1 && i.key() != id + 2)
{
if (i.key() != id + 1 && i.key() != id + 2)
{
VSpline spl = i.value();
box->addItem(spl.name(), i.key());
}
}
else
{
if (i.key() != id)
{
VSpline spl = i.value();
box->addItem(spl.name(), i.key());
}
VSpline spl = i.value();
box->addItem(spl.name(), i.key());
}
}
}
else
{
if (idDetail <= 0)
else
{
qWarning()<<tr("Wrong details id.")<<Q_FUNC_INFO;
return;
}
VDetail det = data->GetDetail(idDetail);
for (ptrdiff_t i = 0; i< det.CountNode(); ++i)
{
if (det[i].getTypeTool() == Tool::SplineTool ||
det[i].getTypeTool() == Tool::NodeSpline )
if (i.key() != id)
{
if(cut == ComboMode::CutSpline)
{
if (det[i].getId() != id + 1 && det[i].getId() != id + 2)
{
VSpline spl = data->GetSplineModeling(det[i].getId());
box->addItem(spl.name(), det[i].getId());
}
}
else
{
if (det[i].getId() != id)
{
VSpline spl = data->GetSplineModeling(det[i].getId());
box->addItem(spl.name(), det[i].getId());
}
}
VSpline spl = i.value();
box->addItem(spl.name(), i.key());
}
}
}
@ -177,60 +111,25 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const qint64 &id, Combo
{
Q_ASSERT(box != 0);
box->clear();
if (mode == Draw::Calculation)
const QHash<qint64, VSplinePath> *splPaths = data->DataSplinePaths();
QHashIterator<qint64, VSplinePath> i(*splPaths);
while (i.hasNext())
{
const QHash<qint64, VSplinePath> *splPaths = data->DataSplinePaths();
QHashIterator<qint64, VSplinePath> i(*splPaths);
while (i.hasNext())
i.next();
if(cut == ComboMode::CutSpline)
{
i.next();
if(cut == ComboMode::CutSpline)
if (i.key() != id + 1 && i.key() != id + 2)
{
if (i.key() != id + 1 && i.key() != id + 2)
{
VSplinePath splPath = i.value();
box->addItem(splPath.name(), i.key());
}
}
else
{
if (i.key() != id)
{
VSplinePath splPath = i.value();
box->addItem(splPath.name(), i.key());
}
VSplinePath splPath = i.value();
box->addItem(splPath.name(), i.key());
}
}
}
else
{
if (idDetail <= 0)
else
{
qWarning()<<tr("Wrong details id.")<<Q_FUNC_INFO;
return;
}
VDetail det = data->GetDetail(idDetail);
for (ptrdiff_t i = 0; i< det.CountNode(); ++i)
{
if (det[i].getTypeTool() == Tool::SplinePathTool ||
det[i].getTypeTool() == Tool::NodeSplinePath )
if (i.key() != id)
{
if(cut == ComboMode::CutSpline)
{
if (det[i].getId() != id + 1 && det[i].getId() != id + 2)
{
VSplinePath splPath = data->GetSplinePathModeling(det[i].getId());
box->addItem(splPath.name(), det[i].getId());
}
}
else
{
if (det[i].getId() != id)
{
VSplinePath splPath = data->GetSplinePathModeling(det[i].getId());
box->addItem(splPath.name(), det[i].getId());
}
}
VSplinePath splPath = i.value();
box->addItem(splPath.name(), i.key());
}
}
}
@ -662,16 +561,6 @@ void DialogTool::UpdateList()
}
}
bool DialogTool::CheckObject(const qint64 &id)
{
if (mode == Draw::Calculation || idDetail == 0)
{
return false;
}
VDetail det = data->GetDetail(idDetail);
return det.Containes(id);
}
template <class key, class val>
void DialogTool::ShowVariable(const QHash<key, val> *var)
{

View File

@ -57,21 +57,10 @@ public:
/**
* @brief DialogTool create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogTool(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
DialogTool(const VContainer *data, QWidget *parent = 0);
virtual ~DialogTool() {}
/**
* @brief getIdDetail return id detail
* @return id
*/
inline qint64 getIdDetail() const {return idDetail;}
/**
* @brief setIdDetail set id detail
* @param value id
*/
inline void setIdDetail(const qint64 &value) {idDetail = value;}
signals:
/**
* @brief DialogClosed signal dialog closed
@ -262,20 +251,6 @@ protected:
* @brief radioButtonLengthCurve radio button for lengths of curves variables
*/
QRadioButton *radioButtonLengthCurve;
/**
* @brief idDetail id detail
*/
qint64 idDetail;
/**
* @brief mode mode
*/
Draw::Draws mode;
/**
* @brief CheckObject check if object belongs to detail
* @param id id of object (point, arc, spline, spline path)
* @return true - belons, false - don't
*/
bool CheckObject(const qint64 &id);
/**
* @brief closeEvent handle when dialog cloded
* @param event event

View File

@ -31,8 +31,8 @@
#include <QPushButton>
DialogTriangle::DialogTriangle(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogTriangle), number(0), pointName(QString()), axisP1Id(0),
DialogTriangle::DialogTriangle(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogTriangle), number(0), pointName(QString()), axisP1Id(0),
axisP2Id(0), firstPointId(0), secondPointId(0)
{
ui->setupUi(this);
@ -43,13 +43,12 @@ DialogTriangle::DialogTriangle(const VContainer *data, Draw::Draws mode, QWidget
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogTriangle::DialogRejected);
if(mode == Draw::Calculation)
{
FillComboBoxPoints(ui->comboBoxAxisP1);
FillComboBoxPoints(ui->comboBoxAxisP2);
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
}
FillComboBoxPoints(ui->comboBoxAxisP1);
FillComboBoxPoints(ui->comboBoxAxisP2);
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogTriangle::NamePointChanged);
}
@ -60,36 +59,9 @@ DialogTriangle::~DialogTriangle()
void DialogTriangle::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
FillComboBoxPoints(ui->comboBoxAxisP1);
FillComboBoxPoints(ui->comboBoxAxisP2);
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Point)
{
VPointF point;
if (mode == Draw::Calculation)
{
point = data->GetPoint(id);
}
else
{
point = data->GetPointModeling(id);
}
VPointF point = data->GetPoint(id);
switch (number)
{
case (0):

View File

@ -46,10 +46,9 @@ public:
/**
* @brief DialogTriangle create dialog
* @param data container with data
* @param mode mode of creation tool
* @param parent parent widget
*/
DialogTriangle(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
DialogTriangle(const VContainer *data, QWidget *parent = 0);
~DialogTriangle();
/**
* @brief getAxisP1Id return id first point of axis

View File

@ -33,12 +33,12 @@ class QRectF;
VArc::VArc ()
: f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()),
center(0), points(QHash<qint64, VPointF>()), mode(Draw::Calculation), idObject(0), _name(QString()){}
center(0), points(QHash<qint64, VPointF>()), idObject(0), _name(QString()){}
VArc::VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Draws mode, qint64 idObject)
qreal f1, QString formulaF1, qreal f2, QString formulaF2, qint64 idObject)
: f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius),
center(center), points(*points), mode(mode), idObject(idObject), _name(QString())
center(center), points(*points), idObject(idObject), _name(QString())
{
/**
* @todo Change name of arc in formula. Name now not unique.
@ -49,8 +49,7 @@ VArc::VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, Q
VArc::VArc(const VArc &arc)
: f1(arc.GetF1()), formulaF1(arc.GetFormulaF1()), f2(arc.GetF2()),
formulaF2(arc.GetFormulaF2()), radius(arc.GetRadius()), formulaRadius(arc.GetFormulaRadius()),
center(arc.GetCenter()), points(arc.GetDataPoints()), mode(arc.getMode()),
idObject(arc.getIdObject()), _name(arc.name()){}
center(arc.GetCenter()), points(arc.GetDataPoints()), idObject(arc.getIdObject()), _name(arc.name()){}
VArc &VArc::operator =(const VArc &arc)
{
@ -62,7 +61,6 @@ VArc &VArc::operator =(const VArc &arc)
this->radius = arc.GetRadius();
this->formulaRadius = arc.GetFormulaRadius();
this->center = arc.GetCenter();
this->mode = arc.getMode();
this->idObject = arc.getIdObject();
this->_name = arc.name();
return *this;

View File

@ -56,8 +56,7 @@ public:
* @param f2 кінцевий кут в градусах.
*/
VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
qreal f1, QString formulaF1, qreal f2, QString formulaF2,
Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
qreal f1, QString formulaF1, qreal f2, QString formulaF2, qint64 idObject = 0);
/**
* @brief VArc
* @param arc
@ -160,16 +159,6 @@ public:
* @return
*/
QVector<QPointF> SplOfArc( qint32 number ) const;
/**
* @brief getMode
* @return
*/
inline Draw::Draws getMode() const {return mode;}
/**
* @brief setMode
* @param value
*/
inline void setMode(const Draw::Draws &value) {mode = value;}
/**
* @brief getIdObject
* @return
@ -223,10 +212,6 @@ private:
* @brief points
*/
QHash<qint64, VPointF> points;
/**
* @brief mode
*/
Draw::Draws mode;
/**
* @brief idObject
*/

View File

@ -29,21 +29,18 @@
#include "vnodedetail.h"
VNodeDetail::VNodeDetail()
:id(0), typeTool(Tool::NodePoint), mode(Draw::Modeling), typeNode(NodeDetail::Contour), mx(0), my(0){}
:id(0), typeTool(Tool::NodePoint), typeNode(NodeDetail::Contour), mx(0), my(0){}
VNodeDetail::VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,
qreal mx, qreal my)
:id(id), typeTool(typeTool), mode(mode), typeNode(typeNode), mx(mx), my(my){}
VNodeDetail::VNodeDetail(qint64 id, Tool::Tools typeTool, NodeDetail::NodeDetails typeNode, qreal mx, qreal my)
:id(id), typeTool(typeTool), typeNode(typeNode), mx(mx), my(my){}
VNodeDetail::VNodeDetail(const VNodeDetail &node)
:id(node.getId()), typeTool(node.getTypeTool()), mode(node.getMode()), typeNode(node.getTypeNode()),
mx(node.getMx()), my(node.getMy()){}
:id(node.getId()), typeTool(node.getTypeTool()), typeNode(node.getTypeNode()), mx(node.getMx()), my(node.getMy()){}
VNodeDetail &VNodeDetail::operator =(const VNodeDetail &node)
{
id = node.getId();
typeTool = node.getTypeTool();
mode = node.getMode();
typeNode = node.getTypeNode();
mx = node.getMx();
my = node.getMy();

View File

@ -61,8 +61,8 @@ public:
* @param mx
* @param my
*/
VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,
qreal mx = 0, qreal my = 0);
VNodeDetail(qint64 id, Tool::Tools typeTool, NodeDetail::NodeDetails typeNode, qreal mx = 0,
qreal my = 0);
/**
* @brief VNodeDetail
* @param node
@ -94,16 +94,6 @@ public:
* @param value
*/
inline void setTypeTool(const Tool::Tools &value) {typeTool = value;}
/**
* @brief getMode
* @return
*/
inline Draw::Draws getMode() const {return mode;}
/**
* @brief setMode
* @param value
*/
inline void setMode(const Draw::Draws &value) {mode = value;}
/**
* @brief getTypeNode
* @return
@ -143,10 +133,6 @@ private:
* @brief typeTool
*/
Tool::Tools typeTool;
/**
* @brief mode
*/
Draw::Draws mode;
/**
* @brief typeNode
*/

View File

@ -32,33 +32,32 @@
VSpline::VSpline()
:p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1),
points(QHash<qint64, VPointF>()), mode(Draw::Calculation), idObject(0), _name(QString()){}
points(QHash<qint64, VPointF>()), idObject(0), _name(QString()){}
VSpline::VSpline ( const VSpline & spline )
:p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()), p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()),
angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()), kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()),
points(spline.GetDataPoints()), mode(spline.getMode()), idObject(spline.getIdObject()), _name(spline.name()){}
points(spline.GetDataPoints()), idObject(spline.getIdObject()), _name(spline.name()){}
VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode, qint64 idObject)
qreal kAsm1, qreal kAsm2, qreal kCurve, qint64 idObject)
:p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2),
kCurve(kCurve), points(*points), mode(mode), idObject(idObject), _name(QString())
kCurve(kCurve), points(*points), idObject(idObject), _name(QString())
{
_name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name());
ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve );
}
VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4,
qreal kCurve, Draw::Draws mode, qint64 idObject)
:p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(*points), mode(mode),
qreal kCurve, qint64 idObject)
:p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(*points),
idObject(idObject), _name(QString())
{
_name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name());
ModifiSpl ( p1, p2, p3, p4, kCurve);
}
void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal kAsm1, qreal kAsm2, qreal kCurve)
void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve)
{
this->p1 = p1;
this->p4 = p4;
@ -854,7 +853,6 @@ VSpline &VSpline::operator =(const VSpline &spline)
this->kAsm2 = spline.GetKasm2();
this->kCurve = spline.GetKcurve();
this->points = spline.GetDataPoints();
this->mode = spline.getMode();
this->idObject = spline.getIdObject();
this->_name = spline.name();
return *this;

View File

@ -64,8 +64,8 @@ public:
* @param kAsm1 коефіцієнт довжини першої напрямної.
* @param kAsm2 коефіцієнт довжини другої напрямної.
*/
VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2, qreal kAsm1,
qreal kAsm2, qreal kCurve, qint64 idObject = 0);
/**
* @brief VSpline конструктор.
* @param p1 початкова точка сплайну.
@ -74,7 +74,7 @@ public:
* @param p4 кінцева точка сплайну.
*/
VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4,
qreal kCurve, Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
qreal kCurve, qint64 idObject = 0);
/**
* @brief ModifiSpl модифікує сплайн.
* @param p1 початкова точка сплайну.
@ -225,16 +225,6 @@ public:
* @param Pmirror точка відносно якої відбувається вертикальне дзеркалення сплайну.
*/
// void Mirror(const QPointF Pmirror);
/**
* @brief getMode
* @return
*/
inline Draw::Draws getMode() const {return mode;}
/**
* @brief setMode
* @param value
*/
inline void setMode(const Draw::Draws &value) {mode = value;}
/**
* @brief SplinePoints
* @param p1
@ -325,10 +315,6 @@ private:
* @brief points
*/
QHash<qint64, VPointF> points;
/**
* @brief mode
*/
Draw::Draws mode;
/**
* @brief idObject
*/

View File

@ -30,15 +30,14 @@
#include "../exception/vexception.h"
VSplinePath::VSplinePath()
: path(QVector<VSplinePoint>()), kCurve(1), mode(Draw::Calculation), points(QHash<qint64, VPointF>()), idObject(0),
_name(QString()){}
: path(QVector<VSplinePoint>()), kCurve(1), points(QHash<qint64, VPointF>()), idObject(0), _name(QString()){}
VSplinePath::VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve, Draw::Draws mode, qint64 idObject)
: path(QVector<VSplinePoint>()), kCurve(kCurve), mode(mode), points(*points), idObject(idObject), _name(QString())
VSplinePath::VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve, qint64 idObject)
: path(QVector<VSplinePoint>()), kCurve(kCurve), points(*points), idObject(idObject), _name(QString())
{}
VSplinePath::VSplinePath(const VSplinePath &splPath)
: path(*splPath.GetPoint()), kCurve(splPath.getKCurve()), mode(splPath.getMode()), points(splPath.GetDataPoints()),
: path(*splPath.GetPoint()), kCurve(splPath.getKCurve()), points(splPath.GetDataPoints()),
idObject(splPath.getIdObject()), _name(splPath.name()){}
void VSplinePath::append(const VSplinePoint &point)
@ -158,7 +157,6 @@ VSplinePath &VSplinePath::operator =(const VSplinePath &path)
{
this->path = path.GetSplinePath();
this->kCurve = path.getKCurve();
this->mode = path.getMode();
this->points = path.GetDataPoints();
this->idObject = path.getIdObject();
this->_name = path.name();

View File

@ -58,8 +58,7 @@ public:
/**
* @brief VSplinePath конструктор по замовчуванню.
*/
VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve = 1,
Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve = 1, qint64 idObject = 0);
/**
* @brief VSplinePath
* @param splPath
@ -156,16 +155,6 @@ public:
* @return
*/
VSplinePoint &operator[](ptrdiff_t indx);
/**
* @brief getMode
* @return
*/
inline Draw::Draws getMode() const {return mode;}
/**
* @brief setMode
* @param value
*/
inline void setMode(const Draw::Draws &value) {mode = value;}
/**
* @brief getIdObject
* @return
@ -208,10 +197,6 @@ protected:
* @brief kCurve
*/
qreal kCurve;
/**
* @brief mode
*/
Draw::Draws mode;
/**
* @brief points
*/

View File

@ -251,7 +251,7 @@ void MainWindow::SetToolButton(bool checked, Tool::Tools t, const QString &curso
QCursor cur(pixmap, 2, 3);
view->setCursor(cur);
helpLabel->setText(toolTip);
dialog = QSharedPointer<Dialog>(new Dialog(data, mode));
dialog = QSharedPointer<Dialog>(new Dialog(data));
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject);
connect(dialog.data(), &Dialog::DialogClosed, this, closeDialogSlot);
connect(dialog.data(), &Dialog::ToolTip, this, &MainWindow::ShowToolTip);
@ -277,20 +277,12 @@ void MainWindow::AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool
det->AddTool(tool, id, typeTool);
}
template <typename DrawTool, typename ModelingTool, typename Dialog>
template <typename DrawTool, typename Dialog>
void MainWindow::ClosedDialog(QSharedPointer<Dialog> &dialog, int result)
{
if (result == QDialog::Accepted)
{
if (mode == Draw::Calculation)
{
DrawTool::Create(dialog, currentScene, doc, data);
}
else
{
ModelingTool *endLine = ModelingTool::Create(dialog, doc, data);
AddToolToDetail(endLine, endLine->getId(), tool, dialog->getIdDetail());
}
DrawTool::Create(dialog, currentScene, doc, data);
}
ArrowTool();
}
@ -303,7 +295,7 @@ void MainWindow::ToolEndLine(bool checked)
void MainWindow::ClosedDialogEndLine(int result)
{
ClosedDialog<VToolEndLine, VModelingEndLine>(dialogEndLine, result);
ClosedDialog<VToolEndLine>(dialogEndLine, result);
}
void MainWindow::ToolLine(bool checked)
@ -314,7 +306,7 @@ void MainWindow::ToolLine(bool checked)
void MainWindow::ClosedDialogLine(int result)
{
ClosedDialog<VToolLine, VModelingLine>(dialogLine, result);
ClosedDialog<VToolLine>(dialogLine, result);
}
void MainWindow::ToolAlongLine(bool checked)
@ -325,7 +317,7 @@ void MainWindow::ToolAlongLine(bool checked)
void MainWindow::ClosedDialogAlongLine(int result)
{
ClosedDialog<VToolAlongLine, VModelingAlongLine>(dialogAlongLine, result);
ClosedDialog<VToolAlongLine>(dialogAlongLine, result);
}
void MainWindow::ToolShoulderPoint(bool checked)
@ -337,7 +329,7 @@ void MainWindow::ToolShoulderPoint(bool checked)
void MainWindow::ClosedDialogShoulderPoint(int result)
{
ClosedDialog<VToolShoulderPoint, VModelingShoulderPoint>(dialogShoulderPoint, result);
ClosedDialog<VToolShoulderPoint>(dialogShoulderPoint, result);
}
void MainWindow::ToolNormal(bool checked)
@ -348,7 +340,7 @@ void MainWindow::ToolNormal(bool checked)
void MainWindow::ClosedDialogNormal(int result)
{
ClosedDialog<VToolNormal, VModelingNormal>(dialogNormal, result);
ClosedDialog<VToolNormal>(dialogNormal, result);
}
void MainWindow::ToolBisector(bool checked)
@ -359,7 +351,7 @@ void MainWindow::ToolBisector(bool checked)
void MainWindow::ClosedDialogBisector(int result)
{
ClosedDialog<VToolBisector, VModelingBisector>(dialogBisector, result);
ClosedDialog<VToolBisector>(dialogBisector, result);
}
void MainWindow::ToolLineIntersect(bool checked)
@ -371,7 +363,7 @@ void MainWindow::ToolLineIntersect(bool checked)
void MainWindow::ClosedDialogLineIntersect(int result)
{
ClosedDialog<VToolLineIntersect, VModelingLineIntersect>(dialogLineIntersect, result);
ClosedDialog<VToolLineIntersect>(dialogLineIntersect, result);
}
void MainWindow::ToolSpline(bool checked)
@ -382,7 +374,7 @@ void MainWindow::ToolSpline(bool checked)
void MainWindow::ClosedDialogSpline(int result)
{
ClosedDialog<VToolSpline, VModelingSpline>(dialogSpline, result);
ClosedDialog<VToolSpline>(dialogSpline, result);
}
void MainWindow::ToolCutSpline(bool checked)
@ -393,7 +385,7 @@ void MainWindow::ToolCutSpline(bool checked)
void MainWindow::ClosedDialogCutSpline(int result)
{
ClosedDialog<VToolCutSpline, VModelingCutSpline>(dialogCutSpline, result);
ClosedDialog<VToolCutSpline>(dialogCutSpline, result);
}
void MainWindow::ToolArc(bool checked)
@ -404,7 +396,7 @@ void MainWindow::ToolArc(bool checked)
void MainWindow::ClosedDialogArc(int result)
{
ClosedDialog<VToolArc, VModelingArc>(dialogArc, result);
ClosedDialog<VToolArc>(dialogArc, result);
}
void MainWindow::ToolSplinePath(bool checked)
@ -415,7 +407,7 @@ void MainWindow::ToolSplinePath(bool checked)
void MainWindow::ClosedDialogSplinePath(int result)
{
ClosedDialog<VToolSplinePath, VModelingSplinePath>(dialogSplinePath, result);
ClosedDialog<VToolSplinePath>(dialogSplinePath, result);
}
void MainWindow::ToolCutSplinePath(bool checked)
@ -426,7 +418,7 @@ void MainWindow::ToolCutSplinePath(bool checked)
void MainWindow::ClosedDialogCutSplinePath(int result)
{
ClosedDialog<VToolCutSplinePath, VModelingCutSplinePath>(dialogCutSplinePath, result);
ClosedDialog<VToolCutSplinePath>(dialogCutSplinePath, result);
}
void MainWindow::ToolPointOfContact(bool checked)
@ -438,7 +430,7 @@ void MainWindow::ToolPointOfContact(bool checked)
void MainWindow::ClosedDialogPointOfContact(int result)
{
ClosedDialog<VToolPointOfContact, VModelingPointOfContact>(dialogPointOfContact, result);
ClosedDialog<VToolPointOfContact>(dialogPointOfContact, result);
}
void MainWindow::ToolDetail(bool checked)
@ -451,7 +443,7 @@ void MainWindow::ToolDetail(bool checked)
QCursor cur(pixmap, 2, 3);
view->setCursor(cur);
helpLabel->setText(tr("Select points, arcs, curves clockwise."));
dialogDetail = QSharedPointer<DialogDetail>(new DialogDetail(data, mode));
dialogDetail = QSharedPointer<DialogDetail>(new DialogDetail(data));
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogDetail.data(),
&DialogDetail::ChoosedObject);
connect(dialogDetail.data(), &DialogDetail::DialogClosed, this, &MainWindow::ClosedDialogDetail);
@ -483,7 +475,7 @@ void MainWindow::ToolHeight(bool checked)
void MainWindow::ClosedDialogHeight(int result)
{
ClosedDialog<VToolHeight, VModelingHeight>(dialogHeight, result);
ClosedDialog<VToolHeight>(dialogHeight, result);
}
void MainWindow::ToolTriangle(bool checked)
@ -494,7 +486,7 @@ void MainWindow::ToolTriangle(bool checked)
void MainWindow::ClosedDialogTriangle(int result)
{
ClosedDialog<VToolTriangle, VModelingTriangle>(dialogTriangle, result);
ClosedDialog<VToolTriangle>(dialogTriangle, result);
}
void MainWindow::ToolPointOfIntersection(bool checked)
@ -506,7 +498,7 @@ void MainWindow::ToolPointOfIntersection(bool checked)
void MainWindow::ClosedDialogPointOfIntersection(int result)
{
ClosedDialog<VToolPointOfIntersection, VModelingPointOfIntersection>(dialogPointOfIntersection, result);
ClosedDialog<VToolPointOfIntersection>(dialogPointOfIntersection, result);
}
void MainWindow::About()

View File

@ -36,7 +36,6 @@
#include "dialogs/dialogs.h"
#include "tools/vtooldetail.h"
#include "tools/drawTools/drawtools.h"
#include "tools/modelingTools/modelingtools.h"
#include "xml/vdomdocument.h"
namespace Ui
@ -555,7 +554,7 @@ private:
*/
void AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool,
const qint64 &idDetail);
template <typename DrawTool, typename ModelingTool, typename Dialog>
template <typename DrawTool, typename Dialog>
/**
* @brief ClosedDialog
* @param dialog

View File

@ -77,9 +77,7 @@ namespace Tool
NodeSplinePath,
Height,
Triangle,
PointOfIntersection,
SimpleSpline,
SimpleSplinePath
PointOfIntersection
};
Q_DECLARE_FLAGS(Tools, Tool)

View File

@ -121,6 +121,7 @@ protected:
virtual void AddToFile();
void RefreshGeometry();
private:
Q_DISABLE_COPY(VToolCutSpline)
/**
* @brief formula keep formula of length
*/

View File

@ -94,7 +94,6 @@ void VToolCutSplinePath::Create(const qint64 _id, const QString &pointName, cons
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
qint32 p1 = 0, p2 = 0;
QPointF point = splPath.CutSplinePath(toPixel(result), p1, p2, spl1p2, spl1p3, spl2p2, spl2p3);
qDebug()<<p1<<p2;
qint64 id = _id;
qint64 splPath1id = 0;

View File

@ -111,6 +111,7 @@ protected:
virtual void AddToFile();
void RefreshGeometry();
private:
Q_DISABLE_COPY(VToolCutSplinePath)
/**
* @brief formula keep formula of length
*/

View File

@ -131,7 +131,7 @@ QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, c
line.setLength(line.length()+step);
a = QLineF(line.p2(), firstPoint).length();
b = QLineF(line.p2(), secondPoint).length();
if (static_cast<qint32>(c*c) == static_cast<qint32>(a*a + b*b))
if (qFuzzyCompare(c*c, a*a + b*b))
{
QLineF l1(axisP2, firstPoint);
QLineF l2(axisP2, secondPoint);
@ -142,6 +142,7 @@ QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, c
}
if (c*c < a*a + b*b)
{
//Still don't know why this code handled. Need to think about that.
qWarning()<<tr("Can't find point.")<<Q_FUNC_INFO;
return line.p2();
}

View File

@ -1,49 +0,0 @@
/************************************************************************
**
** @file modelingtools.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 MODELINGTOOLS_H
#define MODELINGTOOLS_H
#include "vmodelingalongline.h"
#include "vmodelingarc.h"
#include "vmodelingbisector.h"
#include "vmodelingendline.h"
#include "vmodelingline.h"
#include "vmodelinglineintersect.h"
#include "vmodelingnormal.h"
#include "vmodelingpointofcontact.h"
#include "vmodelingshoulderpoint.h"
#include "vmodelingspline.h"
#include "vmodelingsplinepath.h"
#include "vmodelingheight.h"
#include "vmodelingtriangle.h"
#include "vmodelingpointofintersection.h"
#include "vmodelingcutspline.h"
#include "vmodelingcutsplinepath.h"
#endif // MODELINGTOOLS_H

View File

@ -1,174 +0,0 @@
/************************************************************************
**
** @file vmodelingalongline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingalongline.h"
#include "../../container/calculator.h"
const QString VModelingAlongLine::ToolType = QStringLiteral("alongLine");
VModelingAlongLine::VModelingAlongLine(VDomDocument *doc, VContainer *data, qint64 id,
const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const QString &typeLine,
const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VModelingLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId),
dialogAlongLine(QSharedPointer<DialogAlongLine>())
{
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingAlongLine::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong();
}
RefreshGeometry();
}
void VModelingAlongLine::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogAlongLine->getPointName());
domElement.setAttribute(AttrTypeLine, dialogAlongLine->getTypeLine());
domElement.setAttribute(AttrLength, dialogAlongLine->getFormula());
domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogAlongLine->getFirstPointId()));
domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogAlongLine->getSecondPointId()));
emit FullUpdateTree();
}
}
dialogAlongLine.clear();
}
void VModelingAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogAlongLine, this, event);
}
void VModelingAlongLine::AddToFile()
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrTypeLine, typeLine);
AddAttribute(domElement, AttrLength, formula);
AddAttribute(domElement, AttrFirstPoint, basePointId);
AddAttribute(domElement, AttrSecondPoint, secondPointId);
AddToModeling(domElement);
}
void VModelingAlongLine::RemoveReferens()
{
doc->DecrementReferens(secondPointId);
VModelingLinePoint::RemoveReferens();
}
void VModelingAlongLine::setDialog()
{
Q_ASSERT(dialogAlongLine.isNull() == false);
VPointF p = VAbstractTool::data.GetPointModeling(id);
dialogAlongLine->setTypeLine(typeLine);
dialogAlongLine->setFormula(formula);
dialogAlongLine->setFirstPointId(basePointId, id);
dialogAlongLine->setSecondPointId(secondPointId, id);
dialogAlongLine->setPointName(p.name());
}
VModelingAlongLine *VModelingAlongLine::Create(QSharedPointer<DialogAlongLine> &dialog, VDomDocument *doc,
VContainer *data)
{
QString formula = dialog->getFormula();
qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId();
QString typeLine = dialog->getTypeLine();
QString pointName = dialog->getPointName();
return Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, doc, data,
Document::FullParse, Tool::FromGui);
}
VModelingAlongLine *VModelingAlongLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
VModelingAlongLine *point = 0;
VPointF firstPoint = data->GetPointModeling(firstPointId);
VPointF secondPoint = data->GetPointModeling(secondPointId);
QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF());
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(formula, &errorMsg);
if (errorMsg.isEmpty())
{
line.setLength(toPixel(result));
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddPointModeling(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
}
else
{
data->UpdatePointModeling(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
data->AddLine(firstPointId, id);
data->AddLine(id, secondPointId);
if (parse == Document::FullParse)
{
point = new VModelingAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine,
typeCreation);
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
}
}
return point;
}

View File

@ -1,129 +0,0 @@
/************************************************************************
**
** @file vmodelingalongline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGALONGLINE_H
#define VMODELINGALONGLINE_H
#include "vmodelinglinepoint.h"
#include "../../dialogs/dialogalongline.h"
/**
* @brief The VModelingAlongLine class
*/
class VModelingAlongLine : public VModelingLinePoint
{
Q_OBJECT
public:
/**
* @brief VModelingAlongLine
* @param doc dom document container
* @param data
* @param id
* @param formula
* @param firstPointId
* @param secondPointId
* @param typeLine
* @param typeCreation
* @param parent
*/
VModelingAlongLine(VDomDocument *doc, VContainer *data, qint64 id,
const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const QString &typeLine,
const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingAlongLine* Create(QSharedPointer<DialogAlongLine> &dialog, VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param pointName
* @param typeLine
* @param formula
* @param firstPointId
* @param secondPointId
* @param mx
* @param my
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingAlongLine* Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens();
private:
/**
* @brief secondPointId
*/
qint64 secondPointId;
/**
* @brief dialogAlongLine
*/
QSharedPointer<DialogAlongLine> dialogAlongLine;
};
#endif // VMODELINGALONGLINE_H

View File

@ -1,198 +0,0 @@
/************************************************************************
**
** @file vmodelingarc.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingarc.h"
#include "../../container/calculator.h"
const QString VModelingArc::TagName = QStringLiteral("arc");
const QString VModelingArc::ToolType = QStringLiteral("simple");
VModelingArc::VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation,
QGraphicsItem *parent)
:VModelingTool(doc, data, id), QGraphicsPathItem(parent), dialogArc(QSharedPointer<DialogArc>())
{
this->setPen(QPen(baseColor, widthHairLine));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true);
RefreshGeometry();
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingArc::setDialog()
{
Q_ASSERT(dialogArc.isNull() == false);
VArc arc = VAbstractTool::data.GetArcModeling(id);
dialogArc->SetCenter(arc.GetCenter());
dialogArc->SetRadius(arc.GetFormulaRadius());
dialogArc->SetF1(arc.GetFormulaF1());
dialogArc->SetF2(arc.GetFormulaF2());
}
VModelingArc* VModelingArc::Create(QSharedPointer<DialogArc> &dialog, VDomDocument *doc, VContainer *data)
{
qint64 center = dialog->GetCenter();
QString radius = dialog->GetRadius();
QString f1 = dialog->GetF1();
QString f2 = dialog->GetF2();
return Create(0, center, radius, f1, f2, doc, data, Document::FullParse, Tool::FromGui);
}
VModelingArc* VModelingArc::Create(const qint64 _id, const qint64 &center, const QString &radius, const QString &f1,
const QString &f2, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation)
{
VModelingArc *toolArc = 0;
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(radius, &errorMsg);
if (errorMsg.isEmpty())
{
calcRadius = toPixel(result);
}
errorMsg.clear();
result = cal.eval(f1, &errorMsg);
if (errorMsg.isEmpty())
{
calcF1 = result;
}
errorMsg.clear();
result = cal.eval(f2, &errorMsg);
if (errorMsg.isEmpty())
{
calcF2 = result;
}
VArc arc = VArc(data->DataPointsModeling(), center, calcRadius, radius, calcF1, f1, calcF2, f2 );
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddArcModeling(arc);
}
else
{
data->UpdateArcModeling(id, arc);
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
data->AddLengthArc(arc.name(), toMM(arc.GetLength()));
if (parse == Document::FullParse)
{
toolArc = new VModelingArc(doc, data, id, typeCreation);
doc->AddTool(id, toolArc);
doc->IncrementReferens(center);
}
return toolArc;
}
void VModelingArc::FullUpdateFromFile()
{
RefreshGeometry();
}
void VModelingArc::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrCenter, QString().setNum(dialogArc->GetCenter()));
domElement.setAttribute(AttrRadius, dialogArc->GetRadius());
domElement.setAttribute(AttrAngle1, dialogArc->GetF1());
domElement.setAttribute(AttrAngle2, dialogArc->GetF2());
emit FullUpdateTree();
}
}
dialogArc.clear();
}
void VModelingArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogArc, this, event);
}
void VModelingArc::AddToFile()
{
VArc arc = VAbstractTool::data.GetArcModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrCenter, arc.GetCenter());
AddAttribute(domElement, AttrRadius, arc.GetFormulaRadius());
AddAttribute(domElement, AttrAngle1, arc.GetFormulaF1());
AddAttribute(domElement, AttrAngle2, arc.GetFormulaF2());
AddToModeling(domElement);
}
void VModelingArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
emit ChoosedTool(id, Scene::Arc);
}
QGraphicsItem::mouseReleaseEvent(event);
}
void VModelingArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine));
}
void VModelingArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine));
}
void VModelingArc::RemoveReferens()
{
VArc arc = VAbstractTool::data.GetArcModeling(id);
doc->DecrementReferens(arc.GetCenter());
}
void VModelingArc::RefreshGeometry()
{
VArc arc = VAbstractTool::data.GetArcModeling(id);
QPainterPath path;
path.addPath(arc.GetPath());
path.setFillRule( Qt::WindingFill );
this->setPath(path);
}

View File

@ -1,140 +0,0 @@
/************************************************************************
**
** @file vmodelingarc.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGARC_H
#define VMODELINGARC_H
#include "vmodelingtool.h"
#include <QGraphicsPathItem>
#include "../../dialogs/dialogarc.h"
#include "../../widgets/vcontrolpointspline.h"
/**
* @brief The VModelingArc class
*/
class VModelingArc :public VModelingTool, public QGraphicsPathItem
{
Q_OBJECT
public:
/**
* @brief VModelingArc
* @param doc dom document container
* @param data
* @param id
* @param typeCreation
* @param parent
*/
VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation,
QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingArc* Create(QSharedPointer<DialogArc> &dialog, VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param center
* @param radius
* @param f1
* @param f2
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingArc* Create(const qint64 _id, const qint64 &center, const QString &radius, const QString &f1,
const QString &f2, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation);
/**
* @brief TagName
*/
static const QString TagName;
/**
* @brief ToolType
*/
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
/**
* @brief mouseReleaseEvent
* @param event
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent
* @param event
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent
* @param event
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens();
private:
/**
* @brief dialogArc
*/
QSharedPointer<DialogArc> dialogArc;
/**
* @brief RefreshGeometry
*/
void RefreshGeometry();
};
#endif // VMODELINGARC_H

View File

@ -1,185 +0,0 @@
/************************************************************************
**
** @file vmodelingbisector.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingbisector.h"
#include "../drawTools/vtoolbisector.h"
#include "../../container/calculator.h"
const QString VModelingBisector::ToolType = QStringLiteral("bisector");
VModelingBisector::VModelingBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const qint64 &thirdPointId, const Tool::Sources &typeCreation,
QGraphicsItem *parent)
:VModelingLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(0),
thirdPointId(0), dialogBisector(QSharedPointer<DialogBisector>())
{
this->firstPointId = firstPointId;
this->thirdPointId = thirdPointId;
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingBisector::setDialog()
{
Q_ASSERT(dialogBisector.isNull() == false);
VPointF p = VAbstractTool::data.GetPointModeling(id);
dialogBisector->setTypeLine(typeLine);
dialogBisector->setFormula(formula);
dialogBisector->setFirstPointId(firstPointId, id);
dialogBisector->setSecondPointId(basePointId, id);
dialogBisector->setThirdPointId(thirdPointId, id);
dialogBisector->setPointName(p.name());
}
VModelingBisector *VModelingBisector::Create(QSharedPointer<DialogBisector> &dialog, VDomDocument *doc,
VContainer *data)
{
QString formula = dialog->getFormula();
qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId();
qint64 thirdPointId = dialog->getThirdPointId();
QString typeLine = dialog->getTypeLine();
QString pointName = dialog->getPointName();
return Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, doc,
data, Document::FullParse, Tool::FromGui);
}
VModelingBisector *VModelingBisector::Create(const qint64 _id, const QString &formula,
const qint64 &firstPointId, const qint64 &secondPointId,
const qint64 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
VModelingBisector *point = 0;
VPointF firstPoint = data->GetPointModeling(firstPointId);
VPointF secondPoint = data->GetPointModeling(secondPointId);
VPointF thirdPoint = data->GetPointModeling(thirdPointId);
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(formula, &errorMsg);
if (errorMsg.isEmpty())
{
QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
thirdPoint.toQPointF(), toPixel(result));
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddPointModeling(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
}
else
{
data->UpdatePointModeling(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
data->AddLine(firstPointId, id, Draw::Modeling);
if (parse == Document::FullParse)
{
point = new VModelingBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId,
thirdPointId, typeCreation);
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
doc->IncrementReferens(thirdPointId);
}
}
return point;
}
void VModelingBisector::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, "");
firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
basePointId = domElement.attribute(AttrSecondPoint, "").toLongLong();
thirdPointId = domElement.attribute(AttrThirdPoint, "").toLongLong();
}
RefreshGeometry();
}
void VModelingBisector::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogBisector->getPointName());
domElement.setAttribute(AttrTypeLine, dialogBisector->getTypeLine());
domElement.setAttribute(AttrLength, dialogBisector->getFormula());
domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogBisector->getFirstPointId()));
domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogBisector->getSecondPointId()));
domElement.setAttribute(AttrThirdPoint, QString().setNum(dialogBisector->getThirdPointId()));
emit FullUpdateTree();
}
}
dialogBisector.clear();
}
void VModelingBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogBisector, this, event);
}
void VModelingBisector::AddToFile()
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrTypeLine, typeLine);
AddAttribute(domElement, AttrLength, formula);
AddAttribute(domElement, AttrFirstPoint, firstPointId);
AddAttribute(domElement, AttrSecondPoint, basePointId);
AddAttribute(domElement, AttrThirdPoint, thirdPointId);
AddToModeling(domElement);
}
void VModelingBisector::RemoveReferens()
{
doc->DecrementReferens(firstPointId);
doc->DecrementReferens(thirdPointId);
VModelingLinePoint::RemoveReferens();
}

View File

@ -1,137 +0,0 @@
/************************************************************************
**
** @file vmodelingbisector.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGBISECTOR_H
#define VMODELINGBISECTOR_H
#include "vmodelinglinepoint.h"
#include "../../dialogs/dialogbisector.h"
/**
* @brief The VModelingBisector class
*/
class VModelingBisector : public VModelingLinePoint
{
Q_OBJECT
public:
/**
* @brief VModelingBisector
* @param doc dom document container
* @param data
* @param id
* @param typeLine
* @param formula
* @param firstPointId
* @param secondPointId
* @param thirdPointId
* @param typeCreation
* @param parent
*/
VModelingBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula,
const qint64 &firstPointId, const qint64 &secondPointId,
const qint64 &thirdPointId, const Tool::Sources &typeCreation,
QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingBisector* Create(QSharedPointer<DialogBisector> &dialog, VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param formula
* @param firstPointId
* @param secondPointId
* @param thirdPointId
* @param typeLine
* @param pointName
* @param mx
* @param my
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingBisector* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens();
private:
/**
* @brief firstPointId
*/
qint64 firstPointId;
/**
* @brief thirdPointId
*/
qint64 thirdPointId;
/**
* @brief dialogBisector
*/
QSharedPointer<DialogBisector> dialogBisector;
};
#endif // VMODELINGBISECTOR_H

View File

@ -1,239 +0,0 @@
/************************************************************************
**
** @file vmodelingcutspline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 "vmodelingcutspline.h"
#include "../../container/calculator.h"
const QString VModelingCutSpline::ToolType = QStringLiteral("cutSpline");
const QString VModelingCutSpline::AttrSpline = QStringLiteral("spline");
VModelingCutSpline::VModelingCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &formula, const qint64 &splineId, const qint64 &spl1id,
const qint64 &spl2id, const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VModelingPoint(doc, data, id, parent), formula(formula), splineId(splineId),
dialogCutSpline(QSharedPointer<DialogCutSpline>()), firstSpline(), secondSpline(), spl1id(spl1id), spl2id(spl2id)
{
Q_ASSERT_X(splineId > 0, Q_FUNC_INFO, "splineId <= 0");
Q_ASSERT_X(spl1id > 0, Q_FUNC_INFO, "spl1id <= 0");
Q_ASSERT_X(spl2id > 0, Q_FUNC_INFO, "spl2id <= 0");
firstSpline = new VSimpleSpline(spl1id, &currentColor);
Q_ASSERT(firstSpline != 0);
RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint);
firstSpline->setParentItem(this);
connect(firstSpline, &VSimpleSpline::Choosed, this, &VModelingCutSpline::SplineChoosed);
secondSpline = new VSimpleSpline(spl2id, &currentColor);
Q_ASSERT(secondSpline != 0);
RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint);
secondSpline->setParentItem(this);
connect(secondSpline, &VSimpleSpline::Choosed, this, &VModelingCutSpline::SplineChoosed);
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingCutSpline::setDialog()
{
Q_ASSERT(dialogCutSpline.isNull() == false);
VPointF point = VAbstractTool::data.GetPointModeling(id);
dialogCutSpline->setFormula(formula);
dialogCutSpline->setSplineId(splineId, id);
dialogCutSpline->setPointName(point.name());
}
VModelingCutSpline *VModelingCutSpline::Create(QSharedPointer<DialogCutSpline> &dialog,
VDomDocument *doc, VContainer *data)
{
QString pointName = dialog->getPointName();
QString formula = dialog->getFormula();
qint64 splineId = dialog->getSplineId();
return Create(0, pointName, formula, splineId, 5, 10, doc, data, Document::FullParse, Tool::FromGui);
}
VModelingCutSpline *VModelingCutSpline::Create(const qint64 _id, const QString &pointName, const QString &formula,
const qint64 &splineId, const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
VModelingCutSpline *cutPoint = 0;
VSpline spl = data->GetSplineModeling(splineId);
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(formula, &errorMsg);
if (errorMsg.isEmpty())
{
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
QPointF point = spl.CutSpline(toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);
qint64 splP1id, splP4id;
Draw::Draws typeObject = spl.getMode();
if (typeObject == Draw::Calculation)
{
splP1id = data->PointConvertToModeling(spl.GetP1());
splP4id = data->PointConvertToModeling(spl.GetP4());
if (parse == Document::FullParse)
{
doc->IncrementReferens(splP1id);
doc->IncrementReferens(splP4id);
}
}
else
{
splP1id = spl.GetP1();
splP4id = spl.GetP4();
}
qint64 id = _id;
qint64 spl1id = 0;
qint64 spl2id = 0;
if (typeCreation == Tool::FromGui)
{
id = data->AddPointModeling(VPointF(point.x(), point.y(), pointName, mx, my));
VSpline spline1 = VSpline(data->DataPointsModeling(), splP1id, spl1p2, spl1p3, id, spl.GetKcurve());
spl1id = data->AddSplineModeling(spline1);
data->AddLengthSpline(spline1.name(), toMM(spline1.GetLength()));
VSpline spline2 = VSpline(data->DataPointsModeling(), id, spl2p2, spl2p3, splP4id, spl.GetKcurve());
spl2id = data->AddSplineModeling(spline2);
data->AddLengthSpline(spline2.name(), toMM(spline2.GetLength()));
}
else
{
data->UpdatePointModeling(id, VPointF(point.x(), point.y(), pointName, mx, my));
spl1id = id + 1;
spl2id = id + 2;
VSpline spline1 = VSpline(data->DataPointsModeling(), splP1id, spl1p2, spl1p3, id, spl.GetKcurve());
data->UpdateSplineModeling(spl1id, spline1);
data->AddLengthSpline(spline1.name(), toMM(spline1.GetLength()));
VSpline spline2 = VSpline(data->DataPointsModeling(), id, spl2p2, spl2p3, splP4id, spl.GetKcurve());
data->UpdateSplineModeling(spl2id, spline2);
data->AddLengthSpline(spline2.name(), toMM(spline2.GetLength()));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
//VDrawTool::AddRecord(id, Tool::CutSplineTool, doc);
if (parse == Document::FullParse)
{
cutPoint = new VModelingCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation);
doc->AddTool(id, cutPoint);
doc->AddTool(spl1id, cutPoint);
doc->AddTool(spl2id, cutPoint);
doc->IncrementReferens(splineId);
}
}
return cutPoint;
}
void VModelingCutSpline::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
formula = domElement.attribute(AttrLength, "");
splineId = domElement.attribute(AttrSpline, "").toLongLong();
}
RefreshGeometry();
}
void VModelingCutSpline::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogCutSpline->getPointName());
domElement.setAttribute(AttrLength, dialogCutSpline->getFormula());
domElement.setAttribute(AttrSpline, QString().setNum(dialogCutSpline->getSplineId()));
emit FullUpdateTree();
}
}
dialogCutSpline.clear();
}
void VModelingCutSpline::SplineChoosed(qint64 id)
{
emit ChoosedTool(id, Scene::Spline);
}
void VModelingCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogCutSpline, this, event);
}
void VModelingCutSpline::AddToFile()
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrLength, formula);
AddAttribute(domElement, AttrSpline, splineId);
AddToModeling(domElement);
}
void VModelingCutSpline::RefreshGeometry()
{
RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint);
RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint);
VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPointModeling(id));
}
void VModelingCutSpline::RefreshSpline(VSimpleSpline *spline, qint64 splid, SimpleSpline::Translation tr)
{
VSpline spl = VModelingTool::data.GetSplineModeling(splid);
QPainterPath path;
path.addPath(spl.GetPath());
path.setFillRule( Qt::WindingFill );
if(tr == SimpleSpline::FirstPoint)
{
path.translate(-spl.GetPointP1().toQPointF().x(), -spl.GetPointP1().toQPointF().y());
}
else
{
path.translate(-spl.GetPointP4().toQPointF().x(), -spl.GetPointP4().toQPointF().y());
}
spline->setPath(path);
}

View File

@ -1,130 +0,0 @@
/************************************************************************
**
** @file vmodelingcutspline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 VMODELINGCUTSPLINE_H
#define VMODELINGCUTSPLINE_H
#include "vmodelingpoint.h"
#include "../../dialogs/dialogcutspline.h"
#include "../../widgets/vsimplespline.h"
class VModelingCutSpline: public VModelingPoint
{
Q_OBJECT
public:
VModelingCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula,
const qint64 &splineId, const qint64 &spl1id, const qint64 &spl2id,
const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param scene
* @param doc dom document container
* @param data
*/
static VModelingCutSpline* Create(QSharedPointer<DialogCutSpline> &dialog, VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param pointName
* @param formula
* @param splineId
* @param mx
* @param my
* @param scene
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
*/
static VModelingCutSpline* Create(const qint64 _id, const QString &pointName, const QString &formula,
const qint64 &splineId, const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
static const QString AttrSpline;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
/**
* @brief SplineChoosed
* @param id
*/
void SplineChoosed(qint64 id);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
void RefreshGeometry();
private:
/**
* @brief formula keep formula of length
*/
QString formula;
/**
* @brief splineId keep id of spline
*/
qint64 splineId;
/**
* @brief DialogCutSpline pointer to the tool's dialog
*/
QSharedPointer<DialogCutSpline> dialogCutSpline;
/**
* @brief firstSpline
*/
VSimpleSpline *firstSpline;
/**
* @brief secondSpline
*/
VSimpleSpline *secondSpline;
const qint64 spl1id;
const qint64 spl2id;
void RefreshSpline(VSimpleSpline *spline, qint64 splid, SimpleSpline::Translation tr);
};
#endif // VMODELINGCUTSPLINE_H

View File

@ -1,126 +0,0 @@
/************************************************************************
**
** @file vmodelingcutsplinepath.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 "vmodelingcutsplinepath.h"
const QString VModelingCutSplinePath::ToolType = QStringLiteral("cutSplinePath");
const QString VModelingCutSplinePath::AttrSplinePath = QStringLiteral("splinePath");
VModelingCutSplinePath::VModelingCutSplinePath(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &formula, const qint64 &splinePathId,
const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VModelingPoint(doc, data, id, parent), formula(formula), splinePathId(splinePathId),
dialogCutSplinePath(QSharedPointer<DialogCutSplinePath>())
{
Q_ASSERT_X(splinePathId > 0, Q_FUNC_INFO, "splinePathId <= 0");
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingCutSplinePath::setDialog()
{
Q_ASSERT(dialogCutSplinePath.isNull() == false);
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
dialogCutSplinePath->setFormula(formula);
dialogCutSplinePath->setSplinePathId(splinePathId, id);
dialogCutSplinePath->setPointName(splPath.name());
}
VModelingCutSplinePath *VModelingCutSplinePath::Create(QSharedPointer<DialogCutSplinePath> &dialog,
VDomDocument *doc, VContainer *data)
{
QString pointName = dialog->getPointName();
QString formula = dialog->getFormula();
qint64 splinePathId = dialog->getSplinePathId();
return Create(0, pointName, formula, splinePathId, 5, 10, doc, data, Document::FullParse, Tool::FromGui);
}
VModelingCutSplinePath *VModelingCutSplinePath::Create(const qint64 _id, const QString &pointName,
const QString &formula, const qint64 &splinePathId,
const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data,
const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
}
void VModelingCutSplinePath::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
formula = domElement.attribute(AttrLength, "");
splinePathId = domElement.attribute(AttrSplinePath, "").toLongLong();
}
RefreshGeometry();
}
void VModelingCutSplinePath::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogCutSplinePath->getPointName());
domElement.setAttribute(AttrLength, dialogCutSplinePath->getFormula());
domElement.setAttribute(AttrSplinePath, QString().setNum(dialogCutSplinePath->getSplinePathId()));
emit FullUpdateTree();
}
}
dialogCutSplinePath.clear();
}
void VModelingCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogCutSplinePath, this, event);
}
void VModelingCutSplinePath::AddToFile()
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrLength, formula);
AddAttribute(domElement, AttrSplinePath, splinePathId);
AddToModeling(domElement);
}
void VModelingCutSplinePath::RefreshGeometry()
{
VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPointModeling(id));
}

View File

@ -1,113 +0,0 @@
/************************************************************************
**
** @file vmodelingcutsplinepath.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 VMODELINGCUTSPLINEPATH_H
#define VMODELINGCUTSPLINEPATH_H
#include "vmodelingpoint.h"
#include "../../dialogs/dialogcutsplinepath.h"
class VModelingCutSplinePath : public VModelingPoint
{
Q_OBJECT
public:
VModelingCutSplinePath(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula,
const qint64 &splinePathId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param scene
* @param doc dom document container
* @param data
*/
static VModelingCutSplinePath* Create(QSharedPointer<DialogCutSplinePath> &dialog,
VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param pointName
* @param formula
* @param splineId
* @param mx
* @param my
* @param scene
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
*/
static VModelingCutSplinePath* Create(const qint64 _id, const QString &pointName, const QString &formula,
const qint64 &splinePathId, const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
static const QString AttrSplinePath;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
void RefreshGeometry();
private:
/**
* @brief formula keep formula of length
*/
QString formula;
/**
* @brief splineId keep id of spline
*/
qint64 splinePathId;
/**
* @brief DialogCutSpline pointer to the tool's dialog
*/
QSharedPointer<DialogCutSplinePath> dialogCutSplinePath;
};
#endif // VMODELINGCUTSPLINEPATH_H

View File

@ -1,161 +0,0 @@
/************************************************************************
**
** @file vmodelingendline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingendline.h"
#include "../../container/calculator.h"
const QString VModelingEndLine::ToolType = QStringLiteral("endLine");
VModelingEndLine::VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qreal &angle,
const qint64 &basePointId, const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VModelingLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent),
dialogEndLine(QSharedPointer<DialogEndLine>())
{
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingEndLine::setDialog()
{
Q_ASSERT(dialogEndLine.isNull() == false);
VPointF p = VAbstractTool::data.GetPointModeling(id);
dialogEndLine->setTypeLine(typeLine);
dialogEndLine->setFormula(formula);
dialogEndLine->setAngle(angle);
dialogEndLine->setBasePointId(basePointId, id);
dialogEndLine->setPointName(p.name());
}
VModelingEndLine *VModelingEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VDomDocument *doc, VContainer *data)
{
QString pointName = dialog->getPointName();
QString typeLine = dialog->getTypeLine();
QString formula = dialog->getFormula();
qreal angle = dialog->getAngle();
qint64 basePointId = dialog->getBasePointId();
return Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, doc, data, Document::FullParse,
Tool::FromGui);
}
VModelingEndLine *VModelingEndLine::Create(const qint64 _id, const QString &pointName,
const QString &typeLine, const QString &formula,
const qreal &angle, const qint64 &basePointId, const qreal &mx,
const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation)
{
VModelingEndLine *point = 0;
VPointF basePoint = data->GetPointModeling(basePointId);
QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y()));
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(formula, &errorMsg);
if (errorMsg.isEmpty())
{
line.setLength(toPixel(result));
line.setAngle(angle);
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddPointModeling(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
}
else
{
data->UpdatePointModeling(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
data->AddLine(basePointId, id, Draw::Modeling);
if (parse == Document::FullParse)
{
point = new VModelingEndLine(doc, data, id, typeLine, formula, angle, basePointId, typeCreation);
doc->AddTool(id, point);
doc->IncrementReferens(basePointId);
}
}
return point;
}
void VModelingEndLine::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrBasePoint, "").toLongLong();
angle = domElement.attribute(AttrAngle, "").toDouble();
}
RefreshGeometry();
}
void VModelingEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogEndLine, this, event);
}
void VModelingEndLine::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogEndLine->getPointName());
domElement.setAttribute(AttrTypeLine, dialogEndLine->getTypeLine());
domElement.setAttribute(AttrLength, dialogEndLine->getFormula());
domElement.setAttribute(AttrAngle, QString().setNum(dialogEndLine->getAngle()));
domElement.setAttribute(AttrBasePoint, QString().setNum(dialogEndLine->getBasePointId()));
emit FullUpdateTree();
}
}
dialogEndLine.clear();
}
void VModelingEndLine::AddToFile()
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrTypeLine, typeLine);
AddAttribute(domElement, AttrLength, formula);
AddAttribute(domElement, AttrAngle, angle);
AddAttribute(domElement, AttrBasePoint, basePointId);
AddToModeling(domElement);
}

View File

@ -1,121 +0,0 @@
/************************************************************************
**
** @file vmodelingbisector.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGENDLINE_H
#define VMODELINGENDLINE_H
#include "vmodelinglinepoint.h"
#include "../../dialogs/dialogendline.h"
/**
* @brief The VModelingEndLine class
*/
class VModelingEndLine : public VModelingLinePoint
{
Q_OBJECT
public:
/**
* @brief VModelingEndLine
* @param doc dom document container
* @param data
* @param id
* @param typeLine
* @param formula
* @param angle
* @param basePointId
* @param typeCreation
* @param parent
*/
VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qreal &angle,
const qint64 &basePointId, const Tool::Sources &typeCreation,
QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingEndLine* Create(QSharedPointer<DialogEndLine> &dialog, VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param pointName
* @param typeLine
* @param formula
* @param angle
* @param basePointId
* @param mx
* @param my
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingEndLine* Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &basePointId,
const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
private:
/**
* @brief dialogEndLine
*/
QSharedPointer<DialogEndLine> dialogEndLine;
};
#endif // VMODELINGENDLINE_H

View File

@ -1,163 +0,0 @@
/************************************************************************
**
** @file vmodelingheight.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingheight.h"
#include "../drawTools/vtoolheight.h"
const QString VModelingHeight::ToolType = QStringLiteral("height");
VModelingHeight::VModelingHeight(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const qint64 &basePointId, const qint64 &p1LineId,
const qint64 &p2LineId, const Tool::Sources &typeCreation,
QGraphicsItem * parent)
:VModelingLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent),
dialogHeight(QSharedPointer<DialogHeight>()), p1LineId(p1LineId), p2LineId(p2LineId)
{
ignoreFullUpdate = true;
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingHeight::setDialog()
{
Q_ASSERT(dialogHeight.isNull() == false);
VPointF p = VAbstractTool::data.GetPointModeling(id);
dialogHeight->setTypeLine(typeLine);
dialogHeight->setBasePointId(basePointId, id);
dialogHeight->setP1LineId(p1LineId, id);
dialogHeight->setP2LineId(p2LineId, id);
dialogHeight->setPointName(p.name());
}
VModelingHeight *VModelingHeight::Create(QSharedPointer<DialogHeight> &dialog, VDomDocument *doc, VContainer *data)
{
disconnect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &DialogHeight::UpdateList);
QString pointName = dialog->getPointName();
QString typeLine = dialog->getTypeLine();
qint64 basePointId = dialog->getBasePointId();
qint64 p1LineId = dialog->getP1LineId();
qint64 p2LineId = dialog->getP2LineId();
return Create(0, pointName, typeLine, basePointId, p1LineId, p2LineId, 5, 10, doc, data,
Document::FullParse, Tool::FromGui);
}
VModelingHeight *VModelingHeight::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const qint64 &basePointId, const qint64 &p1LineId,
const qint64 &p2LineId, const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation)
{
VModelingHeight *point = 0;
VPointF basePoint = data->GetPointModeling(basePointId);
VPointF p1Line = data->GetPointModeling(p1LineId);
VPointF p2Line = data->GetPointModeling(p2LineId);
QPointF pHeight = VToolHeight::FindPoint(QLineF(p1Line.toQPointF(), p2Line.toQPointF()),
basePoint.toQPointF());
QLineF line = QLineF(basePoint.toQPointF(), pHeight);
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddPointModeling(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
}
else
{
data->UpdatePointModeling(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
data->AddLine(basePointId, id, Draw::Modeling);
if (parse == Document::FullParse)
{
point = new VModelingHeight(doc, data, id, typeLine, basePointId, p1LineId, p2LineId, typeCreation);
doc->AddTool(id, point);
doc->IncrementReferens(basePointId);
doc->IncrementReferens(p1LineId);
doc->IncrementReferens(p2LineId);
}
return point;
}
void VModelingHeight::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
basePointId = domElement.attribute(AttrBasePoint, "").toLongLong();
p1LineId = domElement.attribute(AttrP1Line, "").toLongLong();
p2LineId = domElement.attribute(AttrP2Line, "").toLongLong();
}
RefreshGeometry();
}
void VModelingHeight::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogHeight->getPointName());
domElement.setAttribute(AttrTypeLine, dialogHeight->getTypeLine());
domElement.setAttribute(AttrBasePoint, QString().setNum(dialogHeight->getBasePointId()));
domElement.setAttribute(AttrP1Line, QString().setNum(dialogHeight->getP1LineId()));
domElement.setAttribute(AttrP2Line, QString().setNum(dialogHeight->getP2LineId()));
emit FullUpdateTree();
}
}
dialogHeight.clear();
}
void VModelingHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogHeight, this, event);
}
void VModelingHeight::AddToFile()
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrTypeLine, typeLine);
AddAttribute(domElement, AttrBasePoint, basePointId);
AddAttribute(domElement, AttrP1Line, p1LineId);
AddAttribute(domElement, AttrP2Line, p2LineId);
AddToModeling(domElement);
}

View File

@ -1,129 +0,0 @@
/************************************************************************
**
** @file vmodelingheight.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGHEIGHT_H
#define VMODELINGHEIGHT_H
#include "vmodelinglinepoint.h"
#include "../../dialogs/dialogheight.h"
/**
* @brief The VModelingHeight class
*/
class VModelingHeight : public VModelingLinePoint
{
Q_OBJECT
public:
/**
* @brief VModelingHeight
* @param doc dom document container
* @param data
* @param id
* @param typeLine
* @param basePointId
* @param p1LineId
* @param p2LineId
* @param typeCreation
* @param parent
*/
VModelingHeight(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const qint64 &basePointId, const qint64 &p1LineId,
const qint64 &p2LineId, const Tool::Sources &typeCreation,
QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingHeight* Create(QSharedPointer<DialogHeight> &dialog, VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param pointName
* @param typeLine
* @param basePointId
* @param p1LineId
* @param p2LineId
* @param mx
* @param my
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingHeight* Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId,
const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
private:
/**
* @brief dialogHeight
*/
QSharedPointer<DialogHeight> dialogHeight;
/**
* @brief p1LineId
*/
qint64 p1LineId;
/**
* @brief p2LineId
*/
qint64 p2LineId;
};
#endif // VMODELINGHEIGHT_H

View File

@ -1,156 +0,0 @@
/************************************************************************
**
** @file vmodelingline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingline.h"
const QString VModelingLine::TagName = QStringLiteral("line");
VModelingLine::VModelingLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
qint64 secondPoint, const Tool::Sources &typeCreation, QGraphicsItem *parent):
VModelingTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint),
secondPoint(secondPoint), dialogLine(QSharedPointer<DialogLine>())
{
ignoreFullUpdate = true;
//Лінія
VPointF first = data->GetPointModeling(firstPoint);
VPointF second = data->GetPointModeling(secondPoint);
this->setLine(QLineF(first.toQPointF(), second.toQPointF()));
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true);
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingLine::setDialog()
{
dialogLine->setFirstPoint(firstPoint);
dialogLine->setSecondPoint(secondPoint);
}
VModelingLine *VModelingLine::Create(QSharedPointer<DialogLine> &dialog, VDomDocument *doc, VContainer *data)
{
qint64 firstPoint = dialog->getFirstPoint();
qint64 secondPoint = dialog->getSecondPoint();
return Create(0, firstPoint, secondPoint, doc, data, Document::FullParse, Tool::FromGui);
}
VModelingLine *VModelingLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint,
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
VModelingLine *line = 0;
Q_ASSERT(doc != 0);
Q_ASSERT(data != 0);
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->getNextId();
}
else
{
if (parse != Document::FullParse)
{
data->UpdateId(id);
doc->UpdateToolData(id, data);
}
}
data->AddLine(firstPoint, secondPoint, Draw::Modeling);
if (parse == Document::FullParse)
{
line = new VModelingLine(doc, data, id, firstPoint, secondPoint, typeCreation);
doc->AddTool(id, line);
doc->IncrementReferens(firstPoint);
doc->IncrementReferens(secondPoint);
}
return line;
}
void VModelingLine::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
firstPoint = domElement.attribute(AttrFirstPoint, "").toLongLong();
secondPoint = domElement.attribute(AttrSecondPoint, "").toLongLong();
}
VPointF first = VAbstractTool::data.GetPointModeling(firstPoint);
VPointF second = VAbstractTool::data.GetPointModeling(secondPoint);
this->setLine(QLineF(first.toQPointF(), second.toQPointF()));
}
void VModelingLine::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogLine->getFirstPoint()));
domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogLine->getSecondPoint()));
emit FullUpdateTree();
}
}
dialogLine.clear();
}
void VModelingLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogLine, this, event);
}
void VModelingLine::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrFirstPoint, firstPoint);
AddAttribute(domElement, AttrSecondPoint, secondPoint);
AddToModeling(domElement);
}
void VModelingLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine));
}
void VModelingLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine));
}
void VModelingLine::RemoveReferens()
{
doc->DecrementReferens(firstPoint);
doc->DecrementReferens(secondPoint);
}

View File

@ -1,139 +0,0 @@
/************************************************************************
**
** @file vmodelingline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGLINE_H
#define VMODELINGLINE_H
#include "vmodelingtool.h"
#include <QGraphicsLineItem>
#include "../../dialogs/dialogline.h"
/**
* @brief The VModelingLine class
*/
class VModelingLine: public VModelingTool, public QGraphicsLineItem
{
Q_OBJECT
public:
/**
* @brief VModelingLine
* @param doc dom document container
* @param data
* @param id
* @param firstPoint
* @param secondPoint
* @param typeCreation
* @param parent
*/
VModelingLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
qint64 secondPoint, const Tool::Sources &typeCreation,
QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingLine* Create(QSharedPointer<DialogLine> &dialog, VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param firstPoint
* @param secondPoint
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingLine* Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint,
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation);
/**
* @brief TagName
*/
static const QString TagName;
/**
* @brief ToolType
*/
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
/**
* @brief hoverMoveEvent
* @param event
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent
* @param event
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens();
private:
/**
* @brief firstPoint
*/
qint64 firstPoint;
/**
* @brief secondPoint
*/
qint64 secondPoint;
/**
* @brief dialogLine
*/
QSharedPointer<DialogLine> dialogLine;
};
#endif // VMODELINGLINE_H

View File

@ -1,180 +0,0 @@
/************************************************************************
**
** @file vmodelinglineintersect.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelinglineintersect.h"
const QString VModelingLineIntersect::ToolType = QStringLiteral("lineIntersect");
VModelingLineIntersect::VModelingLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id,
const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line2, const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VModelingPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>())
{
ignoreFullUpdate = true;
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingLineIntersect::setDialog()
{
Q_ASSERT(dialogLineIntersect.isNull() == false);
VPointF p = VAbstractTool::data.GetPointModeling(id);
dialogLineIntersect->setP1Line1(p1Line1);
dialogLineIntersect->setP2Line1(p2Line1);
dialogLineIntersect->setP1Line2(p1Line2);
dialogLineIntersect->setP2Line2(p2Line2);
dialogLineIntersect->setPointName(p.name());
}
VModelingLineIntersect *VModelingLineIntersect::Create(QSharedPointer<DialogLineIntersect> &dialog,
VDomDocument *doc, VContainer *data)
{
qint64 p1Line1Id = dialog->getP1Line1();
qint64 p2Line1Id = dialog->getP2Line1();
qint64 p1Line2Id = dialog->getP1Line2();
qint64 p2Line2Id = dialog->getP2Line2();
QString pointName = dialog->getPointName();
return Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, doc, data,
Document::FullParse, Tool::FromGui);
}
VModelingLineIntersect *VModelingLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id,
const qint64 &p2Line1Id, const qint64 &p1Line2Id,
const qint64 &p2Line2Id, const QString &pointName,
const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
VModelingLineIntersect *point = 0;
VPointF p1Line1 = data->GetPointModeling(p1Line1Id);
VPointF p2Line1 = data->GetPointModeling(p2Line1Id);
VPointF p1Line2 = data->GetPointModeling(p1Line2Id);
VPointF p2Line2 = data->GetPointModeling(p2Line2Id);
QLineF line1(p1Line1.toQPointF(), p2Line1.toQPointF());
QLineF line2(p1Line2.toQPointF(), p2Line2.toQPointF());
QPointF fPoint;
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
{
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddPointModeling(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
}
else
{
data->UpdatePointModeling(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
data->AddLine(p1Line1Id, id, Draw::Modeling);
data->AddLine(id, p2Line1Id, Draw::Modeling);
data->AddLine(p1Line2Id, id, Draw::Modeling);
data->AddLine(id, p2Line2Id, Draw::Modeling);
if (parse == Document::FullParse)
{
point = new VModelingLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id,
typeCreation);
doc->AddTool(id, point);
doc->IncrementReferens(p1Line1Id);
doc->IncrementReferens(p2Line1Id);
doc->IncrementReferens(p1Line2Id);
doc->IncrementReferens(p2Line2Id);
}
}
return point;
}
void VModelingLineIntersect::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
p1Line1 = domElement.attribute(AttrP1Line1, "").toLongLong();
p2Line1 = domElement.attribute(AttrP2Line1, "").toLongLong();
p1Line2 = domElement.attribute(AttrP1Line2, "").toLongLong();
p2Line2 = domElement.attribute(AttrP2Line2, "").toLongLong();
}
RefreshPointGeometry(VAbstractTool::data.GetPointModeling(id));
}
void VModelingLineIntersect::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogLineIntersect->getPointName());
domElement.setAttribute(AttrP1Line1, QString().setNum(dialogLineIntersect->getP1Line1()));
domElement.setAttribute(AttrP2Line1, QString().setNum(dialogLineIntersect->getP2Line1()));
domElement.setAttribute(AttrP1Line2, QString().setNum(dialogLineIntersect->getP1Line2()));
domElement.setAttribute(AttrP2Line2, QString().setNum(dialogLineIntersect->getP2Line2()));
emit FullUpdateTree();
}
}
dialogLineIntersect.clear();
}
void VModelingLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogLineIntersect, this, event);
}
void VModelingLineIntersect::AddToFile()
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrP1Line1, p1Line1);
AddAttribute(domElement, AttrP2Line1, p2Line1);
AddAttribute(domElement, AttrP1Line2, p1Line2);
AddAttribute(domElement, AttrP2Line2, p2Line2);
AddToModeling(domElement);
}
void VModelingLineIntersect::RemoveReferens()
{
doc->DecrementReferens(p1Line1);
doc->DecrementReferens(p2Line1);
doc->DecrementReferens(p1Line2);
doc->DecrementReferens(p2Line2);
}

View File

@ -1,143 +0,0 @@
/************************************************************************
**
** @file vmodelinglineintersect.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGLINEINTERSECT_H
#define VMODELINGLINEINTERSECT_H
#include "vmodelingpoint.h"
#include "../../dialogs/dialoglineintersect.h"
/**
* @brief The VModelingLineIntersect class
*/
class VModelingLineIntersect:public VModelingPoint
{
Q_OBJECT
public:
/**
* @brief VModelingLineIntersect
* @param doc dom document container
* @param data
* @param id
* @param p1Line1
* @param p2Line1
* @param p1Line2
* @param p2Line2
* @param typeCreation
* @param parent
*/
VModelingLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id,
const qint64 &p1Line1, const qint64 &p2Line1,
const qint64 &p1Line2, const qint64 &p2Line2,
const Tool::Sources &typeCreation,
QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingLineIntersect* Create(QSharedPointer<DialogLineIntersect> &dialog, VDomDocument *doc,
VContainer *data);
/**
* @brief Create
* @param _id
* @param p1Line1Id
* @param p2Line1Id
* @param p1Line2Id
* @param p2Line2Id
* @param pointName
* @param mx
* @param my
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingLineIntersect* Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id,
const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName,
const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens();
private:
/**
* @brief p1Line1
*/
qint64 p1Line1;
/**
* @brief p2Line1
*/
qint64 p2Line1;
/**
* @brief p1Line2
*/
qint64 p1Line2;
/**
* @brief p2Line2
*/
qint64 p2Line2;
/**
* @brief dialogLineIntersect
*/
QSharedPointer<DialogLineIntersect> dialogLineIntersect;
};
#endif // VMODELINGLINEINTERSECT_H

View File

@ -1,67 +0,0 @@
/************************************************************************
**
** @file vmodelinglinepoint.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelinglinepoint.h"
VModelingLinePoint::VModelingLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &basePointId,
const qreal &angle, QGraphicsItem *parent)
:VModelingPoint(doc, data, id, parent), typeLine(typeLine), formula(formula), angle(angle),
basePointId(basePointId), mainLine(0)
{
//Лінія, що з'єднує дві точки
QPointF point1 = data->GetPointModeling(basePointId).toQPointF();
QPointF point2 = data->GetPointModeling(id).toQPointF();
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this);
mainLine->setPen(QPen(Qt::black, widthHairLine));
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
if (typeLine == TypeLineNone)
{
mainLine->setVisible(false);
}
else
{
mainLine->setVisible(true);
}
}
void VModelingLinePoint::RefreshGeometry()
{
VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPointModeling(id));
QPointF point = VModelingTool::data.GetPointModeling(id).toQPointF();
QPointF basePoint = VModelingTool::data.GetPointModeling(basePointId).toQPointF();
mainLine->setLine(QLineF(basePoint - point, QPointF()));
if (typeLine == TypeLineNone)
{
mainLine->setVisible(false);
}
else
{
mainLine->setVisible(true);
}
}

View File

@ -1,88 +0,0 @@
/************************************************************************
**
** @file vmodelinglinepoint.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGLINEPOINT_H
#define VMODELINGLINEPOINT_H
#include "vmodelingpoint.h"
/**
* @brief The VModelingLinePoint class
*/
class VModelingLinePoint : public VModelingPoint
{
Q_OBJECT
public:
/**
* @brief VModelingLinePoint
* @param doc dom document container
* @param data
* @param id
* @param typeLine
* @param formula
* @param basePointId
* @param angle
* @param parent
*/
VModelingLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &formula, const qint64 &basePointId, const qreal &angle,
QGraphicsItem * parent = 0);
protected:
/**
* @brief typeLine
*/
QString typeLine;
/**
* @brief formula
*/
QString formula;
/**
* @brief angle
*/
qreal angle;
/**
* @brief basePointId
*/
qint64 basePointId;
/**
* @brief mainLine
*/
QGraphicsLineItem *mainLine;
/**
* @brief RefreshGeometry
*/
virtual void RefreshGeometry();
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens() {doc->DecrementReferens(basePointId);}
private:
Q_DISABLE_COPY(VModelingLinePoint)
};
#endif // VMODELINGLINEPOINT_H

View File

@ -1,175 +0,0 @@
/************************************************************************
**
** @file vmodelingnormal.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingnormal.h"
#include "../drawTools/vtoolnormal.h"
#include "../../container/calculator.h"
const QString VModelingNormal::ToolType = QStringLiteral("normal");
VModelingNormal::VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &firstPointId,
const qint64 &secondPointId, const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VModelingLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent),
secondPointId(secondPointId), dialogNormal(QSharedPointer<DialogNormal>())
{
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingNormal::setDialog()
{
Q_ASSERT(dialogNormal.isNull() == false);
VPointF p = VAbstractTool::data.GetPointModeling(id);
dialogNormal->setTypeLine(typeLine);
dialogNormal->setFormula(formula);
dialogNormal->setAngle(angle);
dialogNormal->setFirstPointId(basePointId, id);
dialogNormal->setSecondPointId(secondPointId, id);
dialogNormal->setPointName(p.name());
}
VModelingNormal* VModelingNormal::Create(QSharedPointer<DialogNormal> &dialog, VDomDocument *doc, VContainer *data)
{
QString formula = dialog->getFormula();
qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId();
QString typeLine = dialog->getTypeLine();
QString pointName = dialog->getPointName();
qreal angle = dialog->getAngle();
return Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, doc, data,
Document::FullParse, Tool::FromGui);
}
VModelingNormal *VModelingNormal::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const QString &typeLine, const QString &pointName,
const qreal angle, const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
VModelingNormal *point = 0;
VPointF firstPoint = data->GetPointModeling(firstPointId);
VPointF secondPoint = data->GetPointModeling(secondPointId);
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(formula, &errorMsg);
if (errorMsg.isEmpty())
{
QPointF fPoint = VToolNormal::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
toPixel(result), angle);
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddPointModeling(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
}
else
{
data->UpdatePointModeling(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
data->AddLine(firstPointId, id, Draw::Modeling);
if (parse == Document::FullParse)
{
point = new VModelingNormal(doc, data, id, typeLine, formula, angle, firstPointId, secondPointId,
typeCreation);
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
}
}
return point;
}
void VModelingNormal::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong();
angle = domElement.attribute(AttrAngle, "").toInt();
}
RefreshGeometry();
}
void VModelingNormal::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogNormal->getPointName());
domElement.setAttribute(AttrTypeLine, dialogNormal->getTypeLine());
domElement.setAttribute(AttrLength, dialogNormal->getFormula());
domElement.setAttribute(AttrAngle, QString().setNum(dialogNormal->getAngle()));
domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogNormal->getFirstPointId()));
domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogNormal->getSecondPointId()));
emit FullUpdateTree();
}
}
dialogNormal.clear();
}
void VModelingNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogNormal, this, event);
}
void VModelingNormal::AddToFile()
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrTypeLine, typeLine);
AddAttribute(domElement, AttrLength, formula);
AddAttribute(domElement, AttrAngle, angle);
AddAttribute(domElement, AttrFirstPoint, basePointId);
AddAttribute(domElement, AttrSecondPoint, secondPointId);
AddToModeling(domElement);
}
void VModelingNormal::RemoveReferens()
{
doc->DecrementReferens(secondPointId);
VModelingLinePoint::RemoveReferens();
}

View File

@ -1,132 +0,0 @@
/************************************************************************
**
** @file vmodelingnormal.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGNORMAL_H
#define VMODELINGNORMAL_H
#include "vmodelinglinepoint.h"
#include "../../dialogs/dialognormal.h"
/**
* @brief The VModelingNormal class
*/
class VModelingNormal : public VModelingLinePoint
{
Q_OBJECT
public:
/**
* @brief VModelingNormal
* @param doc dom document container
* @param data
* @param id
* @param typeLine
* @param formula
* @param angle
* @param firstPointId
* @param secondPointId
* @param typeCreation
* @param parent
*/
VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qreal &angle,
const qint64 &firstPointId, const qint64 &secondPointId,
const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingNormal* Create(QSharedPointer<DialogNormal> &dialog, VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param formula
* @param firstPointId
* @param secondPointId
* @param typeLine
* @param pointName
* @param angle
* @param mx
* @param my
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingNormal* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const QString &typeLine, const QString &pointName,
const qreal angle, const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens();
private:
/**
* @brief secondPointId
*/
qint64 secondPointId;
/**
* @brief dialogNormal
*/
QSharedPointer<DialogNormal> dialogNormal;
};
#endif // VMODELINGNORMAL_H

View File

@ -1,121 +0,0 @@
/************************************************************************
**
** @file vmodelingpoint.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingpoint.h"
#include "../../container/vpointf.h"
const QString VModelingPoint::TagName = QStringLiteral("point");
VModelingPoint::VModelingPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem *parent)
:VModelingTool(doc, data, id), QGraphicsEllipseItem(parent), radius(toPixel(1.5)), namePoint(0), lineName(0)
{
namePoint = new VGraphicsSimpleTextItem(this);
lineName = new QGraphicsLineItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&VModelingPoint::NameChangePosition);
this->setPen(QPen(Qt::black, widthHairLine));
this->setBrush(QBrush(Qt::NoBrush));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true);
RefreshPointGeometry(VAbstractTool::data.GetPointModeling(id));
}
void VModelingPoint::NameChangePosition(const QPointF &pos)
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QPointF p = pos - this->pos();
point.setMx(p.x());
point.setMy(p.y());
RefreshLine();
UpdateNamePosition(point.mx(), point.my());
VAbstractTool::data.UpdatePoint(id, point);
}
void VModelingPoint::UpdateNamePosition(qreal mx, qreal my)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrMx, QString().setNum(toMM(mx)));
domElement.setAttribute(AttrMy, QString().setNum(toMM(my)));
emit toolhaveChange();
}
}
void VModelingPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
emit ChoosedTool(id, Scene::Point);
}
QGraphicsItem::mouseReleaseEvent(event);
}
void VModelingPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine));
}
void VModelingPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine));
}
void VModelingPoint::RefreshPointGeometry(const VPointF &point)
{
QRectF rec = QRectF(0, 0, radius*2, radius*2);
rec.translate(-rec.center().x(), -rec.center().y());
this->setRect(rec);
this->setPos(point.toQPointF());
disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&VModelingPoint::NameChangePosition);
namePoint->setText(point.name());
namePoint->setPos(QPointF(point.mx(), point.my()));
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&VModelingPoint::NameChangePosition);
RefreshLine();
}
void VModelingPoint::RefreshLine()
{
QRectF nameRec = namePoint->sceneBoundingRect();
QPointF p1, p2;
LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2);
QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
lineName->setLine(QLineF(p1, pRec - scenePos()));
if (QLineF(p1, pRec - scenePos()).length() <= toPixel(4))
{
lineName->setVisible(false);
}
else
{
lineName->setVisible(true);
}
}

View File

@ -1,113 +0,0 @@
/************************************************************************
**
** @file vmodelingpoint.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGPOINT_H
#define VMODELINGPOINT_H
#include "vmodelingtool.h"
#include "../../widgets/vgraphicssimpletextitem.h"
/**
* @brief The VModelingPoint class
*/
class VModelingPoint: public VModelingTool, public QGraphicsEllipseItem
{
Q_OBJECT
public:
/**
* @brief VModelingPoint
* @param doc dom document container
* @param data
* @param id
* @param parent
*/
VModelingPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem * parent = 0);
virtual ~VModelingPoint() {}
/**
* @brief TagName
*/
static const QString TagName;
public slots:
/**
* @brief NameChangePosition
* @param pos
*/
void NameChangePosition(const QPointF &pos);
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result) = 0;
protected:
/**
* @brief radius
*/
qreal radius;
/**
* @brief namePoint
*/
VGraphicsSimpleTextItem *namePoint;
/**
* @brief lineName
*/
QGraphicsLineItem *lineName;
/**
* @brief UpdateNamePosition
* @param mx
* @param my
*/
virtual void UpdateNamePosition(qreal mx, qreal my);
/**
* @brief mouseReleaseEvent
* @param event
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent
* @param event
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent
* @param event
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief RefreshPointGeometry
* @param point
*/
virtual void RefreshPointGeometry(const VPointF &point);
/**
* @brief RefreshLine
*/
void RefreshLine();
private:
Q_DISABLE_COPY(VModelingPoint)
};
#endif // VMODELINGPOINT_H

View File

@ -1,177 +0,0 @@
/************************************************************************
**
** @file vmodelingpointofcontact.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingpointofcontact.h"
#include "../drawTools/vtoolpointofcontact.h"
#include "../../container/calculator.h"
const QString VModelingPointOfContact::ToolType = QStringLiteral("pointOfContact");
VModelingPointOfContact::VModelingPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &radius, const qint64 &center,
const qint64 &firstPointId, const qint64 &secondPointId,
const Tool::Sources &typeCreation, QGraphicsItem *parent)
: VModelingPoint(doc, data, id, parent), radius(radius), center(center), firstPointId(firstPointId),
secondPointId(secondPointId), dialogPointOfContact(QSharedPointer<DialogPointOfContact>())
{
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingPointOfContact::setDialog()
{
Q_ASSERT(dialogPointOfContact.isNull() == false);
VPointF p = VAbstractTool::data.GetPointModeling(id);
dialogPointOfContact->setRadius(radius);
dialogPointOfContact->setCenter(center, id);
dialogPointOfContact->setFirstPoint(firstPointId, id);
dialogPointOfContact->setSecondPoint(secondPointId, id);
dialogPointOfContact->setPointName(p.name());
}
VModelingPointOfContact *VModelingPointOfContact::Create(QSharedPointer<DialogPointOfContact> &dialog,
VDomDocument *doc, VContainer *data)
{
QString radius = dialog->getRadius();
qint64 center = dialog->getCenter();
qint64 firstPointId = dialog->getFirstPoint();
qint64 secondPointId = dialog->getSecondPoint();
QString pointName = dialog->getPointName();
return Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, doc, data,
Document::FullParse, Tool::FromGui);
}
VModelingPointOfContact *VModelingPointOfContact::Create(const qint64 _id, const QString &radius,
const qint64 &center, const qint64 &firstPointId,
const qint64 &secondPointId,
const QString &pointName, const qreal &mx,
const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
VModelingPointOfContact *point = 0;
VPointF centerP = data->GetPointModeling(center);
VPointF firstP = data->GetPointModeling(firstPointId);
VPointF secondP = data->GetPointModeling(secondPointId);
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(radius, &errorMsg);
if (errorMsg.isEmpty())
{
QPointF fPoint = VToolPointOfContact::FindPoint(toPixel(result), centerP.toQPointF(),
firstP.toQPointF(), secondP.toQPointF());
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddPointModeling(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
}
else
{
data->UpdatePointModeling(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
if (parse == Document::FullParse)
{
point = new VModelingPointOfContact(doc, data, id, radius, center, firstPointId, secondPointId,
typeCreation);
doc->AddTool(id, point);
doc->IncrementReferens(center);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
}
}
return point;
}
void VModelingPointOfContact::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
radius = domElement.attribute(AttrRadius, "");
center = domElement.attribute(AttrCenter, "").toLongLong();
firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong();
}
RefreshPointGeometry(VAbstractTool::data.GetPointModeling(id));
}
void VModelingPointOfContact::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogPointOfContact->getPointName());
domElement.setAttribute(AttrRadius, dialogPointOfContact->getRadius());
domElement.setAttribute(AttrCenter, QString().setNum(dialogPointOfContact->getCenter()));
domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogPointOfContact->getFirstPoint()));
domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogPointOfContact->getSecondPoint()));
emit FullUpdateTree();
}
}
dialogPointOfContact.clear();
}
void VModelingPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogPointOfContact, this, event);
}
void VModelingPointOfContact::AddToFile()
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrRadius, radius);
AddAttribute(domElement, AttrCenter, center);
AddAttribute(domElement, AttrFirstPoint, firstPointId);
AddAttribute(domElement, AttrSecondPoint, secondPointId);
AddToModeling(domElement);
}
void VModelingPointOfContact::RemoveReferens()
{
doc->DecrementReferens(center);
doc->DecrementReferens(firstPointId);
doc->DecrementReferens(secondPointId);
}

View File

@ -1,144 +0,0 @@
/************************************************************************
**
** @file vmodelingpointofcontact.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGPOINTOFCONTACT_H
#define VMODELINGPOINTOFCONTACT_H
#include "vmodelingpoint.h"
#include "../../dialogs/dialogpointofcontact.h"
/**
* @brief The VModelingPointOfContact class
*/
class VModelingPointOfContact : public VModelingPoint
{
Q_OBJECT
public:
/**
* @brief VModelingPointOfContact
* @param doc dom document container
* @param data
* @param id
* @param radius
* @param center
* @param firstPointId
* @param secondPointId
* @param typeCreation
* @param parent
*/
VModelingPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &radius, const qint64 &center,
const qint64 &firstPointId, const qint64 &secondPointId,
const Tool::Sources &typeCreation,
QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingPointOfContact* Create(QSharedPointer<DialogPointOfContact> &dialog, VDomDocument *doc,
VContainer *data);
/**
* @brief Create
* @param _id
* @param radius
* @param center
* @param firstPointId
* @param secondPointId
* @param pointName
* @param mx
* @param my
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingPointOfContact* Create(const qint64 _id, const QString &radius, const qint64 &center,
const qint64 &firstPointId, const qint64 &secondPointId,
const QString &pointName, const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens();
private:
/**
* @brief radius
*/
QString radius;
/**
* @brief center
*/
qint64 center;
/**
* @brief firstPointId
*/
qint64 firstPointId;
/**
* @brief secondPointId
*/
qint64 secondPointId;
/**
* @brief dialogPointOfContact
*/
QSharedPointer<DialogPointOfContact> dialogPointOfContact;
};
#endif // VMODELINGPOINTOFCONTACT_H

View File

@ -1,152 +0,0 @@
/************************************************************************
**
** @file vmodelingpointofintersection.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingpointofintersection.h"
const QString VModelingPointOfIntersection::ToolType = QStringLiteral("pointOfIntersection");
VModelingPointOfIntersection::VModelingPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id,
const qint64 &firstPointId, const qint64 &secondPointId,
const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VModelingPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId),
dialogPointOfIntersection(QSharedPointer<DialogPointOfIntersection>())
{
ignoreFullUpdate = true;
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingPointOfIntersection::setDialog()
{
Q_ASSERT(dialogPointOfIntersection.isNull() == false);
VPointF p = VAbstractTool::data.GetPoint(id);
dialogPointOfIntersection->setFirstPointId(firstPointId, id);
dialogPointOfIntersection->setSecondPointId(secondPointId, id);
dialogPointOfIntersection->setPointName(p.name());
}
VModelingPointOfIntersection *VModelingPointOfIntersection::Create(QSharedPointer<DialogPointOfIntersection> &dialog,
VDomDocument *doc, VContainer *data)
{
qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId();
QString pointName = dialog->getPointName();
return Create(0, pointName, firstPointId, secondPointId, 5, 10, doc, data, Document::FullParse, Tool::FromGui);
}
VModelingPointOfIntersection *VModelingPointOfIntersection::Create(const qint64 _id, const QString &pointName,
const qint64 &firstPointId,
const qint64 &secondPointId, const qreal &mx,
const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
VModelingPointOfIntersection *tool = 0;
VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId);
QPointF point(firstPoint.x(), secondPoint.y());
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my));
}
else
{
data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
if (parse == Document::FullParse)
{
tool = new VModelingPointOfIntersection(doc, data, id, firstPointId, secondPointId, typeCreation);
doc->AddTool(id, tool);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
}
return tool;
}
void VModelingPointOfIntersection::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong();
}
VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPoint(id));
}
void VModelingPointOfIntersection::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogPointOfIntersection->getPointName());
domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogPointOfIntersection->getFirstPointId()));
domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogPointOfIntersection->getSecondPointId()));
emit FullUpdateTree();
}
}
dialogPointOfIntersection.clear();
}
void VModelingPointOfIntersection::RemoveReferens()
{
doc->DecrementReferens(firstPointId);
doc->DecrementReferens(secondPointId);
}
void VModelingPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogPointOfIntersection, this, event);
}
void VModelingPointOfIntersection::AddToFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrFirstPoint, firstPointId);
AddAttribute(domElement, AttrSecondPoint, secondPointId);
AddToModeling(domElement);
}

View File

@ -1,131 +0,0 @@
/************************************************************************
**
** @file vmodelingpointofintersection.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGPOINTOFINTERSECTION_H
#define VMODELINGPOINTOFINTERSECTION_H
#include "vmodelingpoint.h"
#include "../../dialogs/dialogpointofintersection.h"
/**
* @brief The VModelingPointOfIntersection class
*/
class VModelingPointOfIntersection : public VModelingPoint
{
Q_OBJECT
public:
/**
* @brief VModelingPointOfIntersection
* @param doc dom document container
* @param data
* @param id
* @param firstPointId
* @param secondPointId
* @param typeCreation
* @param parent
*/
VModelingPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id,
const qint64 &firstPointId, const qint64 &secondPointId,
const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingPointOfIntersection* Create(QSharedPointer<DialogPointOfIntersection> &dialog, VDomDocument *doc,
VContainer *data);
/**
* @brief Create
* @param _id
* @param pointName
* @param firstPointId
* @param secondPointId
* @param mx
* @param my
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingPointOfIntersection* Create(const qint64 _id, const QString &pointName,
const qint64 &firstPointId, const qint64 &secondPointId,
const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens();
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
private:
Q_DISABLE_COPY(VModelingPointOfIntersection)
/**
* @brief firstPointId
*/
qint64 firstPointId;
/**
* @brief secondPointId
*/
qint64 secondPointId;
/**
* @brief dialogPointOfIntersection
*/
QSharedPointer<DialogPointOfIntersection> dialogPointOfIntersection;
};
#endif // VMODELINGPOINTOFINTERSECTION_H

View File

@ -1,184 +0,0 @@
/************************************************************************
**
** @file vmodelingshoulderpoint.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingshoulderpoint.h"
#include "../drawTools/vtoolshoulderpoint.h"
#include "../../container/calculator.h"
const QString VModelingShoulderPoint::ToolType = QStringLiteral("shoulder");
VModelingShoulderPoint::VModelingShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &p1Line,
const qint64 &p2Line, const qint64 &pShoulder, const Tool::Sources &typeCreation,
QGraphicsItem * parent)
:VModelingLinePoint(doc, data, id, typeLine, formula, p1Line, 0, parent), p2Line(p2Line),
pShoulder(pShoulder), dialogShoulderPoint(QSharedPointer<DialogShoulderPoint>())
{
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingShoulderPoint::setDialog()
{
Q_ASSERT(dialogShoulderPoint.isNull() == false);
VPointF p = VAbstractTool::data.GetPointModeling(id);
dialogShoulderPoint->setTypeLine(typeLine);
dialogShoulderPoint->setFormula(formula);
dialogShoulderPoint->setP1Line(basePointId, id);
dialogShoulderPoint->setP2Line(p2Line, id);
dialogShoulderPoint->setPShoulder(pShoulder, id);
dialogShoulderPoint->setPointName(p.name());
}
VModelingShoulderPoint *VModelingShoulderPoint::Create(QSharedPointer<DialogShoulderPoint> &dialog,
VDomDocument *doc, VContainer *data)
{
QString formula = dialog->getFormula();
qint64 p1Line = dialog->getP1Line();
qint64 p2Line = dialog->getP2Line();
qint64 pShoulder = dialog->getPShoulder();
QString typeLine = dialog->getTypeLine();
QString pointName = dialog->getPointName();
return Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, doc, data,
Document::FullParse, Tool::FromGui);
}
VModelingShoulderPoint *VModelingShoulderPoint::Create(const qint64 _id, const QString &formula,
const qint64 &p1Line, const qint64 &p2Line,
const qint64 &pShoulder, const QString &typeLine,
const QString &pointName, const qreal &mx,
const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
VModelingShoulderPoint *point = 0;
VPointF firstPoint = data->GetPointModeling(p1Line);
VPointF secondPoint = data->GetPointModeling(p2Line);
VPointF shoulderPoint = data->GetPointModeling(pShoulder);
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(formula, &errorMsg);
if (errorMsg.isEmpty())
{
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
shoulderPoint.toQPointF(), toPixel(result));
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddPointModeling(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
}
else
{
data->UpdatePointModeling(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
data->AddLine(p1Line, id, Draw::Modeling);
data->AddLine(p2Line, id, Draw::Modeling);
if (parse == Document::FullParse)
{
point = new VModelingShoulderPoint(doc, data, id, typeLine, formula, p1Line, p2Line, pShoulder,
typeCreation);
doc->AddTool(id, point);
doc->IncrementReferens(p1Line);
doc->IncrementReferens(p2Line);
doc->IncrementReferens(pShoulder);
}
}
return point;
}
void VModelingShoulderPoint::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formula = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrP1Line, "").toLongLong();
p2Line = domElement.attribute(AttrP2Line, "").toLongLong();
pShoulder = domElement.attribute(AttrPShoulder, "").toLongLong();
}
RefreshGeometry();
}
void VModelingShoulderPoint::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogShoulderPoint->getPointName());
domElement.setAttribute(AttrTypeLine, dialogShoulderPoint->getTypeLine());
domElement.setAttribute(AttrLength, dialogShoulderPoint->getFormula());
domElement.setAttribute(AttrP1Line, QString().setNum(dialogShoulderPoint->getP1Line()));
domElement.setAttribute(AttrP2Line, QString().setNum(dialogShoulderPoint->getP2Line()));
domElement.setAttribute(AttrPShoulder, QString().setNum(dialogShoulderPoint->getPShoulder()));
emit FullUpdateTree();
}
}
dialogShoulderPoint.clear();
}
void VModelingShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogShoulderPoint, this, event);
}
void VModelingShoulderPoint::AddToFile()
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrTypeLine, typeLine);
AddAttribute(domElement, AttrLength, formula);
AddAttribute(domElement, AttrP1Line, basePointId);
AddAttribute(domElement, AttrP2Line, p2Line);
AddAttribute(domElement, AttrPShoulder, pShoulder);
AddToModeling(domElement);
}
void VModelingShoulderPoint::RemoveReferens()
{
doc->DecrementReferens(p2Line);
doc->DecrementReferens(pShoulder);
VModelingLinePoint::RemoveReferens();
}

View File

@ -1,137 +0,0 @@
/************************************************************************
**
** @file vmodelingshoulderpoint.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGSHOULDERPOINT_H
#define VMODELINGSHOULDERPOINT_H
#include "vmodelinglinepoint.h"
#include "../../dialogs/dialogshoulderpoint.h"
/**
* @brief The VModelingShoulderPoint class
*/
class VModelingShoulderPoint : public VModelingLinePoint
{
Q_OBJECT
public:
/**
* @brief VModelingShoulderPoint
* @param doc dom document container
* @param data
* @param id
* @param typeLine
* @param formula
* @param p1Line
* @param p2Line
* @param pShoulder
* @param typeCreation
* @param parent
*/
VModelingShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &formula, const qint64 &p1Line, const qint64 &p2Line,
const qint64 &pShoulder, const Tool::Sources &typeCreation,
QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingShoulderPoint* Create(QSharedPointer<DialogShoulderPoint> &dialog, VDomDocument *doc,
VContainer *data);
/**
* @brief Create
* @param _id
* @param formula
* @param p1Line
* @param p2Line
* @param pShoulder
* @param typeLine
* @param pointName
* @param mx
* @param my
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingShoulderPoint* Create(const qint64 _id, const QString &formula, const qint64 &p1Line,
const qint64 &p2Line, const qint64 &pShoulder, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens();
private:
/**
* @brief p2Line
*/
qint64 p2Line;
/**
* @brief pShoulder
*/
qint64 pShoulder;
/**
* @brief dialogShoulderPoint
*/
QSharedPointer<DialogShoulderPoint> dialogShoulderPoint;
};
#endif // VMODELINGSHOULDERPOINT_H

View File

@ -1,273 +0,0 @@
/************************************************************************
**
** @file vmodelingspline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingspline.h"
#include "../../geometry/vspline.h"
const QString VModelingSpline::TagName = QStringLiteral("spline");
const QString VModelingSpline::ToolType = QStringLiteral("simple");
VModelingSpline::VModelingSpline(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation,
QGraphicsItem *parent)
:VModelingTool(doc, data, id), QGraphicsPathItem(parent),
dialogSpline(QSharedPointer<DialogSpline>()), controlPoints(QVector<VControlPointSpline *>())
{
ignoreFullUpdate = true;
VSpline spl = data->GetSplineModeling(id);
QPainterPath path;
path.addPath(spl.GetPath());
path.setFillRule( Qt::WindingFill );
this->setPath(path);
this->setPen(QPen(Qt::black, widthHairLine));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true);
VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePoint::FirstPoint, spl.GetP2(),
spl.GetPointP1().toQPointF(), this);
connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSpline::ControlPointChangePosition);
connect(this, &VModelingSpline::RefreshLine, controlPoint1, &VControlPointSpline::RefreshLine);
connect(this, &VModelingSpline::setEnabledPoint, controlPoint1, &VControlPointSpline::setEnabledPoint);
controlPoints.append(controlPoint1);
VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePoint::LastPoint, spl.GetP3(),
spl.GetPointP4().toQPointF(), this);
connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSpline::ControlPointChangePosition);
connect(this, &VModelingSpline::RefreshLine, controlPoint2, &VControlPointSpline::RefreshLine);
connect(this, &VModelingSpline::setEnabledPoint, controlPoint2, &VControlPointSpline::setEnabledPoint);
controlPoints.append(controlPoint2);
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingSpline::setDialog()
{
Q_ASSERT(dialogSpline.isNull() == false);
VSpline spl = VAbstractTool::data.GetSplineModeling(id);
dialogSpline->setP1(spl.GetP1());
dialogSpline->setP4(spl.GetP4());
dialogSpline->setAngle1(spl.GetAngle1());
dialogSpline->setAngle2(spl.GetAngle2());
dialogSpline->setKAsm1(spl.GetKasm1());
dialogSpline->setKAsm2(spl.GetKasm2());
dialogSpline->setKCurve(spl.GetKcurve());
}
VModelingSpline *VModelingSpline::Create(QSharedPointer<DialogSpline> &dialog, VDomDocument *doc, VContainer *data)
{
qint64 p1 = dialog->getP1();
qint64 p4 = dialog->getP4();
qreal kAsm1 = dialog->getKAsm1();
qreal kAsm2 = dialog->getKAsm2();
qreal angle1 = dialog->getAngle1();
qreal angle2 = dialog->getAngle2();
qreal kCurve = dialog->getKCurve();
return Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, doc, data, Document::FullParse,
Tool::FromGui);
}
VModelingSpline *VModelingSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4,
const qreal &kAsm1, const qreal kAsm2, const qreal &angle1,
const qreal &angle2, const qreal &kCurve, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
VModelingSpline *spl = 0;
VSpline spline = VSpline(data->DataPointsModeling(), p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve);
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddSplineModeling(spline);
}
else
{
data->UpdateSplineModeling(id, spline);
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
data->AddLengthSpline(spline.name(), toMM(spline.GetLength()));
if (parse == Document::FullParse)
{
spl = new VModelingSpline(doc, data, id, typeCreation);
doc->AddTool(id, spl);
doc->IncrementReferens(p1);
doc->IncrementReferens(p4);
}
return spl;
}
void VModelingSpline::FullUpdateFromFile()
{
RefreshGeometry();
}
void VModelingSpline::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
VSpline spl = VSpline (VAbstractTool::data.DataPointsModeling(), dialogSpline->getP1(),
dialogSpline->getP4(), dialogSpline->getAngle1(), dialogSpline->getAngle2(),
dialogSpline->getKAsm1(), dialogSpline->getKAsm2(), dialogSpline->getKCurve());
disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSpline::ControlPointChangePosition);
disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSpline::ControlPointChangePosition);
controlPoints[0]->setPos(spl.GetP2());
controlPoints[1]->setPos(spl.GetP3());
connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSpline::ControlPointChangePosition);
connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSpline::ControlPointChangePosition);
spl = VSpline (VAbstractTool::data.DataPointsModeling(), dialogSpline->getP1(),
controlPoints[0]->pos(), controlPoints[1]->pos(), dialogSpline->getP4(),
dialogSpline->getKCurve());
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrPoint1, QString().setNum(spl.GetP1()));
domElement.setAttribute(AttrPoint4, QString().setNum(spl.GetP4()));
domElement.setAttribute(AttrAngle1, QString().setNum(spl.GetAngle1()));
domElement.setAttribute(AttrAngle2, QString().setNum(spl.GetAngle2()));
domElement.setAttribute(AttrKAsm1, QString().setNum(spl.GetKasm1()));
domElement.setAttribute(AttrKAsm2, QString().setNum(spl.GetKasm2()));
domElement.setAttribute(AttrKCurve, QString().setNum(spl.GetKcurve()));
emit FullUpdateTree();
}
}
dialogSpline.clear();
}
void VModelingSpline::ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &pos)
{
Q_UNUSED(indexSpline);
VSpline spl = VAbstractTool::data.GetSplineModeling(id);
if (position == SplinePoint::FirstPoint)
{
spl.ModifiSpl (spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve());
}
else
{
spl.ModifiSpl (spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve());
}
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrAngle1, QString().setNum(spl.GetAngle1()));
domElement.setAttribute(AttrAngle2, QString().setNum(spl.GetAngle2()));
domElement.setAttribute(AttrKAsm1, QString().setNum(spl.GetKasm1()));
domElement.setAttribute(AttrKAsm2, QString().setNum(spl.GetKasm2()));
domElement.setAttribute(AttrKCurve, QString().setNum(spl.GetKcurve()));
emit FullUpdateTree();
}
}
void VModelingSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogSpline, this, event);
}
void VModelingSpline::AddToFile()
{
VSpline spl = VAbstractTool::data.GetSplineModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrPoint1, spl.GetP1());
AddAttribute(domElement, AttrPoint4, spl.GetP4());
AddAttribute(domElement, AttrAngle1, spl.GetAngle1());
AddAttribute(domElement, AttrAngle2, spl.GetAngle2());
AddAttribute(domElement, AttrKAsm1, spl.GetKasm1());
AddAttribute(domElement, AttrKAsm2, spl.GetKasm2());
AddAttribute(domElement, AttrKCurve, spl.GetKcurve());
AddToModeling(domElement);
}
void VModelingSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
emit ChoosedTool(id, Scene::Spline);
}
QGraphicsItem::mouseReleaseEvent(event);
}
void VModelingSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine));
}
void VModelingSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine));
}
void VModelingSpline::RemoveReferens()
{
VSpline spl = VAbstractTool::data.GetSplineModeling(id);
doc->DecrementReferens(spl.GetP1());
doc->DecrementReferens(spl.GetP4());
}
void VModelingSpline::RefreshGeometry()
{
VSpline spl = VAbstractTool::data.GetSplineModeling(id);
QPainterPath path;
path.addPath(spl.GetPath());
path.setFillRule( Qt::WindingFill );
this->setPath(path);
QPointF splinePoint = VAbstractTool::data.GetPointModeling(spl.GetP1()).toQPointF();
QPointF controlPoint = spl.GetP2();
emit RefreshLine(1, SplinePoint::FirstPoint, controlPoint, splinePoint);
splinePoint = VAbstractTool::data.GetPointModeling(spl.GetP4()).toQPointF();
controlPoint = spl.GetP3();
emit RefreshLine(1, SplinePoint::LastPoint, controlPoint, splinePoint);
disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSpline::ControlPointChangePosition);
disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSpline::ControlPointChangePosition);
controlPoints[0]->setPos(spl.GetP2());
controlPoints[1]->setPos(spl.GetP3());
connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSpline::ControlPointChangePosition);
connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSpline::ControlPointChangePosition);
}

View File

@ -1,172 +0,0 @@
/************************************************************************
**
** @file vmodelingspline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGSPLINE_H
#define VMODELINGSPLINE_H
#include "vmodelingtool.h"
#include <QGraphicsPathItem>
#include "../../dialogs/dialogspline.h"
#include "../../widgets/vcontrolpointspline.h"
#include "../../geometry/vsplinepath.h"
/**
* @brief The VModelingSpline class
*/
class VModelingSpline:public VModelingTool, public QGraphicsPathItem
{
Q_OBJECT
public:
/**
* @brief VModelingSpline
* @param doc dom document container
* @param data
* @param id
* @param typeCreation
* @param parent
*/
VModelingSpline (VDomDocument *doc, VContainer *data, qint64 id,
const Tool::Sources &typeCreation, QGraphicsItem * parent = 0 );
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingSpline* Create(QSharedPointer<DialogSpline> &dialog, VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param p1
* @param p4
* @param kAsm1
* @param kAsm2
* @param angle1
* @param angle2
* @param kCurve
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingSpline* Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1,
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation);
/**
* @brief TagName
*/
static const QString TagName;
/**
* @brief ToolType
*/
static const QString ToolType;
signals:
/**
* @brief RefreshLine
* @param indexSpline
* @param position
* @param controlPoint
* @param splinePoint
*/
void RefreshLine (const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &controlPoint, const QPointF &splinePoint );
/**
* @brief setEnabledPoint
* @param enable
*/
void setEnabledPoint ( bool enable );
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile ();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui ( int result );
/**
* @brief ControlPointChangePosition
* @param indexSpline
* @param position
* @param pos
*/
void ControlPointChangePosition (const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &pos);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile ();
/**
* @brief mouseReleaseEvent
* @param event
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent
* @param event
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent
* @param event
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens();
private:
/**
* @brief dialogSpline
*/
QSharedPointer<DialogSpline> dialogSpline;
/**
* @brief controlPoints
*/
QVector<VControlPointSpline *> controlPoints;
/**
* @brief RefreshGeometry
*/
void RefreshGeometry ();
};
#endif // VMODELINGSPLINE_H

View File

@ -1,310 +0,0 @@
/************************************************************************
**
** @file vmodelingsplinepath.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingsplinepath.h"
const QString VModelingSplinePath::TagName = QStringLiteral("spline");
const QString VModelingSplinePath::ToolType = QStringLiteral("path");
VModelingSplinePath::VModelingSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VModelingTool(doc, data, id), QGraphicsPathItem(parent), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
controlPoints(QVector<VControlPointSpline *>())
{
ignoreFullUpdate = true;
VSplinePath splPath = data->GetSplinePathModeling(id);
QPainterPath path;
path.addPath(splPath.GetPath());
path.setFillRule( Qt::WindingFill );
this->setPath(path);
this->setPen(QPen(Qt::black, widthHairLine));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true);
for (qint32 i = 1; i<=splPath.Count(); ++i)
{
VSpline spl = splPath.GetSpline(i);
VControlPointSpline *controlPoint = new VControlPointSpline(i, SplinePoint::FirstPoint, spl.GetP2(),
spl.GetPointP1().toQPointF(), this);
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSplinePath::ControlPointChangePosition);
connect(this, &VModelingSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine);
connect(this, &VModelingSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint);
controlPoints.append(controlPoint);
controlPoint = new VControlPointSpline(i, SplinePoint::LastPoint, spl.GetP3(),
spl.GetPointP4().toQPointF(), this);
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSplinePath::ControlPointChangePosition);
connect(this, &VModelingSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine);
connect(this, &VModelingSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint);
controlPoints.append(controlPoint);
}
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingSplinePath::setDialog()
{
Q_ASSERT(dialogSplinePath.isNull() == false);
VSplinePath splPath = VAbstractTool::data.GetSplinePathModeling(id);
dialogSplinePath->SetPath(splPath);
}
VModelingSplinePath *VModelingSplinePath::Create(QSharedPointer<DialogSplinePath> &dialog, VDomDocument *doc,
VContainer *data)
{
VSplinePath path = dialog->GetPath();
for (qint32 i = 0; i < path.CountPoint(); ++i)
{
doc->IncrementReferens(path[i].P());
}
return Create(0, path, doc, data, Document::FullParse, Tool::FromGui);
}
VModelingSplinePath * VModelingSplinePath::Create(const qint64 _id, const VSplinePath &path, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
VModelingSplinePath *spl = 0;
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddSplinePathModeling(path);
}
else
{
data->UpdateSplinePathModeling(id, path);
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
data->AddLengthSpline(path.name(), toMM(path.GetLength()));
if (parse == Document::FullParse)
{
spl = new VModelingSplinePath(doc, data, id, typeCreation);
doc->AddTool(id, spl);
}
return spl;
}
void VModelingSplinePath::FullUpdateFromFile()
{
RefreshGeometry();
}
void VModelingSplinePath::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
VSplinePath splPath = dialogSplinePath->GetPath();
for (qint32 i = 1; i<=splPath.Count(); ++i)
{
VSpline spl = splPath.GetSpline(i);
qint32 j = i*2;
disconnect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSplinePath::ControlPointChangePosition);
disconnect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSplinePath::ControlPointChangePosition);
controlPoints[j-2]->setPos(spl.GetP2());
controlPoints[j-1]->setPos(spl.GetP3());
connect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSplinePath::ControlPointChangePosition);
connect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSplinePath::ControlPointChangePosition);
spl = VSpline (VAbstractTool::data.DataPointsModeling(), spl.GetP1(), controlPoints[j-2]->pos(),
controlPoints[j-1]->pos(), spl.GetP4(), splPath.getKCurve());
CorectControlPoints(spl, splPath, i);
CorectControlPoints(spl, splPath, i);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrKCurve, QString().setNum(splPath.getKCurve()));
UpdatePathPoint(domElement, splPath);
emit FullUpdateTree();
}
}
}
dialogSplinePath.clear();
}
void VModelingSplinePath::ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &pos)
{
VSplinePath splPath = VAbstractTool::data.GetSplinePathModeling(id);
VSpline spl = splPath.GetSpline(indexSpline);
if (position == SplinePoint::FirstPoint)
{
spl.ModifiSpl (spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve());
}
else
{
spl.ModifiSpl (spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve());
}
CorectControlPoints(spl, splPath, indexSpline);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrKCurve, QString().setNum(splPath.getKCurve()));
UpdatePathPoint(domElement, splPath);
emit FullUpdateTree();
}
}
void VModelingSplinePath::CorectControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline)
{
VSplinePoint p = splPath.GetSplinePoint(indexSpline, SplinePoint::FirstPoint);
p.SetAngle(spl.GetAngle1());
p.SetKAsm2(spl.GetKasm1());
splPath.UpdatePoint(indexSpline, SplinePoint::FirstPoint, p);
p = splPath.GetSplinePoint(indexSpline, SplinePoint::LastPoint);
p.SetAngle(spl.GetAngle2()-180);
p.SetKAsm1(spl.GetKasm2());
splPath.UpdatePoint(indexSpline, SplinePoint::LastPoint, p);
}
void VModelingSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path)
{
QDomNodeList nodeList = node.childNodes();
qint32 num = nodeList.size();
for (qint32 i = 0; i < num; ++i)
{
QDomElement domElement = nodeList.at(i).toElement();
if (domElement.isNull() == false)
{
VSplinePoint p = path[i];
domElement.setAttribute(AttrPSpline, QString().setNum(p.P()));
domElement.setAttribute(AttrKAsm1, QString().setNum(p.KAsm1()));
domElement.setAttribute(AttrKAsm2, QString().setNum(p.KAsm2()));
domElement.setAttribute(AttrAngle, QString().setNum(p.Angle2()));
}
}
}
void VModelingSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogSplinePath, this, event);
}
void VModelingSplinePath::AddToFile()
{
VSplinePath splPath = VAbstractTool::data.GetSplinePathModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrKCurve, splPath.getKCurve());
for (qint32 i = 0; i < splPath.CountPoint(); ++i)
{
AddPathPoint(domElement, splPath[i]);
}
AddToModeling(domElement);
}
void VModelingSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint)
{
QDomElement pathPoint = doc->createElement(AttrPathPoint);
AddAttribute(pathPoint, AttrPSpline, splPoint.P());
AddAttribute(pathPoint, AttrKAsm1, splPoint.KAsm1());
AddAttribute(pathPoint, AttrKAsm2, splPoint.KAsm2());
AddAttribute(pathPoint, AttrAngle, splPoint.Angle2());
domElement.appendChild(pathPoint);
}
void VModelingSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
emit ChoosedTool(id, Scene::SplinePath);
}
QGraphicsItem::mouseReleaseEvent(event);
}
void VModelingSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine));
}
void VModelingSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine));
}
void VModelingSplinePath::RemoveReferens()
{
VSplinePath splPath = VAbstractTool::data.GetSplinePathModeling(id);
for (qint32 i = 0; i < splPath.Count(); ++i)
{
doc->DecrementReferens(splPath[i].P());
}
}
void VModelingSplinePath::RefreshGeometry()
{
VSplinePath splPath = VAbstractTool::data.GetSplinePathModeling(id);
QPainterPath path;
path.addPath(splPath.GetPath());
path.setFillRule( Qt::WindingFill );
this->setPath(path);
for (qint32 i = 1; i<=splPath.Count(); ++i)
{
VSpline spl = splPath.GetSpline(i);
QPointF splinePoint = spl.GetPointP1().toQPointF();
QPointF controlPoint = spl.GetP2();
emit RefreshLine(i, SplinePoint::FirstPoint, controlPoint, splinePoint);
splinePoint = spl.GetPointP4().toQPointF();
controlPoint = spl.GetP3();
emit RefreshLine(i, SplinePoint::LastPoint, controlPoint, splinePoint);
qint32 j = i*2;
disconnect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSplinePath::ControlPointChangePosition);
disconnect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSplinePath::ControlPointChangePosition);
controlPoints[j-2]->setPos(spl.GetP2());
controlPoints[j-1]->setPos(spl.GetP3());
connect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSplinePath::ControlPointChangePosition);
connect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this,
&VModelingSplinePath::ControlPointChangePosition);
}
}

View File

@ -1,183 +0,0 @@
/************************************************************************
**
** @file vmodelingsplinepath.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGSPLINEPATH_H
#define VMODELINGSPLINEPATH_H
#include "vmodelingtool.h"
#include <QGraphicsPathItem>
#include "../../dialogs/dialogsplinepath.h"
#include "../../widgets/vcontrolpointspline.h"
/**
* @brief The VModelingSplinePath class
*/
class VModelingSplinePath:public VModelingTool, public QGraphicsPathItem
{
Q_OBJECT
public:
/**
* @brief VModelingSplinePath
* @param doc dom document container
* @param data
* @param id
* @param typeCreation
* @param parent
*/
VModelingSplinePath(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation,
QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingSplinePath* Create(QSharedPointer<DialogSplinePath> &dialog, VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param path
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingSplinePath* Create(const qint64 _id, const VSplinePath &path, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation);
/**
* @brief TagName
*/
static const QString TagName;
/**
* @brief ToolType
*/
static const QString ToolType;
signals:
/**
* @brief RefreshLine
* @param indexSpline
* @param pos
* @param controlPoint
* @param splinePoint
*/
void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, const QPointF &controlPoint,
const QPointF &splinePoint);
/**
* @brief setEnabledPoint
* @param enable
*/
void setEnabledPoint(bool enable);
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
/**
* @brief ControlPointChangePosition
* @param indexSpline
* @param position
* @param pos
*/
void ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &pos);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
/**
* @brief mouseReleaseEvent
* @param event
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent
* @param event
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent
* @param event
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens();
private:
/**
* @brief dialogSplinePath
*/
QSharedPointer<DialogSplinePath> dialogSplinePath;
/**
* @brief controlPoints
*/
QVector<VControlPointSpline *> controlPoints;
/**
* @brief RefreshGeometry
*/
void RefreshGeometry();
/**
* @brief AddPathPoint
* @param domElement
* @param splPoint
*/
void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint);
/**
* @brief UpdatePathPoint
* @param node
* @param path
*/
void UpdatePathPoint(QDomNode& node, VSplinePath &path);
/**
* @brief CorectControlPoints
* @param spl
* @param splPath
* @param indexSpline
*/
void CorectControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline);
};
#endif // VMODELINGSPLINEPATH_H

View File

@ -1,72 +0,0 @@
/************************************************************************
**
** @file vmodelingtool.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingtool.h"
#include <QDebug>
VModelingTool::VModelingTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent)
:VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false), ignoreFullUpdate(false)
{
_referens = 0;
}
void VModelingTool::AddToModeling(const QDomElement &domElement)
{
QDomElement modelingElement;
bool ok = doc->GetActivModelingElement(modelingElement);
if (ok)
{
modelingElement.appendChild(domElement);
}
else
{
qCritical()<<"Can't find tag Modeling"<< Q_FUNC_INFO;
}
emit toolhaveChange();
}
void VModelingTool::decrementReferens()
{
if (_referens > 0)
{
--_referens;
}
if (_referens <= 0)
{
RemoveReferens();
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
QDomNode element = domElement.parentNode();
if (element.isNull() == false)
{
element.removeChild(domElement);
}
}
}
}

View File

@ -1,157 +0,0 @@
/************************************************************************
**
** @file vmodelingtool.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGTOOL_H
#define VMODELINGTOOL_H
#include "../vabstracttool.h"
#include <QGraphicsSceneContextMenuEvent>
#include <QMenu>
/**
* @brief The VModelingTool class
*/
class VModelingTool: public VAbstractTool
{
Q_OBJECT
public:
/**
* @brief VModelingTool
* @param doc dom document container
* @param data
* @param id
* @param parent
*/
VModelingTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0);
virtual ~VModelingTool(){}
/**
* @brief setDialog
*/
virtual void setDialog(){}
/**
* @brief ignoreContextMenu
* @param enable
*/
inline void ignoreContextMenu(bool enable) {ignoreContextMenuEvent = enable;}
public slots:
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result)=0;
protected:
/**
* @brief ignoreContextMenuEvent
*/
bool ignoreContextMenuEvent;
/**
* @brief ignoreFullUpdate
*/
bool ignoreFullUpdate;
/**
* @brief AddToModeling
* @param domElement
*/
void AddToModeling(const QDomElement &domElement);
/**
* @brief decrementReferens
*/
virtual void decrementReferens();
template <typename Dialog, typename Tool>
/**
* @brief ContextMenu
* @param dialog
* @param tool
* @param event
* @param showRemove
*/
void ContextMenu(QSharedPointer<Dialog> &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event,
bool showRemove = true)
{
if (ignoreContextMenuEvent == false)
{
QMenu menu;
QAction *actionOption = menu.addAction(tr("Option"));
QAction *actionRemove = 0;
if (showRemove)
{
actionRemove = menu.addAction(tr("Delete"));
if (_referens > 1)
{
actionRemove->setEnabled(false);
}
else
{
actionRemove->setEnabled(true);
}
}
QAction *selectedAction = menu.exec(event->screenPos());
if (selectedAction == actionOption)
{
dialog = QSharedPointer<Dialog>(new Dialog(getData()));
connect(qobject_cast< VMainGraphicsScene * >(tool->scene()),
&VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject);
connect(dialog.data(), &Dialog::DialogClosed, tool, &Tool::FullUpdateFromGui);
if (ignoreFullUpdate == false)
{
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
}
tool->setDialog();
dialog->show();
}
if (showRemove)
{
if (selectedAction == actionRemove)
{
//deincrement referens
RemoveReferens();
//remove form xml file
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
QDomElement element;
bool ok = doc->GetActivCalculationElement(element);
if (ok)
{
element.removeChild(domElement);
//update xml file
emit FullUpdateTree();
//remove form scene
emit RemoveTool(tool);
}
}
}
}
}
}
};
#endif // VMODELINGTOOL_H

View File

@ -1,170 +0,0 @@
/************************************************************************
**
** @file vmodelingtriangle.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 "vmodelingtriangle.h"
#include "../drawTools/vtooltriangle.h"
const QString VModelingTriangle::ToolType = QStringLiteral("triangle");
VModelingTriangle::VModelingTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &axisP1Id,
const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId,
const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VModelingPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId),
secondPointId(secondPointId), dialogTriangle(QSharedPointer<DialogTriangle>())
{
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingTriangle::setDialog()
{
Q_ASSERT(dialogTriangle.isNull() == false);
VPointF p = VAbstractTool::data.GetPoint(id);
dialogTriangle->setAxisP1Id(axisP1Id, id);
dialogTriangle->setAxisP2Id(axisP2Id, id);
dialogTriangle->setFirstPointId(firstPointId, id);
dialogTriangle->setSecondPointId(secondPointId, id);
dialogTriangle->setPointName(p.name());
}
VModelingTriangle *VModelingTriangle::Create(QSharedPointer<DialogTriangle> &dialog, VDomDocument *doc,
VContainer *data)
{
qint64 axisP1Id = dialog->getAxisP1Id();
qint64 axisP2Id = dialog->getAxisP2Id();
qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId();
QString pointName = dialog->getPointName();
return Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, doc, data, Document::FullParse,
Tool::FromGui);
}
VModelingTriangle *VModelingTriangle::Create(const qint64 _id, const QString &pointName, const qint64 &axisP1Id,
const qint64 &axisP2Id, const qint64 &firstPointId,
const qint64 &secondPointId, const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
VModelingTriangle *tool = 0;
VPointF axisP1 = data->GetPoint(axisP1Id);
VPointF axisP2 = data->GetPoint(axisP2Id);
VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId);
QPointF point = VToolTriangle::FindPoint(axisP1.toQPointF(), axisP2.toQPointF(), firstPoint.toQPointF(),
secondPoint.toQPointF());
qint64 id = _id;
if (typeCreation == Tool::FromGui)
{
id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my));
}
else
{
data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
if (parse == Document::FullParse)
{
tool = new VModelingTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId, secondPointId, typeCreation);
doc->AddTool(id, tool);
doc->IncrementReferens(axisP1Id);
doc->IncrementReferens(axisP2Id);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
}
return tool;
}
void VModelingTriangle::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
axisP1Id = domElement.attribute(AttrAxisP1, "").toLongLong();
axisP2Id = domElement.attribute(AttrAxisP2, "").toLongLong();
firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong();
}
VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPoint(id));
}
void VModelingTriangle::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogTriangle->getPointName());
domElement.setAttribute(AttrAxisP1, QString().setNum(dialogTriangle->getAxisP1Id()));
domElement.setAttribute(AttrAxisP2, QString().setNum(dialogTriangle->getAxisP2Id()));
domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogTriangle->getFirstPointId()));
domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogTriangle->getSecondPointId()));
emit FullUpdateTree();
}
}
dialogTriangle.clear();
}
void VModelingTriangle::RemoveReferens()
{
doc->DecrementReferens(axisP1Id);
doc->DecrementReferens(axisP2Id);
doc->DecrementReferens(firstPointId);
doc->DecrementReferens(secondPointId);
}
void VModelingTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogTriangle, this, event);
}
void VModelingTriangle::AddToFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrAxisP1, axisP1Id);
AddAttribute(domElement, AttrAxisP2, axisP2Id);
AddAttribute(domElement, AttrFirstPoint, firstPointId);
AddAttribute(domElement, AttrSecondPoint, secondPointId);
AddToModeling(domElement);
}

View File

@ -1,142 +0,0 @@
/************************************************************************
**
** @file vmodelingtriangle.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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) 2013 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 VMODELINGTRIANGLE_H
#define VMODELINGTRIANGLE_H
#include "vmodelingpoint.h"
#include "../drawTools/vtooltriangle.h"
#include "../../dialogs/dialogtriangle.h"
/**
* @brief The VModelingTriangle class
*/
class VModelingTriangle : public VModelingPoint
{
Q_OBJECT
public:
/**
* @brief VModelingTriangle
* @param doc dom document container
* @param data
* @param id
* @param axisP1Id
* @param axisP2Id
* @param firstPointId
* @param secondPointId
* @param typeCreation
* @param parent
*/
VModelingTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &axisP1Id,
const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId,
const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param doc dom document container
* @param data
* @return
*/
static VModelingTriangle* Create(QSharedPointer<DialogTriangle> &dialog, VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param pointName
* @param axisP1Id
* @param axisP2Id
* @param firstPointId
* @param secondPointId
* @param mx
* @param my
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
* @return
*/
static VModelingTriangle* Create(const qint64 _id, const QString &pointName, const qint64 &axisP1Id,
const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId,
const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief RemoveReferens
*/
virtual void RemoveReferens();
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
private:
Q_DISABLE_COPY(VModelingTriangle)
/**
* @brief axisP1Id
*/
qint64 axisP1Id;
/**
* @brief axisP2Id
*/
qint64 axisP2Id;
/**
* @brief firstPointId
*/
qint64 firstPointId;
/**
* @brief secondPointId
*/
qint64 secondPointId;
/**
* @brief dialogTriangle
*/
QSharedPointer<DialogTriangle> dialogTriangle;
};
#endif // VMODELINGTRIANGLE_H

View File

@ -30,13 +30,9 @@
#include <QDebug>
const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject");
const QString VAbstractNode::AttrTypeObject = QStringLiteral("typeObject");
const QString VAbstractNode::TypeObjectCalculation = QStringLiteral("Calculation");
const QString VAbstractNode::TypeObjectModeling = QStringLiteral("Modeling");
VAbstractNode::VAbstractNode(VDomDocument *doc, VContainer *data, qint64 id, qint64 idNode, Draw::Draws typeobject,
QObject *parent)
: VAbstractTool(doc, data, id, parent), idNode(idNode), typeobject(typeobject)
VAbstractNode::VAbstractNode(VDomDocument *doc, VContainer *data, qint64 id, qint64 idNode, QObject *parent)
: VAbstractTool(doc, data, id, parent), idNode(idNode)
{
_referens = 0;
}

View File

@ -44,37 +44,19 @@ public:
* @param data
* @param id
* @param idNode
* @param typeobject
* @param parent
*/
VAbstractNode(VDomDocument *doc, VContainer *data, qint64 id, qint64 idNode,
Draw::Draws typeobject, QObject *parent = 0 );
VAbstractNode(VDomDocument *doc, VContainer *data, qint64 id, qint64 idNode, QObject *parent = 0 );
virtual ~VAbstractNode() {}
/**
* @brief AttrIdObject
*/
static const QString AttrIdObject;
/**
* @brief AttrTypeObject
*/
static const QString AttrTypeObject;
/**
* @brief TypeObjectCalculation
*/
static const QString TypeObjectCalculation;
/**
* @brief TypeObjectModeling
*/
static const QString TypeObjectModeling;
protected:
/**
* @brief idNode
*/
qint64 idNode;
/**
* @brief typeobject
*/
Draw::Draws typeobject;
/**
* @brief AddToModeling
* @param domElement

View File

@ -33,9 +33,9 @@
const QString VNodeArc::TagName = QStringLiteral("arc");
const QString VNodeArc::ToolType = QStringLiteral("modeling");
VNodeArc::VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, Draw::Draws typeobject,
const Tool::Sources &typeCreation, QGraphicsItem * parent)
:VAbstractNode(doc, data, id, idArc, typeobject), QGraphicsPathItem(parent)
VNodeArc::VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, const Tool::Sources &typeCreation,
QGraphicsItem * parent)
:VAbstractNode(doc, data, id, idArc), QGraphicsPathItem(parent)
{
RefreshGeometry();
this->setPen(QPen(baseColor, widthHairLine));
@ -48,12 +48,12 @@ VNodeArc::VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc,
}
}
void VNodeArc::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, const Draw::Draws &typeobject,
const Document::Documents &parse, const Tool::Sources &typeCreation)
void VNodeArc::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
if (parse == Document::FullParse)
{
VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeobject, typeCreation);
VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeCreation);
Q_ASSERT(arc != 0);
doc->AddTool(id, arc);
doc->IncrementReferens(idArc);
@ -76,14 +76,6 @@ void VNodeArc::AddToFile()
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrIdObject, idNode);
if (typeobject == Draw::Calculation)
{
AddAttribute(domElement, AttrTypeObject, TypeObjectCalculation);
}
else
{
AddAttribute(domElement, AttrTypeObject, ToolType );
}
AddToModeling(domElement);
}
@ -111,7 +103,7 @@ void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void VNodeArc::RefreshGeometry()
{
VArc arc = VAbstractTool::data.GetArcModeling(id);
VArc arc = VAbstractTool::data.GetArc(id);
QPainterPath path;
path.addPath(arc.GetPath());
path.setFillRule( Qt::WindingFill );

Some files were not shown because too many files have changed in this diff Show More