From ca79c7ff9376dcf00bbcfa1b32a1ace085527112 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sun, 15 Oct 2017 12:25:20 +0300 Subject: [PATCH 01/15] Added place label. --HG-- branch : feature --- .../core/vtooloptionspropertybrowser.cpp | 6 +- src/app/valentina/dialogs/dialoghistory.cpp | 3 +- src/app/valentina/mainwindow.cpp | 47 +- src/app/valentina/mainwindow.h | 2 + src/app/valentina/mainwindow.ui | 48 +- src/app/valentina/share/resources/cursor.qrc | 2 + .../resources/cursor/place_label_cursor.png | Bin 0 -> 572 bytes .../cursor/place_label_cursor@2x.png | Bin 0 -> 1154 bytes .../valentina/share/resources/toolicon.qrc | 2 + .../resources/toolicon/32x32/place_label.png | Bin 0 -> 678 bytes .../toolicon/32x32/place_label@2x.png | Bin 0 -> 1359 bytes .../resources/toolicon/svg/place_label.svg | 80 ++ src/app/valentina/xml/vpattern.cpp | 75 +- src/app/valentina/xml/vpattern.h | 1 + src/libs/ifc/ifcdef.cpp | 3 + src/libs/ifc/ifcdef.h | 3 + src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/pattern/v0.7.0.xsd | 1033 +++++++++++++++++ src/libs/ifc/xml/vabstractpattern.cpp | 21 +- src/libs/ifc/xml/vabstractpattern.h | 3 +- src/libs/ifc/xml/vpatternconverter.cpp | 25 +- src/libs/ifc/xml/vpatternconverter.h | 3 +- src/libs/vdxf/vdxfengine.cpp | 46 +- src/libs/vdxf/vdxfengine.h | 1 + src/libs/vgeometry/vgeometry.pri | 7 +- src/libs/vgeometry/vgeometrydef.h | 45 +- src/libs/vgeometry/vplacelabelitem.cpp | 334 ++++++ src/libs/vgeometry/vplacelabelitem.h | 89 ++ src/libs/vgeometry/vplacelabelitem_p.h | 90 ++ src/libs/vlayout/vabstractpiece.cpp | 15 + src/libs/vlayout/vabstractpiece.h | 3 + src/libs/vlayout/vlayoutpiece.cpp | 119 +- src/libs/vlayout/vlayoutpiece.h | 5 +- src/libs/vlayout/vlayoutpiece_p.h | 11 +- src/libs/vmisc/def.h | 7 +- src/libs/vmisc/share/resources/icon.qrc | 2 + .../share/resources/icon/32x32/button.png | Bin 0 -> 2568 bytes .../share/resources/icon/32x32/button@2x.png | Bin 0 -> 6398 bytes src/libs/vpatterndb/vcontainer.cpp | 9 +- src/libs/vpatterndb/vcontainer.h | 1 + src/libs/vpatterndb/vpiece.cpp | 63 + src/libs/vpatterndb/vpiece.h | 29 +- src/libs/vpatterndb/vpiece_p.h | 3 + src/libs/vtools/dialogs/dialogs.pri | 10 +- src/libs/vtools/dialogs/tooldialogs.h | 1 + src/libs/vtools/dialogs/tools/dialogpin.cpp | 18 +- .../vtools/dialogs/tools/dialogplacelabel.cpp | 469 ++++++++ .../vtools/dialogs/tools/dialogplacelabel.h | 119 ++ .../vtools/dialogs/tools/dialogplacelabel.ui | 655 +++++++++++ src/libs/vtools/dialogs/tools/dialogtool.cpp | 3 +- .../tools/piece/dialogseamallowance.cpp | 346 ++++-- .../dialogs/tools/piece/dialogseamallowance.h | 16 +- .../tools/piece/tabs/tabplacelabels.ui | 28 + .../operation/flipping/vabstractflipping.cpp | 8 +- .../operation/vabstractoperation.cpp | 4 +- .../tools/drawTools/operation/vtoolmove.cpp | 8 +- .../drawTools/operation/vtoolrotation.cpp | 8 +- .../toollinepoint/vtoolcurveintersectaxis.cpp | 1 + .../vtools/tools/nodeDetails/nodedetails.h | 1 + .../tools/nodeDetails/vtoolplacelabel.cpp | 211 ++++ .../tools/nodeDetails/vtoolplacelabel.h | 83 ++ src/libs/vtools/tools/tools.pri | 6 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 70 +- src/libs/vtools/tools/vtoolseamallowance.h | 11 +- src/libs/vtools/tools/vtooluniondetails.cpp | 103 +- .../vtools/undocommands/savepieceoptions.cpp | 10 +- .../undocommands/saveplacelabeloptions.cpp | 125 ++ .../undocommands/saveplacelabeloptions.h | 57 + src/libs/vtools/undocommands/undocommands.pri | 6 +- src/libs/vtools/undocommands/vundocommand.cpp | 18 +- src/libs/vtools/undocommands/vundocommand.h | 1 + .../line/operation/visoperation.cpp | 4 +- .../line/operation/vistoolmove.cpp | 8 +- .../line/operation/vistoolrotation.cpp | 4 +- ...vistoolpin.cpp => vistoolspecialpoint.cpp} | 9 +- .../{vistoolpin.h => vistoolspecialpoint.h} | 16 +- ...iecepins.cpp => vispiecespecialpoints.cpp} | 20 +- ...vispiecepins.h => vispiecespecialpoints.h} | 20 +- .../vtools/visualization/visualization.pri | 8 +- 79 files changed, 4444 insertions(+), 278 deletions(-) create mode 100644 src/app/valentina/share/resources/cursor/place_label_cursor.png create mode 100644 src/app/valentina/share/resources/cursor/place_label_cursor@2x.png create mode 100644 src/app/valentina/share/resources/toolicon/32x32/place_label.png create mode 100644 src/app/valentina/share/resources/toolicon/32x32/place_label@2x.png create mode 100644 src/app/valentina/share/resources/toolicon/svg/place_label.svg create mode 100644 src/libs/ifc/schema/pattern/v0.7.0.xsd create mode 100644 src/libs/vgeometry/vplacelabelitem.cpp create mode 100644 src/libs/vgeometry/vplacelabelitem.h create mode 100644 src/libs/vgeometry/vplacelabelitem_p.h create mode 100644 src/libs/vmisc/share/resources/icon/32x32/button.png create mode 100644 src/libs/vmisc/share/resources/icon/32x32/button@2x.png create mode 100644 src/libs/vtools/dialogs/tools/dialogplacelabel.cpp create mode 100644 src/libs/vtools/dialogs/tools/dialogplacelabel.h create mode 100644 src/libs/vtools/dialogs/tools/dialogplacelabel.ui create mode 100644 src/libs/vtools/dialogs/tools/piece/tabs/tabplacelabels.ui create mode 100644 src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp create mode 100644 src/libs/vtools/tools/nodeDetails/vtoolplacelabel.h create mode 100644 src/libs/vtools/undocommands/saveplacelabeloptions.cpp create mode 100644 src/libs/vtools/undocommands/saveplacelabeloptions.h rename src/libs/vtools/visualization/line/{vistoolpin.cpp => vistoolspecialpoint.cpp} (90%) rename src/libs/vtools/visualization/line/{vistoolpin.h => vistoolspecialpoint.h} (79%) rename src/libs/vtools/visualization/path/{vispiecepins.cpp => vispiecespecialpoints.cpp} (83%) rename src/libs/vtools/visualization/path/{vispiecepins.h => vispiecespecialpoints.h} (75%) diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index ae4116e90..0e6bfe0c7 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -78,7 +78,7 @@ void VToolOptionsPropertyBrowser::ClearPropertyBrowser() void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used in switch."); switch (item->type()) { @@ -205,7 +205,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions() } // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used in switch."); switch (currentItem->type()) { @@ -350,7 +350,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VPE::VProperty *property) } // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used in switch."); switch (currentItem->type()) { diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index 1bdf98b7a..aa01d7f64 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -212,7 +212,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") QString DialogHistory::Record(const VToolRecord &tool) { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were used in history."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used in history."); const QDomElement domElem = doc->elementById(tool.getId()); if (domElem.isElement() == false) @@ -406,6 +406,7 @@ QString DialogHistory::Record(const VToolRecord &tool) case Tool::Move: case Tool::PiecePath: case Tool::Pin: + case Tool::PlaceLabel: case Tool::InsertNode: return QString(); } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 58105575c..ba1faff63 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -55,6 +55,7 @@ #include "tools/vtoolseamallowance.h" #include "tools/nodeDetails/vtoolpiecepath.h" #include "tools/nodeDetails/vtoolpin.h" +#include "tools/nodeDetails/vtoolplacelabel.h" #include "tools/vtooluniondetails.h" #include "dialogs/dialogs.h" #include "dialogs/vwidgetgroups.h" @@ -611,6 +612,9 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons ui->view->setShowToolOptions(false); dialogTool = QSharedPointer(new Dialog(pattern, 0, this)); + // This check helps to find missed tools in the switch + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Check if need to extend."); + switch(t) { case Tool::Midpoint: @@ -619,6 +623,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons case Tool::PiecePath: case Tool::Pin: case Tool::InsertNode: + case Tool::PlaceLabel: dialogTool->SetPiecesList(doc->GetActivePPPieces()); break; default: @@ -1033,6 +1038,14 @@ void MainWindow::ToolPin(bool checked) &MainWindow::ClosedDialogPin); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolPlaceLabel(bool checked) +{ + ToolSelectPointByRelease(); + SetToolButton(checked, Tool::PlaceLabel, "://cursor/place_label_cursor.png", + tr("Select placelabel center point"), &MainWindow::ClosedDialogPlaceLabel); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ToolHeight handler tool height. @@ -1200,6 +1213,18 @@ void MainWindow::ClosedDialogPin(int result) doc->LiteParseTree(Document::LiteParse); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ClosedDialogPlaceLabel(int result) +{ + SCASSERT(dialogTool != nullptr); + if (result == QDialog::Accepted) + { + VToolPlaceLabel::Create(dialogTool, doc, pattern); + } + ArrowTool(); + doc->LiteParseTree(Document::LiteParse); +} + //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ClosedDialogInsertNode(int result) { @@ -1960,7 +1985,7 @@ void MainWindow::InitToolButtons() } // This check helps to find missed tools - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Check if all tools were connected."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Check if all tools were connected."); connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine); connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine); @@ -2009,6 +2034,7 @@ void MainWindow::InitToolButtons() connect(ui->toolButtonEllipticalArc, &QToolButton::clicked, this, &MainWindow::ToolEllipticalArc); connect(ui->toolButtonPin, &QToolButton::clicked, this, &MainWindow::ToolPin); connect(ui->toolButtonInsertNode, &QToolButton::clicked, this, &MainWindow::ToolInsertNode); + connect(ui->toolButtonPlaceLabel, &QToolButton::clicked, this, &MainWindow::ToolPlaceLabel); } //--------------------------------------------------------------------------------------------------------------------- @@ -2036,7 +2062,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") void MainWindow::CancelTool() { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were handled."); qCDebug(vMainWindow, "Canceling tool."); dialogTool.clear(); @@ -2200,6 +2226,9 @@ void MainWindow::CancelTool() case Tool::InsertNode: ui->toolButtonInsertNode->setChecked(false); break; + case Tool::PlaceLabel: + ui->toolButtonPlaceLabel->setChecked(false); + break; } // Crash: using CRTL+Z while using line tool. @@ -3378,6 +3407,8 @@ void MainWindow::SetEnableTool(bool enable) bool modelingTools = false; bool layoutTools = false; +QT_WARNING_PUSH +QT_WARNING_DISABLE_GCC("-Wswitch-default") switch (mode) { case Draw::Calculation: @@ -3389,12 +3420,11 @@ void MainWindow::SetEnableTool(bool enable) case Draw::Layout: layoutTools = enable; break; - default: - break; } +QT_WARNING_POP // This check helps to find missed tools - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were handled."); //Drawing Tools ui->toolButtonEndLine->setEnabled(drawTools); @@ -3437,6 +3467,7 @@ void MainWindow::SetEnableTool(bool enable) ui->toolButtonEllipticalArc->setEnabled(drawTools); ui->toolButtonPin->setEnabled(drawTools); ui->toolButtonInsertNode->setEnabled(drawTools); + ui->toolButtonPlaceLabel->setEnabled(drawTools); ui->actionLast_tool->setEnabled(drawTools); @@ -3721,7 +3752,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") void MainWindow::LastUsedTool() { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were handled."); if (currentTool == lastUsedTool) { @@ -3916,6 +3947,10 @@ void MainWindow::LastUsedTool() ui->toolButtonInsertNode->setChecked(true); ToolInsertNode(true); break; + case Tool::PlaceLabel: + ui->toolButtonPlaceLabel->setChecked(true); + ToolPlaceLabel(true); + break; } } diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 0351e9dd6..47e6a76a0 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -145,6 +145,7 @@ private slots: void ToolDetail(bool checked); void ToolPiecePath(bool checked); void ToolPin(bool checked); + void ToolPlaceLabel(bool checked); void ToolHeight(bool checked); void ToolTriangle(bool checked); void ToolPointOfIntersection(bool checked); @@ -180,6 +181,7 @@ private slots: void ClosedDialogGroup(int result); void ClosedDialogPiecePath(int result); void ClosedDialogPin(int result); + void ClosedDialogPlaceLabel(int result); void ClosedDialogInsertNode(int result); void ZoomFitBestCurrent(); diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index a9e3ac0af..3ac5c3541 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -55,8 +55,8 @@ 0 0 - 127 - 358 + 126 + 351 @@ -402,7 +402,7 @@ 0 0 140 - 110 + 108 @@ -511,7 +511,7 @@ 0 0 140 - 248 + 243 @@ -773,7 +773,7 @@ 0 0 140 - 248 + 243 @@ -1038,7 +1038,7 @@ 0 0 140 - 104 + 102 @@ -1121,7 +1121,7 @@ 0 0 140 - 328 + 324 @@ -1325,7 +1325,7 @@ 0 0 140 - 196 + 237 @@ -1527,6 +1527,32 @@ + + + + false + + + Place label tool + + + ... + + + + :/toolicon/32x32/place_label.png:/toolicon/32x32/place_label.png + + + + 32 + 32 + + + + true + + + @@ -1535,7 +1561,7 @@ 0 0 140 - 328 + 324 @@ -1635,7 +1661,7 @@ 0 0 1100 - 25 + 22 @@ -2737,8 +2763,8 @@ - + diff --git a/src/app/valentina/share/resources/cursor.qrc b/src/app/valentina/share/resources/cursor.qrc index ea61c6eaf..1ef61e19d 100644 --- a/src/app/valentina/share/resources/cursor.qrc +++ b/src/app/valentina/share/resources/cursor.qrc @@ -84,5 +84,7 @@ cursor/pin_cursor@2x.png cursor/insert_node_cursor.png cursor/insert_node_cursor@2x.png + cursor/place_label_cursor@2x.png + cursor/place_label_cursor.png diff --git a/src/app/valentina/share/resources/cursor/place_label_cursor.png b/src/app/valentina/share/resources/cursor/place_label_cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..8bfc47b5f7ab5fb63f9691bde90a1efa6dd3120f GIT binary patch literal 572 zcmV-C0>k}@P)V#s`MoGdp|E zf6kdb%YXgV7hGu)U~)Ie^+Bx&hP*Q3OyM#C8clEfBi_ z3>+c_V4x6Ni2wtG*bBfwAodDSImFK%04jy(6`(SRegMiKuHsx#(4oxzCJy$wi8b89 z0xn_(lX3nd-rz$Kzy=O=aoQ5v^!`MMuXurFycV+Z1B>Id{v1f6&ZR{&?w29Br*}KHx$AvP!FIn>z<2YOfuoj(63AIbrj8Ny@w18)MLf)#&7&(40~bDWHJHUnqz zOy~vZY(!OR7!Pn1$Aq)BB79M=gtlLsZsT&%!_@ZLk3I>z@2cN_;oAQY)1dDF0000< KMNUMnLSTZ(VED)Y literal 0 HcmV?d00001 diff --git a/src/app/valentina/share/resources/cursor/place_label_cursor@2x.png b/src/app/valentina/share/resources/cursor/place_label_cursor@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..8ac92cfe503da79bae44d4fede218e5e51e3db18 GIT binary patch literal 1154 zcmV-|1bzF7P)4Z6?;vCW&{q%+$p)ZrAp9*mfWCmxDuAAca8T<2dK$uC@&VAZ5b^}jlMoKb z7eLQJ*e`zoJq4j%0D1<(pV|kYCm>8|FMz^B=mda5L-<2y02CI&KAi(lNC=$pXx$LHJE~02Bs7Hvtp^!rm04iVopntjRLjp_K3DvJ8~7&c2BR$1CnhLV|YS5-FtCzmCeuM{_@`?oQcPUH{6Y7i%qu3AyBOuydXUGR_v|4nKhlP8s zZ?JzBT`SHfHs>(bE4WCc&v|79un#xj)zLuZ4c7924{?j2*$$P&f;B2^TP5=S>N?kri;%3>Z%hH?>>uWDl2l~}bpSW%?BtVnY{B(8jdzsD0Gq16O!I&(!tEzS3EEA)A$EP^ z_@%|MF2{1Qkk2d41J(*x>GtH|TamgR5Kl0xmg5n;BoQW^TG+B`8c*TIa?7G&aYitV z*A(l#qal^V(L~}1v0EI&(c)+RB~cA-6bs%i zJs9)Ns3Ztoolicon/32x32/pin@2x.png toolicon/32x32/insert_node.png toolicon/32x32/insert_node@2x.png + toolicon/32x32/place_label@2x.png + toolicon/32x32/place_label.png diff --git a/src/app/valentina/share/resources/toolicon/32x32/place_label.png b/src/app/valentina/share/resources/toolicon/32x32/place_label.png new file mode 100644 index 0000000000000000000000000000000000000000..533938118fdc0651c515166923cc68451e270a81 GIT binary patch literal 678 zcmV;X0$KfuP)0005>0kZ=LkpKVy8FWQhbW?9;ba!ELWdL_~cP?peYja~^ zaAhuUa%Y?FJQ@H10wYO8K~z|U)z{C9&0!SB@z)GyVMe1NH8V|FNQ@++N#j=|zs5$) zPT436iG=)GSW#lbLiq4bAL3GPkp=J@Ar8+ z=lwkQJm;J*|GC<*bUXpJ;(8?pYO4e?W}1fWxQ1u=j-PmqJ2;5hr5K!$IByD$;sP3R z184CRldughunecL01q)-3d~5FBUams_Pnt|G0=q5_<${yI$wez>>Xizv>;r8LF_8m zc?;f%?Hx(QPQhHUfc517+!R|mno^G82D}roldP5KM|~9l;0jKZ0?>=y3G-3`+VKf> z`2&R#Q3F=va)RMh_2Ct|QUE%{u^Xr&0Nlc=6o6K|tg>@r2U_!A)?~kjup_%~6xnSk z!DxdB)WL+g^&+Fb&7KF)nFDCSjO>0BI&mPuXgAhjPr}?DEEbD}ALyHyJ@jW6G-pO1 zB^aHD&xvz4i(vd`ZlM^sCyL3`1f!*>3wQHh76N#W``B1T=gnAz+bIBW9*3ou>tZ^B zOXBZJQmv@x#VT1!CY&#_U|Xv5oEG9EmRA5U9nZ0|ROdPMhn+a M07*qoM6N<$f(`p50RR91 literal 0 HcmV?d00001 diff --git a/src/app/valentina/share/resources/toolicon/32x32/place_label@2x.png b/src/app/valentina/share/resources/toolicon/32x32/place_label@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..5130f83125350f68f8be756431b7458097d7bbd0 GIT binary patch literal 1359 zcmV-V1+e;wP)ckpS9N6Lz_1LYX($2|IJu{9oST{FO~2rYPh~C2Rf^oxK(Hi zP_+Y9)6t}P4##xNz$qAqQ5YJ(-;3?ojJ5a(E3igbBMwSBF&od}PvJze9-FWTW1H-I zAqHR`*4g)DzQa=7hzl?QE8};!V;Zi&o$>FxyN&%Dk7In(&LSsgV70{Y9e4m!d+FcT zV{i!OVpTVLe_=7YO7*$~I&p_^rE1tIT-9L>#-)t|&cquMA=YA20e?%S3(Fmk3(l`w7L`QxR9&=gA8wwA= z!*T3Cn4e?rLUiCo$wGHpPCG?%fet(v$M3=UIeo~*Epg)Am|4J1(PXF-%c6~~IJ$r@ zshK1wUK5__MJOX1?2<%`uN3sBAsu)xPPSa}P`a#ic#;q!)Nn~bTYWMoPVzgBE5Tlw z^?>`MtqmAhg1!Cdz$bB%drGodrT{~QgsO(CO0c&dGbLAlR7p0=t_UrR_C8KKAWJ=9 zZfuv~rwrqo$wNXoJ_Qrg3`i@$K*{3rSa!df#*aeIKv=IDl2(Azh2Pk3LUz{5yd2we z({xTNKt0TTTe!tqnH8~}hQWG{lkOff|B7o5Bq#2}2q6Ss-%Fo7+$3DBrOJK0E)Z%IPYTte zo@5T>J{6RkUCgij=&zTf^-A(JjXI`X1UJU^#GDQ_oBC60L!*vq1y~!~34Qiz4Mqrs zQ$kG8Cus%vFt#)Dc+_NO#`Y_0Yt%Wd0IP)R>+$huWoE^8MW4MQX$9DhcjM!k${QQVexh|bW zl9!W%O0ZXE9B`?mWH+Wk-`tGA&vByLO0ZX!07LLiw6(aXQ;oPz@>XbaL0e@Buq4{~ zRuH3K>BQ@C!gWFxnU^vIxLWd(^uhvmGBH}nxobk1tYPV?7m5mSo@D<~zu)>jnJN@X zYr-9o=hiDCz^rcbzo4Q=^DJT2tqH}FV>6D=E5Llom0v0U9asv}g$)ul;R$hZhOt=% z7=}kBg^lNNXomUvjq#G2LEW)5d;8J~&?zi-TO?a!?$Tlr>0n_?Tz#k59^q0?YI z0lI`ehhIp<-6% + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index a2e635357..39608bafd 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -858,7 +858,8 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse << TagGrainline << VToolSeamAllowance::TagCSA << VToolSeamAllowance::TagIPaths - << VToolSeamAllowance::TagPins; + << VToolSeamAllowance::TagPins + << VToolSeamAllowance::TagPlaceLabels; const QDomNodeList nodeList = domElement.childNodes(); for (qint32 i = 0; i < nodeList.size(); ++i) @@ -899,7 +900,10 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse initData.detail.SetInternalPaths(ParsePieceInternalPaths(element)); break; case 6:// VToolSeamAllowance::TagPins - initData.detail.SetPins(ParsePiecePins(element)); + initData.detail.SetPins(ParsePiecePointRecords(element)); + break; + case 7:// VToolSeamAllowance::TagPlaceLabels + initData.detail.SetPlaceLabels(ParsePiecePointRecords(element)); break; default: break; @@ -963,7 +967,7 @@ void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail) ppData.SetOnFold(GetParametrBool(domElement, AttrOnFold, falseStr)); ppData.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0"))); ppData.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1")); - ppData.SetLabelHeight(GetParametrString(domElement, VToolSeamAllowance::AttrHeight, "1")); + ppData.SetLabelHeight(GetParametrString(domElement, AttrHeight, "1")); ppData.SetFontSize(static_cast(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, "0"))); ppData.SetRotation(GetParametrString(domElement, AttrRotation, "0")); ppData.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR)); @@ -979,7 +983,7 @@ void VPattern::ParsePiecePatternInfo(const QDomElement &domElement, VPiece &deta patternInfo.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr)); patternInfo.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0"))); patternInfo.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1")); - patternInfo.SetLabelHeight(GetParametrString(domElement, VToolSeamAllowance::AttrHeight, "1")); + patternInfo.SetLabelHeight(GetParametrString(domElement, AttrHeight, "1")); patternInfo.SetFontSize(static_cast(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, "0"))); patternInfo.SetRotation(GetParametrString(domElement, AttrRotation, "0")); patternInfo.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR)); @@ -1090,7 +1094,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem << VToolPointFromArcAndTangent::ToolType /*20*/ << VToolTrueDarts::ToolType /*21*/ << VToolPointOfIntersectionCurves::ToolType /*22*/ - << VToolPin::ToolType; /*23*/ + << VToolPin::ToolType /*23*/ + << VToolPlaceLabel::ToolType; /*24*/ switch (points.indexOf(type)) { case 0: //VToolBasePoint::ToolType @@ -1165,6 +1170,9 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 23: //VToolPin::ToolType ParsePinPoint(domElement, parse); break; + case 24: //VToolPlaceLabel::ToolType + ParsePlaceLabel(domElement, parse); + break; default: VException e(tr("Unknown point type '%1'.").arg(type)); throw e; @@ -1696,6 +1704,60 @@ void VPattern::ParsePinPoint(const QDomElement &domElement, const Document &pars } } +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::ParsePlaceLabel(QDomElement &domElement, const Document &parse) +{ + Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); + + try + { + VToolPlaceLabelInitData initData; + initData.doc = this; + initData.data = data; + initData.parse = parse; + initData.typeCreation = Source::FromFile; + + ToolsCommonAttributes(domElement, initData.id); + initData.centerPoint = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR); + initData.idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR); + + initData.width = GetParametrString(domElement, AttrLength, "1.0"); + const QString w = initData.width;//need for saving fixed formula; + + initData.height = GetParametrString(domElement, AttrHeight, "1.0"); + const QString h = initData.height;//need for saving fixed formula; + + initData.angle = GetParametrString(domElement, AttrAngle, "0.0"); + const QString angle = initData.angle;//need for saving fixed formula; + + initData.type = static_cast(GetParametrUInt(domElement, AttrPlaceLabelType, "0")); + + VToolPlaceLabel::Create(initData); + + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (w != initData.width || h != initData.height || angle != initData.angle) + { + SetAttribute(domElement, AttrWidth, initData.width); + SetAttribute(domElement, AttrHeight, initData.height); + SetAttribute(domElement, AttrAngle, initData.angle); + modified = true; + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating place lavel"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating place lavel"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } +} + //--------------------------------------------------------------------------------------------------------------------- void VPattern::ParseToolHeight(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse) { @@ -4103,7 +4165,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") QRectF VPattern::ActiveDrawBoundingRect() const { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were used."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used."); QRectF rec; @@ -4183,6 +4245,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const case Tool::PiecePath: case Tool::Pin: case Tool::InsertNode: + case Tool::PlaceLabel: break; } } diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index 6a1a0fc30..d0a6e5780 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -180,6 +180,7 @@ private: void ParseToolPointOfContact(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); void ParseNodePoint(const QDomElement &domElement, const Document &parse); void ParsePinPoint(const QDomElement &domElement, const Document &parse); + void ParsePlaceLabel(QDomElement &domElement, const Document &parse); void ParseToolHeight(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse); void ParseToolTriangle(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse); void ParseToolPointOfIntersection(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse); diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index ce3b30018..bd002fef8 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -126,6 +126,9 @@ const QString AttrClosed = QStringLiteral("closed"); const QString AttrShowLabel = QStringLiteral("showLabel"); const QString AttrShowLabel1 = QStringLiteral("showLabel1"); const QString AttrShowLabel2 = QStringLiteral("showLabel2"); +const QString AttrWidth = QStringLiteral("width"); +const QString AttrHeight = QStringLiteral("height"); +const QString AttrPlaceLabelType = QStringLiteral("placeLabelType"); const QString TypeLineNone = QStringLiteral("none"); const QString TypeLineLine = QStringLiteral("hair"); diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 4de8d078b..a14b930f7 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -145,6 +145,9 @@ extern const QString AttrClosed; extern const QString AttrShowLabel; extern const QString AttrShowLabel1; extern const QString AttrShowLabel2; +extern const QString AttrWidth; +extern const QString AttrHeight; +extern const QString AttrPlaceLabelType; extern const QString TypeLineNone; extern const QString TypeLineLine; diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index c0919498b..b78e02e07 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -41,6 +41,7 @@ schema/pattern/v0.6.4.xsd schema/pattern/v0.6.5.xsd schema/pattern/v0.6.6.xsd + schema/pattern/v0.7.0.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.7.0.xsd b/src/libs/ifc/schema/pattern/v0.7.0.xsd new file mode 100644 index 000000000..2d716b4f7 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.7.0.xsd @@ -0,0 +1,1033 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 5479bbe06..170fdf218 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -124,7 +124,6 @@ const QString VAbstractPattern::AttrStart = QStringLiteral("start"); const QString VAbstractPattern::AttrPath = QStringLiteral("path"); const QString VAbstractPattern::AttrEnd = QStringLiteral("end"); const QString VAbstractPattern::AttrIncludeAs = QStringLiteral("includeAs"); -const QString VAbstractPattern::AttrWidth = QStringLiteral("width"); const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation"); const QString VAbstractPattern::AttrNumber = QStringLiteral("number"); @@ -678,7 +677,7 @@ QVector VAbstractPattern::ParsePieceInternalPaths(const QDomElement &do } //--------------------------------------------------------------------------------------------------------------------- -QVector VAbstractPattern::ParsePiecePins(const QDomElement &domElement) +QVector VAbstractPattern::ParsePiecePointRecords(const QDomElement &domElement) { QVector records; const QDomNodeList nodeList = domElement.childNodes(); @@ -1772,7 +1771,7 @@ QVector VAbstractPattern::ListPointExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment a number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); QVector expressions; const QDomNodeList list = elementsByTagName(TagPoint); @@ -1787,6 +1786,8 @@ QVector VAbstractPattern::ListPointExpressions() const ReadExpressionAttribute(expressions, dom, AttrC2Radius); ReadExpressionAttribute(expressions, dom, AttrCRadius); ReadExpressionAttribute(expressions, dom, AttrRadius); + ReadExpressionAttribute(expressions, dom, AttrWidth); + ReadExpressionAttribute(expressions, dom, AttrHeight); } return expressions; @@ -1798,7 +1799,7 @@ QVector VAbstractPattern::ListArcExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); QVector expressions; const QDomNodeList list = elementsByTagName(TagArc); @@ -1822,7 +1823,7 @@ QVector VAbstractPattern::ListElArcExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); QVector expressions; const QDomNodeList list = elementsByTagName(TagElArc); @@ -1855,7 +1856,7 @@ QVector VAbstractPattern::ListPathPointExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); QVector expressions; const QDomNodeList list = elementsByTagName(AttrPathPoint); @@ -1893,7 +1894,7 @@ QVector VAbstractPattern::ListOperationExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); QVector expressions; const QDomNodeList list = elementsByTagName(TagOperation); @@ -1915,7 +1916,7 @@ QVector VAbstractPattern::ListNodesExpressions(const QDomElement // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); QVector expressions; @@ -1938,7 +1939,7 @@ QVector VAbstractPattern::ListPathExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); QVector expressions; const QDomNodeList list = elementsByTagName(TagPath); @@ -1976,7 +1977,7 @@ QVector VAbstractPattern::ListPieceExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); QVector expressions; const QDomNodeList list = elementsByTagName(TagDetail); diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 6551c6fca..920837731 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -120,7 +120,7 @@ public: static VPiecePath ParsePieceNodes(const QDomElement &domElement); static QVector ParsePieceCSARecords(const QDomElement &domElement); static QVector ParsePieceInternalPaths(const QDomElement &domElement); - static QVector ParsePiecePins(const QDomElement &domElement); + static QVector ParsePiecePointRecords(const QDomElement &domElement); void AddToolOnRemove(VDataTool *tool); @@ -267,7 +267,6 @@ public: static const QString AttrPath; static const QString AttrEnd; static const QString AttrIncludeAs; - static const QString AttrWidth; static const QString AttrRotation; static const QString AttrNumber; diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index ba6557e27..57c04f356 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -58,8 +58,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.6.6"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.6.6.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.0"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.0.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -256,12 +256,12 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000605): return QStringLiteral("://schema/pattern/v0.6.5.xsd"); case (0x000606): + return QStringLiteral("://schema/pattern/v0.6.6.xsd"); + case (0x000700): return CurrentSchema; default: InvalidVersion(ver); - break; } - return QString();//unreachable code } //--------------------------------------------------------------------------------------------------------------------- @@ -430,10 +430,13 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000606), m_convertedFileName); V_FALLTHROUGH case (0x000606): + ToV0_7_0(); + ValidateXML(XSDSchema(0x000700), m_convertedFileName); + V_FALLTHROUGH + case (0x000700): break; default: InvalidVersion(m_ver); - break; } } @@ -448,7 +451,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion() bool VPatternConverter::IsReadOnly() const { // Check if attribute readOnly was not changed in file format - Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 6, 6), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 0), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -912,6 +915,16 @@ void VPatternConverter::ToV0_6_6() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_7_0() +{ + // TODO. Delete if minimal supported version is 0.7.0 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 0), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.7.0")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 088c7b492..72ce8452d 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -53,7 +53,7 @@ public: static const QString PatternMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 6, 6); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 0); protected: virtual int MinVer() const Q_DECL_OVERRIDE; @@ -112,6 +112,7 @@ private: void ToV0_6_4(); void ToV0_6_5(); void ToV0_6_6(); + void ToV0_7_0(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 755dd4be1..759748eb9 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -643,6 +643,7 @@ bool VDxfEngine::ExportToAAMA(const QVector &details) ExportAAMANotch(detailBlock, detail); ExportAAMAGrainline(detailBlock, detail); ExportAAMAText(detailBlock, detail); + ExportAAMADrill(detailBlock, detail); input->AddBlock(detailBlock); @@ -688,11 +689,7 @@ void VDxfEngine::ExportAAMADraw(dx_ifaceBlock *detailBlock, const VLayoutPiece & detailBlock->ent.push_back(e); } } -} -//--------------------------------------------------------------------------------------------------------------------- -void VDxfEngine::ExportAAMAIntcut(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) -{ QVector> drawIntCut = detail.InternalPathsForCut(false); for(int j = 0; j < drawIntCut.size(); ++j) { @@ -703,7 +700,27 @@ void VDxfEngine::ExportAAMAIntcut(dx_ifaceBlock *detailBlock, const VLayoutPiece } } - drawIntCut = detail.InternalPathsForCut(true); + const QVector labels = detail.GetPlaceLabels(); + foreach(const VLayoutPlaceLabel &label, labels) + { + if (label.type != PlaceLabelType::Doubletree && label.type != PlaceLabelType::Button) + { + foreach(const QPolygonF &p, label.shape) + { + DRW_Entity *e = AAMAPolygon(p, "8", false); + if (e) + { + detailBlock->ent.push_back(e); + } + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDxfEngine::ExportAAMAIntcut(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) +{ + QVector> drawIntCut = detail.InternalPathsForCut(true); for(int j = 0; j < drawIntCut.size(); ++j) { DRW_Entity *e = AAMAPolygon(drawIntCut.at(j), "11", false); @@ -776,6 +793,25 @@ void VDxfEngine::ExportAAMAGlobalText(const QSharedPointer &input, con } } +//--------------------------------------------------------------------------------------------------------------------- +void VDxfEngine::ExportAAMADrill(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) +{ + const QVector labels = detail.GetPlaceLabels(); + + foreach(const VLayoutPlaceLabel &label, labels) + { + if (label.type == PlaceLabelType::Doubletree || label.type == PlaceLabelType::Button) + { + DRW_Point *point = new DRW_Point(); + point->basePoint = DRW_Coord(FromPixel(label.center.x(), varInsunits), + FromPixel(getSize().height() - label.center.y(), varInsunits), 0); + point->layer = "13"; + + detailBlock->ent.push_back(point); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- DRW_Entity *VDxfEngine::AAMAPolygon(const QVector &polygon, const QString &layer, bool forceClosed) { diff --git a/src/libs/vdxf/vdxfengine.h b/src/libs/vdxf/vdxfengine.h index 67eb4c363..c09a12fb8 100644 --- a/src/libs/vdxf/vdxfengine.h +++ b/src/libs/vdxf/vdxfengine.h @@ -116,6 +116,7 @@ private: void ExportAAMAGrainline(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail); void ExportAAMAText(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail); void ExportAAMAGlobalText(const QSharedPointer &input, const QVector &details); + void ExportAAMADrill(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail); Q_REQUIRED_RESULT DRW_Entity *AAMAPolygon(const QVector &polygon, const QString &layer, bool forceClosed); Q_REQUIRED_RESULT DRW_Entity *AAMALine(const QLineF &line, const QString &layer); diff --git a/src/libs/vgeometry/vgeometry.pri b/src/libs/vgeometry/vgeometry.pri index 039d6e477..d010aabe0 100644 --- a/src/libs/vgeometry/vgeometry.pri +++ b/src/libs/vgeometry/vgeometry.pri @@ -15,7 +15,8 @@ SOURCES += \ $$PWD/vabstractcubicbezierpath.cpp \ $$PWD/vcubicbezierpath.cpp \ $$PWD/vabstractarc.cpp \ - $$PWD/vabstractbezier.cpp + $$PWD/vabstractbezier.cpp \ + $$PWD/vplacelabelitem.cpp *msvc*:SOURCES += $$PWD/stable.cpp @@ -46,4 +47,6 @@ HEADERS += \ $$PWD/vcubicbezierpath_p.h \ $$PWD/vabstractarc.h \ $$PWD/vabstractarc_p.h \ - $$PWD/vabstractbezier.h + $$PWD/vabstractbezier.h \ + $$PWD/vplacelabelitem.h \ + $$PWD/vplacelabelitem_p.h diff --git a/src/libs/vgeometry/vgeometrydef.h b/src/libs/vgeometry/vgeometrydef.h index de9f4404b..f3a4c1a7f 100644 --- a/src/libs/vgeometry/vgeometrydef.h +++ b/src/libs/vgeometry/vgeometrydef.h @@ -29,8 +29,51 @@ #ifndef VGEOMETRYDEF_H #define VGEOMETRYDEF_H +#include +#include + enum class Draw : char { Calculation, Modeling, Layout }; -enum class GOType : char { Point, Arc, EllipticalArc, Spline, SplinePath, CubicBezier, CubicBezierPath, Unknown }; +enum class GOType : char +{ + Point, + Arc, + EllipticalArc, + Spline, + SplinePath, + CubicBezier, + CubicBezierPath, + PlaceLabel, + Unknown +}; enum class SplinePointPosition : char { FirstPoint, LastPoint }; +// Keep synchronized with XSD schema +enum class PlaceLabelType : unsigned char +{ + Segment= 0, + Rectangle = 1, + Cross = 2, + Tshaped = 3, + Doubletree = 4, + Corner = 5, + Triangle = 6, + Hshaped = 7, + Button = 8 +}; + +typedef QVector PlaceLabelImg; + +struct VLayoutPlaceLabel +{ + VLayoutPlaceLabel() + : center(), + type(PlaceLabelType::Button), + shape() + {} + + QPointF center; + PlaceLabelType type; + PlaceLabelImg shape; +}; + #endif // VGEOMETRYDEF_H diff --git a/src/libs/vgeometry/vplacelabelitem.cpp b/src/libs/vgeometry/vplacelabelitem.cpp new file mode 100644 index 000000000..3ced29e35 --- /dev/null +++ b/src/libs/vgeometry/vplacelabelitem.cpp @@ -0,0 +1,334 @@ +/************************************************************************ + ** + ** @file vplacelabelitem.cpp + ** @author Roman Telezhynskyi + ** @date 15 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 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 "vplacelabelitem.h" +#include "vplacelabelitem_p.h" +#include "../vpatterndb/vcontainer.h" +#include "vellipticalarc.h" + +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +VPlaceLabelItem::VPlaceLabelItem() + : VPointF(), d(new VPlaceLabelItemData) +{ + setType(GOType::PlaceLabel); + setMode(Draw::Modeling); +} + +//--------------------------------------------------------------------------------------------------------------------- +VPlaceLabelItem::VPlaceLabelItem(const VPlaceLabelItem &item) + : VPointF(item), d(item.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VPlaceLabelItem::~VPlaceLabelItem() +{} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPlaceLabelItem::GetWidthFormula() const +{ + return d->width; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString &VPlaceLabelItem::GetWidthFormula() +{ + return d->width; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VPlaceLabelItem::GetWidth() const +{ + return d->wValue; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPlaceLabelItem::SetWidth(qreal value, const QString &formula) +{ + d->wValue = value; + d->width = formula; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPlaceLabelItem::GetHeightFormula() const +{ + return d->height; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString &VPlaceLabelItem::GetHeightFormula() +{ + return d->height; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VPlaceLabelItem::GetHeight() const +{ + return d->hValue; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPlaceLabelItem::SetHeight(qreal value, const QString &formula) +{ + d->hValue = value; + d->height = formula; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPlaceLabelItem::GetAngleFormula() const +{ + return d->angle; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString &VPlaceLabelItem::GetAngleFormula() +{ + return d->angle; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VPlaceLabelItem::GetAngle() const +{ + return d->aValue; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPlaceLabelItem::SetAngle(qreal value, const QString &formula) +{ + d->aValue = value; + d->angle = formula; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VPlaceLabelItem::GetCorrectionAngle() const +{ + return d->correctionAngle; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPlaceLabelItem::SetCorrectionAngle(qreal value) +{ + d->correctionAngle = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VPlaceLabelItem::GetCenterPoint() const +{ + return d->centerPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPlaceLabelItem::SetCenterPoint(quint32 id) +{ + d->centerPoint = id; +} + +//--------------------------------------------------------------------------------------------------------------------- +PlaceLabelType VPlaceLabelItem::GetLabelType() const +{ + return d->type; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPlaceLabelItem::SetLabelType(PlaceLabelType type) +{ + d->type = type; +} + +//--------------------------------------------------------------------------------------------------------------------- +VPlaceLabelItem &VPlaceLabelItem::operator=(const VPlaceLabelItem &item) +{ + if ( &item == this ) + { + return *this; + } + VPointF::operator=(item); + d = item.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +PlaceLabelImg VPlaceLabelItem::LabelShape(const VContainer *data) const +{ + const auto center = data->GeometricObject(d->centerPoint); + + QTransform t; + t.translate(center->x(), center->y()); + t.rotate(-d->aValue+d->correctionAngle); + t.translate(-center->x(), -center->y()); + + auto SegmentShape = [center, t, this]() + { + QPolygonF shape; + shape << QPointF(center->x(), center->y() - d->hValue/2.0) << QPointF(center->x(), center->y() + d->hValue/2.0); + + return PlaceLabelImg({t.map(shape)}); + }; + + auto RectangleShape = [center, t, this]() + { + QRectF rect(QPointF(center->x() - d->wValue/2.0, center->y() - d->hValue/2.0), + QPointF(center->x() + d->wValue/2.0, center->y() + d->hValue/2.0)); + + QPolygonF shape; + shape << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft(); + + return PlaceLabelImg({t.map(shape)}); + }; + + auto CrossShape = [center, t, this]() + { + QPolygonF shape1; + shape1 << QPointF(center->x(), center->y() - d->hValue/2.0) + << QPointF(center->x(), center->y() + d->hValue/2.0); + + QPolygonF shape2; + shape2 << QPointF(center->x() - d->wValue/2.0, center->y()) + << QPointF(center->x() + d->wValue/2.0, center->y()); + + return PlaceLabelImg({t.map(shape1), t.map(shape2)}); + }; + + auto TshapedShape = [center, t, this]() + { + QPointF center2(center->x(), center->y() + d->hValue/2.0); + + QPolygonF shape1; + shape1 << QPointF(center->x(), center->y()) << center2; + + QPolygonF shape2; + shape2 << QPointF(center2.x() - d->wValue/2.0, center2.y()) + << QPointF(center2.x() + d->wValue/2.0, center2.y()); + + return PlaceLabelImg({t.map(shape1), t.map(shape2)}); + }; + + auto DoubletreeShape = [center, t, this]() + { + QRectF rect(QPointF(center->x() - d->wValue/2.0, center->y() - d->hValue/2.0), + QPointF(center->x() + d->wValue/2.0, center->y() + d->hValue/2.0)); + + QPolygonF shape1; + shape1 << rect.topLeft() << rect.bottomRight(); + + QPolygonF shape2; + shape2 << rect.topRight() << rect.bottomLeft(); + + return PlaceLabelImg({t.map(shape1), t.map(shape2)}); + }; + + auto CornerShape = [center, t, this]() + { + QPolygonF shape1; + shape1 << QPointF(center->x(), center->y()) << QPointF(center->x(), center->y() + d->hValue/2.0); + + QPolygonF shape2; + shape2 << QPointF(center->x() - d->wValue/2.0, center->y()) << QPointF(center->x(), center->y()); + + return PlaceLabelImg({t.map(shape1), t.map(shape2)}); + }; + + auto TriangleShape = [center, t, this]() + { + QRectF rect(QPointF(center->x() - d->wValue/2.0, center->y() - d->hValue/2.0), + QPointF(center->x() + d->wValue/2.0, center->y() + d->hValue/2.0)); + + QPolygonF shape; + shape << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.topLeft(); + + return PlaceLabelImg({t.map(shape)}); + }; + + auto HshapedShape = [center, t, this]() + { + const QPointF center1 (center->x(), center->y() - d->hValue/2.0); + const QPointF center2 (center->x(), center->y() + d->hValue/2.0); + + QPolygonF shape1; + shape1 << center1 << center2; + + QPolygonF shape2; + shape2 << QPointF(center1.x() - d->wValue/2.0, center1.y()) + << QPointF(center1.x() + d->wValue/2.0, center1.y()); + + QPolygonF shape3; + shape3 << QPointF(center2.x() - d->wValue/2.0, center2.y()) + << QPointF(center2.x() + d->wValue/2.0, center2.y()); + + return PlaceLabelImg({t.map(shape1), t.map(shape2), t.map(shape3)}); + }; + + auto ButtonShape = [center, t, this]() + { + QPolygonF shape1; + shape1 << QPointF(center->x(), center->y() - d->hValue/2.0) + << QPointF(center->x(), center->y() + d->hValue/2.0); + + QPolygonF shape2; + shape2 << QPointF(center->x() - d->wValue/2.0, center->y()) + << QPointF(center->x() + d->wValue/2.0, center->y()); + + const qreal circleSize = 0.85; + VEllipticalArc elArc(*center, d->wValue/2.0*circleSize, d->hValue/2.0*circleSize, 0, 360, 0); + QPolygonF shape3(elArc.GetPoints()); + if (not shape3.isClosed() && not shape3.isEmpty()) + { + shape3 << shape3.first(); + } + + return PlaceLabelImg({t.map(shape1), t.map(shape2), t.map(shape3)}); + }; + +QT_WARNING_PUSH +QT_WARNING_DISABLE_GCC("-Wswitch-default") + switch(d->type) + { + case PlaceLabelType::Segment: + return SegmentShape(); + case PlaceLabelType::Rectangle: + return RectangleShape(); + case PlaceLabelType::Cross: + return CrossShape(); + case PlaceLabelType::Tshaped: + return TshapedShape(); + case PlaceLabelType::Doubletree: + return DoubletreeShape(); + case PlaceLabelType::Corner: + return CornerShape(); + case PlaceLabelType::Triangle: + return TriangleShape(); + case PlaceLabelType::Hshaped: + return HshapedShape(); + case PlaceLabelType::Button: + return ButtonShape(); + } + QT_WARNING_POP + + return PlaceLabelImg(); +} diff --git a/src/libs/vgeometry/vplacelabelitem.h b/src/libs/vgeometry/vplacelabelitem.h new file mode 100644 index 000000000..7dd004f79 --- /dev/null +++ b/src/libs/vgeometry/vplacelabelitem.h @@ -0,0 +1,89 @@ +/************************************************************************ + ** + ** @file vplacelabelitem.h + ** @author Roman Telezhynskyi + ** @date 15 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 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 VPLACELABELITEM_H +#define VPLACELABELITEM_H + +#include +#include +#include +#include + +#include "vpointf.h" + +class VPlaceLabelItemData; +class VContainer; + +class VPlaceLabelItem : public VPointF +{ +public: + VPlaceLabelItem(); + VPlaceLabelItem(const VPlaceLabelItem &item); + virtual ~VPlaceLabelItem() Q_DECL_OVERRIDE; + + VPlaceLabelItem &operator=(const VPlaceLabelItem &item); +#ifdef Q_COMPILER_RVALUE_REFS + VPlaceLabelItem &operator=(VPlaceLabelItem &&item) Q_DECL_NOTHROW { Swap(item); return *this; } +#endif + + void Swap(VPlaceLabelItem &item) Q_DECL_NOTHROW + { VPointF::Swap(item); std::swap(d, item.d); } + + QString GetWidthFormula() const; + QString& GetWidthFormula(); + qreal GetWidth() const; + void SetWidth(qreal value, const QString &formula); + + QString GetHeightFormula() const; + QString& GetHeightFormula(); + qreal GetHeight() const; + void SetHeight(qreal value, const QString &formula); + + QString GetAngleFormula() const; + QString& GetAngleFormula(); + qreal GetAngle() const; + void SetAngle(qreal value, const QString &formula); + + qreal GetCorrectionAngle() const; + void SetCorrectionAngle(qreal value); + + quint32 GetCenterPoint() const; + void SetCenterPoint(quint32 id); + + PlaceLabelType GetLabelType() const; + void SetLabelType(PlaceLabelType type); + + PlaceLabelImg LabelShape(const VContainer *data) const; + +private: + QSharedDataPointer d; +}; + +Q_DECLARE_METATYPE(VPlaceLabelItem) +Q_DECLARE_TYPEINFO(VPlaceLabelItem, Q_MOVABLE_TYPE); + +#endif // VPLACELABELITEM_H diff --git a/src/libs/vgeometry/vplacelabelitem_p.h b/src/libs/vgeometry/vplacelabelitem_p.h new file mode 100644 index 000000000..61dd9db1e --- /dev/null +++ b/src/libs/vgeometry/vplacelabelitem_p.h @@ -0,0 +1,90 @@ +/************************************************************************ + ** + ** @file vplacelabelitem_p.h + ** @author Roman Telezhynskyi + ** @date 15 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 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 VPLACELABELITEM_P_H +#define VPLACELABELITEM_P_H + +#include +#include "vgeometrydef.h" +#include "../ifc/ifcdef.h" +#include "../vmisc/diagnostic.h" + +QT_WARNING_PUSH +QT_WARNING_DISABLE_GCC("-Weffc++") +QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") + +class VPlaceLabelItemData : public QSharedData +{ +public: + VPlaceLabelItemData() + : width(), + height(), + angle("0"), + type(PlaceLabelType::Button), + centerPoint(0), + wValue(0), + hValue(0), + aValue(0), + correctionAngle(0) + {} + + VPlaceLabelItemData(const VPlaceLabelItemData &item) + : QSharedData(item), + width(item.width), + height(item.height), + angle(item.angle), + type(item.type), + centerPoint(item.centerPoint), + wValue(item.wValue), + hValue(item.hValue), + aValue(item.aValue), + correctionAngle(item.correctionAngle) + {} + + virtual ~VPlaceLabelItemData(); + + QString width; + QString height; + QString angle; + PlaceLabelType type; + quint32 centerPoint; + + qreal wValue; + qreal hValue; + qreal aValue; + qreal correctionAngle; + +private: + VPlaceLabelItemData &operator=(const VPlaceLabelItemData &) Q_DECL_EQ_DELETE; +}; + +VPlaceLabelItemData::~VPlaceLabelItemData() +{} + +QT_WARNING_POP + +#endif // VPLACELABELITEM_P_H diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index edec107dc..1c4ff66c4 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -991,6 +991,21 @@ bool VAbstractPiece::IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &pr && qAbs(prevPoint.GetSAAfter(tmpWidth) - nextPoint.GetSABefore(tmpWidth)) < VGObject::accuracyPointOnLine); } +//--------------------------------------------------------------------------------------------------------------------- +QPainterPath VAbstractPiece::PlaceLabelImgPath(const PlaceLabelImg &img) const +{ + QPainterPath path; + foreach(const QPolygonF &p, img) + { + if (not p.isEmpty()) + { + path.moveTo(p.first()); + path.addPolygon(p); + } + } + return path; +} + //--------------------------------------------------------------------------------------------------------------------- qreal VAbstractPiece::GetMx() const { diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 8e01030e1..fff7e847b 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -41,6 +41,7 @@ template class QVector; class VAbstractPieceData; +class QPainterPath; QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") @@ -194,6 +195,8 @@ protected: static bool IsEkvPointOnLine(const QPointF &iPoint, const QPointF &prevPoint, const QPointF &nextPoint); static bool IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &prevPoint, const VSAPoint &nextPoint); + QPainterPath PlaceLabelImgPath(const PlaceLabelImg &img) const; + private: QSharedDataPointer d; diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index eb86039c0..4f9360c90 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -49,6 +49,7 @@ #include "../vmisc/vabstractapplication.h" #include "../vpatterndb/calculator.h" #include "../vgeometry/vpointf.h" +#include "../vgeometry/vplacelabelitem.h" #include "vlayoutdef.h" #include "vlayoutpiece_p.h" #include "vtextmanager.h" @@ -340,6 +341,22 @@ QStringList PieceLabelText(const QVector &labelShape, const VTextManage } return text; } + +//--------------------------------------------------------------------------------------------------------------------- +QVector ConvertPlaceLabels(const VPiece &piece, const VContainer *pattern) +{ + QVector labels; + for(int i=0; i < piece.GetPlaceLabels().size(); ++i) + { + const auto label = pattern->GeometricObject(piece.GetPlaceLabels().at(i)); + VLayoutPlaceLabel layoutLabel; + layoutLabel.shape = label->LabelShape(pattern); + layoutLabel.center = pattern->GeometricObject(label->GetCenterPoint())->toQPointF(); + layoutLabel.type = label->GetLabelType(); + labels.append(layoutLabel); + } + return labels; +} } //--------------------------------------------------------------------------------------------------------------------- @@ -381,6 +398,7 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern piece.IsSeamAllowanceBuiltIn()); det.SetInternalPaths(ConvertInternalPaths(piece, pattern)); det.SetPassmarks(piece.PassmarksLines(pattern)); + det.SetPlaceLabels(ConvertPlaceLabels(piece, pattern)); det.SetName(piece.GetName()); @@ -415,6 +433,48 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern return det; } +//--------------------------------------------------------------------------------------------------------------------- +template +QVector VLayoutPiece::Map(const QVector &points) const +{ + QVector p; + for (int i = 0; i < points.size(); ++i) + { + p.append(d->matrix.map(points.at(i))); + } + + if (d->mirror) + { + QList list = p.toList(); + for (int k=0, s=list.size(), max=(s/2); k +QVector VLayoutPiece::Map(const QVector &points) const +{ + QVector p; + foreach (const VLayoutPlaceLabel &label, points) + { + VLayoutPlaceLabel mappedLabel; + mappedLabel.type = label.type; + mappedLabel.center = d->matrix.map(label.center); + foreach (const QPolygonF &p, label.shape) + { + mappedLabel.shape.append(d->matrix.map(p)); + } + p.append(mappedLabel); + } + + return p; +} + //--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction QVector VLayoutPiece::GetContourPoints() const @@ -853,6 +913,18 @@ void VLayoutPiece::SetPassmarks(const QVector &passmarks) } } +//--------------------------------------------------------------------------------------------------------------------- +QVector VLayoutPiece::GetPlaceLabels() const +{ + return Map(d->m_placeLabels); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutPiece::SetPlaceLabels(const QVector &labels) +{ + d->m_placeLabels = labels; +} + //--------------------------------------------------------------------------------------------------------------------- QVector > VLayoutPiece::InternalPathsForCut(bool cut) const { @@ -881,28 +953,6 @@ void VLayoutPiece::SetInternalPaths(const QVector &internalPat d->m_internalPaths = internalPaths; } -//--------------------------------------------------------------------------------------------------------------------- -template -QVector VLayoutPiece::Map(const QVector &points) const -{ - QVector p; - for (int i = 0; i < points.size(); ++i) - { - p.append(d->matrix.map(points.at(i))); - } - - if (d->mirror) - { - QList list = p.toList(); - for (int k=0, s=list.size(), max=(s/2); ksetPath(d->matrix.map(d->m_internalPaths.at(i).GetPainterPath())); - - QPen pen = item->pen(); - pen.setStyle(d->m_internalPaths.at(i).PenStyle()); - item->setPen(pen); -} - //--------------------------------------------------------------------------------------------------------------------- QPainterPath VLayoutPiece::LayoutAllowancePath() const { @@ -996,7 +1034,18 @@ QGraphicsItem *VLayoutPiece::GetItem(bool textAsPaths) const for (int i = 0; i < d->m_internalPaths.count(); ++i) { - CreateInternalPathItem(i, item); + QGraphicsPathItem* pathItem = new QGraphicsPathItem(item); + pathItem->setPath(d->matrix.map(d->m_internalPaths.at(i).GetPainterPath())); + + QPen pen = pathItem->pen(); + pen.setStyle(d->m_internalPaths.at(i).PenStyle()); + pathItem->setPen(pen); + } + + for (int i = 0; i < d->m_placeLabels.count(); ++i) + { + QGraphicsPathItem* pathItem = new QGraphicsPathItem(item); + pathItem->setPath(d->matrix.map(PlaceLabelImgPath(d->m_placeLabels.at(i).shape))); } CreateLabelStrings(item, d->detailLabel, d->m_tmDetail, textAsPaths); diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index 8e2c55665..bf88b905a 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -46,6 +46,7 @@ #include "../vpatterndb/floatItemData/vpiecelabeldata.h" #include "../vpatterndb/vcontainer.h" #include "vabstractpiece.h" +#include "../vgeometry/vgeometrydef.h" class VLayoutPieceData; class VLayoutPiecePath; @@ -85,6 +86,9 @@ public: QVector GetPassmarks() const; void SetPassmarks(const QVector &passmarks); + QVector GetPlaceLabels() const; + void SetPlaceLabels(const QVector &labels); + QVector> InternalPathsForCut(bool cut) const; QVector GetInternalPaths() const; void SetInternalPaths(const QVector &internalPaths); @@ -142,7 +146,6 @@ private: Q_REQUIRED_RESULT QGraphicsPathItem *GetMainItem() const; Q_REQUIRED_RESULT QGraphicsPathItem *GetMainPathItem() const; - void CreateInternalPathItem(int i, QGraphicsItem *parent) const; void CreateLabelStrings(QGraphicsItem *parent, const QVector &labelShape, const VTextManager &tm, bool textAsPaths) const; void CreateGrainlineItem(QGraphicsItem *parent) const; diff --git a/src/libs/vlayout/vlayoutpiece_p.h b/src/libs/vlayout/vlayoutpiece_p.h index 963cc54cb..1ebdaaec9 100644 --- a/src/libs/vlayout/vlayoutpiece_p.h +++ b/src/libs/vlayout/vlayoutpiece_p.h @@ -39,7 +39,7 @@ #include "../vpatterndb/floatItemData/vgrainlinedata.h" #include "../vmisc/diagnostic.h" #include "vlayoutpiecepath.h" - +#include "../vgeometry/vgeometrydef.h" #include "vtextmanager.h" QT_WARNING_PUSH @@ -62,7 +62,8 @@ public: patternInfo(), grainlinePoints(), m_tmDetail(), - m_tmPattern() + m_tmPattern(), + m_placeLabels() {} VLayoutPieceData(const VLayoutPieceData &detail) @@ -79,7 +80,8 @@ public: patternInfo(detail.patternInfo), grainlinePoints(detail.grainlinePoints), m_tmDetail(detail.m_tmDetail), - m_tmPattern(detail.m_tmPattern) + m_tmPattern(detail.m_tmPattern), + m_placeLabels(detail.m_placeLabels) {} ~VLayoutPieceData() {} @@ -122,6 +124,9 @@ public: /** @brief m_tmPattern text manager for laying out pattern info */ VTextManager m_tmPattern; + /** @brief m_placeLabels list of place labels. */ + QVector m_placeLabels; + private: VLayoutPieceData &operator=(const VLayoutPieceData &) Q_DECL_EQ_DELETE; }; diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 3e67e04f7..6ef4ff1d3 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -170,6 +170,7 @@ enum class Tool : ToolVisHolderType EllipticalArc, Pin, InsertNode, + PlaceLabel, LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used }; @@ -219,8 +220,9 @@ enum class Vis : ToolVisHolderType ToolEllipticalArc, ToolPiece, ToolPiecePath, - ToolPin, - PiecePins, + ToolSpecialPoint, + ToolPlaceLabel, + PieceSpecialPoints, NoBrush, CurvePathItem, GrainlineItem, @@ -478,7 +480,6 @@ struct CustomSARecord Q_DECLARE_METATYPE(CustomSARecord) Q_DECLARE_TYPEINFO(CustomSARecord, Q_MOVABLE_TYPE); - /**************************************************************************** ** This file is derived from code bearing the following notice: ** The sole author of this file, Adam Higerd, has explicitly disclaimed all diff --git a/src/libs/vmisc/share/resources/icon.qrc b/src/libs/vmisc/share/resources/icon.qrc index 0f67bcfa5..eb7a14625 100644 --- a/src/libs/vmisc/share/resources/icon.qrc +++ b/src/libs/vmisc/share/resources/icon.qrc @@ -75,5 +75,7 @@ icon/32x32/pins@2x.png icon/32x32/passmark.png icon/32x32/passmark@2x.png + icon/32x32/button.png + icon/32x32/button@2x.png diff --git a/src/libs/vmisc/share/resources/icon/32x32/button.png b/src/libs/vmisc/share/resources/icon/32x32/button.png new file mode 100644 index 0000000000000000000000000000000000000000..b87cf72705d78c7615f8e2bb8cedf366e5864d54 GIT binary patch literal 2568 zcmV+j3itJiP)VGd000McNliru;R+B8F#)qB=?Ad(8Y~@H z3y~Ix+zGYrCq(Ym?6?2y+W>|Ae@yrI*Dfnx-V?xAA8i8;61h8Z4k8DUg0)~-{|+tc z9E5AW>>JMmRUVlB-xWu-}h!Z{^ilZ<&WG$*NX?=4Pfcv zLu~l{FHm{%n{%>#sE;5Jotek|@HmJdS9Ugq2M$8piiP#1R-5|`3*9MXumb{%d*v*p zpB0F=B{ZE*oXGy$U+=oK1-^0UIk|4vt%M;ueGWVR8q%FcZrBL66V$XCK-P!`{Kd7F91+^@-WnE`{bIdpC_Gy#XQjyFCpD&%*|WT zdWbkM0vcFcJ!(a}eMeR}#DRnk+X$QI^$59nE0Xl79XUZhU!td@ojCG-RNm+~`uMs9 zDo;PXAUogJOHe2J`Vj!UeM3!!jflCUQ>@OGh^1omT-{H$uLBKTOR-X%DUd&x$A*?n zCPn|o?&f*u@b(QsvCh(w9IH0sijJj9+l)DzIKpO$N`9w(DQU-&Wh$Ryq; zc0k-iTtAu=1XU>(IXdCpCq#dzyk9rJy*ZyUfiERu;~K6Vw+ zk+(QAb&mE#g05I{M4fxZWPbbe;Cpw|)df+2ec?@Hs1wpL01CNt*hXZ5tA=x9@!{N< z7~ed+I5mgy1mhbPPcL9R^UK4zF&WN{32;{<3|XmE0Y&pQbf%0yJV4s>DK_eOMt-m3 z`Zu|E&X$DSX~jeR)^q9u$VA~Y6P z@9X=g+w#+s-}&0~}Emj?yzWb~9X<%Omes|l>+e^p$ z_Y;KCYuQX{oh0X0p%IZ7>cJq?qA0mC{J8;RtBnsg0VsN=i1enx>iHLwJsEDi@7Db- zs(lbZtuwt3+%n3CuVC@>gV2}EYRur$-nDNA|G=)fafY@H{F-OH^-MRQg&NYIA#ObC zE+Rxf>)X{}FqViztqPS8>C3b@eVyOExc`SMUw!1`^+%3=*Z<(wSN#tS-lUC)RTrv`_DmP?#R!+1^fd0>i^!!5Z|ERq@IvTu9JH$mh;+a(sgMiD@dg_5rZ4^fQ8bt!Y}T_#<2J zetkD{)AO9nO;avcF4XUUjs&a(1Zwd`2-Jn9wy-iMVE}#{8OWjw)uzz3urJk^JvxP# z@Mq(DHa?Yje=iupJGF}5{~tupPhrw=G;(abV=o);*!w@8XE<|q5vT94geuaVg1J@d z){^vmN?~KcEKR&UZK{=KA94L=DAv!{d=N^fm+<2LvEkg0V*XCMoP`tRoMfUy{p0mLBt{lGW=6F}?M>tRcvl{)WF(3G3Ec-!;wT}*| zs#@nB^nI^oenqbDgV_q@^6Gh`_{e{o(No_)R6H?<6bjJMi5cC3PAx+t0-$@>X3~A_ z^_7PnW82Q#zrJnf?VkqNblnx|tiwf?EB6d-zrf$8XK70(8`(@65Tql440hlqW?2mb zd}9dJF>-wTIRQAf?UVnw>x&=xxIcOmfWPgKt^a7RvoO^&s z?`)RhR!O${n1<0`QMGyCSBTvAG;}cn+pLBw4f6k-qY?%rV=)%%)xR4(K7OZ6>^=a( zuFTf%+~8fmgl-x@U!TPOAcyp(F(X^hMz~)0*OZ2rX-J}0n^upI(alI(oZ53IDJ+$6 z0v4rVqYYMF-aEXQNC%gOSOxRt?dUdnd;~0WjemxTi3syPb76sOnXs^fWEOf{1xbJb6PzULTo!_HZ-1 e4!qa!&Hn+6N-6D*6Yi`40000VGd000McNliru;R+B8Fe(OuEBF8a7>h|n zK~#9!&6|0YT-AN&Kli@cyQ+GV)Y=yW0!e__N+28TfHTL-;B|~dJfp<+*u;V0!EuZ+ za~zu-V~our7GcNOMi&8{jK-=`#r@;KC*xHRg!;wz5V?8uY{GamLjqg!vz>Q4Xq>9J{MtU)_7vWhk=6QSueBT^y|NEN_z~qN+r0u~kpValLlXau~O}7*O!l!E> z+n;-$Rv3FYykXef_uh(rY0~7D=}91n!w`E0e~k^ z^&z09z%YUs`QNRN-u7jH$#;E(`yH(UX~X zT(|b-1CYOaJMm9mLw?&mAH{LLtyV0x!W&}&Fg}tgAP0tO+O9y*v3CtR&=N!?!d4hx z>~+4(4vf?N-3a0vFrZ=qh=(8+grK%A63{SGM2=*k$y)LcUjXOKN(kgM2x zI|_a7BGl3(u?0zj(GUQIY>{HF1PZj)Pi8K?wiBRm*`J=61&rQ)pN@nnsujz^B;qxb zH{koo=s4zIdyw%GI2xsaGv=Y%qsP?h8@7O&J4|;UwKxGQTCLAJ3OO)=?4KYzoW*sm zCB)(pVvz_Kv%B>d_ndp&7LdL7KFs~wiG<~!NhZUzCL56+t&qtK=BIm*k)p*f^K*Yhhc)87BGNa)69a=!6D2fHp8<*H@6VRC5LwLOt zOpIhO2u6f?Z3zO(sp8A>)+g>Ankj3bDdpXF9|7^hDD{|Hxoj#;DFwcVdEyn!!3l62 z2q>IQOKSm1no(5>6{w{VkGI$Eb^ATRC5JU3X2!r)xI9KwO- zHED%ctTM58kiK8M!oi=VIsC+4CJ&C_m0jzzubY<@ZrNpgV4S|+^wYcNF#QJy$W0XR zeSfz7W-FN8gAH5O8@dRF1BAoDT0vz_miG+k#cqjhonYifP8Z-mh!qjobi z-7PZ(v{o!$JfC<=bjqTXLIw($S4Pom=R->nXX6rD|8F1VQUw$gs#RJeQ5@7?01r)W z`ZL;|`g*ekw0`{K(yF~4{AXRYH4zo<|pY~i1tIw(n-vmH@+cz|t+tmDdHsI7FZvPSF`C9A`rsnif{|7GvH9jLZG&xKAnZZnbLv#RmS1R2dNTs{aNu|5jh#?GI1(X0h z-)DRxJ7XydN_Gd!#rJ+!qc zg25Uz8jcQOULLmfw+Q;Qj@dcc2*tt4x>^4qmG0iGl-dVS%{-+6Qaw8krPAG30e1ov z#|zDFpcRFQJb(-4A{|sessGfI{#Q^`Q|a#efy?dbifq0(JBuqY`^K#mcm{pmB3fHw zNX?xKUbP+og;bI!ps=8mMp1sJczh_)~)5}+j#u2t2-WVMV!y{C}{0w4Ye*>8ShKH6DKEH(we z_yp3Qw+xP>QD-f%Maj&=QFVWO%#mQ@glgtjX9Jt;Km8#$`_u=5$xYwiwSLQOPQdxX ztaKCz90*@`_OrbgUY}5AeUH#flm0(U{$X=s!Hgrs;Ty zmTZW8rGi2+QLWG(jJ&fc256-=6Am|PwvdB;W0r(ShV6EAu3FmBMCQd2-|S2MW=eBP z)Xb{upSBxl(UqJEnG~p`(z1y$d~G8;d!rU8KQ%=?-EFb1+kTkk7tO6a+Z7!jds<0`~R zV?~mGnqb?ep;|zjF6e(f|JlF%dE41bnrevRh9umuVI_*SGaUQgmFu>?+W0HtU_2vQ z>riJ$vf+foLD*;r~O{>PoH|G5S`WKyVk1E*E1b_(AKiMdA)qSho*QV51md5$1btd3$~R>G+hU5BbXpRm`S{7owOjvk`WNT# zeh{VAXRh*)w)0WASkONdBdDjQUdkB@A%LGY5(7K)e_RR=&RD3xHeXg?d7 zA~%ltJR!C)`R?2;+ipmH?mA)}Z?6CJAHe>(t_gkkT*{w33%6^Iz#7uM?yB&W2lxB~ z)enAt>iaL;tCucY@K9T8{PlN?W2M^qf%XWIK%f!dD#jzA^rD}wd2b@1!@+s@5+xLx zy1Gz=e6>~%8yf?T@3ntRK)+?Gc^^btKj_8)VZY1^VjIJqd9%t(`! zwBNZ;>#TQ?#(%sVQRJ??F)YShnd>=xM?4Wr9;;Gp-q%+e{G&>S2+yzprBtLd7?~F^ z6>mA9aGWU%D3_6vXHCdp)8Dbu&g>|(3?+|(BKY35UiI701Ok_=B=F|tb6QS3-ip?W z@$n%DIkbN7FuG`#Jl&G)Qn-)^Kg58xCrxO?zec6cjW7 z0I0e){nY_+-XOiD2;gYECl4WYmzv{<#gcS(Ehh1!Awma=)7)Fx4ci-`*IYAopP)vo zM!LpFK*RxBwYa8hwt4!^!T7hO_XMindJeBzIp!(RP@Ke@*C3kT(V?1XMga`6P>bg$ zY+GuYeK~tV{-BM~$pMTp$Bf+i^mzpT_}s?+ps9~?qE-;l zQ_U9FAYvM6v)-2xp)FusKPU*eE<|h5J`_Sl9DBV2O0MPkk3)FBDI{Axu4hiXGQhrvcQNtmFmADmS90+K;9R+S zT8-r~GI9jp_vVfXMsU{5Bl(dO)m$0R^>M2nV(ju6TUbkes&uT$QTlO*0OK z0elfxdqp=Zz98lD6aeuSXb;=ZTESTH^$0vBUKwO)SFbId>s6zIwi`Fj3ZkCxGP?f& zGFCXIJIvpF4lBR-jz-0(ltM)4?;jzbFTTDpcGeoF8W=BA@x2CcLFG^}9>Am)*Bh*i z7f{t{S`LL#i;`0a4i{eYVScg7(649LJI=C1Ik38wCO%X_aJWkAgGZ>`^=tfR`mMjt z#K1Rny!R|RE?+NZ#_sXxz}V}@yJXltx9CB>LdkWf#M2HX-vb!Xpbq4F$53vyX@5>@ z%%TV|S((NBPA5c$b{=4wixm;BNu|40=Y5xTH|-%5n6V1xZ}v1gKJFtuxDUQ)sqi^0 zVZ}}FP)q*&l0Sy2O_A^Wj8Eo{ogKACB|=tthqL$!JTZ;<5z!6>-}RLuqm`o$XZH<@ z@?FdS*K>a`h&rv)?hCRN%fruQt-hf+n5~=rAh0Uc(|sR+RQx|_GX1@ij9>dWg`?AW zK}TVpAK=wLdVrCKcF&~M5YMpie_nKLD&4&vQA-oxXuG@GGcxCn(D;p;d&ZbEQt9qtfP*~` zoH^sv-u!pcDXI8)ZgWYe98Gy3!{IOe>?S9+Za%OB=&$jK!^W5U0aEE5p95ZcO+v&7 zYD1Ux|EdSs3T4l2jzMBjsFHzEEyAD*=u&q7C^9r{3*XTJEx}r!USal(+VPZGe1NKB z_QPl(n%TK-vqfIX#I)0%5jg9d?|RtL)myJ=({l8o!1+Cx+_YnUAg@uwiwFg z8g8JLEJUyAuw}8-sOOn6z|lnKClKE}fA&icu(4+c`+NSDQ`Y`TKk!}PM=RHEO|4qH zHE)R$*%4`*L5LV3v7mLYai^-JU~*G2nA|iHYTcBpf46hp7Jxn@l1a9-z#QEsy{5A^ zXrVDL43V!?@N2gf5!%C1iZ%d#XNndVxubZbCfwNg6e-f#fjWDk^(O^p@7OH26C*6# zbSi$uYedm#AX;OE_#aBF#t!v7P=~CX=xUp_De7F-=`3EiSh81r;n=RA;+QOdsK?W?F|4@Jv$yVu0JvIbT4EkZ7@^{ zLLrDm(dX8-3ndS;>*%b!9%u=1+Lly<5Lvut3jizDZ8a;_Z8ZSxe|Hps)t9aNNH`vu zBXH|fdsoM`$#337?qhR9BEm!1j z+4jZc=jI+xO5S<{x$AG)9*lvDufeYO~d= z!jd_oMJBVkW<@yxN}h{?zXjOXv%@}i*SgK1)S19b3*K}Jo#!t{oqDR>8yEwF!^qyl z_&+}g4iF09T)Gm1wNaJkHusD8^7k0?OMJ43>A>f0i2QeqtZizIAGewq<^$>g zgdCiUm)SLGg?VNG_wXcRV;MvQzg7b*h$lFZ8AmJi)l|Csv&Whcx!kXK9DejgRHcF( z>Z`TGHEQ(=)arKI7&Qi}27lL4PO$BN630Y9MFKb%E^Z86O3x^Me}>8NY?EeV;V}LA zELy2yeDB6N=L4QycLk|*_n6Y^Z}Nx7$sZbr@kyxrQ80j7)P+88p&f@2An)S;`Uq6~ zlQ?&NJi-gaLv}hOWCtjvFN^7&AeSjLDaBD5$I-aP2l#60l}G$zj>zm>w;2U3D3#X% zhtofHv4wi|DpY+c^ym;WJdSy85Sc97u2E3iA*t5zYn%SbZ~@<-y5g{^9pxwpDCAHE z**i{dI77AS*5<0M?-D1bsa~OSwkdlgS9K!86OfEs ziYpO=QUzLrsBi!#%GM7HE{v9}W@5qS8DN=XHh8YzW}RclXw|}mof~cmHgqR155r)N z!nA2osm+eGv_zOFm+C~w7dNK6f3$P`7VaNOAOEE2uJv2~-FW6L^DkII*M+MPQLtz} zDjoyZMUIXllR3z{c2u@dt&Pfxo%c;fQ1PJk(>F3I8@A)N)O(ZlQQ7e_(w9MsRVqWd z#+0ZL!52d)5+dhS$d$?{rM{C&cYpMRM`d@d-vW>Tdc-$NyEd(6-Z{$<&!FaaK+<-S zWq1M^%QjlmGElGpXk8nfwH;eKEFG9OEIkJRMr=9@2P~)87?xIzHk};GLbeRPP(Ct= z@0o_#8xew$AX&dcwopbXUIZ=>a5tvA-`K41&h=Zm6g(}yS<$w35lb&S15@#ka2UOy z&6dTPJZ2zcZPqoAtJo>hs<9e#)KnXN=6eE4&3=cV-iy%M#*>m~@0YKFCrH)9?a$)- zel6e`j1j`EF-CG(3gs$F@g(qvsdRVw_{j1(j@@U!pOPCUh%6AzF7eIs*uqwpy?s48 z=-4W(J%MTof$L%hvi9A8dZ}CXk!;xlQIo47oO+EHChDuI_{d}hTyJV>$OvBFB&O=& zBbKOgK*z!yofyaU4GLcL;X((>sbgsVxGmuM4Ikv(7anHU`YmzbQG`pKNPxv}J)QWH zcEq(KaVl)Pux7jnWq0Zwfck4P{*0*Jh<3`l%#7D-r2cBn%=d~sgS&qm5rYSW+GFIZ zWkx2lbzcD8B7iJobocS#T=En&xPB2u+F*G)bh*W{kr_$XY zMI85dYpN5j-(Fbv0V*oENx>6F%eDAqw0jzA?kkA7by0U5uvtar0$#z?pLx@(p+OltODwrCecT zaGbq+dYPQaAtD*z##Fj{NvdZ@->w=R_r^MgCwS~!znP8c9XzvsbE}~K1$b+n8;G>E zF#pUY#JiHsR&b&gP^$^Dqgh6ej^S4Q=~Vawz{gYR?&{8USFo|?q2ID)`UZ{{&wMv$ zzx;zbAZr!sL%=l%?Zz0KphLJdMmQcOoQx4}2@#Bh2!w(-0XxB24|rb1!z;VEr7D$t znR1~_wOFN6svt({7IhHVj<6%u(|!2l_KbhaqizwkBI<3xXMyv979cFOlD5GHNxkDc zHAru@TdNoB%1S^U_%{)5-q_RqvL$e~km~8?KNSG=4qO17 z37iTn0pRV( pointer(obj); + return AddGObject(pointer); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VContainer::AddGObject(const QSharedPointer &obj) +{ + SCASSERT(not obj.isNull()) uniqueNames.insert(obj->name()); - return AddObject(d->gObjects, pointer); + return AddObject(d->gObjects, obj); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vcontainer.h b/src/libs/vpatterndb/vcontainer.h index 1e6f1f345..0d6850d02 100644 --- a/src/libs/vpatterndb/vcontainer.h +++ b/src/libs/vpatterndb/vcontainer.h @@ -143,6 +143,7 @@ public: static void UpdateId(quint32 newId); quint32 AddGObject(VGObject *obj); + quint32 AddGObject(const QSharedPointer &obj); quint32 AddPiece(const VPiece &detail); quint32 AddPiecePath(const VPiecePath &path); void AddLine(const quint32 &firstPointId, const quint32 &secondPointId); diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index ad750b7a9..db76f5a6a 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -30,6 +30,7 @@ #include "vpiece_p.h" #include "../vgeometry/vpointf.h" #include "../vgeometry/vabstractcurve.h" +#include "../vgeometry/vplacelabelitem.h" #include "vcontainer.h" #include "../vmisc/vabstractapplication.h" @@ -440,6 +441,25 @@ QVector VPiece::PassmarksLines(const VContainer *data, const QVector VPiece::PlaceLabelPoints(const VContainer *data) const +{ + QVector points; + for(int i=0; i < d->m_placeLabels.size(); ++i) + { + try + { + const auto label = data->GeometricObject(d->m_placeLabels.at(i)); + points.append(label->LabelShape(data)); + } + catch (const VExceptionBadId &e) + { // ignore + Q_UNUSED(e) + } + } + return points; +} + //--------------------------------------------------------------------------------------------------------------------- QPainterPath VPiece::MainPathPath(const VContainer *data) const { @@ -513,6 +533,25 @@ QPainterPath VPiece::PassmarksPath(const VContainer *data, const QVector points = PlaceLabelPoints(data); + QPainterPath path; + + if (not points.isEmpty()) + { + for (qint32 i = 0; i < points.count(); ++i) + { + path.addPath(PlaceLabelImgPath(points.at(i))); + } + + path.setFillRule(Qt::WindingFill); + } + + return path; +} + //--------------------------------------------------------------------------------------------------------------------- bool VPiece::IsInLayout() const { @@ -605,6 +644,24 @@ void VPiece::SetPins(const QVector &pins) d->m_pins = pins; } +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiece::GetPlaceLabels() const +{ + return d->m_placeLabels; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector &VPiece::GetPlaceLabels() +{ + return d->m_placeLabels; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPiece::SetPlaceLabels(const QVector &labels) +{ + d->m_placeLabels = labels; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief MissingNodes find missing nodes in detail. When we deleted object in detail and return this detail need @@ -647,6 +704,12 @@ QVector VPiece::MissingPins(const VPiece &det) const return PieceMissingNodes(d->m_pins, det.GetPins()); } +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiece::MissingPlaceLabels(const VPiece &det) const +{ + return PieceMissingNodes(d->m_placeLabels, det.GetPlaceLabels()); +} + //--------------------------------------------------------------------------------------------------------------------- void VPiece::SetPatternPieceData(const VPieceLabelData &data) { diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 899a519a6..07b4f865a 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -33,6 +33,7 @@ #include #include "../vlayout/vabstractpiece.h" +#include "../vgeometry/vgeometrydef.h" class VPieceData; class VPieceNode; @@ -66,17 +67,19 @@ public: VPiecePath &GetPath(); void SetPath(const VPiecePath &path); - QVector MainPathPoints(const VContainer *data) const; - QVector MainPathNodePoints(const VContainer *data, bool showExcluded = false) const; - QVector SeamAllowancePoints(const VContainer *data) const; - QVector PassmarksLines(const VContainer *data, - const QVector &seamAllowance = QVector()) const; + QVector MainPathPoints(const VContainer *data) const; + QVector MainPathNodePoints(const VContainer *data, bool showExcluded = false) const; + QVector SeamAllowancePoints(const VContainer *data) const; + QVector PassmarksLines(const VContainer *data, + const QVector &seamAllowance = QVector()) const; + QVector PlaceLabelPoints(const VContainer *data) const; QPainterPath MainPathPath(const VContainer *data) const; QPainterPath SeamAllowancePath(const VContainer *data) const; QPainterPath SeamAllowancePath(const QVector &points) const; QPainterPath PassmarksPath(const VContainer *data, const QVector &seamAllowance = QVector()) const; + QPainterPath PlaceLabelPath(const VContainer *data) const; bool IsInLayout() const; void SetInLayout(bool inLayout); @@ -99,10 +102,15 @@ public: QVector &GetPins(); void SetPins(const QVector &pins); + QVector GetPlaceLabels() const; + QVector &GetPlaceLabels(); + void SetPlaceLabels(const QVector &labels); + QVector MissingNodes(const VPiece &det) const; QVector MissingCSAPath(const VPiece &det) const; QVector MissingInternalPaths(const VPiece &det) const; QVector MissingPins(const VPiece &det) const; + QVector MissingPlaceLabels(const VPiece &det) const; void SetPatternPieceData(const VPieceLabelData &data); VPieceLabelData& GetPatternPieceData(); @@ -146,6 +154,17 @@ private: const VContainer *data, int passmarkIndex) const; static int IsCSAStart(const QVector &records, quint32 id); + + PlaceLabelImg LabelShape(const VContainer *data) const; + PlaceLabelImg SegmentShape(const VContainer *data) const; + PlaceLabelImg RectangleShape(const VContainer *data) const; + PlaceLabelImg CrossShape(const VContainer *data) const; + PlaceLabelImg TshapedShape(const VContainer *data) const; + PlaceLabelImg DoubletreeShape(const VContainer *data) const; + PlaceLabelImg CornerShape(const VContainer *data) const; + PlaceLabelImg TriangleShape(const VContainer *data) const; + PlaceLabelImg HshapedShape(const VContainer *data) const; + PlaceLabelImg ButtonShape(const VContainer *data) const; }; Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE); diff --git a/src/libs/vpatterndb/vpiece_p.h b/src/libs/vpatterndb/vpiece_p.h index 63a3bf018..a3bf101b6 100644 --- a/src/libs/vpatterndb/vpiece_p.h +++ b/src/libs/vpatterndb/vpiece_p.h @@ -54,6 +54,7 @@ public: m_customSARecords(), m_internalPaths(), m_pins(), + m_placeLabels(), m_ppData(), m_piPatternInfo(), m_glGrainline(), @@ -68,6 +69,7 @@ public: m_customSARecords(detail.m_customSARecords), m_internalPaths(detail.m_internalPaths), m_pins(detail.m_pins), + m_placeLabels(detail.m_placeLabels), m_ppData(detail.m_ppData), m_piPatternInfo(detail.m_piPatternInfo), m_glGrainline(detail.m_glGrainline), @@ -85,6 +87,7 @@ public: QVector m_customSARecords; QVector m_internalPaths; QVector m_pins; + QVector m_placeLabels; /** @brief Pattern piece data */ VPieceLabelData m_ppData; diff --git a/src/libs/vtools/dialogs/dialogs.pri b/src/libs/vtools/dialogs/dialogs.pri index 5d2fad588..f72bb27df 100644 --- a/src/libs/vtools/dialogs/dialogs.pri +++ b/src/libs/vtools/dialogs/dialogs.pri @@ -46,7 +46,8 @@ HEADERS += \ $$PWD/tools/piece/dialogpiecepath.h \ $$PWD/tools/dialogpin.h \ $$PWD/tools/dialoginsertnode.h \ - $$PWD/support/dialogeditlabel.h + $$PWD/support/dialogeditlabel.h \ + $$PWD/tools/dialogplacelabel.h SOURCES += \ $$PWD/tools/dialogalongline.cpp \ @@ -92,7 +93,8 @@ SOURCES += \ $$PWD/tools/piece/dialogpiecepath.cpp \ $$PWD/tools/dialogpin.cpp \ $$PWD/tools/dialoginsertnode.cpp \ - $$PWD/support/dialogeditlabel.cpp + $$PWD/support/dialogeditlabel.cpp \ + $$PWD/tools/dialogplacelabel.cpp FORMS += \ $$PWD/tools/dialogalongline.ui \ @@ -142,4 +144,6 @@ FORMS += \ $$PWD/tools/piece/tabs/tabpins.ui \ $$PWD/tools/dialoginsertnode.ui \ $$PWD/tools/piece/tabs/tabpassmarks.ui \ - $$PWD/support/dialogeditlabel.ui + $$PWD/support/dialogeditlabel.ui \ + $$PWD/tools/dialogplacelabel.ui \ + $$PWD/tools/piece/tabs/tabplacelabels.ui diff --git a/src/libs/vtools/dialogs/tooldialogs.h b/src/libs/vtools/dialogs/tooldialogs.h index d3794bd3a..4510ba950 100644 --- a/src/libs/vtools/dialogs/tooldialogs.h +++ b/src/libs/vtools/dialogs/tooldialogs.h @@ -69,6 +69,7 @@ #include "tools/piece/dialogpiecepath.h" #include "tools/dialogpin.h" #include "tools/dialoginsertnode.h" +#include "tools/dialogplacelabel.h" #include "support/dialogeditwrongformula.h" #include "support/dialogundo.h" diff --git a/src/libs/vtools/dialogs/tools/dialogpin.cpp b/src/libs/vtools/dialogs/tools/dialogpin.cpp index 8183d210b..e789ce607 100644 --- a/src/libs/vtools/dialogs/tools/dialogpin.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpin.cpp @@ -28,9 +28,8 @@ #include "dialogpin.h" #include "ui_dialogpin.h" -#include "visualization/line/vistoolpin.h" +#include "visualization/line/vistoolspecialpoint.h" #include "../../tools/vabstracttool.h" -#include "../../tools/vtoolseamallowance.h" //--------------------------------------------------------------------------------------------------------------------- DialogPin::DialogPin(const VContainer *data, quint32 toolId, QWidget *parent) @@ -52,7 +51,7 @@ DialogPin::DialogPin(const VContainer *data, quint32 toolId, QWidget *parent) CheckPieces(); }); - vis = new VisToolPin(data); + vis = new VisToolSpecialPoint(data); } //--------------------------------------------------------------------------------------------------------------------- @@ -106,7 +105,7 @@ void DialogPin::SetPointId(quint32 id) { setCurrentPointId(ui->comboBoxPoint, id); - VisToolPin *point = qobject_cast(vis); + VisToolSpecialPoint *point = qobject_cast(vis); SCASSERT(point != nullptr) point->setObject1Id(id); @@ -148,16 +147,7 @@ void DialogPin::CheckState() //--------------------------------------------------------------------------------------------------------------------- void DialogPin::ShowVisualization() { - AddVisualization(); - - if (m_showMode) - { - VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(GetPieceId())); - SCASSERT(tool != nullptr); - auto visPoint = qobject_cast(vis); - SCASSERT(visPoint != nullptr); - visPoint->setParentItem(tool); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp b/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp new file mode 100644 index 000000000..faf2bdcde --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp @@ -0,0 +1,469 @@ +/************************************************************************ + ** + ** @file dialogplacelabel.cpp + ** @author Roman Telezhynskyi + ** @date 14 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 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 "dialogplacelabel.h" +#include "ui_dialogplacelabel.h" + +#include "visualization/line/vistoolspecialpoint.h" +#include "../../tools/vabstracttool.h" +#include "../../tools/vtoolseamallowance.h" +#include "../support/dialogeditwrongformula.h" +#include "../vgeometry/vplacelabelitem.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +DialogPlaceLabel::DialogPlaceLabel(const VContainer *data, quint32 toolId, QWidget *parent) + : DialogTool(data, toolId, parent), + ui(new Ui::DialogPlaceLabel), + m_showMode(false), + m_flagPoint(false), + m_flagWidth(false), + m_flagHeight(false), + m_flagAngle(false), + m_formulaBaseHeightWidth(0), + m_formulaBaseHeightHeight(0), + m_formulaBaseHeightAngle(0), + timerAngle(new QTimer(this)), + timerWidth(new QTimer(this)), + timerHeight(new QTimer(this)) +{ + ui->setupUi(this); + InitOkCancel(ui); + + FillComboBoxPoints(ui->comboBoxPoint); + FillPlaceLabelTypes(); + + m_formulaBaseHeightWidth = ui->plainTextEditFormulaWidth->height(); + m_formulaBaseHeightHeight = ui->plainTextEditFormulaHeight->height(); + m_formulaBaseHeightAngle = ui->plainTextEditFormulaAngle->height(); + + ui->plainTextEditFormulaWidth->installEventFilter(this); + ui->plainTextEditFormulaHeight->installEventFilter(this); + ui->plainTextEditFormulaAngle->installEventFilter(this); + + ui->plainTextEditFormulaWidth->setPlainText(QString::number(UnitConvertor(1, Unit::Cm, qApp->patternUnit()))); + ui->plainTextEditFormulaHeight->setPlainText(QString::number(UnitConvertor(1, Unit::Cm, qApp->patternUnit()))); + + flagError = false; + CheckState(); + + connect(ui->toolButtonExprWidth, &QPushButton::clicked, this, &DialogPlaceLabel::FXWidth); + connect(ui->toolButtonExprHeight, &QPushButton::clicked, this, &DialogPlaceLabel::FXHeight); + connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogPlaceLabel::FXAngle); + + connect(ui->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this, &DialogPlaceLabel::FormulaWidthChanged); + connect(ui->plainTextEditFormulaHeight, &QPlainTextEdit::textChanged, this, + &DialogPlaceLabel::FormulaHeightChanged); + connect(ui->plainTextEditFormulaAngle, &QPlainTextEdit::textChanged, this, &DialogPlaceLabel::FormulaAngleChanged); + + connect(ui->pushButtonGrowWidth, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaWidthEdit); + connect(ui->pushButtonGrowHeight, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaHeightEdit); + connect(ui->pushButtonGrowAngle, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaAngleEdit); + + connect(timerWidth, &QTimer::timeout, this, &DialogPlaceLabel::EvalWidth); + connect(timerHeight, &QTimer::timeout, this, &DialogPlaceLabel::EvalHeight); + connect(timerAngle, &QTimer::timeout, this, &DialogPlaceLabel::EvalAngle); + + connect(ui->comboBoxPiece, static_cast(&QComboBox::currentIndexChanged), this, [this]() + { + CheckPieces(); + }); + + vis = new VisToolSpecialPoint(data); + + FormulaWidthChanged(); + FormulaHeightChanged(); + FormulaAngleChanged(); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogPlaceLabel::~DialogPlaceLabel() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::EnbleShowMode(bool disable) +{ + m_showMode = disable; + ui->comboBoxPiece->setDisabled(m_showMode); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogPlaceLabel::GetCenterPoint() const +{ + return getCurrentObjectId(ui->comboBoxPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::SetCenterPoint(quint32 id) +{ + setCurrentPointId(ui->comboBoxPoint, id); + + if (not m_showMode) + { + VisToolSpecialPoint *point = qobject_cast(vis); + SCASSERT(point != nullptr) + point->setObject1Id(id); + } + + CheckPoint(); +} + +//--------------------------------------------------------------------------------------------------------------------- +PlaceLabelType DialogPlaceLabel::GetLabelType() const +{ + return static_cast(ui->comboBoxLabelType->currentData().toInt()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::SetLabelType(PlaceLabelType type) +{ + const qint32 index = ui->comboBoxLabelType->findData(static_cast(type)); + if (index != -1) + { + ui->comboBoxLabelType->setCurrentIndex(index); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogPlaceLabel::GetWidth() const +{ + return qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormulaWidth->toPlainText().replace("\n", " "), + qApp->Settings()->GetOsSeparator()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::SetWidth(const QString &value) +{ + const QString formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formula.length() > 80) + { + this->DeployFormulaWidthEdit(); + } + ui->plainTextEditFormulaWidth->setPlainText(formula); + +// VisToolPlaceLabel *point = qobject_cast(vis); +// SCASSERT(point != nullptr) +// point->setObject1Id(id); + + MoveCursorToEnd(ui->plainTextEditFormulaWidth); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogPlaceLabel::GetHeight() const +{ + return qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormulaHeight->toPlainText().replace("\n", " "), + qApp->Settings()->GetOsSeparator()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::SetHeight(const QString &value) +{ + const QString formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formula.length() > 80) + { + this->DeployFormulaHeightEdit(); + } + ui->plainTextEditFormulaHeight->setPlainText(formula); + +// VisToolPlaceLabel *point = qobject_cast(vis); +// SCASSERT(point != nullptr) +// point->setObject1Id(id); + + MoveCursorToEnd(ui->plainTextEditFormulaHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogPlaceLabel::GetAngle() const +{ + return qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormulaAngle->toPlainText().replace("\n", " "), + qApp->Settings()->GetOsSeparator()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::SetAngle(const QString &value) +{ + const QString formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formula.length() > 80) + { + this->DeployFormulaAngleEdit(); + } + ui->plainTextEditFormulaAngle->setPlainText(formula); + +// VisToolPlaceLabel *point = qobject_cast(vis); +// SCASSERT(point != nullptr) +// point->setObject1Id(id); + + MoveCursorToEnd(ui->plainTextEditFormulaAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogPlaceLabel::GetPieceId() const +{ + return getCurrentObjectId(ui->comboBoxPiece); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::SetPieceId(quint32 id) +{ + if (ui->comboBoxPiece->count() <= 0) + { + ui->comboBoxPiece->addItem(data->GetPiece(id).GetName(), id); + } + else + { + const qint32 index = ui->comboBoxPiece->findData(id); + if (index != -1) + { + ui->comboBoxPiece->setCurrentIndex(index); + } + else + { + ui->comboBoxPiece->setCurrentIndex(0); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::SetPiecesList(const QVector &list) +{ + FillComboBoxPiecesList(ui->comboBoxPiece, list); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::ChosenObject(quint32 id, const SceneObject &type) +{ + if (not prepare) + { + if (type == SceneObject::Point) + { + if (SetObject(id, ui->comboBoxPoint, "")) + { + vis->VisualMode(id); + CheckPoint(); + prepare = true; + this->setModal(true); + this->show(); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::CheckState() +{ + SCASSERT(bOk != nullptr); + bOk->setEnabled(m_flagPoint && flagError && m_flagWidth && m_flagHeight && m_flagAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::ShowVisualization() +{ + if (not m_showMode) + { + AddVisualization(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::closeEvent(QCloseEvent *event) +{ + ui->plainTextEditFormulaWidth->blockSignals(true); + ui->plainTextEditFormulaHeight->blockSignals(true); + ui->plainTextEditFormulaAngle->blockSignals(true); + DialogTool::closeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::DeployFormulaWidthEdit() +{ + DeployFormula(ui->plainTextEditFormulaWidth, ui->pushButtonGrowWidth, m_formulaBaseHeightWidth); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::DeployFormulaHeightEdit() +{ + DeployFormula(ui->plainTextEditFormulaHeight, ui->pushButtonGrowHeight, m_formulaBaseHeightHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::DeployFormulaAngleEdit() +{ + DeployFormula(ui->plainTextEditFormulaAngle, ui->pushButtonGrowAngle, m_formulaBaseHeightAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::FormulaWidthChanged() +{ + labelEditFormula = ui->labelEditFormulaWidth; + labelResultCalculation = ui->labelResultCalculationWidth; + const QString postfix = UnitsToStr(qApp->patternUnit(), true); + ValFormulaChanged(m_flagWidth, ui->plainTextEditFormulaWidth, timerWidth, postfix); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::FormulaHeightChanged() +{ + labelEditFormula = ui->labelEditFormulaHeight; + labelResultCalculation = ui->labelResultCalculationHeight; + const QString postfix = UnitsToStr(qApp->patternUnit(), true); + ValFormulaChanged(m_flagHeight, ui->plainTextEditFormulaHeight, timerHeight, postfix); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::FormulaAngleChanged() +{ + labelEditFormula = ui->labelEditFormulaAngle; + labelResultCalculation = ui->labelResultCalculationAngle; + ValFormulaChanged(m_flagAngle, ui->plainTextEditFormulaAngle, timerAngle, degreeSymbol); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::EvalWidth() +{ + labelEditFormula = ui->labelEditFormulaWidth; + const QString postfix = UnitsToStr(qApp->patternUnit(), true); + Eval(ui->plainTextEditFormulaWidth->toPlainText(), m_flagWidth, ui->labelResultCalculationWidth, postfix, true, + true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::EvalHeight() +{ + labelEditFormula = ui->labelEditFormulaHeight; + const QString postfix = UnitsToStr(qApp->patternUnit(), true); + Eval(ui->plainTextEditFormulaHeight->toPlainText(), m_flagHeight, ui->labelResultCalculationHeight, postfix, true, + true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::EvalAngle() +{ + labelEditFormula = ui->labelEditFormulaAngle; + Eval(ui->plainTextEditFormulaAngle->toPlainText(), m_flagAngle, ui->labelResultCalculationAngle, degreeSymbol, + false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::FXWidth() +{ + QScopedPointer dialog(new DialogEditWrongFormula(data, toolId, this)); + dialog->setWindowTitle(tr("Edit rectangle width")); + dialog->SetFormula(GetWidth()); + dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true)); + if (dialog->exec() == QDialog::Accepted) + { + SetWidth(dialog->GetFormula()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::FXHeight() +{ + QScopedPointer dialog(new DialogEditWrongFormula(data, toolId, this)); + dialog->setWindowTitle(tr("Edit rectangle width")); + dialog->SetFormula(GetHeight()); + dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true)); + if (dialog->exec() == QDialog::Accepted) + { + SetHeight(dialog->GetFormula()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::FXAngle() +{ + QScopedPointer dialog(new DialogEditWrongFormula(data, toolId, this)); + dialog->setWindowTitle(tr("Edit angle")); + dialog->SetFormula(GetAngle()); + dialog->setPostfix(degreeSymbol); + if (dialog->exec() == QDialog::Accepted) + { + SetAngle(dialog->GetFormula()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::FillPlaceLabelTypes() +{ + ui->comboBoxLabelType->addItem(tr("Segment"), static_cast(PlaceLabelType::Segment)); + ui->comboBoxLabelType->addItem(tr("Rectangle"), static_cast(PlaceLabelType::Rectangle)); + ui->comboBoxLabelType->addItem(tr("Cross"), static_cast(PlaceLabelType::Cross)); + ui->comboBoxLabelType->addItem(tr("T-shaped"), static_cast(PlaceLabelType::Tshaped)); + ui->comboBoxLabelType->addItem(tr("Doubletree"), static_cast(PlaceLabelType::Doubletree)); + ui->comboBoxLabelType->addItem(tr("Corner"), static_cast(PlaceLabelType::Corner)); + ui->comboBoxLabelType->addItem(tr("Triangle"), static_cast(PlaceLabelType::Triangle)); + ui->comboBoxLabelType->addItem(tr("H-shaped"), static_cast(PlaceLabelType::Hshaped)); + ui->comboBoxLabelType->addItem(tr("Button"), static_cast(PlaceLabelType::Button)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::CheckPieces() +{ + if (not m_showMode) + { + QColor color = okColor; + if (ui->comboBoxPiece->count() <= 0 || ui->comboBoxPiece->currentIndex() == -1) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelPiece, color); + CheckState(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPlaceLabel::CheckPoint() +{ + QColor color = okColor; + if (ui->comboBoxPoint->currentIndex() != -1) + { + m_flagPoint = true; + color = okColor; + } + else + { + m_flagPoint = false; + color = errorColor; + } + ChangeColor(ui->labelPoint, color); + CheckState(); +} diff --git a/src/libs/vtools/dialogs/tools/dialogplacelabel.h b/src/libs/vtools/dialogs/tools/dialogplacelabel.h new file mode 100644 index 000000000..92e27971c --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialogplacelabel.h @@ -0,0 +1,119 @@ +/************************************************************************ + ** + ** @file dialogplacelabel.h + ** @author Roman Telezhynskyi + ** @date 14 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 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 DIALOGPLACELABEL_H +#define DIALOGPLACELABEL_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogPlaceLabel; +} + +class VPlaceLabelItem; + +class DialogPlaceLabel : public DialogTool +{ + Q_OBJECT + +public: + explicit DialogPlaceLabel(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); + virtual ~DialogPlaceLabel(); + + void EnbleShowMode(bool disable); + + quint32 GetCenterPoint() const; + void SetCenterPoint(quint32 id); + + PlaceLabelType GetLabelType() const; + void SetLabelType(PlaceLabelType type); + + QString GetWidth() const; + void SetWidth(const QString &value); + + QString GetHeight() const; + void SetHeight(const QString &value); + + QString GetAngle() const; + void SetAngle(const QString &value); + + quint32 GetPieceId() const; + void SetPieceId(quint32 id); + + virtual void SetPiecesList(const QVector &list) Q_DECL_OVERRIDE; + +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; + +protected: + virtual void CheckState() Q_DECL_FINAL; + virtual void ShowVisualization() Q_DECL_OVERRIDE; + virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; + +private slots: + void DeployFormulaWidthEdit(); + void DeployFormulaHeightEdit(); + void DeployFormulaAngleEdit(); + + void FormulaWidthChanged(); + void FormulaHeightChanged(); + void FormulaAngleChanged(); + + void EvalWidth(); + void EvalHeight(); + void EvalAngle(); + + void FXWidth(); + void FXHeight(); + void FXAngle(); + +private: + Q_DISABLE_COPY(DialogPlaceLabel) + Ui::DialogPlaceLabel *ui; + bool m_showMode; + bool m_flagPoint; + bool m_flagWidth; + bool m_flagHeight; + bool m_flagAngle; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int m_formulaBaseHeightWidth; + int m_formulaBaseHeightHeight; + int m_formulaBaseHeightAngle; + + QTimer *timerAngle; + QTimer *timerWidth; + QTimer *timerHeight; + + void FillPlaceLabelTypes(); + + void CheckPieces(); + void CheckPoint(); +}; + +#endif // DIALOGPLACELABEL_H diff --git a/src/libs/vtools/dialogs/tools/dialogplacelabel.ui b/src/libs/vtools/dialogs/tools/dialogplacelabel.ui new file mode 100644 index 000000000..fb7bff15c --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialogplacelabel.ui @@ -0,0 +1,655 @@ + + + DialogPlaceLabel + + + + 0 + 0 + 338 + 363 + + + + Dialog + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Width: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Formula wizard + + + ... + + + + :/icon/24x24/fx.png:/icon/24x24/fx.png + + + + 24 + 24 + + + + + + + + + + + :/icon/24x24/equal.png + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + Value + + + + + + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 28 + + + + Calculation + + + true + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + .. + + + + 16 + 16 + + + + true + + + + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Height: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Formula wizard + + + ... + + + + :/icon/24x24/fx.png:/icon/24x24/fx.png + + + + 24 + 24 + + + + + + + + + + + :/icon/24x24/equal.png + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + Value + + + + + + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 28 + + + + Calculation + + + true + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + .. + + + + 16 + 16 + + + + true + + + + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Angle: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Formula wizard + + + ... + + + + :/icon/24x24/fx.png:/icon/24x24/fx.png + + + + 24 + 24 + + + + + + + + + + + :/icon/24x24/equal.png + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + Value + + + + + + _ + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 28 + + + + Calculation + + + true + + + 0 + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + .. + + + + 16 + 16 + + + + true + + + + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Point: + + + + + + + + + + Piece: + + + + + + + + + + Type: + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DialogPlaceLabel + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogPlaceLabel + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index ffae7cb6d..513e6709f 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -111,7 +111,7 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p flagName(true), flagFormula(true), flagError(true), - timerFormula(nullptr), + timerFormula(new QTimer(this)), bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), @@ -129,7 +129,6 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p vis(nullptr) { SCASSERT(data != nullptr) - timerFormula = new QTimer(this); connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula); } diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 4e94a34d6..a1f830b2b 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -33,23 +33,27 @@ #include "ui_tabgrainline.h" #include "ui_tabpins.h" #include "ui_tabpassmarks.h" +#include "ui_tabplacelabels.h" #include "../vwidgets/fancytabbar/fancytabbar.h" #include "../vpatterndb/vpiecenode.h" #include "../vpatterndb/vpiecepath.h" #include "../vpatterndb/calculator.h" #include "visualization/path/vistoolpiece.h" -#include "visualization/path/vispiecepins.h" +#include "visualization/path/vispiecespecialpoints.h" #include "dialogpiecepath.h" +#include "../dialogplacelabel.h" #include "../../../undocommands/savepiecepathoptions.h" +#include "../../../undocommands/saveplacelabeloptions.h" #include "../../support/dialogeditwrongformula.h" #include "../../support/dialogeditlabel.h" #include "../../../tools/vtoolseamallowance.h" +#include "../vgeometry/vplacelabelitem.h" #include #include #include -enum TabOrder {Paths=0, Pins=1, Labels=2, Grainline=3, Passmarks=4, Count=5}; +enum TabOrder {Paths=0, Pins=1, Labels=2, Grainline=3, Passmarks=4, PlaceLabels=5, Count=6}; namespace { @@ -84,11 +88,13 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & uiTabGrainline(new Ui::TabGrainline), uiTabPins(new Ui::TabPins), uiTabPassmarks(new Ui::TabPassmarks), + uiTabPlaceLabels(new Ui::TabPlaceLabels), m_tabPaths(new QWidget), m_tabLabels(new QWidget), m_tabGrainline(new QWidget), m_tabPins(new QWidget), m_tabPassmarks(new QWidget), + m_tabPlaceLabels(new QWidget), m_ftb(new FancyTabBar(FancyTabBar::Left, this)), applyAllowed(false),// By default disabled flagGPin(true), @@ -103,7 +109,7 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & m_mx(0), m_my(0), m_dialog(), - m_visPins(), + m_visSpecialPoints(), m_oldData(), m_oldGeom(), m_oldGrainline(), @@ -138,6 +144,7 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & InitGrainlineTab(); InitPinsTab(); InitPassmarksTab(); + InitPlaceLabelsTab(); flagName = true;//We have default name of piece. ChangeColor(uiTabLabels->labelEditName, okColor); @@ -155,7 +162,8 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & //--------------------------------------------------------------------------------------------------------------------- DialogSeamAllowance::~DialogSeamAllowance() { - delete m_visPins; + delete m_visSpecialPoints; + delete m_tabPlaceLabels; delete m_tabPassmarks; delete m_tabPins; delete m_tabGrainline; @@ -182,6 +190,7 @@ void DialogSeamAllowance::EnableApply(bool enable) m_ftb->SetTabEnabled(TabOrder::Labels, applyAllowed); m_ftb->SetTabEnabled(TabOrder::Grainline, applyAllowed); m_ftb->SetTabEnabled(TabOrder::Passmarks, applyAllowed); + m_ftb->SetTabEnabled(TabOrder::PlaceLabels, applyAllowed); } //--------------------------------------------------------------------------------------------------------------------- @@ -204,24 +213,71 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) uiTabPaths->listWidgetCustomSA->clear(); for (int i = 0; i < piece.GetCustomSARecords().size(); ++i) { - NewCustomSA(piece.GetCustomSARecords().at(i)); + const CustomSARecord &record = piece.GetCustomSARecords().at(i); + if (record.path > NULL_ID) + { + const QString name = GetPathName(record.path, record.reverse); + + QListWidgetItem *item = new QListWidgetItem(name); + item->setFont(QFont("Times", 12, QFont::Bold)); + item->setData(Qt::UserRole, QVariant::fromValue(record)); + uiTabPaths->listWidgetCustomSA->addItem(item); + uiTabPaths->listWidgetCustomSA->setCurrentRow(uiTabPaths->listWidgetCustomSA->count()-1); + } } uiTabPaths->listWidgetCustomSA->blockSignals(false); uiTabPaths->listWidgetInternalPaths->clear(); for (int i = 0; i < piece.GetInternalPaths().size(); ++i) { - NewInternalPath(piece.GetInternalPaths().at(i)); + const quint32 path = piece.GetInternalPaths().at(i); + if (path > NULL_ID) + { + const QString name = GetPathName(path); + + QListWidgetItem *item = new QListWidgetItem(name); + item->setFont(QFont("Times", 12, QFont::Bold)); + item->setData(Qt::UserRole, QVariant::fromValue(path)); + uiTabPaths->listWidgetInternalPaths->addItem(item); + uiTabPaths->listWidgetInternalPaths->setCurrentRow(uiTabPaths->listWidgetInternalPaths->count()-1); + } } + auto NewSpecialPoint = [this](QListWidget *listWidget, quint32 point) + { + if (point > NULL_ID) + { + try + { + const QSharedPointer p = data->GetGObject(point); + + QListWidgetItem *item = new QListWidgetItem(p->name()); + item->setFont(QFont("Times", 12, QFont::Bold)); + item->setData(Qt::UserRole, QVariant::fromValue(point)); + listWidget->addItem(item); + listWidget->setCurrentRow(uiTabPins->listWidgetPins->count()-1); + } + catch (const VExceptionBadId &e) + { + qWarning() << qUtf8Printable(e.ErrorMessage()); + } + } + }; + uiTabPins->listWidgetPins->clear(); for (int i = 0; i < piece.GetPins().size(); ++i) { - NewPin(piece.GetPins().at(i)); + NewSpecialPoint(uiTabPins->listWidgetPins, piece.GetPins().at(i)); } InitAllPinComboboxes(); + uiTabPlaceLabels->listWidgetPlaceLabels->clear(); + for (int i = 0; i < piece.GetPlaceLabels().size(); ++i) + { + NewSpecialPoint(uiTabPlaceLabels->listWidgetPlaceLabels, piece.GetPlaceLabels().at(i)); + } + uiTabPaths->comboBoxStartPoint->blockSignals(true); uiTabPaths->comboBoxStartPoint->clear(); uiTabPaths->comboBoxStartPoint->blockSignals(false); @@ -656,6 +712,116 @@ void DialogSeamAllowance::ShowPinsContextMenu(const QPoint &pos) } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos) +{ + const int row = uiTabPlaceLabels->listWidgetPlaceLabels->currentRow(); + if (uiTabPlaceLabels->listWidgetPlaceLabels->count() == 0 + || row == -1 + || row >= uiTabPlaceLabels->listWidgetPlaceLabels->count()) + { + return; + } + + QListWidgetItem *rowItem = uiTabPlaceLabels->listWidgetPlaceLabels->item(row); + SCASSERT(rowItem != nullptr); + const quint32 labelId = qvariant_cast(rowItem->data(Qt::UserRole)); + const auto label = data->GeometricObject(labelId); + + QScopedPointer menu(new QMenu()); + + auto InitAction = [&menu, label](const QString &text, PlaceLabelType type) + { + QAction *action = menu->addAction(text); + action->setCheckable(true); + action->setChecked(label->GetLabelType() == type); + return action; + }; + + auto SaveType = [this, label, labelId](PlaceLabelType type) + { + VPlaceLabelItem newLabel = VPlaceLabelItem(*label); + newLabel.SetLabelType(type); + + SavePlaceLabelOptions *saveCommand = new SavePlaceLabelOptions(*label, newLabel, qApp->getCurrentDocument(), + const_cast(data), labelId); + qApp->getUndoStack()->push(saveCommand); + UpdateCurrentPlaceLabelRecords(); + }; + + QAction *actionOption = menu->addAction(QIcon::fromTheme("preferences-other"), tr("Options")); + menu->addSeparator(); + QAction *actionSegment = InitAction(tr("Segment"), PlaceLabelType::Segment); + QAction *actionRectangle = InitAction(tr("Rectangle"), PlaceLabelType::Rectangle); + QAction *actionCross = InitAction(tr("Cross"), PlaceLabelType::Cross); + QAction *actionTshaped = InitAction(tr("T-shaped"), PlaceLabelType::Tshaped); + QAction *actionDoubletree = InitAction(tr("Doubletree"), PlaceLabelType::Doubletree); + QAction *actionCorner = InitAction(tr("Corner"), PlaceLabelType::Corner); + QAction *actionTriangle = InitAction(tr("Triangle"), PlaceLabelType::Triangle); + QAction *actionHshaped = InitAction(tr("H-shaped"), PlaceLabelType::Hshaped); + QAction *actionButton = InitAction(tr("Button"), PlaceLabelType::Button); + menu->addSeparator(); + QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); + + QAction *selectedAction = menu->exec(uiTabPlaceLabels->listWidgetPlaceLabels->viewport()->mapToGlobal(pos)); + if (selectedAction == actionDelete) + { + delete uiTabPlaceLabels->listWidgetPlaceLabels->item(row); + FancyTabChanged(m_ftb->CurrentIndex()); + } + else if (selectedAction == actionOption) + { + auto *dialog = new DialogPlaceLabel(data, labelId, this); + dialog->SetCenterPoint(label->GetCenterPoint()); + dialog->SetLabelType(label->GetLabelType()); + dialog->SetWidth(label->GetWidthFormula()); + dialog->SetHeight(label->GetHeightFormula()); + dialog->SetAngle(label->GetAngleFormula()); + dialog->SetPieceId(toolId); + dialog->EnbleShowMode(true); + m_dialog = dialog; + m_dialog->setModal(true); + connect(m_dialog.data(), &DialogTool::DialogClosed, this, &DialogSeamAllowance::PlaceLabelDialogClosed); + m_dialog->show(); + } + else if (selectedAction == actionSegment) + { + SaveType(PlaceLabelType::Segment); + } + else if (selectedAction == actionRectangle) + { + SaveType(PlaceLabelType::Rectangle); + } + else if (selectedAction == actionCross) + { + SaveType(PlaceLabelType::Cross); + } + else if (selectedAction == actionTshaped) + { + SaveType(PlaceLabelType::Tshaped); + } + else if (selectedAction == actionDoubletree) + { + SaveType(PlaceLabelType::Doubletree); + } + else if (selectedAction == actionCorner) + { + SaveType(PlaceLabelType::Corner); + } + else if (selectedAction == actionTriangle) + { + SaveType(PlaceLabelType::Triangle); + } + else if (selectedAction == actionHshaped) + { + SaveType(PlaceLabelType::Hshaped); + } + else if (selectedAction == actionButton) + { + SaveType(PlaceLabelType::Button); + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::ListChanged() { @@ -1028,6 +1194,55 @@ void DialogSeamAllowance::PathDialogClosed(int result) delete m_dialog; } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::PlaceLabelDialogClosed(int result) +{ + if (result == QDialog::Accepted) + { + SCASSERT(not m_dialog.isNull()); + DialogPlaceLabel *dialogTool = qobject_cast(m_dialog.data()); + SCASSERT(dialogTool != nullptr); + try + { + auto oldLabel = data->GeometricObject(dialogTool->GetToolId()); + + auto point = data->GeometricObject(dialogTool->GetCenterPoint()); + + const QHash > *vars = data->DataVariables(); + + const qreal w = qAbs(Visualization::FindLength(dialogTool->GetWidth(), vars)); + const qreal h = qAbs(Visualization::FindLength(dialogTool->GetHeight(), vars)); + const qreal a = Visualization::FindVal(dialogTool->GetAngle(), vars); + + VPlaceLabelItem newLabel = VPlaceLabelItem(); + newLabel.setName(point->name()); + newLabel.setX(point->x()); + newLabel.setY(point->y()); + newLabel.setMx(point->mx()); + newLabel.setMy(point->my()); + newLabel.SetWidth(w, dialogTool->GetWidth()); + newLabel.SetHeight(h, dialogTool->GetHeight()); + newLabel.SetAngle(a, dialogTool->GetAngle()); + newLabel.SetLabelType(dialogTool->GetLabelType()); + newLabel.SetCenterPoint(dialogTool->GetCenterPoint()); + newLabel.SetCorrectionAngle(oldLabel->GetCorrectionAngle()); + + SavePlaceLabelOptions *saveCommand = new SavePlaceLabelOptions(*oldLabel, newLabel, + qApp->getCurrentDocument(), + const_cast(data), + dialogTool->GetToolId()); + qApp->getUndoStack()->push(saveCommand); + UpdateCurrentPlaceLabelRecords(); + } + catch (const VExceptionBadId &e) + { + qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Error. Can't save piece path.")), + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + } + } + delete m_dialog; +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::FancyTabChanged(int index) { @@ -1041,6 +1256,7 @@ void DialogSeamAllowance::FancyTabChanged(int index) m_tabGrainline->hide(); m_tabPins->hide(); m_tabPassmarks->hide(); + m_tabPlaceLabels->hide(); QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") @@ -1061,20 +1277,28 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") case TabOrder::Passmarks: m_tabPassmarks->show(); break; + case TabOrder::PlaceLabels: + m_tabPlaceLabels->show(); + break; } QT_WARNING_POP - if (index == TabOrder::Pins || index == TabOrder::Grainline + if (index == TabOrder::Pins + || index == TabOrder::Grainline || (index == TabOrder::Labels && uiTabLabels->tabWidget->currentIndex() == uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels))) { - ShowPins(); + ShowPieceSpecialPoints(uiTabPins->listWidgetPins); + } + else if (index == TabOrder::PlaceLabels) + { + ShowPieceSpecialPoints(uiTabPlaceLabels->listWidgetPlaceLabels); } else { - if (not m_visPins.isNull()) + if (not m_visSpecialPoints.isNull()) { - delete m_visPins; + delete m_visSpecialPoints; } } } @@ -1084,13 +1308,13 @@ void DialogSeamAllowance::TabChanged(int index) { if (index == uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels)) { - ShowPins(); + ShowPieceSpecialPoints(uiTabPins->listWidgetPins); } else { - if (not m_visPins.isNull()) + if (not m_visSpecialPoints.isNull()) { - delete m_visPins; + delete m_visSpecialPoints; } } } @@ -1985,6 +2209,7 @@ VPiece DialogSeamAllowance::CreatePiece() const piece.SetCustomSARecords(GetListInternals(uiTabPaths->listWidgetCustomSA)); piece.SetInternalPaths(GetListInternals(uiTabPaths->listWidgetInternalPaths)); piece.SetPins(GetListInternals(uiTabPins->listWidgetPins)); + piece.SetPlaceLabels(GetListInternals(uiTabPlaceLabels->listWidgetPlaceLabels)); piece.SetForbidFlipping(uiTabPaths->checkBoxForbidFlipping->isChecked()); piece.SetSeamAllowance(uiTabPaths->checkBoxSeams->isChecked()); piece.SetSeamAllowanceBuiltIn(uiTabPaths->checkBoxBuiltIn->isChecked()); @@ -2039,51 +2264,6 @@ void DialogSeamAllowance::NewMainPathItem(const VPieceNode &node) NewNodeItem(uiTabPaths->listWidgetMainPath, node); } -//--------------------------------------------------------------------------------------------------------------------- -void DialogSeamAllowance::NewCustomSA(const CustomSARecord &record) -{ - if (record.path > NULL_ID) - { - const QString name = GetPathName(record.path, record.reverse); - - QListWidgetItem *item = new QListWidgetItem(name); - item->setFont(QFont("Times", 12, QFont::Bold)); - item->setData(Qt::UserRole, QVariant::fromValue(record)); - uiTabPaths->listWidgetCustomSA->addItem(item); - uiTabPaths->listWidgetCustomSA->setCurrentRow(uiTabPaths->listWidgetCustomSA->count()-1); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogSeamAllowance::NewInternalPath(quint32 path) -{ - if (path > NULL_ID) - { - const QString name = GetPathName(path); - - QListWidgetItem *item = new QListWidgetItem(name); - item->setFont(QFont("Times", 12, QFont::Bold)); - item->setData(Qt::UserRole, QVariant::fromValue(path)); - uiTabPaths->listWidgetInternalPaths->addItem(item); - uiTabPaths->listWidgetInternalPaths->setCurrentRow(uiTabPaths->listWidgetInternalPaths->count()-1); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogSeamAllowance::NewPin(quint32 pinPoint) -{ - if (pinPoint > NULL_ID) - { - const QSharedPointer pin = data->GetGObject(pinPoint); - - QListWidgetItem *item = new QListWidgetItem(pin->name()); - item->setFont(QFont("Times", 12, QFont::Bold)); - item->setData(Qt::UserRole, QVariant::fromValue(pinPoint)); - uiTabPins->listWidgetPins->addItem(item); - uiTabPins->listWidgetPins->setCurrentRow(uiTabPins->listWidgetPins->count()-1); - } -} - //--------------------------------------------------------------------------------------------------------------------- QString DialogSeamAllowance::GetPathName(quint32 path, bool reverse) const { @@ -2340,6 +2520,7 @@ void DialogSeamAllowance::InitFancyTabBar() m_ftb->InsertTab(TabOrder::Labels, QIcon("://icon/32x32/labels.png"), tr("Labels")); m_ftb->InsertTab(TabOrder::Grainline, QIcon("://icon/32x32/grainline.png"), tr("Grainline")); m_ftb->InsertTab(TabOrder::Passmarks, QIcon("://icon/32x32/passmark.png"), tr("Passmarks")); + m_ftb->InsertTab(TabOrder::PlaceLabels, QIcon("://icon/32x32/button.png"), tr("Place label")); ui->horizontalLayout->addWidget(m_ftb, 0, Qt::AlignLeft); @@ -2365,6 +2546,10 @@ void DialogSeamAllowance::InitFancyTabBar() uiTabPassmarks->setupUi(m_tabPassmarks); ui->horizontalLayout->addWidget(m_tabPassmarks, 1); + m_tabPlaceLabels->hide(); + uiTabPlaceLabels->setupUi(m_tabPlaceLabels); + ui->horizontalLayout->addWidget(m_tabPlaceLabels, 1); + connect(m_ftb, &FancyTabBar::CurrentChanged, this, &DialogSeamAllowance::FancyTabChanged); connect(uiTabLabels->tabWidget, &QTabWidget::currentChanged, this, &DialogSeamAllowance::TabChanged); } @@ -2666,6 +2851,14 @@ void DialogSeamAllowance::InitPassmarksTab() &DialogSeamAllowance::PassmarkShowSecondChanged); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::InitPlaceLabelsTab() +{ + uiTabPlaceLabels->listWidgetPlaceLabels->setContextMenuPolicy(Qt::CustomContextMenu); + connect(uiTabPlaceLabels->listWidgetPlaceLabels, &QListWidget::customContextMenuRequested, this, + &DialogSeamAllowance::ShowPlaceLabelsContextMenu); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::InitAllPinComboboxes() { @@ -2739,6 +2932,22 @@ void DialogSeamAllowance::UpdateCurrentInternalPathRecord() item->setText(GetPathName(path)); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::UpdateCurrentPlaceLabelRecords() +{ + const int row = uiTabPlaceLabels->listWidgetPlaceLabels->currentRow(); + if (uiTabPlaceLabels->listWidgetPlaceLabels->count() == 0 || row == -1) + { + return; + } + + QListWidgetItem *item = uiTabPlaceLabels->listWidgetPlaceLabels->item(row); + SCASSERT(item != nullptr); + const quint32 pointId = qvariant_cast(item->data(Qt::UserRole)); + auto point = data->GeometricObject(pointId); + item->setText(point->name()); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::SetGrainlineAngle(QString angleFormula) { @@ -2899,25 +3108,26 @@ void DialogSeamAllowance::SetPLAngle(QString angleFormula) } //--------------------------------------------------------------------------------------------------------------------- -void DialogSeamAllowance::ShowPins() +void DialogSeamAllowance::ShowPieceSpecialPoints(const QListWidget *list) { - if (m_visPins.isNull()) + SCASSERT(list != nullptr) + if (m_visSpecialPoints.isNull()) { - m_visPins = new VisPiecePins(data); + m_visSpecialPoints = new VisPieceSpecialPoints(data); } - m_visPins->SetPins(GetListInternals(uiTabPins->listWidgetPins)); + m_visSpecialPoints->SetPoints(GetListInternals(list)); - if (not qApp->getCurrentScene()->items().contains(m_visPins)) + if (not qApp->getCurrentScene()->items().contains(m_visSpecialPoints)) { - m_visPins->VisualMode(NULL_ID); - m_visPins->setZValue(10); // pins should be on top + m_visSpecialPoints->VisualMode(NULL_ID); + m_visSpecialPoints->setZValue(10); // pins should be on top VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(toolId)); SCASSERT(tool != nullptr); - m_visPins->setParentItem(tool); + m_visSpecialPoints->setParentItem(tool); } else { - m_visPins->RefreshGeometry(); + m_visSpecialPoints->RefreshGeometry(); } } diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index 48f34032b..ef2f2fb34 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -43,9 +43,10 @@ namespace Ui class TabGrainline; class TabPins; class TabPassmarks; + class TabPlaceLabels; } -class VisPiecePins; +class VisPieceSpecialPoints; class FancyTabBar; class DialogSeamAllowance : public DialogTool @@ -81,6 +82,7 @@ private slots: void ShowCustomSAContextMenu(const QPoint &pos); void ShowInternalPathsContextMenu(const QPoint &pos); void ShowPinsContextMenu(const QPoint &pos); + void ShowPlaceLabelsContextMenu(const QPoint &pos); void ListChanged(); void EnableSeamAllowance(bool enable); @@ -94,6 +96,7 @@ private slots: void ReturnDefAfter(); void CustomSAChanged(int row); void PathDialogClosed(int result); + void PlaceLabelDialogClosed(int result); void FancyTabChanged(int index); void TabChanged(int index); void PassmarkLineTypeChanged(int id); @@ -157,12 +160,14 @@ private: Ui::TabGrainline *uiTabGrainline; Ui::TabPins *uiTabPins; Ui::TabPassmarks *uiTabPassmarks; + Ui::TabPlaceLabels *uiTabPlaceLabels; QWidget *m_tabPaths; QWidget *m_tabLabels; QWidget *m_tabGrainline; QWidget *m_tabPins; QWidget *m_tabPassmarks; + QWidget *m_tabPlaceLabels; FancyTabBar* m_ftb; @@ -180,7 +185,7 @@ private: qreal m_my; QPointer m_dialog; - QPointer m_visPins; + QPointer m_visSpecialPoints; VPieceLabelData m_oldData; VPatternLabelData m_oldGeom; @@ -207,15 +212,13 @@ private: VPiece CreatePiece() const; void NewMainPathItem(const VPieceNode &node); - void NewCustomSA(const CustomSARecord &record); - void NewInternalPath(quint32 path); - void NewPin(quint32 pinPoint); QString GetPathName(quint32 path, bool reverse = false) const; bool MainPathIsValid() const; void ValidObjects(bool value); bool MainPathIsClockwise() const; void UpdateCurrentCustomSARecord(); void UpdateCurrentInternalPathRecord(); + void UpdateCurrentPlaceLabelRecords(); QListWidgetItem *GetItemById(quint32 id); @@ -241,6 +244,7 @@ private: void InitGrainlineTab(); void InitPinsTab(); void InitPassmarksTab(); + void InitPlaceLabelsTab(); void InitAllPinComboboxes(); void SetFormulaSAWidth(const QString &formula); @@ -256,7 +260,7 @@ private: void SetPLHeight(QString heightFormula); void SetPLAngle(QString angleFormula); - void ShowPins(); + void ShowPieceSpecialPoints(const QListWidget *list); }; #endif // DIALOGSEAMALLOWANCE_H diff --git a/src/libs/vtools/dialogs/tools/piece/tabs/tabplacelabels.ui b/src/libs/vtools/dialogs/tools/piece/tabs/tabplacelabels.ui new file mode 100644 index 000000000..4bfc35221 --- /dev/null +++ b/src/libs/vtools/dialogs/tools/piece/tabs/tabplacelabels.ui @@ -0,0 +1,28 @@ + + + TabPlaceLabels + + + + 0 + 0 + 261 + 230 + + + + Dialog + + + + + + QAbstractItemView::InternalMove + + + + + + + + diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.cpp index 7501da6c1..fec1953b8 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.cpp @@ -61,7 +61,7 @@ void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData, const QSharedPointer obj = initData.data->GetGObject(idObject); // This check helps to find missed objects in the switch - Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 7, "Not all objects were handled."); + Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") @@ -98,6 +98,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") initData.data)); break; case GOType::Unknown: + case GOType::PlaceLabel: + Q_UNREACHABLE(); break; } QT_WARNING_POP @@ -111,7 +113,7 @@ QT_WARNING_POP const QSharedPointer obj = initData.data->GetGObject(idObject); // This check helps to find missed objects in the switch - Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 7, "Not all objects were handled."); + Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") @@ -148,6 +150,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") initData.data, initData.destination.at(i).id); break; case GOType::Unknown: + case GOType::PlaceLabel: + Q_UNREACHABLE(); break; } QT_WARNING_POP diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp index c3729f022..7db3e3a49 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp @@ -607,7 +607,7 @@ void VAbstractOperation::InitOperatedObjects() const QSharedPointer obj = VAbstractTool::data.GetGObject(object.id); // This check helps to find missed objects in the switch - Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 7, "Not all objects were handled."); + Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") @@ -650,6 +650,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") InitCurve(object.id, &(VAbstractTool::data), obj->getType(), SceneObject::SplinePath); break; case GOType::Unknown: + case GOType::PlaceLabel: + Q_UNREACHABLE(); break; } QT_WARNING_POP diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp index d72a32881..95e6b9d31 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp @@ -133,7 +133,7 @@ VToolMove *VToolMove::Create(VToolMoveInitData &initData) const QSharedPointer obj = initData.data->GetGObject(idObject); // This check helps to find missed objects in the switch - Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 7, "Not all objects were handled."); + Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") @@ -171,6 +171,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") initData.data)); break; case GOType::Unknown: + case GOType::PlaceLabel: + Q_UNREACHABLE(); break; } QT_WARNING_POP @@ -184,7 +186,7 @@ QT_WARNING_POP const QSharedPointer obj = initData.data->GetGObject(idObject); // This check helps to find missed objects in the switch - Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 7, "Not all objects were handled."); + Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") @@ -220,6 +222,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") initData.destination.at(i).id); break; case GOType::Unknown: + case GOType::PlaceLabel: + Q_UNREACHABLE(); break; } QT_WARNING_POP diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp index 31922cc5e..4867a50e0 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp @@ -150,7 +150,7 @@ VToolRotation *VToolRotation::Create(VToolRotationInitData &initData) const QSharedPointer obj = initData.data->GetGObject(idObject); // This check helps to find missed objects in the switch - Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 7, "Not all objects were handled."); + Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") @@ -187,6 +187,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") initData.data)); break; case GOType::Unknown: + case GOType::PlaceLabel: + Q_UNREACHABLE(); break; } QT_WARNING_POP @@ -200,7 +202,7 @@ QT_WARNING_POP const QSharedPointer obj = initData.data->GetGObject(idObject); // This check helps to find missed objects in the switch - Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 7, "Not all objects were handled."); + Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") @@ -237,6 +239,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") initData.data, initData.destination.at(i).id); break; case GOType::Unknown: + case GOType::PlaceLabel: + Q_UNREACHABLE(); break; } QT_WARNING_POP diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index 7438c0f7d..1e80d4551 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -471,6 +471,7 @@ void VToolCurveIntersectAxis::InitSegments(const GOType &curveType, qreal segLen break; } case GOType::Point: + case GOType::PlaceLabel: case GOType::Unknown: Q_UNREACHABLE(); break; diff --git a/src/libs/vtools/tools/nodeDetails/nodedetails.h b/src/libs/vtools/tools/nodeDetails/nodedetails.h index a2f9eab21..caf1db52a 100644 --- a/src/libs/vtools/tools/nodeDetails/nodedetails.h +++ b/src/libs/vtools/tools/nodeDetails/nodedetails.h @@ -36,5 +36,6 @@ #include "vnodesplinepath.h" #include "vtoolpiecepath.h" #include "vtoolpin.h" +#include "vtoolplacelabel.h" #endif // NODEDETAILS_H diff --git a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp new file mode 100644 index 000000000..fe175bb20 --- /dev/null +++ b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp @@ -0,0 +1,211 @@ +/************************************************************************ + ** + ** @file vtoolplacelabel.cpp + ** @author Roman Telezhynskyi + ** @date 15 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 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 "vtoolplacelabel.h" +#include "../../dialogs/tools/dialogplacelabel.h" +#include "../../undocommands/savepieceoptions.h" +#include "../vtoolseamallowance.h" +#include "../vgeometry/vpointf.h" +#include "../vgeometry/vplacelabelitem.h" + +const QString VToolPlaceLabel::ToolType = QStringLiteral("placeLabel"); + +//--------------------------------------------------------------------------------------------------------------------- +VToolPlaceLabel *VToolPlaceLabel::Create(QSharedPointer dialog, VAbstractPattern *doc, VContainer *data) +{ + SCASSERT(not dialog.isNull()); + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) + + VToolPlaceLabelInitData initData; + initData.width = dialogTool->GetWidth(); + initData.height = dialogTool->GetHeight(); + initData.angle = dialogTool->GetAngle(); + initData.type = dialogTool->GetLabelType(); + initData.centerPoint = dialogTool->GetCenterPoint(); + initData.idObject = dialogTool->GetPieceId(); + initData.doc = doc; + initData.data = data; + initData.parse = Document::FullParse; + initData.typeCreation = Source::FromGui; + + return Create(initData); +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolPlaceLabel *VToolPlaceLabel::Create(VToolPlaceLabelInitData &initData) +{ + const qreal w = qAbs(qApp->toPixel(CheckFormula(initData.id, initData.width, initData.data))); + const qreal h = qAbs(qApp->toPixel(CheckFormula(initData.id, initData.height, initData.data))); + const qreal a = CheckFormula(initData.id, initData.angle, initData.data); + + QSharedPointer node(new VPlaceLabelItem()); + node->SetWidth(w, initData.width); + node->SetHeight(h, initData.height); + node->SetAngle(a, initData.angle); + node->SetLabelType(initData.type); + node->SetCenterPoint(initData.centerPoint); + + if (initData.typeCreation == Source::FromGui) + { + //We can't use exist object. Need create new. + auto point = initData.data->GeometricObject(initData.centerPoint); + + node->setName(point->name()); + node->setX(point->x()); + node->setY(point->y()); + node->setMx(point->mx()); + node->setMy(point->my()); + + initData.id = initData.data->AddGObject(node); + } + else + { + QSharedPointer point; + try + { + point = initData.data->GeometricObject(initData.centerPoint); + } + catch (const VExceptionBadId &e) + { // Possible case. Parent was deleted, but the node object is still here. + Q_UNUSED(e) + return nullptr;// Just ignore + } + node->setName(point->name()); + node->setX(point->x()); + node->setY(point->y()); + node->setMx(point->mx()); + node->setMy(point->my()); + + if (initData.typeCreation == Source::FromTool) + { + QSharedPointer label = qSharedPointerDynamicCast(point); + SCASSERT(label.isNull() == false) + + node->SetCorrectionAngle(label->GetCorrectionAngle()); + } + + initData.data->UpdateGObject(initData.id, node); + if (initData.parse != Document::FullParse) + { + initData.doc->UpdateToolData(initData.id, initData.data); + } + } + VAbstractTool::AddRecord(initData.id, Tool::PlaceLabel, initData.doc); + VToolPlaceLabel *point = nullptr; + if (initData.parse == Document::FullParse) + { + point = new VToolPlaceLabel(initData); + + VAbstractPattern::AddTool(initData.id, point); + if (initData.idTool != NULL_ID) + { + //Some nodes we don't show on scene. Tool that creates this nodes must free memory. + VDataTool *tool = VAbstractPattern::getTool(initData.idTool); + SCASSERT(tool != nullptr) + point->setParent(tool);// Adopted by a tool + } + else + { + // Help to delete the node before each FullParse + initData.doc->AddToolOnRemove(point); + } + } + else + { + initData.doc->UpdateToolData(initData.id, initData.data); + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolPlaceLabel::getTagName() const +{ + return VAbstractPattern::TagPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPlaceLabel::AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, + const VPlaceLabelItem &label) +{ + doc->SetAttribute(domElement, VDomDocument::AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrIdObject, label.GetCenterPoint()); + doc->SetAttribute(domElement, AttrWidth, label.GetWidthFormula()); + doc->SetAttribute(domElement, AttrHeight, label.GetHeightFormula()); + doc->SetAttribute(domElement, AttrAngle, label.GetAngleFormula()); + doc->SetAttribute(domElement, AttrPlaceLabelType, static_cast(label.GetLabelType())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPlaceLabel::AllowHover(bool enabled) +{ + Q_UNUSED(enabled) + // do nothing +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPlaceLabel::AllowSelecting(bool enabled) +{ + Q_UNUSED(enabled) + // do nothing +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPlaceLabel::AddToFile() +{ + auto label = VAbstractTool::data.GeometricObject(m_id); + + QDomElement domElement = doc->createElement(getTagName()); + + AddAttributes(doc, domElement, m_id, *label); + if (idTool != NULL_ID) + { + doc->SetAttribute(domElement, AttrIdTool, idTool); + } + + AddToModeling(domElement); + + if (m_pieceId > NULL_ID) + { + const VPiece oldDet = VAbstractTool::data.GetPiece(m_pieceId); + VPiece newDet = oldDet; + + newDet.GetPlaceLabels().append(m_id); + qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_pieceId)); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolPlaceLabel::VToolPlaceLabel(const VToolPlaceLabelInitData &initData, QObject *qoParent) + : VAbstractNode(initData.doc, initData.data, initData.id, initData.centerPoint, initData.drawName, + initData.idTool, qoParent), + m_pieceId(initData.idObject) +{ + ToolCreation(initData.typeCreation); +} diff --git a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.h b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.h new file mode 100644 index 000000000..77d10f6e3 --- /dev/null +++ b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.h @@ -0,0 +1,83 @@ +/************************************************************************ + ** + ** @file vtoolplacelabel.h + ** @author Roman Telezhynskyi + ** @date 15 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 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 VTOOLPLACELABEL_H +#define VTOOLPLACELABEL_H + +#include + +#include "vabstractnode.h" +#include "../vgeometry/vplacelabelitem.h" + +class DialogTool; + +struct VToolPlaceLabelInitData : VAbstractNodeInitData +{ + VToolPlaceLabelInitData() + : VAbstractNodeInitData(), + width("0"), + height("0"), + angle("0"), + type(PlaceLabelType::Button), + centerPoint(NULL_ID) + {} + + QString width; + QString height; + QString angle; + PlaceLabelType type; + quint32 centerPoint; +}; + +class VToolPlaceLabel : public VAbstractNode +{ + Q_OBJECT +public: + static VToolPlaceLabel* Create(QSharedPointer dialog, VAbstractPattern *doc, VContainer *data); + static VToolPlaceLabel* Create(VToolPlaceLabelInitData &initData); + + static const QString ToolType; + virtual QString getTagName() const Q_DECL_OVERRIDE; + + static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPlaceLabelItem &label); +public slots: + virtual void FullUpdateFromFile () Q_DECL_OVERRIDE {} + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; +protected: + virtual void AddToFile() Q_DECL_OVERRIDE; + virtual void ShowNode() Q_DECL_OVERRIDE {} + virtual void HideNode() Q_DECL_OVERRIDE {} +private: + Q_DISABLE_COPY(VToolPlaceLabel) + + quint32 m_pieceId; + + VToolPlaceLabel(const VToolPlaceLabelInitData &initData, QObject *qoParent = nullptr); +}; + +#endif // VTOOLPLACELABEL_H diff --git a/src/libs/vtools/tools/tools.pri b/src/libs/vtools/tools/tools.pri index 8b34c046c..3d3414519 100644 --- a/src/libs/vtools/tools/tools.pri +++ b/src/libs/vtools/tools/tools.pri @@ -60,7 +60,8 @@ HEADERS += \ $$PWD/vtoolseamallowance.h \ $$PWD/nodeDetails/vtoolpiecepath.h \ $$PWD/nodeDetails/vtoolpin.h \ - $$PWD/vinteractivetool.h + $$PWD/vinteractivetool.h \ + $$PWD/nodeDetails/vtoolplacelabel.h SOURCES += \ $$PWD/vdatatool.cpp \ @@ -118,4 +119,5 @@ SOURCES += \ $$PWD/vtoolseamallowance.cpp \ $$PWD/nodeDetails/vtoolpiecepath.cpp \ $$PWD/nodeDetails/vtoolpin.cpp \ - $$PWD/vinteractivetool.cpp + $$PWD/vinteractivetool.cpp \ + $$PWD/nodeDetails/vtoolplacelabel.cpp diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 881a490ea..d0937bcaa 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -65,17 +65,17 @@ // Current version of seam allowance tag need for backward compatibility const quint8 VToolSeamAllowance::pieceVersion = 2; -const QString VToolSeamAllowance::TagCSA = QStringLiteral("csa"); -const QString VToolSeamAllowance::TagRecord = QStringLiteral("record"); -const QString VToolSeamAllowance::TagIPaths = QStringLiteral("iPaths"); -const QString VToolSeamAllowance::TagPins = QStringLiteral("pins"); +const QString VToolSeamAllowance::TagCSA = QStringLiteral("csa"); +const QString VToolSeamAllowance::TagRecord = QStringLiteral("record"); +const QString VToolSeamAllowance::TagIPaths = QStringLiteral("iPaths"); +const QString VToolSeamAllowance::TagPins = QStringLiteral("pins"); +const QString VToolSeamAllowance::TagPlaceLabels = QStringLiteral("placeLabels"); const QString VToolSeamAllowance::AttrVersion = QStringLiteral("version"); const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping"); const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance"); const QString VToolSeamAllowance::AttrHideMainPath = QStringLiteral("hideMainPath"); const QString VToolSeamAllowance::AttrSeamAllowanceBuiltIn = QStringLiteral("seamAllowanceBuiltIn"); -const QString VToolSeamAllowance::AttrHeight = QStringLiteral("height"); const QString VToolSeamAllowance::AttrUnited = QStringLiteral("united"); const QString VToolSeamAllowance::AttrFont = QStringLiteral("fontSize"); const QString VToolSeamAllowance::AttrTopLeftPin = QStringLiteral("topLeftPin"); @@ -232,7 +232,7 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl domElement.removeAttribute(AttrSeamAllowanceBuiltIn); } - doc->SetAttribute(domElement, VAbstractPattern::AttrWidth, piece.GetFormulaSAWidth()); + doc->SetAttribute(domElement, AttrWidth, piece.GetFormulaSAWidth()); doc->SetAttribute(domElement, AttrUnited, piece.IsUnited()); } @@ -284,17 +284,14 @@ void VToolSeamAllowance::AddInternalPaths(VAbstractPattern *doc, QDomElement &do //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::AddPins(VAbstractPattern *doc, QDomElement &domElement, const QVector &pins) { - if (pins.size() > 0) - { - QDomElement pinsElement = doc->createElement(VToolSeamAllowance::TagPins); - for (int i = 0; i < pins.size(); ++i) - { - QDomElement recordNode = doc->createElement(VToolSeamAllowance::TagRecord); - recordNode.appendChild(doc->createTextNode(QString().setNum(pins.at(i)))); - pinsElement.appendChild(recordNode); - } - domElement.appendChild(pinsElement); - } + AddPointRecords(doc, domElement, pins, VToolSeamAllowance::TagPins); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::AddPlaceLabels(VAbstractPattern *doc, QDomElement &domElement, + const QVector &placeLabels) +{ + AddPointRecords(doc, domElement, placeLabels, VToolSeamAllowance::TagPlaceLabels); } //--------------------------------------------------------------------------------------------------------------------- @@ -313,7 +310,7 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement doc->SetAttribute(domData, VAbstractPattern::AttrOnFold, data.IsOnFold()); doc->SetAttribute(domData, AttrMx, data.GetPos().x()); doc->SetAttribute(domData, AttrMy, data.GetPos().y()); - doc->SetAttribute(domData, VAbstractPattern::AttrWidth, data.GetLabelWidth()); + doc->SetAttribute(domData, AttrWidth, data.GetLabelWidth()); doc->SetAttribute(domData, AttrHeight, data.GetLabelHeight()); doc->SetAttribute(domData, AttrFont, data.GetFontSize()); doc->SetAttribute(domData, VAbstractPattern::AttrRotation, data.GetRotation()); @@ -358,7 +355,7 @@ void VToolSeamAllowance::AddPatternInfo(VAbstractPattern *doc, QDomElement &domE doc->SetAttribute(domData, VAbstractPattern::AttrVisible, geom.IsVisible()); doc->SetAttribute(domData, AttrMx, geom.GetPos().x()); doc->SetAttribute(domData, AttrMy, geom.GetPos().y()); - doc->SetAttribute(domData, VAbstractPattern::AttrWidth, geom.GetLabelWidth()); + doc->SetAttribute(domData, AttrWidth, geom.GetLabelWidth()); doc->SetAttribute(domData, AttrHeight, geom.GetLabelHeight()); doc->SetAttribute(domData, AttrFont, geom.GetFontSize()); doc->SetAttribute(domData, VAbstractPattern::AttrRotation, geom.GetRotation()); @@ -514,7 +511,8 @@ void VToolSeamAllowance::ReinitInternals(const VPiece &detail, VMainGraphicsScen InitNodes(detail, scene); InitCSAPaths(detail); InitInternalPaths(detail); - InitPins(detail); + InitSpecialPoints(detail.GetPins()); + InitSpecialPoints(detail.GetPlaceLabels()); } //--------------------------------------------------------------------------------------------------------------------- @@ -865,6 +863,7 @@ void VToolSeamAllowance::paint(QPainter *painter, const QStyleOptionGraphicsItem setPen(toolPen); m_seamAllowance->setPen(toolPen); m_passmarks->setPen(toolPen); + m_placeLabels->setPen(toolPen); if ((m_dataLabel->IsIdle() == false || m_patternInfo->IsIdle() == false @@ -919,6 +918,7 @@ void VToolSeamAllowance::AddToFile() AddCSARecords(doc, domElement, piece.GetCustomSARecords()); AddInternalPaths(doc, domElement, piece.GetInternalPaths()); AddPins(doc, domElement, piece.GetPins()); + AddPlaceLabels(doc, domElement, piece.GetPlaceLabels()); qApp->getUndoStack()->push(new AddPiece(domElement, doc, VAbstractTool::data, m_sceneDetails, m_drawName)); } @@ -1203,7 +1203,8 @@ VToolSeamAllowance::VToolSeamAllowance(const VToolSeamAllowanceInitData &initDat m_dataLabel(new VTextGraphicsItem(this)), m_patternInfo(new VTextGraphicsItem(this)), m_grainLine(new VGrainlineItem(this)), - m_passmarks(new QGraphicsPathItem(this)) + m_passmarks(new QGraphicsPathItem(this)), + m_placeLabels(new QGraphicsPathItem(this)) { VPiece detail = initData.data->GetPiece(initData.id); ReinitInternals(detail, m_sceneDetails); @@ -1291,6 +1292,8 @@ void VToolSeamAllowance::RefreshGeometry() m_seamAllowance->setPath(QPainterPath()); } + m_placeLabels->setPath(detail.PlaceLabelPath(this->getData())); + UpdateDetailLabel(); UpdatePatternInfo(); UpdateGrainline(); @@ -1549,7 +1552,7 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc } //--------------------------------------------------------------------------------------------------------------------- -void VToolSeamAllowance::InitCSAPaths(const VPiece &detail) +void VToolSeamAllowance::InitCSAPaths(const VPiece &detail) const { for (int i = 0; i < detail.GetCustomSARecords().size(); ++i) { @@ -1576,11 +1579,11 @@ void VToolSeamAllowance::InitInternalPaths(const VPiece &detail) } //--------------------------------------------------------------------------------------------------------------------- -void VToolSeamAllowance::InitPins(const VPiece &detail) +void VToolSeamAllowance::InitSpecialPoints(const QVector &points) const { - for (int i = 0; i < detail.GetPins().size(); ++i) + for (int i = 0; i < points.size(); ++i) { - doc->IncrementReferens(detail.GetPins().at(i)); + doc->IncrementReferens(points.at(i)); } } @@ -1690,3 +1693,20 @@ QList VToolSeamAllowance::SelectedTools() const return tools; } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::AddPointRecords(VAbstractPattern *doc, QDomElement &domElement, + const QVector &records, const QString &tag) +{ + if (records.size() > 0) + { + QDomElement pinsElement = doc->createElement(tag); + for (int i = 0; i < records.size(); ++i) + { + QDomElement recordNode = doc->createElement(VToolSeamAllowance::TagRecord); + recordNode.appendChild(doc->createTextNode(QString().setNum(records.at(i)))); + pinsElement.appendChild(recordNode); + } + domElement.appendChild(pinsElement); + } +} diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 74dfced33..d77f2a7cc 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -71,13 +71,13 @@ public: static const QString TagRecord; static const QString TagIPaths; static const QString TagPins; + static const QString TagPlaceLabels; static const QString AttrVersion; static const QString AttrForbidFlipping; static const QString AttrSeamAllowance; static const QString AttrHideMainPath; static const QString AttrSeamAllowanceBuiltIn; - static const QString AttrHeight; static const QString AttrUnited; static const QString AttrFont; static const QString AttrTopLeftPin; @@ -96,6 +96,7 @@ public: static void AddCSARecords(VAbstractPattern *doc, QDomElement &domElement, const QVector &records); static void AddInternalPaths(VAbstractPattern *doc, QDomElement &domElement, const QVector &paths); static void AddPins(VAbstractPattern *doc, QDomElement &domElement, const QVector &pins); + static void AddPlaceLabels(VAbstractPattern *doc, QDomElement &domElement, const QVector &placeLabels); static void AddPatternPieceData(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece); static void AddPatternInfo(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece); static void AddGrainline(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece); @@ -169,6 +170,7 @@ private: VTextGraphicsItem *m_patternInfo; VGrainlineItem *m_grainLine; QGraphicsPathItem *m_passmarks; + QGraphicsPathItem *m_placeLabels; VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr); @@ -183,15 +185,18 @@ private: void InitNodes(const VPiece &detail, VMainGraphicsScene *scene); static void InitNode(const VPieceNode &node, VMainGraphicsScene *scene, VContainer *data, VAbstractPattern *doc, VToolSeamAllowance *parent); - void InitCSAPaths(const VPiece &detail); + void InitCSAPaths(const VPiece &detail) const; void InitInternalPaths(const VPiece &detail); - void InitPins(const VPiece &detail); + void InitSpecialPoints(const QVector &points) const; bool PrepareLabelData(const VPatternLabelData &labelData, VTextGraphicsItem *labelItem, QPointF &pos, qreal &labelAngle); void UpdateLabelItem(VTextGraphicsItem *labelItem, QPointF pos, qreal labelAngle); QList SelectedTools() const; + + static void AddPointRecords(VAbstractPattern *doc, QDomElement &domElement, const QVector &records, + const QString &tag); }; #endif // VTOOLSEAMALLOWANCE_H diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index 7281d8a37..5885ba7af 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -54,6 +54,7 @@ #include "../vgeometry/vpointf.h" #include "../vgeometry/vspline.h" #include "../vgeometry/vsplinepoint.h" +#include "../vgeometry/vplacelabelitem.h" #include "../vmisc/diagnostic.h" #include "../vmisc/logging.h" #include "../vmisc/vabstractapplication.h" @@ -68,6 +69,7 @@ #include "nodeDetails/vnodesplinepath.h" #include "nodeDetails/vtoolpiecepath.h" #include "nodeDetails/vtoolpin.h" +#include "nodeDetails/vtoolplacelabel.h" #include "vdatatool.h" #include "vnodedetail.h" #include "vtoolseamallowance.h" @@ -221,7 +223,7 @@ QVector GetPiece2Pins(VAbstractPattern *doc, quint32 id) const QDomElement element = detList.at(j).toElement(); if (not element.isNull() && element.tagName() == VToolSeamAllowance::TagPins) { - return VAbstractPattern::ParsePiecePins(element); + return VAbstractPattern::ParsePiecePointRecords(element); } } } @@ -428,6 +430,40 @@ quint32 AddPin(quint32 id, const VToolUnionDetailsInitData &initData, QVector &children, + const QString &drawName, qreal dx, qreal dy, quint32 pRotate, qreal angle) +{ + QScopedPointer label(new VPlaceLabelItem(*initData.data->GeometricObject(id))); + + if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) + { + BiasRotatePoint(label.data(), dx, dy, static_cast(*initData.data->GeometricObject(pRotate)), + angle); + } + + label->SetCorrectionAngle(label->GetCorrectionAngle() + angle); + QScopedPointer label1(new VPlaceLabelItem(*label)); + + const quint32 idObject = initData.data->AddGObject(label.take()); + children.append(idObject); + const quint32 idLabel = initData.data->AddGObject(label1.take()); + + VToolPlaceLabelInitData initNodeData; + initNodeData.id = idLabel; + initNodeData.centerPoint = idObject; + initNodeData.idObject = NULL_ID; + initNodeData.doc = initData.doc; + initNodeData.data = initData.data; + initNodeData.parse = Document::FullParse; + initNodeData.typeCreation = Source::FromTool; + initNodeData.idTool = initData.id; + initNodeData.drawName = drawName; + + VToolPlaceLabel::Create(initNodeData); + return idLabel; +} + //--------------------------------------------------------------------------------------------------------------------- quint32 AddNodeArc(const VPieceNode &node, const VToolUnionDetailsInitData &initData, QVector &children, const QString &drawName, qreal dx, qreal dy, @@ -772,6 +808,12 @@ void SavePinsChildren(VAbstractPattern *doc, quint32 id, const QVector SaveChildren(doc, id, doc->createElement(VToolSeamAllowance::TagPins), children); } +//--------------------------------------------------------------------------------------------------------------------- +void SavePlaceLabelsChildren(VAbstractPattern *doc, quint32 id, const QVector &children) +{ + SaveChildren(doc, id, doc->createElement(VToolSeamAllowance::TagPlaceLabels), children); +} + //--------------------------------------------------------------------------------------------------------------------- QVector GetChildren(VAbstractPattern *doc, quint32 id, const QString &tagName) { @@ -830,6 +872,12 @@ QVector GetPinChildren(VAbstractPattern *doc, quint32 id) return GetChildren(doc, id, VToolSeamAllowance::TagPins); } +//--------------------------------------------------------------------------------------------------------------------- +QVector GetPlaceLabelChildren(VAbstractPattern *doc, quint32 id) +{ + return GetChildren(doc, id, VToolSeamAllowance::TagPlaceLabels); +} + //--------------------------------------------------------------------------------------------------------------------- quint32 TakeNextId(QVector &children) { @@ -1187,6 +1235,22 @@ void CreateUnitedDetailPins(VPiece &newDetail, const VPiece &d, QVector children += nodeChildren; } +//--------------------------------------------------------------------------------------------------------------------- +void CreateUnitedDetailPlaceLabels(VPiece &newDetail, const VPiece &d, QVector &children, + const QString &drawName, const VToolUnionDetailsInitData &initData, qreal dx, + qreal dy, quint32 pRotate, qreal angle) +{ + QVector nodeChildren; + for(int i=0; i < d.GetPlaceLabels().size(); ++i) + { + const quint32 id = AddPlaceLabel(d.GetPlaceLabels().at(i), initData, children, drawName, dx, dy, pRotate, + angle); + newDetail.GetPlaceLabels().append(id); + nodeChildren.prepend(id); + } + children += nodeChildren; +} + //--------------------------------------------------------------------------------------------------------------------- void CreateUnitedPins(VPiece &newDetail, const VPiece &d1, const VPiece &d2, const QString &drawName, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle) @@ -1201,6 +1265,21 @@ void CreateUnitedPins(VPiece &newDetail, const VPiece &d1, const VPiece &d2, con SavePinsChildren(initData.doc, initData.id, children); } +//--------------------------------------------------------------------------------------------------------------------- +void CreateUnitedPlaceLabels(VPiece &newDetail, const VPiece &d1, const VPiece &d2, const QString &drawName, + const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, + qreal angle) +{ + for (int i = 0; i < d1.GetPlaceLabels().size(); ++i) + { + newDetail.GetPlaceLabels().append(d1.GetPlaceLabels().at(i)); + } + + QVector children; + CreateUnitedDetailPlaceLabels(newDetail, d2, children, drawName, initData, dx, dy, pRotate, angle); + SavePlaceLabelsChildren(initData.doc, initData.id, children); +} + //--------------------------------------------------------------------------------------------------------------------- void UpdateUnitedNodes(const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle) { @@ -1328,6 +1407,26 @@ void UpdateUnitedDetailPins(const VToolUnionDetailsInitData &initData, qreal dx, } } +//--------------------------------------------------------------------------------------------------------------------- +void UpdateUnitedDetailPlaceLabels(const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, + qreal angle, const QVector &records) +{ + QVector children = GetPlaceLabelChildren(initData.doc, initData.id); + + for (int i = 0; i < records.size(); ++i) + { + QScopedPointer + label(new VPlaceLabelItem(*initData.data->GeometricObject(records.at(i)))); + if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) + { + BiasRotatePoint(label.data(), dx, dy, + static_cast(*initData.data->GeometricObject(pRotate)), angle); + } + label->SetCorrectionAngle(label->GetCorrectionAngle()+angle); + initData.data->UpdateGObject(TakeNextId(children), label.take()); + } +} + //--------------------------------------------------------------------------------------------------------------------- void CreateUnitedDetail(const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle) { @@ -1343,6 +1442,7 @@ void CreateUnitedDetail(const VToolUnionDetailsInitData &initData, qreal dx, qre CreateUnitedCSA(newDetail, d1, d2, drawName, initData, dx, dy, pRotate, angle); CreateUnitedInternalPaths(newDetail, d1, d2, drawName, initData, dx, dy, pRotate, angle); CreateUnitedPins(newDetail, d1, d2, drawName, initData, dx, dy, pRotate, angle); + CreateUnitedPlaceLabels(newDetail, d1, d2, drawName, initData, dx, dy, pRotate, angle); newDetail.SetName(QObject::tr("United detail")); QString formulaSAWidth = d1.GetFormulaSAWidth(); @@ -1386,6 +1486,7 @@ void UpdateUnitedDetail(const VToolUnionDetailsInitData &initData, qreal dx, qre UpdateUnitedDetailInternalPaths(initData, dx, dy, pRotate, angle, GetPiece2InternalPaths(initData.doc, initData.id)); UpdateUnitedDetailPins(initData, dx, dy, pRotate, angle, GetPiece2Pins(initData.doc, initData.id)); + UpdateUnitedDetailPlaceLabels(initData, dx, dy, pRotate, angle, GetPiece2Pins(initData.doc, initData.id)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/undocommands/savepieceoptions.cpp b/src/libs/vtools/undocommands/savepieceoptions.cpp index 09b297236..91539cc5c 100644 --- a/src/libs/vtools/undocommands/savepieceoptions.cpp +++ b/src/libs/vtools/undocommands/savepieceoptions.cpp @@ -72,6 +72,7 @@ void SavePieceOptions::undo() VToolSeamAllowance::AddCSARecords(doc, domElement, m_oldDet.GetCustomSARecords()); VToolSeamAllowance::AddInternalPaths(doc, domElement, m_oldDet.GetInternalPaths()); VToolSeamAllowance::AddPins(doc, domElement, m_oldDet.GetPins()); + VToolSeamAllowance::AddPlaceLabels(doc, domElement, m_oldDet.GetPlaceLabels()); DecrementReferences(m_newDet.MissingNodes(m_oldDet)); IncrementReferences(m_oldDet.MissingNodes(m_newDet)); @@ -84,7 +85,10 @@ void SavePieceOptions::undo() DecrementReferences(m_newDet.MissingPins(m_oldDet)); IncrementReferences(m_oldDet.MissingPins(m_newDet)); - + + DecrementReferences(m_newDet.MissingPlaceLabels(m_oldDet)); + IncrementReferences(m_oldDet.MissingPlaceLabels(m_newDet)); + if (VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(nodeId))) { tool->Update(m_oldDet); @@ -113,6 +117,7 @@ void SavePieceOptions::redo() VToolSeamAllowance::AddCSARecords(doc, domElement, m_newDet.GetCustomSARecords()); VToolSeamAllowance::AddInternalPaths(doc, domElement, m_newDet.GetInternalPaths()); VToolSeamAllowance::AddPins(doc, domElement, m_newDet.GetPins()); + VToolSeamAllowance::AddPlaceLabels(doc, domElement, m_newDet.GetPlaceLabels()); DecrementReferences(m_oldDet.MissingNodes(m_newDet)); IncrementReferences(m_newDet.MissingNodes(m_oldDet)); @@ -126,6 +131,9 @@ void SavePieceOptions::redo() DecrementReferences(m_oldDet.MissingPins(m_newDet)); IncrementReferences(m_newDet.MissingPins(m_oldDet)); + DecrementReferences(m_oldDet.MissingPlaceLabels(m_newDet)); + IncrementReferences(m_newDet.MissingPlaceLabels(m_oldDet)); + if (VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(nodeId))) { tool->Update(m_newDet); diff --git a/src/libs/vtools/undocommands/saveplacelabeloptions.cpp b/src/libs/vtools/undocommands/saveplacelabeloptions.cpp new file mode 100644 index 000000000..389ccbfab --- /dev/null +++ b/src/libs/vtools/undocommands/saveplacelabeloptions.cpp @@ -0,0 +1,125 @@ +/************************************************************************ + ** + ** @file saveplacelabeloptions.cpp + ** @author Roman Telezhynskyi + ** @date 16 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 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 "saveplacelabeloptions.h" +#include "../tools/nodeDetails/vtoolplacelabel.h" + +//--------------------------------------------------------------------------------------------------------------------- +SavePlaceLabelOptions::SavePlaceLabelOptions(const VPlaceLabelItem &oldLabel, const VPlaceLabelItem &newLabel, + VAbstractPattern *doc, VContainer *data, quint32 id, QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), + m_oldLabel(oldLabel), + m_newLabel(newLabel), + m_data(data) +{ + setText(tr("save place label options")); + nodeId = id; +} + +//--------------------------------------------------------------------------------------------------------------------- +void SavePlaceLabelOptions::undo() +{ + qCDebug(vUndo, "Undo."); + + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint); + if (domElement.isElement()) + { + VToolPlaceLabel::AddAttributes(doc, domElement, nodeId, m_oldLabel); + + if (m_oldLabel.GetCenterPoint() != m_newLabel.GetCenterPoint()) + { + doc->IncrementReferens(m_oldLabel.GetCenterPoint()); + doc->DecrementReferens(m_newLabel.GetCenterPoint()); + } + + SCASSERT(m_data); + m_data->UpdateGObject(nodeId, new VPlaceLabelItem(m_oldLabel)); + } + else + { + qCDebug(vUndo, "Can't find place label with id = %u.", nodeId); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void SavePlaceLabelOptions::redo() +{ + qCDebug(vUndo, "Redo."); + + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint); + if (domElement.isElement()) + { + VToolPlaceLabel::AddAttributes(doc, domElement, nodeId, m_newLabel); + + if (m_oldLabel.GetCenterPoint() != m_newLabel.GetCenterPoint()) + { + doc->IncrementReferens(m_newLabel.GetCenterPoint()); + doc->DecrementReferens(m_oldLabel.GetCenterPoint()); + } + + SCASSERT(m_data); + m_data->UpdateGObject(nodeId, new VPlaceLabelItem(m_newLabel)); + } + else + { + qCDebug(vUndo, "Can't find path with id = %u.", nodeId); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool SavePlaceLabelOptions::mergeWith(const QUndoCommand *command) +{ + const SavePlaceLabelOptions *saveCommand = static_cast(command); + SCASSERT(saveCommand != nullptr); + const quint32 id = saveCommand->LabelId(); + + if (id != nodeId) + { + return false; + } + + m_newLabel = saveCommand->NewLabel(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int SavePlaceLabelOptions::id() const +{ + return static_cast(UndoCommand::SavePlaceLabelOptions); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 SavePlaceLabelOptions::LabelId() const +{ + return nodeId; +} + +//--------------------------------------------------------------------------------------------------------------------- +VPlaceLabelItem SavePlaceLabelOptions::NewLabel() const +{ + return m_newLabel; +} diff --git a/src/libs/vtools/undocommands/saveplacelabeloptions.h b/src/libs/vtools/undocommands/saveplacelabeloptions.h new file mode 100644 index 000000000..bb81bb355 --- /dev/null +++ b/src/libs/vtools/undocommands/saveplacelabeloptions.h @@ -0,0 +1,57 @@ +/************************************************************************ + ** + ** @file saveplacelabeloptions.h + ** @author Roman Telezhynskyi + ** @date 16 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 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 SAVEPLACELABELOPTIONS_H +#define SAVEPLACELABELOPTIONS_H + +#include "vundocommand.h" +#include "../vgeometry/vplacelabelitem.h" + +class SavePlaceLabelOptions : public VUndoCommand +{ +public: + SavePlaceLabelOptions(const VPlaceLabelItem &oldLabel, const VPlaceLabelItem &newLabel, VAbstractPattern *doc, + VContainer *data, quint32 id, QUndoCommand *parent = nullptr); + virtual ~SavePlaceLabelOptions()=default; + + virtual void undo() Q_DECL_OVERRIDE; + virtual void redo() Q_DECL_OVERRIDE; + virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE; + virtual int id() const Q_DECL_OVERRIDE; + + quint32 LabelId() const; + VPlaceLabelItem NewLabel() const; +private: + Q_DISABLE_COPY(SavePlaceLabelOptions) + + const VPlaceLabelItem m_oldLabel; + VPlaceLabelItem m_newLabel; + + VContainer *m_data; +}; + +#endif // SAVEPLACELABELOPTIONS_H diff --git a/src/libs/vtools/undocommands/undocommands.pri b/src/libs/vtools/undocommands/undocommands.pri index 54fd83560..6ef724357 100644 --- a/src/libs/vtools/undocommands/undocommands.pri +++ b/src/libs/vtools/undocommands/undocommands.pri @@ -26,7 +26,8 @@ HEADERS += \ $$PWD/savepiecepathoptions.h \ $$PWD/label/showlabel.h \ $$PWD/label/showdoublelabel.h \ - $$PWD/label/operationshowlabel.h + $$PWD/label/operationshowlabel.h \ + $$PWD/saveplacelabeloptions.h SOURCES += \ $$PWD/addtocalc.cpp \ @@ -53,4 +54,5 @@ SOURCES += \ $$PWD/savepiecepathoptions.cpp \ $$PWD/label/showlabel.cpp \ $$PWD/label/showdoublelabel.cpp \ - $$PWD/label/operationshowlabel.cpp + $$PWD/label/operationshowlabel.cpp \ + $$PWD/saveplacelabeloptions.cpp diff --git a/src/libs/vtools/undocommands/vundocommand.cpp b/src/libs/vtools/undocommands/vundocommand.cpp index c3ec3f33c..2b43f96f1 100644 --- a/src/libs/vtools/undocommands/vundocommand.cpp +++ b/src/libs/vtools/undocommands/vundocommand.cpp @@ -80,7 +80,14 @@ void VUndoCommand::IncrementReferences(const QVector &nodes) const { for (qint32 i = 0; i < nodes.size(); ++i) { - doc->IncrementReferens(nodes.at(i)); + try + { + doc->IncrementReferens(nodes.at(i)); + } + catch (const VExceptionBadId &e) + { // ignoring + Q_UNUSED(e); + } } } @@ -89,7 +96,14 @@ void VUndoCommand::DecrementReferences(const QVector &nodes) const { for (qint32 i = 0; i < nodes.size(); ++i) { - doc->DecrementReferens(nodes.at(i)); + try + { + doc->DecrementReferens(nodes.at(i)); + } + catch (const VExceptionBadId &e) + { // ignoring + Q_UNUSED(e); + } } } diff --git a/src/libs/vtools/undocommands/vundocommand.h b/src/libs/vtools/undocommands/vundocommand.h index c25ebd722..b6a93c89b 100644 --- a/src/libs/vtools/undocommands/vundocommand.h +++ b/src/libs/vtools/undocommands/vundocommand.h @@ -52,6 +52,7 @@ enum class UndoCommand: char { AddPatternPiece, SaveDetailOptions, SavePieceOptions, SavePiecePathOptions, + SavePlaceLabelOptions, MovePiece, DeleteTool, DeletePatternPiece, diff --git a/src/libs/vtools/visualization/line/operation/visoperation.cpp b/src/libs/vtools/visualization/line/operation/visoperation.cpp index d9e108bc4..0dc0530d5 100644 --- a/src/libs/vtools/visualization/line/operation/visoperation.cpp +++ b/src/libs/vtools/visualization/line/operation/visoperation.cpp @@ -109,7 +109,7 @@ void VisOperation::RefreshFlippedObjects(const QPointF &firstPoint, const QPoint const QSharedPointer obj = Visualization::data->GetGObject(id); // This check helps to find missed objects in the switch - Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 7, "Not all objects were handled."); + Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); switch(static_cast(obj->getType())) { @@ -161,6 +161,8 @@ void VisOperation::RefreshFlippedObjects(const QPointF &firstPoint, const QPoint break; } case GOType::Unknown: + case GOType::PlaceLabel: + Q_UNREACHABLE(); break; } } diff --git a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp index 860609019..e6fcc7cfd 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp @@ -224,7 +224,7 @@ QVector VisToolMove::CreateOriginObjects(int &iPoint, int &iCur const QSharedPointer obj = Visualization::data->GetGObject(id); // This check helps to find missed objects in the switch - Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 7, "Not all objects were handled."); + Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); switch(static_cast(obj->getType())) { @@ -258,6 +258,8 @@ QVector VisToolMove::CreateOriginObjects(int &iPoint, int &iCur originObjects.append(AddOriginCurve(id, iCurve)); break; case GOType::Unknown: + case GOType::PlaceLabel: + Q_UNREACHABLE(); break; } } @@ -279,7 +281,7 @@ void VisToolMove::CreateMovedObjects(int &iPoint, int &iCurve, qreal length, qre const QSharedPointer obj = Visualization::data->GetGObject(id); // This check helps to find missed objects in the switch - Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 7, "Not all objects was handled."); + Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects was handled."); switch(static_cast(obj->getType())) { @@ -311,6 +313,8 @@ void VisToolMove::CreateMovedObjects(int &iPoint, int &iCurve, qreal length, qre iCurve = AddMovedCurve(angle, length, id, iCurve); break; case GOType::Unknown: + case GOType::PlaceLabel: + Q_UNREACHABLE(); break; } } diff --git a/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp b/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp index 11a846f1c..152ab2958 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp @@ -131,7 +131,7 @@ void VisToolRotation::RefreshGeometry() const QSharedPointer obj = Visualization::data->GetGObject(id); // This check helps to find missed objects in the switch - Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 7, "Not all objects was handled."); + Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects was handled."); switch(static_cast(obj->getType())) { @@ -184,6 +184,8 @@ void VisToolRotation::RefreshGeometry() break; } case GOType::Unknown: + case GOType::PlaceLabel: + Q_UNREACHABLE(); break; } } diff --git a/src/libs/vtools/visualization/line/vistoolpin.cpp b/src/libs/vtools/visualization/line/vistoolspecialpoint.cpp similarity index 90% rename from src/libs/vtools/visualization/line/vistoolpin.cpp rename to src/libs/vtools/visualization/line/vistoolspecialpoint.cpp index 5c009e21b..a1fea2291 100644 --- a/src/libs/vtools/visualization/line/vistoolpin.cpp +++ b/src/libs/vtools/visualization/line/vistoolspecialpoint.cpp @@ -26,18 +26,19 @@ ** *************************************************************************/ -#include "vistoolpin.h" +#include "vistoolspecialpoint.h" #include "../vwidgets/vsimplepoint.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- -VisToolPin::VisToolPin(const VContainer *data, QGraphicsItem *parent) +VisToolSpecialPoint::VisToolSpecialPoint(const VContainer *data, QGraphicsItem *parent) : VisLine(data, parent), m_point() { this->mainColor = Qt::red; this->setZValue(2);// Show on top real tool + this->setPen(QPen(Qt::NoPen)); m_point = new VSimplePoint(NULL_ID, mainColor); m_point->SetPointHighlight(true); @@ -47,7 +48,7 @@ VisToolPin::VisToolPin(const VContainer *data, QGraphicsItem *parent) } //--------------------------------------------------------------------------------------------------------------------- -VisToolPin::~VisToolPin() +VisToolSpecialPoint::~VisToolSpecialPoint() { if (not m_point.isNull()) { @@ -56,7 +57,7 @@ VisToolPin::~VisToolPin() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPin::RefreshGeometry() +void VisToolSpecialPoint::RefreshGeometry() { if (object1Id > NULL_ID) { diff --git a/src/libs/vtools/visualization/line/vistoolpin.h b/src/libs/vtools/visualization/line/vistoolspecialpoint.h similarity index 79% rename from src/libs/vtools/visualization/line/vistoolpin.h rename to src/libs/vtools/visualization/line/vistoolspecialpoint.h index 510cc76cb..866742171 100644 --- a/src/libs/vtools/visualization/line/vistoolpin.h +++ b/src/libs/vtools/visualization/line/vistoolspecialpoint.h @@ -26,26 +26,26 @@ ** *************************************************************************/ -#ifndef VISTOOLPIN_H -#define VISTOOLPIN_H +#ifndef VISTOOLSPECIALPOINT_H +#define VISTOOLSPECIALPOINT_H #include "visline.h" class VSimplePoint; -class VisToolPin : public VisLine +class VisToolSpecialPoint : public VisLine { Q_OBJECT public: - explicit VisToolPin(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolPin(); + explicit VisToolSpecialPoint(const VContainer *data, QGraphicsItem *parent = nullptr); + virtual ~VisToolSpecialPoint(); virtual void RefreshGeometry() Q_DECL_OVERRIDE; virtual int type() const Q_DECL_OVERRIDE {return Type;} - enum { Type = UserType + static_cast(Vis::ToolPin)}; + enum { Type = UserType + static_cast(Vis::ToolSpecialPoint)}; private: - Q_DISABLE_COPY(VisToolPin) + Q_DISABLE_COPY(VisToolSpecialPoint) QPointer m_point; }; -#endif // VISTOOLPIN_H +#endif // VISTOOLSPECIALPOINT_H diff --git a/src/libs/vtools/visualization/path/vispiecepins.cpp b/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp similarity index 83% rename from src/libs/vtools/visualization/path/vispiecepins.cpp rename to src/libs/vtools/visualization/path/vispiecespecialpoints.cpp index 4b03645c6..dfae65144 100644 --- a/src/libs/vtools/visualization/path/vispiecepins.cpp +++ b/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp @@ -26,48 +26,48 @@ ** *************************************************************************/ -#include "vispiecepins.h" +#include "vispiecespecialpoints.h" #include "../vwidgets/vsimplepoint.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- -VisPiecePins::VisPiecePins(const VContainer *data, QGraphicsItem *parent) +VisPieceSpecialPoints::VisPieceSpecialPoints(const VContainer *data, QGraphicsItem *parent) : VisPath(data, parent), m_points(), - m_pins() + m_spoints() { } //--------------------------------------------------------------------------------------------------------------------- -void VisPiecePins::RefreshGeometry() +void VisPieceSpecialPoints::RefreshGeometry() { HideAllItems(); - for (int i = 0; i < m_pins.size(); ++i) + for (int i = 0; i < m_spoints.size(); ++i) { VSimplePoint *point = GetPoint(static_cast(i), supportColor); point->SetOnlyPoint(false); - const QSharedPointer p = Visualization::data->GeometricObject(m_pins.at(i)); + const QSharedPointer p = Visualization::data->GeometricObject(m_spoints.at(i)); point->RefreshPointGeometry(*p); point->setVisible(true); } } //--------------------------------------------------------------------------------------------------------------------- -void VisPiecePins::SetPins(const QVector &pins) +void VisPieceSpecialPoints::SetPoints(const QVector &pins) { - m_pins = pins; + m_spoints = pins; } //--------------------------------------------------------------------------------------------------------------------- -VSimplePoint *VisPiecePins::GetPoint(quint32 i, const QColor &color) +VSimplePoint *VisPieceSpecialPoints::GetPoint(quint32 i, const QColor &color) { return VisPath::GetPoint(m_points, i, color); } //--------------------------------------------------------------------------------------------------------------------- -void VisPiecePins::HideAllItems() +void VisPieceSpecialPoints::HideAllItems() { for (int i=0; i < m_points.size(); ++i) { diff --git a/src/libs/vtools/visualization/path/vispiecepins.h b/src/libs/vtools/visualization/path/vispiecespecialpoints.h similarity index 75% rename from src/libs/vtools/visualization/path/vispiecepins.h rename to src/libs/vtools/visualization/path/vispiecespecialpoints.h index 9fe8d4ca6..de54da8c9 100644 --- a/src/libs/vtools/visualization/path/vispiecepins.h +++ b/src/libs/vtools/visualization/path/vispiecespecialpoints.h @@ -26,32 +26,32 @@ ** *************************************************************************/ -#ifndef VISPIECEPINS_H -#define VISPIECEPINS_H +#ifndef VISPIECESPECIALPOINTS_H +#define VISPIECESPECIALPOINTS_H #include "vispath.h" class VSimplePoint; -class VisPiecePins : public VisPath +class VisPieceSpecialPoints : public VisPath { Q_OBJECT public: - VisPiecePins(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisPiecePins() Q_DECL_EQ_DEFAULT; + VisPieceSpecialPoints(const VContainer *data, QGraphicsItem *parent = nullptr); + virtual ~VisPieceSpecialPoints() Q_DECL_EQ_DEFAULT; virtual void RefreshGeometry() Q_DECL_OVERRIDE; - void SetPins(const QVector &pins); + void SetPoints(const QVector &pins); virtual int type() const Q_DECL_OVERRIDE {return Type;} - enum { Type = UserType + static_cast(Vis::PiecePins)}; + enum { Type = UserType + static_cast(Vis::PieceSpecialPoints)}; private: - Q_DISABLE_COPY(VisPiecePins) + Q_DISABLE_COPY(VisPieceSpecialPoints) QVector m_points; - QVector m_pins; + QVector m_spoints; VSimplePoint *GetPoint(quint32 i, const QColor &color); void HideAllItems(); }; -#endif // VISPIECEPINS_H +#endif // VISPIECESPECIALPOINTS_H diff --git a/src/libs/vtools/visualization/visualization.pri b/src/libs/vtools/visualization/visualization.pri index 1f822647e..5f9aac564 100644 --- a/src/libs/vtools/visualization/visualization.pri +++ b/src/libs/vtools/visualization/visualization.pri @@ -41,8 +41,8 @@ HEADERS += \ $$PWD/path/vistoolellipticalarc.h \ $$PWD/path/vistoolpiece.h \ $$PWD/path/vistoolpiecepath.h \ - $$PWD/line/vistoolpin.h \ - $$PWD/path/vispiecepins.h + $$PWD/path/vispiecespecialpoints.h \ + $$PWD/line/vistoolspecialpoint.h SOURCES += \ $$PWD/visualization.cpp \ @@ -84,5 +84,5 @@ SOURCES += \ $$PWD/path/vistoolellipticalarc.cpp \ $$PWD/path/vistoolpiece.cpp \ $$PWD/path/vistoolpiecepath.cpp \ - $$PWD/line/vistoolpin.cpp \ - $$PWD/path/vispiecepins.cpp + $$PWD/path/vispiecespecialpoints.cpp \ + $$PWD/line/vistoolspecialpoint.cpp From f4c5ad7213e4bf3ed209769165c2690420c7b78f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 17 Oct 2017 19:35:39 +0300 Subject: [PATCH 02/15] Fix undo bug. Undocommand doesn't increment/decrement reference counters. --HG-- branch : feature --- .../flipping/vtoolflippingbyaxis.cpp | 7 +- .../operation/flipping/vtoolflippingbyaxis.h | 3 +- .../flipping/vtoolflippingbyline.cpp | 8 +- .../operation/flipping/vtoolflippingbyline.h | 3 +- .../tools/drawTools/operation/vtoolmove.cpp | 5 +- .../tools/drawTools/operation/vtoolmove.h | 3 +- .../drawTools/operation/vtoolrotation.cpp | 6 +- .../tools/drawTools/operation/vtoolrotation.h | 3 +- .../drawTools/toolcurve/vabstractspline.cpp | 16 +++ .../drawTools/toolcurve/vabstractspline.h | 11 ++ .../tools/drawTools/toolcurve/vtoolarc.cpp | 39 ++----- .../tools/drawTools/toolcurve/vtoolarc.h | 11 +- .../toolcurve/vtoolarcwithlength.cpp | 40 ++----- .../drawTools/toolcurve/vtoolarcwithlength.h | 11 +- .../drawTools/toolcurve/vtoolcubicbezier.cpp | 13 ++- .../drawTools/toolcurve/vtoolcubicbezier.h | 3 +- .../toolcurve/vtoolcubicbezierpath.cpp | 19 +++- .../toolcurve/vtoolcubicbezierpath.h | 3 +- .../toolcurve/vtoolellipticalarc.cpp | 40 ++----- .../drawTools/toolcurve/vtoolellipticalarc.h | 11 +- .../tools/drawTools/toolcurve/vtoolspline.cpp | 8 +- .../tools/drawTools/toolcurve/vtoolspline.h | 3 +- .../drawTools/toolcurve/vtoolsplinepath.cpp | 16 ++- .../drawTools/toolcurve/vtoolsplinepath.h | 3 +- .../tooldoublepoint/vtooltruedarts.cpp | 105 +++--------------- .../tooldoublepoint/vtooltruedarts.h | 18 +-- .../toolsinglepoint/toolcut/vtoolcut.cpp | 19 ---- .../toolsinglepoint/toolcut/vtoolcut.h | 3 - .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 7 +- .../toolsinglepoint/toolcut/vtoolcutarc.h | 3 +- .../toolcut/vtoolcutspline.cpp | 7 +- .../toolsinglepoint/toolcut/vtoolcutspline.h | 3 +- .../toolcut/vtoolcutsplinepath.cpp | 7 +- .../toolcut/vtoolcutsplinepath.h | 3 +- .../toollinepoint/vtoolalongline.cpp | 27 ++--- .../toollinepoint/vtoolalongline.h | 5 +- .../toollinepoint/vtoolbisector.cpp | 47 ++------ .../toollinepoint/vtoolbisector.h | 9 +- .../toollinepoint/vtoolcurveintersectaxis.cpp | 27 ++--- .../toollinepoint/vtoolcurveintersectaxis.h | 6 +- .../toollinepoint/vtoolendline.cpp | 7 +- .../toollinepoint/vtoolendline.h | 3 +- .../toollinepoint/vtoolheight.cpp | 47 ++------ .../toollinepoint/vtoolheight.h | 9 +- .../toollinepoint/vtoollineintersectaxis.cpp | 47 ++------ .../toollinepoint/vtoollineintersectaxis.h | 9 +- .../toollinepoint/vtoollinepoint.cpp | 18 --- .../toollinepoint/vtoollinepoint.h | 3 - .../toollinepoint/vtoolnormal.cpp | 27 ++--- .../toollinepoint/vtoolnormal.h | 6 +- .../toollinepoint/vtoolshoulderpoint.cpp | 49 ++------ .../toollinepoint/vtoolshoulderpoint.h | 3 +- .../toolsinglepoint/vtoolbasepoint.cpp | 7 +- .../toolsinglepoint/vtoolbasepoint.h | 3 +- .../toolsinglepoint/vtoollineintersect.cpp | 85 ++------------ .../toolsinglepoint/vtoollineintersect.h | 15 +-- .../vtoolpointfromarcandtangent.cpp | 45 ++------ .../vtoolpointfromarcandtangent.h | 9 +- .../vtoolpointfromcircleandtangent.cpp | 45 ++------ .../vtoolpointfromcircleandtangent.h | 9 +- .../toolsinglepoint/vtoolpointofcontact.cpp | 53 ++------- .../toolsinglepoint/vtoolpointofcontact.h | 12 +- .../vtoolpointofintersection.cpp | 45 ++------ .../vtoolpointofintersection.h | 9 +- .../vtoolpointofintersectionarcs.cpp | 45 ++------ .../vtoolpointofintersectionarcs.h | 9 +- .../vtoolpointofintersectioncircles.cpp | 45 ++------ .../vtoolpointofintersectioncircles.h | 9 +- .../vtoolpointofintersectioncurves.cpp | 45 ++------ .../vtoolpointofintersectioncurves.h | 9 +- .../toolsinglepoint/vtooltriangle.cpp | 85 ++------------ .../toolpoint/toolsinglepoint/vtooltriangle.h | 3 +- src/libs/vtools/tools/drawTools/vdrawtool.cpp | 17 ++- src/libs/vtools/tools/drawTools/vdrawtool.h | 6 +- src/libs/vtools/tools/drawTools/vtoolline.cpp | 45 ++------ src/libs/vtools/tools/drawTools/vtoolline.h | 9 +- .../vtools/undocommands/savepieceoptions.cpp | 2 +- .../vtools/undocommands/savepieceoptions.h | 2 +- .../undocommands/savepiecepathoptions.h | 2 +- .../undocommands/saveplacelabeloptions.cpp | 34 ------ .../undocommands/saveplacelabeloptions.h | 5 - .../vtools/undocommands/savetooloptions.cpp | 43 +++---- .../vtools/undocommands/savetooloptions.h | 29 ++--- 83 files changed, 443 insertions(+), 1147 deletions(-) diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp index 8b8a29225..db4dd25eb 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp @@ -196,12 +196,16 @@ void VToolFlippingByAxis::SetVisualization() } //--------------------------------------------------------------------------------------------------------------------- -void VToolFlippingByAxis::SaveDialog(QDomElement &domElement) +void VToolFlippingByAxis::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + AddDependence(oldDependencies, m_originPointId); + AddDependence(newDependencies, dialogTool->GetOriginPointId()); + doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOriginPointId())); doc->SetAttribute(domElement, AttrAxisType, QString().setNum(static_cast(dialogTool->GetAxisType()))); doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); @@ -247,4 +251,3 @@ VToolFlippingByAxis::VToolFlippingByAxis(const VToolFlippingByAxisInitData &init InitOperatedObjects(); ToolCreation(initData.typeCreation); } - diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h index 7fd1ca617..2834a9693 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h @@ -70,7 +70,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void SetVisualization() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual QString MakeToolTip() const Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp index 3c07a36e2..c953fd890 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp @@ -181,12 +181,18 @@ void VToolFlippingByLine::SetVisualization() } //--------------------------------------------------------------------------------------------------------------------- -void VToolFlippingByLine::SaveDialog(QDomElement &domElement) +void VToolFlippingByLine::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + AddDependence(oldDependencies, m_firstLinePointId); + AddDependence(oldDependencies, m_secondLinePointId); + AddDependence(newDependencies, dialogTool->GetFirstLinePointId()); + AddDependence(newDependencies, dialogTool->GetSecondLinePointId()); + doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstLinePointId())); doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondLinePointId())); doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h index 5f9d04808..b4700f404 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h @@ -69,7 +69,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void SetVisualization() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual QString MakeToolTip() const Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp index 95e6b9d31..0cbd767d8 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp @@ -330,12 +330,15 @@ void VToolMove::SetVisualization() } //--------------------------------------------------------------------------------------------------------------------- -void VToolMove::SaveDialog(QDomElement &domElement) +void VToolMove::SaveDialog(QDomElement &domElement, QList &oldDependencies, QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + Q_UNUSED(oldDependencies); + Q_UNUSED(newDependencies) + doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); QString length = dialogTool->GetLength(); doc->SetAttribute(domElement, AttrLength, length); diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.h b/src/libs/vtools/tools/drawTools/operation/vtoolmove.h index 69d645583..939441197 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.h +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.h @@ -83,7 +83,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void SetVisualization() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual QString MakeToolTip() const Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp index 4867a50e0..cc451ebc5 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp @@ -332,12 +332,16 @@ void VToolRotation::SetVisualization() } //--------------------------------------------------------------------------------------------------------------------- -void VToolRotation::SaveDialog(QDomElement &domElement) +void VToolRotation::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + AddDependence(oldDependencies, origPointId); + AddDependence(newDependencies, dialogTool->GetOrigPointId()); + doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOrigPointId())); doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h index 98823f374..433a74a58 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h @@ -82,7 +82,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void SetVisualization() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual QString MakeToolTip() const Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp index b3d17518f..921c63211 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp @@ -47,6 +47,7 @@ #include "../vgeometry/vgobject.h" #include "../vgeometry/vpointf.h" #include "../vgeometry/vspline.h" +#include "../vgeometry/vabstractarc.h" #include "../vpatterndb/vcontainer.h" #include "../vwidgets/vcontrolpointspline.h" #include "../../../visualization/line/visline.h" @@ -453,3 +454,18 @@ void VAbstractSpline::GroupVisibility(quint32 object, bool visible) Q_UNUSED(object) setVisible(visible); } + +// VToolAbstractArc +//--------------------------------------------------------------------------------------------------------------------- +VToolAbstractArc::VToolAbstractArc(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent) + : VAbstractSpline(doc, data, id, parent) +{} + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolAbstractArc::CenterPointName() const +{ + QSharedPointer arc = VAbstractTool::data.GeometricObject(m_id); + SCASSERT(arc.isNull() == false) + + return VAbstractTool::data.GetGObject(arc->GetCenter().id())->name(); +} diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h index fd0598dad..a30258c4a 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h @@ -238,4 +238,15 @@ void VAbstractSpline::InitElArcToolConnections(VMainGraphicsScene *scene, T *too QObject::connect(scene, &VMainGraphicsScene::EnableElArcItemSelection, tool, &T::AllowSelecting); } +class VToolAbstractArc:public VAbstractSpline +{ +public: + VToolAbstractArc(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent = nullptr); + virtual ~VToolAbstractArc() = default; + + QString CenterPointName() const; +private: + Q_DISABLE_COPY(VToolAbstractArc) +}; + #endif // VABSTRACTSPLINE_H diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp index bfa5a6ee2..e62656edc 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp @@ -64,7 +64,7 @@ const QString VToolArc::ToolType = QStringLiteral("simple"); * @param initData init data */ VToolArc::VToolArc(const VToolArcInitData &initData, QGraphicsItem *parent) - : VAbstractSpline(initData.doc, initData.data, initData.id, parent) + : VToolAbstractArc(initData.doc, initData.data, initData.id, parent) { sceneType = SceneObject::Arc; @@ -183,35 +183,6 @@ QString VToolArc::getTagName() const return VAbstractPattern::TagArc; } -//--------------------------------------------------------------------------------------------------------------------- -QString VToolArc::CenterPointName() const -{ - return VAbstractTool::data.GetGObject(getCenter())->name(); -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolArc::getCenter() const -{ - QSharedPointer arc = VAbstractTool::data.GeometricObject(m_id); - SCASSERT(arc.isNull() == false) - - return arc->GetCenter().id(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolArc::setCenter(const quint32 &value) -{ - if (value != NULL_ID) - { - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - QSharedPointer arc = qSharedPointerDynamicCast(obj); - - QSharedPointer point = VAbstractTool::data.GeometricObject(value); - arc->SetCenter(*point.data()); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- VFormula VToolArc::GetFormulaRadius() const { @@ -350,11 +321,17 @@ void VToolArc::RemoveReferens() /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolArc::SaveDialog(QDomElement &domElement) +void VToolArc::SaveDialog(QDomElement &domElement, QList &oldDependencies, QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + QSharedPointer arc = VAbstractTool::data.GeometricObject(m_id); + SCASSERT(arc.isNull() == false) + AddDependence(oldDependencies, arc->GetCenter().id()); + AddDependence(newDependencies, dialogTool->GetCenter()); + doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetCenter())); doc->SetAttribute(domElement, AttrRadius, dialogTool->GetRadius()); doc->SetAttribute(domElement, AttrAngle1, dialogTool->GetF1()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h index cf8771645..47ca3002a 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h @@ -62,7 +62,7 @@ struct VToolArcInitData : VAbstractSplineInitData /** * @brief The VToolArc class tool for creation arc. */ -class VToolArc :public VAbstractSpline +class VToolArc :public VToolAbstractArc { Q_OBJECT public: @@ -76,11 +76,6 @@ public: enum { Type = UserType + static_cast(Tool::Arc)}; virtual QString getTagName() const Q_DECL_OVERRIDE; - QString CenterPointName() const; - - quint32 getCenter() const; - void setCenter(const quint32 &value); - VFormula GetFormulaRadius() const; void SetFormulaRadius(const VFormula &value); @@ -98,7 +93,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; virtual QString MakeToolTip() const Q_DECL_OVERRIDE; @@ -106,6 +102,7 @@ private: Q_DISABLE_COPY(VToolArc) VToolArc(const VToolArcInitData &initData, QGraphicsItem * parent = nullptr); + virtual ~VToolArc()=default; }; #endif // VTOOLARC_H diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp index dfd9effa0..82de192b7 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp @@ -60,7 +60,7 @@ const QString VToolArcWithLength::ToolType = QStringLiteral("arcWithLength"); //--------------------------------------------------------------------------------------------------------------------- VToolArcWithLength::VToolArcWithLength(const VToolArcWithLengthInitData &initData, QGraphicsItem *parent) - :VAbstractSpline(initData.doc, initData.data, initData.id, parent) + :VToolAbstractArc(initData.doc, initData.data, initData.id, parent) { sceneType = SceneObject::Arc; @@ -163,35 +163,6 @@ QString VToolArcWithLength::getTagName() const return VAbstractPattern::TagArc; } -//--------------------------------------------------------------------------------------------------------------------- -QString VToolArcWithLength::CenterPointName() const -{ - return VAbstractTool::data.GetGObject(getCenter())->name(); -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolArcWithLength::getCenter() const -{ - QSharedPointer arc = VAbstractTool::data.GeometricObject(m_id); - SCASSERT(arc.isNull() == false) - - return arc->GetCenter().id(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolArcWithLength::setCenter(const quint32 &value) -{ - if (value != NULL_ID) - { - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - QSharedPointer arc = qSharedPointerDynamicCast(obj); - - QSharedPointer point = VAbstractTool::data.GeometricObject(value); - arc->SetCenter(*point.data()); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- VFormula VToolArcWithLength::GetFormulaRadius() const { @@ -321,11 +292,18 @@ void VToolArcWithLength::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- -void VToolArcWithLength::SaveDialog(QDomElement &domElement) +void VToolArcWithLength::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + QSharedPointer arc = VAbstractTool::data.GeometricObject(m_id); + SCASSERT(arc.isNull() == false) + AddDependence(oldDependencies, arc->GetCenter().id()); + AddDependence(newDependencies, dialogTool->GetCenter()); + doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetCenter())); doc->SetAttribute(domElement, AttrRadius, dialogTool->GetRadius()); doc->SetAttribute(domElement, AttrAngle1, dialogTool->GetF1()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h index 2c931b4f2..f92c55b0d 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h @@ -59,7 +59,7 @@ struct VToolArcWithLengthInitData : VAbstractSplineInitData QString length; }; -class VToolArcWithLength : public VAbstractSpline +class VToolArcWithLength : public VToolAbstractArc { Q_OBJECT public: @@ -73,11 +73,6 @@ public: enum { Type = UserType + static_cast(Tool::ArcWithLength)}; virtual QString getTagName() const Q_DECL_OVERRIDE; - QString CenterPointName() const; - - quint32 getCenter() const; - void setCenter(const quint32 &value); - VFormula GetFormulaRadius() const; void SetFormulaRadius(const VFormula &value); @@ -95,7 +90,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; virtual QString MakeToolTip() const Q_DECL_OVERRIDE; @@ -103,6 +99,7 @@ private: Q_DISABLE_COPY(VToolArcWithLength) VToolArcWithLength(const VToolArcWithLengthInitData &initData, QGraphicsItem *parent = nullptr); + virtual ~VToolArcWithLength()=default; }; #endif // VTOOLARCWITHLENGTH_H diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp index cadcf64c5..1a06d8698 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp @@ -212,13 +212,24 @@ void VToolCubicBezier::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- -void VToolCubicBezier::SaveDialog(QDomElement &domElement) +void VToolCubicBezier::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) auto dialogTool = qobject_cast(m_dialog); SCASSERT(dialogTool != nullptr) + const auto oldSpl = VAbstractTool::data.GeometricObject(m_id); + AddDependence(oldDependencies, oldSpl->GetP1().id()); + AddDependence(oldDependencies, oldSpl->GetP2().id()); + AddDependence(oldDependencies, oldSpl->GetP3().id()); + AddDependence(oldDependencies, oldSpl->GetP4().id()); + const VCubicBezier spl = dialogTool->GetSpline(); + AddDependence(newDependencies, spl.GetP1().id()); + AddDependence(newDependencies, spl.GetP2().id()); + AddDependence(newDependencies, spl.GetP3().id()); + AddDependence(newDependencies, spl.GetP4().id()); SetSplineAttributes(domElement, spl); } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h index 7fea8ada7..a28113b37 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h @@ -84,7 +84,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void RefreshGeometry() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp index c4f6b4905..e4a97bda9 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp @@ -191,20 +191,33 @@ void VToolCubicBezierPath::ShowContextMenu(QGraphicsSceneContextMenuEvent *event void VToolCubicBezierPath::RemoveReferens() { const QSharedPointer splPath = VAbstractTool::data.GeometricObject(m_id); - for (qint32 i = 0; i < splPath->CountSubSpl(); ++i) + for (qint32 i = 0; i < splPath->CountPoints(); ++i) { doc->DecrementReferens(splPath->at(i).getIdTool()); } } //--------------------------------------------------------------------------------------------------------------------- -void VToolCubicBezierPath::SaveDialog(QDomElement &domElement) +void VToolCubicBezierPath::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) const auto dialogTool = qobject_cast(m_dialog); SCASSERT(dialogTool != nullptr) - SetSplinePathAttributes(domElement, dialogTool->GetPath()); + const auto oldSplPath = VAbstractTool::data.GeometricObject(m_id); + for (qint32 i = 0; i < oldSplPath->CountPoints(); ++i) + { + AddDependence(oldDependencies, oldSplPath->at(i).id()); + } + + const VCubicBezierPath splPath = dialogTool->GetPath(); + for (qint32 i = 0; i < splPath.CountPoints(); ++i) + { + AddDependence(newDependencies, splPath.at(i).id()); + } + + SetSplinePathAttributes(domElement, splPath); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h index c9cc6052f..572916fea 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h @@ -81,7 +81,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void RefreshGeometry() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp index b726124d1..8325f4aad 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp @@ -65,7 +65,7 @@ const QString VToolEllipticalArc::ToolType = QStringLiteral("simple"); * @param parent parent object */ VToolEllipticalArc::VToolEllipticalArc(const VToolEllipticalArcInitData &initData, QGraphicsItem *parent) - :VAbstractSpline(initData.doc, initData.data, initData.id, parent) + :VToolAbstractArc(initData.doc, initData.data, initData.id, parent) { sceneType = SceneObject::ElArc; @@ -190,35 +190,6 @@ QString VToolEllipticalArc::getTagName() const return VAbstractPattern::TagElArc; } -//--------------------------------------------------------------------------------------------------------------------- -QString VToolEllipticalArc::CenterPointName() const -{ - return VAbstractTool::data.GetGObject(getCenter())->name(); -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolEllipticalArc::getCenter() const -{ - QSharedPointer elArc = VAbstractTool::data.GeometricObject(m_id); - SCASSERT(elArc.isNull() == false) - - return elArc->GetCenter().id(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolEllipticalArc::setCenter(const quint32 &value) -{ - if (value != NULL_ID) - { - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - QSharedPointer elArc = qSharedPointerDynamicCast(obj); - - QSharedPointer point = VAbstractTool::data.GeometricObject(value); - elArc->SetCenter(*point.data()); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- VFormula VToolEllipticalArc::GetFormulaRadius1() const { @@ -392,11 +363,18 @@ void VToolEllipticalArc::RemoveReferens() /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolEllipticalArc::SaveDialog(QDomElement &domElement) +void VToolEllipticalArc::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + const auto elArc = VAbstractTool::data.GeometricObject(m_id); + SCASSERT(elArc.isNull() == false) + AddDependence(oldDependencies, elArc->GetCenter().id()); + AddDependence(newDependencies, dialogTool->GetCenter()); + doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetCenter())); doc->SetAttribute(domElement, AttrRadius1, dialogTool->GetRadius1()); doc->SetAttribute(domElement, AttrRadius2, dialogTool->GetRadius2()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h index 0a0f178db..f2c2bcf7d 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h @@ -66,7 +66,7 @@ struct VToolEllipticalArcInitData : VAbstractSplineInitData /** * @brief The VToolEllipticalArc class tool for creation elliptical arc. */ -class VToolEllipticalArc : public VAbstractSpline +class VToolEllipticalArc : public VToolAbstractArc { Q_OBJECT public: @@ -79,11 +79,6 @@ public: enum { Type = UserType + static_cast(Tool::EllipticalArc)}; virtual QString getTagName() const Q_DECL_OVERRIDE; - QString CenterPointName() const; - - quint32 getCenter() const; - void setCenter(const quint32 &value); - VFormula GetFormulaRadius1() const; void SetFormulaRadius1(const VFormula &value); @@ -104,7 +99,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; virtual QString MakeToolTip() const Q_DECL_OVERRIDE; @@ -112,6 +108,7 @@ protected: private: Q_DISABLE_COPY(VToolEllipticalArc) VToolEllipticalArc(const VToolEllipticalArcInitData &initData, QGraphicsItem *parent = nullptr); + virtual ~VToolEllipticalArc()=default; }; #endif // VTOOLELLIPTICALARC_H diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index c48698122..c860a5470 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -313,13 +313,19 @@ void VToolSpline::RemoveReferens() /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolSpline::SaveDialog(QDomElement &domElement) +void VToolSpline::SaveDialog(QDomElement &domElement, QList &oldDependencies, QList &newDependencies) { SCASSERT(not m_dialog.isNull()) auto dialogTool = qobject_cast(m_dialog); SCASSERT(dialogTool != nullptr) + const auto oldSpl = VAbstractTool::data.GeometricObject(m_id); + AddDependence(oldDependencies, oldSpl->GetP1().id()); + AddDependence(oldDependencies, oldSpl->GetP4().id()); + const VSpline spl = dialogTool->GetSpline(); + AddDependence(newDependencies, spl.GetP1().id()); + AddDependence(newDependencies, spl.GetP4().id()); controlPoints[0]->blockSignals(true); controlPoints[1]->blockSignals(true); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.h index 11080f827..9e2d12975 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.h @@ -97,7 +97,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void mousePressEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE; virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index c84bc50fe..d8009d57b 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -447,7 +447,7 @@ void VToolSplinePath::AddPathPoint(VAbstractPattern *doc, QDomElement &domElemen void VToolSplinePath::RemoveReferens() { const QSharedPointer splPath = VAbstractTool::data.GeometricObject(m_id); - for (qint32 i = 0; i < splPath->CountSubSpl(); ++i) + for (qint32 i = 0; i < splPath->CountPoints(); ++i) { doc->DecrementReferens(splPath->at(i).P().getIdTool()); } @@ -457,13 +457,25 @@ void VToolSplinePath::RemoveReferens() /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolSplinePath::SaveDialog(QDomElement &domElement) +void VToolSplinePath::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + const auto oldSplPath = VAbstractTool::data.GeometricObject(m_id); + for (qint32 i = 0; i < oldSplPath->CountPoints(); ++i) + { + AddDependence(oldDependencies, oldSplPath->at(i).P().id()); + } + const VSplinePath splPath = dialogTool->GetPath(); + for (qint32 i = 0; i < splPath.CountPoints(); ++i) + { + AddDependence(newDependencies, splPath.at(i).P().id()); + } + for (qint32 i = 1; i <= splPath.CountSubSpl(); ++i) { VSpline spl = splPath.GetSpline(i); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.h index 76420c2c2..fad103440 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.h @@ -108,7 +108,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void mousePressEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE; virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp index 8bbdd7f15..ee6a1e930 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp @@ -229,96 +229,6 @@ QString VToolTrueDarts::DartP3Name() const return VAbstractTool::data.GetGObject(dartP3Id)->name(); } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTrueDarts::GetBaseLineP1Id() const -{ - return baseLineP1Id; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolTrueDarts::SetBaseLineP1Id(const quint32 &value) -{ - if (value != NULL_ID) - { - baseLineP1Id = value; - - QSharedPointer obj = VContainer::GetFakeGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTrueDarts::GetBaseLineP2Id() const -{ - return baseLineP2Id; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolTrueDarts::SetBaseLineP2Id(const quint32 &value) -{ - if (value != NULL_ID) - { - baseLineP2Id = value; - - QSharedPointer obj = VContainer::GetFakeGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTrueDarts::GetDartP1Id() const -{ - return dartP1Id; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolTrueDarts::SetDartP1Id(const quint32 &value) -{ - if (value != NULL_ID) - { - dartP1Id = value; - - QSharedPointer obj = VContainer::GetFakeGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTrueDarts::GetDartP2Id() const -{ - return dartP2Id; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolTrueDarts::SetDartP2Id(const quint32 &value) -{ - if (value != NULL_ID) - { - dartP2Id = value; - - QSharedPointer obj = VContainer::GetFakeGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTrueDarts::GetDartP3Id() const -{ - return dartP3Id; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolTrueDarts::SetDartP3Id(const quint32 &value) -{ - if (value != NULL_ID) - { - dartP3Id = value; - - QSharedPointer obj = VContainer::GetFakeGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VToolTrueDarts::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id) { @@ -351,12 +261,25 @@ void VToolTrueDarts::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- -void VToolTrueDarts::SaveDialog(QDomElement &domElement) +void VToolTrueDarts::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + AddDependence(oldDependencies, baseLineP1Id); + AddDependence(oldDependencies, baseLineP2Id); + AddDependence(oldDependencies, dartP1Id); + AddDependence(oldDependencies, dartP2Id); + AddDependence(oldDependencies, dartP3Id); + + AddDependence(newDependencies, dialogTool->GetFirstBasePointId()); + AddDependence(newDependencies, dialogTool->GetSecondBasePointId()); + AddDependence(newDependencies, dialogTool->GetFirstDartPointId()); + AddDependence(newDependencies, dialogTool->GetSecondDartPointId()); + AddDependence(newDependencies, dialogTool->GetThirdDartPointId()); + doc->SetAttribute(domElement, AttrName1, dialogTool->GetFirstNewDartPointName()); doc->SetAttribute(domElement, AttrName2, dialogTool->GetSecondNewDartPointName()); doc->SetAttribute(domElement, AttrBaseLineP1, QString().setNum(dialogTool->GetFirstBasePointId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h index b55de4048..f3f17518d 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h @@ -104,26 +104,12 @@ public: QString DartP2Name() const; QString DartP3Name() const; - quint32 GetBaseLineP1Id() const; - void SetBaseLineP1Id(const quint32 &value); - - quint32 GetBaseLineP2Id() const; - void SetBaseLineP2Id(const quint32 &value); - - quint32 GetDartP1Id() const; - void SetDartP1Id(const quint32 &value); - - quint32 GetDartP2Id() const; - void SetDartP2Id(const quint32 &value); - - quint32 GetDartP3Id() const; - void SetDartP3Id(const quint32 &value); - protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp index bfe05e1e9..544a278ec 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp @@ -74,25 +74,6 @@ void VToolCut::FullUpdateFromFile() SetVisualization(); } -//--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress unusedFunction -quint32 VToolCut::getCurveCutId() const -{ - return curveCutId; -} - -//--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress unusedFunction -void VToolCut::setCurveCutId(const quint32 &value) -{ - if (value != NULL_ID) - { - curveCutId = value; - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- VFormula VToolCut::GetFormula() const { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h index 7331e4bad..d318b6155 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h @@ -59,9 +59,6 @@ public: QString CurveName() const; - quint32 getCurveCutId() const; - void setCurveCutId(const quint32 &value); - public slots: virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index b94219e27..c08ae727a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -195,11 +195,16 @@ void VToolCutArc::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolCutArc::SaveDialog(QDomElement &domElement) +void VToolCutArc::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, curveCutId); + AddDependence(newDependencies, dialogTool->getArcId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h index fc9a917c4..c800d892b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h @@ -73,7 +73,8 @@ public: protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index 1b1529706..d030552bf 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -194,11 +194,16 @@ void VToolCutSpline::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quin /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolCutSpline::SaveDialog(QDomElement &domElement) +void VToolCutSpline::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, curveCutId); + AddDependence(newDependencies, dialogTool->getSplineId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h index 4392598ed..e87a62b01 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h @@ -74,7 +74,8 @@ public: protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index 6682d0047..7835dbc6d 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -283,11 +283,16 @@ void VToolCutSplinePath::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolCutSplinePath::SaveDialog(QDomElement &domElement) +void VToolCutSplinePath::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, curveCutId); + AddDependence(newDependencies, dialogTool->getSplinePathId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h index fc5cfa293..74c9532c3 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h @@ -81,7 +81,8 @@ public: protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp index ac7262816..54a89c331 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp @@ -87,11 +87,18 @@ void VToolAlongLine::RemoveReferens() /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolAlongLine::SaveDialog(QDomElement &domElement) +void VToolAlongLine::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, basePointId); + AddDependence(oldDependencies, secondPointId); + AddDependence(newDependencies, dialogTool->GetFirstPointId()); + AddDependence(newDependencies, dialogTool->GetSecondPointId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); @@ -166,24 +173,6 @@ QString VToolAlongLine::MakeToolTip() const return toolTip; } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolAlongLine::GetSecondPointId() const -{ - return secondPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolAlongLine::SetSecondPointId(const quint32 &value) -{ - if (value != NULL_ID) - { - secondPointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VToolAlongLine::ShowVisualization(bool show) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h index 12fcda95f..28ee35785 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h @@ -74,14 +74,13 @@ public: QString SecondPointName() const; - quint32 GetSecondPointId() const; - void SetSecondPointId(const quint32 &value); virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp index a87b5df69..aefa8e91f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp @@ -240,11 +240,20 @@ void VToolBisector::RemoveReferens() /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolBisector::SaveDialog(QDomElement &domElement) +void VToolBisector::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, firstPointId); + AddDependence(oldDependencies, basePointId); + AddDependence(oldDependencies, thirdPointId); + AddDependence(newDependencies, dialogTool->GetFirstPointId()); + AddDependence(newDependencies, dialogTool->GetSecondPointId()); + AddDependence(newDependencies, dialogTool->GetThirdPointId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); @@ -294,24 +303,6 @@ void VToolBisector::SetVisualization() } } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolBisector::GetThirdPointId() const -{ - return thirdPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolBisector::SetThirdPointId(const quint32 &value) -{ - if (value != NULL_ID) - { - thirdPointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VToolBisector::ShowVisualization(bool show) { @@ -331,21 +322,3 @@ void VToolBisector::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint return;//Leave this method immediately!!! } } - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolBisector::GetFirstPointId() const -{ - return firstPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolBisector::SetFirstPointId(const quint32 &value) -{ - if (value != NULL_ID) - { - firstPointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h index 88f1b6178..503b4ed51 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h @@ -81,18 +81,13 @@ public: QString FirstPointName() const; QString ThirdPointName() const; - quint32 GetFirstPointId() const; - void SetFirstPointId(const quint32 &value); - - quint32 GetThirdPointId() const; - void SetThirdPointId(const quint32 &value); - virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index 1e80d4551..ab7be544b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -237,24 +237,6 @@ QString VToolCurveIntersectAxis::CurveName() const return VAbstractTool::data.GetGObject(curveId)->name(); } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolCurveIntersectAxis::getCurveId() const -{ - return curveId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolCurveIntersectAxis::setCurveId(const quint32 &value) -{ - if (value != NULL_ID) - { - curveId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VToolCurveIntersectAxis::ShowVisualization(bool show) { @@ -276,11 +258,18 @@ void VToolCurveIntersectAxis::ShowContextMenu(QGraphicsSceneContextMenuEvent *ev } //--------------------------------------------------------------------------------------------------------------------- -void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement) +void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, basePointId); + AddDependence(oldDependencies, curveId); + AddDependence(newDependencies, dialogTool->GetBasePointId()); + AddDependence(newDependencies, dialogTool->getCurveId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h index 1e17e0488..97a7343de 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h @@ -82,14 +82,12 @@ public: QString CurveName() const; - quint32 getCurveId() const; - void setCurveId(const quint32 &value); - virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp index 8721d0006..721698d32 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp @@ -174,11 +174,16 @@ VToolEndLine* VToolEndLine::Create(VToolEndLineInitData &initData) /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolEndLine::SaveDialog(QDomElement &domElement) +void VToolEndLine::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, basePointId); + AddDependence(newDependencies, dialogTool->GetBasePointId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h index 30219ab2b..d92848c07 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h @@ -80,7 +80,8 @@ public: protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp index 2a64a2989..a34c1c3c6 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp @@ -201,11 +201,20 @@ QString VToolHeight::SecondLinePointName() const /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolHeight::SaveDialog(QDomElement &domElement) +void VToolHeight::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, basePointId); + AddDependence(oldDependencies, p1LineId); + AddDependence(oldDependencies, p2LineId); + AddDependence(newDependencies, dialogTool->GetBasePointId()); + AddDependence(newDependencies, dialogTool->GetP1LineId()); + AddDependence(newDependencies, dialogTool->GetP2LineId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); @@ -284,24 +293,6 @@ QString VToolHeight::MakeToolTip() const return toolTip; } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolHeight::GetP2LineId() const -{ - return p2LineId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolHeight::SetP2LineId(const quint32 &value) -{ - if (value != NULL_ID) - { - p2LineId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VToolHeight::ShowVisualization(bool show) { @@ -321,21 +312,3 @@ void VToolHeight::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 return;//Leave this method immediately!!! } } - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolHeight::GetP1LineId() const -{ - return p1LineId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolHeight::SetP1LineId(const quint32 &value) -{ - if (value != NULL_ID) - { - p1LineId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h index ef0df2042..2062d20ef 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h @@ -78,17 +78,12 @@ public: QString FirstLinePointName() const; QString SecondLinePointName() const; - quint32 GetP1LineId() const; - void SetP1LineId(const quint32 &value); - - quint32 GetP2LineId() const; - void SetP2LineId(const quint32 &value); - virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index 39cc1c381..f85518caa 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -220,42 +220,6 @@ void VToolLineIntersectAxis::SetFormulaAngle(const VFormula &value) } } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLineIntersectAxis::GetFirstPointId() const -{ - return firstPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersectAxis::SetFirstPointId(const quint32 &value) -{ - if (value != NULL_ID) - { - firstPointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLineIntersectAxis::GetSecondPointId() const -{ - return secondPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersectAxis::SetSecondPointId(const quint32 &value) -{ - if (value != NULL_ID) - { - secondPointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VToolLineIntersectAxis::ShowVisualization(bool show) { @@ -277,11 +241,20 @@ void VToolLineIntersectAxis::ShowContextMenu(QGraphicsSceneContextMenuEvent *eve } //--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersectAxis::SaveDialog(QDomElement &domElement) +void VToolLineIntersectAxis::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, basePointId); + AddDependence(oldDependencies, firstPointId); + AddDependence(oldDependencies, secondPointId); + AddDependence(newDependencies, dialogTool->GetBasePointId()); + AddDependence(newDependencies, dialogTool->GetFirstPointId()); + AddDependence(newDependencies, dialogTool->GetSecondPointId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h index ff0623e88..f82a66a89 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h @@ -85,17 +85,12 @@ public: VFormula GetFormulaAngle() const; void SetFormulaAngle(const VFormula &value); - quint32 GetFirstPointId() const; - void SetFirstPointId(const quint32 &value); - - quint32 GetSecondPointId() const; - void SetSecondPointId(const quint32 &value); - virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp index 56e3dc604..e6518a109 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp @@ -213,24 +213,6 @@ void VToolLinePoint::SetLineColor(const QString &value) SaveOption(obj); } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLinePoint::GetBasePointId() const -{ - return basePointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolLinePoint::SetBasePointId(const quint32 &value) -{ - if (value != NULL_ID) - { - basePointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- VFormula VToolLinePoint::GetFormulaLength() const { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h index 1cb609769..d78947846 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h @@ -76,9 +76,6 @@ public: QString BasePointName() const; - quint32 GetBasePointId() const; - void SetBasePointId(const quint32 &value); - qreal GetAngle() const; void SetAngle(const qreal &value); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp index b7f8d5db1..2c948afb2 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp @@ -213,11 +213,18 @@ void VToolNormal::RemoveReferens() /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolNormal::SaveDialog(QDomElement &domElement) +void VToolNormal::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, basePointId); + AddDependence(oldDependencies, secondPointId); + AddDependence(newDependencies, dialogTool->GetFirstPointId()); + AddDependence(newDependencies, dialogTool->GetSecondPointId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); @@ -267,24 +274,6 @@ void VToolNormal::SetVisualization() } } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolNormal::GetSecondPointId() const -{ - return secondPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolNormal::SetSecondPointId(const quint32 &value) -{ - if (value != NULL_ID) - { - secondPointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VToolNormal::ShowVisualization(bool show) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h index d21679467..4dc0b8af9 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h @@ -79,15 +79,13 @@ public: QString SecondPointName() const; - quint32 GetSecondPointId() const; - void SetSecondPointId(const quint32 &value); - virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp index c68b0bd3b..908e26d53 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -258,11 +258,20 @@ void VToolShoulderPoint::RemoveReferens() /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolShoulderPoint::SaveDialog(QDomElement &domElement) +void VToolShoulderPoint::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, basePointId); + AddDependence(oldDependencies, p2Line); + AddDependence(oldDependencies, pShoulder); + AddDependence(newDependencies, dialogTool->GetP1Line()); + AddDependence(newDependencies, dialogTool->GetP2Line()); + AddDependence(newDependencies, dialogTool->GetP3()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); @@ -354,46 +363,8 @@ void VToolShoulderPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, } } -//--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress unusedFunction -quint32 VToolShoulderPoint::getPShoulder() const -{ - return pShoulder; -} - -//--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress unusedFunction -void VToolShoulderPoint::setPShoulder(const quint32 &value) -{ - if (value != NULL_ID) - { - pShoulder = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VToolShoulderPoint::ShowVisualization(bool show) { ShowToolVisualization(show); } - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolShoulderPoint::GetP2Line() const -{ - return p2Line; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolShoulderPoint::SetP2Line(const quint32 &value) -{ - if (value != NULL_ID) - { - p2Line = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h index 0d9aa9d20..fb6df7a8f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h @@ -90,7 +90,8 @@ public: virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp index 7c644b584..c603c019a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp @@ -285,11 +285,16 @@ void VToolBasePoint::DeleteToolWithConfirm(bool ask) /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolBasePoint::SaveDialog(QDomElement &domElement) +void VToolBasePoint::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + Q_UNUSED(oldDependencies) + Q_UNUSED(newDependencies) + const QPointF p = dialogTool->GetPoint(); const QString name = dialogTool->getPointName(); doc->SetAttribute(domElement, AttrName, name); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h index 21696ed9d..f0b25887d 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h @@ -90,7 +90,8 @@ protected: virtual void AddToFile() Q_DECL_OVERRIDE; virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE; virtual void DeleteToolWithConfirm(bool ask = true) Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index d881745df..d564de7b6 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -229,11 +229,22 @@ void VToolLineIntersect::RemoveReferens() /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolLineIntersect::SaveDialog(QDomElement &domElement) +void VToolLineIntersect::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, p1Line1); + AddDependence(oldDependencies, p2Line1); + AddDependence(oldDependencies, p1Line2); + AddDependence(oldDependencies, p2Line2); + AddDependence(newDependencies, dialogTool->GetP1Line1()); + AddDependence(newDependencies, dialogTool->GetP2Line1()); + AddDependence(newDependencies, dialogTool->GetP1Line2()); + AddDependence(newDependencies, dialogTool->GetP2Line2()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrP1Line1, QString().setNum(dialogTool->GetP1Line1())); doc->SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogTool->GetP2Line1())); @@ -313,24 +324,6 @@ QString VToolLineIntersect::MakeToolTip() const return toolTip; } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLineIntersect::GetP2Line2() const -{ - return p2Line2; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersect::SetP2Line2(const quint32 &value) -{ - if (value != NULL_ID) - { - p2Line2 = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VToolLineIntersect::ShowVisualization(bool show) { @@ -350,57 +343,3 @@ void VToolLineIntersect::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, return;//Leave this method immediately!!! } } - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLineIntersect::GetP1Line2() const -{ - return p1Line2; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersect::SetP1Line2(const quint32 &value) -{ - if (value != NULL_ID) - { - p1Line2 = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLineIntersect::GetP2Line1() const -{ - return p2Line1; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersect::SetP2Line1(const quint32 &value) -{ - if (value != NULL_ID) - { - p2Line1 = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLineIntersect::GetP1Line1() const -{ - return p1Line1; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersect::SetP1Line1(const quint32 &value) -{ - if (value != NULL_ID) - { - p1Line1 = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h index 7a4c29e86..8aabe7176 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h @@ -79,24 +79,13 @@ public: QString Line2P1Name() const; QString Line2P2Name() const; - quint32 GetP1Line1() const; - void SetP1Line1(const quint32 &value); - - quint32 GetP2Line1() const; - void SetP2Line1(const quint32 &value); - - quint32 GetP1Line2() const; - void SetP1Line2(const quint32 &value); - - quint32 GetP2Line2() const; - void SetP2Line2(const quint32 &value); - virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp index 4a43b1f02..39b520499 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp @@ -233,42 +233,6 @@ QString VToolPointFromArcAndTangent::ArcName() const return VAbstractTool::data.GetGObject(arcId)->name(); } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointFromArcAndTangent::GetTangentPointId() const -{ - return tangentPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointFromArcAndTangent::SetTangentPointId(const quint32 &value) -{ - if (value != NULL_ID) - { - tangentPointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointFromArcAndTangent::GetArcId() const -{ - return arcId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointFromArcAndTangent::SetArcId(const quint32 &value) -{ - if (value != NULL_ID) - { - arcId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- CrossCirclesPoint VToolPointFromArcAndTangent::GetCrossCirclesPoint() const { @@ -315,11 +279,18 @@ void VToolPointFromArcAndTangent::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- -void VToolPointFromArcAndTangent::SaveDialog(QDomElement &domElement) +void VToolPointFromArcAndTangent::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, arcId); + AddDependence(oldDependencies, tangentPointId); + AddDependence(newDependencies, dialogTool->GetArcId()); + AddDependence(newDependencies, dialogTool->GetTangentPointId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->GetArcId())); doc->SetAttribute(domElement, AttrTangent, QString().setNum(dialogTool->GetTangentPointId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h index 40d1bd5ca..7140011e8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h @@ -74,12 +74,6 @@ public: QString TangentPointName() const; QString ArcName() const; - quint32 GetTangentPointId() const; - void SetTangentPointId(const quint32 &value); - - quint32 GetArcId() const; - void SetArcId(const quint32 &value); - CrossCirclesPoint GetCrossCirclesPoint() const; void SetCrossCirclesPoint(const CrossCirclesPoint &value); @@ -88,7 +82,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp index 6fe946882..63c6d6d83 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp @@ -190,42 +190,6 @@ QString VToolPointFromCircleAndTangent::CircleCenterPointName() const return VAbstractTool::data.GetGObject(circleCenterId)->name(); } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointFromCircleAndTangent::GetTangentPointId() const -{ - return tangentPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointFromCircleAndTangent::SetTangentPointId(const quint32 &value) -{ - if (value != NULL_ID) - { - tangentPointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointFromCircleAndTangent::GetCircleCenterId() const -{ - return circleCenterId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointFromCircleAndTangent::SetCircleCenterId(const quint32 &value) -{ - if (value != NULL_ID) - { - circleCenterId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- VFormula VToolPointFromCircleAndTangent::GetCircleRadius() const { @@ -296,11 +260,18 @@ void VToolPointFromCircleAndTangent::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- -void VToolPointFromCircleAndTangent::SaveDialog(QDomElement &domElement) +void VToolPointFromCircleAndTangent::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, circleCenterId); + AddDependence(oldDependencies, tangentPointId); + AddDependence(newDependencies, dialogTool->GetTangentPointId()); + AddDependence(newDependencies, dialogTool->GetCircleCenterId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrCCenter, QString().setNum(dialogTool->GetCircleCenterId())); doc->SetAttribute(domElement, AttrTangent, QString().setNum(dialogTool->GetTangentPointId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h index c796701bc..73653bb8f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h @@ -77,12 +77,6 @@ public: QString TangentPointName() const; QString CircleCenterPointName() const; - quint32 GetTangentPointId() const; - void SetTangentPointId(const quint32 &value); - - quint32 GetCircleCenterId() const; - void SetCircleCenterId(const quint32 &value); - VFormula GetCircleRadius() const; void SetCircleRadius(const VFormula &value); @@ -94,7 +88,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index daf50b688..4a1383ab7 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -274,11 +274,20 @@ void VToolPointOfContact::RemoveReferens() /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolPointOfContact::SaveDialog(QDomElement &domElement) +void VToolPointOfContact::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, center); + AddDependence(oldDependencies, firstPointId); + AddDependence(oldDependencies, secondPointId); + AddDependence(newDependencies, dialogTool->getCenter()); + AddDependence(newDependencies, dialogTool->GetFirstPoint()); + AddDependence(newDependencies, dialogTool->GetSecondPoint()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrRadius, dialogTool->getRadius()); doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->getCenter())); @@ -356,18 +365,6 @@ QString VToolPointOfContact::MakeToolTip() const return toolTip; } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfContact::GetSecondPointId() const -{ - return secondPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfContact::SetSecondPointId(const quint32 &value) -{ - secondPointId = value; -} - //--------------------------------------------------------------------------------------------------------------------- void VToolPointOfContact::ShowVisualization(bool show) { @@ -388,36 +385,6 @@ void VToolPointOfContact::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, } } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfContact::GetFirstPointId() const -{ - return firstPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfContact::SetFirstPointId(const quint32 &value) -{ - firstPointId = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfContact::getCenter() const -{ - return center; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfContact::setCenter(const quint32 &value) -{ - if (value != NULL_ID) - { - center = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- VFormula VToolPointOfContact::getArcRadius() const { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h index 6dc2293e0..b2f13990b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h @@ -85,21 +85,13 @@ public: VFormula getArcRadius() const; void setArcRadius(const VFormula &value); - quint32 getCenter() const; - void setCenter(const quint32 &value); - - quint32 GetFirstPointId() const; - void SetFirstPointId(const quint32 &value); - - quint32 GetSecondPointId() const; - void SetSecondPointId(const quint32 &value); - virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp index ef8f44d27..4e3d619f6 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp @@ -189,11 +189,18 @@ void VToolPointOfIntersection::RemoveReferens() /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolPointOfIntersection::SaveDialog(QDomElement &domElement) +void VToolPointOfIntersection::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, firstPointId); + AddDependence(oldDependencies, secondPointId); + AddDependence(newDependencies, dialogTool->GetFirstPointId()); + AddDependence(newDependencies, dialogTool->GetSecondPointId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); @@ -244,44 +251,8 @@ void VToolPointOfIntersection::ShowContextMenu(QGraphicsSceneContextMenuEvent *e } } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfIntersection::GetSecondPointId() const -{ - return secondPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersection::SetSecondPointId(const quint32 &value) -{ - if (value != NULL_ID) - { - secondPointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VToolPointOfIntersection::ShowVisualization(bool show) { ShowToolVisualization(show); } - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfIntersection::GetFirstPointId() const -{ - return firstPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersection::SetFirstPointId(const quint32 &value) -{ - if (value != NULL_ID) - { - firstPointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h index 2ff809e34..39903c1ee 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h @@ -73,16 +73,11 @@ public: QString FirstPointName() const; QString SecondPointName() const; - quint32 GetFirstPointId() const; - void SetFirstPointId(const quint32 &value); - - quint32 GetSecondPointId() const; - void SetSecondPointId(const quint32 &value); - virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp index d097a5575..352706648 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp @@ -238,42 +238,6 @@ QString VToolPointOfIntersectionArcs::SecondArcName() const return VAbstractTool::data.GetGObject(secondArcId)->name(); } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfIntersectionArcs::GetFirstArcId() const -{ - return firstArcId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersectionArcs::SetFirstArcId(const quint32 &value) -{ - if (value != NULL_ID) - { - firstArcId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_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(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- CrossCirclesPoint VToolPointOfIntersectionArcs::GetCrossCirclesPoint() const { @@ -320,11 +284,18 @@ void VToolPointOfIntersectionArcs::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersectionArcs::SaveDialog(QDomElement &domElement) +void VToolPointOfIntersectionArcs::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, firstArcId); + AddDependence(oldDependencies, secondArcId); + AddDependence(newDependencies, dialogTool->GetFirstArcId()); + AddDependence(newDependencies, dialogTool->GetSecondArcId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrFirstArc, QString().setNum(dialogTool->GetFirstArcId())); doc->SetAttribute(domElement, AttrSecondArc, QString().setNum(dialogTool->GetSecondArcId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h index 488882dcc..6dcd8bbf9 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h @@ -75,12 +75,6 @@ public: QString FirstArcName() const; QString SecondArcName() const; - quint32 GetFirstArcId() const; - void SetFirstArcId(const quint32 &value); - - quint32 GetSecondArcId() const; - void SetSecondArcId(const quint32 &value); - CrossCirclesPoint GetCrossCirclesPoint() const; void SetCrossCirclesPoint(const CrossCirclesPoint &value); @@ -89,7 +83,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp index 423e62e92..96692caf0 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp @@ -196,42 +196,6 @@ QString VToolPointOfIntersectionCircles::SecondCircleCenterPointName() const return VAbstractTool::data.GetGObject(secondCircleCenterId)->name(); } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfIntersectionCircles::GetFirstCircleCenterId() const -{ - return firstCircleCenterId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersectionCircles::SetFirstCircleCenterId(const quint32 &value) -{ - if (value != NULL_ID) - { - firstCircleCenterId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfIntersectionCircles::GetSecondCircleCenterId() const -{ - return secondCircleCenterId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersectionCircles::SetSecondCircleCenterId(const quint32 &value) -{ - if (value != NULL_ID) - { - secondCircleCenterId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- VFormula VToolPointOfIntersectionCircles::GetFirstCircleRadius() const { @@ -326,12 +290,19 @@ void VToolPointOfIntersectionCircles::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersectionCircles::SaveDialog(QDomElement &domElement) +void VToolPointOfIntersectionCircles::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, firstCircleCenterId); + AddDependence(oldDependencies, secondCircleCenterId); + AddDependence(newDependencies, dialogTool->GetFirstCircleCenterId()); + AddDependence(newDependencies, dialogTool->GetSecondCircleCenterId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrC1Center, QString().setNum(dialogTool->GetFirstCircleCenterId())); doc->SetAttribute(domElement, AttrC2Center, QString().setNum(dialogTool->GetSecondCircleCenterId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h index 52090d637..db9720822 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h @@ -80,12 +80,6 @@ public: QString FirstCircleCenterPointName() const; QString SecondCircleCenterPointName() const; - quint32 GetFirstCircleCenterId() const; - void SetFirstCircleCenterId(const quint32 &value); - - quint32 GetSecondCircleCenterId() const; - void SetSecondCircleCenterId(const quint32 &value); - VFormula GetFirstCircleRadius() const; void SetFirstCircleRadius(const VFormula &value); @@ -100,7 +94,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp index 97eeb2273..49a6fa0cd 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -273,42 +273,6 @@ QString VToolPointOfIntersectionCurves::SecondCurveName() const return VAbstractTool::data.GetGObject(secondCurveId)->name(); } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfIntersectionCurves::GetFirstCurveId() const -{ - return firstCurveId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersectionCurves::SetFirstCurveId(const quint32 &value) -{ - if (value != NULL_ID) - { - firstCurveId = value; - - auto obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfIntersectionCurves::GetSecondCurveId() const -{ - return secondCurveId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersectionCurves::SetSecondCurveId(const quint32 &value) -{ - if (value != NULL_ID) - { - secondCurveId = value; - - auto obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- VCrossCurvesPoint VToolPointOfIntersectionCurves::GetVCrossPoint() const { @@ -370,11 +334,18 @@ void VToolPointOfIntersectionCurves::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersectionCurves::SaveDialog(QDomElement &domElement) +void VToolPointOfIntersectionCurves::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) auto dialogTool = qobject_cast(m_dialog); SCASSERT(dialogTool != nullptr) + + AddDependence(oldDependencies, firstCurveId); + AddDependence(oldDependencies, secondCurveId); + AddDependence(newDependencies, dialogTool->GetFirstCurveId()); + AddDependence(newDependencies, dialogTool->GetSecondCurveId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrCurve1, QString().setNum(dialogTool->GetFirstCurveId())); doc->SetAttribute(domElement, AttrCurve2, QString().setNum(dialogTool->GetSecondCurveId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h index 7c73e0799..8f5a3171d 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h @@ -78,12 +78,6 @@ public: QString FirstCurveName() const; QString SecondCurveName() const; - quint32 GetFirstCurveId() const; - void SetFirstCurveId(const quint32 &value); - - quint32 GetSecondCurveId() const; - void SetSecondCurveId(const quint32 &value); - VCrossCurvesPoint GetVCrossPoint() const; void SetVCrossPoint(const VCrossCurvesPoint &value); @@ -95,7 +89,8 @@ protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index 903c56f70..f857c6b10 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -265,11 +265,22 @@ void VToolTriangle::RemoveReferens() /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolTriangle::SaveDialog(QDomElement &domElement) +void VToolTriangle::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, axisP1Id); + AddDependence(oldDependencies, axisP2Id); + AddDependence(oldDependencies, firstPointId); + AddDependence(oldDependencies, secondPointId); + AddDependence(newDependencies, dialogTool->GetAxisP1Id()); + AddDependence(newDependencies, dialogTool->GetAxisP2Id()); + AddDependence(newDependencies, dialogTool->GetFirstPointId()); + AddDependence(newDependencies, dialogTool->GetSecondPointId()); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrAxisP1, QString().setNum(dialogTool->GetAxisP1Id())); doc->SetAttribute(domElement, AttrAxisP2, QString().setNum(dialogTool->GetAxisP2Id())); @@ -328,80 +339,8 @@ void VToolTriangle::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint } } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTriangle::GetSecondPointId() const -{ - return secondPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolTriangle::SetSecondPointId(const quint32 &value) -{ - if (value != NULL_ID) - { - secondPointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VToolTriangle::ShowVisualization(bool show) { ShowToolVisualization(show); } - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTriangle::GetFirstPointId() const -{ - return firstPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolTriangle::SetFirstPointId(const quint32 &value) -{ - if (value != NULL_ID) - { - firstPointId = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTriangle::GetAxisP2Id() const -{ - return axisP2Id; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolTriangle::SetAxisP2Id(const quint32 &value) -{ - if (value != NULL_ID) - { - axisP2Id = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTriangle::GetAxisP1Id() const -{ - return axisP1Id; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolTriangle::SetAxisP1Id(const quint32 &value) -{ - if (value != NULL_ID) - { - axisP1Id = value; - - QSharedPointer obj = VAbstractTool::data.GetGObject(m_id); - SaveOption(obj); - } -} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h index a0536201d..56079ce02 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h @@ -98,7 +98,8 @@ public: virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index 936eafd58..2a8c537ac 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -110,9 +110,12 @@ void VDrawTool::SaveDialogChange() if (oldDomElement.isElement()) { QDomElement newDomElement = oldDomElement.cloneNode().toElement(); - SaveDialog(newDomElement); + QList oldDependencies; + QList newDependencies; + SaveDialog(newDomElement, oldDependencies, newDependencies); - SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, m_id); + SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, oldDependencies, + newDependencies, doc, m_id); connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(saveOptions); } @@ -145,7 +148,8 @@ void VDrawTool::SaveOption(QSharedPointer &obj) SaveOptions(newDomElement, obj); - SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, m_id); + SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, QList(), + QList(), doc, m_id); connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(saveOptions); } @@ -229,6 +233,13 @@ void VDrawTool::AddToCalculation(const QDomElement &domElement) qApp->getUndoStack()->push(addToCal); } +//--------------------------------------------------------------------------------------------------------------------- +void VDrawTool::AddDependence(QList &list, quint32 objectId) const +{ + auto originPoint = VAbstractTool::data.GetGObject(objectId); + list.append(originPoint->getIdTool()); +} + //--------------------------------------------------------------------------------------------------------------------- QString VDrawTool::getLineType() const { diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index 8a37f6db8..370b86c5e 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -94,10 +94,12 @@ protected: /** @brief typeLine line type. */ QString m_lineType; - void AddToCalculation(const QDomElement &domElement); + void AddToCalculation(const QDomElement &domElement); + void AddDependence(QList &list, quint32 objectId) const; /** @brief SaveDialog save options into file after change in dialog. */ - virtual void SaveDialog(QDomElement &domElement)=0; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies)=0; virtual void SaveDialogChange() Q_DECL_FINAL; virtual void AddToFile() Q_DECL_OVERRIDE; void SaveOption(QSharedPointer &obj); diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index c054eca18..32bb0f93c 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -364,11 +364,18 @@ void VToolLine::keyReleaseEvent(QKeyEvent *event) /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolLine::SaveDialog(QDomElement &domElement) +void VToolLine::SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) { SCASSERT(not m_dialog.isNull()) QSharedPointer dialogTool = m_dialog.objectCast(); SCASSERT(not dialogTool.isNull()) + + AddDependence(oldDependencies, firstPoint); + AddDependence(oldDependencies, secondPoint); + AddDependence(newDependencies, dialogTool->GetFirstPoint()); + AddDependence(newDependencies, dialogTool->GetSecondPoint()); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPoint())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint())); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); @@ -430,24 +437,6 @@ QString VToolLine::MakeToolTip() const return toolTip; } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLine::GetSecondPoint() const -{ - return secondPoint; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolLine::SetSecondPoint(const quint32 &value) -{ - if (value != NULL_ID) - { - secondPoint = value; - - QSharedPointer obj;//We don't have object for line in data container. Just will send empty object. - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- void VToolLine::ShowVisualization(bool show) { @@ -504,24 +493,6 @@ void VToolLine::GroupVisibility(quint32 object, bool visible) setVisible(visible); } -//--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLine::GetFirstPoint() const -{ - return firstPoint; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolLine::SetFirstPoint(const quint32 &value) -{ - if (value != NULL_ID) - { - firstPoint = value; - - QSharedPointer obj;//We don't have object for line in data container. Just will send empty object. - SaveOption(obj); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief RefreshGeometry refresh item on scene. diff --git a/src/libs/vtools/tools/drawTools/vtoolline.h b/src/libs/vtools/tools/drawTools/vtoolline.h index c3cfd5b9e..7e829f4a0 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.h +++ b/src/libs/vtools/tools/drawTools/vtoolline.h @@ -83,12 +83,6 @@ public: QString FirstPointName() const; QString SecondPointName() const; - quint32 GetFirstPoint() const; - void SetFirstPoint(const quint32 &value); - - quint32 GetSecondPoint() const; - void SetSecondPoint(const quint32 &value); - QString GetLineColor() const; void SetLineColor(const QString &value); @@ -112,7 +106,8 @@ protected: virtual void RemoveReferens() Q_DECL_OVERRIDE; virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE; virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, + QList &newDependencies) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/savepieceoptions.cpp b/src/libs/vtools/undocommands/savepieceoptions.cpp index 91539cc5c..112b3f813 100644 --- a/src/libs/vtools/undocommands/savepieceoptions.cpp +++ b/src/libs/vtools/undocommands/savepieceoptions.cpp @@ -85,7 +85,7 @@ void SavePieceOptions::undo() DecrementReferences(m_newDet.MissingPins(m_oldDet)); IncrementReferences(m_oldDet.MissingPins(m_newDet)); - + DecrementReferences(m_newDet.MissingPlaceLabels(m_oldDet)); IncrementReferences(m_oldDet.MissingPlaceLabels(m_newDet)); diff --git a/src/libs/vtools/undocommands/savepieceoptions.h b/src/libs/vtools/undocommands/savepieceoptions.h index c940b1811..2654eb7e3 100644 --- a/src/libs/vtools/undocommands/savepieceoptions.h +++ b/src/libs/vtools/undocommands/savepieceoptions.h @@ -39,7 +39,7 @@ class SavePieceOptions : public VUndoCommand public: SavePieceOptions(const VPiece &oldDet, const VPiece &newDet, VAbstractPattern *doc, quint32 id, QUndoCommand *parent = nullptr); - virtual ~SavePieceOptions() =default; + virtual ~SavePieceOptions() = default; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/savepiecepathoptions.h b/src/libs/vtools/undocommands/savepiecepathoptions.h index cb336dc57..a458e35ea 100644 --- a/src/libs/vtools/undocommands/savepiecepathoptions.h +++ b/src/libs/vtools/undocommands/savepiecepathoptions.h @@ -39,7 +39,7 @@ class SavePiecePathOptions : public VUndoCommand public: SavePiecePathOptions(const VPiecePath &oldPath, const VPiecePath &newPath, VAbstractPattern *doc, VContainer *data, quint32 id, QUndoCommand *parent = nullptr); - virtual ~SavePiecePathOptions()=default; + virtual ~SavePiecePathOptions() = default; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/saveplacelabeloptions.cpp b/src/libs/vtools/undocommands/saveplacelabeloptions.cpp index 389ccbfab..4d95d8737 100644 --- a/src/libs/vtools/undocommands/saveplacelabeloptions.cpp +++ b/src/libs/vtools/undocommands/saveplacelabeloptions.cpp @@ -89,37 +89,3 @@ void SavePlaceLabelOptions::redo() qCDebug(vUndo, "Can't find path with id = %u.", nodeId); } } - -//--------------------------------------------------------------------------------------------------------------------- -bool SavePlaceLabelOptions::mergeWith(const QUndoCommand *command) -{ - const SavePlaceLabelOptions *saveCommand = static_cast(command); - SCASSERT(saveCommand != nullptr); - const quint32 id = saveCommand->LabelId(); - - if (id != nodeId) - { - return false; - } - - m_newLabel = saveCommand->NewLabel(); - return true; -} - -//--------------------------------------------------------------------------------------------------------------------- -int SavePlaceLabelOptions::id() const -{ - return static_cast(UndoCommand::SavePlaceLabelOptions); -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 SavePlaceLabelOptions::LabelId() const -{ - return nodeId; -} - -//--------------------------------------------------------------------------------------------------------------------- -VPlaceLabelItem SavePlaceLabelOptions::NewLabel() const -{ - return m_newLabel; -} diff --git a/src/libs/vtools/undocommands/saveplacelabeloptions.h b/src/libs/vtools/undocommands/saveplacelabeloptions.h index bb81bb355..a692816f9 100644 --- a/src/libs/vtools/undocommands/saveplacelabeloptions.h +++ b/src/libs/vtools/undocommands/saveplacelabeloptions.h @@ -40,11 +40,6 @@ public: virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; - virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE; - virtual int id() const Q_DECL_OVERRIDE; - - quint32 LabelId() const; - VPlaceLabelItem NewLabel() const; private: Q_DISABLE_COPY(SavePlaceLabelOptions) diff --git a/src/libs/vtools/undocommands/savetooloptions.cpp b/src/libs/vtools/undocommands/savetooloptions.cpp index 36f9a3e4b..a4629208b 100644 --- a/src/libs/vtools/undocommands/savetooloptions.cpp +++ b/src/libs/vtools/undocommands/savetooloptions.cpp @@ -36,18 +36,19 @@ #include "vundocommand.h" //--------------------------------------------------------------------------------------------------------------------- -SaveToolOptions::SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VAbstractPattern *doc, - const quint32 &id, QUndoCommand *parent) - : VUndoCommand(QDomElement(), doc, parent), oldXml(oldXml), newXml(newXml) +SaveToolOptions::SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, + const QList &oldDependencies, const QList &newDependencies, + VAbstractPattern *doc, const quint32 &id, QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), + oldXml(oldXml), + newXml(newXml), + oldDependencies(oldDependencies), + newDependencies(newDependencies) { setText(tr("save tool option")); nodeId = id; } -//--------------------------------------------------------------------------------------------------------------------- -SaveToolOptions::~SaveToolOptions() -{} - //--------------------------------------------------------------------------------------------------------------------- void SaveToolOptions::undo() { @@ -58,6 +59,9 @@ void SaveToolOptions::undo() { domElement.parentNode().replaceChild(oldXml, domElement); + DecrementReferences(Missing(newDependencies, oldDependencies)); + IncrementReferences(Missing(oldDependencies, newDependencies)); + emit NeedLiteParsing(Document::LiteParse); } else @@ -76,6 +80,9 @@ void SaveToolOptions::redo() { domElement.parentNode().replaceChild(newXml, domElement); + DecrementReferences(Missing(oldDependencies, newDependencies)); + IncrementReferences(Missing(newDependencies, oldDependencies)); + emit NeedLiteParsing(Document::LiteParse); } else @@ -85,23 +92,9 @@ void SaveToolOptions::redo() } //--------------------------------------------------------------------------------------------------------------------- -bool SaveToolOptions::mergeWith(const QUndoCommand *command) +QVector SaveToolOptions::Missing(const QList &list1, const QList &list2) const { - const SaveToolOptions *saveCommand = static_cast(command); - SCASSERT(saveCommand != nullptr) - const quint32 id = saveCommand->getToolId(); - - if (id != nodeId) - { - return false; - } - - newXml = saveCommand->getNewXml(); - return true; -} - -//--------------------------------------------------------------------------------------------------------------------- -int SaveToolOptions::id() const -{ - return static_cast(UndoCommand::SaveToolOptions); + QSet set1 = QSet::fromList(list1); + QSet set2 = QSet::fromList(list2); + return set1.subtract(set2).toList().toVector(); } diff --git a/src/libs/vtools/undocommands/savetooloptions.h b/src/libs/vtools/undocommands/savetooloptions.h index a8b6225c9..8235fc5c1 100644 --- a/src/libs/vtools/undocommands/savetooloptions.h +++ b/src/libs/vtools/undocommands/savetooloptions.h @@ -42,31 +42,20 @@ class SaveToolOptions : public VUndoCommand { Q_OBJECT public: - SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VAbstractPattern *doc, const quint32 &id, + SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, const QList &oldDependencies, + const QList &newDependencies, VAbstractPattern *doc, const quint32 &id, QUndoCommand *parent = nullptr); - virtual ~SaveToolOptions() Q_DECL_OVERRIDE; + virtual ~SaveToolOptions() = default; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; - virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE; - virtual int id() const Q_DECL_OVERRIDE; - QDomElement getNewXml() const; - quint32 getToolId() const; private: Q_DISABLE_COPY(SaveToolOptions) - const QDomElement oldXml; - QDomElement newXml; + const QDomElement oldXml; + const QDomElement newXml; + const QList oldDependencies; + const QList newDependencies; + + QVector Missing(const QList &list1, const QList &list2) const; }; -//--------------------------------------------------------------------------------------------------------------------- -inline QDomElement SaveToolOptions::getNewXml() const -{ - return newXml; -} - -//--------------------------------------------------------------------------------------------------------------------- -inline quint32 SaveToolOptions::getToolId() const -{ - return nodeId; -} - #endif // SAVETOOLOPTIONS_H From 2a3d52ba880608470a79efefdc08823716d93f95 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 21 Oct 2017 16:26:22 +0300 Subject: [PATCH 03/15] Improve scene point. Scale line to label and make the line more transparent. --HG-- branch : feature --- src/libs/vwidgets/vscenepoint.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/vwidgets/vscenepoint.cpp b/src/libs/vwidgets/vscenepoint.cpp index e51ccb5c9..ffb381f23 100644 --- a/src/libs/vwidgets/vscenepoint.cpp +++ b/src/libs/vwidgets/vscenepoint.cpp @@ -78,7 +78,9 @@ void VScenePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio m_namePoint->setVisible(m_showLabel); QPen lPen = m_lineName->pen(); - lPen.setColor(CorrectColor(m_lineName, Qt::black)); + QColor color = CorrectColor(m_lineName, Qt::black); + color.setAlpha(50); + lPen.setColor(color); m_lineName->setPen(lPen); RefreshLine(); @@ -148,7 +150,7 @@ void VScenePoint::RefreshLine() QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2); const QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); - if (QLineF(p1, pRec - scenePos()).length() <= ToPixel(4, Unit::Mm)) + if (QLineF(p1, pRec - scenePos()).length() <= ToPixel(4/qMax(1.0, SceneScale(scene())), Unit::Mm)) { m_lineName->setVisible(false); } From 660efa38448ee8ac8b8a421228e3c136d36b6957 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 23 Oct 2017 10:45:58 +0300 Subject: [PATCH 04/15] Fix bugs. * * * Fix tool union bugs. * * * Fix preparing pieces for layout. * * * Fix bug with formulas. --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 5 +- src/libs/ifc/ifcdef.cpp | 3 +- src/libs/ifc/ifcdef.h | 1 + src/libs/ifc/schema/pattern/v0.7.0.xsd | 9 ++ src/libs/vgeometry/vellipticalarc.cpp | 12 +- src/libs/vgeometry/vplacelabelitem.cpp | 2 +- src/libs/vlayout/vlayoutpiece.cpp | 4 +- src/libs/vpatterndb/vpiece.cpp | 28 ++++ src/libs/vpatterndb/vpiece.h | 1 + src/libs/vpatterndb/vpiecepath.cpp | 11 ++ src/libs/vpatterndb/vpiecepath.h | 1 + .../vtools/dialogs/tools/dialogplacelabel.cpp | 1 + .../vtools/dialogs/tools/dialogspline.cpp | 8 +- .../vtools/dialogs/tools/dialogsplinepath.cpp | 8 +- .../tools/piece/dialogseamallowance.cpp | 103 ++++++++----- .../dialogs/tools/piece/dialogseamallowance.h | 11 ++ .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 2 +- .../toolcut/vtoolcutspline.cpp | 2 +- .../toolcut/vtoolcutsplinepath.cpp | 2 +- src/libs/vtools/tools/drawTools/vdrawtool.cpp | 3 +- src/libs/vtools/tools/drawTools/vdrawtool.h | 2 +- .../tools/nodeDetails/vtoolplacelabel.cpp | 2 +- src/libs/vtools/tools/vinteractivetool.h | 6 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 39 +++-- src/libs/vtools/tools/vtoolseamallowance.h | 6 +- src/libs/vtools/tools/vtooluniondetails.cpp | 144 ++++++++++++++---- src/libs/vtools/tools/vtooluniondetails.h | 10 +- .../vtools/undocommands/savepieceoptions.cpp | 37 ++++- .../vtools/undocommands/savepieceoptions.h | 16 ++ .../undocommands/savepiecepathoptions.cpp | 51 ++++++- .../undocommands/savepiecepathoptions.h | 25 ++- .../undocommands/saveplacelabeloptions.cpp | 49 +++++- .../undocommands/saveplacelabeloptions.h | 28 +++- .../vtools/undocommands/savetooloptions.cpp | 28 ++++ .../vtools/undocommands/savetooloptions.h | 32 +++- .../line/operation/vistoolmove.cpp | 4 +- .../line/operation/vistoolrotation.cpp | 2 +- .../visualization/line/vistoolalongline.cpp | 2 +- .../visualization/line/vistoolbisector.cpp | 2 +- .../line/vistoolcurveintersectaxis.cpp | 2 +- .../visualization/line/vistoolendline.cpp | 4 +- .../line/vistoollineintersectaxis.cpp | 2 +- .../visualization/line/vistoolnormal.cpp | 2 +- .../line/vistoolpointfromcircleandtangent.cpp | 2 +- .../line/vistoolpointofcontact.cpp | 2 +- .../vistoolpointofintersectioncircles.cpp | 4 +- .../line/vistoolshoulderpoint.cpp | 2 +- .../vtools/visualization/path/vistoolarc.cpp | 6 +- .../path/vistoolarcwithlength.cpp | 6 +- .../visualization/path/vistoolcutarc.cpp | 2 +- .../visualization/path/vistoolcutspline.cpp | 2 +- .../path/vistoolcutsplinepath.cpp | 2 +- .../path/vistoolellipticalarc.cpp | 10 +- .../vtools/visualization/visualization.cpp | 16 +- src/libs/vtools/visualization/visualization.h | 6 +- 55 files changed, 615 insertions(+), 157 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 39608bafd..4f6387df2 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -850,7 +850,7 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse initData.width = GetParametrString(domElement, AttrWidth, "0.0"); const QString w = initData.width;//need for saving fixed formula; - const uint version = GetParametrUInt(domElement, VToolSeamAllowance::AttrVersion, "1"); + const uint version = GetParametrUInt(domElement, AttrVersion, "1"); const QStringList tags = QStringList() << TagNodes << TagData @@ -1721,7 +1721,7 @@ void VPattern::ParsePlaceLabel(QDomElement &domElement, const Document &parse) initData.centerPoint = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR); initData.idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR); - initData.width = GetParametrString(domElement, AttrLength, "1.0"); + initData.width = GetParametrString(domElement, AttrWidth, "1.0"); const QString w = initData.width;//need for saving fixed formula; initData.height = GetParametrString(domElement, AttrHeight, "1.0"); @@ -3550,6 +3550,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d VToolUnionDetailsInitData initData; initData.indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1"); initData.indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1"); + initData.version = GetParametrUInt(domElement, AttrVersion, "1"); initData.scene = scene; initData.doc = this; initData.data = data; diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index bd002fef8..7cf49e776 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -43,8 +43,6 @@ const QString CustomMSign = QStringLiteral("@"); const QString CustomIncrSign = QStringLiteral("#"); - - const QString AttrType = QStringLiteral("type"); const QString AttrMx = QStringLiteral("mx"); const QString AttrMy = QStringLiteral("my"); @@ -129,6 +127,7 @@ const QString AttrShowLabel2 = QStringLiteral("showLabel2"); const QString AttrWidth = QStringLiteral("width"); const QString AttrHeight = QStringLiteral("height"); const QString AttrPlaceLabelType = QStringLiteral("placeLabelType"); +const QString AttrVersion = QStringLiteral("version"); const QString TypeLineNone = QStringLiteral("none"); const QString TypeLineLine = QStringLiteral("hair"); diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index a14b930f7..9a1b95892 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -148,6 +148,7 @@ extern const QString AttrShowLabel2; extern const QString AttrWidth; extern const QString AttrHeight; extern const QString AttrPlaceLabelType; +extern const QString AttrVersion; extern const QString TypeLineNone; extern const QString TypeLineLine; diff --git a/src/libs/ifc/schema/pattern/v0.7.0.xsd b/src/libs/ifc/schema/pattern/v0.7.0.xsd index 2d716b4f7..970168e4f 100644 --- a/src/libs/ifc/schema/pattern/v0.7.0.xsd +++ b/src/libs/ifc/schema/pattern/v0.7.0.xsd @@ -548,6 +548,7 @@ + @@ -1030,4 +1031,12 @@ + + + + + + + + diff --git a/src/libs/vgeometry/vellipticalarc.cpp b/src/libs/vgeometry/vellipticalarc.cpp index 75f35f157..792f23abf 100644 --- a/src/libs/vgeometry/vellipticalarc.cpp +++ b/src/libs/vgeometry/vellipticalarc.cpp @@ -266,8 +266,16 @@ QVector VEllipticalArc::GetPoints() const path = t.map(path); - QPolygonF polygon = path.toSubpathPolygons().first(); - polygon.removeFirst(); // remove point (0;0) + QPolygonF polygon; + const QList sub = path.toSubpathPolygons(); + if (not sub.isEmpty()) + { + polygon = path.toSubpathPolygons().first(); + if (not polygon.isEmpty()) + { + polygon.removeFirst(); // remove point (0;0) + } + } return polygon; } diff --git a/src/libs/vgeometry/vplacelabelitem.cpp b/src/libs/vgeometry/vplacelabelitem.cpp index 3ced29e35..95eb9e65c 100644 --- a/src/libs/vgeometry/vplacelabelitem.cpp +++ b/src/libs/vgeometry/vplacelabelitem.cpp @@ -180,7 +180,7 @@ PlaceLabelImg VPlaceLabelItem::LabelShape(const VContainer *data) const QTransform t; t.translate(center->x(), center->y()); - t.rotate(-d->aValue+d->correctionAngle); + t.rotate(-(d->aValue+d->correctionAngle)); t.translate(-center->x(), -center->y()); auto SegmentShape = [center, t, this]() diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 4f9360c90..05280ec9c 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -350,8 +350,8 @@ QVector ConvertPlaceLabels(const VPiece &piece, const VContai { const auto label = pattern->GeometricObject(piece.GetPlaceLabels().at(i)); VLayoutPlaceLabel layoutLabel; - layoutLabel.shape = label->LabelShape(pattern); - layoutLabel.center = pattern->GeometricObject(label->GetCenterPoint())->toQPointF(); + layoutLabel.shape = label->LabelShape(); + layoutLabel.center = label->toQPointF(); layoutLabel.type = label->GetLabelType(); labels.append(layoutLabel); } diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index db76f5a6a..e01c1698b 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -662,6 +662,34 @@ void VPiece::SetPlaceLabels(const QVector &labels) d->m_placeLabels = labels; } +//--------------------------------------------------------------------------------------------------------------------- +QList VPiece::Dependencies() const +{ + QList list = d->m_path.Dependencies(); + + foreach (const CustomSARecord &record, d->m_customSARecords) + { + list.append(record.path); + } + + foreach (const quint32 &value, d->m_internalPaths) + { + list.append(value); + } + + foreach (const quint32 &value, d->m_pins) + { + list.append(value); + } + + foreach (const quint32 &value, d->m_placeLabels) + { + list.append(value); + } + + return list; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief MissingNodes find missing nodes in detail. When we deleted object in detail and return this detail need diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 07b4f865a..5c2d976bf 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -106,6 +106,7 @@ public: QVector &GetPlaceLabels(); void SetPlaceLabels(const QVector &labels); + QList Dependencies() const; QVector MissingNodes(const VPiece &det) const; QVector MissingCSAPath(const VPiece &det) const; QVector MissingInternalPaths(const VPiece &det) const; diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index 0ecf5d92d..1756552b2 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -435,6 +435,17 @@ VSAPoint VPiecePath::EndSegment(const VContainer *data, const QVector VPiecePath::Dependencies() const +{ + QList list; + foreach (const VPieceNode &node, d->m_nodes) + { + list.append(node.GetId()); + } + return list; +} + //--------------------------------------------------------------------------------------------------------------------- QVector VPiecePath::MissingNodes(const VPiecePath &path) const { diff --git a/src/libs/vpatterndb/vpiecepath.h b/src/libs/vpatterndb/vpiecepath.h index ae6cc0354..adaecb980 100644 --- a/src/libs/vpatterndb/vpiecepath.h +++ b/src/libs/vpatterndb/vpiecepath.h @@ -87,6 +87,7 @@ public: QPainterPath PainterPath(const VContainer *data) const; + QList Dependencies() const; QVector MissingNodes(const VPiecePath &path) const; int indexOfNode(quint32 id) const; diff --git a/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp b/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp index faf2bdcde..c0c331f33 100644 --- a/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp +++ b/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp @@ -112,6 +112,7 @@ void DialogPlaceLabel::EnbleShowMode(bool disable) { m_showMode = disable; ui->comboBoxPiece->setDisabled(m_showMode); + ui->comboBoxPoint->setDisabled(m_showMode); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogspline.cpp b/src/libs/vtools/dialogs/tools/dialogspline.cpp index 439a347d5..ff4d0cee8 100644 --- a/src/libs/vtools/dialogs/tools/dialogspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogspline.cpp @@ -457,10 +457,10 @@ VSpline DialogSpline::CurrentSpline() const const QHash > *vars = data->DataVariables(); - const qreal angle1 = Visualization::FindVal(angle1F, vars); - const qreal angle2 = Visualization::FindVal(angle2F, vars); - const qreal length1 = Visualization::FindLength(length1F, vars); - const qreal length2 = Visualization::FindLength(length2F, vars); + const qreal angle1 = Visualization::FindValFromUser(angle1F, vars); + const qreal angle2 = Visualization::FindValFromUser(angle2F, vars); + const qreal length1 = Visualization::FindLengthFromUser(length1F, vars); + const qreal length2 = Visualization::FindLengthFromUser(length2F, vars); const bool separator = qApp->Settings()->GetOsSeparator(); diff --git a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp index 5de20eff2..e614b1cb5 100644 --- a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp @@ -307,7 +307,7 @@ void DialogSplinePath::Angle1Changed() VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); const QString angle1F = ui->plainTextEditAngle1F->toPlainText().replace("\n", " "); - const qreal angle1 = Visualization::FindVal(angle1F, data->DataVariables()); + const qreal angle1 = Visualization::FindValFromUser(angle1F, data->DataVariables()); p.SetAngle1(angle1, VTranslateVars::TryFormulaFromUser(angle1F, qApp->Settings()->GetOsSeparator())); item->setData(Qt::UserRole, QVariant::fromValue(p)); @@ -341,7 +341,7 @@ void DialogSplinePath::Angle2Changed() VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); const QString angle2F = ui->plainTextEditAngle2F->toPlainText().replace("\n", " "); - const qreal angle2 = Visualization::FindVal(angle2F, data->DataVariables()); + const qreal angle2 = Visualization::FindValFromUser(angle2F, data->DataVariables()); p.SetAngle2(angle2, VTranslateVars::TryFormulaFromUser(angle2F, qApp->Settings()->GetOsSeparator())); item->setData(Qt::UserRole, QVariant::fromValue(p)); @@ -375,7 +375,7 @@ void DialogSplinePath::Length1Changed() VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); const QString length1F = ui->plainTextEditLength1F->toPlainText().replace("\n", " "); - const qreal length1 = Visualization::FindLength(length1F, data->DataVariables()); + const qreal length1 = Visualization::FindLengthFromUser(length1F, data->DataVariables()); p.SetLength1(length1, VTranslateVars::TryFormulaFromUser(length1F, qApp->Settings()->GetOsSeparator())); item->setData(Qt::UserRole, QVariant::fromValue(p)); @@ -400,7 +400,7 @@ void DialogSplinePath::Length2Changed() VSplinePoint p = qvariant_cast(item->data(Qt::UserRole)); const QString length2F = ui->plainTextEditLength2F->toPlainText().replace("\n", " "); - const qreal length2 = Visualization::FindLength(length2F, data->DataVariables()); + const qreal length2 = Visualization::FindLengthFromUser(length2F, data->DataVariables()); p.SetLength2(length2, VTranslateVars::TryFormulaFromUser(length2F, qApp->Settings()->GetOsSeparator())); item->setData(Qt::UserRole, QVariant::fromValue(p)); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index a1f830b2b..aaa567b9a 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -128,7 +128,10 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & m_timerWidthBefore(nullptr), m_timerWidthAfter(nullptr), m_saWidth(0), - m_templateLines() + m_templateLines(), + m_undoStack(), + m_newPlaceLabels(), + m_newPaths() { ui->setupUi(this); @@ -641,7 +644,7 @@ void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos) else if (selectedAction == actionOption) { auto *dialog = new DialogPiecePath(data, record.path, this); - dialog->SetPiecePath(data->GetPiecePath(record.path)); + dialog->SetPiecePath(CurrentPath(record.path)); dialog->SetPieceId(toolId); if (record.includeType == PiecePathIncludeType::AsMainPath) { @@ -681,7 +684,7 @@ void DialogSeamAllowance::ShowInternalPathsContextMenu(const QPoint &pos) const quint32 pathId = qvariant_cast(rowItem->data(Qt::UserRole)); auto *dialog = new DialogPiecePath(data, pathId, this); - dialog->SetPiecePath(data->GetPiecePath(pathId)); + dialog->SetPiecePath(CurrentPath(pathId)); dialog->SetPieceId(toolId); dialog->EnbleShowMode(true); m_dialog = dialog; @@ -726,26 +729,28 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos) QListWidgetItem *rowItem = uiTabPlaceLabels->listWidgetPlaceLabels->item(row); SCASSERT(rowItem != nullptr); const quint32 labelId = qvariant_cast(rowItem->data(Qt::UserRole)); - const auto label = data->GeometricObject(labelId); + VPlaceLabelItem currentLabel = CurrentPlaceLabel(labelId); QScopedPointer menu(new QMenu()); - auto InitAction = [&menu, label](const QString &text, PlaceLabelType type) + auto InitAction = [currentLabel, &menu](const QString &text, PlaceLabelType type) { QAction *action = menu->addAction(text); action->setCheckable(true); - action->setChecked(label->GetLabelType() == type); + action->setChecked(currentLabel.GetLabelType() == type); return action; }; - auto SaveType = [this, label, labelId](PlaceLabelType type) + auto SaveType = [this, currentLabel, labelId](PlaceLabelType type) { - VPlaceLabelItem newLabel = VPlaceLabelItem(*label); + VPlaceLabelItem newLabel = VPlaceLabelItem(currentLabel); newLabel.SetLabelType(type); + m_newPlaceLabels.insert(labelId, newLabel); - SavePlaceLabelOptions *saveCommand = new SavePlaceLabelOptions(*label, newLabel, qApp->getCurrentDocument(), + SavePlaceLabelOptions *saveCommand = new SavePlaceLabelOptions(toolId, currentLabel, newLabel, + qApp->getCurrentDocument(), const_cast(data), labelId); - qApp->getUndoStack()->push(saveCommand); + m_undoStack.append(saveCommand); UpdateCurrentPlaceLabelRecords(); }; @@ -772,11 +777,11 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos) else if (selectedAction == actionOption) { auto *dialog = new DialogPlaceLabel(data, labelId, this); - dialog->SetCenterPoint(label->GetCenterPoint()); - dialog->SetLabelType(label->GetLabelType()); - dialog->SetWidth(label->GetWidthFormula()); - dialog->SetHeight(label->GetHeightFormula()); - dialog->SetAngle(label->GetAngleFormula()); + dialog->SetCenterPoint(labelId); + dialog->SetLabelType(currentLabel.GetLabelType()); + dialog->SetWidth(currentLabel.GetWidthFormula()); + dialog->SetHeight(currentLabel.GetHeightFormula()); + dialog->SetAngle(currentLabel.GetAngleFormula()); dialog->SetPieceId(toolId); dialog->EnbleShowMode(true); m_dialog = dialog; @@ -1175,13 +1180,15 @@ void DialogSeamAllowance::PathDialogClosed(int result) SCASSERT(dialogTool != nullptr); try { - const VPiecePath newPath = dialogTool->GetPiecePath(); - const VPiecePath oldPath = data->GetPiecePath(dialogTool->GetToolId()); + VPiecePath currentPath = CurrentPath(dialogTool->GetToolId()); + VPiecePath newPath = dialogTool->GetPiecePath(); + m_newPaths.insert(dialogTool->GetToolId(), newPath); - SavePiecePathOptions *saveCommand = new SavePiecePathOptions(oldPath, newPath, qApp->getCurrentDocument(), + SavePiecePathOptions *saveCommand = new SavePiecePathOptions(toolId, currentPath, newPath, + qApp->getCurrentDocument(), const_cast(data), dialogTool->GetToolId()); - qApp->getUndoStack()->push(saveCommand); + m_undoStack.append(saveCommand); UpdateCurrentCustomSARecord(); UpdateCurrentInternalPathRecord(); } @@ -1204,34 +1211,35 @@ void DialogSeamAllowance::PlaceLabelDialogClosed(int result) SCASSERT(dialogTool != nullptr); try { - auto oldLabel = data->GeometricObject(dialogTool->GetToolId()); - - auto point = data->GeometricObject(dialogTool->GetCenterPoint()); + VPlaceLabelItem currentLabel = CurrentPlaceLabel(dialogTool->GetToolId()); const QHash > *vars = data->DataVariables(); - const qreal w = qAbs(Visualization::FindLength(dialogTool->GetWidth(), vars)); - const qreal h = qAbs(Visualization::FindLength(dialogTool->GetHeight(), vars)); - const qreal a = Visualization::FindVal(dialogTool->GetAngle(), vars); + const qreal w = qAbs(Visualization::FindLengthFromUser(dialogTool->GetWidth(), vars, false)); + const qreal h = qAbs(Visualization::FindLengthFromUser(dialogTool->GetHeight(), vars, false)); + const qreal a = Visualization::FindValFromUser(dialogTool->GetAngle(), vars, false); + qDebug() << w << h << a; - VPlaceLabelItem newLabel = VPlaceLabelItem(); - newLabel.setName(point->name()); - newLabel.setX(point->x()); - newLabel.setY(point->y()); - newLabel.setMx(point->mx()); - newLabel.setMy(point->my()); + VPlaceLabelItem newLabel = VPlaceLabelItem(); + newLabel.setName(currentLabel.name()); + newLabel.setX(currentLabel.x()); + newLabel.setY(currentLabel.y()); + newLabel.setMx(currentLabel.mx()); + newLabel.setMy(currentLabel.my()); newLabel.SetWidth(w, dialogTool->GetWidth()); newLabel.SetHeight(h, dialogTool->GetHeight()); newLabel.SetAngle(a, dialogTool->GetAngle()); newLabel.SetLabelType(dialogTool->GetLabelType()); - newLabel.SetCenterPoint(dialogTool->GetCenterPoint()); - newLabel.SetCorrectionAngle(oldLabel->GetCorrectionAngle()); + newLabel.SetCenterPoint(currentLabel.GetCenterPoint()); + newLabel.SetCorrectionAngle(currentLabel.GetCorrectionAngle()); - SavePlaceLabelOptions *saveCommand = new SavePlaceLabelOptions(*oldLabel, newLabel, + m_newPlaceLabels.insert(dialogTool->GetToolId(), newLabel); + + SavePlaceLabelOptions *saveCommand = new SavePlaceLabelOptions(toolId, currentLabel, newLabel, qApp->getCurrentDocument(), const_cast(data), dialogTool->GetToolId()); - qApp->getUndoStack()->push(saveCommand); + m_undoStack.append(saveCommand); UpdateCurrentPlaceLabelRecords(); } catch (const VExceptionBadId &e) @@ -2271,7 +2279,7 @@ QString DialogSeamAllowance::GetPathName(quint32 path, bool reverse) const if (path > NULL_ID) { - name = data->GetPiecePath(path).GetName(); + name = CurrentPath(path).GetName(); if (reverse) { @@ -2883,6 +2891,12 @@ QString DialogSeamAllowance::GetFormulaSAWidth() const return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator()); } +//--------------------------------------------------------------------------------------------------------------------- +QVector &DialogSeamAllowance::UndoStack() +{ + return m_undoStack; +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula) { @@ -2943,9 +2957,8 @@ void DialogSeamAllowance::UpdateCurrentPlaceLabelRecords() QListWidgetItem *item = uiTabPlaceLabels->listWidgetPlaceLabels->item(row); SCASSERT(item != nullptr); - const quint32 pointId = qvariant_cast(item->data(Qt::UserRole)); - auto point = data->GeometricObject(pointId); - item->setText(point->name()); + const quint32 labelId = qvariant_cast(item->data(Qt::UserRole)); + item->setText(CurrentPlaceLabel(labelId).name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -3131,3 +3144,15 @@ void DialogSeamAllowance::ShowPieceSpecialPoints(const QListWidget *list) m_visSpecialPoints->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +VPiecePath DialogSeamAllowance::CurrentPath(quint32 id) const +{ + return m_newPaths.contains(id) ? m_newPaths.value(id) : data->GetPiecePath(id); +} + +//--------------------------------------------------------------------------------------------------------------------- +VPlaceLabelItem DialogSeamAllowance::CurrentPlaceLabel(quint32 id) const +{ + return m_newPlaceLabels.contains(id) ? m_newPlaceLabels.value(id) : *data->GeometricObject(id); +} diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index ef2f2fb34..2e8883f99 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -48,6 +48,8 @@ namespace Ui class VisPieceSpecialPoints; class FancyTabBar; +class VPlaceLabelItem; +class QUndoCommand; class DialogSeamAllowance : public DialogTool { @@ -64,6 +66,8 @@ public: QString GetFormulaSAWidth() const; + QVector &UndoStack(); + public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; virtual void ShowDialog(bool click) Q_DECL_OVERRIDE; @@ -209,6 +213,10 @@ private: QVector m_templateLines; + QVector m_undoStack; + QHash m_newPlaceLabels; + QHash m_newPaths; + VPiece CreatePiece() const; void NewMainPathItem(const VPieceNode &node); @@ -261,6 +269,9 @@ private: void SetPLAngle(QString angleFormula); void ShowPieceSpecialPoints(const QListWidget *list); + + VPiecePath CurrentPath(quint32 id) const; + VPlaceLabelItem CurrentPlaceLabel(quint32 id) const; }; #endif // DIALOGSEAMALLOWANCE_H diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index c08ae727a..faf490820 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -251,7 +251,7 @@ QString VToolCutArc::MakeToolTip() const const QSharedPointer arc = VAbstractTool::data.GeometricObject(curveCutId); const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); - const qreal length = Visualization::FindVal(expression, VAbstractTool::data.DataVariables()); + const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); const QString arcStr = tr("Arc"); const QString lengthStr = tr("length"); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index d030552bf..91c4866b1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -250,7 +250,7 @@ QString VToolCutSpline::MakeToolTip() const const auto spl = VAbstractTool::data.GeometricObject(curveCutId); const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); - const qreal length = Visualization::FindVal(expression, VAbstractTool::data.DataVariables()); + const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); QPointF spl1p2, spl1p3, spl2p2, spl2p3; QPointF point = spl->CutSpline(qApp->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index 7835dbc6d..58e12eea6 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -339,7 +339,7 @@ QString VToolCutSplinePath::MakeToolTip() const const auto splPath = VAbstractTool::data.GeometricObject(curveCutId); const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); - const qreal length = Visualization::FindVal(expression, VAbstractTool::data.DataVariables()); + const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); VSplinePath *splPath1 = nullptr; VSplinePath *splPath2 = nullptr; diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index 2a8c537ac..96ba1f547 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -103,8 +103,9 @@ void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName) } //--------------------------------------------------------------------------------------------------------------------- -void VDrawTool::SaveDialogChange() +void VDrawTool::SaveDialogChange(const QString &undoText) { + Q_UNUSED(undoText) qCDebug(vTool, "Saving tool options after using dialog"); QDomElement oldDomElement = doc->elementById(m_id, getTagName()); if (oldDomElement.isElement()) diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index 370b86c5e..6f21f6f46 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -100,7 +100,7 @@ protected: /** @brief SaveDialog save options into file after change in dialog. */ virtual void SaveDialog(QDomElement &domElement, QList &oldDependencies, QList &newDependencies)=0; - virtual void SaveDialogChange() Q_DECL_FINAL; + virtual void SaveDialogChange(const QString &undoText = QString()) Q_DECL_FINAL; virtual void AddToFile() Q_DECL_OVERRIDE; void SaveOption(QSharedPointer &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); diff --git a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp index fe175bb20..0e99b2235 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp +++ b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp @@ -102,7 +102,7 @@ VToolPlaceLabel *VToolPlaceLabel::Create(VToolPlaceLabelInitData &initData) node->setMx(point->mx()); node->setMy(point->my()); - if (initData.typeCreation == Source::FromTool) + if (initData.idTool != NULL_ID) { QSharedPointer label = qSharedPointerDynamicCast(point); SCASSERT(label.isNull() == false) diff --git a/src/libs/vtools/tools/vinteractivetool.h b/src/libs/vtools/tools/vinteractivetool.h index 820f1d98a..d5d9a4da0 100644 --- a/src/libs/vtools/tools/vinteractivetool.h +++ b/src/libs/vtools/tools/vinteractivetool.h @@ -46,8 +46,8 @@ public: static bool m_suppressContextMenu; public slots: - void FullUpdateFromGuiOk(int result); - void FullUpdateFromGuiApply(); + virtual void FullUpdateFromGuiOk(int result); + virtual void FullUpdateFromGuiApply(); protected: /** @brief m_dialog tool's dialog options.*/ @@ -55,7 +55,7 @@ protected: /** @brief setDialog set dialog when user want change tool option. */ virtual void setDialog() {/*do nothing by default*/} - virtual void SaveDialogChange()=0; + virtual void SaveDialogChange(const QString &undoText = QString())=0; private: Q_DISABLE_COPY(VInteractiveTool) diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index d0937bcaa..d261adf37 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -71,7 +71,6 @@ const QString VToolSeamAllowance::TagIPaths = QStringLiteral("iPaths"); const QString VToolSeamAllowance::TagPins = QStringLiteral("pins"); const QString VToolSeamAllowance::TagPlaceLabels = QStringLiteral("placeLabels"); -const QString VToolSeamAllowance::AttrVersion = QStringLiteral("version"); const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping"); const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance"); const QString VToolSeamAllowance::AttrHideMainPath = QStringLiteral("hideMainPath"); @@ -900,6 +899,12 @@ QPainterPath VToolSeamAllowance::shape() const } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::FullUpdateFromGuiApply() +{ + SaveDialogChange(tr("apply save detail options")); +} + //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::AddToFile() { @@ -935,7 +940,7 @@ void VToolSeamAllowance::RefreshDataInFile() Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 4, 0), "Time to refactor the code."); - const uint version = doc->GetParametrUInt(domElement, VToolSeamAllowance::AttrVersion, "1"); + const uint version = doc->GetParametrUInt(domElement, AttrVersion, "1"); if (version == 1) { const VPiece piece = VAbstractTool::data.GetPiece(m_id); @@ -1221,10 +1226,6 @@ VToolSeamAllowance::VToolSeamAllowance(const VToolSeamAllowanceInitData &initDat connect(this, &VToolSeamAllowance::ChoosedTool, m_sceneDetails, &VMainGraphicsScene::ChoosedItem); ConnectOutsideSignals(); - - UpdateDetailLabel(); - UpdatePatternInfo(); - UpdateGrainline(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1302,7 +1303,7 @@ void VToolSeamAllowance::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VToolSeamAllowance::SaveDialogChange() +void VToolSeamAllowance::SaveDialogChange(const QString &undoText) { SCASSERT(not m_dialog.isNull()); DialogSeamAllowance *dialogTool = qobject_cast(m_dialog.data()); @@ -1310,8 +1311,28 @@ void VToolSeamAllowance::SaveDialogChange() const VPiece newDet = dialogTool->GetPiece(); const VPiece oldDet = VAbstractTool::data.GetPiece(m_id); - qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); - UpdateDetailLabel(); + QVector &undocommands = dialogTool->UndoStack(); + const bool groupChange = not undocommands.isEmpty(); + + SavePieceOptions *saveCommand = new SavePieceOptions(oldDet, newDet, doc, m_id); + + if (groupChange) + { + qApp->getUndoStack()->beginMacro(undoText.isEmpty() ? saveCommand->text(): undoText); + + foreach (QUndoCommand* command, undocommands) + { + qApp->getUndoStack()->push(command); + } + undocommands.clear(); + } + + qApp->getUndoStack()->push(saveCommand); + + if (groupChange) + { + qApp->getUndoStack()->endMacro(); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index d77f2a7cc..401c2971e 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -73,7 +73,6 @@ public: static const QString TagPins; static const QString TagPlaceLabels; - static const QString AttrVersion; static const QString AttrForbidFlipping; static const QString AttrSeamAllowance; static const QString AttrHideMainPath; @@ -106,6 +105,7 @@ public: void DisconnectOutsideSignals(); void ConnectOutsideSignals(); void ReinitInternals(const VPiece &detail, VMainGraphicsScene *scene); + void RefreshGeometry(); virtual int type() const Q_DECL_OVERRIDE {return Type;} enum { Type = UserType + static_cast(Tool::Piece)}; @@ -118,6 +118,7 @@ public: virtual QRectF boundingRect() const Q_DECL_OVERRIDE; virtual QPainterPath shape() const Q_DECL_OVERRIDE; public slots: + virtual void FullUpdateFromGuiApply() Q_DECL_OVERRIDE; virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; void EnableToolMove(bool move); virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; @@ -153,7 +154,7 @@ protected: virtual void DeleteToolWithConfirm(bool ask = true) Q_DECL_OVERRIDE; virtual void ToolCreation(const Source &typeCreation) Q_DECL_OVERRIDE; virtual void SetDialog() Q_DECL_FINAL; - virtual void SaveDialogChange() Q_DECL_FINAL; + virtual void SaveDialogChange(const QString &undoText = QString()) Q_DECL_FINAL; private: Q_DISABLE_COPY(VToolSeamAllowance) @@ -175,7 +176,6 @@ private: VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr); void UpdateExcludeState(); - void RefreshGeometry(); VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth, qreal &labelHeight, QPointF &pos); diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index 5885ba7af..8eb89fb0d 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -86,6 +86,9 @@ const QString VToolUnionDetails::AttrNodeType = QStringLiteral("nodeType"); const QString VToolUnionDetails::NodeTypeContour = QStringLiteral("Contour"); const QString VToolUnionDetails::NodeTypeModeling = QStringLiteral("Modeling"); +// Current version of union tag need for backward compatibility +const quint8 VToolUnionDetails::unionVersion = UNION_VERSSION; + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) @@ -232,6 +235,37 @@ QVector GetPiece2Pins(VAbstractPattern *doc, quint32 id) return QVector(); } +//--------------------------------------------------------------------------------------------------------------------- +QVector GetPiece2PlaceLabels(VAbstractPattern *doc, quint32 id) +{ + const QDomElement tool = doc->elementById(id, VAbstractPattern::TagTools); + if (tool.isNull()) + { + VException e(QString("Can't get tool by id='%1'.").arg(id)); + throw e; + } + + const QDomNodeList nodesList = tool.childNodes(); + for (qint32 i = 0; i < nodesList.size(); ++i) + { + const QDomElement element = nodesList.at(i).toElement(); + if (not element.isNull() && element.tagName() == VToolUnionDetails::TagDetail && i+1 == 2) + { + const QDomNodeList detList = element.childNodes(); + for (qint32 j = 0; j < detList.size(); ++j) + { + const QDomElement element = detList.at(j).toElement(); + if (not element.isNull() && element.tagName() == VToolSeamAllowance::TagPlaceLabels) + { + return VAbstractPattern::ParsePiecePointRecords(element); + } + } + } + } + + return QVector(); +} + //--------------------------------------------------------------------------------------------------------------------- QString DrawName(VAbstractPattern *doc, quint32 d1id, quint32 d2id) { @@ -390,6 +424,7 @@ quint32 AddNodePoint(const VPieceNode &node, const VToolUnionDetailsInitData &in initNodeData.typeCreation = Source::FromTool; initNodeData.idTool = initData.id; initNodeData.drawName = drawName; + initNodeData.scene = initData.scene; VNodePoint::Create(initNodeData); return id; @@ -443,15 +478,8 @@ quint32 AddPlaceLabel(quint32 id, const VToolUnionDetailsInitData &initData, QVe } label->SetCorrectionAngle(label->GetCorrectionAngle() + angle); - QScopedPointer label1(new VPlaceLabelItem(*label)); - - const quint32 idObject = initData.data->AddGObject(label.take()); - children.append(idObject); - const quint32 idLabel = initData.data->AddGObject(label1.take()); VToolPlaceLabelInitData initNodeData; - initNodeData.id = idLabel; - initNodeData.centerPoint = idObject; initNodeData.idObject = NULL_ID; initNodeData.doc = initData.doc; initNodeData.data = initData.data; @@ -459,6 +487,18 @@ quint32 AddPlaceLabel(quint32 id, const VToolUnionDetailsInitData &initData, QVe initNodeData.typeCreation = Source::FromTool; initNodeData.idTool = initData.id; initNodeData.drawName = drawName; + initNodeData.width = label->GetWidthFormula(); + initNodeData.height = label->GetHeightFormula(); + initNodeData.angle = label->GetAngleFormula(); + initNodeData.type = label->GetLabelType(); + + QScopedPointer label1(new VPlaceLabelItem(*label)); + + initNodeData.centerPoint = initData.data->AddGObject(label.take()); + children.append(initNodeData.centerPoint); + + const quint32 idLabel = initData.data->AddGObject(label1.take()); + initNodeData.id = idLabel; VToolPlaceLabel::Create(initNodeData); return idLabel; @@ -1148,7 +1188,14 @@ void CreateUnitedDetailCSA(VPiece &newDetail, const VPiece &d, QVector VToolPiecePath::Create(initNodeData); record.path = idPath; newDetail.GetCustomSARecords().append(record); - nodeChildren.prepend(idPath); + + if (initData.version == 1) + { + // TODO. Delete if minimal supported version is 0.7.0 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 0), + "Time to refactor the code."); + nodeChildren.prepend(idPath); + } } children += nodeChildren; } @@ -1199,7 +1246,14 @@ void CreateUnitedDetailInternalPaths(VPiece &newDetail, const VPiece &d, QVector VToolPiecePath::Create(initNodeData); newDetail.GetInternalPaths().append(idPath); - nodeChildren.prepend(idPath); + + if (initData.version == 1) + { + // TODO. Delete if minimal supported version is 0.7.0 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 0), + "Time to refactor the code."); + nodeChildren.prepend(idPath); + } } children += nodeChildren; } @@ -1230,7 +1284,6 @@ void CreateUnitedDetailPins(VPiece &newDetail, const VPiece &d, QVector { const quint32 id = AddPin(d.GetPins().at(i), initData, children, drawName, dx, dy, pRotate, angle); newDetail.GetPins().append(id); - nodeChildren.prepend(id); } children += nodeChildren; } @@ -1246,7 +1299,6 @@ void CreateUnitedDetailPlaceLabels(VPiece &newDetail, const VPiece &d, QVectorGetPiecePath(records.at(i)); - const quint32 updatedId = TakeNextId(children); - VPiecePath updatedPath(path); - updatedPath.Clear(); - - for (int j=0; j < path.CountNodes(); ++j) + if (initData.version == 1) { - const VPieceNode &node = path.at(j); - const quint32 id = TakeNextId(children); - updatedPath.Append(VPieceNode(id, node.GetTypeTool(), node.GetReverse())); - QVector nodeChildren = {id}; - UpdatePathNode(initData.data, path.at(j), nodeChildren, dx, dy, pRotate, angle); + // TODO. Delete if minimal supported version is 0.7.0 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 0), + "Time to refactor the code."); + const quint32 updatedId = TakeNextId(children); + + VPiecePath updatedPath(path); + updatedPath.Clear(); + + for (int j=0; j < path.CountNodes(); ++j) + { + const VPieceNode &node = path.at(j); + const quint32 id = TakeNextId(children); + updatedPath.Append(VPieceNode(id, node.GetTypeTool(), node.GetReverse())); + QVector nodeChildren = {id}; + UpdatePathNode(initData.data, path.at(j), nodeChildren, dx, dy, pRotate, angle); + } + initData.data->UpdatePiecePath(updatedId, updatedPath); + } + else + { + + for (int j=0; j < path.CountNodes(); ++j) + { + const quint32 id = TakeNextId(children); + QVector nodeChildren = {id}; + UpdatePathNode(initData.data, path.at(j), nodeChildren, dx, dy, pRotate, angle); + } } - initData.data->UpdatePiecePath(updatedId, updatedPath); } } @@ -1415,14 +1484,20 @@ void UpdateUnitedDetailPlaceLabels(const VToolUnionDetailsInitData &initData, qr for (int i = 0; i < records.size(); ++i) { - QScopedPointer - label(new VPlaceLabelItem(*initData.data->GeometricObject(records.at(i)))); + QSharedPointer parentLabel = initData.data->GeometricObject(records.at(i)); if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) { - BiasRotatePoint(label.data(), dx, dy, + BiasRotatePoint(parentLabel.data(), dx, dy, static_cast(*initData.data->GeometricObject(pRotate)), angle); } - label->SetCorrectionAngle(label->GetCorrectionAngle()+angle); + QScopedPointer label(new VPlaceLabelItem()); + label->setName(parentLabel->name()); + label->setX(parentLabel->x()); + label->setY(parentLabel->y()); + label->setMx(parentLabel->mx()); + label->setMy(parentLabel->my()); + + label->SetCorrectionAngle(parentLabel->GetCorrectionAngle()+angle); initData.data->UpdateGObject(TakeNextId(children), label.take()); } } @@ -1486,7 +1561,7 @@ void UpdateUnitedDetail(const VToolUnionDetailsInitData &initData, qreal dx, qre UpdateUnitedDetailInternalPaths(initData, dx, dy, pRotate, angle, GetPiece2InternalPaths(initData.doc, initData.id)); UpdateUnitedDetailPins(initData, dx, dy, pRotate, angle, GetPiece2Pins(initData.doc, initData.id)); - UpdateUnitedDetailPlaceLabels(initData, dx, dy, pRotate, angle, GetPiece2Pins(initData.doc, initData.id)); + UpdateUnitedDetailPlaceLabels(initData, dx, dy, pRotate, angle, GetPiece2PlaceLabels(initData.doc, initData.id)); } //--------------------------------------------------------------------------------------------------------------------- @@ -1525,7 +1600,8 @@ VToolUnionDetails::VToolUnionDetails(const VToolUnionDetailsInitData &initData, d1id(initData.d1id), d2id(initData.d2id), indexD1(initData.indexD1), - indexD2(initData.indexD2) + indexD2(initData.indexD2), + version(initData.version) { _referens = 0; ToolCreation(initData.typeCreation); @@ -1668,6 +1744,7 @@ void VToolUnionDetails::AddToFile() doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrIndexD1, indexD1); doc->SetAttribute(domElement, AttrIndexD2, indexD2); + doc->SetAttribute(domElement, AttrVersion, unionVersion); AddDetail(domElement, data.GetPiece(d1id)); AddDetail(domElement, data.GetPiece(d2id)); @@ -1691,6 +1768,7 @@ void VToolUnionDetails::AddDetail(QDomElement &domElement, const VPiece &d) cons VToolSeamAllowance::AddCSARecords(doc, det, d.GetCustomSARecords()); VToolSeamAllowance::AddInternalPaths(doc, det, d.GetInternalPaths()); VToolSeamAllowance::AddPins(doc, det, d.GetPins()); + VToolSeamAllowance::AddPlaceLabels(doc, det, d.GetPlaceLabels()); domElement.appendChild(det); } @@ -1726,10 +1804,11 @@ QVector VToolUnionDetails::GetReferenceObjects() const return list; } - const QStringList parts = QStringList() << VAbstractPattern::TagNodes /*0*/ - << VToolSeamAllowance::TagCSA /*1*/ - << VToolSeamAllowance::TagIPaths /*2*/ - << VToolSeamAllowance::TagPins; /*3*/ + const QStringList parts = QStringList() << VAbstractPattern::TagNodes /*0*/ + << VToolSeamAllowance::TagCSA /*1*/ + << VToolSeamAllowance::TagIPaths /*2*/ + << VToolSeamAllowance::TagPins /*3*/ + << VToolSeamAllowance::TagPlaceLabels; /*4*/ const QDomNodeList nodesList = tool.childNodes(); for (qint32 i = 0; i < nodesList.size(); ++i) @@ -1754,6 +1833,7 @@ QVector VToolUnionDetails::GetReferenceObjects() const VAbstractPattern::AttrPath); break; case 3://VToolSeamAllowance::TagPins + case 4://VToolSeamAllowance::TagPlaceLabels { const QDomNodeList children = element.childNodes(); for (qint32 i = 0; i < children.size(); ++i) diff --git a/src/libs/vtools/tools/vtooluniondetails.h b/src/libs/vtools/tools/vtooluniondetails.h index 964415e15..63c1e9bf3 100644 --- a/src/libs/vtools/tools/vtooluniondetails.h +++ b/src/libs/vtools/tools/vtooluniondetails.h @@ -47,6 +47,8 @@ class DialogTool; +#define UNION_VERSSION 2 + struct VToolUnionDetailsInitData : VAbstractToolInitData { VToolUnionDetailsInitData() @@ -55,7 +57,8 @@ struct VToolUnionDetailsInitData : VAbstractToolInitData d2id(NULL_ID), indexD1(NULL_ID), indexD2(NULL_ID), - retainPieces(false) + retainPieces(false), + version(UNION_VERSSION) {} quint32 d1id; @@ -63,6 +66,7 @@ struct VToolUnionDetailsInitData : VAbstractToolInitData quint32 indexD1; quint32 indexD2; bool retainPieces; + uint version; }; /** @@ -88,6 +92,8 @@ public: static const QString NodeTypeContour; static const QString NodeTypeModeling; + static const quint8 unionVersion; + virtual QString getTagName() const Q_DECL_OVERRIDE; virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; virtual void incrementReferens() Q_DECL_OVERRIDE; @@ -120,6 +126,8 @@ private: /** @brief indexD2 index edge in second detail. */ quint32 indexD2; + uint version; + VToolUnionDetails(const VToolUnionDetailsInitData &initData, QObject *parent = nullptr); void AddDetail(QDomElement &domElement, const VPiece &d) const; diff --git a/src/libs/vtools/undocommands/savepieceoptions.cpp b/src/libs/vtools/undocommands/savepieceoptions.cpp index 112b3f813..b525a86ee 100644 --- a/src/libs/vtools/undocommands/savepieceoptions.cpp +++ b/src/libs/vtools/undocommands/savepieceoptions.cpp @@ -51,7 +51,7 @@ SavePieceOptions::SavePieceOptions(const VPiece &oldDet, const VPiece &newDet, V m_oldDet(oldDet), m_newDet(newDet) { - setText(tr("save detail option")); + setText(tr("save detail options")); nodeId = id; } @@ -144,3 +144,38 @@ void SavePieceOptions::redo() qCDebug(vUndo, "Can't find detail with id = %u.", nodeId); } } + +//--------------------------------------------------------------------------------------------------------------------- +bool SavePieceOptions::mergeWith(const QUndoCommand *command) +{ + const SavePieceOptions *saveCommand = static_cast(command); + SCASSERT(saveCommand != nullptr); + + if (saveCommand->DetId() != nodeId) + { + return false; + } + else + { + const QSet currentSet; + currentSet.fromList(m_newDet.Dependencies()); + + const VPiece candidate = saveCommand->NewDet(); + const QSet candidateSet; + candidateSet.fromList(candidate.Dependencies()); + + if (currentSet != candidateSet) + { + return false; + } + } + + m_newDet = saveCommand->NewDet(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int SavePieceOptions::id() const +{ + return static_cast(UndoCommand::SavePieceOptions); +} diff --git a/src/libs/vtools/undocommands/savepieceoptions.h b/src/libs/vtools/undocommands/savepieceoptions.h index 2654eb7e3..3bf80ed7c 100644 --- a/src/libs/vtools/undocommands/savepieceoptions.h +++ b/src/libs/vtools/undocommands/savepieceoptions.h @@ -43,6 +43,10 @@ public: virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; + virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE; + virtual int id() const Q_DECL_OVERRIDE; + quint32 DetId() const; + VPiece NewDet() const; private: Q_DISABLE_COPY(SavePieceOptions) @@ -50,4 +54,16 @@ private: VPiece m_newDet; }; +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 SavePieceOptions::DetId() const +{ + return nodeId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VPiece SavePieceOptions::NewDet() const +{ + return m_newDet; +} + #endif // SAVEPIECEOPTIONS_H diff --git a/src/libs/vtools/undocommands/savepiecepathoptions.cpp b/src/libs/vtools/undocommands/savepiecepathoptions.cpp index a7968c9b9..2cd26a408 100644 --- a/src/libs/vtools/undocommands/savepiecepathoptions.cpp +++ b/src/libs/vtools/undocommands/savepiecepathoptions.cpp @@ -35,15 +35,17 @@ #include "../ifc/xml/vabstractpattern.h" #include "../vmisc/logging.h" #include "../tools/nodeDetails/vtoolpiecepath.h" +#include "../tools/vtoolseamallowance.h" //--------------------------------------------------------------------------------------------------------------------- -SavePiecePathOptions::SavePiecePathOptions(const VPiecePath &oldPath, const VPiecePath &newPath, +SavePiecePathOptions::SavePiecePathOptions(quint32 pieceId, const VPiecePath &oldPath, const VPiecePath &newPath, VAbstractPattern *doc, VContainer *data, quint32 id, QUndoCommand *parent) : VUndoCommand(QDomElement(), doc, parent), m_oldPath(oldPath), m_newPath(newPath), - m_data(data) + m_data(data), + m_pieceId(pieceId) { setText(tr("save path options")); nodeId = id; @@ -66,6 +68,14 @@ void SavePiecePathOptions::undo() SCASSERT(m_data); m_data->UpdatePiecePath(nodeId, m_oldPath); + + if (m_pieceId != NULL_ID) + { + if (VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(m_pieceId))) + { + tool->RefreshGeometry(); + } + } } else { @@ -90,9 +100,46 @@ void SavePiecePathOptions::redo() SCASSERT(m_data); m_data->UpdatePiecePath(nodeId, m_newPath); + + if (m_pieceId != NULL_ID) + { + if (VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(m_pieceId))) + { + tool->RefreshGeometry(); + } + } } else { qCDebug(vUndo, "Can't find path with id = %u.", nodeId); } } + +//--------------------------------------------------------------------------------------------------------------------- +bool SavePiecePathOptions::mergeWith(const QUndoCommand *command) +{ + const SavePiecePathOptions *saveCommand = static_cast(command); + SCASSERT(saveCommand != nullptr); + + if (saveCommand->PathId() != nodeId) + { + return false; + } + else + { + const QSet currentSet; + currentSet.fromList(m_newPath.Dependencies()); + + const VPiecePath candidate = saveCommand->NewPath(); + const QSet candidateSet; + candidateSet.fromList(candidate.Dependencies()); + + if (currentSet != candidateSet) + { + return false; + } + } + + m_newPath = saveCommand->NewPath(); + return true; +} diff --git a/src/libs/vtools/undocommands/savepiecepathoptions.h b/src/libs/vtools/undocommands/savepiecepathoptions.h index a458e35ea..160fc05e6 100644 --- a/src/libs/vtools/undocommands/savepiecepathoptions.h +++ b/src/libs/vtools/undocommands/savepiecepathoptions.h @@ -37,12 +37,16 @@ class SavePiecePathOptions : public VUndoCommand { public: - SavePiecePathOptions(const VPiecePath &oldPath, const VPiecePath &newPath, VAbstractPattern *doc, + SavePiecePathOptions(quint32 pieceId, const VPiecePath &oldPath, const VPiecePath &newPath, VAbstractPattern *doc, VContainer *data, quint32 id, QUndoCommand *parent = nullptr); virtual ~SavePiecePathOptions() = default; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; + virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE; + virtual int id() const Q_DECL_OVERRIDE; + quint32 PathId() const; + VPiecePath NewPath() const; private: Q_DISABLE_COPY(SavePiecePathOptions) @@ -50,6 +54,25 @@ private: VPiecePath m_newPath; VContainer *m_data; + quint32 m_pieceId; }; +//--------------------------------------------------------------------------------------------------------------------- +inline int SavePiecePathOptions::id() const +{ + return static_cast(UndoCommand::SavePiecePathOptions); +} + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 SavePiecePathOptions::PathId() const +{ + return nodeId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VPiecePath SavePiecePathOptions::NewPath() const +{ + return m_newPath; +} + #endif // SAVEPIECEPATHOPTIONS_H diff --git a/src/libs/vtools/undocommands/saveplacelabeloptions.cpp b/src/libs/vtools/undocommands/saveplacelabeloptions.cpp index 4d95d8737..e2fab6a6e 100644 --- a/src/libs/vtools/undocommands/saveplacelabeloptions.cpp +++ b/src/libs/vtools/undocommands/saveplacelabeloptions.cpp @@ -27,14 +27,17 @@ *************************************************************************/ #include "saveplacelabeloptions.h" #include "../tools/nodeDetails/vtoolplacelabel.h" +#include "../tools/vtoolseamallowance.h" //--------------------------------------------------------------------------------------------------------------------- -SavePlaceLabelOptions::SavePlaceLabelOptions(const VPlaceLabelItem &oldLabel, const VPlaceLabelItem &newLabel, - VAbstractPattern *doc, VContainer *data, quint32 id, QUndoCommand *parent) +SavePlaceLabelOptions::SavePlaceLabelOptions(quint32 pieceId, const VPlaceLabelItem &oldLabel, + const VPlaceLabelItem &newLabel, VAbstractPattern *doc, VContainer *data, + quint32 id, QUndoCommand *parent) : VUndoCommand(QDomElement(), doc, parent), m_oldLabel(oldLabel), m_newLabel(newLabel), - m_data(data) + m_data(data), + m_pieceId(pieceId) { setText(tr("save place label options")); nodeId = id; @@ -58,6 +61,14 @@ void SavePlaceLabelOptions::undo() SCASSERT(m_data); m_data->UpdateGObject(nodeId, new VPlaceLabelItem(m_oldLabel)); + + if (m_pieceId != NULL_ID) + { + if (VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(m_pieceId))) + { + tool->RefreshGeometry(); + } + } } else { @@ -83,9 +94,41 @@ void SavePlaceLabelOptions::redo() SCASSERT(m_data); m_data->UpdateGObject(nodeId, new VPlaceLabelItem(m_newLabel)); + + if (m_pieceId != NULL_ID) + { + if (VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(m_pieceId))) + { + tool->RefreshGeometry(); + } + } } else { qCDebug(vUndo, "Can't find path with id = %u.", nodeId); } } + +//--------------------------------------------------------------------------------------------------------------------- +bool SavePlaceLabelOptions::mergeWith(const QUndoCommand *command) +{ + const SavePlaceLabelOptions *saveCommand = static_cast(command); + SCASSERT(saveCommand != nullptr); + + if (saveCommand->LabelId() != nodeId) + { + return false; + } + else + { + const VPlaceLabelItem candidate = saveCommand->NewLabel(); + + if (m_newLabel.GetCenterPoint() != candidate.GetCenterPoint()) + { + return false; + } + } + + m_newLabel = saveCommand->NewLabel(); + return true; +} diff --git a/src/libs/vtools/undocommands/saveplacelabeloptions.h b/src/libs/vtools/undocommands/saveplacelabeloptions.h index a692816f9..828f23360 100644 --- a/src/libs/vtools/undocommands/saveplacelabeloptions.h +++ b/src/libs/vtools/undocommands/saveplacelabeloptions.h @@ -34,12 +34,17 @@ class SavePlaceLabelOptions : public VUndoCommand { public: - SavePlaceLabelOptions(const VPlaceLabelItem &oldLabel, const VPlaceLabelItem &newLabel, VAbstractPattern *doc, - VContainer *data, quint32 id, QUndoCommand *parent = nullptr); + SavePlaceLabelOptions(quint32 pieceId, const VPlaceLabelItem &oldLabel, const VPlaceLabelItem &newLabel, + VAbstractPattern *doc, VContainer *data, quint32 id, QUndoCommand *parent = nullptr); virtual ~SavePlaceLabelOptions()=default; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; + virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE; + virtual int id() const Q_DECL_OVERRIDE; + + quint32 LabelId() const; + VPlaceLabelItem NewLabel() const; private: Q_DISABLE_COPY(SavePlaceLabelOptions) @@ -47,6 +52,25 @@ private: VPlaceLabelItem m_newLabel; VContainer *m_data; + quint32 m_pieceId; }; +//--------------------------------------------------------------------------------------------------------------------- +inline int SavePlaceLabelOptions::id() const +{ + return static_cast(UndoCommand::SavePlaceLabelOptions); +} + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 SavePlaceLabelOptions::LabelId() const +{ + return nodeId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VPlaceLabelItem SavePlaceLabelOptions::NewLabel() const +{ + return m_newLabel; +} + #endif // SAVEPLACELABELOPTIONS_H diff --git a/src/libs/vtools/undocommands/savetooloptions.cpp b/src/libs/vtools/undocommands/savetooloptions.cpp index a4629208b..36a9b7bb1 100644 --- a/src/libs/vtools/undocommands/savetooloptions.cpp +++ b/src/libs/vtools/undocommands/savetooloptions.cpp @@ -98,3 +98,31 @@ QVector SaveToolOptions::Missing(const QList &list1, const QLi QSet set2 = QSet::fromList(list2); return set1.subtract(set2).toList().toVector(); } + +//--------------------------------------------------------------------------------------------------------------------- +bool SaveToolOptions::mergeWith(const QUndoCommand *command) +{ + const SaveToolOptions *saveCommand = static_cast(command); + SCASSERT(saveCommand != nullptr) + + if (saveCommand->getToolId() != nodeId) + { + return false; + } + else + { + const QSet currentSet; + currentSet.fromList(newDependencies); + + const QSet candidateSet; + candidateSet.fromList(saveCommand->NewDependencies()); + + if (currentSet != candidateSet) + { + return false; + } + } + + newXml = saveCommand->getNewXml(); + return true; +} diff --git a/src/libs/vtools/undocommands/savetooloptions.h b/src/libs/vtools/undocommands/savetooloptions.h index 8235fc5c1..f97728d94 100644 --- a/src/libs/vtools/undocommands/savetooloptions.h +++ b/src/libs/vtools/undocommands/savetooloptions.h @@ -48,14 +48,44 @@ public: virtual ~SaveToolOptions() = default; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; + virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE; + virtual int id() const Q_DECL_OVERRIDE; + + QDomElement getNewXml() const; + quint32 getToolId() const; + QList NewDependencies() const; private: Q_DISABLE_COPY(SaveToolOptions) const QDomElement oldXml; - const QDomElement newXml; + QDomElement newXml; const QList oldDependencies; const QList newDependencies; QVector Missing(const QList &list1, const QList &list2) const; }; +//--------------------------------------------------------------------------------------------------------------------- +inline int SaveToolOptions::id() const +{ + return static_cast(UndoCommand::SaveToolOptions); +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QDomElement SaveToolOptions::getNewXml() const +{ + return newXml; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 SaveToolOptions::getToolId() const +{ + return nodeId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QList SaveToolOptions::NewDependencies() const +{ + return newDependencies; +} + #endif // SAVETOOLOPTIONS_H diff --git a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp index e6fcc7cfd..63e485468 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp @@ -137,7 +137,7 @@ QString VisToolMove::Angle() const //--------------------------------------------------------------------------------------------------------------------- void VisToolMove::SetAngle(const QString &expression) { - angle = FindVal(expression, Visualization::data->DataVariables()); + angle = FindValFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- @@ -155,7 +155,7 @@ qreal VisToolMove::LengthValue() const //--------------------------------------------------------------------------------------------------------------------- void VisToolMove::SetLength(const QString &expression) { - length = FindLength(expression, Visualization::data->DataVariables()); + length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp b/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp index 152ab2958..11f9fa258 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp @@ -207,7 +207,7 @@ QString VisToolRotation::Angle() const //--------------------------------------------------------------------------------------------------------------------- void VisToolRotation::SetAngle(const QString &expression) { - angle = FindVal(expression, Visualization::data->DataVariables()); + angle = FindValFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/vistoolalongline.cpp b/src/libs/vtools/visualization/line/vistoolalongline.cpp index 32eb95c23..c3642261f 100644 --- a/src/libs/vtools/visualization/line/vistoolalongline.cpp +++ b/src/libs/vtools/visualization/line/vistoolalongline.cpp @@ -66,7 +66,7 @@ void VisToolAlongLine::setObject2Id(const quint32 &value) //--------------------------------------------------------------------------------------------------------------------- void VisToolAlongLine::setLength(const QString &expression) { - length = FindLength(expression, Visualization::data->DataVariables()); + length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/vistoolbisector.cpp b/src/libs/vtools/visualization/line/vistoolbisector.cpp index 2a669ea1a..35ac9cd5e 100644 --- a/src/libs/vtools/visualization/line/vistoolbisector.cpp +++ b/src/libs/vtools/visualization/line/vistoolbisector.cpp @@ -72,7 +72,7 @@ void VisToolBisector::setObject3Id(const quint32 &value) //--------------------------------------------------------------------------------------------------------------------- void VisToolBisector::setLength(const QString &expression) { - length = FindLength(expression, Visualization::data->DataVariables()); + length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.cpp b/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.cpp index 831ab1c6a..749f0b9f8 100644 --- a/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.cpp +++ b/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.cpp @@ -105,7 +105,7 @@ QString VisToolCurveIntersectAxis::Angle() const //--------------------------------------------------------------------------------------------------------------------- void VisToolCurveIntersectAxis::SetAngle(const QString &expression) { - angle = FindVal(expression, Visualization::data->DataVariables()); + angle = FindValFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/vistoolendline.cpp b/src/libs/vtools/visualization/line/vistoolendline.cpp index a5ec13572..4e5924b67 100644 --- a/src/libs/vtools/visualization/line/vistoolendline.cpp +++ b/src/libs/vtools/visualization/line/vistoolendline.cpp @@ -96,7 +96,7 @@ QString VisToolEndLine::Angle() const //--------------------------------------------------------------------------------------------------------------------- void VisToolEndLine::SetAngle(const QString &expression) { - angle = FindVal(expression, Visualization::data->DataVariables()); + angle = FindValFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- @@ -108,5 +108,5 @@ QString VisToolEndLine::Length() const //--------------------------------------------------------------------------------------------------------------------- void VisToolEndLine::setLength(const QString &expression) { - length = FindLength(expression, Visualization::data->DataVariables()); + length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } diff --git a/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp b/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp index 29cc1e898..f21da50b5 100644 --- a/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp +++ b/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp @@ -118,7 +118,7 @@ QString VisToolLineIntersectAxis::Angle() const //--------------------------------------------------------------------------------------------------------------------- void VisToolLineIntersectAxis::SetAngle(const QString &expression) { - angle = FindVal(expression, Visualization::data->DataVariables()); + angle = FindValFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/vistoolnormal.cpp b/src/libs/vtools/visualization/line/vistoolnormal.cpp index bb16350cc..1e718e282 100644 --- a/src/libs/vtools/visualization/line/vistoolnormal.cpp +++ b/src/libs/vtools/visualization/line/vistoolnormal.cpp @@ -110,7 +110,7 @@ void VisToolNormal::setObject2Id(const quint32 &value) //--------------------------------------------------------------------------------------------------------------------- void VisToolNormal::setLength(const QString &expression) { - length = FindLength(expression, Visualization::data->DataVariables()); + length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.cpp b/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.cpp index 19bf5f927..843cedccb 100644 --- a/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.cpp @@ -92,7 +92,7 @@ void VisToolPointFromCircleAndTangent::setObject2Id(const quint32 &value) //--------------------------------------------------------------------------------------------------------------------- void VisToolPointFromCircleAndTangent::setCRadius(const QString &value) { - cRadius = FindLength(value, Visualization::data->DataVariables()); + cRadius = FindLengthFromUser(value, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/vistoolpointofcontact.cpp b/src/libs/vtools/visualization/line/vistoolpointofcontact.cpp index 2c7dc1ebe..843024a00 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofcontact.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointofcontact.cpp @@ -108,5 +108,5 @@ void VisToolPointOfContact::setRadiusId(const quint32 &value) //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfContact::setRadius(const QString &expression) { - radius = FindLength(expression, Visualization::data->DataVariables()); + radius = FindLengthFromUser(expression, Visualization::data->DataVariables()); } diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp b/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp index 7462bad81..09a80a67b 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp @@ -111,13 +111,13 @@ void VisToolPointOfIntersectionCircles::setObject2Id(const quint32 &value) //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionCircles::setC1Radius(const QString &value) { - c1Radius = FindLength(value, Visualization::data->DataVariables()); + c1Radius = FindLengthFromUser(value, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionCircles::setC2Radius(const QString &value) { - c2Radius = FindLength(value, Visualization::data->DataVariables()); + c2Radius = FindLengthFromUser(value, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/vistoolshoulderpoint.cpp b/src/libs/vtools/visualization/line/vistoolshoulderpoint.cpp index 5f2a4199a..320fec06b 100644 --- a/src/libs/vtools/visualization/line/vistoolshoulderpoint.cpp +++ b/src/libs/vtools/visualization/line/vistoolshoulderpoint.cpp @@ -129,5 +129,5 @@ void VisToolShoulderPoint::setLineP2Id(const quint32 &value) //--------------------------------------------------------------------------------------------------------------------- void VisToolShoulderPoint::setLength(const QString &expression) { - length = FindLength(expression, Visualization::data->DataVariables()); + length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } diff --git a/src/libs/vtools/visualization/path/vistoolarc.cpp b/src/libs/vtools/visualization/path/vistoolarc.cpp index 4976b29b8..7200d0b52 100644 --- a/src/libs/vtools/visualization/path/vistoolarc.cpp +++ b/src/libs/vtools/visualization/path/vistoolarc.cpp @@ -70,17 +70,17 @@ void VisToolArc::RefreshGeometry() //--------------------------------------------------------------------------------------------------------------------- void VisToolArc::setRadius(const QString &expression) { - radius = FindLength(expression, Visualization::data->DataVariables()); + radius = FindLengthFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolArc::setF1(const QString &expression) { - f1 = FindVal(expression, Visualization::data->DataVariables()); + f1 = FindValFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolArc::setF2(const QString &expression) { - f2 = FindVal(expression, Visualization::data->DataVariables()); + f2 = FindValFromUser(expression, Visualization::data->DataVariables()); } diff --git a/src/libs/vtools/visualization/path/vistoolarcwithlength.cpp b/src/libs/vtools/visualization/path/vistoolarcwithlength.cpp index 35b34fb1a..5cc0f4490 100644 --- a/src/libs/vtools/visualization/path/vistoolarcwithlength.cpp +++ b/src/libs/vtools/visualization/path/vistoolarcwithlength.cpp @@ -69,17 +69,17 @@ void VisToolArcWithLength::RefreshGeometry() //--------------------------------------------------------------------------------------------------------------------- void VisToolArcWithLength::setRadius(const QString &expression) { - radius = FindLength(expression, Visualization::data->DataVariables()); + radius = FindLengthFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolArcWithLength::setF1(const QString &expression) { - f1 = FindVal(expression, Visualization::data->DataVariables()); + f1 = FindValFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolArcWithLength::setLength(const QString &expression) { - length = FindLength(expression, Visualization::data->DataVariables()); + length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } diff --git a/src/libs/vtools/visualization/path/vistoolcutarc.cpp b/src/libs/vtools/visualization/path/vistoolcutarc.cpp index 9f2d92017..6070f97d7 100644 --- a/src/libs/vtools/visualization/path/vistoolcutarc.cpp +++ b/src/libs/vtools/visualization/path/vistoolcutarc.cpp @@ -82,5 +82,5 @@ void VisToolCutArc::RefreshGeometry() //--------------------------------------------------------------------------------------------------------------------- void VisToolCutArc::setLength(const QString &expression) { - length = FindLength(expression, Visualization::data->DataVariables()); + length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } diff --git a/src/libs/vtools/visualization/path/vistoolcutspline.cpp b/src/libs/vtools/visualization/path/vistoolcutspline.cpp index b22c9bb33..46c53038c 100644 --- a/src/libs/vtools/visualization/path/vistoolcutspline.cpp +++ b/src/libs/vtools/visualization/path/vistoolcutspline.cpp @@ -90,5 +90,5 @@ void VisToolCutSpline::RefreshGeometry() //--------------------------------------------------------------------------------------------------------------------- void VisToolCutSpline::setLength(const QString &expression) { - length = FindLength(expression, Visualization::data->DataVariables()); + length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } diff --git a/src/libs/vtools/visualization/path/vistoolcutsplinepath.cpp b/src/libs/vtools/visualization/path/vistoolcutsplinepath.cpp index 360f069ba..1f59bc17a 100644 --- a/src/libs/vtools/visualization/path/vistoolcutsplinepath.cpp +++ b/src/libs/vtools/visualization/path/vistoolcutsplinepath.cpp @@ -91,5 +91,5 @@ void VisToolCutSplinePath::RefreshGeometry() //--------------------------------------------------------------------------------------------------------------------- void VisToolCutSplinePath::setLength(const QString &expression) { - length = FindLength(expression, Visualization::data->DataVariables()); + length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } diff --git a/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp b/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp index b588ae68e..bc76b22ef 100644 --- a/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp +++ b/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp @@ -65,29 +65,29 @@ void VisToolEllipticalArc::RefreshGeometry() //--------------------------------------------------------------------------------------------------------------------- void VisToolEllipticalArc::setRadius1(const QString &expression) { - radius1 = FindLength(expression, Visualization::data->DataVariables()); + radius1 = FindLengthFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolEllipticalArc::setRadius2(const QString &expression) { - radius2 = FindLength(expression, Visualization::data->DataVariables()); + radius2 = FindLengthFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolEllipticalArc::setF1(const QString &expression) { - f1 = FindVal(expression, Visualization::data->DataVariables()); + f1 = FindValFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolEllipticalArc::setF2(const QString &expression) { - f2 = FindVal(expression, Visualization::data->DataVariables()); + f2 = FindValFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolEllipticalArc::setRotationAngle(const QString &expression) { - rotationAngle = FindVal(expression, Visualization::data->DataVariables()); + rotationAngle = FindValFromUser(expression, Visualization::data->DataVariables()); } diff --git a/src/libs/vtools/visualization/visualization.cpp b/src/libs/vtools/visualization/visualization.cpp index 8b8c170c7..1fcfc6ce1 100644 --- a/src/libs/vtools/visualization/visualization.cpp +++ b/src/libs/vtools/visualization/visualization.cpp @@ -143,15 +143,15 @@ VScaledEllipse *Visualization::InitPoint(const QColor &color, QGraphicsItem *par } //--------------------------------------------------------------------------------------------------------------------- -qreal Visualization::FindLength(const QString &expression, - const QHash > *vars) +qreal Visualization::FindLengthFromUser(const QString &expression, + const QHash > *vars, bool fromUser) { - return qApp->toPixel(FindVal(expression, vars)); + return qApp->toPixel(FindValFromUser(expression, vars, fromUser)); } //--------------------------------------------------------------------------------------------------------------------- -qreal Visualization::FindVal(const QString &expression, - const QHash > *vars) +qreal Visualization::FindValFromUser(const QString &expression, + const QHash > *vars, bool fromUser) { qreal val = 0; if (expression.isEmpty()) @@ -165,7 +165,11 @@ qreal Visualization::FindVal(const QString &expression, // Replace line return with spaces for calc if exist QString formula = expression; formula.replace("\n", " "); - formula = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + if (fromUser) + { + formula = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + } + QScopedPointer cal(new Calculator()); val = cal->EvalFormula(vars, formula); diff --git a/src/libs/vtools/visualization/visualization.h b/src/libs/vtools/visualization/visualization.h index d48342920..5878bd9aa 100644 --- a/src/libs/vtools/visualization/visualization.h +++ b/src/libs/vtools/visualization/visualization.h @@ -72,8 +72,10 @@ public: Mode GetMode() const; void SetMode(const Mode &value); - static qreal FindLength(const QString &expression, const QHash > *vars); - static qreal FindVal(const QString &expression, const QHash > *vars); + static qreal FindLengthFromUser(const QString &expression, const QHash > *vars, bool fromUser = true); + static qreal FindValFromUser(const QString &expression, const QHash > *vars, bool fromUser = true); signals: void ToolTip(const QString &toolTip); public slots: From 6f5969a35746ef570766d8ed69d4e3921d9e08d0 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 23 Oct 2017 11:33:34 +0300 Subject: [PATCH 05/15] Use icon from default theme. --HG-- branch : feature --- .../dialogs/tools/piece/dialogseamallowance.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index aaa567b9a..81a358c50 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -528,7 +528,8 @@ void DialogSeamAllowance::NameDetailChanged() flagName = false; ChangeColor(uiTabLabels->labelEditName, Qt::red); m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + QLatin1String("*")); - QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"); + const QIcon icon = QIcon::fromTheme("dialog-warning", + QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png")); uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabPieceLabelData), icon); } else @@ -1578,7 +1579,8 @@ void DialogSeamAllowance::UpdateDetailLabelValues() if (not flagDLAngle || not (flagDLFormulas || flagDPin) || not flagPLAngle || not (flagPLFormulas || flagPPin)) { m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + QLatin1String("*")); - QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"); + const QIcon icon = QIcon::fromTheme("dialog-warning", + QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png")); uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon); } else @@ -1663,7 +1665,8 @@ void DialogSeamAllowance::UpdatePatternLabelValues() if (not flagDLAngle || not (flagDLFormulas || flagDPin) || not flagPLAngle || not (flagPLFormulas || flagPPin)) { m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + QLatin1String("*")); - QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"); + const QIcon icon = QIcon::fromTheme("dialog-warning", + QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png")); uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon); } else @@ -2155,7 +2158,8 @@ void DialogSeamAllowance::DetailPinPointChanged() topPinId == NULL_ID && bottomPinId == NULL_ID ? color = okColor : color = errorColor; m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + QLatin1String("*")); - QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"); + const QIcon icon = QIcon::fromTheme("dialog-warning", + QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png")); uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon); } UpdateDetailLabelValues(); @@ -2187,7 +2191,8 @@ void DialogSeamAllowance::PatternPinPointChanged() topPinId == NULL_ID && bottomPinId == NULL_ID ? color = okColor : color = errorColor; m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + QLatin1String("*")); - QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"); + const QIcon icon = QIcon::fromTheme("dialog-warning", + QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png")); uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon); } UpdatePatternLabelValues(); From 233efde70475e1061da8eab6273ed7b8d438dedf Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 23 Oct 2017 12:33:54 +0300 Subject: [PATCH 06/15] Always draw circle for Button type. --HG-- branch : feature --- src/libs/vgeometry/vplacelabelitem.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libs/vgeometry/vplacelabelitem.cpp b/src/libs/vgeometry/vplacelabelitem.cpp index 95eb9e65c..52f36df49 100644 --- a/src/libs/vgeometry/vplacelabelitem.cpp +++ b/src/libs/vgeometry/vplacelabelitem.cpp @@ -28,7 +28,7 @@ #include "vplacelabelitem.h" #include "vplacelabelitem_p.h" #include "../vpatterndb/vcontainer.h" -#include "vellipticalarc.h" +#include "varc.h" #include #include @@ -286,17 +286,19 @@ PlaceLabelImg VPlaceLabelItem::LabelShape(const VContainer *data) const auto ButtonShape = [center, t, this]() { + const qreal radius = qMin(d->wValue/2.0, d->hValue/2.0); QPolygonF shape1; - shape1 << QPointF(center->x(), center->y() - d->hValue/2.0) - << QPointF(center->x(), center->y() + d->hValue/2.0); + shape1 << QPointF(center->x(), center->y() - radius) + << QPointF(center->x(), center->y() + radius); QPolygonF shape2; - shape2 << QPointF(center->x() - d->wValue/2.0, center->y()) - << QPointF(center->x() + d->wValue/2.0, center->y()); + shape2 << QPointF(center->x() - radius, center->y()) + << QPointF(center->x() + radius, center->y()); const qreal circleSize = 0.85; - VEllipticalArc elArc(*center, d->wValue/2.0*circleSize, d->hValue/2.0*circleSize, 0, 360, 0); - QPolygonF shape3(elArc.GetPoints()); + VArc arc(*center, radius*circleSize, 0, 360); + arc.SetApproximationScale(10); + QPolygonF shape3(arc.GetPoints()); if (not shape3.isClosed() && not shape3.isEmpty()) { shape3 << shape3.first(); From 05cad85ab3f7f1654cbc8e823bbea2087417ab8d Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 23 Oct 2017 14:31:01 +0300 Subject: [PATCH 07/15] Fix bug with tool seam allowance cursor. --HG-- branch : feature --- src/libs/vtools/tools/vtoolseamallowance.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index d261adf37..6791982e6 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1063,7 +1063,7 @@ void VToolSeamAllowance::mousePressEvent(QGraphicsSceneMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - if (event->button() == Qt::LeftButton) + if (event->button() == Qt::LeftButton && (flags() & QGraphicsItem::ItemIsMovable)) { SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); } @@ -1077,6 +1077,16 @@ void VToolSeamAllowance::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); } + else + { + if (QGraphicsScene *scene = this->scene()) + { + if (QGraphicsView *view = scene->views().at(0)) + { + setCursor(view->viewport()->cursor()); + } + } + } QGraphicsPathItem::hoverEnterEvent(event); } From f27c7e4e3516b275a2f45154cd9ef50599ff0b98 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 23 Oct 2017 21:10:48 +0300 Subject: [PATCH 08/15] Fix recursive repaint after label scale. --HG-- branch : feature --- src/libs/vmisc/def.h | 1 + src/libs/vwidgets/vgraphicssimpletextitem.cpp | 43 +++++++++++++++++-- src/libs/vwidgets/vgraphicssimpletextitem.h | 1 + src/libs/vwidgets/vscenepoint.h | 9 +++- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 6ef4ff1d3..4f67cd982 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -228,6 +228,7 @@ enum class Vis : ToolVisHolderType GrainlineItem, PieceItem, TextGraphicsItem, + ScenePoint, LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used }; diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.cpp b/src/libs/vwidgets/vgraphicssimpletextitem.cpp index 59c7e32d7..84f7f8696 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.cpp +++ b/src/libs/vwidgets/vgraphicssimpletextitem.cpp @@ -46,6 +46,9 @@ #include "vmaingraphicsscene.h" #include "vmaingraphicsview.h" #include "global.h" +#include "vscenepoint.h" + +#define DEFAULT_SCALE 0.0001 //--------------------------------------------------------------------------------------------------------------------- /** @@ -53,7 +56,8 @@ * @param parent parent object. */ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent) - :QGraphicsSimpleTextItem(parent), m_fontSize(0), selectionType(SelectionType::ByMouseRelease) + :QGraphicsSimpleTextItem(parent), m_fontSize(0), selectionType(SelectionType::ByMouseRelease), + m_oldScale(DEFAULT_SCALE) { this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true); @@ -64,6 +68,7 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent) font.setPointSize(font.pointSize()+20); m_fontSize = font.pointSize(); this->setFont(font); + setScale(m_oldScale); } //--------------------------------------------------------------------------------------------------------------------- @@ -73,23 +78,53 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent) * @param parent parent object. */ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent ) - :QGraphicsSimpleTextItem(text, parent), m_fontSize(0), selectionType(SelectionType::ByMouseRelease) + :QGraphicsSimpleTextItem(text, parent), m_fontSize(0), selectionType(SelectionType::ByMouseRelease), + m_oldScale(DEFAULT_SCALE) { this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setAcceptHoverEvents(true); + setScale(m_oldScale); } //--------------------------------------------------------------------------------------------------------------------- void VGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - const qreal scale = SceneScale(scene()); - if (scale > 1) + auto UpdateLine = [this]() { + if (VScenePoint *parent = dynamic_cast(parentItem())) + { + parent->RefreshLine(); + } + }; + + QGraphicsScene *scene = this->scene(); + const qreal scale = SceneScale(scene); + if (scale > 1 && not VFuzzyComparePossibleNulls(m_oldScale, scale)) + { + const QRectF nameRec = boundingRect(); + setTransformOriginPoint(nameRec.center()); setScale(1/scale); + UpdateLine(); + m_oldScale = scale; + } + else if (scale <= 1 && not VFuzzyComparePossibleNulls(m_oldScale, 1.0)) + { + const QRectF nameRec = boundingRect(); + setTransformOriginPoint(nameRec.center()); + setScale(1); + UpdateLine(); + m_oldScale = 1; } + if (scene) + { + if (QGraphicsView *view = scene->views().at(0)) + { + VMainGraphicsView::NewSceneRect(scene, view); + } + } QGraphicsSimpleTextItem::paint(painter, option, widget); } diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.h b/src/libs/vwidgets/vgraphicssimpletextitem.h index 26f232398..34a739448 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.h +++ b/src/libs/vwidgets/vgraphicssimpletextitem.h @@ -87,6 +87,7 @@ private: /** @brief fontSize label font size. */ qint32 m_fontSize; SelectionType selectionType; + qreal m_oldScale; }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vwidgets/vscenepoint.h b/src/libs/vwidgets/vscenepoint.h index 25f59f777..55be9e34e 100644 --- a/src/libs/vwidgets/vscenepoint.h +++ b/src/libs/vwidgets/vscenepoint.h @@ -32,6 +32,8 @@ #include #include +#include "../vmisc/def.h" + class VGraphicsSimpleTextItem; class VPointF; class VScaledLine; @@ -42,10 +44,15 @@ public: explicit VScenePoint(QGraphicsItem *parent = nullptr); virtual ~VScenePoint() = default; + virtual int type() const Q_DECL_OVERRIDE {return Type;} + enum { Type = UserType + static_cast(Vis::ScenePoint)}; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) Q_DECL_OVERRIDE; virtual void RefreshPointGeometry(const VPointF &point); + void RefreshLine(); + protected: /** @brief namePoint point label. */ VGraphicsSimpleTextItem *m_namePoint; @@ -63,8 +70,6 @@ protected: virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE; - void RefreshLine(); - void SetOnlyPoint(bool value); bool IsOnlyPoint() const; private: From 9c6160fa503cf28920e2ddddf906cbbfc8927078 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 24 Oct 2017 12:02:47 +0300 Subject: [PATCH 09/15] Fix bug with parent disappearing. --HG-- branch : feature --- src/libs/vgeometry/vplacelabelitem.cpp | 70 +++++++++++++------------- src/libs/vgeometry/vplacelabelitem.h | 2 +- src/libs/vpatterndb/vpiece.cpp | 6 +-- 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/libs/vgeometry/vplacelabelitem.cpp b/src/libs/vgeometry/vplacelabelitem.cpp index 52f36df49..e237381dc 100644 --- a/src/libs/vgeometry/vplacelabelitem.cpp +++ b/src/libs/vgeometry/vplacelabelitem.cpp @@ -174,27 +174,25 @@ VPlaceLabelItem &VPlaceLabelItem::operator=(const VPlaceLabelItem &item) } //--------------------------------------------------------------------------------------------------------------------- -PlaceLabelImg VPlaceLabelItem::LabelShape(const VContainer *data) const +PlaceLabelImg VPlaceLabelItem::LabelShape() const { - const auto center = data->GeometricObject(d->centerPoint); - QTransform t; - t.translate(center->x(), center->y()); + t.translate(x(), y()); t.rotate(-(d->aValue+d->correctionAngle)); - t.translate(-center->x(), -center->y()); + t.translate(-x(), -y()); - auto SegmentShape = [center, t, this]() + auto SegmentShape = [t, this]() { QPolygonF shape; - shape << QPointF(center->x(), center->y() - d->hValue/2.0) << QPointF(center->x(), center->y() + d->hValue/2.0); + shape << QPointF(x(), y() - d->hValue/2.0) << QPointF(x(), y() + d->hValue/2.0); return PlaceLabelImg({t.map(shape)}); }; - auto RectangleShape = [center, t, this]() + auto RectangleShape = [t, this]() { - QRectF rect(QPointF(center->x() - d->wValue/2.0, center->y() - d->hValue/2.0), - QPointF(center->x() + d->wValue/2.0, center->y() + d->hValue/2.0)); + QRectF rect(QPointF(x() - d->wValue/2.0, y() - d->hValue/2.0), + QPointF(x() + d->wValue/2.0, y() + d->hValue/2.0)); QPolygonF shape; shape << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft(); @@ -202,25 +200,25 @@ PlaceLabelImg VPlaceLabelItem::LabelShape(const VContainer *data) const return PlaceLabelImg({t.map(shape)}); }; - auto CrossShape = [center, t, this]() + auto CrossShape = [t, this]() { QPolygonF shape1; - shape1 << QPointF(center->x(), center->y() - d->hValue/2.0) - << QPointF(center->x(), center->y() + d->hValue/2.0); + shape1 << QPointF(x(), y() - d->hValue/2.0) + << QPointF(x(), y() + d->hValue/2.0); QPolygonF shape2; - shape2 << QPointF(center->x() - d->wValue/2.0, center->y()) - << QPointF(center->x() + d->wValue/2.0, center->y()); + shape2 << QPointF(x() - d->wValue/2.0, y()) + << QPointF(x() + d->wValue/2.0, y()); return PlaceLabelImg({t.map(shape1), t.map(shape2)}); }; - auto TshapedShape = [center, t, this]() + auto TshapedShape = [t, this]() { - QPointF center2(center->x(), center->y() + d->hValue/2.0); + QPointF center2(x(), y() + d->hValue/2.0); QPolygonF shape1; - shape1 << QPointF(center->x(), center->y()) << center2; + shape1 << QPointF(x(), y()) << center2; QPolygonF shape2; shape2 << QPointF(center2.x() - d->wValue/2.0, center2.y()) @@ -229,10 +227,10 @@ PlaceLabelImg VPlaceLabelItem::LabelShape(const VContainer *data) const return PlaceLabelImg({t.map(shape1), t.map(shape2)}); }; - auto DoubletreeShape = [center, t, this]() + auto DoubletreeShape = [t, this]() { - QRectF rect(QPointF(center->x() - d->wValue/2.0, center->y() - d->hValue/2.0), - QPointF(center->x() + d->wValue/2.0, center->y() + d->hValue/2.0)); + QRectF rect(QPointF(x() - d->wValue/2.0, y() - d->hValue/2.0), + QPointF(x() + d->wValue/2.0, y() + d->hValue/2.0)); QPolygonF shape1; shape1 << rect.topLeft() << rect.bottomRight(); @@ -243,21 +241,21 @@ PlaceLabelImg VPlaceLabelItem::LabelShape(const VContainer *data) const return PlaceLabelImg({t.map(shape1), t.map(shape2)}); }; - auto CornerShape = [center, t, this]() + auto CornerShape = [t, this]() { QPolygonF shape1; - shape1 << QPointF(center->x(), center->y()) << QPointF(center->x(), center->y() + d->hValue/2.0); + shape1 << QPointF(x(), y()) << QPointF(x(), y() + d->hValue/2.0); QPolygonF shape2; - shape2 << QPointF(center->x() - d->wValue/2.0, center->y()) << QPointF(center->x(), center->y()); + shape2 << QPointF(x() - d->wValue/2.0, y()) << QPointF(x(), y()); return PlaceLabelImg({t.map(shape1), t.map(shape2)}); }; - auto TriangleShape = [center, t, this]() + auto TriangleShape = [t, this]() { - QRectF rect(QPointF(center->x() - d->wValue/2.0, center->y() - d->hValue/2.0), - QPointF(center->x() + d->wValue/2.0, center->y() + d->hValue/2.0)); + QRectF rect(QPointF(x() - d->wValue/2.0, y() - d->hValue/2.0), + QPointF(x() + d->wValue/2.0, y() + d->hValue/2.0)); QPolygonF shape; shape << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.topLeft(); @@ -265,10 +263,10 @@ PlaceLabelImg VPlaceLabelItem::LabelShape(const VContainer *data) const return PlaceLabelImg({t.map(shape)}); }; - auto HshapedShape = [center, t, this]() + auto HshapedShape = [t, this]() { - const QPointF center1 (center->x(), center->y() - d->hValue/2.0); - const QPointF center2 (center->x(), center->y() + d->hValue/2.0); + const QPointF center1 (x(), y() - d->hValue/2.0); + const QPointF center2 (x(), y() + d->hValue/2.0); QPolygonF shape1; shape1 << center1 << center2; @@ -284,19 +282,19 @@ PlaceLabelImg VPlaceLabelItem::LabelShape(const VContainer *data) const return PlaceLabelImg({t.map(shape1), t.map(shape2), t.map(shape3)}); }; - auto ButtonShape = [center, t, this]() + auto ButtonShape = [t, this]() { const qreal radius = qMin(d->wValue/2.0, d->hValue/2.0); QPolygonF shape1; - shape1 << QPointF(center->x(), center->y() - radius) - << QPointF(center->x(), center->y() + radius); + shape1 << QPointF(x(), y() - radius) + << QPointF(x(), y() + radius); QPolygonF shape2; - shape2 << QPointF(center->x() - radius, center->y()) - << QPointF(center->x() + radius, center->y()); + shape2 << QPointF(x() - radius, y()) + << QPointF(x() + radius, y()); const qreal circleSize = 0.85; - VArc arc(*center, radius*circleSize, 0, 360); + VArc arc(*this, radius*circleSize, 0, 360); arc.SetApproximationScale(10); QPolygonF shape3(arc.GetPoints()); if (not shape3.isClosed() && not shape3.isEmpty()) diff --git a/src/libs/vgeometry/vplacelabelitem.h b/src/libs/vgeometry/vplacelabelitem.h index 7dd004f79..d63e423d8 100644 --- a/src/libs/vgeometry/vplacelabelitem.h +++ b/src/libs/vgeometry/vplacelabelitem.h @@ -77,7 +77,7 @@ public: PlaceLabelType GetLabelType() const; void SetLabelType(PlaceLabelType type); - PlaceLabelImg LabelShape(const VContainer *data) const; + PlaceLabelImg LabelShape() const; private: QSharedDataPointer d; diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index e01c1698b..c3e982297 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -450,11 +450,11 @@ QVector VPiece::PlaceLabelPoints(const VContainer *data) const try { const auto label = data->GeometricObject(d->m_placeLabels.at(i)); - points.append(label->LabelShape(data)); + points.append(label->LabelShape()); } catch (const VExceptionBadId &e) - { // ignore - Q_UNUSED(e) + { + qWarning() << e.ErrorMessage(); } } return points; From 14e19ced4bbcbaf16a49444296d2aec37eee581c Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 24 Oct 2017 14:14:59 +0300 Subject: [PATCH 10/15] Refactoring. Move dialogs related to pieces. --HG-- branch : feature --- src/libs/vtools/dialogs/dialogs.pri | 18 +++++++++--------- src/libs/vtools/dialogs/tooldialogs.h | 6 +++--- .../tools/{ => piece}/dialoginsertnode.cpp | 0 .../tools/{ => piece}/dialoginsertnode.h | 2 +- .../tools/{ => piece}/dialoginsertnode.ui | 0 .../dialogs/tools/{ => piece}/dialogpin.cpp | 2 +- .../dialogs/tools/{ => piece}/dialogpin.h | 2 +- .../dialogs/tools/{ => piece}/dialogpin.ui | 0 .../tools/{ => piece}/dialogplacelabel.cpp | 6 +++--- .../tools/{ => piece}/dialogplacelabel.h | 2 +- .../tools/{ => piece}/dialogplacelabel.ui | 0 .../tools/piece/dialogseamallowance.cpp | 2 +- src/libs/vtools/tools/nodeDetails/vtoolpin.cpp | 2 +- .../tools/nodeDetails/vtoolplacelabel.cpp | 2 +- 14 files changed, 22 insertions(+), 22 deletions(-) rename src/libs/vtools/dialogs/tools/{ => piece}/dialoginsertnode.cpp (100%) rename src/libs/vtools/dialogs/tools/{ => piece}/dialoginsertnode.h (98%) rename src/libs/vtools/dialogs/tools/{ => piece}/dialoginsertnode.ui (100%) rename src/libs/vtools/dialogs/tools/{ => piece}/dialogpin.cpp (99%) rename src/libs/vtools/dialogs/tools/{ => piece}/dialogpin.h (98%) rename src/libs/vtools/dialogs/tools/{ => piece}/dialogpin.ui (100%) rename src/libs/vtools/dialogs/tools/{ => piece}/dialogplacelabel.cpp (99%) rename src/libs/vtools/dialogs/tools/{ => piece}/dialogplacelabel.h (99%) rename src/libs/vtools/dialogs/tools/{ => piece}/dialogplacelabel.ui (100%) diff --git a/src/libs/vtools/dialogs/dialogs.pri b/src/libs/vtools/dialogs/dialogs.pri index f72bb27df..9df554fc8 100644 --- a/src/libs/vtools/dialogs/dialogs.pri +++ b/src/libs/vtools/dialogs/dialogs.pri @@ -44,10 +44,10 @@ HEADERS += \ $$PWD/tools/dialogellipticalarc.h \ $$PWD/tools/piece/dialogseamallowance.h \ $$PWD/tools/piece/dialogpiecepath.h \ - $$PWD/tools/dialogpin.h \ - $$PWD/tools/dialoginsertnode.h \ + $$PWD/tools/piece/dialogpin.h \ + $$PWD/tools/piece/dialoginsertnode.h \ $$PWD/support/dialogeditlabel.h \ - $$PWD/tools/dialogplacelabel.h + $$PWD/tools/piece/dialogplacelabel.h SOURCES += \ $$PWD/tools/dialogalongline.cpp \ @@ -91,10 +91,10 @@ SOURCES += \ $$PWD/tools/dialogellipticalarc.cpp \ $$PWD/tools/piece/dialogseamallowance.cpp \ $$PWD/tools/piece/dialogpiecepath.cpp \ - $$PWD/tools/dialogpin.cpp \ - $$PWD/tools/dialoginsertnode.cpp \ + $$PWD/tools/piece/dialogpin.cpp \ + $$PWD/tools/piece/dialoginsertnode.cpp \ $$PWD/support/dialogeditlabel.cpp \ - $$PWD/tools/dialogplacelabel.cpp + $$PWD/tools/piece/dialogplacelabel.cpp FORMS += \ $$PWD/tools/dialogalongline.ui \ @@ -137,13 +137,13 @@ FORMS += \ $$PWD/tools/dialogellipticalarc.ui \ $$PWD/tools/piece/dialogseamallowance.ui \ $$PWD/tools/piece/dialogpiecepath.ui \ - $$PWD/tools/dialogpin.ui \ + $$PWD/tools/piece/dialogpin.ui \ $$PWD/tools/piece/tabs/tabpaths.ui \ $$PWD/tools/piece/tabs/tablabels.ui \ $$PWD/tools/piece/tabs/tabgrainline.ui \ $$PWD/tools/piece/tabs/tabpins.ui \ - $$PWD/tools/dialoginsertnode.ui \ + $$PWD/tools/piece/dialoginsertnode.ui \ $$PWD/tools/piece/tabs/tabpassmarks.ui \ $$PWD/support/dialogeditlabel.ui \ - $$PWD/tools/dialogplacelabel.ui \ + $$PWD/tools/piece/dialogplacelabel.ui \ $$PWD/tools/piece/tabs/tabplacelabels.ui diff --git a/src/libs/vtools/dialogs/tooldialogs.h b/src/libs/vtools/dialogs/tooldialogs.h index 4510ba950..0db5a3721 100644 --- a/src/libs/vtools/dialogs/tooldialogs.h +++ b/src/libs/vtools/dialogs/tooldialogs.h @@ -67,9 +67,9 @@ #include "tools/dialogmove.h" #include "tools/dialogellipticalarc.h" #include "tools/piece/dialogpiecepath.h" -#include "tools/dialogpin.h" -#include "tools/dialoginsertnode.h" -#include "tools/dialogplacelabel.h" +#include "tools/piece/dialogpin.h" +#include "tools/piece/dialoginsertnode.h" +#include "tools/piece/dialogplacelabel.h" #include "support/dialogeditwrongformula.h" #include "support/dialogundo.h" diff --git a/src/libs/vtools/dialogs/tools/dialoginsertnode.cpp b/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.cpp similarity index 100% rename from src/libs/vtools/dialogs/tools/dialoginsertnode.cpp rename to src/libs/vtools/dialogs/tools/piece/dialoginsertnode.cpp diff --git a/src/libs/vtools/dialogs/tools/dialoginsertnode.h b/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.h similarity index 98% rename from src/libs/vtools/dialogs/tools/dialoginsertnode.h rename to src/libs/vtools/dialogs/tools/piece/dialoginsertnode.h index 081c2471a..840582f5f 100644 --- a/src/libs/vtools/dialogs/tools/dialoginsertnode.h +++ b/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.h @@ -29,7 +29,7 @@ #ifndef DIALOGINSERTNODE_H #define DIALOGINSERTNODE_H -#include "dialogtool.h" +#include "../dialogtool.h" #include "../vpatterndb/vpiecenode.h" namespace Ui diff --git a/src/libs/vtools/dialogs/tools/dialoginsertnode.ui b/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.ui similarity index 100% rename from src/libs/vtools/dialogs/tools/dialoginsertnode.ui rename to src/libs/vtools/dialogs/tools/piece/dialoginsertnode.ui diff --git a/src/libs/vtools/dialogs/tools/dialogpin.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp similarity index 99% rename from src/libs/vtools/dialogs/tools/dialogpin.cpp rename to src/libs/vtools/dialogs/tools/piece/dialogpin.cpp index e789ce607..6c7479ce9 100644 --- a/src/libs/vtools/dialogs/tools/dialogpin.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp @@ -29,7 +29,7 @@ #include "dialogpin.h" #include "ui_dialogpin.h" #include "visualization/line/vistoolspecialpoint.h" -#include "../../tools/vabstracttool.h" +#include "../../../tools/vabstracttool.h" //--------------------------------------------------------------------------------------------------------------------- DialogPin::DialogPin(const VContainer *data, quint32 toolId, QWidget *parent) diff --git a/src/libs/vtools/dialogs/tools/dialogpin.h b/src/libs/vtools/dialogs/tools/piece/dialogpin.h similarity index 98% rename from src/libs/vtools/dialogs/tools/dialogpin.h rename to src/libs/vtools/dialogs/tools/piece/dialogpin.h index c6488d0bd..80d57b434 100644 --- a/src/libs/vtools/dialogs/tools/dialogpin.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogpin.h @@ -29,7 +29,7 @@ #ifndef DIALOGPIN_H #define DIALOGPIN_H -#include "dialogtool.h" +#include "../dialogtool.h" namespace Ui { diff --git a/src/libs/vtools/dialogs/tools/dialogpin.ui b/src/libs/vtools/dialogs/tools/piece/dialogpin.ui similarity index 100% rename from src/libs/vtools/dialogs/tools/dialogpin.ui rename to src/libs/vtools/dialogs/tools/piece/dialogpin.ui diff --git a/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp similarity index 99% rename from src/libs/vtools/dialogs/tools/dialogplacelabel.cpp rename to src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp index c0c331f33..717945bb8 100644 --- a/src/libs/vtools/dialogs/tools/dialogplacelabel.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp @@ -29,9 +29,9 @@ #include "ui_dialogplacelabel.h" #include "visualization/line/vistoolspecialpoint.h" -#include "../../tools/vabstracttool.h" -#include "../../tools/vtoolseamallowance.h" -#include "../support/dialogeditwrongformula.h" +#include "../../../tools/vabstracttool.h" +#include "../../../tools/vtoolseamallowance.h" +#include "../../support/dialogeditwrongformula.h" #include "../vgeometry/vplacelabelitem.h" #include diff --git a/src/libs/vtools/dialogs/tools/dialogplacelabel.h b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.h similarity index 99% rename from src/libs/vtools/dialogs/tools/dialogplacelabel.h rename to src/libs/vtools/dialogs/tools/piece/dialogplacelabel.h index 92e27971c..8346e2470 100644 --- a/src/libs/vtools/dialogs/tools/dialogplacelabel.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.h @@ -28,7 +28,7 @@ #ifndef DIALOGPLACELABEL_H #define DIALOGPLACELABEL_H -#include "dialogtool.h" +#include "../dialogtool.h" namespace Ui { diff --git a/src/libs/vtools/dialogs/tools/dialogplacelabel.ui b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.ui similarity index 100% rename from src/libs/vtools/dialogs/tools/dialogplacelabel.ui rename to src/libs/vtools/dialogs/tools/piece/dialogplacelabel.ui diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 81a358c50..c7656f99f 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -41,7 +41,7 @@ #include "visualization/path/vistoolpiece.h" #include "visualization/path/vispiecespecialpoints.h" #include "dialogpiecepath.h" -#include "../dialogplacelabel.h" +#include "dialogplacelabel.h" #include "../../../undocommands/savepiecepathoptions.h" #include "../../../undocommands/saveplacelabeloptions.h" #include "../../support/dialogeditwrongformula.h" diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpin.cpp b/src/libs/vtools/tools/nodeDetails/vtoolpin.cpp index 3c518c3b4..55cd6a1ad 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpin.cpp +++ b/src/libs/vtools/tools/nodeDetails/vtoolpin.cpp @@ -27,7 +27,7 @@ *************************************************************************/ #include "vtoolpin.h" -#include "../../dialogs/tools/dialogpin.h" +#include "../../dialogs/tools/piece/dialogpin.h" #include "../../undocommands/savepieceoptions.h" #include "../vtoolseamallowance.h" #include "../vgeometry/vpointf.h" diff --git a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp index 0e99b2235..6b597fcf5 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp +++ b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp @@ -27,7 +27,7 @@ *************************************************************************/ #include "vtoolplacelabel.h" -#include "../../dialogs/tools/dialogplacelabel.h" +#include "../../dialogs/tools/piece/dialogplacelabel.h" #include "../../undocommands/savepieceoptions.h" #include "../vtoolseamallowance.h" #include "../vgeometry/vpointf.h" From 7a2297ed6bd0e82497888818065062a23e70987b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 24 Oct 2017 14:23:11 +0300 Subject: [PATCH 11/15] Correct applying correction angle. --HG-- branch : feature --- src/libs/vgeometry/vplacelabelitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/vgeometry/vplacelabelitem.cpp b/src/libs/vgeometry/vplacelabelitem.cpp index e237381dc..1e43006ea 100644 --- a/src/libs/vgeometry/vplacelabelitem.cpp +++ b/src/libs/vgeometry/vplacelabelitem.cpp @@ -178,7 +178,7 @@ PlaceLabelImg VPlaceLabelItem::LabelShape() const { QTransform t; t.translate(x(), y()); - t.rotate(-(d->aValue+d->correctionAngle)); + t.rotate(-d->aValue-d->correctionAngle); t.translate(-x(), -y()); auto SegmentShape = [t, this]() From f78c122cb0adc831794e8a6f21b44902ae1329e8 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 24 Oct 2017 16:42:09 +0300 Subject: [PATCH 12/15] Show place label rect. --HG-- branch : feature --- .../tools/piece/dialogseamallowance.cpp | 37 +++++++++++++++++-- .../dialogs/tools/piece/dialogseamallowance.h | 3 +- .../path/vispiecespecialpoints.cpp | 32 ++++++++++++---- .../path/vispiecespecialpoints.h | 28 +++++++++++++- src/libs/vwidgets/vcurvepathitem.cpp | 11 +++++- src/libs/vwidgets/vcurvepathitem.h | 2 + 6 files changed, 98 insertions(+), 15 deletions(-) diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index c7656f99f..07e91c519 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -281,6 +281,11 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) NewSpecialPoint(uiTabPlaceLabels->listWidgetPlaceLabels, piece.GetPlaceLabels().at(i)); } + if (piece.GetPlaceLabels().size() > 0) + { + uiTabPlaceLabels->listWidgetPlaceLabels->setCurrentRow(0); + } + uiTabPaths->comboBoxStartPoint->blockSignals(true); uiTabPaths->comboBoxStartPoint->clear(); uiTabPaths->comboBoxStartPoint->blockSignals(false); @@ -1297,11 +1302,11 @@ QT_WARNING_POP || (index == TabOrder::Labels && uiTabLabels->tabWidget->currentIndex() == uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels))) { - ShowPieceSpecialPoints(uiTabPins->listWidgetPins); + ShowPieceSpecialPointsWithRect(uiTabPins->listWidgetPins, false); } else if (index == TabOrder::PlaceLabels) { - ShowPieceSpecialPoints(uiTabPlaceLabels->listWidgetPlaceLabels); + ShowPieceSpecialPointsWithRect(uiTabPlaceLabels->listWidgetPlaceLabels, true); } else { @@ -1317,7 +1322,7 @@ void DialogSeamAllowance::TabChanged(int index) { if (index == uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels)) { - ShowPieceSpecialPoints(uiTabPins->listWidgetPins); + ShowPieceSpecialPointsWithRect(uiTabPins->listWidgetPins, false); } else { @@ -2868,6 +2873,15 @@ void DialogSeamAllowance::InitPassmarksTab() void DialogSeamAllowance::InitPlaceLabelsTab() { uiTabPlaceLabels->listWidgetPlaceLabels->setContextMenuPolicy(Qt::CustomContextMenu); + connect(uiTabPlaceLabels->listWidgetPlaceLabels, &QListWidget::currentRowChanged, this, [this]() + { + if (not m_visSpecialPoints.isNull()) + { + m_visSpecialPoints->SetShowRect(true); + m_visSpecialPoints->SetRect(CurrentRect()); + m_visSpecialPoints->RefreshGeometry(); + } + }); connect(uiTabPlaceLabels->listWidgetPlaceLabels, &QListWidget::customContextMenuRequested, this, &DialogSeamAllowance::ShowPlaceLabelsContextMenu); } @@ -3126,7 +3140,20 @@ void DialogSeamAllowance::SetPLAngle(QString angleFormula) } //--------------------------------------------------------------------------------------------------------------------- -void DialogSeamAllowance::ShowPieceSpecialPoints(const QListWidget *list) +QRectF DialogSeamAllowance::CurrentRect() const +{ + QRectF rect; + if (QListWidgetItem *item = uiTabPlaceLabels->listWidgetPlaceLabels->currentItem()) + { + VPlaceLabelItem label = CurrentPlaceLabel(qvariant_cast(item->data(Qt::UserRole))); + rect = QRectF(QPointF(label.x() - label.GetWidth()/2.0, label.y() - label.GetHeight()/2.0), + QPointF(label.x() + label.GetWidth()/2.0, label.y() + label.GetHeight()/2.0)); + } + return rect; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::ShowPieceSpecialPointsWithRect(const QListWidget *list, bool showRect) { SCASSERT(list != nullptr) if (m_visSpecialPoints.isNull()) @@ -3135,6 +3162,8 @@ void DialogSeamAllowance::ShowPieceSpecialPoints(const QListWidget *list) } m_visSpecialPoints->SetPoints(GetListInternals(list)); + m_visSpecialPoints->SetShowRect(showRect); + m_visSpecialPoints->SetRect(CurrentRect()); if (not qApp->getCurrentScene()->items().contains(m_visSpecialPoints)) { diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index 2e8883f99..0303102b9 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -268,7 +268,8 @@ private: void SetPLHeight(QString heightFormula); void SetPLAngle(QString angleFormula); - void ShowPieceSpecialPoints(const QListWidget *list); + QRectF CurrentRect() const; + void ShowPieceSpecialPointsWithRect(const QListWidget *list, bool showRect); VPiecePath CurrentPath(quint32 id) const; VPlaceLabelItem CurrentPlaceLabel(quint32 id) const; diff --git a/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp b/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp index dfae65144..27e361dc8 100644 --- a/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp +++ b/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp @@ -31,12 +31,31 @@ #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" +namespace +{ +QPainterPath RectPath(const QRectF &rect) +{ + QPainterPath path; + if (not rect.isNull()) + { + path.addRect(rect); + } + return path; +} +} + //--------------------------------------------------------------------------------------------------------------------- VisPieceSpecialPoints::VisPieceSpecialPoints(const VContainer *data, QGraphicsItem *parent) : VisPath(data, parent), m_points(), - m_spoints() + m_spoints(), + m_showRect(false), + m_placeLabelRect(), + m_rectItem(nullptr), + supportColor2(Qt::darkGreen) { + m_rectItem = InitItem(supportColor2, this); + m_rectItem->SetWidth(widthHairLine); } //--------------------------------------------------------------------------------------------------------------------- @@ -51,13 +70,12 @@ void VisPieceSpecialPoints::RefreshGeometry() const QSharedPointer p = Visualization::data->GeometricObject(m_spoints.at(i)); point->RefreshPointGeometry(*p); point->setVisible(true); - } -} -//--------------------------------------------------------------------------------------------------------------------- -void VisPieceSpecialPoints::SetPoints(const QVector &pins) -{ - m_spoints = pins; + if (m_showRect) + { + DrawPath(m_rectItem, RectPath(m_placeLabelRect), supportColor2, Qt::SolidLine, Qt::RoundCap); + } + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/path/vispiecespecialpoints.h b/src/libs/vtools/visualization/path/vispiecespecialpoints.h index de54da8c9..859757c66 100644 --- a/src/libs/vtools/visualization/path/vispiecespecialpoints.h +++ b/src/libs/vtools/visualization/path/vispiecespecialpoints.h @@ -41,17 +41,43 @@ public: virtual ~VisPieceSpecialPoints() Q_DECL_EQ_DEFAULT; virtual void RefreshGeometry() Q_DECL_OVERRIDE; - void SetPoints(const QVector &pins); + + void SetPoints(const QVector &pins); + void SetShowRect(bool show); + void SetRect(const QRectF &rect); + virtual int type() const Q_DECL_OVERRIDE {return Type;} enum { Type = UserType + static_cast(Vis::PieceSpecialPoints)}; private: Q_DISABLE_COPY(VisPieceSpecialPoints) QVector m_points; QVector m_spoints; + bool m_showRect; + QRectF m_placeLabelRect; + VCurvePathItem *m_rectItem; + QColor supportColor2; VSimplePoint *GetPoint(quint32 i, const QColor &color); void HideAllItems(); }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisPieceSpecialPoints::SetPoints(const QVector &pins) +{ + m_spoints = pins; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisPieceSpecialPoints::SetShowRect(bool show) +{ + m_showRect = show; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisPieceSpecialPoints::SetRect(const QRectF &rect) +{ + m_placeLabelRect = rect; +} + #endif // VISPIECESPECIALPOINTS_H diff --git a/src/libs/vwidgets/vcurvepathitem.cpp b/src/libs/vwidgets/vcurvepathitem.cpp index e87c2ef5e..b6568e31c 100644 --- a/src/libs/vwidgets/vcurvepathitem.cpp +++ b/src/libs/vwidgets/vcurvepathitem.cpp @@ -36,7 +36,8 @@ VCurvePathItem::VCurvePathItem(QGraphicsItem *parent) : QGraphicsPathItem(parent), m_directionArrows(), - m_points() + m_points(), + m_defaultWidth(widthMainLine) { } @@ -107,10 +108,16 @@ void VCurvePathItem::SetPoints(const QVector &points) m_points = points; } +//--------------------------------------------------------------------------------------------------------------------- +void VCurvePathItem::SetWidth(qreal width) +{ + m_defaultWidth = width; +} + //--------------------------------------------------------------------------------------------------------------------- void VCurvePathItem::ScalePenWidth() { - const qreal width = ScaleWidth(widthMainLine, SceneScale(scene())); + const qreal width = ScaleWidth(m_defaultWidth, SceneScale(scene())); QPen toolPen = pen(); toolPen.setWidthF(width); diff --git a/src/libs/vwidgets/vcurvepathitem.h b/src/libs/vwidgets/vcurvepathitem.h index a0d3cd356..7d35ca3d7 100644 --- a/src/libs/vwidgets/vcurvepathitem.h +++ b/src/libs/vwidgets/vcurvepathitem.h @@ -50,6 +50,7 @@ public: void SetDirectionArrows(const QVector> &arrows); void SetPoints(const QVector &points); + void SetWidth(qreal width); protected: virtual void ScalePenWidth(); private: @@ -57,6 +58,7 @@ private: QVector> m_directionArrows; QVector m_points; + qreal m_defaultWidth; }; #endif // VCURVEPATHITEM_H From 89a2323944e2a50ff33fc8267ec00e539ba72507 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 24 Oct 2017 19:50:16 +0300 Subject: [PATCH 13/15] Fix problem with updating objects inside vcontainer. --HG-- branch : feature --- src/libs/vpatterndb/vcontainer.cpp | 37 --------------- src/libs/vpatterndb/vcontainer.h | 73 +++++++++++++++++++++++++++--- 2 files changed, 67 insertions(+), 43 deletions(-) diff --git a/src/libs/vpatterndb/vcontainer.cpp b/src/libs/vpatterndb/vcontainer.cpp index 5457a88d0..10caece95 100644 --- a/src/libs/vpatterndb/vcontainer.cpp +++ b/src/libs/vpatterndb/vcontainer.cpp @@ -249,22 +249,6 @@ void VContainer::UpdateId(quint32 newId) } } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief UpdateObject update object in container - * @param id id of existing object - * @param point object - */ -template -void VContainer::UpdateObject(const quint32 &id, val point) -{ - Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712 - SCASSERT(point.isNull() == false) - point->setId(id); - d->gObjects.insert(id, point); - UpdateId(id); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief Clear clear data in container. Id will be 0. @@ -497,27 +481,6 @@ quint32 VContainer::AddObject(QHash &obj, val value) return id; } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief UpdateGObject update GObject by id - * @param id id of existing GObject - * @param obj object - */ -void VContainer::UpdateGObject(quint32 id, VGObject* obj) -{ - SCASSERT(obj != nullptr) - QSharedPointer pointer(obj); - UpdateGObject(id, pointer); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VContainer::UpdateGObject(quint32 id, const QSharedPointer &obj) -{ - SCASSERT(not obj.isNull()) - UpdateObject(id, obj); - uniqueNames.insert(obj->name()); -} - //--------------------------------------------------------------------------------------------------------------------- void VContainer::UpdatePiece(quint32 id, const VPiece &detail) { diff --git a/src/libs/vpatterndb/vcontainer.h b/src/libs/vpatterndb/vcontainer.h index 0d6850d02..2837bbddd 100644 --- a/src/libs/vpatterndb/vcontainer.h +++ b/src/libs/vpatterndb/vcontainer.h @@ -160,8 +160,10 @@ public: void RemoveVariable(const QString& name); void RemovePiece(quint32 id); - void UpdateGObject(quint32 id, VGObject* obj); - void UpdateGObject(quint32 id, const QSharedPointer &obj); + template + void UpdateGObject(quint32 id, T* obj); + template + void UpdateGObject(quint32 id, const QSharedPointer &obj); void UpdatePiece(quint32 id, const VPiece &detail); void UpdatePiecePath(quint32 id, const VPiecePath &path); @@ -221,8 +223,8 @@ private: // cppcheck-suppress functionStatic const val GetObject(const QHash &obj, key id) const; - template - void UpdateObject(const quint32 &id, val point); + template + void UpdateObject(const quint32 &id, const QSharedPointer &point); template static quint32 AddObject(QHash &obj, val value); @@ -312,14 +314,23 @@ void VContainer::AddVariable(const QString& name, const QSharedPointer &var) { if (d->variables.value(name)->GetType() == var->GetType()) { - d->variables[name].clear(); + QSharedPointer v = qSharedPointerDynamicCast(d->variables.value(name)); + if (v.isNull()) + { + throw VExceptionBadId(tr("Can't cast object."), name); + } + *v = *var; } else { throw VExceptionBadId(tr("Can't find object. Type mismatch."), name); } } - d->variables.insert(name, var); + else + { + d->variables.insert(name, var); + } + uniqueNames.insert(name); } @@ -329,4 +340,54 @@ uint VContainer::qHash( const QSharedPointer &p ) { return qHash( p.data() ); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateGObject update GObject by id + * @param id id of existing GObject + * @param obj object + */ +template +void VContainer::UpdateGObject(quint32 id, T* obj) +{ + SCASSERT(obj != nullptr) + UpdateGObject(id, QSharedPointer(obj)); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void VContainer::UpdateGObject(quint32 id, const QSharedPointer &obj) +{ + SCASSERT(not obj.isNull()) + UpdateObject(id, obj); + uniqueNames.insert(obj->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateObject update object in container + * @param id id of existing object + * @param point object + */ +template +void VContainer::UpdateObject(const quint32 &id, const QSharedPointer &point) +{ + Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712 + SCASSERT(point.isNull() == false) + point->setId(id); + if (d->gObjects.contains(id)) + { + QSharedPointer obj = qSharedPointerDynamicCast(d->gObjects.value(id)); + if (obj.isNull()) + { + throw VExceptionBadId(tr("Can't cast object"), id); + } + *obj = *point; + } + else + { + d->gObjects.insert(id, point); + } + UpdateId(id); +} #endif // VCONTAINER_H From 7fce20c98eac14789124496b19b7e292c78fada1 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 24 Oct 2017 20:25:51 +0300 Subject: [PATCH 14/15] Removed redundant calls UpdateGObject(). Undocommand for piece label. --HG-- branch : feature --- .../operation/vabstractoperation.cpp | 3 +- .../drawTools/operation/vabstractoperation.h | 2 +- .../tooldoublepoint/vtooldoublepoint.cpp | 4 +- .../tooldoublepoint/vtooldoublepoint.h | 2 +- .../toolsinglepoint/vtoolsinglepoint.cpp | 3 +- .../toolsinglepoint/vtoolsinglepoint.h | 2 +- src/libs/vtools/tools/drawTools/vdrawtool.cpp | 7 ---- src/libs/vtools/tools/drawTools/vdrawtool.h | 1 - .../vtools/tools/nodeDetails/vnodepoint.cpp | 41 ++++++++----------- .../vtools/tools/nodeDetails/vnodepoint.h | 3 +- src/libs/vtools/tools/vabstracttool.cpp | 7 ++++ src/libs/vtools/tools/vabstracttool.h | 1 + .../undocommands/label/movedoublelabel.cpp | 2 +- .../vtools/undocommands/label/movelabel.cpp | 7 ++-- .../undocommands/label/operationmovelabel.cpp | 2 +- 15 files changed, 39 insertions(+), 48 deletions(-) diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp index 7db3e3a49..16eb41479 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp @@ -86,7 +86,7 @@ void VAbstractOperation::paint(QPainter *painter, const QStyleOptionGraphicsItem } //--------------------------------------------------------------------------------------------------------------------- -void VAbstractOperation::DoChangePosition(quint32 id, const QPointF &pos) +void VAbstractOperation::ChangeLabelPosition(quint32 id, const QPointF &pos) { if (operatedObjects.contains(id)) { @@ -98,7 +98,6 @@ void VAbstractOperation::DoChangePosition(quint32 id, const QPointF &pos) QSharedPointer point = VAbstractTool::data.GeometricObject(id); point->setMx(pos.x()); point->setMy(pos.y()); - VAbstractTool::data.UpdateGObject(id, point); item->RefreshPointGeometry(*(point.data())); } } diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h index 1137bc6e0..ea1c1fd29 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h @@ -87,7 +87,7 @@ public: virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE; - virtual void DoChangePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE; + virtual void ChangeLabelPosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE; virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE; virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp index e384bf580..a8025c93b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp @@ -220,14 +220,13 @@ void VToolDoublePoint::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- -void VToolDoublePoint::DoChangePosition(quint32 id, const QPointF &pos) +void VToolDoublePoint::ChangeLabelPosition(quint32 id, const QPointF &pos) { if (id == p1id) { QSharedPointer point = VAbstractTool::data.GeometricObject(p1id); point->setMx(pos.x()); point->setMy(pos.y()); - VAbstractTool::data.UpdateGObject(p1id, point); firstPoint->RefreshPointGeometry(*(point.data())); } else if (id == p2id) @@ -235,7 +234,6 @@ void VToolDoublePoint::DoChangePosition(quint32 id, const QPointF &pos) QSharedPointer point = VAbstractTool::data.GeometricObject(p2id); point->setMx(pos.x()); point->setMy(pos.y()); - VAbstractTool::data.UpdateGObject(p2id, point); secondPoint->RefreshPointGeometry(*(point.data())); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h index 4e5cdd720..f384d47fa 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h @@ -63,7 +63,7 @@ public: void setNameP2(const QString &name); virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; - virtual void DoChangePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE; + virtual void ChangeLabelPosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE; virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE; virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index dae587b22..b0b212de5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -324,14 +324,13 @@ void VToolSinglePoint::ChangeLabelVisibility(quint32 id, bool visible) } //--------------------------------------------------------------------------------------------------------------------- -void VToolSinglePoint::DoChangePosition(quint32 id, const QPointF &pos) +void VToolSinglePoint::ChangeLabelPosition(quint32 id, const QPointF &pos) { if (id == m_id) { QSharedPointer point = VAbstractTool::data.GeometricObject(id); point->setMx(pos.x()); point->setMy(pos.y()); - VAbstractTool::data.UpdateGObject(id, point); m_namePoint->blockSignals(true); m_namePoint->setPos(pos); m_namePoint->blockSignals(false); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h index 02a863768..51c195fe5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h @@ -79,7 +79,7 @@ public: void SetEnabled(bool enabled); virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; - virtual void DoChangePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE; + virtual void ChangeLabelPosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE; virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE; virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index 96ba1f547..87f0f34a4 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -269,10 +269,3 @@ void VDrawTool::SetLabelVisible(quint32 id, bool visible) Q_UNUSED(id) Q_UNUSED(visible) } - -//--------------------------------------------------------------------------------------------------------------------- -void VDrawTool::DoChangePosition(quint32 id, const QPointF &pos) -{ - Q_UNUSED(id) - Q_UNUSED(pos) -} diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index 6f21f6f46..b39f5d33b 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -69,7 +69,6 @@ public: virtual bool IsLabelVisible(quint32 id) const; virtual void SetLabelVisible(quint32 id, bool visible); - virtual void DoChangePosition(quint32 id, const QPointF &pos); signals: void ChangedToolSelection(bool selected, quint32 object, quint32 tool); diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp index d7681b648..721907088 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp @@ -54,6 +54,7 @@ #include "../vabstracttool.h" #include "../vdatatool.h" #include "vabstractnode.h" +#include "../../undocommands/label/movelabel.h" const QString VNodePoint::ToolType = QStringLiteral("modeling"); @@ -126,6 +127,21 @@ QString VNodePoint::getTagName() const return VAbstractPattern::TagPoint; } +//--------------------------------------------------------------------------------------------------------------------- +void VNodePoint::ChangeLabelPosition(quint32 id, const QPointF &pos) +{ + if (id == m_id) + { + QSharedPointer point = VAbstractTool::data.GeometricObject(id); + point->setMx(pos.x()); + point->setMy(pos.y()); + m_namePoint->blockSignals(true); + m_namePoint->setPos(pos); + m_namePoint->blockSignals(false); + RefreshLine(); + } +} + //--------------------------------------------------------------------------------------------------------------------- void VNodePoint::PointChoosed() { @@ -199,30 +215,7 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) */ void VNodePoint::NameChangePosition(const QPointF &pos) { - VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject(m_id)); - QPointF p = pos - this->pos(); - point->setMx(p.x()); - point->setMy(p.y()); - RefreshLine(); - UpdateNamePosition(point->mx(), point->my()); - VAbstractTool::data.UpdateGObject(m_id, point); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief UpdateNamePosition update label position in file. - * @param mx label bias x axis. - * @param my label bias y axis. - */ -void VNodePoint::UpdateNamePosition(qreal mx, qreal my) -{ - QDomElement domElement = doc->elementById(m_id, getTagName()); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx))); - doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(my))); - emit toolhaveChange(); - } + qApp->getUndoStack()->push(new MoveLabel(doc, pos - this->pos(), m_id)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.h b/src/libs/vtools/tools/nodeDetails/vnodepoint.h index 81c47c267..30ee4380d 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.h +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.h @@ -57,6 +57,8 @@ public: enum { Type = UserType + static_cast(Tool::NodePoint)}; virtual QString getTagName() const Q_DECL_OVERRIDE; + virtual void ChangeLabelPosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE; + signals: /** * @brief ShowContextMenu emit when need show tool context menu. @@ -77,7 +79,6 @@ protected: virtual void AddToFile() Q_DECL_OVERRIDE; virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE; virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; - virtual void UpdateNamePosition(qreal mx, qreal my); virtual void ShowNode() Q_DECL_OVERRIDE; virtual void HideNode() Q_DECL_OVERRIDE; virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index 7228a96c9..07d94fffe 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -397,6 +397,13 @@ QMap VAbstractTool::PointsList() const return list; } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractTool::ChangeLabelPosition(quint32 id, const QPointF &pos) +{ + Q_UNUSED(id) + Q_UNUSED(pos) +} + //--------------------------------------------------------------------------------------------------------------------- void VAbstractTool::ToolSelectionType(const SelectionType &type) { diff --git a/src/libs/vtools/tools/vabstracttool.h b/src/libs/vtools/tools/vabstracttool.h index 7af08426e..585de3903 100644 --- a/src/libs/vtools/tools/vabstracttool.h +++ b/src/libs/vtools/tools/vabstracttool.h @@ -108,6 +108,7 @@ public: QMap PointsList() const; virtual QString getTagName() const =0; virtual void ShowVisualization(bool show) =0; + virtual void ChangeLabelPosition(quint32 id, const QPointF &pos); template static quint32 CreateNode(VContainer *data, quint32 id); diff --git a/src/libs/vtools/undocommands/label/movedoublelabel.cpp b/src/libs/vtools/undocommands/label/movedoublelabel.cpp index 13e8878c7..8cc724ecc 100644 --- a/src/libs/vtools/undocommands/label/movedoublelabel.cpp +++ b/src/libs/vtools/undocommands/label/movedoublelabel.cpp @@ -146,7 +146,7 @@ void MoveDoubleLabel::Do(const QPointF &pos) if (VDrawTool *tool = qobject_cast(VAbstractPattern::getTool(m_idTool))) { - tool->DoChangePosition(nodeId, pos); + tool->ChangeLabelPosition(nodeId, pos); } VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView()); } diff --git a/src/libs/vtools/undocommands/label/movelabel.cpp b/src/libs/vtools/undocommands/label/movelabel.cpp index a0792856a..46ae8e487 100644 --- a/src/libs/vtools/undocommands/label/movelabel.cpp +++ b/src/libs/vtools/undocommands/label/movelabel.cpp @@ -37,7 +37,8 @@ #include "../vmisc/vabstractapplication.h" #include "../vundocommand.h" #include "moveabstractlabel.h" -#include "../vtools/tools/drawTools/vdrawtool.h" +#include "../vtools/tools/vabstracttool.h" +#include "../vwidgets/vmaingraphicsview.h" //--------------------------------------------------------------------------------------------------------------------- MoveLabel::MoveLabel(VAbstractPattern *doc, const QPointF &pos, const quint32 &id, QUndoCommand *parent) @@ -97,9 +98,9 @@ void MoveLabel::Do(const QPointF &pos) doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(pos.x()))); doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(pos.y()))); - if (VDrawTool *tool = qobject_cast(VAbstractPattern::getTool(nodeId))) + if (VAbstractTool *tool = qobject_cast(VAbstractPattern::getTool(nodeId))) { - tool->DoChangePosition(nodeId, pos); + tool->ChangeLabelPosition(nodeId, pos); } VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView()); } diff --git a/src/libs/vtools/undocommands/label/operationmovelabel.cpp b/src/libs/vtools/undocommands/label/operationmovelabel.cpp index d2cc93752..cd3cea064 100644 --- a/src/libs/vtools/undocommands/label/operationmovelabel.cpp +++ b/src/libs/vtools/undocommands/label/operationmovelabel.cpp @@ -104,7 +104,7 @@ void OperationMoveLabel::Do(const QPointF &pos) if (VDrawTool *tool = qobject_cast(VAbstractPattern::getTool(m_idTool))) { - tool->DoChangePosition(nodeId, pos); + tool->ChangeLabelPosition(nodeId, pos); } VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView()); } From d463dc364ac41e7e1c682cbfc6f89290dfa06610 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 25 Oct 2017 10:21:09 +0300 Subject: [PATCH 15/15] Update changelog. --HG-- branch : feature --- ChangeLog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index d16d4cfad..9712a5c7e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -27,6 +27,7 @@ - [#765] New feature. Free curve mode. - [#657] Improve feature: Allow more paper formats for printing tiled PDF - [#768] New feature. Custom curve approximation scale. +- [#759] Add place label tool. # Version 0.5.1 - [#683] Tool Seam allowance's dialog is off screen on small resolutions.