diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 1258a0c1..65271b59 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -59,6 +59,8 @@ add_files( qt/view/graphElements/QtGraphNode.h qt/view/graphElements/QtGraphNodeAccess.cpp qt/view/graphElements/QtGraphNodeAccess.h + qt/view/graphElements/QtGraphNodeData.cpp + qt/view/graphElements/QtGraphNodeData.h qt/view/graphElements/QtGraphNodeExpandToggle.cpp qt/view/graphElements/QtGraphNodeExpandToggle.h diff --git a/src/app/qt/view/QtGraphView.cpp b/src/app/qt/view/QtGraphView.cpp index 9e4a17fc..8d50f552 100644 --- a/src/app/qt/view/QtGraphView.cpp +++ b/src/app/qt/view/QtGraphView.cpp @@ -1,4 +1,4 @@ -#include "QtGraphView.h" +#include "qt/view/QtGraphView.h" #include #include @@ -8,6 +8,9 @@ #include #include +#include "component/controller/helper/DummyEdge.h" +#include "component/controller/helper/DummyNode.h" + #include "qt/utility/QtGraphPostprocessor.h" #include "qt/utility/utilityQt.h" @@ -15,7 +18,7 @@ #include "qt/view/graphElements/nodeComponents/QtGraphNodeComponentClickable.h" #include "qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.h" #include "qt/view/graphElements/QtGraphEdge.h" -#include "qt/view/graphElements/QtGraphNode.h" +#include "qt/view/graphElements/QtGraphNodeData.h" #include "qt/view/graphElements/QtGraphNodeAccess.h" #include "qt/view/graphElements/QtGraphNodeExpandToggle.h" @@ -27,7 +30,6 @@ QtGraphView::QtGraphView(ViewLayout* viewLayout) , m_resizeFunctor(std::bind(&QtGraphView::doResize, this)) , m_focusInFunctor(std::bind(&QtGraphView::doFocusIn, this, std::placeholders::_1)) , m_focusOutFunctor(std::bind(&QtGraphView::doFocusOut, this, std::placeholders::_1)) - { } @@ -245,7 +247,7 @@ std::shared_ptr QtGraphView::createNodeRecursive( std::shared_ptr newNode; if (node.isGraphNode()) { - newNode = std::make_shared(node.data, node.childVisible); + newNode = std::make_shared(node.data, node.childVisible); } else if (node.isAccessNode()) { diff --git a/src/app/qt/view/QtGraphView.h b/src/app/qt/view/QtGraphView.h index c4800c9e..9cd2dd8f 100644 --- a/src/app/qt/view/QtGraphView.h +++ b/src/app/qt/view/QtGraphView.h @@ -3,11 +3,10 @@ #include -#include "qt/utility/QtThreadedFunctor.h" -#include "utility/math/MatrixDynamicBase.h" -#include "utility/math/Vector4.h" #include "utility/types.h" +#include "qt/utility/QtThreadedFunctor.h" + #include "component/view/GraphView.h" struct DummyEdge; diff --git a/src/app/qt/view/graphElements/QtGraphEdge.cpp b/src/app/qt/view/graphElements/QtGraphEdge.cpp index 5971b7dd..3c1d7011 100644 --- a/src/app/qt/view/graphElements/QtGraphEdge.cpp +++ b/src/app/qt/view/graphElements/QtGraphEdge.cpp @@ -1,21 +1,20 @@ #include "qt/view/graphElements/QtGraphEdge.h" -#include #include -#include #include "utility/messaging/type/MessageActivateTokens.h" #include "utility/messaging/type/MessageFocusIn.h" #include "utility/messaging/type/MessageFocusOut.h" -#include "component/view/graphElements/GraphNode.h" #include "component/view/GraphViewStyle.h" +#include "data/graph/Edge.h" #include "data/graph/token_component/TokenComponentAggregation.h" #include "qt/graphics/QtAngledLineItem.h" #include "qt/graphics/QtStraightLineItem.h" +#include "qt/view/graphElements/QtGraphNode.h" -QtGraphEdge::QtGraphEdge(const std::weak_ptr& owner, const std::weak_ptr& target, const Edge* data) - : GraphEdge(data) +QtGraphEdge::QtGraphEdge(const std::weak_ptr& owner, const std::weak_ptr& target, const Edge* data) + : m_data(data) , m_owner(owner) , m_target(target) , m_child(nullptr) @@ -30,20 +29,25 @@ QtGraphEdge::~QtGraphEdge() { } -std::weak_ptr QtGraphEdge::getOwner() +const Edge* QtGraphEdge::getData() const +{ + return m_data; +} + +std::weak_ptr QtGraphEdge::getOwner() { return m_owner; } -std::weak_ptr QtGraphEdge::getTarget() +std::weak_ptr QtGraphEdge::getTarget() { return m_target; } void QtGraphEdge::updateLine() { - std::shared_ptr owner = m_owner.lock(); - std::shared_ptr target = m_target.lock(); + std::shared_ptr owner = m_owner.lock(); + std::shared_ptr target = m_target.lock(); if (owner == NULL || target == NULL) { @@ -114,6 +118,18 @@ void QtGraphEdge::onClick() } } +void QtGraphEdge::focusIn() +{ + bool isActive = m_isActive; + this->setIsActive(true); + m_isActive = isActive; +} + +void QtGraphEdge::focusOut() +{ + this->setIsActive(m_isActive); +} + void QtGraphEdge::mousePressEvent(QGraphicsSceneMouseEvent* event) { m_mousePos = Vec2i(event->scenePos().x(), event->scenePos().y()); @@ -147,15 +163,3 @@ void QtGraphEdge::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) { MessageFocusOut(getData()->getId()).dispatch(); } - -void QtGraphEdge::focusIn() -{ - bool isActive = m_isActive; - this->setIsActive(true); - m_isActive = isActive; -} - -void QtGraphEdge::focusOut() -{ - this->setIsActive(m_isActive); -} \ No newline at end of file diff --git a/src/app/qt/view/graphElements/QtGraphEdge.h b/src/app/qt/view/graphElements/QtGraphEdge.h index 98372c0e..00fc809c 100644 --- a/src/app/qt/view/graphElements/QtGraphEdge.h +++ b/src/app/qt/view/graphElements/QtGraphEdge.h @@ -7,24 +7,24 @@ #include "utility/math/Vector2.h" -#include "component/view/graphElements/GraphEdge.h" - -class GraphNode; +class Edge; +class QtGraphNode; class QtGraphEdge : public QObject - , public GraphEdge , public QGraphicsItemGroup { Q_OBJECT Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) public: - QtGraphEdge(const std::weak_ptr& owner, const std::weak_ptr& target, const Edge* data); + QtGraphEdge(const std::weak_ptr& owner, const std::weak_ptr& target, const Edge* data); virtual ~QtGraphEdge(); - virtual std::weak_ptr getOwner(); - virtual std::weak_ptr getTarget(); + const Edge* getData() const; + + virtual std::weak_ptr getOwner(); + virtual std::weak_ptr getTarget(); virtual void updateLine(); @@ -45,8 +45,10 @@ protected: virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event); private: - std::weak_ptr m_owner; - std::weak_ptr m_target; + const Edge* m_data; + + std::weak_ptr m_owner; + std::weak_ptr m_target; QGraphicsLineItem* m_child; diff --git a/src/app/qt/view/graphElements/QtGraphNode.cpp b/src/app/qt/view/graphElements/QtGraphNode.cpp index a88fa551..000064da 100644 --- a/src/app/qt/view/graphElements/QtGraphNode.cpp +++ b/src/app/qt/view/graphElements/QtGraphNode.cpp @@ -1,14 +1,10 @@ #include "qt/view/graphElements/QtGraphNode.h" #include +#include #include #include -#include "utility/messaging/type/MessageActivateTokens.h" -#include "utility/messaging/type/MessageGraphNodeMove.h" -#include "utility/messaging/type/MessageFocusIn.h" -#include "utility/messaging/type/MessageFocusOut.h" - #include "qt/graphics/QtRoundedRectItem.h" #include "qt/utility/QtDeviceScaledPixmap.h" #include "qt/utility/QtGraphPostprocessor.h" @@ -43,11 +39,9 @@ QFont QtGraphNode::getFontForNodeType(Node::NodeType type) } QtGraphNode::QtGraphNode() - : GraphNode(nullptr) - , m_undefinedRect(nullptr) + : m_undefinedRect(nullptr) , m_isActive(false) , m_isHovering(false) - , m_childVisible(false) { this->setPen(QPen(Qt::transparent)); @@ -55,45 +49,29 @@ QtGraphNode::QtGraphNode() m_text = new QGraphicsSimpleTextItem(this); } -QtGraphNode::QtGraphNode(const Node* data, bool childVisible) - : GraphNode(data) - , m_undefinedRect(nullptr) - , m_isActive(false) - , m_isHovering(false) - , m_childVisible(childVisible) -{ - this->setPen(QPen(Qt::transparent)); - - m_rect = new QtRoundedRectItem(this); - m_text = new QGraphicsSimpleTextItem(this); - - this->setAcceptHoverEvents(true); - - this->setName(data->getName()); -} - QtGraphNode::~QtGraphNode() { } -std::string QtGraphNode::getName() const +QtGraphNode* QtGraphNode::getParent() const { - return m_text->text().toStdString(); + return m_parentNode.lock().get(); } -void QtGraphNode::setName(const std::string& name) +void QtGraphNode::setParent(std::weak_ptr parentNode) { - m_text->setText(QString::fromStdString(name)); + m_parentNode = parentNode; + + std::shared_ptr parent = parentNode.lock(); + if (parent != NULL) + { + QGraphicsRectItem::setParentItem(parent.get()); + } } -bool QtGraphNode::isAccessNode() const +std::list> QtGraphNode::getSubNodes() const { - return false; -} - -bool QtGraphNode::isExpandToggleNode() const -{ - return false; + return m_subNodes; } Vec2i QtGraphNode::getPosition() const @@ -116,16 +94,6 @@ bool QtGraphNode::setPosition(const Vec2i& position) return false; } -void QtGraphNode::moved() -{ - QtGraphPostprocessor::alignNodeOnRaster(this); - - if (m_data) - { - MessageGraphNodeMove(m_data->getId(), getPosition()).dispatch(); - } -} - Vec2i QtGraphNode::getSize() const { return m_size; @@ -144,6 +112,16 @@ void QtGraphNode::setSize(const Vec2i& size) } } +QSize QtGraphNode::size() const +{ + return QSize(m_size.x, m_size.y); +} + +void QtGraphNode::setSize(const QSize& size) +{ + setSize(Vec2i(size.width(), size.height())); +} + Vec4i QtGraphNode::getBoundingRect() const { Vec2i pos = getPosition(); @@ -167,12 +145,12 @@ Vec4i QtGraphNode::getParentBoundingRect() const return node->getBoundingRect(); } -void QtGraphNode::addOutEdge(const std::shared_ptr& edge) +void QtGraphNode::addOutEdge(const std::shared_ptr& edge) { m_outEdges.push_back(edge); } -void QtGraphNode::addInEdge(const std::weak_ptr& edge) +void QtGraphNode::addInEdge(const std::weak_ptr& edge) { m_inEdges.push_back(edge); } @@ -187,16 +165,6 @@ size_t QtGraphNode::getInEdgeCount() const return m_inEdges.size(); } -QSize QtGraphNode::size() const -{ - return QSize(m_size.x, m_size.y); -} - -void QtGraphNode::setSize(const QSize& size) -{ - setSize(Vec2i(size.width(), size.height())); -} - bool QtGraphNode::getIsActive() const { return m_isActive; @@ -209,20 +177,14 @@ void QtGraphNode::setIsActive(bool isActive) updateStyle(); } -QtGraphNode* QtGraphNode::getParent() const +std::string QtGraphNode::getName() const { - return m_parentNode.lock().get(); + return m_text->text().toStdString(); } -void QtGraphNode::setParent(std::weak_ptr parentNode) +void QtGraphNode::setName(const std::string& name) { - m_parentNode = parentNode; - - std::shared_ptr parent = parentNode.lock(); - if (parent != NULL) - { - QGraphicsRectItem::setParentItem(parent.get()); - } + m_text->setText(QString::fromStdString(name)); } void QtGraphNode::addComponent(const std::shared_ptr& component) @@ -230,16 +192,6 @@ void QtGraphNode::addComponent(const std::shared_ptr& comp m_components.push_back(component); } -std::list> QtGraphNode::getSubNodes() const -{ - return m_subNodes; -} - -void QtGraphNode::addSubNode(const std::shared_ptr& node) -{ - m_subNodes.push_back(node); -} - void QtGraphNode::setShadowEnabledRecursive(bool enabled) { m_rect->setShadowEnabled(enabled); @@ -250,14 +202,6 @@ void QtGraphNode::setShadowEnabledRecursive(bool enabled) } } -void QtGraphNode::onClick() -{ - if (!m_isActive && m_data && !m_data->isType(Node::NODE_UNDEFINED | Node::NODE_NAMESPACE)) - { - MessageActivateTokens(m_data->getId()).dispatch(); - } -} - void QtGraphNode::hoverEnter() { hoverEnterEvent(nullptr); @@ -269,11 +213,50 @@ void QtGraphNode::hoverEnter() } } -void QtGraphNode::updateStyle() +void QtGraphNode::focusIn() +{ + m_isHovering = true; + updateStyle(); +} + +void QtGraphNode::focusOut() +{ + m_isHovering = false; + updateStyle(); +} + +bool QtGraphNode::isDataNode() const +{ + return false; +} + +bool QtGraphNode::isAccessNode() const +{ + return false; +} + +bool QtGraphNode::isExpandToggleNode() const +{ + return false; +} + +Id QtGraphNode::getTokenId() const +{ + return 0; +} + +void QtGraphNode::addSubNode(const std::shared_ptr& node) +{ + m_subNodes.push_back(node); +} + +void QtGraphNode::moved() +{ + QtGraphPostprocessor::alignNodeOnRaster(this); +} + +void QtGraphNode::onClick() { - GraphViewStyle::NodeStyle style = - GraphViewStyle::getStyleForNodeType(m_data->getType(), m_isActive, m_isHovering, m_childVisible); - setStyle(style); } void QtGraphNode::mousePressEvent(QGraphicsSceneMouseEvent* event) @@ -333,44 +316,16 @@ void QtGraphNode::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) } } -void QtGraphNode::hoverEnterEvent(QGraphicsSceneHoverEvent* event) -{ - if(m_data) - { - MessageFocusIn(m_data->getId()).dispatch(); - } -} - -void QtGraphNode::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) -{ - if(m_data) - { - MessageFocusOut(m_data->getId()).dispatch(); - } -} - -void QtGraphNode::focusIn() -{ - m_isHovering = true; - updateStyle(); -} - -void QtGraphNode::focusOut() -{ - m_isHovering = false; - updateStyle(); -} - void QtGraphNode::notifyEdgesAfterMove() { - for (const std::shared_ptr& edge : m_outEdges) + for (const std::shared_ptr& edge : m_outEdges) { edge->updateLine(); } - for (const std::weak_ptr& e : m_inEdges) + for (const std::weak_ptr& e : m_inEdges) { - std::shared_ptr edge = e.lock(); + std::shared_ptr edge = e.lock(); if (edge) { edge->updateLine(); diff --git a/src/app/qt/view/graphElements/QtGraphNode.h b/src/app/qt/view/graphElements/QtGraphNode.h index 312ab021..2586b67b 100644 --- a/src/app/qt/view/graphElements/QtGraphNode.h +++ b/src/app/qt/view/graphElements/QtGraphNode.h @@ -1,20 +1,17 @@ #ifndef QT_GRAPH_NODE_H #define QT_GRAPH_NODE_H -#include #include -#include "component/view/graphElements/GraphNode.h" #include "component/view/GraphViewStyle.h" -#include "utility/messaging/MessageListener.h" +class QFont; class QtGraphEdge; class QtRoundedRectItem; class QtGraphNodeComponent; class QtGraphNode : public QObject - , public GraphNode , public QGraphicsRectItem { Q_OBJECT @@ -33,69 +30,70 @@ public: static QFont getFontForNodeType(Node::NodeType type); QtGraphNode(); - QtGraphNode(const Node* data, bool childVisible); virtual ~QtGraphNode(); - virtual std::string getName() const; - void setName(const std::string& name); - - virtual bool isAccessNode() const; - virtual bool isExpandToggleNode() const; - - virtual Vec2i getPosition() const; - virtual bool setPosition(const Vec2i& position); - virtual void moved(); - - virtual Vec2i getSize() const; - virtual void setSize(const Vec2i& size); - - virtual Vec4i getBoundingRect() const; - virtual Vec4i getParentBoundingRect() const; - - virtual void addOutEdge(const std::shared_ptr& edge); - virtual void addInEdge(const std::weak_ptr& edge); - - virtual size_t getOutEdgeCount() const; - virtual size_t getInEdgeCount() const; - - QSize size() const; - void setSize(const QSize& size); - - bool getIsActive() const; - void setIsActive(bool isActive); - QtGraphNode* getParent() const; void setParent(std::weak_ptr parentNode); - void addComponent(const std::shared_ptr& component); - std::list> getSubNodes() const; - virtual void addSubNode(const std::shared_ptr& node); + + Vec2i getPosition() const; + bool setPosition(const Vec2i& position); + + Vec2i getSize() const; + void setSize(const Vec2i& size); + + QSize size() const; + void setSize(const QSize& size); + + Vec4i getBoundingRect() const; + Vec4i getParentBoundingRect() const; + + void addOutEdge(const std::shared_ptr& edge); + void addInEdge(const std::weak_ptr& edge); + + size_t getOutEdgeCount() const; + size_t getInEdgeCount() const; + + bool getIsActive() const; + void setIsActive(bool isActive); + + std::string getName() const; + void setName(const std::string& name); + + void addComponent(const std::shared_ptr& component); void setShadowEnabledRecursive(bool enabled); - virtual void onClick(); void hoverEnter(); void focusIn(); void focusOut(); - virtual void updateStyle(); + virtual bool isDataNode() const; + virtual bool isAccessNode() const; + virtual bool isExpandToggleNode() const; + + virtual Id getTokenId() const; + + virtual void addSubNode(const std::shared_ptr& node); + + virtual void onClick(); + virtual void moved(); + + virtual void updateStyle() = 0; protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent* event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); - virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event); - virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event); - void notifyEdgesAfterMove(); void setStyle(const GraphViewStyle::NodeStyle& style); - std::list> m_outEdges; - std::list> m_inEdges; + std::list> m_outEdges; + std::list> m_inEdges; std::weak_ptr m_parentNode; std::list> m_subNodes; @@ -106,12 +104,11 @@ protected: Vec2i m_size; -private: - std::list> m_components; - bool m_isActive; bool m_isHovering; - bool m_childVisible; + +private: + std::list> m_components; }; #endif // QT_GRAPH_NODE_H diff --git a/src/app/qt/view/graphElements/QtGraphNodeAccess.cpp b/src/app/qt/view/graphElements/QtGraphNodeAccess.cpp index dcdd6b08..e68f42fb 100644 --- a/src/app/qt/view/graphElements/QtGraphNodeAccess.cpp +++ b/src/app/qt/view/graphElements/QtGraphNodeAccess.cpp @@ -27,16 +27,16 @@ QtGraphNodeAccess::~QtGraphNodeAccess() { } -bool QtGraphNodeAccess::isAccessNode() const -{ - return true; -} - TokenComponentAccess::AccessType QtGraphNodeAccess::getAccessType() const { return m_access; } +bool QtGraphNodeAccess::isAccessNode() const +{ + return true; +} + void QtGraphNodeAccess::addSubNode(const std::shared_ptr& node) { QtGraphNode::addSubNode(node); diff --git a/src/app/qt/view/graphElements/QtGraphNodeAccess.h b/src/app/qt/view/graphElements/QtGraphNodeAccess.h index 9bc6414e..09144041 100644 --- a/src/app/qt/view/graphElements/QtGraphNodeAccess.h +++ b/src/app/qt/view/graphElements/QtGraphNodeAccess.h @@ -11,11 +11,12 @@ public: QtGraphNodeAccess(TokenComponentAccess::AccessType accessType); virtual ~QtGraphNodeAccess(); - virtual bool isAccessNode() const; TokenComponentAccess::AccessType getAccessType() const; - virtual void addSubNode(const std::shared_ptr& node); + // QtGraphNode implementation + virtual bool isAccessNode() const; + virtual void addSubNode(const std::shared_ptr& node); virtual void updateStyle(); void hideLabel(); diff --git a/src/app/qt/view/graphElements/QtGraphNodeData.cpp b/src/app/qt/view/graphElements/QtGraphNodeData.cpp new file mode 100644 index 00000000..e55317c1 --- /dev/null +++ b/src/app/qt/view/graphElements/QtGraphNodeData.cpp @@ -0,0 +1,66 @@ +#include "qt/view/graphElements/QtGraphNodeData.h" + +#include "utility/messaging/type/MessageActivateTokens.h" +#include "utility/messaging/type/MessageFocusIn.h" +#include "utility/messaging/type/MessageFocusOut.h" +#include "utility/messaging/type/MessageGraphNodeMove.h" + +QtGraphNodeData::QtGraphNodeData(const Node* data, bool childVisible) + : m_data(data) + , m_childVisible(childVisible) +{ + this->setAcceptHoverEvents(true); + + this->setName(data->getName()); +} + +QtGraphNodeData::~QtGraphNodeData() +{ +} + +const Node* QtGraphNodeData::getData() const +{ + return m_data; +} + +bool QtGraphNodeData::isDataNode() const +{ + return true; +} + +Id QtGraphNodeData::getTokenId() const +{ + return m_data->getId(); +} + +void QtGraphNodeData::onClick() +{ + if (!m_isActive && !m_data->isType(Node::NODE_UNDEFINED | Node::NODE_NAMESPACE)) + { + MessageActivateTokens(m_data->getId()).dispatch(); + } +} + +void QtGraphNodeData::moved() +{ + QtGraphNode::moved(); + + MessageGraphNodeMove(m_data->getId(), getPosition()).dispatch(); +} + +void QtGraphNodeData::updateStyle() +{ + GraphViewStyle::NodeStyle style = + GraphViewStyle::getStyleForNodeType(m_data->getType(), m_isActive, m_isHovering, m_childVisible); + setStyle(style); +} + +void QtGraphNodeData::hoverEnterEvent(QGraphicsSceneHoverEvent* event) +{ + MessageFocusIn(m_data->getId()).dispatch(); +} + +void QtGraphNodeData::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) +{ + MessageFocusOut(m_data->getId()).dispatch(); +} diff --git a/src/app/qt/view/graphElements/QtGraphNodeData.h b/src/app/qt/view/graphElements/QtGraphNodeData.h new file mode 100644 index 00000000..f5a463c5 --- /dev/null +++ b/src/app/qt/view/graphElements/QtGraphNodeData.h @@ -0,0 +1,33 @@ +#ifndef QT_GRAPH_NODE_DATA_H +#define QT_GRAPH_NODE_DATA_H + +#include "qt/view/graphElements/QtGraphNode.h" + +class QtGraphNodeData + : public QtGraphNode +{ +public: + QtGraphNodeData(const Node* data, bool childVisible); + virtual ~QtGraphNodeData(); + + const Node* getData() const; + + // QtGraphNode implementation + virtual bool isDataNode() const; + + virtual Id getTokenId() const; + + virtual void onClick(); + virtual void moved(); + virtual void updateStyle(); + +protected: + virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event); + virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event); + +private: + const Node* m_data; + bool m_childVisible; +}; + +#endif // QT_GRAPH_NODE_DATA_H diff --git a/src/app/qt/view/graphElements/QtGraphNodeExpandToggle.cpp b/src/app/qt/view/graphElements/QtGraphNodeExpandToggle.cpp index 6e6ee040..64864e50 100644 --- a/src/app/qt/view/graphElements/QtGraphNodeExpandToggle.cpp +++ b/src/app/qt/view/graphElements/QtGraphNodeExpandToggle.cpp @@ -1,10 +1,13 @@ #include "qt/view/graphElements/QtGraphNodeExpandToggle.h" +#include + #include "utility/logging/logging.h" #include "utility/messaging/type/MessageGraphNodeExpand.h" #include "qt/graphics/QtRoundedRectItem.h" #include "qt/utility/QtDeviceScaledPixmap.h" +#include "qt/view/graphElements/QtGraphNodeData.h" QtGraphNodeExpandToggle::QtGraphNodeExpandToggle(bool expanded, int invisibleSubNodeCount) : m_allVisible(invisibleSubNodeCount == 0) @@ -47,9 +50,9 @@ void QtGraphNodeExpandToggle::onClick() { QtGraphNode* parent = getParent(); - if (parent && parent->getData()) + if (parent && parent->getTokenId()) { - MessageGraphNodeExpand(parent->getData()->getId()).dispatch(); + MessageGraphNodeExpand(parent->getTokenId()).dispatch(); } } diff --git a/src/app/qt/view/graphElements/QtGraphNodeExpandToggle.h b/src/app/qt/view/graphElements/QtGraphNodeExpandToggle.h index 959a9b9e..ea54e1fe 100644 --- a/src/app/qt/view/graphElements/QtGraphNodeExpandToggle.h +++ b/src/app/qt/view/graphElements/QtGraphNodeExpandToggle.h @@ -12,6 +12,7 @@ public: QtGraphNodeExpandToggle(bool expanded, int invisibleSubNodeCount); virtual ~QtGraphNodeExpandToggle(); + // QtGraphNode implementation virtual bool isExpandToggleNode() const; virtual void onClick(); diff --git a/src/app/qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.cpp b/src/app/qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.cpp index 4c21f9c0..8ee9b03a 100644 --- a/src/app/qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.cpp +++ b/src/app/qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.cpp @@ -16,7 +16,7 @@ QtGraphNodeComponentMoveable::~QtGraphNodeComponentMoveable() void QtGraphNodeComponentMoveable::nodeMousePressEvent(QGraphicsSceneMouseEvent* event) { - std::shared_ptr node = m_graphNode.lock(); + std::shared_ptr node = m_graphNode.lock(); if (node != NULL) { m_mouseOffset.x = event->scenePos().x() - node->getPosition().x; @@ -28,7 +28,7 @@ void QtGraphNodeComponentMoveable::nodeMousePressEvent(QGraphicsSceneMouseEvent* void QtGraphNodeComponentMoveable::nodeMouseMoveEvent(QGraphicsSceneMouseEvent* event) { - std::shared_ptr node = m_graphNode.lock(); + std::shared_ptr node = m_graphNode.lock(); if (node != NULL) { node->setPosition(Vec2i(event->scenePos().x() - m_mouseOffset.x, event->scenePos().y() - m_mouseOffset.y)); diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 550543e5..827e9fc8 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -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 diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index b5b719c1..4e47a08b 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.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" diff --git a/src/lib/component/controller/GraphLayouter.cpp b/src/lib/component/controller/GraphLayouter.cpp index e3db2be5..60eef8ec 100644 --- a/src/lib/component/controller/GraphLayouter.cpp +++ b/src/lib/component/controller/GraphLayouter.cpp @@ -1,16 +1,14 @@ #include "component/controller/GraphLayouter.h" -#include - #include #include #include -#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& nodes, const nodes[i].position.x = newPos.x; nodes[i].position.y = newPos.y; - - //std::cout << newPos << std::endl; } - //std::cout << "=================" << std::endl; } } diff --git a/src/lib/component/controller/helper/DummyEdge.h b/src/lib/component/controller/helper/DummyEdge.h new file mode 100644 index 00000000..c9973e77 --- /dev/null +++ b/src/lib/component/controller/helper/DummyEdge.h @@ -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 diff --git a/src/lib/component/view/graphElements/GraphNode.h b/src/lib/component/controller/helper/DummyNode.h similarity index 53% rename from src/lib/component/view/graphElements/GraphNode.h rename to src/lib/component/controller/helper/DummyNode.h index 16715599..1683bd04 100644 --- a/src/lib/component/view/graphElements/GraphNode.h +++ b/src/lib/component/controller/helper/DummyNode.h @@ -1,51 +1,14 @@ -#ifndef GRAPH_NODE_H -#define GRAPH_NODE_H - -#include -#include +#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& edge) = 0; - virtual void addInEdge(const std::weak_ptr& 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 diff --git a/src/lib/component/view/GraphView.h b/src/lib/component/view/GraphView.h index 42322692..ca96fc84 100644 --- a/src/lib/component/view/GraphView.h +++ b/src/lib/component/view/GraphView.h @@ -1,10 +1,6 @@ #ifndef GRAPH_VIEW_H #define GRAPH_VIEW_H -#include -#include - -#include "utility/math/Vector2.h" #include "utility/types.h" #include "component/view/View.h" diff --git a/src/lib/component/view/GraphViewStyle.cpp b/src/lib/component/view/GraphViewStyle.cpp index c7de69fb..af8fb462 100644 --- a/src/lib/component/view/GraphViewStyle.cpp +++ b/src/lib/component/view/GraphViewStyle.cpp @@ -2,6 +2,7 @@ #include "utility/logging/logging.h" +#include "component/view/GraphViewStyleImpl.h" #include "settings/ApplicationSettings.h" GraphViewStyle::NodeMargins::NodeMargins() diff --git a/src/lib/component/view/GraphViewStyle.h b/src/lib/component/view/GraphViewStyle.h index 98eeef35..9f3f0541 100644 --- a/src/lib/component/view/GraphViewStyle.h +++ b/src/lib/component/view/GraphViewStyle.h @@ -4,11 +4,14 @@ #include #include -#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: diff --git a/src/lib/component/view/graphElements/GraphEdge.cpp b/src/lib/component/view/graphElements/GraphEdge.cpp deleted file mode 100644 index 3fb2c9ea..00000000 --- a/src/lib/component/view/graphElements/GraphEdge.cpp +++ /dev/null @@ -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; -} diff --git a/src/lib/component/view/graphElements/GraphEdge.h b/src/lib/component/view/graphElements/GraphEdge.h deleted file mode 100644 index bafb1da8..00000000 --- a/src/lib/component/view/graphElements/GraphEdge.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef GRAPH_EDGE_H -#define GRAPH_EDGE_H - -#include - -#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 getOwner() = 0; - virtual std::weak_ptr 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 diff --git a/src/lib/component/view/graphElements/GraphNode.cpp b/src/lib/component/view/graphElements/GraphNode.cpp deleted file mode 100644 index 780fbee8..00000000 --- a/src/lib/component/view/graphElements/GraphNode.cpp +++ /dev/null @@ -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; -}