ui: graph showing neighbours
The graph view can now display the n1 neighbours of the active node, including connections between neighbours.
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "utility/types.h"
|
||||
|
||||
class GraphNode;
|
||||
|
||||
class GraphEdge
|
||||
@@ -13,20 +15,39 @@ public:
|
||||
|
||||
virtual void ownerMoved() = 0;
|
||||
virtual void targetMoved() = 0;
|
||||
|
||||
virtual void removeEdgeFromScene() = 0;
|
||||
|
||||
virtual std::weak_ptr<GraphNode> getOwner() = 0;
|
||||
virtual std::weak_ptr<GraphNode> getTarget() = 0;
|
||||
};
|
||||
|
||||
// temporary data structure for (visual) graph creation process
|
||||
struct DummyEdge
|
||||
{
|
||||
public:
|
||||
DummyEdge(const std::weak_ptr<GraphNode> o, const std::weak_ptr<GraphNode> t)
|
||||
: owner(o)
|
||||
, target(t)
|
||||
DummyEdge(const Id o, const Id t)
|
||||
: ownerId(o)
|
||||
, targetId(t)
|
||||
{
|
||||
}
|
||||
|
||||
std::weak_ptr<GraphNode> owner;
|
||||
std::weak_ptr<GraphNode> target;
|
||||
Id ownerId;
|
||||
Id targetId;
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // GRAPH_EDGE_H
|
||||
@@ -18,10 +18,12 @@ public:
|
||||
Id getTokenId();
|
||||
virtual Vec2i getPosition() = 0;
|
||||
|
||||
virtual void addOutEdge(const std::shared_ptr<GraphEdge>& edge) = 0;
|
||||
virtual void addInEdge(const std::weak_ptr<GraphEdge>& edge) = 0;
|
||||
virtual bool addOutEdge(const std::shared_ptr<GraphEdge>& edge) = 0;
|
||||
virtual bool addInEdge(const std::weak_ptr<GraphEdge>& edge) = 0;
|
||||
|
||||
virtual void removeOutEdge(const std::shared_ptr<GraphEdge>& edge) = 0;
|
||||
virtual void removeOutEdge(GraphEdge* edge) = 0;
|
||||
|
||||
virtual void addSubNode(const std::shared_ptr<GraphNode>& node) = 0;
|
||||
|
||||
protected:
|
||||
Id m_tokenId;
|
||||
|
||||
Reference in New Issue
Block a user