Added DialogPiecePath class. Not finished.
--HG-- branch : feature
This commit is contained in:
parent
50d42238f5
commit
f741e1387c
|
@ -42,7 +42,8 @@ HEADERS += \
|
|||
$$PWD/tools/dialogflippingbyline.h \
|
||||
$$PWD/tools/dialogflippingbyaxis.h \
|
||||
$$PWD/tools/dialogmove.h \
|
||||
$$PWD/tools/dialogseamallowance.h
|
||||
$$PWD/tools/dialogseamallowance.h \
|
||||
$$PWD/tools/dialogpiecepath.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/tools/dialogalongline.cpp \
|
||||
|
@ -84,7 +85,8 @@ SOURCES += \
|
|||
$$PWD/tools/dialogflippingbyline.cpp \
|
||||
$$PWD/tools/dialogflippingbyaxis.cpp \
|
||||
$$PWD/tools/dialogmove.cpp \
|
||||
$$PWD/tools/dialogseamallowance.cpp
|
||||
$$PWD/tools/dialogseamallowance.cpp \
|
||||
$$PWD/tools/dialogpiecepath.cpp
|
||||
|
||||
FORMS += \
|
||||
$$PWD/tools/dialogalongline.ui \
|
||||
|
@ -125,4 +127,5 @@ FORMS += \
|
|||
$$PWD/tools/dialogflippingbyline.ui \
|
||||
$$PWD/tools/dialogflippingbyaxis.ui \
|
||||
$$PWD/tools/dialogmove.ui \
|
||||
$$PWD/tools/dialogseamallowance.ui
|
||||
$$PWD/tools/dialogseamallowance.ui \
|
||||
$$PWD/tools/dialogpiecepath.ui
|
||||
|
|
289
src/libs/vtools/dialogs/tools/dialogpiecepath.cpp
Normal file
289
src/libs/vtools/dialogs/tools/dialogpiecepath.cpp
Normal file
|
@ -0,0 +1,289 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogpiecepath.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 22 11, 2016
|
||||
**
|
||||
** @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) 2016 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 "dialogpiecepath.h"
|
||||
#include "ui_dialogpiecepath.h"
|
||||
#include "../vpatterndb/vpiecenode.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||
: DialogTool(data, toolId, parent),
|
||||
ui(new Ui::DialogPiecePath),
|
||||
m_showMode(true)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
InitOkCancel(ui);
|
||||
|
||||
flagName = true;//We have default name of piece.
|
||||
flagError = PathIsValid();
|
||||
CheckState();
|
||||
|
||||
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogPiecePath::NameChanged);
|
||||
|
||||
if (not m_showMode)
|
||||
{
|
||||
//vis = new VisToolPiecePath(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->comboBoxType->setDisabled(true);
|
||||
ui->comboBoxPiece->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogPiecePath::~DialogPiecePath()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::DisableShowMode(bool disable)
|
||||
{
|
||||
m_showMode = disable;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::ChosenObject(quint32 id, const SceneObject &type)
|
||||
{
|
||||
if (not prepare)
|
||||
{
|
||||
bool reverse = false;
|
||||
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
||||
{
|
||||
reverse = true;
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case SceneObject::Arc:
|
||||
NewItem(VPieceNode(id, Tool::NodeArc, reverse));
|
||||
break;
|
||||
case SceneObject::Point:
|
||||
NewItem(VPieceNode(id, Tool::NodePoint));
|
||||
break;
|
||||
case SceneObject::Spline:
|
||||
NewItem(VPieceNode(id, Tool::NodeSpline, reverse));
|
||||
break;
|
||||
case SceneObject::SplinePath:
|
||||
NewItem(VPieceNode(id, Tool::NodeSplinePath, reverse));
|
||||
break;
|
||||
case (SceneObject::Line):
|
||||
case (SceneObject::Detail):
|
||||
case (SceneObject::Unknown):
|
||||
default:
|
||||
qDebug() << "Got wrong scene object. Ignore.";
|
||||
break;
|
||||
}
|
||||
|
||||
ValidObjects(PathIsValid());
|
||||
|
||||
if (not m_showMode)
|
||||
{
|
||||
// auto visPath = qobject_cast<VisToolPiecePath *>(vis);
|
||||
// SCASSERT(visPath != nullptr);
|
||||
// const VPiecePath p = CreatePath();
|
||||
// visPath->SetPath(p);
|
||||
|
||||
// if (p.CountNodes() == 1)
|
||||
// {
|
||||
// emit ToolTip(tr("Select main path objects, <b>Shift</b> - reverse direction curve, "
|
||||
// "<b>Enter</b> - finish creation"));
|
||||
|
||||
// visPath->VisualMode(NULL_ID);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// visPath->RefreshGeometry();
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::ShowDialog(bool click)
|
||||
{
|
||||
if (click == false)
|
||||
{
|
||||
emit ToolTip("");
|
||||
prepare = true;
|
||||
|
||||
if (not m_showMode)
|
||||
{
|
||||
// auto visPath = qobject_cast<VisToolPiecePath *>(vis);
|
||||
// SCASSERT(visPath != nullptr);
|
||||
// visPath->SetMode(Mode::Show);
|
||||
// visPath->RefreshGeometry();
|
||||
}
|
||||
setModal(true);
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::SaveData()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::CheckState()
|
||||
{
|
||||
SCASSERT(bOk != nullptr);
|
||||
bOk->setEnabled(flagName && flagError && ui->comboBoxPiece->count() > 0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::ShowContextMenu(const QPoint &pos)
|
||||
{
|
||||
const int row = ui->listWidget->currentRow();
|
||||
if (ui->listWidget->count() == 0 || row == -1 || row >= ui->listWidget->count())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QMenu *menu = new QMenu(this);
|
||||
QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
||||
actionDelete->setEnabled(m_showMode);//Because we can't undo this operation when creating a piece.
|
||||
|
||||
QListWidgetItem *rowItem = ui->listWidget->item(row);
|
||||
SCASSERT(rowItem != nullptr);
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
|
||||
QAction *actionReverse = nullptr;
|
||||
if (rowNode.GetTypeTool() != Tool::NodePoint)
|
||||
{
|
||||
actionReverse = menu->addAction(tr("Reverse"));
|
||||
actionReverse->setCheckable(true);
|
||||
actionReverse->setChecked(rowNode.GetReverse());
|
||||
}
|
||||
|
||||
QAction *selectedAction = menu->exec(ui->listWidget->viewport()->mapToGlobal(pos));
|
||||
if (selectedAction == actionDelete)
|
||||
{
|
||||
delete ui->listWidget->item(row);
|
||||
ValidObjects(PathIsValid());
|
||||
}
|
||||
else if (selectedAction == actionReverse)
|
||||
{
|
||||
rowNode.SetReverse(not rowNode.GetReverse());
|
||||
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
||||
rowItem->setText(GetNodeName(rowNode));
|
||||
ValidObjects(PathIsValid());
|
||||
}
|
||||
|
||||
ListChanged();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::ListChanged()
|
||||
{
|
||||
if (not m_showMode)
|
||||
{
|
||||
// auto visPath = qobject_cast<VisToolPiecePath *>(vis);
|
||||
// SCASSERT(visPath != nullptr);
|
||||
// visPath->SetPiece(CreatePath());
|
||||
// visPath->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::NameChanged()
|
||||
{
|
||||
if (ui->lineEditName->text().isEmpty())
|
||||
{
|
||||
flagName = false;
|
||||
ChangeColor(ui->labelName, Qt::red);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagName = true;
|
||||
ChangeColor(ui->labelName, okColor);
|
||||
}
|
||||
CheckState();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
//VPiecePath DialogPiecePath::GetPiecePath() const
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
//void DialogPiecePath::SetPiecePath(const VPiecePath &path)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
//VPiecePath DialogPiecePath::CreatePath() const
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogPiecePath::PathIsValid() const
|
||||
{
|
||||
// QString url = DialogWarningIcon();
|
||||
|
||||
// if(CreatePath().Points(data).count() < 2)
|
||||
// {
|
||||
// url += tr("You need more points!");
|
||||
// ui->helpLabel->setText(url);
|
||||
// return false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (FirstPointEqualLast(ui->listWidget))
|
||||
// {
|
||||
// url += tr("First point cannot be equal to the last point!");
|
||||
// ui->helpLabel->setText(url);
|
||||
// return false;
|
||||
// }
|
||||
// else if (DoublePoints(ui->listWidget))
|
||||
// {
|
||||
// url += tr("You have double points!");
|
||||
// ui->helpLabel->setText(url);
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
ui->helpLabel->setText(tr("Ready!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::ValidObjects(bool value)
|
||||
{
|
||||
flagError = value;
|
||||
CheckState();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::NewItem(const VPieceNode &node)
|
||||
{
|
||||
NewNodeItem(ui->listWidget, node);
|
||||
}
|
77
src/libs/vtools/dialogs/tools/dialogpiecepath.h
Normal file
77
src/libs/vtools/dialogs/tools/dialogpiecepath.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogpiecepath.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 22 11, 2016
|
||||
**
|
||||
** @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) 2016 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 DIALOGPIECEPATH_H
|
||||
#define DIALOGPIECEPATH_H
|
||||
|
||||
#include "dialogtool.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class DialogPiecePath;
|
||||
}
|
||||
|
||||
class DialogPiecePath : public DialogTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DialogPiecePath(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||
virtual ~DialogPiecePath();
|
||||
|
||||
void DisableShowMode(bool disable);
|
||||
|
||||
// VPiecePath GetPiecePath() const;
|
||||
// void SetPiecePath(const VPiecePath &path);
|
||||
|
||||
public slots:
|
||||
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
|
||||
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
|
||||
|
||||
protected:
|
||||
/** @brief SaveData Put dialog data in local variables */
|
||||
virtual void SaveData() Q_DECL_OVERRIDE;
|
||||
virtual void CheckState() Q_DECL_OVERRIDE;
|
||||
|
||||
private slots:
|
||||
void ShowContextMenu(const QPoint &pos);
|
||||
void ListChanged();
|
||||
void NameChanged();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogPiecePath)
|
||||
Ui::DialogPiecePath *ui;
|
||||
bool m_showMode;
|
||||
|
||||
// VPiecePath CreatePath() const;
|
||||
|
||||
bool PathIsValid() const;
|
||||
void ValidObjects(bool value);
|
||||
void NewItem(const VPieceNode &node);
|
||||
};
|
||||
|
||||
#endif // DIALOGPIECEPATH_H
|
128
src/libs/vtools/dialogs/tools/dialogpiecepath.ui
Normal file
128
src/libs/vtools/dialogs/tools/dialogpiecepath.ui
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogPiecePath</class>
|
||||
<widget class="QDialog" name="DialogPiecePath">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>365</width>
|
||||
<height>337</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</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="labelName">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEditName">
|
||||
<property name="text">
|
||||
<string>Unnamed path</string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Create name for your path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelType">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBoxType"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelPiece">
|
||||
<property name="text">
|
||||
<string>Piece:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBoxPiece"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="helpLabel">
|
||||
<property name="text">
|
||||
<string>Ready!</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</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/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DialogPiecePath</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>DialogPiecePath</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>
|
|
@ -31,7 +31,6 @@
|
|||
#include "../vpatterndb/vpiecenode.h"
|
||||
#include "visualization/path/vistoolpiece.h"
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QMenu>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -453,69 +452,13 @@ VPiece DialogSeamAllowance::CreatePiece() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::NewItem(const VPieceNode &node)
|
||||
{
|
||||
SCASSERT(node.GetId() > NULL_ID);
|
||||
QString name;
|
||||
switch (node.GetTypeTool())
|
||||
{
|
||||
case (Tool::NodePoint):
|
||||
case (Tool::NodeArc):
|
||||
case (Tool::NodeSpline):
|
||||
case (Tool::NodeSplinePath):
|
||||
{
|
||||
name = GetNodeName(node);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qDebug()<<"Got wrong tools. Ignore.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool canAddNewPoint = false;
|
||||
|
||||
if(ui->listWidget->count() == 0)
|
||||
{
|
||||
canAddNewPoint = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(RowId(ui->listWidget->count()-1) != node.GetId())
|
||||
{
|
||||
canAddNewPoint = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(canAddNewPoint)
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(name);
|
||||
item->setFont(QFont("Times", 12, QFont::Bold));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
||||
ui->listWidget->addItem(item);
|
||||
ui->listWidget->setCurrentRow(ui->listWidget->count()-1);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 DialogSeamAllowance::RowId(int i) const
|
||||
{
|
||||
const QListWidgetItem *rowItem = ui->listWidget->item(i);
|
||||
SCASSERT(rowItem != nullptr);
|
||||
const VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
return rowNode.GetId();
|
||||
NewNodeItem(ui->listWidget, node);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogSeamAllowance::MainPathIsValid() const
|
||||
{
|
||||
const QIcon icon = QIcon::fromTheme("dialog-warning",
|
||||
QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
|
||||
|
||||
const QPixmap pixmap = icon.pixmap(QSize(16, 16));
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
pixmap.save(&buffer, "PNG");
|
||||
QString url = QString("<img src=\"data:image/png;base64,") + byteArray.toBase64() + QLatin1String("\"/> ");
|
||||
QString url = DialogWarningIcon();
|
||||
|
||||
if(CreatePiece().MainPathPoints(data).count() < 3)
|
||||
{
|
||||
|
@ -531,23 +474,17 @@ bool DialogSeamAllowance::MainPathIsValid() const
|
|||
ui->helpLabel->setText(url);
|
||||
return false;
|
||||
}
|
||||
if (FirstPointEqualLast())
|
||||
if (FirstPointEqualLast(ui->listWidget))
|
||||
{
|
||||
url += tr("First point cannot be equal to the last point!");
|
||||
ui->helpLabel->setText(url);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
else if (DoublePoints(ui->listWidget))
|
||||
{
|
||||
for (int i=0, sz = ui->listWidget->count()-1; i<sz; ++i)
|
||||
{
|
||||
if (RowId(i) == RowId(i+1))
|
||||
{
|
||||
url += tr("You have double points!");
|
||||
ui->helpLabel->setText(url);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
url += tr("You have double points!");
|
||||
ui->helpLabel->setText(url);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ui->helpLabel->setText(tr("Ready!"));
|
||||
|
@ -561,23 +498,6 @@ void DialogSeamAllowance::ValidObjects(bool value)
|
|||
CheckState();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogSeamAllowance::FirstPointEqualLast() const
|
||||
{
|
||||
if (ui->listWidget->count() > 1)
|
||||
{
|
||||
if (RowId(0) == RowId(ui->listWidget->count()-1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogSeamAllowance::MainPathIsClockwise() const
|
||||
{
|
||||
|
@ -596,20 +516,6 @@ bool DialogSeamAllowance::MainPathIsClockwise() const
|
|||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogSeamAllowance::GetNodeName(const VPieceNode &node) const
|
||||
{
|
||||
const QSharedPointer<VGObject> obj = data->GeometricObject<VGObject>(node.GetId());
|
||||
QString name = obj->name();
|
||||
|
||||
if (node.GetTypeTool() != Tool::NodePoint && node.GetReverse())
|
||||
{
|
||||
name = QLatin1String("- ") + name;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::InitNodesList()
|
||||
{
|
||||
|
|
|
@ -81,12 +81,9 @@ private:
|
|||
VPiece CreatePiece() const;
|
||||
|
||||
void NewItem(const VPieceNode &node);
|
||||
quint32 RowId(int i) const;
|
||||
bool MainPathIsValid() const;
|
||||
void ValidObjects(bool value);
|
||||
bool FirstPointEqualLast() const;
|
||||
bool MainPathIsClockwise() const;
|
||||
QString GetNodeName(const VPieceNode &node) const;
|
||||
void InitNodesList();
|
||||
void InitNodeAngles();
|
||||
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
<string>Dialog</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../../vmisc/share/resources/icon.qrc">
|
||||
<iconset>
|
||||
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabMainPath">
|
||||
<attribute name="title">
|
||||
|
@ -42,7 +42,7 @@
|
|||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/32x32/clockwise.png</pixmap>
|
||||
<pixmap>:/icon/32x32/clockwise.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -301,9 +301,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../vmisc/share/resources/icon.qrc"/>
|
||||
</resources>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include <Qt>
|
||||
#include <QtDebug>
|
||||
#include <new>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "../ifc/xml/vdomdocument.h"
|
||||
#include "../qmuparser/qmudef.h"
|
||||
|
@ -66,6 +67,7 @@
|
|||
#include "../vpatterndb/calculator.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vpatterndb/vtranslatevars.h"
|
||||
#include "../vpatterndb/vpiecenode.h"
|
||||
#include "../../tools/vabstracttool.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../vgeometry/vabstractcurve.h"
|
||||
|
@ -392,6 +394,114 @@ quint32 DialogTool::DNumber(const QString &baseName) const
|
|||
return num;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 DialogTool::RowId(QListWidget *listWidget, int i)
|
||||
{
|
||||
SCASSERT(listWidget != nullptr);
|
||||
const QListWidgetItem *rowItem = listWidget->item(i);
|
||||
SCASSERT(rowItem != nullptr);
|
||||
const VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
return rowNode.GetId();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogTool::FirstPointEqualLast(QListWidget *listWidget)
|
||||
{
|
||||
SCASSERT(listWidget != nullptr);
|
||||
if (listWidget->count() > 1)
|
||||
{
|
||||
return RowId(listWidget, 0) == RowId(listWidget, listWidget->count()-1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogTool::DoublePoints(QListWidget *listWidget)
|
||||
{
|
||||
SCASSERT(listWidget != nullptr);
|
||||
for (int i=0, sz = listWidget->count()-1; i<sz; ++i)
|
||||
{
|
||||
if (RowId(listWidget, i) == RowId(listWidget, i+1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogTool::DialogWarningIcon()
|
||||
{
|
||||
const QIcon icon = QIcon::fromTheme("dialog-warning",
|
||||
QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
|
||||
|
||||
const QPixmap pixmap = icon.pixmap(QSize(16, 16));
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
pixmap.save(&buffer, "PNG");
|
||||
const QString url = QString("<img src=\"data:image/png;base64,") + byteArray.toBase64() + QLatin1String("\"/> ");
|
||||
return url;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogTool::GetNodeName(const VPieceNode &node) const
|
||||
{
|
||||
const QSharedPointer<VGObject> obj = data->GeometricObject<VGObject>(node.GetId());
|
||||
QString name = obj->name();
|
||||
|
||||
if (node.GetTypeTool() != Tool::NodePoint && node.GetReverse())
|
||||
{
|
||||
name = QLatin1String("- ") + name;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTool::NewNodeItem(QListWidget *listWidget, const VPieceNode &node)
|
||||
{
|
||||
SCASSERT(listWidget != nullptr);
|
||||
SCASSERT(node.GetId() > NULL_ID);
|
||||
QString name;
|
||||
switch (node.GetTypeTool())
|
||||
{
|
||||
case (Tool::NodePoint):
|
||||
case (Tool::NodeArc):
|
||||
case (Tool::NodeSpline):
|
||||
case (Tool::NodeSplinePath):
|
||||
{
|
||||
name = GetNodeName(node);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qDebug()<<"Got wrong tools. Ignore.";
|
||||
return;
|
||||
}
|
||||
|
||||
bool canAddNewPoint = false;
|
||||
|
||||
if(listWidget->count() == 0)
|
||||
{
|
||||
canAddNewPoint = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(RowId(listWidget, listWidget->count()-1) != node.GetId())
|
||||
{
|
||||
canAddNewPoint = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(canAddNewPoint)
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(name);
|
||||
item->setFont(QFont("Times", 12, QFont::Bold));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
||||
listWidget->addItem(item);
|
||||
listWidget->setCurrentRow(listWidget->count()-1);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogTool::IsSplinePath(const QSharedPointer<VGObject> &obj) const
|
||||
{
|
||||
|
|
|
@ -274,6 +274,14 @@ protected:
|
|||
void MoveCursorToEnd(QPlainTextEdit *plainTextEdit);
|
||||
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
|
||||
quint32 DNumber(const QString &baseName) const;
|
||||
|
||||
static quint32 RowId(QListWidget *listWidget, int i);
|
||||
static bool FirstPointEqualLast(QListWidget *listWidget);
|
||||
static bool DoublePoints(QListWidget *listWidget);
|
||||
static QString DialogWarningIcon();
|
||||
|
||||
QString GetNodeName(const VPieceNode &node) const;
|
||||
void NewNodeItem(QListWidget *listWidget, const VPieceNode &node);
|
||||
private:
|
||||
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user