From 1ba4725538e8d6985c5b572aeb3408dd05107431 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 25 May 2015 15:49:28 +0300 Subject: [PATCH 1/8] Method intersection circles. --HG-- branch : feature --- src/libs/vgeometry/vgobject.cpp | 25 +++++++++++++++++++++++++ src/libs/vgeometry/vgobject.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp index 6a66bd978..d2ca296c1 100644 --- a/src/libs/vgeometry/vgobject.cpp +++ b/src/libs/vgeometry/vgobject.cpp @@ -260,6 +260,19 @@ QPointF VGObject::LineIntersectRect(const QRectF &rec, const QLineF &line) return point; } +//--------------------------------------------------------------------------------------------------------------------- +int VGObject::IntersectionCircles(const QPointF &c1, double r1, const QPointF &c2, double r2, QPointF &p1, QPointF &p2) +{ + if (qFuzzyCompare(c1.x(), c2.x()) && qFuzzyCompare(c1.y(), c2.y()) && qFuzzyCompare(r1, r2)) + { + return 3;// Circles are equal + } + const double a = 2.0 * (c2.x() - c1.x()); + const double b = 2.0 * (c2.y() - c1.y()); + const double c = c1.x() * c1.x() + c1.y() * c1.y() - r1 * r1 - (c2.x() * c2.x() + c2.y() * c2.y() - r2 * r2); + return LineIntersectCircle (c1, r1, CreateSegment(a, b, c), p1, p2); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief LineIntersectCircle find point intersection line and circle. @@ -416,6 +429,18 @@ double VGObject::GetEpsilon(const QPointF &p1, const QPointF &p2) return epsilon; } +//--------------------------------------------------------------------------------------------------------------------- +QLineF VGObject::CreateSegment(double a, double b, double c) +{ + const double x1 = 0; + const double y1 = (-a*x1-c)/b; + + const double x2 = 1000; + const double y2 = (-a*x2-c)/b; + + return QLineF(x1, y1, x2, y2); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief GetReversePoint return revers container of points. diff --git a/src/libs/vgeometry/vgobject.h b/src/libs/vgeometry/vgobject.h index 5ad5d0b7c..2e32741b3 100644 --- a/src/libs/vgeometry/vgobject.h +++ b/src/libs/vgeometry/vgobject.h @@ -73,6 +73,8 @@ public: static QLineF BuildAxis(const QPointF &p1, const QPointF &p2, const QRectF &scRect); static QPointF LineIntersectRect(const QRectF &rec, const QLineF &line); + static int IntersectionCircles(const QPointF &c1, double r1, const QPointF &c2, double r2, QPointF &p1, + QPointF &p2); static qint32 LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1, QPointF &p2); static QPointF ClosestPoint(const QLineF &line, const QPointF &point); @@ -88,6 +90,7 @@ private: static bool IsPointOnLineviaPDP(const QPointF &t, const QPointF &p1, const QPointF &p2); static double PerpDotProduct(const QPointF &t, const QPointF &p1, const QPointF &p2); static double GetEpsilon(const QPointF &p1, const QPointF &p2); + static QLineF CreateSegment(double a, double b, double c); }; #endif // VGOBJECT_H From 99bb6bb98302c42edbd2b7422da15e7964422eb8 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 25 May 2015 15:51:44 +0300 Subject: [PATCH 2/8] Refactoring. --HG-- branch : feature --- src/libs/vgeometry/vgobject.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp index d2ca296c1..6046fe5bf 100644 --- a/src/libs/vgeometry/vgobject.cpp +++ b/src/libs/vgeometry/vgobject.cpp @@ -289,10 +289,10 @@ qint32 VGObject::LineIntersectCircle(const QPointF ¢er, qreal radius, const qreal a = 0, b = 0, c = 0; LineCoefficients(line, &a, &b, &c); // projection center of circle on to line - QPointF p = ClosestPoint (line, center); + const QPointF p = ClosestPoint (line, center); // how many solutions? qint32 flag = 0; - qreal d = QLineF (center, p).length(); + const qreal d = QLineF (center, p).length(); if (qFuzzyCompare(d, radius)) { flag = 1; @@ -309,8 +309,8 @@ qint32 VGObject::LineIntersectCircle(const QPointF ¢er, qreal radius, const } } // find distance from projection to points of intersection - qreal k = qSqrt (qAbs(radius * radius - d * d)); - qreal t = QLineF (QPointF (0, 0), QPointF (b, - a)).length(); + const qreal k = qSqrt (qAbs(radius * radius - d * d)); + const qreal t = QLineF (QPointF (0, 0), QPointF (b, - a)).length(); // add to projection a vectors aimed to points of intersection p1 = addVector (p, QPointF (0, 0), QPointF (- b, a), k / t); p2 = addVector (p, QPointF (0, 0), QPointF (b, - a), k / t); From 086a2ebaa93fdc07d4e7c02f616abfa6181ecd3f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 25 May 2015 16:00:52 +0300 Subject: [PATCH 3/8] Toolbutton for tool "Point of intersection arcs". --HG-- branch : feature --- src/app/mainwindow.cpp | 1 + src/app/mainwindow.ui | 25 ++++- src/app/share/resources/cursor.qrc | 1 + .../cursor/point_of_intersection_arcs.png | Bin 0 -> 1332 bytes src/app/share/resources/icon.qrc | 1 + .../icon/32x32/point_of_intersection_arcs.png | Bin 0 -> 1542 bytes .../icon/svg/point_of_intersection_arcs.svg | 101 ++++++++++++++++++ 7 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 src/app/share/resources/cursor/point_of_intersection_arcs.png create mode 100644 src/app/share/resources/icon/32x32/point_of_intersection_arcs.png create mode 100644 src/app/share/resources/icon/svg/point_of_intersection_arcs.svg diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index e38a66335..489c54a29 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -2128,6 +2128,7 @@ void MainWindow::SetEnableTool(bool enable) ui->toolButtonLineIntersectAxis->setEnabled(drawTools); ui->toolButtonCurveIntersectAxis->setEnabled(drawTools); ui->toolButtonArcIntersectAxis->setEnabled(drawTools); + ui->toolButtonPointOfIntersectionArcs->setEnabled(drawTools); ui->actionLast_tool->setEnabled(drawTools); diff --git a/src/app/mainwindow.ui b/src/app/mainwindow.ui index d3f5123c9..b04af4683 100644 --- a/src/app/mainwindow.ui +++ b/src/app/mainwindow.ui @@ -43,7 +43,7 @@ - 4 + 3 @@ -662,6 +662,29 @@ + + + + false + + + Point of intersection arcs + + + ... + + + + :/icon/32x32/point_of_intersection_arcs.png:/icon/32x32/point_of_intersection_arcs.png + + + + 32 + 32 + + + + diff --git a/src/app/share/resources/cursor.qrc b/src/app/share/resources/cursor.qrc index 1aec9decd..5dacc775f 100644 --- a/src/app/share/resources/cursor.qrc +++ b/src/app/share/resources/cursor.qrc @@ -24,5 +24,6 @@ cursor/line_intersect_axis_cursor.png cursor/arc_intersect_axis_cursor.png cursor/curve_intersect_axis_cursor.png + cursor/point_of_intersection_arcs.png diff --git a/src/app/share/resources/cursor/point_of_intersection_arcs.png b/src/app/share/resources/cursor/point_of_intersection_arcs.png new file mode 100644 index 0000000000000000000000000000000000000000..fda5eb7af4401916715330c7a6dda01c4089b79b GIT binary patch literal 1332 zcmV-41Vl&|00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-vt>95fc%A9uNQk06}y` zSad^gZEa<4bO1wAML|?gQaT`KWG!lNWoICEF)lD5D0OpbZf77#N=G0{P(?=|b~Z98 zEFf`pVQgu1c_2L?IWP*aMOc#n00eYNL_t(Y$HkX#Ow@H8$6w#y?{^{R0dhD*ph?5g zT7w>RrB2uywtzZ7bT-zbnoqn&rqymOms|B9AGlhx2W_ooPlUx-OwW~LjdN{6eLp?W-*wPQB%FP=@AmzCf8Xu>`Tzd@;Qy38d-lxIw{PFB?yCX2 zckjMjU0p4Hzh6Y;k^2hX)YNnekgBRGNk1PN8p)2QYy8aZ#g+R zQeIvziw=8wh2O0Jl~S|xnVA{fZZ`u11C{;#{dskDb>U5$Hr-rQ!DR}4CPS1`3=aFCML+w&wm~GV99cRH)BKutu-RTnKNg&apMNjXf*EJIdS5|!olaO_Dm_UENfO8 zwAS?X^}W;9)^_RO!GqV&0MQ$t26h1Qz9 zygc#wd}?}nde+3VZ5zw7@Z@{YS`(d)a`Wa!PM+Kfyxj#%f%>MKeaEMs`6~I+t}8w? ztv~@_1APFrwzj7D91z1WoEFnoxVHk*r7={rOk>9k|=eoPQJqrUby`HXxzpc9T!^X202gCle$p-rxg~-U|i*)RI z1N>aI=CYdB+6E>&Iy#P*mX>yUz22X;ZQC~WpS$8PrX8cT<=DtpJo^%g>m5S)bYf#lKR;-mqPNF)HHu&{7y$BrG}1HnWhan!c$$YI@bLh*XeNP_+h9!RGE#UBPM?H#9~&JtEP!}C4q%s+l}#Nu zaNt>h{rmT)+9)26rw9fh7K<@6GcybH$=Y>PKT*SvAATA)U`BFC&S_c|XLZtmF%5s_ z+~x>qY;5!cFDRw_hYlTD^iRXfVDSrHLcB^ySr9fM@(TREa?vc9o12Sin)6>ef{PGu za*+a*tboW{5O&=&n9JqDFpPOeuOkHo1@Il~KHggV+53F-ImCRaHWK2CJ0o2IeSZN26ZD=DE;e`o0000icon/16x16/roll.png icon/16x16/progress.gif icon/32x32/export_to_picture_document.png + icon/32x32/point_of_intersection_arcs.png diff --git a/src/app/share/resources/icon/32x32/point_of_intersection_arcs.png b/src/app/share/resources/icon/32x32/point_of_intersection_arcs.png new file mode 100644 index 0000000000000000000000000000000000000000..e9e583428aa1715661ecbb7d2bc8f76a050adbb8 GIT binary patch literal 1542 zcmV+h2Ko7kP)I000McNliru-vt>94=8js$m;+A1(Qic zK~z}7wby-Y)>jn=@Xvjo(gG_jH1ZAuVQhv107KM6xLE&-l6St{p0yP<>?D^i}fVG zJmdkBPAtQD9K?RIwTwGJeF!>Y^l`mtlVFKxvtc^T z7fch46^#;{!wEs7V4GpyaZ+cX@qXe;j6gfyM+;745GG+LI`9vyBKt}-u9<0R2F8Uy zIS{vwX-gUA9z2E5U?46g`i|ooj7)SDp+&T!i0nDSCgNtYuQUF1@1r%1pkpcV%Xp5| zHy^R)h1GsK5bu|q3&&M>TC@QB@H4@Bi|p#9YJ*ZG7K%PEh`sl6tblLnV?NILqO~>q zRmNy~jON6bZ=Vz=|ElDWtsYjTsGE3o0spH1g^pi=;1l1CX2fV#%$gN1448R2np4>& zQ1#)prarvrs4nh8$w2Kz0R&N7dqsHLb%VMD7T5nD091D!f52nkIy`vGjMG^{GnX@~ z-5D!Ab1ShtCp1j|QbDMMO_uqC=3#5ozius?RvCSACXLT>{7lgB4K^l{@AV^qm%6Ml zMwJb!?DS{juLztSNM=2mx5!M*jkWiq3%=B4iFufhHRh>T0}Uv>h!-&dcTgV~&`$vV z)RpB%UH^w@AmlBe_3m9^f^ zK{tf*A{GS3cC!0gYJXd+Sc@CbB&&|X(-%^@j?N6G2lYdv@vXC&T$GEO(#TtHQoB6? zvAqxglv9kab@J?G%1fv_#xrj5N7Y87RdGQ|>_sD6$+Tf)G@^Jh#ZCO+5)VaE1E`zB z{n)=fx!m1iATSu;KTY|OTq(OL@YMw9$8g47I{r&sUC33w;@HgXfxAwSs?U|vn*#S1 z9=vA|#>l0RNQB&XsURJNtM9uy&veLHvM5a(vc)L5vbZ%Aq_&;_&ZqcM8Am4M3i>wu zBH8?G(jQ!f9?3JMXr(pQ@D6@CoWo-{m1cdKjis(wv0Du6r2W&p*v`MxjLNdFmcQGg z9H%fKjC+EEh`l1ZU4DCR-WU5puwG)zS#JqPB49Z6Dy&K~D=dd0dr@s&2Qa z2Q|zhbCk@J9K5Q#=Ju5bYCb5cR*HiCiGOGJuKA7mFrJ^ddLL8b)%5NBNU3;T*A;0H z9Kvm?u((iYG-AL!>?J0p@JK(@g5_P3?}>hwcr$_?2T7 zH^;15F>7`_WbvtLUtij157%!^>GH-a_xRmVHnycGN!8J0Cx+f*_ch?Yhj=aYhpqFC zMz0Qa-cwf9HdzpJZ-d!!@A#?lf$vmow$F{-M0a<$oY#753pA`COdxKc^!JpX>m$XE zBP_{X$}qpoxp#l=`ML+a{wW4rSg|~_>xU0y=C&8bQKC0QztQeh%be}wMx~tcSybXk zpyAtu?+YrT-WDHBCy$$?Jdu$0Z3)T+?&AM9w|8m!nh+yDRo07*qoM6N<$g5qle#sB~S literal 0 HcmV?d00001 diff --git a/src/app/share/resources/icon/svg/point_of_intersection_arcs.svg b/src/app/share/resources/icon/svg/point_of_intersection_arcs.svg new file mode 100644 index 000000000..6060afdd2 --- /dev/null +++ b/src/app/share/resources/icon/svg/point_of_intersection_arcs.svg @@ -0,0 +1,101 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + From 71302fddf05eb2f36a0b598b54e8d4a110db8111 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 27 May 2015 13:48:21 +0300 Subject: [PATCH 4/8] First successful build. --HG-- branch : feature --- src/app/dialogs/dialogs.h | 1 + src/app/dialogs/dialogs.pri | 9 +- .../tools/dialogpointofintersection.cpp | 12 +- .../tools/dialogpointofintersectionarcs.cpp | 234 ++++++++++++++ .../tools/dialogpointofintersectionarcs.h | 78 +++++ .../tools/dialogpointofintersectionarcs.ui | 149 +++++++++ src/app/mainwindow.cpp | 14 + src/app/mainwindow.h | 1 + src/app/options.h | 6 +- src/app/tools/drawTools/drawtools.h | 1 + .../vtoolpointofintersectionarcs.cpp | 290 ++++++++++++++++++ .../drawTools/vtoolpointofintersectionarcs.h | 89 ++++++ src/app/tools/tools.pri | 6 +- src/app/tools/vabstracttool.cpp | 3 + src/app/tools/vabstracttool.h | 3 + .../vistoolpointofintersectionarcs.cpp | 88 ++++++ .../vistoolpointofintersectionarcs.h | 60 ++++ src/app/visualization/visualization.pri | 6 +- src/app/xml/vpattern.h | 1 + 19 files changed, 1031 insertions(+), 20 deletions(-) create mode 100644 src/app/dialogs/tools/dialogpointofintersectionarcs.cpp create mode 100644 src/app/dialogs/tools/dialogpointofintersectionarcs.h create mode 100644 src/app/dialogs/tools/dialogpointofintersectionarcs.ui create mode 100644 src/app/tools/drawTools/vtoolpointofintersectionarcs.cpp create mode 100644 src/app/tools/drawTools/vtoolpointofintersectionarcs.h create mode 100644 src/app/visualization/vistoolpointofintersectionarcs.cpp create mode 100644 src/app/visualization/vistoolpointofintersectionarcs.h diff --git a/src/app/dialogs/dialogs.h b/src/app/dialogs/dialogs.h index 27195b696..2751cdf0f 100644 --- a/src/app/dialogs/dialogs.h +++ b/src/app/dialogs/dialogs.h @@ -51,6 +51,7 @@ #include "tools/dialogpointofintersection.h" #include "tools/dialoglineintersectaxis.h" #include "tools/dialogcurveintersectaxis.h" +#include "tools/dialogpointofintersectionarcs.h" #include "app/dialoghistory.h" #include "app/dialogincrements.h" diff --git a/src/app/dialogs/dialogs.pri b/src/app/dialogs/dialogs.pri index 0e684e367..27409388e 100644 --- a/src/app/dialogs/dialogs.pri +++ b/src/app/dialogs/dialogs.pri @@ -44,7 +44,8 @@ HEADERS += \ $$PWD/tools/dialogcurveintersectaxis.h \ $$PWD/app/dialoglayoutsettings.h \ $$PWD/app/dialoglayoutprogress.h \ - dialogs/app/dialogsavelayout.h + $$PWD/app/dialogsavelayout.h \ + $$PWD/tools/dialogpointofintersectionarcs.h SOURCES += \ $$PWD/tools/dialogtriangle.cpp \ @@ -87,7 +88,8 @@ SOURCES += \ $$PWD/tools/dialogcurveintersectaxis.cpp \ $$PWD/app/dialoglayoutsettings.cpp \ $$PWD/app/dialoglayoutprogress.cpp \ - dialogs/app/dialogsavelayout.cpp + $$PWD/app/dialogsavelayout.cpp \ + $$PWD/tools/dialogpointofintersectionarcs.cpp FORMS += \ $$PWD/tools/dialogtriangle.ui \ @@ -124,4 +126,5 @@ FORMS += \ $$PWD/tools/dialogcurveintersectaxis.ui \ $$PWD/app/dialoglayoutsettings.ui \ $$PWD/app/dialoglayoutprogress.ui \ - dialogs/app/dialogsavelayout.ui + $$PWD/app/dialogsavelayout.ui \ + $$PWD/tools/dialogpointofintersectionarcs.ui diff --git a/src/app/dialogs/tools/dialogpointofintersection.cpp b/src/app/dialogs/tools/dialogpointofintersection.cpp index 1c60117e5..1870f8204 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.cpp +++ b/src/app/dialogs/tools/dialogpointofintersection.cpp @@ -165,17 +165,7 @@ void DialogPointOfIntersection::PointNameChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogPointOfIntersection::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr); - - VisToolPointOfIntersection *toolVis = qobject_cast(vis); - SCASSERT(toolVis != nullptr); - - connect(scene, &VMainGraphicsScene::NewFactor, toolVis, &Visualization::SetFactor); - toolVis->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogpointofintersectionarcs.cpp b/src/app/dialogs/tools/dialogpointofintersectionarcs.cpp new file mode 100644 index 000000000..b232a79c9 --- /dev/null +++ b/src/app/dialogs/tools/dialogpointofintersectionarcs.cpp @@ -0,0 +1,234 @@ +/************************************************************************ + ** + ** @file dialogpointofintersectionarcs.cpp + ** @author Roman Telezhynskyi + ** @date 25 5, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "dialogpointofintersectionarcs.h" +#include "ui_dialogpointofintersectionarcs.h" + +#include "../../libs/vgeometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoolpointofintersectionarcs.h" +#include "../../widgets/vmaingraphicsscene.h" + +//--------------------------------------------------------------------------------------------------------------------- +DialogPointOfIntersectionArcs::DialogPointOfIntersectionArcs(const VContainer *data, const quint32 &toolId, + QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersectionArcs) +{ + ui->setupUi(this); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + + InitOkCancelApply(ui); + CheckState(); + + FillComboBoxArcs(ui->comboBoxArc1); + FillComboBoxArcs(ui->comboBoxArc2); + FillComboBoxCrossArcPoints(); + + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersectionArcs::NamePointChanged); + connect(ui->comboBoxArc1, static_cast(&QComboBox::currentIndexChanged), + this, &DialogPointOfIntersectionArcs::ArcChanged); + connect(ui->comboBoxArc1, static_cast(&QComboBox::currentIndexChanged), + this, &DialogPointOfIntersectionArcs::ArcChanged); + + vis = new VisToolPointOfIntersectionArcs(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogPointOfIntersectionArcs::~DialogPointOfIntersectionArcs() +{ + DeleteVisualization(); + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionArcs::SetPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogPointOfIntersectionArcs::GetFirstArcId() const +{ + return getCurrentObjectId(ui->comboBoxArc1); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionArcs::SetFirstArcId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxArc1, value); + + VisToolPointOfIntersectionArcs *point = qobject_cast(vis); + SCASSERT(point != nullptr); + point->setArc1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogPointOfIntersectionArcs::GetSecondArcId() const +{ + return getCurrentObjectId(ui->comboBoxArc2); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionArcs::SetSecondArcId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxArc2, value); + + VisToolPointOfIntersectionArcs *point = qobject_cast(vis); + SCASSERT(point != nullptr); + point->setArc2Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +CrossArcPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const +{ + int value; + bool ok = false; +#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) + value = ui->comboBoxResult->itemData(box->currentIndex()).toInt(&ok); +#else + value = ui->comboBoxResult->currentData().toInt(&ok); +#endif + if (not ok) + { + return CrossArcPoint::FirstPoint; + } + + switch(value) + { + case 1: + return CrossArcPoint::FirstPoint; + break; + case 2: + return CrossArcPoint::SecondPoint; + break; + default: + return CrossArcPoint::FirstPoint; + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossArcPoint &p) +{ + const qint32 index = ui->comboBoxResult->findData(static_cast(p)); + if (index != -1) + { + ui->comboBoxResult->setCurrentIndex(index); + + VisToolPointOfIntersectionArcs *point = qobject_cast(vis); + SCASSERT(point != nullptr); + point->setCrossPoint(p); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionArcs::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Arc) + { + VisToolPointOfIntersectionArcs *point = qobject_cast(vis); + SCASSERT(point != nullptr); + + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxArc1, tr("Select second an arc"))) + { + number++; + point->setArc1Id(id); + point->RefreshGeometry(); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxArc2) != id) + { + if (SetObject(id, ui->comboBoxArc2, "")) + { + point->setArc2Id(id); + point->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionArcs::ArcChanged() +{ + QColor color = okColor; + if (getCurrentObjectId(ui->comboBoxArc1) == getCurrentObjectId(ui->comboBoxArc2)) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelArc1, color); + ChangeColor(ui->labelArc2, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionArcs::ShowVisualization() +{ + AddVisualization(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionArcs::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + + VisToolPointOfIntersectionArcs *point = qobject_cast(vis); + SCASSERT(point != nullptr); + + point->setArc1Id(GetFirstArcId()); + point->setArc2Id(GetSecondArcId()); + point->RefreshGeometry(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionArcs::FillComboBoxCrossArcPoints() +{ + ui->comboBoxResult->addItem(tr("First point"), QVariant(static_cast(CrossArcPoint::FirstPoint))); + ui->comboBoxResult->addItem(tr("Second point"), QVariant(static_cast(CrossArcPoint::SecondPoint))); +} diff --git a/src/app/dialogs/tools/dialogpointofintersectionarcs.h b/src/app/dialogs/tools/dialogpointofintersectionarcs.h new file mode 100644 index 000000000..1b89df131 --- /dev/null +++ b/src/app/dialogs/tools/dialogpointofintersectionarcs.h @@ -0,0 +1,78 @@ +/************************************************************************ + ** + ** @file dialogpointofintersectionarcs.h + ** @author Roman Telezhynskyi + ** @date 25 5, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef DIALOGPOINTOFINTERSECTIONARCS_H +#define DIALOGPOINTOFINTERSECTIONARCS_H + +#include "dialogtool.h" +#include "../../xml/vpattern.h" + +namespace Ui +{ + class DialogPointOfIntersectionArcs; +} + +class DialogPointOfIntersectionArcs : public DialogTool +{ + Q_OBJECT + +public: + explicit DialogPointOfIntersectionArcs(const VContainer *data, const quint32 &toolId, QWidget *parent = 0); + virtual ~DialogPointOfIntersectionArcs(); + + void SetPointName(const QString &value); + + quint32 GetFirstArcId() const; + void SetFirstArcId(const quint32 &value); + + quint32 GetSecondArcId() const; + void SetSecondArcId(const quint32 &value); + + CrossArcPoint GetCrossArcPoint() const; + void SetCrossArcPoint(CrossArcPoint &p); + +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + virtual void ArcChanged(); + +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + +private: + Q_DISABLE_COPY(DialogPointOfIntersectionArcs) + + Ui::DialogPointOfIntersectionArcs *ui; + + void FillComboBoxCrossArcPoints(); +}; + +#endif // DIALOGPOINTOFINTERSECTIONARCS_H diff --git a/src/app/dialogs/tools/dialogpointofintersectionarcs.ui b/src/app/dialogs/tools/dialogpointofintersectionarcs.ui new file mode 100644 index 000000000..eafdf1e12 --- /dev/null +++ b/src/app/dialogs/tools/dialogpointofintersectionarcs.ui @@ -0,0 +1,149 @@ + + + DialogPointOfIntersectionArcs + + + + 0 + 0 + 285 + 179 + + + + + 285 + 179 + + + + + 285 + 179 + + + + Dialog + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + + 0 + 0 + + + + Point label + + + + + + + + + + + 0 + 0 + + + + First arc + + + + + + + Selected arc + + + + + + + + 0 + 0 + + + + Second arc + + + + + + + Selected arc + + + + + + + Take + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + DialogPointOfIntersectionArcs + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogPointOfIntersectionArcs + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 489c54a29..d85447891 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -695,6 +695,16 @@ void MainWindow::ToolCurveIntersectAxis(bool checked) &MainWindow::ApplyDialog); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::PointOfIntersectionArcs(bool checked) +{ + SetToolButtonWithApply(checked, Tool::PointOfIntersectionArcs, + "://cursor/point_of_intersection_arcs.png", + tr("Select first an arc"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief About show widows about. @@ -990,6 +1000,7 @@ void MainWindow::InitToolButtons() connect(ui->toolButtonCurveIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis); connect(ui->toolButtonArcIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis); connect(ui->toolButtonLayoutSettings, &QToolButton::clicked, this, &MainWindow::ToolLayoutSettings); + connect(ui->toolButtonPointOfIntersectionArcs, &QToolButton::clicked, this, &MainWindow::PointOfIntersectionArcs); } //--------------------------------------------------------------------------------------------------------------------- @@ -1103,6 +1114,9 @@ void MainWindow::CancelTool() ui->toolButtonCurveIntersectAxis->setChecked(false); ui->toolButtonArcIntersectAxis->setChecked(false); break; + case Tool::PointOfIntersectionArcs: + ui->toolButtonPointOfIntersectionArcs->setChecked(false); + break; case Tool::NodePoint: case Tool::NodeArc: case Tool::NodeSpline: diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index a6778c7dd..b42907978 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -115,6 +115,7 @@ public slots: void ToolCutArc(bool checked); void ToolLineIntersectAxis(bool checked); void ToolCurveIntersectAxis(bool checked); + void PointOfIntersectionArcs(bool checked); void ClosedDialogDetail(int result); void ClosedDialogUnionDetails(int result); diff --git a/src/app/options.h b/src/app/options.h index 395fc5b8f..f65601b42 100644 --- a/src/app/options.h +++ b/src/app/options.h @@ -86,14 +86,15 @@ enum class Tool : unsigned char Height, Triangle, LineIntersectAxis, + PointOfIntersectionArcs, CurveIntersectAxis, PointOfIntersection, - UnionDetails // 30 + UnionDetails // 31 }; enum class Vis : unsigned char { - ControlPointSpline = 31, // increase this value if need more positions in Tool enum + ControlPointSpline = 32, // increase this value if need more positions in Tool enum GraphicsSimpleTextItem, SimpleSplinePath, Line, @@ -109,6 +110,7 @@ enum class Vis : unsigned char ToolNormal, ToolPointOfContact, ToolPointOfIntersection, + ToolPointOfIntersectionArcs, ToolShoulderPoint, ToolSpline, ToolTriangle, diff --git a/src/app/tools/drawTools/drawtools.h b/src/app/tools/drawTools/drawtools.h index 804266cb5..b8f771bf8 100644 --- a/src/app/tools/drawTools/drawtools.h +++ b/src/app/tools/drawTools/drawtools.h @@ -44,6 +44,7 @@ #include "vtoolheight.h" #include "vtooltriangle.h" #include "vtoolpointofintersection.h" +#include "vtoolpointofintersectionarcs.h" #include "vtoolcutspline.h" #include "vtoolcutsplinepath.h" #include "vtoolcutarc.h" diff --git a/src/app/tools/drawTools/vtoolpointofintersectionarcs.cpp b/src/app/tools/drawTools/vtoolpointofintersectionarcs.cpp new file mode 100644 index 000000000..781170840 --- /dev/null +++ b/src/app/tools/drawTools/vtoolpointofintersectionarcs.cpp @@ -0,0 +1,290 @@ +/************************************************************************ + ** + ** @file vtoolpointofintersectionarcs.cpp + ** @author Roman Telezhynskyi + ** @date 25 5, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vtoolpointofintersectionarcs.h" +#include "../../dialogs/tools/dialogpointofintersectionarcs.h" +#include "../../libs/vgeometry/vpointf.h" +#include "../../libs/vgeometry/varc.h" +#include "../../visualization/vistoolpointofintersectionarcs.h" + +const QString VToolPointOfIntersectionArcs::ToolType = QStringLiteral("pointOfIntersectionArcs"); + +//--------------------------------------------------------------------------------------------------------------------- +VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(VPattern *doc, VContainer *data, const quint32 &id, + const quint32 &firstArcId, const quint32 &secondArcId, + CrossArcPoint pType, const Source &typeCreation, + QGraphicsItem *parent) + :VToolPoint(doc, data, id, parent), firstArcId(firstArcId), secondArcId(secondArcId), crossPoint(pType) +{ + if (typeCreation == Source::FromGui) + { + AddToFile(); + } + else + { + RefreshDataInFile(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionArcs::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogPointOfIntersectionArcs *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->SetFirstArcId(firstArcId); + dialogTool->SetSecondArcId(secondArcId); + dialogTool->SetCrossArcPoint(crossPoint); + dialogTool->SetPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(DialogTool *dialog, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogPointOfIntersectionArcs *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const quint32 firstArcId = dialogTool->GetFirstArcId(); + const quint32 secondArcId = dialogTool->GetSecondArcId(); + const CrossArcPoint pType = dialogTool->GetCrossArcPoint(); + const QString pointName = dialogTool->getPointName(); + VToolPointOfIntersectionArcs *point = nullptr; + point = Create(0, pointName, firstArcId, secondArcId, pType, 5, 10, scene, doc, data, Document::FullParse, + Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32 _id, const QString &pointName, + const quint32 &firstArcId, + const quint32 &secondArcId, CrossArcPoint pType, + const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, + const Source &typeCreation) +{ + const QSharedPointer firstArc = data->GeometricObject(firstArcId); + const QSharedPointer secondArc = data->GeometricObject(secondArcId); + + const QPointF point = FindPoint(firstArc.data(), secondArc.data(), pType); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(point, pointName, mx, my)); + } + else + { + data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::PointOfIntersectionArcs, doc); + if (parse == Document::FullParse) + { + VToolPointOfIntersectionArcs *point = new VToolPointOfIntersectionArcs(doc, data, id, firstArcId, + secondArcId, pType, typeCreation); + scene->addItem(point); + connect(point, &VToolPointOfIntersectionArcs::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersectionArcs::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersectionArcs::Disable); + connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersectionArcs::EnableToolMove); + doc->AddTool(id, point); + doc->IncrementReferens(firstArcId); + doc->IncrementReferens(secondArcId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcPoint pType) +{ + QPointF p1, p2; + const int res = VGObject::IntersectionCircles(arc1->GetCenter().toQPointF(), arc1->GetRadius(), + arc2->GetCenter().toQPointF(), arc2->GetRadius(), p1, p2); + + switch(res) + { + case 2: + if (pType == CrossArcPoint::FirstPoint) + { + return p1; + } + else + { + return p2; + } + break; + case 1: + return p1; + break; + case 3: + case 0: + default: + return QPointF(0, 0); + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointOfIntersectionArcs::GetFirstArcId() const +{ + return firstArcId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionArcs::SetFirstArcId(const quint32 &value) +{ + if (value != NULL_ID) + { + firstArcId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointOfIntersectionArcs::GetSecondArcId() const +{ + return secondArcId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionArcs::SetSecondArcId(const quint32 &value) +{ + if (value != NULL_ID) + { + secondArcId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +CrossArcPoint VToolPointOfIntersectionArcs::GetCrossArcPoint() const +{ + return crossPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionArcs::SetCrossArcPoint(CrossArcPoint &value) +{ + crossPoint = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionArcs::ShowVisualization(bool show) +{ + ShowToolVisualization(show); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionArcs::FullUpdateFromFile() +{ + ReadAttributes(); + VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); + SetVisualization(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionArcs::RemoveReferens() +{ + doc->DecrementReferens(firstArcId); + doc->DecrementReferens(secondArcId); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionArcs::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionArcs::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogPointOfIntersectionArcs *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrFirstArc, QString().setNum(dialogTool->GetFirstArcId())); + doc->SetAttribute(domElement, AttrSecondArc, QString().setNum(dialogTool->GetSecondArcId())); + doc->SetAttribute(domElement, AttrCrossPoint, QString().setNum(static_cast(dialogTool->GetCrossArcPoint()))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionArcs::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + QSharedPointer point = qSharedPointerDynamicCast(obj); + SCASSERT(point.isNull() == false); + + doc->SetAttribute(tag, VDomDocument::AttrId, id); + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrName, point->name()); + doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + + doc->SetAttribute(tag, AttrFirstArc, firstArcId); + doc->SetAttribute(tag, AttrSecondArc, secondArcId); + doc->SetAttribute(tag, AttrCrossPoint, static_cast(crossPoint)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionArcs::ReadToolAttributes(const QDomElement &domElement) +{ + firstArcId = doc->GetParametrUInt(domElement, AttrFirstArc, NULL_ID_STR); + secondArcId = doc->GetParametrUInt(domElement, AttrSecondArc, NULL_ID_STR); + crossPoint = static_cast(doc->GetParametrUInt(domElement, AttrCrossPoint, "1")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionArcs::SetVisualization() +{ + if (vis != nullptr) + { + VisToolPointOfIntersectionArcs *visual = qobject_cast(vis); + SCASSERT(visual != nullptr); + + visual->setArc1Id(firstArcId); + visual->setArc2Id(secondArcId); + visual->setCrossPoint(crossPoint); + visual->RefreshGeometry(); + } +} diff --git a/src/app/tools/drawTools/vtoolpointofintersectionarcs.h b/src/app/tools/drawTools/vtoolpointofintersectionarcs.h new file mode 100644 index 000000000..3d208b23a --- /dev/null +++ b/src/app/tools/drawTools/vtoolpointofintersectionarcs.h @@ -0,0 +1,89 @@ +/************************************************************************ + ** + ** @file vtoolpointofintersectionarcs.h + ** @author Roman Telezhynskyi + ** @date 25 5, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VTOOLPOINTOFINTERSECTIONARCS_H +#define VTOOLPOINTOFINTERSECTIONARCS_H + +#include "vtoolpoint.h" +#include "../../xml/vpattern.h" + +class VArc; + +class VToolPointOfIntersectionArcs : public VToolPoint +{ + Q_OBJECT + +public: + VToolPointOfIntersectionArcs(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstArcId, + const quint32 &secondArcId, CrossArcPoint crossPoint, const Source &typeCreation, + QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolPointOfIntersectionArcs *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data); + static VToolPointOfIntersectionArcs *Create(const quint32 _id, const QString &pointName, const quint32 &firstArcId, + const quint32 &secondArcId, CrossArcPoint crossPoint, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); + static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcPoint crossPoint); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::PointOfIntersectionArcs) }; + + quint32 GetFirstArcId() const; + void SetFirstArcId(const quint32 &value); + + quint32 GetSecondArcId() const; + void SetSecondArcId(const quint32 &value); + + CrossArcPoint GetCrossArcPoint() const; + void SetCrossArcPoint(CrossArcPoint &value); + + virtual void ShowVisualization(bool show); +public slots: + virtual void FullUpdateFromFile(); +protected: + virtual void RemoveReferens(); + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); + virtual void SetVisualization(); +private: + Q_DISABLE_COPY(VToolPointOfIntersectionArcs) + + /** @brief firstArcId id first arc. */ + quint32 firstArcId; + + /** @brief secondArcId id second arc. */ + quint32 secondArcId; + + CrossArcPoint crossPoint; +}; + +#endif // VTOOLPOINTOFINTERSECTIONARCS_H diff --git a/src/app/tools/tools.pri b/src/app/tools/tools.pri index 9e4c233b4..425ed0dd5 100644 --- a/src/app/tools/tools.pri +++ b/src/app/tools/tools.pri @@ -38,7 +38,8 @@ HEADERS += \ $$PWD/drawTools/vabstractspline.h \ $$PWD/drawTools/vtoolcut.h \ $$PWD/drawTools/vtoollineintersectaxis.h \ - $$PWD/drawTools/vtoolcurveintersectaxis.h + $$PWD/drawTools/vtoolcurveintersectaxis.h \ + $$PWD/drawTools/vtoolpointofintersectionarcs.h SOURCES += \ $$PWD/vtooldetail.cpp \ @@ -74,4 +75,5 @@ SOURCES += \ $$PWD/drawTools/vabstractspline.cpp \ $$PWD/drawTools/vtoolcut.cpp \ $$PWD/drawTools/vtoollineintersectaxis.cpp \ - $$PWD/drawTools/vtoolcurveintersectaxis.cpp + $$PWD/drawTools/vtoolcurveintersectaxis.cpp \ + $$PWD/drawTools/vtoolpointofintersectionarcs.cpp diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp index 3451ac7b8..e62120f5d 100644 --- a/src/app/tools/vabstracttool.cpp +++ b/src/app/tools/vabstracttool.cpp @@ -76,6 +76,9 @@ const QString VAbstractTool::AttrAxisP2 = QStringLiteral("axisP2"); const QString VAbstractTool::AttrCurve = QStringLiteral("curve"); const QString VAbstractTool::AttrLineColor = QStringLiteral("lineColor"); const QString VAbstractTool::AttrColor = QStringLiteral("color"); +const QString VAbstractTool::AttrFirstArc = QStringLiteral("firstArc"); +const QString VAbstractTool::AttrSecondArc = QStringLiteral("secondArc"); +const QString VAbstractTool::AttrCrossPoint = QStringLiteral("crossPoint"); const QString VAbstractTool::TypeLineNone = QStringLiteral("none"); const QString VAbstractTool::TypeLineLine = QStringLiteral("hair"); diff --git a/src/app/tools/vabstracttool.h b/src/app/tools/vabstracttool.h index 6ee96ee69..0b9dc83ed 100644 --- a/src/app/tools/vabstracttool.h +++ b/src/app/tools/vabstracttool.h @@ -91,6 +91,9 @@ public: static const QString AttrCurve; static const QString AttrLineColor; static const QString AttrColor; + static const QString AttrFirstArc; + static const QString AttrSecondArc; + static const QString AttrCrossPoint; static const QString TypeLineNone; static const QString TypeLineLine; diff --git a/src/app/visualization/vistoolpointofintersectionarcs.cpp b/src/app/visualization/vistoolpointofintersectionarcs.cpp new file mode 100644 index 000000000..b0f043cc1 --- /dev/null +++ b/src/app/visualization/vistoolpointofintersectionarcs.cpp @@ -0,0 +1,88 @@ +/************************************************************************ + ** + ** @file vistoolpointofintersectionarcs.cpp + ** @author Roman Telezhynskyi + ** @date 27 5, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vistoolpointofintersectionarcs.h" +#include "../libs/vgeometry/varc.h" +#include "../container/vcontainer.h" +#include "../tools/drawTools/vtoolpointofintersectionarcs.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolPointOfIntersectionArcs::VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent) + : VisLine(data, parent), arc1Id(NULL_ID), arc2Id(NULL_ID), crossPoint(CrossArcPoint::FirstPoint), point(nullptr), + arc1Path(nullptr), arc2Path(nullptr) +{ + arc1Path = InitItem(Qt::darkGreen, this); + arc1Path->setFlag(QGraphicsItem::ItemStacksBehindParent, false); + arc2Path = InitItem(Qt::darkRed, this); + arc2Path->setFlag(QGraphicsItem::ItemStacksBehindParent, false); + + point = InitPoint(mainColor, this); + point->setZValue(2); + point->setFlag(QGraphicsItem::ItemStacksBehindParent, false); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolPointOfIntersectionArcs::~VisToolPointOfIntersectionArcs() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersectionArcs::RefreshGeometry() +{ + if (arc1Id > NULL_ID) + { + const QSharedPointer arc1 = Visualization::data->GeometricObject(arc1Id); + DrawPath(arc1Path, arc1->GetPath(PathDirection::Hide), supportColor, Qt::SolidLine, Qt::RoundCap); + + if (arc2Id > NULL_ID) + { + const QSharedPointer arc2 = Visualization::data->GeometricObject(arc2Id); + DrawPath(arc2Path, arc2->GetPath(PathDirection::Hide), supportColor, Qt::SolidLine, Qt::RoundCap); + + const QPointF fPoint = VToolPointOfIntersectionArcs::FindPoint(arc1.data(), arc2.data(), crossPoint); + DrawPoint(point, fPoint, mainColor); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersectionArcs::setArc1Id(const quint32 &value) +{ + arc1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersectionArcs::setArc2Id(const quint32 &value) +{ + arc2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossArcPoint &value) +{ + crossPoint = value; +} diff --git a/src/app/visualization/vistoolpointofintersectionarcs.h b/src/app/visualization/vistoolpointofintersectionarcs.h new file mode 100644 index 000000000..88375b032 --- /dev/null +++ b/src/app/visualization/vistoolpointofintersectionarcs.h @@ -0,0 +1,60 @@ +/************************************************************************ + ** + ** @file vistoolpointofintersectionarcs.h + ** @author Roman Telezhynskyi + ** @date 27 5, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VISTOOLPOINTOFINTERSECTIONARCS_H +#define VISTOOLPOINTOFINTERSECTIONARCS_H + +#include "visline.h" +#include "../xml/vpattern.h" + +class VisToolPointOfIntersectionArcs : public VisLine +{ + Q_OBJECT +public: + VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolPointOfIntersectionArcs(); + + virtual void RefreshGeometry(); + + void setArc1Id(const quint32 &value); + void setArc2Id(const quint32 &value); + void setCrossPoint(const CrossArcPoint &value); + + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolPointOfIntersection)}; +private: + Q_DISABLE_COPY(VisToolPointOfIntersectionArcs) + quint32 arc1Id; + quint32 arc2Id; + CrossArcPoint crossPoint; + QGraphicsEllipseItem *point; + QGraphicsPathItem *arc1Path; + QGraphicsPathItem *arc2Path; +}; + +#endif // VISTOOLPOINTOFINTERSECTIONARCS_H diff --git a/src/app/visualization/visualization.pri b/src/app/visualization/visualization.pri index aa73530fe..85b167327 100644 --- a/src/app/visualization/visualization.pri +++ b/src/app/visualization/visualization.pri @@ -26,7 +26,8 @@ HEADERS += \ $$PWD/vistoolsplinepath.h \ $$PWD/vistoolcutsplinepath.h \ $$PWD/vistoollineintersectaxis.h \ - $$PWD/vistoolcurveintersectaxis.h + $$PWD/vistoolcurveintersectaxis.h \ + $$PWD/vistoolpointofintersectionarcs.h SOURCES += \ $$PWD/vgraphicssimpletextitem.cpp \ @@ -53,4 +54,5 @@ SOURCES += \ $$PWD/vistoolsplinepath.cpp \ $$PWD/vistoolcutsplinepath.cpp \ $$PWD/vistoollineintersectaxis.cpp \ - $$PWD/vistoolcurveintersectaxis.cpp + $$PWD/vistoolcurveintersectaxis.cpp \ + $$PWD/vistoolpointofintersectionarcs.cpp diff --git a/src/app/xml/vpattern.h b/src/app/xml/vpattern.h index bac00fe71..c532f4250 100644 --- a/src/app/xml/vpattern.h +++ b/src/app/xml/vpattern.h @@ -38,6 +38,7 @@ class VMainGraphicsScene; enum class Document : char { LiteParse, LitePPParse, FullParse }; enum class LabelType : char {NewPatternPiece, NewLabel}; +enum class CrossArcPoint : char {FirstPoint = 1, SecondPoint = 2}; /** * @brief The VPattern class working with pattern file. From 2beac39ce164b7f07cfd1470b54d070756bd668c Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 27 May 2015 13:48:50 +0300 Subject: [PATCH 5/8] History record. --HG-- branch : feature --- src/app/dialogs/app/dialoghistory.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/dialogs/app/dialoghistory.cpp b/src/app/dialogs/app/dialoghistory.cpp index 7e80e91b6..143dc33a3 100644 --- a/src/app/dialogs/app/dialoghistory.cpp +++ b/src/app/dialogs/app/dialoghistory.cpp @@ -384,6 +384,10 @@ QString DialogHistory::Record(const VToolRecord &tool) .arg(PointName(tool.getId())) .arg(PointName(AttrUInt(domElem, VAbstractTool::AttrBasePoint))); } + case Tool::PointOfIntersectionArcs: + { + return QString(tr("%1 - point of arcs intersection")).arg(PointName(tool.getId())); + } //Because "history" not only show history of pattern, but help restore current data for each pattern's //piece, we need add record about details and nodes, but don't show them. case Tool::Detail: From e37e2d48f3f1b1140cc4b666375a476d8e7c1a38 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 27 May 2015 19:24:20 +0300 Subject: [PATCH 6/8] Successful show first point. --HG-- branch : feature --- .../tools/dialogpointofintersectionarcs.cpp | 22 ++--- .../tools/dialogpointofintersectionarcs.h | 4 +- .../tools/dialogpointofintersectionarcs.ui | 6 +- src/app/mainwindow.cpp | 8 +- src/app/mainwindow.h | 4 +- src/app/mainwindow.ui | 15 ++-- .../vtoolpointofintersectionarcs.cpp | 16 ++-- .../drawTools/vtoolpointofintersectionarcs.h | 12 +-- .../vistoolpointofintersectionarcs.cpp | 21 ++++- .../vistoolpointofintersectionarcs.h | 5 +- src/app/visualization/visualization.h | 2 +- .../widgets/vtooloptionspropertybrowser.cpp | 85 ++++++++++++++++++- src/app/widgets/vtooloptionspropertybrowser.h | 6 ++ src/app/xml/vpattern.h | 2 +- src/libs/vgeometry/vgobject.cpp | 46 ++++++---- src/libs/vgeometry/vgobject.h | 1 - 16 files changed, 189 insertions(+), 66 deletions(-) diff --git a/src/app/dialogs/tools/dialogpointofintersectionarcs.cpp b/src/app/dialogs/tools/dialogpointofintersectionarcs.cpp index b232a79c9..d6b2ba7a7 100644 --- a/src/app/dialogs/tools/dialogpointofintersectionarcs.cpp +++ b/src/app/dialogs/tools/dialogpointofintersectionarcs.cpp @@ -106,7 +106,7 @@ void DialogPointOfIntersectionArcs::SetSecondArcId(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -CrossArcPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const +CrossArcsPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const { int value; bool ok = false; @@ -117,25 +117,25 @@ CrossArcPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const #endif if (not ok) { - return CrossArcPoint::FirstPoint; + return CrossArcsPoint::FirstPoint; } switch(value) { case 1: - return CrossArcPoint::FirstPoint; + return CrossArcsPoint::FirstPoint; break; case 2: - return CrossArcPoint::SecondPoint; + return CrossArcsPoint::SecondPoint; break; default: - return CrossArcPoint::FirstPoint; + return CrossArcsPoint::FirstPoint; break; } } //--------------------------------------------------------------------------------------------------------------------- -void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossArcPoint &p) +void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossArcsPoint &p) { const qint32 index = ui->comboBoxResult->findData(static_cast(p)); if (index != -1) @@ -164,15 +164,15 @@ void DialogPointOfIntersectionArcs::ChosenObject(quint32 id, const SceneObject & if (SetObject(id, ui->comboBoxArc1, tr("Select second an arc"))) { number++; - point->setArc1Id(id); - point->RefreshGeometry(); + point->VisualMode(id); } break; case 1: - if (getCurrentObjectId(ui->comboBoxArc2) != id) + if (getCurrentObjectId(ui->comboBoxArc1) != id) { if (SetObject(id, ui->comboBoxArc2, "")) { + number = 0; point->setArc2Id(id); point->RefreshGeometry(); prepare = true; @@ -229,6 +229,6 @@ void DialogPointOfIntersectionArcs::SaveData() //--------------------------------------------------------------------------------------------------------------------- void DialogPointOfIntersectionArcs::FillComboBoxCrossArcPoints() { - ui->comboBoxResult->addItem(tr("First point"), QVariant(static_cast(CrossArcPoint::FirstPoint))); - ui->comboBoxResult->addItem(tr("Second point"), QVariant(static_cast(CrossArcPoint::SecondPoint))); + ui->comboBoxResult->addItem(tr("First point"), QVariant(static_cast(CrossArcsPoint::FirstPoint))); + ui->comboBoxResult->addItem(tr("Second point"), QVariant(static_cast(CrossArcsPoint::SecondPoint))); } diff --git a/src/app/dialogs/tools/dialogpointofintersectionarcs.h b/src/app/dialogs/tools/dialogpointofintersectionarcs.h index 1b89df131..a555e42c3 100644 --- a/src/app/dialogs/tools/dialogpointofintersectionarcs.h +++ b/src/app/dialogs/tools/dialogpointofintersectionarcs.h @@ -53,8 +53,8 @@ public: quint32 GetSecondArcId() const; void SetSecondArcId(const quint32 &value); - CrossArcPoint GetCrossArcPoint() const; - void SetCrossArcPoint(CrossArcPoint &p); + CrossArcsPoint GetCrossArcPoint() const; + void SetCrossArcPoint(CrossArcsPoint &p); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); diff --git a/src/app/dialogs/tools/dialogpointofintersectionarcs.ui b/src/app/dialogs/tools/dialogpointofintersectionarcs.ui index eafdf1e12..f6f9ebc12 100644 --- a/src/app/dialogs/tools/dialogpointofintersectionarcs.ui +++ b/src/app/dialogs/tools/dialogpointofintersectionarcs.ui @@ -6,19 +6,19 @@ 0 0 - 285 + 300 179 - 285 + 300 179 - 285 + 300 179 diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index d85447891..d95c618e2 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -696,7 +696,7 @@ void MainWindow::ToolCurveIntersectAxis(bool checked) } //--------------------------------------------------------------------------------------------------------------------- -void MainWindow::PointOfIntersectionArcs(bool checked) +void MainWindow::ToolPointOfIntersectionArcs(bool checked) { SetToolButtonWithApply(checked, Tool::PointOfIntersectionArcs, "://cursor/point_of_intersection_arcs.png", @@ -1000,7 +1000,7 @@ void MainWindow::InitToolButtons() connect(ui->toolButtonCurveIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis); connect(ui->toolButtonArcIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis); connect(ui->toolButtonLayoutSettings, &QToolButton::clicked, this, &MainWindow::ToolLayoutSettings); - connect(ui->toolButtonPointOfIntersectionArcs, &QToolButton::clicked, this, &MainWindow::PointOfIntersectionArcs); + connect(ui->toolButtonPointOfIntersectionArcs, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersectionArcs); } //--------------------------------------------------------------------------------------------------------------------- @@ -2477,6 +2477,10 @@ void MainWindow::LastUsedTool() ui->toolButtonPointOfIntersection->setChecked(true); ToolPointOfIntersection(true); break; + case Tool::PointOfIntersectionArcs: + ui->toolButtonPointOfIntersectionArcs->setChecked(true); + ToolPointOfIntersectionArcs(true); + break; case Tool::CutSpline: ui->toolButtonSplineCutPoint->setChecked(true); ToolCutSpline(true); diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index b42907978..077115283 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -115,13 +115,13 @@ public slots: void ToolCutArc(bool checked); void ToolLineIntersectAxis(bool checked); void ToolCurveIntersectAxis(bool checked); - void PointOfIntersectionArcs(bool checked); + void ToolPointOfIntersectionArcs(bool checked); void ClosedDialogDetail(int result); void ClosedDialogUnionDetails(int result); //tmp - void LastUsedTool(); + void LastUsedTool(); /** * @brief Edit XML code of pattern diff --git a/src/app/mainwindow.ui b/src/app/mainwindow.ui index b04af4683..b4dc108bb 100644 --- a/src/app/mainwindow.ui +++ b/src/app/mainwindow.ui @@ -50,7 +50,7 @@ 0 0 - 105 + 100 272 @@ -337,7 +337,7 @@ 0 0 - 105 + 100 58 @@ -413,7 +413,7 @@ 0 0 - 105 + 100 156 @@ -683,6 +683,9 @@ 32 + + true + @@ -692,7 +695,7 @@ 0 0 - 105 + 100 58 @@ -768,8 +771,8 @@ 0 0 - 105 - 380 + 98 + 58 diff --git a/src/app/tools/drawTools/vtoolpointofintersectionarcs.cpp b/src/app/tools/drawTools/vtoolpointofintersectionarcs.cpp index 781170840..d20d33509 100644 --- a/src/app/tools/drawTools/vtoolpointofintersectionarcs.cpp +++ b/src/app/tools/drawTools/vtoolpointofintersectionarcs.cpp @@ -37,7 +37,7 @@ const QString VToolPointOfIntersectionArcs::ToolType = QStringLiteral("pointOfIn //--------------------------------------------------------------------------------------------------------------------- VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstArcId, const quint32 &secondArcId, - CrossArcPoint pType, const Source &typeCreation, + CrossArcsPoint pType, const Source &typeCreation, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), firstArcId(firstArcId), secondArcId(secondArcId), crossPoint(pType) { @@ -73,7 +73,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(DialogTool *d SCASSERT(dialogTool != nullptr); const quint32 firstArcId = dialogTool->GetFirstArcId(); const quint32 secondArcId = dialogTool->GetSecondArcId(); - const CrossArcPoint pType = dialogTool->GetCrossArcPoint(); + const CrossArcsPoint pType = dialogTool->GetCrossArcPoint(); const QString pointName = dialogTool->getPointName(); VToolPointOfIntersectionArcs *point = nullptr; point = Create(0, pointName, firstArcId, secondArcId, pType, 5, 10, scene, doc, data, Document::FullParse, @@ -88,7 +88,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(DialogTool *d //--------------------------------------------------------------------------------------------------------------------- VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32 _id, const QString &pointName, const quint32 &firstArcId, - const quint32 &secondArcId, CrossArcPoint pType, + const quint32 &secondArcId, CrossArcsPoint pType, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, @@ -130,7 +130,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32 } //--------------------------------------------------------------------------------------------------------------------- -QPointF VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcPoint pType) +QPointF VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcsPoint pType) { QPointF p1, p2; const int res = VGObject::IntersectionCircles(arc1->GetCenter().toQPointF(), arc1->GetRadius(), @@ -139,7 +139,7 @@ QPointF VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *ar switch(res) { case 2: - if (pType == CrossArcPoint::FirstPoint) + if (pType == CrossArcsPoint::FirstPoint) { return p1; } @@ -196,13 +196,13 @@ void VToolPointOfIntersectionArcs::SetSecondArcId(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -CrossArcPoint VToolPointOfIntersectionArcs::GetCrossArcPoint() const +CrossArcsPoint VToolPointOfIntersectionArcs::GetCrossArcsPoint() const { return crossPoint; } //--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersectionArcs::SetCrossArcPoint(CrossArcPoint &value) +void VToolPointOfIntersectionArcs::SetCrossArcsPoint(CrossArcsPoint &value) { crossPoint = value; @@ -271,7 +271,7 @@ void VToolPointOfIntersectionArcs::ReadToolAttributes(const QDomElement &domElem { firstArcId = doc->GetParametrUInt(domElement, AttrFirstArc, NULL_ID_STR); secondArcId = doc->GetParametrUInt(domElement, AttrSecondArc, NULL_ID_STR); - crossPoint = static_cast(doc->GetParametrUInt(domElement, AttrCrossPoint, "1")); + crossPoint = static_cast(doc->GetParametrUInt(domElement, AttrCrossPoint, "1")); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolpointofintersectionarcs.h b/src/app/tools/drawTools/vtoolpointofintersectionarcs.h index 3d208b23a..0a942ad8b 100644 --- a/src/app/tools/drawTools/vtoolpointofintersectionarcs.h +++ b/src/app/tools/drawTools/vtoolpointofintersectionarcs.h @@ -40,17 +40,17 @@ class VToolPointOfIntersectionArcs : public VToolPoint public: VToolPointOfIntersectionArcs(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstArcId, - const quint32 &secondArcId, CrossArcPoint crossPoint, const Source &typeCreation, + const quint32 &secondArcId, CrossArcsPoint crossPoint, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); static VToolPointOfIntersectionArcs *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolPointOfIntersectionArcs *Create(const quint32 _id, const QString &pointName, const quint32 &firstArcId, - const quint32 &secondArcId, CrossArcPoint crossPoint, + const quint32 &secondArcId, CrossArcsPoint crossPoint, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); - static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcPoint crossPoint); + static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcsPoint crossPoint); static const QString ToolType; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::PointOfIntersectionArcs) }; @@ -61,8 +61,8 @@ public: quint32 GetSecondArcId() const; void SetSecondArcId(const quint32 &value); - CrossArcPoint GetCrossArcPoint() const; - void SetCrossArcPoint(CrossArcPoint &value); + CrossArcsPoint GetCrossArcsPoint() const; + void SetCrossArcsPoint(CrossArcsPoint &value); virtual void ShowVisualization(bool show); public slots: @@ -83,7 +83,7 @@ private: /** @brief secondArcId id second arc. */ quint32 secondArcId; - CrossArcPoint crossPoint; + CrossArcsPoint crossPoint; }; #endif // VTOOLPOINTOFINTERSECTIONARCS_H diff --git a/src/app/visualization/vistoolpointofintersectionarcs.cpp b/src/app/visualization/vistoolpointofintersectionarcs.cpp index b0f043cc1..6c9309219 100644 --- a/src/app/visualization/vistoolpointofintersectionarcs.cpp +++ b/src/app/visualization/vistoolpointofintersectionarcs.cpp @@ -33,7 +33,7 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolPointOfIntersectionArcs::VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), arc1Id(NULL_ID), arc2Id(NULL_ID), crossPoint(CrossArcPoint::FirstPoint), point(nullptr), + : VisLine(data, parent), arc1Id(NULL_ID), arc2Id(NULL_ID), crossPoint(CrossArcsPoint::FirstPoint), point(nullptr), arc1Path(nullptr), arc2Path(nullptr) { arc1Path = InitItem(Qt::darkGreen, this); @@ -56,12 +56,12 @@ void VisToolPointOfIntersectionArcs::RefreshGeometry() if (arc1Id > NULL_ID) { const QSharedPointer arc1 = Visualization::data->GeometricObject(arc1Id); - DrawPath(arc1Path, arc1->GetPath(PathDirection::Hide), supportColor, Qt::SolidLine, Qt::RoundCap); + DrawPath(arc1Path, arc1->GetPath(PathDirection::Hide), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); if (arc2Id > NULL_ID) { const QSharedPointer arc2 = Visualization::data->GeometricObject(arc2Id); - DrawPath(arc2Path, arc2->GetPath(PathDirection::Hide), supportColor, Qt::SolidLine, Qt::RoundCap); + DrawPath(arc2Path, arc2->GetPath(PathDirection::Hide), Qt::darkRed, Qt::SolidLine, Qt::RoundCap); const QPointF fPoint = VToolPointOfIntersectionArcs::FindPoint(arc1.data(), arc2.data(), crossPoint); DrawPoint(point, fPoint, mainColor); @@ -69,6 +69,19 @@ void VisToolPointOfIntersectionArcs::RefreshGeometry() } } +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersectionArcs::VisualMode(const quint32 &id) +{ + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr); + + this->arc1Id = id; + Visualization::scenePos = scene->getScenePos(); + RefreshGeometry(); + + AddOnScene(); +} + //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionArcs::setArc1Id(const quint32 &value) { @@ -82,7 +95,7 @@ void VisToolPointOfIntersectionArcs::setArc2Id(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossArcPoint &value) +void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossArcsPoint &value) { crossPoint = value; } diff --git a/src/app/visualization/vistoolpointofintersectionarcs.h b/src/app/visualization/vistoolpointofintersectionarcs.h index 88375b032..fb20ecfd2 100644 --- a/src/app/visualization/vistoolpointofintersectionarcs.h +++ b/src/app/visualization/vistoolpointofintersectionarcs.h @@ -40,10 +40,11 @@ public: virtual ~VisToolPointOfIntersectionArcs(); virtual void RefreshGeometry(); + virtual void VisualMode(const quint32 &id); void setArc1Id(const quint32 &value); void setArc2Id(const quint32 &value); - void setCrossPoint(const CrossArcPoint &value); + void setCrossPoint(const CrossArcsPoint &value); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Vis::ToolPointOfIntersection)}; @@ -51,7 +52,7 @@ private: Q_DISABLE_COPY(VisToolPointOfIntersectionArcs) quint32 arc1Id; quint32 arc2Id; - CrossArcPoint crossPoint; + CrossArcsPoint crossPoint; QGraphicsEllipseItem *point; QGraphicsPathItem *arc1Path; QGraphicsPathItem *arc2Path; diff --git a/src/app/visualization/visualization.h b/src/app/visualization/visualization.h index c72d21ad2..5596084db 100644 --- a/src/app/visualization/visualization.h +++ b/src/app/visualization/visualization.h @@ -52,7 +52,7 @@ public: void setPoint1Id(const quint32 &value); void setLineStyle(const Qt::PenStyle &value); void setScenePos(const QPointF &value); - void VisualMode(const quint32 &pointId); + virtual void VisualMode(const quint32 &pointId); void setMainColor(const QColor &value); signals: void ToolTip(const QString &toolTip); diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index 5b71762aa..9bcb69c90 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -116,6 +116,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) case VToolPointOfIntersection::Type: ShowOptionsToolPointOfIntersection(item); break; + case VToolPointOfIntersectionArcs::Type: + ShowOptionsToolPointOfIntersectionArcs(item); + break; case VToolShoulderPoint::Type: ShowOptionsToolShoulderPoint(item); break; @@ -203,6 +206,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions() case VToolPointOfIntersection::Type: UpdateOptionsToolPointOfIntersection(); break; + case VToolPointOfIntersectionArcs::Type: + UpdateOptionsToolPointOfIntersectionArcs(); + break; case VToolShoulderPoint::Type: UpdateOptionsToolShoulderPoint(); break; @@ -305,6 +311,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) case VToolPointOfIntersection::Type: ChangeDataToolPointOfIntersection(prop); break; + case VToolPointOfIntersectionArcs::Type: + ChangeDataToolPointOfIntersectionArcs(prop); + break; case VToolShoulderPoint::Type: ChangeDataToolShoulderPoint(prop); break; @@ -388,6 +397,16 @@ void VToolOptionsPropertyBrowser::AddPropertyPointName(Tool *i, const QString &p AddProperty(itemName, VAbstractTool::AttrName); } +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::AddPropertyCrossPoint(Tool *i, const QString &propertyName) +{ + VEnumProperty* itemProperty = new VEnumProperty(propertyName); + itemProperty->setLiterals(QStringList()<< tr("First point") << tr("Second point")); + itemProperty->setValue(static_cast(i->GetCrossArcsPoint())-1); + AddProperty(itemProperty, VAbstractTool::AttrCrossPoint); +} + //--------------------------------------------------------------------------------------------------------------------- template void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &propertyName, @@ -827,6 +846,49 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersection(VProperty *p } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersectionArcs(VProperty *property) +{ + SCASSERT(property != nullptr) + + const QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolPointOfIntersectionArcs *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 28: // VAbstractTool::AttrCrossPoint + { + const QVariant value = property->data(VProperty::DPC_Data, Qt::EditRole); + bool ok = false; + const int val = value.toInt(&ok); + + CrossArcsPoint cross = CrossArcsPoint::FirstPoint; + if (ok) + { + switch(val) + { + case 0: + cross = CrossArcsPoint::FirstPoint; + case 1: + cross = CrossArcsPoint::SecondPoint; + default: + cross = CrossArcsPoint::FirstPoint; + } + } + i->SetCrossArcsPoint(cross); + break; + } + default: + qWarning()<<"Unknown property type. id = "<(item); + i->ShowVisualization(true); + formView->setTitle(tr("Tool to make point from intersection two arcs")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyCrossPoint(i, tr("Take")); +} + //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *item) { @@ -1485,6 +1558,15 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersection() idToProperty[VAbstractTool::AttrName]->setValue(i->name()); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionArcs() +{ + VToolPointOfIntersectionArcs *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + idToProperty[VAbstractTool::AttrCrossPoint]->setValue(static_cast(i->GetCrossArcsPoint())-1); +} + //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint() { @@ -1611,6 +1693,7 @@ QStringList VToolOptionsPropertyBrowser::PropertiesList() const << VAbstractTool::AttrAxisP2 /* 24 */ << VAbstractTool::AttrKCurve /* 25 */ << VAbstractTool::AttrLineColor /* 26 */ - << VAbstractTool::AttrColor; /* 27 */ + << VAbstractTool::AttrColor /* 27 */ + << VAbstractTool::AttrCrossPoint; /* 28 */ return attr; } diff --git a/src/app/widgets/vtooloptionspropertybrowser.h b/src/app/widgets/vtooloptionspropertybrowser.h index e0830771a..f12b9d86f 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.h +++ b/src/app/widgets/vtooloptionspropertybrowser.h @@ -71,6 +71,9 @@ private: template void AddPropertyPointName(Tool *i, const QString &propertyName); + template + void AddPropertyCrossPoint(Tool *i, const QString &propertyName); + template void AddPropertyLineType(Tool *i, const QString &propertyName, const QMap &styles); @@ -96,6 +99,7 @@ private: void ChangeDataToolNormal(VPE::VProperty *property); void ChangeDataToolPointOfContact(VPE::VProperty *property); void ChangeDataToolPointOfIntersection(VPE::VProperty *property); + void ChangeDataToolPointOfIntersectionArcs(VPE::VProperty *property); void ChangeDataToolShoulderPoint(VPE::VProperty *property); void ChangeDataToolSpline(VPE::VProperty *property); void ChangeDataToolSplinePath(VPE::VProperty *property); @@ -117,6 +121,7 @@ private: void ShowOptionsToolNormal(QGraphicsItem *item); void ShowOptionsToolPointOfContact(QGraphicsItem *item); void ShowOptionsToolPointOfIntersection(QGraphicsItem *item); + void ShowOptionsToolPointOfIntersectionArcs(QGraphicsItem *item); void ShowOptionsToolShoulderPoint(QGraphicsItem *item); void ShowOptionsToolSpline(QGraphicsItem *item); void ShowOptionsToolSplinePath(QGraphicsItem *item); @@ -138,6 +143,7 @@ private: void UpdateOptionsToolNormal(); void UpdateOptionsToolPointOfContact(); void UpdateOptionsToolPointOfIntersection(); + void UpdateOptionsToolPointOfIntersectionArcs(); void UpdateOptionsToolShoulderPoint(); void UpdateOptionsToolSpline(); void UpdateOptionsToolSplinePath(); diff --git a/src/app/xml/vpattern.h b/src/app/xml/vpattern.h index c532f4250..04e9b1ba8 100644 --- a/src/app/xml/vpattern.h +++ b/src/app/xml/vpattern.h @@ -38,7 +38,7 @@ class VMainGraphicsScene; enum class Document : char { LiteParse, LitePPParse, FullParse }; enum class LabelType : char {NewPatternPiece, NewLabel}; -enum class CrossArcPoint : char {FirstPoint = 1, SecondPoint = 2}; +enum class CrossArcsPoint : char {FirstPoint = 1, SecondPoint = 2}; /** * @brief The VPattern class working with pattern file. diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp index 6046fe5bf..c0000900b 100644 --- a/src/libs/vgeometry/vgobject.cpp +++ b/src/libs/vgeometry/vgobject.cpp @@ -267,10 +267,36 @@ int VGObject::IntersectionCircles(const QPointF &c1, double r1, const QPointF &c { return 3;// Circles are equal } - const double a = 2.0 * (c2.x() - c1.x()); - const double b = 2.0 * (c2.y() - c1.y()); - const double c = c1.x() * c1.x() + c1.y() * c1.y() - r1 * r1 - (c2.x() * c2.x() + c2.y() * c2.y() - r2 * r2); - return LineIntersectCircle (c1, r1, CreateSegment(a, b, c), p1, p2); + const double a = - 2.0 * (c2.x() - c1.x()); + const double b = - 2.0 * (c2.y() - c1.y()); + const double c = (c2.x() - c1.x())* (c2.x() - c1.x()) + (c2.y() - c1.y()) * (c2.y() - c1.y()) + r1 * r1 - r2 * r2; + + const double x0 = -a*c/(a*a+b*b); + const double y0 = -b*c/(a*a+b*b); + + if (c*c > r1*r1*(a*a+b*b)) + { + return 0; + } + else if (qFuzzyCompare(c*c, r1*r1*(a*a+b*b))) + { + p1 = QPointF(x0 + c1.x(), y0 + c1.y()); + return 1; + } + else + { + const double d = r1*r1 - c*c/(a*a+b*b); + const double mult = sqrt (d / (a*a+b*b)); + + const double ax = x0 + b * mult; + const double bx = x0 - b * mult; + const double ay = y0 - a * mult; + const double by = y0 + a * mult; + + p1 = QPointF(ax + c1.x(), ay + c1.y()); + p2 = QPointF(bx + c1.x(), by + c1.y()); + return 2; + } } //--------------------------------------------------------------------------------------------------------------------- @@ -429,18 +455,6 @@ double VGObject::GetEpsilon(const QPointF &p1, const QPointF &p2) return epsilon; } -//--------------------------------------------------------------------------------------------------------------------- -QLineF VGObject::CreateSegment(double a, double b, double c) -{ - const double x1 = 0; - const double y1 = (-a*x1-c)/b; - - const double x2 = 1000; - const double y2 = (-a*x2-c)/b; - - return QLineF(x1, y1, x2, y2); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief GetReversePoint return revers container of points. diff --git a/src/libs/vgeometry/vgobject.h b/src/libs/vgeometry/vgobject.h index 2e32741b3..de8075a76 100644 --- a/src/libs/vgeometry/vgobject.h +++ b/src/libs/vgeometry/vgobject.h @@ -90,7 +90,6 @@ private: static bool IsPointOnLineviaPDP(const QPointF &t, const QPointF &p1, const QPointF &p2); static double PerpDotProduct(const QPointF &t, const QPointF &p1, const QPointF &p2); static double GetEpsilon(const QPointF &p1, const QPointF &p2); - static QLineF CreateSegment(double a, double b, double c); }; #endif // VGOBJECT_H From 93a812af086ec31b0ab047d4f55a6e51daafe153 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 27 May 2015 21:23:50 +0300 Subject: [PATCH 7/8] Fixes. --HG-- branch : feature --- .../tools/dialogpointofintersectionarcs.cpp | 1 + .../vistoolpointofintersectionarcs.cpp | 4 ++-- .../widgets/vtooloptionspropertybrowser.cpp | 3 +++ src/app/xml/vpattern.cpp | 23 ++++++++++++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/app/dialogs/tools/dialogpointofintersectionarcs.cpp b/src/app/dialogs/tools/dialogpointofintersectionarcs.cpp index d6b2ba7a7..2246568b8 100644 --- a/src/app/dialogs/tools/dialogpointofintersectionarcs.cpp +++ b/src/app/dialogs/tools/dialogpointofintersectionarcs.cpp @@ -223,6 +223,7 @@ void DialogPointOfIntersectionArcs::SaveData() point->setArc1Id(GetFirstArcId()); point->setArc2Id(GetSecondArcId()); + point->setCrossPoint(GetCrossArcPoint()); point->RefreshGeometry(); } diff --git a/src/app/visualization/vistoolpointofintersectionarcs.cpp b/src/app/visualization/vistoolpointofintersectionarcs.cpp index 6c9309219..0b5b4f469 100644 --- a/src/app/visualization/vistoolpointofintersectionarcs.cpp +++ b/src/app/visualization/vistoolpointofintersectionarcs.cpp @@ -56,12 +56,12 @@ void VisToolPointOfIntersectionArcs::RefreshGeometry() if (arc1Id > NULL_ID) { const QSharedPointer arc1 = Visualization::data->GeometricObject(arc1Id); - DrawPath(arc1Path, arc1->GetPath(PathDirection::Hide), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); + DrawPath(arc1Path, arc1->GetPath(PathDirection::Show), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); if (arc2Id > NULL_ID) { const QSharedPointer arc2 = Visualization::data->GeometricObject(arc2Id); - DrawPath(arc2Path, arc2->GetPath(PathDirection::Hide), Qt::darkRed, Qt::SolidLine, Qt::RoundCap); + DrawPath(arc2Path, arc2->GetPath(PathDirection::Show), Qt::darkRed, Qt::SolidLine, Qt::RoundCap); const QPointF fPoint = VToolPointOfIntersectionArcs::FindPoint(arc1.data(), arc2.data(), crossPoint); DrawPoint(point, fPoint, mainColor); diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index 9bcb69c90..f265cbc56 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -874,10 +874,13 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersectionArcs(VPropert { case 0: cross = CrossArcsPoint::FirstPoint; + break; case 1: cross = CrossArcsPoint::SecondPoint; + break; default: cross = CrossArcsPoint::FirstPoint; + break; } } i->SetCrossArcsPoint(cross); diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index c82cf8ecb..bf920b614 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -1142,7 +1142,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem << VNodePoint::ToolType << VToolHeight::ToolType << VToolTriangle::ToolType << VToolPointOfIntersection::ToolType << VToolCutSpline::ToolType << VToolCutSplinePath::ToolType << VToolCutArc::ToolType - << VToolLineIntersectAxis::ToolType << VToolCurveIntersectAxis::ToolType; + << VToolLineIntersectAxis::ToolType << VToolCurveIntersectAxis::ToolType + << VToolPointOfIntersectionArcs::ToolType; switch (points.indexOf(type)) { case 0: //VToolSinglePoint::ToolType @@ -1633,6 +1634,26 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem throw excep; } break; + case 17: //VToolPointOfIntersectionArcs::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my); + const quint32 firstArcId = GetParametrUInt(domElement, VAbstractTool::AttrFirstArc, NULL_ID_STR); + const quint32 secondArcId = GetParametrUInt(domElement, VAbstractTool::AttrSecondArc, NULL_ID_STR); + const CrossArcsPoint crossPoint = static_cast(GetParametrUInt(domElement, + VAbstractTool::AttrCrossPoint, + "1")); + + VToolPointOfIntersectionArcs::Create(id, name, firstArcId, secondArcId, crossPoint, mx, my, scene, this, + data, parse, Source::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of intersection arcs"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; default: qDebug() << "Illegal point type in VDomDocument::ParsePointElement()."; break; From 256ad10169b0d197fc82b3a171d37d7a014c691b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 28 May 2015 12:07:52 +0300 Subject: [PATCH 8/8] New pattern format version. --HG-- branch : feature --- src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/pattern/v0.1.4.xsd | 312 +++++++++++++++++++++++++ src/libs/ifc/xml/vpatternconverter.cpp | 23 +- src/libs/ifc/xml/vpatternconverter.h | 1 + 4 files changed, 335 insertions(+), 2 deletions(-) create mode 100644 src/libs/ifc/schema/pattern/v0.1.4.xsd diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index f8b8fe11e..d1285d947 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -6,5 +6,6 @@ schema/pattern/v0.1.1.xsd schema/pattern/v0.1.2.xsd schema/pattern/v0.1.3.xsd + schema/pattern/v0.1.4.xsd diff --git a/src/libs/ifc/schema/pattern/v0.1.4.xsd b/src/libs/ifc/schema/pattern/v0.1.4.xsd new file mode 100644 index 000000000..059a82091 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.1.4.xsd @@ -0,0 +1,312 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index f3f834ea8..028b1ae8a 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -40,8 +40,8 @@ */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.1.3"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.1.3.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.1.4"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.1.4.xsd"); //--------------------------------------------------------------------------------------------------------------------- VPatternConverter::VPatternConverter(const QString &fileName) @@ -93,6 +93,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000102): return QStringLiteral("://schema/pattern/v0.1.2.xsd"); case (0x000103): + return QStringLiteral("://schema/pattern/v0.1.3.xsd"); + case (0x000104): return CurrentSchema; default: { @@ -140,6 +142,16 @@ void VPatternConverter::ApplyPatches() #endif } case (0x000103): + { + ToV0_1_4(); + const QString schema = XSDSchema(0x000104); + ValidateXML(schema, fileName); + // continue conversion + #ifdef Q_CC_CLANG + [[clang::fallthrough]]; + #endif + } + case (0x000104): break; default: break; @@ -184,3 +196,10 @@ void VPatternConverter::ToV0_1_3() SetVersion(QStringLiteral("0.1.3")); Save(); } + +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_1_4() +{ + SetVersion(QStringLiteral("0.1.4")); + Save(); +} diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index c9075318d..5df5443cd 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -58,6 +58,7 @@ private: void ToV0_1_1(); void ToV0_1_2(); void ToV0_1_3(); + void ToV0_1_4(); }; #endif // VPATTERNCONVERTER_H