Dialog Insert node tool.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-03-21 15:39:14 +02:00
parent 699adc56bb
commit 96255ef093
20 changed files with 534 additions and 29 deletions

View File

@ -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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were used in switch.");
switch (currentItem->type())
{

View File

@ -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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in history.");
Q_STATIC_ASSERT_X(static_cast<int>(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();
}
}

View File

@ -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<VToolTrueDarts>);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolInsertNode(bool checked)
{
ToolSelectAllDrawObjects();
SetToolButton<DialogInsertNode>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Check if all tools were connected.");
Q_STATIC_ASSERT_X(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled.");
Q_STATIC_ASSERT_X(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled.");
Q_STATIC_ASSERT_X(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled.");
Q_STATIC_ASSERT_X(static_cast<int>(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;
}
}

View File

@ -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();

View File

@ -55,7 +55,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>117</width>
<width>100</width>
<height>358</height>
</rect>
</property>
@ -427,7 +427,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<width>100</width>
<height>110</height>
</rect>
</property>
@ -536,7 +536,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<width>100</width>
<height>248</height>
</rect>
</property>
@ -798,7 +798,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<width>100</width>
<height>248</height>
</rect>
</property>
@ -1063,7 +1063,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<width>100</width>
<height>58</height>
</rect>
</property>
@ -1143,8 +1143,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<height>326</height>
<width>100</width>
<height>196</height>
</rect>
</property>
<attribute name="icon">
@ -1322,7 +1322,7 @@
<x>0</x>
<y>0</y>
<width>130</width>
<height>150</height>
<height>196</height>
</rect>
</property>
<property name="sizePolicy">
@ -1475,6 +1475,32 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QToolButton" name="toolButtonInsertNode">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Insert node tool</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/insert_node.png</normaloff>:/toolicon/32x32/insert_node.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutPage">
@ -1482,8 +1508,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<height>326</height>
<width>100</width>
<height>58</height>
</rect>
</property>
<attribute name="icon">

View File

@ -82,5 +82,7 @@
<file>cursor/path_cursor@2x.png</file>
<file>cursor/pin_cursor.png</file>
<file>cursor/pin_cursor@2x.png</file>
<file>cursor/insert_node_cursor.png</file>
<file>cursor/insert_node_cursor@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -80,5 +80,7 @@
<file>toolicon/32x32/path@2x.png</file>
<file>toolicon/32x32/pin.png</file>
<file>toolicon/32x32/pin@2x.png</file>
<file>toolicon/32x32/insert_node.png</file>
<file>toolicon/32x32/insert_node@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Capa_1"
x="0px"
y="0px"
width="446.615px"
height="446.616px"
viewBox="0 0 446.615 446.616"
style="enable-background:new 0 0 446.615 446.616;"
xml:space="preserve"
sodipodi:docname="insert_node.svg"
inkscape:export-filename="/home/dismine/CAD/Valentina_insert/valentina/src/app/valentina/share/resources/toolicon/svg/insert_node@2x.png"
inkscape:export-xdpi="13.756784"
inkscape:export-ydpi="13.756784"
inkscape:version="0.92.1 unknown"><metadata
id="metadata49"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
id="defs47" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1314"
inkscape:window-height="849"
id="namedview45"
showgrid="false"
inkscape:zoom="0.52841815"
inkscape:cx="-159.91174"
inkscape:cy="223.308"
inkscape:window-x="75"
inkscape:window-y="34"
inkscape:window-maximized="0"
inkscape:current-layer="Capa_1" /><g
id="g12"><g
id="g10"><g
id="g6"><path
d="M191.852,260.427l-60.628,60.62c-22.054,22.048-59.52,20.479-83.508-3.505c-23.991-23.998-25.569-61.446-3.51-83.517 l68.694-68.69c22.057-22.057,59.52-20.479,83.511,3.505c10.214,10.212,16.321,22.859,18.313,35.727 c8.889-0.929,17.271-4.569,23.795-11.089l2.53-2.53c-4.052-15.396-12.125-30.14-24.37-42.377 c-35.171-35.171-90.824-36.744-124.056-3.505l-68.69,68.69c-33.239,33.229-31.662,88.889,3.507,124.061 c35.168,35.166,90.821,36.739,124.06,3.505l68.69-68.69c3.89-3.888,7.269-8.116,10.207-12.563 C217.798,262.658,204.711,262.714,191.852,260.427z"
id="path2" /><path
d="M210.06,27.633l-68.7,68.695c-3.899,3.901-7.273,8.13-10.218,12.578c12.603-2.581,25.694-2.66,38.545-0.359 l60.642-60.639c22.052-22.057,59.52-20.479,83.508,3.509c23.994,23.994,25.571,61.452,3.51,83.508l-68.689,68.695 c-22.057,22.057-59.515,20.483-83.511-3.51c-10.214-10.212-16.321-22.869-18.314-35.731c-8.888,0.92-17.275,4.583-23.795,11.094 l-2.527,2.53c4.051,15.401,12.123,30.14,24.367,42.381c35.171,35.172,90.824,36.739,124.059,3.51l68.685-68.69 c33.239-33.239,31.662-88.889-3.505-124.056C298.954-4.023,243.294-5.605,210.06,27.633z"
id="path4" /></g><path
d="M351.038,251.742c-52.794,0-95.581,42.797-95.581,95.582c0,52.789,42.787,95.591,95.581,95.591 c52.79,0,95.577-42.802,95.577-95.591C446.615,294.539,403.828,251.742,351.038,251.742z M407.192,367.018h-35.348v35.503 c0,11.164-9.055,20.199-20.214,20.199s-20.208-9.035-20.208-20.199v-35.503h-35.358c-11.149,0-20.198-9.054-20.198-20.208 s9.049-20.208,20.198-20.208h35.358v-35.214c0-11.154,9.049-20.203,20.208-20.203s20.214,9.049,20.214,20.203v35.214h35.348 c11.159,0,20.213,9.054,20.213,20.208C427.401,357.974,418.352,367.018,407.192,367.018z"
id="path8" /></g></g><g
id="g14" /><g
id="g16" /><g
id="g18" /><g
id="g20" /><g
id="g22" /><g
id="g24" /><g
id="g26" /><g
id="g28" /><g
id="g30" /><g
id="g32" /><g
id="g34" /><g
id="g36" /><g
id="g38" /><g
id="g40" /><g
id="g42" /></svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used.");
Q_STATIC_ASSERT_X(static_cast<int>(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;
}
}

View File

@ -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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
Q_STATIC_ASSERT(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
Q_STATIC_ASSERT(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
Q_STATIC_ASSERT(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
Q_STATIC_ASSERT(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
Q_STATIC_ASSERT(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
Q_STATIC_ASSERT(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 52);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagDetail);

View File

@ -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
};

View File

@ -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

View File

@ -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"

View File

@ -0,0 +1,193 @@
/************************************************************************
**
** @file dialoginsertnode.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#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<quint32> &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();
}

View File

@ -0,0 +1,73 @@
/************************************************************************
**
** @file dialoginsertnode.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#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<quint32> &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

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogInsertNode</class>
<widget class="QDialog" name="DialogInsertNode">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>244</width>
<height>103</height>
</rect>
</property>
<property name="windowTitle">
<string>Insert node</string>
</property>
<property name="windowIcon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelItem">
<property name="text">
<string>Item:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelItemName">
<property name="text">
<string notr="true">item name</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelPiece">
<property name="text">
<string>Piece:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxPiece"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogInsertNode</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogInsertNode</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>