New option Turn point for context menu.
This commit is contained in:
parent
6c0863ca62
commit
0bf3d93d7e
|
@ -67,6 +67,7 @@
|
|||
<file>schema/pattern/v0.8.13.xsd</file>
|
||||
<file>schema/pattern/v0.9.0.xsd</file>
|
||||
<file>schema/pattern/v0.9.1.xsd</file>
|
||||
<file>schema/pattern/v0.9.2.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.3.0.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.4.0.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.4.1.xsd</file>
|
||||
|
|
1181
src/libs/ifc/schema/pattern/v0.9.2.xsd
Normal file
1181
src/libs/ifc/schema/pattern/v0.9.2.xsd
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -129,6 +129,7 @@ const QString VAbstractPattern::AttrNodePassmark = QStringLiteral("passmark
|
|||
const QString VAbstractPattern::AttrNodePassmarkLine = QStringLiteral("passmarkLine");
|
||||
const QString VAbstractPattern::AttrNodePassmarkAngle = QStringLiteral("passmarkAngle");
|
||||
const QString VAbstractPattern::AttrNodeShowSecondPassmark = QStringLiteral("showSecondPassmark");
|
||||
const QString VAbstractPattern::AttrNodeTurnPoint = QStringLiteral("turnPoint");
|
||||
const QString VAbstractPattern::AttrSABefore = QStringLiteral("before");
|
||||
const QString VAbstractPattern::AttrSAAfter = QStringLiteral("after");
|
||||
const QString VAbstractPattern::AttrStart = QStringLiteral("start");
|
||||
|
@ -811,6 +812,9 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement)
|
|||
const QString passmarkLength =
|
||||
VDomDocument::GetParametrEmptyString(domElement, VAbstractPattern::AttrPassmarkLength);
|
||||
|
||||
const bool turnPoint =
|
||||
VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeTurnPoint, trueStr);
|
||||
|
||||
const QString t = VDomDocument::GetParametrString(domElement, AttrType, VAbstractPattern::NodePoint);
|
||||
Tool tool;
|
||||
|
||||
|
@ -841,8 +845,7 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement)
|
|||
tool = Tool::NodeElArc;
|
||||
break;
|
||||
default:
|
||||
VException e(QObject::tr("Wrong tag name '%1'.").arg(t));
|
||||
throw e;
|
||||
throw VException(tr("Wrong tag name '%1'.").arg(t));
|
||||
}
|
||||
VPieceNode node(id, tool, reverse);
|
||||
node.SetFormulaSABefore(saBefore);
|
||||
|
@ -856,6 +859,7 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement)
|
|||
node.SetPassmarkAngleType(passmarkAngle);
|
||||
node.SetManualPassmarkLength(manualPassmarkLength);
|
||||
node.SetFormulaPassmarkLength(passmarkLength);
|
||||
node.SetTurnPoint(turnPoint);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
|
|
@ -324,6 +324,7 @@ public:
|
|||
static const QString AttrNodePassmarkLine;
|
||||
static const QString AttrNodePassmarkAngle;
|
||||
static const QString AttrNodeShowSecondPassmark;
|
||||
static const QString AttrNodeTurnPoint;
|
||||
static const QString AttrSABefore;
|
||||
static const QString AttrSAAfter;
|
||||
static const QString AttrStart;
|
||||
|
|
|
@ -60,8 +60,8 @@ class QDomElement;
|
|||
*/
|
||||
|
||||
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.1");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.1.xsd");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.2");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.2.xsd");
|
||||
|
||||
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
|
@ -266,7 +266,8 @@ auto VPatternConverter::XSDSchema(unsigned ver) const -> QString
|
|||
std::make_pair(FormatVersion(0, 8, 12), QStringLiteral("://schema/pattern/v0.8.12.xsd")),
|
||||
std::make_pair(FormatVersion(0, 8, 13), QStringLiteral("://schema/pattern/v0.8.13.xsd")),
|
||||
std::make_pair(FormatVersion(0, 9, 0), QStringLiteral("://schema/pattern/v0.9.0.xsd")),
|
||||
std::make_pair(FormatVersion(0, 9, 1), CurrentSchema)
|
||||
std::make_pair(FormatVersion(0, 9, 1), QStringLiteral("://schema/pattern/v0.9.1.xsd")),
|
||||
std::make_pair(FormatVersion(0, 9, 2), CurrentSchema)
|
||||
};
|
||||
|
||||
if (schemas.contains(ver))
|
||||
|
@ -374,6 +375,10 @@ void VPatternConverter::ApplyPatches()
|
|||
ValidateXML(CurrentSchema);
|
||||
Q_FALLTHROUGH();
|
||||
case (FormatVersion(0, 9, 1)):
|
||||
ToV0_9_2();
|
||||
ValidateXML(CurrentSchema);
|
||||
Q_FALLTHROUGH();
|
||||
case (FormatVersion(0, 9, 2)):
|
||||
break;
|
||||
default:
|
||||
InvalidVersion(m_ver);
|
||||
|
@ -391,7 +396,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
|
|||
bool VPatternConverter::IsReadOnly() const
|
||||
{
|
||||
// Check if attribute readOnly was not changed in file format
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 1),
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 2),
|
||||
"Check attribute readOnly.");
|
||||
|
||||
// Possibly in future attribute readOnly will change position etc.
|
||||
|
@ -562,6 +567,17 @@ void VPatternConverter::ToV0_9_1()
|
|||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::ToV0_9_2()
|
||||
{
|
||||
// TODO. Delete if minimal supported version is 0.9.2
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 2),
|
||||
"Time to refactor the code.");
|
||||
|
||||
SetVersion(QStringLiteral("0.9.2"));
|
||||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::TagUnitToV0_2_0()
|
||||
{
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
static const QString PatternMaxVerStr;
|
||||
static const QString CurrentSchema;
|
||||
static Q_DECL_CONSTEXPR const unsigned PatternMinVer = FormatVersion(0, 1, 4);
|
||||
static Q_DECL_CONSTEXPR const unsigned PatternMaxVer = FormatVersion(0, 9, 1);
|
||||
static Q_DECL_CONSTEXPR const unsigned PatternMaxVer = FormatVersion(0, 9, 2);
|
||||
|
||||
protected:
|
||||
void Save() override;
|
||||
|
@ -86,6 +86,7 @@ private:
|
|||
void ToV0_8_8();
|
||||
void ToV0_9_0();
|
||||
void ToV0_9_1();
|
||||
void ToV0_9_2();
|
||||
|
||||
void TagUnitToV0_2_0();
|
||||
void TagIncrementToV0_2_0();
|
||||
|
|
|
@ -672,6 +672,11 @@ QString GetNodeName(const VContainer *data, const VPieceNode &node, bool showPas
|
|||
{
|
||||
name = QLatin1Char('[') + name + QLatin1Char(']');
|
||||
}
|
||||
|
||||
if (not node.IsTurnPoint())
|
||||
{
|
||||
name += QStringLiteral(" ⦿");
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
|
|
|
@ -329,11 +329,13 @@ void DialogPiecePath::ShowContextMenu(const QPoint &pos)
|
|||
|
||||
QListWidgetItem *rowItem = ui->listWidget->item(row);
|
||||
SCASSERT(rowItem != nullptr);
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
|
||||
QAction *actionPassmark = nullptr;
|
||||
QAction *actionUniqueness = nullptr;
|
||||
QAction *actionReverse = nullptr;
|
||||
QAction *actionTurnPoint = nullptr;
|
||||
|
||||
if (rowNode.GetTypeTool() != Tool::NodePoint)
|
||||
{
|
||||
actionReverse = menu->addAction(tr("Reverse"));
|
||||
|
@ -353,6 +355,10 @@ void DialogPiecePath::ShowContextMenu(const QPoint &pos)
|
|||
actionUniqueness = menu->addAction(tr("Check uniqueness"));
|
||||
actionUniqueness->setCheckable(true);
|
||||
actionUniqueness->setChecked(rowNode.IsCheckUniqueness());
|
||||
|
||||
actionTurnPoint = menu->addAction(tr("Turn point"));
|
||||
actionTurnPoint->setCheckable(true);
|
||||
actionTurnPoint->setChecked(rowNode.IsTurnPoint());
|
||||
}
|
||||
|
||||
QAction *actionExcluded = menu->addAction(tr("Excluded"));
|
||||
|
@ -393,6 +399,12 @@ void DialogPiecePath::ShowContextMenu(const QPoint &pos)
|
|||
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
||||
rowItem->setText(GetNodeName(data, rowNode, IsShowNotch()));
|
||||
}
|
||||
else if (rowNode.GetTypeTool() == Tool::NodePoint && selectedAction == actionTurnPoint)
|
||||
{
|
||||
rowNode.SetTurnPoint(not rowNode.IsTurnPoint());
|
||||
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
||||
rowItem->setText(GetNodeName(data, rowNode, IsShowNotch()));
|
||||
}
|
||||
|
||||
ValidObjects(PathIsValid());
|
||||
ListChanged();
|
||||
|
|
|
@ -745,11 +745,13 @@ void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos)
|
|||
|
||||
QListWidgetItem *rowItem = uiTabPaths->listWidgetMainPath->item(row);
|
||||
SCASSERT(rowItem != nullptr);
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
|
||||
QAction *actionPassmark = nullptr;
|
||||
QAction *actionUniqueness = nullptr;
|
||||
QAction *actionReverse = nullptr;
|
||||
QAction *actionTurnPoint = nullptr;
|
||||
|
||||
if (rowNode.GetTypeTool() != Tool::NodePoint)
|
||||
{
|
||||
actionReverse = menu->addAction(tr("Reverse"));
|
||||
|
@ -768,6 +770,10 @@ void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos)
|
|||
actionUniqueness = menu->addAction(tr("Check uniqueness"));
|
||||
actionUniqueness->setCheckable(true);
|
||||
actionUniqueness->setChecked(rowNode.IsCheckUniqueness());
|
||||
|
||||
actionTurnPoint = menu->addAction(tr("Turn point"));
|
||||
actionTurnPoint->setCheckable(true);
|
||||
actionTurnPoint->setChecked(rowNode.IsTurnPoint());
|
||||
}
|
||||
|
||||
QAction *actionExcluded = menu->addAction(tr("Excluded"));
|
||||
|
@ -807,6 +813,13 @@ void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos)
|
|||
rowItem->setText(GetNodeName(data, rowNode, true));
|
||||
}
|
||||
|
||||
else if (selectedAction == actionTurnPoint)
|
||||
{
|
||||
rowNode.SetTurnPoint(not rowNode.IsTurnPoint());
|
||||
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
||||
rowItem->setText(GetNodeName(data, rowNode, true));
|
||||
}
|
||||
|
||||
ValidObjects(MainPathIsValid());
|
||||
ListChanged();
|
||||
}
|
||||
|
|
|
@ -100,6 +100,7 @@ enum class ContextMenuOption : int
|
|||
ForbidFlipping,
|
||||
ForceFlipping,
|
||||
Remove,
|
||||
TurnPoint,
|
||||
LAST_ONE_DO_NOT_USE
|
||||
};
|
||||
}
|
||||
|
@ -140,7 +141,7 @@ void VNodePoint::Create(const VAbstractNodeInitData &initData)
|
|||
VAbstractTool::AddRecord(initData.id, Tool::NodePoint, initData.doc);
|
||||
//TODO Need create garbage collector and remove all nodes, what we don't use.
|
||||
//Better check garbage before each saving file. Check only modeling tags.
|
||||
VNodePoint *point = new VNodePoint(initData);
|
||||
auto *point = new VNodePoint(initData);
|
||||
|
||||
connect(initData.scene, &VMainGraphicsScene::EnableToolMove, point, &VNodePoint::EnableToolMove);
|
||||
connect(initData.scene, &VMainGraphicsScene::EnablePointItemHover, point, &VNodePoint::AllowHover);
|
||||
|
@ -326,7 +327,7 @@ QHash<int, QAction *> VNodePoint::InitContextMenu(QMenu *menu, vidtype pieceId,
|
|||
InitPassmarkAngleTypeMenu(menu, pieceId, contextMenu);
|
||||
InitPassmarkLineTypeMenu(menu, pieceId, contextMenu);
|
||||
|
||||
QAction *separatorAct = new QAction(this);
|
||||
auto *separatorAct = new QAction(this);
|
||||
separatorAct->setSeparator(true);
|
||||
menu->addAction(separatorAct);
|
||||
|
||||
|
@ -366,11 +367,17 @@ void VNodePoint::InitPassmarkMenu(QMenu *menu, vidtype pieceId, QHash<int, QActi
|
|||
const int nodeIndex = detail.GetPath().indexOfNode(m_id);
|
||||
if (nodeIndex != -1)
|
||||
{
|
||||
const VPieceNode &node = detail.GetPath().at(nodeIndex);
|
||||
|
||||
QAction *actionPassmark = menu->addAction(tr("Passmark"));
|
||||
actionPassmark->setCheckable(true);
|
||||
actionPassmark->setChecked(detail.GetPath().at(nodeIndex).IsPassmark());
|
||||
|
||||
actionPassmark->setChecked(node.IsPassmark());
|
||||
contextMenu.insert(static_cast<int>(ContextMenuOption::Passmark), actionPassmark);
|
||||
|
||||
QAction *actionTurnPoint = menu->addAction(tr("Turn point"));
|
||||
actionTurnPoint->setCheckable(true);
|
||||
actionTurnPoint->setChecked(node.IsTurnPoint());
|
||||
contextMenu.insert(static_cast<int>(ContextMenuOption::TurnPoint), actionTurnPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -524,7 +531,7 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
return;
|
||||
}
|
||||
|
||||
if (VToolSeamAllowance *piece = qgraphicsitem_cast<VToolSeamAllowance *>(parentItem()))
|
||||
if (auto *piece = qgraphicsitem_cast<VToolSeamAllowance *>(parentItem()))
|
||||
{
|
||||
QMenu menu;
|
||||
QHash<int, QAction *> contextMenu = InitContextMenu(&menu, piece->getId(), piece->referens());
|
||||
|
@ -573,7 +580,7 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
ContextMenuOption selectedOption = static_cast<ContextMenuOption>(
|
||||
contextMenu.key(selectedAction, static_cast<int>(ContextMenuOption::NoSelection)));
|
||||
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(ContextMenuOption::LAST_ONE_DO_NOT_USE) == 31,
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(ContextMenuOption::LAST_ONE_DO_NOT_USE) == 32,
|
||||
"Not all options were handled.");
|
||||
|
||||
QT_WARNING_PUSH
|
||||
|
@ -614,6 +621,9 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
case ContextMenuOption::Exclude:
|
||||
emit ToggleExcludeState(m_id);
|
||||
break;
|
||||
case ContextMenuOption::TurnPoint:
|
||||
emit ToggleTurnPointState(m_id);
|
||||
break;
|
||||
case ContextMenuOption::ByLength:
|
||||
SelectSeamAllowanceAngle(PieceNodeAngle::ByLength);
|
||||
break;
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "vabstractnode.h"
|
||||
#include "../vwidgets/vscenepoint.h"
|
||||
|
@ -66,6 +65,7 @@ signals:
|
|||
void ToggleForceFlipping(bool checked);
|
||||
void Delete();
|
||||
void ToggleExcludeState(quint32 id);
|
||||
void ToggleTurnPointState(quint32 id);
|
||||
void ToggleSeamAllowanceAngleType(quint32 id, PieceNodeAngle type);
|
||||
void TogglePassmark(quint32 id, bool toggle);
|
||||
void TogglePassmarkAngleType(quint32 id, PassmarkAngleType type);
|
||||
|
|
|
@ -567,6 +567,9 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa
|
|||
nod.removeAttribute(VAbstractPattern::AttrNodePassmarkLine);
|
||||
nod.removeAttribute(VAbstractPattern::AttrNodePassmarkAngle);
|
||||
}
|
||||
|
||||
doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrNodeTurnPoint, node.IsTurnPoint(),
|
||||
[](bool value) noexcept {return value;});
|
||||
}
|
||||
else
|
||||
{ // Wrong configuration.
|
||||
|
|
|
@ -1584,6 +1584,26 @@ void VToolSeamAllowance::ToggleExcludeState(quint32 id)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSeamAllowance::ToggleTurnPointState(quint32 id)
|
||||
{
|
||||
const VPiece oldDet = VAbstractTool::data.GetPiece(m_id);
|
||||
VPiece newDet = oldDet;
|
||||
|
||||
for (int i = 0; i< oldDet.GetPath().CountNodes(); ++i)
|
||||
{
|
||||
VPieceNode node = oldDet.GetPath().at(i);
|
||||
if (node.GetId() == id && node.GetTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
node.SetTurnPoint(not node.IsTurnPoint());
|
||||
newDet.GetPath()[i] = node;
|
||||
|
||||
VAbstractApplication::VApp()->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSeamAllowance::ToggleNodePointAngleType(quint32 id, PieceNodeAngle type)
|
||||
{
|
||||
|
@ -1876,7 +1896,7 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc
|
|||
{
|
||||
case (Tool::NodePoint):
|
||||
{
|
||||
VNodePoint *tool = qobject_cast<VNodePoint*>(VAbstractPattern::getTool(node.GetId()));
|
||||
auto *tool = qobject_cast<VNodePoint*>(VAbstractPattern::getTool(node.GetId()));
|
||||
SCASSERT(tool != nullptr);
|
||||
|
||||
if (tool->parent() != parent)
|
||||
|
@ -1891,6 +1911,8 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc
|
|||
connect(tool, &VNodePoint::Delete, parent, &VToolSeamAllowance::DeleteFromMenu, Qt::UniqueConnection);
|
||||
connect(tool, &VNodePoint::ToggleExcludeState, parent, &VToolSeamAllowance::ToggleExcludeState,
|
||||
Qt::UniqueConnection);
|
||||
connect(tool, &VNodePoint::ToggleTurnPointState, parent, &VToolSeamAllowance::ToggleTurnPointState,
|
||||
Qt::UniqueConnection);
|
||||
connect(tool, &VNodePoint::ToggleSeamAllowanceAngleType, parent,
|
||||
&VToolSeamAllowance::ToggleNodePointAngleType, Qt::UniqueConnection);
|
||||
connect(tool, &VNodePoint::TogglePassmark, parent, &VToolSeamAllowance::ToggleNodePointPassmark,
|
||||
|
|
|
@ -168,6 +168,7 @@ private slots:
|
|||
void ToggleForbidFlipping(bool checked);
|
||||
void ToggleForceFlipping(bool checked);
|
||||
void ToggleExcludeState(quint32 id);
|
||||
void ToggleTurnPointState(quint32 id);
|
||||
void ToggleNodePointAngleType(quint32 id, PieceNodeAngle type);
|
||||
void ToggleNodePointPassmark(quint32 id, bool toggle);
|
||||
void TogglePassmarkAngleType(quint32 id, PassmarkAngleType type);
|
||||
|
|
Loading…
Reference in New Issue
Block a user