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->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"));
|
||||
forbidFlippingOption->setCheckable(true);
|
||||
forbidFlippingOption->setChecked(detail.IsForbidFlipping());
|
||||
|
@ -1292,6 +1296,10 @@ void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
{
|
||||
ToggleInLayout(selectedAction->isChecked());
|
||||
}
|
||||
else if (selectedAction == hideMainPathOption)
|
||||
{
|
||||
ToggleHideMainPath(selectedAction->isChecked());
|
||||
}
|
||||
else if (selectedAction == forbidFlippingOption)
|
||||
{
|
||||
ToggleForbidFlipping(selectedAction->isChecked());
|
||||
|
@ -1602,9 +1610,17 @@ void VToolSeamAllowance::ShowOptions()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSeamAllowance::ToggleInLayout(bool checked)
|
||||
{
|
||||
auto *togglePrint = new TogglePieceInLayout(m_id, checked, &(VAbstractTool::data), doc);
|
||||
connect(togglePrint, &TogglePieceInLayout::Toggled, doc, &VAbstractPattern::CheckInLayoutList);
|
||||
VAbstractApplication::VApp()->getUndoStack()->push(togglePrint);
|
||||
auto *toggleInLayout = new TogglePieceInLayout(m_id, checked, &(VAbstractTool::data), doc);
|
||||
connect(toggleInLayout, &TogglePieceInLayout::Toggled, doc, &VAbstractPattern::CheckInLayoutList);
|
||||
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:
|
||||
void ToggleInLayout(bool checked);
|
||||
void ToggleHideMainPath(bool checked);
|
||||
void ToggleForbidFlipping(bool checked);
|
||||
void ToggleForceFlipping(bool checked);
|
||||
void ToggleExcludeState(quint32 id);
|
||||
|
|
|
@ -35,20 +35,19 @@
|
|||
|
||||
#include "../ifc/ifcdef.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vpatterndb/vpiece.h"
|
||||
#include "vundocommand.h"
|
||||
#include "../vtools/tools/vtoolseamallowance.h"
|
||||
#include "vundocommand.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
TogglePieceInLayout::TogglePieceInLayout(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)
|
||||
: VUndoCommand(QDomElement(), doc, parent),
|
||||
m_id(id),
|
||||
m_data(data),
|
||||
m_oldState(not state),
|
||||
m_newState(state)
|
||||
{
|
||||
setText(tr("detail in layout list"));
|
||||
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);
|
||||
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);
|
||||
det.SetInLayout(state);
|
||||
|
@ -91,14 +90,10 @@ void TogglePieceInLayout::Do(bool state)
|
|||
TogglePieceForceForbidFlipping::TogglePieceForceForbidFlipping(quint32 id, bool state, ForceForbidFlippingType type,
|
||||
VContainer *data, VAbstractPattern *doc,
|
||||
QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent),
|
||||
m_id(id),
|
||||
m_data(data),
|
||||
m_type(type),
|
||||
m_oldForceState(false),
|
||||
m_newForceState(false),
|
||||
m_oldForbidState(false),
|
||||
m_newForbidState(false)
|
||||
: VUndoCommand(QDomElement(), doc, parent),
|
||||
m_id(id),
|
||||
m_data(data),
|
||||
m_type(type)
|
||||
{
|
||||
setText(tr("piece flipping"));
|
||||
|
||||
|
@ -174,3 +169,49 @@ void TogglePieceForceForbidFlipping::redo()
|
|||
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);
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
ForceFlipping,
|
||||
|
@ -75,19 +100,19 @@ class TogglePieceForceForbidFlipping : public VUndoCommand
|
|||
public:
|
||||
TogglePieceForceForbidFlipping(quint32 id, bool state, ForceForbidFlippingType type, VContainer *data,
|
||||
VAbstractPattern *doc, QUndoCommand *parent = nullptr);
|
||||
virtual ~TogglePieceForceForbidFlipping() = default;
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
~TogglePieceForceForbidFlipping() override = default;
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(TogglePieceForceForbidFlipping) // NOLINT
|
||||
quint32 m_id;
|
||||
VContainer *m_data;
|
||||
ForceForbidFlippingType m_type;
|
||||
bool m_oldForceState;
|
||||
bool m_newForceState;
|
||||
bool m_oldForbidState;
|
||||
bool m_newForbidState;
|
||||
bool m_oldForceState{false};
|
||||
bool m_newForceState{false};
|
||||
bool m_oldForbidState{false};
|
||||
bool m_newForbidState{false};
|
||||
};
|
||||
|
||||
#endif // TOGGLEDETAILINLAYOUT_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user