First working result.
Doesn't change file. --HG-- branch : feature
This commit is contained in:
parent
f2d1b4b916
commit
fa74e32769
|
@ -245,21 +245,16 @@ void VContainer::UpdateId(quint32 newId)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief UpdateObject update object in container
|
* @brief UpdateObject update object in container
|
||||||
* @param obj container
|
|
||||||
* @param id id of existing object
|
* @param id id of existing object
|
||||||
* @param point object
|
* @param point object
|
||||||
*/
|
*/
|
||||||
template <typename val>
|
template <typename val>
|
||||||
void VContainer::UpdateObject(QHash<quint32, val> &obj, const quint32 &id, val point)
|
void VContainer::UpdateObject(const quint32 &id, val point)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712
|
Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712
|
||||||
SCASSERT(point.isNull() == false)
|
SCASSERT(point.isNull() == false)
|
||||||
point->setId(id);
|
point->setId(id);
|
||||||
if (d->gObjects.contains(id))
|
d->gObjects.insert(id, point);
|
||||||
{
|
|
||||||
d->gObjects[id].clear();
|
|
||||||
}
|
|
||||||
obj[id] = point;
|
|
||||||
UpdateId(id);
|
UpdateId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,7 +500,14 @@ void VContainer::UpdateGObject(quint32 id, VGObject* obj)
|
||||||
{
|
{
|
||||||
SCASSERT(obj != nullptr)
|
SCASSERT(obj != nullptr)
|
||||||
QSharedPointer<VGObject> pointer(obj);
|
QSharedPointer<VGObject> pointer(obj);
|
||||||
UpdateObject(d->gObjects, id, pointer);
|
UpdateGObject(id, pointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VContainer::UpdateGObject(quint32 id, const QSharedPointer<VGObject> &obj)
|
||||||
|
{
|
||||||
|
SCASSERT(not obj.isNull())
|
||||||
|
UpdateObject(id, obj);
|
||||||
uniqueNames.insert(obj->name());
|
uniqueNames.insert(obj->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,7 @@ public:
|
||||||
void RemovePiece(quint32 id);
|
void RemovePiece(quint32 id);
|
||||||
|
|
||||||
void UpdateGObject(quint32 id, VGObject* obj);
|
void UpdateGObject(quint32 id, VGObject* obj);
|
||||||
|
void UpdateGObject(quint32 id, const QSharedPointer<VGObject> &obj);
|
||||||
void UpdatePiece(quint32 id, const VPiece &detail);
|
void UpdatePiece(quint32 id, const VPiece &detail);
|
||||||
void UpdatePiecePath(quint32 id, const VPiecePath &path);
|
void UpdatePiecePath(quint32 id, const VPiecePath &path);
|
||||||
|
|
||||||
|
@ -220,7 +221,7 @@ private:
|
||||||
const val GetObject(const QHash<key, val> &obj, key id) const;
|
const val GetObject(const QHash<key, val> &obj, key id) const;
|
||||||
|
|
||||||
template <typename val>
|
template <typename val>
|
||||||
void UpdateObject(QHash<quint32, val > &obj, const quint32 &id, val point);
|
void UpdateObject(const quint32 &id, val point);
|
||||||
|
|
||||||
template <typename key, typename val>
|
template <typename key, typename val>
|
||||||
static quint32 AddObject(QHash<key, val> &obj, val value);
|
static quint32 AddObject(QHash<key, val> &obj, val value);
|
||||||
|
|
|
@ -114,6 +114,31 @@ void VToolSinglePoint::GroupVisibility(quint32 object, bool visible)
|
||||||
setVisible(visible);
|
setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VToolSinglePoint::IsLabelVisible(quint32 id) const
|
||||||
|
{
|
||||||
|
if (this->id == id)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||||
|
return point->IsShowLabel();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolSinglePoint::SetLabelVisible(quint32 id, bool visible)
|
||||||
|
{
|
||||||
|
if (this->id == id)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||||
|
point->SetShowLabel(visible);
|
||||||
|
RefreshPointGeometry(*point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief NameChangePosition handle change posion point label.
|
* @brief NameChangePosition handle change posion point label.
|
||||||
|
|
|
@ -63,6 +63,9 @@ public:
|
||||||
void SetEnabled(bool enabled);
|
void SetEnabled(bool enabled);
|
||||||
|
|
||||||
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 NameChangePosition(const QPointF &pos);
|
void NameChangePosition(const QPointF &pos);
|
||||||
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
|
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -210,6 +210,13 @@ void VDrawTool::DetailsMode(bool mode)
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VDrawTool::ChangeLabelVisibility(quint32 id, bool visible)
|
||||||
|
{
|
||||||
|
Q_UNUSED(id)
|
||||||
|
Q_UNUSED(visible)
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief AddToCalculation add tool to calculation tag in pattern file.
|
* @brief AddToCalculation add tool to calculation tag in pattern file.
|
||||||
|
@ -236,3 +243,17 @@ void VDrawTool::SetTypeLine(const QString &value)
|
||||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||||
SaveOption(obj);
|
SaveOption(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VDrawTool::IsLabelVisible(quint32 id) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(id)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VDrawTool::SetLabelVisible(quint32 id, bool visible)
|
||||||
|
{
|
||||||
|
Q_UNUSED(id)
|
||||||
|
Q_UNUSED(visible)
|
||||||
|
}
|
||||||
|
|
|
@ -67,6 +67,9 @@ public:
|
||||||
QString getLineType() const;
|
QString getLineType() const;
|
||||||
virtual void SetTypeLine(const QString &value);
|
virtual void SetTypeLine(const QString &value);
|
||||||
|
|
||||||
|
virtual bool IsLabelVisible(quint32 id) const;
|
||||||
|
virtual void SetLabelVisible(quint32 id, bool visible);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ChangedToolSelection(bool selected, quint32 object, quint32 tool);
|
void ChangedToolSelection(bool selected, quint32 object, quint32 tool);
|
||||||
|
|
||||||
|
@ -79,6 +82,7 @@ public slots:
|
||||||
virtual void DetailsMode(bool mode);
|
virtual void DetailsMode(bool mode);
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID)=0;
|
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID)=0;
|
||||||
|
virtual void ChangeLabelVisibility(quint32 id, bool visible);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
enum class RemoveOption : bool {Disable = false, Enable = true};
|
enum class RemoveOption : bool {Disable = false, Enable = true};
|
||||||
|
@ -209,7 +213,7 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI
|
||||||
}
|
}
|
||||||
else if (selectedAction == actionShowLabel)
|
else if (selectedAction == actionShowLabel)
|
||||||
{
|
{
|
||||||
// do something here to show/hide a label
|
SetLabelVisible(itemId, selectedAction->isChecked());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ VScenePoint::VScenePoint(QGraphicsItem *parent)
|
||||||
m_lineName(nullptr),
|
m_lineName(nullptr),
|
||||||
m_onlyPoint(false),
|
m_onlyPoint(false),
|
||||||
m_isHovered(false),
|
m_isHovered(false),
|
||||||
|
m_showLabel(true),
|
||||||
m_baseColor(Qt::black)
|
m_baseColor(Qt::black)
|
||||||
{
|
{
|
||||||
m_namePoint = new VGraphicsSimpleTextItem(this);
|
m_namePoint = new VGraphicsSimpleTextItem(this);
|
||||||
|
@ -74,7 +75,7 @@ void VScenePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
||||||
|
|
||||||
if (not m_onlyPoint)
|
if (not m_onlyPoint)
|
||||||
{
|
{
|
||||||
m_namePoint->setVisible(true);
|
m_namePoint->setVisible(m_showLabel);
|
||||||
|
|
||||||
QPen lPen = m_lineName->pen();
|
QPen lPen = m_lineName->pen();
|
||||||
lPen.setColor(CorrectColor(m_lineName, Qt::black));
|
lPen.setColor(CorrectColor(m_lineName, Qt::black));
|
||||||
|
@ -94,9 +95,12 @@ void VScenePoint::RefreshPointGeometry(const VPointF &point)
|
||||||
setPos(static_cast<QPointF>(point));
|
setPos(static_cast<QPointF>(point));
|
||||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
|
|
||||||
|
m_showLabel = point.IsShowLabel();
|
||||||
|
|
||||||
m_namePoint->blockSignals(true);
|
m_namePoint->blockSignals(true);
|
||||||
m_namePoint->setText(point.name());
|
m_namePoint->setText(point.name());
|
||||||
m_namePoint->setPos(QPointF(point.mx(), point.my()));
|
m_namePoint->setPos(QPointF(point.mx(), point.my()));
|
||||||
|
m_namePoint->setVisible(m_showLabel);
|
||||||
m_namePoint->blockSignals(false);
|
m_namePoint->blockSignals(false);
|
||||||
|
|
||||||
RefreshLine();
|
RefreshLine();
|
||||||
|
@ -151,7 +155,7 @@ void VScenePoint::RefreshLine()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_lineName->setLine(QLineF(p1, pRec - scenePos()));
|
m_lineName->setLine(QLineF(p1, pRec - scenePos()));
|
||||||
m_lineName->setVisible(true);
|
m_lineName->setVisible(m_showLabel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -55,6 +55,7 @@ protected:
|
||||||
|
|
||||||
bool m_onlyPoint;
|
bool m_onlyPoint;
|
||||||
bool m_isHovered;
|
bool m_isHovered;
|
||||||
|
bool m_showLabel;
|
||||||
|
|
||||||
/** @brief m_baseColor base color of point. */
|
/** @brief m_baseColor base color of point. */
|
||||||
QColor m_baseColor;
|
QColor m_baseColor;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user