Merged default with feature

This commit is contained in:
dismine 2013-10-01 21:17:32 +03:00
commit 04632b26e5
138 changed files with 2338 additions and 2249 deletions

View File

@ -6,7 +6,7 @@
# Use out-of-source builds (shadow builds) # Use out-of-source builds (shadow builds)
QT += core gui widgets xml svg printsupport QT += core gui widgets xml svg
TARGET = Valentina TARGET = Valentina
TEMPLATE = app TEMPLATE = app
@ -234,10 +234,10 @@ CONFIG(debug, debug|release){
# Debug # Debug
QMAKE_CXXFLAGS += -isystem "/usr/include/qt5" -isystem "/usr/include/qt5/QtWidgets" \ QMAKE_CXXFLAGS += -isystem "/usr/include/qt5" -isystem "/usr/include/qt5/QtWidgets" \
-isystem "/usr/include/qt5/QtXml" -isystem "/usr/include/qt5/QtGui" \ -isystem "/usr/include/qt5/QtXml" -isystem "/usr/include/qt5/QtGui" \
-isystem "/usr/include/qt5/QtCore" -O0 -Wall -Wextra -pedantic -Weffc++ \ -isystem "/usr/include/qt5/QtCore" -isystem "$$OUT_PWD/uic" -isystem "$$OUT_PWD/moc/" \
-isystem "$$OUT_PWD/uic" \ -Og -Wall -Wextra -pedantic -Weffc++ -Woverloaded-virtual -Wctor-dtor-privacy \
-Woverloaded-virtual -Wctor-dtor-privacy -Wnon-virtual-dtor -Wold-style-cast \ -Wnon-virtual-dtor -Wold-style-cast -Wconversion -Winit-self \
-Wconversion -Wsign-conversion -Winit-self -Wunreachable-code -Wunreachable-code
}else{ }else{
# Release # Release
QMAKE_CXXFLAGS += -O1 QMAKE_CXXFLAGS += -O1
@ -249,6 +249,17 @@ CONFIG(debug, debug|release){
lrelease.CONFIG += no_link target_predeps lrelease.CONFIG += no_link target_predeps
} }
message(Qt version: $$[QT_VERSION])
message(Qt is installed in $$[QT_INSTALL_PREFIX])
message(Qt resources can be found in the following locations:)
message(Documentation: $$[QT_INSTALL_DOCS])
message(Header files: $$[QT_INSTALL_HEADERS])
message(Libraries: $$[QT_INSTALL_LIBS])
message(Binary files (executables): $$[QT_INSTALL_BINS])
message(Plugins: $$[QT_INSTALL_PLUGINS])
message(Data files: $$[QT_INSTALL_DATA])
message(Translation files: $$[QT_INSTALL_TRANSLATIONS])
message(Settings: $$[QT_INSTALL_SETTINGS])
message(Examples: $$[QT_INSTALL_EXAMPLES])

View File

@ -20,7 +20,6 @@
****************************************************************************/ ****************************************************************************/
#include "calculator.h" #include "calculator.h"
#include <cmath>
#include <QDebug> #include <QDebug>
#define DELIMITER 1 #define DELIMITER 1

View File

@ -22,11 +22,7 @@
#ifndef CALCULATOR_H #ifndef CALCULATOR_H
#define CALCULATOR_H #define CALCULATOR_H
#include <QtGlobal>
#include <QString> #include <QString>
#include <QMap>
#include <QLineF>
#include <QPointF>
#include "vcontainer.h" #include "vcontainer.h"
/** /**
@ -40,7 +36,7 @@ public:
* @brief Calculator конструктор класу. Використовується при розрахунку лекала. * @brief Calculator конструктор класу. Використовується при розрахунку лекала.
* @param data покажчик на контейнер змінних * @param data покажчик на контейнер змінних
*/ */
Calculator(const VContainer *data); explicit Calculator(const VContainer *data);
/** /**
* @brief eval виконує розрахунок формули. * @brief eval виконує розрахунок формули.
* @param prog рядко в якому зберігається формула. * @param prog рядко в якому зберігається формула.
@ -48,8 +44,7 @@ public:
*/ */
qreal eval(QString prog, QString *errorMsg); qreal eval(QString prog, QString *errorMsg);
private: private:
Calculator(const Calculator &calc); Q_DISABLE_COPY(Calculator)
const Calculator &operator=(const Calculator &calc);
QString *errorMsg; QString *errorMsg;
/** /**
* @brief token теперішня лексема. * @brief token теперішня лексема.

View File

@ -165,87 +165,17 @@ void VContainer::UpdateId(qint64 newId){
} }
} }
void VContainer::IncrementReferens(qint64 id, Scene::Type obj, Draw::Mode mode){
switch( obj ){
case(Scene::Line):
break;
case(Scene::Point):{
VPointF point;
if(mode == Draw::Calculation){
point = GetPoint(id);
} else {
point = GetModelingPoint(id);
}
point.incrementReferens();
if(mode == Draw::Calculation){
UpdatePoint(id, point);
} else {
UpdateModelingPoint(id, point);
}
}
break;
case(Scene::Arc):{
VArc arc;
if(mode == Draw::Calculation){
arc = GetArc(id);
} else {
arc = GetModelingArc(id);
}
arc.incrementReferens();
if(mode == Draw::Calculation){
UpdateArc(id, arc);
} else {
UpdateModelingArc(id, arc);
}
}
break;
case(Scene::Spline):{
VSpline spl;
if(mode == Draw::Calculation){
spl = GetSpline(id);
} else {
spl = GetModelingSpline(id);
}
spl.incrementReferens();
if(mode == Draw::Calculation){
UpdateSpline(id, spl);
} else {
UpdateModelingSpline(id, spl);
}
}
break;
case(Scene::SplinePath):{
VSplinePath splPath;
if(mode == Draw::Calculation){
splPath = GetSplinePath(id);
} else {
splPath = GetModelingSplinePath(id);
}
splPath.incrementReferens();
if(mode == Draw::Calculation){
UpdateSplinePath(id, splPath);
} else {
UpdateModelingSplinePath(id, splPath);
}
}
break;
default:
qWarning()<<"Get wrong scene type.";
break;
}
}
QPainterPath VContainer::ContourPath(qint64 idDetail) const{ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
VDetail detail = GetDetail(idDetail); VDetail detail = GetDetail(idDetail);
QVector<QPointF> points; QVector<QPointF> points;
for(qint32 i = 0; i< detail.CountNode(); ++i){ for(qint32 i = 0; i< detail.CountNode(); ++i){
switch(detail[i].getTypeTool()){ switch(detail[i].getTypeTool()){
case(Tools::NodePoint):{ case(Tool::NodePoint):{
VPointF point = GetModelingPoint(detail[i].getId()); VPointF point = GetModelingPoint(detail[i].getId());
points.append(point.toQPointF()); points.append(point.toQPointF());
} }
break; break;
case(Tools::NodeArc):{ case(Tool::NodeArc):{
VArc arc = GetModelingArc(detail[i].getId()); VArc arc = GetModelingArc(detail[i].getId());
qreal len1 = GetLengthContour(points, arc.GetPoints()); qreal len1 = GetLengthContour(points, arc.GetPoints());
qreal lenReverse = GetLengthContour(points, GetReversePoint(arc.GetPoints())); qreal lenReverse = GetLengthContour(points, GetReversePoint(arc.GetPoints()));
@ -256,7 +186,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
} }
} }
break; break;
case(Tools::NodeSpline):{ case(Tool::NodeSpline):{
VSpline spline = GetModelingSpline(detail[i].getId()); VSpline spline = GetModelingSpline(detail[i].getId());
qreal len1 = GetLengthContour(points, spline.GetPoints()); qreal len1 = GetLengthContour(points, spline.GetPoints());
qreal lenReverse = GetLengthContour(points, GetReversePoint(spline.GetPoints())); qreal lenReverse = GetLengthContour(points, GetReversePoint(spline.GetPoints()));
@ -267,7 +197,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
} }
} }
break; break;
case(Tools::NodeSplinePath):{ case(Tool::NodeSplinePath):{
VSplinePath splinePath = GetModelingSplinePath(detail[i].getId()); VSplinePath splinePath = GetModelingSplinePath(detail[i].getId());
qreal len1 = GetLengthContour(points, splinePath.GetPathPoints()); qreal len1 = GetLengthContour(points, splinePath.GetPathPoints());
qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath.GetPathPoints())); qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath.GetPathPoints()));
@ -701,7 +631,7 @@ const QMap<qint64, VDetail> *VContainer::DataDetails() const{
return &details; return &details;
} }
void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId, Draw::Mode mode){ void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId, Draw::Draws mode){
QString nameLine = GetNameLine(firstPointId, secondPointId, mode); QString nameLine = GetNameLine(firstPointId, secondPointId, mode);
VPointF first; VPointF first;
VPointF second; VPointF second;
@ -760,7 +690,7 @@ qint64 VContainer::AddModelingArc(const VArc &arc){
return AddObject(modelingArcs, arc); return AddObject(modelingArcs, arc);
} }
QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, Draw::Mode mode) const{ QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, Draw::Draws mode) const{
VPointF first; VPointF first;
VPointF second; VPointF second;
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
@ -774,7 +704,7 @@ QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPo
} }
QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint, QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint,
Draw::Mode mode) const{ Draw::Draws mode) const{
VPointF first; VPointF first;
VPointF second; VPointF second;
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
@ -788,7 +718,7 @@ QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &sec
} }
QString VContainer::GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint, QString VContainer::GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint,
Draw::Mode mode) const{ Draw::Draws mode) const{
VPointF first; VPointF first;
VPointF second; VPointF second;
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
@ -801,7 +731,7 @@ QString VContainer::GetNameSpline(const qint64 &firstPoint, const qint64 &second
return QString("Spl_%1_%2").arg(first.name(), second.name()); return QString("Spl_%1_%2").arg(first.name(), second.name());
} }
QString VContainer::GetNameSplinePath(const VSplinePath &path, Draw::Mode mode) const{ QString VContainer::GetNameSplinePath(const VSplinePath &path, Draw::Draws mode) const{
if(path.Count() == 0){ if(path.Count() == 0){
return QString(); return QString();
} }
@ -823,7 +753,7 @@ QString VContainer::GetNameSplinePath(const VSplinePath &path, Draw::Mode mode)
return name; return name;
} }
QString VContainer::GetNameArc(const qint64 &center, const qint64 &id, Draw::Mode mode) const{ QString VContainer::GetNameArc(const qint64 &center, const qint64 &id, Draw::Draws mode) const{
VPointF centerPoint; VPointF centerPoint;
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
centerPoint = GetPoint(center); centerPoint = GetPoint(center);
@ -838,7 +768,7 @@ void VContainer::AddLengthLine(const QString &name, const qreal &value){
lengthLines[name] = value; lengthLines[name] = value;
} }
void VContainer::AddLengthSpline(const qint64 &firstPointId, const qint64 &secondPointId, Draw::Mode mode){ void VContainer::AddLengthSpline(const qint64 &firstPointId, const qint64 &secondPointId, Draw::Draws mode){
QString nameLine = GetNameSpline(firstPointId, secondPointId, mode); QString nameLine = GetNameSpline(firstPointId, secondPointId, mode);
VPointF first; VPointF first;
VPointF second; VPointF second;

View File

@ -22,13 +22,9 @@
#ifndef VCONTAINER_H #ifndef VCONTAINER_H
#define VCONTAINER_H #define VCONTAINER_H
#include <QMap>
#include <QTableWidget> #include <QTableWidget>
#include "options.h"
#include "vpointf.h"
#include "vstandarttablecell.h" #include "vstandarttablecell.h"
#include "vincrementtablerow.h" #include "vincrementtablerow.h"
#include "geometry/vspline.h"
#include "geometry/varc.h" #include "geometry/varc.h"
#include "geometry/vsplinepath.h" #include "geometry/vsplinepath.h"
#include "geometry/vdetail.h" #include "geometry/vdetail.h"
@ -75,13 +71,13 @@ public:
void AddIncrementTableRow(const QString& name, const VIncrementTableRow &cell); void AddIncrementTableRow(const QString& name, const VIncrementTableRow &cell);
void AddLengthLine(const QString &name, const qreal &value); void AddLengthLine(const QString &name, const qreal &value);
void AddLengthSpline(const qint64 &firstPointId, const qint64 &secondPointId, void AddLengthSpline(const qint64 &firstPointId, const qint64 &secondPointId,
Draw::Mode mode = Draw::Calculation); Draw::Draws mode = Draw::Calculation);
void AddLengthSpline(const QString &name, const qreal &value); void AddLengthSpline(const QString &name, const qreal &value);
void AddLengthArc(const qint64 &center, const qint64 &id); void AddLengthArc(const qint64 &center, const qint64 &id);
void AddLengthArc(const QString &name, const qreal &value); void AddLengthArc(const QString &name, const qreal &value);
void AddLineAngle(const QString &name, const qreal &value); void AddLineAngle(const QString &name, const qreal &value);
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId, void AddLine(const qint64 &firstPointId, const qint64 &secondPointId,
Draw::Mode mode = Draw::Calculation); Draw::Draws mode = Draw::Calculation);
qint64 AddSpline(const VSpline& spl); qint64 AddSpline(const VSpline& spl);
qint64 AddModelingSpline(const VSpline& spl); qint64 AddModelingSpline(const VSpline& spl);
qint64 AddSplinePath(const VSplinePath& splPath); qint64 AddSplinePath(const VSplinePath& splPath);
@ -89,15 +85,15 @@ public:
qint64 AddArc(const VArc& arc); qint64 AddArc(const VArc& arc);
qint64 AddModelingArc(const VArc& arc); qint64 AddModelingArc(const VArc& arc);
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint,
Draw::Mode mode = Draw::Calculation) const; Draw::Draws mode = Draw::Calculation) const;
QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint, QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint,
Draw::Mode mode = Draw::Calculation) const; Draw::Draws mode = Draw::Calculation) const;
QString GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint, QString GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint,
Draw::Mode mode = Draw::Calculation) const; Draw::Draws mode = Draw::Calculation) const;
QString GetNameSplinePath(const VSplinePath &path, QString GetNameSplinePath(const VSplinePath &path,
Draw::Mode mode = Draw::Calculation) const; Draw::Draws mode = Draw::Calculation) const;
QString GetNameArc(const qint64 &center, const qint64 &id, QString GetNameArc(const qint64 &center, const qint64 &id,
Draw::Mode mode = Draw::Calculation) const; Draw::Draws mode = Draw::Calculation) const;
void UpdatePoint(qint64 id, const VPointF& point); void UpdatePoint(qint64 id, const VPointF& point);
void UpdateModelingPoint(qint64 id, const VPointF& point); void UpdateModelingPoint(qint64 id, const VPointF& point);
void UpdateDetail(qint64 id, const VDetail& detail); void UpdateDetail(qint64 id, const VDetail& detail);
@ -143,7 +139,6 @@ public:
const QMap<qint64, VSplinePath> *DataModelingSplinePaths() const; const QMap<qint64, VSplinePath> *DataModelingSplinePaths() const;
const QMap<qint64, VDetail> *DataDetails() const; const QMap<qint64, VDetail> *DataDetails() const;
static void UpdateId(qint64 newId); static void UpdateId(qint64 newId);
void IncrementReferens(qint64 id, Scene::Type obj, Draw::Mode mode = Draw::Calculation);
QPainterPath ContourPath(qint64 idDetail) const; QPainterPath ContourPath(qint64 idDetail) const;
QPainterPath Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, QPainterPath Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv,
const qreal &width)const; const qreal &width)const;

View File

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

View File

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

View File

@ -22,7 +22,7 @@
#include "dialogalongline.h" #include "dialogalongline.h"
#include "ui_dialogalongline.h" #include "ui_dialogalongline.h"
DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Mode mode, QWidget *parent) : DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()), DialogTool(data, mode, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0){ typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0){
ui->setupUi(this); ui->setupUi(this);
@ -64,7 +64,7 @@ DialogAlongLine::~DialogAlongLine()
delete ui; delete ui;
} }
void DialogAlongLine::ChoosedObject(qint64 id, Scene::Type type){ void DialogAlongLine::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){ if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){ if(type == Scene::Detail){
idDetail = id; idDetail = id;

View File

@ -23,8 +23,6 @@
#define DIALOGALONGLINE_H #define DIALOGALONGLINE_H
#include "dialogtool.h" #include "dialogtool.h"
#include "options.h"
#include "container/vcontainer.h"
#include "container/calculator.h" #include "container/calculator.h"
namespace Ui { namespace Ui {
@ -35,7 +33,7 @@ class DialogAlongLine : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogAlongLine(const VContainer *data, Draw::Mode mode = Draw::Calculation, explicit DialogAlongLine(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogAlongLine(); ~DialogAlongLine();
QString getPointName() const; QString getPointName() const;
@ -49,9 +47,10 @@ public:
qint64 getSecondPointId() const; qint64 getSecondPointId() const;
void setSecondPointId(const qint64 &value, const qint64 &id); void setSecondPointId(const qint64 &value, const qint64 &id);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type); virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogAlongLine)
Ui::DialogAlongLine *ui; Ui::DialogAlongLine *ui;
qint32 number; qint32 number;
QString pointName; QString pointName;
@ -59,8 +58,6 @@ private:
QString formula; QString formula;
qint64 firstPointId; qint64 firstPointId;
qint64 secondPointId; qint64 secondPointId;
DialogAlongLine(const DialogAlongLine &dialog);
const DialogAlongLine &operator=(const DialogAlongLine& dialog);
}; };
#endif // DIALOGALONGLINE_H #endif // DIALOGALONGLINE_H

View File

@ -23,7 +23,7 @@
#include "ui_dialogarc.h" #include "ui_dialogarc.h"
#include "../container/calculator.h" #include "../container/calculator.h"
DialogArc::DialogArc(const VContainer *data, Draw::Mode mode, QWidget *parent) : DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false), DialogTool(data, mode, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
timerRadius(0), timerF1(0), timerF2(0), center(0), radius(QString()), f1(QString()), f2(QString()){ timerRadius(0), timerF1(0), timerF2(0), center(0), radius(QString()), f1(QString()), f2(QString()){
ui->setupUi(this); ui->setupUi(this);
@ -114,7 +114,7 @@ DialogArc::~DialogArc(){
delete ui; delete ui;
} }
void DialogArc::ChoosedObject(qint64 id, Scene::Type type){ void DialogArc::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){ if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){ if(type == Scene::Detail){
idDetail = id; idDetail = id;

View File

@ -23,7 +23,6 @@
#define DIALOGARC_H #define DIALOGARC_H
#include "dialogtool.h" #include "dialogtool.h"
#include "container/vcontainer.h"
namespace Ui { namespace Ui {
class DialogArc; class DialogArc;
@ -33,7 +32,7 @@ class DialogArc : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogArc(const VContainer *data, Draw::Mode mode = Draw::Calculation, QWidget *parent = 0); explicit DialogArc(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
~DialogArc(); ~DialogArc();
qint64 GetCenter() const; qint64 GetCenter() const;
void SetCenter(const qint64 &value); void SetCenter(const qint64 &value);
@ -48,7 +47,7 @@ public:
void SetF2(const QString &value); void SetF2(const QString &value);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type); virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted(); virtual void DialogAccepted();
virtual void ValChenged(int row); virtual void ValChenged(int row);
void PutRadius(); void PutRadius();
@ -61,6 +60,7 @@ public slots:
protected: protected:
virtual void CheckState(); virtual void CheckState();
private: private:
Q_DISABLE_COPY(DialogArc)
Ui::DialogArc *ui; Ui::DialogArc *ui;
bool flagRadius; bool flagRadius;
bool flagF1; bool flagF1;
@ -76,8 +76,6 @@ private:
void EvalF1(); void EvalF1();
void EvalF2(); void EvalF2();
void ShowLineArcs(); void ShowLineArcs();
DialogArc(const DialogArc &dialog);
const DialogArc &operator=(const DialogArc& dialog);
}; };
#endif // DIALOGARC_H #endif // DIALOGARC_H

View File

@ -22,7 +22,7 @@
#include "dialogbisector.h" #include "dialogbisector.h"
#include "ui_dialogbisector.h" #include "ui_dialogbisector.h"
DialogBisector::DialogBisector(const VContainer *data, Draw::Mode mode, QWidget *parent) : DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()), DialogTool(data, mode, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0){ typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0){
ui->setupUi(this); ui->setupUi(this);
@ -64,7 +64,7 @@ DialogBisector::~DialogBisector(){
delete ui; delete ui;
} }
void DialogBisector::ChoosedObject(qint64 id, Scene::Type type){ void DialogBisector::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){ if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){ if(type == Scene::Detail){
idDetail = id; idDetail = id;

View File

@ -23,11 +23,7 @@
#define DIALOGBISECTOR_H #define DIALOGBISECTOR_H
#include "dialogtool.h" #include "dialogtool.h"
#include <QPushButton>
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QTimer>
#include "options.h"
#include "container/vcontainer.h"
#include "container/calculator.h" #include "container/calculator.h"
namespace Ui { namespace Ui {
@ -39,7 +35,7 @@ class DialogBisector : public DialogTool
Q_OBJECT Q_OBJECT
public: public:
explicit DialogBisector(const VContainer *data, Draw::Mode mode = Draw::Calculation, explicit DialogBisector(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogBisector(); ~DialogBisector();
QString getPointName() const; QString getPointName() const;
@ -55,9 +51,10 @@ public:
qint64 getThirdPointId() const; qint64 getThirdPointId() const;
void setThirdPointId(const qint64 &value, const qint64 &id); void setThirdPointId(const qint64 &value, const qint64 &id);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type); virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogBisector)
Ui::DialogBisector *ui; Ui::DialogBisector *ui;
qint32 number; qint32 number;
QString pointName; QString pointName;
@ -66,8 +63,6 @@ private:
qint64 firstPointId; qint64 firstPointId;
qint64 secondPointId; qint64 secondPointId;
qint64 thirdPointId; qint64 thirdPointId;
DialogBisector(const DialogBisector &dialog);
const DialogBisector &operator=(const DialogBisector& dialog);
}; };
#endif // DIALOGBISECTOR_H #endif // DIALOGBISECTOR_H

View File

@ -22,7 +22,7 @@
#include "dialogdetail.h" #include "dialogdetail.h"
#include <QDebug> #include <QDebug>
DialogDetail::DialogDetail(const VContainer *data, Draw::Mode mode, QWidget *parent) : DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(), details(VDetail()){ DialogTool(data, mode, parent), ui(), details(VDetail()){
ui.setupUi(this); ui.setupUi(this);
bOk = ui.buttonBox->button(QDialogButtonBox::Ok); bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
@ -32,7 +32,7 @@ DialogDetail::DialogDetail(const VContainer *data, Draw::Mode mode, QWidget *par
connect(bCansel, &QPushButton::clicked, this, &DialogDetail::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogDetail::DialogRejected);
} }
void DialogDetail::ChoosedObject(qint64 id, Scene::Type type){ void DialogDetail::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){ if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){ if(type == Scene::Detail){
idDetail = id; idDetail = id;
@ -47,16 +47,16 @@ void DialogDetail::ChoosedObject(qint64 id, Scene::Type type){
if(type != Scene::Line && type != Scene::Detail){ if(type != Scene::Line && type != Scene::Detail){
switch(type){ switch(type){
case(Scene::Arc): case(Scene::Arc):
NewItem(id, Tools::NodeArc, mode, NodeDetail::Contour); NewItem(id, Tool::NodeArc, mode, NodeDetail::Contour);
break; break;
case(Scene::Point): case(Scene::Point):
NewItem(id, Tools::NodePoint, mode, NodeDetail::Contour); NewItem(id, Tool::NodePoint, mode, NodeDetail::Contour);
break; break;
case(Scene::Spline): case(Scene::Spline):
NewItem(id, Tools::NodeSpline, mode, NodeDetail::Contour); NewItem(id, Tool::NodeSpline, mode, NodeDetail::Contour);
break; break;
case(Scene::SplinePath): case(Scene::SplinePath):
NewItem(id, Tools::NodeSplinePath, mode, NodeDetail::Contour); NewItem(id, Tool::NodeSplinePath, mode, NodeDetail::Contour);
break; break;
default: default:
qWarning()<<"Get wrong scene object. Ignore."; qWarning()<<"Get wrong scene object. Ignore.";
@ -76,10 +76,10 @@ void DialogDetail::DialogAccepted(){
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogDetail::NewItem(qint64 id, Tools::Enum typeTool, Draw::Mode mode, NodeDetail::Type typeNode){ void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode){
QString name; QString name;
switch(typeTool){ switch(typeTool){
case(Tools::NodePoint):{ case(Tool::NodePoint):{
VPointF point; VPointF point;
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
point = data->GetPoint(id); point = data->GetPoint(id);
@ -89,7 +89,7 @@ void DialogDetail::NewItem(qint64 id, Tools::Enum typeTool, Draw::Mode mode, Nod
name = point.name(); name = point.name();
break; break;
} }
case(Tools::NodeArc):{ case(Tool::NodeArc):{
VArc arc; VArc arc;
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
arc = data->GetArc(id); arc = data->GetArc(id);
@ -99,7 +99,7 @@ void DialogDetail::NewItem(qint64 id, Tools::Enum typeTool, Draw::Mode mode, Nod
name = data->GetNameArc(arc.GetCenter(), id, mode); name = data->GetNameArc(arc.GetCenter(), id, mode);
break; break;
} }
case(Tools::NodeSpline):{ case(Tool::NodeSpline):{
VSpline spl; VSpline spl;
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
spl = data->GetSpline(id); spl = data->GetSpline(id);
@ -109,7 +109,7 @@ void DialogDetail::NewItem(qint64 id, Tools::Enum typeTool, Draw::Mode mode, Nod
name = spl.GetName(); name = spl.GetName();
break; break;
} }
case(Tools::NodeSplinePath):{ case(Tool::NodeSplinePath):{
VSplinePath splPath; VSplinePath splPath;
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
splPath = data->GetSplinePath(id); splPath = data->GetSplinePath(id);

View File

@ -24,24 +24,22 @@
#include "ui_dialogdetail.h" #include "ui_dialogdetail.h"
#include "dialogtool.h" #include "dialogtool.h"
#include "container/vcontainer.h"
#include "geometry/vdetail.h" #include "geometry/vdetail.h"
class DialogDetail : public DialogTool class DialogDetail : public DialogTool{
{
Q_OBJECT Q_OBJECT
public: public:
explicit DialogDetail(const VContainer *data, Draw::Mode mode, QWidget *parent = 0); explicit DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent = 0);
VDetail getDetails() const; VDetail getDetails() const;
void setDetails(const VDetail &value); void setDetails(const VDetail &value);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type); virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Ui::DialogDetail ui; Ui::DialogDetail ui;
VDetail details; VDetail details;
void NewItem(qint64 id, Tools::Enum typeTool, Draw::Mode mode, NodeDetail::Type typeNode); void NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode);
}; };
#endif // DIALOGDETAIL_H #endif // DIALOGDETAIL_H

View File

@ -26,7 +26,7 @@
#include "container/vpointf.h" #include "container/vpointf.h"
#include "container/calculator.h" #include "container/calculator.h"
DialogEndLine::DialogEndLine(const VContainer *data, Draw::Mode mode, QWidget *parent) : DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()), DialogTool(data, mode, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()),
formula(QString()), angle(0), basePointId(0){ formula(QString()), angle(0), basePointId(0){
ui->setupUi(this); ui->setupUi(this);
@ -79,7 +79,7 @@ DialogEndLine::DialogEndLine(const VContainer *data, Draw::Mode mode, QWidget *p
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEndLine::FormulaChanged); connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEndLine::FormulaChanged);
} }
void DialogEndLine::ChoosedObject(qint64 id, Scene::Type type){ void DialogEndLine::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){ if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){ if(type == Scene::Detail){
idDetail = id; idDetail = id;

View File

@ -23,11 +23,7 @@
#define DIALOGENDLINE_H #define DIALOGENDLINE_H
#include "dialogtool.h" #include "dialogtool.h"
#include <QPushButton>
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QTimer>
#include "options.h"
#include "container/vcontainer.h"
#include "container/calculator.h" #include "container/calculator.h"
namespace Ui { namespace Ui {
@ -38,7 +34,7 @@ class DialogEndLine : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogEndLine(const VContainer *data, Draw::Mode mode = Draw::Calculation, explicit DialogEndLine(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogEndLine(); ~DialogEndLine();
QString getPointName() const; QString getPointName() const;
@ -52,17 +48,16 @@ public:
qint64 getBasePointId() const; qint64 getBasePointId() const;
void setBasePointId(const qint64 &value, const qint64 &id); void setBasePointId(const qint64 &value, const qint64 &id);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type); virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogEndLine)
Ui::DialogEndLine *ui; Ui::DialogEndLine *ui;
QString pointName; QString pointName;
QString typeLine; QString typeLine;
QString formula; QString formula;
qreal angle; qreal angle;
qint64 basePointId; qint64 basePointId;
DialogEndLine(const DialogEndLine &dialog);
const DialogEndLine &operator=(const DialogEndLine& dialog);
}; };
#endif // DIALOGENDLINE_H #endif // DIALOGENDLINE_H

View File

@ -144,12 +144,12 @@ QString DialogHistory::Record(const VToolRecord &tool){
qint64 center = 0; qint64 center = 0;
QDomElement domElement; QDomElement domElement;
switch( tool.getTypeTool() ){ switch( tool.getTypeTool() ){
case Tools::ArrowTool: case Tool::ArrowTool:
break; break;
case Tools::SinglePointTool: case Tool::SinglePointTool:
record = QString("%1 - Базова точка").arg(data->GetPoint(tool.getId()).name()); record = QString("%1 - Базова точка").arg(data->GetPoint(tool.getId()).name());
break; break;
case Tools::EndLineTool: case Tool::EndLineTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if(domElement.isElement()){
basePointId = domElement.attribute("basePoint", "").toLongLong(); basePointId = domElement.attribute("basePoint", "").toLongLong();
@ -157,7 +157,7 @@ QString DialogHistory::Record(const VToolRecord &tool){
record = QString("%1_%2 - Відрізок з точки %1 до точки %2").arg(data->GetPoint(basePointId).name(), record = QString("%1_%2 - Відрізок з точки %1 до точки %2").arg(data->GetPoint(basePointId).name(),
data->GetPoint(tool.getId()).name()); data->GetPoint(tool.getId()).name());
break; break;
case Tools::LineTool: case Tool::LineTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if(domElement.isElement()){
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = domElement.attribute("firstPoint", "").toLongLong();
@ -166,7 +166,7 @@ QString DialogHistory::Record(const VToolRecord &tool){
record = QString("%1_%2 - Лінія з точки %1 до точки %2").arg(data->GetPoint(firstPointId).name(), record = QString("%1_%2 - Лінія з точки %1 до точки %2").arg(data->GetPoint(firstPointId).name(),
data->GetPoint(secondPointId).name()); data->GetPoint(secondPointId).name());
break; break;
case Tools::AlongLineTool: case Tool::AlongLineTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if(domElement.isElement()){
basePointId = domElement.attribute("firstPoint", "").toLongLong(); basePointId = domElement.attribute("firstPoint", "").toLongLong();
@ -176,10 +176,10 @@ QString DialogHistory::Record(const VToolRecord &tool){
data->GetPoint(secondPointId).name(), data->GetPoint(secondPointId).name(),
data->GetPoint(tool.getId()).name()); data->GetPoint(tool.getId()).name());
break; break;
case Tools::ShoulderPointTool: case Tool::ShoulderPointTool:
record = QString("%1 - Плечева точка").arg(data->GetPoint(tool.getId()).name()); record = QString("%1 - Плечева точка").arg(data->GetPoint(tool.getId()).name());
break; break;
case Tools::NormalTool: case Tool::NormalTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if(domElement.isElement()){
basePointId = domElement.attribute("firstPoint", "").toLongLong(); basePointId = domElement.attribute("firstPoint", "").toLongLong();
@ -189,7 +189,7 @@ QString DialogHistory::Record(const VToolRecord &tool){
data->GetPoint(secondPointId).name(), data->GetPoint(secondPointId).name(),
data->GetPoint(tool.getId()).name()); data->GetPoint(tool.getId()).name());
break; break;
case Tools::BisectorTool: case Tool::BisectorTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if(domElement.isElement()){
firstPointId = domElement.attribute("firstPoint", "").toLongLong(); firstPointId = domElement.attribute("firstPoint", "").toLongLong();
@ -201,7 +201,7 @@ QString DialogHistory::Record(const VToolRecord &tool){
data->GetPoint(thirdPointId).name(), data->GetPoint(thirdPointId).name(),
data->GetPoint(tool.getId()).name()); data->GetPoint(tool.getId()).name());
break; break;
case Tools::LineIntersectTool: case Tool::LineIntersectTool:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if(domElement.isElement()){
p1Line1 = domElement.attribute("p1Line1", "").toLongLong(); p1Line1 = domElement.attribute("p1Line1", "").toLongLong();
@ -215,18 +215,18 @@ QString DialogHistory::Record(const VToolRecord &tool){
data->GetPoint(p2Line2).name(), data->GetPoint(p2Line2).name(),
data->GetPoint(tool.getId()).name()); data->GetPoint(tool.getId()).name());
break; break;
case Tools::SplineTool:{ case Tool::SplineTool:{
VSpline spl = data->GetSpline(tool.getId()); VSpline spl = data->GetSpline(tool.getId());
record = QString("Сплайн %1_%2").arg(data->GetPoint(spl.GetP1()).name(), record = QString("Сплайн %1_%2").arg(data->GetPoint(spl.GetP1()).name(),
data->GetPoint(spl.GetP4()).name()); data->GetPoint(spl.GetP4()).name());
} }
break; break;
case Tools::ArcTool:{ case Tool::ArcTool:{
VArc arc = data->GetArc(tool.getId()); VArc arc = data->GetArc(tool.getId());
record = QString("Дуга з центром в точці %1").arg(data->GetPoint(arc.GetCenter()).name()); record = QString("Дуга з центром в точці %1").arg(data->GetPoint(arc.GetCenter()).name());
} }
break; break;
case Tools::SplinePathTool:{ case Tool::SplinePathTool:{
VSplinePath splPath = data->GetSplinePath(tool.getId()); VSplinePath splPath = data->GetSplinePath(tool.getId());
QVector<VSplinePoint> points = splPath.GetSplinePath(); QVector<VSplinePoint> points = splPath.GetSplinePath();
if(points.size() != 0 ){ if(points.size() != 0 ){
@ -238,7 +238,7 @@ QString DialogHistory::Record(const VToolRecord &tool){
} }
} }
break; break;
case Tools::PointOfContact: case Tool::PointOfContact:
domElement = doc->elementById(QString().setNum(tool.getId())); domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){ if(domElement.isElement()){
center = domElement.attribute("center", "").toLongLong(); center = domElement.attribute("center", "").toLongLong();

View File

@ -46,6 +46,7 @@ signals:
protected: protected:
virtual void closeEvent ( QCloseEvent * event ); virtual void closeEvent ( QCloseEvent * event );
private: private:
Q_DISABLE_COPY(DialogHistory)
Ui::DialogHistory *ui; Ui::DialogHistory *ui;
VDomDocument *doc; VDomDocument *doc;
qint32 cursorRow; qint32 cursorRow;
@ -54,8 +55,6 @@ private:
QString Record(const VToolRecord &tool); QString Record(const VToolRecord &tool);
void InitialTable(); void InitialTable();
void ShowPoint(); void ShowPoint();
DialogHistory(const DialogHistory &dialog);
const DialogHistory &operator=(const DialogHistory& dialog);
}; };
#endif // DIALOGHISTORY_H #endif // DIALOGHISTORY_H

View File

@ -23,9 +23,7 @@
#define DIALOGINCREMENTS_H #define DIALOGINCREMENTS_H
#include "dialogtool.h" #include "dialogtool.h"
#include <QPushButton>
#include "xml/vdomdocument.h" #include "xml/vdomdocument.h"
#include "container/vcontainer.h"
namespace Ui { namespace Ui {
class DialogIncrements; class DialogIncrements;
@ -47,6 +45,7 @@ signals:
void FullUpdateTree(); void FullUpdateTree();
void haveLiteChange(); void haveLiteChange();
private: private:
Q_DISABLE_COPY(DialogIncrements)
Ui::DialogIncrements *ui; Ui::DialogIncrements *ui;
VContainer *data; // need because we must change data VContainer *data; // need because we must change data
VDomDocument *doc; VDomDocument *doc;
@ -62,8 +61,6 @@ private:
void FillLengthArcs(); void FillLengthArcs();
void AddIncrementToFile(qint64 id, QString name, qint32 base, qreal ksize, qreal kgrowth, void AddIncrementToFile(qint64 id, QString name, qint32 base, qreal ksize, qreal kgrowth,
QString description); QString description);
DialogIncrements(const DialogIncrements &dialog);
const DialogIncrements &operator=(const DialogIncrements& dialog);
}; };
#endif // DIALOGINCREMENTS_H #endif // DIALOGINCREMENTS_H

View File

@ -24,7 +24,7 @@
#include <QPushButton> #include <QPushButton>
#include <QCloseEvent> #include <QCloseEvent>
DialogLine::DialogLine(const VContainer *data, Draw::Mode mode, QWidget *parent) : DialogLine::DialogLine(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0){ DialogTool(data, mode, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0){
ui->setupUi(this); ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
@ -75,7 +75,7 @@ void DialogLine::DialogAccepted(){
DialogClosed(QDialog::Accepted); DialogClosed(QDialog::Accepted);
} }
void DialogLine::ChoosedObject(qint64 id, Scene::Type type){ void DialogLine::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){ if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){ if(type == Scene::Detail){
idDetail = id; idDetail = id;

View File

@ -23,10 +23,6 @@
#define DIALOGLINE_H #define DIALOGLINE_H
#include "dialogtool.h" #include "dialogtool.h"
#include <QComboBox>
#include "container/vcontainer.h"
#include "options.h"
namespace Ui { namespace Ui {
class DialogLine; class DialogLine;
@ -36,7 +32,7 @@ class DialogLine : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogLine(const VContainer *data, Draw::Mode mode = Draw::Calculation, explicit DialogLine(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogLine(); ~DialogLine();
qint64 getFirstPoint() const; qint64 getFirstPoint() const;
@ -44,15 +40,14 @@ public:
qint64 getSecondPoint() const; qint64 getSecondPoint() const;
void setSecondPoint(const qint64 &value); void setSecondPoint(const qint64 &value);
public slots: public slots:
void ChoosedObject(qint64 id, Scene::Type type); void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogLine)
Ui::DialogLine *ui; Ui::DialogLine *ui;
qint32 number; qint32 number;
qint64 firstPoint; qint64 firstPoint;
qint64 secondPoint; qint64 secondPoint;
DialogLine(const DialogLine &dialog);
const DialogLine &operator=(const DialogLine& dialog);
}; };
#endif // DIALOGLINE_H #endif // DIALOGLINE_H

View File

@ -22,7 +22,7 @@
#include "dialoglineintersect.h" #include "dialoglineintersect.h"
#include "ui_dialoglineintersect.h" #include "ui_dialoglineintersect.h"
DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Mode mode, QWidget *parent) : DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()), DialogTool(data, mode, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()),
p1Line1(0), p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true){ p1Line1(0), p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true){
ui->setupUi(this); ui->setupUi(this);
@ -45,7 +45,7 @@ DialogLineIntersect::~DialogLineIntersect()
delete ui; delete ui;
} }
void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Type type){ void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){ if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){ if(type == Scene::Detail){
idDetail = id; idDetail = id;

View File

@ -32,7 +32,7 @@ class DialogLineIntersect : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogLineIntersect(const VContainer *data, Draw::Mode mode = Draw::Calculation, explicit DialogLineIntersect(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogLineIntersect(); ~DialogLineIntersect();
qint64 getP1Line1() const; qint64 getP1Line1() const;
@ -46,13 +46,14 @@ public:
QString getPointName() const; QString getPointName() const;
void setPointName(const QString &value); void setPointName(const QString &value);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type); virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted(); virtual void DialogAccepted();
void P1Line1Changed( int index); void P1Line1Changed( int index);
void P2Line1Changed( int index); void P2Line1Changed( int index);
void P1Line2Changed( int index); void P1Line2Changed( int index);
void P2Line2Changed( int index); void P2Line2Changed( int index);
private: private:
Q_DISABLE_COPY(DialogLineIntersect)
Ui::DialogLineIntersect *ui; Ui::DialogLineIntersect *ui;
qint32 number; qint32 number;
QString pointName; QString pointName;
@ -63,8 +64,6 @@ private:
bool flagPoint; bool flagPoint;
virtual void CheckState(); virtual void CheckState();
bool CheckIntersecion(); bool CheckIntersecion();
DialogLineIntersect(const DialogLineIntersect &dialog);
const DialogLineIntersect &operator=(const DialogLineIntersect& dialog);
}; };
#endif // DIALOGLINEINTERSECT_H #endif // DIALOGLINEINTERSECT_H

View File

@ -23,7 +23,7 @@
#include "ui_dialognormal.h" #include "ui_dialognormal.h"
#include <QMenu> #include <QMenu>
DialogNormal::DialogNormal(const VContainer *data, Draw::Mode mode, QWidget *parent) : DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), DialogTool(data, mode, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), angle(0), firstPointId(0), secondPointId(0){ typeLine(QString()), formula(QString()), angle(0), firstPointId(0), secondPointId(0){
ui->setupUi(this); ui->setupUi(this);
@ -82,7 +82,7 @@ DialogNormal::~DialogNormal()
delete ui; delete ui;
} }
void DialogNormal::ChoosedObject(qint64 id, Scene::Type type){ void DialogNormal::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){ if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){ if(type == Scene::Detail){
idDetail = id; idDetail = id;

View File

@ -23,11 +23,7 @@
#define DIALOGNORMAL_H #define DIALOGNORMAL_H
#include "dialogtool.h" #include "dialogtool.h"
#include <QPushButton>
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QTimer>
#include "options.h"
#include "container/vcontainer.h"
#include "container/calculator.h" #include "container/calculator.h"
namespace Ui { namespace Ui {
@ -38,7 +34,7 @@ class DialogNormal : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogNormal(const VContainer *data, Draw::Mode mode = Draw::Calculation, explicit DialogNormal(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogNormal(); ~DialogNormal();
QString getPointName() const; QString getPointName() const;
@ -54,9 +50,10 @@ public:
qint64 getSecondPointId() const; qint64 getSecondPointId() const;
void setSecondPointId(const qint64 &value, const qint64 &id); void setSecondPointId(const qint64 &value, const qint64 &id);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type); virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogNormal)
Ui::DialogNormal *ui; Ui::DialogNormal *ui;
qint32 number; qint32 number;
QString pointName; QString pointName;
@ -65,8 +62,6 @@ private:
qreal angle; qreal angle;
qint64 firstPointId; qint64 firstPointId;
qint64 secondPointId; qint64 secondPointId;
DialogNormal(const DialogNormal &dialog);
const DialogNormal &operator=(const DialogNormal& dialog);
}; };
#endif // DIALOGNORMAL_H #endif // DIALOGNORMAL_H

View File

@ -21,7 +21,7 @@
#include "dialogpointofcontact.h" #include "dialogpointofcontact.h"
DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Mode mode, QWidget *parent) : DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0), DialogTool(data, mode, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0),
firstPoint(0), secondPoint(0){ firstPoint(0), secondPoint(0){
ui.setupUi(this); ui.setupUi(this);
@ -58,7 +58,7 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Mode mo
connect(ui.lineEditFormula, &QLineEdit::textChanged, this, &DialogPointOfContact::FormulaChanged); connect(ui.lineEditFormula, &QLineEdit::textChanged, this, &DialogPointOfContact::FormulaChanged);
} }
void DialogPointOfContact::ChoosedObject(qint64 id, Scene::Type type){ void DialogPointOfContact::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){ if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){ if(type == Scene::Detail){
idDetail = id; idDetail = id;

View File

@ -24,8 +24,6 @@
#include "ui_dialogpointofcontact.h" #include "ui_dialogpointofcontact.h"
#include "dialogtool.h" #include "dialogtool.h"
#include "options.h"
#include "container/vcontainer.h"
#include "container/calculator.h" #include "container/calculator.h"
class DialogPointOfContact : public DialogTool class DialogPointOfContact : public DialogTool
@ -33,7 +31,7 @@ class DialogPointOfContact : public DialogTool
Q_OBJECT Q_OBJECT
public: public:
explicit DialogPointOfContact(const VContainer *data, Draw::Mode mode = Draw::Calculation, explicit DialogPointOfContact(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
QString getPointName() const; QString getPointName() const;
void setPointName(const QString &value); void setPointName(const QString &value);
@ -51,9 +49,10 @@ public:
void setSecondPoint(const qint64 &value, const qint64 &id); void setSecondPoint(const qint64 &value, const qint64 &id);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type); virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogPointOfContact)
Ui::DialogPointOfContact ui; Ui::DialogPointOfContact ui;
qint32 number; qint32 number;
QString pointName; QString pointName;
@ -61,8 +60,6 @@ private:
qint64 center; qint64 center;
qint64 firstPoint; qint64 firstPoint;
qint64 secondPoint; qint64 secondPoint;
DialogPointOfContact(const DialogPointOfContact &dialog);
const DialogPointOfContact &operator=(const DialogPointOfContact& dialog);
}; };
#endif // DIALOGPOINTOFCONTACT_H #endif // DIALOGPOINTOFCONTACT_H

View File

@ -22,7 +22,7 @@
#include "dialogshoulderpoint.h" #include "dialogshoulderpoint.h"
#include "ui_dialogshoulderpoint.h" #include "ui_dialogshoulderpoint.h"
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Mode mode, QWidget *parent) : DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()), DialogTool(data, mode, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0){ typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0){
ui->setupUi(this); ui->setupUi(this);
@ -66,7 +66,7 @@ DialogShoulderPoint::~DialogShoulderPoint()
delete ui; delete ui;
} }
void DialogShoulderPoint::ChoosedObject(qint64 id, Scene::Type type){ void DialogShoulderPoint::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){ if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){ if(type == Scene::Detail){
idDetail = id; idDetail = id;

View File

@ -23,8 +23,6 @@
#define DIALOGSHOULDERPOINT_H #define DIALOGSHOULDERPOINT_H
#include "dialogtool.h" #include "dialogtool.h"
#include "options.h"
#include "container/vcontainer.h"
#include "container/calculator.h" #include "container/calculator.h"
namespace Ui { namespace Ui {
@ -35,7 +33,7 @@ class DialogShoulderPoint : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogShoulderPoint(const VContainer *data, Draw::Mode mode = Draw::Calculation, explicit DialogShoulderPoint(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogShoulderPoint(); ~DialogShoulderPoint();
QString getPointName() const; QString getPointName() const;
@ -51,9 +49,10 @@ public:
qint64 getPShoulder() const; qint64 getPShoulder() const;
void setPShoulder(const qint64 &value, const qint64 &id); void setPShoulder(const qint64 &value, const qint64 &id);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type); virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogShoulderPoint)
Ui::DialogShoulderPoint *ui; Ui::DialogShoulderPoint *ui;
qint32 number; qint32 number;
QString pointName; QString pointName;
@ -62,8 +61,6 @@ private:
qint64 p1Line; qint64 p1Line;
qint64 p2Line; qint64 p2Line;
qint64 pShoulder; qint64 pShoulder;
DialogShoulderPoint(const DialogShoulderPoint &dialog);
const DialogShoulderPoint &operator=(const DialogShoulderPoint& dialog);
}; };
#endif // DIALOGSHOULDERPOINT_H #endif // DIALOGSHOULDERPOINT_H

View File

@ -23,7 +23,6 @@
#define DIALOGSINGLEPOINT_H #define DIALOGSINGLEPOINT_H
#include "dialogtool.h" #include "dialogtool.h"
#include "container/vcontainer.h"
namespace Ui { namespace Ui {
class DialogSinglePoint; class DialogSinglePoint;
@ -42,11 +41,10 @@ public slots:
void mousePress(QPointF scenePos); void mousePress(QPointF scenePos);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogSinglePoint)
Ui::DialogSinglePoint *ui; Ui::DialogSinglePoint *ui;
QString name; QString name;
QPointF point; QPointF point;
DialogSinglePoint(const DialogSinglePoint &dialog);
const DialogSinglePoint &operator=(const DialogSinglePoint& dialog);
}; };
#endif // DIALOGSINGLEPOINT_H #endif // DIALOGSINGLEPOINT_H

View File

@ -22,7 +22,7 @@
#include "dialogspline.h" #include "dialogspline.h"
#include "ui_dialogspline.h" #include "ui_dialogspline.h"
DialogSpline::DialogSpline(const VContainer *data, Draw::Mode mode, QWidget *parent) : DialogSpline::DialogSpline(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0), DialogTool(data, mode, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0),
kAsm1(1), kAsm2(1), kCurve(1){ kAsm1(1), kAsm2(1), kCurve(1){
ui->setupUi(this); ui->setupUi(this);
@ -41,7 +41,7 @@ DialogSpline::~DialogSpline(){
delete ui; delete ui;
} }
void DialogSpline::ChoosedObject(qint64 id, Scene::Type type){ void DialogSpline::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){ if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){ if(type == Scene::Detail){
idDetail = id; idDetail = id;

View File

@ -23,7 +23,6 @@
#define DIALOGSPLINE_H #define DIALOGSPLINE_H
#include "dialogtool.h" #include "dialogtool.h"
#include "container/vcontainer.h"
namespace Ui { namespace Ui {
class DialogSpline; class DialogSpline;
@ -33,7 +32,7 @@ class DialogSpline : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogSpline(const VContainer *data, Draw::Mode mode = Draw::Calculation, explicit DialogSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogSpline(); ~DialogSpline();
qint64 getP1() const; qint64 getP1() const;
@ -51,9 +50,10 @@ public:
qreal getKCurve() const; qreal getKCurve() const;
void setKCurve(const qreal &value); void setKCurve(const qreal &value);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type); virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted(); virtual void DialogAccepted();
private: private:
Q_DISABLE_COPY(DialogSpline)
Ui::DialogSpline *ui; Ui::DialogSpline *ui;
qint32 number; qint32 number;
qint64 p1; // перша точка qint64 p1; // перша точка
@ -63,8 +63,6 @@ private:
qreal kAsm1; qreal kAsm1;
qreal kAsm2; qreal kAsm2;
qreal kCurve; qreal kCurve;
DialogSpline(const DialogSpline &dialog);
const DialogSpline &operator=(const DialogSpline& dialog);
}; };
#endif // DIALOGSPLINE_H #endif // DIALOGSPLINE_H

View File

@ -23,7 +23,7 @@
#include "ui_dialogsplinepath.h" #include "ui_dialogsplinepath.h"
#include "geometry/vsplinepoint.h" #include "geometry/vsplinepoint.h"
DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Mode mode, QWidget *parent) : DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()){ DialogTool(data, mode, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()){
ui->setupUi(this); ui->setupUi(this);
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
@ -68,7 +68,7 @@ void DialogSplinePath::SetPath(const VSplinePath &value){
} }
void DialogSplinePath::ChoosedObject(qint64 id, Scene::Type type){ void DialogSplinePath::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){ if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){ if(type == Scene::Detail){
idDetail = id; idDetail = id;

View File

@ -23,7 +23,6 @@
#define DIALOGSPLINEPATH_H #define DIALOGSPLINEPATH_H
#include "dialogtool.h" #include "dialogtool.h"
#include "container/vcontainer.h"
#include "geometry/vsplinepath.h" #include "geometry/vsplinepath.h"
namespace Ui { namespace Ui {
@ -34,13 +33,13 @@ class DialogSplinePath : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogSplinePath(const VContainer *data, Draw::Mode mode = Draw::Calculation, explicit DialogSplinePath(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
~DialogSplinePath(); ~DialogSplinePath();
VSplinePath GetPath() const; VSplinePath GetPath() const;
void SetPath(const VSplinePath &value); void SetPath(const VSplinePath &value);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type); virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted(); virtual void DialogAccepted();
void PointChenged(int row); void PointChenged(int row);
void currentPointChanged( int index ); void currentPointChanged( int index );
@ -49,14 +48,13 @@ public slots:
void KAsm1Changed(qreal d); void KAsm1Changed(qreal d);
void KAsm2Changed(qreal d); void KAsm2Changed(qreal d);
private: private:
Q_DISABLE_COPY(DialogSplinePath)
Ui::DialogSplinePath *ui; Ui::DialogSplinePath *ui;
VSplinePath path; VSplinePath path;
void NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2); void NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2);
void DataPoint(qint64 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2); void DataPoint(qint64 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2);
void EnableFields(); void EnableFields();
void SetAngle(qint32 angle); void SetAngle(qint32 angle);
DialogSplinePath(const DialogSplinePath &dialog);
const DialogSplinePath &operator=(const DialogSplinePath& dialog);
}; };
#endif // DIALOGSPLINEPATH_H #endif // DIALOGSPLINEPATH_H

View File

@ -26,7 +26,7 @@
#include "geometry/vdetail.h" #include "geometry/vdetail.h"
#include <QDebug> #include <QDebug>
DialogTool::DialogTool(const VContainer *data, Draw::Mode mode, QWidget *parent):QDialog(parent), data(data), DialogTool::DialogTool(const VContainer *data, Draw::Draws mode, QWidget *parent):QDialog(parent), data(data),
isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0), spinBoxAngle(0), isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0), spinBoxAngle(0),
lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0), lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0),
radioButtonSizeGrowth(0), radioButtonStandartTable(0), radioButtonIncrements(0), radioButtonSizeGrowth(0), radioButtonStandartTable(0), radioButtonIncrements(0),
@ -74,14 +74,14 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{
} }
VDetail det = data->GetDetail(idDetail); VDetail det = data->GetDetail(idDetail);
for(qint32 i = 0; i< det.CountNode(); ++i){ for(qint32 i = 0; i< det.CountNode(); ++i){
if(det[i].getTypeTool() == Tools::NodePoint || if(det[i].getTypeTool() == Tool::NodePoint ||
det[i].getTypeTool() == Tools::AlongLineTool || det[i].getTypeTool() == Tool::AlongLineTool ||
det[i].getTypeTool() == Tools::BisectorTool || det[i].getTypeTool() == Tool::BisectorTool ||
det[i].getTypeTool() == Tools::EndLineTool || det[i].getTypeTool() == Tool::EndLineTool ||
det[i].getTypeTool() == Tools::LineIntersectTool || det[i].getTypeTool() == Tool::LineIntersectTool ||
det[i].getTypeTool() == Tools::NormalTool || det[i].getTypeTool() == Tool::NormalTool ||
det[i].getTypeTool() == Tools::PointOfContact || det[i].getTypeTool() == Tool::PointOfContact ||
det[i].getTypeTool() == Tools::ShoulderPointTool){ det[i].getTypeTool() == Tool::ShoulderPointTool){
if(det[i].getId() != id){ if(det[i].getId() != id){
VPointF point = data->GetModelingPoint(det[i].getId()); VPointF point = data->GetModelingPoint(det[i].getId());
box->addItem(point.name(), det[i].getId()); box->addItem(point.name(), det[i].getId());
@ -200,7 +200,7 @@ void DialogTool::CheckState(){
} }
void DialogTool::ChoosedObject(qint64 id, Scene::Type type){ void DialogTool::ChoosedObject(qint64 id, Scene::Scenes type){
Q_UNUSED(id); Q_UNUSED(id);
Q_UNUSED(type); Q_UNUSED(type);
} }

View File

@ -32,13 +32,11 @@
#include <QRadioButton> #include <QRadioButton>
#include <QTimer> #include <QTimer>
#include "container/vcontainer.h" #include "container/vcontainer.h"
#include "options.h"
class DialogTool : public QDialog class DialogTool : public QDialog{
{
Q_OBJECT Q_OBJECT
public: public:
DialogTool(const VContainer *data, Draw::Mode mode = Draw::Calculation, DialogTool(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0); QWidget *parent = 0);
virtual ~DialogTool(); virtual ~DialogTool();
qint64 getIdDetail() const; qint64 getIdDetail() const;
@ -46,7 +44,7 @@ public:
signals: signals:
void DialogClosed(int result); void DialogClosed(int result);
public slots: public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type); virtual void ChoosedObject(qint64 id, Scene::Scenes type);
void NamePointChanged(); void NamePointChanged();
virtual void DialogAccepted(); virtual void DialogAccepted();
virtual void DialogRejected(); virtual void DialogRejected();
@ -69,6 +67,7 @@ public slots:
virtual void ValChenged(int row); virtual void ValChenged(int row);
void UpdateList(); void UpdateList();
protected: protected:
Q_DISABLE_COPY(DialogTool)
const VContainer *data; const VContainer *data;
bool isInitialized; bool isInitialized;
bool flagName; bool flagName;
@ -85,7 +84,7 @@ protected:
QRadioButton *radioButtonIncrements; QRadioButton *radioButtonIncrements;
QRadioButton *radioButtonLengthLine; QRadioButton *radioButtonLengthLine;
qint64 idDetail; qint64 idDetail;
Draw::Mode mode; Draw::Draws mode;
bool CheckObject(const qint64 &id); bool CheckObject(const qint64 &id);
virtual void closeEvent ( QCloseEvent * event ); virtual void closeEvent ( QCloseEvent * event );
virtual void showEvent( QShowEvent *event ); virtual void showEvent( QShowEvent *event );
@ -102,8 +101,6 @@ protected:
void Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label); void Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label);
void setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64 &value, const qint64 &id) const; void setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64 &value, const qint64 &id) const;
qint64 getCurrentPointId(QComboBox *box) const; qint64 getCurrentPointId(QComboBox *box) const;
DialogTool(const DialogTool &dialog);
DialogTool &operator=(const DialogTool &dialog);
}; };
#endif // DIALOGTOOL_H #endif // DIALOGTOOL_H

View File

@ -23,7 +23,7 @@
#define VEXCEPTIONEMPTYPARAMETER_H #define VEXCEPTIONEMPTYPARAMETER_H
#include "vexception.h" #include "vexception.h"
#include "QDomElement" #include <QDomElement>
class VExceptionEmptyParameter : public VException class VExceptionEmptyParameter : public VException
{ {

View File

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

View File

@ -22,10 +22,6 @@
#ifndef VARC_H #ifndef VARC_H
#define VARC_H #define VARC_H
#include <QPainterPath>
#include <QVector>
#include <QMap>
#include "container/vpointf.h"
#include "vspline.h" #include "vspline.h"
/** /**
@ -46,7 +42,7 @@ public:
*/ */
VArc (const QMap<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius, VArc (const QMap<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
qreal f1, QString formulaF1, qreal f2 , QString formulaF2, qreal f1, QString formulaF1, qreal f2 , QString formulaF2,
Draw::Mode mode = Draw::Calculation, qint64 idObject = 0); Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
VArc(const VArc &arc); VArc(const VArc &arc);
VArc& operator= (const VArc &arc); VArc& operator= (const VArc &arc);
/** /**
@ -98,12 +94,8 @@ public:
qint32 NumberSplOfArc () const; qint32 NumberSplOfArc () const;
QVector<QPointF> GetPoints () const; QVector<QPointF> GetPoints () const;
QVector<QPointF> SplOfArc( qint32 number ) const; QVector<QPointF> SplOfArc( qint32 number ) const;
qint32 referens() const; Draw::Draws getMode() const;
void incrementReferens(); void setMode(const Draw::Draws &value);
void decrementReferens();
Draw::Mode getMode() const;
void setMode(const Draw::Mode &value);
qint64 getIdObject() const; qint64 getIdObject() const;
void setIdObject(const qint64 &value); void setIdObject(const qint64 &value);
@ -128,8 +120,7 @@ private:
*/ */
qint64 center; qint64 center;
const QMap<qint64, VPointF> *points; const QMap<qint64, VPointF> *points;
qint32 _referens; Draw::Draws mode;
Draw::Mode mode;
qint64 idObject; qint64 idObject;
}; };

View File

@ -27,22 +27,17 @@
#include <QString> #include <QString>
#include <QPainterPath> #include <QPainterPath>
namespace Detail{ namespace Detail {
enum Contour enum Contour { OpenContour, CloseContour };
{ Q_DECLARE_FLAGS(Contours, Contour)
OpenContour,
CloseContour
};
enum Equidistant enum Equidistant { OpenEquidistant, CloseEquidistant };
{ Q_DECLARE_FLAGS(Equidistants, Equidistant)
OpenEquidistant,
CloseEquidistant
};
} }
Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Contours)
Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants)
class VDetail class VDetail{
{
public: public:
VDetail(); VDetail();
VDetail(const QString &name, const QVector<VNodeDetail> &nodes); VDetail(const QString &name, const QVector<VNodeDetail> &nodes);
@ -53,13 +48,10 @@ public:
VNodeDetail & operator[](int indx); VNodeDetail & operator[](int indx);
QString getName() const; QString getName() const;
void setName(const QString &value); void setName(const QString &value);
qreal getMx() const; qreal getMx() const;
void setMx(const qreal &value); void setMx(const qreal &value);
qreal getMy() const; qreal getMy() const;
void setMy(const qreal &value); void setMy(const qreal &value);
private: private:
QVector<VNodeDetail> nodes; QVector<VNodeDetail> nodes;
QString name; QString name;

View File

@ -21,11 +21,11 @@
#include "vnodedetail.h" #include "vnodedetail.h"
VNodeDetail::VNodeDetail():id(0), typeTool(Tools::NodePoint), mode(Draw::Calculation), VNodeDetail::VNodeDetail():id(0), typeTool(Tool::NodePoint), mode(Draw::Calculation),
typeNode(NodeDetail::Contour){ typeNode(NodeDetail::Contour){
} }
VNodeDetail::VNodeDetail(qint64 id, Tools::Enum typeTool, Draw::Mode mode, NodeDetail::Type typeNode):id(id), VNodeDetail::VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode):id(id),
typeTool(typeTool), mode(mode), typeNode(typeNode){ typeTool(typeTool), mode(mode), typeNode(typeNode){
} }
@ -33,11 +33,11 @@ VNodeDetail::VNodeDetail(const VNodeDetail &node):id(node.getId()), typeTool(nod
mode(node.getMode()), typeNode(node.getTypeNode()){ mode(node.getMode()), typeNode(node.getTypeNode()){
} }
Tools::Enum VNodeDetail::getTypeTool() const{ Tool::Tools VNodeDetail::getTypeTool() const{
return typeTool; return typeTool;
} }
void VNodeDetail::setTypeTool(const Tools::Enum &value){ void VNodeDetail::setTypeTool(const Tool::Tools &value){
typeTool = value; typeTool = value;
} }
@ -49,18 +49,18 @@ void VNodeDetail::setId(const qint64 &value){
id = value; id = value;
} }
Draw::Mode VNodeDetail::getMode() const{ Draw::Draws VNodeDetail::getMode() const{
return mode; return mode;
} }
void VNodeDetail::setMode(const Draw::Mode &value){ void VNodeDetail::setMode(const Draw::Draws &value){
mode = value; mode = value;
} }
NodeDetail::Type VNodeDetail::getTypeNode() const{ NodeDetail::NodeDetails VNodeDetail::getTypeNode() const{
return typeNode; return typeNode;
} }
void VNodeDetail::setTypeNode(const NodeDetail::Type &value){ void VNodeDetail::setTypeNode(const NodeDetail::NodeDetails &value){
typeNode = value; typeNode = value;
} }

View File

@ -22,38 +22,35 @@
#ifndef VNODEDETAIL_H #ifndef VNODEDETAIL_H
#define VNODEDETAIL_H #define VNODEDETAIL_H
#include <QtGlobal>
#include <QMetaType> #include <QMetaType>
#include "options.h" #include "options.h"
namespace NodeDetail{ namespace NodeDetail {
enum Type enum NodeDetail { Contour, Modeling };
{ Q_DECLARE_FLAGS(NodeDetails, NodeDetail)
Contour,
Modeling
};
} }
Q_DECLARE_OPERATORS_FOR_FLAGS(NodeDetail::NodeDetails)
class VNodeDetail class VNodeDetail
{ {
public: public:
VNodeDetail(); VNodeDetail();
VNodeDetail(qint64 id, Tools::Enum typeTool, Draw::Mode mode, NodeDetail::Type typeNode); VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode);
VNodeDetail(const VNodeDetail &node); VNodeDetail(const VNodeDetail &node);
qint64 getId() const; qint64 getId() const;
void setId(const qint64 &value); void setId(const qint64 &value);
Tools::Enum getTypeTool() const; Tool::Tools getTypeTool() const;
void setTypeTool(const Tools::Enum &value); void setTypeTool(const Tool::Tools &value);
Draw::Mode getMode() const; Draw::Draws getMode() const;
void setMode(const Draw::Mode &value); void setMode(const Draw::Draws &value);
NodeDetail::Type getTypeNode() const; NodeDetail::NodeDetails getTypeNode() const;
void setTypeNode(const NodeDetail::Type &value); void setTypeNode(const NodeDetail::NodeDetails &value);
private: private:
qint64 id; qint64 id;
Tools::Enum typeTool; Tool::Tools typeTool;
Draw::Mode mode; Draw::Draws mode;
NodeDetail::Type typeNode; NodeDetail::NodeDetails typeNode;
}; };
Q_DECLARE_METATYPE(VNodeDetail) Q_DECLARE_METATYPE(VNodeDetail)

View File

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

View File

@ -28,7 +28,6 @@
#include <QVector> #include <QVector>
#include <QMap> #include <QMap>
#include "container/vpointf.h" #include "container/vpointf.h"
#include "options.h"
/** /**
* @brief VSpline клас, що реалізує сплайн. * @brief VSpline клас, що реалізує сплайн.
@ -53,7 +52,7 @@ public:
*/ */
VSpline (const QMap<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, VSpline (const QMap<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1,
qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve,
Draw::Mode mode = Draw::Calculation, qint64 idObject = 0); Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
/** /**
* @brief VSpline конструктор. * @brief VSpline конструктор.
* @param p1 початкова точка сплайну. * @param p1 початкова точка сплайну.
@ -62,7 +61,7 @@ public:
* @param p4 кінцева точка сплайну. * @param p4 кінцева точка сплайну.
*/ */
VSpline (const QMap<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, VSpline (const QMap<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3,
qint64 p4, qreal kCurve, Draw::Mode mode = Draw::Calculation, qint64 p4, qreal kCurve, Draw::Draws mode = Draw::Calculation,
qint64 idObject = 0); qint64 idObject = 0);
/** /**
* @brief ModifiSpl модифікує сплайн. * @brief ModifiSpl модифікує сплайн.
@ -180,11 +179,8 @@ public:
* @param Pmirror точка відносно якої відбувається вертикальне дзеркалення сплайну. * @param Pmirror точка відносно якої відбувається вертикальне дзеркалення сплайну.
*/ */
// void Mirror(const QPointF Pmirror); // void Mirror(const QPointF Pmirror);
qint32 referens() const; Draw::Draws getMode() const;
void incrementReferens(); void setMode(const Draw::Draws &value);
void decrementReferens();
Draw::Mode getMode() const;
void setMode(const Draw::Mode &value);
static QVector<QPointF> SplinePoints(QPointF p1, QPointF p4, qreal angle1, static QVector<QPointF> SplinePoints(QPointF p1, QPointF p4, qreal angle1,
qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve); qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve);
qint64 getIdObject() const; qint64 getIdObject() const;
@ -229,8 +225,7 @@ private:
qreal kAsm2; qreal kAsm2;
qreal kCurve; qreal kCurve;
const QMap<qint64, VPointF> *points; const QMap<qint64, VPointF> *points;
qint32 _referens; Draw::Draws mode;
Draw::Mode mode;
qint64 idObject; qint64 idObject;
/** /**
* @brief LengthBezier повертає дожину сплайну за його чотирьма точками. * @brief LengthBezier повертає дожину сплайну за його чотирьма точками.

View File

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

View File

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

View File

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

View File

@ -20,7 +20,7 @@
****************************************************************************/ ****************************************************************************/
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication> #include "widgets/vapplication.h"
#include <QTextCodec> #include <QTextCodec>
#include "tablewindow.h" #include "tablewindow.h"
@ -48,7 +48,7 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
qInstallMessageHandler(myMessageOutput); qInstallMessageHandler(myMessageOutput);
QApplication app(argc, argv); VApplication app(argc, argv);
QTranslator qtTranslator; QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(), qtTranslator.load("qt_" + QLocale::system().name(),

View File

@ -37,7 +37,7 @@
#include "exception/vexceptionwrongparameterid.h" #include "exception/vexceptionwrongparameterid.h"
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow), tool(Tools::ArrowTool), currentScene(0), sceneDraw(0), QMainWindow(parent), ui(new Ui::MainWindow), tool(Tool::ArrowTool), currentScene(0), sceneDraw(0),
sceneDetails(0), mouseCoordinate(0), helpLabel(0), view(0), isInitialized(false), dialogTable(0), sceneDetails(0), mouseCoordinate(0), helpLabel(0), view(0), isInitialized(false), dialogTable(0),
dialogEndLine(QSharedPointer<DialogEndLine>()), dialogLine(QSharedPointer<DialogLine>()), dialogEndLine(QSharedPointer<DialogEndLine>()), dialogLine(QSharedPointer<DialogLine>()),
dialogAlongLine(QSharedPointer<DialogAlongLine>()), dialogAlongLine(QSharedPointer<DialogAlongLine>()),
@ -152,7 +152,7 @@ void MainWindow::ActionNewDraw(){
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem); connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools(); QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, spoint); tools->insert(id, spoint);
VDrawTool::AddRecord(id, Tools::SinglePointTool, doc); VDrawTool::AddRecord(id, Tool::SinglePointTool, doc);
SetEnableTool(true); SetEnableTool(true);
SetEnableWidgets(true); SetEnableWidgets(true);
changeInFile = true; changeInFile = true;
@ -191,7 +191,7 @@ void MainWindow::OptionDraw(){
} }
template <typename Dialog, typename Func> template <typename Dialog, typename Func>
void MainWindow::SetToolButton(bool checked, Tools::Enum t, const QString &cursor, void MainWindow::SetToolButton(bool checked, Tool::Tools t, const QString &cursor,
QSharedPointer<Dialog> &dialog, Func closeDialogSlot){ QSharedPointer<Dialog> &dialog, Func closeDialogSlot){
if(checked){ if(checked){
CanselTool(); CanselTool();
@ -211,8 +211,8 @@ void MainWindow::SetToolButton(bool checked, Tools::Enum t, const QString &curso
} }
} }
template <typename Tool> template <typename T>
void MainWindow::AddToolToDetail(Tool *tool, const qint64 &id, Tools::Enum typeTool, void MainWindow::AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool,
const qint64 &idDetail){ const qint64 &idDetail){
QMap<qint64, VDataTool*>* tools = doc->getTools(); QMap<qint64, VDataTool*>* tools = doc->getTools();
VToolDetail *det = qobject_cast<VToolDetail*>(tools->value(idDetail)); VToolDetail *det = qobject_cast<VToolDetail*>(tools->value(idDetail));
@ -221,7 +221,7 @@ void MainWindow::AddToolToDetail(Tool *tool, const qint64 &id, Tools::Enum typeT
} }
void MainWindow::ToolEndLine(bool checked){ void MainWindow::ToolEndLine(bool checked){
SetToolButton(checked, Tools::EndLineTool, ":/cursor/endline_cursor.png", dialogEndLine, SetToolButton(checked, Tool::EndLineTool, ":/cursor/endline_cursor.png", dialogEndLine,
&MainWindow::ClosedDialogEndLine); &MainWindow::ClosedDialogEndLine);
} }
@ -231,14 +231,14 @@ void MainWindow::ClosedDialogEndLine(int result){
VToolEndLine::Create(dialogEndLine, currentScene, doc, data); VToolEndLine::Create(dialogEndLine, currentScene, doc, data);
} else { } else {
VModelingEndLine *endLine = VModelingEndLine::Create(dialogEndLine, doc, data); VModelingEndLine *endLine = VModelingEndLine::Create(dialogEndLine, doc, data);
AddToolToDetail(endLine, endLine->getId(), Tools::EndLineTool, dialogEndLine->getIdDetail()); AddToolToDetail(endLine, endLine->getId(), Tool::EndLineTool, dialogEndLine->getIdDetail());
} }
} }
ArrowTool(); ArrowTool();
} }
void MainWindow::ToolLine(bool checked){ void MainWindow::ToolLine(bool checked){
SetToolButton(checked, Tools::LineTool, ":/cursor/line_cursor.png", dialogLine, SetToolButton(checked, Tool::LineTool, ":/cursor/line_cursor.png", dialogLine,
&MainWindow::ClosedDialogLine); &MainWindow::ClosedDialogLine);
} }
@ -248,14 +248,14 @@ void MainWindow::ClosedDialogLine(int result){
VToolLine::Create(dialogLine, currentScene, doc, data); VToolLine::Create(dialogLine, currentScene, doc, data);
} else { } else {
VModelingLine *line = VModelingLine::Create(dialogLine, doc, data); VModelingLine *line = VModelingLine::Create(dialogLine, doc, data);
AddToolToDetail(line, line->getId(), Tools::LineTool, dialogLine->getIdDetail()); AddToolToDetail(line, line->getId(), Tool::LineTool, dialogLine->getIdDetail());
} }
} }
ArrowTool(); ArrowTool();
} }
void MainWindow::ToolAlongLine(bool checked){ void MainWindow::ToolAlongLine(bool checked){
SetToolButton(checked, Tools::AlongLineTool, ":/cursor/alongline_cursor.png", dialogAlongLine, SetToolButton(checked, Tool::AlongLineTool, ":/cursor/alongline_cursor.png", dialogAlongLine,
&MainWindow::ClosedDialogAlongLine); &MainWindow::ClosedDialogAlongLine);
} }
@ -265,14 +265,14 @@ void MainWindow::ClosedDialogAlongLine(int result){
VToolAlongLine::Create(dialogAlongLine, currentScene, doc, data); VToolAlongLine::Create(dialogAlongLine, currentScene, doc, data);
} else{ } else{
VModelingAlongLine *point = VModelingAlongLine::Create(dialogAlongLine, doc, data); VModelingAlongLine *point = VModelingAlongLine::Create(dialogAlongLine, doc, data);
AddToolToDetail(point, point->getId(), Tools::AlongLineTool, dialogAlongLine->getIdDetail()); AddToolToDetail(point, point->getId(), Tool::AlongLineTool, dialogAlongLine->getIdDetail());
} }
} }
ArrowTool(); ArrowTool();
} }
void MainWindow::ToolShoulderPoint(bool checked){ void MainWindow::ToolShoulderPoint(bool checked){
SetToolButton(checked, Tools::ShoulderPointTool, ":/cursor/shoulder_cursor.png", dialogShoulderPoint, SetToolButton(checked, Tool::ShoulderPointTool, ":/cursor/shoulder_cursor.png", dialogShoulderPoint,
&MainWindow::ClosedDialogShoulderPoint); &MainWindow::ClosedDialogShoulderPoint);
} }
@ -282,7 +282,7 @@ void MainWindow::ClosedDialogShoulderPoint(int result){
VToolShoulderPoint::Create(dialogShoulderPoint, currentScene, doc, data); VToolShoulderPoint::Create(dialogShoulderPoint, currentScene, doc, data);
} else { } else {
VModelingShoulderPoint *point = VModelingShoulderPoint::Create(dialogShoulderPoint, doc, data); VModelingShoulderPoint *point = VModelingShoulderPoint::Create(dialogShoulderPoint, doc, data);
AddToolToDetail(point, point->getId(), Tools::ShoulderPointTool, AddToolToDetail(point, point->getId(), Tool::ShoulderPointTool,
dialogShoulderPoint->getIdDetail()); dialogShoulderPoint->getIdDetail());
} }
} }
@ -290,7 +290,7 @@ void MainWindow::ClosedDialogShoulderPoint(int result){
} }
void MainWindow::ToolNormal(bool checked){ void MainWindow::ToolNormal(bool checked){
SetToolButton(checked, Tools::NormalTool, ":/cursor/normal_cursor.png", dialogNormal, SetToolButton(checked, Tool::NormalTool, ":/cursor/normal_cursor.png", dialogNormal,
&MainWindow::ClosedDialogNormal); &MainWindow::ClosedDialogNormal);
} }
@ -300,14 +300,14 @@ void MainWindow::ClosedDialogNormal(int result){
VToolNormal::Create(dialogNormal, currentScene, doc, data); VToolNormal::Create(dialogNormal, currentScene, doc, data);
} else { } else {
VModelingNormal *point = VModelingNormal::Create(dialogNormal, doc, data); VModelingNormal *point = VModelingNormal::Create(dialogNormal, doc, data);
AddToolToDetail(point, point->getId(), Tools::NormalTool, dialogNormal->getIdDetail()); AddToolToDetail(point, point->getId(), Tool::NormalTool, dialogNormal->getIdDetail());
} }
} }
ArrowTool(); ArrowTool();
} }
void MainWindow::ToolBisector(bool checked){ void MainWindow::ToolBisector(bool checked){
SetToolButton(checked, Tools::BisectorTool, ":/cursor/bisector_cursor.png", dialogBisector, SetToolButton(checked, Tool::BisectorTool, ":/cursor/bisector_cursor.png", dialogBisector,
&MainWindow::ClosedDialogBisector); &MainWindow::ClosedDialogBisector);
} }
@ -317,14 +317,14 @@ void MainWindow::ClosedDialogBisector(int result){
VToolBisector::Create(dialogBisector, currentScene, doc, data); VToolBisector::Create(dialogBisector, currentScene, doc, data);
} else { } else {
VModelingBisector *point = VModelingBisector::Create(dialogBisector, doc, data); VModelingBisector *point = VModelingBisector::Create(dialogBisector, doc, data);
AddToolToDetail(point, point->getId(), Tools::BisectorTool, dialogBisector->getIdDetail()); AddToolToDetail(point, point->getId(), Tool::BisectorTool, dialogBisector->getIdDetail());
} }
} }
ArrowTool(); ArrowTool();
} }
void MainWindow::ToolLineIntersect(bool checked){ void MainWindow::ToolLineIntersect(bool checked){
SetToolButton(checked, Tools::LineIntersectTool, ":/cursor/intersect_cursor.png", dialogLineIntersect, SetToolButton(checked, Tool::LineIntersectTool, ":/cursor/intersect_cursor.png", dialogLineIntersect,
&MainWindow::ClosedDialogLineIntersect); &MainWindow::ClosedDialogLineIntersect);
} }
@ -334,7 +334,7 @@ void MainWindow::ClosedDialogLineIntersect(int result){
VToolLineIntersect::Create(dialogLineIntersect, currentScene, doc, data); VToolLineIntersect::Create(dialogLineIntersect, currentScene, doc, data);
} else { } else {
VModelingLineIntersect *point = VModelingLineIntersect::Create(dialogLineIntersect, doc, data); VModelingLineIntersect *point = VModelingLineIntersect::Create(dialogLineIntersect, doc, data);
AddToolToDetail(point, point->getId(), Tools::LineIntersectTool, AddToolToDetail(point, point->getId(), Tool::LineIntersectTool,
dialogLineIntersect->getIdDetail()); dialogLineIntersect->getIdDetail());
} }
} }
@ -342,7 +342,7 @@ void MainWindow::ClosedDialogLineIntersect(int result){
} }
void MainWindow::ToolSpline(bool checked){ void MainWindow::ToolSpline(bool checked){
SetToolButton(checked, Tools::SplineTool, ":/cursor/spline_cursor.png", dialogSpline, SetToolButton(checked, Tool::SplineTool, ":/cursor/spline_cursor.png", dialogSpline,
&MainWindow::ClosedDialogSpline); &MainWindow::ClosedDialogSpline);
} }
@ -352,14 +352,14 @@ void MainWindow::ClosedDialogSpline(int result){
VToolSpline::Create(dialogSpline, currentScene, doc, data); VToolSpline::Create(dialogSpline, currentScene, doc, data);
} else { } else {
VModelingSpline *spl = VModelingSpline::Create(dialogSpline, doc, data); VModelingSpline *spl = VModelingSpline::Create(dialogSpline, doc, data);
AddToolToDetail(spl, spl->getId(), Tools::SplineTool, dialogSpline->getIdDetail()); AddToolToDetail(spl, spl->getId(), Tool::SplineTool, dialogSpline->getIdDetail());
} }
} }
ArrowTool(); ArrowTool();
} }
void MainWindow::ToolArc(bool checked){ void MainWindow::ToolArc(bool checked){
SetToolButton(checked, Tools::ArcTool, ":/cursor/arc_cursor.png", dialogArc, SetToolButton(checked, Tool::ArcTool, ":/cursor/arc_cursor.png", dialogArc,
&MainWindow::ClosedDialogArc); &MainWindow::ClosedDialogArc);
} }
@ -369,14 +369,14 @@ void MainWindow::ClosedDialogArc(int result){
VToolArc::Create(dialogArc, currentScene, doc, data); VToolArc::Create(dialogArc, currentScene, doc, data);
} else { } else {
VModelingArc *arc = VModelingArc::Create(dialogArc, doc, data); VModelingArc *arc = VModelingArc::Create(dialogArc, doc, data);
AddToolToDetail(arc, arc->getId(), Tools::ArcTool, dialogArc->getIdDetail()); AddToolToDetail(arc, arc->getId(), Tool::ArcTool, dialogArc->getIdDetail());
} }
} }
ArrowTool(); ArrowTool();
} }
void MainWindow::ToolSplinePath(bool checked){ void MainWindow::ToolSplinePath(bool checked){
SetToolButton(checked, Tools::SplinePathTool, ":/cursor/splinepath_cursor.png", dialogSplinePath, SetToolButton(checked, Tool::SplinePathTool, ":/cursor/splinepath_cursor.png", dialogSplinePath,
&MainWindow::ClosedDialogSplinePath); &MainWindow::ClosedDialogSplinePath);
} }
@ -386,14 +386,14 @@ void MainWindow::ClosedDialogSplinePath(int result){
VToolSplinePath::Create(dialogSplinePath, currentScene, doc, data); VToolSplinePath::Create(dialogSplinePath, currentScene, doc, data);
} else { } else {
VModelingSplinePath *spl = VModelingSplinePath::Create(dialogSplinePath, doc, data); VModelingSplinePath *spl = VModelingSplinePath::Create(dialogSplinePath, doc, data);
AddToolToDetail(spl, spl->getId(), Tools::SplinePathTool, dialogSplinePath->getIdDetail()); AddToolToDetail(spl, spl->getId(), Tool::SplinePathTool, dialogSplinePath->getIdDetail());
} }
} }
ArrowTool(); ArrowTool();
} }
void MainWindow::ToolPointOfContact(bool checked){ void MainWindow::ToolPointOfContact(bool checked){
SetToolButton(checked, Tools::PointOfContact, ":/cursor/pointcontact_cursor.png", dialogPointOfContact, SetToolButton(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png", dialogPointOfContact,
&MainWindow::ClosedDialogPointOfContact); &MainWindow::ClosedDialogPointOfContact);
} }
@ -404,7 +404,7 @@ void MainWindow::ClosedDialogPointOfContact(int result){
} else { } else {
VModelingPointOfContact *point = VModelingPointOfContact::Create(dialogPointOfContact, doc, VModelingPointOfContact *point = VModelingPointOfContact::Create(dialogPointOfContact, doc,
data); data);
AddToolToDetail(point, point->getId(), Tools::PointOfContact, AddToolToDetail(point, point->getId(), Tool::PointOfContact,
dialogPointOfContact->getIdDetail()); dialogPointOfContact->getIdDetail());
} }
} }
@ -414,7 +414,7 @@ void MainWindow::ClosedDialogPointOfContact(int result){
void MainWindow::ToolDetail(bool checked){ void MainWindow::ToolDetail(bool checked){
if(checked){ if(checked){
CanselTool(); CanselTool();
tool = Tools::Detail; tool = Tool::Detail;
QPixmap pixmap("://cursor/new_detail_cursor.png"); QPixmap pixmap("://cursor/new_detail_cursor.png");
QCursor cur(pixmap, 2, 3); QCursor cur(pixmap, 2, 3);
view->setCursor(cur); view->setCursor(cur);
@ -575,79 +575,79 @@ void MainWindow::mouseMove(QPointF scenePos){
void MainWindow::CanselTool(){ void MainWindow::CanselTool(){
switch( tool ) switch( tool )
{ {
case Tools::ArrowTool: case Tool::ArrowTool:
ui->actionArrowTool->setChecked(false); ui->actionArrowTool->setChecked(false);
break; break;
case Tools::SinglePointTool: case Tool::SinglePointTool:
//Nothing to do here because we can't create this tool from main window. //Nothing to do here because we can't create this tool from main window.
break; break;
case Tools::EndLineTool: case Tool::EndLineTool:
dialogEndLine.clear(); dialogEndLine.clear();
ui->toolButtonEndLine->setChecked(false); ui->toolButtonEndLine->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason); currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection(); currentScene->clearSelection();
break; break;
case Tools::LineTool: case Tool::LineTool:
dialogLine.clear(); dialogLine.clear();
ui->toolButtonLine->setChecked(false); ui->toolButtonLine->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason); currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearFocus(); currentScene->clearFocus();
break; break;
case Tools::AlongLineTool: case Tool::AlongLineTool:
dialogAlongLine.clear(); dialogAlongLine.clear();
ui->toolButtonAlongLine->setChecked(false); ui->toolButtonAlongLine->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason); currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection(); currentScene->clearSelection();
break; break;
case Tools::ShoulderPointTool: case Tool::ShoulderPointTool:
dialogShoulderPoint.clear(); dialogShoulderPoint.clear();
ui->toolButtonShoulderPoint->setChecked(false); ui->toolButtonShoulderPoint->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason); currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection(); currentScene->clearSelection();
break; break;
case Tools::NormalTool: case Tool::NormalTool:
dialogNormal.clear(); dialogNormal.clear();
ui->toolButtonNormal->setChecked(false); ui->toolButtonNormal->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason); currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection(); currentScene->clearSelection();
break; break;
case Tools::BisectorTool: case Tool::BisectorTool:
dialogBisector.clear(); dialogBisector.clear();
ui->toolButtonBisector->setChecked(false); ui->toolButtonBisector->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason); currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection(); currentScene->clearSelection();
break; break;
case Tools::LineIntersectTool: case Tool::LineIntersectTool:
dialogLineIntersect.clear(); dialogLineIntersect.clear();
ui->toolButtonLineIntersect->setChecked(false); ui->toolButtonLineIntersect->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason); currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection(); currentScene->clearSelection();
break; break;
case Tools::SplineTool: case Tool::SplineTool:
dialogSpline.clear(); dialogSpline.clear();
ui->toolButtonSpline->setChecked(false); ui->toolButtonSpline->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason); currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection(); currentScene->clearSelection();
break; break;
case Tools::ArcTool: case Tool::ArcTool:
dialogArc.clear(); dialogArc.clear();
ui->toolButtonArc->setChecked(false); ui->toolButtonArc->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason); currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection(); currentScene->clearSelection();
break; break;
case Tools::SplinePathTool: case Tool::SplinePathTool:
dialogSplinePath.clear(); dialogSplinePath.clear();
ui->toolButtonSplinePath->setChecked(false); ui->toolButtonSplinePath->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason); currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection(); currentScene->clearSelection();
break; break;
case Tools::PointOfContact: case Tool::PointOfContact:
dialogPointOfContact.clear(); dialogPointOfContact.clear();
ui->toolButtonPointOfContact->setChecked(false); ui->toolButtonPointOfContact->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason); currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection(); currentScene->clearSelection();
break; break;
case Tools::Detail: case Tool::Detail:
dialogDetail.clear(); dialogDetail.clear();
ui->toolButtonNewDetail->setChecked(false); ui->toolButtonNewDetail->setChecked(false);
break; break;
@ -660,7 +660,7 @@ void MainWindow::CanselTool(){
void MainWindow::ArrowTool(){ void MainWindow::ArrowTool(){
CanselTool(); CanselTool();
ui->actionArrowTool->setChecked(true); ui->actionArrowTool->setChecked(true);
tool = Tools::ArrowTool; tool = Tool::ArrowTool;
QCursor cur(Qt::ArrowCursor); QCursor cur(Qt::ArrowCursor);
view->setCursor(cur); view->setCursor(cur);
helpLabel->setText(""); helpLabel->setText("");
@ -729,7 +729,7 @@ void MainWindow::ActionSaveAs(){
QString filters("Lekalo files (*.xml);;All files (*.*)"); QString filters("Lekalo files (*.xml);;All files (*.*)");
QString defaultFilter("Lekalo files (*.xml)"); QString defaultFilter("Lekalo files (*.xml)");
QString fName = QFileDialog::getSaveFileName(this, "Зберегти файл як", QDir::homePath(), QString fName = QFileDialog::getSaveFileName(this, "Зберегти файл як", QDir::homePath(),
filters, &defaultFilter); filters, &defaultFilter);
if(fName.isEmpty()) if(fName.isEmpty())
return; return;
if(fName.indexOf(".xml",fName.size()-4)<0){ if(fName.indexOf(".xml",fName.size()-4)<0){

View File

@ -35,8 +35,6 @@
#include "tools/drawTools/drawtools.h" #include "tools/drawTools/drawtools.h"
#include "tools/modelingTools/modelingtools.h" #include "tools/modelingTools/modelingtools.h"
#include "xml/vdomdocument.h" #include "xml/vdomdocument.h"
#include "container/vcontainer.h"
#include "options.h"
#include "tools/vtooldetail.h" #include "tools/vtooldetail.h"
namespace Ui { namespace Ui {
@ -111,8 +109,9 @@ protected:
virtual void closeEvent( QCloseEvent * event ); virtual void closeEvent( QCloseEvent * event );
void Clear(); void Clear();
private: private:
Q_DISABLE_COPY(MainWindow)
Ui::MainWindow *ui; Ui::MainWindow *ui;
Tools::Enum tool; Tool::Tools tool;
VMainGraphicsScene *currentScene; VMainGraphicsScene *currentScene;
VMainGraphicsScene *sceneDraw; VMainGraphicsScene *sceneDraw;
VMainGraphicsScene *sceneDetails; VMainGraphicsScene *sceneDetails;
@ -139,9 +138,7 @@ private:
QComboBox *comboBoxDraws; QComboBox *comboBoxDraws;
QString fileName; QString fileName;
bool changeInFile; bool changeInFile;
Draw::Mode mode; Draw::Draws mode;
MainWindow(const MainWindow &window);
const MainWindow &operator=(const MainWindow &window);
void ToolBarOption(); void ToolBarOption();
void ToolBarDraws(); void ToolBarDraws();
void CanselTool(); void CanselTool();
@ -149,12 +146,12 @@ private:
void SetEnableWidgets(bool enable); void SetEnableWidgets(bool enable);
void SetEnableTool(bool enable); void SetEnableTool(bool enable);
template <typename Dialog, typename Func> template <typename Dialog, typename Func>
void SetToolButton(bool checked, Tools::Enum t, const QString &cursor, void SetToolButton(bool checked, Tool::Tools t, const QString &cursor,
QSharedPointer<Dialog> &dialog, QSharedPointer<Dialog> &dialog,
Func closeDialogSlot); Func closeDialogSlot);
void MinimumScrollBar(); void MinimumScrollBar();
template <typename Tool> template <typename T>
void AddToolToDetail(Tool *tool, const qint64 &id, Tools::Enum typeTool, void AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool,
const qint64 &idDetail); const qint64 &idDetail);
}; };

View File

@ -22,7 +22,7 @@
#ifndef OPTIONS_H #ifndef OPTIONS_H
#define OPTIONS_H #define OPTIONS_H
#include <QtGlobal> #include <QFlags>
#define PrintDPI 96 #define PrintDPI 96
#define PaperSize 50000 #define PaperSize 50000
@ -31,49 +31,44 @@
#define widthMainLine toPixel(0.8) #define widthMainLine toPixel(0.8)
#define widthHairLine widthMainLine/3 #define widthHairLine widthMainLine/3
namespace Scene{ namespace Scene{
enum Type enum Scene { Point, Line, Spline, Arc, SplinePath, Detail };
{ Q_DECLARE_FLAGS(Scenes, Scene)
Point,
Line,
Spline,
Arc,
SplinePath,
Detail
};
} }
Q_DECLARE_OPERATORS_FOR_FLAGS( Scene::Scenes )
namespace Tools{ namespace Tool{
enum Enum enum Tool {ArrowTool,
{ SinglePointTool,
ArrowTool, EndLineTool,
SinglePointTool, LineTool,
EndLineTool, AlongLineTool,
LineTool, ShoulderPointTool,
AlongLineTool, NormalTool,
ShoulderPointTool, BisectorTool,
NormalTool, LineIntersectTool,
BisectorTool, SplineTool,
LineIntersectTool, ArcTool,
SplineTool, SplinePathTool,
ArcTool, PointOfContact,
SplinePathTool, Detail,
PointOfContact, NodePoint,
Detail, NodeArc,
NodePoint, NodeSpline,
NodeArc, NodeSplinePath
NodeSpline, };
NodeSplinePath Q_DECLARE_FLAGS(Tools, Tool)
};
}
namespace Draw{ enum Source { FromGui, FromFile };
enum Mode Q_DECLARE_FLAGS(Sources, Source)
{
Calculation,
Modeling
};
} }
Q_DECLARE_OPERATORS_FOR_FLAGS( Tool::Tools )
Q_DECLARE_OPERATORS_FOR_FLAGS( Tool::Sources )
namespace Draw {
enum Draw { Calculation, Modeling };
Q_DECLARE_FLAGS(Draws, Draw)
}
Q_DECLARE_OPERATORS_FOR_FLAGS(Draw::Draws)
#endif // OPTIONS_H #endif // OPTIONS_H

View File

@ -27,8 +27,6 @@
#include <QFileDialog> #include <QFileDialog>
#include "options.h" #include "options.h"
#include <QtSvg/QtSvg> #include <QtSvg/QtSvg>
#undef PaperSize
#include <QtPrintSupport/QPrinter>
TableWindow::TableWindow(QWidget *parent) : TableWindow::TableWindow(QWidget *parent) :
QMainWindow(parent), numberDetal(0), colission(0), ui(new Ui::TableWindow), QMainWindow(parent), numberDetal(0), colission(0), ui(new Ui::TableWindow),
@ -143,7 +141,7 @@ void TableWindow::StopTable(){
} }
void TableWindow::saveScene(){ void TableWindow::saveScene(){
QString name = QFileDialog::getSaveFileName(0, "Зберегти розкладку", "", "Images (*.png);;Svg files (*.svg);;Ps files (*.ps)"); QString name = QFileDialog::getSaveFileName(0, "Зберегти розкладку", "", "Images (*.png);;Svg files (*.svg)");
if(name.isNull()){ if(name.isNull()){
return; return;
} }
@ -164,8 +162,6 @@ void TableWindow::saveScene(){
SvgFile(name); SvgFile(name);
} else if(fi.suffix() == "png"){ } else if(fi.suffix() == "png"){
PngFile(name); PngFile(name);
} else if(fi.suffix() == "ps"){
PsFile(name);
} }
// if(name.indexOf(".svg",name.size()-4)<0){ // if(name.indexOf(".svg",name.size()-4)<0){
// name.append(".svg"); // name.append(".svg");
@ -348,28 +344,3 @@ void TableWindow::PngFile(const QString &name) const{
currentScene->render(&painter); currentScene->render(&painter);
image.save(name); image.save(name);
} }
void TableWindow::PsFile(const QString &name) const{
QPrinter printer(QPrinter::HighResolution);
//printer.setOutputFormat(QPrinter::PostScriptFormat);
printer.setOutputFileName(name);
QRectF r = paper->rect();
qreal x=0, y=0, w=0, h=0;
r.getRect(&x,&y,&w,&h);
printer.setResolution(PrintDPI);
qDebug()<<printer.resolution();
printer.setPaperSize ( QSizeF(w/printer.resolution()*25.4, h/printer.resolution()*25.4), QPrinter::Millimeter );
QPainter painter;
if (! painter.begin( &printer )) { // failed to open file
qCritical("Не можу відкрити файл %s",qPrintable(name));
return;
}
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, widthMainLine, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
currentScene->render(&painter);
painter.end();
}

View File

@ -125,6 +125,7 @@ protected:
void showEvent ( QShowEvent * event ); void showEvent ( QShowEvent * event );
void keyPressEvent ( QKeyEvent * event ); void keyPressEvent ( QKeyEvent * event );
private: private:
Q_DISABLE_COPY(TableWindow)
/** /**
* @brief ui Змінна для доступу до об'єктів вікна. * @brief ui Змінна для доступу до об'єктів вікна.
*/ */
@ -181,8 +182,6 @@ private:
* @brief sceneRect Мінімальний розмір листа паперу що буде показуватися на сцені. * @brief sceneRect Мінімальний розмір листа паперу що буде показуватися на сцені.
*/ */
QRectF sceneRect; QRectF sceneRect;
TableWindow(const TableWindow &window);
const TableWindow &operator=(const TableWindow& window);
void SvgFile(const QString &name)const; void SvgFile(const QString &name)const;
void PngFile(const QString &name)const; void PngFile(const QString &name)const;
void PsFile(const QString &name)const; void PsFile(const QString &name)const;

View File

@ -36,7 +36,7 @@ VDrawTool::~VDrawTool(){
void VDrawTool::setDialog(){ void VDrawTool::setDialog(){
} }
void VDrawTool::AddRecord(const qint64 id, Tools::Enum toolType, VDomDocument *doc){ void VDrawTool::AddRecord(const qint64 id, Tool::Tools toolType, VDomDocument *doc){
qint64 cursor = doc->getCursor(); qint64 cursor = doc->getCursor();
QVector<VToolRecord> *history = doc->getHistory(); QVector<VToolRecord> *history = doc->getHistory();
if(cursor <= 0){ if(cursor <= 0){

View File

@ -25,14 +25,13 @@
#include "../vabstracttool.h" #include "../vabstracttool.h"
#include <QMenu> #include <QMenu>
class VDrawTool : public VAbstractTool class VDrawTool : public VAbstractTool{
{
Q_OBJECT Q_OBJECT
public: public:
VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0); VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0);
virtual ~VDrawTool(); virtual ~VDrawTool();
virtual void setDialog(); virtual void setDialog();
static void AddRecord(const qint64 id, Tools::Enum toolType, VDomDocument *doc); static void AddRecord(const qint64 id, Tool::Tools toolType, VDomDocument *doc);
void ignoreContextMenu(bool enable); void ignoreContextMenu(bool enable);
public slots: public slots:
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
@ -51,12 +50,14 @@ protected:
if(!ignoreContextMenuEvent){ if(!ignoreContextMenuEvent){
QMenu menu; QMenu menu;
QAction *actionOption = menu.addAction(tr("Options")); QAction *actionOption = menu.addAction(tr("Options"));
QAction *actionRemove; QAction *actionRemove = 0;
if(showRemove){ if(showRemove){
actionRemove = menu.addAction(tr("Delete")); actionRemove = menu.addAction(tr("Delete"));
} else { if(_referens > 1){
actionRemove = menu.addAction(tr("Delete")); actionRemove->setEnabled(false);
actionRemove->setEnabled(false); } else {
actionRemove->setEnabled(true);
}
} }
QAction *selectedAction = menu.exec(event->screenPos()); QAction *selectedAction = menu.exec(event->screenPos());
if(selectedAction == actionOption){ if(selectedAction == actionOption){
@ -73,6 +74,8 @@ protected:
dialog->show(); dialog->show();
} }
if(selectedAction == actionRemove){ if(selectedAction == actionRemove){
//deincrement referens
RemoveReferens();
//remove form xml file //remove form xml file
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if(domElement.isElement()){

View File

@ -21,13 +21,12 @@
#include "vtoolalongline.h" #include "vtoolalongline.h"
#include <QDialog> #include <QDialog>
#include <QMenu>
#include <QDebug> #include <QDebug>
#include "container/calculator.h" #include "container/calculator.h"
VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula, VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,
const qint64 &firstPointId, const qint64 &secondPointId, const qint64 &firstPointId, const qint64 &secondPointId,
const QString &typeLine, Tool::Enum typeCreation, const QString &typeLine, Tool::Sources typeCreation,
QGraphicsItem *parent): QGraphicsItem *parent):
VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId), VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId),
dialogAlongLine(QSharedPointer<DialogAlongLine>()){ dialogAlongLine(QSharedPointer<DialogAlongLine>()){
@ -65,12 +64,7 @@ void VToolAlongLine::FullUpdateFromGui(int result){
} }
void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogAlongLine, this, event);
if(point.referens() > 1){
ContextMenu(dialogAlongLine, this, event, false);
} else {
ContextMenu(dialogAlongLine, this, event);
}
} }
void VToolAlongLine::AddToFile(){ void VToolAlongLine::AddToFile(){
@ -91,6 +85,11 @@ void VToolAlongLine::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolAlongLine::RemoveReferens(){
doc->DecrementReferens(secondPointId);
VToolLinePoint::RemoveReferens();
}
void VToolAlongLine::setDialog(){ void VToolAlongLine::setDialog(){
Q_ASSERT(!dialogAlongLine.isNull()); Q_ASSERT(!dialogAlongLine.isNull());
if(!dialogAlongLine.isNull()){ if(!dialogAlongLine.isNull()){
@ -117,7 +116,7 @@ void VToolAlongLine::Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphi
void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine, void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){ VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){
VPointF firstPoint = data->GetPoint(firstPointId); VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId); VPointF secondPoint = data->GetPoint(secondPointId);
QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()); QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF());
@ -132,15 +131,10 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS
} else { } else {
data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point);
}
} }
} }
VDrawTool::AddRecord(id, Tools::AlongLineTool, doc); VDrawTool::AddRecord(id, Tool::AlongLineTool, doc);
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
data->AddLine(id, secondPointId); data->AddLine(id, secondPointId);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
@ -149,9 +143,9 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS
scene->addItem(point); scene->addItem(point);
connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolAlongLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolAlongLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
} }
} }
} }

View File

@ -31,21 +31,21 @@ class VToolAlongLine : public VToolLinePoint
public: public:
VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula, VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,
const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine, const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine,
Tool::Enum typeCreation, QGraphicsItem * parent = 0); Tool::Sources typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, static void Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data); VContainer *data);
static void Create(const qint64 _id, const QString &pointName, const QString &typeLine, static void Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId, const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation); VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 secondPointId; qint64 secondPointId;
QSharedPointer<DialogAlongLine> dialogAlongLine; QSharedPointer<DialogAlongLine> dialogAlongLine;

View File

@ -20,10 +20,9 @@
****************************************************************************/ ****************************************************************************/
#include "vtoolarc.h" #include "vtoolarc.h"
#include <QMenu>
#include "container/calculator.h" #include "container/calculator.h"
VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation, VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation,
QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsPathItem(parent), QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsPathItem(parent),
dialogArc(QSharedPointer<DialogArc>()){ dialogArc(QSharedPointer<DialogArc>()){
VArc arc = data->GetArc(id); VArc arc = data->GetArc(id);
@ -62,7 +61,7 @@ void VToolArc::Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *sce
void VToolArc::Create(const qint64 _id, const qint64 &center, const QString &radius, const QString &f1, void VToolArc::Create(const qint64 _id, const qint64 &center, const QString &radius, const QString &f1,
const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc, const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){ VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
Calculator cal(data); Calculator cal(data);
@ -91,23 +90,18 @@ void VToolArc::Create(const qint64 _id, const qint64 &center, const QString &rad
} else { } else {
data->UpdateArc(id, arc); data->UpdateArc(id, arc);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Arc);
}
} }
} }
data->AddLengthArc(data->GetNameArc(center,id), arc.GetLength()); data->AddLengthArc(data->GetNameArc(center,id), arc.GetLength());
VDrawTool::AddRecord(id, Tools::ArcTool, doc); VDrawTool::AddRecord(id, Tool::ArcTool, doc);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation); VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
scene->addItem(toolArc); scene->addItem(toolArc);
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(toolArc, &VToolArc::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(toolArc, &VToolArc::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, toolArc);
tools->insert(id,toolArc); doc->IncrementReferens(center);
} }
} }
@ -156,12 +150,7 @@ void VToolArc::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){
} }
void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VArc arc = VDrawTool::data.GetArc(id); ContextMenu(dialogArc, this, event);
if(arc.referens() > 1){
ContextMenu(dialogArc, this, event, false);
} else {
ContextMenu(dialogArc, this, event);
}
} }
void VToolArc::AddToFile(){ void VToolArc::AddToFile(){
@ -195,6 +184,11 @@ void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VToolArc::RemoveReferens(){
VArc arc = VAbstractTool::data.GetArc(id);
doc->DecrementReferens(arc.GetCenter());
}
void VToolArc::RefreshGeometry(){ void VToolArc::RefreshGeometry(){
VArc arc = VAbstractTool::data.GetArc(id); VArc arc = VAbstractTool::data.GetArc(id);
QPainterPath path; QPainterPath path;

View File

@ -23,24 +23,23 @@
#define VTOOLARC_H #define VTOOLARC_H
#include "vdrawtool.h" #include "vdrawtool.h"
#include "xml/vdomdocument.h"
#include <QGraphicsPathItem> #include <QGraphicsPathItem>
#include "dialogs/dialogarc.h" #include "dialogs/dialogarc.h"
#include "widgets/vcontrolpointspline.h" #include "widgets/vcontrolpointspline.h"
#include "container/vcontainer.h"
class VToolArc :public VDrawTool, public QGraphicsPathItem class VToolArc :public VDrawTool, public QGraphicsPathItem{
{
Q_OBJECT Q_OBJECT
public: public:
VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation, VToolArc(VDomDocument *doc, VContainer *data, qint64 id,
QGraphicsItem * parent = 0); Tool::Sources typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, static void Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc,
VContainer *data); VContainer *data);
static void Create(const qint64 _id, const qint64 &center, const QString &radius, static void Create(const qint64 _id, const qint64 &center, const QString &radius,
const QString &f1, const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc, const QString &f1, const QString &f2, VMainGraphicsScene *scene,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation); VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
@ -52,6 +51,7 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
private: private:
QSharedPointer<DialogArc> dialogArc; QSharedPointer<DialogArc> dialogArc;
void RefreshGeometry(); void RefreshGeometry();

View File

@ -20,11 +20,10 @@
****************************************************************************/ ****************************************************************************/
#include "vtoolbisector.h" #include "vtoolbisector.h"
#include <QMenu>
VToolBisector::VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, VToolBisector::VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &firstPointId, const QString &typeLine, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Enum typeCreation, const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Sources typeCreation,
QGraphicsItem *parent): QGraphicsItem *parent):
VToolLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(0), VToolLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(0),
thirdPointId(0), dialogBisector(QSharedPointer<DialogBisector>()){ thirdPointId(0), dialogBisector(QSharedPointer<DialogBisector>()){
@ -78,7 +77,7 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine, const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my, const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
Document::Enum parse, Tool::Enum typeCreation){ const Document::Documents &parse, Tool::Sources typeCreation){
VPointF firstPoint = data->GetPoint(firstPointId); VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId); VPointF secondPoint = data->GetPoint(secondPointId);
VPointF thirdPoint = data->GetPoint(thirdPointId); VPointF thirdPoint = data->GetPoint(thirdPointId);
@ -95,16 +94,11 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
} else { } else {
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point);
}
} }
} }
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
VDrawTool::AddRecord(id, Tools::BisectorTool, doc); VDrawTool::AddRecord(id, Tool::BisectorTool, doc);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula,
firstPointId, secondPointId, thirdPointId, firstPointId, secondPointId, thirdPointId,
@ -112,8 +106,10 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
scene->addItem(point); scene->addItem(point);
connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
doc->IncrementReferens(thirdPointId);
} }
} }
} }
@ -147,12 +143,7 @@ void VToolBisector::FullUpdateFromGui(int result){
} }
void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogBisector, this, event);
if(point.referens() > 1){
ContextMenu(dialogBisector, this, event, false);
} else {
ContextMenu(dialogBisector, this, event);
}
} }
void VToolBisector::AddToFile(){ void VToolBisector::AddToFile(){
@ -173,3 +164,9 @@ void VToolBisector::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolBisector::RemoveReferens(){
doc->DecrementReferens(firstPointId);
doc->DecrementReferens(thirdPointId);
VToolLinePoint::RemoveReferens();
}

View File

@ -22,16 +22,14 @@
#ifndef VTOOLBISECTOR_H #ifndef VTOOLBISECTOR_H
#define VTOOLBISECTOR_H #define VTOOLBISECTOR_H
#include <QSharedPointer>
#include "vtoollinepoint.h" #include "vtoollinepoint.h"
#include "dialogs/dialogbisector.h" #include "dialogs/dialogbisector.h"
class VToolBisector : public VToolLinePoint class VToolBisector : public VToolLinePoint{
{
public: public:
VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &firstPointId, const QString &typeLine, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Enum typeCreation, const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Sources typeCreation,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
const QPointF &thirdPoint, const qreal& length); const QPointF &thirdPoint, const qreal& length);
@ -41,13 +39,15 @@ public:
static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine, const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data, Document::Enum parse, Tool::Enum typeCreation); VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 firstPointId; qint64 firstPointId;
qint64 thirdPointId; qint64 thirdPointId;

View File

@ -26,7 +26,7 @@
VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &basePointId, const QString &formula, const qreal &angle, const qint64 &basePointId,
Tool::Enum typeCreation, QGraphicsItem *parent): Tool::Sources typeCreation, QGraphicsItem *parent):
VToolLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent), VToolLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent),
dialogEndLine(QSharedPointer<DialogEndLine>()){ dialogEndLine(QSharedPointer<DialogEndLine>()){
@ -61,7 +61,7 @@ void VToolEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsSc
void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine, void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &basePointId, const QString &formula, const qreal &angle, const qint64 &basePointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){ VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){
VPointF basePoint = data->GetPoint(basePointId); VPointF basePoint = data->GetPoint(basePointId);
QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y())); QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y()));
@ -77,24 +77,19 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
} else { } else {
data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
Q_CHECK_PTR(tool);
data->IncrementReferens(id, Scene::Point);
tool->VDataTool::setData(data);
} }
} }
data->AddLine(basePointId, id); data->AddLine(basePointId, id);
VDrawTool::AddRecord(id, Tools::EndLineTool, doc); VDrawTool::AddRecord(id, Tool::EndLineTool, doc);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formula, angle, VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formula, angle,
basePointId, typeCreation); basePointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
Q_CHECK_PTR(tools); doc->IncrementReferens(basePointId);
tools->insert(id,point);
} }
} }
} }
@ -111,12 +106,7 @@ void VToolEndLine::FullUpdateFromFile(){
} }
void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogEndLine, this, event);
if(point.referens() > 1){
ContextMenu(dialogEndLine, this, event, false);
} else {
ContextMenu(dialogEndLine, this, event);
}
} }
void VToolEndLine::FullUpdateFromGui(int result){ void VToolEndLine::FullUpdateFromGui(int result){

View File

@ -22,25 +22,23 @@
#ifndef VTOOLENDLINE_H #ifndef VTOOLENDLINE_H
#define VTOOLENDLINE_H #define VTOOLENDLINE_H
#include <QSharedPointer>
#include "vtoollinepoint.h" #include "vtoollinepoint.h"
#include "dialogs/dialogendline.h" #include "dialogs/dialogendline.h"
class VToolEndLine : public VToolLinePoint class VToolEndLine : public VToolLinePoint{
{
Q_OBJECT Q_OBJECT
public: public:
VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qreal &angle, const QString &typeLine, const QString &formula, const qreal &angle,
const qint64 &basePointId, Tool::Enum typeCreation, const qint64 &basePointId, Tool::Sources typeCreation,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, static void Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data); VContainer *data);
static void Create(const qint64 _id, const QString &pointName, const QString &typeLine, static void 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, const QString &formula, const qreal &angle, const qint64 &basePointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
Tool::Enum typeCreation); const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);

View File

@ -20,11 +20,10 @@
****************************************************************************/ ****************************************************************************/
#include "vtoolline.h" #include "vtoolline.h"
#include <QMenu>
#include <QDebug> #include <QDebug>
VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint, VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint,
Tool::Enum typeCreation, QGraphicsItem *parent):VDrawTool(doc, data, id), Tool::Sources typeCreation, QGraphicsItem *parent):VDrawTool(doc, data, id),
QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint),
dialogLine(QSharedPointer<DialogLine>()){ dialogLine(QSharedPointer<DialogLine>()){
//Лінія //Лінія
@ -53,20 +52,16 @@ void VToolLine::Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *s
} }
void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint, void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
Tool::Enum typeCreation){ const Document::Documents &parse, Tool::Sources typeCreation){
Q_CHECK_PTR(scene); Q_CHECK_PTR(scene);
Q_CHECK_PTR(doc); Q_CHECK_PTR(doc);
Q_CHECK_PTR(data); Q_CHECK_PTR(data);
data->AddLine(firstPoint, secondPoint); data->AddLine(firstPoint, secondPoint);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
Q_CHECK_PTR(tools);
VDataTool *tool = tools->value(id);
Q_CHECK_PTR(tool);
tool->VDataTool::setData(data);
} }
VDrawTool::AddRecord(id, Tools::LineTool, doc); VDrawTool::AddRecord(id, Tool::LineTool, doc);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
qint64 id = data->getNextId(); qint64 id = data->getNextId();
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeCreation); VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeCreation);
@ -74,8 +69,9 @@ void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64
scene->addItem(line); scene->addItem(line);
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(line, &VToolLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(line, &VToolLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, line);
tools->insert(id,line); doc->IncrementReferens(firstPoint);
doc->IncrementReferens(secondPoint);
} }
} }
@ -150,3 +146,8 @@ void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VToolLine::RemoveReferens(){
doc->DecrementReferens(firstPoint);
doc->DecrementReferens(secondPoint);
}

View File

@ -26,18 +26,17 @@
#include "QGraphicsLineItem" #include "QGraphicsLineItem"
#include "dialogs/dialogline.h" #include "dialogs/dialogline.h"
class VToolLine: public VDrawTool, public QGraphicsLineItem class VToolLine: public VDrawTool, public QGraphicsLineItem{
{
Q_OBJECT Q_OBJECT
public: public:
VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
qint64 secondPoint, Tool::Enum typeCreation, QGraphicsItem * parent = 0); qint64 secondPoint, Tool::Sources typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, static void Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data); VContainer *data);
static void Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint, static void Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
Tool::Enum typeCreation); const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void ChangedActivDraw(const QString newName); virtual void ChangedActivDraw(const QString newName);
@ -48,6 +47,7 @@ protected:
virtual void AddToFile(); virtual void AddToFile();
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
private: private:
qint64 firstPoint; qint64 firstPoint;
qint64 secondPoint; qint64 secondPoint;

View File

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

View File

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

View File

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

View File

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

View File

@ -20,12 +20,11 @@
****************************************************************************/ ****************************************************************************/
#include "vtoolnormal.h" #include "vtoolnormal.h"
#include <QMenu>
VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &firstPointId, const QString &formula, const qreal &angle, const qint64 &firstPointId,
const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem *parent): const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem *parent):
VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent), VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent),
secondPointId(secondPointId), dialogNormal(QSharedPointer<DialogNormal>()){ secondPointId(secondPointId), dialogNormal(QSharedPointer<DialogNormal>()){
@ -63,7 +62,7 @@ void VToolNormal::Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScen
void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const QString typeLine, const QString pointName, const qint64 &secondPointId, const QString typeLine, const QString pointName,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data, Document::Enum parse, Tool::Enum typeCreation){ VDomDocument *doc, VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){
VPointF firstPoint = data->GetPoint(firstPointId); VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId); VPointF secondPoint = data->GetPoint(secondPointId);
Calculator cal(data); Calculator cal(data);
@ -78,24 +77,20 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64
} else { } else {
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point);
}
} }
} }
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
VDrawTool::AddRecord(id, Tools::NormalTool, doc); VDrawTool::AddRecord(id, Tool::NormalTool, doc);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle, VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle,
firstPointId, secondPointId, typeCreation); firstPointId, secondPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolNormal::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolNormal::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
} }
} }
} }
@ -138,12 +133,7 @@ void VToolNormal::FullUpdateFromGui(int result){
} }
void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogNormal, this, event);
if(point.referens() > 1){
ContextMenu(dialogNormal, this, event, false);
} else {
ContextMenu(dialogNormal, this, event);
}
} }
void VToolNormal::AddToFile(){ void VToolNormal::AddToFile(){
@ -164,3 +154,8 @@ void VToolNormal::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolNormal::RemoveReferens(){
doc->DecrementReferens(secondPointId);
VToolLinePoint::RemoveReferens();
}

View File

@ -22,7 +22,6 @@
#ifndef VTOOLNORMAL_H #ifndef VTOOLNORMAL_H
#define VTOOLNORMAL_H #define VTOOLNORMAL_H
#include <QSharedPointer>
#include "vtoollinepoint.h" #include "vtoollinepoint.h"
#include "dialogs/dialognormal.h" #include "dialogs/dialognormal.h"
@ -33,7 +32,7 @@ public:
VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const QString &typeLine, const QString &formula,
const qreal &angle, const qint64 &firstPointId, const qreal &angle, const qint64 &firstPointId,
const qint64 &secondPointId, Tool::Enum typeCreation, const qint64 &secondPointId, Tool::Sources typeCreation,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, static void Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
@ -41,7 +40,7 @@ public:
static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const QString typeLine, const QString pointName, const qint64 &secondPointId, const QString typeLine, const QString pointName,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data, Document::Enum parse, Tool::Enum typeCreation); VDomDocument *doc, VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation);
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
const qreal &length, const qreal &angle = 0); const qreal &length, const qreal &angle = 0);
public slots: public slots:
@ -50,6 +49,7 @@ public slots:
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 secondPointId; qint64 secondPointId;
QSharedPointer<DialogNormal> dialogNormal; QSharedPointer<DialogNormal> dialogNormal;

View File

@ -24,7 +24,6 @@
#include <QBrush> #include <QBrush>
#include <QDebug> #include <QDebug>
#include <QGraphicsItem> #include <QGraphicsItem>
#include "container/vpointf.h"
VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id,

View File

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

View File

@ -24,7 +24,7 @@
VToolPointOfContact::VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, VToolPointOfContact::VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &radius, const qint64 &center, const QString &radius, const qint64 &center,
const qint64 &firstPointId, const qint64 &secondPointId, const qint64 &firstPointId, const qint64 &secondPointId,
Tool::Enum typeCreation, QGraphicsItem *parent) Tool::Sources typeCreation, QGraphicsItem *parent)
: VToolPoint(doc, data, id, parent), radius(radius), center(center), firstPointId(firstPointId), : VToolPoint(doc, data, id, parent), radius(radius), center(center), firstPointId(firstPointId),
secondPointId(secondPointId), dialogPointOfContact(QSharedPointer<DialogPointOfContact>()){ secondPointId(secondPointId), dialogPointOfContact(QSharedPointer<DialogPointOfContact>()){
@ -82,7 +82,7 @@ void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const
const qint64 &firstPointId, const qint64 &secondPointId, const qint64 &firstPointId, const qint64 &secondPointId,
const QString &pointName, const qreal &mx, const qreal &my, const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
Document::Enum parse, Tool::Enum typeCreation){ const Document::Documents &parse, Tool::Sources typeCreation){
VPointF centerP = data->GetPoint(center); VPointF centerP = data->GetPoint(center);
VPointF firstP = data->GetPoint(firstPointId); VPointF firstP = data->GetPoint(firstPointId);
VPointF secondP = data->GetPoint(secondPointId); VPointF secondP = data->GetPoint(secondPointId);
@ -99,23 +99,20 @@ void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const
} else { } else {
data->UpdatePoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdatePoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point);
}
} }
} }
VDrawTool::AddRecord(id, Tools::PointOfContact, doc); VDrawTool::AddRecord(id, Tool::PointOfContact, doc);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center, VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center,
firstPointId, secondPointId, typeCreation); firstPointId, secondPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(center);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
} }
} }
} }
@ -147,12 +144,7 @@ void VToolPointOfContact::FullUpdateFromGui(int result){
} }
void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogPointOfContact, this, event);
if(point.referens() > 1){
ContextMenu(dialogPointOfContact, this, event, false);
} else {
ContextMenu(dialogPointOfContact, this, event);
}
} }
void VToolPointOfContact::AddToFile(){ void VToolPointOfContact::AddToFile(){
@ -172,3 +164,9 @@ void VToolPointOfContact::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolPointOfContact::RemoveReferens(){
doc->DecrementReferens(center);
doc->DecrementReferens(firstPointId);
doc->DecrementReferens(secondPointId);
}

View File

@ -30,7 +30,7 @@ class VToolPointOfContact : public VToolPoint
public: public:
VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &radius, const qint64 &center, const qint64 &firstPointId, const QString &radius, const qint64 &center, const qint64 &firstPointId,
const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem * parent = 0); const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static QPointF FindPoint(const qreal &radius, const QPointF &center, const QPointF &firstPoint, static QPointF FindPoint(const qreal &radius, const QPointF &center, const QPointF &firstPoint,
const QPointF &secondPoint); const QPointF &secondPoint);
@ -39,13 +39,14 @@ public:
static void Create(const qint64 _id, const QString &radius, const qint64 &center, const qint64 &firstPointId, static void Create(const qint64 _id, const QString &radius, const qint64 &center, const qint64 &firstPointId,
const qint64 &secondPointId, const QString &pointName, const qint64 &secondPointId, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation); VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
QString radius; QString radius;
qint64 center; qint64 center;

View File

@ -21,11 +21,10 @@
#include "vtoolshoulderpoint.h" #include "vtoolshoulderpoint.h"
#include <QDebug> #include <QDebug>
#include <QMenu>
VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &p1Line, const QString &typeLine, const QString &formula, const qint64 &p1Line,
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation, const qint64 &p2Line, const qint64 &pShoulder, Tool::Sources typeCreation,
QGraphicsItem * parent): QGraphicsItem * parent):
VToolLinePoint(doc, data, id, typeLine, formula, p1Line, 0, parent), p2Line(p2Line), pShoulder(pShoulder), VToolLinePoint(doc, data, id, typeLine, formula, p1Line, 0, parent), p2Line(p2Line), pShoulder(pShoulder),
dialogShoulderPoint(QSharedPointer<DialogShoulderPoint>()){ dialogShoulderPoint(QSharedPointer<DialogShoulderPoint>()){
@ -86,7 +85,7 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
const qint64 &p2Line, const qint64 &pShoulder, const QString &typeLine, const qint64 &p2Line, const qint64 &pShoulder, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my, const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
Document::Enum parse, Tool::Enum typeCreation){ const Document::Documents &parse, Tool::Sources typeCreation){
VPointF firstPoint = data->GetPoint(p1Line); VPointF firstPoint = data->GetPoint(p1Line);
VPointF secondPoint = data->GetPoint(p2Line); VPointF secondPoint = data->GetPoint(p2Line);
VPointF shoulderPoint = data->GetPoint(pShoulder); VPointF shoulderPoint = data->GetPoint(pShoulder);
@ -103,17 +102,12 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
} else { } else {
data->UpdatePoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdatePoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point);
}
} }
} }
data->AddLine(p1Line, id); data->AddLine(p1Line, id);
data->AddLine(p2Line, id); data->AddLine(p2Line, id);
VDrawTool::AddRecord(id, Tools::ShoulderPointTool, doc); VDrawTool::AddRecord(id, Tool::ShoulderPointTool, doc);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, formula, VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, formula,
p1Line, p2Line, pShoulder, p1Line, p2Line, pShoulder,
@ -121,8 +115,10 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
scene->addItem(point); scene->addItem(point);
connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolShoulderPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolShoulderPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(p1Line);
doc->IncrementReferens(p2Line);
doc->IncrementReferens(pShoulder);
} }
} }
} }
@ -156,12 +152,7 @@ void VToolShoulderPoint::FullUpdateFromGui(int result){
} }
void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VPointF point = VDrawTool::data.GetPoint(id); ContextMenu(dialogShoulderPoint, this, event);
if(point.referens() > 1){
ContextMenu(dialogShoulderPoint, this, event, false);
} else {
ContextMenu(dialogShoulderPoint, this, event);
}
} }
void VToolShoulderPoint::AddToFile(){ void VToolShoulderPoint::AddToFile(){
@ -182,3 +173,9 @@ void VToolShoulderPoint::AddToFile(){
AddToCalculation(domElement); AddToCalculation(domElement);
} }
void VToolShoulderPoint::RemoveReferens(){
doc->DecrementReferens(p2Line);
doc->DecrementReferens(pShoulder);
VToolLinePoint::RemoveReferens();
}

View File

@ -30,7 +30,7 @@ class VToolShoulderPoint : public VToolLinePoint
public: public:
VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &p1Line, const QString &typeLine, const QString &formula, const qint64 &p1Line,
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation, const qint64 &p2Line, const qint64 &pShoulder, Tool::Sources typeCreation,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
@ -40,13 +40,14 @@ public:
static void Create(const qint64 _id, const QString &formula, const qint64 &p1Line, const qint64 &p2Line, static void Create(const qint64 _id, const QString &formula, const qint64 &p1Line, const qint64 &p2Line,
const qint64 &pShoulder, const QString &typeLine, const QString &pointName, const qint64 &pShoulder, const QString &typeLine, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation); VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
virtual void RemoveReferens();
private: private:
qint64 p2Line; qint64 p2Line;
qint64 pShoulder; qint64 pShoulder;

View File

@ -24,13 +24,9 @@
#include <QBrush> #include <QBrush>
#include <QDebug> #include <QDebug>
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QMenu>
#include <QGraphicsSceneContextMenuEvent> #include <QGraphicsSceneContextMenuEvent>
#include <cmath>
#include "options.h"
#include "container/vpointf.h"
VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation, VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation,
QGraphicsItem * parent ):VToolPoint(doc, data, id, parent), QGraphicsItem * parent ):VToolPoint(doc, data, id, parent),
dialogSinglePoint(QSharedPointer<DialogSinglePoint>()){ dialogSinglePoint(QSharedPointer<DialogSinglePoint>()){
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
@ -89,6 +85,12 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change,
return QGraphicsItem::itemChange(change, value); return QGraphicsItem::itemChange(change, value);
} }
void VToolSinglePoint::decrementReferens(){
if(_referens > 1){
--_referens;
}
}
void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ){ void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ){
ContextMenu(dialogSinglePoint, this, event, false); ContextMenu(dialogSinglePoint, this, event, false);
} }

View File

@ -22,8 +22,6 @@
#ifndef VTOOLSINGLEPOINT_H #ifndef VTOOLSINGLEPOINT_H
#define VTOOLSINGLEPOINT_H #define VTOOLSINGLEPOINT_H
#include "container/vcontainer.h"
#include "xml/vdomdocument.h"
#include "dialogs/dialogsinglepoint.h" #include "dialogs/dialogsinglepoint.h"
#include "vtoolpoint.h" #include "vtoolpoint.h"
@ -32,7 +30,7 @@ class VToolSinglePoint : public VToolPoint
Q_OBJECT Q_OBJECT
public: public:
VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id,
Tool::Enum typeCreation, QGraphicsItem * parent = 0 ); Tool::Sources typeCreation, QGraphicsItem * parent = 0 );
virtual void setDialog(); virtual void setDialog();
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
@ -44,6 +42,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void decrementReferens();
private: private:
QSharedPointer<DialogSinglePoint> dialogSinglePoint; QSharedPointer<DialogSinglePoint> dialogSinglePoint;
}; };

View File

@ -20,13 +20,12 @@
****************************************************************************/ ****************************************************************************/
#include "vtoolspline.h" #include "vtoolspline.h"
#include <QMenu>
#include <QDebug> #include <QDebug>
#include "geometry/vspline.h" #include "geometry/vspline.h"
VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id,
Tool::Enum typeCreation, Tool::Sources typeCreation,
QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsPathItem(parent), QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsPathItem(parent),
dialogSpline(QSharedPointer<DialogSpline>()), controlPoints(QVector<VControlPointSpline *>()){ dialogSpline(QSharedPointer<DialogSpline>()), controlPoints(QVector<VControlPointSpline *>()){
@ -89,8 +88,8 @@ void VToolSpline::Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScen
void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1, void VToolSpline::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, const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Enum typeCreation){ Tool::Sources typeCreation){
VSpline spline = VSpline(data->DataPoints(), p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve); VSpline spline = VSpline(data->DataPoints(), p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve);
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if(typeCreation == Tool::FromGui){
@ -98,23 +97,19 @@ void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, c
} else { } else {
data->UpdateSpline(id, spline); data->UpdateSpline(id, spline);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Spline);
}
} }
} }
data->AddLengthSpline(data->GetNameSpline(p1, p4), spline.GetLength()); data->AddLengthSpline(data->GetNameSpline(p1, p4), spline.GetLength());
VDrawTool::AddRecord(id, Tools::SplineTool, doc); VDrawTool::AddRecord(id, Tool::SplineTool, doc);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation); VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation);
scene->addItem(spl); scene->addItem(spl);
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(spl, &VToolSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(spl, &VToolSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, spl);
tools->insert(id,spl); doc->IncrementReferens(p1);
doc->IncrementReferens(p4);
} }
} }
@ -177,12 +172,7 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, SplinePo
} }
void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
VSpline spl = VDrawTool::data.GetSpline(id); ContextMenu(dialogSpline, this, event);
if(spl.referens() > 1){
ContextMenu(dialogSpline, this, event, false);
} else {
ContextMenu(dialogSpline, this, event);
}
} }
void VToolSpline::AddToFile(){ void VToolSpline::AddToFile(){
@ -219,6 +209,12 @@ void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VToolSpline::RemoveReferens(){
VSpline spl = VAbstractTool::data.GetSpline(id);
doc->DecrementReferens(spl.GetP1());
doc->DecrementReferens(spl.GetP4());
}
void VToolSpline::RefreshGeometry(){ void VToolSpline::RefreshGeometry(){
VSpline spl = VAbstractTool::data.GetSpline(id); VSpline spl = VAbstractTool::data.GetSpline(id);
QPainterPath path; QPainterPath path;

View File

@ -23,11 +23,9 @@
#define VTOOLSPLINE_H #define VTOOLSPLINE_H
#include "vdrawtool.h" #include "vdrawtool.h"
#include "xml/vdomdocument.h"
#include <QGraphicsPathItem> #include <QGraphicsPathItem>
#include "dialogs/dialogspline.h" #include "dialogs/dialogspline.h"
#include "widgets/vcontrolpointspline.h" #include "widgets/vcontrolpointspline.h"
#include "container/vcontainer.h"
#include "geometry/vsplinepath.h" #include "geometry/vsplinepath.h"
class VToolSpline:public VDrawTool, public QGraphicsPathItem class VToolSpline:public VDrawTool, public QGraphicsPathItem
@ -35,14 +33,14 @@ class VToolSpline:public VDrawTool, public QGraphicsPathItem
Q_OBJECT Q_OBJECT
public: public:
VToolSpline (VDomDocument *doc, VContainer *data, qint64 id, VToolSpline (VDomDocument *doc, VContainer *data, qint64 id,
Tool::Enum typeCreation, QGraphicsItem * parent = 0 ); Tool::Sources typeCreation, QGraphicsItem * parent = 0 );
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, static void Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data); VContainer *data);
static void Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1, static void 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, const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Enum typeCreation); Tool::Sources typeCreation);
signals: signals:
void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position, void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &controlPoint, const QPointF &splinePoint ); const QPointF &controlPoint, const QPointF &splinePoint );
@ -61,6 +59,7 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
private: private:
QSharedPointer<DialogSpline> dialogSpline; QSharedPointer<DialogSpline> dialogSpline;
QVector<VControlPointSpline *> controlPoints; QVector<VControlPointSpline *> controlPoints;

View File

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

View File

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

View File

@ -21,14 +21,13 @@
#include "vmodelingalongline.h" #include "vmodelingalongline.h"
#include <QDialog> #include <QDialog>
#include <QMenu>
#include <QDebug> #include <QDebug>
#include "container/calculator.h" #include "container/calculator.h"
VModelingAlongLine::VModelingAlongLine(VDomDocument *doc, VContainer *data, qint64 id, VModelingAlongLine::VModelingAlongLine(VDomDocument *doc, VContainer *data, qint64 id,
const QString &formula, const qint64 &firstPointId, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const QString &typeLine, const qint64 &secondPointId, const QString &typeLine,
Tool::Enum typeCreation, QGraphicsItem *parent): Tool::Sources typeCreation, QGraphicsItem *parent):
VModelingLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), VModelingLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent),
secondPointId(secondPointId), dialogAlongLine(QSharedPointer<DialogAlongLine>()){ secondPointId(secondPointId), dialogAlongLine(QSharedPointer<DialogAlongLine>()){
@ -86,6 +85,11 @@ void VModelingAlongLine::AddToFile(){
AddToModeling(domElement); AddToModeling(domElement);
} }
void VModelingAlongLine::RemoveReferens(){
doc->DecrementReferens(secondPointId);
VModelingLinePoint::RemoveReferens();
}
void VModelingAlongLine::setDialog(){ void VModelingAlongLine::setDialog(){
Q_ASSERT(!dialogAlongLine.isNull()); Q_ASSERT(!dialogAlongLine.isNull());
if(!dialogAlongLine.isNull()){ if(!dialogAlongLine.isNull()){
@ -113,8 +117,8 @@ VModelingAlongLine *VModelingAlongLine::Create(const qint64 _id, const QString &
const QString &typeLine, const QString &formula, const QString &typeLine, const QString &formula,
const qint64 &firstPointId, const qint64 &secondPointId, const qint64 &firstPointId, const qint64 &secondPointId,
const qreal &mx, const qreal &my, VDomDocument *doc, const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, Document::Enum parse, VContainer *data, const Document::Documents &parse,
Tool::Enum typeCreation){ Tool::Sources typeCreation){
VModelingAlongLine *point = 0; VModelingAlongLine *point = 0;
VPointF firstPoint = data->GetModelingPoint(firstPointId); VPointF firstPoint = data->GetModelingPoint(firstPointId);
VPointF secondPoint = data->GetModelingPoint(secondPointId); VPointF secondPoint = data->GetModelingPoint(secondPointId);
@ -130,24 +134,18 @@ VModelingAlongLine *VModelingAlongLine::Create(const qint64 _id, const QString &
} else { } else {
data->UpdateModelingPoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); data->UpdateModelingPoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
}
} }
} }
data->AddLine(firstPointId, id); data->AddLine(firstPointId, id);
data->AddLine(id, secondPointId); data->AddLine(id, secondPointId);
data->IncrementReferens(firstPointId, Scene::Point, Draw::Modeling);
data->IncrementReferens(secondPointId, Scene::Point, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
point = new VModelingAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine, point = new VModelingAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine,
typeCreation); typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
} }
} }
return point; return point;

View File

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

View File

@ -23,7 +23,7 @@
#include <QMenu> #include <QMenu>
#include "container/calculator.h" #include "container/calculator.h"
VModelingArc::VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation, VModelingArc::VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation,
QGraphicsItem *parent):VModelingTool(doc, data, id), QGraphicsPathItem(parent), QGraphicsItem *parent):VModelingTool(doc, data, id), QGraphicsPathItem(parent),
dialogArc(QSharedPointer<DialogArc>()){ dialogArc(QSharedPointer<DialogArc>()){
VArc arc = data->GetModelingArc(id); VArc arc = data->GetModelingArc(id);
@ -61,7 +61,7 @@ VModelingArc* VModelingArc::Create(QSharedPointer<DialogArc> &dialog, VDomDocume
VModelingArc* VModelingArc::Create(const qint64 _id, const qint64 &center, const QString &radius, VModelingArc* VModelingArc::Create(const qint64 _id, const qint64 &center, const QString &radius,
const QString &f1, const QString &f2, VDomDocument *doc, const QString &f1, const QString &f2, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){ VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){
VModelingArc *toolArc = 0; VModelingArc *toolArc = 0;
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
@ -91,20 +91,14 @@ VModelingArc* VModelingArc::Create(const qint64 _id, const qint64 &center, const
} else { } else {
data->UpdateModelingArc(id, arc); data->UpdateModelingArc(id, arc);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Arc, Draw::Modeling);
}
} }
} }
data->AddLengthArc(data->GetNameArc(center,id, Draw::Modeling), arc.GetLength()); data->AddLengthArc(data->GetNameArc(center,id, Draw::Modeling), arc.GetLength());
data->IncrementReferens(center, Scene::Point, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
toolArc = new VModelingArc(doc, data, id, typeCreation); toolArc = new VModelingArc(doc, data, id, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, toolArc);
tools->insert(id,toolArc); doc->IncrementReferens(center);
} }
return toolArc; return toolArc;
} }
@ -162,6 +156,11 @@ void VModelingArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VModelingArc::RemoveReferens(){
VArc arc = VAbstractTool::data.GetModelingArc(id);
doc->DecrementReferens(arc.GetCenter());
}
void VModelingArc::RefreshGeometry(){ void VModelingArc::RefreshGeometry(){
VArc arc = VAbstractTool::data.GetModelingArc(id); VArc arc = VAbstractTool::data.GetModelingArc(id);
QPainterPath path; QPainterPath path;

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@
VModelingEndLine::VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine, VModelingEndLine::VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &basePointId, const QString &formula, const qreal &angle, const qint64 &basePointId,
Tool::Enum typeCreation, QGraphicsItem *parent): Tool::Sources typeCreation, QGraphicsItem *parent):
VModelingLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent), VModelingLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent),
dialogEndLine(QSharedPointer<DialogEndLine>()){ dialogEndLine(QSharedPointer<DialogEndLine>()){
@ -62,7 +62,7 @@ VModelingEndLine *VModelingEndLine::Create(const qint64 _id, const QString &poin
const QString &typeLine, const QString &formula, const QString &typeLine, const QString &formula,
const qreal &angle, const qint64 &basePointId, const qreal &mx, const qreal &angle, const qint64 &basePointId, const qreal &mx,
const qreal &my, VDomDocument *doc, VContainer *data, const qreal &my, VDomDocument *doc, VContainer *data,
Document::Enum parse, Tool::Enum typeCreation){ const Document::Documents &parse, Tool::Sources typeCreation){
VModelingEndLine *point = 0; VModelingEndLine *point = 0;
VPointF basePoint = data->GetModelingPoint(basePointId); VPointF basePoint = data->GetModelingPoint(basePointId);
QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y())); QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y()));
@ -78,20 +78,14 @@ VModelingEndLine *VModelingEndLine::Create(const qint64 _id, const QString &poin
} else { } else {
data->UpdateModelingPoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); data->UpdateModelingPoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
}
} }
} }
data->AddLine(basePointId, id, Draw::Modeling); data->AddLine(basePointId, id, Draw::Modeling);
data->IncrementReferens(basePointId, Scene::Point, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
point = new VModelingEndLine(doc, data, id, typeLine, formula, angle, basePointId, typeCreation); point = new VModelingEndLine(doc, data, id, typeLine, formula, angle, basePointId, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(basePointId);
} }
} }
return point; return point;

View File

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

View File

@ -20,11 +20,10 @@
****************************************************************************/ ****************************************************************************/
#include "vmodelingline.h" #include "vmodelingline.h"
#include <QMenu>
#include <QDebug> #include <QDebug>
VModelingLine::VModelingLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, VModelingLine::VModelingLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
qint64 secondPoint, Tool::Enum typeCreation, QGraphicsItem *parent): qint64 secondPoint, Tool::Sources typeCreation, QGraphicsItem *parent):
VModelingTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), VModelingTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint),
secondPoint(secondPoint), dialogLine(QSharedPointer<DialogLine>()){ secondPoint(secondPoint), dialogLine(QSharedPointer<DialogLine>()){
//Лінія //Лінія
@ -53,26 +52,21 @@ VModelingLine *VModelingLine::Create(QSharedPointer<DialogLine> &dialog, VDomDoc
} }
VModelingLine *VModelingLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint, VModelingLine *VModelingLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
VDomDocument *doc, VContainer *data, Document::Enum parse, VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Enum typeCreation){ Tool::Sources typeCreation){
VModelingLine *line = 0; VModelingLine *line = 0;
Q_CHECK_PTR(doc); Q_CHECK_PTR(doc);
Q_CHECK_PTR(data); Q_CHECK_PTR(data);
data->AddLine(firstPoint, secondPoint, Draw::Modeling); data->AddLine(firstPoint, secondPoint, Draw::Modeling);
data->IncrementReferens(firstPoint, Scene::Point, Draw::Modeling);
data->IncrementReferens(secondPoint, Scene::Point, Draw::Modeling);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
Q_CHECK_PTR(tools);
VDataTool *tool = tools->value(id);
Q_CHECK_PTR(tool);
tool->VDataTool::setData(data);
} }
if(parse == Document::FullParse){ if(parse == Document::FullParse){
qint64 id = data->getNextId(); qint64 id = data->getNextId();
line = new VModelingLine(doc, data, id, firstPoint, secondPoint, typeCreation); line = new VModelingLine(doc, data, id, firstPoint, secondPoint, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, line);
tools->insert(id,line); doc->IncrementReferens(firstPoint);
doc->IncrementReferens(secondPoint);
} }
return line; return line;
} }
@ -122,3 +116,8 @@ void VModelingLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine));
} }
void VModelingLine::RemoveReferens(){
doc->DecrementReferens(firstPoint);
doc->DecrementReferens(secondPoint);
}

View File

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

View File

@ -20,11 +20,10 @@
****************************************************************************/ ****************************************************************************/
#include "vmodelinglineintersect.h" #include "vmodelinglineintersect.h"
#include <QMenu>
VModelingLineIntersect::VModelingLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, VModelingLineIntersect::VModelingLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id,
const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2, const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line2, Tool::Enum typeCreation, QGraphicsItem *parent): const qint64 &p2Line2, Tool::Sources typeCreation, QGraphicsItem *parent):
VModelingPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2), VModelingPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>()){ p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>()){
if(typeCreation == Tool::FromGui){ if(typeCreation == Tool::FromGui){
@ -59,8 +58,8 @@ VModelingLineIntersect *VModelingLineIntersect::Create(const qint64 _id, const q
const qint64 &p2Line1Id, const qint64 &p1Line2Id, const qint64 &p2Line1Id, const qint64 &p1Line2Id,
const qint64 &p2Line2Id, const QString &pointName, const qint64 &p2Line2Id, const QString &pointName,
const qreal &mx, const qreal &my, VDomDocument *doc, const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, Document::Enum parse, VContainer *data, const Document::Documents &parse,
Tool::Enum typeCreation){ Tool::Sources typeCreation){
VModelingLineIntersect *point = 0; VModelingLineIntersect *point = 0;
VPointF p1Line1 = data->GetModelingPoint(p1Line1Id); VPointF p1Line1 = data->GetModelingPoint(p1Line1Id);
VPointF p2Line1 = data->GetModelingPoint(p2Line1Id); VPointF p2Line1 = data->GetModelingPoint(p2Line1Id);
@ -78,12 +77,7 @@ VModelingLineIntersect *VModelingLineIntersect::Create(const qint64 _id, const q
} else { } else {
data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
}
} }
} }
data->AddLine(p1Line1Id, id, Draw::Modeling); data->AddLine(p1Line1Id, id, Draw::Modeling);
@ -93,8 +87,11 @@ VModelingLineIntersect *VModelingLineIntersect::Create(const qint64 _id, const q
if(parse == Document::FullParse){ if(parse == Document::FullParse){
point = new VModelingLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, point = new VModelingLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id,
typeCreation); typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(p1Line1Id);
doc->IncrementReferens(p2Line1Id);
doc->IncrementReferens(p1Line2Id);
doc->IncrementReferens(p2Line2Id);
} }
} }
return point; return point;
@ -147,3 +144,10 @@ void VModelingLineIntersect::AddToFile(){
AddToModeling(domElement); AddToModeling(domElement);
} }
void VModelingLineIntersect::RemoveReferens(){
doc->DecrementReferens(p1Line1);
doc->DecrementReferens(p2Line1);
doc->DecrementReferens(p1Line2);
doc->DecrementReferens(p2Line2);
}

View File

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

View File

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

View File

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

View File

@ -20,12 +20,11 @@
****************************************************************************/ ****************************************************************************/
#include "vmodelingnormal.h" #include "vmodelingnormal.h"
#include <QMenu>
VModelingNormal::VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id, VModelingNormal::VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &firstPointId, const QString &formula, const qreal &angle, const qint64 &firstPointId,
const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem *parent): const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem *parent):
VModelingLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent), VModelingLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent),
secondPointId(secondPointId), dialogNormal(QSharedPointer<DialogNormal>()){ secondPointId(secondPointId), dialogNormal(QSharedPointer<DialogNormal>()){
@ -64,8 +63,8 @@ VModelingNormal *VModelingNormal::Create(const qint64 _id, const QString &formul
const qint64 &firstPointId, const qint64 &secondPointId, const qint64 &firstPointId, const qint64 &secondPointId,
const QString typeLine, const QString pointName, const QString typeLine, const QString pointName,
const qreal angle, const qreal &mx, const qreal &my, const qreal angle, const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data, Document::Enum parse, VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Enum typeCreation){ Tool::Sources typeCreation){
VModelingNormal *point = 0; VModelingNormal *point = 0;
VPointF firstPoint = data->GetModelingPoint(firstPointId); VPointF firstPoint = data->GetModelingPoint(firstPointId);
VPointF secondPoint = data->GetModelingPoint(secondPointId); VPointF secondPoint = data->GetModelingPoint(secondPointId);
@ -81,22 +80,16 @@ VModelingNormal *VModelingNormal::Create(const qint64 _id, const QString &formul
} else { } else {
data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){ if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->UpdateToolData(id, data);
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
}
} }
} }
data->AddLine(firstPointId, id, Draw::Modeling); data->AddLine(firstPointId, id, Draw::Modeling);
data->IncrementReferens(firstPointId, Scene::Point, Draw::Modeling);
data->IncrementReferens(secondPointId, Scene::Point, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
point = new VModelingNormal(doc, data, id, typeLine, formula, angle, firstPointId, secondPointId, point = new VModelingNormal(doc, data, id, typeLine, formula, angle, firstPointId, secondPointId,
typeCreation); typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools(); doc->AddTool(id, point);
tools->insert(id,point); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
} }
} }
return point; return point;
@ -161,3 +154,8 @@ void VModelingNormal::AddToFile(){
AddToModeling(domElement); AddToModeling(domElement);
} }
void VModelingNormal::RemoveReferens(){
doc->DecrementReferens(secondPointId);
VModelingLinePoint::RemoveReferens();
}

View File

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

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