From 1c751891e27ea14fdbd758bb7d04cafd7f686b9a Mon Sep 17 00:00:00 2001 From: dismine Date: Wed, 21 Aug 2013 11:03:53 +0300 Subject: [PATCH] Add tool point of contact. --- Valentina.pro | 11 +- container/vcontainer.cpp | 30 +-- container/vcontainer.h | 10 +- cursor.qrc | 1 + cursor/pointcontact_cursor.png | Bin 0 -> 1340 bytes dialogs/dialogarc.cpp | 8 +- dialogs/dialogarc.ui | 2 +- dialogs/dialoglineintersect.cpp | 6 + dialogs/dialoglineintersect.h | 6 + dialogs/dialognormal.cpp | 6 + dialogs/dialognormal.h | 7 +- dialogs/dialogpointofcontact.cpp | 129 ++++++++++++ dialogs/dialogpointofcontact.h | 52 +++++ dialogs/dialogpointofcontact.ui | 348 +++++++++++++++++++++++++++++++ dialogs/dialogshoulderpoint.cpp | 6 + dialogs/dialogshoulderpoint.h | 6 + icon.qrc | 1 + icon/32x32/point_of_contact.png | Bin 0 -> 977 bytes mainwindow.cpp | 24 ++- mainwindow.h | 4 + mainwindow.ui | 29 ++- options.h | 3 +- tools/vtoolpointofcontact.cpp | 146 +++++++++++++ tools/vtoolpointofcontact.h | 36 ++++ tools/vtoolsplinepath.cpp | 40 +--- tools/vtoolsplinepath.h | 5 +- xml/vdomdocument.cpp | 60 ++++-- 27 files changed, 887 insertions(+), 89 deletions(-) create mode 100644 cursor/pointcontact_cursor.png create mode 100644 dialogs/dialogpointofcontact.cpp create mode 100644 dialogs/dialogpointofcontact.h create mode 100644 dialogs/dialogpointofcontact.ui create mode 100644 icon/32x32/point_of_contact.png create mode 100644 tools/vtoolpointofcontact.cpp create mode 100644 tools/vtoolpointofcontact.h diff --git a/Valentina.pro b/Valentina.pro index b83b64fba..ca6f80a16 100644 --- a/Valentina.pro +++ b/Valentina.pro @@ -58,7 +58,9 @@ SOURCES += main.cpp\ widgets/vmaingraphicsview.cpp \ tools/vdatatool.cpp \ xml/vtoolrecord.cpp \ - dialogs/dialoghistory.cpp + dialogs/dialoghistory.cpp \ + tools/vtoolpointofcontact.cpp \ + dialogs/dialogpointofcontact.cpp HEADERS += mainwindow.h \ widgets/vmaingraphicsscene.h \ @@ -107,7 +109,9 @@ HEADERS += mainwindow.h \ widgets/vmaingraphicsview.h \ tools/vdatatool.h \ xml/vtoolrecord.h \ - dialogs/dialoghistory.h + dialogs/dialoghistory.h \ + tools/vtoolpointofcontact.h \ + dialogs/dialogpointofcontact.h FORMS += mainwindow.ui \ dialogs/dialogsinglepoint.ui \ @@ -122,7 +126,8 @@ FORMS += mainwindow.ui \ dialogs/dialogspline.ui \ dialogs/dialogarc.ui \ dialogs/dialogsplinepath.ui \ - dialogs/dialoghistory.ui + dialogs/dialoghistory.ui \ + dialogs/dialogpointofcontact.ui RESOURCES += \ icon.qrc \ diff --git a/container/vcontainer.cpp b/container/vcontainer.cpp index d2d79dd61..317d77ac6 100644 --- a/container/vcontainer.cpp +++ b/container/vcontainer.cpp @@ -12,7 +12,7 @@ qint64 VContainer::_id = 0; VContainer::VContainer():base(QMap()), points(QMap()), standartTable(QMap()), incrementTable(QMap()), - lengthLines(QMap()), lineArcs(QMap()), splines(QMap()), + lengthLines(QMap()), lineAngles(QMap()), splines(QMap()), lengthSplines(QMap()), arcs(QMap()), lengthArcs(QMap()), splinePaths(QMap()){ SetSize(500); @@ -31,7 +31,7 @@ void VContainer::setData(const VContainer &data){ standartTable = *data.DataStandartTable(); incrementTable = *data.DataIncrementTable(); lengthLines = *data.DataLengthLines(); - lineArcs = *data.DataLengthArcs(); + lineAngles = *data.DataLengthArcs(); splines = *data.DataSplines(); lengthSplines = *data.DataLengthSplines(); arcs = *data.DataArcs(); @@ -71,7 +71,7 @@ qreal VContainer::GetLine(const QString &name) const{ qreal VContainer::GetLineArc(const QString &name) const{ Q_ASSERT(!name.isEmpty()); - return GetObject(lineArcs, name); + return GetObject(lineAngles, name); } VSpline VContainer::GetSpline(qint64 id) const{ @@ -157,9 +157,9 @@ void VContainer::AddLengthArc(const QString &name, const qreal &value){ lengthArcs[name] = value; } -void VContainer::AddLineArc(const QString &name, const qint32 &value){ +void VContainer::AddLineAngle(const QString &name, const qreal &value){ Q_ASSERT(!name.isEmpty()); - lineArcs[name] = value; + lineAngles[name] = value; } qreal VContainer::GetValueStandartTableCell(const QString& name) const{ @@ -184,7 +184,7 @@ void VContainer::Clear(){ incrementTable.clear(); lengthLines.clear(); lengthArcs.clear(); - lineArcs.clear(); + lineAngles.clear(); ClearObject(); CreateManTableIGroup (); } @@ -211,8 +211,8 @@ void VContainer::ClearLengthArcs(){ lengthArcs.clear(); } -void VContainer::ClearLineArcs(){ - lineArcs.clear(); +void VContainer::ClearLineAngles(){ + lineAngles.clear(); } void VContainer::SetSize(qint32 size){ @@ -257,9 +257,9 @@ qreal VContainer::FindVar(const QString &name, bool *ok)const{ *ok = true; return lengthArcs.value(name); } - if(lineArcs.contains(name)){ + if(lineAngles.contains(name)){ *ok = true; - return lineArcs.value(name); + return lineAngles.value(name); } *ok = false; return 0; @@ -301,8 +301,8 @@ const QMap *VContainer::DataLengthArcs() const{ return &lengthArcs; } -const QMap *VContainer::DataLineArcs() const{ - return &lineArcs; +const QMap *VContainer::DataLineAngles() const{ + return &lineAngles; } const QMap *VContainer::DataSplinePaths() const{ @@ -314,6 +314,8 @@ void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId VPointF firstPoint = GetPoint(firstPointId); VPointF secondPoint = GetPoint(secondPointId); AddLengthLine(nameLine, QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()).length()/PrintDPI*25.4); + nameLine = GetNameLineAngle(firstPointId, secondPointId); + AddLineAngle(nameLine, QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()).angle()); } template @@ -345,10 +347,10 @@ QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPo return QString("Line_%1_%2").arg(first.name(), second.name()); } -QString VContainer::GetNameLineArc(const qint64 &firstPoint, const qint64 &secondPoint) const{ +QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint) const{ VPointF first = GetPoint(firstPoint); VPointF second = GetPoint(secondPoint); - return QString("ArcLine_%1_%2").arg(first.name(), second.name()); + return QString("AngleLine_%1_%2").arg(first.name(), second.name()); } QString VContainer::GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint) const{ diff --git a/container/vcontainer.h b/container/vcontainer.h index 15431cf77..2de885fe8 100644 --- a/container/vcontainer.h +++ b/container/vcontainer.h @@ -50,13 +50,13 @@ public: void AddLengthSpline(const QString &name, const qreal &value); void AddLengthArc(const qint64 ¢er, const qint64 &id); void AddLengthArc(const QString &name, const qreal &value); - void AddLineArc(const QString &name, const qint32 &value); + void AddLineAngle(const QString &name, const qreal &value); void AddLine(const qint64 &firstPointId, const qint64 &secondPointId); qint64 AddSpline(const VSpline& spl); qint64 AddSplinePath(const VSplinePath& splPath); qint64 AddArc(const VArc& arc); QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const; - QString GetNameLineArc(const qint64 &firstPoint, const qint64 &secondPoint) const; + QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint) const; QString GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint) const; QString GetNameSplinePath(const VSplinePath &path) const; QString GetNameArc(const qint64 ¢er, const qint64 &id) const; @@ -74,7 +74,7 @@ public: void ClearLengthLines(); void ClearLengthSplines(); void ClearLengthArcs(); - void ClearLineArcs(); + void ClearLineAngles(); void SetSize(qint32 size); void SetGrowth(qint32 growth); qint32 size() const; @@ -92,7 +92,7 @@ public: const QMap *DataLengthLines() const; const QMap *DataLengthSplines() const; const QMap *DataLengthArcs() const; - const QMap *DataLineArcs() const; + const QMap *DataLineAngles() const; const QMap *DataSplinePaths() const; void UpdateId(qint64 newId); private: @@ -102,7 +102,7 @@ private: QMap standartTable; QMap incrementTable; QMap lengthLines; - QMap lineArcs; + QMap lineAngles; QMap splines; QMap lengthSplines; QMap arcs; diff --git a/cursor.qrc b/cursor.qrc index ab84498f9..57f9e9510 100644 --- a/cursor.qrc +++ b/cursor.qrc @@ -10,5 +10,6 @@ cursor/spline_cursor.png cursor/arc_cursor.png cursor/splinepath_cursor.png + cursor/pointcontact_cursor.png diff --git a/cursor/pointcontact_cursor.png b/cursor/pointcontact_cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..0501136dbf02e0a6bed0ee4ecff8dabd137d21a9 GIT binary patch literal 1340 zcmV-C1;hG@P)Vl&|00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-3Sy84K-x^xjX;>06}y` zSad^gZEa<4bO1wAML|?gQaT`KWG!lNWoICEF)lD5D0OpbZf77#N=G0{P(?=|b~Z98 zEFf`pVQgu1c_2L?IWP*aMOc#n00ewVL_t(Y$HkUWOcYlXhQB*^hDGcyLR-OxRB8=L z6Tzxbiorer4MnjkPy5uQF^$<$wOT_$ee$(2tq-j+(I&pM@K6$)wjrra5Yx&-Nr(_l zTEWIf5)HVb6zsAy_w-?B=vWuf=-QK@@{C;q7FsHaSfNk3VB$G)=Bog8{4pmiEiR$X= z6FJX(`}Xa_fM~5nDJ6h(baeFO8rKRhJkLWU!~FR8_}YE@_I=pV(b4c!G7qv3Tqz|D z4Gq%M)3YLHH4mFH1^^MkvMfqUN@#0qo5~sON@Ye{DK-Bb1k%;jg;GjNOG~A$uC5?w zH4o|?Hl-A{Z6hKK3=GT$@6Vh$qjE-j*j(4;)~#C-kH^JzUE=XLJ9qAUGT_-V4oqu} z=Xn6CySp2J=H})nPkT1XUDriK5RrK?8XFq}D6X%sFMpz=7WP1Jlv48^e2YXPQdU+b zk4<~H!xw5mrPO`vR4PS5K>_{!{V(_R^+mUA*)rbP*f{Z64VR7jY=J1H7#$rYkw}bA zO-&Jt#XbT)4INwqyb1hn!FO|zdSviy!2~^^l;ZN`%V@2cot>Qv_Bil@WCE!NrVO+J zeOViBv2M>+65F=#D}ynHvuDp9*|lreAE!^BzOEnwtn|0XfWk+vc@UUnQ09QNKlcuh z2dH3Ae}8{5P+VGC3h<`~zX25rdNrJ15?pINFEUCgj4?!`(R6in_2kUV%mk2BO1ZXe z=cQ7qm61r~SrI7~5uHw_0jR93WG<6=32;N;eFMn_v)i#_$NYT`h-F#9h^1RvTCM=g zfqX!R^=A=bssUz!u7I5-70wugWm&V6|9t-x1oIX8c8N^>j!8D#Bm$}q_ea0OJFtd zVm2Ap@V15{HoWnlPn$xNTQwUuQde6G@EouL(2kR*KG=WI0buLat;2v66&0Did-q-k z_8&TQsL8K$EL+_)+_ph9+y#yTwX5LytZCSmyVJ3b_XIVzI(Z_DxMq!+@+? zw=Nr%dD*~ixaWh5U;p$bnD`sy9>_sx2Uht3M1Xvid5-$-1i#K714WlEU6P@pq1Fu> zHhdpwj2~$_OHjSQtH95|PeAPzc>PBxHej8AV?ZbHD=-LLR8VVW0_pbP%2H|?_3IuU zE9FaQp#y94GKU4W3@8WUz!yI7Ux24T?0^01hmrPj|8j^fHm?gQv#$?pfOiy(gur_N zTQ6~d05ADbP6O^k{G0@(vi#A!0}R`6Q8JTrL%}HnS05&us6QfidwHzsOu_POgq#Elj)aa#v&;xc3j6TG6v)5G^YJ0000toolButtonPutHereRadius, &QPushButton::clicked, this, &DialogArc::PutRadius); connect(ui->toolButtonPutHereF1, &QPushButton::clicked, this, &DialogArc::PutF1); - connect(ui->toolButtonPutHereF1, &QPushButton::clicked, this, &DialogArc::PutF1); + connect(ui->toolButtonPutHereF2, &QPushButton::clicked, this, &DialogArc::PutF2); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); ShowVariable(data->DataBase()); @@ -42,7 +42,7 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent) : connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogArc::StandartTable); connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogArc::Increments); connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogArc::LengthLines); - connect(ui->radioButtonLineArcs, &QRadioButton::clicked, this, &DialogArc::LineArcs); + connect(ui->radioButtonLineAngles, &QRadioButton::clicked, this, &DialogArc::LineArcs); connect(ui->toolButtonEqualRadius, &QPushButton::clicked, this, &DialogArc::EvalRadius); connect(ui->toolButtonEqualF1, &QPushButton::clicked, this, &DialogArc::EvalF1); @@ -114,7 +114,7 @@ void DialogArc::ValChenged(int row){ return; } QListWidgetItem *item = ui->listWidget->item( row ); - if(ui->radioButtonLineArcs->isChecked()){ + if(ui->radioButtonLineAngles->isChecked()){ QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLineArc(item->text())) .arg("Значення кута лінії."); ui->labelDescription->setText(desc); @@ -172,7 +172,7 @@ void DialogArc::ShowLineArcs(){ disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); ui->listWidget->clear(); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); - const QMap *lineArcsTable = data->DataLineArcs(); + const QMap *lineArcsTable = data->DataLineAngles(); QMapIterator i(*lineArcsTable); while (i.hasNext()) { i.next(); diff --git a/dialogs/dialogarc.ui b/dialogs/dialogarc.ui index 1e3d26380..1252550fa 100644 --- a/dialogs/dialogarc.ui +++ b/dialogs/dialogarc.ui @@ -342,7 +342,7 @@ - + true diff --git a/dialogs/dialoglineintersect.cpp b/dialogs/dialoglineintersect.cpp index 24fdba4c0..17f9891cb 100644 --- a/dialogs/dialoglineintersect.cpp +++ b/dialogs/dialoglineintersect.cpp @@ -1,5 +1,11 @@ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" #include "dialoglineintersect.h" #include "ui_dialoglineintersect.h" +#pragma GCC diagnostic pop DialogLineIntersect::DialogLineIntersect(const VContainer *data, QWidget *parent) : DialogTool(data, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()), p1Line1(0), diff --git a/dialogs/dialoglineintersect.h b/dialogs/dialoglineintersect.h index 8a0ee23c2..271da9973 100644 --- a/dialogs/dialoglineintersect.h +++ b/dialogs/dialoglineintersect.h @@ -1,7 +1,13 @@ #ifndef DIALOGLINEINTERSECT_H #define DIALOGLINEINTERSECT_H +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" #include "dialogtool.h" +#pragma GCC diagnostic pop namespace Ui { class DialogLineIntersect; diff --git a/dialogs/dialognormal.cpp b/dialogs/dialognormal.cpp index ccabc8007..2658545c9 100644 --- a/dialogs/dialognormal.cpp +++ b/dialogs/dialognormal.cpp @@ -1,6 +1,12 @@ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" #include "dialognormal.h" #include "ui_dialognormal.h" #include +#pragma GCC diagnostic pop DialogNormal::DialogNormal(const VContainer *data, QWidget *parent) : DialogTool(data, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), typeLine(QString()), diff --git a/dialogs/dialognormal.h b/dialogs/dialognormal.h index e98837705..ee2a2457f 100644 --- a/dialogs/dialognormal.h +++ b/dialogs/dialognormal.h @@ -1,11 +1,16 @@ #ifndef DIALOGNORMAL_H #define DIALOGNORMAL_H +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" #include "dialogtool.h" #include #include #include - +#pragma GCC diagnostic pop #include "../options.h" #include "../container/vcontainer.h" #include "../container/calculator.h" diff --git a/dialogs/dialogpointofcontact.cpp b/dialogs/dialogpointofcontact.cpp new file mode 100644 index 000000000..470713cf6 --- /dev/null +++ b/dialogs/dialogpointofcontact.cpp @@ -0,0 +1,129 @@ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" +#include "dialogpointofcontact.h" +#pragma GCC diagnostic pop + +DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *parent) : + DialogTool(data, parent){ + ui.setupUi(this); + number = 0; + listWidget = ui.listWidget; + labelResultCalculation = ui.labelResultCalculation; + labelDescription = ui.labelDescription; + radioButtonSizeGrowth = ui.radioButtonSizeGrowth; + radioButtonStandartTable = ui.radioButtonStandartTable; + radioButtonIncrements = ui.radioButtonIncrements; + radioButtonLengthLine = ui.radioButtonLengthLine; + lineEditFormula = ui.lineEditFormula; + flagFormula = false; + bOk = ui.buttonBox->button(QDialogButtonBox::Ok); + connect(bOk, &QPushButton::clicked, this, &DialogPointOfContact::DialogAccepted); + flagName = false; + CheckState(); + QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel); + connect(bCansel, &QPushButton::clicked, this, &DialogPointOfContact::DialogRejected); + FillComboBoxPoints(ui.comboBoxCenter); + FillComboBoxPoints(ui.comboBoxFirstPoint); + FillComboBoxPoints(ui.comboBoxSecondPoint); + + connect(ui.toolButtonPutHere, &QPushButton::clicked, this, &DialogPointOfContact::PutHere); + connect(ui.listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal); + connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogPointOfContact::ValChenged); + + ShowVariable(data->DataBase()); + connect(ui.radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogPointOfContact::SizeGrowth); + connect(ui.radioButtonStandartTable, &QRadioButton::clicked, this, &DialogPointOfContact::StandartTable); + connect(ui.radioButtonIncrements, &QRadioButton::clicked, this, &DialogPointOfContact::Increments); + connect(ui.radioButtonLengthLine, &QRadioButton::clicked, this, &DialogPointOfContact::LengthLines); + connect(ui.toolButtonEqual, &QPushButton::clicked, this, &DialogPointOfContact::EvalFormula); + connect(ui.lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged); + connect(ui.lineEditFormula, &QLineEdit::textChanged, this, &DialogPointOfContact::FormulaChanged); +} + +void DialogPointOfContact::ChoosedObject(qint64 id, Scene::Type type){ + if(type == Scene::Point){ + VPointF point = data->GetPoint(id); + if(number == 0){ + qint32 index = ui.comboBoxFirstPoint->findText(point.name()); + if ( index != -1 ) { // -1 for not found + ui.comboBoxFirstPoint->setCurrentIndex(index); + number++; + return; + } + } + if(number == 1){ + qint32 index = ui.comboBoxSecondPoint->findText(point.name()); + if ( index != -1 ) { // -1 for not found + ui.comboBoxSecondPoint->setCurrentIndex(index); + number++; + return; + } + } + if(number == 2){ + qint32 index = ui.comboBoxCenter->findText(point.name()); + if ( index != -1 ) { // -1 for not found + ui.comboBoxCenter->setCurrentIndex(index); + number = 0; + } + if(!isInitialized){ + this->show(); + } + } + } +} + + +void DialogPointOfContact::DialogAccepted(){ + pointName = ui.lineEditNamePoint->text(); + radius = ui.lineEditFormula->text(); + center = getCurrentPointId(ui.comboBoxCenter); + firstPoint = getCurrentPointId(ui.comboBoxFirstPoint); + secondPoint = getCurrentPointId(ui.comboBoxSecondPoint); + emit DialogClosed(QDialog::Accepted); +} + +qint64 DialogPointOfContact::getSecondPoint() const{ + return secondPoint; +} + +void DialogPointOfContact::setSecondPoint(const qint64 &value, const qint64 &id){ + setCurrentPointId(ui.comboBoxSecondPoint, secondPoint, value, id); +} + +qint64 DialogPointOfContact::getFirstPoint() const{ + return firstPoint; +} + +void DialogPointOfContact::setFirstPoint(const qint64 &value, const qint64 &id){ + setCurrentPointId(ui.comboBoxFirstPoint, firstPoint, value, id); +} + +qint64 DialogPointOfContact::getCenter() const{ + return center; +} + +void DialogPointOfContact::setCenter(const qint64 &value, const qint64 &id){ + setCurrentPointId(ui.comboBoxCenter, center, value, id); + center = value; +} + +QString DialogPointOfContact::getRadius() const{ + return radius; +} + +void DialogPointOfContact::setRadius(const QString &value){ + radius = value; + ui.lineEditFormula->setText(radius); +} + +QString DialogPointOfContact::getPointName() const{ + return pointName; +} + +void DialogPointOfContact::setPointName(const QString &value){ + pointName = value; + ui.lineEditNamePoint->setText(pointName); +} diff --git a/dialogs/dialogpointofcontact.h b/dialogs/dialogpointofcontact.h new file mode 100644 index 000000000..e02ff16cc --- /dev/null +++ b/dialogs/dialogpointofcontact.h @@ -0,0 +1,52 @@ +#ifndef DIALOGPOINTOFCONTACT_H +#define DIALOGPOINTOFCONTACT_H + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" +#include "ui_dialogpointofcontact.h" +#include "dialogtool.h" +#pragma GCC diagnostic pop +#include "../options.h" +#include "../container/vcontainer.h" +#include "../container/calculator.h" + +class DialogPointOfContact : public DialogTool +{ + Q_OBJECT + +public: + explicit DialogPointOfContact(const VContainer *data, QWidget *parent = 0); + QString getPointName() const; + void setPointName(const QString &value); + + QString getRadius() const; + void setRadius(const QString &value); + + qint64 getCenter() const; + void setCenter(const qint64 &value, const qint64 &id); + + qint64 getFirstPoint() const; + void setFirstPoint(const qint64 &value, const qint64 &id); + + qint64 getSecondPoint() const; + void setSecondPoint(const qint64 &value, const qint64 &id); + +public slots: + virtual void ChoosedObject(qint64 id, Scene::Type type); + virtual void DialogAccepted(); +private: + Ui::DialogPointOfContact ui; + qint32 number; + QString pointName; + QString radius; + qint64 center; + qint64 firstPoint; + qint64 secondPoint; + DialogPointOfContact(const DialogPointOfContact &dialog); + const DialogPointOfContact &operator=(const DialogPointOfContact& dialog); +}; + +#endif // DIALOGPOINTOFCONTACT_H diff --git a/dialogs/dialogpointofcontact.ui b/dialogs/dialogpointofcontact.ui new file mode 100644 index 000000000..45a173603 --- /dev/null +++ b/dialogs/dialogpointofcontact.ui @@ -0,0 +1,348 @@ + + + DialogPointOfContact + + + + 0 + 0 + 476 + 450 + + + + Dialog + + + + + + + + + 0 + 0 + + + + Радіус + + + + + + + + 0 + 0 + + + + + + + + ... + + + + :/icon/24x24/equal.png:/icon/24x24/equal.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + _ + + + + + + + + + + + + + + + + 0 + 0 + + + + Ім'я нової точки + + + + + + + + + + ... + + + + :/icon/24x24/putHere.png:/icon/24x24/putHere.png + + + + 24 + 24 + + + + + + + + + + + + + 0 + 0 + + + + Центр дуги + + + + + + + + 0 + 0 + + + + + 145 + 0 + + + + + + + + + + + + + 0 + 0 + + + + Початок лінії + + + + + + + + 0 + 0 + + + + + 143 + 0 + + + + + + + + + + + + + 0 + 0 + + + + Кінець лінії + + + + + + + + 0 + 0 + + + + + 145 + 0 + + + + + + + + + + + + Вхідні данні + + + + + + + Розмір і зріст + + + true + + + + + + + Стандартна таблиця + + + + + + + Прибавки + + + + + + + true + + + Довжини ліній + + + + + + + false + + + Довжини дуг + + + + + + + false + + + Довжини сплайні + + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DialogPointOfContact + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogPointOfContact + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/dialogs/dialogshoulderpoint.cpp b/dialogs/dialogshoulderpoint.cpp index 3d40e65fa..f6f8b9201 100644 --- a/dialogs/dialogshoulderpoint.cpp +++ b/dialogs/dialogshoulderpoint.cpp @@ -1,5 +1,11 @@ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" #include "dialogshoulderpoint.h" #include "ui_dialogshoulderpoint.h" +#pragma GCC diagnostic pop DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, QWidget *parent) : DialogTool(data, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()), diff --git a/dialogs/dialogshoulderpoint.h b/dialogs/dialogshoulderpoint.h index 2104dc17c..3a80eff8d 100644 --- a/dialogs/dialogshoulderpoint.h +++ b/dialogs/dialogshoulderpoint.h @@ -1,7 +1,13 @@ #ifndef DIALOGSHOULDERPOINT_H #define DIALOGSHOULDERPOINT_H +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" #include "dialogtool.h" +#pragma GCC diagnostic pop #include "../options.h" #include "../container/vcontainer.h" #include "../container/calculator.h" diff --git a/icon.qrc b/icon.qrc index a627cf202..961116aff 100644 --- a/icon.qrc +++ b/icon.qrc @@ -30,5 +30,6 @@ icon/32x32/splinePath.png icon/32x32/history.png icon/32x32/put_after.png + icon/32x32/point_of_contact.png diff --git a/icon/32x32/point_of_contact.png b/icon/32x32/point_of_contact.png new file mode 100644 index 0000000000000000000000000000000000000000..110aa8fdfa99ecaf41f2e02f0b72e50c5768a512 GIT binary patch literal 977 zcmV;?11|iDP)6CB1VE2)RbC^RHYZC7nqsvxHxCXpkO;QZG4kSCMP-X`<&-}-pd#CX*CA1 zFaHLxfGNy2Xs&g?vH`)5L{8#09K%8E4BV`+SW^C%k7^&mtNGQ(aRLW21GjK6G9UOY zGx9(y`XFEs`yx-|;6oX}D4xn^yVr73^eKUMzyXAO7BCdqz8(if$E9wqiG|1?Xmp&% z$YNmHIz(7t3=j1Hq8a%GGbKwg1&%Rk;3BTz`g#D2OG@nuK!awJ`4-noR$G)UR!Yv{ zgTT24t84kGN=m(r*h3nI@o*Mo#I?wol8;*~u2%!gX!QUfWcChcAa`&X=Ocfv*GVDK z6nm_I1G(|E>;D_fcH^(;@%5xKdp5HGH!^^QZk!a>Xq8>i|1*Bd|GNV4ztP`MC)^PF z?+&9pSlVF9HOAdGNbW>4wM6AoT2A z`OT!ioq|)@;b5SQ9E}_*)2#mzGue3q@lBq-%CSX;uXAUv5Bl2xo(ybli!!jiN&X#!>9RBU>r!9c$bWMJ1*0L{8NWX+LPEtn66f>Un78Vd{2+ zR;A!|Y|CI8k>BxkyzTNfLMO4(Auw-3zD@5(@)4c+4O# z1>Os_bXe*5M!3^R6Y@b_uxmgCMRD)O6)_ulH|WpS0(1n23&x9oSKA`qujt=m-YJ%H z1x(>PT*9}3zY4}fs;0a12EPVAtJ+wL9c4UQNnb~|Fp`LoHZ00000NkvXXu0mjfG}Oe5 literal 0 HcmV?d00001 diff --git a/mainwindow.cpp b/mainwindow.cpp index 3d00cf6d4..8ee56ac4e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -23,6 +23,7 @@ #include "tools/vtoolspline.h" #include "tools/vtoolarc.h" #include "tools/vtoolsplinepath.h" +#include "tools/vtoolpointofcontact.h" #pragma GCC diagnostic pop #include "geometry/vspline.h" @@ -36,7 +37,8 @@ MainWindow::MainWindow(QWidget *parent) : dialogLineIntersect(QSharedPointer()), dialogSpline(QSharedPointer()), dialogArc(QSharedPointer()), dialogSplinePath(QSharedPointer()), - dialogHistory(0), doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false){ + dialogPointOfContact(QSharedPointer()), dialogHistory(0), + doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false){ ui->setupUi(this); ToolBarOption(); ToolBarDraws(); @@ -74,6 +76,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->toolButtonSpline, &QToolButton::clicked, this, &MainWindow::ToolSpline); connect(ui->toolButtonArc, &QToolButton::clicked, this, &MainWindow::ToolArc); connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, &MainWindow::ToolSplinePath); + connect(ui->toolButtonPointOfContact, &QToolButton::clicked, this, &MainWindow::ToolPointOfContact); data = new VContainer; @@ -317,6 +320,18 @@ void MainWindow::ClosedDialogSplinePath(int result){ ArrowTool(); } +void MainWindow::ToolPointOfContact(bool checked){ + SetToolButton(checked, Tools::PointOfContact, ":/cursor/pointcontact_cursor.png", dialogPointOfContact, + &MainWindow::ClosedDialogPointOfContact); +} + +void MainWindow::ClosedDialogPointOfContact(int result){ + if(result == QDialog::Accepted){ + VToolPointOfContact::Create(dialogPointOfContact, scene, doc, data); + } + ArrowTool(); +} + void MainWindow::showEvent( QShowEvent *event ){ QMainWindow::showEvent( event ); if( event->spontaneous() ){ @@ -479,6 +494,12 @@ void MainWindow::CanselTool(){ scene->setFocus(Qt::OtherFocusReason); scene->clearSelection(); break; + case Tools::PointOfContact: + dialogPointOfContact.clear(); + ui->toolButtonPointOfContact->setChecked(false); + scene->setFocus(Qt::OtherFocusReason); + scene->clearSelection(); + break; } } @@ -685,6 +706,7 @@ void MainWindow::SetEnableTool(bool enable){ ui->toolButtonSpline->setEnabled(enable); ui->toolButtonArc->setEnabled(enable); ui->toolButtonSplinePath->setEnabled(enable); + ui->toolButtonPointOfContact->setEnabled(enable); } MainWindow::~MainWindow(){ diff --git a/mainwindow.h b/mainwindow.h index 5a205eb48..f4e3e458e 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -28,6 +28,7 @@ #include "dialogs/dialogarc.h" #include "dialogs/dialogsplinepath.h" #include "dialogs/dialoghistory.h" +#include "dialogs/dialogpointofcontact.h" #include "tools/vtoolsinglepoint.h" #include "xml/vdomdocument.h" #pragma GCC diagnostic pop @@ -83,6 +84,8 @@ public slots: void ClosedDialogArc(int result); void ToolSplinePath(bool checked); void ClosedDialogSplinePath(int result); + void ToolPointOfContact(bool checked); + void ClosedDialogPointOfContact(int result); protected: virtual void keyPressEvent ( QKeyEvent * event ); virtual void showEvent( QShowEvent *event ); @@ -105,6 +108,7 @@ private: QSharedPointer dialogSpline; QSharedPointer dialogArc; QSharedPointer dialogSplinePath; + QSharedPointer dialogPointOfContact; DialogHistory *dialogHistory; VDomDocument *doc; VContainer *data; diff --git a/mainwindow.ui b/mainwindow.ui index 408dce2de..49b0b634e 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -166,6 +166,29 @@ + + + + false + + + ... + + + + :/icon/32x32/point_of_contact.png:/icon/32x32/point_of_contact.png + + + + 32 + 32 + + + + true + + + @@ -173,7 +196,7 @@ 0 0 - 100 + 150 58 @@ -240,7 +263,7 @@ 0 0 - 100 + 150 58 @@ -307,7 +330,7 @@ 0 0 - 87 + 150 58 diff --git a/options.h b/options.h index 8bb658500..cfabb4e4e 100644 --- a/options.h +++ b/options.h @@ -31,7 +31,8 @@ namespace Tools{ LineIntersectTool, SplineTool, ArcTool, - SplinePathTool + SplinePathTool, + PointOfContact }; } diff --git a/tools/vtoolpointofcontact.cpp b/tools/vtoolpointofcontact.cpp new file mode 100644 index 000000000..8b15f21d3 --- /dev/null +++ b/tools/vtoolpointofcontact.cpp @@ -0,0 +1,146 @@ +#include "vtoolpointofcontact.h" + +VToolPointOfContact::VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, + const QString &radius, const qint64 ¢er, + const qint64 &firstPointId, const qint64 &secondPointId, + Tool::Enum typeCreation, QGraphicsItem *parent) + : VToolPoint(doc, data, id, parent), radius(radius), center(center), firstPointId(firstPointId), + secondPointId(secondPointId), dialogPointOfContact(QSharedPointer()){ + + if(typeCreation == Tool::FromGui){ + AddToFile(); + } +} + +void VToolPointOfContact::setDialog(){ + Q_ASSERT(!dialogPointOfContact.isNull()); + if(!dialogPointOfContact.isNull()){ + VPointF p = VAbstractTool::data.GetPoint(id); + dialogPointOfContact->setRadius(radius); + dialogPointOfContact->setCenter(center, id); + dialogPointOfContact->setFirstPoint(firstPointId, id); + dialogPointOfContact->setSecondPoint(secondPointId, id); + dialogPointOfContact->setPointName(p.name()); + } +} + +QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint, + const QPointF &secondPoint){ + QPointF pArc; + qreal s = 0.0, s_x, s_y, step = 0.01, distans; + while( s < 1){ + s_x = secondPoint.x()-(qAbs(secondPoint.x()-firstPoint.x()))*s; + s_y = secondPoint.y()-(qAbs(secondPoint.y()-firstPoint.y()))*s; + distans = QLineF(center.x(), center.y(), s_x, s_y).length(); + if(ceil(distans*10) == ceil(radius*10)){ + pArc.rx() = s_x; + pArc.ry() = s_y; + break; + } + if(distans &dialog, VMainGraphicsScene *scene, + VDomDocument *doc, VContainer *data){ + QString radius = dialog->getRadius(); + qint64 center = dialog->getCenter(); + qint64 firstPointId = dialog->getFirstPoint(); + qint64 secondPointId = dialog->getSecondPoint(); + QString pointName = dialog->getPointName(); + Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data, + Document::FullParse, Tool::FromGui); +} + +void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const qint64 ¢er, + const qint64 &firstPointId, const qint64 &secondPointId, + const QString &pointName, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + Document::Enum parse, Tool::Enum typeCreation){ + VPointF centerP = data->GetPoint(center); + VPointF firstP = data->GetPoint(firstPointId); + VPointF secondP = data->GetPoint(secondPointId); + + Calculator cal(data); + QString errorMsg; + qreal result = cal.eval(radius, &errorMsg); + if(errorMsg.isEmpty()){ + QPointF fPoint = VToolPointOfContact::FindPoint(result*PrintDPI/25.4, centerP.toQPointF(), + firstP.toQPointF(), secondP.toQPointF()); + qint64 id = _id; + if(typeCreation == Tool::FromGui){ + id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); + } else { + data->UpdatePoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); + if(parse != Document::FullParse){ + QMap* tools = doc->getTools(); + VDataTool *tool = tools->value(id); + tool->VDataTool::setData(data); + tools->insert(id, tool); + } + } + VAbstractTool::AddRecord(id, Tools::PointOfContact, doc); + if(parse == Document::FullParse){ + VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center, + firstPointId, secondPointId, typeCreation); + scene->addItem(point); + connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(point, &VToolPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); + QMap* tools = doc->getTools(); + tools->insert(id,point); + } + } +} + +void VToolPointOfContact::FullUpdateFromFile(){ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if(domElement.isElement()){ + radius = domElement.attribute("radius", ""); + center = domElement.attribute("center", "").toLongLong(); + firstPointId = domElement.attribute("firstPoint", "").toLongLong(); + secondPointId = domElement.attribute("secondPoint", "").toLongLong(); + } + RefreshGeometry(); +} + +void VToolPointOfContact::FullUpdateFromGui(int result){ + if(result == QDialog::Accepted){ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if(domElement.isElement()){ + domElement.setAttribute("name", dialogPointOfContact->getPointName()); + domElement.setAttribute("radius", dialogPointOfContact->getRadius()); + domElement.setAttribute("center", QString().setNum(dialogPointOfContact->getCenter())); + domElement.setAttribute("firstPoint", QString().setNum(dialogPointOfContact->getFirstPoint())); + domElement.setAttribute("secondPoint", QString().setNum(dialogPointOfContact->getSecondPoint())); + emit FullUpdateTree(); + } + } + dialogPointOfContact.clear(); +} + +void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ + ContextMenu(dialogPointOfContact, this, event); +} + +void VToolPointOfContact::AddToFile(){ + VPointF point = VAbstractTool::data.GetPoint(id); + QDomElement domElement = doc->createElement("point"); + + AddAttribute(domElement, "id", id); + AddAttribute(domElement, "type", "pointOfContact"); + AddAttribute(domElement, "name", point.name()); + AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4); + AddAttribute(domElement, "my", point.my()/PrintDPI*25.4); + + AddAttribute(domElement, "radius", radius); + AddAttribute(domElement, "center", center); + AddAttribute(domElement, "firstPoint", firstPointId); + AddAttribute(domElement, "secondPoint", secondPointId); + + AddToCalculation(domElement); +} diff --git a/tools/vtoolpointofcontact.h b/tools/vtoolpointofcontact.h new file mode 100644 index 000000000..1c4fa2a53 --- /dev/null +++ b/tools/vtoolpointofcontact.h @@ -0,0 +1,36 @@ +#ifndef VTOOLPOINTOFCONTACT_H +#define VTOOLPOINTOFCONTACT_H + +#include "vtoolpoint.h" +#include "../dialogs/dialogpointofcontact.h" + +class VToolPointOfContact : public VToolPoint +{ +public: + VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, + const QString &radius, const qint64 ¢er, const qint64 &firstPointId, + const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem * parent = 0); + virtual void setDialog(); + static QPointF FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint, + const QPointF &secondPoint); + static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, + VDomDocument *doc, VContainer *data); + static void Create(const qint64 _id, const QString &radius, const qint64 ¢er, const qint64 &firstPointId, + const qint64 &secondPointId, const QString &pointName, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, + VContainer *data, Document::Enum parse, Tool::Enum typeCreation); +public slots: + virtual void FullUpdateFromFile(); + virtual void FullUpdateFromGui(int result); +protected: + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void AddToFile(); +private: + QString radius; + qint64 center; + qint64 firstPointId; + qint64 secondPointId; + QSharedPointer dialogPointOfContact; +}; + +#endif // VTOOLPOINTOFCONTACT_H diff --git a/tools/vtoolsplinepath.cpp b/tools/vtoolsplinepath.cpp index b4af95a76..67ccaf662 100644 --- a/tools/vtoolsplinepath.cpp +++ b/tools/vtoolsplinepath.cpp @@ -102,8 +102,8 @@ void VToolSplinePath::FullUpdateFromGui(int result){ spl = VSpline (VAbstractTool::data.DataPoints(), spl.GetP1(), controlPoints[j-2]->pos(), controlPoints[j-1]->pos(), spl.GetP4(), splPath.getKCurve()); - CorectControlPoints(spl, splPath, i-1, i, SplinePoint::FirstPoint); - CorectControlPoints(spl, splPath, i, i, SplinePoint::LastPoint); + CorectControlPoints(spl, splPath, i); + CorectControlPoints(spl, splPath, i); QDomElement domElement = doc->elementById(QString().setNum(id)); if(domElement.isElement()){ @@ -118,20 +118,16 @@ void VToolSplinePath::FullUpdateFromGui(int result){ } void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position, - const QPointF pos) -{ - qint32 index = 0; + const QPointF pos){ VSplinePath splPath = VAbstractTool::data.GetSplinePath(id); VSpline spl = splPath.GetSpline(indexSpline); if(position == SplinePoint::FirstPoint){ spl.ModifiSpl (spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve()); - index = indexSpline - 1; } else { spl.ModifiSpl (spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve()); - index = indexSpline; } - CorectControlPoints(spl, splPath, index, indexSpline, position); + CorectControlPoints(spl, splPath, indexSpline); QDomElement domElement = doc->elementById(QString().setNum(id)); if(domElement.isElement()){ domElement.setAttribute("kCurve", QString().setNum(splPath.getKCurve())); @@ -140,8 +136,8 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, Spli } } -void VToolSplinePath::CorectControlPoints(const VSpline &spl, VSplinePath &splPath, qint32 index, - const qint32 &indexSpline, SplinePoint::Position position){ +void VToolSplinePath::CorectControlPoints(const VSpline &spl, VSplinePath &splPath, + const qint32 &indexSpline){ VSplinePoint p = splPath.GetSplinePoint(indexSpline, SplinePoint::FirstPoint); p.SetAngle(spl.GetAngle1()); p.SetKAsm2(spl.GetKasm1()); @@ -151,26 +147,6 @@ void VToolSplinePath::CorectControlPoints(const VSpline &spl, VSplinePath &splPa p.SetAngle(spl.GetAngle2()-180); p.SetKAsm1(spl.GetKasm2()); splPath.UpdatePoint(indexSpline, SplinePoint::LastPoint, p); - - if(index > 0 && index < splPath.CountPoint()-1){ - if(position == SplinePoint::FirstPoint){ - VSpline spl = splPath.GetSpline(indexSpline-1); - qint32 i = (indexSpline-1)*2-1; - disconnect(controlPoints[i], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - controlPoints[i]->setPos(spl.GetP3()); - connect(controlPoints[i], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - } else { - VSpline spl = splPath.GetSpline(indexSpline+1); - qint32 i = (indexSpline+1)*2-2; - disconnect(controlPoints[i], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - controlPoints[i]->setPos(spl.GetP2()); - connect(controlPoints[i], &VControlPointSpline::ControlPointChangePosition, this, - &VToolSplinePath::ControlPointChangePosition); - } - } } void VToolSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path){ @@ -271,10 +247,10 @@ void VToolSplinePath::RefreshGeometry(){ this->setPath(path); for(qint32 i = 1; i<=splPath.Count(); ++i){ VSpline spl = splPath.GetSpline(i); - QPointF splinePoint = VAbstractTool::data.GetPoint(spl.GetP1()).toQPointF(); + QPointF splinePoint = spl.GetPointP1().toQPointF(); QPointF controlPoint = spl.GetP2(); emit RefreshLine(i, SplinePoint::FirstPoint, controlPoint, splinePoint); - splinePoint = VAbstractTool::data.GetPoint(spl.GetP4()).toQPointF(); + splinePoint = spl.GetPointP4().toQPointF(); controlPoint = spl.GetP3(); emit RefreshLine(i, SplinePoint::LastPoint, controlPoint, splinePoint); diff --git a/tools/vtoolsplinepath.h b/tools/vtoolsplinepath.h index e3daa5edc..9a6c416c8 100644 --- a/tools/vtoolsplinepath.h +++ b/tools/vtoolsplinepath.h @@ -49,9 +49,8 @@ private: void RefreshGeometry(); void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint); void UpdatePathPoint(QDomNode& node, VSplinePath &path); - void CorectControlPoints(const VSpline &spl, VSplinePath &splPath, qint32 index, - const qint32 &indexSpline, - SplinePoint::Position position); + void CorectControlPoints(const VSpline &spl, VSplinePath &splPath, + const qint32 &indexSpline); }; #endif // VTOOLSPLINEPATH_H diff --git a/xml/vdomdocument.cpp b/xml/vdomdocument.cpp index 34a8a2e4a..79b766029 100644 --- a/xml/vdomdocument.cpp +++ b/xml/vdomdocument.cpp @@ -16,6 +16,7 @@ #include "../tools/vtoolspline.h" #include "../tools/vtoolarc.h" #include "../tools/vtoolsplinepath.h" +#include "../tools/vtoolpointofcontact.h" #pragma GCC diagnostic pop #include "../options.h" #include "../container/calculator.h" @@ -242,7 +243,7 @@ void VDomDocument::Parse(Document::Enum parse, VMainGraphicsScene *scene){ data->ClearLengthLines(); data->ClearLengthArcs(); data->ClearLengthSplines(); - data->ClearLineArcs(); + data->ClearLineAngles(); history.clear(); QDomElement rootElement = this->documentElement(); QDomNode domNode = rootElement.firstChild(); @@ -477,6 +478,21 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen } return; } + if(type == "pointOfContact"){ + if(!domElement.isNull()){ + qint64 id = domElement.attribute("id", "").toLongLong(); + QString name = domElement.attribute("name", ""); + qreal mx = domElement.attribute("mx","").toDouble()*PrintDPI/25.4; + qreal my = domElement.attribute("my","").toDouble()*PrintDPI/25.4; + QString radius = domElement.attribute("radius", ""); + qint64 center = domElement.attribute("center", "").toLongLong(); + qint64 firstPointId = domElement.attribute("firstPoint", "").toLongLong(); + qint64 secondPointId = domElement.attribute("secondPoint", "").toLongLong(); + VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my, + scene, this, data, parse, Tool::FromFile); + } + return; + } } void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement, @@ -527,7 +543,7 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme } } } - VToolSplinePath::Create(id, path, scene, this, data, Document::FullParse, Tool::FromFile); + VToolSplinePath::Create(id, path, scene, this, data, parse, Tool::FromFile); } return; } @@ -576,26 +592,28 @@ void VDomDocument::setCursor(const qint64 &value){ void VDomDocument::setCurrentData(){ QString nameDraw = comboBoxDraws->itemText(comboBoxDraws->currentIndex()); - nameActivDraw = nameDraw; - qint64 id = 0; - if(history.size() == 0){ - return; - } - for(qint32 i = 0; i < history.size(); ++i){ - VToolRecord tool = history.at(i); - if(tool.getNameDraw() == nameDraw){ - id = tool.getId(); - } - } - if(id == 0){ - VToolRecord tool = history.at(history.size()-1); - id = tool.getId(); - if(id == 0){ + if(nameActivDraw != nameDraw){ + nameActivDraw = nameDraw; + qint64 id = 0; + if(history.size() == 0){ return; } - } - if(tools.size() > 0){ - VDataTool *vTool = tools.value(id); - data->setData(vTool->getData()); + for(qint32 i = 0; i < history.size(); ++i){ + VToolRecord tool = history.at(i); + if(tool.getNameDraw() == nameDraw){ + id = tool.getId(); + } + } + if(id == 0){ + VToolRecord tool = history.at(history.size()-1); + id = tool.getId(); + if(id == 0){ + return; + } + } + if(tools.size() > 0){ + VDataTool *vTool = tools.value(id); + data->setData(vTool->getData()); + } } }