src: refactoring of GraphNode and GraphEdge classes

* common base class QtGraphNode
* derived class QtGraphNodeData for nodes representing the data model
* removed GraphNode and GraphEdge interface classes
* moved and renamed files for DummyNode and DummyEdge
* refactored includes throughout Graph UI related files
This commit is contained in:
Eberhard Graether
2015-05-22 13:54:50 +02:00
parent 1e8d8cece0
commit bd5de1d271
25 changed files with 328 additions and 373 deletions
+2 -5
View File
@@ -35,6 +35,8 @@ add_files(
add_files(
LIB_FILES
component/controller/helper/DummyEdge.h
component/controller/helper/DummyNode.h
component/controller/helper/SnippetMerger.cpp
component/controller/helper/SnippetMerger.h
@@ -55,11 +57,6 @@ add_files(
component/controller/UndoRedoController.cpp
component/controller/UndoRedoController.h
component/view/graphElements/GraphEdge.cpp
component/view/graphElements/GraphEdge.h
component/view/graphElements/GraphNode.cpp
component/view/graphElements/GraphNode.h
component/view/CodeView.cpp
component/view/CodeView.h
component/view/CompositeView.cpp
@@ -4,8 +4,8 @@
#include "utility/logging/logging.h"
#include "component/view/graphElements/GraphEdge.h"
#include "component/view/graphElements/GraphNode.h"
#include "component/controller/helper/DummyEdge.h"
#include "component/controller/helper/DummyNode.h"
#include "component/view/GraphView.h"
#include "component/view/GraphViewStyle.h"
#include "data/access/StorageAccess.h"
@@ -1,16 +1,14 @@
#include "component/controller/GraphLayouter.h"
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include "component/view/graphElements/GraphEdge.h"
#include "component/view/graphElements/GraphNode.h"
#include "utility/math/MatrixDynamicBase.h"
#include "component/controller/helper/DummyEdge.h"
#include "component/controller/helper/DummyNode.h"
// for prototyping, remove when done
#include "Eigen/Dense"
#include "Eigen/Eigenvalues"
@@ -151,10 +149,7 @@ void GraphLayouter::layoutSpectralPrototype(std::vector<DummyNode>& nodes, const
nodes[i].position.x = newPos.x;
nodes[i].position.y = newPos.y;
//std::cout << newPos << std::endl;
}
//std::cout << "=================" << std::endl;
}
}
@@ -0,0 +1,29 @@
#ifndef DUMMY_EDGE_H
#define DUMMY_EDGE_H
#include "utility/types.h"
class Edge;
// temporary data structure for (visual) graph creation process
struct DummyEdge
{
DummyEdge(const Id ownerId, const Id targetId, const Edge* data)
: ownerId(ownerId)
, targetId(targetId)
, data(data)
, visible(false)
, active(false)
{
}
Id ownerId;
Id targetId;
const Edge* data;
bool visible;
bool active;
};
#endif // DUMMY_EDGE_H
@@ -1,51 +1,14 @@
#ifndef GRAPH_NODE_H
#define GRAPH_NODE_H
#include <list>
#include <memory>
#ifndef DUMMY_NODE_H
#define DUMMY_NODE_H
#include "utility/math/Vector2.h"
#include "utility/math/Vector4.h"
#include "utility/types.h"
#include "data/graph/Node.h"
#include "data/graph/token_component/TokenComponentAccess.h"
class GraphEdge;
class GraphNode
{
public:
GraphNode(const Node* data);
virtual ~GraphNode();
virtual std::string getName() const = 0;
Id getTokenId() const;
const Node* getData() const;
void setData(const Node* data);
virtual bool isAccessNode() const = 0;
virtual Vec2i getPosition() const = 0;
virtual bool setPosition(const Vec2i& position) = 0;
virtual Vec2i getSize() const = 0;
virtual void setSize(const Vec2i& size) = 0;
virtual Vec4i getBoundingRect() const = 0;
virtual Vec4i getParentBoundingRect() const = 0;
virtual void addOutEdge(const std::shared_ptr<GraphEdge>& edge) = 0;
virtual void addInEdge(const std::weak_ptr<GraphEdge>& edge) = 0;
virtual size_t getOutEdgeCount() const = 0;
virtual size_t getInEdgeCount() const = 0;
protected:
const Node* m_data;
};
class Node;
// temporary data structure for (visual) graph creation process
struct DummyNode
{
public:
@@ -111,4 +74,4 @@ public:
size_t invisibleSubNodeCount;
};
#endif // GRAPH_NODE_H
#endif // DUMMY_NODE_H
-4
View File
@@ -1,10 +1,6 @@
#ifndef GRAPH_VIEW_H
#define GRAPH_VIEW_H
#include <list>
#include <memory>
#include "utility/math/Vector2.h"
#include "utility/types.h"
#include "component/view/View.h"
@@ -2,6 +2,7 @@
#include "utility/logging/logging.h"
#include "component/view/GraphViewStyleImpl.h"
#include "settings/ApplicationSettings.h"
GraphViewStyle::NodeMargins::NodeMargins()
+5 -2
View File
@@ -4,11 +4,14 @@
#include <map>
#include <memory>
#include "component/view/graphElements/GraphNode.h"
#include "component/view/GraphViewStyleImpl.h"
#include "utility/math/Vector2.h"
#include "utility/math/Vector4.h"
#include "data/graph/Node.h"
#include "data/graph/token_component/TokenComponentAccess.h"
class GraphViewStyleImpl;
class GraphViewStyle
{
public:
@@ -1,15 +0,0 @@
#include "component/view/graphElements/GraphEdge.h"
GraphEdge::GraphEdge(const Edge* data)
: m_data(data)
{
}
GraphEdge::~GraphEdge()
{
}
const Edge* GraphEdge::getData() const
{
return m_data;
}
@@ -1,50 +0,0 @@
#ifndef GRAPH_EDGE_H
#define GRAPH_EDGE_H
#include <memory>
#include "data/graph/Edge.h"
#include "utility/math/Vector4.h"
#include "utility/types.h"
class GraphNode;
class GraphEdge
{
public:
GraphEdge(const Edge* data);
virtual ~GraphEdge();
virtual std::weak_ptr<GraphNode> getOwner() = 0;
virtual std::weak_ptr<GraphNode> getTarget() = 0;
virtual void updateLine() = 0;
const Edge* getData() const;
private:
const Edge* m_data;
};
// temporary data structure for (visual) graph creation process
struct DummyEdge
{
DummyEdge(const Id o, const Id t, const Edge* data)
: ownerId(o)
, targetId(t)
, data(data)
, visible(false)
, active(false)
{
}
Id ownerId;
Id targetId;
const Edge* data;
bool visible;
bool active;
};
#endif // GRAPH_EDGE_H
@@ -1,29 +0,0 @@
#include "component/view/graphElements/GraphNode.h"
GraphNode::GraphNode(const Node* data)
: m_data(data)
{
}
GraphNode::~GraphNode()
{
}
Id GraphNode::getTokenId() const
{
if (m_data)
{
return m_data->getId();
}
return 0;
}
const Node* GraphNode::getData() const
{
return m_data;
}
void GraphNode::setData(const Node* data)
{
m_data = data;
}