From 96255ef09357a9930d3ba5ffd4f03840235fb869 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 21 Mar 2017 15:39:14 +0200 Subject: [PATCH 1/6] Dialog Insert node tool. --HG-- branch : feature --- .../core/vtooloptionspropertybrowser.cpp | 6 +- src/app/valentina/dialogs/dialoghistory.cpp | 3 +- src/app/valentina/mainwindow.cpp | 38 +++- src/app/valentina/mainwindow.h | 2 + src/app/valentina/mainwindow.ui | 46 ++++- src/app/valentina/share/resources/cursor.qrc | 2 + .../resources/cursor/insert_node_cursor.png | Bin 0 -> 452 bytes .../cursor/insert_node_cursor@2x.png | Bin 0 -> 1061 bytes .../valentina/share/resources/toolicon.qrc | 2 + .../resources/toolicon/32x32/insert_node.png | Bin 0 -> 665 bytes .../toolicon/32x32/insert_node@2x.png | Bin 0 -> 1371 bytes .../resources/toolicon/svg/insert_node.svg | 69 +++++++ src/app/valentina/xml/vpattern.cpp | 3 +- src/libs/ifc/xml/vabstractpattern.cpp | 14 +- src/libs/vmisc/def.h | 1 + src/libs/vtools/dialogs/dialogs.pri | 9 +- src/libs/vtools/dialogs/tooldialogs.h | 1 + .../vtools/dialogs/tools/dialoginsertnode.cpp | 193 ++++++++++++++++++ .../vtools/dialogs/tools/dialoginsertnode.h | 73 +++++++ .../vtools/dialogs/tools/dialoginsertnode.ui | 101 +++++++++ 20 files changed, 534 insertions(+), 29 deletions(-) create mode 100644 src/app/valentina/share/resources/cursor/insert_node_cursor.png create mode 100644 src/app/valentina/share/resources/cursor/insert_node_cursor@2x.png create mode 100644 src/app/valentina/share/resources/toolicon/32x32/insert_node.png create mode 100644 src/app/valentina/share/resources/toolicon/32x32/insert_node@2x.png create mode 100644 src/app/valentina/share/resources/toolicon/svg/insert_node.svg create mode 100644 src/libs/vtools/dialogs/tools/dialoginsertnode.cpp create mode 100644 src/libs/vtools/dialogs/tools/dialoginsertnode.h create mode 100644 src/libs/vtools/dialogs/tools/dialoginsertnode.ui diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 462911065..9425b87cd 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -76,7 +76,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) == 52, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were used in switch."); switch (item->type()) { @@ -203,7 +203,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) == 52, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were used in switch."); switch (currentItem->type()) { @@ -348,7 +348,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) == 52, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "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 216fec813..5f1d0c550 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) == 52, "Not all tools were used in history."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "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::InsertNode: return QString(); } } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 9e5410e24..80e940776 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -574,6 +574,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons break; case Tool::PiecePath: case Tool::Pin: + case Tool::InsertNode: dialogTool->SetPiecesList(doc->GetActivePPPieces()); break; default: @@ -1162,6 +1163,18 @@ void MainWindow::ClosedDialogPin(int result) doc->LiteParseTree(Document::LiteParse); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ClosedDialogInsertNode(int result) +{ + SCASSERT(dialogTool != nullptr); +// if (result == QDialog::Accepted) +// { +// VToolInsertTool::Create(dialogTool, doc, pattern); +// } + ArrowTool(); +// doc->LiteParseTree(Document::LiteParse); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ToolCutArc handler tool cutArc. @@ -1286,6 +1299,14 @@ void MainWindow::ToolTrueDarts(bool checked) &MainWindow::ApplyDrawDialog); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolInsertNode(bool checked) +{ + ToolSelectAllDrawObjects(); + SetToolButton(checked, Tool::InsertNode, "://cursor/insert_node_cursor.png", + tr("Select an item to insert"), &MainWindow::ClosedDialogInsertNode); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ShowTool highlight tool.Tip show tools tooltip. @@ -1801,7 +1822,7 @@ void MainWindow::InitToolButtons() } // This check helps to find missed tools - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Check if all tools were connected."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Check if all tools were connected."); connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine); connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine); @@ -1848,6 +1869,7 @@ void MainWindow::InitToolButtons() connect(ui->toolButtonLayoutExportAs, &QToolButton::clicked, this, &MainWindow::ExportLayoutAs); connect(ui->toolButtonEllipticalArc, &QToolButton::clicked, this, &MainWindow::ToolEllipticalArc); connect(ui->toolButtonPin, &QToolButton::clicked, this, &MainWindow::ToolPin); + connect(ui->toolButtonInsertNode, &QToolButton::clicked, this, &MainWindow::ToolInsertNode); } //--------------------------------------------------------------------------------------------------------------------- @@ -1875,7 +1897,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) == 52, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were handled."); qCDebug(vMainWindow, "Canceling tool."); delete dialogTool; @@ -2034,6 +2056,9 @@ void MainWindow::CancelTool() case Tool::Pin: ui->toolButtonPin->setChecked(false); break; + case Tool::InsertNode: + ui->toolButtonInsertNode->setChecked(false); + break; } // Crash: using CRTL+Z while using line tool. @@ -3152,7 +3177,7 @@ void MainWindow::SetEnableTool(bool enable) } // This check helps to find missed tools - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were handled."); //Drawing Tools ui->toolButtonEndLine->setEnabled(drawTools); @@ -3194,6 +3219,7 @@ void MainWindow::SetEnableTool(bool enable) ui->toolButtonMidpoint->setEnabled(drawTools); ui->toolButtonEllipticalArc->setEnabled(drawTools); ui->toolButtonPin->setEnabled(drawTools); + ui->toolButtonInsertNode->setEnabled(drawTools); ui->actionLast_tool->setEnabled(drawTools); @@ -3475,7 +3501,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) == 52, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were handled."); if (currentTool == lastUsedTool) { @@ -3666,6 +3692,10 @@ void MainWindow::LastUsedTool() ui->toolButtonPin->setChecked(true); ToolPin(true); break; + case Tool::InsertNode: + ui->toolButtonInsertNode->setChecked(true); + ToolInsertNode(true); + break; } } diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index f5fed5834..39beb5c1b 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -158,6 +158,7 @@ private slots: void ToolPointFromArcAndTangent(bool checked); void ToolArcWithLength(bool checked); void ToolTrueDarts(bool checked); + void ToolInsertNode(bool checked); void ActionDraw(bool checked); void ActionDetails(bool checked); @@ -172,6 +173,7 @@ private slots: void ClosedDialogGroup(int result); void ClosedDialogPiecePath(int result); void ClosedDialogPin(int result); + void ClosedDialogInsertNode(int result); void LoadIndividual(); void LoadStandard(); diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index bb1dc0243..6b2c120fd 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -55,7 +55,7 @@ 0 0 - 117 + 100 358 @@ -427,7 +427,7 @@ 0 0 - 130 + 100 110 @@ -536,7 +536,7 @@ 0 0 - 130 + 100 248 @@ -798,7 +798,7 @@ 0 0 - 130 + 100 248 @@ -1063,7 +1063,7 @@ 0 0 - 130 + 100 58 @@ -1143,8 +1143,8 @@ 0 0 - 130 - 326 + 100 + 196 @@ -1322,7 +1322,7 @@ 0 0 130 - 150 + 196 @@ -1475,6 +1475,32 @@ + + + + false + + + Insert node tool + + + ... + + + + :/toolicon/32x32/insert_node.png:/toolicon/32x32/insert_node.png + + + + 32 + 32 + + + + true + + + @@ -1482,8 +1508,8 @@ 0 0 - 130 - 326 + 100 + 58 diff --git a/src/app/valentina/share/resources/cursor.qrc b/src/app/valentina/share/resources/cursor.qrc index 4a3771e1c..ea61c6eaf 100644 --- a/src/app/valentina/share/resources/cursor.qrc +++ b/src/app/valentina/share/resources/cursor.qrc @@ -82,5 +82,7 @@ cursor/path_cursor@2x.png cursor/pin_cursor.png cursor/pin_cursor@2x.png + cursor/insert_node_cursor.png + cursor/insert_node_cursor@2x.png diff --git a/src/app/valentina/share/resources/cursor/insert_node_cursor.png b/src/app/valentina/share/resources/cursor/insert_node_cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..271923bc7a460eab9501634e7e48c42e86e4aa2f GIT binary patch literal 452 zcmV;#0XzPQP)kdg0004tNklXQ@sfVv;~h!u6;_2mO{ z5vxEBVmSm_CK^DCL^IG5@jC*vK&%Hc6B~hy#8M29iHHX>5J^C4;#VS&lK2}CB?3Jz z7|@;tXb^#$rd)B)yj{(};y-{@B5=#gaQ9UYl7N+jlYVg8gdJg`*YjrJ=i1nkFM49{ z)aR*T$HMN8avV^zU}sD?a9PC-C3E_5%`00r0#)NS$8I0;)N#=}iMrbi{FOVRzfOvVupZ u?N0|p>ws@&6n*u64b50bjT!aC9{vC+8V|1+1i|M30000l literal 0 HcmV?d00001 diff --git a/src/app/valentina/share/resources/cursor/insert_node_cursor@2x.png b/src/app/valentina/share/resources/cursor/insert_node_cursor@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..418f976735a407f74266e16cd33a1c5c0a02dc0f GIT binary patch literal 1061 zcmV+=1ls$FP)AS_ZW zFwqDlqCz9JhzN=vG?FRimUDm9c{g{vZMW-z=i2Viwwu4Zd*b`y-F@%#`rhyJ`+V;> zF6B}#CaLUl9H1Cc3r6eeJMi8K7~XIP_j?qe?W-{y#oLxA@mFalz@;9 zC_14#15ji_JPV+xgzSJK61s8#ibja#1Qdxd6rd=C&LIIsAercM)_uU=5?AZ)F@(|YaLN7Z(>b!k_1d7JJI5)V{pG`Ur}}FPDjb!R6g4j>z|GESa%+kZGFzQaZ}ng2YqaST7xN)1 z{3RwXX=hM?kQYRqw#{P}drw5nvH@*2TZgCJsLCXSOjTu?9gYhum1?z0=+>=IleL4o ze7?h`W~^DFO`y5jJR5AZ)TFebdzWt8tx)40=MSwKEB&Ef;0a}&_vd?{SC5ZS;jkXP z`h1~CDYHBEr`X`TV6LKNs_!Kv?N{k~?UK5!$()9TOqH$T;&wSCp(S$?7Cz%F_NfED fv&kJ7&fEV0iaA1yQ;gW^00000NkvXXu0mjfQAGMR literal 0 HcmV?d00001 diff --git a/src/app/valentina/share/resources/toolicon.qrc b/src/app/valentina/share/resources/toolicon.qrc index 0fd19e3bf..64d036f3b 100644 --- a/src/app/valentina/share/resources/toolicon.qrc +++ b/src/app/valentina/share/resources/toolicon.qrc @@ -80,5 +80,7 @@ toolicon/32x32/path@2x.png toolicon/32x32/pin.png toolicon/32x32/pin@2x.png + toolicon/32x32/insert_node.png + toolicon/32x32/insert_node@2x.png diff --git a/src/app/valentina/share/resources/toolicon/32x32/insert_node.png b/src/app/valentina/share/resources/toolicon/32x32/insert_node.png new file mode 100644 index 0000000000000000000000000000000000000000..da441f7d010f5bf5d2de3026a39baf6e4acd8e3f GIT binary patch literal 665 zcmV;K0%rY*P)kdg0007DNklf+qimfE@po9e;^5m&n1zpArok0@m(uAly*eUD~9&8~R zMuCL|i%mlo!H^)Zw4k~yoo0?jPS<|l_O^zb+jDQ9k2x*zs*inTzfEp8Z<`H^h=`v& zY+ha$@wGNjdrQ9<@~EnHh{AT0>Kzxqx=U4dio!Ni)j2C#Rbi(nw7XfW_|lwS6NRm2 zY8Jnk!)l-TT$|af5kHzkqbIGi$ZYnABW_`X(<0(u$E+}2lOeHDMI8!pMUQV?7gs&w zhUNYcpQ=&88=|mB$zm*WPz-A}VTB8#N1Y0Gi^3L-esDgpvxji9)+cwZ0SA9Q1qm8n@Ihn$2dZr)=7ZEQSb5!gzU6TQE zN`pzgBBEPai-`Eg5*`=Vt#iXN=fyYbOZCs5_dKDth+2S_Sb-JLzO#59n z#oZospV{mX{knA7r)<40UHZf+RaveO5#7pKL`1xzN*{`d9%U^e;&*kbRIg9OfQ9%# z#GpsaLxV#`MZZ1~r>!t=59x5!7v8mAjdA}0ax@ENqm9sH00000NkvXXu0mjf-C{Ep literal 0 HcmV?d00001 diff --git a/src/app/valentina/share/resources/toolicon/32x32/insert_node@2x.png b/src/app/valentina/share/resources/toolicon/32x32/insert_node@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..3ddc9643b54d81d77f845a9d671a6ed30b30d152 GIT binary patch literal 1371 zcmV-h1*H0kP)SxPkP;nO0<2v!=Dk(in42`eB*nRA&HRCZ!tIZH?(v+?$RH6TlDT*bLD&E}rLOUwzvZ=UdK360)G zDfy(cfYN{`UzfK<0QLM&vO@$=6xuY26!0!pRI-vZuCwg-s64h0*rkqP5uH9owwFed zEcnLJCOr1r?F>?slA@16>WMe?jiN!K)9umc(Qn#r9AT0P{pS+5-QN0(6{-P#rIHd> zvq2_TH*PL4&Ci3|EHQ`dwIoFfO&#|rmRPdrlD0D>4)Kj0b-98;pwDRmvGBH&87lCNX=*P`;4Yf|9ay0rzsXt|MMoi=tg?<45YsK#xpX|6x z=)2?|goPgRGN^(J5K>FHb~5Ad-ThdESEDRsUDQpYGReWnMedMoGl7{k{$Ydg+AB7p2T@2 z1Li5oC6*VIw;`MKvz1me!w=?ZE-J~XkDYu)Birazv^MF-a9XZ@p$Tp>$4qNO2lv@4 zI@NND#Q~6`sb#=Vb!@Qv8hVGUd6ky%6R6>oMt+WZ`wa)YET%cGw8}F#LMbL8fne z;%zYQwoD&Ovz+iSw-_Ln$>i<1+DEk@e$jh~KB2zT^6IZ7-4g~EFNRMwx>`m6<7icM zXL;s|gSY2>%;M^|Dqn@h53xt_tw!HQw7kN-T9cRRb=f9VB^KzTm4e&N1Or65&oeJm zY&$f|d2hc^DirNLrPhePF#!FOLk`^=igk;R?Eo%-@lr9*ls-n8z-aR!iuRxaaFg#b z{2+e*MS{ud*9TZVq#9g1^8k){nz_lc7Vcq`;nY#oOQ#<0_Y-78&;fXxIX;q#E|P~# zJW{#${^?!(Elc%p{47Scf~b(%L$aj3=e=CJl?zhKRGF<3DBy%b@4x6I3QU!ynvx(M z{EuG6ZS2>!<_!C2QZ +image/svg+xml diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index e4a95f52d..79ec633d8 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -3747,7 +3747,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) == 52, "Not all tools were used."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were used."); QRectF rec; @@ -3882,6 +3882,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const case Tool::Group: case Tool::PiecePath: case Tool::Pin: + case Tool::InsertNode: break; } } diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 4d6535325..706aac902 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1637,7 +1637,7 @@ QStringList 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) == 52); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); QStringList expressions; const QDomNodeList list = elementsByTagName(TagPoint); @@ -1709,7 +1709,7 @@ QStringList 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) == 52); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); QStringList expressions; const QDomNodeList list = elementsByTagName(TagArc); @@ -1763,7 +1763,7 @@ QStringList 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) == 52); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); QStringList expressions; const QDomNodeList list = elementsByTagName(TagElArc); @@ -1834,7 +1834,7 @@ QStringList 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) == 52); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); QStringList expressions; const QDomNodeList list = elementsByTagName(AttrPathPoint); @@ -1901,7 +1901,7 @@ QStringList 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) == 52); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); QStringList expressions; const QDomNodeList list = elementsByTagName(TagOperation); @@ -1956,7 +1956,7 @@ QStringList 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) == 52); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); QStringList expressions; const QDomNodeList list = elementsByTagName(TagPath); @@ -2009,7 +2009,7 @@ QStringList 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) == 52); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53); QStringList expressions; const QDomNodeList list = elementsByTagName(TagDetail); diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index c8149b503..4d8d2215a 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -152,6 +152,7 @@ enum class Tool : ToolVisHolderType Midpoint, EllipticalArc, Pin, + InsertNode, LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used }; diff --git a/src/libs/vtools/dialogs/dialogs.pri b/src/libs/vtools/dialogs/dialogs.pri index 4e4f2d5c4..94dbeb526 100644 --- a/src/libs/vtools/dialogs/dialogs.pri +++ b/src/libs/vtools/dialogs/dialogs.pri @@ -44,7 +44,8 @@ HEADERS += \ $$PWD/tools/dialogellipticalarc.h \ $$PWD/tools/piece/dialogseamallowance.h \ $$PWD/tools/dialogpiecepath.h \ - $$PWD/tools/dialogpin.h + $$PWD/tools/dialogpin.h \ + $$PWD/tools/dialoginsertnode.h SOURCES += \ $$PWD/tools/dialogalongline.cpp \ @@ -88,7 +89,8 @@ SOURCES += \ $$PWD/tools/dialogellipticalarc.cpp \ $$PWD/tools/piece/dialogseamallowance.cpp \ $$PWD/tools/dialogpiecepath.cpp \ - $$PWD/tools/dialogpin.cpp + $$PWD/tools/dialogpin.cpp \ + $$PWD/tools/dialoginsertnode.cpp FORMS += \ $$PWD/tools/dialogalongline.ui \ @@ -135,4 +137,5 @@ FORMS += \ $$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/piece/tabs/tabpins.ui \ + $$PWD/tools/dialoginsertnode.ui diff --git a/src/libs/vtools/dialogs/tooldialogs.h b/src/libs/vtools/dialogs/tooldialogs.h index 8bd6558ac..ed3b103f9 100644 --- a/src/libs/vtools/dialogs/tooldialogs.h +++ b/src/libs/vtools/dialogs/tooldialogs.h @@ -68,6 +68,7 @@ #include "tools/dialogellipticalarc.h" #include "tools/dialogpiecepath.h" #include "tools/dialogpin.h" +#include "tools/dialoginsertnode.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/dialoginsertnode.cpp new file mode 100644 index 000000000..ef35bcd92 --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialoginsertnode.cpp @@ -0,0 +1,193 @@ +/************************************************************************ + ** + ** @file dialoginsertnode.cpp + ** @author Roman Telezhynskyi + ** @date 21 3, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 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 "dialoginsertnode.h" +#include "ui_dialoginsertnode.h" + +//--------------------------------------------------------------------------------------------------------------------- +DialogInsertNode::DialogInsertNode(const VContainer *data, quint32 toolId, QWidget *parent) + : DialogTool(data, toolId, parent), + ui(new Ui::DialogInsertNode), + m_node(), + m_flagItem(false) +{ + ui->setupUi(this); + InitOkCancel(ui); + + CheckPieces(); + CheckItem(); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogInsertNode::~DialogInsertNode() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogInsertNode::SetPiecesList(const QVector &list) +{ + for (int i=0; i < list.size(); ++i) + { + const VPiece piece = data->GetPiece(list.at(i)); + ui->comboBoxPiece->addItem(piece.GetName(), list.at(i)); + } + + CheckPieces(); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogInsertNode::GetPieceId() const +{ + return getCurrentObjectId(ui->comboBoxPiece); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogInsertNode::SetPieceId(quint32 id) +{ + if (ui->comboBoxPiece->count() <= 0) + { + const VPiece piece = data->GetPiece(id); + ui->comboBoxPiece->addItem(piece.GetName(), id); + } + else + { + const qint32 index = ui->comboBoxPiece->findData(id); + if (index != -1) + { + ui->comboBoxPiece->setCurrentIndex(index); + } + else + { + ui->comboBoxPiece->setCurrentIndex(0); + } + } + + CheckPieces(); +} + +//--------------------------------------------------------------------------------------------------------------------- +VPieceNode DialogInsertNode::GetNode() const +{ + return m_node; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogInsertNode::SetNode(const VPieceNode &node) +{ + m_node = node; + m_flagItem = true; + QString name = tr("Uknown"); + try + { + name = qApp->TrVars()->InternalVarToUser(data->GetGObject(m_node.GetId())->name()); + } + catch (const VExceptionBadId &) + { + m_flagItem = false; + // Broken id + } + + ui->labelItemName->setText(name); + ui->labelItemName->setToolTip(name); + + CheckItem(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogInsertNode::ChosenObject(quint32 id, const SceneObject &type) +{ + if (not prepare) + { + VPieceNode node; + switch (type) + { + case SceneObject::Arc: + node = VPieceNode(id, Tool::NodeArc); + break; + case SceneObject::ElArc: + node = VPieceNode(id, Tool::NodeElArc); + break; + case SceneObject::Point: + node = VPieceNode(id, Tool::NodePoint); + break; + case SceneObject::Spline: + node = VPieceNode(id, Tool::NodeSpline); + break; + case SceneObject::SplinePath: + node = VPieceNode(id, Tool::NodeSplinePath); + break; + case (SceneObject::Line): + case (SceneObject::Detail): + case (SceneObject::Unknown): + default: + qDebug() << "Got wrong scene object. Ignore."; + return; + } + + SetNode(node); + + prepare = true; + this->setModal(true); + this->show(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogInsertNode::CheckState() +{ + SCASSERT(bOk != nullptr); + bOk->setEnabled(m_flagItem && flagError); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogInsertNode::CheckPieces() +{ + QColor color = okColor; + if (ui->comboBoxPiece->count() <= 0) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelPiece, color); + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogInsertNode::CheckItem() +{ + QColor color = okColor; + m_flagItem ? color = okColor : color = errorColor; + ChangeColor(ui->labelItem, color); + CheckState(); +} diff --git a/src/libs/vtools/dialogs/tools/dialoginsertnode.h b/src/libs/vtools/dialogs/tools/dialoginsertnode.h new file mode 100644 index 000000000..6171e7c7c --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialoginsertnode.h @@ -0,0 +1,73 @@ +/************************************************************************ + ** + ** @file dialoginsertnode.h + ** @author Roman Telezhynskyi + ** @date 21 3, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 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 DIALOGINSERTNODE_H +#define DIALOGINSERTNODE_H + +#include "dialogtool.h" +#include "../vpatterndb/vpiecenode.h" + +namespace Ui +{ + class DialogInsertNode; +} + +class DialogInsertNode : public DialogTool +{ + Q_OBJECT + +public: + explicit DialogInsertNode(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); + virtual ~DialogInsertNode(); + + virtual void SetPiecesList(const QVector &list) Q_DECL_OVERRIDE; + + quint32 GetPieceId() const; + void SetPieceId(quint32 id); + + VPieceNode GetNode() const; + void SetNode(const VPieceNode &node); + +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; + +protected: + virtual void CheckState() Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(DialogInsertNode) + Ui::DialogInsertNode *ui; + + VPieceNode m_node; + bool m_flagItem; + + void CheckPieces(); + void CheckItem(); +}; + +#endif // DIALOGINSERTNODE_H diff --git a/src/libs/vtools/dialogs/tools/dialoginsertnode.ui b/src/libs/vtools/dialogs/tools/dialoginsertnode.ui new file mode 100644 index 000000000..6b034c86f --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialoginsertnode.ui @@ -0,0 +1,101 @@ + + + DialogInsertNode + + + + 0 + 0 + 244 + 103 + + + + Insert node + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Item: + + + + + + + item name + + + + + + + Piece: + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DialogInsertNode + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogInsertNode + reject() + + + 316 + 260 + + + 286 + 274 + + + + + From fa1ab37ca2260868223fc93043e57cd79afdb3aa Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 21 Mar 2017 15:42:37 +0200 Subject: [PATCH 2/6] Fix dialogs window title. --HG-- branch : feature --- src/libs/vtools/dialogs/tools/dialogellipticalarc.ui | 6 +++++- src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui | 2 +- src/libs/vtools/dialogs/tools/dialogflippingbyline.ui | 2 +- src/libs/vtools/dialogs/tools/dialogmove.ui | 2 +- src/libs/vtools/dialogs/tools/dialogpin.ui | 10 ++++++++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/libs/vtools/dialogs/tools/dialogellipticalarc.ui b/src/libs/vtools/dialogs/tools/dialogellipticalarc.ui index ea551e763..2721767be 100644 --- a/src/libs/vtools/dialogs/tools/dialogellipticalarc.ui +++ b/src/libs/vtools/dialogs/tools/dialogellipticalarc.ui @@ -11,7 +11,11 @@ - Dialog + Elliptical arc + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui index d80fc67e4..d21839e55 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.ui @@ -11,7 +11,7 @@ - Dialog + Flipping by axis diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.ui b/src/libs/vtools/dialogs/tools/dialogflippingbyline.ui index 81d43f46f..fc76e9099 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.ui +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.ui @@ -11,7 +11,7 @@ - Dialog + Flipping by line diff --git a/src/libs/vtools/dialogs/tools/dialogmove.ui b/src/libs/vtools/dialogs/tools/dialogmove.ui index c3b39063f..677859d71 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.ui +++ b/src/libs/vtools/dialogs/tools/dialogmove.ui @@ -11,7 +11,7 @@ - Dialog + Move diff --git a/src/libs/vtools/dialogs/tools/dialogpin.ui b/src/libs/vtools/dialogs/tools/dialogpin.ui index 682ffb9a1..8e5c65b3f 100644 --- a/src/libs/vtools/dialogs/tools/dialogpin.ui +++ b/src/libs/vtools/dialogs/tools/dialogpin.ui @@ -11,7 +11,11 @@ - Dialog + Pin + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png Pin tool @@ -53,7 +57,9 @@ - + + + buttonBox From 86f6bb035d60306c6b8f308b6388b5cddd979a72 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 21 Mar 2017 17:03:09 +0200 Subject: [PATCH 3/6] Code style. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 80e940776..050573c7f 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1229,7 +1229,7 @@ void MainWindow::ToolPointOfIntersectionArcs(bool checked) SetToolButtonWithApply(checked, Tool::PointOfIntersectionArcs, "://cursor/point_of_intersection_arcs.png", tr("Select first an arc"), - &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } @@ -1240,8 +1240,8 @@ void MainWindow::ToolPointOfIntersectionCircles(bool checked) SetToolButtonWithApply(checked, Tool::PointOfIntersectionCircles, "://cursor/point_of_intersection_circles.png", tr("Select first circle center"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1251,8 +1251,8 @@ void MainWindow::ToolPointOfIntersectionCurves(bool checked) SetToolButtonWithApply(checked, Tool::PointOfIntersectionCurves, "://cursor/intersection_curves_cursor.png", tr("Select first curve"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1262,8 +1262,8 @@ void MainWindow::ToolPointFromCircleAndTangent(bool checked) SetToolButtonWithApply(checked, Tool::PointFromCircleAndTangent, "://cursor/point_from_circle_and_tangent_cursor.png", tr("Select point on tangent"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1273,7 +1273,7 @@ void MainWindow::ToolPointFromArcAndTangent(bool checked) SetToolButtonWithApply(checked, Tool::PointFromArcAndTangent, "://cursor/point_from_arc_and_tangent_cursor.png", tr("Select point on tangent"), - &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } From 7fe86bc319854734316023a30355d6706acea0a8 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 21 Mar 2017 17:18:48 +0200 Subject: [PATCH 4/6] Successful build. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 12 +- src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/pattern/v0.4.5.xsd | 876 ++++++++++++++++++ src/libs/ifc/xml/vabstractpattern.cpp | 3 + src/libs/ifc/xml/vabstractpattern.h | 1 + src/libs/ifc/xml/vpatternconverter.cpp | 18 +- src/libs/ifc/xml/vpatternconverter.h | 5 +- src/libs/vpatterndb/vpiecenode.cpp | 12 + src/libs/vpatterndb/vpiecenode.h | 3 + src/libs/vpatterndb/vpiecenode_p.h | 7 + .../vtools/dialogs/tools/dialoginsertnode.cpp | 1 + src/libs/vtools/tools/vabstracttool.cpp | 10 + src/libs/vtools/tools/vtoolseamallowance.cpp | 28 + src/libs/vtools/tools/vtoolseamallowance.h | 2 + src/libs/vtools/tools/vtooluniondetails.cpp | 6 +- 15 files changed, 976 insertions(+), 9 deletions(-) create mode 100644 src/libs/ifc/schema/pattern/v0.4.5.xsd diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 050573c7f..600549224 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1167,12 +1167,14 @@ void MainWindow::ClosedDialogPin(int result) void MainWindow::ClosedDialogInsertNode(int result) { SCASSERT(dialogTool != nullptr); -// if (result == QDialog::Accepted) -// { -// VToolInsertTool::Create(dialogTool, doc, pattern); -// } + if (result == QDialog::Accepted) + { + DialogInsertNode *dTool = qobject_cast(dialogTool); + SCASSERT(dTool != nullptr); + VToolSeamAllowance::InsertNode(dTool->GetNode(), dTool->GetPieceId(), pattern, doc); + } ArrowTool(); -// doc->LiteParseTree(Document::LiteParse); + doc->LiteParseTree(Document::LiteParse); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 36ee8e5e6..617a40a45 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -28,6 +28,7 @@ schema/pattern/v0.4.2.xsd schema/pattern/v0.4.3.xsd schema/pattern/v0.4.4.xsd + schema/pattern/v0.4.5.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.4.5.xsd b/src/libs/ifc/schema/pattern/v0.4.5.xsd new file mode 100644 index 000000000..2813487dc --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.4.5.xsd @@ -0,0 +1,876 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 706aac902..9f41ae600 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -107,6 +107,7 @@ const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber" const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement"); const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows"); const QString VAbstractPattern::AttrNodeReverse = QStringLiteral("reverse"); +const QString VAbstractPattern::AttrNodeExcluded = QStringLiteral("excluded"); const QString VAbstractPattern::AttrSABefore = QStringLiteral("before"); const QString VAbstractPattern::AttrSAAfter = QStringLiteral("after"); const QString VAbstractPattern::AttrStart = QStringLiteral("start"); @@ -665,6 +666,7 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement) { const quint32 id = VDomDocument::GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR); const bool reverse = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrNodeReverse, "0"); + const bool excluded = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrNodeExcluded, "0"); const QString saBefore = VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSABefore, currentSeamAllowance); const QString saAfter = VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSAAfter, @@ -705,6 +707,7 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement) node.SetFormulaSABefore(saBefore); node.SetFormulaSAAfter(saAfter); node.SetAngleType(angle); + node.SetExcluded(excluded); return node; } diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index bdc11de53..0eb281daf 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -217,6 +217,7 @@ public: static const QString AttrPlacement; static const QString AttrArrows; static const QString AttrNodeReverse; + static const QString AttrNodeExcluded; static const QString AttrSABefore; static const QString AttrSAAfter; static const QString AttrStart; diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index aafd32345..19f4443e3 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -207,6 +207,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000403): return QStringLiteral("://schema/pattern/v0.4.3.xsd"); case (0x000404): + return QStringLiteral("://schema/pattern/v0.4.4.xsd"); + case (0x000405): return CurrentSchema; default: InvalidVersion(ver); @@ -329,6 +331,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000404), m_convertedFileName); V_FALLTHROUGH case (0x000404): + ToV0_4_5(); + ValidateXML(XSDSchema(0x000405), m_convertedFileName); + V_FALLTHROUGH + case (0x000405): break; default: InvalidVersion(m_ver); @@ -347,7 +353,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, 4, 4), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 4, 5), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -676,6 +682,16 @@ void VPatternConverter::ToV0_4_4() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_4_5() +{ + // TODO. Delete if minimal supported version is 0.4.5 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 4, 5), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.4.5")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 70df5445e..1eb0a7b0b 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -55,10 +55,10 @@ public: // GCC 4.6 doesn't allow constexpr and const together #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406 static Q_DECL_CONSTEXPR int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 4); + static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 5); #else static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 4); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 5); #endif protected: @@ -105,6 +105,7 @@ private: void ToV0_4_2(); void ToV0_4_3(); void ToV0_4_4(); + void ToV0_4_5(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp index 2d74cd4a5..b83daa1df 100644 --- a/src/libs/vpatterndb/vpiecenode.cpp +++ b/src/libs/vpatterndb/vpiecenode.cpp @@ -235,3 +235,15 @@ QDataStream& operator>>(QDataStream& in, VPieceNode& p) in >> p.d->m_reverse; return in; } + +//--------------------------------------------------------------------------------------------------------------------- +bool VPieceNode::IsExcluded() const +{ + return d->m_excluded; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceNode::SetExcluded(bool exclude) +{ + d->m_excluded = exclude; +} diff --git a/src/libs/vpatterndb/vpiecenode.h b/src/libs/vpatterndb/vpiecenode.h index a350164a4..d16616493 100644 --- a/src/libs/vpatterndb/vpiecenode.h +++ b/src/libs/vpatterndb/vpiecenode.h @@ -59,6 +59,9 @@ public: bool GetReverse() const; void SetReverse(bool reverse); + bool IsExcluded() const; + void SetExcluded(bool exclude); + qreal GetSABefore(const VContainer *data) const; qreal GetSABefore(const VContainer *data, Unit unit) const; diff --git a/src/libs/vpatterndb/vpiecenode_p.h b/src/libs/vpatterndb/vpiecenode_p.h index 6defef952..0c6fb68ed 100644 --- a/src/libs/vpatterndb/vpiecenode_p.h +++ b/src/libs/vpatterndb/vpiecenode_p.h @@ -43,6 +43,7 @@ public: : m_id(NULL_ID), m_typeTool(Tool::NodePoint), m_reverse(false), + m_excluded(false), m_saBefore(-1), m_saAfter(-1), m_formulaWidthBefore(currentSeamAllowance), @@ -54,6 +55,7 @@ public: : m_id(id), m_typeTool(typeTool), m_reverse(reverse), + m_excluded(false), m_saBefore(-1), m_saAfter(-1), m_formulaWidthBefore(currentSeamAllowance), @@ -71,6 +73,7 @@ public: m_id(node.m_id), m_typeTool(node.m_typeTool), m_reverse(node.m_reverse), + m_excluded(node.m_excluded), m_saBefore(node.m_saBefore), m_saAfter(node.m_saAfter), m_formulaWidthBefore(node.m_formulaWidthBefore), @@ -89,6 +92,10 @@ public: /** @brief reverse true if need reverse points list for node. */ bool m_reverse; + /** @brief m_excluded true if item excluded from main path. Excluded item is not visible and also will not has + * affect on main path. Also include to exist path items automatically setted excluded. */ + bool m_excluded; + qreal m_saBefore; qreal m_saAfter; diff --git a/src/libs/vtools/dialogs/tools/dialoginsertnode.cpp b/src/libs/vtools/dialogs/tools/dialoginsertnode.cpp index ef35bcd92..c3eadd59c 100644 --- a/src/libs/vtools/dialogs/tools/dialoginsertnode.cpp +++ b/src/libs/vtools/dialogs/tools/dialoginsertnode.cpp @@ -150,6 +150,7 @@ void DialogInsertNode::ChosenObject(quint32 id, const SceneObject &type) return; } + node.SetExcluded(true); SetNode(node); prepare = true; diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index 5d8e62684..28da1944f 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -624,6 +624,16 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa } } + const bool excluded = node.IsExcluded(); + if (excluded) + { + doc->SetAttribute(nod, VAbstractPattern::AttrNodeExcluded, node.IsExcluded()); + } + else + { // For backward compatebility. + nod.removeAttribute(VAbstractPattern::AttrNodeExcluded); + } + switch (type) { case (Tool::NodeArc): diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index dece7bca2..e005b1976 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -166,6 +166,34 @@ void VToolSeamAllowance::Remove(bool ask) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::InsertNode(const VPieceNode &node, quint32 pieceId, VContainer *data, VAbstractPattern *doc) +{ + SCASSERT(data != nullptr); + + if (pieceId > NULL_ID) + { + VPiece oldDet; + try + { + oldDet = data->GetPiece(pieceId); + } + catch (const VExceptionBadId &) + { + return; + } + + VPiece newDet = oldDet; + + newDet.GetPath().Append(node); + + SavePieceOptions *saveCommand = new SavePieceOptions(oldDet, newDet, doc, pieceId); + qApp->getUndoStack()->push(saveCommand);// First push then make a connect + data->UpdatePiece(pieceId, newDet);// Update piece because first save will not call lite update + connect(saveCommand, &SavePieceOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); + } +} + //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiece &piece) { diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 08d70bf99..023e1fdec 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -74,6 +74,8 @@ public: void Remove(bool ask); + static void InsertNode(const VPieceNode &node, quint32 pieceId, VContainer *data, VAbstractPattern *doc); + static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiece &piece); static void AddCSARecord(VAbstractPattern *doc, QDomElement &domElement, const CustomSARecord &record); static void AddCSARecords(VAbstractPattern *doc, QDomElement &domElement, const QVector &records); diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index 1e9442ac3..3e35e9776 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -624,7 +624,11 @@ void AddNodeToNewPath(const VToolUnionDetailsInitData &initData, VPiecePath &new qDebug()<<"May be wrong tool type!!! Ignoring."< Date: Tue, 21 Mar 2017 18:00:31 +0200 Subject: [PATCH 5/6] Create modeling items before insert new node. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 2 +- src/libs/vtools/tools/vabstracttool.cpp | 69 +++++++++------ src/libs/vtools/tools/vabstracttool.h | 3 + src/libs/vtools/tools/vtoolseamallowance.cpp | 89 ++++++++++++-------- src/libs/vtools/tools/vtoolseamallowance.h | 8 +- 5 files changed, 103 insertions(+), 68 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 600549224..43753ccee 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1171,7 +1171,7 @@ void MainWindow::ClosedDialogInsertNode(int result) { DialogInsertNode *dTool = qobject_cast(dialogTool); SCASSERT(dTool != nullptr); - VToolSeamAllowance::InsertNode(dTool->GetNode(), dTool->GetPieceId(), pattern, doc); + VToolSeamAllowance::InsertNode(dTool->GetNode(), dTool->GetPieceId(), sceneDetails, pattern, doc); } ArrowTool(); doc->LiteParseTree(Document::LiteParse); diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index 28da1944f..eb3036c03 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -679,36 +679,51 @@ QVector VAbstractTool::PrepareNodes(const VPiecePath &path, VMainGra QVector nodes; for (int i = 0; i< path.CountNodes(); ++i) { - quint32 id = 0; VPieceNode nodeD = path.at(i); - switch (nodeD.GetTypeTool()) + const quint32 id = PrepareNode(nodeD, scene, doc, data); + if (id > NULL_ID) { - case (Tool::NodePoint): - id = CreateNode(data, nodeD.GetId()); - VNodePoint::Create(doc, data, scene, id, nodeD.GetId(), Document::FullParse, Source::FromGui); - break; - case (Tool::NodeArc): - id = CreateNode(data, nodeD.GetId()); - VNodeArc::Create(doc, data, id, nodeD.GetId(), Document::FullParse, Source::FromGui); - break; - case (Tool::NodeElArc): - id = CreateNode(data, nodeD.GetId()); - VNodeEllipticalArc::Create(doc, data, id, nodeD.GetId(), Document::FullParse, Source::FromGui); - break; - case (Tool::NodeSpline): - id = CreateNodeSpline(data, nodeD.GetId()); - VNodeSpline::Create(doc, data, id, nodeD.GetId(), Document::FullParse, Source::FromGui); - break; - case (Tool::NodeSplinePath): - id = CreateNodeSplinePath(data, nodeD.GetId()); - VNodeSplinePath::Create(doc, data, id, nodeD.GetId(), Document::FullParse, Source::FromGui); - break; - default: - qDebug()<<"May be wrong tool type!!! Ignoring."<(data, node.GetId()); + VNodePoint::Create(doc, data, scene, id, node.GetId(), Document::FullParse, Source::FromGui); + break; + case (Tool::NodeArc): + id = CreateNode(data, node.GetId()); + VNodeArc::Create(doc, data, id, node.GetId(), Document::FullParse, Source::FromGui); + break; + case (Tool::NodeElArc): + id = CreateNode(data, node.GetId()); + VNodeEllipticalArc::Create(doc, data, id, node.GetId(), Document::FullParse, Source::FromGui); + break; + case (Tool::NodeSpline): + id = CreateNodeSpline(data, node.GetId()); + VNodeSpline::Create(doc, data, id, node.GetId(), Document::FullParse, Source::FromGui); + break; + case (Tool::NodeSplinePath): + id = CreateNodeSplinePath(data, node.GetId()); + VNodeSplinePath::Create(doc, data, id, node.GetId(), Document::FullParse, Source::FromGui); + break; + default: + qDebug()<<"May be wrong tool type!!! Ignoring."< PrepareNodes(const VPiecePath &path, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); + static quint32 PrepareNode(const VPieceNode &node, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data); private: Q_DISABLE_COPY(VAbstractTool) }; diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index e005b1976..d0788a5cc 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -167,9 +167,12 @@ void VToolSeamAllowance::Remove(bool ask) } //--------------------------------------------------------------------------------------------------------------------- -void VToolSeamAllowance::InsertNode(const VPieceNode &node, quint32 pieceId, VContainer *data, VAbstractPattern *doc) +void VToolSeamAllowance::InsertNode(VPieceNode node, quint32 pieceId, VMainGraphicsScene *scene, + VContainer *data, VAbstractPattern *doc) { - SCASSERT(data != nullptr); + SCASSERT(scene != nullptr) + SCASSERT(data != nullptr) + SCASSERT(doc != nullptr) if (pieceId > NULL_ID) { @@ -185,8 +188,21 @@ void VToolSeamAllowance::InsertNode(const VPieceNode &node, quint32 pieceId, VCo VPiece newDet = oldDet; + const quint32 id = PrepareNode(node, scene, doc, data); + if (id == NULL_ID) + { + return; + } + + node.SetId(id); newDet.GetPath().Append(node); + // Seam allowance tool already initializated and can't init the node + VToolSeamAllowance *saTool = qobject_cast(doc->getTool(pieceId)); + SCASSERT(saTool != nullptr); + + InitNode(node, scene, data, doc, saTool); + SavePieceOptions *saveCommand = new SavePieceOptions(oldDet, newDet, doc, pieceId); qApp->getUndoStack()->push(saveCommand);// First push then make a connect data->UpdatePiece(pieceId, newDet);// Update piece because first save will not call lite update @@ -1422,24 +1438,43 @@ void VToolSeamAllowance::InitNodes(const VPiece &detail, VMainGraphicsScene *sce { for (int i = 0; i< detail.GetPath().CountNodes(); ++i) { - switch (detail.GetPath().at(i).GetTypeTool()) + InitNode(detail.GetPath().at(i), scene, &(VAbstractTool::data), doc, this); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *scene, VContainer *data, + VAbstractPattern *doc, VToolSeamAllowance *parent) +{ + SCASSERT(scene != nullptr) + SCASSERT(data != nullptr) + SCASSERT(doc != nullptr) + SCASSERT(parent != nullptr) + + switch (node.GetTypeTool()) + { + case (Tool::NodePoint): { - case (Tool::NodePoint): - { - VNodePoint *tool = InitTool(scene, detail.GetPath().at(i).GetId()); - connect(tool, &VNodePoint::ShowContextMenu, this, &VToolSeamAllowance::contextMenuEvent); - break; - } - case (Tool::NodeArc): - case (Tool::NodeElArc): - case (Tool::NodeSpline): - case (Tool::NodeSplinePath): - doc->IncrementReferens(VAbstractTool::data.GetGObject(detail.GetPath().at(i).GetId())->getIdTool()); - break; - default: - qDebug()<<"Get wrong tool type. Ignore."; - break; + VNodePoint *tool = qobject_cast(doc->getTool(node.GetId())); + SCASSERT(tool != nullptr); + + connect(tool, &VNodePoint::ShowContextMenu, parent, &VToolSeamAllowance::contextMenuEvent); + connect(tool, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + tool->setParentItem(parent); + tool->SetParentType(ParentType::Item); + tool->setVisible(not node.IsExcluded());//Hide excluded point + doc->IncrementReferens(node.GetId()); + break; } + case (Tool::NodeArc): + case (Tool::NodeElArc): + case (Tool::NodeSpline): + case (Tool::NodeSplinePath): + doc->IncrementReferens(data->GetGObject(node.GetId())->getIdTool()); + break; + default: + qDebug()<<"Get wrong tool type. Ignore."; + break; } } @@ -1528,21 +1563,3 @@ void VToolSeamAllowance::ToolCreation(const Source &typeCreation) RefreshDataInFile(); } } - -//--------------------------------------------------------------------------------------------------------------------- -template -/** - * @brief InitTool initial node item on scene - * @param scene pointer to scene. - * @param toolId if of tool object. - */ -Tool *VToolSeamAllowance::InitTool(VMainGraphicsScene *scene, quint32 toolId) -{ - Tool *tool = qobject_cast(doc->getTool(toolId)); - SCASSERT(tool != nullptr); - connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - tool->setParentItem(this); - tool->SetParentType(ParentType::Item); - doc->IncrementReferens(toolId); - return tool; -} diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 023e1fdec..4eab60d9e 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -74,7 +74,8 @@ public: void Remove(bool ask); - static void InsertNode(const VPieceNode &node, quint32 pieceId, VContainer *data, VAbstractPattern *doc); + static void InsertNode(VPieceNode node, quint32 pieceId, VMainGraphicsScene *scene, VContainer *data, + VAbstractPattern *doc); static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiece &piece); static void AddCSARecord(VAbstractPattern *doc, QDomElement &domElement, const CustomSARecord &record); @@ -160,12 +161,11 @@ private: QPointF &pos); 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 InitInternalPaths(const VPiece &detail); void InitPins(const VPiece &detail); - - template - Tool* InitTool(VMainGraphicsScene *scene, quint32 toolId); }; #endif // VTOOLSEAMALLOWANCE_H From e995f6f68a3a28fbc86bbeadcaab812e0c0d40c2 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 22 Mar 2017 12:05:53 +0200 Subject: [PATCH 6/6] Added new tool Insert node. --HG-- branch : feature --- src/libs/ifc/xml/vabstractpattern.cpp | 2 +- src/libs/ifc/xml/vpatternconverter.cpp | 4 +- src/libs/vpatterndb/vpiece.cpp | 17 ++- src/libs/vpatterndb/vpiece.h | 2 +- src/libs/vpatterndb/vpiecepath.cpp | 14 ++- src/libs/vpatterndb/vpiecepath.h | 2 +- src/libs/vtools/dialogs/tools/dialogtool.cpp | 100 ++++++++++++++++-- src/libs/vtools/dialogs/tools/dialogtool.h | 4 +- .../tools/piece/dialogseamallowance.cpp | 39 +++++-- .../tools/nodeDetails/vabstractnode.cpp | 21 +++- .../vtools/tools/nodeDetails/vabstractnode.h | 10 +- .../vtools/tools/nodeDetails/vnodepoint.cpp | 2 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 20 ++++ src/libs/vtools/tools/vtoolseamallowance.h | 1 + 14 files changed, 204 insertions(+), 34 deletions(-) diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 9f41ae600..509634035 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -666,7 +666,7 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement) { const quint32 id = VDomDocument::GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR); const bool reverse = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrNodeReverse, "0"); - const bool excluded = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrNodeExcluded, "0"); + const bool excluded = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeExcluded, falseStr); const QString saBefore = VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSABefore, currentSeamAllowance); const QString saAfter = VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSAAfter, diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 19f4443e3..44b74b287 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.4.4"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.4.4.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.4.5"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.4.5.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index ef954c760..1de1c57ca 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -121,9 +121,9 @@ QVector VPiece::MainPathPoints(const VContainer *data) const } //--------------------------------------------------------------------------------------------------------------------- -QVector VPiece::MainPathNodePoints(const VContainer *data) const +QVector VPiece::MainPathNodePoints(const VContainer *data, bool showExcluded) const { - return GetPath().PathNodePoints(data); + return GetPath().PathNodePoints(data, showExcluded); } //--------------------------------------------------------------------------------------------------------------------- @@ -146,6 +146,11 @@ QVector VPiece::SeamAllowancePoints(const VContainer *data) const for (int i = 0; i< d->m_path.CountNodes(); ++i) { const VPieceNode &node = d->m_path.at(i); + if (node.IsExcluded()) + { + continue;// skip excluded node + } + switch (node.GetTypeTool()) { case (Tool::NodePoint): @@ -491,12 +496,16 @@ QVector VPiece::GetValidRecords() const for (int i = 0; i < d->m_customSARecords.size(); ++i) { const CustomSARecord &record = d->m_customSARecords.at(i); + const int indexStartPoint = d->m_path.indexOfNode(record.startPoint); + const int indexEndPoint = d->m_path.indexOfNode(record.endPoint); if (record.startPoint > NULL_ID && record.path > NULL_ID && record.endPoint > NULL_ID - && d->m_path.indexOfNode(record.startPoint) != -1 - && d->m_path.indexOfNode(record.endPoint) != -1) + && indexStartPoint != -1 + && not d->m_path.at(indexStartPoint).IsExcluded() + && indexEndPoint != -1 + && not d->m_path.at(indexEndPoint).IsExcluded()) { records.append(record); } diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 31c7fe476..234a2bbf1 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -59,7 +59,7 @@ public: void SetPath(const VPiecePath &path); QVector MainPathPoints(const VContainer *data) const; - QVector MainPathNodePoints(const VContainer *data) const; + QVector MainPathNodePoints(const VContainer *data, bool showExcluded = false) const; QVector SeamAllowancePoints(const VContainer *data) const; QPainterPath MainPathPath(const VContainer *data) const; diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index d11956179..998061e1b 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -243,6 +243,11 @@ QVector VPiecePath::PathPoints(const VContainer *data) const QVector points; for (int i = 0; i < CountNodes(); ++i) { + if (at(i).IsExcluded()) + { + continue;// skip excluded node + } + switch (at(i).GetTypeTool()) { case (Tool::NodePoint): @@ -274,7 +279,7 @@ QVector VPiecePath::PathPoints(const VContainer *data) const } //--------------------------------------------------------------------------------------------------------------------- -QVector VPiecePath::PathNodePoints(const VContainer *data) const +QVector VPiecePath::PathNodePoints(const VContainer *data, bool showExcluded) const { QVector points; for (int i = 0; i < CountNodes(); ++i) @@ -283,8 +288,11 @@ QVector VPiecePath::PathNodePoints(const VContainer *data) const { case Tool::NodePoint: { - const QSharedPointer point = data->GeometricObject(at(i).GetId()); - points.append(*point); + if (showExcluded || not at(i).IsExcluded()) + { + const QSharedPointer point = data->GeometricObject(at(i).GetId()); + points.append(*point); + } } break; case Tool::NodeArc: diff --git a/src/libs/vpatterndb/vpiecepath.h b/src/libs/vpatterndb/vpiecepath.h index 4bb8400fe..492053c0c 100644 --- a/src/libs/vpatterndb/vpiecepath.h +++ b/src/libs/vpatterndb/vpiecepath.h @@ -71,7 +71,7 @@ public: void SetPenType(const Qt::PenStyle &type); QVector PathPoints(const VContainer *data) const; - QVector PathNodePoints(const VContainer *data) const; + QVector PathNodePoints(const VContainer *data, bool showExcluded = true) const; QVector SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const; QPainterPath PainterPath(const VContainer *data) const; diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 6216b6b20..93628eb88 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -79,6 +79,25 @@ Q_LOGGING_CATEGORY(vDialog, "v.dialog") #define DIALOG_MAX_FORMULA_HEIGHT 64 +namespace +{ +//--------------------------------------------------------------------------------------------------------------------- +quint32 RowId(QListWidget *listWidget, int i) +{ + SCASSERT(listWidget != nullptr); + + if (i < 0 || i >= listWidget->count()) + { + return NULL_ID; + } + + const QListWidgetItem *rowItem = listWidget->item(i); + SCASSERT(rowItem != nullptr); + const VPieceNode rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + return rowNode.GetId(); +} +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogTool create dialog @@ -411,13 +430,65 @@ quint32 DialogTool::DNumber(const QString &baseName) const } //--------------------------------------------------------------------------------------------------------------------- -quint32 DialogTool::RowId(QListWidget *listWidget, int i) +quint32 DialogTool::FindNotExcludedNodeDown(QListWidget *listWidget, int candidate) { SCASSERT(listWidget != nullptr); - const QListWidgetItem *rowItem = listWidget->item(i); - SCASSERT(rowItem != nullptr); - const VPieceNode rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); - return rowNode.GetId(); + + quint32 id = NULL_ID; + if (candidate < 0 || candidate >= listWidget->count()) + { + return id; + } + + int i = candidate; + VPieceNode rowNode; + do + { + const QListWidgetItem *rowItem = listWidget->item(i); + SCASSERT(rowItem != nullptr); + rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + + if (not rowNode.IsExcluded()) + { + id = rowNode.GetId(); + } + + ++i; + } + while (rowNode.IsExcluded() && i < listWidget->count()); + + return id; +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogTool::FindNotExcludedNodeUp(QListWidget *listWidget, int candidate) +{ + SCASSERT(listWidget != nullptr); + + quint32 id = NULL_ID; + if (candidate < 0 || candidate >= listWidget->count()) + { + return id; + } + + int i = candidate; + VPieceNode rowNode; + do + { + const QListWidgetItem *rowItem = listWidget->item(i); + SCASSERT(rowItem != nullptr); + rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + + if (not rowNode.IsExcluded()) + { + id = rowNode.GetId(); + } + + --i; + } + while (rowNode.IsExcluded() && i > -1); + + return id; } //--------------------------------------------------------------------------------------------------------------------- @@ -426,7 +497,9 @@ bool DialogTool::FirstPointEqualLast(QListWidget *listWidget) SCASSERT(listWidget != nullptr); if (listWidget->count() > 1) { - return RowId(listWidget, 0) == RowId(listWidget, listWidget->count()-1); + const quint32 topId = FindNotExcludedNodeDown(listWidget, 0); + const quint32 bottomId = FindNotExcludedNodeUp(listWidget, listWidget->count()-1); + return topId == bottomId; } return false; } @@ -437,7 +510,10 @@ bool DialogTool::DoublePoints(QListWidget *listWidget) SCASSERT(listWidget != nullptr); for (int i=0, sz = listWidget->count()-1; isetFont(QFont("Times", 12, QFont::Bold)); + item->setFont(NodeFont(node.IsExcluded())); item->setData(Qt::UserRole, QVariant::fromValue(node)); listWidget->addItem(item); listWidget->setCurrentRow(listWidget->count()-1); diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index b57bcb642..95ea94b98 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -266,10 +266,12 @@ protected: virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; quint32 DNumber(const QString &baseName) const; - static quint32 RowId(QListWidget *listWidget, int i); + static quint32 FindNotExcludedNodeDown(QListWidget *listWidget, int candidate); + static quint32 FindNotExcludedNodeUp(QListWidget *listWidget, int candidate); static bool FirstPointEqualLast(QListWidget *listWidget); static bool DoublePoints(QListWidget *listWidget); static QString DialogWarningIcon(); + static QFont NodeFont(bool nodeExcluded); QString GetNodeName(const VPieceNode &node) const; void NewNodeItem(QListWidget *listWidget, const VPieceNode &node); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 7fb12683a..b1060eb01 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -587,6 +587,10 @@ void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos) actionReverse->setChecked(rowNode.GetReverse()); } + QAction *actionExcluded = menu->addAction(tr("Excluded")); + actionExcluded->setCheckable(true); + actionExcluded->setChecked(rowNode.IsExcluded()); + QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); QAction *selectedAction = menu->exec(uiTabPaths->listWidgetMainPath->viewport()->mapToGlobal(pos)); @@ -602,6 +606,14 @@ void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos) rowItem->setText(GetNodeName(rowNode)); ValidObjects(MainPathIsValid()); } + else if (selectedAction == actionExcluded) + { + rowNode.SetExcluded(not rowNode.IsExcluded()); + rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); + rowItem->setText(GetNodeName(rowNode)); + rowItem->setFont(NodeFont(rowNode.IsExcluded())); + ValidObjects(MainPathIsValid()); + } ListChanged(); } @@ -1989,12 +2001,13 @@ QString DialogSeamAllowance::GetPathName(quint32 path, bool reverse) const bool DialogSeamAllowance::MainPathIsValid() const { QString url = DialogWarningIcon(); + bool valid = true; if(CreatePiece().MainPathPoints(data).count() < 3) { url += tr("You need more points!"); uiTabPaths->helpLabel->setText(url); - return false; + valid = false; } else { @@ -2002,23 +2015,33 @@ bool DialogSeamAllowance::MainPathIsValid() const { url += tr("You have to choose points in a clockwise direction!"); uiTabPaths->helpLabel->setText(url); - return false; + valid = false; } if (FirstPointEqualLast(uiTabPaths->listWidgetMainPath)) { url += tr("First point cannot be equal to the last point!"); uiTabPaths->helpLabel->setText(url); - return false; + valid = false; } else if (DoublePoints(uiTabPaths->listWidgetMainPath)) { url += tr("You have double points!"); uiTabPaths->helpLabel->setText(url); - return false; + valid = false; } } - uiTabPaths->helpLabel->setText(tr("Ready!")); - return true; + + if (valid) + { + m_ftb->SetTabText(TabOrder::Paths, tr("Paths")); + uiTabPaths->helpLabel->setText(tr("Ready!")); + } + else + { + m_ftb->SetTabText(TabOrder::Paths, tr("Paths") + QLatin1String("*")); + } + + return valid; } //--------------------------------------------------------------------------------------------------------------------- @@ -2059,7 +2082,7 @@ void DialogSeamAllowance::InitNodesList() for (int i = 0; i < nodes.size(); ++i) { const VPieceNode node = nodes.at(i); - if (node.GetTypeTool() == Tool::NodePoint) + if (node.GetTypeTool() == Tool::NodePoint && not node.IsExcluded()) { const QString name = GetNodeName(node); @@ -2283,7 +2306,7 @@ void DialogSeamAllowance::InitCSAPoint(QComboBox *box) for (int i = 0; i < nodes.size(); ++i) { const VPieceNode &node = nodes.at(i); - if (node.GetTypeTool() == Tool::NodePoint) + if (node.GetTypeTool() == Tool::NodePoint && not node.IsExcluded()) { const QString name = GetNodeName(node); box->addItem(name, node.GetId()); diff --git a/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp b/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp index 6d1ec701b..906e3df5d 100644 --- a/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp +++ b/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp @@ -58,8 +58,13 @@ const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool"); */ VAbstractNode::VAbstractNode(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode, const QString &drawName, const quint32 &idTool, QObject *parent) - : VAbstractTool(doc, data, id, parent), parentType(ParentType::Item), idNode(idNode), idTool(idTool), - currentColor(Qt::black), m_drawName(drawName) + : VAbstractTool(doc, data, id, parent), + parentType(ParentType::Item), + idNode(idNode), + idTool(idTool), + currentColor(Qt::black), + m_drawName(drawName), + m_exluded(false) { _referens = 0; } @@ -140,6 +145,18 @@ void VAbstractNode::GroupVisibility(quint32 object, bool visible) Q_UNUSED(visible) } +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractNode::IsExluded() const +{ + return m_exluded; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractNode::SetExluded(bool exluded) +{ + m_exluded = exluded; +} + //--------------------------------------------------------------------------------------------------------------------- void VAbstractNode::ToolCreation(const Source &typeCreation) { diff --git a/src/libs/vtools/tools/nodeDetails/vabstractnode.h b/src/libs/vtools/tools/nodeDetails/vabstractnode.h index cfc45919a..fa666b9c2 100644 --- a/src/libs/vtools/tools/nodeDetails/vabstractnode.h +++ b/src/libs/vtools/tools/nodeDetails/vabstractnode.h @@ -61,11 +61,12 @@ public: virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; + bool IsExluded() const; + void SetExluded(bool exluded); + protected: ParentType parentType; - virtual void ToolCreation(const Source &typeCreation) Q_DECL_OVERRIDE; -protected: /** @brief idNodenode id. */ quint32 idNode; @@ -77,11 +78,16 @@ protected: QString m_drawName; + bool m_exluded; + void AddToModeling(const QDomElement &domElement); + virtual void ToolCreation(const Source &typeCreation) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE {} virtual void ShowNode()=0; virtual void HideNode()=0; +private: + Q_DISABLE_COPY(VAbstractNode) }; #endif // VABSTRACTNODE_H diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp index 2a0a9a1a2..2d645a141 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp @@ -321,7 +321,7 @@ void VNodePoint::RefreshLine() //--------------------------------------------------------------------------------------------------------------------- void VNodePoint::ShowNode() { - if (parentType != ParentType::Scene) + if (parentType != ParentType::Scene && not m_exluded) { show(); } diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index d0788a5cc..d02b237ee 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -453,6 +453,7 @@ void VToolSeamAllowance::GroupVisibility(quint32 object, bool visible) //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::FullUpdateFromFile() { + UpdateExcludeState(); RefreshGeometry(); } @@ -1207,6 +1208,24 @@ VToolSeamAllowance::VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, UpdateGrainline(); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::UpdateExcludeState() +{ + const VPiece detail = VAbstractTool::data.GetPiece(id); + for (int i = 0; i< detail.GetPath().CountNodes(); ++i) + { + const VPieceNode &node = detail.GetPath().at(i); + if (node.GetTypeTool() == Tool::NodePoint) + { + VNodePoint *tool = qobject_cast(doc->getTool(node.GetId())); + SCASSERT(tool != nullptr); + + tool->SetExluded(node.IsExcluded()); + tool->setVisible(not node.IsExcluded());//Hide excluded point + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::RefreshGeometry() { @@ -1462,6 +1481,7 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc connect(tool, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); tool->setParentItem(parent); tool->SetParentType(ParentType::Item); + tool->SetExluded(node.IsExcluded()); tool->setVisible(not node.IsExcluded());//Hide excluded point doc->IncrementReferens(node.GetId()); break; diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 4eab60d9e..469c3a19e 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -153,6 +153,7 @@ private: VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, VMainGraphicsScene *scene, const QString &m_drawName, QGraphicsItem * parent = nullptr); + void UpdateExcludeState(); void RefreshGeometry(); void SaveDialogChange(); VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth,