Fix VToolPiecePath visualization.
--HG-- branch : feature
This commit is contained in:
parent
35f54c5cc7
commit
641a807f24
|
@ -169,10 +169,17 @@ const QString VAbstractPattern::NodePoint = QStringLiteral("NodePoint");
|
||||||
const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline");
|
const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline");
|
||||||
const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath");
|
const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath");
|
||||||
|
|
||||||
|
QHash<quint32, VDataTool*> VAbstractPattern::tools = QHash<quint32, VDataTool*>();
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractPattern::VAbstractPattern(QObject *parent)
|
VAbstractPattern::VAbstractPattern(QObject *parent)
|
||||||
: QObject(parent), VDomDocument(), nameActivPP(QString()), cursor(0), tools(QHash<quint32, VDataTool*>()),
|
: QObject(parent),
|
||||||
toolsOnRemove(QVector<VDataTool*>()), history(QVector<VToolRecord>()), patternPieces(QStringList()),
|
VDomDocument(),
|
||||||
|
nameActivPP(QString()),
|
||||||
|
cursor(0),
|
||||||
|
toolsOnRemove(QVector<VDataTool*>()),
|
||||||
|
history(QVector<VToolRecord>()),
|
||||||
|
patternPieces(QStringList()),
|
||||||
modified(false)
|
modified(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -1264,7 +1271,7 @@ void VAbstractPattern::SelectedDetail(quint32 id)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractPattern::ToolExists(const quint32 &id) const
|
void VAbstractPattern::ToolExists(const quint32 &id)
|
||||||
{
|
{
|
||||||
if (tools.contains(id) == false)
|
if (tools.contains(id) == false)
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,9 +90,8 @@ public:
|
||||||
|
|
||||||
virtual void UpdateToolData(const quint32 &id, VContainer *data)=0;
|
virtual void UpdateToolData(const quint32 &id, VContainer *data)=0;
|
||||||
|
|
||||||
QHash<quint32, VDataTool *> *getTools();
|
static VDataTool* getTool(const quint32 &id);
|
||||||
VDataTool *getTool(const quint32 &id);
|
static void AddTool(const quint32 &id, VDataTool *tool);
|
||||||
void AddTool(const quint32 &id, VDataTool *tool);
|
|
||||||
|
|
||||||
void AddToolOnRemove(VDataTool *tool);
|
void AddToolOnRemove(VDataTool *tool);
|
||||||
|
|
||||||
|
@ -329,9 +328,6 @@ protected:
|
||||||
/** @brief cursor cursor keep id tool after which we will add new tool in file. */
|
/** @brief cursor cursor keep id tool after which we will add new tool in file. */
|
||||||
quint32 cursor;
|
quint32 cursor;
|
||||||
|
|
||||||
/** @brief tools list with pointer on tools. */
|
|
||||||
QHash<quint32, VDataTool*> tools;
|
|
||||||
|
|
||||||
QVector<VDataTool*> toolsOnRemove;
|
QVector<VDataTool*> toolsOnRemove;
|
||||||
|
|
||||||
/** @brief history history records. */
|
/** @brief history history records. */
|
||||||
|
@ -343,7 +339,10 @@ protected:
|
||||||
/** @brief modified keep state of the document for cases that do not cover QUndoStack*/
|
/** @brief modified keep state of the document for cases that do not cover QUndoStack*/
|
||||||
mutable bool modified;
|
mutable bool modified;
|
||||||
|
|
||||||
void ToolExists(const quint32 &id) const;
|
/** @brief tools list with pointer on tools. */
|
||||||
|
static QHash<quint32, VDataTool*> tools;
|
||||||
|
|
||||||
|
static void ToolExists(const quint32 &id);
|
||||||
|
|
||||||
void SetActivPP(const QString& name);
|
void SetActivPP(const QString& name);
|
||||||
|
|
||||||
|
@ -374,14 +373,4 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief getTools return list of tools pointers.
|
|
||||||
* @return list.
|
|
||||||
*/
|
|
||||||
inline QHash<quint32, VDataTool *> *VAbstractPattern::getTools()
|
|
||||||
{
|
|
||||||
return &tools;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // VABSTRACTPATTERN_H
|
#endif // VABSTRACTPATTERN_H
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "../vpatterndb/vpiecenode.h"
|
#include "../vpatterndb/vpiecenode.h"
|
||||||
#include "visualization/path/vistoolpiecepath.h"
|
#include "visualization/path/vistoolpiecepath.h"
|
||||||
#include "../../tools/vabstracttool.h"
|
#include "../../tools/vabstracttool.h"
|
||||||
|
#include "../../tools/vtoolseamallowance.h"
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
@ -210,6 +211,12 @@ void DialogPiecePath::CheckState()
|
||||||
void DialogPiecePath::ShowVisualization()
|
void DialogPiecePath::ShowVisualization()
|
||||||
{
|
{
|
||||||
AddVisualization<VisToolPiecePath>();
|
AddVisualization<VisToolPiecePath>();
|
||||||
|
|
||||||
|
VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance*>(VAbstractPattern::getTool(GetPieceId()));
|
||||||
|
SCASSERT(tool != nullptr);
|
||||||
|
auto visPath = qobject_cast<VisToolPiecePath *>(vis);
|
||||||
|
SCASSERT(visPath != nullptr);
|
||||||
|
visPath->setParentItem(tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -1239,9 +1239,7 @@ template <typename Tool>
|
||||||
//cppcheck-suppress unusedFunction
|
//cppcheck-suppress unusedFunction
|
||||||
Tool* VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
|
Tool* VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
|
||||||
{
|
{
|
||||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
Tool *tool = qobject_cast<Tool*>(doc->getTool(node.getId()));
|
||||||
SCASSERT(tools != nullptr);
|
|
||||||
Tool *tool = qobject_cast<Tool*>(tools->value(node.getId()));
|
|
||||||
SCASSERT(tool != nullptr);
|
SCASSERT(tool != nullptr);
|
||||||
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
tool->setParentItem(this);
|
tool->setParentItem(this);
|
||||||
|
|
|
@ -764,9 +764,7 @@ void VToolSeamAllowance::InitInternalPaths(const VPiece &detail)
|
||||||
QVector<quint32> records = detail.GetInternalPaths();
|
QVector<quint32> records = detail.GetInternalPaths();
|
||||||
for (int i = 0; i < records.size(); ++i)
|
for (int i = 0; i < records.size(); ++i)
|
||||||
{
|
{
|
||||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
VToolPiecePath *tool = qobject_cast<VToolPiecePath*>(doc->getTool(records.at(i)));
|
||||||
SCASSERT(tools != nullptr);
|
|
||||||
VToolPiecePath *tool = qobject_cast<VToolPiecePath*>(tools->value(records.at(i)));
|
|
||||||
SCASSERT(tool != nullptr);
|
SCASSERT(tool != nullptr);
|
||||||
tool->setParentItem(this);
|
tool->setParentItem(this);
|
||||||
tool->SetParentType(ParentType::Item);
|
tool->SetParentType(ParentType::Item);
|
||||||
|
@ -819,9 +817,7 @@ template <typename Tool>
|
||||||
*/
|
*/
|
||||||
Tool *VToolSeamAllowance::InitTool(VMainGraphicsScene *scene, quint32 toolId)
|
Tool *VToolSeamAllowance::InitTool(VMainGraphicsScene *scene, quint32 toolId)
|
||||||
{
|
{
|
||||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
Tool *tool = qobject_cast<Tool*>(doc->getTool(toolId));
|
||||||
SCASSERT(tools != nullptr);
|
|
||||||
Tool *tool = qobject_cast<Tool*>(tools->value(toolId));
|
|
||||||
SCASSERT(tool != nullptr);
|
SCASSERT(tool != nullptr);
|
||||||
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
tool->setParentItem(this);
|
tool->setParentItem(this);
|
||||||
|
|
|
@ -647,24 +647,19 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d
|
||||||
newDetail.setMx(d1.getMx());
|
newDetail.setMx(d1.getMx());
|
||||||
newDetail.setMy(d1.getMy());
|
newDetail.setMy(d1.getMy());
|
||||||
VToolDetail::Create(0, newDetail, scene, doc, data, parse, Source::FromTool, drawName);
|
VToolDetail::Create(0, newDetail, scene, doc, data, parse, Source::FromTool, drawName);
|
||||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
|
||||||
SCASSERT(tools != nullptr);
|
|
||||||
|
|
||||||
if (not retainPieces)
|
auto RemoveDetail = [doc](quint32 id)
|
||||||
{
|
{
|
||||||
{
|
VToolDetail *toolDet = qobject_cast<VToolDetail*>(doc->getTool(id));
|
||||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(d1id));
|
|
||||||
SCASSERT(toolDet != nullptr);
|
SCASSERT(toolDet != nullptr);
|
||||||
bool ask = false;
|
bool ask = false;
|
||||||
toolDet->Remove(ask);
|
toolDet->Remove(ask);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
if (not retainPieces)
|
||||||
{
|
{
|
||||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(d2id));
|
RemoveDetail(d1id);
|
||||||
SCASSERT(toolDet != nullptr);
|
RemoveDetail(d2id);
|
||||||
const bool ask = false;
|
|
||||||
toolDet->Remove(ask);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SCASSERT(not children.isEmpty())
|
SCASSERT(not children.isEmpty())
|
||||||
|
|
|
@ -96,9 +96,7 @@ void DeleteDetail::redo()
|
||||||
|
|
||||||
// UnionDetails delete two old details and create one new.
|
// UnionDetails delete two old details and create one new.
|
||||||
// So when UnionDetail delete detail we can't use FullParsing. So we hide detail on scene directly.
|
// So when UnionDetail delete detail we can't use FullParsing. So we hide detail on scene directly.
|
||||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
VToolDetail *toolDet = qobject_cast<VToolDetail*>(doc->getTool(nodeId));
|
||||||
SCASSERT(tools != nullptr);
|
|
||||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(nodeId));
|
|
||||||
SCASSERT(toolDet != nullptr);
|
SCASSERT(toolDet != nullptr);
|
||||||
toolDet->hide();
|
toolDet->hide();
|
||||||
|
|
||||||
|
|
|
@ -100,9 +100,7 @@ void DeletePiece::redo()
|
||||||
|
|
||||||
// UnionDetails delete two old details and create one new.
|
// UnionDetails delete two old details and create one new.
|
||||||
// So when UnionDetail delete detail we can't use FullParsing. So we hide detail on scene directly.
|
// So when UnionDetail delete detail we can't use FullParsing. So we hide detail on scene directly.
|
||||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
VToolSeamAllowance *toolDet = qobject_cast<VToolSeamAllowance*>(doc->getTool(nodeId));
|
||||||
SCASSERT(tools != nullptr);
|
|
||||||
VToolSeamAllowance *toolDet = qobject_cast<VToolSeamAllowance*>(tools->value(nodeId));
|
|
||||||
SCASSERT(toolDet != nullptr);
|
SCASSERT(toolDet != nullptr);
|
||||||
toolDet->hide();
|
toolDet->hide();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user