ui: graph edges clickable
The graph views edges are now clickable. On click the edge and its connected nodes will be displayed. fortune cookie message = Be prepared to accept an exciting opportunity in the future.
This commit is contained in:
@@ -24,6 +24,7 @@ QtGraphView::QtGraphView(ViewLayout* viewLayout)
|
||||
m_edgeColors.push_back(Vec4i(73, 155, 222, 255)); // type
|
||||
m_edgeColors.push_back(Vec4i(231, 65, 65, 255)); // return
|
||||
m_edgeColors.push_back(Vec4i(227, 180, 68, 255)); // parameter
|
||||
m_edgeColors.push_back(Vec4i(113, 96, 191, 255)); // inheritance
|
||||
}
|
||||
|
||||
QtGraphView::~QtGraphView()
|
||||
@@ -240,7 +241,7 @@ std::shared_ptr<QtGraphEdge> QtGraphView::createEdge(QGraphicsView* view, const
|
||||
|
||||
if(owner != NULL && target != NULL)
|
||||
{
|
||||
std::shared_ptr<QtGraphEdge> qtEdge = std::make_shared<QtGraphEdge>(owner, target);
|
||||
std::shared_ptr<QtGraphEdge> qtEdge = std::make_shared<QtGraphEdge>(owner, target, edge.tokenId);
|
||||
|
||||
switch(edge.edgeType)
|
||||
{
|
||||
@@ -259,6 +260,9 @@ std::shared_ptr<QtGraphEdge> QtGraphView::createEdge(QGraphicsView* view, const
|
||||
case Edge::EdgeType::EDGE_PARAMETER_TYPE_OF:
|
||||
qtEdge->setColor(m_edgeColors[4]);
|
||||
break;
|
||||
case Edge::EdgeType::EDGE_INHERITANCE:
|
||||
qtEdge->setColor(m_edgeColors[5]);
|
||||
break;
|
||||
default:
|
||||
qtEdge->setColor(Vec4i(0, 0, 0, 255));
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
|
||||
#include "component/view/graphElements/GraphNode.h"
|
||||
|
||||
QtGraphEdge::QtGraphEdge(const std::weak_ptr<GraphNode>& owner, const std::weak_ptr<GraphNode>& target)
|
||||
: m_owner(owner)
|
||||
QtGraphEdge::QtGraphEdge(const std::weak_ptr<GraphNode>& owner, const std::weak_ptr<GraphNode>& target, const Id id)
|
||||
: GraphEdge(id)
|
||||
, m_owner(owner)
|
||||
, m_target(target)
|
||||
, m_color(0, 0, 0, 0)
|
||||
{
|
||||
@@ -99,3 +100,9 @@ Vec4i QtGraphEdge::getColor() const
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
void QtGraphEdge::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
MessageActivateToken message(m_tokenId);
|
||||
message.dispatch();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "qgraphicsitem.h"
|
||||
|
||||
#include "utility/messaging/type/MessageActivateToken.h"
|
||||
|
||||
#include "component/view/graphElements/GraphEdge.h"
|
||||
|
||||
class GraphNode;
|
||||
@@ -14,7 +16,7 @@ class QtGraphEdge:
|
||||
public QGraphicsLineItem
|
||||
{
|
||||
public:
|
||||
QtGraphEdge(const std::weak_ptr<GraphNode>& owner, const std::weak_ptr<GraphNode>& target);
|
||||
QtGraphEdge(const std::weak_ptr<GraphNode>& owner, const std::weak_ptr<GraphNode>& target, const Id id);
|
||||
virtual ~QtGraphEdge();
|
||||
|
||||
virtual void ownerMoved();
|
||||
@@ -28,6 +30,8 @@ public:
|
||||
virtual void setColor(const Vec4i& color);
|
||||
virtual Vec4i getColor() const;
|
||||
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
|
||||
|
||||
private:
|
||||
std::weak_ptr<GraphNode> m_owner;
|
||||
std::weak_ptr<GraphNode> m_target;
|
||||
|
||||
Reference in New Issue
Block a user