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::NodeSplinePath = QStringLiteral("NodeSplinePath");
|
||||
|
||||
QHash<quint32, VDataTool*> VAbstractPattern::tools = QHash<quint32, VDataTool*>();
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractPattern::VAbstractPattern(QObject *parent)
|
||||
: QObject(parent), VDomDocument(), nameActivPP(QString()), cursor(0), tools(QHash<quint32, VDataTool*>()),
|
||||
toolsOnRemove(QVector<VDataTool*>()), history(QVector<VToolRecord>()), patternPieces(QStringList()),
|
||||
: QObject(parent),
|
||||
VDomDocument(),
|
||||
nameActivPP(QString()),
|
||||
cursor(0),
|
||||
toolsOnRemove(QVector<VDataTool*>()),
|
||||
history(QVector<VToolRecord>()),
|
||||
patternPieces(QStringList()),
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -90,9 +90,8 @@ public:
|
|||
|
||||
virtual void UpdateToolData(const quint32 &id, VContainer *data)=0;
|
||||
|
||||
QHash<quint32, VDataTool *> *getTools();
|
||||
VDataTool *getTool(const quint32 &id);
|
||||
void AddTool(const quint32 &id, VDataTool *tool);
|
||||
static VDataTool* getTool(const quint32 &id);
|
||||
static void AddTool(const quint32 &id, 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. */
|
||||
quint32 cursor;
|
||||
|
||||
/** @brief tools list with pointer on tools. */
|
||||
QHash<quint32, VDataTool*> tools;
|
||||
|
||||
QVector<VDataTool*> toolsOnRemove;
|
||||
|
||||
/** @brief history history records. */
|
||||
|
@ -343,7 +339,10 @@ protected:
|
|||
/** @brief modified keep state of the document for cases that do not cover QUndoStack*/
|
||||
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);
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "../vpatterndb/vpiecenode.h"
|
||||
#include "visualization/path/vistoolpiecepath.h"
|
||||
#include "../../tools/vabstracttool.h"
|
||||
#include "../../tools/vtoolseamallowance.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
|
@ -210,6 +211,12 @@ void DialogPiecePath::CheckState()
|
|||
void DialogPiecePath::ShowVisualization()
|
||||
{
|
||||
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
|
||||
Tool* VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
|
||||
{
|
||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
||||
SCASSERT(tools != nullptr);
|
||||
Tool *tool = qobject_cast<Tool*>(tools->value(node.getId()));
|
||||
Tool *tool = qobject_cast<Tool*>(doc->getTool(node.getId()));
|
||||
SCASSERT(tool != nullptr);
|
||||
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
tool->setParentItem(this);
|
||||
|
|
|
@ -764,9 +764,7 @@ void VToolSeamAllowance::InitInternalPaths(const VPiece &detail)
|
|||
QVector<quint32> records = detail.GetInternalPaths();
|
||||
for (int i = 0; i < records.size(); ++i)
|
||||
{
|
||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
||||
SCASSERT(tools != nullptr);
|
||||
VToolPiecePath *tool = qobject_cast<VToolPiecePath*>(tools->value(records.at(i)));
|
||||
VToolPiecePath *tool = qobject_cast<VToolPiecePath*>(doc->getTool(records.at(i)));
|
||||
SCASSERT(tool != nullptr);
|
||||
tool->setParentItem(this);
|
||||
tool->SetParentType(ParentType::Item);
|
||||
|
@ -819,9 +817,7 @@ template <typename Tool>
|
|||
*/
|
||||
Tool *VToolSeamAllowance::InitTool(VMainGraphicsScene *scene, quint32 toolId)
|
||||
{
|
||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
||||
SCASSERT(tools != nullptr);
|
||||
Tool *tool = qobject_cast<Tool*>(tools->value(toolId));
|
||||
Tool *tool = qobject_cast<Tool*>(doc->getTool(toolId));
|
||||
SCASSERT(tool != nullptr);
|
||||
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
tool->setParentItem(this);
|
||||
|
|
|
@ -647,24 +647,19 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d
|
|||
newDetail.setMx(d1.getMx());
|
||||
newDetail.setMy(d1.getMy());
|
||||
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*>(tools->value(d1id));
|
||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(doc->getTool(id));
|
||||
SCASSERT(toolDet != nullptr);
|
||||
bool ask = false;
|
||||
toolDet->Remove(ask);
|
||||
}
|
||||
};
|
||||
|
||||
if (not retainPieces)
|
||||
{
|
||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(d2id));
|
||||
SCASSERT(toolDet != nullptr);
|
||||
const bool ask = false;
|
||||
toolDet->Remove(ask);
|
||||
}
|
||||
RemoveDetail(d1id);
|
||||
RemoveDetail(d2id);
|
||||
}
|
||||
|
||||
SCASSERT(not children.isEmpty())
|
||||
|
|
|
@ -96,9 +96,7 @@ void DeleteDetail::redo()
|
|||
|
||||
// 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.
|
||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
||||
SCASSERT(tools != nullptr);
|
||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(nodeId));
|
||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(doc->getTool(nodeId));
|
||||
SCASSERT(toolDet != nullptr);
|
||||
toolDet->hide();
|
||||
|
||||
|
|
|
@ -100,9 +100,7 @@ void DeletePiece::redo()
|
|||
|
||||
// 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.
|
||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
||||
SCASSERT(tools != nullptr);
|
||||
VToolSeamAllowance *toolDet = qobject_cast<VToolSeamAllowance*>(tools->value(nodeId));
|
||||
VToolSeamAllowance *toolDet = qobject_cast<VToolSeamAllowance*>(doc->getTool(nodeId));
|
||||
SCASSERT(toolDet != nullptr);
|
||||
toolDet->hide();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user