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 000000000..271923bc7 Binary files /dev/null and b/src/app/valentina/share/resources/cursor/insert_node_cursor.png differ 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 000000000..418f97673 Binary files /dev/null and b/src/app/valentina/share/resources/cursor/insert_node_cursor@2x.png differ 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 000000000..da441f7d0 Binary files /dev/null and b/src/app/valentina/share/resources/toolicon/32x32/insert_node.png differ 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 000000000..3ddc9643b Binary files /dev/null and b/src/app/valentina/share/resources/toolicon/32x32/insert_node@2x.png differ diff --git a/src/app/valentina/share/resources/toolicon/svg/insert_node.svg b/src/app/valentina/share/resources/toolicon/svg/insert_node.svg new file mode 100644 index 000000000..81c7db96d --- /dev/null +++ b/src/app/valentina/share/resources/toolicon/svg/insert_node.svg @@ -0,0 +1,69 @@ + +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 + + + + +