From 96255ef09357a9930d3ba5ffd4f03840235fb869 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 21 Mar 2017 15:39:14 +0200 Subject: [PATCH] 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 + + + + +