ui: graph view edges

Added simple edges to the graph view. Also fixed a memory leak source in QtMainWindow.

fortune cookie message = Good health will be with you.
This commit is contained in:
Manuel Dobusch
2014-07-04 14:11:09 +02:00
parent b1023ba4ac
commit 610aa2eb09
15 changed files with 290 additions and 23 deletions
+2
View File
@@ -25,6 +25,8 @@ add_files(
component/controller/SearchController.cpp
component/controller/SearchController.h
component/view/graphElements/GraphEdge.cpp
component/view/graphElements/GraphEdge.h
component/view/graphElements/GraphNode.cpp
component/view/graphElements/GraphNode.h
+5 -2
View File
@@ -25,9 +25,12 @@ ComponentManager::~ComponentManager()
void ComponentManager::setup()
{
std::shared_ptr<Component> graphComponent = m_componentFactory->createGraphComponent();
GraphView* graphView = graphComponent->getView<GraphView>();
graphView->addNode(Vec2i(-100, -100), "foo");
graphView->addNode(Vec2i(50, 50), "bar");
std::weak_ptr<GraphNode> node0 = graphView->addNode(Vec2i(-50, -50), "foo");
graphView->addEdge(node0, graphView->addNode(Vec2i(100, 100), "bar"));
graphView->addEdge(node0, graphView->addNode(Vec2i(50, -50), "war production co-ordinating commitee"));
m_components.push_back(graphComponent);
std::shared_ptr<Component> codeComponent = m_componentFactory->createCodeComponent();
+12 -1
View File
@@ -1,8 +1,14 @@
#ifndef GRAPH_VIEW_H
#define GRAPH_VIEW_H
#include <list>
#include <memory>
#include "component/view/View.h"
class GraphEdge;
class GraphNode;
class GraphView : public View
{
public:
@@ -11,7 +17,12 @@ public:
virtual std::string getName() const;
virtual void addNode(const Vec2i& position, const std::string& name) = 0;
virtual std::weak_ptr<GraphNode> addNode(const Vec2i& position, const std::string& name) = 0;
virtual void addEdge(const std::weak_ptr<GraphNode>& owner, const std::weak_ptr<GraphNode>& target) = 0;
protected:
std::list<std::shared_ptr<GraphNode> > m_nodes;
std::list<std::weak_ptr<GraphEdge> > m_edges;
};
#endif // GRAPH_VIEW_H
@@ -0,0 +1,9 @@
#include "component/view/graphElements/GraphEdge.h"
GraphEdge::GraphEdge()
{
}
GraphEdge::~GraphEdge()
{
}
@@ -0,0 +1,14 @@
#ifndef GRAPH_EDGE_H
#define GRAPH_EDGE_H
class GraphEdge
{
public:
GraphEdge();
virtual ~GraphEdge();
virtual void ownerMoved() = 0;
virtual void targetMoved() = 0;
};
#endif // GRAPH_EDGE_H
@@ -1,11 +1,22 @@
#ifndef GRAPH_NODE_H
#define GRAPH_NODE_H
#include "utility/math/Vector2.h"
class GraphEdge;
class GraphNode
{
public:
GraphNode();
virtual ~GraphNode();
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 void removeOutEdge(const std::shared_ptr<GraphEdge>& edge) = 0;
};
#endif // GRAPH_NODE_H