Added option delete object ( for tools, details ).

--HG--
branch : feature
This commit is contained in:
dismine 2013-09-30 19:29:03 +03:00
parent b46d1968ba
commit 3782400aae
85 changed files with 801 additions and 1015 deletions

View File

@ -165,76 +165,6 @@ void VContainer::UpdateId(qint64 newId){
} }
} }
void VContainer::IncrementReferens(qint64 id, Scene::Scenes obj, Draw::Draws mode){
switch( obj ){
case(Scene::Line):
break;
case(Scene::Point):{
VPointF point;
if(mode == Draw::Calculation){
point = GetPoint(id);
} else {
point = GetModelingPoint(id);
}
point.incrementReferens();
if(mode == Draw::Calculation){
UpdatePoint(id, point);
} else {
UpdateModelingPoint(id, point);
}
}
break;
case(Scene::Arc):{
VArc arc;
if(mode == Draw::Calculation){
arc = GetArc(id);
} else {
arc = GetModelingArc(id);
}
arc.incrementReferens();
if(mode == Draw::Calculation){
UpdateArc(id, arc);
} else {
UpdateModelingArc(id, arc);
}
}
break;
case(Scene::Spline):{
VSpline spl;
if(mode == Draw::Calculation){
spl = GetSpline(id);
} else {
spl = GetModelingSpline(id);
}
spl.incrementReferens();
if(mode == Draw::Calculation){
UpdateSpline(id, spl);
} else {
UpdateModelingSpline(id, spl);
}
}
break;
case(Scene::SplinePath):{
VSplinePath splPath;
if(mode == Draw::Calculation){
splPath = GetSplinePath(id);
} else {
splPath = GetModelingSplinePath(id);
}
splPath.incrementReferens();
if(mode == Draw::Calculation){
UpdateSplinePath(id, splPath);
} else {
UpdateModelingSplinePath(id, splPath);
}
}
break;
default:
qWarning()<<"Get wrong scene type.";
break;
}
}
QPainterPath VContainer::ContourPath(qint64 idDetail) const{ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
VDetail detail = GetDetail(idDetail); VDetail detail = GetDetail(idDetail);
QVector<QPointF> points; QVector<QPointF> points;

View File

@ -143,7 +143,6 @@ public:
const QMap<qint64, VSplinePath> *DataModelingSplinePaths() const; const QMap<qint64, VSplinePath> *DataModelingSplinePaths() const;
const QMap<qint64, VDetail> *DataDetails() const; const QMap<qint64, VDetail> *DataDetails() const;
static void UpdateId(qint64 newId); static void UpdateId(qint64 newId);
void IncrementReferens(qint64 id, Scene::Scenes obj, Draw::Draws mode = Draw::Calculation);
QPainterPath ContourPath(qint64 idDetail) const; QPainterPath ContourPath(qint64 idDetail) const;
QPainterPath Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, QPainterPath Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv,
const qreal &width)const; const qreal &width)const;

View File

@ -21,105 +21,13 @@
#include "vpointf.h" #include "vpointf.h"
VPointF::VPointF():_name(QString()), _mx(0), _my(0), _x(0), _y(0), _referens(0), mode(Draw::Calculation),
idObject(0){
}
VPointF::VPointF ( const VPointF & point ):_name(point.name()), _mx(point.mx()), _my(point.my()),
_x(point.x()), _y(point.y()), _referens(point.referens()), mode(point.getMode()), idObject(point.getIdObject()){
}
VPointF::VPointF (qreal x, qreal y , QString name, qreal mx, qreal my, Draw::Draws mode, qint64 idObject):_name(name), _mx(mx),
_my(my), _x(x), _y(y), _referens(0), mode(mode), idObject(idObject){
}
VPointF &VPointF::operator =(const VPointF &point){ VPointF &VPointF::operator =(const VPointF &point){
_name = point.name(); _name = point.name();
_mx = point.mx(); _mx = point.mx();
_my = point.my(); _my = point.my();
_x = point.x(); _x = point.x();
_y = point.y(); _y = point.y();
_referens = point.referens();
mode = point.getMode(); mode = point.getMode();
idObject = point.getIdObject(); idObject = point.getIdObject();
return *this; return *this;
} }
VPointF::~VPointF(){
}
QString VPointF::name() const{
return _name;
}
qreal VPointF::mx() const{
return _mx;
}
qreal VPointF::my() const{
return _my;
}
void VPointF::setName(const QString& name){
_name = name;
}
void VPointF::setMx(qreal mx){
_mx = mx;
}
void VPointF::setMy(qreal my){
_my = my;
}
QPointF VPointF::toQPointF()const{
return QPointF(_x, _y);
}
qreal VPointF::y() const{
return _y;
}
void VPointF::setY(const qreal &value){
_y = value;
}
qreal VPointF::x() const{
return _x;
}
void VPointF::setX(const qreal &value){
_x = value;
}
qint32 VPointF::referens() const{
return _referens;
}
void VPointF::incrementReferens(){
++_referens;
}
void VPointF::decrementReferens(){
if(_referens > 0){
--_referens;
}
}
Draw::Draws VPointF::getMode() const
{
return mode;
}
void VPointF::setMode(const Draw::Draws &value)
{
mode = value;
}
qint64 VPointF::getIdObject() const{
return idObject;
}
void VPointF::setIdObject(const qint64 &value){
idObject = value;
}

View File

@ -28,41 +28,39 @@
class VPointF{ class VPointF{
public: public:
VPointF(); inline VPointF ()
VPointF (const VPointF &point ); :_name(QString()), _mx(0), _my(0), _x(0), _y(0), mode(Draw::Calculation), idObject(0){}
VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my, Draw::Draws mode = Draw::Calculation, inline VPointF (const VPointF &point )
qint64 idObject = 0); :_name(point.name()), _mx(point.mx()), _my(point.my()), _x(point.x()), _y(point.y()),
VPointF &operator=(const VPointF &point); mode(point.getMode()), idObject(point.getIdObject()){}
~VPointF(); inline VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my,
QString name() const; Draw::Draws mode = Draw::Calculation, qint64 idObject = 0)
qreal mx() const; :_name(name), _mx(mx), _my(my), _x(x), _y(y), mode(mode), idObject(idObject){}
qreal my() const; VPointF &operator=(const VPointF &point);
void setName(const QString &name); ~VPointF(){}
void setMx(qreal mx); inline QString name() const { return _name;}
void setMy(qreal my); inline qreal mx() const {return _mx;}
QPointF toQPointF()const; inline qreal my() const {return _my;}
qreal x() const; inline void setName(const QString &name) {_name = name;}
void setX(const qreal &value); inline void setMx(qreal mx) {_mx = mx;}
qreal y() const; inline void setMy(qreal my) {_my = my;}
void setY(const qreal &value); inline QPointF toQPointF()const {return QPointF(_x, _y);}
qint32 referens() const; inline qreal x() const {return _x;}
void incrementReferens(); inline void setX(const qreal &value){_x = value;}
void decrementReferens(); inline qreal y() const {return _y;}
Draw::Draws getMode() const; inline void setY(const qreal &value){_y = value;}
void setMode(const Draw::Draws &value); inline Draw::Draws getMode() const{return mode;}
inline void setMode(const Draw::Draws &value) {mode = value;}
qint64 getIdObject() const; inline qint64 getIdObject() const {return idObject;}
void setIdObject(const qint64 &value); inline void setIdObject(const qint64 &value) {idObject = value;}
private: private:
QString _name; QString _name;
qreal _mx; qreal _mx;
qreal _my; qreal _my;
qreal _x; qreal _x;
qreal _y; qreal _y;
qint32 _referens; Draw::Draws mode;
Draw::Draws mode; qint64 idObject;
qint64 idObject;
}; };
#endif // VPOINTF_H #endif // VPOINTF_H

View File

@ -19,24 +19,22 @@
** **
****************************************************************************/ ****************************************************************************/
#define _USE_MATH_DEFINES
#include <cmath>
#include "varc.h" #include "varc.h"
#include <QDebug> #include <QDebug>
VArc::VArc () : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()), VArc::VArc () : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()),
center(0), points(0), _referens(0), mode(Draw::Calculation), idObject(0){ center(0), points(0), mode(Draw::Calculation), idObject(0){
} }
VArc::VArc (const QMap<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius, VArc::VArc (const QMap<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Draws mode, qint64 idObject) qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Draws mode, qint64 idObject)
: f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius), : f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius),
center(center), points(points), _referens(0), mode(mode), idObject(idObject){ center(center), points(points), mode(mode), idObject(idObject){
} }
VArc::VArc(const VArc &arc): f1(arc.GetF1()), formulaF1(arc.GetFormulaF1()), f2(arc.GetF2()), VArc::VArc(const VArc &arc): f1(arc.GetF1()), formulaF1(arc.GetFormulaF1()), f2(arc.GetF2()),
formulaF2(arc.GetFormulaF2()), radius(arc.GetRadius()), formulaRadius(arc.GetFormulaRadius()), formulaF2(arc.GetFormulaF2()), radius(arc.GetRadius()), formulaRadius(arc.GetFormulaRadius()),
center(arc.GetCenter()), points(arc.GetDataPoints()), _referens(0), mode(arc.getMode()), center(arc.GetCenter()), points(arc.GetDataPoints()), mode(arc.getMode()),
idObject(arc.getIdObject()){ idObject(arc.getIdObject()){
} }
@ -50,7 +48,6 @@ VArc &VArc::operator =(const VArc &arc){
this->formulaRadius = arc.GetFormulaRadius(); this->formulaRadius = arc.GetFormulaRadius();
this->center = arc.GetCenter(); this->center = arc.GetCenter();
this->mode = arc.getMode(); this->mode = arc.getMode();
this->_referens = 0;
this->idObject = arc.getIdObject(); this->idObject = arc.getIdObject();
return *this; return *this;
} }
@ -198,37 +195,18 @@ QVector<QPointF> VArc::SplOfArc(qint32 number) const{
return QVector<QPointF>(); return QVector<QPointF>();
} }
qint32 VArc::referens() const{ Draw::Draws VArc::getMode() const{
return _referens;
}
void VArc::incrementReferens(){
++_referens;
}
void VArc::decrementReferens(){
if(_referens > 0){
--_referens;
}
}
Draw::Draws VArc::getMode() const
{
return mode; return mode;
} }
void VArc::setMode(const Draw::Draws &value) void VArc::setMode(const Draw::Draws &value){
{
mode = value; mode = value;
} }
qint64 VArc::getIdObject() const qint64 VArc::getIdObject() const{
{
return idObject; return idObject;
} }
void VArc::setIdObject(const qint64 &value) void VArc::setIdObject(const qint64 &value){
{
idObject = value; idObject = value;
} }

View File

@ -98,12 +98,8 @@ public:
qint32 NumberSplOfArc () const; qint32 NumberSplOfArc () const;
QVector<QPointF> GetPoints () const; QVector<QPointF> GetPoints () const;
QVector<QPointF> SplOfArc( qint32 number ) const; QVector<QPointF> SplOfArc( qint32 number ) const;
qint32 referens() const;
void incrementReferens();
void decrementReferens();
Draw::Draws getMode() const; Draw::Draws getMode() const;
void setMode(const Draw::Draws &value); void setMode(const Draw::Draws &value);
qint64 getIdObject() const; qint64 getIdObject() const;
void setIdObject(const qint64 &value); void setIdObject(const qint64 &value);
@ -128,7 +124,6 @@ private:
*/ */
qint64 center; qint64 center;
const QMap<qint64, VPointF> *points; const QMap<qint64, VPointF> *points;
qint32 _referens;
Draw::Draws mode; Draw::Draws mode;
qint64 idObject; qint64 idObject;
}; };

View File

@ -37,8 +37,7 @@ namespace Detail {
Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Contours) Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Contours)
Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants) Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants)
class VDetail class VDetail{
{
public: public:
VDetail(); VDetail();
VDetail(const QString &name, const QVector<VNodeDetail> &nodes); VDetail(const QString &name, const QVector<VNodeDetail> &nodes);
@ -49,13 +48,10 @@ public:
VNodeDetail & operator[](int indx); VNodeDetail & operator[](int indx);
QString getName() const; QString getName() const;
void setName(const QString &value); void setName(const QString &value);
qreal getMx() const; qreal getMx() const;
void setMx(const qreal &value); void setMx(const qreal &value);
qreal getMy() const; qreal getMy() const;
void setMy(const qreal &value); void setMy(const qreal &value);
private: private:
QVector<VNodeDetail> nodes; QVector<VNodeDetail> nodes;
QString name; QString name;

View File

@ -22,7 +22,6 @@
#ifndef VNODEDETAIL_H #ifndef VNODEDETAIL_H
#define VNODEDETAIL_H #define VNODEDETAIL_H
#include <QtGlobal>
#include <QMetaType> #include <QMetaType>
#include "options.h" #include "options.h"

View File

@ -19,31 +19,29 @@
** **
****************************************************************************/ ****************************************************************************/
#define _USE_MATH_DEFINES
#include <cmath>
#include "vspline.h" #include "vspline.h"
#include <QDebug> #include <QDebug>
VSpline::VSpline():p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1), VSpline::VSpline():p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1),
kCurve(1), points(0), _referens(0), mode(Draw::Calculation), idObject(0){ kCurve(1), points(0), mode(Draw::Calculation), idObject(0){
} }
VSpline::VSpline ( const VSpline & spline ):p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()), VSpline::VSpline ( const VSpline & spline ):p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()),
p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()), angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()), p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()), angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()),
kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()), points(spline.GetDataPoints()), _referens(0), kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()), points(spline.GetDataPoints()),
mode(spline.getMode()), idObject(spline.getIdObject()){ mode(spline.getMode()), idObject(spline.getIdObject()){
} }
VSpline::VSpline (const QMap<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2, VSpline::VSpline (const QMap<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal kAsm1, qreal kAsm2 , qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(QPointF()), p3(QPointF()), qreal kAsm1, qreal kAsm2 , qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(QPointF()), p3(QPointF()),
p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve), points(points), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve), points(points),
_referens(0), mode(mode), idObject(idObject){ mode(mode), idObject(idObject){
ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve ); ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve );
} }
VSpline::VSpline (const QMap<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4, VSpline::VSpline (const QMap<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4,
qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(p2), p3(p3), p4(p4), angle1(0),
kCurve(1), points(points), _referens(0), mode(mode), idObject(idObject){ angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(points), mode(mode), idObject(idObject){
ModifiSpl ( p1, p2, p3, p4, kCurve); ModifiSpl ( p1, p2, p3, p4, kCurve);
} }
@ -629,20 +627,6 @@ QPainterPath VSpline::GetPath() const{
return splinePath; return splinePath;
} }
qint32 VSpline::referens() const{
return _referens;
}
void VSpline::incrementReferens(){
++_referens;
}
void VSpline::decrementReferens(){
if(_referens > 0){
--_referens;
}
}
/* Cubic equation solution. Real coefficients case. /* Cubic equation solution. Real coefficients case.
int Cubic(double *x,double a,double b,double c); int Cubic(double *x,double a,double b,double c);
@ -811,7 +795,6 @@ VSpline &VSpline::operator =(const VSpline &spline){
this->kAsm2 = spline.GetKasm2(); this->kAsm2 = spline.GetKasm2();
this->kCurve = spline.GetKcurve(); this->kCurve = spline.GetKcurve();
this->points = spline.GetDataPoints(); this->points = spline.GetDataPoints();
this->_referens = 0;
this->mode = spline.getMode(); this->mode = spline.getMode();
this->idObject = spline.getIdObject(); this->idObject = spline.getIdObject();
return *this; return *this;

View File

@ -180,9 +180,6 @@ public:
* @param Pmirror точка відносно якої відбувається вертикальне дзеркалення сплайну. * @param Pmirror точка відносно якої відбувається вертикальне дзеркалення сплайну.
*/ */
// void Mirror(const QPointF Pmirror); // void Mirror(const QPointF Pmirror);
qint32 referens() const;
void incrementReferens();
void decrementReferens();
Draw::Draws getMode() const; Draw::Draws getMode() const;
void setMode(const Draw::Draws &value); void setMode(const Draw::Draws &value);
static QVector<QPointF> SplinePoints(QPointF p1, QPointF p4, qreal angle1, static QVector<QPointF> SplinePoints(QPointF p1, QPointF p4, qreal angle1,
@ -229,7 +226,6 @@ private:
qreal kAsm2; qreal kAsm2;
qreal kCurve; qreal kCurve;
const QMap<qint64, VPointF> *points; const QMap<qint64, VPointF> *points;
qint32 _referens;
Draw::Draws mode; Draw::Draws mode;
qint64 idObject; qint64 idObject;
/** /**

View File

@ -20,17 +20,18 @@
****************************************************************************/ ****************************************************************************/
#include "vsplinepath.h" #include "vsplinepath.h"
#include "exception/vexception.h"
VSplinePath::VSplinePath(): path(QVector<VSplinePoint>()), kCurve(1), mode(Draw::Calculation), points(0), VSplinePath::VSplinePath(): path(QVector<VSplinePoint>()), kCurve(1), mode(Draw::Calculation), points(0),
_referens(0), idObject(0){ idObject(0){
} }
VSplinePath::VSplinePath(const QMap<qint64, VPointF> *points, qreal kCurve, Draw::Draws mode, qint64 idObject): path(QVector<VSplinePoint>()), VSplinePath::VSplinePath(const QMap<qint64, VPointF> *points, qreal kCurve, Draw::Draws mode, qint64 idObject): path(QVector<VSplinePoint>()),
kCurve(kCurve), mode(mode), points(points), _referens(0), idObject(idObject){ kCurve(kCurve), mode(mode), points(points), idObject(idObject){
} }
VSplinePath::VSplinePath(const VSplinePath &splPath): path(*splPath.GetPoint()), VSplinePath::VSplinePath(const VSplinePath &splPath): path(*splPath.GetPoint()),
kCurve(splPath.getKCurve()), mode(splPath.getMode()), points( splPath.GetDataPoints()), _referens(0), kCurve(splPath.getKCurve()), mode(splPath.getMode()), points( splPath.GetDataPoints()),
idObject(splPath.getIdObject()){ idObject(splPath.getIdObject()){
} }
@ -60,10 +61,10 @@ qint32 VSplinePath::CountPoint() const{
VSpline VSplinePath::GetSpline(qint32 index) const{ VSpline VSplinePath::GetSpline(qint32 index) const{
if(Count()<1){ if(Count()<1){
throw "Недостатня кількість точок для створення сплайну."; throw VException(tr("Not enough points to create the spline."));
} }
if(index < 1 || index > Count()){ if(index < 1 || index > Count()){
throw "Такого сплайну немає."; throw VException(tr("This spline is not exist."));
} }
VSpline spl(points, path[index-1].P(), path[index].P(), path[index-1].Angle2(), path[index].Angle1(), VSpline spl(points, path[index-1].P(), path[index].P(), path[index-1].Angle2(), path[index].Angle1(),
path[index-1].KAsm2(), path[index].KAsm1(), this->kCurve); path[index-1].KAsm2(), path[index].KAsm1(), this->kCurve);
@ -113,7 +114,7 @@ const QMap<qint64, VPointF> *VSplinePath::GetDataPoints() const{
void VSplinePath::UpdatePoint(qint32 indexSpline, SplinePoint::Position pos, VSplinePoint point){ void VSplinePath::UpdatePoint(qint32 indexSpline, SplinePoint::Position pos, VSplinePoint point){
if(indexSpline < 1 || indexSpline > Count()){ if(indexSpline < 1 || indexSpline > Count()){
throw "Такого сплайну немає."; throw VException(tr("This spline is not exist."));
} }
if(pos == SplinePoint::FirstPoint){ if(pos == SplinePoint::FirstPoint){
path[indexSpline-1] = point; path[indexSpline-1] = point;
@ -124,7 +125,7 @@ void VSplinePath::UpdatePoint(qint32 indexSpline, SplinePoint::Position pos, VSp
VSplinePoint VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const{ VSplinePoint VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const{
if(indexSpline < 1 || indexSpline > Count()){ if(indexSpline < 1 || indexSpline > Count()){
throw "Такого сплайну немає."; throw VException(tr("This spline is not exist."));
} }
if(pos == SplinePoint::FirstPoint){ if(pos == SplinePoint::FirstPoint){
return path.at(indexSpline-1); return path.at(indexSpline-1);
@ -154,7 +155,6 @@ VSplinePath &VSplinePath::operator =(const VSplinePath &path){
this->kCurve = path.getKCurve(); this->kCurve = path.getKCurve();
this->mode = path.getMode(); this->mode = path.getMode();
this->points = path.GetDataPoints(); this->points = path.GetDataPoints();
this->_referens = 0;
this->idObject = path.getIdObject(); this->idObject = path.getIdObject();
return *this; return *this;
} }
@ -163,26 +163,10 @@ VSplinePoint & VSplinePath::operator[](int indx){
return path[indx]; return path[indx];
} }
qint32 VSplinePath::referens() const{ qint64 VSplinePath::getIdObject() const{
return _referens; return idObject;
} }
void VSplinePath::incrementReferens(){ void VSplinePath::setIdObject(const qint64 &value){
++_referens; idObject = value;
}
void VSplinePath::decrementReferens(){
if(_referens > 0){
--_referens;
}
}
qint64 VSplinePath::getIdObject() const
{
return idObject;
}
void VSplinePath::setIdObject(const qint64 &value)
{
idObject = value;
} }

View File

@ -23,22 +23,21 @@
#define VSPLINEPATH_H #define VSPLINEPATH_H
#include "vsplinepoint.h" #include "vsplinepoint.h"
#include <QVector>
#include "vspline.h" #include "vspline.h"
#include "options.h" #include "options.h"
#include <QCoreApplication>
namespace SplinePoint{ namespace SplinePoint{
enum Position enum Position { FirstPoint, LastPoint };
{ Q_DECLARE_FLAGS(Positions, Position)
FirstPoint,
LastPoint
};
} }
Q_DECLARE_OPERATORS_FOR_FLAGS( SplinePoint::Positions )
/** /**
* @brief The VSplinePath клас, що розраховує шлях сплайнів. * @brief The VSplinePath клас, що розраховує шлях сплайнів.
*/ */
class VSplinePath{ class VSplinePath{
Q_DECLARE_TR_FUNCTIONS(VSplinePath)
public: public:
/** /**
* @brief VSplinePath конструктор по замовчуванню. * @brief VSplinePath конструктор по замовчуванню.
@ -74,9 +73,6 @@ public:
const QVector<VSplinePoint> *GetPoint() const; const QVector<VSplinePoint> *GetPoint() const;
VSplinePath& operator=(const VSplinePath &path); VSplinePath& operator=(const VSplinePath &path);
VSplinePoint & operator[](int indx); VSplinePoint & operator[](int indx);
qint32 referens() const;
void incrementReferens();
void decrementReferens();
Draw::Draws getMode() const; Draw::Draws getMode() const;
void setMode(const Draw::Draws &value); void setMode(const Draw::Draws &value);
@ -91,7 +87,6 @@ protected:
qreal kCurve; qreal kCurve;
Draw::Draws mode; Draw::Draws mode;
const QMap<qint64, VPointF> *points; const QMap<qint64, VPointF> *points;
qint32 _referens;
qint64 idObject; qint64 idObject;
}; };

View File

@ -22,7 +22,6 @@
#ifndef VSPLINEPOINT_H #ifndef VSPLINEPOINT_H
#define VSPLINEPOINT_H #define VSPLINEPOINT_H
#include "QtGlobal"
#include <QMetaType> #include <QMetaType>
/** /**

View File

@ -729,7 +729,7 @@ void MainWindow::ActionSaveAs(){
QString filters("Lekalo files (*.xml);;All files (*.*)"); QString filters("Lekalo files (*.xml);;All files (*.*)");
QString defaultFilter("Lekalo files (*.xml)"); QString defaultFilter("Lekalo files (*.xml)");
QString fName = QFileDialog::getSaveFileName(this, "Зберегти файл як", QDir::homePath(), QString fName = QFileDialog::getSaveFileName(this, "Зберегти файл як", QDir::homePath(),
filters, &defaultFilter); filters, &defaultFilter);
if(fName.isEmpty()) if(fName.isEmpty())
return; return;
if(fName.indexOf(".xml",fName.size()-4)<0){ if(fName.indexOf(".xml",fName.size()-4)<0){

View File

@ -25,8 +25,7 @@
#include "../vabstracttool.h" #include "../vabstracttool.h"
#include <QMenu> #include <QMenu>
class VDrawTool : public VAbstractTool class VDrawTool : public VAbstractTool{
{
Q_OBJECT Q_OBJECT
public: public:
VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0); VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0);
@ -54,9 +53,11 @@ protected:
QAction *actionRemove; QAction *actionRemove;
if(showRemove){ if(showRemove){
actionRemove = menu.addAction(tr("Delete")); actionRemove = menu.addAction(tr("Delete"));
} else { if(_referens > 1){
actionRemove = menu.addAction(tr("Delete")); actionRemove->setEnabled(false);
actionRemove->setEnabled(false); } else {
actionRemove->setEnabled(true);
}
} }
QAction *selectedAction = menu.exec(event->screenPos()); QAction *selectedAction = menu.exec(event->screenPos());
if(selectedAction == actionOption){ if(selectedAction == actionOption){
@ -73,6 +74,8 @@ protected:
dialog->show(); dialog->show();
} }
if(selectedAction == actionRemove){ if(selectedAction == actionRemove){
//deincrement referens
RemoveReferens();
//remove form xml file //remove form xml file
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if(domElement.isElement()){

View File

@ -65,12 +65,7 @@ void VToolAlongLine::FullUpdateFromGui(int result){
} }
void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogAlongLine, this, event);
if(point.referens() > 1){
ContextMenu(dialogAlongLine, this, event, false);
} else {
ContextMenu(dialogAlongLine, this, event);
}
} }
void VToolAlongLine::AddToFile(){ void VToolAlongLine::AddToFile(){
@ -91,6 +86,11 @@ void VToolAlongLine::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolAlongLine::RemoveReferens(){
doc->DecrementReferens(secondPointId);
VToolLinePoint::RemoveReferens();
}
void VToolAlongLine::setDialog(){ void VToolAlongLine::setDialog(){
Q_ASSERT(!dialogAlongLine.isNull()); Q_ASSERT(!dialogAlongLine.isNull());
if(!dialogAlongLine.isNull()){ if(!dialogAlongLine.isNull()){
@ -132,12 +132,7 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS
} else { } else {
data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point);
}
} }
} }
VDrawTool::AddRecord(id, Tool::AlongLineTool, doc); VDrawTool::AddRecord(id, Tool::AlongLineTool, doc);
@ -149,9 +144,9 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS
scene->addItem(point); scene->addItem(point);
connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolAlongLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolAlongLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
} }
} }
} }

View File

@ -45,7 +45,7 @@ public slots:
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 secondPointId; qint64 secondPointId;
QSharedPointer<DialogAlongLine> dialogAlongLine; QSharedPointer<DialogAlongLine> dialogAlongLine;

View File

@ -91,12 +91,7 @@ void VToolArc::Create(const qint64 _id, const qint64 &center, const QString &rad
} else { } else {
data->UpdateArc(id, arc); data->UpdateArc(id, arc);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Arc);
}
} }
} }
data->AddLengthArc(data->GetNameArc(center,id), arc.GetLength()); data->AddLengthArc(data->GetNameArc(center,id), arc.GetLength());
@ -106,8 +101,8 @@ void VToolArc::Create(const qint64 _id, const qint64 &center, const QString &rad
scene->addItem(toolArc); scene->addItem(toolArc);
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(toolArc, &VToolArc::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(toolArc, &VToolArc::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, toolArc);
tools->insert(id,toolArc); doc->IncrementReferens(center);
} }
} }
@ -156,12 +151,7 @@ void VToolArc::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){
} }
void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VArc arc = VDrawTool::data.GetArc(id); ContextMenu(dialogArc, this, event);
if(arc.referens() > 1){
ContextMenu(dialogArc, this, event, false);
} else {
ContextMenu(dialogArc, this, event);
}
} }
void VToolArc::AddToFile(){ void VToolArc::AddToFile(){
@ -195,6 +185,11 @@ void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VToolArc::RemoveReferens(){
VArc arc = VAbstractTool::data.GetArc(id);
doc->DecrementReferens(arc.GetCenter());
}
void VToolArc::RefreshGeometry(){ void VToolArc::RefreshGeometry(){
VArc arc = VAbstractTool::data.GetArc(id); VArc arc = VAbstractTool::data.GetArc(id);
QPainterPath path; QPainterPath path;

View File

@ -52,6 +52,7 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
private: private:
QSharedPointer<DialogArc> dialogArc; QSharedPointer<DialogArc> dialogArc;
void RefreshGeometry(); void RefreshGeometry();

View File

@ -95,12 +95,7 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
} else { } else {
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point);
}
} }
} }
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
@ -112,8 +107,10 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
scene->addItem(point); scene->addItem(point);
connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
doc->IncrementReferens(thirdPointId);
} }
} }
} }
@ -147,12 +144,7 @@ void VToolBisector::FullUpdateFromGui(int result){
} }
void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogBisector, this, event);
if(point.referens() > 1){
ContextMenu(dialogBisector, this, event, false);
} else {
ContextMenu(dialogBisector, this, event);
}
} }
void VToolBisector::AddToFile(){ void VToolBisector::AddToFile(){
@ -173,3 +165,9 @@ void VToolBisector::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolBisector::RemoveReferens(){
doc->DecrementReferens(firstPointId);
doc->DecrementReferens(thirdPointId);
VToolLinePoint::RemoveReferens();
}

View File

@ -49,6 +49,7 @@ public slots:
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 firstPointId; qint64 firstPointId;
qint64 thirdPointId; qint64 thirdPointId;

View File

@ -77,11 +77,7 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
} else { } else {
data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
Q_CHECK_PTR(tool);
data->IncrementReferens(id, Scene::Point);
tool->VDataTool::setData(data);
} }
} }
data->AddLine(basePointId, id); data->AddLine(basePointId, id);
@ -92,9 +88,8 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
Q_CHECK_PTR(tools); doc->IncrementReferens(basePointId);
tools->insert(id,point);
} }
} }
} }
@ -111,12 +106,7 @@ void VToolEndLine::FullUpdateFromFile(){
} }
void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogEndLine, this, event);
if(point.referens() > 1){
ContextMenu(dialogEndLine, this, event, false);
} else {
ContextMenu(dialogEndLine, this, event);
}
} }
void VToolEndLine::FullUpdateFromGui(int result){ void VToolEndLine::FullUpdateFromGui(int result){

View File

@ -53,18 +53,14 @@ void VToolLine::Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *s
} }
void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint, void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, const Document::Documents &parse, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
Tool::Sources typeCreation){ const Document::Documents &parse, Tool::Sources typeCreation){
Q_CHECK_PTR(scene); Q_CHECK_PTR(scene);
Q_CHECK_PTR(doc); Q_CHECK_PTR(doc);
Q_CHECK_PTR(data); Q_CHECK_PTR(data);
data->AddLine(firstPoint, secondPoint); data->AddLine(firstPoint, secondPoint);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
Q_CHECK_PTR(tools);
VDataTool *tool = tools->value(id);
Q_CHECK_PTR(tool);
tool->VDataTool::setData(data);
} }
VDrawTool::AddRecord(id, Tool::LineTool, doc); VDrawTool::AddRecord(id, Tool::LineTool, doc);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
@ -74,8 +70,9 @@ void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64
scene->addItem(line); scene->addItem(line);
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(line, &VToolLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(line, &VToolLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, line);
tools->insert(id,line); doc->IncrementReferens(firstPoint);
doc->IncrementReferens(secondPoint);
} }
} }
@ -150,3 +147,8 @@ void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VToolLine::RemoveReferens(){
doc->DecrementReferens(firstPoint);
doc->DecrementReferens(secondPoint);
}

View File

@ -48,6 +48,7 @@ protected:
virtual void AddToFile(); virtual void AddToFile();
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
private: private:
qint64 firstPoint; qint64 firstPoint;
qint64 secondPoint; qint64 secondPoint;

View File

@ -75,12 +75,7 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
} else { } else {
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point);
}
} }
} }
data->AddLine(p1Line1Id, id); data->AddLine(p1Line1Id, id);
@ -95,8 +90,11 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
scene->addItem(point); scene->addItem(point);
connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolLineIntersect::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolLineIntersect::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(p1Line1Id);
doc->IncrementReferens(p2Line1Id);
doc->IncrementReferens(p1Line2Id);
doc->IncrementReferens(p2Line2Id);
} }
} }
} }
@ -128,12 +126,7 @@ void VToolLineIntersect::FullUpdateFromGui(int result){
} }
void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogLineIntersect, this, event);
if(point.referens() > 1){
ContextMenu(dialogLineIntersect, this, event, false);
} else {
ContextMenu(dialogLineIntersect, this, event);
}
} }
void VToolLineIntersect::AddToFile(){ void VToolLineIntersect::AddToFile(){
@ -153,3 +146,10 @@ void VToolLineIntersect::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolLineIntersect::RemoveReferens(){
doc->DecrementReferens(p1Line1);
doc->DecrementReferens(p2Line1);
doc->DecrementReferens(p1Line2);
doc->DecrementReferens(p2Line2);
}

View File

@ -25,29 +25,32 @@
#include "vtoolpoint.h" #include "vtoolpoint.h"
#include "dialogs/dialoglineintersect.h" #include "dialogs/dialoglineintersect.h"
class VToolLineIntersect:public VToolPoint class VToolLineIntersect:public VToolPoint{
{
Q_OBJECT Q_OBJECT
public: public:
VToolLineIntersect(VDomDocument *doc, VContainer *data, VToolLineIntersect(VDomDocument *doc, VContainer *data,
const qint64 &id, const qint64 &id,
const qint64 &p1Line1, const qint64 &p1Line1,
const qint64 &p2Line1, const qint64 &p1Line2, const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line2, Tool::Sources typeCreation, const qint64 &p2Line2, Tool::Sources typeCreation,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogLineIntersect> &dialog, VMainGraphicsScene *scene, static void Create(QSharedPointer<DialogLineIntersect> &dialog,
VDomDocument *doc,VContainer *data); VMainGraphicsScene *scene, VDomDocument *doc,
static void Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id, VContainer *data);
const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName, static void Create(const qint64 _id, const qint64 &p1Line1Id,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, const qint64 &p2Line1Id, const qint64 &p1Line2Id,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation); const qint64 &p2Line2Id, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 p1Line1; qint64 p1Line1;
qint64 p2Line1; qint64 p2Line1;

View File

@ -60,3 +60,7 @@ void VToolLinePoint::RefreshGeometry(){
mainLine->setVisible(true); mainLine->setVisible(true);
} }
} }
void VToolLinePoint::RemoveReferens(){
doc->DecrementReferens(basePointId);
}

View File

@ -24,13 +24,12 @@
#include "vtoolpoint.h" #include "vtoolpoint.h"
class VToolLinePoint : public VToolPoint class VToolLinePoint : public VToolPoint{
{
Q_OBJECT Q_OBJECT
public: public:
VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const QString &typeLine, const QString &formula,
const qint64 &basePointId, const qreal &angle, QGraphicsItem * parent = 0); const qint64 &basePointId, const qreal &angle, QGraphicsItem * parent = 0);
public slots: public slots:
virtual void ChangedActivDraw(const QString newName); virtual void ChangedActivDraw(const QString newName);
protected: protected:
@ -40,9 +39,9 @@ protected:
qint64 basePointId; qint64 basePointId;
QGraphicsLineItem *mainLine; QGraphicsLineItem *mainLine;
virtual void RefreshGeometry(); virtual void RefreshGeometry();
virtual void RemoveReferens();
private: private:
VToolLinePoint(const VToolLinePoint &tool); Q_DISABLE_COPY(VToolLinePoint)
const VToolLinePoint &operator=(const VToolLinePoint &tool);
}; };
#endif // VTOOLLINEPOINT_H #endif // VTOOLLINEPOINT_H

View File

@ -78,12 +78,7 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64
} else { } else {
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point);
}
} }
} }
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
@ -94,8 +89,9 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64
scene->addItem(point); scene->addItem(point);
connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolNormal::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolNormal::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
} }
} }
} }
@ -138,12 +134,7 @@ void VToolNormal::FullUpdateFromGui(int result){
} }
void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogNormal, this, event);
if(point.referens() > 1){
ContextMenu(dialogNormal, this, event, false);
} else {
ContextMenu(dialogNormal, this, event);
}
} }
void VToolNormal::AddToFile(){ void VToolNormal::AddToFile(){
@ -164,3 +155,8 @@ void VToolNormal::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolNormal::RemoveReferens(){
doc->DecrementReferens(secondPointId);
VToolLinePoint::RemoveReferens();
}

View File

@ -50,6 +50,7 @@ public slots:
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 secondPointId; qint64 secondPointId;
QSharedPointer<DialogNormal> dialogNormal; QSharedPointer<DialogNormal> dialogNormal;

View File

@ -26,12 +26,12 @@
#include "widgets/vgraphicssimpletextitem.h" #include "widgets/vgraphicssimpletextitem.h"
#include "options.h" #include "options.h"
class VToolPoint: public VDrawTool, public QGraphicsEllipseItem class VToolPoint: public VDrawTool, public QGraphicsEllipseItem{
{
Q_OBJECT Q_OBJECT
public: public:
VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem * parent = 0); VToolPoint(VDomDocument *doc, VContainer *data, qint64 id,
virtual ~VToolPoint(); QGraphicsItem * parent = 0);
virtual ~VToolPoint();
public slots: public slots:
void NameChangePosition(const QPointF pos); void NameChangePosition(const QPointF pos);
virtual void ChangedActivDraw(const QString newName); virtual void ChangedActivDraw(const QString newName);
@ -48,8 +48,7 @@ protected:
virtual void RefreshPointGeometry(const VPointF &point); virtual void RefreshPointGeometry(const VPointF &point);
void RefreshLine(); void RefreshLine();
private: private:
VToolPoint(const VToolPoint &tool); Q_DISABLE_COPY(VToolPoint)
const VToolPoint &operator=(const VToolPoint &tool);
}; };
#endif // VTOOLPOINT_H #endif // VTOOLPOINT_H

View File

@ -99,12 +99,7 @@ void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const
} else { } else {
data->UpdatePoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdatePoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point);
}
} }
} }
VDrawTool::AddRecord(id, Tool::PointOfContact, doc); VDrawTool::AddRecord(id, Tool::PointOfContact, doc);
@ -114,8 +109,10 @@ void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(center);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
} }
} }
} }
@ -147,12 +144,7 @@ void VToolPointOfContact::FullUpdateFromGui(int result){
} }
void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogPointOfContact, this, event);
if(point.referens() > 1){
ContextMenu(dialogPointOfContact, this, event, false);
} else {
ContextMenu(dialogPointOfContact, this, event);
}
} }
void VToolPointOfContact::AddToFile(){ void VToolPointOfContact::AddToFile(){
@ -172,3 +164,9 @@ void VToolPointOfContact::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolPointOfContact::RemoveReferens(){
doc->DecrementReferens(center);
doc->DecrementReferens(firstPointId);
doc->DecrementReferens(secondPointId);
}

View File

@ -46,6 +46,7 @@ public slots:
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
QString radius; QString radius;
qint64 center; qint64 center;

View File

@ -103,12 +103,7 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
} else { } else {
data->UpdatePoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdatePoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point);
}
} }
} }
data->AddLine(p1Line, id); data->AddLine(p1Line, id);
@ -121,8 +116,10 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
scene->addItem(point); scene->addItem(point);
connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolShoulderPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolShoulderPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(p1Line);
doc->IncrementReferens(p2Line);
doc->IncrementReferens(pShoulder);
} }
} }
} }
@ -156,12 +153,7 @@ void VToolShoulderPoint::FullUpdateFromGui(int result){
} }
void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogShoulderPoint, this, event);
if(point.referens() > 1){
ContextMenu(dialogShoulderPoint, this, event, false);
} else {
ContextMenu(dialogShoulderPoint, this, event);
}
} }
void VToolShoulderPoint::AddToFile(){ void VToolShoulderPoint::AddToFile(){
@ -182,3 +174,9 @@ void VToolShoulderPoint::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolShoulderPoint::RemoveReferens(){
doc->DecrementReferens(p2Line);
doc->DecrementReferens(pShoulder);
VToolLinePoint::RemoveReferens();
}

View File

@ -47,6 +47,7 @@ public slots:
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 p2Line; qint64 p2Line;
qint64 pShoulder; qint64 pShoulder;

View File

@ -89,6 +89,12 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change,
return QGraphicsItem::itemChange(change, value); return QGraphicsItem::itemChange(change, value);
} }
void VToolSinglePoint::decrementReferens(){
if(_referens > 1){
--_referens;
}
}
void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ){ void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ){
ContextMenu(dialogSinglePoint, this, event, false); ContextMenu(dialogSinglePoint, this, event, false);
} }

View File

@ -44,6 +44,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void decrementReferens();
private: private:
QSharedPointer<DialogSinglePoint> dialogSinglePoint; QSharedPointer<DialogSinglePoint> dialogSinglePoint;
}; };

View File

@ -98,12 +98,7 @@ void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, c
} else { } else {
data->UpdateSpline(id, spline); data->UpdateSpline(id, spline);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Spline);
}
} }
} }
data->AddLengthSpline(data->GetNameSpline(p1, p4), spline.GetLength()); data->AddLengthSpline(data->GetNameSpline(p1, p4), spline.GetLength());
@ -113,8 +108,9 @@ void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, c
scene->addItem(spl); scene->addItem(spl);
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(spl, &VToolSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(spl, &VToolSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, spl);
tools->insert(id,spl); doc->IncrementReferens(p1);
doc->IncrementReferens(p4);
} }
} }
@ -177,12 +173,7 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, SplinePo
} }
void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VSpline spl = VDrawTool::data.GetSpline(id); ContextMenu(dialogSpline, this, event);
if(spl.referens() > 1){
ContextMenu(dialogSpline, this, event, false);
} else {
ContextMenu(dialogSpline, this, event);
}
} }
void VToolSpline::AddToFile(){ void VToolSpline::AddToFile(){
@ -219,6 +210,12 @@ void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VToolSpline::RemoveReferens(){
VSpline spl = VAbstractTool::data.GetSpline(id);
doc->DecrementReferens(spl.GetP1());
doc->DecrementReferens(spl.GetP4());
}
void VToolSpline::RefreshGeometry(){ void VToolSpline::RefreshGeometry(){
VSpline spl = VAbstractTool::data.GetSpline(id); VSpline spl = VAbstractTool::data.GetSpline(id);
QPainterPath path; QPainterPath path;

View File

@ -61,6 +61,7 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
private: private:
QSharedPointer<DialogSpline> dialogSpline; QSharedPointer<DialogSpline> dialogSpline;
QVector<VControlPointSpline *> controlPoints; QVector<VControlPointSpline *> controlPoints;

View File

@ -70,6 +70,9 @@ void VToolSplinePath::setDialog(){
void VToolSplinePath::Create(QSharedPointer<DialogSplinePath> &dialog, VMainGraphicsScene *scene, void VToolSplinePath::Create(QSharedPointer<DialogSplinePath> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data){ VDomDocument *doc, VContainer *data){
VSplinePath path = dialog->GetPath(); VSplinePath path = dialog->GetPath();
for(qint32 i = 0; i < path.CountPoint(); ++i){
doc->IncrementReferens(path[i].P());
}
Create(0, path, scene, doc, data, Document::FullParse, Tool::FromGui); Create(0, path, scene, doc, data, Document::FullParse, Tool::FromGui);
} }
@ -82,12 +85,7 @@ void VToolSplinePath::Create(const qint64 _id, const VSplinePath &path, VMainGra
} else { } else {
data->UpdateSplinePath(id, path); data->UpdateSplinePath(id, path);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::SplinePath);
}
} }
} }
data->AddLengthSpline(data->GetNameSplinePath(path), path.GetLength()); data->AddLengthSpline(data->GetNameSplinePath(path), path.GetLength());
@ -97,8 +95,7 @@ void VToolSplinePath::Create(const qint64 _id, const VSplinePath &path, VMainGra
scene->addItem(spl); scene->addItem(spl);
connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(spl, &VToolSplinePath::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(spl, &VToolSplinePath::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, spl);
tools->insert(id,spl);
} }
} }
@ -216,12 +213,7 @@ void VToolSplinePath::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){
} }
void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VSplinePath path = VDrawTool::data.GetSplinePath(id); ContextMenu(dialogSplinePath, this, event);
if(path.referens() > 1){
ContextMenu(dialogSplinePath, this, event, false);
} else {
ContextMenu(dialogSplinePath, this, event);
}
} }
void VToolSplinePath::AddToFile(){ void VToolSplinePath::AddToFile(){
@ -267,6 +259,13 @@ void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VToolSplinePath::RemoveReferens(){
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
for(qint32 i = 0; i < splPath.Count(); ++i){
doc->DecrementReferens(splPath[i].P());
}
}
void VToolSplinePath::RefreshGeometry(){ void VToolSplinePath::RefreshGeometry(){
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id); VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
QPainterPath path; QPainterPath path;

View File

@ -29,18 +29,18 @@
#include "widgets/vcontrolpointspline.h" #include "widgets/vcontrolpointspline.h"
#include "container/vcontainer.h" #include "container/vcontainer.h"
class VToolSplinePath:public VDrawTool, public QGraphicsPathItem class VToolSplinePath:public VDrawTool, public QGraphicsPathItem{
{
Q_OBJECT Q_OBJECT
public: public:
VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id, VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
Tool::Sources typeCreation, Tool::Sources typeCreation,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogSplinePath> &dialog, VMainGraphicsScene *scene, static void Create(QSharedPointer<DialogSplinePath> &dialog,
VDomDocument *doc, VContainer *data); VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data);
static void Create(const qint64 _id, const VSplinePath &path, VMainGraphicsScene *scene, static void Create(const qint64 _id, const VSplinePath &path,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation); VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
signals: signals:
void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos,
const QPointF &controlPoint, const QPointF &splinePoint); const QPointF &controlPoint, const QPointF &splinePoint);
@ -59,6 +59,7 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
private: private:
QSharedPointer<DialogSplinePath> dialogSplinePath; QSharedPointer<DialogSplinePath> dialogSplinePath;
QVector<VControlPointSpline *> controlPoints; QVector<VControlPointSpline *> controlPoints;

View File

@ -86,6 +86,11 @@ void VModelingAlongLine::AddToFile(){
AddToModeling(domElement); AddToModeling(domElement);
} }
void VModelingAlongLine::RemoveReferens(){
doc->DecrementReferens(secondPointId);
VModelingLinePoint::RemoveReferens();
}
void VModelingAlongLine::setDialog(){ void VModelingAlongLine::setDialog(){
Q_ASSERT(!dialogAlongLine.isNull()); Q_ASSERT(!dialogAlongLine.isNull());
if(!dialogAlongLine.isNull()){ if(!dialogAlongLine.isNull()){
@ -130,24 +135,18 @@ VModelingAlongLine *VModelingAlongLine::Create(const qint64 _id, const QString &
} else { } else {
data->UpdateModelingPoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); data->UpdateModelingPoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
}
} }
} }
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
data->AddLine(id, secondPointId); data->AddLine(id, secondPointId);
data->IncrementReferens(firstPointId, Scene::Point, Draw::Modeling);
data->IncrementReferens(secondPointId, Scene::Point, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
point = new VModelingAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine, point = new VModelingAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine,
typeCreation); typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
} }
} }
return point; return point;

View File

@ -25,30 +25,30 @@
#include "vmodelinglinepoint.h" #include "vmodelinglinepoint.h"
#include "dialogs/dialogalongline.h" #include "dialogs/dialogalongline.h"
class VModelingAlongLine : public VModelingLinePoint class VModelingAlongLine : public VModelingLinePoint{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula, VModelingAlongLine(VDomDocument *doc, VContainer *data, qint64 id,
const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine, const QString &formula, const qint64 &firstPointId,
Tool::Sources typeCreation, QGraphicsItem * parent = 0); const qint64 &secondPointId, const QString &typeLine,
virtual void setDialog(); Tool::Sources typeCreation, QGraphicsItem * parent = 0);
static VModelingAlongLine* Create(QSharedPointer<DialogAlongLine> &dialog, VDomDocument *doc, virtual void setDialog();
VContainer *data); static VModelingAlongLine* Create(QSharedPointer<DialogAlongLine> &dialog, VDomDocument *doc,
static VModelingAlongLine* Create(const qint64 _id, const QString &pointName, const QString &typeLine, VContainer *data);
const QString &formula, const qint64 &firstPointId, static VModelingAlongLine* Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const qint64 &secondPointId, const qreal &mx, const qreal &my, const QString &formula, const qint64 &firstPointId,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, const qint64 &secondPointId, const qreal &mx, const qreal &my,
Tool::Sources typeCreation); VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 secondPointId; qint64 secondPointId;
QSharedPointer<DialogAlongLine> dialogAlongLine; QSharedPointer<DialogAlongLine> dialogAlongLine;
}; };

View File

@ -91,20 +91,14 @@ VModelingArc* VModelingArc::Create(const qint64 _id, const qint64 &center, const
} else { } else {
data->UpdateModelingArc(id, arc); data->UpdateModelingArc(id, arc);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Arc, Draw::Modeling);
}
} }
} }
data->AddLengthArc(data->GetNameArc(center,id, Draw::Modeling), arc.GetLength()); data->AddLengthArc(data->GetNameArc(center,id, Draw::Modeling), arc.GetLength());
data->IncrementReferens(center, Scene::Point, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
toolArc = new VModelingArc(doc, data, id, typeCreation); toolArc = new VModelingArc(doc, data, id, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, toolArc);
tools->insert(id,toolArc); doc->IncrementReferens(center);
} }
return toolArc; return toolArc;
} }
@ -162,6 +156,11 @@ void VModelingArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VModelingArc::RemoveReferens(){
VArc arc = VAbstractTool::data.GetModelingArc(id);
doc->DecrementReferens(arc.GetCenter());
}
void VModelingArc::RefreshGeometry(){ void VModelingArc::RefreshGeometry(){
VArc arc = VAbstractTool::data.GetModelingArc(id); VArc arc = VAbstractTool::data.GetModelingArc(id);
QPainterPath path; QPainterPath path;

View File

@ -29,17 +29,16 @@
#include "widgets/vcontrolpointspline.h" #include "widgets/vcontrolpointspline.h"
#include "container/vcontainer.h" #include "container/vcontainer.h"
class VModelingArc :public VModelingTool, public QGraphicsPathItem class VModelingArc :public VModelingTool, public QGraphicsPathItem{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation, VModelingArc(VDomDocument *doc, VContainer *data, qint64 id,
QGraphicsItem * parent = 0); Tool::Sources typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static VModelingArc* Create(QSharedPointer<DialogArc> &dialog, VDomDocument *doc, VContainer *data); static VModelingArc* Create(QSharedPointer<DialogArc> &dialog, VDomDocument *doc, VContainer *data);
static VModelingArc* Create(const qint64 _id, const qint64 &center, const QString &radius, static VModelingArc* Create(const qint64 _id, const qint64 &center, const QString &radius,
const QString &f1, const QString &f2, VDomDocument *doc, VContainer *data, const QString &f1, const QString &f2, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation); const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
@ -49,6 +48,7 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
private: private:
QSharedPointer<DialogArc> dialogArc; QSharedPointer<DialogArc> dialogArc;
void RefreshGeometry(); void RefreshGeometry();

View File

@ -97,23 +97,17 @@ VModelingBisector *VModelingBisector::Create(const qint64 _id, const QString &fo
} else { } else {
data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
}
} }
} }
data->AddLine(firstPointId, id, Draw::Modeling); data->AddLine(firstPointId, id, Draw::Modeling);
data->IncrementReferens(firstPointId, Scene::Point, Draw::Modeling);
data->IncrementReferens(secondPointId, Scene::Point, Draw::Modeling);
data->IncrementReferens(thirdPointId, Scene::Point, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
point = new VModelingBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId, point = new VModelingBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId,
thirdPointId, typeCreation); thirdPointId, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
doc->IncrementReferens(thirdPointId);
} }
} }
return point; return point;
@ -169,3 +163,9 @@ void VModelingBisector::AddToFile(){
AddToModeling(domElement); AddToModeling(domElement);
} }
void VModelingBisector::RemoveReferens(){
doc->DecrementReferens(firstPointId);
doc->DecrementReferens(thirdPointId);
VModelingLinePoint::RemoveReferens();
}

View File

@ -26,33 +26,34 @@
#include "vmodelinglinepoint.h" #include "vmodelinglinepoint.h"
#include "dialogs/dialogbisector.h" #include "dialogs/dialogbisector.h"
class VModelingBisector : public VModelingLinePoint class VModelingBisector : public VModelingLinePoint{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingBisector(VDomDocument *doc, VContainer *data, const qint64 &id, VModelingBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &firstPointId, const QString &typeLine, const QString &formula,
const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Sources typeCreation, const qint64 &firstPointId, const qint64 &secondPointId,
QGraphicsItem * parent = 0); const qint64 &thirdPointId, Tool::Sources typeCreation,
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, QGraphicsItem * parent = 0);
const QPointF &thirdPoint, const qreal& length); static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
virtual void setDialog(); const QPointF &thirdPoint, const qreal& length);
static VModelingBisector* Create(QSharedPointer<DialogBisector> &dialog, VDomDocument *doc, virtual void setDialog();
VContainer *data); static VModelingBisector* Create(QSharedPointer<DialogBisector> &dialog, VDomDocument *doc,
static VModelingBisector* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, VContainer *data);
const qint64 &secondPointId, const qint64 &thirdPointId, static VModelingBisector* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
const QString &typeLine, const QString &pointName, const qreal &mx, const qint64 &secondPointId, const qint64 &thirdPointId,
const qreal &my, VDomDocument *doc, VContainer *data, const QString &typeLine, const QString &pointName, const qreal &mx,
const Document::Documents &parse, Tool::Sources typeCreation); const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 firstPointId; qint64 firstPointId;
qint64 thirdPointId; qint64 thirdPointId;
QSharedPointer<DialogBisector> dialogBisector; QSharedPointer<DialogBisector> dialogBisector;
}; };

View File

@ -78,20 +78,14 @@ VModelingEndLine *VModelingEndLine::Create(const qint64 _id, const QString &poin
} else { } else {
data->UpdateModelingPoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); data->UpdateModelingPoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
}
} }
} }
data->AddLine(basePointId, id, Draw::Modeling); data->AddLine(basePointId, id, Draw::Modeling);
data->IncrementReferens(basePointId, Scene::Point, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
point = new VModelingEndLine(doc, data, id, typeLine, formula, angle, basePointId, typeCreation); point = new VModelingEndLine(doc, data, id, typeLine, formula, angle, basePointId, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(basePointId);
} }
} }
return point; return point;

View File

@ -26,27 +26,27 @@
#include "vmodelinglinepoint.h" #include "vmodelinglinepoint.h"
#include "dialogs/dialogendline.h" #include "dialogs/dialogendline.h"
class VModelingEndLine : public VModelingLinePoint class VModelingEndLine : public VModelingLinePoint{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qreal &angle, const QString &typeLine, const QString &formula,
const qint64 &basePointId, Tool::Sources typeCreation, const qreal &angle, const qint64 &basePointId,
QGraphicsItem * parent = 0); Tool::Sources typeCreation,
virtual void setDialog(); QGraphicsItem * parent = 0);
static VModelingEndLine* Create(QSharedPointer<DialogEndLine> &dialog, VDomDocument *doc, virtual void setDialog();
VContainer *data); static VModelingEndLine* Create(QSharedPointer<DialogEndLine> &dialog, VDomDocument *doc,
static VModelingEndLine* Create(const qint64 _id, const QString &pointName, const QString &typeLine, VContainer *data);
const QString &formula, const qreal &angle, const qint64 &basePointId, static VModelingEndLine* Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data, const QString &formula, const qreal &angle, const qint64 &basePointId,
const Document::Documents &parse, Tool::Sources typeCreation); const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
private: private:
QSharedPointer<DialogEndLine> dialogEndLine; QSharedPointer<DialogEndLine> dialogEndLine;
}; };

View File

@ -59,20 +59,15 @@ VModelingLine *VModelingLine::Create(const qint64 &id, const qint64 &firstPoint,
Q_CHECK_PTR(doc); Q_CHECK_PTR(doc);
Q_CHECK_PTR(data); Q_CHECK_PTR(data);
data->AddLine(firstPoint, secondPoint, Draw::Modeling); data->AddLine(firstPoint, secondPoint, Draw::Modeling);
data->IncrementReferens(firstPoint, Scene::Point, Draw::Modeling);
data->IncrementReferens(secondPoint, Scene::Point, Draw::Modeling);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
Q_CHECK_PTR(tools);
VDataTool *tool = tools->value(id);
Q_CHECK_PTR(tool);
tool->VDataTool::setData(data);
} }
if(parse == Document::FullParse){ if(parse == Document::FullParse){
qint64 id = data->getNextId(); qint64 id = data->getNextId();
line = new VModelingLine(doc, data, id, firstPoint, secondPoint, typeCreation); line = new VModelingLine(doc, data, id, firstPoint, secondPoint, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, line);
tools->insert(id,line); doc->IncrementReferens(firstPoint);
doc->IncrementReferens(secondPoint);
} }
return line; return line;
} }
@ -122,3 +117,8 @@ void VModelingLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VModelingLine::RemoveReferens(){
doc->DecrementReferens(firstPoint);
doc->DecrementReferens(secondPoint);
}

View File

@ -26,28 +26,29 @@
#include "QGraphicsLineItem" #include "QGraphicsLineItem"
#include "dialogs/dialogline.h" #include "dialogs/dialogline.h"
class VModelingLine: public VModelingTool, public QGraphicsLineItem class VModelingLine: public VModelingTool, public QGraphicsLineItem{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, VModelingLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
qint64 secondPoint, Tool::Sources typeCreation, QGraphicsItem * parent = 0); qint64 secondPoint, Tool::Sources typeCreation,
virtual void setDialog(); QGraphicsItem * parent = 0);
static VModelingLine* Create(QSharedPointer<DialogLine> &dialog, VDomDocument *doc, VContainer *data); virtual void setDialog();
static VModelingLine* Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint, static VModelingLine* Create(QSharedPointer<DialogLine> &dialog, VDomDocument *doc, VContainer *data);
VDomDocument *doc, VContainer *data, const Document::Documents &parse, static VModelingLine* Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
Tool::Sources typeCreation); VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
private: private:
qint64 firstPoint; qint64 firstPoint;
qint64 secondPoint; qint64 secondPoint;
QSharedPointer<DialogLine> dialogLine; QSharedPointer<DialogLine> dialogLine;
}; };

View File

@ -78,12 +78,7 @@ VModelingLineIntersect *VModelingLineIntersect::Create(const qint64 _id, const q
} else { } else {
data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
}
} }
} }
data->AddLine(p1Line1Id, id, Draw::Modeling); data->AddLine(p1Line1Id, id, Draw::Modeling);
@ -93,8 +88,11 @@ VModelingLineIntersect *VModelingLineIntersect::Create(const qint64 _id, const q
if(parse == Document::FullParse){ if(parse == Document::FullParse){
point = new VModelingLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, point = new VModelingLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id,
typeCreation); typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(p1Line1Id);
doc->IncrementReferens(p2Line1Id);
doc->IncrementReferens(p1Line2Id);
doc->IncrementReferens(p2Line2Id);
} }
} }
return point; return point;
@ -147,3 +145,10 @@ void VModelingLineIntersect::AddToFile(){
AddToModeling(domElement); AddToModeling(domElement);
} }
void VModelingLineIntersect::RemoveReferens(){
doc->DecrementReferens(p1Line1);
doc->DecrementReferens(p2Line1);
doc->DecrementReferens(p1Line2);
doc->DecrementReferens(p2Line2);
}

View File

@ -25,30 +25,31 @@
#include "vmodelingpoint.h" #include "vmodelingpoint.h"
#include "dialogs/dialoglineintersect.h" #include "dialogs/dialoglineintersect.h"
class VModelingLineIntersect:public VModelingPoint class VModelingLineIntersect:public VModelingPoint{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingLineIntersect(VDomDocument *doc, VContainer *data, VModelingLineIntersect(VDomDocument *doc, VContainer *data,
const qint64 &id, const qint64 &id, const qint64 &p1Line1,
const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line1, const qint64 &p1Line2, const qint64 &p2Line2,
const qint64 &p2Line2, Tool::Sources typeCreation, Tool::Sources typeCreation,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static VModelingLineIntersect* Create(QSharedPointer<DialogLineIntersect> &dialog, static VModelingLineIntersect* Create(QSharedPointer<DialogLineIntersect> &dialog,
VDomDocument *doc,VContainer *data); VDomDocument *doc,VContainer *data);
static VModelingLineIntersect* Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id, static VModelingLineIntersect* Create(const qint64 _id, const qint64 &p1Line1Id,
const qint64 &p1Line2Id, const qint64 &p2Line2Id, const qint64 &p2Line1Id, const qint64 &p1Line2Id,
const QString &pointName, const qreal &mx, const qreal &my, const qint64 &p2Line2Id, const QString &pointName,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, const qreal &mx, const qreal &my, VDomDocument *doc,
Tool::Sources typeCreation); VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 p1Line1; qint64 p1Line1;
qint64 p2Line1; qint64 p2Line1;

View File

@ -50,3 +50,7 @@ void VModelingLinePoint::RefreshGeometry(){
mainLine->setVisible(true); mainLine->setVisible(true);
} }
} }
void VModelingLinePoint::RemoveReferens(){
doc->DecrementReferens(basePointId);
}

View File

@ -24,13 +24,13 @@
#include "vmodelingpoint.h" #include "vmodelingpoint.h"
class VModelingLinePoint : public VModelingPoint class VModelingLinePoint : public VModelingPoint{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, VModelingLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const QString &typeLine, const QString &formula,
const qint64 &basePointId, const qreal &angle, QGraphicsItem * parent = 0); const qint64 &basePointId, const qreal &angle,
QGraphicsItem * parent = 0);
protected: protected:
QString typeLine; QString typeLine;
QString formula; QString formula;
@ -38,9 +38,9 @@ protected:
qint64 basePointId; qint64 basePointId;
QGraphicsLineItem *mainLine; QGraphicsLineItem *mainLine;
virtual void RefreshGeometry(); virtual void RefreshGeometry();
virtual void RemoveReferens();
private: private:
VModelingLinePoint(const VModelingLinePoint &tool); Q_DISABLE_COPY(VModelingLinePoint)
const VModelingLinePoint &operator=(const VModelingLinePoint &tool);
}; };
#endif // VMODELINGLINEPOINT_H #endif // VMODELINGLINEPOINT_H

View File

@ -81,22 +81,16 @@ VModelingNormal *VModelingNormal::Create(const qint64 _id, const QString &formul
} else { } else {
data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
}
} }
} }
data->AddLine(firstPointId, id, Draw::Modeling); data->AddLine(firstPointId, id, Draw::Modeling);
data->IncrementReferens(firstPointId, Scene::Point, Draw::Modeling);
data->IncrementReferens(secondPointId, Scene::Point, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
point = new VModelingNormal(doc, data, id, typeLine, formula, angle, firstPointId, secondPointId, point = new VModelingNormal(doc, data, id, typeLine, formula, angle, firstPointId, secondPointId,
typeCreation); typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
} }
} }
return point; return point;
@ -161,3 +155,8 @@ void VModelingNormal::AddToFile(){
AddToModeling(domElement); AddToModeling(domElement);
} }
void VModelingNormal::RemoveReferens(){
doc->DecrementReferens(secondPointId);
VModelingLinePoint::RemoveReferens();
}

View File

@ -26,22 +26,22 @@
#include "vmodelinglinepoint.h" #include "vmodelinglinepoint.h"
#include "dialogs/dialognormal.h" #include "dialogs/dialognormal.h"
class VModelingNormal : public VModelingLinePoint class VModelingNormal : public VModelingLinePoint{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id, VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const QString &typeLine, const QString &formula,
const qreal &angle, const qint64 &firstPointId, const qreal &angle, const qint64 &firstPointId,
const qint64 &secondPointId, Tool::Sources typeCreation, const qint64 &secondPointId, Tool::Sources typeCreation,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static VModelingNormal* Create(QSharedPointer<DialogNormal> &dialog, VDomDocument *doc, VContainer *data); static VModelingNormal* Create(QSharedPointer<DialogNormal> &dialog, VDomDocument *doc,
static VModelingNormal* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, VContainer *data);
const qint64 &secondPointId, const QString typeLine, static VModelingNormal* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
const QString pointName, const qreal angle, const qreal &mx, const qint64 &secondPointId, const QString typeLine,
const qreal &my, VDomDocument *doc, VContainer *data, const Document::Documents &parse, const QString pointName, const qreal angle, const qreal &mx,
Tool::Sources typeCreation); const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
const qreal &length, const qreal &angle = 0); const qreal &length, const qreal &angle = 0);
public slots: public slots:
@ -50,6 +50,7 @@ public slots:
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 secondPointId; qint64 secondPointId;
QSharedPointer<DialogNormal> dialogNormal; QSharedPointer<DialogNormal> dialogNormal;

View File

@ -26,12 +26,12 @@
#include "widgets/vgraphicssimpletextitem.h" #include "widgets/vgraphicssimpletextitem.h"
#include "options.h" #include "options.h"
class VModelingPoint: public VModelingTool, public QGraphicsEllipseItem class VModelingPoint: public VModelingTool, public QGraphicsEllipseItem{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem * parent = 0); VModelingPoint(VDomDocument *doc, VContainer *data, qint64 id,
virtual ~VModelingPoint(); QGraphicsItem * parent = 0);
virtual ~VModelingPoint();
public slots: public slots:
void NameChangePosition(const QPointF pos); void NameChangePosition(const QPointF pos);
virtual void FullUpdateFromGui(int result) = 0; virtual void FullUpdateFromGui(int result) = 0;
@ -46,8 +46,7 @@ protected:
virtual void RefreshPointGeometry(const VPointF &point); virtual void RefreshPointGeometry(const VPointF &point);
void RefreshLine(); void RefreshLine();
private: private:
VModelingPoint(const VModelingPoint &tool); Q_DISABLE_COPY(VModelingPoint)
const VModelingPoint &operator=(const VModelingPoint &tool);
}; };
#endif // VMODELINGPOINT_H #endif // VMODELINGPOINT_H

View File

@ -102,22 +102,16 @@ VModelingPointOfContact *VModelingPointOfContact::Create(const qint64 _id, const
} else { } else {
data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
}
} }
} }
data->IncrementReferens(center, Scene::Point, Draw::Modeling);
data->IncrementReferens(firstPointId, Scene::Point, Draw::Modeling);
data->IncrementReferens(secondPointId, Scene::Point, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
point = new VModelingPointOfContact(doc, data, id, radius, center, firstPointId, secondPointId, point = new VModelingPointOfContact(doc, data, id, radius, center, firstPointId, secondPointId,
typeCreation); typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(center);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
} }
} }
return point; return point;
@ -170,3 +164,9 @@ void VModelingPointOfContact::AddToFile(){
AddToModeling(domElement); AddToModeling(domElement);
} }
void VModelingPointOfContact::RemoveReferens(){
doc->DecrementReferens(center);
doc->DecrementReferens(firstPointId);
doc->DecrementReferens(secondPointId);
}

View File

@ -25,34 +25,38 @@
#include "vmodelingpoint.h" #include "vmodelingpoint.h"
#include "dialogs/dialogpointofcontact.h" #include "dialogs/dialogpointofcontact.h"
class VModelingPointOfContact : public VModelingPoint class VModelingPointOfContact : public VModelingPoint{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, VModelingPointOfContact(VDomDocument *doc, VContainer *data,
const QString &radius, const qint64 &center, const qint64 &firstPointId, const qint64 &id, const QString &radius,
const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem * parent = 0); const qint64 &center,
virtual void setDialog(); const qint64 &firstPointId,
static QPointF FindPoint(const qreal &radius, const QPointF &center, const QPointF &firstPoint, const qint64 &secondPointId,
const QPointF &secondPoint); Tool::Sources typeCreation,
static VModelingPointOfContact* Create(QSharedPointer<DialogPointOfContact> &dialog, QGraphicsItem * parent = 0);
VDomDocument *doc, VContainer *data); virtual void setDialog();
static VModelingPointOfContact* Create(const qint64 _id, const QString &radius, const qint64 &center, static QPointF FindPoint(const qreal &radius, const QPointF &center,
const qint64 &firstPointId, const qint64 &secondPointId, const QPointF &firstPoint, const QPointF &secondPoint);
const QString &pointName, const qreal &mx, const qreal &my, static VModelingPointOfContact* Create(QSharedPointer<DialogPointOfContact> &dialog,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, VDomDocument *doc, VContainer *data);
Tool::Sources typeCreation); static VModelingPointOfContact* Create(const qint64 _id, const QString &radius, const qint64 &center,
const qint64 &firstPointId, const qint64 &secondPointId,
const QString &pointName, const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
QString radius; QString radius;
qint64 center; qint64 center;
qint64 firstPointId; qint64 firstPointId;
qint64 secondPointId; qint64 secondPointId;
QSharedPointer<DialogPointOfContact> dialogPointOfContact; QSharedPointer<DialogPointOfContact> dialogPointOfContact;
}; };

View File

@ -83,11 +83,12 @@ VModelingShoulderPoint *VModelingShoulderPoint::Create(QSharedPointer<DialogShou
} }
VModelingShoulderPoint *VModelingShoulderPoint::Create(const qint64 _id, const QString &formula, VModelingShoulderPoint *VModelingShoulderPoint::Create(const qint64 _id, const QString &formula,
const qint64 &p1Line, const qint64 &p2Line, const qint64 &p1Line, const qint64 &p2Line,
const qint64 &pShoulder, const QString &typeLine, const qint64 &pShoulder, const QString &typeLine,
const QString &pointName, const qreal &mx, const QString &pointName, const qreal &mx,
const qreal &my, VDomDocument *doc, VContainer *data, const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation){ const Document::Documents &parse,
const Tool::Sources &typeCreation){
VModelingShoulderPoint *point = 0; VModelingShoulderPoint *point = 0;
VPointF firstPoint = data->GetModelingPoint(p1Line); VPointF firstPoint = data->GetModelingPoint(p1Line);
VPointF secondPoint = data->GetModelingPoint(p2Line); VPointF secondPoint = data->GetModelingPoint(p2Line);
@ -105,24 +106,18 @@ VModelingShoulderPoint *VModelingShoulderPoint::Create(const qint64 _id, const Q
} else { } else {
data->UpdateModelingPoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdateModelingPoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
}
} }
} }
data->AddLine(p1Line, id, Draw::Modeling); data->AddLine(p1Line, id, Draw::Modeling);
data->AddLine(p2Line, id, Draw::Modeling); data->AddLine(p2Line, id, Draw::Modeling);
data->IncrementReferens(p1Line, Scene::Point, Draw::Modeling);
data->IncrementReferens(p2Line, Scene::Point, Draw::Modeling);
data->IncrementReferens(pShoulder, Scene::Point, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
point = new VModelingShoulderPoint(doc, data, id, typeLine, formula, p1Line, p2Line, pShoulder, point = new VModelingShoulderPoint(doc, data, id, typeLine, formula, p1Line, p2Line, pShoulder,
typeCreation); typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(p1Line);
doc->IncrementReferens(p2Line);
doc->IncrementReferens(pShoulder);
} }
} }
return point; return point;
@ -178,3 +173,9 @@ void VModelingShoulderPoint::AddToFile(){
AddToModeling(domElement); AddToModeling(domElement);
} }
void VModelingShoulderPoint::RemoveReferens(){
doc->DecrementReferens(p2Line);
doc->DecrementReferens(pShoulder);
VModelingLinePoint::RemoveReferens();
}

View File

@ -25,33 +25,36 @@
#include "vmodelinglinepoint.h" #include "vmodelinglinepoint.h"
#include "dialogs/dialogshoulderpoint.h" #include "dialogs/dialogshoulderpoint.h"
class VModelingShoulderPoint : public VModelingLinePoint class VModelingShoulderPoint : public VModelingLinePoint{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, VModelingShoulderPoint(VDomDocument *doc, VContainer *data,
const QString &typeLine, const QString &formula, const qint64 &p1Line, const qint64 &id, const QString &typeLine,
const qint64 &p2Line, const qint64 &pShoulder, Tool::Sources typeCreation, const QString &formula, const qint64 &p1Line,
QGraphicsItem * parent = 0); const qint64 &p2Line, const qint64 &pShoulder,
virtual void setDialog(); Tool::Sources typeCreation,
static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, QGraphicsItem * parent = 0);
const qreal &length); virtual void setDialog();
static VModelingShoulderPoint* Create(QSharedPointer<DialogShoulderPoint> &dialog, static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line,
VDomDocument *doc, VContainer *data); const QPointF &pShoulder, const qreal &length);
static VModelingShoulderPoint* Create(const qint64 _id, const QString &formula, const qint64 &p1Line, static VModelingShoulderPoint* Create(QSharedPointer<DialogShoulderPoint> &dialog,
const qint64 &p2Line, const qint64 &pShoulder, VDomDocument *doc, VContainer *data);
const QString &typeLine, const QString &pointName, static VModelingShoulderPoint* Create(const qint64 _id, const QString &formula, const qint64 &p1Line,
const qreal &mx, const qreal &my, VDomDocument *doc, const qint64 &p2Line, const qint64 &pShoulder,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation); const QString &typeLine, const QString &pointName,
const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 p2Line; qint64 p2Line;
qint64 pShoulder; qint64 pShoulder;
QSharedPointer<DialogShoulderPoint> dialogShoulderPoint; QSharedPointer<DialogShoulderPoint> dialogShoulderPoint;
}; };

View File

@ -100,16 +100,14 @@ VModelingSpline *VModelingSpline::Create(const qint64 _id, const qint64 &p1, con
data->UpdateModelingSpline(id, spline); data->UpdateModelingSpline(id, spline);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
data->IncrementReferens(id, Scene::Spline, Draw::Modeling);
} }
} }
data->AddLengthSpline(data->GetNameSpline(p1, p4, Draw::Modeling), spline.GetLength()); data->AddLengthSpline(data->GetNameSpline(p1, p4, Draw::Modeling), spline.GetLength());
data->IncrementReferens(p1, Scene::Point, Draw::Modeling);
data->IncrementReferens(p4, Scene::Point, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
spl = new VModelingSpline(doc, data, id, typeCreation); spl = new VModelingSpline(doc, data, id, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, spl);
tools->insert(id,spl); doc->IncrementReferens(p1);
doc->IncrementReferens(p4);
} }
return spl; return spl;
} }
@ -211,6 +209,12 @@ void VModelingSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VModelingSpline::RemoveReferens(){
VSpline spl = VAbstractTool::data.GetModelingSpline(id);
doc->DecrementReferens(spl.GetP1());
doc->DecrementReferens(spl.GetP4());
}
void VModelingSpline::RefreshGeometry(){ void VModelingSpline::RefreshGeometry(){
VSpline spl = VAbstractTool::data.GetModelingSpline(id); VSpline spl = VAbstractTool::data.GetModelingSpline(id);
QPainterPath path; QPainterPath path;

View File

@ -30,19 +30,19 @@
#include "container/vcontainer.h" #include "container/vcontainer.h"
#include "geometry/vsplinepath.h" #include "geometry/vsplinepath.h"
class VModelingSpline:public VModelingTool, public QGraphicsPathItem class VModelingSpline:public VModelingTool, public QGraphicsPathItem{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingSpline (VDomDocument *doc, VContainer *data, qint64 id, VModelingSpline (VDomDocument *doc, VContainer *data, qint64 id,
Tool::Sources typeCreation, QGraphicsItem * parent = 0 ); Tool::Sources typeCreation, QGraphicsItem * parent = 0 );
virtual void setDialog(); virtual void setDialog();
static VModelingSpline* Create(QSharedPointer<DialogSpline> &dialog, VDomDocument *doc, static VModelingSpline* Create(QSharedPointer<DialogSpline> &dialog, VDomDocument *doc,
VContainer *data); VContainer *data);
static VModelingSpline* Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1, static VModelingSpline* Create(const qint64 _id, const qint64 &p1, const qint64 &p4,
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kAsm1, const qreal kAsm2, const qreal &angle1,
const qreal &kCurve, VDomDocument *doc, VContainer *data, const qreal &angle2, const qreal &kCurve, VDomDocument *doc,
const Document::Documents &parse, Tool::Sources typeCreation); VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation);
signals: signals:
void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position, void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &controlPoint, const QPointF &splinePoint ); const QPointF &controlPoint, const QPointF &splinePoint );
@ -59,6 +59,7 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
private: private:
QSharedPointer<DialogSpline> dialogSpline; QSharedPointer<DialogSpline> dialogSpline;
QVector<VControlPointSpline *> controlPoints; QVector<VControlPointSpline *> controlPoints;

View File

@ -70,6 +70,9 @@ void VModelingSplinePath::setDialog(){
VModelingSplinePath *VModelingSplinePath::Create(QSharedPointer<DialogSplinePath> &dialog, VModelingSplinePath *VModelingSplinePath::Create(QSharedPointer<DialogSplinePath> &dialog,
VDomDocument *doc, VContainer *data){ VDomDocument *doc, VContainer *data){
VSplinePath path = dialog->GetPath(); VSplinePath path = dialog->GetPath();
for(qint32 i = 0; i < path.CountPoint(); ++i){
doc->IncrementReferens(path[i].P());
}
return Create(0, path, doc, data, Document::FullParse, Tool::FromGui); return Create(0, path, doc, data, Document::FullParse, Tool::FromGui);
} }
@ -83,22 +86,13 @@ VModelingSplinePath * VModelingSplinePath::Create(const qint64 _id, const VSplin
} else { } else {
data->UpdateModelingSplinePath(id, path); data->UpdateModelingSplinePath(id, path);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::SplinePath, Draw::Modeling);
}
} }
} }
for(qint32 i = 0; i < path.CountPoint(); ++i){
data->IncrementReferens(path.getIdObject(), Scene::Point, Draw::Modeling);
}
data->AddLengthSpline(data->GetNameSplinePath(path), path.GetLength()); data->AddLengthSpline(data->GetNameSplinePath(path), path.GetLength());
if(parse == Document::FullParse){ if(parse == Document::FullParse){
spl = new VModelingSplinePath(doc, data, id, typeCreation); spl = new VModelingSplinePath(doc, data, id, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, spl);
tools->insert(id,spl);
} }
return spl; return spl;
} }
@ -235,6 +229,13 @@ void VModelingSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VModelingSplinePath::RemoveReferens(){
VSplinePath splPath = VAbstractTool::data.GetModelingSplinePath(id);
for(qint32 i = 0; i < splPath.Count(); ++i){
doc->DecrementReferens(splPath[i].P());
}
}
void VModelingSplinePath::RefreshGeometry(){ void VModelingSplinePath::RefreshGeometry(){
VSplinePath splPath = VAbstractTool::data.GetModelingSplinePath(id); VSplinePath splPath = VAbstractTool::data.GetModelingSplinePath(id);
QPainterPath path; QPainterPath path;

View File

@ -29,18 +29,18 @@
#include "widgets/vcontrolpointspline.h" #include "widgets/vcontrolpointspline.h"
#include "container/vcontainer.h" #include "container/vcontainer.h"
class VModelingSplinePath:public VModelingTool, public QGraphicsPathItem class VModelingSplinePath:public VModelingTool, public QGraphicsPathItem{
{
Q_OBJECT Q_OBJECT
public: public:
VModelingSplinePath(VDomDocument *doc, VContainer *data, qint64 id, VModelingSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
Tool::Sources typeCreation, Tool::Sources typeCreation,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static VModelingSplinePath* Create(QSharedPointer<DialogSplinePath> &dialog, static VModelingSplinePath* Create(QSharedPointer<DialogSplinePath> &dialog,
VDomDocument *doc, VContainer *data); VDomDocument *doc, VContainer *data);
static VModelingSplinePath* Create(const qint64 _id, const VSplinePath &path, VDomDocument *doc, static VModelingSplinePath* Create(const qint64 _id, const VSplinePath &path, VDomDocument *doc,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation); VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation);
signals: signals:
void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos,
const QPointF &controlPoint, const QPointF &splinePoint); const QPointF &controlPoint, const QPointF &splinePoint);
@ -57,6 +57,7 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
private: private:
QSharedPointer<DialogSplinePath> dialogSplinePath; QSharedPointer<DialogSplinePath> dialogSplinePath;
QVector<VControlPointSpline *> controlPoints; QVector<VControlPointSpline *> controlPoints;

View File

@ -24,6 +24,7 @@
VModelingTool::VModelingTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent): VModelingTool::VModelingTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent):
VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false){ VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false){
_referens = 0;
} }
VModelingTool::~VModelingTool(){ VModelingTool::~VModelingTool(){
@ -46,3 +47,19 @@ void VModelingTool::AddToModeling(const QDomElement &domElement){
} }
emit toolhaveChange(); emit toolhaveChange();
} }
void VModelingTool::decrementReferens(){
if(_referens > 0){
--_referens;
}
if(_referens <= 0){
RemoveReferens();
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
QDomNode element = domElement.parentNode();
if(!element.isNull()){
element.removeChild(domElement);
}
}
}
}

View File

@ -35,9 +35,12 @@ public:
void ignoreContextMenu(bool enable); void ignoreContextMenu(bool enable);
public slots: public slots:
virtual void FullUpdateFromGui(int result)=0; virtual void FullUpdateFromGui(int result)=0;
signals:
void RemoveTool(QGraphicsItem *tool);
protected: protected:
bool ignoreContextMenuEvent; bool ignoreContextMenuEvent;
void AddToModeling(const QDomElement &domElement); void AddToModeling(const QDomElement &domElement);
virtual void decrementReferens();
template <typename Dialog, typename Tool> template <typename Dialog, typename Tool>
void ContextMenu(QSharedPointer<Dialog> &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event, void ContextMenu(QSharedPointer<Dialog> &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event,
bool showRemove = true){ bool showRemove = true){
@ -73,7 +76,7 @@ protected:
//update xml file //update xml file
emit FullUpdateTree(); emit FullUpdateTree();
//remove form scene //remove form scene
//emit RemoveTool(tool); emit RemoveTool(tool);
} }
} }
} }

View File

@ -25,9 +25,7 @@
VAbstractNode::VAbstractNode(VDomDocument *doc, VContainer *data, qint64 id, qint64 idNode, VAbstractNode::VAbstractNode(VDomDocument *doc, VContainer *data, qint64 id, qint64 idNode,
Draw::Draws typeobject, QObject *parent) : Draw::Draws typeobject, QObject *parent) :
VAbstractTool(doc, data, id, parent), idNode(idNode), typeobject(typeobject){ VAbstractTool(doc, data, id, parent), idNode(idNode), typeobject(typeobject){
} _referens = 0;
VAbstractNode::~VAbstractNode(){
} }
void VAbstractNode::AddToModeling(const QDomElement &domElement){ void VAbstractNode::AddToModeling(const QDomElement &domElement){
@ -40,3 +38,19 @@ void VAbstractNode::AddToModeling(const QDomElement &domElement){
} }
emit toolhaveChange(); emit toolhaveChange();
} }
void VAbstractNode::decrementReferens(){
if(_referens > 0){
--_referens;
}
if(_referens <= 0){
doc->DecrementReferens(idNode);
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
QDomNode element = domElement.parentNode();
if(!element.isNull()){
element.removeChild(domElement);
}
}
}
}

View File

@ -30,11 +30,12 @@ class VAbstractNode : public VAbstractTool
public: public:
VAbstractNode(VDomDocument *doc, VContainer *data, qint64 id, qint64 idNode, VAbstractNode(VDomDocument *doc, VContainer *data, qint64 id, qint64 idNode,
Draw::Draws typeobject, QObject *parent = 0 ); Draw::Draws typeobject, QObject *parent = 0 );
virtual ~VAbstractNode(); virtual ~VAbstractNode() {}
protected: protected:
qint64 idNode; qint64 idNode;
Draw::Draws typeobject; Draw::Draws typeobject;
void AddToModeling(const QDomElement &domElement); void AddToModeling(const QDomElement &domElement);
virtual void decrementReferens();
}; };
#endif // VABSTRACTNODE_H #endif // VABSTRACTNODE_H

View File

@ -34,16 +34,16 @@ VNodeArc::VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc,
} }
} }
VNodeArc *VNodeArc::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, void VNodeArc::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc,
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation){ Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation){
VNodeArc *arc = 0;
if(parse == Document::FullParse){ if(parse == Document::FullParse){
arc = new VNodeArc(doc, data, id, idArc, typeobject, typeCreation); VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeobject, typeCreation);
Q_CHECK_PTR(arc);
doc->AddTool(id, arc); doc->AddTool(id, arc);
doc->IncrementReferens(idArc);
} else { } else {
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
return arc;
} }
void VNodeArc::FullUpdateFromFile(){ void VNodeArc::FullUpdateFromFile(){

View File

@ -29,19 +29,19 @@ class VNodeArc :public VAbstractNode, public QGraphicsPathItem
{ {
Q_OBJECT Q_OBJECT
public: public:
VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, Draw::Draws typeobject, VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, Draw::Draws typeobject,
Tool::Sources typeCreation, QGraphicsItem * parent = 0); Tool::Sources typeCreation, QGraphicsItem * parent = 0);
static VNodeArc *Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, static void Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc,
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation); Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
protected: protected:
virtual void AddToFile(); virtual void AddToFile();
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private: private:
void RefreshGeometry(); void RefreshGeometry();
}; };
#endif // VNODEARC_H #endif // VNODEARC_H4

View File

@ -39,16 +39,16 @@ VNodePoint::VNodePoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 id
} }
} }
VNodePoint *VNodePoint::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, void VNodePoint::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint,
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation){ Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation){
VNodePoint *point = 0;
if(parse == Document::FullParse){ if(parse == Document::FullParse){
point = new VNodePoint(doc, data, id, idPoint, typeobject, typeCreation); VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeobject, typeCreation);
Q_CHECK_PTR(point);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(idPoint);
} else { } else {
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
return point;
} }
void VNodePoint::FullUpdateFromFile(){ void VNodePoint::FullUpdateFromFile(){

View File

@ -29,10 +29,12 @@ class VNodePoint: public VAbstractNode, public QGraphicsEllipseItem
{ {
Q_OBJECT Q_OBJECT
public: public:
VNodePoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, Draw::Draws typeobject, VNodePoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint,
Tool::Sources typeCreation, QGraphicsItem * parent = 0 ); Draw::Draws typeobject, Tool::Sources typeCreation,
static VNodePoint *Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, QGraphicsItem * parent = 0 );
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation); static void Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint,
Draw::Draws typeobject, const Document::Documents &parse,
Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
void NameChangePosition(const QPointF pos); void NameChangePosition(const QPointF pos);
@ -48,8 +50,7 @@ protected:
virtual void RefreshPointGeometry(const VPointF &point); virtual void RefreshPointGeometry(const VPointF &point);
void RefreshLine(); void RefreshLine();
private: private:
VNodePoint(const VNodePoint &point); Q_DISABLE_COPY(VNodePoint)
const VNodePoint &operator=(const VNodePoint &point);
}; };
#endif // VNODEPOINT_H #endif // VNODEPOINT_H

View File

@ -40,6 +40,7 @@ VNodeSpline *VNodeSpline::Create(VDomDocument *doc, VContainer *data, qint64 id,
if(parse == Document::FullParse){ if(parse == Document::FullParse){
spl = new VNodeSpline(doc, data, id, idSpline, typeobject, typeCreation); spl = new VNodeSpline(doc, data, id, idSpline, typeobject, typeCreation);
doc->AddTool(id, spl); doc->AddTool(id, spl);
doc->IncrementReferens(idSpline);
} else { } else {
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }

View File

@ -35,17 +35,21 @@ VNodeSplinePath::VNodeSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
} }
} }
VNodeSplinePath *VNodeSplinePath::Create(VDomDocument *doc, VContainer *data, qint64 id, void VNodeSplinePath::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
qint64 idSpline, Draw::Draws typeobject, const Document::Documents &parse, Draw::Draws typeobject, const Document::Documents &parse,
Tool::Sources typeCreation){ Tool::Sources typeCreation){
VNodeSplinePath *splPath = 0;
if(parse == Document::FullParse){ if(parse == Document::FullParse){
splPath = new VNodeSplinePath(doc, data, id, idSpline, typeobject, typeCreation); VNodeSplinePath *splPath = new VNodeSplinePath(doc, data, id, idSpline, typeobject, typeCreation);
Q_CHECK_PTR(splPath);
doc->AddTool(id, splPath); doc->AddTool(id, splPath);
VSplinePath path = data->GetModelingSplinePath(id);
const QVector<VSplinePoint> *points = path.GetPoint();
for(qint32 i = 0; i<points->size(); ++i){
doc->IncrementReferens(points->at(i).P());
}
} else { } else {
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
return splPath;
} }
void VNodeSplinePath::FullUpdateFromFile(){ void VNodeSplinePath::FullUpdateFromFile(){

View File

@ -29,10 +29,11 @@ class VNodeSplinePath : public VAbstractNode, public QGraphicsPathItem
{ {
Q_OBJECT Q_OBJECT
public: public:
VNodeSplinePath(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, VNodeSplinePath(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
Draw::Draws typeobject, Tool::Sources typeCreation, QGraphicsItem * parent = 0); Draw::Draws typeobject, Tool::Sources typeCreation,
static VNodeSplinePath *Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, QGraphicsItem * parent = 0);
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation); static void Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
protected: protected:

View File

@ -24,8 +24,6 @@
VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent): VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent):
VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black){ VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black){
this->doc = doc;
this->id = id;
connect(this, &VAbstractTool::toolhaveChange, this->doc, &VDomDocument::haveLiteChange); connect(this, &VAbstractTool::toolhaveChange, this->doc, &VDomDocument::haveLiteChange);
connect(this->doc, &VDomDocument::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile); connect(this->doc, &VDomDocument::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile);

View File

@ -46,7 +46,7 @@ signals:
void FullUpdateTree(); void FullUpdateTree();
protected: protected:
VDomDocument *doc; VDomDocument *doc;
qint64 id; const qint64 id;
const Qt::GlobalColor baseColor; const Qt::GlobalColor baseColor;
Qt::GlobalColor currentColor; Qt::GlobalColor currentColor;
virtual void AddToFile()=0; virtual void AddToFile()=0;
@ -55,6 +55,7 @@ protected:
void AddAttribute(QDomElement &domElement, const QString &name, const qreal &value); void AddAttribute(QDomElement &domElement, const QString &name, const qreal &value);
void AddAttribute(QDomElement &domElement, const QString &name, const QString &value); void AddAttribute(QDomElement &domElement, const QString &name, const QString &value);
const VContainer *getData() const; const VContainer *getData() const;
virtual void RemoveReferens(){}
private: private:
Q_DISABLE_COPY(VAbstractTool) Q_DISABLE_COPY(VAbstractTool)
}; };

View File

@ -30,3 +30,9 @@ VDataTool &VDataTool::operator =(const VDataTool &tool){
void VDataTool::setData(const VContainer *value){ void VDataTool::setData(const VContainer *value){
data = *value; data = *value;
} }
void VDataTool::decrementReferens(){
if(_referens > 0){
--_referens;
}
}

View File

@ -28,17 +28,18 @@
class VDataTool : public QObject{ class VDataTool : public QObject{
Q_OBJECT Q_OBJECT
public: public:
explicit VDataTool(VContainer *data, QObject *parent = 0): QObject(parent), data(*data), _referens(0){} explicit VDataTool(VContainer *data, QObject *parent = 0)
virtual ~VDataTool(){} : QObject(parent), data(*data), _referens(1){}
VDataTool& operator= (const VDataTool &tool); virtual ~VDataTool(){}
VContainer getData() const { return data; } VDataTool &operator= (const VDataTool &tool);
void setData(const VContainer *value); inline VContainer getData() const { return data; }
qint64 referens() const {return _referens;} void setData(const VContainer *value);
void incrementReferens(){++_referens;} virtual inline qint64 referens() const {return _referens;}
void decrementReferens(){--_referens;} virtual inline void incrementReferens(){++_referens;}
virtual void decrementReferens();
protected: protected:
VContainer data; VContainer data;
qint64 _referens; qint64 _referens;
}; };
#endif // VDATATOOL_H #endif // VDATATOOL_H

View File

@ -25,136 +25,128 @@
#include "modelingTools/vmodelingtool.h" #include "modelingTools/vmodelingtool.h"
#include "modelingTools/modelingtools.h" #include "modelingTools/modelingtools.h"
VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, VDetail &oldDetail, VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, Tool::Sources typeCreation,
Tool::Sources typeCreation, const Document::Documents &parse,
VMainGraphicsScene *scene, QGraphicsItem *parent) VMainGraphicsScene *scene, QGraphicsItem *parent)
:VAbstractTool(doc, data, id), QGraphicsPathItem(parent), :VAbstractTool(doc, data, id), QGraphicsPathItem(parent), dialogDetail(QSharedPointer<DialogDetail>()),
dialogDetail(QSharedPointer<DialogDetail>()), sceneDetails(scene){ sceneDetails(scene){
VDetail detail = data->GetDetail(id); VDetail detail = data->GetDetail(id);
QMap<qint64, VDataTool*>* tools = doc->getTools();
Q_CHECK_PTR(tools);
for(qint32 i = 0; i< detail.CountNode(); ++i){ for(qint32 i = 0; i< detail.CountNode(); ++i){
switch(detail[i].getTypeTool()){ switch(detail[i].getTypeTool()){
case(Tool::NodePoint):{ case(Tool::NodePoint):{
VNodePoint *point = VNodePoint::Create(doc, data, detail[i].getId(), oldDetail[i].getId(), VNodePoint *point = qobject_cast<VNodePoint*>(tools->value(detail[i].getId()));
detail[i].getMode(), parse, typeCreation); Q_CHECK_PTR(point);
connect(point, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(detail[i].getId(),point);
point->setParentItem(this); point->setParentItem(this);
break; break;
} }
case(Tool::NodeArc):{ case(Tool::NodeArc):{
VNodeArc *arc = VNodeArc::Create(doc, data, detail[i].getId(), oldDetail[i].getId(), VNodeArc *arc = qobject_cast<VNodeArc*>(tools->value(detail[i].getId()));
detail[i].getMode(), parse, typeCreation); Q_CHECK_PTR(arc);
connect(arc, &VNodeArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(arc, &VNodeArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(detail[i].getId(), arc);
arc->setParentItem(this); arc->setParentItem(this);
break; break;
} }
case(Tool::NodeSpline):{ case(Tool::NodeSpline):{
VNodeSpline *spl = VNodeSpline::Create(doc, data, detail[i].getId(), oldDetail[i].getId(), VNodeSpline *spl = qobject_cast<VNodeSpline*>(tools->value(detail[i].getId()));
detail[i].getMode(), parse, typeCreation); Q_CHECK_PTR(spl);
connect(spl, &VNodeSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(spl, &VNodeSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(detail[i].getId(), spl);
spl->setParentItem(this); spl->setParentItem(this);
break; break;
} }
case(Tool::NodeSplinePath):{ case(Tool::NodeSplinePath):{
VNodeSplinePath *splPath = VNodeSplinePath::Create(doc, data, detail[i].getId(), VNodeSplinePath *splPath = qobject_cast<VNodeSplinePath*>(tools->value(detail[i].getId()));
oldDetail[i].getId(), Q_CHECK_PTR(splPath);
detail[i].getMode(), parse, typeCreation);
connect(splPath, &VNodeSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(splPath, &VNodeSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(detail[i].getId(), splPath);
splPath->setParentItem(this); splPath->setParentItem(this);
break; break;
} }
case(Tool::AlongLineTool):{ case(Tool::AlongLineTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingAlongLine *tool = qobject_cast<VModelingAlongLine*>(tools->value(detail[i].getId())); VModelingAlongLine *tool = qobject_cast<VModelingAlongLine*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool); Q_CHECK_PTR(tool);
connect(tool, &VModelingAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &VModelingAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingAlongLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this); tool->setParentItem(this);
break; break;
} }
case(Tool::ArcTool):{ case(Tool::ArcTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingArc *tool = qobject_cast<VModelingArc*>(tools->value(detail[i].getId())); VModelingArc *tool = qobject_cast<VModelingArc*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool); Q_CHECK_PTR(tool);
connect(tool, &VModelingArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &VModelingArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingArc::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this); tool->setParentItem(this);
break; break;
} }
case(Tool::BisectorTool):{ case(Tool::BisectorTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingBisector *tool = qobject_cast<VModelingBisector*>(tools->value(detail[i].getId())); VModelingBisector *tool = qobject_cast<VModelingBisector*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool); Q_CHECK_PTR(tool);
connect(tool, &VModelingBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &VModelingBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this); tool->setParentItem(this);
break; break;
} }
case(Tool::EndLineTool):{ case(Tool::EndLineTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingEndLine *tool = qobject_cast<VModelingEndLine*>(tools->value(detail[i].getId())); VModelingEndLine *tool = qobject_cast<VModelingEndLine*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool); Q_CHECK_PTR(tool);
connect(tool, &VModelingEndLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &VModelingEndLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingEndLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this); tool->setParentItem(this);
break; break;
} }
case(Tool::LineIntersectTool):{ case(Tool::LineIntersectTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingLineIntersect *tool = qobject_cast<VModelingLineIntersect*>(tools->value(detail[i].getId())); VModelingLineIntersect *tool = qobject_cast<VModelingLineIntersect*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool); Q_CHECK_PTR(tool);
connect(tool, &VModelingLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &VModelingLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingLineIntersect::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this); tool->setParentItem(this);
break; break;
} }
case(Tool::LineTool):{ case(Tool::LineTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingLine *tool = qobject_cast<VModelingLine*>(tools->value(detail[i].getId())); VModelingLine *tool = qobject_cast<VModelingLine*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool); Q_CHECK_PTR(tool);
connect(tool, &VModelingLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &VModelingLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this); tool->setParentItem(this);
break; break;
} }
case(Tool::NormalTool):{ case(Tool::NormalTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingNormal *tool = qobject_cast<VModelingNormal*>(tools->value(detail[i].getId())); VModelingNormal *tool = qobject_cast<VModelingNormal*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool); Q_CHECK_PTR(tool);
connect(tool, &VModelingNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &VModelingNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingNormal::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this); tool->setParentItem(this);
break; break;
} }
case(Tool::PointOfContact):{ case(Tool::PointOfContact):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingPointOfContact *tool = qobject_cast<VModelingPointOfContact*>(tools->value(detail[i].getId())); VModelingPointOfContact *tool = qobject_cast<VModelingPointOfContact*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool); Q_CHECK_PTR(tool);
connect(tool, &VModelingPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &VModelingPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this); tool->setParentItem(this);
break; break;
} }
case(Tool::ShoulderPointTool):{ case(Tool::ShoulderPointTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingShoulderPoint *tool = qobject_cast<VModelingShoulderPoint*>(tools->value(detail[i].getId())); VModelingShoulderPoint *tool = qobject_cast<VModelingShoulderPoint*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool); Q_CHECK_PTR(tool);
connect(tool, &VModelingShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &VModelingShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingShoulderPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this); tool->setParentItem(this);
break; break;
} }
case(Tool::SplinePathTool):{ case(Tool::SplinePathTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingSplinePath *tool = qobject_cast<VModelingSplinePath*>(tools->value(detail[i].getId())); VModelingSplinePath *tool = qobject_cast<VModelingSplinePath*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool); Q_CHECK_PTR(tool);
connect(tool, &VModelingSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &VModelingSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingSplinePath::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this); tool->setParentItem(this);
break; break;
} }
case(Tool::SplineTool):{ case(Tool::SplineTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingSpline *tool = qobject_cast<VModelingSpline*>(tools->value(detail[i].getId())); VModelingSpline *tool = qobject_cast<VModelingSpline*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool); Q_CHECK_PTR(tool);
connect(tool, &VModelingSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &VModelingSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this); tool->setParentItem(this);
break; break;
} }
@ -162,6 +154,7 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
qWarning()<<"Get wrong tool type. Ignore."; qWarning()<<"Get wrong tool type. Ignore.";
break; break;
} }
doc->IncrementReferens(detail[i].getId());
} }
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -236,11 +229,10 @@ void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScen
det.append(node); det.append(node);
} }
det.setName(detail.getName()); det.setName(detail.getName());
Create(0, det, detail, scene, doc, data, Document::FullParse, Tool::FromGui); Create(0, det, scene, doc, data, Document::FullParse, Tool::FromGui);
} }
void VToolDetail::Create(const qint64 _id, VDetail &newDetail, VDetail &oldDetail, void VToolDetail::Create(const qint64 _id, VDetail &newDetail, VMainGraphicsScene *scene, VDomDocument *doc,
VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){ VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if(typeCreation == Tool::FromGui){
@ -248,25 +240,14 @@ void VToolDetail::Create(const qint64 _id, VDetail &newDetail, VDetail &oldDetai
} else { } else {
data->UpdateDetail(id, newDetail); data->UpdateDetail(id, newDetail);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
}
for(qint32 i = 0; i< newDetail.CountNode(); ++i){
VDataTool *tool = tools->value(newDetail[i].getId());
if(tool != 0){
tool->VDataTool::setData(data);
}
}
} }
} }
if(parse == Document::FullParse){ if(parse == Document::FullParse){
VToolDetail *detail = new VToolDetail(doc, data, id, oldDetail, typeCreation, parse, scene); VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene);
scene->addItem(detail); scene->addItem(detail);
connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
//connect(detail, &VToolBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(detail, &VToolDetail::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, detail); tools->insert(id, detail);
} }
@ -323,6 +304,54 @@ void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
QGraphicsItem::mouseReleaseEvent(event); QGraphicsItem::mouseReleaseEvent(event);
} }
void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
QMenu menu;
//QAction *actionOption = menu.addAction(tr("Options"));
QAction *actionRemove = menu.addAction(tr("Delete"));
if(_referens > 1){
actionRemove->setEnabled(false);
} else {
actionRemove->setEnabled(true);
}
QAction *selectedAction = menu.exec(event->screenPos());
// if(selectedAction == actionOption){
// dialog = QSharedPointer<Dialog>(new Dialog(getData()));
// connect(qobject_cast< VMainGraphicsScene * >(tool->scene()), &VMainGraphicsScene::ChoosedObject,
// dialog.data(), &Dialog::ChoosedObject);
// connect(dialog.data(), &Dialog::DialogClosed, tool,
// &Tool::FullUpdateFromGui);
// connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
// tool->setDialog();
// dialog->show();
// }
if(selectedAction == actionRemove){
//deincrement referens
RemoveReferens();
//remove form xml file
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
QDomNode element = domElement.parentNode();
if(!element.isNull()){
element.removeChild(domElement);
//update xml file
emit FullUpdateTree();
//remove form scene
emit RemoveTool(this);
}
}
}
}
void VToolDetail::RemoveReferens(){
VDetail detail = VAbstractTool::data.GetDetail(id);
for(qint32 i = 0; i< detail.CountNode(); ++i){
doc->DecrementReferens(detail[i].getId());
}
}
void VToolDetail::AddNode(QDomElement &domElement, VNodeDetail &node){ void VToolDetail::AddNode(QDomElement &domElement, VNodeDetail &node){
QDomElement nod = doc->createElement("node"); QDomElement nod = doc->createElement("node");

View File

@ -26,19 +26,18 @@
#include <QGraphicsPathItem> #include <QGraphicsPathItem>
#include "dialogs/dialogdetail.h" #include "dialogs/dialogdetail.h"
class VToolDetail: public VAbstractTool, public QGraphicsPathItem class VToolDetail: public VAbstractTool, public QGraphicsPathItem{
{
Q_OBJECT Q_OBJECT
public: public:
VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, VDetail &oldDetail, VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
Tool::Sources typeCreation, const Document::Documents &parse, VMainGraphicsScene *scene, Tool::Sources typeCreation, VMainGraphicsScene *scene,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, static void Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScene *scene,
VContainer *data); VDomDocument *doc, VContainer *data);
static void Create(const qint64 _id, VDetail &newDetail, VDetail &oldDetail, static void Create(const qint64 _id, VDetail &newDetail, VMainGraphicsScene *scene,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, const Document::Documents &parse,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation); Tool::Sources typeCreation);
template <typename T> template <typename T>
void AddTool(T *tool, const qint64 &id, Tool::Tools typeTool){ void AddTool(T *tool, const qint64 &id, Tool::Tools typeTool){
tool->setParentItem(this); tool->setParentItem(this);
@ -55,16 +54,20 @@ public:
public slots: public slots:
virtual void FullUpdateFromFile (); virtual void FullUpdateFromFile ();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
signals:
void RemoveTool(QGraphicsItem *tool);
protected: protected:
virtual void AddToFile (); virtual void AddToFile ();
QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void RemoveReferens();
private: private:
Q_DISABLE_COPY(VToolDetail) Q_DISABLE_COPY(VToolDetail)
QSharedPointer<DialogDetail> dialogDetail; QSharedPointer<DialogDetail> dialogDetail;
VMainGraphicsScene *sceneDetails; VMainGraphicsScene *sceneDetails;
void RefreshGeometry (); void RefreshGeometry ();
void AddNode(QDomElement &domElement, VNodeDetail &node); void AddNode(QDomElement &domElement, VNodeDetail &node);
}; };
#endif // VTOOLDETAIL_H #endif // VTOOLDETAIL_H

View File

@ -494,7 +494,7 @@ void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDo
} }
} }
} }
VToolDetail::Create(id, detail, oldDetail, sceneDetail, this, data, parse, Tool::FromFile); VToolDetail::Create(id, detail, sceneDetail, this, data, parse, Tool::FromFile);
} }
catch(const VExceptionBadId &e){ catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating detail"), domElement); VExceptionObjectError excep(tr("Error creating or updating detail"), domElement);
@ -565,7 +565,6 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
QString formula = GetParametrString(domElement, "length"); QString formula = GetParametrString(domElement, "length");
qint64 basePointId = GetParametrLongLong(domElement, "basePoint"); qint64 basePointId = GetParametrLongLong(domElement, "basePoint");
qreal angle = GetParametrDouble(domElement, "angle"); qreal angle = GetParametrDouble(domElement, "angle");
data->IncrementReferens(basePointId, Scene::Point, mode);
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, scene, this, VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, scene, this,
data, parse, Tool::FromFile); data, parse, Tool::FromFile);
@ -591,8 +590,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
QString formula = GetParametrString(domElement, "length"); QString formula = GetParametrString(domElement, "length");
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
data->IncrementReferens(firstPointId, Scene::Point, mode);
data->IncrementReferens(secondPointId, Scene::Point, mode);
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my,
scene, this, data, parse, Tool::FromFile); scene, this, data, parse, Tool::FromFile);
@ -619,9 +617,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 p1Line = GetParametrLongLong(domElement, "p1Line"); qint64 p1Line = GetParametrLongLong(domElement, "p1Line");
qint64 p2Line = GetParametrLongLong(domElement, "p2Line"); qint64 p2Line = GetParametrLongLong(domElement, "p2Line");
qint64 pShoulder = GetParametrLongLong(domElement, "pShoulder"); qint64 pShoulder = GetParametrLongLong(domElement, "pShoulder");
data->IncrementReferens(p1Line, Scene::Point, mode);
data->IncrementReferens(p2Line, Scene::Point, mode);
data->IncrementReferens(pShoulder, Scene::Point, mode);
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my, VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my,
scene, this, data, parse, Tool::FromFile); scene, this, data, parse, Tool::FromFile);
@ -648,8 +644,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
qreal angle = GetParametrDouble(domElement, "angle"); qreal angle = GetParametrDouble(domElement, "angle");
data->IncrementReferens(firstPointId, Scene::Point, mode);
data->IncrementReferens(secondPointId, Scene::Point, mode);
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle, VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle,
mx, my, scene, this, data, parse, Tool::FromFile); mx, my, scene, this, data, parse, Tool::FromFile);
@ -676,9 +671,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
qint64 thirdPointId = GetParametrLongLong(domElement, "thirdPoint"); qint64 thirdPointId = GetParametrLongLong(domElement, "thirdPoint");
data->IncrementReferens(firstPointId, Scene::Point, mode);
data->IncrementReferens(secondPointId, Scene::Point, mode);
data->IncrementReferens(thirdPointId, Scene::Point, mode);
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine, VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine,
name, mx, my, scene, this, data, parse, Tool::FromFile); name, mx, my, scene, this, data, parse, Tool::FromFile);
@ -704,10 +697,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 p2Line1Id = GetParametrLongLong(domElement, "p2Line1"); qint64 p2Line1Id = GetParametrLongLong(domElement, "p2Line1");
qint64 p1Line2Id = GetParametrLongLong(domElement, "p1Line2"); qint64 p1Line2Id = GetParametrLongLong(domElement, "p1Line2");
qint64 p2Line2Id = GetParametrLongLong(domElement, "p2Line2"); qint64 p2Line2Id = GetParametrLongLong(domElement, "p2Line2");
data->IncrementReferens(p1Line1Id, Scene::Point, mode);
data->IncrementReferens(p2Line1Id, Scene::Point, mode);
data->IncrementReferens(p1Line2Id, Scene::Point, mode);
data->IncrementReferens(p2Line2Id, Scene::Point, mode);
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my, VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my,
scene, this, data, parse, Tool::FromFile); scene, this, data, parse, Tool::FromFile);
@ -733,9 +723,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 center = GetParametrLongLong(domElement, "center"); qint64 center = GetParametrLongLong(domElement, "center");
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
data->IncrementReferens(center, Scene::Point, mode);
data->IncrementReferens(firstPointId, Scene::Point, mode);
data->IncrementReferens(secondPointId, Scene::Point, mode);
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my, VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my,
scene, this, data, parse, Tool::FromFile); scene, this, data, parse, Tool::FromFile);
@ -769,7 +757,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qreal my = toPixel(GetParametrDouble(domElement, "my")); qreal my = toPixel(GetParametrDouble(domElement, "my"));
data->UpdateModelingPoint(id, VPointF(point.x(), point.y(), point.name(), mx, my, typeObject, data->UpdateModelingPoint(id, VPointF(point.x(), point.y(), point.name(), mx, my, typeObject,
idObject )); idObject ));
data->IncrementReferens(idObject, Scene::Point, typeObject); VNodePoint::Create(this, data, id, idObject, mode, parse, Tool::FromFile);
return; return;
} }
catch(const VExceptionBadId &e){ catch(const VExceptionBadId &e){
@ -788,8 +776,7 @@ void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement
qint64 id = GetParametrId(domElement); qint64 id = GetParametrId(domElement);
qint64 firstPoint = GetParametrLongLong(domElement, "firstPoint"); qint64 firstPoint = GetParametrLongLong(domElement, "firstPoint");
qint64 secondPoint = GetParametrLongLong(domElement, "secondPoint"); qint64 secondPoint = GetParametrLongLong(domElement, "secondPoint");
data->IncrementReferens(firstPoint, Scene::Point, mode);
data->IncrementReferens(secondPoint, Scene::Point, mode);
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile); VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile);
} else { } else {
@ -805,7 +792,8 @@ void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement
} }
void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement, void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
const Document::Documents &parse, const QString &type, Draw::Draws mode){ const Document::Documents &parse, const QString &type,
Draw::Draws mode){
Q_CHECK_PTR(scene); Q_CHECK_PTR(scene);
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(!type.isEmpty(), Q_FUNC_INFO, "type of spline is empty"); Q_ASSERT_X(!type.isEmpty(), Q_FUNC_INFO, "type of spline is empty");
@ -819,8 +807,7 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
qreal kAsm1 = GetParametrDouble(domElement, "kAsm1"); qreal kAsm1 = GetParametrDouble(domElement, "kAsm1");
qreal kAsm2 = GetParametrDouble(domElement, "kAsm2"); qreal kAsm2 = GetParametrDouble(domElement, "kAsm2");
qreal kCurve = GetParametrDouble(domElement, "kCurve"); qreal kCurve = GetParametrDouble(domElement, "kCurve");
data->IncrementReferens(point1, Scene::Point, mode);
data->IncrementReferens(point4, Scene::Point, mode);
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this,
data, parse, Tool::FromFile); data, parse, Tool::FromFile);
@ -855,7 +842,9 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
qint64 pSpline = GetParametrLongLong(element, "pSpline"); qint64 pSpline = GetParametrLongLong(element, "pSpline");
VSplinePoint splPoint(pSpline, kAsm1, angle, kAsm2); VSplinePoint splPoint(pSpline, kAsm1, angle, kAsm2);
path.append(splPoint); path.append(splPoint);
data->IncrementReferens(pSpline, Scene::Point, mode); if(parse == Document::FullParse){
IncrementReferens(pSpline);
}
} }
} }
} }
@ -888,14 +877,8 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
} }
spl.setMode(typeObject); spl.setMode(typeObject);
spl.setIdObject(idObject); spl.setIdObject(idObject);
if(typeObject == Draw::Calculation){
data->IncrementReferens(spl.GetP1(), Scene::Point, Draw::Calculation);
data->IncrementReferens(spl.GetP4(), Scene::Point, Draw::Calculation);
} else {
data->IncrementReferens(spl.GetP1(), Scene::Point, Draw::Modeling);
data->IncrementReferens(spl.GetP4(), Scene::Point, Draw::Modeling);
}
data->UpdateModelingSpline(id, spl); data->UpdateModelingSpline(id, spl);
VNodeSpline::Create(this, data, id, idObject,mode, parse, Tool::FromFile);
return; return;
} }
catch(const VExceptionBadId &e){ catch(const VExceptionBadId &e){
@ -921,14 +904,7 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
path.setMode(typeObject); path.setMode(typeObject);
path.setIdObject(idObject); path.setIdObject(idObject);
data->UpdateModelingSplinePath(id, path); data->UpdateModelingSplinePath(id, path);
const QVector<VSplinePoint> *points = path.GetPoint(); VNodeSplinePath::Create(this, data, id, idObject, mode, parse, Tool::FromFile);
for(qint32 i = 0; i<points->size(); ++i){
if(typeObject == Draw::Calculation){
data->IncrementReferens(points->at(i).P(), Scene::Point, Draw::Calculation);
} else {
data->IncrementReferens(points->at(i).P(), Scene::Point, Draw::Modeling);
}
}
return; return;
} }
catch(const VExceptionBadId &e){ catch(const VExceptionBadId &e){
@ -951,7 +927,7 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
QString radius = GetParametrString(domElement, "radius"); QString radius = GetParametrString(domElement, "radius");
QString f1 = GetParametrString(domElement, "angle1"); QString f1 = GetParametrString(domElement, "angle1");
QString f2 = GetParametrString(domElement, "angle2"); QString f2 = GetParametrString(domElement, "angle2");
data->IncrementReferens(center, Scene::Point, mode);
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile); VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile);
} else { } else {
@ -983,7 +959,7 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
arc.setMode(typeObject); arc.setMode(typeObject);
arc.setIdObject(idObject); arc.setIdObject(idObject);
data->UpdateModelingArc(id, arc); data->UpdateModelingArc(id, arc);
data->IncrementReferens(idObject, Scene::Point, mode); VNodeArc::Create(this, data, id, idObject, mode, parse, Tool::FromFile);
return; return;
} }
catch(const VExceptionBadId &e){ catch(const VExceptionBadId &e){
@ -1059,73 +1035,18 @@ void VDomDocument::setCurrentData(){
} }
void VDomDocument::GarbageCollector(){ void VDomDocument::GarbageCollector(){
const QMap<qint64, VPointF> *points = data->DataPoints(); QMapIterator<qint64, VDataTool*> t(tools);
Q_CHECK_PTR(points); while (t.hasNext()) {
QMapIterator<qint64, VPointF> p(*points); t.next();
while (p.hasNext()) { VDataTool *tool = t.value();
p.next(); if(tool->referens() <= 0){
VPointF point = p.value(); QDomElement domElement = elementById(QString().setNum(t.key()));
if(point.referens() <= 0){
QDomElement domElement = elementById(QString().setNum(p.key()));
if(domElement.isElement()){ if(domElement.isElement()){
QDomElement element; QDomNode parent = domElement.parentNode();
bool ok = GetActivModelingElement(element); if(!parent.isNull()){
if(ok){ parent.removeChild(domElement);
element.removeChild(domElement); } else {
} qWarning()<<tr("Can't get parent for object id = %1").arg(t.key());
}
}
}
const QMap<qint64, VArc> *arc = data->DataArcs();
Q_CHECK_PTR(arc);
QMapIterator<qint64, VArc> a(*arc);
while (a.hasNext()) {
a.next();
VArc arc = a.value();
if(arc.referens() <= 0){
QDomElement domElement = elementById(QString().setNum(a.key()));
if(domElement.isElement()){
QDomElement element;
bool ok = GetActivModelingElement(element);
if(ok){
element.removeChild(domElement);
}
}
}
}
const QMap<qint64, VSpline> *spl = data->DataSplines();
Q_CHECK_PTR(spl);
QMapIterator<qint64, VSpline> s(*spl);
while (s.hasNext()) {
s.next();
VSpline spl = s.value();
if(spl.referens() <= 0){
QDomElement domElement = elementById(QString().setNum(s.key()));
if(domElement.isElement()){
QDomElement element;
bool ok = GetActivModelingElement(element);
if(ok){
element.removeChild(domElement);
}
}
}
}
const QMap<qint64, VSplinePath> *splPath = data->DataSplinePaths();
Q_CHECK_PTR(splPath);
QMapIterator<qint64, VSplinePath> q(*splPath);
while (q.hasNext()) {
q.next();
VSplinePath splPath = q.value();
if(splPath.referens() <= 0){
QDomElement domElement = elementById(QString().setNum(q.key()));
if(domElement.isElement()){
QDomElement element;
bool ok = GetActivModelingElement(element);
if(ok){
element.removeChild(domElement);
} }
} }
} }
@ -1145,3 +1066,17 @@ void VDomDocument::UpdateToolData(const qint64 &id, VContainer *data){
Q_CHECK_PTR(tool); Q_CHECK_PTR(tool);
tool->VDataTool::setData(data); tool->VDataTool::setData(data);
} }
void VDomDocument::IncrementReferens(qint64 id) const{
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
VDataTool *tool = tools.value(id);
Q_CHECK_PTR(tool);
tool->incrementReferens();
}
void VDomDocument::DecrementReferens(qint64 id) const{
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
VDataTool *tool = tools.value(id);
Q_CHECK_PTR(tool);
tool->decrementReferens();
}

View File

@ -67,6 +67,8 @@ public:
void GarbageCollector(); void GarbageCollector();
void AddTool(const qint64 &id, VDataTool *tool); void AddTool(const qint64 &id, VDataTool *tool);
void UpdateToolData(const qint64 &id, VContainer *data); void UpdateToolData(const qint64 &id, VContainer *data);
void IncrementReferens(qint64 id) const;
void DecrementReferens(qint64 id) const;
signals: signals:
void ChangedActivDraw(const QString newName); void ChangedActivDraw(const QString newName);
void ChangedNameDraw(const QString oldName, const QString newName); void ChangedNameDraw(const QString oldName, const QString newName);