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
-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;
}
@@ -1,114 +0,0 @@
#ifndef GRAPH_NODE_H
#define GRAPH_NODE_H
#include <list>
#include <memory>
#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;
};
struct DummyNode
{
public:
DummyNode()
: visible(false)
, childVisible(false)
, topLevelAncestorId(0)
, tokenId(0)
, data(nullptr)
, active(false)
, connected(false)
, aggregated(false)
, expanded(false)
, autoExpanded(false)
, accessType(TokenComponentAccess::ACCESS_NONE)
, invisibleSubNodeCount(0)
{
}
bool isGraphNode() const
{
return data != nullptr;
}
bool isAccessNode() const
{
return accessType != TokenComponentAccess::ACCESS_NONE;
}
bool isExpandToggleNode() const
{
return !data && !isAccessNode();
}
bool isExpanded() const
{
return expanded || autoExpanded;
}
Vec2i position;
Vec2i size;
bool visible;
bool childVisible;
Id topLevelAncestorId;
Id tokenId;
std::vector<DummyNode> subNodes;
// GraphNode
const Node* data;
bool active;
bool connected;
bool aggregated;
bool expanded;
bool autoExpanded;
// AccessNode
TokenComponentAccess::AccessType accessType;
// ExpandToggleNode
size_t invisibleSubNodeCount;
};
#endif // GRAPH_NODE_H