diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp
index de6777e33..360ef865f 100644
--- a/src/app/valentina/xml/vpattern.cpp
+++ b/src/app/valentina/xml/vpattern.cpp
@@ -2186,10 +2186,12 @@ void VPattern::ParseToolTrueDarts(VMainGraphicsScene *scene, const QDomElement &
initData.name1 = GetParametrString(domElement, AttrName1, "A");
initData.mx1 = qApp->toPixel(GetParametrDouble(domElement, AttrMx1, "10.0"));
initData.my1 = qApp->toPixel(GetParametrDouble(domElement, AttrMy1, "15.0"));
+ initData.showLabel1 = GetParametrBool(domElement, AttrShowLabel1, trueStr);
initData.name2 = GetParametrString(domElement, AttrName2, "A");
initData.mx2 = qApp->toPixel(GetParametrDouble(domElement, AttrMx2, "10.0"));
initData.my2 = qApp->toPixel(GetParametrDouble(domElement, AttrMy2, "15.0"));
+ initData.showLabel2 = GetParametrBool(domElement, AttrShowLabel2, trueStr);
VToolTrueDarts::Create(initData);
}
diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp
index 33e62e8f0..744338e00 100644
--- a/src/libs/ifc/ifcdef.cpp
+++ b/src/libs/ifc/ifcdef.cpp
@@ -123,6 +123,8 @@ const QString AttrInLayout = QStringLiteral("inLayout");
const QString AttrRotationAngle = QStringLiteral("rotationAngle");
const QString AttrClosed = QStringLiteral("closed");
const QString AttrShowLabel = QStringLiteral("showLabel");
+const QString AttrShowLabel1 = QStringLiteral("showLabel1");
+const QString AttrShowLabel2 = QStringLiteral("showLabel2");
const QString TypeLineNone = QStringLiteral("none");
const QString TypeLineLine = QStringLiteral("hair");
diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h
index 86cdbb41c..fe3d6ea84 100644
--- a/src/libs/ifc/ifcdef.h
+++ b/src/libs/ifc/ifcdef.h
@@ -142,6 +142,8 @@ extern const QString AttrIdObject;
extern const QString AttrInLayout;
extern const QString AttrClosed;
extern const QString AttrShowLabel;
+extern const QString AttrShowLabel1;
+extern const QString AttrShowLabel2;
extern const QString TypeLineNone;
extern const QString TypeLineLine;
diff --git a/src/libs/ifc/schema/pattern/v0.6.3.xsd b/src/libs/ifc/schema/pattern/v0.6.3.xsd
index 3a990fe84..ff5e59890 100644
--- a/src/libs/ifc/schema/pattern/v0.6.3.xsd
+++ b/src/libs/ifc/schema/pattern/v0.6.3.xsd
@@ -217,6 +217,8 @@
+
+
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp
index a8ff6331c..230ae02f4 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp
+++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp
@@ -38,6 +38,7 @@
#include
#include "../../../../undocommands/label/movedoublelabel.h"
+#include "../../../../undocommands/label/showdoublelabel.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/exception/vexceptionbadid.h"
#include "../ifc/xml/vabstractpattern.h"
@@ -121,6 +122,40 @@ void VToolDoublePoint::GroupVisibility(quint32 object, bool visible)
}
}
+//---------------------------------------------------------------------------------------------------------------------
+bool VToolDoublePoint::IsLabelVisible(quint32 id) const
+{
+ if (p1id == id)
+ {
+ return VAbstractTool::data.GeometricObject(p1id)->IsShowLabel();
+ }
+ else if (p2id == id)
+ {
+ return VAbstractTool::data.GeometricObject(p2id)->IsShowLabel();
+ }
+ else
+ {
+ return false;
+ }
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void VToolDoublePoint::SetLabelVisible(quint32 id, bool visible)
+{
+ if (p1id == id)
+ {
+ const QSharedPointer point = VAbstractTool::data.GeometricObject(p1id);
+ point->SetShowLabel(visible);
+ firstPoint->RefreshPointGeometry(*point);
+ }
+ else if (p2id == id)
+ {
+ const QSharedPointer point = VAbstractTool::data.GeometricObject(p2id);
+ point->SetShowLabel(visible);
+ secondPoint->RefreshPointGeometry(*point);
+ }
+}
+
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::Label1ChangePosition(const QPointF &pos)
{
@@ -248,7 +283,7 @@ void VToolDoublePoint::UpdateNamePosition(quint32 id)
{
const VPointF *p1 = VAbstractTool::data.GeometricObject(p1id).data();
- auto moveLabel = new MoveDoubleLabel(doc, p1->mx(), p1->my(), DoublePoint::FirstPoint, m_id, p1id);
+ auto moveLabel = new MoveDoubleLabel(doc, p1->mx(), p1->my(), MoveDoublePoint::FirstPoint, m_id, p1id);
connect(moveLabel, &MoveDoubleLabel::ChangePosition, this, &VToolDoublePoint::DoChangePosition);
qApp->getUndoStack()->push(moveLabel);
}
@@ -256,7 +291,7 @@ void VToolDoublePoint::UpdateNamePosition(quint32 id)
{
const VPointF *p2 = VAbstractTool::data.GeometricObject(p2id).data();
- auto moveLabel = new MoveDoubleLabel(doc, p2->mx(), p2->my(), DoublePoint::SecondPoint, m_id, p2id);
+ auto moveLabel = new MoveDoubleLabel(doc, p2->mx(), p2->my(), MoveDoublePoint::SecondPoint, m_id, p2id);
connect(moveLabel, &MoveDoubleLabel::ChangePosition, this, &VToolDoublePoint::DoChangePosition);
qApp->getUndoStack()->push(moveLabel);
}
@@ -324,38 +359,43 @@ void VToolDoublePoint::SaveOptions(QDomElement &tag, QSharedPointer &o
{
VDrawTool::SaveOptions(tag, obj);
+ auto SavePoint1 = [this](QDomElement &tag, const QSharedPointer &point)
+ {
+ doc->SetAttribute(tag, AttrName1, point->name());
+ doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(point->mx()));
+ doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(point->my()));
+ doc->SetAttribute(tag, AttrShowLabel1, point->IsShowLabel());
+ };
+
+ auto SavePoint2 = [this](QDomElement &tag, const QSharedPointer &point)
+ {
+ doc->SetAttribute(tag, AttrName2, point->name());
+ doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(point->mx()));
+ doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(point->my()));
+ doc->SetAttribute(tag, AttrShowLabel2, point->IsShowLabel());
+ };
+
if (obj->id() == p1id)
{
QSharedPointer point = qSharedPointerDynamicCast(obj);
SCASSERT(point.isNull() == false)
- doc->SetAttribute(tag, AttrName1, point->name());
- doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(point->mx()));
- doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(point->my()));
+ SavePoint1(tag, point);
}
else if (obj->id() == p2id)
{
QSharedPointer point = qSharedPointerDynamicCast(obj);
SCASSERT(point.isNull() == false)
- doc->SetAttribute(tag, AttrName2, point->name());
- doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(point->mx()));
- doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(point->my()));
+ SavePoint2(tag, point);
}
else
{
- VPointF *p1 = VAbstractTool::data.GeometricObject(p1id).data();
- VPointF *p2 = VAbstractTool::data.GeometricObject(p2id).data();
-
doc->SetAttribute(tag, AttrPoint1, p1id);
- doc->SetAttribute(tag, AttrName1, p1->name());
- doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(p1->mx()));
- doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(p1->my()));
+ SavePoint1(tag, VAbstractTool::data.GeometricObject(p1id));
doc->SetAttribute(tag, AttrPoint2, p2id);
- doc->SetAttribute(tag, AttrName2, p2->name());
- doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(p2->mx()));
- doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(p2->my()));
+ SavePoint2(tag, VAbstractTool::data.GeometricObject(p2id));
}
}
@@ -368,6 +408,19 @@ void VToolDoublePoint::AddToFile()
AddToCalculation(domElement);
}
+//---------------------------------------------------------------------------------------------------------------------
+void VToolDoublePoint::ChangeLabelVisibility(quint32 id, bool visible)
+{
+ if (id == p1id)
+ {
+ qApp->getUndoStack()->push(new ShowDoubleLabel(doc, m_id, p1id, visible, ShowDoublePoint::FirstPoint));
+ }
+ else if (id == p2id)
+ {
+ qApp->getUndoStack()->push(new ShowDoubleLabel(doc, m_id, p2id, visible, ShowDoublePoint::SecondPoint));
+ }
+}
+
//---------------------------------------------------------------------------------------------------------------------
QString VToolDoublePoint::ComplexToolTip(quint32 itemId) const
{
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h
index c4e2453d0..e66baa9eb 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h
+++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h
@@ -63,6 +63,9 @@ public:
void setNameP2(const QString &name);
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
+
+ virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE;
+ virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE;
public slots:
void Label1ChangePosition(const QPointF &pos);
void Label2ChangePosition(const QPointF &pos);
@@ -93,6 +96,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE;
virtual void AddToFile() Q_DECL_OVERRIDE;
+ virtual void ChangeLabelVisibility(quint32 id, bool visible) Q_DECL_OVERRIDE;
QString ComplexToolTip(quint32 itemId) const;
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp
index 38fa56219..e712164e3 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp
+++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp
@@ -154,20 +154,22 @@ VToolTrueDarts *VToolTrueDarts::Create(VToolTrueDartsInitData initData)
static_cast(*dartP1), static_cast(*dartP2),
static_cast(*dartP3), fPoint1, fPoint2);
+ VPointF *p1 = new VPointF(fPoint1, initData.name1, initData.mx1, initData.my1, initData.id);
+ p1->SetShowLabel(initData.showLabel1);
+
+ VPointF *p2 = new VPointF(fPoint2, initData.name2, initData.mx2, initData.my2, initData.id);
+ p2->SetShowLabel(initData.showLabel2);
+
if (initData.typeCreation == Source::FromGui)
{
initData.id = VContainer::getNextId();//Just reserve id for tool
- initData.p1id = initData.data->AddGObject(new VPointF(fPoint1, initData.name1, initData.mx1, initData.my1,
- initData.id));
- initData.p2id = initData.data->AddGObject(new VPointF(fPoint2, initData.name2, initData.mx2, initData.my2,
- initData.id));
+ initData.p1id = initData.data->AddGObject(p1);
+ initData.p2id = initData.data->AddGObject(p2);
}
else
{
- initData.data->UpdateGObject(initData.p1id, new VPointF(fPoint1, initData.name1, initData.mx1, initData.my1,
- initData.id));
- initData.data->UpdateGObject(initData.p2id, new VPointF(fPoint2, initData.name2, initData.mx2, initData.my2,
- initData.id));
+ initData.data->UpdateGObject(initData.p1id, p1);
+ initData.data->UpdateGObject(initData.p2id, p2);
if (initData.parse != Document::FullParse)
{
initData.doc->UpdateToolData(initData.id, initData.data);
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h
index 348a4341e..2729f5be9 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h
+++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h
@@ -58,9 +58,11 @@ struct VToolTrueDartsInitData : public VAbstractToolInitData
name1(),
mx1(10),
my1(15),
+ showLabel1(true),
name2(),
mx2(10),
- my2(15)
+ my2(15),
+ showLabel2(true)
{}
quint32 p1id;
@@ -71,11 +73,13 @@ struct VToolTrueDartsInitData : public VAbstractToolInitData
quint32 dartP2Id;
quint32 dartP3Id;
QString name1;
- qreal mx1;
- qreal my1;
+ qreal mx1;
+ qreal my1;
+ bool showLabel1;
QString name2;
- qreal mx2;
- qreal my2;
+ qreal mx2;
+ qreal my2;
+ bool showLabel2;
};
class VToolTrueDarts : public VToolDoublePoint
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp
index 8fe6d6ddc..ee4425a77 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp
+++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp
@@ -311,7 +311,7 @@ void VToolSinglePoint::SaveOptions(QDomElement &tag, QSharedPointer &o
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
- doc->SetAttribute(tag, AttrShowLabel, point->IsShowLabel());
+ doc->SetAttribute(tag, AttrShowLabel, point->IsShowLabel());
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h
index 5d21c18b3..4167323a9 100644
--- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h
+++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h
@@ -104,7 +104,7 @@ protected:
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE;
- virtual void ChangeLabelVisibility(quint32 id, bool visible);
+ virtual void ChangeLabelVisibility(quint32 id, bool visible) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VToolSinglePoint)
};
diff --git a/src/libs/vtools/undocommands/label/movedoublelabel.cpp b/src/libs/vtools/undocommands/label/movedoublelabel.cpp
index 8a3a4d505..b4970eb54 100644
--- a/src/libs/vtools/undocommands/label/movedoublelabel.cpp
+++ b/src/libs/vtools/undocommands/label/movedoublelabel.cpp
@@ -39,13 +39,13 @@
#include "moveabstractlabel.h"
//---------------------------------------------------------------------------------------------------------------------
-MoveDoubleLabel::MoveDoubleLabel(VAbstractPattern *doc, const double &x, const double &y, DoublePoint type,
+MoveDoubleLabel::MoveDoubleLabel(VAbstractPattern *doc, const double &x, const double &y, MoveDoublePoint type,
quint32 toolId, quint32 pointId, QUndoCommand *parent)
: MoveAbstractLabel(doc, pointId, x, y, parent),
m_type(type),
m_idTool(toolId)
{
- if (type == DoublePoint::FirstPoint)
+ if (type == MoveDoublePoint::FirstPoint)
{
setText(tr("move the first dart label"));
}
@@ -57,7 +57,7 @@ MoveDoubleLabel::MoveDoubleLabel(VAbstractPattern *doc, const double &x, const d
const QDomElement domElement = doc->elementById(m_idTool, VAbstractPattern::TagPoint);
if (domElement.isElement())
{
- if (type == DoublePoint::FirstPoint)
+ if (type == MoveDoublePoint::FirstPoint)
{
m_oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx1, "0.0"));
m_oldMy = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMy1, "0.0"));
@@ -100,7 +100,7 @@ bool MoveDoubleLabel::mergeWith(const QUndoCommand *command)
m_newMx = moveCommand->GetNewMx();
m_newMy = moveCommand->GetNewMy();
- if (m_type == DoublePoint::FirstPoint)
+ if (m_type == MoveDoublePoint::FirstPoint)
{
qCDebug(vUndo, "Label new Mx1 %f", m_newMx);
qCDebug(vUndo, "Label new My1 %f", m_newMy);
@@ -122,7 +122,7 @@ int MoveDoubleLabel::id() const
//---------------------------------------------------------------------------------------------------------------------
void MoveDoubleLabel::Do(double mx, double my)
{
- if (m_type == DoublePoint::FirstPoint)
+ if (m_type == MoveDoublePoint::FirstPoint)
{
qCDebug(vUndo, "New mx1 %f", mx);
qCDebug(vUndo, "New my1 %f", my);
@@ -136,7 +136,7 @@ void MoveDoubleLabel::Do(double mx, double my)
QDomElement domElement = doc->elementById(m_idTool, VAbstractPattern::TagPoint);
if (domElement.isElement())
{
- if (m_type == DoublePoint::FirstPoint)
+ if (m_type == MoveDoublePoint::FirstPoint)
{
doc->SetAttribute(domElement, AttrMx1, QString().setNum(qApp->fromPixel(mx)));
doc->SetAttribute(domElement, AttrMy1, QString().setNum(qApp->fromPixel(my)));
diff --git a/src/libs/vtools/undocommands/label/movedoublelabel.h b/src/libs/vtools/undocommands/label/movedoublelabel.h
index 4864c1d2f..201256943 100644
--- a/src/libs/vtools/undocommands/label/movedoublelabel.h
+++ b/src/libs/vtools/undocommands/label/movedoublelabel.h
@@ -37,13 +37,13 @@
#include "moveabstractlabel.h"
-enum class DoublePoint: char { FirstPoint, SecondPoint };
+enum class MoveDoublePoint: char { FirstPoint, SecondPoint };
class MoveDoubleLabel : public MoveAbstractLabel
{
Q_OBJECT
public:
- MoveDoubleLabel(VAbstractPattern *doc, const double &x, const double &y, DoublePoint type,
+ MoveDoubleLabel(VAbstractPattern *doc, const double &x, const double &y, MoveDoublePoint type,
quint32 toolId, quint32 pointId, QUndoCommand *parent = nullptr);
virtual ~MoveDoubleLabel() Q_DECL_OVERRIDE;
@@ -51,17 +51,17 @@ public:
virtual int id() const Q_DECL_OVERRIDE;
quint32 GetToolId() const;
- DoublePoint GetPointType() const;
+ MoveDoublePoint GetPointType() const;
protected:
virtual void Do(double mx, double my) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(MoveDoubleLabel)
- DoublePoint m_type;
+ MoveDoublePoint m_type;
quint32 m_idTool;
};
//---------------------------------------------------------------------------------------------------------------------
-inline DoublePoint MoveDoubleLabel::GetPointType() const
+inline MoveDoublePoint MoveDoubleLabel::GetPointType() const
{
return m_type;
}
diff --git a/src/libs/vtools/undocommands/label/showdoublelabel.cpp b/src/libs/vtools/undocommands/label/showdoublelabel.cpp
new file mode 100644
index 000000000..710a9e130
--- /dev/null
+++ b/src/libs/vtools/undocommands/label/showdoublelabel.cpp
@@ -0,0 +1,121 @@
+/************************************************************************
+ **
+ ** @file
+ ** @author Roman Telezhynskyi
+ ** @date 20 9, 2017
+ **
+ ** @brief
+ ** @copyright
+ ** This source code is part of the Valentine project, a pattern making
+ ** program, whose allow create and modeling patterns of clothing.
+ ** Copyright (C) 2017 Valentina project
+ ** All Rights Reserved.
+ **
+ ** Valentina is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Valentina is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with Valentina. If not, see .
+ **
+ *************************************************************************/
+
+#include "showdoublelabel.h"
+
+#include
+
+#include "../ifc/xml/vabstractpattern.h"
+#include "../vmisc/logging.h"
+#include "../vwidgets/vmaingraphicsview.h"
+#include "../vmisc/vabstractapplication.h"
+#include "../vtools/tools/drawTools/vdrawtool.h"
+
+//---------------------------------------------------------------------------------------------------------------------
+ShowDoubleLabel::ShowDoubleLabel(VAbstractPattern *doc, quint32 toolId, quint32 pointId, bool visible,
+ ShowDoublePoint type, QUndoCommand *parent)
+ : VUndoCommand(QDomElement(), doc, parent),
+ m_visible(visible),
+ m_oldVisible(not visible),
+ m_scene(qApp->getCurrentScene()),
+ m_type(type),
+ m_idTool(toolId)
+{
+ nodeId = pointId;
+ qCDebug(vUndo, "Point id %u", nodeId);
+
+ if (type == ShowDoublePoint::FirstPoint)
+ {
+ setText(tr("show the first dart label"));
+ }
+ else
+ {
+ setText(tr("show the second dart label"));
+ }
+
+ const QDomElement domElement = doc->elementById(m_idTool, VAbstractPattern::TagPoint);
+ if (domElement.isElement())
+ {
+ if (type == ShowDoublePoint::FirstPoint)
+ {
+ m_oldVisible = doc->GetParametrBool(domElement, AttrShowLabel1, trueStr);
+ }
+ else
+ {
+ m_oldVisible = doc->GetParametrBool(domElement, AttrShowLabel2, trueStr);
+ }
+ }
+ else
+ {
+ qCDebug(vUndo, "Can't find point with id = %u.", m_idTool);
+ }
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void ShowDoubleLabel::undo()
+{
+ qCDebug(vUndo, "Undo.");
+
+ Do(m_oldVisible);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void ShowDoubleLabel::redo()
+{
+ qCDebug(vUndo, "Redo.");
+
+ Do(m_visible);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void ShowDoubleLabel::Do(bool visible)
+{
+ QDomElement domElement = doc->elementById(m_idTool, VAbstractPattern::TagPoint);
+ if (domElement.isElement())
+ {
+ if (m_type == ShowDoublePoint::FirstPoint)
+ {
+ doc->SetAttribute(domElement, AttrShowLabel1, visible);
+ }
+ else
+ {
+ doc->SetAttribute(domElement, AttrShowLabel2, visible);
+ }
+
+ if (VDrawTool *tool = qobject_cast(VAbstractPattern::getTool(m_idTool)))
+ {
+ tool->SetLabelVisible(nodeId, visible);
+ }
+ VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
+ }
+ else
+ {
+ qCDebug(vUndo, "Can't find point with id = %u.", m_idTool);
+ }
+}
+
diff --git a/src/libs/vtools/undocommands/label/showdoublelabel.h b/src/libs/vtools/undocommands/label/showdoublelabel.h
new file mode 100644
index 000000000..0d2309e78
--- /dev/null
+++ b/src/libs/vtools/undocommands/label/showdoublelabel.h
@@ -0,0 +1,59 @@
+/************************************************************************
+ **
+ ** @file
+ ** @author Roman Telezhynskyi
+ ** @date 20 9, 2017
+ **
+ ** @brief
+ ** @copyright
+ ** This source code is part of the Valentine project, a pattern making
+ ** program, whose allow create and modeling patterns of clothing.
+ ** Copyright (C) 2017 Valentina project
+ ** All Rights Reserved.
+ **
+ ** Valentina is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Valentina is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with Valentina. If not, see .
+ **
+ *************************************************************************/
+
+#ifndef SHOWDOUBLELABEL_H
+#define SHOWDOUBLELABEL_H
+
+#include "../vundocommand.h"
+
+class QGraphicsScene;
+
+enum class ShowDoublePoint: char { FirstPoint, SecondPoint };
+
+class ShowDoubleLabel : public VUndoCommand
+{
+public:
+ ShowDoubleLabel(VAbstractPattern *doc, quint32 toolId, quint32 pointId, bool visible, ShowDoublePoint type,
+ QUndoCommand *parent = nullptr);
+ virtual ~ShowDoubleLabel()=default;
+
+ virtual void undo() Q_DECL_OVERRIDE;
+ virtual void redo() Q_DECL_OVERRIDE;
+private:
+ Q_DISABLE_COPY(ShowDoubleLabel)
+ bool m_visible;
+ bool m_oldVisible;
+ //Need for resizing scene rect
+ QGraphicsScene *m_scene;
+ ShowDoublePoint m_type;
+ quint32 m_idTool;
+
+ void Do(bool visible);
+};
+
+#endif // SHOWDOUBLELABEL_H
diff --git a/src/libs/vtools/undocommands/label/showlabel.cpp b/src/libs/vtools/undocommands/label/showlabel.cpp
index 485099147..179681e61 100644
--- a/src/libs/vtools/undocommands/label/showlabel.cpp
+++ b/src/libs/vtools/undocommands/label/showlabel.cpp
@@ -80,13 +80,13 @@ void ShowLabel::Do(bool visible)
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint);
if (domElement.isElement())
{
- doc->SetAttribute(domElement, AttrShowLabel, QString().setNum(visible));
+ doc->SetAttribute(domElement, AttrShowLabel, visible);
- VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
if (VDrawTool *tool = qobject_cast(VAbstractPattern::getTool(nodeId)))
{
tool->SetLabelVisible(nodeId, visible);
}
+ VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
}
else
{
diff --git a/src/libs/vtools/undocommands/label/showlabel.h b/src/libs/vtools/undocommands/label/showlabel.h
index 540b43c0a..f9562b0ad 100644
--- a/src/libs/vtools/undocommands/label/showlabel.h
+++ b/src/libs/vtools/undocommands/label/showlabel.h
@@ -36,8 +36,7 @@ class QGraphicsScene;
class ShowLabel : public VUndoCommand
{
public:
- ShowLabel(VAbstractPattern *doc, quint32 id, bool visible,
- QUndoCommand *parent = nullptr);
+ ShowLabel(VAbstractPattern *doc, quint32 id, bool visible, QUndoCommand *parent = nullptr);
virtual ~ShowLabel()=default;
virtual void undo() Q_DECL_OVERRIDE;
diff --git a/src/libs/vtools/undocommands/undocommands.pri b/src/libs/vtools/undocommands/undocommands.pri
index 731009a06..d689b7c92 100644
--- a/src/libs/vtools/undocommands/undocommands.pri
+++ b/src/libs/vtools/undocommands/undocommands.pri
@@ -25,7 +25,8 @@ HEADERS += \
$$PWD/savepieceoptions.h \
$$PWD/togglepieceinlayout.h \
$$PWD/savepiecepathoptions.h \
- $$PWD/label/showlabel.h
+ $$PWD/label/showlabel.h \
+ $$PWD/label/showdoublelabel.h
SOURCES += \
$$PWD/addtocalc.cpp \
@@ -51,4 +52,5 @@ SOURCES += \
$$PWD/savepieceoptions.cpp \
$$PWD/togglepieceinlayout.cpp \
$$PWD/savepiecepathoptions.cpp \
- $$PWD/label/showlabel.cpp
+ $$PWD/label/showlabel.cpp \
+ $$PWD/label/showdoublelabel.cpp