From 9b54b0c069d4d7af8c8c1ba519b1aef0f3fcd69d Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 25 Oct 2017 17:49:04 +0300 Subject: [PATCH 1/5] Dialog Duplicate Detail. --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 | 28 ++- src/app/valentina/share/resources/cursor.qrc | 2 + .../cursor/duplicate_detail_cursor.png | Bin 0 -> 902 bytes .../cursor/duplicate_detail_cursor@2x.png | Bin 0 -> 1939 bytes .../valentina/share/resources/toolicon.qrc | 2 + .../toolicon/32x32/duplicate_detail.png | Bin 0 -> 1462 bytes .../toolicon/32x32/duplicate_detail@2x.png | Bin 0 -> 2940 bytes .../toolicon/svg/duplicate_detail.svg | 194 ++++++++++++++++++ src/app/valentina/xml/vpattern.cpp | 3 +- src/libs/ifc/xml/vabstractpattern.cpp | 16 +- src/libs/vmisc/def.h | 2 + src/libs/vtools/dialogs/dialogs.pri | 9 +- src/libs/vtools/dialogs/tooldialogs.h | 1 + .../tools/piece/dialogduplicatedetail.cpp | 93 +++++++++ .../tools/piece/dialogduplicatedetail.h | 80 ++++++++ .../tools/piece/dialogduplicatedetail.ui | 80 ++++++++ src/libs/vtools/tools/vtoolseamallowance.cpp | 35 +++- src/libs/vtools/tools/vtoolseamallowance.h | 3 + .../path/vistoolduplicatedetail.cpp | 69 +++++++ .../path/vistoolduplicatedetail.h | 68 ++++++ .../vtools/visualization/visualization.pri | 6 +- 25 files changed, 718 insertions(+), 31 deletions(-) create mode 100644 src/app/valentina/share/resources/cursor/duplicate_detail_cursor.png create mode 100644 src/app/valentina/share/resources/cursor/duplicate_detail_cursor@2x.png create mode 100644 src/app/valentina/share/resources/toolicon/32x32/duplicate_detail.png create mode 100644 src/app/valentina/share/resources/toolicon/32x32/duplicate_detail@2x.png create mode 100644 src/app/valentina/share/resources/toolicon/svg/duplicate_detail.svg create mode 100644 src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp create mode 100644 src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.h create mode 100644 src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.ui create mode 100644 src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp create mode 100644 src/libs/vtools/visualization/path/vistoolduplicatedetail.h diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 0e6bfe0c7..f4bfc1d12 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) == 54, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "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) == 54, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "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) == 54, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "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 aa01d7f64..3a767a7cf 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) == 54, "Not all tools were used in history."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used in history."); const QDomElement domElem = doc->elementById(tool.getId()); if (domElem.isElement() == false) @@ -408,6 +408,7 @@ QString DialogHistory::Record(const VToolRecord &tool) case Tool::Pin: case Tool::PlaceLabel: case Tool::InsertNode: + case Tool::DuplicateDetail: return QString(); } } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index ba1faff63..a15642ffa 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -613,7 +613,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons 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."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Check if need to extend."); switch(t) { @@ -1107,8 +1107,32 @@ void MainWindow::ToolUnionDetails(bool checked) */ void MainWindow::ClosedDialogUnionDetails(int result) { - ClosedDialog(result); - doc->LiteParseTree(Document::LiteParse); + ClosedDialog(result);// Avoid error: Template function as signal or slot +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolDuplicateDetail(bool checked) +{ + ToolSelectDetail(); + SetToolButton(checked, Tool::DuplicateDetail, ":/cursor/duplicate_detail_cursor.png", + tr("Select detail"), &MainWindow::ClosedDialogDuplicateDetail); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ClosedDialogDuplicateDetail(int result) +{ + SCASSERT(not dialogTool.isNull()) + if (result == QDialog::Accepted) + { + VMainGraphicsScene *scene = qobject_cast(currentScene); + SCASSERT(scene != nullptr) + + QGraphicsItem *tool = dynamic_cast(VToolSeamAllowance::Duplicate(dialogTool, scene, doc, + pattern)); + // Do not check for nullptr! See issue #719. + ui->view->itemClicked(tool); + } + ArrowTool(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1985,7 +2009,7 @@ void MainWindow::InitToolButtons() } // This check helps to find missed tools - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Check if all tools were connected."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Check if all tools were connected."); connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine); connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine); @@ -2008,6 +2032,7 @@ void MainWindow::InitToolButtons() connect(ui->toolButtonSplineCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSpline); connect(ui->toolButtonSplinePathCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSplinePath); connect(ui->toolButtonUnionDetails, &QToolButton::clicked, this, &MainWindow::ToolUnionDetails); + connect(ui->toolButtonDuplicateDetail, &QToolButton::clicked, this, &MainWindow::ToolDuplicateDetail); connect(ui->toolButtonArcCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutArc); connect(ui->toolButtonLineIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolLineIntersectAxis); connect(ui->toolButtonCurveIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis); @@ -2062,7 +2087,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) == 54, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were handled."); qCDebug(vMainWindow, "Canceling tool."); dialogTool.clear(); @@ -2172,6 +2197,9 @@ void MainWindow::CancelTool() case Tool::UnionDetails: ui->toolButtonUnionDetails->setChecked(false); break; + case Tool::DuplicateDetail: + ui->toolButtonDuplicateDetail->setChecked(false); + break; case Tool::CutArc: ui->toolButtonArcCutPoint->setChecked(false); break; @@ -3424,7 +3452,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") QT_WARNING_POP // This check helps to find missed tools - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were handled."); //Drawing Tools ui->toolButtonEndLine->setEnabled(drawTools); @@ -3480,6 +3508,7 @@ QT_WARNING_POP //Modeling Tools ui->toolButtonUnionDetails->setEnabled(modelingTools); ui->toolButtonDetailExportAs->setEnabled(modelingTools); + ui->toolButtonDuplicateDetail->setEnabled(modelingTools); //Layout tools ui->toolButtonLayoutSettings->setEnabled(layoutTools); @@ -3752,7 +3781,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) == 54, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were handled."); if (currentTool == lastUsedTool) { @@ -3875,6 +3904,10 @@ void MainWindow::LastUsedTool() ui->toolButtonUnionDetails->setChecked(true); ToolUnionDetails(true); break; + case Tool::DuplicateDetail: + ui->toolButtonDuplicateDetail->setChecked(true); + ToolDuplicateDetail(true); + break; case Tool::CutArc: ui->toolButtonArcCutPoint->setChecked(true); ToolCutArc(true); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 47e6a76a0..386f04058 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -150,6 +150,7 @@ private slots: void ToolTriangle(bool checked); void ToolPointOfIntersection(bool checked); void ToolUnionDetails(bool checked); + void ToolDuplicateDetail(bool checked); void ToolGroup(bool checked); void ToolRotation(bool checked); void ToolFlippingByLine(bool checked); @@ -178,6 +179,7 @@ private slots: void Open(); void ClosedDialogUnionDetails(int result); + void ClosedDialogDuplicateDetail(int result); void ClosedDialogGroup(int result); void ClosedDialogPiecePath(int result); void ClosedDialogPin(int result); diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index b81b324b6..f2ae0f667 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -48,7 +48,7 @@ Export details skiping the Layout stage - 7 + 6 @@ -1550,6 +1550,32 @@ + + + + false + + + Duplicate detail tool + + + ... + + + + :/toolicon/32x32/duplicate_detail.png:/toolicon/32x32/duplicate_detail.png + + + + 32 + 32 + + + + true + + + diff --git a/src/app/valentina/share/resources/cursor.qrc b/src/app/valentina/share/resources/cursor.qrc index 1ef61e19d..52afe1836 100644 --- a/src/app/valentina/share/resources/cursor.qrc +++ b/src/app/valentina/share/resources/cursor.qrc @@ -86,5 +86,7 @@ cursor/insert_node_cursor@2x.png cursor/place_label_cursor@2x.png cursor/place_label_cursor.png + cursor/duplicate_detail_cursor.png + cursor/duplicate_detail_cursor@2x.png diff --git a/src/app/valentina/share/resources/cursor/duplicate_detail_cursor.png b/src/app/valentina/share/resources/cursor/duplicate_detail_cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..9ce8097ec137759e752004c5f45d04db22006c42 GIT binary patch literal 902 zcmV;119|+3P)bZ!Y(XgRMN0!8I~W-rXG*;+jHJ7obELI z+@{|22f+v4^FBY`=bWR!|Li6R;BqGc9Drme5gY)rgSgU3K*tb#Kt~Yl9zfd>l>lu; zR0FgPQK$iE3!)yN<%mWAEk)!T1hfp%44@^5W&wwe$n67gsEGXn{y|JlO-Zd*t7(0G z{oU;BtN{RKW@ZK)4#$J#<>lM00uTVn>FMdGKA-P9$8m%ZLTomhb!~0!Su`3=5<-Z_ z<8h6Qj7X{hvIhhZnM_9Pb~`D>>-7?TIF2Jur*p|{HmfQDGF3L_(8LX@R;$YmeLf$l zl$Dj0@+gG0W`g4H0}bFj071Qv%jJ3%3_j*NebtH1-92z&9W>+B2l@1X^r2FbvKSf#J>@=ZmpgPeDV`YPCoCH6aA0Q2@ZkueXS#-2h1OE)&G?hw)1Q zNMiIBbzp#0Dm}ul6Nv7B3xxs!0JHHSuAaWN7~cHzI-aBvp(E%moO)up`~K4N`He3J zK7omeiI3ysP)6yZH3BW%9EVDh4*%BE# zTCqSOkTJ(C0E=gLIx{a3;Sd&FBuEGcu;3!$=?GYG5Cq5rSTGQx0ay?acti&C@jo-NufgLx{QpB*BFM`d*Z|iKH7k)1Wi0qS_YsI;Sdx%ckaw7 zE-rqxy1M#}%F4>;^?JR+<#LsbxsKYjX_L9EtZYklb@khom6a>}e!sM5&z?g7+Txu= zH)baV!qP#f(>+&PTU&bU*s;%BT3Wmu$C0r*ckWzEMMXv0jvYG+j~qGjQBzaX-TwZ5 zao8?N64}3h|ABa&2Y{|506QK# zSFescos$9p0J3b^GSc4OE(_rN`SXP5d0E@ASeBJeo;-P`w6rv?*Zbbtc03jc&CSgu z7z{=QKnNiW!-y9yT)0+OSGNl>*1V3{cKYdK)v8qyjyau9(%s!XApk-`_2Ba5%Qpd} zKkcj{79z7PtyUXx&Sta0?RLj>Jw;K_YPAZ;Ec=N7K!!dq0LT~`WXeZ|@}iJQ)-G#ZT(@>}(UYO(-&0c;2GXJV%_Dy!AH zSgBMhr>p;AP3B&}4PYxmH!jm9s<5zdYf4JWxG5S824z==colCE{2PEB)9XC8ZQHi4 zs;X)|MU9^UEiEl5DJdD(9;@O>finPhBlP+_p(-ygS7&8qWf=?xU2bmf=GxlY5AyT# z!!|8E&qEYNNRkAn(}~Q?Or)l!M)bw<0bFeT0lfpABaRrfG*TI>?AWma_yoX*n5L?1 zu~@1O9z6J~*=$x=tyZmCt&V8pa5!Kz8bMJM3JVL7o*uEO0|0dN{)@hWF4U~t3yM+# zAZWVzGuk??$+n-U28aOa0346Yqc~+UnU>h?cAY{o{;I6eXs~kS$_e`tMFHN&_t1R% z6oymizfKnTOgb*g(9?pp$O5Xq)__Q(Uf2q7K8mkfEo>pAj1TJBmtmMC?dCX zW90MsuypBCS=+wt^|*1zfq{Vm>Ed4vXM&`cO`{FF@(LEKhIi7P9X(Jm={+9ry>HbT z1p^8MM7jzj2>_a=b0FS8t@8eRrD zj)j#j>i+6*<6(r}evc?A05mi-9PjGtDz;cGFBpx+%>4ZPl(9MQ^Z5b}hr>nFbWToA zPP)ltir6(doz7N|$8&elBEigYELffyd78lSEF@8s9Xlxi)YsR)Z?oC71qB6kZf>r{ zY&KVAXJ?lb6&0;DnN0aTJv}!M960b&d3m`ZD=Vv1qtU!rQ&aPn(P-2d3!AF02~KtoTW4=004l?~?#K)oM*?Yil#O-EP0z z?e+uk6crUYd_LbDLWq`O7?o0~)O)?&9|3?B(TTpnz6ZAjEg>NU93yZK2ivb9^ktoolicon/32x32/insert_node@2x.png toolicon/32x32/place_label@2x.png toolicon/32x32/place_label.png + toolicon/32x32/duplicate_detail.png + toolicon/32x32/duplicate_detail@2x.png diff --git a/src/app/valentina/share/resources/toolicon/32x32/duplicate_detail.png b/src/app/valentina/share/resources/toolicon/32x32/duplicate_detail.png new file mode 100644 index 0000000000000000000000000000000000000000..ac021c364730bb6981075783ab6be5c991790a79 GIT binary patch literal 1462 zcmV;n1xfmeP))7q4_oHIT^ReJ>p($aB1PFnXT?ih@yGsb;1mZ$C7qwkJ7pMfUtU=l$Nx^IrJgkHQO}q@-kJM@PqJJ9g~&dUkg9?%3Gah@4(^ zb+vu__U)Y>k7sQ(8jZe43|Z9G)j4V_Df05t-U^svN{JmU(GdOeR49T=3ANu?IM_O81{JDZrGBTmDu`y6xUG2`ta%yS{ z<>lpy**Kj}v)yhFXfzsCG#b4MfG8U6+qds4rOYCc2oXh5u>u(|3`06QJG&RhQp*vz ze*O9_Ns{uCbi3Uc9UWCnCIg*L2ZzIvWfB)~}7jR4<1B0DgXcKDlh~%OC(0GOaI@fLg8A{ci+ZE?0R)MTJetn2_ZcNtQr! zbMu=nm&+h`mO&zsfZ1%$r}EzjxLht%AP{&*$#8IR5I&!8*#u|+DgY}1kd~H~<}F*c ze6)4z*1B84E%4wr^cL9cm2l0d@jd;%IGELncE&1PGz6g-tm!DKQO z6dV9}jzgNAhaj@gWGu_c>e4owZIzP42M->gq@<)^0)ilbuzdQN?31?-p~$e>48WYx+5f|b>u96V zs7N5+)=Q`75E}djdTsXJl8A`8^z*wc{MRwiRQ5SQK=AOCa` zno{f5x*aRk3tBfBPvG&~V^)y(xr~hC_(uh`fMwatjk*N8wjIN*@geX$hZCod{4|!h z_`RB}UmUxz(4Ow@?*7v2^?EE8OQpqP@%a6I z>*9SdJUl!qisH1*W~;2Ntz9E`D~7}2sZc2N8vw8Z2aaPPE~tRO^8k^#hz=h2yLenKbnD^mvoWWO#v}E3tp>)zOsJsHW5^LI8*=?)K=!&|(7r0`E`A2P@cY QPXGV_07*qoM6N<$g7(F*cK`qY literal 0 HcmV?d00001 diff --git a/src/app/valentina/share/resources/toolicon/32x32/duplicate_detail@2x.png b/src/app/valentina/share/resources/toolicon/32x32/duplicate_detail@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..a4fc05ae0fe4e8e7664e511eba0474ce82363e39 GIT binary patch literal 2940 zcmV-?3xo8DP);I#;&%t+U;sm>$)mzS_`QUqCC1H z!gRoKa0gHaX6BxA_K!ge$UN@c3uO0`K*;5s?>Xmp&+pvd`JDqy4TiF^vVAL8uDofn zSYDJWW;UCjEh#B^PmYdFDr&X*XH`{Ihj#AVdCTkdGQZ!?91cfaf^tc-XU|^0bm`LX z4jeczxN+mgYjX6FmqTP6oW){UJ8Rag->zA+X70v~8#5IO#iM^_Wo11nQct^J!Gc$d zi;I_U+qP|%)9F+IKzDby4uBTGfP7t-MylOz-(FKw({$p*iTjjNHW4Flj*BIxR4T2D z7A-osb?esluCA`f#OmwoLwR|5tEXUGF)@^tmF?TIWlL*YTN{~h)T20ZAiRFUPPT>Fv!Zw%MVZGK*uoNzvCqk2(Ze^%46f?#`w1&2ytoE z*48!yNS?}Za~6x``Q^)(pWnZK|J^_!5cj}G^ZM(rcWbp;E5iQ$er;`Sb7NzpXtDbG z`eB>RwrMH`u9!1t&d#-K*M5KI%o%?|qaHZ*T9DV8BPDr>Dd3_sbzQA$Gf+-@bkOEJ~>{R#`Cy zfY({T#Atf162Jm=1KL&$A$&JpRKOdJbUzV&R2cisc`}XZ~EiElf zYNIBT2|YbMQe|X8lmWWCyDzu4w%(tt&P)fQ3;>|_)~#FjCZ#9SgjfUkdU|?>b8V}O*RqN38Yv^2?$HZ?Wjsi&TjtRn|;8=$nb^wn2hd1ba7jUGRK9Ltw4mqSW2 zaT&mBwK{8RYBtTDJzMfAOhZEh=FFJ`rBW$XN)}>%h-c26xoXLhCGWrc?z>`7bswX( zwH2pNpT;}yypvGvXyYfk1#36&0!H&6}sQ+wGz|x_9qh^!N9JF$Rv~z!-xrhlwBwFtw-?V-SLPB_9@eY_WZ4;IW3B&mK+{w#22&1Ax(JEZVwttFExH zP;!vt^Z62f%h4Eka2JG73o;e9-A+*(y8+B@~1Z5GsH~Nl7q5K?wm9GXqpA zl`K0vuh)yoawS3u1oH4lh*(abLf8ew%z*UtbXj&KlW71@21XbN4bOr|FhW2njd%Qy z7D3r&fYoZ1L+UXI4ZDCqLJ&yg_)VY`lu#hfj57}asi~>5B{|B<%0$=ez1xXvH!os1 z7&+m5=dPPkLO4nYNE8>K0s$ce?VfM2W}E%j`n-&4(6MDWa6v*z(}#a(IK=}{Xf&E> zTLZ3leut0#_G)-qPx#Wp4=JNu632mpK#1l7EW8MI+-XFnG3^B^5cZSG*rG4(uJ{uV zKyNmiW!aeogF%eG6&ep`8vlw=a2U^5Z-ps4diW}kVKjH1LWl$+micAHi^$PFazhRi zT*?dyL417r1Lhm-dx;02&&$h`=fX|`_y)Y7l%dkT779N0d${Rogm>Up#Q)DL`USM< zIWct_^UiP=uboNaH5!d6H#b*$mLoyJ*&zX+{PQgsvkRh@^$!o=w(myNGN&&75qe#8 zoj~vbuC&*K5(?gAGFkO{z4Rz3K?n&iT6YG!F&OYj*7H5^!1o}w4xs`BLcmY=K7fvV z-iRQ8@Kbl|l@J0(2;&tBg;A^3$|9ObIL#;pBNPG^Ado3EfIvVA0iThPp^{@C(BI#W zL<~tO3-9y@i5la}O*pWk;HP^ZKuP#b5HhthfD!^q3FD`GAD~rdqr3M9xZSs*NR1vt zq^2s6nH7DO`TfHf@C^ds#sxoY%%4L;LyQngcsch0GiJ;XU2jFzX0+UBgzxT8H*eU; zZ%PFUaH9j+WM#U7Qz#;z&D^@_LSQHa#sEeM0mnty6fjB|>UgD6DccNiI2@wu*=JSY z{T*N6YWu$s62e#TIF7@m%a;NT-~atXO*a1{0D$6UaGY5XLP+K#uUSM8z!Y>sQCBzGL)l?5nMmD&vlwtsZ_EAL0+#n;nUuHV-fO=V-u#I|9Qg?=a0B|U}Qqn zyp*>A9A_4YfMgOm>qJO6BUDmQiMPJo|Ct~NXQQ>v=jG+evJVIZ0+0<6JURLq zBLoZ_1c4wqT0Vdf5W>Zq4*`Gf+_{>Ozco6YZh_TmU8&dW=VoSR=9ZL{WL8yG85S;F z$fcx2KNZi($@y``iWR>rC@82f8jUuS$&@#D?%dq!>S{x2X=zfd`lD%YZ|^|(gz6E3 zAb{hNMrJ^iMUW6s5`SPfI=3{~-`{`!(xpr1M?Ev;=jT^iES6^t2E#0kMq^&IXp!OR zr=M1rl#IQKf8)lD8-Bn4i}+dRR#w@vWy{nKhXcjM z#S^B`ySlpIcDpZ(f6gcaOQMVrfg@1{NC*Lo;v&%uFcCd2m+KRk%k{~_@&^wdEGaB3 zT&maW9r^kB`4)@CTvk?Q?CR=joS=TM+wK0;?RI|(01k&^?;CHt@%!fHW*j|w6roTE zBhRsT@nRSZ1{^+oIN03W{Fm`Uf*^oP=0=jDkq1Z#L9FA$(TKgKB>=eE(a~|WqoV^C zFJ1%yl~$`=I5049C01p(+kJe;jvddb)#^ug?kS~QQ&Uq~U0t0vEiFyi*Vi`$!2MWd z4!s=1+&*_dQWO(+n=v31ph!vLaepv!)@ZEk{|FW9RL?Pv` + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 4f6387df2..1a224c2e6 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -4166,7 +4166,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) == 54, "Not all tools were used."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used."); QRectF rec; @@ -4247,6 +4247,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const case Tool::Pin: case Tool::InsertNode: case Tool::PlaceLabel: + case Tool::DuplicateDetail: break; } } diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 170fdf218..c17775469 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1771,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) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(TagPoint); @@ -1799,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) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(TagArc); @@ -1823,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) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(TagElArc); @@ -1856,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) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(AttrPathPoint); @@ -1894,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) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(TagOperation); @@ -1916,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) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; @@ -1939,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) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(TagPath); @@ -1977,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) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(TagDetail); diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 4f67cd982..899ae9f63 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -171,6 +171,7 @@ enum class Tool : ToolVisHolderType Pin, InsertNode, PlaceLabel, + DuplicateDetail, LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used }; @@ -222,6 +223,7 @@ enum class Vis : ToolVisHolderType ToolPiecePath, ToolSpecialPoint, ToolPlaceLabel, + ToolDuplicateDetail, PieceSpecialPoints, NoBrush, CurvePathItem, diff --git a/src/libs/vtools/dialogs/dialogs.pri b/src/libs/vtools/dialogs/dialogs.pri index 9df554fc8..ddba6edce 100644 --- a/src/libs/vtools/dialogs/dialogs.pri +++ b/src/libs/vtools/dialogs/dialogs.pri @@ -47,7 +47,8 @@ HEADERS += \ $$PWD/tools/piece/dialogpin.h \ $$PWD/tools/piece/dialoginsertnode.h \ $$PWD/support/dialogeditlabel.h \ - $$PWD/tools/piece/dialogplacelabel.h + $$PWD/tools/piece/dialogplacelabel.h \ + $$PWD/tools/piece/dialogduplicatedetail.h SOURCES += \ $$PWD/tools/dialogalongline.cpp \ @@ -94,7 +95,8 @@ SOURCES += \ $$PWD/tools/piece/dialogpin.cpp \ $$PWD/tools/piece/dialoginsertnode.cpp \ $$PWD/support/dialogeditlabel.cpp \ - $$PWD/tools/piece/dialogplacelabel.cpp + $$PWD/tools/piece/dialogplacelabel.cpp \ + $$PWD/tools/piece/dialogduplicatedetail.cpp FORMS += \ $$PWD/tools/dialogalongline.ui \ @@ -146,4 +148,5 @@ FORMS += \ $$PWD/tools/piece/tabs/tabpassmarks.ui \ $$PWD/support/dialogeditlabel.ui \ $$PWD/tools/piece/dialogplacelabel.ui \ - $$PWD/tools/piece/tabs/tabplacelabels.ui + $$PWD/tools/piece/tabs/tabplacelabels.ui \ + $$PWD/tools/piece/dialogduplicatedetail.ui diff --git a/src/libs/vtools/dialogs/tooldialogs.h b/src/libs/vtools/dialogs/tooldialogs.h index 0db5a3721..58d46f9e5 100644 --- a/src/libs/vtools/dialogs/tooldialogs.h +++ b/src/libs/vtools/dialogs/tooldialogs.h @@ -70,6 +70,7 @@ #include "tools/piece/dialogpin.h" #include "tools/piece/dialoginsertnode.h" #include "tools/piece/dialogplacelabel.h" +#include "tools/piece/dialogduplicatedetail.h" #include "support/dialogeditwrongformula.h" #include "support/dialogundo.h" diff --git a/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp new file mode 100644 index 000000000..9a75421cb --- /dev/null +++ b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp @@ -0,0 +1,93 @@ +/************************************************************************ + ** + ** @file dialogduplicatedetail.cpp + ** @author Roman Telezhynskyi + ** @date 25 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 "dialogduplicatedetail.h" +#include "ui_dialogduplicatedetail.h" +#include "../vwidgets/vabstractmainwindow.h" +#include "../../../visualization/path/vistoolduplicatedetail.h" + +//--------------------------------------------------------------------------------------------------------------------- +DialogDuplicateDetail::DialogDuplicateDetail(const VContainer *data, const quint32 &toolId, QWidget *parent) + : DialogTool(data, toolId, parent), + ui(new Ui::DialogDuplicateDetail), + m_idDetail(NULL_ID), + m_mx(0), + m_my(0), + m_firstRelease(false) +{ + ui->setupUi(this); + InitOkCancel(ui); + + vis = new VisToolDuplicateDetail(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogDuplicateDetail::~DialogDuplicateDetail() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogDuplicateDetail::ShowDialog(bool click) +{ + if (prepare) + { + if (click) + { + // The check need to ignore first release of mouse button. + // User should have chance to place piece. + if (not m_firstRelease) + { + m_firstRelease = true; + return; + } + + VisToolDuplicateDetail *piece = qobject_cast(vis); + SCASSERT(piece != nullptr) + + m_mx = piece->Mx(); + m_my = piece->My(); + emit ToolTip(""); + DialogAccepted(); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogDuplicateDetail::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Detail && id > NULL_ID) + { + m_idDetail = id; + emit ToolTip(tr("Click to place duplicate")); + vis->VisualMode(id); + prepare = true; + } + } +} diff --git a/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.h b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.h new file mode 100644 index 000000000..d36a0186b --- /dev/null +++ b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.h @@ -0,0 +1,80 @@ +/************************************************************************ + ** + ** @file dialogduplicatedetail.h + ** @author Roman Telezhynskyi + ** @date 25 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 DIALOGDUPLICATEDETAIL_H +#define DIALOGDUPLICATEDETAIL_H + +#include "../dialogtool.h" + +namespace Ui +{ + class DialogDuplicateDetail; +} + +class DialogDuplicateDetail : public DialogTool +{ + Q_OBJECT + +public: + explicit DialogDuplicateDetail(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + virtual ~DialogDuplicateDetail(); + + quint32 Duplicate() const; + qreal MoveDuplicateX() const; + qreal MoveDuplicateY() const; + + virtual void ShowDialog(bool click) Q_DECL_OVERRIDE; +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; +private: + Q_DISABLE_COPY(DialogDuplicateDetail) + Ui::DialogDuplicateDetail *ui; + quint32 m_idDetail; + qreal m_mx; + qreal m_my; + bool m_firstRelease; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 DialogDuplicateDetail::Duplicate() const +{ + return m_idDetail; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline qreal DialogDuplicateDetail::MoveDuplicateX() const +{ + return m_mx; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline qreal DialogDuplicateDetail::MoveDuplicateY() const +{ + return m_my; +} + +#endif // DIALOGDUPLICATEDETAIL_H diff --git a/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.ui b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.ui new file mode 100644 index 000000000..fa187e416 --- /dev/null +++ b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.ui @@ -0,0 +1,80 @@ + + + DialogDuplicateDetail + + + + 0 + 0 + 184 + 66 + + + + Dialog duplicate detail + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + The dialog is never shown. + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DialogDuplicateDetail + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogDuplicateDetail + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 6791982e6..c9009fecf 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -28,6 +28,7 @@ #include "vtoolseamallowance.h" #include "../dialogs/tools/piece/dialogseamallowance.h" +#include "../dialogs/tools/piece/dialogduplicatedetail.h" #include "../vpatterndb/vpiecenode.h" #include "../vpatterndb/vpiecepath.h" #include "../vpatterndb/calculator.h" @@ -151,6 +152,35 @@ VToolSeamAllowance *VToolSeamAllowance::Create(VToolSeamAllowanceInitData &initD return piece; } +//--------------------------------------------------------------------------------------------------------------------- +VToolSeamAllowance *VToolSeamAllowance::Duplicate(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) +{ + SCASSERT(not dialog.isNull()); + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) + + VToolSeamAllowanceInitData initData; + initData.scene = scene; + initData.doc = doc; + initData.data = data; + initData.parse = Document::FullParse; + initData.typeCreation = Source::FromGui; + +// initData.detail = dialogTool->GetPiece(); + initData.width = initData.detail.GetFormulaSAWidth(); + +// initData.detail.GetPath().SetNodes(PrepareNodes(initData.detail.GetPath(), scene, doc, data)); + + return Duplicate(initData); +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolSeamAllowance *VToolSeamAllowance::Duplicate(VToolSeamAllowanceInitData &initData) +{ + return nullptr; +} + //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::RemoveWithConfirm(bool ask) { @@ -1005,11 +1035,6 @@ QVariant VToolSeamAllowance::itemChange(QGraphicsItem::GraphicsItemChange change } } } - // Don't forget to update geometry, because first change never call full parse - VPiece detail = VAbstractTool::data.GetPiece(m_id); - detail.SetMx(newPos.x()); - detail.SetMy(newPos.y()); - VAbstractTool::data.UpdatePiece(m_id, detail); changeFinished = true; } diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 401c2971e..c13742e52 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -64,6 +64,9 @@ public: static VToolSeamAllowance* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolSeamAllowance* Create(VToolSeamAllowanceInitData &initData); + static VToolSeamAllowance* Duplicate(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); + static VToolSeamAllowance* Duplicate(VToolSeamAllowanceInitData &initData); static const quint8 pieceVersion; diff --git a/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp b/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp new file mode 100644 index 000000000..971eeaf90 --- /dev/null +++ b/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp @@ -0,0 +1,69 @@ +/************************************************************************ + ** + ** @file vistoolduplicatedetail.cpp + ** @author Roman Telezhynskyi + ** @date 25 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 "vistoolduplicatedetail.h" +#include "../vpatterndb/vcontainer.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolDuplicateDetail::VisToolDuplicateDetail(const VContainer *data, QGraphicsItem *parent) + : VisPath(data, parent), + m_start(), + m_started(false), + m_diff() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolDuplicateDetail::RefreshGeometry() +{ + const VPiece piece = Visualization::data->GetPiece(object1Id); + + if (not m_started) + { + m_start = Visualization::scenePos; + m_started = true; + } + else + { + m_diff = Visualization::scenePos - m_start; + setPos(m_diff); + } + + DrawPath(this, PiecePath(piece), mainColor, Qt::SolidLine, Qt::RoundCap); +} + +//--------------------------------------------------------------------------------------------------------------------- +QPainterPath VisToolDuplicateDetail::PiecePath(const VPiece &piece) const +{ + if (not piece.IsHideMainPath() || not piece.IsSeamAllowance() || piece.IsSeamAllowanceBuiltIn()) + { + return piece.MainPathPath(Visualization::data); + } + else + { + return piece.SeamAllowancePath(Visualization::data); + } +} diff --git a/src/libs/vtools/visualization/path/vistoolduplicatedetail.h b/src/libs/vtools/visualization/path/vistoolduplicatedetail.h new file mode 100644 index 000000000..a306211c5 --- /dev/null +++ b/src/libs/vtools/visualization/path/vistoolduplicatedetail.h @@ -0,0 +1,68 @@ +/************************************************************************ + ** + ** @file vistoolduplicatedetail.h + ** @author Roman Telezhynskyi + ** @date 25 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 VISTOOLDUPLICATEDETAIL_H +#define VISTOOLDUPLICATEDETAIL_H + +#include "vispath.h" +#include "../vpatterndb/vpiece.h" + +class VisToolDuplicateDetail : public VisPath +{ + Q_OBJECT +public: + VisToolDuplicateDetail(const VContainer *data, QGraphicsItem *parent = nullptr); + virtual ~VisToolDuplicateDetail() = default; + + qreal Mx() const; + qreal My() const; + + virtual void RefreshGeometry() Q_DECL_OVERRIDE; + virtual int type() const Q_DECL_OVERRIDE {return Type;} + enum { Type = UserType + static_cast(Vis::ToolDuplicateDetail)}; +private: + Q_DISABLE_COPY(VisToolDuplicateDetail) + QPointF m_start; + bool m_started; + QPointF m_diff; + + QPainterPath PiecePath(const VPiece &piece) const; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline qreal VisToolDuplicateDetail::Mx() const +{ + return m_diff.x(); +} + +//--------------------------------------------------------------------------------------------------------------------- +inline qreal VisToolDuplicateDetail::My() const +{ + return m_diff.y(); +} + +#endif // VISTOOLDUPLICATEDETAIL_H diff --git a/src/libs/vtools/visualization/visualization.pri b/src/libs/vtools/visualization/visualization.pri index 5f9aac564..2eef73604 100644 --- a/src/libs/vtools/visualization/visualization.pri +++ b/src/libs/vtools/visualization/visualization.pri @@ -42,7 +42,8 @@ HEADERS += \ $$PWD/path/vistoolpiece.h \ $$PWD/path/vistoolpiecepath.h \ $$PWD/path/vispiecespecialpoints.h \ - $$PWD/line/vistoolspecialpoint.h + $$PWD/line/vistoolspecialpoint.h \ + $$PWD/path/vistoolduplicatedetail.h SOURCES += \ $$PWD/visualization.cpp \ @@ -85,4 +86,5 @@ SOURCES += \ $$PWD/path/vistoolpiece.cpp \ $$PWD/path/vistoolpiecepath.cpp \ $$PWD/path/vispiecespecialpoints.cpp \ - $$PWD/line/vistoolspecialpoint.cpp + $$PWD/line/vistoolspecialpoint.cpp \ + $$PWD/path/vistoolduplicatedetail.cpp From e8ca7f575d1ee3d2c8bea9d8846760ad57eb003e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 26 Oct 2017 12:54:08 +0300 Subject: [PATCH 2/5] Fix bug. Modeling objects should be separated from calculation objects and stay in not copied container. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 2 +- src/libs/vpatterndb/vcontainer.cpp | 107 +++++++------------ src/libs/vpatterndb/vcontainer.h | 71 ++++++------ src/libs/vtools/dialogs/tools/dialogtool.cpp | 28 +++-- src/libs/vtools/tools/vabstracttool.cpp | 59 +++++----- 5 files changed, 122 insertions(+), 145 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index a15642ffa..4298a9ddc 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -260,7 +260,7 @@ void MainWindow::AddPP(const QString &PPName) comboBoxDraws->blockSignals(true); comboBoxDraws->addItem(PPName); - pattern->ClearGObjects(); + pattern->ClearCalculationGObjects(); //Create single point ui->view->itemClicked(nullptr);//hide options previous tool const QString label = doc->GenerateLabel(LabelType::NewPatternPiece); diff --git a/src/libs/vpatterndb/vcontainer.cpp b/src/libs/vpatterndb/vcontainer.cpp index 10caece95..1e2820220 100644 --- a/src/libs/vpatterndb/vcontainer.cpp +++ b/src/libs/vpatterndb/vcontainer.cpp @@ -103,10 +103,7 @@ VContainer::VContainer(const VContainer &data) //--------------------------------------------------------------------------------------------------------------------- VContainer::~VContainer() -{ - ClearGObjects(); - ClearVariables(); -} +{} //--------------------------------------------------------------------------------------------------------------------- /** @@ -115,9 +112,20 @@ VContainer::~VContainer() * @return point */ // cppcheck-suppress unusedFunction -const QSharedPointer VContainer::GetGObject(quint32 id)const +const QSharedPointer VContainer::GetGObject(quint32 id) const { - return GetObject(d->gObjects, id); + if (d->calculationObjects.contains(id)) + { + return d->calculationObjects.value(id); + } + else if (d->modelingObjects->contains(id)) + { + return d->modelingObjects->value(id); + } + else + { + throw VExceptionBadId(tr("Can't find object"), id); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -129,26 +137,6 @@ const QSharedPointer VContainer::GetFakeGObject(quint32 id) return pointer; } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief GetObject return object from container - * @param obj container - * @param id id of object - * @return Object - */ -template -const val VContainer::GetObject(const QHash &obj, key id) const -{ - if (obj.contains(id)) - { - return obj.value(id); - } - else - { - throw VExceptionBadId(tr("Can't find object"), id); - } -} - //--------------------------------------------------------------------------------------------------------------------- VPiece VContainer::GetPiece(quint32 id) const { @@ -192,8 +180,27 @@ quint32 VContainer::AddGObject(VGObject *obj) quint32 VContainer::AddGObject(const QSharedPointer &obj) { SCASSERT(not obj.isNull()) + + if (obj->getMode() == Draw::Layout) + { + qWarning("Can't add an object with mode 'Layout'"); + return NULL_ID; + } + uniqueNames.insert(obj->name()); - return AddObject(d->gObjects, obj); + const quint32 id = getNextId(); + obj->setId(id); + + if (obj->getMode() == Draw::Calculation) + { + d->calculationObjects.insert(id, obj); + } + else if (obj->getMode() == Draw::Modeling) + { + d->modelingObjects->insert(id, obj); + } + + return id; } //--------------------------------------------------------------------------------------------------------------------- @@ -290,33 +297,14 @@ void VContainer::ClearForFullParse() */ void VContainer::ClearGObjects() { - d->gObjects.clear(); + d->calculationObjects.clear(); + d->modelingObjects->clear(); } //--------------------------------------------------------------------------------------------------------------------- void VContainer::ClearCalculationGObjects() { - if (not d->gObjects.isEmpty()) //-V807 - { - QVector keys; - QHash >::iterator i; - for (i = d->gObjects.begin(); i != d->gObjects.end(); ++i) - { - if (i.value()->getMode() == Draw::Calculation) - { - i.value().clear(); - keys.append(i.key()); - } - } - // We can't delete objects in previous loop it will destroy the iterator. - if (not keys.isEmpty()) - { - for (int i = 0; i < keys.size(); ++i) - { - d->gObjects.remove(keys.at(i)); - } - } - } + d->calculationObjects.clear(); } //--------------------------------------------------------------------------------------------------------------------- @@ -464,23 +452,6 @@ void VContainer::RemovePiece(quint32 id) d->pieces->remove(id); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AddObject add object to container - * @param obj container - * @param value object - * @return id of object in container - */ -template -quint32 VContainer::AddObject(QHash &obj, val value) -{ - SCASSERT(value != nullptr) - const quint32 id = getNextId(); - value->setId(id); - obj[id] = value; - return id; -} - //--------------------------------------------------------------------------------------------------------------------- void VContainer::UpdatePiece(quint32 id, const VPiece &detail) { @@ -678,9 +649,9 @@ qreal *VContainer::rheight() * @brief data container with datagObjects return container of gObjects * @return pointer on container of gObjects */ -const QHash > *VContainer::DataGObjects() const +const QHash > *VContainer::CalculationGObjects() const { - return &d->gObjects; + return &d->calculationObjects; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vcontainer.h b/src/libs/vpatterndb/vcontainer.h index 2837bbddd..65999883d 100644 --- a/src/libs/vpatterndb/vcontainer.h +++ b/src/libs/vpatterndb/vcontainer.h @@ -69,7 +69,8 @@ class VContainerData : public QSharedData //-V690 public: VContainerData(const VTranslateVars *trVars, const Unit *patternUnit) - : gObjects(QHash >()), + : calculationObjects(QHash >()), + modelingObjects(QSharedPointer>>::create()), variables(QHash > ()), pieces(QSharedPointer>::create()), piecePaths(QSharedPointer>::create()), @@ -79,7 +80,8 @@ public: VContainerData(const VContainerData &data) : QSharedData(data), - gObjects(data.gObjects), + calculationObjects(data.calculationObjects), + modelingObjects(data.modelingObjects), variables(data.variables), pieces(data.pieces), piecePaths(data.piecePaths), @@ -89,10 +91,8 @@ public: virtual ~VContainerData(); - /** - * @brief gObjects graphicals objects of pattern. - */ - QHash > gObjects; + QHash > calculationObjects; + QSharedPointer>> modelingObjects; /** * @brief variables container for measurements, increments, lines lengths, lines angles, arcs lengths, curve lengths @@ -184,7 +184,7 @@ public: void RemoveIncrement(const QString& name); - const QHash > *DataGObjects() const; + const QHash > *CalculationGObjects() const; const QHash *DataPieces() const; const QHash> *DataVariables() const; @@ -219,16 +219,9 @@ private: template uint qHash( const QSharedPointer &p ); - template - // cppcheck-suppress functionStatic - const val GetObject(const QHash &obj, key id) const; - template void UpdateObject(const quint32 &id, const QSharedPointer &point); - template - static quint32 AddObject(QHash &obj, val value); - template const QMap > DataVar(const VarType &type) const; }; @@ -248,25 +241,23 @@ const QSharedPointer VContainer::GeometricObject(const quint32 &id) const throw VExceptionBadId(tr("Can't find object"), id); } - QSharedPointer gObj = QSharedPointer(); - if (d->gObjects.contains(id)) + QSharedPointer gObj; + if (d->calculationObjects.contains(id)) { - gObj = d->gObjects.value(id); + gObj = d->calculationObjects.value(id); + } + else if (d->modelingObjects->contains(id)) + { + gObj = d->modelingObjects->value(id); } else { throw VExceptionBadId(tr("Can't find object"), id); } - try - { - QSharedPointer obj = qSharedPointerDynamicCast(gObj); - SCASSERT(obj.isNull() == false) - return obj; - } - catch (const std::bad_alloc &) - { - throw VExceptionBadId(tr("Can't cast object"), id); - } + + QSharedPointer obj = qSharedPointerDynamicCast(gObj); + SCASSERT(obj.isNull() == false) + return obj; } @@ -375,19 +366,39 @@ 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)) + + if (d->calculationObjects.contains(id) && point->getMode() == Draw::Calculation) { - QSharedPointer obj = qSharedPointerDynamicCast(d->gObjects.value(id)); + QSharedPointer obj = qSharedPointerDynamicCast(d->calculationObjects.value(id)); if (obj.isNull()) { throw VExceptionBadId(tr("Can't cast object"), id); } *obj = *point; } + else if (d->modelingObjects->contains(id) && point->getMode() == Draw::Modeling) + { + QSharedPointer obj = qSharedPointerDynamicCast(d->modelingObjects->value(id)); + if (obj.isNull()) + { + throw VExceptionBadId(tr("Can't cast object"), id); + } + *obj = *point; + } + else if (point->getMode() == Draw::Calculation) + { + d->calculationObjects.insert(id, point); + } + else if (point->getMode() == Draw::Modeling) + { + d->modelingObjects->insert(id, point); + } else { - d->gObjects.insert(id, point); + qWarning("Can't update an object with mode 'Layout'"); + return; } + UpdateId(id); } #endif // VCONTAINER_H diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 513e6709f..53f13eccc 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -215,7 +215,7 @@ void DialogTool::FillComboBoxSplines(QComboBox *box) const SCASSERT(box != nullptr) box->blockSignals(true); - const auto objs = data->DataGObjects(); + const auto objs = data->CalculationGObjects(); QHash >::const_iterator i; QMap list; for (i = objs->constBegin(); i != objs->constEnd(); ++i) @@ -239,7 +239,7 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box) const SCASSERT(box != nullptr) box->blockSignals(true); - const auto objs = data->DataGObjects(); + const auto objs = data->CalculationGObjects(); QHash >::const_iterator i; QMap list; for (i = objs->constBegin(); i != objs->constEnd(); ++i) @@ -261,7 +261,7 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box) const void DialogTool::FillComboBoxCurves(QComboBox *box) const { SCASSERT(box != nullptr) - const auto objs = data->DataGObjects(); + const auto objs = data->CalculationGObjects(); QMap list; QHash >::const_iterator i; for (i = objs->constBegin(); i != objs->constEnd(); ++i) @@ -269,12 +269,12 @@ void DialogTool::FillComboBoxCurves(QComboBox *box) const if (i.key() != toolId) { QSharedPointer obj = i.value(); - if ((obj->getType() == GOType::Arc - || obj->getType() == GOType::EllipticalArc - || obj->getType() == GOType::Spline - || obj->getType() == GOType::SplinePath - || obj->getType() == GOType::CubicBezier - || obj->getType() == GOType::CubicBezierPath) && obj->getMode() == Draw::Calculation) + if (obj->getType() == GOType::Arc + || obj->getType() == GOType::EllipticalArc + || obj->getType() == GOType::Spline + || obj->getType() == GOType::SplinePath + || obj->getType() == GOType::CubicBezier + || obj->getType() == GOType::CubicBezierPath) { PrepareList(list, i.key()); } @@ -683,8 +683,7 @@ void DialogTool::InitNodeAngles(QComboBox *box) //--------------------------------------------------------------------------------------------------------------------- bool DialogTool::IsSplinePath(const QSharedPointer &obj) const { - return (obj->getType() == GOType::SplinePath || obj->getType() == GOType::CubicBezierPath) && - obj->getMode() == Draw::Calculation; + return obj->getType() == GOType::SplinePath || obj->getType() == GOType::CubicBezierPath; } //--------------------------------------------------------------------------------------------------------------------- @@ -1010,8 +1009,7 @@ void DialogTool::PrepareList(QMap &list, quint32 id) const //--------------------------------------------------------------------------------------------------------------------- bool DialogTool::IsSpline(const QSharedPointer &obj) const { - return (obj->getType() == GOType::Spline || obj->getType() == GOType::CubicBezier) && - obj->getMode() == Draw::Calculation; + return obj->getType() == GOType::Spline || obj->getType() == GOType::CubicBezier; } //--------------------------------------------------------------------------------------------------------------------- @@ -1290,7 +1288,7 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, cons SCASSERT(box != nullptr) box->blockSignals(true); - const QHash > *objs = data->DataGObjects(); + const QHash > *objs = data->CalculationGObjects(); QHash >::const_iterator i; QMap list; for (i = objs->constBegin(); i != objs->constEnd(); ++i) @@ -1300,7 +1298,7 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, cons if (i.key() != toolId && i.key() != ch1 && i.key() != ch2) { QSharedPointer obj = i.value(); - if (obj->getType() == gType && obj->getMode() == Draw::Calculation) + if (obj->getType() == gType) { PrepareList(list, i.key()); } diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index 07d94fffe..75d99cfa7 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -83,35 +83,6 @@ template class QSharedPointer; const QString VAbstractTool::AttrInUse = QStringLiteral("inUse"); -namespace -{ -//--------------------------------------------------------------------------------------------------------------------- -quint32 CreateNodeSpline(VContainer *data, quint32 id) -{ - if (data->GetGObject(id)->getType() == GOType::Spline) - { - return VAbstractTool::CreateNode(data, id); - } - else - { - return VAbstractTool::CreateNode(data, id); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -quint32 CreateNodeSplinePath(VContainer *data, quint32 id) -{ - if (data->GetGObject(id)->getType() == GOType::SplinePath) - { - return VAbstractTool::CreateNode(data, id); - } - else - { - return VAbstractTool::CreateNode(data, id); - } -} -}//static functions - //--------------------------------------------------------------------------------------------------------------------- /** * @brief VAbstractTool container. @@ -379,7 +350,7 @@ QMap VAbstractTool::ColorsList() // cppcheck-suppress unusedFunction QMap VAbstractTool::PointsList() const { - const QHash > *objs = data.DataGObjects(); + const QHash > *objs = data.CalculationGObjects(); QMap list; QHash >::const_iterator i; for (i = objs->constBegin(); i != objs->constEnd(); ++i) @@ -387,7 +358,7 @@ QMap VAbstractTool::PointsList() const if (i.key() != m_id) { QSharedPointer obj = i.value(); - if (obj->getType() == GOType::Point && obj->getMode() == Draw::Calculation) + if (obj->getType() == GOType::Point) { const QSharedPointer point = data.GeometricObject(i.key()); list[point->name()] = i.key(); @@ -694,3 +665,29 @@ quint32 VAbstractTool::PrepareNode(const VPieceNode &node, VMainGraphicsScene *s } return initData.id; } + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VAbstractTool::CreateNodeSpline(VContainer *data, quint32 id) +{ + if (data->GetGObject(id)->getType() == GOType::Spline) + { + return VAbstractTool::CreateNode(data, id); + } + else + { + return VAbstractTool::CreateNode(data, id); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VAbstractTool::CreateNodeSplinePath(VContainer *data, quint32 id) +{ + if (data->GetGObject(id)->getType() == GOType::SplinePath) + { + return VAbstractTool::CreateNode(data, id); + } + else + { + return VAbstractTool::CreateNode(data, id); + } +} From 51e670bd844bf92ecd9699346c95eee4b9f96a7e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 26 Oct 2017 16:57:52 +0300 Subject: [PATCH 3/5] Duplicate from GUI. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 3 +- src/libs/ifc/xml/vabstractpattern.cpp | 18 ++ src/libs/ifc/xml/vabstractpattern.h | 2 + .../vtools/tools/nodeDetails/vnodearc.cpp | 2 +- src/libs/vtools/tools/nodeDetails/vnodearc.h | 2 +- .../tools/nodeDetails/vnodeellipticalarc.cpp | 2 +- .../tools/nodeDetails/vnodeellipticalarc.h | 2 +- .../vtools/tools/nodeDetails/vnodepoint.cpp | 2 +- .../vtools/tools/nodeDetails/vnodepoint.h | 2 +- .../vtools/tools/nodeDetails/vnodespline.cpp | 2 +- .../vtools/tools/nodeDetails/vnodespline.h | 2 +- .../tools/nodeDetails/vnodesplinepath.cpp | 2 +- .../tools/nodeDetails/vnodesplinepath.h | 2 +- src/libs/vtools/tools/vabstracttool.h | 7 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 211 +++++++++++++++++- src/libs/vtools/tools/vtoolseamallowance.h | 18 +- 16 files changed, 252 insertions(+), 27 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 4298a9ddc..cae1e9574 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1127,8 +1127,7 @@ void MainWindow::ClosedDialogDuplicateDetail(int result) VMainGraphicsScene *scene = qobject_cast(currentScene); SCASSERT(scene != nullptr) - QGraphicsItem *tool = dynamic_cast(VToolSeamAllowance::Duplicate(dialogTool, scene, doc, - pattern)); + QGraphicsItem *tool = dynamic_cast(VToolSeamAllowance::Duplicate(dialogTool, scene, doc)); // Do not check for nullptr! See issue #719. ui->view->itemClicked(tool); } diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index c17775469..86d190725 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -2420,3 +2420,21 @@ void VAbstractPattern::SetGroupVisivility(quint32 id, bool visible) qDebug("Can't get group by id = %u.", id); } } + +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractPattern::PieceDrawName(quint32 id) +{ + const QDomElement detail = elementById(id, VAbstractPattern::TagDetail); + if (detail.isNull()) + { + return QString(); + } + + const QDomElement draw = detail.parentNode().parentNode().toElement(); + if (draw.isNull() || not draw.hasAttribute(VAbstractPattern::AttrName)) + { + return QString(); + } + + return draw.attribute(VAbstractPattern::AttrName); +} diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 920837731..d2ccf0d16 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -198,6 +198,8 @@ public: bool GetGroupVisivility(quint32 id); void SetGroupVisivility(quint32 id, bool visible); + QString PieceDrawName(quint32 id); + static const QString TagPattern; static const QString TagCalculation; static const QString TagModeling; diff --git a/src/libs/vtools/tools/nodeDetails/vnodearc.cpp b/src/libs/vtools/tools/nodeDetails/vnodearc.cpp index 13ae8beb6..6832ef4e8 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodearc.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodearc.cpp @@ -59,7 +59,7 @@ VNodeArc::VNodeArc(const VAbstractNodeInitData &initData, QObject *qoParent) * @brief Create help create tool. * @param initData init data. */ -void VNodeArc::Create(VAbstractNodeInitData initData) +void VNodeArc::Create(const VAbstractNodeInitData &initData) { if (initData.parse == Document::FullParse) { diff --git a/src/libs/vtools/tools/nodeDetails/vnodearc.h b/src/libs/vtools/tools/nodeDetails/vnodearc.h index 1be22d12a..b12f7c9ef 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodearc.h +++ b/src/libs/vtools/tools/nodeDetails/vnodearc.h @@ -47,7 +47,7 @@ class VNodeArc :public VAbstractNode { Q_OBJECT public: - static void Create(VAbstractNodeInitData initData); + static void Create(const VAbstractNodeInitData &initData); static const QString ToolType; virtual QString getTagName() const Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.cpp b/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.cpp index f79d6a24b..9aa9d43a6 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.cpp @@ -42,7 +42,7 @@ const QString VNodeEllipticalArc::ToolType = QStringLiteral("modeling"); //--------------------------------------------------------------------------------------------------------------------- -void VNodeEllipticalArc::Create(VAbstractNodeInitData initData) +void VNodeEllipticalArc::Create(const VAbstractNodeInitData &initData) { if (initData.parse == Document::FullParse) { diff --git a/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h b/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h index e392f6192..31af86c22 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h +++ b/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h @@ -44,7 +44,7 @@ class VNodeEllipticalArc :public VAbstractNode { Q_OBJECT public: - static void Create(VAbstractNodeInitData initData); + static void Create(const VAbstractNodeInitData &initData); static const QString ToolType; virtual QString getTagName() const Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp index 721907088..864e89adf 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp @@ -85,7 +85,7 @@ VNodePoint::VNodePoint(const VAbstractNodeInitData &initData, QObject *qoParent, * @brief Create help create tool. * @param initData init data. */ -void VNodePoint::Create(VAbstractNodeInitData initData) +void VNodePoint::Create(const VAbstractNodeInitData &initData) { if (initData.parse == Document::FullParse) { diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.h b/src/libs/vtools/tools/nodeDetails/vnodepoint.h index 30ee4380d..ee550ab94 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.h +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.h @@ -50,7 +50,7 @@ class VNodePoint: public VAbstractNode, public VScenePoint { Q_OBJECT public: - static void Create(VAbstractNodeInitData initData); + static void Create(const VAbstractNodeInitData &initData); static const QString ToolType; virtual int type() const Q_DECL_OVERRIDE {return Type;} diff --git a/src/libs/vtools/tools/nodeDetails/vnodespline.cpp b/src/libs/vtools/tools/nodeDetails/vnodespline.cpp index ee75c99c7..6fa3c46f8 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodespline.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodespline.cpp @@ -60,7 +60,7 @@ VNodeSpline::VNodeSpline(const VAbstractNodeInitData &initData, QObject *qoParen * @param initData init data. * @return pointer to node. */ -VNodeSpline *VNodeSpline::Create(VAbstractNodeInitData initData) +VNodeSpline *VNodeSpline::Create(const VAbstractNodeInitData &initData) { VNodeSpline *spl = nullptr; if (initData.parse == Document::FullParse) diff --git a/src/libs/vtools/tools/nodeDetails/vnodespline.h b/src/libs/vtools/tools/nodeDetails/vnodespline.h index 5f2c82690..e7336936a 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodespline.h +++ b/src/libs/vtools/tools/nodeDetails/vnodespline.h @@ -47,7 +47,7 @@ class VNodeSpline:public VAbstractNode { Q_OBJECT public: - static VNodeSpline *Create(VAbstractNodeInitData initData); + static VNodeSpline *Create(const VAbstractNodeInitData &initData); static const QString ToolType; virtual QString getTagName() const Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/nodeDetails/vnodesplinepath.cpp b/src/libs/vtools/tools/nodeDetails/vnodesplinepath.cpp index 201f6eed5..d9b050d83 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodesplinepath.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodesplinepath.cpp @@ -59,7 +59,7 @@ VNodeSplinePath::VNodeSplinePath(const VAbstractNodeInitData &initData, QObject * @brief Create help create tool. * @param initData init data. */ -void VNodeSplinePath::Create(VAbstractNodeInitData initData) +void VNodeSplinePath::Create(const VAbstractNodeInitData &initData) { if (initData.parse == Document::FullParse) { diff --git a/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h b/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h index 2bbc0bc40..5b71f26fb 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h +++ b/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h @@ -47,7 +47,7 @@ class VNodeSplinePath : public VAbstractNode { Q_OBJECT public: - static void Create(VAbstractNodeInitData initData); + static void Create(const VAbstractNodeInitData &initData); static const QString ToolType; virtual QString getTagName() const Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/vabstracttool.h b/src/libs/vtools/tools/vabstracttool.h index 585de3903..bb2c0fce1 100644 --- a/src/libs/vtools/tools/vabstracttool.h +++ b/src/libs/vtools/tools/vabstracttool.h @@ -110,8 +110,6 @@ public: virtual void ShowVisualization(bool show) =0; virtual void ChangeLabelPosition(quint32 id, const QPointF &pos); - template - static quint32 CreateNode(VContainer *data, quint32 id); public slots: /** * @brief FullUpdateFromFile update tool data form file. @@ -162,6 +160,11 @@ protected: virtual void DeleteToolWithConfirm(bool ask = true); static int ConfirmDeletion(); + template + static quint32 CreateNode(VContainer *data, quint32 id); + static quint32 CreateNodeSpline(VContainer *data, quint32 id); + static quint32 CreateNodeSplinePath(VContainer *data, quint32 id); + template void AddVisualization(); diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index c9009fecf..7188f5a61 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -34,12 +34,7 @@ #include "../vpatterndb/calculator.h" #include "../vpatterndb/floatItemData/vpatternlabeldata.h" #include "../vpatterndb/floatItemData/vpiecelabeldata.h" -#include "nodeDetails/vnodearc.h" -#include "nodeDetails/vnodeellipticalarc.h" -#include "nodeDetails/vnodepoint.h" -#include "nodeDetails/vnodespline.h" -#include "nodeDetails/vnodesplinepath.h" -#include "nodeDetails/vtoolpiecepath.h" +#include "nodeDetails/nodedetails.h" #include "../vgeometry/varc.h" #include "../vgeometry/vellipticalarc.h" #include "../vgeometry/vcubicbezier.h" @@ -47,6 +42,7 @@ #include "../vgeometry/vpointf.h" #include "../vgeometry/vspline.h" #include "../vgeometry/vsplinepath.h" +#include "../vgeometry/vplacelabelitem.h" #include "../ifc/xml/vpatternconverter.h" #include "../undocommands/addpiece.h" #include "../undocommands/deletepiece.h" @@ -154,7 +150,7 @@ VToolSeamAllowance *VToolSeamAllowance::Create(VToolSeamAllowanceInitData &initD //--------------------------------------------------------------------------------------------------------------------- VToolSeamAllowance *VToolSeamAllowance::Duplicate(QSharedPointer dialog, VMainGraphicsScene *scene, - VAbstractPattern *doc, VContainer *data) + VAbstractPattern *doc) { SCASSERT(not dialog.isNull()); QSharedPointer dialogTool = dialog.objectCast(); @@ -163,22 +159,37 @@ VToolSeamAllowance *VToolSeamAllowance::Duplicate(QSharedPointer dia VToolSeamAllowanceInitData initData; initData.scene = scene; initData.doc = doc; - initData.data = data; initData.parse = Document::FullParse; initData.typeCreation = Source::FromGui; + initData.drawName = doc->PieceDrawName(dialogTool->Duplicate()); -// initData.detail = dialogTool->GetPiece(); + VContainer toolData = VAbstractPattern::getTool(dialogTool->Duplicate())->getData(); + initData.data = &toolData; + + VPiece detail = initData.data->GetPiece(dialogTool->Duplicate()); + detail.SetMx(dialogTool->MoveDuplicateX()); + detail.SetMy(dialogTool->MoveDuplicateY()); + initData.detail = detail; initData.width = initData.detail.GetFormulaSAWidth(); -// initData.detail.GetPath().SetNodes(PrepareNodes(initData.detail.GetPath(), scene, doc, data)); - return Duplicate(initData); } //--------------------------------------------------------------------------------------------------------------------- VToolSeamAllowance *VToolSeamAllowance::Duplicate(VToolSeamAllowanceInitData &initData) { - return nullptr; + VPiece dupDetail = initData.detail; + + QMap replacements; + dupDetail.GetPath().SetNodes(DuplicateNodes(initData.detail.GetPath(), initData, replacements)); + dupDetail.SetCustomSARecords(DuplicateCustomSARecords(initData.detail.GetCustomSARecords(), initData, + replacements)); + dupDetail.SetInternalPaths(DuplicateInternalPaths(initData.detail.GetInternalPaths(), initData)); + dupDetail.SetPins(DuplicatePins(initData.detail.GetPins(), initData)); + dupDetail.SetPlaceLabels(DuplicatePlaceLabels(initData.detail.GetPlaceLabels(), initData)); + + initData.detail = dupDetail; + return VToolSeamAllowance::Create(initData); } //--------------------------------------------------------------------------------------------------------------------- @@ -1766,3 +1777,179 @@ void VToolSeamAllowance::AddPointRecords(VAbstractPattern *doc, QDomElement &dom domElement.appendChild(pinsElement); } } + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolSeamAllowance::DuplicateNode(const VPieceNode &node, const VToolSeamAllowanceInitData &initData) +{ + SCASSERT(initData.scene != nullptr) + SCASSERT(initData.doc != nullptr) + SCASSERT(initData.data != nullptr) + + const QSharedPointer gobj = initData.data->GetGObject(node.GetId()); + + VAbstractNodeInitData initNodeData; + initNodeData.idObject = gobj->getIdObject(); + initNodeData.doc = initData.doc; + initNodeData.data = initData.data; + initNodeData.parse = Document::FullParse; + initNodeData.typeCreation = Source::FromGui; + initNodeData.scene = initData.scene; + initNodeData.drawName = initData.drawName; + + switch (node.GetTypeTool()) + { + case (Tool::NodePoint): + initNodeData.id = VAbstractTool::CreateNode(initData.data, gobj->getIdObject()); + VNodePoint::Create(initNodeData); + break; + case (Tool::NodeArc): + initNodeData.id = VAbstractTool::CreateNode(initData.data, gobj->getIdObject()); + VNodeArc::Create(initNodeData); + break; + case (Tool::NodeElArc): + initNodeData.id = VAbstractTool::CreateNode(initData.data, gobj->getIdObject()); + VNodeEllipticalArc::Create(initNodeData); + break; + case (Tool::NodeSpline): + initNodeData.id = VAbstractTool::CreateNodeSpline(initData.data, gobj->getIdObject()); + VNodeSpline::Create(initNodeData); + break; + case (Tool::NodeSplinePath): + initNodeData.id = VAbstractTool::CreateNodeSplinePath(initData.data, gobj->getIdObject()); + VNodeSplinePath::Create(initNodeData); + break; + default: + qDebug()<<"May be wrong tool type!!! Ignoring."<GetPiecePath(id); + VPiecePath newPath = path; + QMap recordReplacements; // Not used + newPath.SetNodes(DuplicateNodes(path, initData, recordReplacements)); + + const quint32 idPath = initData.data->AddPiecePath(newPath); + + VToolPiecePathInitData initNodeData; + initNodeData.id = idPath; + initNodeData.idObject = NULL_ID; // piece id + initNodeData.scene = initData.scene; + initNodeData.doc = initData.doc; + initNodeData.data = initData.data; + initNodeData.parse = Document::FullParse; + initNodeData.typeCreation = Source::FromTool; + initNodeData.drawName = initData.drawName; + initNodeData.path = newPath; + + VToolPiecePath::Create(initNodeData); + return idPath; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VToolSeamAllowance::DuplicateCustomSARecords(const QVector &records, + const VToolSeamAllowanceInitData &initData, + const QMap &replacements) +{ + QVector newRecords; + for(int i=0; i < records.size(); ++i) + { + CustomSARecord record = records.at(i); + record.path = DuplicatePiecePath(record.path, initData); + record.startPoint = replacements.value(record.startPoint, NULL_ID); + record.endPoint = replacements.value(record.endPoint, NULL_ID); + newRecords.append(record); + } + return newRecords; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VToolSeamAllowance::DuplicateInternalPaths(const QVector &iPaths, + const VToolSeamAllowanceInitData &initData) +{ + QVector newPaths; + for(int i=0; i < iPaths.size(); ++i) + { + newPaths.append(DuplicatePiecePath(iPaths.at(i), initData)); + } + return newPaths; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VToolSeamAllowance::DuplicatePins(const QVector &pins, + const VToolSeamAllowanceInitData &initData) +{ + QVector newPins; + for(int i=0; i < pins.size(); ++i) + { + QSharedPointer pin = initData.data->GeometricObject(pins.at(i)); + + VToolPinInitData initNodeData; + initNodeData.id = initData.data->AddGObject(new VPointF(*pin)); + initNodeData.pointId = pin->getIdObject(); + initNodeData.idObject = NULL_ID; // piece id + initNodeData.doc = initData.doc; + initNodeData.data = initData.data; + initNodeData.parse = Document::FullParse; + initNodeData.typeCreation = Source::FromTool; + initNodeData.drawName = initData.drawName; + + VToolPin::Create(initNodeData); + newPins.append(initNodeData.id); + } + return newPins; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VToolSeamAllowance::DuplicatePlaceLabels(const QVector &placeLabels, + const VToolSeamAllowanceInitData &initData) +{ + QVector newPlaceLabels; + for(int i=0; i < placeLabels.size(); ++i) + { + QSharedPointer label = initData.data->GeometricObject(placeLabels.at(i)); + + VToolPlaceLabelInitData initNodeData; + initNodeData.idObject = NULL_ID; // piece id + initNodeData.doc = initData.doc; + initNodeData.data = initData.data; + initNodeData.parse = Document::FullParse; + initNodeData.typeCreation = Source::FromTool; + initNodeData.drawName = initData.drawName; + initNodeData.width = label->GetWidthFormula(); + initNodeData.height = label->GetHeightFormula(); + initNodeData.angle = label->GetAngleFormula(); + initNodeData.type = label->GetLabelType(); + initNodeData.centerPoint = label->GetCenterPoint(); + initNodeData.id = initNodeData.data->AddGObject(new VPlaceLabelItem(*label)); + + VToolPlaceLabel::Create(initNodeData); + newPlaceLabels.append(initNodeData.id); + } + return newPlaceLabels; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VToolSeamAllowance::DuplicateNodes(const VPiecePath &path, + const VToolSeamAllowanceInitData &initData, + QMap &replacements) +{ + QVector nodes; + for (int i = 0; i< path.CountNodes(); ++i) + { + VPieceNode nodeD = path.at(i); + const quint32 oldId = nodeD.GetId(); + const quint32 id = DuplicateNode(nodeD, initData); + if (id > NULL_ID) + { + nodeD.SetId(id); + nodes.append(nodeD); + replacements.insert(oldId, id); + } + } + return nodes; +} diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index c13742e52..55aea4aae 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -65,7 +65,7 @@ public: VAbstractPattern *doc, VContainer *data); static VToolSeamAllowance* Create(VToolSeamAllowanceInitData &initData); static VToolSeamAllowance* Duplicate(QSharedPointer dialog, VMainGraphicsScene *scene, - VAbstractPattern *doc, VContainer *data); + VAbstractPattern *doc); static VToolSeamAllowance* Duplicate(VToolSeamAllowanceInitData &initData); static const quint8 pieceVersion; @@ -200,6 +200,22 @@ private: static void AddPointRecords(VAbstractPattern *doc, QDomElement &domElement, const QVector &records, const QString &tag); + + static QVector DuplicateNodes(const VPiecePath &path, const VToolSeamAllowanceInitData &initData, + QMap &replacements); + static quint32 DuplicateNode(const VPieceNode &node, const VToolSeamAllowanceInitData &initData); + + static quint32 DuplicatePiecePath(quint32 id, const VToolSeamAllowanceInitData &initData); + + static QVector DuplicateCustomSARecords(const QVector &records, + const VToolSeamAllowanceInitData &initData, + const QMap &replacements); + + static QVector DuplicateInternalPaths(const QVector &iPaths, + const VToolSeamAllowanceInitData &initData); + static QVector DuplicatePins(const QVector &pins, const VToolSeamAllowanceInitData &initData); + static QVector DuplicatePlaceLabels(const QVector &placeLabels, + const VToolSeamAllowanceInitData &initData); }; #endif // VTOOLSEAMALLOWANCE_H From 5a07871a8d73d7a035383e774f4fbbf7fb35a1f1 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 26 Oct 2017 17:22:12 +0300 Subject: [PATCH 4/5] Fix Tool union Reatin pieces option. --HG-- branch : feature --- src/libs/vtools/tools/vtooluniondetails.cpp | 35 ++++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index 8eb89fb0d..bf3a395db 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -1538,19 +1538,38 @@ void CreateUnitedDetail(const VToolUnionDetailsInitData &initData, qreal dx, qre VToolSeamAllowance::Create(pieceInitData); - auto RemoveDetail = [initData](quint32 id) + auto DuplicateDetail = [initData](quint32 id) + { + VToolSeamAllowanceInitData initPieceData; + initPieceData.scene = initData.scene; + initPieceData.doc = initData.doc; + initPieceData.parse = Document::FullParse; + initPieceData.typeCreation = Source::FromGui; + initPieceData.drawName = initData.doc->PieceDrawName(id); + + VContainer toolData = VAbstractPattern::getTool(id)->getData(); + initPieceData.data = &toolData; + + initPieceData.detail = initData.data->GetPiece(id); + initPieceData.width = initPieceData.detail.GetFormulaSAWidth(); + VToolSeamAllowance::Duplicate(initPieceData); + }; + + if (initData.retainPieces) + { + DuplicateDetail(initData.d1id); + DuplicateDetail(initData.d2id); + } + + auto RemoveDetail = [](quint32 id) { VToolSeamAllowance *toolDet = qobject_cast(VAbstractPattern::getTool(id)); SCASSERT(toolDet != nullptr); - bool ask = false; - toolDet->RemoveWithConfirm(ask); + toolDet->RemoveWithConfirm(false); }; - if (not initData.retainPieces) - { - RemoveDetail(initData.d1id); - RemoveDetail(initData.d2id); - } + RemoveDetail(initData.d1id); + RemoveDetail(initData.d2id); } //--------------------------------------------------------------------------------------------------------------------- From 0708cfd4260105a5e45d2b1fdd4fd145e2382dd8 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 26 Oct 2017 17:25:50 +0300 Subject: [PATCH 5/5] Update changelog. --HG-- branch : feature --- ChangeLog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index ded5ebd21..95bd28892 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -29,6 +29,7 @@ - [#768] New feature. Custom curve approximation scale. - [#759] Add place label tool. - [#771] Improve tool Point at intersection of arc and line. +- [#772] New tool Duplicate detail. # Version 0.5.1 - [#683] Tool Seam allowance's dialog is off screen on small resolutions.