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:
Manuel Dobusch
2014-07-17 12:19:28 +02:00
parent 2c9c83d003
commit 7157f0d127
11 changed files with 228 additions and 88 deletions
+48 -12
View File
@@ -289,9 +289,9 @@ std::vector<Id> Storage::getIdsOfNeighbours(const Id id) const
return result;
}
std::vector<std::pair<Id, Id>> Storage::getNeighbourEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> Storage::getNeighbourEdgesOfNode(const Id id) const
{
std::vector<std::pair<Id, Id>> result;
std::vector<std::tuple<Id, Id, Id>> result;
Node* node = m_graph.findNode([&](Node* node){
return node->getId() == id;
@@ -302,7 +302,7 @@ std::vector<std::pair<Id, Id>> Storage::getNeighbourEdgesOfNode(const Id id) con
node->forEachEdge(
[&result](Edge* e)
{
result.push_back(std::pair<Id, Id>(e->getFrom()->getId(), e->getTo()->getId()));
result.push_back(std::tuple<Id, Id, Id>(e->getFrom()->getId(), e->getTo()->getId(), e->getId()));
}
);
}
@@ -310,36 +310,72 @@ std::vector<std::pair<Id, Id>> Storage::getNeighbourEdgesOfNode(const Id id) con
return result;
}
std::vector<std::pair<Id, Id>> Storage::getMemberEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> Storage::getMemberEdgesOfNode(const Id id) const
{
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_MEMBER);
}
std::vector<std::pair<Id, Id>> Storage::getUsageEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> Storage::getUsageEdgesOfNode(const Id id) const
{
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_USAGE);
}
std::vector<std::pair<Id, Id>> Storage::getCallEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> Storage::getCallEdgesOfNode(const Id id) const
{
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_CALL);
}
std::vector<std::pair<Id, Id>> Storage::getTypeOfEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> Storage::getTypeOfEdgesOfNode(const Id id) const
{
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_TYPE_OF);
}
std::vector<std::pair<Id, Id>> Storage::getReturnTypeOfEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> Storage::getReturnTypeOfEdgesOfNode(const Id id) const
{
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_RETURN_TYPE_OF);
}
std::vector<std::pair<Id, Id>> Storage::getParameterOfEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> Storage::getParameterOfEdgesOfNode(const Id id) const
{
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_PARAMETER_TYPE_OF);
}
std::vector<std::tuple<Id, Id, Id>> Storage::getInheritanceEdgesOfNode(const Id id) const
{
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_INHERITANCE);
}
std::pair<Id, Id> Storage::getNodesOfEdge(const Id id) const
{
std::pair<Id, Id> result;
Edge* edge = m_graph.findEdge([&](Edge* edge){
return edge->getId() == id;
});
if(edge != NULL)
{
result.first = edge->getFrom()->getId();
result.second = edge->getTo()->getId();
}
return result;
}
bool Storage::checkTokenIsNode(const Id id) const
{
Token* token = m_graph.findToken([&](Token* token){
return token->getId() == id;
});
if(token != NULL)
{
return token->isNode();
}
return false;
}
TokenLocationCollection Storage::getTokenLocationsForTokenId(Id id) const
{
TokenLocationCollection ret;
@@ -461,9 +497,9 @@ void Storage::log(std::string type, std::string str, const ParseLocation& locati
LOG_INFO(info.str());
}
std::vector<std::pair<Id, Id>> Storage::getEdgesOfTypeOfNode(const Id id, const Edge::EdgeType type) const
std::vector<std::tuple<Id, Id, Id>> Storage::getEdgesOfTypeOfNode(const Id id, const Edge::EdgeType type) const
{
std::vector<std::pair<Id, Id>> result;
std::vector<std::tuple<Id, Id, Id>> result;
Node* node = m_graph.findNode([&](Node* node){
return node->getId() == id;
@@ -476,7 +512,7 @@ std::vector<std::pair<Id, Id>> Storage::getEdgesOfTypeOfNode(const Id id, const
{
if(e->getType() == type)
{
result.push_back(std::pair<Id, Id>(e->getFrom()->getId(), e->getTo()->getId()));
result.push_back(std::tuple<Id, Id, Id>(e->getFrom()->getId(), e->getTo()->getId(), e->getId()));
}
}
);
+13 -8
View File
@@ -62,13 +62,18 @@ public:
virtual std::string getNameForNodeWithId(Id id) const;
virtual std::vector<std::string> getNamesForNodesWithNamePrefix(const std::string& prefix) const;
virtual std::vector<Id> getIdsOfNeighbours(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getNeighbourEdgesOfNode(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getMemberEdgesOfNode(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getUsageEdgesOfNode(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getCallEdgesOfNode(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getTypeOfEdgesOfNode(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getReturnTypeOfEdgesOfNode(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getParameterOfEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getNeighbourEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getMemberEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getUsageEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getCallEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getTypeOfEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getReturnTypeOfEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getParameterOfEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getInheritanceEdgesOfNode(const Id id) const;
virtual std::pair<Id, Id> getNodesOfEdge(const Id id) const;
virtual bool checkTokenIsNode(const Id id) const;
// LocationAccess implementation
virtual TokenLocationCollection getTokenLocationsForTokenId(Id locationId) const;
@@ -84,7 +89,7 @@ private:
void log(std::string type, std::string str, const ParseLocation& location) const;
std::vector<std::pair<Id, Id>> getEdgesOfTypeOfNode(const Id id, const Edge::EdgeType type) const;
std::vector<std::tuple<Id, Id, Id>> getEdgesOfTypeOfNode(const Id id, const Edge::EdgeType type) const;
Graph m_graph;
TokenLocationCollection m_locationCollection;
+12 -7
View File
@@ -18,13 +18,18 @@ public:
virtual std::string getNameForNodeWithId(Id id) const = 0;
virtual std::vector<std::string> getNamesForNodesWithNamePrefix(const std::string& prefix) const = 0;
virtual std::vector<Id> getIdsOfNeighbours(const Id id) const = 0;
virtual std::vector<std::pair<Id, Id>> getNeighbourEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::pair<Id, Id>> getMemberEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::pair<Id, Id>> getUsageEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::pair<Id, Id>> getCallEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::pair<Id, Id>> getTypeOfEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::pair<Id, Id>> getReturnTypeOfEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::pair<Id, Id>> getParameterOfEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::tuple<Id, Id, Id>> getNeighbourEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::tuple<Id, Id, Id>> getMemberEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::tuple<Id, Id, Id>> getUsageEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::tuple<Id, Id, Id>> getCallEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::tuple<Id, Id, Id>> getTypeOfEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::tuple<Id, Id, Id>> getReturnTypeOfEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::tuple<Id, Id, Id>> getParameterOfEdgesOfNode(const Id id) const = 0;
virtual std::vector<std::tuple<Id, Id, Id>> getInheritanceEdgesOfNode(const Id id) const = 0;
virtual std::pair<Id, Id> getNodesOfEdge(const Id id) const = 0;
virtual bool checkTokenIsNode(const Id id) const = 0;
};
+44 -14
View File
@@ -67,72 +67,102 @@ std::vector<Id> GraphAccessProxy::getIdsOfNeighbours(const Id id) const
return std::vector<Id>();
}
std::vector<std::pair<Id, Id>> GraphAccessProxy::getNeighbourEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getNeighbourEdgesOfNode(const Id id) const
{
if (hasSubject())
{
return m_subject->getNeighbourEdgesOfNode(id);
}
return std::vector<std::pair<Id, Id>>();
return std::vector<std::tuple<Id, Id, Id>>();
}
std::vector<std::pair<Id, Id>> GraphAccessProxy::getMemberEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getMemberEdgesOfNode(const Id id) const
{
if (hasSubject())
{
return m_subject->getMemberEdgesOfNode(id);
}
return std::vector<std::pair<Id, Id>>();
return std::vector<std::tuple<Id, Id, Id>>();
}
std::vector<std::pair<Id, Id>> GraphAccessProxy::getUsageEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getUsageEdgesOfNode(const Id id) const
{
if (hasSubject())
{
return m_subject->getUsageEdgesOfNode(id);
}
return std::vector<std::pair<Id, Id>>();
return std::vector<std::tuple<Id, Id, Id>>();
}
std::vector<std::pair<Id, Id>> GraphAccessProxy::getCallEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getCallEdgesOfNode(const Id id) const
{
if (hasSubject())
{
return m_subject->getCallEdgesOfNode(id);
}
return std::vector<std::pair<Id, Id>>();
return std::vector<std::tuple<Id, Id, Id>>();
}
std::vector<std::pair<Id, Id>> GraphAccessProxy::getTypeOfEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getTypeOfEdgesOfNode(const Id id) const
{
if (hasSubject())
{
return m_subject->getTypeOfEdgesOfNode(id);
}
return std::vector<std::pair<Id, Id>>();
return std::vector<std::tuple<Id, Id, Id>>();
}
std::vector<std::pair<Id, Id>> GraphAccessProxy::getReturnTypeOfEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getReturnTypeOfEdgesOfNode(const Id id) const
{
if (hasSubject())
{
return m_subject->getReturnTypeOfEdgesOfNode(id);
}
return std::vector<std::pair<Id, Id>>();
return std::vector<std::tuple<Id, Id, Id>>();
}
std::vector<std::pair<Id, Id>> GraphAccessProxy::getParameterOfEdgesOfNode(const Id id) const
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getParameterOfEdgesOfNode(const Id id) const
{
if (hasSubject())
{
return m_subject->getParameterOfEdgesOfNode(id);
}
return std::vector<std::pair<Id, Id>>();
return std::vector<std::tuple<Id, Id, Id>>();
}
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getInheritanceEdgesOfNode(const Id id) const
{
if (hasSubject())
{
return m_subject->getInheritanceEdgesOfNode(id);
}
return std::vector<std::tuple<Id, Id, Id>>();
}
std::pair<Id, Id> GraphAccessProxy::getNodesOfEdge(const Id id) const
{
if (hasSubject())
{
return m_subject->getNodesOfEdge(id);
}
return std::pair<Id, Id>();
}
bool GraphAccessProxy::checkTokenIsNode(const Id id) const
{
if (hasSubject())
{
return m_subject->checkTokenIsNode(id);
}
return false;
}
+12 -7
View File
@@ -17,13 +17,18 @@ public:
virtual std::string getNameForNodeWithId(Id id) const;
virtual std::vector<std::string> getNamesForNodesWithNamePrefix(const std::string& prefix) const;
virtual std::vector<Id> getIdsOfNeighbours(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getNeighbourEdgesOfNode(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getMemberEdgesOfNode(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getUsageEdgesOfNode(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getCallEdgesOfNode(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getTypeOfEdgesOfNode(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getReturnTypeOfEdgesOfNode(const Id id) const;
virtual std::vector<std::pair<Id, Id>> getParameterOfEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getNeighbourEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getMemberEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getUsageEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getCallEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getTypeOfEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getReturnTypeOfEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getParameterOfEdgesOfNode(const Id id) const;
virtual std::vector<std::tuple<Id, Id, Id>> getInheritanceEdgesOfNode(const Id id) const;
virtual std::pair<Id, Id> getNodesOfEdge(const Id id) const;
virtual bool checkTokenIsNode(const Id id) const;
private:
GraphAccess* m_subject;