From 8aea1ee3f3c1918e8c52def25523ac54ed47aeda Mon Sep 17 00:00:00 2001 From: dismine Date: Tue, 12 Nov 2013 14:48:45 +0200 Subject: [PATCH] Arc, spline, spline path store their name by yourself. --HG-- branch : develop --- Valentina.pro | 2 +- dialogs/dialogdetail.cpp | 4 ++-- dialogs/dialogsplinepath.cpp | 1 + geometry/varc.cpp | 21 ++++++++++++++++----- geometry/varc.h | 8 ++++++++ geometry/vspline.cpp | 11 +++++++---- geometry/vspline.h | 5 +++++ geometry/vsplinepath.cpp | 18 +++++++++++++++--- geometry/vsplinepath.h | 4 +++- tablewindow.cpp | 3 +++ 10 files changed, 61 insertions(+), 16 deletions(-) diff --git a/Valentina.pro b/Valentina.pro index 5b88224a5..229bd92d1 100644 --- a/Valentina.pro +++ b/Valentina.pro @@ -78,7 +78,7 @@ CONFIG(debug, debug|release){ -isystem "/usr/include/qt5/QtCore" -isystem "$$OUT_PWD/uic" -isystem "$$OUT_PWD/moc/" \ -Og -Wall -Wextra -pedantic -Weffc++ -Woverloaded-virtual -Wctor-dtor-privacy \ -Wnon-virtual-dtor -Wold-style-cast -Wconversion -Winit-self \ - -Wunreachable-code + -Wunreachable-code -gdwarf-3 }else{ # Release TARGET = $$RELEASE_TARGET diff --git a/dialogs/dialogdetail.cpp b/dialogs/dialogdetail.cpp index 91d339552..106ac5cba 100644 --- a/dialogs/dialogdetail.cpp +++ b/dialogs/dialogdetail.cpp @@ -131,7 +131,7 @@ void DialogDetail::NewItem(qint64 id, const Tool::Tools &typeTool, const Draw::D { arc = data->GetModelingArc(id); } - name = data->GetNameArc(arc.GetCenter(), id, mode); + name = arc.name(); break; } case (Tool::NodeSpline): @@ -159,7 +159,7 @@ void DialogDetail::NewItem(qint64 id, const Tool::Tools &typeTool, const Draw::D { splPath = data->GetModelingSplinePath(id); } - name = data->GetNameSplinePath(splPath, mode); + name = splPath.name(); break; } default: diff --git a/dialogs/dialogsplinepath.cpp b/dialogs/dialogsplinepath.cpp index 76efb8bd8..132e12179 100644 --- a/dialogs/dialogsplinepath.cpp +++ b/dialogs/dialogsplinepath.cpp @@ -101,6 +101,7 @@ void DialogSplinePath::DialogAccepted() path.append( qvariant_cast(item->data(Qt::UserRole))); } path.setKCurve(ui->doubleSpinBoxKcurve->value()); + path.setName(data->GetNameSplinePath(path, mode)); emit ToolTip(""); emit DialogClosed(QDialog::Accepted); } diff --git a/geometry/varc.cpp b/geometry/varc.cpp index d7f5ef860..dff1f8840 100644 --- a/geometry/varc.cpp +++ b/geometry/varc.cpp @@ -22,20 +22,25 @@ #include "varc.h" #include "../exception/vexception.h" +class QRectF; + VArc::VArc () : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()), - center(0), points(QHash()), mode(Draw::Calculation), idObject(0){} + center(0), points(QHash()), mode(Draw::Calculation), idObject(0), _name(QString()){} VArc::VArc (const QHash *points, qint64 center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Draws mode, qint64 idObject) : f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius), - center(center), points(*points), mode(mode), idObject(idObject){} + center(center), points(*points), mode(mode), idObject(idObject), _name(QString()) +{ + _name = QString ("Arc_%1_%2").arg(this->GetCenterVPoint().name()).arg(radius); +} VArc::VArc(const VArc &arc) : f1(arc.GetF1()), formulaF1(arc.GetFormulaF1()), f2(arc.GetF2()), formulaF2(arc.GetFormulaF2()), radius(arc.GetRadius()), formulaRadius(arc.GetFormulaRadius()), center(arc.GetCenter()), points(arc.GetDataPoints()), mode(arc.getMode()), - idObject(arc.getIdObject()){} + idObject(arc.getIdObject()), _name(arc.name()){} VArc &VArc::operator =(const VArc &arc) { @@ -49,21 +54,27 @@ VArc &VArc::operator =(const VArc &arc) this->center = arc.GetCenter(); this->mode = arc.getMode(); this->idObject = arc.getIdObject(); + this->_name = arc.name(); return *this; } QPointF VArc::GetCenterPoint() const +{ + return GetCenterVPoint().toQPointF(); +} + +VPointF VArc::GetCenterVPoint() const { if (points.contains(center)) { - return points.value(center).toQPointF(); + return points.value(center); } else { QString error = QString(tr("Can't find id = %1 in table.")).arg(center); throw VException(error); } - return QPointF(); + return VPointF(); } QPointF VArc::GetP1() const diff --git a/geometry/varc.h b/geometry/varc.h index 6f4b4771b..5c658b453 100644 --- a/geometry/varc.h +++ b/geometry/varc.h @@ -23,6 +23,10 @@ #define VARC_H #include "vspline.h" +class QString; +class QLineF; +class QPainterPath; +class QPointF; /** * @brief VArc клас, що реалізує дугу. Дуга розраховується за годиниковою стрілкою. @@ -76,6 +80,7 @@ public: */ inline qint64 GetCenter () const {return center;} QPointF GetCenterPoint() const; + VPointF GetCenterVPoint() const; /** * @brief GetP1 повертає першу точку з якої починається дуга. * @return точку початку дуги. @@ -100,6 +105,8 @@ public: inline void setMode(const Draw::Draws &value) {mode = value;} inline qint64 getIdObject() const {return idObject;} inline void setIdObject(const qint64 &value) {idObject = value;} + QString name() const {return _name;} + void setName(const QString &name) {_name = name;} private: /** * @brief f1 початковий кут в градусах @@ -123,6 +130,7 @@ private: QHash points; Draw::Draws mode; qint64 idObject; + QString _name; }; #endif // VARC_H diff --git a/geometry/vspline.cpp b/geometry/vspline.cpp index 25b56b8db..2b6c19c6e 100644 --- a/geometry/vspline.cpp +++ b/geometry/vspline.cpp @@ -23,26 +23,28 @@ VSpline::VSpline() :p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1), - points(QHash()), mode(Draw::Calculation), idObject(0){} + points(QHash()), mode(Draw::Calculation), idObject(0), _name(QString()){} VSpline::VSpline ( const VSpline & spline ) :p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()), p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()), angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()), kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()), - points(spline.GetDataPoints()), mode(spline.getMode()), idObject(spline.getIdObject()){} + points(spline.GetDataPoints()), mode(spline.getMode()), idObject(spline.getIdObject()), _name(spline.name()){} VSpline::VSpline (const QHash *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode, qint64 idObject) :p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), - kCurve(kCurve), points(*points), mode(mode), idObject(idObject) + kCurve(kCurve), points(*points), mode(mode), idObject(idObject), _name(QString()) { + _name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name()); ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve ); } VSpline::VSpline (const QHash *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4, qreal kCurve, Draw::Draws mode, qint64 idObject) :p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(*points), mode(mode), - idObject(idObject) + idObject(idObject), _name(QString()) { + _name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name()); ModifiSpl ( p1, p2, p3, p4, kCurve); } @@ -778,5 +780,6 @@ VSpline &VSpline::operator =(const VSpline &spline) this->points = spline.GetDataPoints(); this->mode = spline.getMode(); this->idObject = spline.getIdObject(); + this->_name = spline.name(); return *this; } diff --git a/geometry/vspline.h b/geometry/vspline.h index a8245de01..874a3d765 100644 --- a/geometry/vspline.h +++ b/geometry/vspline.h @@ -24,6 +24,8 @@ #include "../container/vpointf.h" +class QString; + #define M_2PI 6.28318530717958647692528676655900576 /** @@ -184,6 +186,8 @@ public: inline qint64 getIdObject() const {return idObject;} inline void setIdObject(const qint64 &value) {idObject = value;} VSpline &operator=(const VSpline &spl); + QString name() const {return _name;} + void setName(const QString &name) {_name = name;} protected: /** * @brief GetPoints повертає точки з яких складається сплайн. @@ -225,6 +229,7 @@ private: QHash points; Draw::Draws mode; qint64 idObject; + QString _name; /** * @brief LengthBezier повертає дожину сплайну за його чотирьма точками. * @param p1 початкова точка сплайну. diff --git a/geometry/vsplinepath.cpp b/geometry/vsplinepath.cpp index df3baad54..3f7af17d5 100644 --- a/geometry/vsplinepath.cpp +++ b/geometry/vsplinepath.cpp @@ -23,18 +23,29 @@ #include "../exception/vexception.h" VSplinePath::VSplinePath() - : path(QVector()), kCurve(1), mode(Draw::Calculation), points(QHash()), idObject(0){} + : path(QVector()), kCurve(1), mode(Draw::Calculation), points(QHash()), idObject(0), + _name(QString()){} VSplinePath::VSplinePath(const QHash *points, qreal kCurve, Draw::Draws mode, qint64 idObject) - : path(QVector()), kCurve(kCurve), mode(mode), points(*points), idObject(idObject){} + : path(QVector()), kCurve(kCurve), mode(mode), points(*points), idObject(idObject), _name(QString()) +{} VSplinePath::VSplinePath(const VSplinePath &splPath) : path(*splPath.GetPoint()), kCurve(splPath.getKCurve()), mode(splPath.getMode()), points(splPath.GetDataPoints()), - idObject(splPath.getIdObject()){} + idObject(splPath.getIdObject()), _name(splPath.name()){} void VSplinePath::append(const VSplinePoint &point) { path.append(point); + _name = QString("SplPath"); + for (qint32 i = 1; i <= this->Count(); ++i) + { + VSpline spl = this->GetSpline(i); + VPointF first = spl.GetPointP1(); + VPointF second = spl.GetPointP4(); + QString splName = QString("_%1_%2").arg(first.name(), second.name()); + _name.append(splName); + } } qint32 VSplinePath::Count() const @@ -143,6 +154,7 @@ VSplinePath &VSplinePath::operator =(const VSplinePath &path) this->mode = path.getMode(); this->points = path.GetDataPoints(); this->idObject = path.getIdObject(); + this->_name = path.name(); return *this; } diff --git a/geometry/vsplinepath.h b/geometry/vsplinepath.h index 412afb317..60657783d 100644 --- a/geometry/vsplinepath.h +++ b/geometry/vsplinepath.h @@ -80,7 +80,8 @@ public: inline qint64 getIdObject() const {return idObject;} inline void setIdObject(const qint64 &value) {idObject = value;} - + QString name() const {return _name;} + void setName(const QString &name) {_name = name;} protected: /** * @brief path вектор з точок сплайна. @@ -90,6 +91,7 @@ protected: Draw::Draws mode; QHash points; qint64 idObject; + QString _name; }; #endif // VSPLINEPATH_H diff --git a/tablewindow.cpp b/tablewindow.cpp index d597590ff..a704e91e3 100644 --- a/tablewindow.cpp +++ b/tablewindow.cpp @@ -23,6 +23,7 @@ #include "ui_tablewindow.h" #include "widgets/vtablegraphicsview.h" #include "options.h" +#include TableWindow::TableWindow(QWidget *parent) :QMainWindow(parent), numberDetal(0), colission(0), ui(new Ui::TableWindow), @@ -375,6 +376,8 @@ void TableWindow::SvgFile(const QString &name) const generator.setTitle(tr("SVG Generator Example Drawing")); generator.setDescription(tr("An SVG drawing created by the SVG Generator " "Example provided with Qt.")); + generator.setResolution(PrintDPI); + qDebug()<<"resolution is" << generator.resolution(); QPainter painter; painter.begin(&generator); painter.setFont( QFont( "Arial", 8, QFont::Normal ) );