Allow a user to select a point covered by visualization.
--HG-- branch : feature
This commit is contained in:
parent
c44a16197b
commit
59c9a0b400
|
@ -92,6 +92,7 @@ VSimplePoint *VisToolPiecePath::GetPoint(quint32 i, const QColor &color)
|
||||||
VSimplePoint *point = new VSimplePoint(NULL_ID, color, *Visualization::data->GetPatternUnit(), &factor);
|
VSimplePoint *point = new VSimplePoint(NULL_ID, color, *Visualization::data->GetPatternUnit(), &factor);
|
||||||
point->SetPointHighlight(true);
|
point->SetPointHighlight(true);
|
||||||
point->setParentItem(this);
|
point->setParentItem(this);
|
||||||
|
point->SetVisualizationMode(true);
|
||||||
m_points.append(point);
|
m_points.append(point);
|
||||||
|
|
||||||
return point;
|
return point;
|
||||||
|
|
|
@ -59,7 +59,8 @@ VSimplePoint::VSimplePoint(quint32 id, const QColor ¤tColor, Unit patternU
|
||||||
namePoint(nullptr),
|
namePoint(nullptr),
|
||||||
lineName(nullptr),
|
lineName(nullptr),
|
||||||
m_onlyPoint(false),
|
m_onlyPoint(false),
|
||||||
m_isHighlight(false)
|
m_isHighlight(false),
|
||||||
|
m_visualizationMode(false)
|
||||||
{
|
{
|
||||||
namePoint = new VGraphicsSimpleTextItem(this);
|
namePoint = new VGraphicsSimpleTextItem(this);
|
||||||
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VSimplePoint::ContextMenu);
|
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VSimplePoint::ContextMenu);
|
||||||
|
@ -92,6 +93,19 @@ bool VSimplePoint::IsOnlyPoint() const
|
||||||
return m_onlyPoint;
|
return m_onlyPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimplePoint::SetVisualizationMode(bool value)
|
||||||
|
{
|
||||||
|
m_visualizationMode = value;
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsFocusable, not m_visualizationMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VSimplePoint::IsVisualizationMode() const
|
||||||
|
{
|
||||||
|
return m_visualizationMode;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSimplePoint::SetPointHighlight(bool value)
|
void VSimplePoint::SetPointHighlight(bool value)
|
||||||
{
|
{
|
||||||
|
@ -208,6 +222,12 @@ void VSimplePoint::ChangedPosition(const QPointF &pos)
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSimplePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void VSimplePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (m_visualizationMode)
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Special for not selectable item first need to call standard mousePressEvent then accept event
|
// Special for not selectable item first need to call standard mousePressEvent then accept event
|
||||||
QGraphicsEllipseItem::mousePressEvent(event);
|
QGraphicsEllipseItem::mousePressEvent(event);
|
||||||
|
@ -219,8 +239,8 @@ void VSimplePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectionType == SelectionType::ByMouseRelease)
|
if (selectionType == SelectionType::ByMouseRelease)
|
||||||
{
|
{// Special for not selectable item first need to call standard mousePressEvent then accept event
|
||||||
event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event
|
event->accept();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -230,9 +250,12 @@ void VSimplePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSimplePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void VSimplePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (not m_visualizationMode)
|
||||||
{
|
{
|
||||||
if (selectionType == SelectionType::ByMouseRelease)
|
if (selectionType == SelectionType::ByMouseRelease)
|
||||||
{
|
{
|
||||||
|
@ -243,6 +266,7 @@ void VSimplePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
}
|
}
|
||||||
QGraphicsEllipseItem::mouseReleaseEvent(event);
|
QGraphicsEllipseItem::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSimplePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void VSimplePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
|
|
@ -65,6 +65,9 @@ public:
|
||||||
void SetOnlyPoint(bool value);
|
void SetOnlyPoint(bool value);
|
||||||
bool IsOnlyPoint() const;
|
bool IsOnlyPoint() const;
|
||||||
|
|
||||||
|
void SetVisualizationMode(bool value);
|
||||||
|
bool IsVisualizationMode() const;
|
||||||
|
|
||||||
void SetPointHighlight(bool value);
|
void SetPointHighlight(bool value);
|
||||||
|
|
||||||
void RefreshLine();
|
void RefreshLine();
|
||||||
|
@ -112,6 +115,7 @@ private:
|
||||||
|
|
||||||
bool m_onlyPoint;
|
bool m_onlyPoint;
|
||||||
bool m_isHighlight;
|
bool m_isHighlight;
|
||||||
|
bool m_visualizationMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VSIMPLEPOINT_H
|
#endif // VSIMPLEPOINT_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user