ui: graphView
Graph view has now toggle-able subnodes. Subnodes connected to the active node are always visible. fortune cookie message = You will enjoy true success in whatever you do.
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
|
/*
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
/* */
|
||||||
|
|
||||||
const bool *abd(int abc, int bca);
|
const bool *abd(int abc, int bca);
|
||||||
|
|
||||||
@@ -117,6 +119,25 @@ namespace
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
noname::V voo;
|
||||||
|
|
||||||
typedef A* D;
|
typedef A* D;
|
||||||
|
|
||||||
D globalD;
|
D globalD;
|
||||||
|
|
||||||
|
class E
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
E(){}
|
||||||
|
~E(){}
|
||||||
|
|
||||||
|
class SubE
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SubE(){}
|
||||||
|
~SubE(){}
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_importantInt;
|
||||||
|
};
|
||||||
|
|||||||
@@ -22,12 +22,17 @@ add_files(
|
|||||||
qt/utility/utilityQt.cpp
|
qt/utility/utilityQt.cpp
|
||||||
qt/utility/utilityQt.h
|
qt/utility/utilityQt.h
|
||||||
|
|
||||||
|
qt/view/graphElements/nodeComponents/QtGraphNodeComponent.cpp
|
||||||
|
qt/view/graphElements/nodeComponents/QtGraphNodeComponent.h
|
||||||
|
qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.cpp
|
||||||
|
qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.h
|
||||||
|
qt/view/graphElements/nodeComponents/QtGraphNodeComponentToggleButton.cpp
|
||||||
|
qt/view/graphElements/nodeComponents/QtGraphNodeComponentToggleButton.h
|
||||||
|
|
||||||
qt/view/graphElements/QtGraphEdge.cpp
|
qt/view/graphElements/QtGraphEdge.cpp
|
||||||
qt/view/graphElements/QtGraphEdge.h
|
qt/view/graphElements/QtGraphEdge.h
|
||||||
qt/view/graphElements/QtGraphNode.cpp
|
qt/view/graphElements/QtGraphNode.cpp
|
||||||
qt/view/graphElements/QtGraphNode.h
|
qt/view/graphElements/QtGraphNode.h
|
||||||
qt/view/graphElements/QtGraphNodeMouseMovable.cpp
|
|
||||||
qt/view/graphElements/QtGraphNodeMouseMovable.h
|
|
||||||
|
|
||||||
qt/view/QtCodeView.cpp
|
qt/view/QtCodeView.cpp
|
||||||
qt/view/QtCodeView.h
|
qt/view/QtCodeView.h
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
#include "qt/view/QtViewWidgetWrapper.h"
|
#include "qt/view/QtViewWidgetWrapper.h"
|
||||||
#include "qt/view/graphElements/QtGraphEdge.h"
|
#include "qt/view/graphElements/QtGraphEdge.h"
|
||||||
#include "qt/view/graphElements/QtGraphNode.h"
|
#include "qt/view/graphElements/QtGraphNode.h"
|
||||||
#include "qt/view/graphElements/QtGraphNodeMouseMovable.h"
|
#include "qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.h"
|
||||||
|
#include "qt/view/graphElements/nodeComponents/QtGraphNodeComponentToggleButton.h"
|
||||||
|
|
||||||
QtGraphView::QtGraphView(ViewLayout* viewLayout)
|
QtGraphView::QtGraphView(ViewLayout* viewLayout)
|
||||||
: GraphView(viewLayout)
|
: GraphView(viewLayout)
|
||||||
@@ -108,6 +109,12 @@ void QtGraphView::doRebuildGraph(const std::vector<DummyNode>& nodes, const std:
|
|||||||
m_edges.push_back(edge);
|
m_edges.push_back(edge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hide node content by default, must be done after all edges are created to keep subnodes with connections visible
|
||||||
|
for(std::list<std::shared_ptr<GraphNode>>::iterator it = m_nodes.begin(); it != m_nodes.end(); it++)
|
||||||
|
{
|
||||||
|
(*it)->hideContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -183,21 +190,24 @@ std::shared_ptr<GraphNode> QtGraphView::createNode(QGraphicsView* view, const Du
|
|||||||
{
|
{
|
||||||
if (view != NULL)
|
if (view != NULL)
|
||||||
{
|
{
|
||||||
std::shared_ptr<QtGraphNodeMouseMovable> newNode =
|
std::shared_ptr<QtGraphNode> newNode =
|
||||||
std::make_shared<QtGraphNodeMouseMovable>(Vec2i(0, 0), node.name, node.tokenId);
|
std::make_shared<QtGraphNode>(Vec2i(0, 0), Vec2i(100, 30), node.name, node.tokenId);
|
||||||
view->scene()->addItem(newNode.get());
|
view->scene()->addItem(newNode.get());
|
||||||
m_nodes.push_back(newNode);
|
m_nodes.push_back(newNode);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < node.subNodes.size(); i++)
|
newNode->addComponent(std::make_shared<QtGraphNodeComponentMoveable>(newNode));
|
||||||
{
|
|
||||||
std::shared_ptr<QtGraphNode> subNode = createSubNode(view, node.subNodes[i]);
|
|
||||||
subNode->setParentItem(newNode.get());
|
|
||||||
newNode->addSubNode(subNode);
|
|
||||||
subNode->setRect(0, 0, 80, 20);
|
|
||||||
subNode->moveBy(10, (i + 1) * 30);
|
|
||||||
}
|
|
||||||
|
|
||||||
newNode->setRect(0, 0, 100, 40 + (node.subNodes.size() * 30));
|
if(node.subNodes.size() > 0)
|
||||||
|
{
|
||||||
|
newNode->addComponent(std::make_shared<QtGraphNodeComponentToggleButton>(newNode));
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < node.subNodes.size(); i++)
|
||||||
|
{
|
||||||
|
std::shared_ptr<QtGraphNode> subNode = createSubNode(view, node.subNodes[i]);
|
||||||
|
subNode->setParent(newNode);
|
||||||
|
newNode->addSubNode(subNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return newNode;
|
return newNode;
|
||||||
}
|
}
|
||||||
@@ -212,16 +222,21 @@ std::shared_ptr<QtGraphNode> QtGraphView::createSubNode(QGraphicsView* view, con
|
|||||||
{
|
{
|
||||||
if (view != NULL)
|
if (view != NULL)
|
||||||
{
|
{
|
||||||
std::shared_ptr<QtGraphNode> newNode = std::make_shared<QtGraphNode>(Vec2i(0, 0), node.name, node.tokenId);
|
std::shared_ptr<QtGraphNode> newNode = std::make_shared<QtGraphNode>(Vec2i(0, 0), Vec2i(80, 20), node.name, node.tokenId);
|
||||||
view->scene()->addItem(newNode.get());
|
view->scene()->addItem(newNode.get());
|
||||||
|
|
||||||
for (unsigned int i = 0; i < node.subNodes.size(); i++)
|
if(node.subNodes.size() > 0)
|
||||||
{
|
{
|
||||||
std::shared_ptr<QtGraphNode> subNode = createSubNode(view, node.subNodes[i]);
|
newNode->addComponent(std::make_shared<QtGraphNodeComponentToggleButton>(newNode));
|
||||||
subNode->setParentItem(newNode.get());
|
|
||||||
newNode->addSubNode(subNode);
|
for (unsigned int i = 0; i < node.subNodes.size(); i++)
|
||||||
subNode->setRect(0, 0, 80, 20);
|
{
|
||||||
subNode->moveBy(10, (i + 1) * 30);
|
std::shared_ptr<QtGraphNode> subNode = createSubNode(view, node.subNodes[i]);
|
||||||
|
|
||||||
|
subNode->setParent(newNode);
|
||||||
|
|
||||||
|
newNode->addSubNode(subNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newNode;
|
return newNode;
|
||||||
|
|||||||
@@ -6,11 +6,16 @@
|
|||||||
#include <QGraphicsSceneEvent>
|
#include <QGraphicsSceneEvent>
|
||||||
|
|
||||||
#include "qt/view/graphElements/QtGraphEdge.h"
|
#include "qt/view/graphElements/QtGraphEdge.h"
|
||||||
|
#include "qt/view/graphElements/nodeComponents/QtGraphNodeComponent.h"
|
||||||
|
|
||||||
QtGraphNode::QtGraphNode(const Vec2i& position, const std::string& name, const Id tokenId)
|
QtGraphNode::QtGraphNode(const Vec2i& position, const Vec2i& size, const std::string& name, const Id tokenId)
|
||||||
: GraphNode(tokenId)
|
: GraphNode(tokenId)
|
||||||
|
, m_baseSize(size)
|
||||||
|
, m_currentSize(size)
|
||||||
|
, m_padding(10, 10)
|
||||||
|
, m_contentHidden(false)
|
||||||
{
|
{
|
||||||
this->setRect(0, 0, 100, 100);
|
this->setRect(0, 0, size.x, size.y);
|
||||||
this->setPos(position.x, position.y);
|
this->setPos(position.x, position.y);
|
||||||
QBrush brush(Qt::lightGray);
|
QBrush brush(Qt::lightGray);
|
||||||
this->setBrush(brush);
|
this->setBrush(brush);
|
||||||
@@ -56,6 +61,27 @@ void QtGraphNode::setPosition(const Vec2i& position)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vec2i QtGraphNode::getSize() const
|
||||||
|
{
|
||||||
|
return m_currentSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNode::setParent(std::weak_ptr<QtGraphNode> parentNode)
|
||||||
|
{
|
||||||
|
m_parentNode = parentNode;
|
||||||
|
|
||||||
|
std::shared_ptr<QtGraphNode> parent = parentNode.lock();
|
||||||
|
if(parent != NULL)
|
||||||
|
{
|
||||||
|
QGraphicsRectItem::setParentItem(parent.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNode::addComponent(const std::shared_ptr<QtGraphNodeComponent>& component)
|
||||||
|
{
|
||||||
|
m_components.push_back(component);
|
||||||
|
}
|
||||||
|
|
||||||
bool QtGraphNode::addOutEdge(const std::shared_ptr<GraphEdge>& edge)
|
bool QtGraphNode::addOutEdge(const std::shared_ptr<GraphEdge>& edge)
|
||||||
{
|
{
|
||||||
for (std::list<std::shared_ptr<GraphEdge>>::iterator it = m_outEdges.begin(); it != m_outEdges.end(); it++)
|
for (std::list<std::shared_ptr<GraphEdge>>::iterator it = m_outEdges.begin(); it != m_outEdges.end(); it++)
|
||||||
@@ -113,12 +139,35 @@ std::list<std::shared_ptr<GraphNode>> QtGraphNode::getSubNodes() const
|
|||||||
void QtGraphNode::addSubNode(const std::shared_ptr<GraphNode>& node)
|
void QtGraphNode::addSubNode(const std::shared_ptr<GraphNode>& node)
|
||||||
{
|
{
|
||||||
m_subNodes.push_back(node);
|
m_subNodes.push_back(node);
|
||||||
|
|
||||||
|
rebuildLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNode::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||||
|
{
|
||||||
|
for (std::list<std::shared_ptr<QtGraphNodeComponent>>::iterator it = m_components.begin(); it != m_components.end(); it++)
|
||||||
|
{
|
||||||
|
(*it)->nodeMousePressEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNode::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
||||||
|
{
|
||||||
|
for (std::list<std::shared_ptr<QtGraphNodeComponent>>::iterator it = m_components.begin(); it != m_components.end(); it++)
|
||||||
|
{
|
||||||
|
(*it)->nodeMouseMoveEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtGraphNode::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
|
void QtGraphNode::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
|
||||||
{
|
{
|
||||||
MessageActivateToken message(m_tokenId);
|
MessageActivateToken message(m_tokenId);
|
||||||
message.dispatch();
|
message.dispatch();
|
||||||
|
|
||||||
|
for (std::list<std::shared_ptr<QtGraphNodeComponent>>::iterator it = m_components.begin(); it != m_components.end(); it++)
|
||||||
|
{
|
||||||
|
(*it)->nodeMouseDoubleClickEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtGraphNode::notifyParentMoved()
|
void QtGraphNode::notifyParentMoved()
|
||||||
@@ -126,6 +175,83 @@ void QtGraphNode::notifyParentMoved()
|
|||||||
notifyEdgesAfterMove();
|
notifyEdgesAfterMove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtGraphNode::hideContent()
|
||||||
|
{
|
||||||
|
for (std::list<std::shared_ptr<GraphNode>>::iterator it = m_subNodes.begin(); it != m_subNodes.end(); it++)
|
||||||
|
{
|
||||||
|
(*it)->hideContent();
|
||||||
|
|
||||||
|
if((*it)->getEdgeCountRecursive() <= 0)
|
||||||
|
{
|
||||||
|
(*it)->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_contentHidden = true;
|
||||||
|
|
||||||
|
rebuildLayout();
|
||||||
|
|
||||||
|
notifyParentNodeAfterSizeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNode::showContent()
|
||||||
|
{
|
||||||
|
for (std::list<std::shared_ptr<GraphNode>>::iterator it = m_subNodes.begin(); it != m_subNodes.end(); it++)
|
||||||
|
{
|
||||||
|
(*it)->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_contentHidden = false;
|
||||||
|
|
||||||
|
rebuildLayout();
|
||||||
|
|
||||||
|
notifyParentNodeAfterSizeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNode::hide()
|
||||||
|
{
|
||||||
|
QGraphicsRectItem::hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNode::show()
|
||||||
|
{
|
||||||
|
QGraphicsRectItem::show();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtGraphNode::isHidden()
|
||||||
|
{
|
||||||
|
return !QGraphicsRectItem::isVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtGraphNode::contentIsHidden()
|
||||||
|
{
|
||||||
|
return m_contentHidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int QtGraphNode::getOutEdgeCount() const
|
||||||
|
{
|
||||||
|
return m_outEdges.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int QtGraphNode::getInEdgeCount() const
|
||||||
|
{
|
||||||
|
return m_inEdges.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int QtGraphNode::getEdgeCountRecursive() const
|
||||||
|
{
|
||||||
|
unsigned int result = 0;
|
||||||
|
|
||||||
|
for (std::list<std::shared_ptr<GraphNode>>::const_iterator it = m_subNodes.begin(); it != m_subNodes.end(); it++)
|
||||||
|
{
|
||||||
|
result += (*it)->getEdgeCountRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
result += (getInEdgeCount() + getOutEdgeCount());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void QtGraphNode::notifyEdgesAfterMove()
|
void QtGraphNode::notifyEdgesAfterMove()
|
||||||
{
|
{
|
||||||
for (std::list<std::shared_ptr<GraphEdge>>::iterator it = m_outEdges.begin(); it != m_outEdges.end(); it++)
|
for (std::list<std::shared_ptr<GraphEdge>>::iterator it = m_outEdges.begin(); it != m_outEdges.end(); it++)
|
||||||
@@ -153,3 +279,47 @@ void QtGraphNode::notifyEdgesAfterMove()
|
|||||||
(*it3)->notifyParentMoved();
|
(*it3)->notifyParentMoved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtGraphNode::notifyParentNodeAfterSizeChanged()
|
||||||
|
{
|
||||||
|
std::shared_ptr<QtGraphNode> parentNode = m_parentNode.lock();
|
||||||
|
|
||||||
|
if(parentNode != NULL)
|
||||||
|
{
|
||||||
|
parentNode->onChildSizeChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNode::onChildSizeChanged()
|
||||||
|
{
|
||||||
|
rebuildLayout();
|
||||||
|
|
||||||
|
notifyParentNodeAfterSizeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNode::rebuildLayout()
|
||||||
|
{
|
||||||
|
int nextYPos = m_baseSize.y;
|
||||||
|
int newWidth = m_baseSize.x;
|
||||||
|
|
||||||
|
for (std::list<std::shared_ptr<GraphNode>>::iterator it = m_subNodes.begin(); it != m_subNodes.end(); it++)
|
||||||
|
{
|
||||||
|
if((*it)->isHidden() == false)
|
||||||
|
{
|
||||||
|
(*it)->setPosition(this->getPosition() + Vec2i(m_padding.x, nextYPos));
|
||||||
|
nextYPos += (*it)->getSize().y + m_padding.y;
|
||||||
|
|
||||||
|
int tmpWidth = ((*it)->getPosition().x - getPosition().x) + (*it)->getSize().x + m_padding.x;
|
||||||
|
|
||||||
|
if(tmpWidth > newWidth)
|
||||||
|
{
|
||||||
|
newWidth = tmpWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_currentSize.x = newWidth;
|
||||||
|
m_currentSize.y = nextYPos;
|
||||||
|
|
||||||
|
this->setRect(0, 0, m_currentSize.x, m_currentSize.y);
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,19 +9,26 @@
|
|||||||
#include "component/view/graphElements/GraphNode.h"
|
#include "component/view/graphElements/GraphNode.h"
|
||||||
|
|
||||||
class QtGraphEdge;
|
class QtGraphEdge;
|
||||||
|
class QtGraphNodeComponent;
|
||||||
|
|
||||||
class QtGraphNode
|
class QtGraphNode
|
||||||
: public GraphNode
|
: public GraphNode
|
||||||
, public QGraphicsRectItem
|
, public QGraphicsRectItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QtGraphNode(const Vec2i& position, const std::string& name, const Id tokenId);
|
QtGraphNode(const Vec2i& position, const Vec2i& size, const std::string& name, const Id tokenId);
|
||||||
virtual ~QtGraphNode();
|
virtual ~QtGraphNode();
|
||||||
|
|
||||||
virtual std::string getName() const;
|
virtual std::string getName() const;
|
||||||
virtual Vec2i getPosition() const;
|
virtual Vec2i getPosition() const;
|
||||||
virtual void setPosition(const Vec2i& position);
|
virtual void setPosition(const Vec2i& position);
|
||||||
|
|
||||||
|
virtual Vec2i getSize() const;
|
||||||
|
|
||||||
|
void setParent(std::weak_ptr<QtGraphNode> parentNode);
|
||||||
|
|
||||||
|
void addComponent(const std::shared_ptr<QtGraphNodeComponent>& component);
|
||||||
|
|
||||||
virtual bool addOutEdge(const std::shared_ptr<GraphEdge>& edge);
|
virtual bool addOutEdge(const std::shared_ptr<GraphEdge>& edge);
|
||||||
virtual bool addInEdge(const std::weak_ptr<GraphEdge>& edge);
|
virtual bool addInEdge(const std::weak_ptr<GraphEdge>& edge);
|
||||||
|
|
||||||
@@ -30,20 +37,54 @@ public:
|
|||||||
virtual std::list<std::shared_ptr<GraphNode>> getSubNodes() const;
|
virtual std::list<std::shared_ptr<GraphNode>> getSubNodes() const;
|
||||||
virtual void addSubNode(const std::shared_ptr<GraphNode>& node);
|
virtual void addSubNode(const std::shared_ptr<GraphNode>& node);
|
||||||
|
|
||||||
|
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
|
||||||
virtual void notifyParentMoved();
|
virtual void notifyParentMoved();
|
||||||
|
|
||||||
|
virtual void hideContent();
|
||||||
|
virtual void showContent();
|
||||||
|
|
||||||
|
virtual void hide();
|
||||||
|
virtual void show();
|
||||||
|
|
||||||
|
virtual bool isHidden();
|
||||||
|
virtual bool contentIsHidden();
|
||||||
|
|
||||||
|
virtual unsigned int getOutEdgeCount() const;
|
||||||
|
virtual unsigned int getInEdgeCount() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the count of all connected edges (including edges of sub nodes)
|
||||||
|
*/
|
||||||
|
virtual unsigned int getEdgeCountRecursive() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void notifyEdgesAfterMove();
|
void notifyEdgesAfterMove();
|
||||||
|
void notifyParentNodeAfterSizeChanged();
|
||||||
|
|
||||||
|
void onChildSizeChanged();
|
||||||
|
|
||||||
std::list<std::shared_ptr<GraphEdge>> m_outEdges;
|
std::list<std::shared_ptr<GraphEdge>> m_outEdges;
|
||||||
std::list<std::weak_ptr<GraphEdge>> m_inEdges;
|
std::list<std::weak_ptr<GraphEdge>> m_inEdges;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void rebuildLayout();
|
||||||
|
|
||||||
QGraphicsTextItem* m_text;
|
QGraphicsTextItem* m_text;
|
||||||
|
|
||||||
|
std::weak_ptr<QtGraphNode> m_parentNode;
|
||||||
std::list<std::shared_ptr<GraphNode>> m_subNodes;
|
std::list<std::shared_ptr<GraphNode>> m_subNodes;
|
||||||
|
|
||||||
|
std::list<std::shared_ptr<QtGraphNodeComponent>> m_components;
|
||||||
|
|
||||||
|
const Vec2i m_baseSize;
|
||||||
|
Vec2i m_currentSize;
|
||||||
|
|
||||||
|
Vec2i m_padding;
|
||||||
|
|
||||||
|
bool m_contentHidden;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QT_GRAPH_NODE_H
|
#endif // QT_GRAPH_NODE_H
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
#include "qt/view/graphElements/QtGraphNodeMouseMovable.h"
|
|
||||||
|
|
||||||
#include "qgraphicssceneevent.h"
|
|
||||||
|
|
||||||
#include "qt/view/graphElements/QtGraphEdge.h"
|
|
||||||
|
|
||||||
QtGraphNodeMouseMovable::QtGraphNodeMouseMovable(const Vec2i& position, const std::string& name, const Id tokenId)
|
|
||||||
: QtGraphNode(position, name, tokenId)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QtGraphNodeMouseMovable::~QtGraphNodeMouseMovable()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtGraphNodeMouseMovable::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
|
||||||
{
|
|
||||||
m_mouseOffset.x = event->pos().x();
|
|
||||||
m_mouseOffset.y = event->pos().y();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtGraphNodeMouseMovable::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
|
||||||
{
|
|
||||||
this->setPos(event->scenePos().x() - m_mouseOffset.x, event->scenePos().y() - m_mouseOffset.y);
|
|
||||||
|
|
||||||
Vec2i p(event->scenePos().x(), event->scenePos().y());
|
|
||||||
|
|
||||||
notifyEdgesAfterMove();
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
#ifndef QT_GRAPH_NODE_MOUSE_MOVABLE_H
|
|
||||||
#define QT_GRAPH_NODE_MOUSE_MOVABLE_H
|
|
||||||
|
|
||||||
#include "qt/view/graphElements/QtGraphNode.h"
|
|
||||||
|
|
||||||
class QtGraphNodeMouseMovable : public QtGraphNode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QtGraphNodeMouseMovable(const Vec2i& position, const std::string& name, const Id tokenId);
|
|
||||||
virtual ~QtGraphNodeMouseMovable();
|
|
||||||
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Vec2i m_mouseOffset;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // QT_GRAPH_NODE_MOUSE_MOVABLE_H
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include "QtGraphNodeComponent.h"
|
||||||
|
|
||||||
|
QtGraphNodeComponent::QtGraphNodeComponent(const std::weak_ptr<QtGraphNode>& graphNode)
|
||||||
|
: m_graphNode(graphNode)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QtGraphNodeComponent::~QtGraphNodeComponent()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef QT_GRAPH_NODE_COMPONENT_H
|
||||||
|
#define QT_GRAPH_NODE_COMPONENT_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
|
||||||
|
class QtGraphNode;
|
||||||
|
|
||||||
|
class QtGraphNodeComponent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QtGraphNodeComponent(const std::weak_ptr<QtGraphNode>& graphNode);
|
||||||
|
~QtGraphNodeComponent();
|
||||||
|
|
||||||
|
virtual void nodeMousePressEvent(QGraphicsSceneMouseEvent* event) = 0;
|
||||||
|
virtual void nodeMouseMoveEvent(QGraphicsSceneMouseEvent* event) = 0;
|
||||||
|
virtual void nodeMouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::weak_ptr<QtGraphNode> m_graphNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_GRAPH_NODE_COMPONENT_H
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#include "QtGraphNodeComponentMoveable.h"
|
||||||
|
|
||||||
|
#include <QGraphicsSceneEvent>
|
||||||
|
|
||||||
|
#include "qt/view/graphElements/QtGraphNode.h"
|
||||||
|
|
||||||
|
QtGraphNodeComponentMoveable::QtGraphNodeComponentMoveable(const std::weak_ptr<QtGraphNode>& graphNode)
|
||||||
|
: QtGraphNodeComponent(graphNode)
|
||||||
|
, m_mouseOffset(0.0f, 0.0f)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QtGraphNodeComponentMoveable::~QtGraphNodeComponentMoveable()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNodeComponentMoveable::nodeMousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||||
|
{
|
||||||
|
m_mouseOffset.x = event->pos().x();
|
||||||
|
m_mouseOffset.y = event->pos().y();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNodeComponentMoveable::nodeMouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
||||||
|
{
|
||||||
|
std::shared_ptr<GraphNode> node = m_graphNode.lock();
|
||||||
|
|
||||||
|
if(node != NULL)
|
||||||
|
{
|
||||||
|
node->setPosition(Vec2i(event->scenePos().x() - m_mouseOffset.x, event->scenePos().y() - m_mouseOffset.y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNodeComponentMoveable::nodeMouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef QT_GRAPH_NODE_COMPONENT_MOVEABLE
|
||||||
|
#define QT_GRAPH_NODE_COMPONENT_MOVEABLE
|
||||||
|
|
||||||
|
#include "QtGraphNodeComponent.h"
|
||||||
|
|
||||||
|
#include "utility/math/Vector2.h"
|
||||||
|
|
||||||
|
class QtGraphNodeComponentMoveable
|
||||||
|
: public QtGraphNodeComponent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QtGraphNodeComponentMoveable(const std::weak_ptr<QtGraphNode>& graphNode);
|
||||||
|
~QtGraphNodeComponentMoveable();
|
||||||
|
|
||||||
|
virtual void nodeMousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
virtual void nodeMouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
virtual void nodeMouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Vec2i m_mouseOffset;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_GRAPH_NODE_COMPONENT_MOVEABLE
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
#include "QtGraphNodeComponentToggleButton.h"
|
||||||
|
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsSceneEvent>
|
||||||
|
|
||||||
|
#include "qt/view/graphElements/QtGraphNode.h"
|
||||||
|
|
||||||
|
QtGraphNodeComponentToggleButton::QtGraphNodeComponentToggleButton(const std::weak_ptr<QtGraphNode>& graphNode)
|
||||||
|
: QtGraphNodeComponent(graphNode)
|
||||||
|
{
|
||||||
|
this->setRect(0, 0, 10, 10);
|
||||||
|
this->setPos(0, 0);
|
||||||
|
QBrush brush(Qt::darkGray);
|
||||||
|
this->setBrush(brush);
|
||||||
|
|
||||||
|
std::shared_ptr<QtGraphNode> node = graphNode.lock();
|
||||||
|
if(node != NULL)
|
||||||
|
{
|
||||||
|
this->setParentItem(node.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QtGraphNodeComponentToggleButton::~QtGraphNodeComponentToggleButton()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNodeComponentToggleButton::nodeMousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNodeComponentToggleButton::nodeMouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNodeComponentToggleButton::nodeMouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNodeComponentToggleButton::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||||
|
{
|
||||||
|
std::shared_ptr<QtGraphNode> node = m_graphNode.lock();
|
||||||
|
if(node != NULL)
|
||||||
|
{
|
||||||
|
if(node->contentIsHidden())
|
||||||
|
{
|
||||||
|
node->showContent();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
node->hideContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNodeComponentToggleButton::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtGraphNodeComponentToggleButton::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef QT_GRAPH_NODE_COMPONENT_TOGGLE_BUTTON_H
|
||||||
|
#define QT_GRAPH_NODE_COMPONENT_TOGGLE_BUTTON_H
|
||||||
|
|
||||||
|
#include "QtGraphNodeComponent.h"
|
||||||
|
|
||||||
|
class QtGraphNodeComponentToggleButton
|
||||||
|
: public QtGraphNodeComponent
|
||||||
|
, public QGraphicsRectItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QtGraphNodeComponentToggleButton(const std::weak_ptr<QtGraphNode>& graphNode);
|
||||||
|
~QtGraphNodeComponentToggleButton();
|
||||||
|
|
||||||
|
virtual void nodeMousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
virtual void nodeMouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
virtual void nodeMouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
|
||||||
|
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_GRAPH_NODE_COMPONENT_TOGGLE_BUTTON_H
|
||||||
@@ -20,6 +20,8 @@ public:
|
|||||||
virtual Vec2i getPosition() const = 0;
|
virtual Vec2i getPosition() const = 0;
|
||||||
virtual void setPosition(const Vec2i& position) = 0;
|
virtual void setPosition(const Vec2i& position) = 0;
|
||||||
|
|
||||||
|
virtual Vec2i getSize() const = 0;
|
||||||
|
|
||||||
virtual bool addOutEdge(const std::shared_ptr<GraphEdge>& edge) = 0;
|
virtual bool addOutEdge(const std::shared_ptr<GraphEdge>& edge) = 0;
|
||||||
virtual bool addInEdge(const std::weak_ptr<GraphEdge>& edge) = 0;
|
virtual bool addInEdge(const std::weak_ptr<GraphEdge>& edge) = 0;
|
||||||
|
|
||||||
@@ -30,6 +32,20 @@ public:
|
|||||||
|
|
||||||
virtual void notifyParentMoved() = 0;
|
virtual void notifyParentMoved() = 0;
|
||||||
|
|
||||||
|
virtual void hideContent() = 0;
|
||||||
|
virtual void showContent() = 0;
|
||||||
|
|
||||||
|
virtual void hide() = 0;
|
||||||
|
virtual void show() = 0;
|
||||||
|
|
||||||
|
virtual bool isHidden() = 0;
|
||||||
|
virtual bool contentIsHidden() = 0;
|
||||||
|
|
||||||
|
virtual unsigned int getOutEdgeCount() const = 0;
|
||||||
|
virtual unsigned int getInEdgeCount() const = 0;
|
||||||
|
|
||||||
|
virtual unsigned int getEdgeCountRecursive() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Id m_tokenId;
|
Id m_tokenId;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public:
|
|||||||
~Property();
|
~Property();
|
||||||
|
|
||||||
T& operator=(const T& value);
|
T& operator=(const T& value);
|
||||||
|
T& operator=(const Property& property);
|
||||||
|
|
||||||
operator const T&() const;
|
operator const T&() const;
|
||||||
|
|
||||||
@@ -34,6 +35,13 @@ T& Property<T>::operator=(const T& value)
|
|||||||
return *m_valuePointer;
|
return *m_valuePointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T& Property<T>::operator=(const Property& property)
|
||||||
|
{
|
||||||
|
*m_valuePointer = *property.m_valuePointer;
|
||||||
|
return *m_valuePointer;
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Property<T>::operator const T&() const
|
Property<T>::operator const T&() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ template<class U>
|
|||||||
void Vector2<T>::operator=(const Vector2<U>& other)
|
void Vector2<T>::operator=(const Vector2<U>& other)
|
||||||
{
|
{
|
||||||
this->assign(other);
|
this->assign(other);
|
||||||
|
x = Property(&VectorBase<T, 2>::m_values[m_xIndex]);
|
||||||
|
y = Property(&VectorBase<T, 2>::m_values[m_yIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef Vector2<float> Vec2f;
|
typedef Vector2<float> Vec2f;
|
||||||
|
|||||||
Reference in New Issue
Block a user