diff --git a/Valentina.pro b/Valentina.pro
index 496310cf8..fb54f3f3c 100644
--- a/Valentina.pro
+++ b/Valentina.pro
@@ -126,11 +126,11 @@ pixmaps.path = $$DATADIR/pixmaps/
pixmaps.files += dist/$${TARGET}.png
INSTALL_TRANSLATIONS += share/translations/valentina_ru.qm \
share/translations/valentina_uk.qm \
- share/translations/valentina_de.qm \
+ share/translations/valentina_de.qm
translations.path = $$DATADIR/$${TARGET}/translations/
translations.files = $$INSTALL_TRANSLATIONS
INSTALLS += target \
desktop \
pixmaps \
translations
-}
+}
diff --git a/share/resources/cursor.qrc b/share/resources/cursor.qrc
index 0af6dcf3b..4e9cd2b99 100644
--- a/share/resources/cursor.qrc
+++ b/share/resources/cursor.qrc
@@ -17,5 +17,6 @@
cursor/pointofintersect_cursor.png
cursor/spline_cut_point_cursor.png
cursor/splinepath_cut_point_cursor.png
+ cursor/union_cursor.png
diff --git a/share/resources/cursor/union_cursor.png b/share/resources/cursor/union_cursor.png
new file mode 100644
index 000000000..687d2ca59
Binary files /dev/null and b/share/resources/cursor/union_cursor.png differ
diff --git a/share/resources/icon.qrc b/share/resources/icon.qrc
index 85c2c0ddf..8ba3c5058 100644
--- a/share/resources/icon.qrc
+++ b/share/resources/icon.qrc
@@ -39,5 +39,6 @@
icon/32x32/point_of_intersection.png
icon/32x32/spline_cut_point.png
icon/32x32/splinePath_cut_point.png
+ icon/32x32/union.png
diff --git a/share/resources/icon/32x32/union.png b/share/resources/icon/32x32/union.png
new file mode 100644
index 000000000..5c8ad9c88
Binary files /dev/null and b/share/resources/icon/32x32/union.png differ
diff --git a/src/container/container.pri b/src/container/container.pri
index be62d71f1..b7f46dfd6 100644
--- a/src/container/container.pri
+++ b/src/container/container.pri
@@ -1,12 +1,10 @@
SOURCES += \
- src/container/vpointf.cpp \
src/container/vincrementtablerow.cpp \
src/container/vcontainer.cpp \
src/container/calculator.cpp \
src/container/vstandarttablerow.cpp
HEADERS += \
- src/container/vpointf.h \
src/container/vincrementtablerow.h \
src/container/vcontainer.h \
src/container/calculator.h \
diff --git a/src/container/vcontainer.cpp b/src/container/vcontainer.cpp
index 1e3f186a9..f21c26977 100644
--- a/src/container/vcontainer.cpp
+++ b/src/container/vcontainer.cpp
@@ -27,18 +27,17 @@
*************************************************************************/
#include "vcontainer.h"
-#include "../exception/vexceptionbadid.h"
#include
+#include
qint64 VContainer::_id = 0;
VContainer::VContainer()
- :base(QHash()), points(QHash()),
+ :base(QHash()), gObjects(QHash()),
standartTable(QHash()), incrementTable(QHash()),
- lengthLines(QHash()), lineAngles(QHash()), splines(QHash()),
- lengthSplines(QHash()), arcs(QHash()), lengthArcs(QHash()),
- splinePaths(QHash()), details(QHash())
+ lengthLines(QHash()), lineAngles(QHash()), lengthSplines(QHash()),
+ lengthArcs(QHash()), details(QHash())
{
SetSize(500);
SetGrowth(1760);
@@ -52,38 +51,74 @@ VContainer &VContainer::operator =(const VContainer &data)
}
VContainer::VContainer(const VContainer &data)
- :base(QHash()), points(QHash()),
- standartTable(QHash()), incrementTable(QHash()),
- lengthLines(QHash()), lineAngles(QHash()), splines(QHash()),
- lengthSplines(QHash()), arcs(QHash()), lengthArcs(QHash()),
- splinePaths(QHash()), details(QHash())
+ :base(QHash()), gObjects(QHash()),
+ standartTable(QHash()), incrementTable(QHash()),
+ lengthLines(QHash()), lineAngles(QHash()), lengthSplines(QHash()),
+ lengthArcs(QHash()), details(QHash())
{
setData(data);
}
+VContainer::~VContainer()
+{
+ qDeleteAll(gObjects);
+ gObjects.clear();
+}
+
void VContainer::setData(const VContainer &data)
{
base = *data.DataBase();
- points = *data.DataPoints();
+
+ qDeleteAll(gObjects);
+ gObjects.clear();
+ const QHash *obj = data.DataGObjects();
+ Q_ASSERT(obj != 0);
+ QHashIterator i(*obj);
+ while (i.hasNext())
+ {
+ i.next();
+ switch (i.value()->getType())
+ {
+ case (GObject::Arc):
+ {
+ CopyGObject(data, i.key());
+ break;
+ }
+ case (GObject::Point):
+ {
+ CopyGObject(data, i.key());
+ break;
+ }
+ case (GObject::Spline):
+ {
+ CopyGObject(data, i.key());
+ break;
+ }
+ case (GObject::SplinePath):
+ {
+ CopyGObject(data, i.key());
+ break;
+ }
+ default:
+ qWarning()<<"Don't know how copy this type.";
+ }
+ }
standartTable = *data.DataStandartTable();
incrementTable = *data.DataIncrementTable();
lengthLines = *data.DataLengthLines();
lineAngles = *data.DataLineAngles();
- splines = *data.DataSplines();
lengthSplines = *data.DataLengthSplines();
- arcs = *data.DataArcs();
lengthArcs = *data.DataLengthArcs();
- splinePaths = *data.DataSplinePaths();
details = *data.DataDetails();
}
-VPointF VContainer::GetPoint(qint64 id) const
+const VGObject *VContainer::GetGObject(qint64 id)const
{
- return GetObject(points, id);
+ return GetObject(gObjects, id);
}
template
-val VContainer::GetObject(const QHash &obj, key id)
+const val VContainer::GetObject(const QHash &obj, key id) const
{
if (obj.contains(id))
{
@@ -95,70 +130,75 @@ val VContainer::GetObject(const QHash &obj, key id)
}
}
-VStandartTableRow VContainer::GetStandartTableCell(const QString &name) const
+template
+val VContainer::GetVariable(const QHash &obj, key id) const
{
- Q_ASSERT(name.isEmpty()==false);
- return GetObject(standartTable, name);
+ if (obj.contains(id))
+ {
+ return obj.value(id);
+ }
+ else
+ {
+ throw VExceptionBadId(tr("Can't find object"), id);
+ }
}
-VIncrementTableRow VContainer::GetIncrementTableRow(const QString& name) const
+const VStandartTableRow VContainer::GetStandartTableCell(const QString &name) const
{
Q_ASSERT(name.isEmpty()==false);
- return GetObject(incrementTable, name);
+ return GetVariable(standartTable, name);
+}
+
+const VIncrementTableRow VContainer::GetIncrementTableRow(const QString& name) const
+{
+ Q_ASSERT(name.isEmpty()==false);
+ return GetVariable(incrementTable, name);
}
qreal VContainer::GetLine(const QString &name) const
{
Q_ASSERT(name.isEmpty()==false);
- return GetObject(lengthLines, name);
+ return GetVariable(lengthLines, name);
}
qreal VContainer::GetLengthArc(const QString &name) const
{
Q_ASSERT(name.isEmpty()==false);
- return GetObject(lengthArcs, name);
+ return GetVariable(lengthArcs, name);
}
qreal VContainer::GetLengthSpline(const QString &name) const
{
Q_ASSERT(name.isEmpty()==false);
- return GetObject(lengthSplines, name);
+ return GetVariable(lengthSplines, name);
}
qreal VContainer::GetLineAngle(const QString &name) const
{
Q_ASSERT(name.isEmpty()==false);
- return GetObject(lineAngles, name);
+ return GetVariable(lineAngles, name);
}
-VSpline VContainer::GetSpline(qint64 id) const
+const VDetail VContainer::GetDetail(qint64 id) const
{
- return GetObject(splines, id);
+ return GetVariable(details, id);
}
-VArc VContainer::GetArc(qint64 id) const
+qint64 VContainer::AddGObject(VGObject *obj)
{
- return GetObject(arcs, id);
+ return AddObject(gObjects, obj);
}
-VSplinePath VContainer::GetSplinePath(qint64 id) const
+qint64 VContainer::AddDetail(VDetail detail)
{
- return GetObject(splinePaths, id);
+ qint64 id = getNextId();
+ details[id] = detail;
+ return id;
}
-VDetail VContainer::GetDetail(qint64 id) const
+void VContainer::AddIncrementTableRow(const QString &name, VIncrementTableRow row)
{
- return GetObject(details, id);
-}
-
-qint64 VContainer::AddPoint(const VPointF &point)
-{
- return AddObject(points, point);
-}
-
-qint64 VContainer::AddDetail(const VDetail &detail)
-{
- return AddObject(details, detail);
+ incrementTable[name] = row;
}
qint64 VContainer::getNextId()
@@ -182,96 +222,95 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
QVector pointsEkv;
for (ptrdiff_t i = 0; i< detail.CountNode(); ++i)
{
- switch (detail[i].getTypeTool())
+ switch (detail.at(i).getTypeTool())
{
case (Tool::NodePoint):
{
- VPointF point = GetPoint(detail[i].getId());
- points.append(point.toQPointF());
+ const VPointF *point = GeometricObject(detail.at(i).getId());
+ points.append(point->toQPointF());
if (detail.getSupplement() == true)
{
- QPointF pEkv = point.toQPointF();
- pEkv.setX(pEkv.x()+detail[i].getMx());
- pEkv.setY(pEkv.y()+detail[i].getMy());
+ QPointF pEkv = point->toQPointF();
+ pEkv.setX(pEkv.x()+detail.at(i).getMx());
+ pEkv.setY(pEkv.y()+detail.at(i).getMy());
pointsEkv.append(pEkv);
}
}
break;
case (Tool::NodeArc):
{
- VArc arc = GetArc(detail[i].getId());
- qreal len1 = GetLengthContour(points, arc.GetPoints());
- qreal lenReverse = GetLengthContour(points, GetReversePoint(arc.GetPoints()));
+ const VArc *arc = GeometricObject(detail.at(i).getId());
+ qreal len1 = GetLengthContour(points, arc->GetPoints());
+ qreal lenReverse = GetLengthContour(points, GetReversePoint(arc->GetPoints()));
if (len1 <= lenReverse)
{
- points << arc.GetPoints();
+ points << arc->GetPoints();
if (detail.getSupplement() == true)
{
- pointsEkv << biasPoints(arc.GetPoints(), detail[i].getMx(), detail[i].getMy());
+ pointsEkv << biasPoints(arc->GetPoints(), detail.at(i).getMx(), detail.at(i).getMy());
}
}
else
{
- points << GetReversePoint(arc.GetPoints());
+ points << GetReversePoint(arc->GetPoints());
if (detail.getSupplement() == true)
{
- pointsEkv << biasPoints(GetReversePoint(arc.GetPoints()), detail[i].getMx(), detail[i].getMy());
+ pointsEkv << biasPoints(GetReversePoint(arc->GetPoints()), detail.at(i).getMx(),
+ detail.at(i).getMy());
}
}
}
break;
case (Tool::NodeSpline):
{
- VSpline spline = GetSpline(detail[i].getId());
- qreal len1 = GetLengthContour(points, spline.GetPoints());
- qreal lenReverse = GetLengthContour(points, GetReversePoint(spline.GetPoints()));
+ const VSpline *spline = GeometricObject(detail.at(i).getId());
+ qreal len1 = GetLengthContour(points, spline->GetPoints());
+ qreal lenReverse = GetLengthContour(points, GetReversePoint(spline->GetPoints()));
if (len1 <= lenReverse)
{
- points << spline.GetPoints();
+ points << spline->GetPoints();
if (detail.getSupplement() == true)
{
- pointsEkv << biasPoints(spline.GetPoints(), detail[i].getMx(), detail[i].getMy());
+ pointsEkv << biasPoints(spline->GetPoints(), detail.at(i).getMx(), detail.at(i).getMy());
}
}
else
{
- points << GetReversePoint(spline.GetPoints());
+ points << GetReversePoint(spline->GetPoints());
if (detail.getSupplement() == true)
{
- pointsEkv << biasPoints(GetReversePoint(spline.GetPoints()), detail[i].getMx(),
- detail[i].getMy());
+ pointsEkv << biasPoints(GetReversePoint(spline->GetPoints()), detail.at(i).getMx(),
+ detail.at(i).getMy());
}
}
}
break;
case (Tool::NodeSplinePath):
{
- VSplinePath splinePath = GetSplinePath(detail[i].getId());
- qreal len1 = GetLengthContour(points, splinePath.GetPathPoints());
- qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath.GetPathPoints()));
+ const VSplinePath *splinePath = GeometricObject(detail.at(i).getId());
+ qreal len1 = GetLengthContour(points, splinePath->GetPathPoints());
+ qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath->GetPathPoints()));
if (len1 <= lenReverse)
{
- points << splinePath.GetPathPoints();
+ points << splinePath->GetPathPoints();
if (detail.getSupplement() == true)
{
- pointsEkv << biasPoints(splinePath.GetPathPoints(), detail[i].getMx(), detail[i].getMy());
+ pointsEkv << biasPoints(splinePath->GetPathPoints(), detail.at(i).getMx(), detail.at(i).getMy());
}
}
else
{
- points << GetReversePoint(splinePath.GetPathPoints());
+ points << GetReversePoint(splinePath->GetPathPoints());
if (detail.getSupplement() == true)
{
- pointsEkv << biasPoints(GetReversePoint(splinePath.GetPathPoints()), detail[i].getMx(),
- detail[i].getMy());
+ pointsEkv << biasPoints(GetReversePoint(splinePath->GetPathPoints()), detail.at(i).getMx(),
+ detail.at(i).getMy());
}
}
}
break;
- case (Tool::SplineTool):
- break;//Nothing to do, just ignore.
default:
- qWarning()<<"Get wrong tool type. Ignore."< points, const Detail::Equi
continue;
}
else if (i == points.size()-1 && eqv == Detail::OpenEquidistant)
- {//остання точка, polyline doesn't closed
+ {//last point, polyline doesn't closed
ekvPoints.append(SingleParallelPoint(QLineF(points[points.size()-1], points[points.size()-2]), -90,
width));
continue;
@@ -508,18 +547,25 @@ QVector VContainer::CheckLoops(const QVector &points) const
void VContainer::PrepareDetails(QVector &list) const
{
- QHashIterator iDetail(details);
- while (iDetail.hasNext())
+ QHashIterator idetail(details);
+ while (idetail.hasNext())
{
- iDetail.next();
- list.append(new VItem(ContourPath(iDetail.key()), list.size()));
+ idetail.next();
+ list.append(new VItem(ContourPath(idetail.key()), list.size()));
}
}
template
-void VContainer::UpdateObject(QHash &obj, const qint64 &id, const val& point)
+void VContainer::UpdateObject(QHash &obj, const qint64 &id, val point)
{
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
+ Q_ASSERT(point != 0);
+ point->setId(id);
+ if (gObjects.contains(id))
+ {
+ delete gObjects.value(id);
+ gObjects.remove(id);
+ }
obj[id] = point;
UpdateId(id);
}
@@ -532,7 +578,8 @@ void VContainer::AddLengthSpline(const QString &name, const qreal &value)
void VContainer::AddLengthArc(const qint64 &id)
{
- AddLengthArc(GetArc(id).name(), toMM(GetArc(id).GetLength()));
+ const VArc * arc = GeometricObject(id);
+ AddLengthArc(arc->name(), toMM(arc->GetLength()));
}
void VContainer::AddLengthArc(const QString &name, const qreal &value)
@@ -574,16 +621,33 @@ void VContainer::Clear()
lengthArcs.clear();
lineAngles.clear();
details.clear();
- ClearObject();
- CreateManTableIGroup ();
+ ClearGObjects();
}
-void VContainer::ClearObject()
+void VContainer::ClearGObjects()
{
- points.clear();
- splines.clear();
- arcs.clear();
- splinePaths.clear();
+ if (gObjects.size()>0)
+ {
+ qDeleteAll(gObjects);
+ }
+ gObjects.clear();
+}
+
+void VContainer::ClearCalculationGObjects()
+{
+ if (gObjects.size()>0)
+ {
+ QHashIterator i(gObjects);
+ while (i.hasNext())
+ {
+ i.next();
+ if (i.value()->getMode() == Draw::Calculation)
+ {
+ delete i.value();
+ gObjects.remove(i.key());
+ }
+ }
+ }
}
qreal VContainer::FindVar(const QString &name, bool *ok)const
@@ -631,75 +695,49 @@ qreal VContainer::FindVar(const QString &name, bool *ok)const
void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId)
{
QString nameLine = GetNameLine(firstPointId, secondPointId);
- VPointF first = GetPoint(firstPointId);
- VPointF second = GetPoint(secondPointId);
- AddLengthLine(nameLine, toMM(QLineF(first.toQPointF(), second.toQPointF()).length()));
+ const VPointF *first = GeometricObject(firstPointId);
+ const VPointF *second = GeometricObject(secondPointId);
+ AddLengthLine(nameLine, toMM(QLineF(first->toQPointF(), second->toQPointF()).length()));
nameLine = GetNameLineAngle(firstPointId, secondPointId);
- AddLineAngle(nameLine, QLineF(first.toQPointF(), second.toQPointF()).angle());
-}
-
-qint64 VContainer::AddSpline(const VSpline &spl)
-{
- return AddObject(splines, spl);
-}
-
-qint64 VContainer::AddSplinePath(const VSplinePath &splPath)
-{
- return AddObject(splinePaths, splPath);
-}
-
-qint64 VContainer::AddArc(const VArc &arc)
-{
- return AddObject(arcs, arc);
+ AddLineAngle(nameLine, QLineF(first->toQPointF(), second->toQPointF()).angle());
}
template
-qint64 VContainer::AddObject(QHash &obj, const val& value)
+qint64 VContainer::AddObject(QHash &obj, val value)
{
+ Q_ASSERT(value != 0);
qint64 id = getNextId();
+ value->setId(id);
obj[id] = value;
return id;
}
QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const
{
- VPointF first = GetPoint(firstPoint);
- VPointF second = GetPoint(secondPoint);
+ const VPointF *first = GeometricObject(firstPoint);
+ const VPointF *second = GeometricObject(secondPoint);
- return QString("Line_%1_%2").arg(first.name(), second.name());
+ return QString("Line_%1_%2").arg(first->name(), second->name());
}
QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint) const
{
- VPointF first = GetPoint(firstPoint);
- VPointF second = GetPoint(secondPoint);
+ const VPointF *first = GeometricObject(firstPoint);
+ const VPointF *second = GeometricObject(secondPoint);
- return QString("AngleLine_%1_%2").arg(first.name(), second.name());
+ return QString("AngleLine_%1_%2").arg(first->name(), second->name());
}
-void VContainer::UpdatePoint(qint64 id, const VPointF &point)
+void VContainer::UpdateGObject(qint64 id, VGObject* obj)
{
- UpdateObject(points, id, point);
+ UpdateObject(gObjects, id, obj);
}
-void VContainer::UpdateDetail(qint64 id, const VDetail &detail)
+void VContainer::UpdateDetail(qint64 id, VDetail detail)
{
- UpdateObject(details, id, detail);
-}
-
-void VContainer::UpdateSpline(qint64 id, const VSpline &spl)
-{
- UpdateObject(splines, id, spl);
-}
-
-void VContainer::UpdateSplinePath(qint64 id, const VSplinePath &splPath)
-{
- UpdateObject(splinePaths, id, splPath);
-}
-
-void VContainer::UpdateArc(qint64 id, const VArc &arc)
-{
- UpdateObject(arcs, id, arc);
+ Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
+ details[id] = detail;
+ UpdateId(id);
}
void VContainer::AddLengthLine(const QString &name, const qreal &value)
@@ -710,7 +748,6 @@ void VContainer::AddLengthLine(const QString &name, const qreal &value)
void VContainer::CreateManTableIGroup ()
{
- AddStandartTableCell("Pkor", VStandartTableRow(84, 0, 3));
AddStandartTableCell("Pkor", VStandartTableRow(84, 0, 3));
AddStandartTableCell("Vtos", VStandartTableRow(1450, 2, 51));
AddStandartTableCell("Vtosh", VStandartTableRow(1506, 2, 54));
@@ -726,8 +763,6 @@ void VContainer::CreateManTableIGroup ()
AddStandartTableCell("SgI", VStandartTableRow(517, 18, 2));
AddStandartTableCell("SgII", VStandartTableRow(522, 19, 1));
AddStandartTableCell("SgIII", VStandartTableRow(500, 20, 0));
- AddStandartTableCell("St", VStandartTableRow(390, 20, 0));
- AddStandartTableCell("Sb", VStandartTableRow(492, 15, 5));
AddStandartTableCell("SbI", VStandartTableRow(482, 12, 6));
AddStandartTableCell("Obed", VStandartTableRow(566, 18, 6));
AddStandartTableCell("Ok", VStandartTableRow(386, 8, 8));
@@ -760,10 +795,17 @@ void VContainer::CreateManTableIGroup ()
AddStandartTableCell("dpzr", VStandartTableRow(121, 6, 0));
AddStandartTableCell("Ogol", VStandartTableRow(576, 4, 4));
AddStandartTableCell("Ssh1", VStandartTableRow(205, 5, 0));
- AddStandartTableCell("St", VStandartTableRow(410, 20, 0));
+
+ //TODO Posible duplicate. Need check.
+ //AddStandartTableCell("St", VStandartTableRow(410, 20, 0));
+ AddStandartTableCell("St", VStandartTableRow(390, 20, 0));
+
AddStandartTableCell("Drzap", VStandartTableRow(594, 3, 19));
AddStandartTableCell("DbII", VStandartTableRow(1020, 0, 44));
- AddStandartTableCell("Sb", VStandartTableRow(504, 15, 4));
+
+ //TODO Posible duplicate. Need check.
+ //AddStandartTableCell("Sb", VStandartTableRow(504, 15, 4));
+ AddStandartTableCell("Sb", VStandartTableRow(492, 15, 5));
}
QVector VContainer::GetReversePoint(const QVector &points) const
diff --git a/src/container/vcontainer.h b/src/container/vcontainer.h
index 8465a19ae..87f5ce1ab 100644
--- a/src/container/vcontainer.h
+++ b/src/container/vcontainer.h
@@ -35,6 +35,8 @@
#include "../geometry/vsplinepath.h"
#include "../geometry/vdetail.h"
#include "../widgets/vitem.h"
+#include "../geometry/vgobject.h"
+#include "../exception/vexceptionbadid.h"
/**
* @brief The VContainer class container of all variables.
@@ -58,29 +60,54 @@ public:
* @param data container
*/
VContainer(const VContainer &data);
+ ~VContainer();
+ template
+ void CopyGObject(const VContainer &data, const qint64 &id)
+ {
+ T *obj = new T(*data.GeometricObject(id));
+ Q_ASSERT(obj != 0);
+ UpdateGObject(id, obj);
+ }
/**
* @brief setData copy data from container
* @param data container
*/
void setData(const VContainer &data);
+ template
+ const T GeometricObject(qint64 id) const
+ {
+ VGObject *gObj = 0;
+ if (gObjects.contains(id))
+ {
+ gObj = gObjects.value(id);
+ }
+ else
+ {
+ throw VExceptionBadId(tr("Can't find object"), id);
+ }
+ T obj = dynamic_cast(gObj);
+ Q_ASSERT(obj != 0);
+ return obj;
+ }
+
/**
- * @brief GetPoint returns a point by id
+ * @brief GetGObject returns a point by id
* @param id id of point
* @return point
*/
- VPointF GetPoint(qint64 id) const;
+ const VGObject *GetGObject(qint64 id) const;
/**
* @brief GetStandartTableCell return standart table row by name
* @param name name of standart table row
* @return row of standart table
*/
- VStandartTableRow GetStandartTableCell(const QString& name) const;
+ const VStandartTableRow GetStandartTableCell(const QString& name) const;
/**
* @brief GetIncrementTableRow return increment table row by name
* @param name name of increment table row
* @return row of increment table
*/
- VIncrementTableRow GetIncrementTableRow(const QString& name) const;
+ const VIncrementTableRow GetIncrementTableRow(const QString& name) const;
/**
* @brief GetLine return length of line by name
* @param name name of line
@@ -105,30 +132,12 @@ public:
* @return angle in degree
*/
qreal GetLineAngle(const QString &name) const;
- /**
- * @brief GetSpline return spline by id
- * @param id id of spline
- * @return spline
- */
- VSpline GetSpline(qint64 id) const;
- /**
- * @brief GetArc return arc by id
- * @param id id of arc
- * @return arc
- */
- VArc GetArc(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 GetDetail return detail by id
* @param id id of detail
* @return detail
*/
- VDetail GetDetail(qint64 id) const;
+ const VDetail GetDetail(qint64 id) const;
/**
* @brief getId return current id
* @return current id
@@ -139,27 +148,26 @@ public:
* @param point new point
* @return return id of new point in container
*/
- qint64 AddPoint(const VPointF& point);
+ qint64 AddGObject(VGObject *obj);
/**
* @brief AddDetail add new detail to container
* @param detail new detail
* @return return id of new detail in container
*/
- qint64 AddDetail(const VDetail& detail);
+ qint64 AddDetail(VDetail detail);
/**
* @brief AddStandartTableCell add new row of standart table
* @param name name of row of standart table
* @param cell row of standart table
*/
- inline void AddStandartTableCell(const QString& name, const VStandartTableRow& cell)
+ inline void AddStandartTableCell(const QString& name, const VStandartTableRow &cell)
{standartTable[name] = cell;}
/**
* @brief AddIncrementTableRow add new row of increment table
* @param name name of new row of increment table
* @param row new row of increment table
*/
- inline void AddIncrementTableRow(const QString& name, const VIncrementTableRow &row)
- {incrementTable[name] = row;}
+ void AddIncrementTableRow(const QString& name, VIncrementTableRow row);
/**
* @brief AddLengthLine add length of line to container
* @param name name of line
@@ -196,30 +204,6 @@ public:
* @param mode mode of line
*/
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 AddSplinePath add spline path to container
- * @param splPath new spline path
- * @return id of spline path in container
- */
- qint64 AddSplinePath(const VSplinePath& splPath);
- /**
- * @brief AddArc add arc to container
- * @param arc new arc
- * @return id of arc in container in container
- */
- qint64 AddArc(const VArc& arc);
- /**
- * @brief AddArcModeling add arc modeling to container
- * @param arc new arc modeling
- * @return id of new arc modeling in container
- */
- qint64 AddArcModeling(const VArc& arc);
/**
* @brief GetNameLine return name of line
* @param firstPoint id of first point of line
@@ -239,50 +223,26 @@ public:
* @param id id of existing point
* @param point point
*/
- void UpdatePoint(qint64 id, const VPointF& point);
+ void UpdateGObject(qint64 id, VGObject* obj);
/**
* @brief UpdateDetail update detail by id
* @param id id of existing detail
* @param detail detail
*/
- void UpdateDetail(qint64 id, const VDetail& detail);
- /**
- * @brief UpdateSpline update spline by id
- * @param id if of existing spline
- * @param spl spline
- */
- void UpdateSpline(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 UpdateArc update arc by id
- * @param id id of existing arc
- * @param arc arc
- */
- void UpdateArc(qint64 id, const VArc& arc);
- /**
- * @brief UpdateArcModeling update arc modeling by id
- * @param id id of existing arc modeling
- * @param arc arc modeling
- */
- void UpdateArcModeling(qint64 id, const VArc& arc);
+ void UpdateDetail(qint64 id, VDetail detail);
/**
* @brief UpdateStandartTableCell update standart table row by name
* @param name name of row
* @param cell row of standart table
*/
- inline void UpdateStandartTableCell(const QString& name, const VStandartTableRow& cell)
+ inline void UpdateStandartTableCell(const QString& name, VStandartTableRow cell)
{standartTable[name] = cell;}
/**
* @brief UpdateIncrementTableRow update increment table row by name
* @param name name of row
* @param row row
*/
- inline void UpdateIncrementTableRow(const QString& name, const VIncrementTableRow& row)
+ inline void UpdateIncrementTableRow(const QString& name, VIncrementTableRow row)
{incrementTable[name] = row;}
/**
* @brief GetValueStandartTableCell return value of standart table row by name
@@ -303,7 +263,8 @@ public:
/**
* @brief ClearObject points, splines, arcs, spline paths will be cleared.
*/
- void ClearObject();
+ void ClearGObjects();
+ void ClearCalculationGObjects();
/**
* @brief ClearIncrementTable clear increment table
*/
@@ -368,20 +329,10 @@ public:
*/
inline void RemoveIncrementTableRow(const QString& name) {incrementTable.remove(name);}
/**
- * @brief data container with dataPoints return container of points
- * @return pointer on container of points
+ * @brief data container with datagObjects return container of gObjects
+ * @return pointer on container of gObjects
*/
- inline const QHash *DataPoints() const {return &points;}
- /**
- * @brief data container with dataSplines return container of splines
- * @return pointer on container of splines
- */
- inline const QHash *DataSplines() const {return &splines;}
- /**
- * @brief data container with dataArcs return container of arcs
- * @return pointer on container of arcs
- */
- inline const QHash *DataArcs() const {return &arcs;}
+ inline const QHash *DataGObjects() const {return &gObjects;}
/**
* @brief data container with dataBase return container of data
* @return pointer on container of base data
@@ -417,11 +368,6 @@ public:
* @return pointer on container of angles of line
*/
inline const QHash *DataLineAngles() const {return &lineAngles;}
- /**
- * @brief data container with dataSplinePaths return container of spline paths
- * @return pointer on container of spline paths
- */
- inline const QHash *DataSplinePaths() const {return &splinePaths;}
/**
* @brief data container with dataDetails return container of details
* @return pointer on container of details
@@ -488,6 +434,10 @@ public:
* @param list list of details
*/
void PrepareDetails(QVector & list) const;
+ /**
+ * @brief CreateManTableIGroup generate man standart table of measurements
+ */
+ void CreateManTableIGroup ();
private:
/**
* @brief _id current id. New object will have value +1. For full class equal 0.
@@ -498,9 +448,9 @@ private:
*/
QHash base;
/**
- * @brief points container of points
+ * @brief gObjects graphicals objects of pattern.
*/
- QHash points;
+ QHash gObjects;
/**
* @brief standartTable container of standart table rows
*/
@@ -517,34 +467,18 @@ private:
* @brief lineAngles container of angles of lines
*/
QHash lineAngles;
- /**
- * @brief splines container of splines
- */
- QHash splines;
/**
* @brief lengthSplines container of splines length
*/
QHash lengthSplines;
- /**
- * @brief arcs container of arcs
- */
- QHash arcs;
/**
* @brief lengthArcs container of arcs length
*/
QHash lengthArcs;
- /**
- * @brief splinePaths container of spline paths
- */
- QHash splinePaths;
/**
* @brief details container of details
*/
QHash details;
- /**
- * @brief CreateManTableIGroup generate man standart table of measurements
- */
- void CreateManTableIGroup ();
/**
* @brief GetReversePoint return revers container of points
* @param points container with points
@@ -565,7 +499,15 @@ private:
* @param id id of object
* @return Object
*/
- static val GetObject(const QHash &obj, key id);
+ const val GetObject(const QHash &obj, key id) const;
+ template
+ /**
+ * @brief GetObject return object from container
+ * @param obj container
+ * @param id id of object
+ * @return Object
+ */
+ val GetVariable(const QHash &obj, key id) const;
template
/**
* @brief UpdateObject update object in container
@@ -573,7 +515,7 @@ private:
* @param id id of existing object
* @param point object
*/
- static void UpdateObject(QHash &obj, const qint64 &id, const val& point);
+ void UpdateObject(QHash &obj, const qint64 &id, val point);
template
/**
* @brief AddObject add object to container
@@ -581,7 +523,7 @@ private:
* @param value object
* @return id of object in container
*/
- static qint64 AddObject(QHash &obj, const val& value);
+ static qint64 AddObject(QHash &obj, val value);
};
#endif // VCONTAINER_H
diff --git a/src/container/vstandarttablerow.cpp b/src/container/vstandarttablerow.cpp
index 668036804..e79809424 100644
--- a/src/container/vstandarttablerow.cpp
+++ b/src/container/vstandarttablerow.cpp
@@ -31,5 +31,6 @@
VStandartTableRow::VStandartTableRow()
:base(0), ksize(0), kgrowth(0), description(QString()){}
-VStandartTableRow::VStandartTableRow(qint32 base, qreal ksize, qreal kgrowth, QString description)
+VStandartTableRow::VStandartTableRow(const qint32 &base, const qreal &ksize, const qreal &kgrowth,
+ const QString &description)
:base(base), ksize(ksize), kgrowth(kgrowth), description(description){}
diff --git a/src/container/vstandarttablerow.h b/src/container/vstandarttablerow.h
index 4a56dad47..ffd973fd8 100644
--- a/src/container/vstandarttablerow.h
+++ b/src/container/vstandarttablerow.h
@@ -48,7 +48,9 @@ public:
* @param kgrowth increment in growths
* @param description description of increment
*/
- VStandartTableRow(qint32 base, qreal ksize, qreal kgrowth, QString description = QString());
+ VStandartTableRow(const qint32 &base, const qreal &ksize, const qreal &kgrowth,
+ const QString &description = QString());
+ ~VStandartTableRow(){}
/**
* @brief GetBase return value in base size and growth
* @return value
diff --git a/src/dialogs/dialogalongline.cpp b/src/dialogs/dialogalongline.cpp
index 89bb3b174..651343519 100644
--- a/src/dialogs/dialogalongline.cpp
+++ b/src/dialogs/dialogalongline.cpp
@@ -85,10 +85,10 @@ void DialogAlongLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
+ const VPointF *point = data->GeometricObject(id);
if (number == 0)
{
- qint32 index = ui->comboBoxFirstPoint->findText(point.name());
+ qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
@@ -99,7 +99,7 @@ void DialogAlongLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 1)
{
- qint32 index = ui->comboBoxSecondPoint->findText(point.name());
+ qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
diff --git a/src/dialogs/dialogarc.cpp b/src/dialogs/dialogarc.cpp
index b66326639..442aff59f 100644
--- a/src/dialogs/dialogarc.cpp
+++ b/src/dialogs/dialogarc.cpp
@@ -122,9 +122,9 @@ void DialogArc::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
+ const VPointF *point = data->GeometricObject(id);
- ChangeCurrentText(ui->comboBoxBasePoint, point.name());
+ ChangeCurrentText(ui->comboBoxBasePoint, point->name());
emit ToolTip("");
this->show();
}
diff --git a/src/dialogs/dialogbisector.cpp b/src/dialogs/dialogbisector.cpp
index f6c9c6058..8d3bdd51b 100644
--- a/src/dialogs/dialogbisector.cpp
+++ b/src/dialogs/dialogbisector.cpp
@@ -86,10 +86,10 @@ void DialogBisector::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
+ const VPointF *point = data->GeometricObject(id);
if (number == 0)
{
- qint32 index = ui->comboBoxFirstPoint->findText(point.name());
+ qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
@@ -100,7 +100,7 @@ void DialogBisector::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 1)
{
- qint32 index = ui->comboBoxSecondPoint->findText(point.name());
+ qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
@@ -111,7 +111,7 @@ void DialogBisector::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 2)
{
- qint32 index = ui->comboBoxThirdPoint->findText(point.name());
+ qint32 index = ui->comboBoxThirdPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxThirdPoint->setCurrentIndex(index);
diff --git a/src/dialogs/dialogcutspline.cpp b/src/dialogs/dialogcutspline.cpp
index be3f83513..f125429dd 100644
--- a/src/dialogs/dialogcutspline.cpp
+++ b/src/dialogs/dialogcutspline.cpp
@@ -97,8 +97,8 @@ void DialogCutSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Spline)
{
- VSpline spl = data->GetSpline(id);
- ChangeCurrentText(ui->comboBoxSpline, spl.name());
+ const VSpline *spl = data->GeometricObject(id);
+ ChangeCurrentText(ui->comboBoxSpline, spl->name());
emit ToolTip("");
this->show();
}
diff --git a/src/dialogs/dialogcutspline.h b/src/dialogs/dialogcutspline.h
index 85209cb24..a08f1c305 100644
--- a/src/dialogs/dialogcutspline.h
+++ b/src/dialogs/dialogcutspline.h
@@ -31,8 +31,9 @@
#include "dialogtool.h"
-namespace Ui {
-class DialogCutSpline;
+namespace Ui
+{
+ class DialogCutSpline;
}
class DialogCutSpline : public DialogTool
diff --git a/src/dialogs/dialogcutsplinepath.cpp b/src/dialogs/dialogcutsplinepath.cpp
index dff368e47..bb0694ea4 100644
--- a/src/dialogs/dialogcutsplinepath.cpp
+++ b/src/dialogs/dialogcutsplinepath.cpp
@@ -98,8 +98,8 @@ void DialogCutSplinePath::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::SplinePath)
{
- VSplinePath splPath = data->GetSplinePath(id);
- ChangeCurrentText(ui->comboBoxSplinePath, splPath.name());
+ const VSplinePath *splPath = data->GeometricObject(id);
+ ChangeCurrentText(ui->comboBoxSplinePath, splPath->name());
emit ToolTip("");
this->show();
}
diff --git a/src/dialogs/dialogcutsplinepath.h b/src/dialogs/dialogcutsplinepath.h
index 5069688f6..89342a917 100644
--- a/src/dialogs/dialogcutsplinepath.h
+++ b/src/dialogs/dialogcutsplinepath.h
@@ -31,8 +31,9 @@
#include "dialogtool.h"
-namespace Ui {
-class DialogCutSplinePath;
+namespace Ui
+{
+ class DialogCutSplinePath;
}
class DialogCutSplinePath : public DialogTool
diff --git a/src/dialogs/dialogdetail.cpp b/src/dialogs/dialogdetail.cpp
index 8a86c15ea..ff437406b 100644
--- a/src/dialogs/dialogdetail.cpp
+++ b/src/dialogs/dialogdetail.cpp
@@ -103,26 +103,26 @@ void DialogDetail::NewItem(qint64 id, const Tool::Tools &typeTool, const NodeDet
{
case (Tool::NodePoint):
{
- VPointF point = data->GetPoint(id);
- name = point.name();
+ const VPointF *point = data->GeometricObject(id);
+ name = point->name();
break;
}
case (Tool::NodeArc):
{
- VArc arc = data->GetArc(id);
- name = arc.name();
+ const VArc *arc = data->GeometricObject(id);
+ name = arc->name();
break;
}
case (Tool::NodeSpline):
{
- VSpline spl = data->GetSpline(id);
- name = spl.GetName();
+ const VSpline *spl = data->GeometricObject(id);
+ name = spl->name();
break;
}
case (Tool::NodeSplinePath):
{
- VSplinePath splPath = data->GetSplinePath(id);
- name = splPath.name();
+ const VSplinePath *splPath = data->GeometricObject(id);
+ name = splPath->name();
break;
}
default:
diff --git a/src/dialogs/dialogendline.cpp b/src/dialogs/dialogendline.cpp
index 8bb4f6592..f71ea2c77 100644
--- a/src/dialogs/dialogendline.cpp
+++ b/src/dialogs/dialogendline.cpp
@@ -97,8 +97,8 @@ void DialogEndLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
- ChangeCurrentText(ui->comboBoxBasePoint, point.name());
+ const VPointF *point = data->GeometricObject(id);
+ ChangeCurrentText(ui->comboBoxBasePoint, point->name());
emit ToolTip("");
this->show();
}
diff --git a/src/dialogs/dialogheight.cpp b/src/dialogs/dialogheight.cpp
index 8b4076411..184cf725d 100644
--- a/src/dialogs/dialogheight.cpp
+++ b/src/dialogs/dialogheight.cpp
@@ -90,21 +90,21 @@ void DialogHeight::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
+ const VPointF *point = data->GeometricObject(id);
switch (number)
{
case (0):
- ChangeCurrentText(ui->comboBoxBasePoint, point.name());
+ ChangeCurrentText(ui->comboBoxBasePoint, point->name());
number++;
emit ToolTip(tr("Select first point of line"));
break;
case (1):
- ChangeCurrentText(ui->comboBoxP1Line, point.name());
+ ChangeCurrentText(ui->comboBoxP1Line, point->name());
number++;
emit ToolTip(tr("Select second point of line"));
break;
case (2):
- ChangeCurrentText(ui->comboBoxP2Line, point.name());
+ ChangeCurrentText(ui->comboBoxP2Line, point->name());
number = 0;
emit ToolTip(tr(""));
if (isInitialized == false)
diff --git a/src/dialogs/dialoghistory.cpp b/src/dialogs/dialoghistory.cpp
index cef3eb755..3a8bc2d9c 100644
--- a/src/dialogs/dialoghistory.cpp
+++ b/src/dialogs/dialoghistory.cpp
@@ -31,6 +31,9 @@
#include "../geometry/varc.h"
#include "../geometry/vspline.h"
#include "../geometry/vsplinepath.h"
+#include "../tools/vabstracttool.h"
+#include "../tools/drawTools/vtoolcutspline.h"
+#include "../tools/drawTools/vtoolcutsplinepath.h"
#include
#include
@@ -172,120 +175,156 @@ QString DialogHistory::Record(const VToolRecord &tool)
case Tool::ArrowTool:
break;
case Tool::SinglePointTool:
- record = QString(tr("%1 - Base point")).arg(data->GetPoint(tool.getId()).name());
+ {
+ QString name = data->GeometricObject(tool.getId())->name();
+ record = QString(tr("%1 - Base point")).arg(name);
break;
+ }
case Tool::EndLineTool:
+ {
domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement())
{
- basePointId = domElement.attribute("basePoint", "").toLongLong();
+ basePointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrBasePoint, "0");
}
- record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(basePointId).name(),
- data->GetPoint(tool.getId()).name());
+ QString basePointIdName = data->GeometricObject(basePointId)->name();
+ QString toolIdName = data->GeometricObject(tool.getId())->name();
+ record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(basePointIdName, toolIdName);
break;
+ }
case Tool::LineTool:
+ {
domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement())
{
- firstPointId = domElement.attribute("firstPoint", "").toLongLong();
- secondPointId = domElement.attribute("secondPoint", "").toLongLong();
+ firstPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
+ secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
}
- record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(firstPointId).name(),
- data->GetPoint(secondPointId).name());
+ QString firstPointIdName = data->GeometricObject(firstPointId)->name();
+ QString secondPointIdName = data->GeometricObject(secondPointId)->name();
+ record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(firstPointIdName, secondPointIdName);
break;
+ }
case Tool::AlongLineTool:
+ {
domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement())
{
- basePointId = domElement.attribute("firstPoint", "").toLongLong();
- secondPointId = domElement.attribute("secondPoint", "").toLongLong();
+ basePointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
+ secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
}
- record = QString(tr("%3 - Point along line %1_%2")).arg(data->GetPoint(basePointId).name(),
- data->GetPoint(secondPointId).name(),
- data->GetPoint(tool.getId()).name());
+ QString basePointIdName = data->GeometricObject(basePointId)->name();
+ QString secondPointIdName = data->GeometricObject(secondPointId)->name();
+ QString toolIdName = data->GeometricObject(tool.getId())->name();
+ record = QString(tr("%3 - Point along line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName);
break;
+ }
case Tool::ShoulderPointTool:
- record = QString(tr("%1 - Point of shoulder")).arg(data->GetPoint(tool.getId()).name());
+ {
+ QString name = data->GeometricObject(tool.getId())->name();
+ record = QString(tr("%1 - Point of shoulder")).arg(name);
break;
+ }
case Tool::NormalTool:
+ {
domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement())
{
- basePointId = domElement.attribute("firstPoint", "").toLongLong();
- secondPointId = domElement.attribute("secondPoint", "").toLongLong();
+ basePointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
+ secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
}
- record = QString(tr("%3 - normal to line %1_%2")).arg(data->GetPoint(basePointId).name(),
- data->GetPoint(secondPointId).name(),
- data->GetPoint(tool.getId()).name());
+ QString basePointIdName = data->GeometricObject(basePointId)->name();
+ QString secondPointIdName = data->GeometricObject(secondPointId)->name();
+ QString toolIdName = data->GeometricObject(tool.getId())->name();
+ record = QString(tr("%3 - normal to line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName);
break;
+ }
case Tool::BisectorTool:
+ {
domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement())
{
- firstPointId = domElement.attribute("firstPoint", "").toLongLong();
- basePointId = domElement.attribute("secondPoint", "").toLongLong();
- thirdPointId = domElement.attribute("thirdPoint", "").toLongLong();
+ firstPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
+ secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
+ thirdPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrThirdPoint, "0");
}
- record = QString(tr("%4 - bisector of angle %1_%2_%3")).arg(data->GetPoint(firstPointId).name(),
- data->GetPoint(basePointId).name(),
- data->GetPoint(thirdPointId).name(),
- data->GetPoint(tool.getId()).name());
+ QString firstPointIdName = data->GeometricObject(firstPointId)->name();
+ QString basePointIdName = data->GeometricObject(basePointId)->name();
+ QString thirdPointIdName = data->GeometricObject(thirdPointId)->name();
+ QString toolIdName = data->GeometricObject(tool.getId())->name();
+ record = QString(tr("%4 - bisector of angle %1_%2_%3")).arg(firstPointIdName, basePointIdName,
+ thirdPointIdName, toolIdName);
break;
+ }
case Tool::LineIntersectTool:
+ {
domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement())
{
- p1Line1 = domElement.attribute("p1Line1", "").toLongLong();
- p2Line1 = domElement.attribute("p2Line1", "").toLongLong();
- p1Line2 = domElement.attribute("p1Line2", "").toLongLong();
- p2Line2 = domElement.attribute("p2Line2", "").toLongLong();
+ p1Line1 = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP1Line1, "0");
+ p2Line1 = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP2Line1, "0");
+ p1Line2 = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP1Line2, "0");
+ p2Line2 = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP2Line2, "0");
}
- record = QString(tr("%5 - intersection of lines %1_%2 and %3_%4")).arg(data->GetPoint(p1Line1).name(),
- data->GetPoint(p2Line1).name(),
- data->GetPoint(p1Line2).name(),
- data->GetPoint(p2Line2).name(),
- data->GetPoint(tool.getId()).name());
+ QString p1Line1Name = data->GeometricObject(p1Line1)->name();
+ QString p2Line1Name = data->GeometricObject(p2Line1)->name();
+ QString p1Line2Name = data->GeometricObject(p1Line2)->name();
+ QString p2Line2Name = data->GeometricObject(p2Line2)->name();
+ QString toolIdName = data->GeometricObject(tool.getId())->name();
+ record = QString(tr("%5 - intersection of lines %1_%2 and %3_%4")).arg(p1Line1Name, p2Line1Name,
+ p1Line2Name, p2Line2Name,
+ toolIdName);
break;
+ }
case Tool::SplineTool:
{
- VSpline spl = data->GetSpline(tool.getId());
- record = QString(tr("Curve %1_%2")).arg(data->GetPoint(spl.GetP1()).name(),
- data->GetPoint(spl.GetP4()).name());
+ const VSpline *spl = data->GeometricObject(tool.getId());
+ QString splP1Name = data->GeometricObject(spl->GetP1().id())->name();
+ QString splP4Name = data->GeometricObject(spl->GetP4().id())->name();
+ record = QString(tr("Curve %1_%2")).arg(splP1Name, splP4Name);
}
break;
case Tool::ArcTool:
{
- VArc arc = data->GetArc(tool.getId());
- record = QString(tr("Arc with center in point %1")).arg(data->GetPoint(arc.GetCenter()).name());
+ const VArc *arc = data->GeometricObject(tool.getId());
+ QString arcCenterName = data->GeometricObject(arc->GetCenter().id())->name();
+ record = QString(tr("Arc with center in point %1")).arg(arcCenterName);
}
break;
case Tool::SplinePathTool:
{
- VSplinePath splPath = data->GetSplinePath(tool.getId());
- QVector points = splPath.GetSplinePath();
+ const VSplinePath *splPath = data->GeometricObject(tool.getId());
+ QVector points = splPath->GetSplinePath();
if (points.size() != 0 )
{
- record = QString(tr("Curve point %1")).arg(data->GetPoint(points[0].P()).name());
+ QString pName = data->GeometricObject(points[0].P().id())->name();
+ record = QString(tr("Curve point %1")).arg(pName);
for (qint32 i = 1; i< points.size(); ++i)
{
- QString name = QString("_%1").arg(data->GetPoint(points[i].P()).name());
+ pName = data->GeometricObject(points[i].P().id())->name();
+ QString name = QString("_%1").arg(pName);
record.append(name);
}
}
}
break;
case Tool::PointOfContact:
+ {
domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement())
{
- center = domElement.attribute("center", "").toLongLong();
- firstPointId = domElement.attribute("firstPoint", "").toLongLong();
- secondPointId = domElement.attribute("secondPoint", "").toLongLong();
+ center = doc->GetParametrLongLong(domElement, VAbstractTool::AttrCenter, "0");
+ firstPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
+ secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
}
+ QString firstPointIdName = data->GeometricObject(firstPointId)->name();
+ QString centerName = data->GeometricObject(center)->name();
+ QString secondPointIdName = data->GeometricObject(secondPointId)->name();
+ QString toolIdName = data->GeometricObject(tool.getId())->name();
record = QString(tr("%4 - point of contact of arc with the center in point %1 and line %2_%3")).arg(
- data->GetPoint(center).name(), data->GetPoint(firstPointId).name(),
- data->GetPoint(secondPointId).name(), data->GetPoint(tool.getId()).name());
+ centerName, firstPointIdName, secondPointIdName, toolIdName);
break;
+ }
case Tool::Height:
{
qint64 p1LineId = 0;
@@ -293,13 +332,15 @@ QString DialogHistory::Record(const VToolRecord &tool)
domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement())
{
- basePointId = domElement.attribute("basePoint", "").toLongLong();
- p1LineId = domElement.attribute("p1Line", "").toLongLong();
- p2LineId = domElement.attribute("p2Line", "").toLongLong();
+ basePointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrBasePoint, "0");
+ p1LineId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP1Line, "0");
+ p2LineId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP2Line, "0");
}
- record = QString(tr("Point of perpendicular from point %1 to line %2_%3")).arg(
- data->GetPoint(basePointId).name(), data->GetPoint(p1LineId).name(),
- data->GetPoint(p2LineId).name());
+ QString basePointIdName = data->GeometricObject(basePointId)->name();
+ QString p1LineIdName = data->GeometricObject(p1LineId)->name();
+ QString p2LineIdName = data->GeometricObject(p2LineId)->name();
+ record = QString(tr("Point of perpendicular from point %1 to line %2_%3")).arg( basePointIdName,
+ p1LineIdName, p2LineIdName);
break;
}
case Tool::Triangle:
@@ -309,16 +350,72 @@ QString DialogHistory::Record(const VToolRecord &tool)
domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement())
{
- axisP1Id = domElement.attribute("axisP1", "").toLongLong();
- axisP2Id = domElement.attribute("axisP2", "").toLongLong();
- firstPointId = domElement.attribute("firstPoint", "").toLongLong();
- secondPointId = domElement.attribute("secondPoint", "").toLongLong();
+ axisP1Id = doc->GetParametrLongLong(domElement, VAbstractTool::AttrAxisP1, "0");
+ axisP2Id = doc->GetParametrLongLong(domElement, VAbstractTool::AttrAxisP2, "0");
+ firstPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
+ secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
}
- record = QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg(
- data->GetPoint(axisP1Id).name(), data->GetPoint(axisP2Id).name(),
- data->GetPoint(firstPointId).name(), data->GetPoint(secondPointId).name());
+ QString axisP1IdName = data->GeometricObject(axisP1Id)->name();
+ QString axisP2IdName = data->GeometricObject(axisP2Id)->name();
+ QString firstPointIdName = data->GeometricObject(firstPointId)->name();
+ QString secondPointIdName = data->GeometricObject(secondPointId)->name();
+ record = QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg( axisP1IdName, axisP2IdName,
+ firstPointIdName, secondPointIdName);
break;
}
+ case Tool::CutSplineTool:
+ {
+ qint64 splineId = 0;
+ domElement = doc->elementById(QString().setNum(tool.getId()));
+ if (domElement.isElement())
+ {
+ splineId = doc->GetParametrLongLong(domElement, VToolCutSpline::AttrSpline, "0");
+ }
+ const VSpline *spl = data->GeometricObject(splineId);
+ QString toolIdName = data->GeometricObject(tool.getId())->name();
+ QString splP1Name = data->GeometricObject(spl->GetP1().id())->name();
+ QString splP4Name = data->GeometricObject(spl->GetP4().id())->name();
+ record = QString(tr("%1 - cut curve %2_%3")).arg(toolIdName, splP1Name, splP4Name);
+ }
+ break;
+ case Tool::CutSplinePathTool:
+ {
+ qint64 splinePathId = 0;
+ domElement = doc->elementById(QString().setNum(tool.getId()));
+ if (domElement.isElement())
+ {
+ splinePathId = doc->GetParametrLongLong(domElement, VToolCutSplinePath::AttrSplinePath, "0");
+ }
+ const VSplinePath *splPath = data->GeometricObject(splinePathId);
+ QVector points = splPath->GetSplinePath();
+ if (points.size() != 0 )
+ {
+ QString toolIdName = data->GeometricObject(tool.getId())->name();
+ QString pName = data->GeometricObject(points[0].P().id())->name();
+ record = QString(tr("%1 - cut curve point %2")).arg(toolIdName, pName);
+ for (qint32 i = 1; i< points.size(); ++i)
+ {
+ pName = data->GeometricObject(points[i].P().id())->name();
+ QString name = QString("_%1").arg(pName);
+ record.append(name);
+ }
+ }
+ }
+ break;
+ //Because "history" not only show history of pattern, but help restore current data for each pattern's piece, we
+ //need add record about details and nodes, but don't show them.
+ case Tool::Detail:
+ break;
+ case Tool::UnionDetails:
+ break;
+ case Tool::NodeArc:
+ break;
+ case Tool::NodePoint:
+ break;
+ case Tool::NodeSpline:
+ break;
+ case Tool::NodeSplinePath:
+ break;
default:
qWarning()<GetPoint(value);
- qint32 index = ui->comboBoxSecondPoint->findText(point.name());
+ const VPointF *point = data->GeometricObject(value);
+ qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if (index != -1)
{
ui->comboBoxSecondPoint->setCurrentIndex(index);
@@ -65,8 +65,8 @@ void DialogLine::setSecondPoint(const qint64 &value)
void DialogLine::setFirstPoint(const qint64 &value)
{
firstPoint = value;
- VPointF point = data->GetPoint(value);
- qint32 index = ui->comboBoxFirstPoint->findText(point.name());
+ const VPointF *point = data->GeometricObject(value);
+ qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if (index != -1)
{
ui->comboBoxFirstPoint->setCurrentIndex(index);
@@ -87,10 +87,10 @@ void DialogLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
+ const VPointF *point = data->GeometricObject(id);
if (number == 0)
{
- qint32 index = ui->comboBoxFirstPoint->findText(point.name());
+ qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
@@ -101,7 +101,7 @@ void DialogLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 1)
{
- qint32 index = ui->comboBoxSecondPoint->findText(point.name());
+ qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
diff --git a/src/dialogs/dialoglineintersect.cpp b/src/dialogs/dialoglineintersect.cpp
index e6e4e2e4e..74899f451 100644
--- a/src/dialogs/dialoglineintersect.cpp
+++ b/src/dialogs/dialoglineintersect.cpp
@@ -61,10 +61,10 @@ void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
+ const VPointF *point = data->GeometricObject(id);
if (number == 0)
{
- qint32 index = ui->comboBoxP1Line1->findText(point.name());
+ qint32 index = ui->comboBoxP1Line1->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line1->setCurrentIndex(index);
@@ -76,7 +76,7 @@ void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 1)
{
- qint32 index = ui->comboBoxP2Line1->findText(point.name());
+ qint32 index = ui->comboBoxP2Line1->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line1->setCurrentIndex(index);
@@ -88,7 +88,7 @@ void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 2)
{
- qint32 index = ui->comboBoxP1Line2->findText(point.name());
+ qint32 index = ui->comboBoxP1Line2->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line2->setCurrentIndex(index);
@@ -100,7 +100,7 @@ void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 3)
{
- qint32 index = ui->comboBoxP2Line2->findText(point.name());
+ qint32 index = ui->comboBoxP2Line2->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line2->setCurrentIndex(index);
@@ -176,13 +176,13 @@ void DialogLineIntersect::CheckState()
bool DialogLineIntersect::CheckIntersecion()
{
- VPointF p1L1 = data->GetPoint(p1Line1);
- VPointF p2L1 = data->GetPoint(p2Line1);
- VPointF p1L2 = data->GetPoint(p1Line2);
- VPointF p2L2 = data->GetPoint(p2Line2);
+ const VPointF *p1L1 = data->GeometricObject(p1Line1);
+ const VPointF *p2L1 = data->GeometricObject(p2Line1);
+ const VPointF *p1L2 = data->GeometricObject(p1Line2);
+ const VPointF *p2L2 = data->GeometricObject(p2Line2);
- QLineF line1(p1L1.toQPointF(), p2L1.toQPointF());
- QLineF line2(p1L2.toQPointF(), p2L2.toQPointF());
+ QLineF line1(p1L1->toQPointF(), p2L1->toQPointF());
+ QLineF line2(p1L2->toQPointF(), p2L2->toQPointF());
QPointF fPoint;
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
diff --git a/src/dialogs/dialognormal.cpp b/src/dialogs/dialognormal.cpp
index e018ec574..a65a7f8fd 100644
--- a/src/dialogs/dialognormal.cpp
+++ b/src/dialogs/dialognormal.cpp
@@ -102,10 +102,10 @@ void DialogNormal::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
+ const VPointF *point = data->GeometricObject(id);
if (number == 0)
{
- qint32 index = ui->comboBoxFirstPoint->findText(point.name());
+ qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
@@ -116,7 +116,7 @@ void DialogNormal::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 1)
{
- qint32 index = ui->comboBoxSecondPoint->findText(point.name());
+ qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
diff --git a/src/dialogs/dialognormal.h b/src/dialogs/dialognormal.h
index 9beb035a1..556a8b9a2 100644
--- a/src/dialogs/dialognormal.h
+++ b/src/dialogs/dialognormal.h
@@ -96,7 +96,7 @@ public:
*/
inline qint64 getFirstPointId() const {return firstPointId;}
/**
- * @brief setFirstPointId set id of first point
+ * @brief setFirstPointId set id of first point
* @param value id
* @param id don't show this id in list
*/
diff --git a/src/dialogs/dialogpointofcontact.cpp b/src/dialogs/dialogpointofcontact.cpp
index 645634e5a..d593310b3 100644
--- a/src/dialogs/dialogpointofcontact.cpp
+++ b/src/dialogs/dialogpointofcontact.cpp
@@ -79,10 +79,10 @@ void DialogPointOfContact::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
+ const VPointF *point = data->GeometricObject(id);
if (number == 0)
{
- qint32 index = ui.comboBoxFirstPoint->findText(point.name());
+ qint32 index = ui.comboBoxFirstPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui.comboBoxFirstPoint->setCurrentIndex(index);
@@ -93,7 +93,7 @@ void DialogPointOfContact::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 1)
{
- qint32 index = ui.comboBoxSecondPoint->findText(point.name());
+ qint32 index = ui.comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui.comboBoxSecondPoint->setCurrentIndex(index);
@@ -104,7 +104,7 @@ void DialogPointOfContact::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 2)
{
- qint32 index = ui.comboBoxCenter->findText(point.name());
+ qint32 index = ui.comboBoxCenter->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui.comboBoxCenter->setCurrentIndex(index);
diff --git a/src/dialogs/dialogpointofintersection.cpp b/src/dialogs/dialogpointofintersection.cpp
index d0c5ce633..0ec306a6e 100644
--- a/src/dialogs/dialogpointofintersection.cpp
+++ b/src/dialogs/dialogpointofintersection.cpp
@@ -65,10 +65,10 @@ void DialogPointOfIntersection::ChoosedObject(qint64 id, const Scene::Scenes &ty
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
+ const VPointF *point = data->GeometricObject(id);
if (number == 0)
{
- qint32 index = ui->comboBoxFirstPoint->findText(point.name());
+ qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
@@ -79,7 +79,7 @@ void DialogPointOfIntersection::ChoosedObject(qint64 id, const Scene::Scenes &ty
}
if (number == 1)
{
- qint32 index = ui->comboBoxSecondPoint->findText(point.name());
+ qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
diff --git a/src/dialogs/dialogpointofintersection.h b/src/dialogs/dialogpointofintersection.h
index 49d7e0f12..4a184a544 100644
--- a/src/dialogs/dialogpointofintersection.h
+++ b/src/dialogs/dialogpointofintersection.h
@@ -66,7 +66,7 @@ public:
*/
inline qint64 getFirstPointId() const {return firstPointId;}
/**
- * @brief setFirstPointId set id of first point
+ * @brief setFirstPointId set id of first point
* @param value id
* @param id don't show this id in list.
*/
diff --git a/src/dialogs/dialogs.h b/src/dialogs/dialogs.h
index 06b0c2aa6..e61d49cb5 100644
--- a/src/dialogs/dialogs.h
+++ b/src/dialogs/dialogs.h
@@ -47,5 +47,6 @@
#include "dialogheight.h"
#include "dialogcutspline.h"
#include "dialogcutsplinepath.h"
+#include "dialoguniondetails.h"
#endif // DIALOGS_H
diff --git a/src/dialogs/dialogs.pri b/src/dialogs/dialogs.pri
index d18e02857..3367425c8 100644
--- a/src/dialogs/dialogs.pri
+++ b/src/dialogs/dialogs.pri
@@ -20,7 +20,8 @@ HEADERS += \
src/dialogs/dialogarc.h \
src/dialogs/dialogalongline.h \
src/dialogs/dialogcutspline.h \
- src/dialogs/dialogcutsplinepath.h
+ src/dialogs/dialogcutsplinepath.h \
+ src/dialogs/dialoguniondetails.h
SOURCES += \
src/dialogs/dialogtriangle.cpp \
@@ -43,7 +44,8 @@ SOURCES += \
src/dialogs/dialogarc.cpp \
src/dialogs/dialogalongline.cpp \
src/dialogs/dialogcutspline.cpp \
- src/dialogs/dialogcutsplinepath.cpp
+ src/dialogs/dialogcutsplinepath.cpp \
+ src/dialogs/dialoguniondetails.cpp
FORMS += \
src/dialogs/dialogtriangle.ui \
@@ -65,4 +67,5 @@ FORMS += \
src/dialogs/dialogarc.ui \
src/dialogs/dialogalongline.ui \
src/dialogs/dialogcutspline.ui \
- src/dialogs/dialogcutsplinepath.ui
+ src/dialogs/dialogcutsplinepath.ui \
+ src/dialogs/dialoguniondetails.ui
diff --git a/src/dialogs/dialogshoulderpoint.cpp b/src/dialogs/dialogshoulderpoint.cpp
index b570adef5..336b12d90 100644
--- a/src/dialogs/dialogshoulderpoint.cpp
+++ b/src/dialogs/dialogshoulderpoint.cpp
@@ -87,10 +87,10 @@ void DialogShoulderPoint::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
+ const VPointF *point = data->GeometricObject(id);
if (number == 0)
{
- qint32 index = ui->comboBoxP1Line->findText(point.name());
+ qint32 index = ui->comboBoxP1Line->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1Line->setCurrentIndex(index);
@@ -101,7 +101,7 @@ void DialogShoulderPoint::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 1)
{
- qint32 index = ui->comboBoxP2Line->findText(point.name());
+ qint32 index = ui->comboBoxP2Line->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP2Line->setCurrentIndex(index);
@@ -112,7 +112,7 @@ void DialogShoulderPoint::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 2)
{
- qint32 index = ui->comboBoxPShoulder->findText(point.name());
+ qint32 index = ui->comboBoxPShoulder->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxPShoulder->setCurrentIndex(index);
diff --git a/src/dialogs/dialogspline.cpp b/src/dialogs/dialogspline.cpp
index 03acc8478..88b1a8f19 100644
--- a/src/dialogs/dialogspline.cpp
+++ b/src/dialogs/dialogspline.cpp
@@ -51,14 +51,19 @@ DialogSpline::~DialogSpline()
delete ui;
}
+qint64 DialogSpline::getP1() const
+{
+ return p1;
+}
+
void DialogSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
+ const VPointF *point = data->GeometricObject(id);
if (number == 0)
{
- qint32 index = ui->comboBoxP1->findText(point.name());
+ qint32 index = ui->comboBoxP1->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP1->setCurrentIndex(index);
@@ -69,7 +74,7 @@ void DialogSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
}
if (number == 1)
{
- qint32 index = ui->comboBoxP4->findText(point.name());
+ qint32 index = ui->comboBoxP4->findText(point->name());
if ( index != -1 )
{ // -1 for not found
ui->comboBoxP4->setCurrentIndex(index);
@@ -78,8 +83,8 @@ void DialogSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
index = ui->comboBoxP1->currentIndex();
qint64 p1Id = qvariant_cast(ui->comboBoxP1->itemData(index));
- QPointF p1 = data->GetPoint(p1Id).toQPointF();
- QPointF p4 = data->GetPoint(id).toQPointF();
+ QPointF p1 = data->GeometricObject(p1Id)->toQPointF();
+ QPointF p4 = data->GeometricObject(id)->toQPointF();
ui->spinBoxAngle1->setValue(static_cast(QLineF(p1, p4).angle()));
ui->spinBoxAngle2->setValue(static_cast(QLineF(p4, p1).angle()));
@@ -145,3 +150,8 @@ void DialogSpline::setP1(const qint64 &value)
p1 = value;
ChangeCurrentData(ui->comboBoxP1, value);
}
+
+qint64 DialogSpline::getP4() const
+{
+ return p4;
+}
diff --git a/src/dialogs/dialogspline.h b/src/dialogs/dialogspline.h
index 1ba4b4179..f78b94bd5 100644
--- a/src/dialogs/dialogspline.h
+++ b/src/dialogs/dialogspline.h
@@ -54,7 +54,7 @@ public:
* @brief getP1 return id first point of spline
* @return id
*/
- inline qint64 getP1() const {return p1;}
+ qint64 getP1() const;
/**
* @brief setP1 set id first point of spline
* @param value id
@@ -64,7 +64,7 @@ public:
* @brief getP4 return id fourth point of spline
* @return id
*/
- inline qint64 getP4() const {return p4;}
+ qint64 getP4() const;
/**
* @brief setP4 set id fourth point of spline
* @param value id
diff --git a/src/dialogs/dialogsplinepath.cpp b/src/dialogs/dialogsplinepath.cpp
index 9f837cac3..1aa2ec9f0 100644
--- a/src/dialogs/dialogsplinepath.cpp
+++ b/src/dialogs/dialogsplinepath.cpp
@@ -44,8 +44,6 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, QWidget *parent)
FillComboBoxPoints(ui->comboBoxPoint);
- path = VSplinePath(data->DataPoints());
-
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogSplinePath::PointChenged);
connect(ui->comboBoxPoint, static_cast(&QComboBox::currentIndexChanged),
this, &DialogSplinePath::currentPointChanged);
@@ -70,7 +68,7 @@ void DialogSplinePath::SetPath(const VSplinePath &value)
ui->listWidget->clear();
for (qint32 i = 0; i < path.CountPoint(); ++i)
{
- NewItem(path[i].P(), path[i].KAsm1(), path[i].Angle2(), path[i].KAsm2());
+ NewItem(path[i].P().id(), path[i].KAsm1(), path[i].Angle2(), path[i].KAsm2());
}
ui->listWidget->setFocus(Qt::OtherFocusReason);
ui->doubleSpinBoxKcurve->setValue(path.getKCurve());
@@ -108,7 +106,7 @@ void DialogSplinePath::PointChenged(int row)
}
QListWidgetItem *item = ui->listWidget->item( row );
VSplinePoint p = qvariant_cast(item->data(Qt::UserRole));
- DataPoint(p.P(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
+ DataPoint(p.P().id(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
EnableFields();
}
@@ -118,8 +116,9 @@ void DialogSplinePath::currentPointChanged(int index)
qint32 row = ui->listWidget->currentRow();
QListWidgetItem *item = ui->listWidget->item( row );
VSplinePoint p = qvariant_cast(item->data(Qt::UserRole));
- p.SetP(id);
- DataPoint(p.P(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
+ const VPointF *point = data->GeometricObject(id);
+ p.SetP(*point);
+ DataPoint(p.P().id(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
EnableFields();
item->setData(Qt::UserRole, QVariant::fromValue(p));
}
@@ -154,11 +153,11 @@ void DialogSplinePath::KAsm2Changed(qreal d)
void DialogSplinePath::NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2)
{
- VPointF point = data->GetPoint(id);
- QListWidgetItem *item = new QListWidgetItem(point.name());
+ const VPointF *point = data->GeometricObject(id);
+ QListWidgetItem *item = new QListWidgetItem(point->name());
item->setFont(QFont("Times", 12, QFont::Bold));
- VSplinePoint p(id, kAsm1, angle, kAsm2);
- DataPoint(id, kAsm1, angle+180, kAsm2, angle);
+ VSplinePoint p(*point, kAsm1, angle, kAsm2);
+ DataPoint(point->id(), kAsm1, angle+180, kAsm2, angle);
item->setData(Qt::UserRole, QVariant::fromValue(p));
ui->listWidget->addItem(item);
EnableFields();
@@ -222,6 +221,6 @@ void DialogSplinePath::SetAngle(qint32 angle)
QListWidgetItem *item = ui->listWidget->item( row );
VSplinePoint p = qvariant_cast(item->data(Qt::UserRole));
p.SetAngle(angle);
- DataPoint(p.P(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
+ DataPoint(p.P().id(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
item->setData(Qt::UserRole, QVariant::fromValue(p));
}
diff --git a/src/dialogs/dialogtool.cpp b/src/dialogs/dialogtool.cpp
index 479a49219..4816d7a5f 100644
--- a/src/dialogs/dialogtool.cpp
+++ b/src/dialogs/dialogtool.cpp
@@ -28,6 +28,7 @@
#include "dialogtool.h"
#include "../container/calculator.h"
+#include "../geometry/vgobject.h"
#include
@@ -66,15 +67,19 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const
{
Q_ASSERT(box != 0);
box->clear();
- const QHash *points = data->DataPoints();
- QHashIterator i(*points);
+ const QHash *objs = data->DataGObjects();
+ QHashIterator i(*objs);
while (i.hasNext())
{
i.next();
if (i.key() != id)
{
- VPointF point = i.value();
- box->addItem(point.name(), i.key());
+ VGObject *obj = i.value();
+ if (obj->getType() == GObject::Point && obj->getMode() == Draw::Calculation)
+ {
+ const VPointF *point = data->GeometricObject(i.key());
+ box->addItem(point->name(), i.key());
+ }
}
}
}
@@ -83,25 +88,33 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, const qint64 &id, ComboMode
{
Q_ASSERT(box != 0);
box->clear();
- const QHash *spls = data->DataSplines();
- QHashIterator i(*spls);
+ const QHash *objs = data->DataGObjects();
+ QHashIterator i(*objs);
while (i.hasNext())
{
i.next();
- if(cut == ComboMode::CutSpline)
+ if (cut == ComboMode::CutSpline)
{
if (i.key() != id + 1 && i.key() != id + 2)
{
- VSpline spl = i.value();
- box->addItem(spl.name(), i.key());
+ VGObject *obj = i.value();
+ if (obj->getType() == GObject::Spline && obj->getMode() == Draw::Calculation)
+ {
+ const VSpline *spl = data->GeometricObject(i.key());
+ box->addItem(spl->name(), i.key());
+ }
}
}
else
{
if (i.key() != id)
{
- VSpline spl = i.value();
- box->addItem(spl.name(), i.key());
+ VGObject *obj = i.value();
+ if (obj->getType() == GObject::Spline && obj->getMode() == Draw::Calculation)
+ {
+ const VSpline *spl = data->GeometricObject(i.key());
+ box->addItem(spl->name(), i.key());
+ }
}
}
}
@@ -111,25 +124,33 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const qint64 &id, Combo
{
Q_ASSERT(box != 0);
box->clear();
- const QHash *splPaths = data->DataSplinePaths();
- QHashIterator i(*splPaths);
+ const QHash *objs = data->DataGObjects();
+ QHashIterator i(*objs);
while (i.hasNext())
{
i.next();
- if(cut == ComboMode::CutSpline)
+ if (cut == ComboMode::CutSpline)
{
if (i.key() != id + 1 && i.key() != id + 2)
{
- VSplinePath splPath = i.value();
- box->addItem(splPath.name(), i.key());
+ VGObject *obj = i.value();
+ if (obj->getType() == GObject::SplinePath && obj->getMode() == Draw::Calculation)
+ {
+ const VSplinePath *splPath = data->GeometricObject(i.key());
+ box->addItem(splPath->name(), i.key());
+ }
}
}
else
{
if (i.key() != id)
{
- VSplinePath splPath = i.value();
- box->addItem(splPath.name(), i.key());
+ VGObject *obj = i.value();
+ if (obj->getType() == GObject::SplinePath && obj->getMode() == Draw::Calculation)
+ {
+ const VSplinePath *splPath = data->GeometricObject(i.key());
+ box->addItem(splPath->name(), i.key());
+ }
}
}
}
diff --git a/src/dialogs/dialogtriangle.cpp b/src/dialogs/dialogtriangle.cpp
index e9b4a3bc1..e4c1f63aa 100644
--- a/src/dialogs/dialogtriangle.cpp
+++ b/src/dialogs/dialogtriangle.cpp
@@ -61,26 +61,26 @@ void DialogTriangle::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Point)
{
- VPointF point = data->GetPoint(id);
+ const VPointF *point = data->GeometricObject(id);
switch (number)
{
case (0):
- ChangeCurrentText(ui->comboBoxAxisP1, point.name());
+ ChangeCurrentText(ui->comboBoxAxisP1, point->name());
number++;
emit ToolTip(tr("Select second point of axis"));
break;
case (1):
- ChangeCurrentText(ui->comboBoxAxisP2, point.name());
+ ChangeCurrentText(ui->comboBoxAxisP2, point->name());
number++;
emit ToolTip(tr("Select first point"));
break;
case (2):
- ChangeCurrentText(ui->comboBoxFirstPoint, point.name());
+ ChangeCurrentText(ui->comboBoxFirstPoint, point->name());
number++;
emit ToolTip(tr("Select second point"));
break;
case (3):
- ChangeCurrentText(ui->comboBoxSecondPoint, point.name());
+ ChangeCurrentText(ui->comboBoxSecondPoint, point->name());
number = 0;
emit ToolTip(tr(""));
if (isInitialized == false)
diff --git a/src/dialogs/dialogtriangle.h b/src/dialogs/dialogtriangle.h
index e75d83a8c..0335aa9c4 100644
--- a/src/dialogs/dialogtriangle.h
+++ b/src/dialogs/dialogtriangle.h
@@ -78,7 +78,7 @@ public:
*/
inline qint64 getFirstPointId() const {return firstPointId;}
/**
- * @brief setFirstPointId set id of first point
+ * @brief setFirstPointId set id of first point
* @param value id
* @param id don't show this point in list
*/
diff --git a/src/dialogs/dialoguniondetails.cpp b/src/dialogs/dialoguniondetails.cpp
new file mode 100644
index 000000000..9dac1278d
--- /dev/null
+++ b/src/dialogs/dialoguniondetails.cpp
@@ -0,0 +1,135 @@
+/************************************************************************
+ **
+ ** @file dialoguniondetails.cpp
+ ** @author Roman Telezhinsky
+ ** @date 23 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
+ ** All Rights Reserved.
+ **
+ ** Valentina is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Valentina is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with Valentina. If not, see .
+ **
+ *************************************************************************/
+
+#include "dialoguniondetails.h"
+#include "ui_dialoguniondetails.h"
+
+DialogUnionDetails::DialogUnionDetails(const VContainer *data, QWidget *parent) :
+ DialogTool(data, parent), ui(new Ui::DialogUnionDetails), indexD1(0), indexD2(0), d1(0), d2(0), numberD(0),
+ numberP(0), p1(0), p2(0)
+{
+ ui->setupUi(this);
+ bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
+ connect(bOk, &QPushButton::clicked, this, &DialogUnionDetails::DialogAccepted);
+ QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
+ connect(bCansel, &QPushButton::clicked, this, &DialogUnionDetails::DialogRejected);
+}
+
+DialogUnionDetails::~DialogUnionDetails()
+{
+ delete ui;
+}
+
+void DialogUnionDetails::ChoosedObject(qint64 id, const Scene::Scenes &type)
+{
+ if (numberD == 0)
+ {
+ ChoosedDetail(id, type, d1, indexD1);
+ }
+ else
+ {
+ ChoosedDetail(id, type, d2, indexD2);
+ }
+}
+
+void DialogUnionDetails::DialogAccepted()
+{
+ emit DialogClosed(QDialog::Accepted);
+}
+
+bool DialogUnionDetails::CheckObject(const qint64 &id, const qint64 &idDetail) const
+{
+ if (idDetail == 0)
+ {
+ return false;
+ }
+ VDetail det = data->GetDetail(idDetail);
+ return det.Containes(id);
+}
+
+void DialogUnionDetails::ChoosedDetail(const qint64 &id, const Scene::Scenes &type, qint64 &idDetail, ptrdiff_t &index)
+{
+ if (idDetail == 0)
+ {
+ if (type == Scene::Detail)
+ {
+ idDetail = id;
+ emit ToolTip(tr("Select first point"));
+ return;
+ }
+ }
+ if (CheckObject(id, idDetail) == false)
+ {
+ return;
+ }
+ if (type == Scene::Point)
+ {
+ if (numberP == 0)
+ {
+ p1 = id;
+ ++numberP;
+ emit ToolTip(tr("Select second point"));
+ return;
+ }
+ if (numberP == 1)
+ {
+ if (id == p1)
+ {
+ emit ToolTip(tr("Select another second point"));
+ return;
+ }
+ VDetail d = data->GetDetail(idDetail);
+ if (d.OnEdge(p1, id))
+ {
+ p2 = id;
+ index = d.Edge(p1, p2);
+ ++numberD;
+ if (numberD > 1)
+ {
+ ++numberP;
+ emit ToolTip("");
+ this->show();
+ return;
+ }
+ else
+ {
+ numberP = 0;
+ p1 = 0;
+ p2 = 0;
+ emit ToolTip(tr("Select detail"));
+ return;
+ }
+ }
+ else
+ {
+ emit ToolTip(tr("Select another second point"));
+ return;
+ }
+ }
+ }
+}
diff --git a/src/dialogs/dialoguniondetails.h b/src/dialogs/dialoguniondetails.h
new file mode 100644
index 000000000..2815c65fc
--- /dev/null
+++ b/src/dialogs/dialoguniondetails.h
@@ -0,0 +1,75 @@
+/************************************************************************
+ **
+ ** @file dialoguniondetails.h
+ ** @author Roman Telezhinsky
+ ** @date 23 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
+ ** All Rights Reserved.
+ **
+ ** Valentina is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Valentina is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with Valentina. If not, see .
+ **
+ *************************************************************************/
+
+#ifndef DIALOGUNIONDETAILS_H
+#define DIALOGUNIONDETAILS_H
+
+#include "dialogtool.h"
+
+namespace Ui
+{
+ class DialogUnionDetails;
+}
+
+class DialogUnionDetails : public DialogTool
+{
+ Q_OBJECT
+public:
+ explicit DialogUnionDetails(const VContainer *data, QWidget *parent = 0);
+ ~DialogUnionDetails();
+ inline qint64 getD1() const {return d1;}
+ inline qint64 getD2() const {return d2;}
+ inline ptrdiff_t getIndexD1() const {return indexD1;}
+ inline ptrdiff_t getIndexD2() const {return indexD2;}
+public slots:
+ /**
+ * @brief ChoosedObject gets id and type of selected object. Save correct data and ignore wrong.
+ * @param id id of point or detail
+ * @param type type of object
+ */
+ void ChoosedObject(qint64 id, const Scene::Scenes &type);
+ /**
+ * @brief DialogAccepted save data and emit signal about closed dialog.
+ */
+ virtual void DialogAccepted();
+private:
+ Q_DISABLE_COPY(DialogUnionDetails)
+ Ui::DialogUnionDetails *ui;
+ ptrdiff_t indexD1;
+ ptrdiff_t indexD2;
+ qint64 d1;
+ qint64 d2;
+ qint32 numberD; // number of detail, what we already have
+ qint32 numberP; // number of points, what we already have
+ qint64 p1;
+ qint64 p2;
+ bool CheckObject(const qint64 &id, const qint64 &idDetail) const;
+ void ChoosedDetail(const qint64 &id, const Scene::Scenes &type, qint64 &idDetail, ptrdiff_t &index);
+};
+
+#endif // DIALOGUNIONDETAILS_H
diff --git a/src/dialogs/dialoguniondetails.ui b/src/dialogs/dialoguniondetails.ui
new file mode 100644
index 000000000..24e84b14a
--- /dev/null
+++ b/src/dialogs/dialoguniondetails.ui
@@ -0,0 +1,81 @@
+
+
+ DialogUnionDetails
+
+
+
+ 0
+ 0
+ 473
+ 78
+
+
+
+ Dialog
+
+
+
+
+ 120
+ 40
+ 341
+ 32
+
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+ 10
+ 20
+ 451
+ 17
+
+
+
+ Do you really want union details? This operation can't be undone.
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ DialogUnionDetails
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ DialogUnionDetails
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/src/geometry/geometry.pri b/src/geometry/geometry.pri
index e04865bed..6d6a337ed 100644
--- a/src/geometry/geometry.pri
+++ b/src/geometry/geometry.pri
@@ -4,7 +4,9 @@ HEADERS += \
src/geometry/vspline.h \
src/geometry/vnodedetail.h \
src/geometry/vdetail.h \
- src/geometry/varc.h
+ src/geometry/varc.h \
+ src/geometry/vgobject.h \
+ src/geometry/vpointf.h
SOURCES += \
src/geometry/vsplinepoint.cpp \
@@ -12,4 +14,6 @@ SOURCES += \
src/geometry/vspline.cpp \
src/geometry/vnodedetail.cpp \
src/geometry/vdetail.cpp \
- src/geometry/varc.cpp
+ src/geometry/varc.cpp \
+ src/geometry/vgobject.cpp \
+ src/geometry/vpointf.cpp
diff --git a/src/geometry/varc.cpp b/src/geometry/varc.cpp
index d8f314b8d..4613c243a 100644
--- a/src/geometry/varc.cpp
+++ b/src/geometry/varc.cpp
@@ -27,33 +27,36 @@
*************************************************************************/
#include "varc.h"
+#include "vspline.h"
#include "../exception/vexception.h"
class QRectF;
VArc::VArc ()
- : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()),
- center(0), points(QHash()), idObject(0), _name(QString()){}
-
-VArc::VArc (const QHash *points, qint64 center, qreal radius, QString formulaRadius,
- 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), idObject(idObject), _name(QString())
+ :VGObject(GObject::Arc), f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0),
+ formulaRadius(QString()), center(VPointF())
{
- /**
- * @todo Change name of arc in formula. Name now not unique.
- */
- _name = QString ("Arc_%1").arg(this->GetCenterVPoint().name());
+}
+
+VArc::VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2,
+ QString formulaF2, qint64 idObject, Draw::Draws mode)
+ : VGObject(GObject::Arc, idObject, mode), f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2),
+ radius(radius), formulaRadius(formulaRadius), center(center)
+{
+ //TODO Change name of arc in formula. Name now not unique.
+ _name = QString ("Arc_%1").arg(this->GetCenter().name());
}
VArc::VArc(const VArc &arc)
- : f1(arc.GetF1()), formulaF1(arc.GetFormulaF1()), f2(arc.GetF2()),
+ : VGObject(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()), idObject(arc.getIdObject()), _name(arc.name()){}
+ center(arc.GetCenter())
+{
+}
VArc &VArc::operator =(const VArc &arc)
{
- this->points = arc.GetDataPoints();
+ VGObject::operator=(arc);
this->f1 = arc.GetF1();
this->formulaF1 = arc.GetFormulaF1();
this->f2 = arc.GetF2();
@@ -61,55 +64,29 @@ VArc &VArc::operator =(const VArc &arc)
this->radius = arc.GetRadius();
this->formulaRadius = arc.GetFormulaRadius();
this->center = arc.GetCenter();
- this->idObject = arc.getIdObject();
- this->_name = arc.name();
return *this;
}
-QPointF VArc::GetCenterPoint() const
-{
- return GetCenterVPoint().toQPointF();
-}
-
-VPointF VArc::GetCenterVPoint() const
-{
- if (points.contains(center))
- {
- return points.value(center);
- }
- else
- {
- QString error = QString(tr("Can't find id = %1 in table.")).arg(center);
- throw VException(error);
- }
- return VPointF();
-}
-
QPointF VArc::GetP1() const
{
- QPointF p1 ( GetCenterPoint().x () + radius, GetCenterPoint().y () );
- QLineF centerP1(GetCenterPoint(), p1);
+ QPointF p1 ( GetCenter().x () + radius, GetCenter().y () );
+ QLineF centerP1(GetCenter().toQPointF(), p1);
centerP1.setAngle(f1);
return centerP1.p2();
}
QPointF VArc::GetP2 () const
{
- QPointF p2 ( GetCenterPoint().x () + radius, GetCenterPoint().y () );
- QLineF centerP2(GetCenterPoint(), p2);
+ QPointF p2 ( GetCenter().x () + radius, GetCenter().y () );
+ QLineF centerP2(GetCenter().toQPointF(), p2);
centerP2.setAngle(f2);
return centerP2.p2();
}
-const QHash VArc::GetDataPoints() const
-{
- return points;
-}
-
QPainterPath VArc::GetPath() const
{
QPainterPath Path;
- QPointF center = GetCenterPoint();
+ QPointF center = GetCenter().toQPointF();
QRectF rect(center.x()-radius, center.y()-radius, radius*2, radius*2);
Path.moveTo(GetP1());
qreal angle = QLineF(center, GetP1()).angleTo(QLineF(center, GetP2()));
diff --git a/src/geometry/varc.h b/src/geometry/varc.h
index 754e4ddea..dd54e5fe1 100644
--- a/src/geometry/varc.h
+++ b/src/geometry/varc.h
@@ -29,18 +29,18 @@
#ifndef VARC_H
#define VARC_H
-#include "vspline.h"
+#include "vgobject.h"
#include
#include "../options.h"
+#include "vpointf.h"
class QString;
class QLineF;
class QPainterPath;
-class QPointF;
/**
* @brief VArc клас, що реалізує дугу. Дуга розраховується за годиниковою стрілкою.
*/
-class VArc
+class VArc: public VGObject
{
Q_DECLARE_TR_FUNCTIONS(VArc)
public:
@@ -55,8 +55,8 @@ public:
* @param f1 початковий кут в градусах.
* @param f2 кінцевий кут в градусах.
*/
- VArc (const QHash *points, qint64 center, qreal radius, QString formulaRadius,
- qreal f1, QString formulaF1, qreal f2, QString formulaF2, qint64 idObject = 0);
+ VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2,
+ QString formulaF2, qint64 idObject = 0, Draw::Draws mode = Draw::Calculation);
/**
* @brief VArc
* @param arc
@@ -107,32 +107,17 @@ public:
* @brief GetCenter повертає точку центра дуги.
* @return повертає точку центра дуги.
*/
- inline qint64 GetCenter () const {return center;}
- /**
- * @brief GetCenterPoint
- * @return
- */
- QPointF GetCenterPoint() const;
- /**
- * @brief GetCenterVPoint
- * @return
- */
- VPointF GetCenterVPoint() const;
+ inline VPointF GetCenter () const {return center;}
/**
* @brief GetP1 повертає першу точку з якої починається дуга.
* @return точку початку дуги.
*/
- QPointF GetP1 () const;
+ QPointF GetP1() const;
/**
* @brief GetP2 повертає другу точку в якій закінчується дуга.
* @return точку кінця дуги.
*/
QPointF GetP2 () const;
- /**
- * @brief GetDataPoints
- * @return
- */
- const QHash GetDataPoints() const;
/**
* @brief GetPath будує шлях по даній дузі.
* @return повертає шлях.
@@ -159,26 +144,7 @@ public:
* @return
*/
QVector SplOfArc( qint32 number ) const;
- /**
- * @brief getIdObject
- * @return
- */
- inline qint64 getIdObject() const {return idObject;}
- /**
- * @brief setIdObject
- * @param value
- */
- inline void setIdObject(const qint64 &value) {idObject = value;}
- /**
- * @brief name
- * @return
- */
- QString name() const {return _name;}
- /**
- * @brief setName
- * @param name
- */
- void setName(const QString &name) {_name = name;}
+ virtual QString name() const{return _name;}
private:
/**
* @brief f1 початковий кут в градусах
@@ -207,19 +173,7 @@ private:
/**
* @brief center центральна точка дуги.
*/
- qint64 center;
- /**
- * @brief points
- */
- QHash points;
- /**
- * @brief idObject
- */
- qint64 idObject;
- /**
- * @brief _name
- */
- QString _name;
+ VPointF center;
};
#endif // VARC_H
diff --git a/src/geometry/vdetail.cpp b/src/geometry/vdetail.cpp
index a5453788c..24c7811c8 100644
--- a/src/geometry/vdetail.cpp
+++ b/src/geometry/vdetail.cpp
@@ -29,20 +29,23 @@
#include "vdetail.h"
VDetail::VDetail()
- :nodes(QVector()), name(QString()), mx(0), my(0), supplement(true), closed(true), width(10){}
+ :_id(0), nodes(QVector()), name(QString()), mx(0), my(0), supplement(true), closed(true),
+ width(10){}
VDetail::VDetail(const QString &name, const QVector &nodes)
- :nodes(QVector()), name(name), mx(0), my(0), supplement(true), closed(true), width(10)
+ :_id(0), nodes(QVector()), name(name), mx(0), my(0), supplement(true), closed(true),
+ width(10)
{
this->nodes = nodes;
}
VDetail::VDetail(const VDetail &detail)
- :nodes(detail.getNodes()), name(detail.getName()), mx(detail.getMx()), my(detail.getMy()),
+ :_id(0), nodes(detail.getNodes()), name(detail.getName()), mx(detail.getMx()), my(detail.getMy()),
supplement(detail.getSupplement()), closed(detail.getClosed()), width(detail.getWidth()){}
VDetail &VDetail::operator =(const VDetail &detail)
{
+ _id = detail.id();
nodes = detail.getNodes();
name = detail.getName();
mx = detail.getMx();
@@ -66,7 +69,7 @@ void VDetail::Clear()
bool VDetail::Containes(const qint64 &id) const
{
- for (qint32 i = 0; i < nodes.size(); ++i)
+ for (ptrdiff_t i = 0; i < nodes.size(); ++i)
{
VNodeDetail node = nodes[i];
if (node.getId() == id)
@@ -81,3 +84,102 @@ VNodeDetail &VDetail::operator [](ptrdiff_t indx)
{
return nodes[indx];
}
+
+const VNodeDetail &VDetail::at(ptrdiff_t indx) const
+{
+ return nodes[indx];
+}
+
+ptrdiff_t VDetail::indexOfNode(const qint64 &id) const
+{
+ for (ptrdiff_t i = 0; i < nodes.size(); ++i)
+ {
+ VNodeDetail node = nodes[i];
+ if (node.getId() == id)
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+qint64 VDetail::id() const
+{
+ return _id;
+}
+
+void VDetail::setId(const qint64 &id)
+{
+ _id = id;
+}
+
+bool VDetail::OnEdge(const qint64 &p1, const qint64 &p2) const
+{
+ ptrdiff_t i = indexOfNode(p1);
+ ptrdiff_t j1 = 0, j2 = 0;
+
+ if (i == nodes.size() - 1)
+ {
+ j1 = i-1;
+ j2 = 0;
+ }
+ else if (i == 0)
+ {
+ j1 = nodes.size() - 1;
+ j2 = i + 1;
+ }
+ else
+ {
+ j1 = i - 1;
+ j2 = i + 1;
+ }
+
+ if (nodes.at(j1).getId() == p2 || nodes.at(j2).getId() == p2)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+ptrdiff_t VDetail::Edge(const qint64 &p1, const qint64 &p2) const
+{
+ if (OnEdge(p1, p2) == false)
+ {
+ qWarning()<<"Points don't on edge.";
+ return -1;
+ }
+
+ ptrdiff_t i = indexOfNode(p1);
+ ptrdiff_t j = indexOfNode(p2);
+
+ ptrdiff_t min = qMin(i, j);
+
+ if (min == 0 && (i == nodes.size() - 1 || j == nodes.size() - 1))
+ {
+ return nodes.size() - 1;
+ }
+ else
+ {
+ return min;
+ }
+}
+
+void VDetail::NodeOnEdge(const ptrdiff_t &index, VNodeDetail &p1, VNodeDetail &p2) const
+{
+ if (index <= 0 || index > nodes.size())
+ {
+ qWarning()<<"Wrong edge index";
+ return;
+ }
+ p1 = nodes.at(index);
+ if (index + 1 > nodes.size() - 1)
+ {
+ p2 = nodes.at(0);
+ }
+ else
+ {
+ p2 = nodes.at(index+1);
+ }
+}
diff --git a/src/geometry/vdetail.h b/src/geometry/vdetail.h
index 958c8f421..16411a50a 100644
--- a/src/geometry/vdetail.h
+++ b/src/geometry/vdetail.h
@@ -104,6 +104,7 @@ public:
* @return
*/
VNodeDetail & operator[](ptrdiff_t indx);
+ const VNodeDetail & at ( ptrdiff_t indx ) const;
/**
* @brief getName
* @return
@@ -174,7 +175,14 @@ public:
* @param value
*/
inline void setNodes(const QVector &value) {nodes = value;}
+ ptrdiff_t indexOfNode(const qint64 &id) const;
+ qint64 id() const;
+ void setId(const qint64 &id);
+ bool OnEdge(const qint64 &p1, const qint64 &p2)const;
+ ptrdiff_t Edge(const qint64 &p1, const qint64 &p2)const;
+ void NodeOnEdge(const ptrdiff_t &index, VNodeDetail &p1, VNodeDetail &p2)const;
private:
+ qint64 _id;
/**
* @brief nodes
*/
diff --git a/src/geometry/vgobject.cpp b/src/geometry/vgobject.cpp
new file mode 100644
index 000000000..94d025598
--- /dev/null
+++ b/src/geometry/vgobject.cpp
@@ -0,0 +1,99 @@
+/************************************************************************
+ **
+ ** @file vgobject.cpp
+ ** @author Roman Telezhinsky
+ ** @date 27 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
+ ** All Rights Reserved.
+ **
+ ** Valentina is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Valentina is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with Valentina. If not, see .
+ **
+ *************************************************************************/
+
+#include "vgobject.h"
+
+VGObject::VGObject()
+ :_id(0), type(GObject::Point), idObject(0), _name(QString()), mode(Draw::Calculation)
+{
+}
+
+VGObject::VGObject(const GObject::Type &type, const qint64 &idObject, const Draw::Draws &mode)
+ :_id(0), type(type), idObject(idObject), _name(QString()), mode(mode)
+{
+}
+
+VGObject::VGObject(const VGObject &obj)
+ :_id(obj.id()), type(obj.getType()), idObject(obj.getIdObject()), _name(obj.name()), mode(obj.getMode())
+{
+}
+
+VGObject &VGObject::operator=(const VGObject &obj)
+{
+ this->_id = obj.id();
+ this->type = obj.getType();
+ this->idObject = obj.getIdObject();
+ this->_name = obj.name();
+ this->mode = obj.getMode();
+ return *this;
+}
+
+qint64 VGObject::getIdObject() const
+{
+ return idObject;
+}
+
+void VGObject::setIdObject(const qint64 &value)
+{
+ idObject = value;
+}
+
+QString VGObject::name() const
+{
+ return _name;
+}
+
+void VGObject::setName(const QString &name)
+{
+ _name = name;
+}
+
+Draw::Draws VGObject::getMode() const
+{
+ return mode;
+}
+
+void VGObject::setMode(const Draw::Draws &value)
+{
+ mode = value;
+}
+
+GObject::Type VGObject::getType() const
+{
+ return type;
+}
+
+qint64 VGObject::id() const
+{
+ return _id;
+}
+
+void VGObject::setId(const qint64 &id)
+{
+ _id = id;
+}
diff --git a/src/geometry/vgobject.h b/src/geometry/vgobject.h
new file mode 100644
index 000000000..eb904c072
--- /dev/null
+++ b/src/geometry/vgobject.h
@@ -0,0 +1,88 @@
+/************************************************************************
+ **
+ ** @file vgobject.h
+ ** @author Roman Telezhinsky
+ ** @date 27 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
+ ** All Rights Reserved.
+ **
+ ** Valentina is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Valentina is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with Valentina. If not, see .
+ **
+ *************************************************************************/
+
+#ifndef VGOBJECT_H
+#define VGOBJECT_H
+
+#include "../options.h"
+#include "../exception/vexception.h"
+#include
+#include
+
+
+namespace GObject
+{
+ /**
+ * @brief The NodeDetail enum
+ */
+ enum Type { Point, Arc, Spline, SplinePath };
+ Q_DECLARE_FLAGS(Types, Type)
+}
+Q_DECLARE_OPERATORS_FOR_FLAGS(GObject::Types)
+
+class VGObject
+{
+public:
+ VGObject();
+ VGObject(const GObject::Type &type, const qint64 &idObject = 0, const Draw::Draws &mode = Draw::Calculation);
+ VGObject(const VGObject &obj);
+ VGObject& operator= (const VGObject &obj);
+ virtual ~VGObject(){}
+ qint64 getIdObject() const;
+ void setIdObject(const qint64 &value);
+ virtual QString name() const;
+ void setName(const QString &name);
+ Draw::Draws getMode() const;
+ void setMode(const Draw::Draws &value);
+ GObject::Type getType() const;
+ qint64 id() const;
+ void setId(const qint64 &id);
+protected:
+ /**
+ * @brief _id id in container. Ned for arcs, spline and spline paths.
+ */
+ qint64 _id;
+ /**
+ * @brief type type of graphical object
+ */
+ GObject::Type type;
+ /**
+ * @brief idObject id of parent object. Only for modeling. All another return 0.
+ */
+ qint64 idObject;
+ /**
+ * @brief _name object name
+ */
+ QString _name;
+ /**
+ * @brief mode object created in calculation or drawing mode
+ */
+ Draw::Draws mode;
+};
+
+#endif // VGOBJECT_H
diff --git a/src/container/vpointf.cpp b/src/geometry/vpointf.cpp
similarity index 85%
rename from src/container/vpointf.cpp
rename to src/geometry/vpointf.cpp
index 7b2c6187a..33783552f 100644
--- a/src/container/vpointf.cpp
+++ b/src/geometry/vpointf.cpp
@@ -28,13 +28,18 @@
#include "vpointf.h"
+VPointF::VPointF(qreal x, qreal y, QString name, qreal mx, qreal my, qint64 idObject, Draw::Draws mode)
+ :VGObject(GObject::Point, idObject, mode), _mx(mx), _my(my), _x(x), _y(y)
+{
+ this->_name = name;
+}
+
VPointF &VPointF::operator =(const VPointF &point)
{
- _name = point.name();
+ VGObject::operator=(point);
_mx = point.mx();
_my = point.my();
_x = point.x();
_y = point.y();
- idObject = point.getIdObject();
return *this;
}
diff --git a/src/container/vpointf.h b/src/geometry/vpointf.h
similarity index 72%
rename from src/container/vpointf.h
rename to src/geometry/vpointf.h
index 39869fb68..63da46ba7 100644
--- a/src/container/vpointf.h
+++ b/src/geometry/vpointf.h
@@ -32,36 +32,36 @@
#include
#include
#include "../options.h"
+#include "vgobject.h"
/**
* @brief The VPointF class keep data of point.
*/
-class VPointF
+class VPointF:public VGObject
{
public:
/**
* @brief VPointF creat empty point
*/
inline VPointF ()
- :_name(QString()), _mx(0), _my(0), _x(0), _y(0), idObject(0){}
+ :VGObject(GObject::Point, 0, Draw::Calculation), _mx(0), _my(0), _x(0), _y(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()),
- idObject(point.getIdObject()){}
+ :VGObject(point), _mx(point.mx()), _my(point.my()), _x(point.x()), _y(point.y()){}
+ inline VPointF (const QPointF &point )
+ :VGObject(VPointF()), _mx(0), _my(0), _x(point.x()), _y(point.y()){}
/**
* @brief VPointF create new point
* @param x x coordinate
* @param y y coordinate
- * @param name name of point
* @param mx offset name respect to x
* @param my offset name respect to y
- * @param idObject point modeling keep here id of parent point
*/
- 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){}
+ VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my, qint64 idObject = 0,
+ Draw::Draws mode = Draw::Calculation);
/**
* @brief operator = assignment operator
* @param point point
@@ -69,11 +69,6 @@ public:
*/
VPointF &operator=(const VPointF &point);
~VPointF(){}
- /**
- * @brief name return name of point
- * @return name
- */
- inline QString name() const { return _name;}
/**
* @brief mx return offset name respect to x
* @return offset
@@ -84,11 +79,6 @@ public:
* @return offset
*/
inline qreal my() const {return _my;}
- /**
- * @brief setName set name of point
- * @param name name
- */
- inline void setName(const QString &name) {_name = name;}
/**
* @brief setMx set offset name respect to x
* @param mx offset
@@ -124,21 +114,8 @@ public:
* @param value y coordinate
*/
inline void setY(const qreal &value){_y = value;}
- /**
- * @brief getIdObject return id of parrent.
- * @return id
- */
- inline qint64 getIdObject() const {return idObject;}
- /**
- * @brief setIdObject set id of parent
- * @param value id
- */
- inline void setIdObject(const qint64 &value) {idObject = value;}
+ virtual QString name() const{return _name;}
private:
- /**
- * @brief _name name of point
- */
- QString _name;
/**
* @brief _mx offset name respect to x
*/
@@ -155,10 +132,6 @@ private:
* @brief _y y coordinate
*/
qreal _y;
- /**
- * @brief idObject id of parent. Only for point modeling. All another return 0.
- */
- qint64 idObject;
};
#endif // VPOINTF_H
diff --git a/src/geometry/vspline.cpp b/src/geometry/vspline.cpp
index 02dbb69b6..f37ba220e 100644
--- a/src/geometry/vspline.cpp
+++ b/src/geometry/vspline.cpp
@@ -31,34 +31,21 @@
#include
VSpline::VSpline()
- :p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1),
- points(QHash()), idObject(0), _name(QString()){}
+ :VGObject(GObject::Spline), p1(VPointF()), p2(QPointF()), p3(QPointF()), p4(VPointF()), angle1(0), angle2(0),
+ kAsm1(1), kAsm2(1), kCurve(1){}
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()), idObject(spline.getIdObject()), _name(spline.name()){}
+ :VGObject(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()){}
-VSpline::VSpline (const QHash *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2,
- 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), idObject(idObject), _name(QString())
+VSpline::VSpline (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve,
+ qint64 idObject, Draw::Draws mode)
+ :VGObject(GObject::Spline, idObject, mode), p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1),
+ angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve)
{
- _name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name());
- ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve );
-}
+ CreateName();
-VSpline::VSpline (const QHash *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4,
- 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)
-{
this->p1 = p1;
this->p4 = p4;
this->angle1 = angle1;
@@ -66,130 +53,80 @@ void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2, qrea
this->kAsm1 = kAsm1;
this->kAsm2 = kAsm2;
this->kCurve = kCurve;
- QLineF p1pX(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + 100, GetPointP1().y());
+ QLineF p1pX(GetP1().x(), GetP1().y(), GetP1().x() + 100, GetP1().y());
p1pX.setAngle( angle1 );
qreal L = 0, radius = 0, angle = 90;
// angle = QLineF(GetPointP1(), p1pX.p2()).angleTo(QLineF(GetPointP1(), GetPointP4()));
// if ( angle > 180 ){
// angle = 360 - angle;
// }
- QPointF point1 = GetPointP1().toQPointF();
- QPointF point4 = GetPointP4().toQPointF();
+ QPointF point1 = GetP1().toQPointF();
+ QPointF point4 = GetP4().toQPointF();
radius = QLineF(QPointF(point1.x(), point4.y()), point4).length();
// radius = QLineF(GetPointP1(), GetPointP4()).length() / 2 / sin( angle * M_PI / 180.0 );
L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 );
- QLineF p1p2(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + L * kAsm1, GetPointP1().y());
+ QLineF p1p2(GetP1().x(), GetP1().y(), GetP1().x() + L * kAsm1, GetP1().y());
p1p2.setAngle(angle1);
- QLineF p4p3(GetPointP4().x(), GetPointP4().y(), GetPointP4().x() + L * kAsm2, GetPointP4().y());
+ QLineF p4p3(GetP4().x(), GetP4().y(), GetP4().x() + L * kAsm2, GetP4().y());
p4p3.setAngle(angle2);
this->p2 = p1p2.p2();
this->p3 = p4p3.p2();
}
-void VSpline::ModifiSpl (const qint64 &p1, const QPointF &p2, const QPointF &p3, const qint64 &p4, const qreal &kCurve)
+VSpline::VSpline (VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal kCurve, qint64 idObject, Draw::Draws mode)
+ :VGObject(GObject::Spline, idObject, mode), p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1),
+ kAsm2(1), kCurve(1)
{
+ CreateName();
+
this->p1 = p1;
this->p2 = p2;
this->p3 = p3;
this->p4 = p4;
- this->angle1 = QLineF ( GetPointP1().toQPointF(), p2 ).angle();
- this->angle2 = QLineF ( GetPointP4().toQPointF(), p3 ).angle();
+ this->angle1 = QLineF ( GetP1().toQPointF(), p2 ).angle();
+ this->angle2 = QLineF ( GetP4().toQPointF(), p3 ).angle();
- QLineF p1pX(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + 100, GetPointP1().y());
+ QLineF p1pX(GetP1().x(), GetP1().y(), GetP1().x() + 100, GetP1().y());
p1pX.setAngle( angle1 );
qreal L = 0, radius = 0, angle = 90;
// angle = QLineF(GetPointP1(), p1pX.p2()).angleTo(QLineF(GetPointP1(), GetPointP4()));
// if ( angle >= 180 ){
// angle = 360 - angle;
// }
- QPointF point1 = GetPointP1().toQPointF();
- QPointF point4 = GetPointP4().toQPointF();
+ QPointF point1 = GetP1().toQPointF();
+ QPointF point4 = GetP4().toQPointF();
radius = QLineF(QPointF(point1.x(), point4.y()), point4).length();
// radius = QLineF(GetPointP1(), GetPointP4()).length() / 2 / sin( angle * M_PI / 180.0 );
L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 );
this->kCurve = kCurve;
- this->kAsm1 = QLineF ( GetPointP1().toQPointF(), p2 ).length()/L;
- this->kAsm2 = QLineF ( GetPointP4().toQPointF(), p3 ).length()/L;
-}
-
-//void VSpline::RotationSpl (QPointF pRotate, qreal angle ){
-// QLineF pRotateP1 (pRotate, p1);
-// pRotateP1.setAngle(angle);
-// p1 = pRotateP1.p2();
-// QLineF pRotateP2 (pRotate, p2);
-// pRotateP2.setAngle(angle);
-// p2 = pRotateP2.p2();
-// QLineF pRotateP3 (pRotate, p3);
-// pRotateP3.setAngle(angle);
-// p3 = pRotateP3.p2();
-// QLineF pRotateP4 (pRotate, p4);
-// pRotateP4.setAngle(angle);
-// p4 = pRotateP4.p2();
-// angle1 = QLineF(p1, p2).angle();
-// angle2 = QLineF(p4, p2).angle();
-//}
-
-//void VSpline::BiasSpl ( qreal mx, qreal my ){
-// p1 = QPointF(p1.x()+mx, p1.y()+my);
-// p2 = QPointF(p2.x()+mx, p2.y()+my);
-// p3 = QPointF(p3.x()+mx, p3.y()+my);
-// p4 = QPointF(p4.x()+mx, p4.y()+my);
-//}
-
-VPointF VSpline::GetPointP1() const
-{
- if (points.contains(p1))
- {
- return points.value(p1);
- }
- else
- {
- qCritical()<<"Не можу знайти id = "<kAsm1 = QLineF ( GetP1().toQPointF(), p2 ).length()/L;
+ this->kAsm2 = QLineF ( GetP4().toQPointF(), p3 ).length()/L;
}
qreal VSpline::GetLength () const
{
- return LengthBezier ( GetPointP1().toQPointF(), this->p2, this->p3, GetPointP4().toQPointF());
+ return LengthBezier ( GetP1().toQPointF(), this->p2, this->p3, GetP4().toQPointF());
}
-QString VSpline::GetName() const
+QString VSpline::name() const
{
- VPointF first = GetPointP1();
- VPointF second = GetPointP4();
- return QString("Spl_%1_%2").arg(first.name(), second.name());
+ return _name;
}
QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *intersectionPoint ) const
{
QVector px;
QVector py;
- px.append ( GetPointP1 ().x () );
- py.append ( GetPointP1 ().y () );
+ px.append ( GetP1 ().x () );
+ py.append ( GetP1 ().y () );
QVector& wpx = px;
QVector