From ca32f1c9dfcb46ab4122986b44f236c6553c4ada Mon Sep 17 00:00:00 2001 From: dismine Date: Thu, 21 Aug 2014 15:44:40 +0300 Subject: [PATCH] Fixed issue 168. --HG-- branch : develop --- src/app/container/calculator.cpp | 6 +- src/app/container/vcontainer.cpp | 325 ++++++++++-------- src/app/container/vcontainer.h | 230 ++++--------- src/app/dialogs/app/dialoghistory.cpp | 14 +- src/app/dialogs/app/dialogincrements.cpp | 24 +- src/app/dialogs/tools/dialogarc.cpp | 9 +- src/app/dialogs/tools/dialogdetail.cpp | 8 +- src/app/dialogs/tools/dialogendline.cpp | 2 +- src/app/dialogs/tools/dialogheight.cpp | 6 +- src/app/dialogs/tools/dialoglineintersect.cpp | 16 +- src/app/dialogs/tools/dialogspline.cpp | 6 +- src/app/dialogs/tools/dialogsplinepath.cpp | 4 +- src/app/dialogs/tools/dialogtool.cpp | 70 ++-- src/app/geometry/vequidistant.cpp | 8 +- src/app/tools/drawTools/vabstractspline.cpp | 2 +- src/app/tools/drawTools/vtoolalongline.cpp | 10 +- src/app/tools/drawTools/vtoolarc.cpp | 10 +- src/app/tools/drawTools/vtoolbisector.cpp | 12 +- src/app/tools/drawTools/vtoolcut.cpp | 2 +- src/app/tools/drawTools/vtoolcutarc.cpp | 10 +- src/app/tools/drawTools/vtoolcutspline.cpp | 10 +- .../tools/drawTools/vtoolcutsplinepath.cpp | 10 +- src/app/tools/drawTools/vtoolendline.cpp | 8 +- src/app/tools/drawTools/vtoolheight.cpp | 12 +- src/app/tools/drawTools/vtoolline.cpp | 8 +- .../tools/drawTools/vtoollineintersect.cpp | 18 +- src/app/tools/drawTools/vtoollinepoint.cpp | 10 +- src/app/tools/drawTools/vtoolnormal.cpp | 10 +- src/app/tools/drawTools/vtoolpoint.cpp | 6 +- .../tools/drawTools/vtoolpointofcontact.cpp | 16 +- .../drawTools/vtoolpointofintersection.cpp | 12 +- .../tools/drawTools/vtoolshoulderpoint.cpp | 12 +- src/app/tools/drawTools/vtoolsinglepoint.cpp | 10 +- src/app/tools/drawTools/vtoolspline.cpp | 28 +- src/app/tools/drawTools/vtoolsplinepath.cpp | 14 +- src/app/tools/drawTools/vtooltriangle.cpp | 16 +- src/app/tools/nodeDetails/vnodearc.cpp | 2 +- src/app/tools/nodeDetails/vnodepoint.cpp | 10 +- src/app/tools/nodeDetails/vnodespline.cpp | 2 +- src/app/tools/nodeDetails/vnodesplinepath.cpp | 4 +- src/app/tools/vdatatool.h | 2 + src/app/tools/vtooldetail.h | 2 +- src/app/tools/vtooluniondetails.cpp | 68 ++-- src/app/visualization/vistoolalongline.cpp | 4 +- src/app/visualization/vistoolarc.cpp | 2 +- src/app/visualization/vistoolbisector.cpp | 6 +- src/app/visualization/vistoolcutarc.cpp | 2 +- src/app/visualization/vistoolendline.cpp | 2 +- src/app/visualization/vistoolheight.cpp | 6 +- src/app/visualization/vistoolline.cpp | 4 +- .../visualization/vistoollineintersect.cpp | 8 +- src/app/visualization/vistoolnormal.cpp | 4 +- .../visualization/vistoolpointofcontact.cpp | 6 +- .../vistoolpointofintersection.cpp | 4 +- .../visualization/vistoolshoulderpoint.cpp | 6 +- src/app/visualization/vistoolspline.cpp | 4 +- src/app/visualization/vistooltriangle.cpp | 8 +- src/app/xml/vpattern.cpp | 12 +- 58 files changed, 537 insertions(+), 605 deletions(-) diff --git a/src/app/container/calculator.cpp b/src/app/container/calculator.cpp index d0697da1c..3ea4cb7f1 100644 --- a/src/app/container/calculator.cpp +++ b/src/app/container/calculator.cpp @@ -167,18 +167,18 @@ void Calculator::InitVariables(const VContainer *data, const QMap vVarVal = new qreal[2]; } - const QHash *vars = data->DataVariables(); + const QHash > *vars = data->DataVariables(); QMap::const_iterator i = tokens.constBegin(); while (i != tokens.constEnd()) { if (vars->contains(i.value())) { - VInternalVariable *var = vars->value(i.value()); + QSharedPointer var = vars->value(i.value()); if ((qApp->patternType() == MeasurementsType::Standard) && (var->GetType() == VarType::Measurement || var->GetType() == VarType::Increment)) { - VVariable *m = data->GetVariable(i.value()); + QSharedPointer m = data->GetVariable(i.value()); m->SetValue(data->size(), data->height()); } DefineVar(i.value(), var->GetValue()); diff --git a/src/app/container/vcontainer.cpp b/src/app/container/vcontainer.cpp index 94c2f21ae..0e9960bd4 100644 --- a/src/app/container/vcontainer.cpp +++ b/src/app/container/vcontainer.cpp @@ -35,17 +35,16 @@ #include quint32 VContainer::_id = NULL_ID; +qreal VContainer::_size = 50; +qreal VContainer::_height = 176; //--------------------------------------------------------------------------------------------------------------------- /** * @brief VContainer create empty container */ VContainer::VContainer() - :_size(50), sizeName(size_M), _height(176), heightName(height_M), - gObjects(QHash()), variables(QHash ()), - details(QHash()) -{ -} + :d(new VContainerData) +{} //--------------------------------------------------------------------------------------------------------------------- /** @@ -59,7 +58,7 @@ VContainer &VContainer::operator =(const VContainer &data) { return *this; } - setData(data); + d = data.d; return *this; } @@ -69,12 +68,8 @@ VContainer &VContainer::operator =(const VContainer &data) * @param data container */ VContainer::VContainer(const VContainer &data) - :_size(50), sizeName(size_M), _height(176), heightName(height_M), - gObjects(QHash()), variables(QHash ()), - details(QHash()) -{ - setData(data); -} + :d(data.d) +{} //--------------------------------------------------------------------------------------------------------------------- VContainer::~VContainer() @@ -83,79 +78,6 @@ VContainer::~VContainer() ClearVariables(); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief setData copy data from container - * @param data container - */ -void VContainer::setData(const VContainer &data) -{ - _size = data.size(); - sizeName = data.SizeName(); - _height = data.height(); - heightName = data.HeightName(); - { - ClearGObjects(); - QHash::const_iterator i; - for (i = data.gObjects.constBegin(); i != data.gObjects.constEnd(); ++i) - { - switch (i.value()->getType()) - { - case (GOType::Arc): - CopyGObject(data, i.key()); - break; - case (GOType::Point): - CopyGObject(data, i.key()); - break; - case (GOType::Spline): - CopyGObject(data, i.key()); - break; - case (GOType::SplinePath): - CopyGObject(data, i.key()); - break; - default: - qDebug()<<"Don't know how copy this type."; - break; - } - } - } - - { - ClearVariables(); - QHash::const_iterator i; - for (i = data.variables.constBegin(); i != data.variables.constEnd(); ++i) - { - switch (i.value()->GetType()) - { - case (VarType::Measurement): - CopyVar(data, i.key()); - break; - case (VarType::Increment): - CopyVar(data, i.key()); - break; - case (VarType::LineLength): - CopyVar(data, i.key()); - break; - case (VarType::SplineLength): - CopyVar(data, i.key()); - break; - case (VarType::ArcLength): - CopyVar(data, i.key()); - break; - case (VarType::LineAngle): - CopyVar(data, i.key()); - break; - case (VarType::Unknown): - default: - qDebug()<<"Don't know how copy this type."; - break; - } - } - } - - details = *data.DataDetails(); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief GetGObject returns a point by id @@ -163,9 +85,9 @@ void VContainer::setData(const VContainer &data) * @return point */ // cppcheck-suppress unusedFunction -const VGObject *VContainer::GetGObject(quint32 id)const +const QSharedPointer VContainer::GetGObject(quint32 id)const { - return GetObject(gObjects, id); + return GetObject(d->gObjects, id); } //--------------------------------------------------------------------------------------------------------------------- @@ -196,9 +118,9 @@ const val VContainer::GetObject(const QHash &obj, key id) const */ const VDetail VContainer::GetDetail(quint32 id) const { - if (details.contains(id)) + if (d->details.contains(id)) { - return details.value(id); + return d->details.value(id); } else { @@ -214,7 +136,9 @@ const VDetail VContainer::GetDetail(quint32 id) const */ quint32 VContainer::AddGObject(VGObject *obj) { - return AddObject(gObjects, obj); + SCASSERT(obj != nullptr); + QSharedPointer pointer(obj); + return AddObject(d->gObjects, pointer); } //--------------------------------------------------------------------------------------------------------------------- @@ -226,7 +150,7 @@ quint32 VContainer::AddGObject(VGObject *obj) quint32 VContainer::AddDetail(VDetail detail) { quint32 id = getNextId(); - details[id] = detail; + d->details[id] = detail; return id; } @@ -265,12 +189,11 @@ template void VContainer::UpdateObject(QHash &obj, const quint32 &id, val point) { Q_ASSERT_X(id > NULL_ID, Q_FUNC_INFO, "id = 0"); - SCASSERT(point != nullptr); + SCASSERT(point.isNull() == false); point->setId(id); - if (gObjects.contains(id)) + if (d->gObjects.contains(id)) { - delete gObjects.value(id); - gObjects.remove(id); + d->gObjects[id].clear(); } obj[id] = point; UpdateId(id); @@ -284,7 +207,7 @@ void VContainer::Clear() { _id = NULL_ID; - details.clear(); + d->details.clear(); ClearVariables(); ClearGObjects(); } @@ -295,23 +218,34 @@ void VContainer::Clear() */ void VContainer::ClearGObjects() { - qDeleteAll(gObjects); - gObjects.clear(); + QHash >::iterator i; + for (i = d->gObjects.begin(); i != d->gObjects.end(); ++i) + { + i.value().clear(); + } + d->gObjects.clear(); } //--------------------------------------------------------------------------------------------------------------------- void VContainer::ClearCalculationGObjects() { - if (gObjects.size()>0) + if (d->gObjects.size()>0) { - QHashIterator i(gObjects); - while (i.hasNext()) + QVector keys; + QHash >::iterator i; + for (i = d->gObjects.begin(); i != d->gObjects.end(); ++i) { - i.next(); if (i.value()->getMode() == Draw::Calculation) { - delete i.value(); - gObjects.remove(i.key()); + i.value().clear(); + keys.append(i.key()); + } + } + if (keys.size()>0) + { + for (int i = 0; i < keys.size(); ++i) + { + d->gObjects.remove(keys.at(i)); } } } @@ -320,23 +254,34 @@ void VContainer::ClearCalculationGObjects() //--------------------------------------------------------------------------------------------------------------------- void VContainer::ClearVariables(const VarType &type) { - if (variables.size()>0) + if (d->variables.size()>0) { if (type == VarType::Unknown) { - qDeleteAll(variables); - variables.clear(); + QHash >::iterator i; + for (i = d->variables.begin(); i != d->variables.end(); ++i) + { + i.value().clear(); + } + d->variables.clear(); } else { - QHashIterator i(variables); - while (i.hasNext()) + QVector keys; + QHash >::iterator i; + for (i = d->variables.begin(); i != d->variables.end(); ++i) { - i.next(); if (i.value()->GetType() == type) { - delete i.value(); - variables.remove(i.key()); + i.value().clear(); + keys.append(i.key()); + } + } + if (keys.size()>0) + { + for (int i = 0; i < keys.size(); ++i) + { + d->variables.remove(keys.at(i)); } } } @@ -351,13 +296,13 @@ void VContainer::ClearVariables(const VarType &type) */ void VContainer::AddLine(const quint32 &firstPointId, const quint32 &secondPointId) { - const VPointF *first = GeometricObject(firstPointId); - const VPointF *second = GeometricObject(secondPointId); + const QSharedPointer first = GeometricObject(firstPointId); + const QSharedPointer second = GeometricObject(secondPointId); - VLengthLine *length = new VLengthLine(first, firstPointId, second, secondPointId); + VLengthLine *length = new VLengthLine(first.data(), firstPointId, second.data(), secondPointId); AddVariable(length->GetName(), length); - VLineAngle *angle = new VLineAngle(first, firstPointId, second, secondPointId); + VLineAngle *angle = new VLineAngle(first.data(), firstPointId, second.data(), secondPointId); AddVariable(angle->GetName(), angle); } @@ -387,7 +332,8 @@ quint32 VContainer::AddObject(QHash &obj, val value) void VContainer::UpdateGObject(quint32 id, VGObject* obj) { SCASSERT(obj != nullptr); - UpdateObject(gObjects, id, obj); + QSharedPointer pointer(obj); + UpdateObject(d->gObjects, id, pointer); } //--------------------------------------------------------------------------------------------------------------------- @@ -399,14 +345,14 @@ void VContainer::UpdateGObject(quint32 id, VGObject* obj) void VContainer::UpdateDetail(quint32 id, const VDetail &detail) { Q_ASSERT_X(id > NULL_ID, Q_FUNC_INFO, "id = 0"); - details[id] = detail; + d->details[id] = detail; UpdateId(id); } //--------------------------------------------------------------------------------------------------------------------- qreal VContainer::GetTableValue(const QString &name) const { - VVariable *m = GetVariable(name); + QSharedPointer m = GetVariable(name); if (qApp->patternType() == MeasurementsType::Standard) { m->SetValue(size(), height()); @@ -421,42 +367,42 @@ qreal VContainer::GetTableValue(const QString &name) const */ void VContainer::RemoveIncrement(const QString &name) { - delete variables.value(name); - variables.remove(name); + d->variables[name].clear(); + d->variables.remove(name); } //--------------------------------------------------------------------------------------------------------------------- -const QMap VContainer::DataMeasurements() const +const QMap > VContainer::DataMeasurements() const { return DataVar(VarType::Measurement); } //--------------------------------------------------------------------------------------------------------------------- -const QMap VContainer::DataIncrements() const +const QMap > VContainer::DataIncrements() const { return DataVar(VarType::Increment); } //--------------------------------------------------------------------------------------------------------------------- -const QMap VContainer::DataLengthLines() const +const QMap > VContainer::DataLengthLines() const { return DataVar(VarType::LineLength); } //--------------------------------------------------------------------------------------------------------------------- -const QMap VContainer::DataLengthSplines() const +const QMap > VContainer::DataLengthSplines() const { return DataVar(VarType::SplineLength); } //--------------------------------------------------------------------------------------------------------------------- -const QMap VContainer::DataLengthArcs() const +const QMap > VContainer::DataLengthArcs() const { return DataVar(VarType::ArcLength); } //--------------------------------------------------------------------------------------------------------------------- -const QMap VContainer::DataAngleLines() const +const QMap > VContainer::DataAngleLines() const { return DataVar(VarType::LineAngle); } @@ -469,40 +415,119 @@ const QMap VContainer::DataAngleLines() const */ bool VContainer::VariableExist(const QString &name) { - return variables.contains(name); + return d->variables.contains(name); } //--------------------------------------------------------------------------------------------------------------------- template -void VContainer::CopyGObject(const VContainer &data, const quint32 &id) +const QMap > VContainer::DataVar(const VarType &type) const { - T *obj = new T(*data.GeometricObject(id)); - UpdateGObject(id, obj); -} - -//--------------------------------------------------------------------------------------------------------------------- -template -void VContainer::CopyVar(const VContainer &data, const QString &name) -{ - T *var = new T(*data.GetVariable(name)); - AddVariable(name, var); -} - -//--------------------------------------------------------------------------------------------------------------------- -template -const QMap VContainer::DataVar(const VarType &type) const -{ - QHashIterator i(variables); - QMap map; + QMap > map; //Sorting QHash by id - while (i.hasNext()) + QHash >::const_iterator i; + for (i = d->variables.constBegin(); i != d->variables.constEnd(); ++i) { - i.next(); if(i.value()->GetType() == type) { - T *var = GetVariable(i.key()); + QSharedPointer var = GetVariable(i.key()); map.insert(qApp->VarToUser(i.key()), var); } } return map; } + +//--------------------------------------------------------------------------------------------------------------------- +void VContainer::ClearDetails() +{ + d->details.clear(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetSize set value of size + * @param size value of size + */ +void VContainer::SetSize(qreal size) +{ + _size = size; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VContainer::SetSizeName(const QString &name) +{ + d->sizeName = name; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetGrowth set value of growth + * @param height value of height + */ +void VContainer::SetHeight(qreal height) +{ + _height = height; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VContainer::SetHeightName(const QString &name) +{ + d->heightName = name; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief size return size + * @return size in mm + */ +qreal VContainer::size() const +{ + return _size; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VContainer::SizeName() const +{ + return d->sizeName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief height return height + * @return height in pattern units + */ +qreal VContainer::height() const +{ + return _height; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VContainer::HeightName() const +{ + return d->heightName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief data container with datagObjects return container of gObjects + * @return pointer on container of gObjects + */ +const QHash > *VContainer::DataGObjects() const +{ + return &d->gObjects; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief data container with dataDetails return container of details + * @return pointer on container of details + */ +const QHash *VContainer::DataDetails() const +{ + return &d->details; +} + +//--------------------------------------------------------------------------------------------------------------------- +const QHash > *VContainer::DataVariables() const +{ + return &d->variables; +} diff --git a/src/app/container/vcontainer.h b/src/app/container/vcontainer.h index f511d51a0..c473244d5 100644 --- a/src/app/container/vcontainer.h +++ b/src/app/container/vcontainer.h @@ -38,6 +38,39 @@ #include #include +class VContainerData : public QSharedData +{ +public: + + VContainerData() + :sizeName(size_M), heightName(height_M), gObjects(QHash >()), + variables(QHash > ()), details(QHash()) + {} + + VContainerData(const VContainerData &data) + :QSharedData(data), sizeName(data.sizeName), heightName(data.heightName), gObjects(data.gObjects), + variables(data.variables), details(data.details) + {} + + virtual ~VContainerData() {} + + QString sizeName; + QString heightName; + /** + * @brief gObjects graphicals objects of pattern. + */ + QHash > gObjects; + + /** + * @brief variables container for measurements, increments, lines lengths, lines angles, arcs lengths, curve lengths + */ + QHash> variables; + /** + * @brief details container of details + */ + QHash details; +}; + /** * @brief The VContainer class container of all variables. */ @@ -50,37 +83,33 @@ public: VContainer(const VContainer &data); ~VContainer(); - void setData(const VContainer &data); - template - const T GeometricObject(const quint32 &id) const + const QSharedPointer GeometricObject(const quint32 &id) const { - VGObject *gObj = nullptr; - if (gObjects.contains(id)) + QSharedPointer gObj = QSharedPointer(); + if (d->gObjects.contains(id)) { - gObj = gObjects.value(id); + gObj = d->gObjects.value(id); } else { throw VExceptionBadId(tr("Can't find object"), id); - return nullptr; } try { - T obj = dynamic_cast(gObj); - SCASSERT(obj != nullptr); + QSharedPointer obj = qSharedPointerDynamicCast(gObj); + SCASSERT(obj.isNull() == false); return obj; } catch (const std::bad_alloc &) { throw VExceptionBadId(tr("Can't cast object"), id); - return nullptr; } - return nullptr; + return QSharedPointer(); } - const VGObject *GetGObject(quint32 id) const; + const QSharedPointer GetGObject(quint32 id) const; const VDetail GetDetail(quint32 id) const; qreal GetTableValue(const QString& name) const; template @@ -89,27 +118,25 @@ public: * @param name variable's name * @return variable */ - T GetVariable(QString name) const + QSharedPointer GetVariable(QString name) const { SCASSERT(name.isEmpty()==false); - if (variables.contains(name)) + if (d->variables.contains(name)) { try { - T value = dynamic_cast(variables.value(name)); - SCASSERT(value != nullptr); + QSharedPointer value = qSharedPointerDynamicCast(d->variables.value(name)); + SCASSERT(value.isNull() == false); return value; } catch (const std::bad_alloc &) { throw VExceptionBadId(tr("Can't cast object"), name); - return nullptr; } } else { throw VExceptionBadId(tr("Can't find object"), name); - return nullptr; } } @@ -131,31 +158,25 @@ public: */ void AddCurveLength(const quint32 &id, const quint32 &parentId = 0) { - const VAbstractCurve *var = GeometricObject(id); - AddVariable(var->name(), new TLength(id, parentId, var)); + const QSharedPointer var = GeometricObject(id); + AddVariable(var->name(), new TLength(id, parentId, var.data())); } template - void AddVariable(const QString& name, T var) + void AddVariable(const QString& name, T *var) { - if(variables.contains(name)) + if(d->variables.contains(name)) { - if(variables.value(name)->GetType() == var->GetType()) + if(d->variables.value(name)->GetType() == var->GetType()) { - T v = dynamic_cast(variables.value(name)); - SCASSERT(v != nullptr); - *v = *var; - delete var; + d->variables[name].clear(); } else { throw VExceptionBadId(tr("Can't find object. Type mismatch."), name); } } - else - { - variables[name] = var; - } + d->variables[name] = QSharedPointer(var); } void UpdateGObject(quint32 id, VGObject* obj); @@ -180,16 +201,16 @@ public: void RemoveIncrement(const QString& name); - const QHash *DataGObjects() const; - const QHash *DataDetails() const; - const QHash *DataVariables() const; + const QHash > *DataGObjects() const; + const QHash *DataDetails() const; + const QHash> *DataVariables() const; - const QMap DataMeasurements() const; - const QMap DataIncrements() const; - const QMap DataLengthLines() const; - const QMap DataLengthSplines() const; - const QMap DataLengthArcs() const; - const QMap DataAngleLines() const; + const QMap > DataMeasurements() const; + const QMap > DataIncrements() const; + const QMap > DataLengthLines() const; + const QMap > DataLengthSplines() const; + const QMap > DataLengthArcs() const; + const QMap > DataAngleLines() const; private: @@ -197,23 +218,16 @@ private: * @brief _id current id. New object will have value +1. For empty class equal 0. */ static quint32 _id; - qreal _size; - QString sizeName; - qreal _height; - QString heightName; - /** - * @brief gObjects graphicals objects of pattern. - */ - QHash gObjects; + static qreal _size; + static qreal _height; - /** - * @brief variables container for measurements, increments, lines lengths, lines angles, arcs lengths, curve lengths - */ - QHash variables; - /** - * @brief details container of details - */ - QHash details; + QSharedDataPointer d; + + template + uint qHash( const QSharedPointer &p ) + { + return qHash( p.data() ); + } template // cppcheck-suppress functionStatic @@ -226,109 +240,7 @@ private: static quint32 AddObject(QHash &obj, val value); template - void CopyGObject(const VContainer &data, const quint32 &id); - - template - void CopyVar(const VContainer &data, const QString &name); - - template - const QMap DataVar(const VarType &type) const; + const QMap > DataVar(const VarType &type) const; }; -//--------------------------------------------------------------------------------------------------------------------- -inline void VContainer::ClearDetails() -{ - details.clear(); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief SetSize set value of size - * @param size value of size - */ -inline void VContainer::SetSize(qreal size) -{ - _size = size; -} - -//--------------------------------------------------------------------------------------------------------------------- -inline void VContainer::SetSizeName(const QString &name) -{ - sizeName = name; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief SetGrowth set value of growth - * @param height value of height - */ -inline void VContainer::SetHeight(qreal height) -{ - _height = height; -} - -//--------------------------------------------------------------------------------------------------------------------- -inline void VContainer::SetHeightName(const QString &name) -{ - heightName = name; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief size return size - * @return size in mm - */ -inline qreal VContainer::size() const -{ - return _size; -} - -//--------------------------------------------------------------------------------------------------------------------- -inline QString VContainer::SizeName() const -{ - return sizeName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief height return height - * @return height in pattern units - */ -inline qreal VContainer::height() const -{ - return _height; -} - -//--------------------------------------------------------------------------------------------------------------------- -inline QString VContainer::HeightName() const -{ - return heightName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief data container with datagObjects return container of gObjects - * @return pointer on container of gObjects - */ -inline const QHash *VContainer::DataGObjects() const -{ - return &gObjects; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief data container with dataDetails return container of details - * @return pointer on container of details - */ -inline const QHash *VContainer::DataDetails() const -{ - return &details; -} - -//--------------------------------------------------------------------------------------------------------------------- -inline const QHash *VContainer::DataVariables() const -{ - return &variables; -} - #endif // VCONTAINER_H diff --git a/src/app/dialogs/app/dialoghistory.cpp b/src/app/dialogs/app/dialoghistory.cpp index 2ee26aa2d..188efdb7a 100644 --- a/src/app/dialogs/app/dialoghistory.cpp +++ b/src/app/dialogs/app/dialoghistory.cpp @@ -269,19 +269,19 @@ QString DialogHistory::Record(const VToolRecord &tool) } case Tool::SplineTool: { - const VSpline *spl = data->GeometricObject(tool.getId()); + const QSharedPointer spl = data->GeometricObject(tool.getId()); SCASSERT(spl != nullptr); return QString(tr("Curve %1_%2")).arg(PointName(spl->GetP1().id())).arg(PointName(spl->GetP4().id())); } case Tool::ArcTool: { - const VArc *arc = data->GeometricObject(tool.getId()); + const QSharedPointer arc = data->GeometricObject(tool.getId()); SCASSERT(arc != nullptr); return QString(tr("Arc with center in point %1")).arg(PointName(arc->GetCenter().id())); } case Tool::SplinePathTool: { - const VSplinePath *splPath = data->GeometricObject(tool.getId()); + const QSharedPointer splPath = data->GeometricObject(tool.getId()); SCASSERT(splPath != nullptr); const QVector points = splPath->GetSplinePath(); QString record; @@ -333,7 +333,7 @@ QString DialogHistory::Record(const VToolRecord &tool) } case Tool::CutArcTool: { - const VArc *arc = data->GeometricObject(AttrUInt(domElem, VToolCutArc::AttrArc)); + const QSharedPointer arc = data->GeometricObject(AttrUInt(domElem, VToolCutArc::AttrArc)); SCASSERT(arc != nullptr); return QString(tr("%1 - cut arc with center %2")) .arg(PointName(tool.getId())) @@ -342,7 +342,7 @@ QString DialogHistory::Record(const VToolRecord &tool) case Tool::CutSplineTool: { const quint32 splineId = AttrUInt(domElem, VToolCutSpline::AttrSpline); - const VSpline *spl = data->GeometricObject(splineId); + const QSharedPointer spl = data->GeometricObject(splineId); SCASSERT(spl != nullptr); return QString(tr("%1 - cut curve %2_%3")) .arg(PointName(tool.getId())) @@ -352,7 +352,7 @@ QString DialogHistory::Record(const VToolRecord &tool) case Tool::CutSplinePathTool: { const quint32 splinePathId = AttrUInt(domElem, VToolCutSplinePath::AttrSplinePath); - const VSplinePath *splPath = data->GeometricObject(splinePathId); + const QSharedPointer splPath = data->GeometricObject(splinePathId); SCASSERT(splPath != nullptr); const QVector points = splPath->GetSplinePath(); QString record; @@ -440,7 +440,7 @@ void DialogHistory::ShowPoint() */ QString DialogHistory::PointName(quint32 pointId) { - return data->GeometricObject(pointId)->name(); + return data->GeometricObject(pointId)->name(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/app/dialogincrements.cpp b/src/app/dialogs/app/dialogincrements.cpp index 494195f02..d2fd0853f 100644 --- a/src/app/dialogs/app/dialogincrements.cpp +++ b/src/app/dialogs/app/dialogincrements.cpp @@ -143,14 +143,13 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par */ void DialogIncrements::FillMeasurements() { - const QMap table = data->DataMeasurements(); + const QMap > table = data->DataMeasurements(); qint32 currentRow = -1; - QMapIterator iMap(table); + QMap >::const_iterator iMap; ui->tableWidgetMeasurements->setRowCount ( table.size() ); - while (iMap.hasNext()) + for (iMap = table.constBegin(); iMap != table.constEnd(); ++iMap) { - iMap.next(); - VMeasurement *m = iMap.value(); + QSharedPointer m = iMap.value(); currentRow++; QTableWidgetItem *item = new QTableWidgetItem(QString(iMap.key())); @@ -220,14 +219,13 @@ void DialogIncrements::FillMeasurements() */ void DialogIncrements::FillIncrements() { - const QMap increments = data->DataIncrements(); - QMapIterator i(increments); + const QMap > increments = data->DataIncrements(); + QMap >::const_iterator i; QMap map; //Sorting QHash by id - while (i.hasNext()) + for (i = increments.constBegin(); i != increments.constEnd(); ++i) { - i.next(); - VIncrement *incr = i.value(); + QSharedPointer incr = i.value(); map.insert(incr->getId(), i.key()); } @@ -236,7 +234,7 @@ void DialogIncrements::FillIncrements() while (iMap.hasNext()) { iMap.next(); - VIncrement *incr = increments.value(iMap.value()); + QSharedPointer incr = increments.value(iMap.value()); currentRow++; ui->tableWidgetIncrement->setRowCount ( increments.size() ); @@ -694,7 +692,7 @@ void DialogIncrements::IncrementChanged ( qint32 row, qint32 column ) case 5: // VPattern::IncrementDescription { doc->SetAttribute(domElement, VPattern::IncrementDescription, item->text()); - VIncrement *incr = data->GetVariable(itemName->text()); + QSharedPointer incr = data->GetVariable(itemName->text()); incr->SetDescription(item->text()); ui->tableWidgetIncrement->resizeColumnsToContents(); ui->tableWidgetIncrement->resizeRowsToContents(); @@ -719,7 +717,7 @@ void DialogIncrements::MeasurementChanged(qint32 row, qint32 column) const QTableWidgetItem *itemName = ui->tableWidgetMeasurements->item(row, 0);// name column QTableWidgetItem *item = ui->tableWidgetMeasurements->item(row, 2); - VMeasurement *measur = data->GetVariable(qApp->VarFromUser(itemName->text())); + QSharedPointer measur = data->GetVariable(qApp->VarFromUser(itemName->text())); const QString tag = measur->TagName(); QDomNodeList list = m->elementsByTagName(tag); QDomElement domElement = list.at(0).toElement(); diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp index e14418a86..e41f7b862 100644 --- a/src/app/dialogs/tools/dialogarc.cpp +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -246,7 +246,7 @@ void DialogArc::ValChenged(int row) QListWidgetItem *item = ui->listWidget->item( row ); if (ui->radioButtonAngleLine->isChecked()) { - qreal angle = *data->GetVariable(item->text())->GetValue(); + qreal angle = *data->GetVariable(item->text())->GetValue(); QString desc = QString("%1(%2) - %3").arg(item->text()).arg(angle).arg(tr("Value of angle of line.")); ui->labelDescription->setText(desc); return; @@ -375,11 +375,10 @@ void DialogArc::ShowLineAngles() ui->listWidget->blockSignals(true); ui->listWidget->clear(); ui->listWidget->blockSignals(false); - const QMap lineAnglesTable = data->DataAngleLines(); - QMapIterator i(lineAnglesTable); - while (i.hasNext()) + const QMap > lineAnglesTable = data->DataAngleLines(); + QMap >::const_iterator i; + for (i = lineAnglesTable.constBegin(); i != lineAnglesTable.constEnd(); ++i) { - i.next(); QListWidgetItem *item = new QListWidgetItem(i.key()); item->setFont(QFont("Times", 12, QFont::Bold)); diff --git a/src/app/dialogs/tools/dialogdetail.cpp b/src/app/dialogs/tools/dialogdetail.cpp index ea37c9dca..3d6a014f0 100644 --- a/src/app/dialogs/tools/dialogdetail.cpp +++ b/src/app/dialogs/tools/dialogdetail.cpp @@ -141,25 +141,25 @@ void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &t { case (Tool::NodePoint): { - const VPointF *point = data->GeometricObject(id); + const QSharedPointer point = data->GeometricObject(id); name = point->name(); break; } case (Tool::NodeArc): { - const VArc *arc = data->GeometricObject(id); + const QSharedPointer arc = data->GeometricObject(id); name = arc->name(); break; } case (Tool::NodeSpline): { - const VSpline *spl = data->GeometricObject(id); + const QSharedPointer spl = data->GeometricObject(id); name = spl->name(); break; } case (Tool::NodeSplinePath): { - const VSplinePath *splPath = data->GeometricObject(id); + const QSharedPointer splPath = data->GeometricObject(id); name = splPath->name(); break; } diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp index fd4bb2cec..f1bc2253e 100644 --- a/src/app/dialogs/tools/dialogendline.cpp +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -235,7 +235,7 @@ void DialogEndLine::ShowDialog(bool click) /*We will ignore click if poinet is in point circle*/ VMainGraphicsScene *scene = qApp->getCurrentScene(); SCASSERT(scene != nullptr); - const VPointF *point = data->GeometricObject(basePointId); + const QSharedPointer point = data->GeometricObject(basePointId); QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); //Radius of point circle, but little bigger. Need handle with hover sizes. diff --git a/src/app/dialogs/tools/dialogheight.cpp b/src/app/dialogs/tools/dialogheight.cpp index 8eddb8f03..5fb40d6b1 100644 --- a/src/app/dialogs/tools/dialogheight.cpp +++ b/src/app/dialogs/tools/dialogheight.cpp @@ -203,9 +203,9 @@ void DialogHeight::PointNameChanged() set.insert(p1LineId); set.insert(p2LineId); - const VPointF *basePoint = data->GeometricObject(basePointId); - const VPointF *p1Line = data->GeometricObject(p1LineId); - const VPointF *p2Line = data->GeometricObject(p2LineId); + const QSharedPointer basePoint = data->GeometricObject(basePointId); + const QSharedPointer p1Line = data->GeometricObject(p1LineId); + const QSharedPointer p2Line = data->GeometricObject(p2LineId); QColor color = okColor; if (set.size() != 3 || VAbstractTool::ClosestPoint(QLineF(p1Line->toQPointF(), p2Line->toQPointF()), diff --git a/src/app/dialogs/tools/dialoglineintersect.cpp b/src/app/dialogs/tools/dialoglineintersect.cpp index 2b9466508..674eb5ac9 100644 --- a/src/app/dialogs/tools/dialoglineintersect.cpp +++ b/src/app/dialogs/tools/dialoglineintersect.cpp @@ -233,10 +233,10 @@ void DialogLineIntersect::PointNameChanged() set.insert(p1Line2Id); set.insert(p2Line2Id); - const VPointF *p1Line1 = data->GeometricObject(p1Line1Id); - const VPointF *p2Line1 = data->GeometricObject(p2Line1Id); - const VPointF *p1Line2 = data->GeometricObject(p1Line2Id); - const VPointF *p2Line2 = data->GeometricObject(p2Line2Id); + const QSharedPointer p1Line1 = data->GeometricObject(p1Line1Id); + const QSharedPointer p2Line1 = data->GeometricObject(p2Line1Id); + const QSharedPointer p1Line2 = data->GeometricObject(p1Line2Id); + const QSharedPointer p2Line2 = data->GeometricObject(p2Line2Id); QLineF line1(p1Line1->toQPointF(), p2Line1->toQPointF()); QLineF line2(p1Line2->toQPointF(), p2Line2->toQPointF()); @@ -299,10 +299,10 @@ void DialogLineIntersect::CheckState() */ bool DialogLineIntersect::CheckIntersecion() { - const VPointF *p1L1 = data->GeometricObject(p1Line1); - const VPointF *p2L1 = data->GeometricObject(p2Line1); - const VPointF *p1L2 = data->GeometricObject(p1Line2); - const VPointF *p2L2 = data->GeometricObject(p2Line2); + const QSharedPointer p1L1 = data->GeometricObject(p1Line1); + const QSharedPointer p2L1 = data->GeometricObject(p2Line1); + const QSharedPointer p1L2 = data->GeometricObject(p1Line2); + const QSharedPointer p2L2 = data->GeometricObject(p2Line2); QLineF line1(p1L1->toQPointF(), p2L1->toQPointF()); QLineF line2(p1L2->toQPointF(), p2L2->toQPointF()); diff --git a/src/app/dialogs/tools/dialogspline.cpp b/src/app/dialogs/tools/dialogspline.cpp index 8654c7557..062c766cc 100644 --- a/src/app/dialogs/tools/dialogspline.cpp +++ b/src/app/dialogs/tools/dialogspline.cpp @@ -96,7 +96,7 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type) break; case 1: { - const VPointF *point = data->GeometricObject(id); + const QSharedPointer point = data->GeometricObject(id); qint32 index = ui->comboBoxP4->findText(point->name()); if ( index != -1 ) { // -1 for not found @@ -105,8 +105,8 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type) index = ui->comboBoxP1->currentIndex(); quint32 p1Id = qvariant_cast(ui->comboBoxP1->itemData(index)); - QPointF p1 = data->GeometricObject(p1Id)->toQPointF(); - QPointF p4 = data->GeometricObject(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())); diff --git a/src/app/dialogs/tools/dialogsplinepath.cpp b/src/app/dialogs/tools/dialogsplinepath.cpp index 6ac0b8d8b..833737387 100644 --- a/src/app/dialogs/tools/dialogsplinepath.cpp +++ b/src/app/dialogs/tools/dialogsplinepath.cpp @@ -138,7 +138,7 @@ void DialogSplinePath::currentPointChanged(int index) qint32 row = ui->listWidget->currentRow(); QListWidgetItem *item = ui->listWidget->item( row ); VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); - const VPointF *point = data->GeometricObject(id); + const QSharedPointer point = data->GeometricObject(id); p.SetP(*point); DataPoint(p.P().id(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2()); EnableFields(); @@ -225,7 +225,7 @@ void DialogSplinePath::UpdateList() */ void DialogSplinePath::NewItem(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2) { - const VPointF *point = data->GeometricObject(id); + const QSharedPointer point = data->GeometricObject(id); QListWidgetItem *item = new QListWidgetItem(point->name()); item->setFont(QFont("Times", 12, QFont::Bold)); VSplinePoint p(*point, kAsm1, angle1, kAsm2, angle2); diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index ce695c101..515ab0109 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -117,18 +117,17 @@ void DialogTool::showEvent(QShowEvent *event) void DialogTool::FillComboBoxPoints(QComboBox *box) const { SCASSERT(box != nullptr); - const QHash *objs = data->DataGObjects(); - QHashIterator i(*objs); + const QHash > *objs = data->DataGObjects(); QMap list; - while (i.hasNext()) + QHash >::const_iterator i; + for (i = objs->constBegin(); i != objs->constEnd(); ++i) { - i.next(); if (i.key() != toolId) { - VGObject *obj = i.value(); + QSharedPointer obj = i.value(); if (obj->getType() == GOType::Point && obj->getMode() == Draw::Calculation) { - const VPointF *point = data->GeometricObject(i.key()); + const QSharedPointer point = data->GeometricObject(i.key()); list[point->name()] = i.key(); } } @@ -140,20 +139,19 @@ void DialogTool::FillComboBoxPoints(QComboBox *box) const void DialogTool::FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut) const { SCASSERT(box != nullptr); - const QHash *objs = data->DataGObjects(); - QHashIterator i(*objs); + const QHash > *objs = data->DataGObjects(); + QHash >::const_iterator i; QMap list; - while (i.hasNext()) + for (i = objs->constBegin(); i != objs->constEnd(); ++i) { - i.next(); if (cut == ComboBoxCutArc::CutArc) { if (i.key() != toolId + 1 && i.key() != toolId + 2) { - VGObject *obj = i.value(); + QSharedPointer obj = i.value(); if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation) { - const VArc *arc = data->GeometricObject(i.key()); + const QSharedPointer arc = data->GeometricObject(i.key()); list[arc->name()] = i.key(); } } @@ -162,10 +160,10 @@ void DialogTool::FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut) const { if (i.key() != toolId) { - VGObject *obj = i.value(); + QSharedPointer obj = i.value(); if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation) { - const VArc *arc = data->GeometricObject(i.key()); + const QSharedPointer arc = data->GeometricObject(i.key()); list[arc->name()] = i.key(); } } @@ -183,20 +181,19 @@ void DialogTool::FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut) const void DialogTool::FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut) const { SCASSERT(box != nullptr); - const QHash *objs = data->DataGObjects(); - QHashIterator i(*objs); + const QHash > *objs = data->DataGObjects(); + QHash >::const_iterator i; QMap list; - while (i.hasNext()) + for (i = objs->constBegin(); i != objs->constEnd(); ++i) { - i.next(); if (cut == ComboBoxCutSpline::CutSpline) { if (i.key() != toolId + 1 && i.key() != toolId + 2) { - VGObject *obj = i.value(); + QSharedPointer obj = i.value(); if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation) { - const VSpline *spl = data->GeometricObject(i.key()); + const QSharedPointer spl = data->GeometricObject(i.key()); list[spl->name()] = i.key(); } } @@ -205,10 +202,10 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut) cons { if (i.key() != toolId) { - VGObject *obj = i.value(); + QSharedPointer obj = i.value(); if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation) { - const VSpline *spl = data->GeometricObject(i.key()); + const QSharedPointer spl = data->GeometricObject(i.key()); list[spl->name()] = i.key(); } } @@ -226,20 +223,19 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut) cons void DialogTool::FillComboBoxSplinesPath(QComboBox *box, ComboBoxCutSpline cut) const { SCASSERT(box != nullptr); - const QHash *objs = data->DataGObjects(); - QHashIterator i(*objs); + const QHash > *objs = data->DataGObjects(); QMap list; - while (i.hasNext()) + QHash >::const_iterator i; + for (i = objs->constBegin(); i != objs->constEnd(); ++i) { - i.next(); if (cut == ComboBoxCutSpline::CutSpline) { if (i.key() != toolId + 1 && i.key() != toolId + 2) { - VGObject *obj = i.value(); + QSharedPointer obj = i.value(); if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation) { - const VSplinePath *splPath = data->GeometricObject(i.key()); + const QSharedPointer splPath = data->GeometricObject(i.key()); list[splPath->name()] = i.key(); } } @@ -248,10 +244,10 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box, ComboBoxCutSpline cut) { if (i.key() != toolId) { - VGObject *obj = i.value(); + QSharedPointer obj = i.value(); if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation) { - const VSplinePath *splPath = data->GeometricObject(i.key()); + const QSharedPointer splPath = data->GeometricObject(i.key()); list[splPath->name()] = i.key(); } } @@ -563,8 +559,8 @@ quint32 DialogTool::getCurrentObjectId(QComboBox *box) const bool DialogTool::SetObject(const quint32 &id, QComboBox *box, const QString &toolTip) { SCASSERT(box != nullptr); - const VGObject *obj = data->GetGObject(id); - SCASSERT(obj != nullptr); + const QSharedPointer obj = data->GetGObject(id); + SCASSERT(obj.isNull() == false); const qint32 index = box->findText(obj->name()); if ( index != -1 ) { // -1 for not found @@ -964,7 +960,7 @@ void DialogTool::ValChenged(int row) if (radioButtonStandardTable->isChecked()) { QString name = qApp->VarFromUser(item->text()); - VMeasurement *stable = data->GetVariable(name); + QSharedPointer stable = data->GetVariable(name); QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(name)) .arg(stable->GetGuiText()); labelDescription->setText(desc); @@ -972,7 +968,7 @@ void DialogTool::ValChenged(int row) } if (radioButtonIncrements->isChecked()) { - VIncrement *incr = data->GetVariable(item->text()); + QSharedPointer incr = data->GetVariable(item->text()); QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetTableValue(item->text())) .arg(incr->GetDescription()); labelDescription->setText(desc); @@ -981,7 +977,7 @@ void DialogTool::ValChenged(int row) if (radioButtonLengthLine->isChecked()) { QString desc = QString("%1(%2) - %3").arg(item->text()) - .arg(*data->GetVariable(qApp->VarFromUser(item->text()))->GetValue()) + .arg(*data->GetVariable(qApp->VarFromUser(item->text()))->GetValue()) .arg(tr("Line length")); labelDescription->setText(desc); return; @@ -989,7 +985,7 @@ void DialogTool::ValChenged(int row) if (radioButtonLengthArc->isChecked()) { QString desc = QString("%1(%2) - %3").arg(item->text()) - .arg(*data->GetVariable(qApp->VarFromUser(item->text()))->GetValue()) + .arg(*data->GetVariable(qApp->VarFromUser(item->text()))->GetValue()) .arg(tr("Arc length")); labelDescription->setText(desc); return; @@ -997,7 +993,7 @@ void DialogTool::ValChenged(int row) if (radioButtonLengthCurve->isChecked()) { QString desc = QString("%1(%2) - %3").arg(item->text()) - .arg(*data->GetVariable(qApp->VarFromUser(item->text()))->GetValue()) + .arg(*data->GetVariable(qApp->VarFromUser(item->text()))->GetValue()) .arg(tr("Curve length")); labelDescription->setText(desc); return; diff --git a/src/app/geometry/vequidistant.cpp b/src/app/geometry/vequidistant.cpp index 94abf849a..5e6ae7349 100644 --- a/src/app/geometry/vequidistant.cpp +++ b/src/app/geometry/vequidistant.cpp @@ -49,7 +49,7 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer { case (Tool::NodePoint): { - const VPointF *point = data->GeometricObject(detail.at(i).getId()); + const QSharedPointer point = data->GeometricObject(detail.at(i).getId()); points.append(point->toQPointF()); if (detail.getSeamAllowance() == true) { @@ -62,7 +62,7 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer break; case (Tool::NodeArc): { - const VArc *arc = data->GeometricObject(detail.at(i).getId()); + const QSharedPointer arc = data->GeometricObject(detail.at(i).getId()); qreal len1 = GetLengthContour(points, arc->GetPoints()); qreal lenReverse = GetLengthContour(points, GetReversePoint(arc->GetPoints())); if (len1 <= lenReverse) @@ -86,7 +86,7 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer break; case (Tool::NodeSpline): { - const VSpline *spline = data->GeometricObject(detail.at(i).getId()); + const QSharedPointer spline = data->GeometricObject(detail.at(i).getId()); qreal len1 = GetLengthContour(points, spline->GetPoints()); qreal lenReverse = GetLengthContour(points, GetReversePoint(spline->GetPoints())); if (len1 <= lenReverse) @@ -110,7 +110,7 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer break; case (Tool::NodeSplinePath): { - const VSplinePath *splinePath = data->GeometricObject(detail.at(i).getId()); + const QSharedPointer splinePath = data->GeometricObject(detail.at(i).getId()); qreal len1 = GetLengthContour(points, splinePath->GetPoints()); qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath->GetPoints())); if (len1 <= lenReverse) diff --git a/src/app/tools/drawTools/vabstractspline.cpp b/src/app/tools/drawTools/vabstractspline.cpp index dc1ec9bff..78bbdfd57 100644 --- a/src/app/tools/drawTools/vabstractspline.cpp +++ b/src/app/tools/drawTools/vabstractspline.cpp @@ -205,7 +205,7 @@ void VAbstractSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- QPainterPath VAbstractSpline::ToolPath(PathDirection direction) const { - const VAbstractCurve *curve = VAbstractTool::data.GeometricObject(id); + const QSharedPointer curve = VAbstractTool::data.GeometricObject(id); QPainterPath path; path.addPath(curve->GetPath(direction)); path.setFillRule( Qt::WindingFill ); diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp index 63c07c9db..1840e143e 100644 --- a/src/app/tools/drawTools/vtoolalongline.cpp +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -119,7 +119,7 @@ void VToolAlongLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) */ void VToolAlongLine::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -142,7 +142,7 @@ void VToolAlongLine::AddToFile() */ void VToolAlongLine::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { @@ -191,7 +191,7 @@ void VToolAlongLine::setDialog() SCASSERT(dialog != nullptr); DialogAlongLine *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *p = VAbstractTool::data.GeometricObject(id); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setTypeLine(typeLine); dialogTool->setFormula(formulaLength); dialogTool->setFirstPointId(basePointId); @@ -249,8 +249,8 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VPointF *firstPoint = data->GeometricObject(firstPointId); - const VPointF *secondPoint = data->GeometricObject(secondPointId); + const QSharedPointer firstPoint = data->GeometricObject(firstPointId); + const QSharedPointer secondPoint = data->GeometricObject(secondPointId); QLineF line = QLineF(firstPoint->toQPointF(), secondPoint->toQPointF()); line.setLength(qApp->toPixel(CheckFormula(_id, formula, data))); diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index b0a3b2180..1bbd344fe 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -74,7 +74,7 @@ void VToolArc::setDialog() SCASSERT(dialog != nullptr); DialogArc *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VArc *arc = VAbstractTool::data.GeometricObject(id); + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); dialogTool->SetCenter(arc->GetCenter().id()); dialogTool->SetF1(arc->GetFormulaF1()); dialogTool->SetF2(arc->GetFormulaF2()); @@ -132,7 +132,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &ra calcF1 = CheckFormula(_id, f1, data); calcF2 = CheckFormula(_id, f2, data); - VPointF c = *data->GeometricObject(center); + VPointF c = *data->GeometricObject(center); VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 ); quint32 id = _id; if (typeCreation == Source::FromGui) @@ -189,7 +189,7 @@ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolArc::AddToFile() { - const VArc *arc = VAbstractTool::data.GeometricObject(id); + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -208,7 +208,7 @@ void VToolArc::AddToFile() */ void VToolArc::RefreshDataInFile() { - const VArc *arc = VAbstractTool::data.GeometricObject(id); + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { @@ -225,7 +225,7 @@ void VToolArc::RefreshDataInFile() */ void VToolArc::RemoveReferens() { - const VArc *arc = VAbstractTool::data.GeometricObject(id); + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); doc->DecrementReferens(arc->GetCenter().id()); } diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp index df5a0cfbb..d6ff4d469 100644 --- a/src/app/tools/drawTools/vtoolbisector.cpp +++ b/src/app/tools/drawTools/vtoolbisector.cpp @@ -110,7 +110,7 @@ void VToolBisector::setDialog() SCASSERT(dialog != nullptr); DialogBisector *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *p = VAbstractTool::data.GeometricObject(id); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setTypeLine(typeLine); dialogTool->setFormula(formulaLength); dialogTool->setFirstPointId(firstPointId); @@ -173,9 +173,9 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VPointF *firstPoint = data->GeometricObject(firstPointId); - const VPointF *secondPoint = data->GeometricObject(secondPointId); - const VPointF *thirdPoint = data->GeometricObject(thirdPointId); + const QSharedPointer firstPoint = data->GeometricObject(firstPointId); + const QSharedPointer secondPoint = data->GeometricObject(secondPointId); + const QSharedPointer thirdPoint = data->GeometricObject(thirdPointId); const qreal result = CheckFormula(_id, formula, data); @@ -269,7 +269,7 @@ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolBisector::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -293,7 +293,7 @@ void VToolBisector::AddToFile() */ void VToolBisector::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { diff --git a/src/app/tools/drawTools/vtoolcut.cpp b/src/app/tools/drawTools/vtoolcut.cpp index 30ec3e935..4593f5112 100644 --- a/src/app/tools/drawTools/vtoolcut.cpp +++ b/src/app/tools/drawTools/vtoolcut.cpp @@ -92,7 +92,7 @@ void VToolCut::RefreshGeometry() { RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); - VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); + VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index a7998ff1b..b89cdcdad 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -75,7 +75,7 @@ void VToolCutArc::setDialog() SCASSERT(dialog != nullptr); DialogCutArc *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); dialogTool->setFormula(formula); dialogTool->setArcId(curveCutId); dialogTool->setPointName(point->name()); @@ -125,7 +125,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VArc *arc = data->GeometricObject(arcId); + const QSharedPointer arc = data->GeometricObject(arcId); const qreal result = CheckFormula(_id, formula, data); @@ -225,7 +225,7 @@ void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolCutArc::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -246,7 +246,7 @@ void VToolCutArc::AddToFile() */ void VToolCutArc::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { @@ -282,7 +282,7 @@ void VToolCutArc::SaveDialog(QDomElement &domElement) void VToolCutArc::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, PathDirection direction) { - const VArc *arc = VAbstractTool::data.GeometricObject(curveId); + const QSharedPointer arc = VAbstractTool::data.GeometricObject(curveId); QPainterPath path; path.addPath(arc->GetPath(direction)); path.setFillRule( Qt::WindingFill ); diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp index 6fa944056..7ab7352e5 100644 --- a/src/app/tools/drawTools/vtoolcutspline.cpp +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -74,7 +74,7 @@ void VToolCutSpline::setDialog() SCASSERT(dialog != nullptr); DialogCutSpline *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); dialogTool->setFormula(formula); dialogTool->setSplineId(curveCutId); dialogTool->setPointName(point->name()); @@ -119,7 +119,7 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VSpline *spl = data->GeometricObject(splineId); + const QSharedPointer spl = data->GeometricObject(splineId); const qreal result = CheckFormula(_id, formula, data); @@ -223,7 +223,7 @@ void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolCutSpline::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -244,7 +244,7 @@ void VToolCutSpline::AddToFile() */ void VToolCutSpline::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { @@ -280,7 +280,7 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement) void VToolCutSpline::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, PathDirection direction) { - const VSpline *spl = VAbstractTool::data.GeometricObject(curveId); + const QSharedPointer spl = VAbstractTool::data.GeometricObject(curveId); QPainterPath path; path.addPath(spl->GetPath(direction)); path.setFillRule( Qt::WindingFill ); diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index d91baa1e2..5148330a2 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -77,7 +77,7 @@ void VToolCutSplinePath::setDialog() SCASSERT(dialog != nullptr); DialogCutSplinePath *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); dialogTool->setFormula(formula); dialogTool->setSplinePathId(curveCutId); dialogTool->setPointName(point->name()); @@ -122,7 +122,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VSplinePath *splPath = data->GeometricObject(splinePathId); + const QSharedPointer splPath = data->GeometricObject(splinePathId); SCASSERT(splPath != nullptr); const qreal result = CheckFormula(_id, formula, data); @@ -278,7 +278,7 @@ void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolCutSplinePath::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -299,7 +299,7 @@ void VToolCutSplinePath::AddToFile() */ void VToolCutSplinePath::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { @@ -335,7 +335,7 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement) void VToolCutSplinePath::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, PathDirection direction) { - const VSplinePath *splPath = VAbstractTool::data.GeometricObject(curveId); + const QSharedPointer splPath = VAbstractTool::data.GeometricObject(curveId); QPainterPath path; path.addPath(splPath->GetPath(direction)); path.setFillRule( Qt::WindingFill ); diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp index e36663cde..b77479a13 100644 --- a/src/app/tools/drawTools/vtoolendline.cpp +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -73,7 +73,7 @@ void VToolEndLine::setDialog() dialog->setModal(true); DialogEndLine *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *p = VAbstractTool::data.GeometricObject(id); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setTypeLine(typeLine); dialogTool->setFormula(formulaLength); dialogTool->setAngle(formulaAngle); @@ -134,7 +134,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VPointF *basePoint = data->GeometricObject(basePointId); + const QSharedPointer basePoint = data->GeometricObject(basePointId); QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y())); line.setLength(qApp->toPixel(CheckFormula(_id, formulaLength, data))); @@ -213,7 +213,7 @@ void VToolEndLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) */ void VToolEndLine::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -236,7 +236,7 @@ void VToolEndLine::AddToFile() */ void VToolEndLine::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { diff --git a/src/app/tools/drawTools/vtoolheight.cpp b/src/app/tools/drawTools/vtoolheight.cpp index d19dd9ac0..8425e50f7 100644 --- a/src/app/tools/drawTools/vtoolheight.cpp +++ b/src/app/tools/drawTools/vtoolheight.cpp @@ -70,7 +70,7 @@ void VToolHeight::setDialog() SCASSERT(dialog != nullptr); DialogHeight *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *p = VAbstractTool::data.GeometricObject(id); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setTypeLine(typeLine); dialogTool->setBasePointId(basePointId); dialogTool->setP1LineId(p1LineId); @@ -132,9 +132,9 @@ VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, co const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VPointF *basePoint = data->GeometricObject(basePointId); - const VPointF *p1Line = data->GeometricObject(p1LineId); - const VPointF *p2Line = data->GeometricObject(p2LineId); + const QSharedPointer basePoint = data->GeometricObject(basePointId); + const QSharedPointer p1Line = data->GeometricObject(p1LineId); + const QSharedPointer p2Line = data->GeometricObject(p2LineId); QPointF pHeight = FindPoint(QLineF(p1Line->toQPointF(), p2Line->toQPointF()), basePoint->toQPointF()); quint32 id = _id; @@ -230,7 +230,7 @@ void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolHeight::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -254,7 +254,7 @@ void VToolHeight::AddToFile() */ void VToolHeight::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp index 035913be7..ef718f501 100644 --- a/src/app/tools/drawTools/vtoolline.cpp +++ b/src/app/tools/drawTools/vtoolline.cpp @@ -53,8 +53,8 @@ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstP this->typeLine = typeLine; ignoreFullUpdate = true; //Line - const VPointF *first = data->GeometricObject(firstPoint); - const VPointF *second = data->GeometricObject(secondPoint); + const QSharedPointer first = data->GeometricObject(firstPoint); + const QSharedPointer second = data->GeometricObject(secondPoint); this->setLine(QLineF(first->toQPointF(), second->toQPointF())); this->setFlag(QGraphicsItem::ItemStacksBehindParent, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true); @@ -379,8 +379,8 @@ void VToolLine::RefreshGeometry() secondPoint = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); typeLine = doc->GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); } - const VPointF *first = VAbstractTool::data.GeometricObject(firstPoint); - const VPointF *second = VAbstractTool::data.GeometricObject(secondPoint); + const QSharedPointer first = VAbstractTool::data.GeometricObject(firstPoint); + const QSharedPointer second = VAbstractTool::data.GeometricObject(secondPoint); this->setLine(QLineF(first->toQPointF(), second->toQPointF())); this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine))); } diff --git a/src/app/tools/drawTools/vtoollineintersect.cpp b/src/app/tools/drawTools/vtoollineintersect.cpp index d7ec86fe4..84c594214 100644 --- a/src/app/tools/drawTools/vtoollineintersect.cpp +++ b/src/app/tools/drawTools/vtoollineintersect.cpp @@ -72,7 +72,7 @@ void VToolLineIntersect::setDialog() SCASSERT(dialog != nullptr); DialogLineIntersect *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *p = VAbstractTool::data.GeometricObject(id); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setP1Line1(p1Line1); dialogTool->setP2Line1(p2Line1); dialogTool->setP1Line2(p1Line2); @@ -134,10 +134,10 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32 VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VPointF *p1Line1 = data->GeometricObject(p1Line1Id); - const VPointF *p2Line1 = data->GeometricObject(p2Line1Id); - const VPointF *p1Line2 = data->GeometricObject(p1Line2Id); - const VPointF *p2Line2 = data->GeometricObject(p2Line2Id); + const QSharedPointer p1Line1 = data->GeometricObject(p1Line1Id); + const QSharedPointer p2Line1 = data->GeometricObject(p2Line1Id); + const QSharedPointer p1Line2 = data->GeometricObject(p1Line2Id); + const QSharedPointer p2Line2 = data->GeometricObject(p2Line2Id); QLineF line1(p1Line1->toQPointF(), p2Line1->toQPointF()); QLineF line2(p1Line2->toQPointF(), p2Line2->toQPointF()); @@ -200,7 +200,7 @@ void VToolLineIntersect::FullUpdateFromFile() p1Line2 = domElement.attribute(AttrP1Line2, "").toUInt(); p2Line2 = domElement.attribute(AttrP2Line2, "").toUInt(); } - RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- @@ -211,7 +211,7 @@ void VToolLineIntersect::FullUpdateFromFile() void VToolLineIntersect::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); - RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- @@ -240,7 +240,7 @@ void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolLineIntersect::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -263,7 +263,7 @@ void VToolLineIntersect::AddToFile() */ void VToolLineIntersect::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { diff --git a/src/app/tools/drawTools/vtoollinepoint.cpp b/src/app/tools/drawTools/vtoollinepoint.cpp index 362fd4d57..6340b1c45 100644 --- a/src/app/tools/drawTools/vtoollinepoint.cpp +++ b/src/app/tools/drawTools/vtoollinepoint.cpp @@ -49,8 +49,8 @@ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &i { this->typeLine = typeLine; Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0"); - QPointF point1 = data->GeometricObject(basePointId)->toQPointF(); - QPointF point2 = data->GeometricObject(id)->toQPointF(); + QPointF point1 = data->GeometricObject(basePointId)->toQPointF(); + QPointF point2 = data->GeometricObject(id)->toQPointF(); mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this); mainLine->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine))); mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); @@ -82,9 +82,9 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName) void VToolLinePoint::RefreshGeometry() { mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine))); - VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); - QPointF point = VDrawTool::data.GeometricObject(id)->toQPointF(); - QPointF basePoint = VDrawTool::data.GeometricObject(basePointId)->toQPointF(); + VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); + QPointF point = VDrawTool::data.GeometricObject(id)->toQPointF(); + QPointF basePoint = VDrawTool::data.GeometricObject(basePointId)->toQPointF(); mainLine->setLine(QLineF(basePoint - point, QPointF())); } diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp index 8f18c438b..41ea76357 100644 --- a/src/app/tools/drawTools/vtoolnormal.cpp +++ b/src/app/tools/drawTools/vtoolnormal.cpp @@ -73,7 +73,7 @@ void VToolNormal::setDialog() SCASSERT(dialog != nullptr); DialogNormal *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *p = VAbstractTool::data.GeometricObject(id); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setTypeLine(typeLine); dialogTool->setFormula(formulaLength); dialogTool->setAngle(angle); @@ -135,8 +135,8 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VPointF *firstPoint = data->GeometricObject(firstPointId); - const VPointF *secondPoint = data->GeometricObject(secondPointId); + const QSharedPointer firstPoint = data->GeometricObject(firstPointId); + const QSharedPointer secondPoint = data->GeometricObject(secondPointId); const qreal result = CheckFormula(_id, formula, data); @@ -248,7 +248,7 @@ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolNormal::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -272,7 +272,7 @@ void VToolNormal::AddToFile() */ void VToolNormal::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { diff --git a/src/app/tools/drawTools/vtoolpoint.cpp b/src/app/tools/drawTools/vtoolpoint.cpp index c58285bfd..3f4c8cb1c 100644 --- a/src/app/tools/drawTools/vtoolpoint.cpp +++ b/src/app/tools/drawTools/vtoolpoint.cpp @@ -56,7 +56,7 @@ VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsIte this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); - RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- @@ -79,7 +79,7 @@ void VToolPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option */ void VToolPoint::NameChangePosition(const QPointF &pos) { - VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject(id)); + VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject(id)); QPointF p = pos - this->pos(); point->setMx(p.x()); point->setMy(p.y()); @@ -155,7 +155,7 @@ void VToolPoint::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) void VToolPoint::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); - RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp index c400041aa..0f7ae3e28 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp @@ -72,7 +72,7 @@ void VToolPointOfContact::setDialog() SCASSERT(dialog != nullptr); DialogPointOfContact *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *p = VAbstractTool::data.GeometricObject(id); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setRadius(arcRadius); dialogTool->setCenter(center); dialogTool->setFirstPoint(firstPointId); @@ -167,9 +167,9 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VPointF *centerP = data->GeometricObject(center); - const VPointF *firstP = data->GeometricObject(firstPointId); - const VPointF *secondP = data->GeometricObject(secondPointId); + const QSharedPointer centerP = data->GeometricObject(center); + const QSharedPointer firstP = data->GeometricObject(firstPointId); + const QSharedPointer secondP = data->GeometricObject(secondPointId); const qreal result = CheckFormula(_id, radius, data); @@ -226,7 +226,7 @@ void VToolPointOfContact::FullUpdateFromFile() firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt(); secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); } - RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- @@ -237,7 +237,7 @@ void VToolPointOfContact::FullUpdateFromFile() void VToolPointOfContact::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); - RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- @@ -266,7 +266,7 @@ void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event */ void VToolPointOfContact::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -289,7 +289,7 @@ void VToolPointOfContact::AddToFile() */ void VToolPointOfContact::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { diff --git a/src/app/tools/drawTools/vtoolpointofintersection.cpp b/src/app/tools/drawTools/vtoolpointofintersection.cpp index 3ff069da6..10790a8b4 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.cpp +++ b/src/app/tools/drawTools/vtoolpointofintersection.cpp @@ -68,7 +68,7 @@ void VToolPointOfIntersection::setDialog() SCASSERT(dialog != nullptr); DialogPointOfIntersection *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *p = VAbstractTool::data.GeometricObject(id); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setFirstPointId(firstPointId); dialogTool->setSecondPointId(secondPointId); dialogTool->setPointName(p->name()); @@ -124,8 +124,8 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, co VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VPointF *firstPoint = data->GeometricObject(firstPointId); - const VPointF *secondPoint = data->GeometricObject(secondPointId); + const QSharedPointer firstPoint = data->GeometricObject(firstPointId); + const QSharedPointer secondPoint = data->GeometricObject(secondPointId); QPointF point(firstPoint->x(), secondPoint->y()); quint32 id = _id; @@ -170,7 +170,7 @@ void VToolPointOfIntersection::FullUpdateFromFile() firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt(); secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); } - VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); + VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- @@ -209,7 +209,7 @@ void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent * */ void VToolPointOfIntersection::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -230,7 +230,7 @@ void VToolPointOfIntersection::AddToFile() */ void VToolPointOfIntersection::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp index bec148cee..da67ecb83 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp @@ -72,7 +72,7 @@ void VToolShoulderPoint::setDialog() SCASSERT(dialog != nullptr); DialogShoulderPoint *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *p = VAbstractTool::data.GeometricObject(id); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setTypeLine(typeLine); dialogTool->setFormula(formulaLength); dialogTool->setP1Line(basePointId); @@ -174,9 +174,9 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VPointF *firstPoint = data->GeometricObject(p1Line); - const VPointF *secondPoint = data->GeometricObject(p2Line); - const VPointF *shoulderPoint = data->GeometricObject(pShoulder); + const QSharedPointer firstPoint = data->GeometricObject(p1Line); + const QSharedPointer secondPoint = data->GeometricObject(p2Line); + const QSharedPointer shoulderPoint = data->GeometricObject(pShoulder); const qreal result = CheckFormula(_id, formula, data); @@ -273,7 +273,7 @@ void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolShoulderPoint::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -297,7 +297,7 @@ void VToolShoulderPoint::AddToFile() */ void VToolShoulderPoint::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { diff --git a/src/app/tools/drawTools/vtoolsinglepoint.cpp b/src/app/tools/drawTools/vtoolsinglepoint.cpp index ca06a51ce..408af790e 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/app/tools/drawTools/vtoolsinglepoint.cpp @@ -78,7 +78,7 @@ void VToolSinglePoint::setDialog() SCASSERT(dialog != nullptr); DialogSinglePoint *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *p = VAbstractTool::data.GeometricObject(id); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setData(p->name(), p->toQPointF()); } @@ -90,7 +90,7 @@ void VToolSinglePoint::AddToFile() { Q_ASSERT_X(namePP.isEmpty() == false, "AddToFile", "name pattern piece is empty"); - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement sPoint = doc->createElement(TagName); // Create SPoint tag @@ -125,7 +125,7 @@ void VToolSinglePoint::AddToFile() */ void VToolSinglePoint::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { @@ -304,7 +304,7 @@ void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event */ void VToolSinglePoint::FullUpdateFromFile() { - VPointF point = *VAbstractTool::data.GeometricObject(id); + VPointF point = *VAbstractTool::data.GeometricObject(id); RefreshPointGeometry(point); } @@ -337,7 +337,7 @@ void VToolSinglePoint::ChangedActivDraw(const QString &newName) void VToolSinglePoint::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); - RefreshPointGeometry(*(VAbstractTool::data.GeometricObject(id))); + RefreshPointGeometry(*(VAbstractTool::data.GeometricObject(id))); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index efc043fb5..47e71f20d 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -54,7 +54,7 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Sour this->setAcceptHoverEvents(true); this->setPath(ToolPath()); - const VSpline *spl = VAbstractTool::data.GeometricObject(id); + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePointPosition::FirstPoint, spl->GetP2(), spl->GetP1().toQPointF(), this); connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this, @@ -90,7 +90,7 @@ void VToolSpline::setDialog() SCASSERT(dialog != nullptr); DialogSpline *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VSpline *spl = VAbstractTool::data.GeometricObject(id); + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); dialogTool->setP1(spl->GetP1().id()); dialogTool->setP4(spl->GetP4().id()); dialogTool->setAngle1(spl->GetAngle1()); @@ -154,8 +154,8 @@ VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const qui VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - VPointF point1 = *data->GeometricObject(p1); - VPointF point4 = *data->GeometricObject(p4); + VPointF point1 = *data->GeometricObject(p1); + VPointF point4 = *data->GeometricObject(p4); VSpline *spline = new VSpline(point1, point4, angle1, angle2, kAsm1, kAsm2, kCurve); quint32 id = _id; if (typeCreation == Source::FromGui) @@ -199,7 +199,7 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp const QPointF &pos) { Q_UNUSED(indexSpline); - const VSpline *spline = VAbstractTool::data.GeometricObject(id); + const QSharedPointer spline = VAbstractTool::data.GeometricObject(id); VSpline spl; if (position == SplinePointPosition::FirstPoint) { @@ -210,7 +210,7 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp spl = VSpline(spline->GetP1(), spline->GetP2(), pos, spline->GetP4(), spline->GetKcurve()); } - MoveSpline *moveSpl = new MoveSpline(doc, spline, spl, id, this->scene()); + MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, id, this->scene()); connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VPattern::LiteParseTree); qApp->getUndoStack()->push(moveSpl); } @@ -231,7 +231,7 @@ void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolSpline::AddToFile() { - const VSpline *spl = VAbstractTool::data.GeometricObject(id); + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -253,7 +253,7 @@ void VToolSpline::AddToFile() */ void VToolSpline::RefreshDataInFile() { - const VSpline *spl = VAbstractTool::data.GeometricObject(id); + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { @@ -273,7 +273,7 @@ void VToolSpline::RefreshDataInFile() */ void VToolSpline::RemoveReferens() { - const VSpline *spl = VAbstractTool::data.GeometricObject(id); + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); doc->DecrementReferens(spl->GetP1().id()); doc->DecrementReferens(spl->GetP4().id()); } @@ -288,8 +288,8 @@ void VToolSpline::SaveDialog(QDomElement &domElement) DialogSpline *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - VPointF point1 = *VAbstractTool::data.GeometricObject(dialogTool->getP1()); - VPointF point4 = *VAbstractTool::data.GeometricObject(dialogTool->getP4()); + VPointF point1 = *VAbstractTool::data.GeometricObject(dialogTool->getP1()); + VPointF point4 = *VAbstractTool::data.GeometricObject(dialogTool->getP4()); VSpline spl = VSpline (point1, point4, dialogTool->getAngle1(), dialogTool->getAngle2(), dialogTool->getKAsm1(), dialogTool->getKAsm2(), dialogTool->getKCurve()); @@ -329,11 +329,11 @@ void VToolSpline::RefreshGeometry() this->setPath(ToolPath()); } - const VSpline *spl = VAbstractTool::data.GeometricObject(id); - QPointF splinePoint = VAbstractTool::data.GeometricObject(spl->GetP1().id())->toQPointF(); + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); + QPointF splinePoint = VAbstractTool::data.GeometricObject(spl->GetP1().id())->toQPointF(); QPointF controlPoint = spl->GetP2(); emit RefreshLine(1, SplinePointPosition::FirstPoint, controlPoint, splinePoint); - splinePoint = VAbstractTool::data.GeometricObject(spl->GetP4().id())->toQPointF(); + splinePoint = VAbstractTool::data.GeometricObject(spl->GetP4().id())->toQPointF(); controlPoint = spl->GetP3(); emit RefreshLine(1, SplinePointPosition::LastPoint, controlPoint, splinePoint); diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index e85c744ba..d66847b4e 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -53,7 +53,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); - const VSplinePath *splPath = data->GeometricObject(id); + const QSharedPointer splPath = data->GeometricObject(id); for (qint32 i = 1; i<=splPath->Count(); ++i) { VSpline spl = splPath->GetSpline(i); @@ -92,7 +92,7 @@ void VToolSplinePath::setDialog() SCASSERT(dialog != nullptr); DialogSplinePath *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VSplinePath *splPath = VAbstractTool::data.GeometricObject(id); + const QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); dialogTool->SetPath(*splPath); } @@ -168,7 +168,7 @@ void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphics void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position, const QPointF &pos) { - VSplinePath oldSplPath = *VAbstractTool::data.GeometricObject(id); + VSplinePath oldSplPath = *VAbstractTool::data.GeometricObject(id); VSplinePath newSplPath = oldSplPath; VSpline spl = newSplPath.GetSpline(indexSpline); if (position == SplinePointPosition::FirstPoint) @@ -272,7 +272,7 @@ void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolSplinePath::AddToFile() { - VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); + VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -299,7 +299,7 @@ void VToolSplinePath::RefreshDataInFile() qDebug()<<"Can't find element with id="<(id); + VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); RefreshSplinePath(splPath); doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); UpdatePathPoint(doc, domElement, splPath); @@ -329,7 +329,7 @@ void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint & */ void VToolSplinePath::RemoveReferens() { - VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); + VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); for (qint32 i = 0; i < splPath.Count(); ++i) { doc->DecrementReferens(splPath.at(i).P().id()); @@ -367,7 +367,7 @@ void VToolSplinePath::RefreshGeometry() this->setPath(ToolPath()); } - const VSplinePath *splPath = VAbstractTool::data.GeometricObject(id); + const QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); for (qint32 i = 1; i<=splPath->Count(); ++i) { VSpline spl = splPath->GetSpline(i); diff --git a/src/app/tools/drawTools/vtooltriangle.cpp b/src/app/tools/drawTools/vtooltriangle.cpp index 38486eff1..73021e3f2 100644 --- a/src/app/tools/drawTools/vtooltriangle.cpp +++ b/src/app/tools/drawTools/vtooltriangle.cpp @@ -73,7 +73,7 @@ void VToolTriangle::setDialog() SCASSERT(dialog != nullptr); DialogTriangle *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const VPointF *p = VAbstractTool::data.GeometricObject(id); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setAxisP1Id(axisP1Id); dialogTool->setAxisP2Id(axisP2Id); dialogTool->setFirstPointId(firstPointId); @@ -133,10 +133,10 @@ VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { - const VPointF *axisP1 = data->GeometricObject(axisP1Id); - const VPointF *axisP2 = data->GeometricObject(axisP2Id); - const VPointF *firstPoint = data->GeometricObject(firstPointId); - const VPointF *secondPoint = data->GeometricObject(secondPointId); + const QSharedPointer axisP1 = data->GeometricObject(axisP1Id); + const QSharedPointer axisP2 = data->GeometricObject(axisP2Id); + const QSharedPointer firstPoint = data->GeometricObject(firstPointId); + const QSharedPointer secondPoint = data->GeometricObject(secondPointId); QPointF point = FindPoint(axisP1->toQPointF(), axisP2->toQPointF(), firstPoint->toQPointF(), secondPoint->toQPointF()); @@ -228,7 +228,7 @@ void VToolTriangle::FullUpdateFromFile() firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt(); secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); } - VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); + VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- @@ -269,7 +269,7 @@ void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolTriangle::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -292,7 +292,7 @@ void VToolTriangle::AddToFile() */ void VToolTriangle::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { diff --git a/src/app/tools/nodeDetails/vnodearc.cpp b/src/app/tools/nodeDetails/vnodearc.cpp index 0b9d03cfa..802265e19 100644 --- a/src/app/tools/nodeDetails/vnodearc.cpp +++ b/src/app/tools/nodeDetails/vnodearc.cpp @@ -211,7 +211,7 @@ void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) */ void VNodeArc::RefreshGeometry() { - const VArc *arc = VAbstractTool::data.GeometricObject(id); + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); QPainterPath path; path.addPath(arc->GetPath()); path.setFillRule( Qt::WindingFill ); diff --git a/src/app/tools/nodeDetails/vnodepoint.cpp b/src/app/tools/nodeDetails/vnodepoint.cpp index 9b27d5b5e..5e02e2443 100644 --- a/src/app/tools/nodeDetails/vnodepoint.cpp +++ b/src/app/tools/nodeDetails/vnodepoint.cpp @@ -64,7 +64,7 @@ VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPo this->setBrush(QBrush(Qt::NoBrush)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setAcceptHoverEvents(true); - RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); if (typeCreation == Source::FromGui) { AddToFile(); @@ -142,7 +142,7 @@ void VNodePoint::RestoreNode() */ void VNodePoint::FullUpdateFromFile() { - RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- @@ -151,7 +151,7 @@ void VNodePoint::FullUpdateFromFile() */ void VNodePoint::AddToFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); doc->SetAttribute(domElement, VDomDocument::AttrId, id); @@ -173,7 +173,7 @@ void VNodePoint::AddToFile() */ void VNodePoint::RefreshDataInFile() { - const VPointF *point = VAbstractTool::data.GeometricObject(id); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { @@ -230,7 +230,7 @@ void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) */ void VNodePoint::NameChangePosition(const QPointF &pos) { - VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject(id)); + VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject(id)); QPointF p = pos - this->pos(); point->setMx(p.x()); point->setMy(p.y()); diff --git a/src/app/tools/nodeDetails/vnodespline.cpp b/src/app/tools/nodeDetails/vnodespline.cpp index 1126ff51e..ffbe5327d 100644 --- a/src/app/tools/nodeDetails/vnodespline.cpp +++ b/src/app/tools/nodeDetails/vnodespline.cpp @@ -214,7 +214,7 @@ void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) */ void VNodeSpline::RefreshGeometry() { - const VSpline *spl = VAbstractTool::data.GeometricObject(id); + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); QPainterPath path; path.addPath(spl->GetPath()); path.setFillRule( Qt::WindingFill ); diff --git a/src/app/tools/nodeDetails/vnodesplinepath.cpp b/src/app/tools/nodeDetails/vnodesplinepath.cpp index 06bbe5eb4..9451e3f11 100644 --- a/src/app/tools/nodeDetails/vnodesplinepath.cpp +++ b/src/app/tools/nodeDetails/vnodesplinepath.cpp @@ -86,7 +86,7 @@ void VNodeSplinePath::Create(VPattern *doc, VContainer *data, quint32 id, quint3 { VNodeSplinePath *splPath = new VNodeSplinePath(doc, data, id, idSpline, typeCreation, idTool, parent); doc->AddTool(id, splPath); - const VSplinePath *path = data->GeometricObject(id); + const QSharedPointer path = data->GeometricObject(id); const QVector *points = path->GetPoint(); for (qint32 i = 0; isize(); ++i) { @@ -217,7 +217,7 @@ void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) */ void VNodeSplinePath::RefreshGeometry() { - const VSplinePath *splPath = VAbstractTool::data.GeometricObject(id); + const QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); QPainterPath path; path.addPath(splPath->GetPath()); path.setFillRule( Qt::WindingFill ); diff --git a/src/app/tools/vdatatool.h b/src/app/tools/vdatatool.h index 887a74fd2..b06c1dbca 100644 --- a/src/app/tools/vdatatool.h +++ b/src/app/tools/vdatatool.h @@ -74,6 +74,8 @@ inline VContainer VDataTool::getData() const */ inline void VDataTool::setData(const VContainer *value) { + data.ClearVariables(); + data.ClearGObjects(); data = *value; } diff --git a/src/app/tools/vtooldetail.h b/src/app/tools/vtooldetail.h index b29b6c969..df90ad8e5 100644 --- a/src/app/tools/vtooldetail.h +++ b/src/app/tools/vtooldetail.h @@ -58,7 +58,7 @@ public: static quint32 CreateNode(VContainer *data, const quint32 &id) { //We can't use exist object. Need create new. - T *node = new T(*data->GeometricObject(id)); + T *node = new T(*data->GeometricObject(id).data()); node->setMode(Draw::Modeling); return data->AddGObject(node); } diff --git a/src/app/tools/vtooluniondetails.cpp b/src/app/tools/vtooluniondetails.cpp index 93a046b4b..76b9dfc7c 100644 --- a/src/app/tools/vtooluniondetails.cpp +++ b/src/app/tools/vtooluniondetails.cpp @@ -104,9 +104,9 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer } else { - VPointF *point = new VPointF(*data->GeometricObject(det.at(i).getId())); + VPointF *point = new VPointF(*data->GeometricObject(det.at(i).getId())); point->setMode(Draw::Modeling); - BiasRotatePoint(point, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + BiasRotatePoint(point, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); idObject = data->AddGObject(point); VPointF *point1 = new VPointF(*point); @@ -124,13 +124,13 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer } else { - const VArc *arc = data->GeometricObject(det.at(i).getId()); + const QSharedPointer arc = data->GeometricObject(det.at(i).getId()); VPointF p1 = VPointF(arc->GetP1(), "A", 0, 0); - BiasRotatePoint(&p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(&p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF p2 = VPointF(arc->GetP2(), "A", 0, 0); - BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF *center = new VPointF(arc->GetCenter()); - BiasRotatePoint(center, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + BiasRotatePoint(center, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); QLineF l1(center->toQPointF(), p1.toQPointF()); @@ -160,20 +160,20 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer } else { - const VSpline *spline = data->GeometricObject(det.at(i).getId()); + const QSharedPointer spline = data->GeometricObject(det.at(i).getId()); VPointF *p1 = new VPointF(spline->GetP1()); - BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); //quint32 idP1 = data->AddGObject(p1); VPointF p2 = VPointF(spline->GetP2()); - BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF p3 = VPointF(spline->GetP3()); - BiasRotatePoint(&p3, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(&p3, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF *p4 = new VPointF(spline->GetP4()); - BiasRotatePoint(p4, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(p4, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); //quint32 idP4 = data->AddGObject(p4); VSpline *spl = new VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline->GetKcurve(), 0, @@ -197,7 +197,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer { VSplinePath *path = new VSplinePath(); path->setMode(Draw::Modeling); - const VSplinePath *splinePath = data->GeometricObject(det.at(i).getId()); + const QSharedPointer splinePath = data->GeometricObject(det.at(i).getId()); qint32 k = splinePath->getMaxCountPoints(); for (qint32 i = 1; i <= splinePath->Count(); ++i) { @@ -206,21 +206,21 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer splinePath->at(i).KAsm1(), splinePath->getKCurve()); VPointF *p1 = new VPointF(spline.GetP1()); - BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); //quint32 idP1 = data->AddGObject(p1); --k; VPointF p2 = VPointF(spline.GetP2()); - BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF p3 = VPointF(spline.GetP3()); - BiasRotatePoint(&p3, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + BiasRotatePoint(&p3, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF *p4 = new VPointF(spline.GetP4()); - BiasRotatePoint(p4, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + BiasRotatePoint(p4, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); //quint32 idP4 = data->AddGObject(p4); --k; @@ -278,9 +278,9 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, { if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0) { - VPointF *point = new VPointF(*data->GeometricObject(det.at(i).getId())); + VPointF *point = new VPointF(*data->GeometricObject(det.at(i).getId())); point->setMode(Draw::Modeling); - BiasRotatePoint(point, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(point, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); ++idCount; data->UpdateGObject(idDetail+idCount, point); @@ -292,13 +292,13 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, { if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0) { - const VArc *arc = data->GeometricObject(det.at(i).getId()); + const QSharedPointer arc = data->GeometricObject(det.at(i).getId()); VPointF p1 = VPointF(arc->GetP1()); - BiasRotatePoint(&p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(&p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF p2 = VPointF(arc->GetP2()); - BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF *center = new VPointF(arc->GetCenter()); - BiasRotatePoint(center, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + BiasRotatePoint(center, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); QLineF l1(center->toQPointF(), p1.toQPointF()); @@ -320,21 +320,21 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, { if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0) { - const VSpline *spline = data->GeometricObject(det.at(i).getId()); + const QSharedPointer spline = data->GeometricObject(det.at(i).getId()); VPointF *p1 = new VPointF(spline->GetP1()); - BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); ++idCount; data->UpdateGObject(idDetail+idCount, p1); VPointF p2 = VPointF(spline->GetP2()); - BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF p3 = VPointF(spline->GetP3()); - BiasRotatePoint(&p3, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(&p3, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF *p4 = new VPointF(spline->GetP4()); - BiasRotatePoint(p4, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); + BiasRotatePoint(p4, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); ++idCount; data->UpdateGObject(idDetail+idCount, p4); @@ -354,7 +354,7 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, { VSplinePath *path = new VSplinePath(); path->setMode(Draw::Modeling); - const VSplinePath *splinePath = data->GeometricObject(det.at(i).getId()); + const QSharedPointer splinePath = data->GeometricObject(det.at(i).getId()); SCASSERT(splinePath != nullptr); qint32 k = splinePath->getMaxCountPoints(); for (qint32 i = 1; i <= splinePath->Count(); ++i) @@ -364,22 +364,22 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, splinePath->at(i).KAsm1(), splinePath->getKCurve()); VPointF *p1 = new VPointF(spline.GetP1()); - BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); ++idCount; data->UpdateGObject(idDetail+idCount, p1); --k; VPointF p2 = VPointF(spline.GetP2()); - BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + BiasRotatePoint(&p2, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF p3 = VPointF(spline.GetP3()); - BiasRotatePoint(&p3, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + BiasRotatePoint(&p3, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); VPointF *p4 = new VPointF(spline.GetP4()); - BiasRotatePoint(p4, dx, dy, data->GeometricObject(pRotate)->toQPointF(), + BiasRotatePoint(p4, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); ++idCount; data->UpdateGObject(idDetail+idCount, p4); @@ -617,8 +617,8 @@ void VToolUnionDetails::PointsOnEdge(const VDetail &d, const quint32 &index, VPo VNodeDetail det2p1; VNodeDetail det2p2; d.NodeOnEdge(index, det2p1, det2p2); - p1 = VPointF(*data->GeometricObject(det2p1.getId())); - p2 = VPointF(*data->GeometricObject(det2p2.getId())); + p1 = VPointF(*data->GeometricObject(det2p1.getId())); + p2 = VPointF(*data->GeometricObject(det2p2.getId())); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/visualization/vistoolalongline.cpp b/src/app/visualization/vistoolalongline.cpp index 004b7f489..9e378b862 100644 --- a/src/app/visualization/vistoolalongline.cpp +++ b/src/app/visualization/vistoolalongline.cpp @@ -65,7 +65,7 @@ void VisToolAlongLine::RefreshGeometry() { if (point1Id > 0) { - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); DrawPoint(lineP1, first->toQPointF(), supportColor); if (point2Id <= 0) @@ -74,7 +74,7 @@ void VisToolAlongLine::RefreshGeometry() } else { - const VPointF *second = Visualization::data->GeometricObject(point2Id); + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); DrawPoint(lineP2, second->toQPointF(), supportColor); DrawLine(line, QLineF(first->toQPointF(), second->toQPointF()), supportColor); diff --git a/src/app/visualization/vistoolarc.cpp b/src/app/visualization/vistoolarc.cpp index cadebd346..81dddad2b 100644 --- a/src/app/visualization/vistoolarc.cpp +++ b/src/app/visualization/vistoolarc.cpp @@ -47,7 +47,7 @@ void VisToolArc::RefreshGeometry() { if (point1Id > 0) { - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); DrawPoint(arcCenter, first->toQPointF(), supportColor); if (qFuzzyCompare(1 + radius, 1 + 0) == false && f1 >= 0 && f2 >= 0 && qFuzzyCompare(1 + f1, 1 + f2) == false) diff --git a/src/app/visualization/vistoolbisector.cpp b/src/app/visualization/vistoolbisector.cpp index 0ff245193..695933f5a 100644 --- a/src/app/visualization/vistoolbisector.cpp +++ b/src/app/visualization/vistoolbisector.cpp @@ -73,7 +73,7 @@ void VisToolBisector::RefreshGeometry() { if (point1Id > 0) { - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); DrawPoint(line1P1, first->toQPointF(), supportColor); if (point2Id <= 0) @@ -82,7 +82,7 @@ void VisToolBisector::RefreshGeometry() } else { - const VPointF *second = Visualization::data->GeometricObject(point2Id); + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); DrawPoint(line1P2, second->toQPointF(), supportColor); DrawLine(line1, QLineF(first->toQPointF(), second->toQPointF()), supportColor); @@ -93,7 +93,7 @@ void VisToolBisector::RefreshGeometry() } else { - const VPointF *third = Visualization::data->GeometricObject(point3Id); + const QSharedPointer third = Visualization::data->GeometricObject(point3Id); DrawPoint(line2P2, third->toQPointF(), supportColor); DrawLine(line2, QLineF(second->toQPointF(), third->toQPointF()), supportColor); diff --git a/src/app/visualization/vistoolcutarc.cpp b/src/app/visualization/vistoolcutarc.cpp index 6c9465f9f..5acfd2964 100644 --- a/src/app/visualization/vistoolcutarc.cpp +++ b/src/app/visualization/vistoolcutarc.cpp @@ -53,7 +53,7 @@ void VisToolCutArc::RefreshGeometry() { if (point1Id > 0) { - const VArc *arc = Visualization::data->GeometricObject(point1Id); + const QSharedPointer arc = Visualization::data->GeometricObject(point1Id); DrawPath(this, arc->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); if (qFuzzyCompare(1 + length, 1 + 0) == false) diff --git a/src/app/visualization/vistoolendline.cpp b/src/app/visualization/vistoolendline.cpp index 865f3e2c1..267f2de14 100644 --- a/src/app/visualization/vistoolendline.cpp +++ b/src/app/visualization/vistoolendline.cpp @@ -50,7 +50,7 @@ VisToolEndLine::~VisToolEndLine() //--------------------------------------------------------------------------------------------------------------------- void VisToolEndLine::RefreshGeometry() { - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); QLineF line; if (qFuzzyCompare(1 + length, 1 + 0)) { diff --git a/src/app/visualization/vistoolheight.cpp b/src/app/visualization/vistoolheight.cpp index 8bbf9a9ae..26cdbf2b4 100644 --- a/src/app/visualization/vistoolheight.cpp +++ b/src/app/visualization/vistoolheight.cpp @@ -53,7 +53,7 @@ void VisToolHeight::RefreshGeometry() { if (point1Id > 0) { - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); DrawPoint(base_point, first->toQPointF(), supportColor); if (lineP1Id <= 0) @@ -62,7 +62,7 @@ void VisToolHeight::RefreshGeometry() } else { - const VPointF *second = Visualization::data->GeometricObject(lineP1Id); + const QSharedPointer second = Visualization::data->GeometricObject(lineP1Id); DrawPoint(lineP1, second->toQPointF(), supportColor); QLineF base_line; @@ -73,7 +73,7 @@ void VisToolHeight::RefreshGeometry() } else { - const VPointF *third = Visualization::data->GeometricObject(lineP2Id); + const QSharedPointer third = Visualization::data->GeometricObject(lineP2Id); DrawPoint(lineP2, third->toQPointF(), supportColor); base_line = QLineF(second->toQPointF(), third->toQPointF()); diff --git a/src/app/visualization/vistoolline.cpp b/src/app/visualization/vistoolline.cpp index c6fc56995..3ce21c3f8 100644 --- a/src/app/visualization/vistoolline.cpp +++ b/src/app/visualization/vistoolline.cpp @@ -46,14 +46,14 @@ VisToolLine::~VisToolLine() void VisToolLine::RefreshGeometry() { QLineF line; - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); if (point2Id == 0) { line = QLineF(first->toQPointF(), Visualization::scenePos); } else { - const VPointF *second = Visualization::data->GeometricObject(point2Id); + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); line = QLineF(first->toQPointF(), second->toQPointF()); } DrawLine(this, line, mainColor, lineStyle); diff --git a/src/app/visualization/vistoollineintersect.cpp b/src/app/visualization/vistoollineintersect.cpp index c3ab55d65..3e2b2981b 100644 --- a/src/app/visualization/vistoollineintersect.cpp +++ b/src/app/visualization/vistoollineintersect.cpp @@ -54,7 +54,7 @@ void VisToolLineIntersect::RefreshGeometry() { if (point1Id > 0) { - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); DrawPoint(line1P1, first->toQPointF(), supportColor); if (line1P2Id <= 0) @@ -63,7 +63,7 @@ void VisToolLineIntersect::RefreshGeometry() } else { - const VPointF *second = Visualization::data->GeometricObject(line1P2Id); + const QSharedPointer second = Visualization::data->GeometricObject(line1P2Id); DrawPoint(line1P2, second->toQPointF(), supportColor); DrawLine(line1, QLineF(first->toQPointF(), second->toQPointF()), supportColor); @@ -74,7 +74,7 @@ void VisToolLineIntersect::RefreshGeometry() } else { - const VPointF *third = Visualization::data->GeometricObject(line2P1Id); + const QSharedPointer third = Visualization::data->GeometricObject(line2P1Id); DrawPoint(line2P1, third->toQPointF(), supportColor); if (line2P2Id <= 0) @@ -92,7 +92,7 @@ void VisToolLineIntersect::RefreshGeometry() } else { - const VPointF *forth = Visualization::data->GeometricObject(line2P2Id); + const QSharedPointer forth = Visualization::data->GeometricObject(line2P2Id); DrawPoint(line2P2, forth->toQPointF(), supportColor); DrawLine(this, QLineF(third->toQPointF(), forth->toQPointF()), supportColor); diff --git a/src/app/visualization/vistoolnormal.cpp b/src/app/visualization/vistoolnormal.cpp index af11fe951..ebaae9da7 100644 --- a/src/app/visualization/vistoolnormal.cpp +++ b/src/app/visualization/vistoolnormal.cpp @@ -53,7 +53,7 @@ void VisToolNormal::RefreshGeometry() { if (point1Id > 0) { - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); DrawPoint(lineP1, first->toQPointF(), supportColor); if (point2Id <= 0) @@ -67,7 +67,7 @@ void VisToolNormal::RefreshGeometry() } else { - const VPointF *second = Visualization::data->GeometricObject(point2Id); + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); DrawPoint(lineP2, second->toQPointF(), supportColor); QLineF line_mouse(first->toQPointF(), second->toQPointF()); diff --git a/src/app/visualization/vistoolpointofcontact.cpp b/src/app/visualization/vistoolpointofcontact.cpp index 1af058f3a..96950dee8 100644 --- a/src/app/visualization/vistoolpointofcontact.cpp +++ b/src/app/visualization/vistoolpointofcontact.cpp @@ -52,7 +52,7 @@ void VisToolPointOfContact::RefreshGeometry() { if (point1Id > 0) { - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); DrawPoint(lineP1, first->toQPointF(), supportColor); if (lineP2Id <= 0) @@ -61,7 +61,7 @@ void VisToolPointOfContact::RefreshGeometry() } else { - const VPointF *second = Visualization::data->GeometricObject(lineP2Id); + const QSharedPointer second = Visualization::data->GeometricObject(lineP2Id); DrawPoint(lineP2, second->toQPointF(), supportColor); DrawLine(this, QLineF(first->toQPointF(), second->toQPointF()), supportColor); @@ -71,7 +71,7 @@ void VisToolPointOfContact::RefreshGeometry() } else { - const VPointF *third = Visualization::data->GeometricObject(radiusId); + const QSharedPointer third = Visualization::data->GeometricObject(radiusId); DrawPoint(arc_point, third->toQPointF(), supportColor); if (qFuzzyCompare(1 + radius, 1 + 0) == false) diff --git a/src/app/visualization/vistoolpointofintersection.cpp b/src/app/visualization/vistoolpointofintersection.cpp index f6f98136a..a2282ab9c 100644 --- a/src/app/visualization/vistoolpointofintersection.cpp +++ b/src/app/visualization/vistoolpointofintersection.cpp @@ -50,7 +50,7 @@ void VisToolPointOfIntersection::RefreshGeometry() { if (point1Id > 0) { - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); DrawPoint(axisP1, first->toQPointF(), supportColor); QLineF axisL1 = Axis(first->toQPointF(), 90); @@ -63,7 +63,7 @@ void VisToolPointOfIntersection::RefreshGeometry() } else { - const VPointF *second = Visualization::data->GeometricObject(point2Id); + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); DrawPoint(axisP2, second->toQPointF(), supportColor); axisL2 = Axis(second->toQPointF(), 180); ShowIntersection(axisL1, axisL2); diff --git a/src/app/visualization/vistoolshoulderpoint.cpp b/src/app/visualization/vistoolshoulderpoint.cpp index aefca4667..49283788f 100644 --- a/src/app/visualization/vistoolshoulderpoint.cpp +++ b/src/app/visualization/vistoolshoulderpoint.cpp @@ -55,7 +55,7 @@ void VisToolShoulderPoint::RefreshGeometry() { if (point1Id > 0) { - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); DrawPoint(line1P1, first->toQPointF(), supportColor); if (lineP1Id <= 0) @@ -64,7 +64,7 @@ void VisToolShoulderPoint::RefreshGeometry() } else { - const VPointF *second = Visualization::data->GeometricObject(lineP1Id); + const QSharedPointer second = Visualization::data->GeometricObject(lineP1Id); DrawPoint(line1P2, second->toQPointF(), supportColor); DrawLine(line1, QLineF(first->toQPointF(), second->toQPointF()), supportColor); @@ -75,7 +75,7 @@ void VisToolShoulderPoint::RefreshGeometry() } else { - const VPointF *third = Visualization::data->GeometricObject(lineP2Id); + const QSharedPointer third = Visualization::data->GeometricObject(lineP2Id); DrawPoint(line2P2, third->toQPointF(), supportColor); DrawLine(line2, QLineF(second->toQPointF(), third->toQPointF()), supportColor); diff --git a/src/app/visualization/vistoolspline.cpp b/src/app/visualization/vistoolspline.cpp index 4cf8c4f09..3ed3b63e6 100644 --- a/src/app/visualization/vistoolspline.cpp +++ b/src/app/visualization/vistoolspline.cpp @@ -52,7 +52,7 @@ void VisToolSpline::RefreshGeometry() { if (point1Id > 0) { - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); DrawPoint(lineP1, first->toQPointF(), supportColor); if (point4Id <= 0) @@ -61,7 +61,7 @@ void VisToolSpline::RefreshGeometry() } else { - const VPointF *second = Visualization::data->GeometricObject(point4Id); + const QSharedPointer second = Visualization::data->GeometricObject(point4Id); DrawPoint(lineP4, second->toQPointF(), supportColor); if (qFuzzyCompare(angle1, EMPTY_ANGLE) || qFuzzyCompare(angle2, EMPTY_ANGLE)) diff --git a/src/app/visualization/vistooltriangle.cpp b/src/app/visualization/vistooltriangle.cpp index ba1966100..e10b3536a 100644 --- a/src/app/visualization/vistooltriangle.cpp +++ b/src/app/visualization/vistooltriangle.cpp @@ -58,7 +58,7 @@ void VisToolTriangle::RefreshGeometry() { if (point1Id > 0) { - const VPointF *first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(point1Id); DrawPoint(axisP1, first->toQPointF(), supportColor); if (point2Id <= 0) @@ -67,7 +67,7 @@ void VisToolTriangle::RefreshGeometry() } else { - const VPointF *second = Visualization::data->GeometricObject(point2Id); + const QSharedPointer second = Visualization::data->GeometricObject(point2Id); DrawPoint(axisP2, second->toQPointF(), supportColor); DrawAimedAxis(axis, QLineF(first->toQPointF(), second->toQPointF()), supportColor); @@ -78,7 +78,7 @@ void VisToolTriangle::RefreshGeometry() } else { - const VPointF *third = Visualization::data->GeometricObject(hypotenuseP1Id); + const QSharedPointer third = Visualization::data->GeometricObject(hypotenuseP1Id); DrawPoint(hypotenuseP1, third->toQPointF(), supportColor); if (hypotenuseP2Id <= 0) @@ -94,7 +94,7 @@ void VisToolTriangle::RefreshGeometry() } else { - const VPointF *forth = Visualization::data->GeometricObject(hypotenuseP2Id); + const QSharedPointer forth = Visualization::data->GeometricObject(hypotenuseP2Id); DrawPoint(hypotenuseP2, forth->toQPointF(), supportColor); DrawLine(this, QLineF(third->toQPointF(), forth->toQPointF()), supportColor, Qt::DashLine); diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 56dec289d..33edc92a2 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -431,7 +431,7 @@ void VPattern::setCurrentData() if (tools.size() > 0) { const VDataTool *vTool = tools.value(id); - data->setData(vTool->getData()); + *data = vTool->getData(); } } } @@ -1340,7 +1340,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem PointsCommonAttributes(domElement, id, mx, my); const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0"); const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0"); - const VPointF *point = data->GeometricObject(idObject ); + const QSharedPointer point = data->GeometricObject(idObject ); data->UpdateGObject(id, new VPointF(point->toQPointF(), point->name(), mx, my, idObject, Draw::Modeling)); VNodePoint::Create(this, data, id, idObject, parse, Source::FromFile, idTool); @@ -1684,7 +1684,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & const qreal angle = GetParametrDouble(element, VAbstractTool::AttrAngle, "0"); const qreal kAsm2 = GetParametrDouble(element, VAbstractTool::AttrKAsm2, "1.0"); const quint32 pSpline = GetParametrUInt(element, VAbstractTool::AttrPSpline, "0"); - const VPointF p = *data->GeometricObject(pSpline); + const VPointF p = *data->GeometricObject(pSpline); QLineF line(0, 0, 100, 0); line.setAngle(angle+180); @@ -1712,7 +1712,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & try { SplinesCommonAttributes(domElement, id, idObject, idTool); - VSpline *spl = new VSpline(*data->GeometricObject(idObject)); + VSpline *spl = new VSpline(*data->GeometricObject(idObject)); spl->setIdObject(idObject); spl->setMode(Draw::Modeling); data->UpdateGObject(id, spl); @@ -1729,7 +1729,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & try { SplinesCommonAttributes(domElement, id, idObject, idTool); - VSplinePath *path = new VSplinePath(*data->GeometricObject(idObject)); + VSplinePath *path = new VSplinePath(*data->GeometricObject(idObject)); path->setIdObject(idObject); path->setMode(Draw::Modeling); data->UpdateGObject(id, path); @@ -1809,7 +1809,7 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen ToolsCommonAttributes(domElement, id); const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0"); const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0"); - VArc *arc = new VArc(*data->GeometricObject(idObject)); + VArc *arc = new VArc(*data->GeometricObject(idObject)); arc->setIdObject(idObject); arc->setMode(Draw::Modeling); data->UpdateGObject(id, arc);