ui: extented graph view ui features

* fitting boxes to name length
* highlighting active edges and nodes
* hover for edges and nodes
* single click selection for edges and nodes
* edges have transparent second line for easier clicking
* sub structure class members by public/protected/private
This commit is contained in:
Eberhard Graether
2014-11-09 05:18:37 +01:00
parent 3441b6a8f4
commit 5b230cefa0
26 changed files with 644 additions and 417 deletions
@@ -1,7 +1,7 @@
#include "component/view/graphElements/GraphEdge.h"
GraphEdge::GraphEdge(const Id tokenId)
: m_tokenId(tokenId)
GraphEdge::GraphEdge(const Edge* data)
: m_data(data)
{
}
@@ -11,5 +11,10 @@ GraphEdge::~GraphEdge()
Id GraphEdge::getTokenId() const
{
return m_tokenId;
return m_data->getId();
}
const Edge* GraphEdge::getData() const
{
return m_data;
}
@@ -12,7 +12,7 @@ class GraphNode;
class GraphEdge
{
public:
GraphEdge(const Id tokenId);
GraphEdge(const Edge* data);
virtual ~GraphEdge();
virtual void ownerMoved() = 0;
@@ -24,63 +24,26 @@ public:
virtual std::weak_ptr<GraphNode> getTarget() = 0;
Id getTokenId() const;
virtual void setColor(const Vec4i& color) = 0;
virtual Vec4i getColor() const = 0;
const Edge* getData() const;
protected:
Id m_tokenId;
const Edge* m_data;
};
// temporary data structure for (visual) graph creation process
struct DummyEdge
{
public:
DummyEdge(const Id o, const Id t, const Id tknId, Edge::EdgeType type)
DummyEdge(const Id o, const Id t, const Edge* data)
: ownerId(o)
, targetId(t)
, tokenId(tknId)
, edgeType(type)
, data(data)
{
}
bool operator==(const DummyEdge& other) const
{
if (ownerId == other.ownerId && targetId == other.targetId)
{
return true;
}
return false;
}
bool operator!=(const DummyEdge& other) const
{
return !(*this == other);
}
bool operator<(const DummyEdge& other) const
{
if (ownerId < other.ownerId )
{
return true;
}
else if (ownerId == other.ownerId)
{
return (targetId < other.targetId);
}
return false;
}
bool operator>(const DummyEdge& other) const
{
return !(*this < other);
}
Id ownerId;
Id targetId;
Id tokenId;
Edge::EdgeType edgeType;
const Edge* data;
};
#endif // GRAPH_EDGE_H
@@ -1,7 +1,7 @@
#include "component/view/graphElements/GraphNode.h"
GraphNode::GraphNode(const Id tokenId)
: m_tokenId(tokenId)
GraphNode::GraphNode(const Node* data)
: m_data(data)
{
}
@@ -11,5 +11,19 @@ GraphNode::~GraphNode()
Id GraphNode::getTokenId() const
{
return m_tokenId;
if (m_data)
{
return m_data->getId();
}
return 0;
}
const Node* GraphNode::getData() const
{
return m_data;
}
void GraphNode::setData(const Node* data)
{
m_data = data;
}
@@ -7,16 +7,23 @@
#include "utility/math/Vector2.h"
#include "utility/types.h"
#include "data/graph/Node.h"
#include "data/graph/token_component/TokenComponentAccess.h"
class GraphEdge;
class GraphNode
{
public:
GraphNode(const Id tokenId);
GraphNode(const Node* data);
virtual ~GraphNode();
virtual std::string getName() const = 0;
Id getTokenId() const;
const Node* getData() const;
void setData(const Node* data);
virtual Vec2i getPosition() const = 0;
virtual void setPosition(const Vec2i& position) = 0;
@@ -44,71 +51,31 @@ public:
virtual unsigned int getOutEdgeCount() const = 0;
virtual unsigned int getInEdgeCount() const = 0;
virtual unsigned int getEdgeCountRecursive() const = 0;
virtual unsigned int getEdgeAndActiveCountRecursive() const = 0;
protected:
Id m_tokenId;
const Node* m_data;
};
struct DummyNode
{
public:
DummyNode(const std::string& n, const Id tId, const Vec2i& p)
: name(n)
, tokenId(tId)
, position(p)
, subNodes()
, actualNode()
DummyNode(const Node* data)
: data(data)
, accessType(TokenComponentAccess::ACCESS_NONE)
{
}
bool operator==(const DummyNode& other) const
DummyNode(TokenComponentAccess::AccessType accessType)
: data(nullptr)
, accessType(accessType)
{
if (tokenId == other.tokenId
&& name == other.name
&& position == position)
{
return true;
}
return false;
}
bool operator!=(const DummyNode& other) const
{
return !(*this == other);
}
const Node* data;
const TokenComponentAccess::AccessType accessType;
bool operator<(const DummyNode& other) const
{
if (tokenId < other.tokenId)
{
return true;
}
return false;
}
bool operator>(const DummyNode& other) const
{
return !(*this < other);
}
DummyNode& operator=(const DummyNode& other)
{
name = other.name;
tokenId = other.tokenId;
position = other.position;
subNodes = other.subNodes;
actualNode = other.actualNode;
return *this;
}
std::string name;
Id tokenId;
Vec2i position;
std::vector<DummyNode> subNodes;
std::weak_ptr<GraphNode> actualNode;
};
#endif // GRAPH_NODE_H