Add Hide main path option to details's context menu.
This commit is contained in:
parent
e7f0628bf9
commit
427503a886
|
@ -1269,6 +1269,10 @@ void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
inLayoutOption->setCheckable(true);
|
inLayoutOption->setCheckable(true);
|
||||||
inLayoutOption->setChecked(detail.IsInLayout());
|
inLayoutOption->setChecked(detail.IsInLayout());
|
||||||
|
|
||||||
|
QAction *hideMainPathOption = menu.addAction(tr("Hide main path"));
|
||||||
|
hideMainPathOption->setCheckable(true);
|
||||||
|
hideMainPathOption->setChecked(detail.IsHideMainPath());
|
||||||
|
|
||||||
QAction *forbidFlippingOption = menu.addAction(tr("Forbid flipping"));
|
QAction *forbidFlippingOption = menu.addAction(tr("Forbid flipping"));
|
||||||
forbidFlippingOption->setCheckable(true);
|
forbidFlippingOption->setCheckable(true);
|
||||||
forbidFlippingOption->setChecked(detail.IsForbidFlipping());
|
forbidFlippingOption->setChecked(detail.IsForbidFlipping());
|
||||||
|
@ -1292,6 +1296,10 @@ void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
ToggleInLayout(selectedAction->isChecked());
|
ToggleInLayout(selectedAction->isChecked());
|
||||||
}
|
}
|
||||||
|
else if (selectedAction == hideMainPathOption)
|
||||||
|
{
|
||||||
|
ToggleHideMainPath(selectedAction->isChecked());
|
||||||
|
}
|
||||||
else if (selectedAction == forbidFlippingOption)
|
else if (selectedAction == forbidFlippingOption)
|
||||||
{
|
{
|
||||||
ToggleForbidFlipping(selectedAction->isChecked());
|
ToggleForbidFlipping(selectedAction->isChecked());
|
||||||
|
@ -1602,9 +1610,17 @@ void VToolSeamAllowance::ShowOptions()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolSeamAllowance::ToggleInLayout(bool checked)
|
void VToolSeamAllowance::ToggleInLayout(bool checked)
|
||||||
{
|
{
|
||||||
auto *togglePrint = new TogglePieceInLayout(m_id, checked, &(VAbstractTool::data), doc);
|
auto *toggleInLayout = new TogglePieceInLayout(m_id, checked, &(VAbstractTool::data), doc);
|
||||||
connect(togglePrint, &TogglePieceInLayout::Toggled, doc, &VAbstractPattern::CheckInLayoutList);
|
connect(toggleInLayout, &TogglePieceInLayout::Toggled, doc, &VAbstractPattern::CheckInLayoutList);
|
||||||
VAbstractApplication::VApp()->getUndoStack()->push(togglePrint);
|
VAbstractApplication::VApp()->getUndoStack()->push(toggleInLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolSeamAllowance::ToggleHideMainPath(bool checked)
|
||||||
|
{
|
||||||
|
auto *toggleHideMainPath = new class ToggleHideMainPath(m_id, checked, &(VAbstractTool::data), doc);
|
||||||
|
connect(toggleHideMainPath, &ToggleHideMainPath::Toggled, this, [this]() { RefreshGeometry(false); });
|
||||||
|
VAbstractApplication::VApp()->getUndoStack()->push(toggleHideMainPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -162,6 +162,7 @@ protected:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ToggleInLayout(bool checked);
|
void ToggleInLayout(bool checked);
|
||||||
|
void ToggleHideMainPath(bool checked);
|
||||||
void ToggleForbidFlipping(bool checked);
|
void ToggleForbidFlipping(bool checked);
|
||||||
void ToggleForceFlipping(bool checked);
|
void ToggleForceFlipping(bool checked);
|
||||||
void ToggleExcludeState(quint32 id);
|
void ToggleExcludeState(quint32 id);
|
||||||
|
|
|
@ -35,20 +35,19 @@
|
||||||
|
|
||||||
#include "../ifc/ifcdef.h"
|
#include "../ifc/ifcdef.h"
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
#include "../vmisc/def.h"
|
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../vpatterndb/vpiece.h"
|
#include "../vpatterndb/vpiece.h"
|
||||||
#include "vundocommand.h"
|
|
||||||
#include "../vtools/tools/vtoolseamallowance.h"
|
#include "../vtools/tools/vtoolseamallowance.h"
|
||||||
|
#include "vundocommand.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
TogglePieceInLayout::TogglePieceInLayout(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
TogglePieceInLayout::TogglePieceInLayout(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: VUndoCommand(QDomElement(), doc, parent),
|
: VUndoCommand(QDomElement(), doc, parent),
|
||||||
m_id(id),
|
m_id(id),
|
||||||
m_data(data),
|
m_data(data),
|
||||||
m_oldState(not state),
|
m_oldState(not state),
|
||||||
m_newState(state)
|
m_newState(state)
|
||||||
{
|
{
|
||||||
setText(tr("detail in layout list"));
|
setText(tr("detail in layout list"));
|
||||||
m_oldState = m_data->DataPieces()->value(m_id).IsInLayout();
|
m_oldState = m_data->DataPieces()->value(m_id).IsInLayout();
|
||||||
|
@ -74,7 +73,7 @@ void TogglePieceInLayout::Do(bool state)
|
||||||
QDomElement detail = doc->elementById(m_id, VAbstractPattern::TagDetail);
|
QDomElement detail = doc->elementById(m_id, VAbstractPattern::TagDetail);
|
||||||
if (detail.isElement())
|
if (detail.isElement())
|
||||||
{
|
{
|
||||||
doc->SetAttributeOrRemoveIf<bool>(detail, AttrInLayout, state, [](bool state) noexcept {return state;});
|
doc->SetAttributeOrRemoveIf<bool>(detail, AttrInLayout, state, [](bool state) noexcept { return state; });
|
||||||
|
|
||||||
VPiece det = m_data->DataPieces()->value(m_id);
|
VPiece det = m_data->DataPieces()->value(m_id);
|
||||||
det.SetInLayout(state);
|
det.SetInLayout(state);
|
||||||
|
@ -91,14 +90,10 @@ void TogglePieceInLayout::Do(bool state)
|
||||||
TogglePieceForceForbidFlipping::TogglePieceForceForbidFlipping(quint32 id, bool state, ForceForbidFlippingType type,
|
TogglePieceForceForbidFlipping::TogglePieceForceForbidFlipping(quint32 id, bool state, ForceForbidFlippingType type,
|
||||||
VContainer *data, VAbstractPattern *doc,
|
VContainer *data, VAbstractPattern *doc,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: VUndoCommand(QDomElement(), doc, parent),
|
: VUndoCommand(QDomElement(), doc, parent),
|
||||||
m_id(id),
|
m_id(id),
|
||||||
m_data(data),
|
m_data(data),
|
||||||
m_type(type),
|
m_type(type)
|
||||||
m_oldForceState(false),
|
|
||||||
m_newForceState(false),
|
|
||||||
m_oldForbidState(false),
|
|
||||||
m_newForbidState(false)
|
|
||||||
{
|
{
|
||||||
setText(tr("piece flipping"));
|
setText(tr("piece flipping"));
|
||||||
|
|
||||||
|
@ -174,3 +169,49 @@ void TogglePieceForceForbidFlipping::redo()
|
||||||
qDebug("Can't get detail by id = %u.", m_id);
|
qDebug("Can't get detail by id = %u.", m_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
ToggleHideMainPath::ToggleHideMainPath(quint32 id, bool state, VContainer *data, VAbstractPattern *doc,
|
||||||
|
QUndoCommand *parent)
|
||||||
|
: VUndoCommand(QDomElement(), doc, parent),
|
||||||
|
m_id(id),
|
||||||
|
m_data(data),
|
||||||
|
m_oldState(not state),
|
||||||
|
m_newState(state)
|
||||||
|
{
|
||||||
|
setText(tr("detail hide main path"));
|
||||||
|
m_oldState = m_data->DataPieces()->value(m_id).IsHideMainPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void ToggleHideMainPath::undo()
|
||||||
|
{
|
||||||
|
qCDebug(vUndo, "ToggleHideMainPath::undo().");
|
||||||
|
Do(m_oldState);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void ToggleHideMainPath::redo()
|
||||||
|
{
|
||||||
|
qCDebug(vUndo, "ToggleHideMainPath::redo().");
|
||||||
|
Do(m_newState);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void ToggleHideMainPath::Do(bool state)
|
||||||
|
{
|
||||||
|
QDomElement detail = doc->elementById(m_id, VAbstractPattern::TagDetail);
|
||||||
|
if (detail.isElement())
|
||||||
|
{
|
||||||
|
doc->SetAttribute(detail, VToolSeamAllowance::AttrHideMainPath, state);
|
||||||
|
|
||||||
|
VPiece det = m_data->DataPieces()->value(m_id);
|
||||||
|
det.SetHideMainPath(state);
|
||||||
|
m_data->UpdatePiece(m_id, det);
|
||||||
|
emit Toggled(m_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("Can't get detail by id = %u.", m_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -62,6 +62,31 @@ private:
|
||||||
void Do(bool state);
|
void Do(bool state);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ToggleHideMainPath : public VUndoCommand
|
||||||
|
{
|
||||||
|
Q_OBJECT // NOLINT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ToggleHideMainPath(quint32 id, bool state, VContainer *data, VAbstractPattern *doc, QUndoCommand *parent = nullptr);
|
||||||
|
~ToggleHideMainPath() override = default;
|
||||||
|
|
||||||
|
void undo() override;
|
||||||
|
void redo() override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void Toggled(quint32 id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// cppcheck-suppress unknownMacro
|
||||||
|
Q_DISABLE_COPY_MOVE(ToggleHideMainPath) // NOLINT
|
||||||
|
quint32 m_id;
|
||||||
|
VContainer *m_data;
|
||||||
|
bool m_oldState;
|
||||||
|
bool m_newState;
|
||||||
|
|
||||||
|
void Do(bool state);
|
||||||
|
};
|
||||||
|
|
||||||
enum class ForceForbidFlippingType : qint8
|
enum class ForceForbidFlippingType : qint8
|
||||||
{
|
{
|
||||||
ForceFlipping,
|
ForceFlipping,
|
||||||
|
@ -75,19 +100,19 @@ class TogglePieceForceForbidFlipping : public VUndoCommand
|
||||||
public:
|
public:
|
||||||
TogglePieceForceForbidFlipping(quint32 id, bool state, ForceForbidFlippingType type, VContainer *data,
|
TogglePieceForceForbidFlipping(quint32 id, bool state, ForceForbidFlippingType type, VContainer *data,
|
||||||
VAbstractPattern *doc, QUndoCommand *parent = nullptr);
|
VAbstractPattern *doc, QUndoCommand *parent = nullptr);
|
||||||
virtual ~TogglePieceForceForbidFlipping() = default;
|
~TogglePieceForceForbidFlipping() override = default;
|
||||||
virtual void undo() override;
|
void undo() override;
|
||||||
virtual void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY_MOVE(TogglePieceForceForbidFlipping) // NOLINT
|
Q_DISABLE_COPY_MOVE(TogglePieceForceForbidFlipping) // NOLINT
|
||||||
quint32 m_id;
|
quint32 m_id;
|
||||||
VContainer *m_data;
|
VContainer *m_data;
|
||||||
ForceForbidFlippingType m_type;
|
ForceForbidFlippingType m_type;
|
||||||
bool m_oldForceState;
|
bool m_oldForceState{false};
|
||||||
bool m_newForceState;
|
bool m_newForceState{false};
|
||||||
bool m_oldForbidState;
|
bool m_oldForbidState{false};
|
||||||
bool m_newForbidState;
|
bool m_newForbidState{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TOGGLEDETAILINLAYOUT_H
|
#endif // TOGGLEDETAILINLAYOUT_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user