Get active pattern piece list of pieces.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-23 18:41:01 +02:00
parent 965e588a9d
commit 524e98d372
7 changed files with 100 additions and 2 deletions

View File

@ -58,6 +58,7 @@
#include "dialogs/vwidgetgroups.h"
#include "../vtools/undocommands/addgroup.h"
#include "dialogs/vwidgetdetails.h"
#include "../vpatterndb/vpiecepath.h"
#include <QInputDialog>
#include <QtDebug>
@ -558,9 +559,16 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
ui->view->setShowToolOptions(false);
dialogTool = new Dialog(pattern, 0, this);
if (t == Tool::Midpoint)
switch(t)
{
dialogTool->Build(t);
case Tool::Midpoint:
dialogTool->Build(t);
break;
case Tool::PiecePath:
dialogTool->SetPiecesList(doc->GetActivePPPieces());
break;
default:
break;
}
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene);
@ -1121,8 +1129,12 @@ void MainWindow::ClosedDialogPiecePath(int result)
DialogPiecePath *dialog = qobject_cast<DialogPiecePath*>(dialogTool);
SCASSERT(dialog != nullptr);
const PiecePathType type = dialog->GetType();
const VPiecePath path = dialog->GetPiecePath();
//VToolDetail::Create(dialogTool, sceneDetails, doc, pattern);
}
ArrowTool();
doc->LiteParseTree(Document::LiteParse);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -350,6 +350,31 @@ quint32 VPattern::SPointActiveDraw()
return 0;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> VPattern::GetActivePPPieces() const
{
QVector<quint32> pieces;
QDomElement drawElement;
if (GetActivDrawElement(drawElement))
{
const QDomElement details = drawElement.firstChildElement(TagDetails);
if (not details.isNull())
{
QDomElement detail = details.firstChildElement(TagDetail);
while(not detail.isNull())
{
bool united = GetParametrBool(detail, VToolSeamAllowance::AttrUnited, falseStr);
if (not united)
{
pieces.append(GetParametrId(detail));
}
detail = detail.nextSiblingElement(TagDetail);
}
}
}
return pieces;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPattern::SaveDocument(const QString &fileName, QString &error) const
{

View File

@ -59,6 +59,8 @@ public:
quint32 SPointActiveDraw();
QVector<quint32> GetActivePPPieces() const;
virtual void setXMLContent(const QString &fileName) Q_DECL_OVERRIDE;
virtual bool SaveDocument(const QString &fileName, QString &error) const Q_DECL_OVERRIDE;

View File

@ -282,6 +282,52 @@ void DialogPiecePath::SetType(PiecePathType type)
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogPiecePath::GetPieceId() const
{
quint32 id = NULL_ID;
if (ui->comboBoxPiece->count() > 0)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
id = ui->comboBoxPiece->itemData(ui->comboBoxPiece->currentIndex()).toUInt();
#else
id = ui->comboBoxPiece->currentData().toUInt();
#endif
}
return id;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::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->comboBoxType->setCurrentIndex(index);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::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));
}
ValidObjects(PathIsValid());
}
//---------------------------------------------------------------------------------------------------------------------
VPiecePath DialogPiecePath::CreatePath() const
{

View File

@ -51,6 +51,11 @@ public:
PiecePathType GetType() const;
void SetType(PiecePathType type);
quint32 GetPieceId() const;
void SetPieceId(quint32 id);
virtual void SetPiecesList(const QVector<quint32> &list) Q_DECL_OVERRIDE;
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
@ -71,6 +76,7 @@ private:
bool m_showMode;
void InitPathTypes();
void InitListPieces();
VPiecePath CreatePath() const;

View File

@ -1073,6 +1073,12 @@ void DialogTool::Build(const Tool &type)
Q_UNUSED(type);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::SetPiecesList(const QVector<quint32> &list)
{
Q_UNUSED(list);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::SetAssociatedTool(VAbstractTool *tool)
{

View File

@ -95,6 +95,7 @@ public:
virtual void ShowDialog(bool click);
virtual void Build(const Tool &type);
virtual void SetPiecesList(const QVector<quint32> &list);
quint32 GetToolId() const;
void SetToolId(const quint32 &value);