ui: graphView

Added basic graph view with simple nodes (just text, no edges or anything...)

fortune cookie message = Don't be afraid to take that big step.
This commit is contained in:
Manuel Dobusch
2014-07-02 16:14:56 +02:00
parent 5251e3ecb6
commit a8e32af5dd
16 changed files with 220 additions and 2 deletions
+7 -2
View File
@@ -21,15 +21,20 @@ add_files(
component/controller/Controller.cpp
component/controller/Controller.h
component/view/graphElements/GraphNode.cpp
component/view/graphElements/GraphNode.h
component/view/CodeView.cpp
component/view/CodeView.h
component/view/GraphView.cpp
component/view/GraphView.h
component/view/MainView.cpp
component/view/MainView.h
component/view/View.cpp
component/view/View.h
component/view/ViewLayout.cpp
component/view/ViewLayout.h
component/view/ViewLayout.h
component/Component.cpp
component/Component.h
component/ComponentFactory.cpp
+10
View File
@@ -2,6 +2,7 @@
#include "component/controller/CodeController.h"
#include "component/view/CodeView.h"
#include "component/view/GraphView.h"
#include "component/view/ViewLayout.h"
#include "gui/GuiFactory.h"
@@ -32,6 +33,15 @@ std::shared_ptr<Component> ComponentFactory::createCodeComponent()
return component;
}
std::shared_ptr<Component> ComponentFactory::createGraphComponent()
{
std::shared_ptr<View> view = m_guiFactory->createGraphView(m_viewLayout);
std::shared_ptr<Controller> controller = std::make_shared<CodeController>();
std::shared_ptr<Component> component = std::make_shared<Component>(view, controller);
return component;
}
ComponentFactory::ComponentFactory()
{
}
+1
View File
@@ -22,6 +22,7 @@ public:
~ComponentFactory();
std::shared_ptr<Component> createCodeComponent();
std::shared_ptr<Component> createGraphComponent();
private:
ComponentFactory();
+8
View File
@@ -1,6 +1,7 @@
#include "component/ComponentManager.h"
#include "component/view/CodeView.h"
#include "component/view/GraphView.h"
#include "component/view/ViewLayout.h"
std::shared_ptr<ComponentManager> ComponentManager::create(
@@ -20,6 +21,13 @@ ComponentManager::~ComponentManager()
void ComponentManager::setup()
{
std::shared_ptr<Component> graphComponent = m_componentFactory->createGraphComponent();
GraphView* graphView = dynamic_cast<GraphView*>(graphComponent->getView());
graphView->addNode(Vec2i(-100, -100), "foo");
graphView->addNode(Vec2i(50, 50), "bar");
m_components.push_back(graphComponent);
std::shared_ptr<Component> codeComponent = m_componentFactory->createCodeComponent();
m_components.push_back(codeComponent);
+15
View File
@@ -0,0 +1,15 @@
#include "component/view/GraphView.h"
GraphView::GraphView(ViewLayout* viewLayout)
: View(viewLayout, Vec2i(100, 100))
{
}
GraphView::~GraphView()
{
}
std::string GraphView::getName() const
{
return "GraphView";
}
+17
View File
@@ -0,0 +1,17 @@
#ifndef GRAPH_VIEW_H
#define GRAPH_VIEW_H
#include "component/view/View.h"
class GraphView : public View
{
public:
GraphView(ViewLayout* viewLayout);
virtual ~GraphView();
virtual std::string getName() const;
virtual void addNode(const Vec2i& position, const std::string& name) = 0;
};
#endif // GRAPH_VIEW_H
@@ -0,0 +1,9 @@
#include "component/view/graphElements/GraphNode.h"
GraphNode::GraphNode()
{
}
GraphNode::~GraphNode()
{
}
@@ -0,0 +1,11 @@
#ifndef GRAPH_NODE_H
#define GRAPH_NODE_H
class GraphNode
{
public:
GraphNode();
virtual ~GraphNode();
};
#endif // GRAPH_NODE_H
+2
View File
@@ -4,6 +4,7 @@
#include <memory>
class CodeView;
class GraphView;
class MainView;
class ViewLayout;
@@ -15,6 +16,7 @@ public:
virtual std::shared_ptr<MainView> createMainView() const = 0;
virtual std::shared_ptr<CodeView> createCodeView(ViewLayout* viewLayout) const = 0;
virtual std::shared_ptr<GraphView> createGraphView(ViewLayout* viewLayout) const = 0;
};
#endif // GUI_FACTORY_H