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{
VDetail detail = GetDetail(idDetail);
QVector<QPointF> points;

View File

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

View File

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

View File

@ -19,24 +19,22 @@
**
****************************************************************************/
#define _USE_MATH_DEFINES
#include <cmath>
#include "varc.h"
#include <QDebug>
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,
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),
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()),
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()){
}
@ -50,7 +48,6 @@ VArc &VArc::operator =(const VArc &arc){
this->formulaRadius = arc.GetFormulaRadius();
this->center = arc.GetCenter();
this->mode = arc.getMode();
this->_referens = 0;
this->idObject = arc.getIdObject();
return *this;
}
@ -198,37 +195,18 @@ QVector<QPointF> VArc::SplOfArc(qint32 number) const{
return QVector<QPointF>();
}
qint32 VArc::referens() const{
return _referens;
}
void VArc::incrementReferens(){
++_referens;
}
void VArc::decrementReferens(){
if(_referens > 0){
--_referens;
}
}
Draw::Draws VArc::getMode() const
{
Draw::Draws VArc::getMode() const{
return mode;
}
void VArc::setMode(const Draw::Draws &value)
{
void VArc::setMode(const Draw::Draws &value){
mode = value;
}
qint64 VArc::getIdObject() const
{
qint64 VArc::getIdObject() const{
return idObject;
}
void VArc::setIdObject(const qint64 &value)
{
void VArc::setIdObject(const qint64 &value){
idObject = value;
}

View File

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

View File

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

View File

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

View File

@ -19,31 +19,29 @@
**
****************************************************************************/
#define _USE_MATH_DEFINES
#include <cmath>
#include "vspline.h"
#include <QDebug>
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 ()),
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()){
}
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()),
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 );
}
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),
kCurve(1), points(points), _referens(0), mode(mode), idObject(idObject){
qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(p2), p3(p3), p4(p4), angle1(0),
angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(points), mode(mode), idObject(idObject){
ModifiSpl ( p1, p2, p3, p4, kCurve);
}
@ -629,20 +627,6 @@ QPainterPath VSpline::GetPath() const{
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.
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->kCurve = spline.GetKcurve();
this->points = spline.GetDataPoints();
this->_referens = 0;
this->mode = spline.getMode();
this->idObject = spline.getIdObject();
return *this;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -77,11 +77,7 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
} else {
data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
Q_CHECK_PTR(tool);
data->IncrementReferens(id, Scene::Point);
tool->VDataTool::setData(data);
doc->UpdateToolData(id, data);
}
}
data->AddLine(basePointId, id);
@ -92,9 +88,8 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools();
Q_CHECK_PTR(tools);
tools->insert(id,point);
doc->AddTool(id, point);
doc->IncrementReferens(basePointId);
}
}
}
@ -111,12 +106,7 @@ void VToolEndLine::FullUpdateFromFile(){
}
void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id);
if(point.referens() > 1){
ContextMenu(dialogEndLine, this, event, false);
} else {
ContextMenu(dialogEndLine, this, event);
}
ContextMenu(dialogEndLine, this, event);
}
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,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation){
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation){
Q_CHECK_PTR(scene);
Q_CHECK_PTR(doc);
Q_CHECK_PTR(data);
data->AddLine(firstPoint, secondPoint);
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
Q_CHECK_PTR(tools);
VDataTool *tool = tools->value(id);
Q_CHECK_PTR(tool);
tool->VDataTool::setData(data);
doc->UpdateToolData(id, data);
}
VDrawTool::AddRecord(id, Tool::LineTool, doc);
if(parse == Document::FullParse){
@ -74,8 +70,9 @@ void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64
scene->addItem(line);
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(line, &VToolLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id,line);
doc->AddTool(id, line);
doc->IncrementReferens(firstPoint);
doc->IncrementReferens(secondPoint);
}
}
@ -150,3 +147,8 @@ void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
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 hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
private:
qint64 firstPoint;
qint64 secondPoint;

View File

@ -75,12 +75,7 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
} else {
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point);
}
doc->UpdateToolData(id, data);
}
}
data->AddLine(p1Line1Id, id);
@ -95,8 +90,11 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
scene->addItem(point);
connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolLineIntersect::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id,point);
doc->AddTool(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){
VPointF point = VDrawTool::data.GetPoint(id);
if(point.referens() > 1){
ContextMenu(dialogLineIntersect, this, event, false);
} else {
ContextMenu(dialogLineIntersect, this, event);
}
ContextMenu(dialogLineIntersect, this, event);
}
void VToolLineIntersect::AddToFile(){
@ -153,3 +146,10 @@ void VToolLineIntersect::AddToFile(){
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 "dialogs/dialoglineintersect.h"
class VToolLineIntersect:public VToolPoint
{
class VToolLineIntersect:public VToolPoint{
Q_OBJECT
public:
VToolLineIntersect(VDomDocument *doc, VContainer *data,
const qint64 &id,
const qint64 &p1Line1,
const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line2, Tool::Sources typeCreation,
QGraphicsItem * parent = 0);
virtual void setDialog();
static void Create(QSharedPointer<DialogLineIntersect> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc,VContainer *data);
static void Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id,
const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation);
VToolLineIntersect(VDomDocument *doc, VContainer *data,
const qint64 &id,
const qint64 &p1Line1,
const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line2, Tool::Sources typeCreation,
QGraphicsItem * parent = 0);
virtual void setDialog();
static void Create(QSharedPointer<DialogLineIntersect> &dialog,
VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
static void Create(const qint64 _id, const qint64 &p1Line1Id,
const qint64 &p2Line1Id, const qint64 &p1Line2Id,
const qint64 &p2Line2Id, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RemoveReferens();
private:
qint64 p1Line1;
qint64 p2Line1;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,27 +26,27 @@
#include "vmodelinglinepoint.h"
#include "dialogs/dialogendline.h"
class VModelingEndLine : public VModelingLinePoint
{
class VModelingEndLine : public VModelingLinePoint{
Q_OBJECT
public:
VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qreal &angle,
const qint64 &basePointId, Tool::Sources typeCreation,
QGraphicsItem * parent = 0);
virtual void setDialog();
static VModelingEndLine* Create(QSharedPointer<DialogEndLine> &dialog, VDomDocument *doc,
VContainer *data);
static VModelingEndLine* Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &basePointId,
const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula,
const qreal &angle, const qint64 &basePointId,
Tool::Sources typeCreation,
QGraphicsItem * parent = 0);
virtual void setDialog();
static VModelingEndLine* Create(QSharedPointer<DialogEndLine> &dialog, VDomDocument *doc,
VContainer *data);
static VModelingEndLine* Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &basePointId,
const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
private:
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(data);
data->AddLine(firstPoint, secondPoint, Draw::Modeling);
data->IncrementReferens(firstPoint, Scene::Point, Draw::Modeling);
data->IncrementReferens(secondPoint, Scene::Point, Draw::Modeling);
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
Q_CHECK_PTR(tools);
VDataTool *tool = tools->value(id);
Q_CHECK_PTR(tool);
tool->VDataTool::setData(data);
doc->UpdateToolData(id, data);
}
if(parse == Document::FullParse){
qint64 id = data->getNextId();
line = new VModelingLine(doc, data, id, firstPoint, secondPoint, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id,line);
doc->AddTool(id, line);
doc->IncrementReferens(firstPoint);
doc->IncrementReferens(secondPoint);
}
return line;
}
@ -122,3 +117,8 @@ void VModelingLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine));
}
void VModelingLine::RemoveReferens(){
doc->DecrementReferens(firstPoint);
doc->DecrementReferens(secondPoint);
}

View File

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

View File

@ -78,12 +78,7 @@ VModelingLineIntersect *VModelingLineIntersect::Create(const qint64 _id, const q
} else {
data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
}
doc->UpdateToolData(id, data);
}
}
data->AddLine(p1Line1Id, id, Draw::Modeling);
@ -93,8 +88,11 @@ VModelingLineIntersect *VModelingLineIntersect::Create(const qint64 _id, const q
if(parse == Document::FullParse){
point = new VModelingLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id,
typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id,point);
doc->AddTool(id, point);
doc->IncrementReferens(p1Line1Id);
doc->IncrementReferens(p2Line1Id);
doc->IncrementReferens(p1Line2Id);
doc->IncrementReferens(p2Line2Id);
}
}
return point;
@ -147,3 +145,10 @@ void VModelingLineIntersect::AddToFile(){
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 "dialogs/dialoglineintersect.h"
class VModelingLineIntersect:public VModelingPoint
{
class VModelingLineIntersect:public VModelingPoint{
Q_OBJECT
public:
VModelingLineIntersect(VDomDocument *doc, VContainer *data,
const qint64 &id,
const qint64 &p1Line1,
const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line2, Tool::Sources typeCreation,
QGraphicsItem * parent = 0);
virtual void setDialog();
static VModelingLineIntersect* Create(QSharedPointer<DialogLineIntersect> &dialog,
VDomDocument *doc,VContainer *data);
static VModelingLineIntersect* Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id,
const qint64 &p1Line2Id, const qint64 &p2Line2Id,
const QString &pointName, const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation);
VModelingLineIntersect(VDomDocument *doc, VContainer *data,
const qint64 &id, const qint64 &p1Line1,
const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line2,
Tool::Sources typeCreation,
QGraphicsItem * parent = 0);
virtual void setDialog();
static VModelingLineIntersect* Create(QSharedPointer<DialogLineIntersect> &dialog,
VDomDocument *doc,VContainer *data);
static VModelingLineIntersect* Create(const qint64 _id, const qint64 &p1Line1Id,
const qint64 &p2Line1Id, const qint64 &p1Line2Id,
const qint64 &p2Line2Id, const QString &pointName,
const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RemoveReferens();
private:
qint64 p1Line1;
qint64 p2Line1;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -100,16 +100,14 @@ VModelingSpline *VModelingSpline::Create(const qint64 _id, const qint64 &p1, con
data->UpdateModelingSpline(id, spline);
if(parse != Document::FullParse){
doc->UpdateToolData(id, data);
data->IncrementReferens(id, Scene::Spline, Draw::Modeling);
}
}
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){
spl = new VModelingSpline(doc, data, id, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id,spl);
doc->AddTool(id, spl);
doc->IncrementReferens(p1);
doc->IncrementReferens(p4);
}
return spl;
}
@ -211,6 +209,12 @@ void VModelingSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
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(){
VSpline spl = VAbstractTool::data.GetModelingSpline(id);
QPainterPath path;

View File

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

View File

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

View File

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

View File

@ -24,6 +24,7 @@
VModelingTool::VModelingTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent):
VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false){
_referens = 0;
}
VModelingTool::~VModelingTool(){
@ -46,3 +47,19 @@ void VModelingTool::AddToModeling(const QDomElement &domElement){
}
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);
public slots:
virtual void FullUpdateFromGui(int result)=0;
signals:
void RemoveTool(QGraphicsItem *tool);
protected:
bool ignoreContextMenuEvent;
void AddToModeling(const QDomElement &domElement);
virtual void decrementReferens();
template <typename Dialog, typename Tool>
void ContextMenu(QSharedPointer<Dialog> &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event,
bool showRemove = true){
@ -73,7 +76,7 @@ protected:
//update xml file
emit FullUpdateTree();
//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,
Draw::Draws typeobject, QObject *parent) :
VAbstractTool(doc, data, id, parent), idNode(idNode), typeobject(typeobject){
}
VAbstractNode::~VAbstractNode(){
_referens = 0;
}
void VAbstractNode::AddToModeling(const QDomElement &domElement){
@ -40,3 +38,19 @@ void VAbstractNode::AddToModeling(const QDomElement &domElement){
}
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:
VAbstractNode(VDomDocument *doc, VContainer *data, qint64 id, qint64 idNode,
Draw::Draws typeobject, QObject *parent = 0 );
virtual ~VAbstractNode();
virtual ~VAbstractNode() {}
protected:
qint64 idNode;
Draw::Draws typeobject;
Draw::Draws typeobject;
void AddToModeling(const QDomElement &domElement);
virtual void decrementReferens();
};
#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,
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation){
VNodeArc *arc = 0;
void VNodeArc::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc,
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation){
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->IncrementReferens(idArc);
} else {
doc->UpdateToolData(id, data);
}
return arc;
}
void VNodeArc::FullUpdateFromFile(){

View File

@ -29,19 +29,19 @@ class VNodeArc :public VAbstractNode, public QGraphicsPathItem
{
Q_OBJECT
public:
VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, Draw::Draws typeobject,
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
static VNodeArc *Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc,
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation);
VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, Draw::Draws typeobject,
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
static void Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc,
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromFile();
protected:
virtual void AddToFile();
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void AddToFile();
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
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,
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation){
VNodePoint *point = 0;
void VNodePoint::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint,
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation){
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->IncrementReferens(idPoint);
} else {
doc->UpdateToolData(id, data);
}
return point;
}
void VNodePoint::FullUpdateFromFile(){

View File

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

View File

@ -40,6 +40,7 @@ VNodeSpline *VNodeSpline::Create(VDomDocument *doc, VContainer *data, qint64 id,
if(parse == Document::FullParse){
spl = new VNodeSpline(doc, data, id, idSpline, typeobject, typeCreation);
doc->AddTool(id, spl);
doc->IncrementReferens(idSpline);
} else {
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,
qint64 idSpline, Draw::Draws typeobject, const Document::Documents &parse,
Tool::Sources typeCreation){
VNodeSplinePath *splPath = 0;
void VNodeSplinePath::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
Draw::Draws typeobject, const Document::Documents &parse,
Tool::Sources typeCreation){
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);
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 {
doc->UpdateToolData(id, data);
}
return splPath;
}
void VNodeSplinePath::FullUpdateFromFile(){

View File

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

View File

@ -24,8 +24,6 @@
VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent):
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->doc, &VDomDocument::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile);

View File

@ -46,7 +46,7 @@ signals:
void FullUpdateTree();
protected:
VDomDocument *doc;
qint64 id;
const qint64 id;
const Qt::GlobalColor baseColor;
Qt::GlobalColor currentColor;
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 QString &value);
const VContainer *getData() const;
virtual void RemoveReferens(){}
private:
Q_DISABLE_COPY(VAbstractTool)
};

View File

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

View File

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

View File

@ -25,136 +25,128 @@
#include "modelingTools/vmodelingtool.h"
#include "modelingTools/modelingtools.h"
VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, VDetail &oldDetail,
Tool::Sources typeCreation, const Document::Documents &parse,
VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, Tool::Sources typeCreation,
VMainGraphicsScene *scene, QGraphicsItem *parent)
:VAbstractTool(doc, data, id), QGraphicsPathItem(parent),
dialogDetail(QSharedPointer<DialogDetail>()), sceneDetails(scene){
:VAbstractTool(doc, data, id), QGraphicsPathItem(parent), dialogDetail(QSharedPointer<DialogDetail>()),
sceneDetails(scene){
VDetail detail = data->GetDetail(id);
QMap<qint64, VDataTool*>* tools = doc->getTools();
Q_CHECK_PTR(tools);
for(qint32 i = 0; i< detail.CountNode(); ++i){
switch(detail[i].getTypeTool()){
case(Tool::NodePoint):{
VNodePoint *point = VNodePoint::Create(doc, data, detail[i].getId(), oldDetail[i].getId(),
detail[i].getMode(), parse, typeCreation);
connect(point, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(detail[i].getId(),point);
VNodePoint *point = qobject_cast<VNodePoint*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(point);
connect(point, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
point->setParentItem(this);
break;
}
case(Tool::NodeArc):{
VNodeArc *arc = VNodeArc::Create(doc, data, detail[i].getId(), oldDetail[i].getId(),
detail[i].getMode(), parse, typeCreation);
VNodeArc *arc = qobject_cast<VNodeArc*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(arc);
connect(arc, &VNodeArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(detail[i].getId(), arc);
arc->setParentItem(this);
break;
}
case(Tool::NodeSpline):{
VNodeSpline *spl = VNodeSpline::Create(doc, data, detail[i].getId(), oldDetail[i].getId(),
detail[i].getMode(), parse, typeCreation);
VNodeSpline *spl = qobject_cast<VNodeSpline*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(spl);
connect(spl, &VNodeSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(detail[i].getId(), spl);
spl->setParentItem(this);
break;
}
case(Tool::NodeSplinePath):{
VNodeSplinePath *splPath = VNodeSplinePath::Create(doc, data, detail[i].getId(),
oldDetail[i].getId(),
detail[i].getMode(), parse, typeCreation);
VNodeSplinePath *splPath = qobject_cast<VNodeSplinePath*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(splPath);
connect(splPath, &VNodeSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(detail[i].getId(), splPath);
splPath->setParentItem(this);
break;
}
case(Tool::AlongLineTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingAlongLine *tool = qobject_cast<VModelingAlongLine*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool);
connect(tool, &VModelingAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingAlongLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this);
break;
}
case(Tool::ArcTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingArc *tool = qobject_cast<VModelingArc*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool);
connect(tool, &VModelingArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingArc::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this);
break;
}
case(Tool::BisectorTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingBisector *tool = qobject_cast<VModelingBisector*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool);
connect(tool, &VModelingBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this);
break;
}
case(Tool::EndLineTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingEndLine *tool = qobject_cast<VModelingEndLine*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool);
connect(tool, &VModelingEndLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingEndLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this);
break;
}
case(Tool::LineIntersectTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingLineIntersect *tool = qobject_cast<VModelingLineIntersect*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool);
connect(tool, &VModelingLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingLineIntersect::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this);
break;
}
case(Tool::LineTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingLine *tool = qobject_cast<VModelingLine*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool);
connect(tool, &VModelingLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this);
break;
}
case(Tool::NormalTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingNormal *tool = qobject_cast<VModelingNormal*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool);
connect(tool, &VModelingNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingNormal::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this);
break;
}
case(Tool::PointOfContact):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingPointOfContact *tool = qobject_cast<VModelingPointOfContact*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool);
connect(tool, &VModelingPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this);
break;
}
case(Tool::ShoulderPointTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingShoulderPoint *tool = qobject_cast<VModelingShoulderPoint*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool);
connect(tool, &VModelingShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingShoulderPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this);
break;
}
case(Tool::SplinePathTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingSplinePath *tool = qobject_cast<VModelingSplinePath*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool);
connect(tool, &VModelingSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingSplinePath::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this);
break;
}
case(Tool::SplineTool):{
QMap<qint64, VDataTool*>* tools = doc->getTools();
VModelingSpline *tool = qobject_cast<VModelingSpline*>(tools->value(detail[i].getId()));
Q_CHECK_PTR(tool);
connect(tool, &VModelingSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &VModelingSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this);
break;
}
@ -162,6 +154,7 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
qWarning()<<"Get wrong tool type. Ignore.";
break;
}
doc->IncrementReferens(detail[i].getId());
}
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -236,11 +229,10 @@ void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScen
det.append(node);
}
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,
VMainGraphicsScene *scene, VDomDocument *doc,
void VToolDetail::Create(const qint64 _id, VDetail &newDetail, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){
qint64 id = _id;
if(typeCreation == Tool::FromGui){
@ -248,25 +240,14 @@ void VToolDetail::Create(const qint64 _id, VDetail &newDetail, VDetail &oldDetai
} else {
data->UpdateDetail(id, newDetail);
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
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);
}
}
doc->UpdateToolData(id, data);
}
}
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);
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();
tools->insert(id, detail);
}
@ -323,6 +304,54 @@ void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *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){
QDomElement nod = doc->createElement("node");

View File

@ -26,19 +26,18 @@
#include <QGraphicsPathItem>
#include "dialogs/dialogdetail.h"
class VToolDetail: public VAbstractTool, public QGraphicsPathItem
{
class VToolDetail: public VAbstractTool, public QGraphicsPathItem{
Q_OBJECT
public:
VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, VDetail &oldDetail,
Tool::Sources typeCreation, const Document::Documents &parse, VMainGraphicsScene *scene,
QGraphicsItem * parent = 0);
virtual void setDialog();
static void Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
static void Create(const qint64 _id, VDetail &newDetail, VDetail &oldDetail,
VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation);
VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
Tool::Sources typeCreation, VMainGraphicsScene *scene,
QGraphicsItem * parent = 0);
virtual void setDialog();
static void Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data);
static void Create(const qint64 _id, VDetail &newDetail, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation);
template <typename T>
void AddTool(T *tool, const qint64 &id, Tool::Tools typeTool){
tool->setParentItem(this);
@ -55,16 +54,20 @@ public:
public slots:
virtual void FullUpdateFromFile ();
virtual void FullUpdateFromGui(int result);
signals:
void RemoveTool(QGraphicsItem *tool);
protected:
virtual void AddToFile ();
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void RemoveReferens();
private:
Q_DISABLE_COPY(VToolDetail)
QSharedPointer<DialogDetail> dialogDetail;
VMainGraphicsScene *sceneDetails;
void RefreshGeometry ();
void AddNode(QDomElement &domElement, VNodeDetail &node);
void AddNode(QDomElement &domElement, VNodeDetail &node);
};
#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){
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");
qint64 basePointId = GetParametrLongLong(domElement, "basePoint");
qreal angle = GetParametrDouble(domElement, "angle");
data->IncrementReferens(basePointId, Scene::Point, mode);
if(mode == Draw::Calculation){
VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, scene, this,
data, parse, Tool::FromFile);
@ -591,8 +590,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
QString formula = GetParametrString(domElement, "length");
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
data->IncrementReferens(firstPointId, Scene::Point, mode);
data->IncrementReferens(secondPointId, Scene::Point, mode);
if(mode == Draw::Calculation){
VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my,
scene, this, data, parse, Tool::FromFile);
@ -619,9 +617,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 p1Line = GetParametrLongLong(domElement, "p1Line");
qint64 p2Line = GetParametrLongLong(domElement, "p2Line");
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){
VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my,
scene, this, data, parse, Tool::FromFile);
@ -648,8 +644,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
qreal angle = GetParametrDouble(domElement, "angle");
data->IncrementReferens(firstPointId, Scene::Point, mode);
data->IncrementReferens(secondPointId, Scene::Point, mode);
if(mode == Draw::Calculation){
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle,
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 secondPointId = GetParametrLongLong(domElement, "secondPoint");
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){
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine,
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 p1Line2Id = GetParametrLongLong(domElement, "p1Line2");
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){
VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my,
scene, this, data, parse, Tool::FromFile);
@ -733,9 +723,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 center = GetParametrLongLong(domElement, "center");
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
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){
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my,
scene, this, data, parse, Tool::FromFile);
@ -769,7 +757,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qreal my = toPixel(GetParametrDouble(domElement, "my"));
data->UpdateModelingPoint(id, VPointF(point.x(), point.y(), point.name(), mx, my, typeObject,
idObject ));
data->IncrementReferens(idObject, Scene::Point, typeObject);
VNodePoint::Create(this, data, id, idObject, mode, parse, Tool::FromFile);
return;
}
catch(const VExceptionBadId &e){
@ -788,8 +776,7 @@ void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement
qint64 id = GetParametrId(domElement);
qint64 firstPoint = GetParametrLongLong(domElement, "firstPoint");
qint64 secondPoint = GetParametrLongLong(domElement, "secondPoint");
data->IncrementReferens(firstPoint, Scene::Point, mode);
data->IncrementReferens(secondPoint, Scene::Point, mode);
if(mode == Draw::Calculation){
VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile);
} else {
@ -805,7 +792,8 @@ void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement
}
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_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
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 kAsm2 = GetParametrDouble(domElement, "kAsm2");
qreal kCurve = GetParametrDouble(domElement, "kCurve");
data->IncrementReferens(point1, Scene::Point, mode);
data->IncrementReferens(point4, Scene::Point, mode);
if(mode == Draw::Calculation){
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this,
data, parse, Tool::FromFile);
@ -855,7 +842,9 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
qint64 pSpline = GetParametrLongLong(element, "pSpline");
VSplinePoint splPoint(pSpline, kAsm1, angle, kAsm2);
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.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);
VNodeSpline::Create(this, data, id, idObject,mode, parse, Tool::FromFile);
return;
}
catch(const VExceptionBadId &e){
@ -921,14 +904,7 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
path.setMode(typeObject);
path.setIdObject(idObject);
data->UpdateModelingSplinePath(id, path);
const QVector<VSplinePoint> *points = path.GetPoint();
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);
}
}
VNodeSplinePath::Create(this, data, id, idObject, mode, parse, Tool::FromFile);
return;
}
catch(const VExceptionBadId &e){
@ -951,7 +927,7 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
QString radius = GetParametrString(domElement, "radius");
QString f1 = GetParametrString(domElement, "angle1");
QString f2 = GetParametrString(domElement, "angle2");
data->IncrementReferens(center, Scene::Point, mode);
if(mode == Draw::Calculation){
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile);
} else {
@ -983,7 +959,7 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
arc.setMode(typeObject);
arc.setIdObject(idObject);
data->UpdateModelingArc(id, arc);
data->IncrementReferens(idObject, Scene::Point, mode);
VNodeArc::Create(this, data, id, idObject, mode, parse, Tool::FromFile);
return;
}
catch(const VExceptionBadId &e){
@ -1059,73 +1035,18 @@ void VDomDocument::setCurrentData(){
}
void VDomDocument::GarbageCollector(){
const QMap<qint64, VPointF> *points = data->DataPoints();
Q_CHECK_PTR(points);
QMapIterator<qint64, VPointF> p(*points);
while (p.hasNext()) {
p.next();
VPointF point = p.value();
if(point.referens() <= 0){
QDomElement domElement = elementById(QString().setNum(p.key()));
QMapIterator<qint64, VDataTool*> t(tools);
while (t.hasNext()) {
t.next();
VDataTool *tool = t.value();
if(tool->referens() <= 0){
QDomElement domElement = elementById(QString().setNum(t.key()));
if(domElement.isElement()){
QDomElement element;
bool ok = GetActivModelingElement(element);
if(ok){
element.removeChild(domElement);
}
}
}
}
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);
QDomNode parent = domElement.parentNode();
if(!parent.isNull()){
parent.removeChild(domElement);
} else {
qWarning()<<tr("Can't get parent for object id = %1").arg(t.key());
}
}
}
@ -1145,3 +1066,17 @@ void VDomDocument::UpdateToolData(const qint64 &id, VContainer *data){
Q_CHECK_PTR(tool);
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 AddTool(const qint64 &id, VDataTool *tool);
void UpdateToolData(const qint64 &id, VContainer *data);
void IncrementReferens(qint64 id) const;
void DecrementReferens(qint64 id) const;
signals:
void ChangedActivDraw(const QString newName);
void ChangedNameDraw(const QString oldName, const QString newName);