Added support for tool True Darts.
--HG-- branch : feature
This commit is contained in:
parent
795438c202
commit
7864ae9572
|
@ -2186,10 +2186,12 @@ void VPattern::ParseToolTrueDarts(VMainGraphicsScene *scene, const QDomElement &
|
||||||
initData.name1 = GetParametrString(domElement, AttrName1, "A");
|
initData.name1 = GetParametrString(domElement, AttrName1, "A");
|
||||||
initData.mx1 = qApp->toPixel(GetParametrDouble(domElement, AttrMx1, "10.0"));
|
initData.mx1 = qApp->toPixel(GetParametrDouble(domElement, AttrMx1, "10.0"));
|
||||||
initData.my1 = qApp->toPixel(GetParametrDouble(domElement, AttrMy1, "15.0"));
|
initData.my1 = qApp->toPixel(GetParametrDouble(domElement, AttrMy1, "15.0"));
|
||||||
|
initData.showLabel1 = GetParametrBool(domElement, AttrShowLabel1, trueStr);
|
||||||
|
|
||||||
initData.name2 = GetParametrString(domElement, AttrName2, "A");
|
initData.name2 = GetParametrString(domElement, AttrName2, "A");
|
||||||
initData.mx2 = qApp->toPixel(GetParametrDouble(domElement, AttrMx2, "10.0"));
|
initData.mx2 = qApp->toPixel(GetParametrDouble(domElement, AttrMx2, "10.0"));
|
||||||
initData.my2 = qApp->toPixel(GetParametrDouble(domElement, AttrMy2, "15.0"));
|
initData.my2 = qApp->toPixel(GetParametrDouble(domElement, AttrMy2, "15.0"));
|
||||||
|
initData.showLabel2 = GetParametrBool(domElement, AttrShowLabel2, trueStr);
|
||||||
|
|
||||||
VToolTrueDarts::Create(initData);
|
VToolTrueDarts::Create(initData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,8 @@ const QString AttrInLayout = QStringLiteral("inLayout");
|
||||||
const QString AttrRotationAngle = QStringLiteral("rotationAngle");
|
const QString AttrRotationAngle = QStringLiteral("rotationAngle");
|
||||||
const QString AttrClosed = QStringLiteral("closed");
|
const QString AttrClosed = QStringLiteral("closed");
|
||||||
const QString AttrShowLabel = QStringLiteral("showLabel");
|
const QString AttrShowLabel = QStringLiteral("showLabel");
|
||||||
|
const QString AttrShowLabel1 = QStringLiteral("showLabel1");
|
||||||
|
const QString AttrShowLabel2 = QStringLiteral("showLabel2");
|
||||||
|
|
||||||
const QString TypeLineNone = QStringLiteral("none");
|
const QString TypeLineNone = QStringLiteral("none");
|
||||||
const QString TypeLineLine = QStringLiteral("hair");
|
const QString TypeLineLine = QStringLiteral("hair");
|
||||||
|
|
|
@ -142,6 +142,8 @@ extern const QString AttrIdObject;
|
||||||
extern const QString AttrInLayout;
|
extern const QString AttrInLayout;
|
||||||
extern const QString AttrClosed;
|
extern const QString AttrClosed;
|
||||||
extern const QString AttrShowLabel;
|
extern const QString AttrShowLabel;
|
||||||
|
extern const QString AttrShowLabel1;
|
||||||
|
extern const QString AttrShowLabel2;
|
||||||
|
|
||||||
extern const QString TypeLineNone;
|
extern const QString TypeLineNone;
|
||||||
extern const QString TypeLineLine;
|
extern const QString TypeLineLine;
|
||||||
|
|
|
@ -217,6 +217,8 @@
|
||||||
<xs:attribute name="baseLineP1" type="xs:unsignedInt"/>
|
<xs:attribute name="baseLineP1" type="xs:unsignedInt"/>
|
||||||
<xs:attribute name="baseLineP2" type="xs:unsignedInt"/>
|
<xs:attribute name="baseLineP2" type="xs:unsignedInt"/>
|
||||||
<xs:attribute name="showLabel" type="xs:boolean"/>
|
<xs:attribute name="showLabel" type="xs:boolean"/>
|
||||||
|
<xs:attribute name="showLabel1" type="xs:boolean"/>
|
||||||
|
<xs:attribute name="showLabel2" type="xs:boolean"/>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
|
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include "../../../../undocommands/label/movedoublelabel.h"
|
#include "../../../../undocommands/label/movedoublelabel.h"
|
||||||
|
#include "../../../../undocommands/label/showdoublelabel.h"
|
||||||
#include "../ifc/exception/vexception.h"
|
#include "../ifc/exception/vexception.h"
|
||||||
#include "../ifc/exception/vexceptionbadid.h"
|
#include "../ifc/exception/vexceptionbadid.h"
|
||||||
#include "../ifc/xml/vabstractpattern.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<VPointF>(p1id)->IsShowLabel();
|
||||||
|
}
|
||||||
|
else if (p2id == id)
|
||||||
|
{
|
||||||
|
return VAbstractTool::data.GeometricObject<VPointF>(p2id)->IsShowLabel();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolDoublePoint::SetLabelVisible(quint32 id, bool visible)
|
||||||
|
{
|
||||||
|
if (p1id == id)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(p1id);
|
||||||
|
point->SetShowLabel(visible);
|
||||||
|
firstPoint->RefreshPointGeometry(*point);
|
||||||
|
}
|
||||||
|
else if (p2id == id)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(p2id);
|
||||||
|
point->SetShowLabel(visible);
|
||||||
|
secondPoint->RefreshPointGeometry(*point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolDoublePoint::Label1ChangePosition(const QPointF &pos)
|
void VToolDoublePoint::Label1ChangePosition(const QPointF &pos)
|
||||||
{
|
{
|
||||||
|
@ -248,7 +283,7 @@ void VToolDoublePoint::UpdateNamePosition(quint32 id)
|
||||||
{
|
{
|
||||||
const VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
|
const VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(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);
|
connect(moveLabel, &MoveDoubleLabel::ChangePosition, this, &VToolDoublePoint::DoChangePosition);
|
||||||
qApp->getUndoStack()->push(moveLabel);
|
qApp->getUndoStack()->push(moveLabel);
|
||||||
}
|
}
|
||||||
|
@ -256,7 +291,7 @@ void VToolDoublePoint::UpdateNamePosition(quint32 id)
|
||||||
{
|
{
|
||||||
const VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id).data();
|
const VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(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);
|
connect(moveLabel, &MoveDoubleLabel::ChangePosition, this, &VToolDoublePoint::DoChangePosition);
|
||||||
qApp->getUndoStack()->push(moveLabel);
|
qApp->getUndoStack()->push(moveLabel);
|
||||||
}
|
}
|
||||||
|
@ -324,38 +359,43 @@ void VToolDoublePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &o
|
||||||
{
|
{
|
||||||
VDrawTool::SaveOptions(tag, obj);
|
VDrawTool::SaveOptions(tag, obj);
|
||||||
|
|
||||||
|
auto SavePoint1 = [this](QDomElement &tag, const QSharedPointer<VPointF> &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<bool>(tag, AttrShowLabel1, point->IsShowLabel());
|
||||||
|
};
|
||||||
|
|
||||||
|
auto SavePoint2 = [this](QDomElement &tag, const QSharedPointer<VPointF> &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<bool>(tag, AttrShowLabel2, point->IsShowLabel());
|
||||||
|
};
|
||||||
|
|
||||||
if (obj->id() == p1id)
|
if (obj->id() == p1id)
|
||||||
{
|
{
|
||||||
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
|
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
|
||||||
SCASSERT(point.isNull() == false)
|
SCASSERT(point.isNull() == false)
|
||||||
|
|
||||||
doc->SetAttribute(tag, AttrName1, point->name());
|
SavePoint1(tag, point);
|
||||||
doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(point->mx()));
|
|
||||||
doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(point->my()));
|
|
||||||
}
|
}
|
||||||
else if (obj->id() == p2id)
|
else if (obj->id() == p2id)
|
||||||
{
|
{
|
||||||
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
|
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
|
||||||
SCASSERT(point.isNull() == false)
|
SCASSERT(point.isNull() == false)
|
||||||
|
|
||||||
doc->SetAttribute(tag, AttrName2, point->name());
|
SavePoint2(tag, point);
|
||||||
doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(point->mx()));
|
|
||||||
doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(point->my()));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
|
|
||||||
VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id).data();
|
|
||||||
|
|
||||||
doc->SetAttribute(tag, AttrPoint1, p1id);
|
doc->SetAttribute(tag, AttrPoint1, p1id);
|
||||||
doc->SetAttribute(tag, AttrName1, p1->name());
|
SavePoint1(tag, VAbstractTool::data.GeometricObject<VPointF>(p1id));
|
||||||
doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(p1->mx()));
|
|
||||||
doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(p1->my()));
|
|
||||||
|
|
||||||
doc->SetAttribute(tag, AttrPoint2, p2id);
|
doc->SetAttribute(tag, AttrPoint2, p2id);
|
||||||
doc->SetAttribute(tag, AttrName2, p2->name());
|
SavePoint2(tag, VAbstractTool::data.GeometricObject<VPointF>(p2id));
|
||||||
doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(p2->mx()));
|
|
||||||
doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(p2->my()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,6 +408,19 @@ void VToolDoublePoint::AddToFile()
|
||||||
AddToCalculation(domElement);
|
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
|
QString VToolDoublePoint::ComplexToolTip(quint32 itemId) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,6 +63,9 @@ public:
|
||||||
void setNameP2(const QString &name);
|
void setNameP2(const QString &name);
|
||||||
|
|
||||||
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
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:
|
public slots:
|
||||||
void Label1ChangePosition(const QPointF &pos);
|
void Label1ChangePosition(const QPointF &pos);
|
||||||
void Label2ChangePosition(const QPointF &pos);
|
void Label2ChangePosition(const QPointF &pos);
|
||||||
|
@ -93,6 +96,7 @@ protected:
|
||||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||||
virtual void AddToFile() Q_DECL_OVERRIDE;
|
virtual void AddToFile() Q_DECL_OVERRIDE;
|
||||||
|
virtual void ChangeLabelVisibility(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
QString ComplexToolTip(quint32 itemId) const;
|
QString ComplexToolTip(quint32 itemId) const;
|
||||||
|
|
||||||
|
|
|
@ -154,20 +154,22 @@ VToolTrueDarts *VToolTrueDarts::Create(VToolTrueDartsInitData initData)
|
||||||
static_cast<QPointF>(*dartP1), static_cast<QPointF>(*dartP2),
|
static_cast<QPointF>(*dartP1), static_cast<QPointF>(*dartP2),
|
||||||
static_cast<QPointF>(*dartP3), fPoint1, fPoint2);
|
static_cast<QPointF>(*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)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
initData.id = VContainer::getNextId();//Just reserve id for tool
|
initData.id = VContainer::getNextId();//Just reserve id for tool
|
||||||
initData.p1id = initData.data->AddGObject(new VPointF(fPoint1, initData.name1, initData.mx1, initData.my1,
|
initData.p1id = initData.data->AddGObject(p1);
|
||||||
initData.id));
|
initData.p2id = initData.data->AddGObject(p2);
|
||||||
initData.p2id = initData.data->AddGObject(new VPointF(fPoint2, initData.name2, initData.mx2, initData.my2,
|
|
||||||
initData.id));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
initData.data->UpdateGObject(initData.p1id, new VPointF(fPoint1, initData.name1, initData.mx1, initData.my1,
|
initData.data->UpdateGObject(initData.p1id, p1);
|
||||||
initData.id));
|
initData.data->UpdateGObject(initData.p2id, p2);
|
||||||
initData.data->UpdateGObject(initData.p2id, new VPointF(fPoint2, initData.name2, initData.mx2, initData.my2,
|
|
||||||
initData.id));
|
|
||||||
if (initData.parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
|
|
|
@ -58,9 +58,11 @@ struct VToolTrueDartsInitData : public VAbstractToolInitData
|
||||||
name1(),
|
name1(),
|
||||||
mx1(10),
|
mx1(10),
|
||||||
my1(15),
|
my1(15),
|
||||||
|
showLabel1(true),
|
||||||
name2(),
|
name2(),
|
||||||
mx2(10),
|
mx2(10),
|
||||||
my2(15)
|
my2(15),
|
||||||
|
showLabel2(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
quint32 p1id;
|
quint32 p1id;
|
||||||
|
@ -71,11 +73,13 @@ struct VToolTrueDartsInitData : public VAbstractToolInitData
|
||||||
quint32 dartP2Id;
|
quint32 dartP2Id;
|
||||||
quint32 dartP3Id;
|
quint32 dartP3Id;
|
||||||
QString name1;
|
QString name1;
|
||||||
qreal mx1;
|
qreal mx1;
|
||||||
qreal my1;
|
qreal my1;
|
||||||
|
bool showLabel1;
|
||||||
QString name2;
|
QString name2;
|
||||||
qreal mx2;
|
qreal mx2;
|
||||||
qreal my2;
|
qreal my2;
|
||||||
|
bool showLabel2;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VToolTrueDarts : public VToolDoublePoint
|
class VToolTrueDarts : public VToolDoublePoint
|
||||||
|
|
|
@ -311,7 +311,7 @@ void VToolSinglePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &o
|
||||||
doc->SetAttribute(tag, AttrName, point->name());
|
doc->SetAttribute(tag, AttrName, point->name());
|
||||||
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
|
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
|
||||||
doc->SetAttribute(tag, AttrShowLabel, point->IsShowLabel());
|
doc->SetAttribute<bool>(tag, AttrShowLabel, point->IsShowLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -104,7 +104,7 @@ protected:
|
||||||
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
|
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
|
||||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||||
virtual void ChangeLabelVisibility(quint32 id, bool visible);
|
virtual void ChangeLabelVisibility(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolSinglePoint)
|
Q_DISABLE_COPY(VToolSinglePoint)
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,13 +39,13 @@
|
||||||
#include "moveabstractlabel.h"
|
#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)
|
quint32 toolId, quint32 pointId, QUndoCommand *parent)
|
||||||
: MoveAbstractLabel(doc, pointId, x, y, parent),
|
: MoveAbstractLabel(doc, pointId, x, y, parent),
|
||||||
m_type(type),
|
m_type(type),
|
||||||
m_idTool(toolId)
|
m_idTool(toolId)
|
||||||
{
|
{
|
||||||
if (type == DoublePoint::FirstPoint)
|
if (type == MoveDoublePoint::FirstPoint)
|
||||||
{
|
{
|
||||||
setText(tr("move the first dart label"));
|
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);
|
const QDomElement domElement = doc->elementById(m_idTool, VAbstractPattern::TagPoint);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
if (type == DoublePoint::FirstPoint)
|
if (type == MoveDoublePoint::FirstPoint)
|
||||||
{
|
{
|
||||||
m_oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx1, "0.0"));
|
m_oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx1, "0.0"));
|
||||||
m_oldMy = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMy1, "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_newMx = moveCommand->GetNewMx();
|
||||||
m_newMy = moveCommand->GetNewMy();
|
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 Mx1 %f", m_newMx);
|
||||||
qCDebug(vUndo, "Label new My1 %f", m_newMy);
|
qCDebug(vUndo, "Label new My1 %f", m_newMy);
|
||||||
|
@ -122,7 +122,7 @@ int MoveDoubleLabel::id() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveDoubleLabel::Do(double mx, double my)
|
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 mx1 %f", mx);
|
||||||
qCDebug(vUndo, "New my1 %f", my);
|
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);
|
QDomElement domElement = doc->elementById(m_idTool, VAbstractPattern::TagPoint);
|
||||||
if (domElement.isElement())
|
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, AttrMx1, QString().setNum(qApp->fromPixel(mx)));
|
||||||
doc->SetAttribute(domElement, AttrMy1, QString().setNum(qApp->fromPixel(my)));
|
doc->SetAttribute(domElement, AttrMy1, QString().setNum(qApp->fromPixel(my)));
|
||||||
|
|
|
@ -37,13 +37,13 @@
|
||||||
|
|
||||||
#include "moveabstractlabel.h"
|
#include "moveabstractlabel.h"
|
||||||
|
|
||||||
enum class DoublePoint: char { FirstPoint, SecondPoint };
|
enum class MoveDoublePoint: char { FirstPoint, SecondPoint };
|
||||||
|
|
||||||
class MoveDoubleLabel : public MoveAbstractLabel
|
class MoveDoubleLabel : public MoveAbstractLabel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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);
|
quint32 toolId, quint32 pointId, QUndoCommand *parent = nullptr);
|
||||||
virtual ~MoveDoubleLabel() Q_DECL_OVERRIDE;
|
virtual ~MoveDoubleLabel() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
@ -51,17 +51,17 @@ public:
|
||||||
virtual int id() const Q_DECL_OVERRIDE;
|
virtual int id() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
quint32 GetToolId() const;
|
quint32 GetToolId() const;
|
||||||
DoublePoint GetPointType() const;
|
MoveDoublePoint GetPointType() const;
|
||||||
protected:
|
protected:
|
||||||
virtual void Do(double mx, double my) Q_DECL_OVERRIDE;
|
virtual void Do(double mx, double my) Q_DECL_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(MoveDoubleLabel)
|
Q_DISABLE_COPY(MoveDoubleLabel)
|
||||||
DoublePoint m_type;
|
MoveDoublePoint m_type;
|
||||||
quint32 m_idTool;
|
quint32 m_idTool;
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline DoublePoint MoveDoubleLabel::GetPointType() const
|
inline MoveDoublePoint MoveDoubleLabel::GetPointType() const
|
||||||
{
|
{
|
||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
|
|
121
src/libs/vtools/undocommands/label/showdoublelabel.cpp
Normal file
121
src/libs/vtools/undocommands/label/showdoublelabel.cpp
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @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
|
||||||
|
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "showdoublelabel.h"
|
||||||
|
|
||||||
|
#include <QDomElement>
|
||||||
|
|
||||||
|
#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<bool>(domElement, AttrShowLabel1, visible);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
doc->SetAttribute<bool>(domElement, AttrShowLabel2, visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VDrawTool *tool = qobject_cast<VDrawTool *>(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
59
src/libs/vtools/undocommands/label/showdoublelabel.h
Normal file
59
src/libs/vtools/undocommands/label/showdoublelabel.h
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @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
|
||||||
|
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#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
|
|
@ -80,13 +80,13 @@ void ShowLabel::Do(bool visible)
|
||||||
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, AttrShowLabel, QString().setNum(visible));
|
doc->SetAttribute<bool>(domElement, AttrShowLabel, visible);
|
||||||
|
|
||||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
|
||||||
if (VDrawTool *tool = qobject_cast<VDrawTool *>(VAbstractPattern::getTool(nodeId)))
|
if (VDrawTool *tool = qobject_cast<VDrawTool *>(VAbstractPattern::getTool(nodeId)))
|
||||||
{
|
{
|
||||||
tool->SetLabelVisible(nodeId, visible);
|
tool->SetLabelVisible(nodeId, visible);
|
||||||
}
|
}
|
||||||
|
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,8 +36,7 @@ class QGraphicsScene;
|
||||||
class ShowLabel : public VUndoCommand
|
class ShowLabel : public VUndoCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ShowLabel(VAbstractPattern *doc, quint32 id, bool visible,
|
ShowLabel(VAbstractPattern *doc, quint32 id, bool visible, QUndoCommand *parent = nullptr);
|
||||||
QUndoCommand *parent = nullptr);
|
|
||||||
virtual ~ShowLabel()=default;
|
virtual ~ShowLabel()=default;
|
||||||
|
|
||||||
virtual void undo() Q_DECL_OVERRIDE;
|
virtual void undo() Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -25,7 +25,8 @@ HEADERS += \
|
||||||
$$PWD/savepieceoptions.h \
|
$$PWD/savepieceoptions.h \
|
||||||
$$PWD/togglepieceinlayout.h \
|
$$PWD/togglepieceinlayout.h \
|
||||||
$$PWD/savepiecepathoptions.h \
|
$$PWD/savepiecepathoptions.h \
|
||||||
$$PWD/label/showlabel.h
|
$$PWD/label/showlabel.h \
|
||||||
|
$$PWD/label/showdoublelabel.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/addtocalc.cpp \
|
$$PWD/addtocalc.cpp \
|
||||||
|
@ -51,4 +52,5 @@ SOURCES += \
|
||||||
$$PWD/savepieceoptions.cpp \
|
$$PWD/savepieceoptions.cpp \
|
||||||
$$PWD/togglepieceinlayout.cpp \
|
$$PWD/togglepieceinlayout.cpp \
|
||||||
$$PWD/savepiecepathoptions.cpp \
|
$$PWD/savepiecepathoptions.cpp \
|
||||||
$$PWD/label/showlabel.cpp
|
$$PWD/label/showlabel.cpp \
|
||||||
|
$$PWD/label/showdoublelabel.cpp
|
||||||
|
|
Loading…
Reference in New Issue
Block a user