ui: graph view layouting and member rendering
Added simple layouting functions (implementations for simple grid and circle layout). Also the graph displays class members and connections (edges) to or from them "correctly" now. fortune cookie message = Your exotic ideas will lead you to many exciting new adventures.
This commit is contained in:
@@ -289,7 +289,7 @@ std::vector<Id> Storage::getIdsOfNeighbours(const Id id) const
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> Storage::getConnectedEdges(const Id id) const
|
||||
std::vector<std::pair<Id, Id>> Storage::getNeighbourEdgesOfNode(const Id id) const
|
||||
{
|
||||
std::vector<std::pair<Id, Id>> result;
|
||||
|
||||
@@ -300,7 +300,7 @@ std::vector<std::pair<Id, Id>> Storage::getConnectedEdges(const Id id) const
|
||||
if (node != NULL)
|
||||
{
|
||||
node->forEachEdge(
|
||||
[&result, &id](Edge* e)
|
||||
[&result](Edge* e)
|
||||
{
|
||||
result.push_back(std::pair<Id, Id>(e->getFrom()->getId(), e->getTo()->getId()));
|
||||
}
|
||||
@@ -310,6 +310,36 @@ std::vector<std::pair<Id, Id>> Storage::getConnectedEdges(const Id id) const
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::pair<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
|
||||
{
|
||||
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_USAGE);
|
||||
}
|
||||
|
||||
std::vector<std::pair<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
|
||||
{
|
||||
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_TYPE_OF);
|
||||
}
|
||||
|
||||
std::vector<std::pair<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
|
||||
{
|
||||
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_PARAMETER_TYPE_OF);
|
||||
}
|
||||
|
||||
TokenLocationCollection Storage::getTokenLocationsForTokenId(Id id) const
|
||||
{
|
||||
TokenLocationCollection ret;
|
||||
@@ -430,3 +460,27 @@ void Storage::log(std::string type, std::string str, const ParseLocation& locati
|
||||
info << location.endLineNumber << ":" << location.endColumnNumber << ">";
|
||||
LOG_INFO(info.str());
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> Storage::getEdgesOfTypeOfNode(const Id id, const Edge::EdgeType type) const
|
||||
{
|
||||
std::vector<std::pair<Id, Id>> result;
|
||||
|
||||
Node* node = m_graph.findNode([&](Node* node){
|
||||
return node->getId() == id;
|
||||
});
|
||||
|
||||
if (node != NULL)
|
||||
{
|
||||
node->forEachEdge(
|
||||
[&result, &type](Edge* e)
|
||||
{
|
||||
if(e->getType() == type)
|
||||
{
|
||||
result.push_back(std::pair<Id, Id>(e->getFrom()->getId(), e->getTo()->getId()));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,13 @@ 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>> getConnectedEdges(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;
|
||||
|
||||
// LocationAccess implementation
|
||||
virtual TokenLocationCollection getTokenLocationsForTokenId(Id locationId) const;
|
||||
@@ -78,6 +84,8 @@ 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;
|
||||
|
||||
Graph m_graph;
|
||||
TokenLocationCollection m_locationCollection;
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "utility/types.h"
|
||||
|
||||
class Edge;
|
||||
class Token;
|
||||
|
||||
class GraphAccess
|
||||
@@ -17,7 +18,13 @@ 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>> getConnectedEdges(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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -67,11 +67,71 @@ std::vector<Id> GraphAccessProxy::getIdsOfNeighbours(const Id id) const
|
||||
return std::vector<Id>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getConnectedEdges(const Id id) const
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getNeighbourEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getConnectedEdges(id);
|
||||
return m_subject->getNeighbourEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getMemberEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getMemberEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getUsageEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getUsageEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getCallEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getCallEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getTypeOfEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getTypeOfEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getReturnTypeOfEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getReturnTypeOfEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getParameterOfEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getParameterOfEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
|
||||
@@ -17,7 +17,13 @@ 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>> getConnectedEdges(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;
|
||||
|
||||
private:
|
||||
GraphAccess* m_subject;
|
||||
|
||||
Reference in New Issue
Block a user