logic: Group nodes in inheritance graph who have the same base and derived nodes (issue #459)
* added graph node for grouping nodes with separate sub-layout * group nodes show name in top left corner * clicking on single edge activates source locations of all edges * removed separate setters for token components * fixed text nodes missing or too many in list layout * moved simple row and column layouts to ListLayouter * added skewed layout type to ListLayouter fortune cookie message = Sometimes you should have the courage and risk something.
This commit is contained in:
@@ -127,6 +127,8 @@ add_files(
|
||||
qt/view/graphElements/QtGraphNodeData.h
|
||||
qt/view/graphElements/QtGraphNodeExpandToggle.cpp
|
||||
qt/view/graphElements/QtGraphNodeExpandToggle.h
|
||||
qt/view/graphElements/QtGraphNodeGroup.cpp
|
||||
qt/view/graphElements/QtGraphNodeGroup.h
|
||||
qt/view/graphElements/QtGraphNodeQualifier.cpp
|
||||
qt/view/graphElements/QtGraphNodeQualifier.h
|
||||
qt/view/graphElements/QtGraphNodeText.cpp
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "qt/view/graphElements/QtGraphNodeBundle.h"
|
||||
#include "qt/view/graphElements/QtGraphNodeData.h"
|
||||
#include "qt/view/graphElements/QtGraphNodeExpandToggle.h"
|
||||
#include "qt/view/graphElements/QtGraphNodeGroup.h"
|
||||
#include "qt/view/graphElements/QtGraphNodeQualifier.h"
|
||||
#include "qt/view/graphElements/QtGraphNodeText.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
@@ -890,6 +891,10 @@ QtGraphNode* QtGraphView::createNodeRecursive(
|
||||
{
|
||||
newNode = new QtGraphNodeText(node->name);
|
||||
}
|
||||
else if (node->isGroupNode())
|
||||
{
|
||||
newNode = new QtGraphNodeGroup(node->tokenId, node->name, node->groupType);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("DummyNode is not valid");
|
||||
@@ -1083,7 +1088,8 @@ void QtGraphView::compareNodesRecursive(
|
||||
dynamic_cast<QtGraphNodeAccess*>(*it2)->getAccessKind()) ||
|
||||
((*it)->isExpandToggleNode() && (*it2)->isExpandToggleNode()) ||
|
||||
((*it)->isBundleNode() && (*it2)->isBundleNode() && (*it)->getTokenId() == (*it2)->getTokenId()) ||
|
||||
((*it)->isQualifierNode() && (*it2)->isQualifierNode() && (*it)->getTokenId() == (*it2)->getTokenId()))
|
||||
((*it)->isQualifierNode() && (*it2)->isQualifierNode() && (*it)->getTokenId() == (*it2)->getTokenId()) ||
|
||||
((*it)->isGroupNode() && (*it2)->isGroupNode() && (*it)->getName() == (*it2)->getName()))
|
||||
{
|
||||
remainingNodes->push_back(std::pair<QtGraphNode*, QtGraphNode*>(*it, *it2));
|
||||
compareNodesRecursive(
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "data/graph/Edge.h"
|
||||
#include "data/graph/token_component/TokenComponentAggregation.h"
|
||||
#include "data/graph/token_component/TokenComponentEdgeIds.h"
|
||||
#include "data/graph/token_component/TokenComponentInheritanceChain.h"
|
||||
#include "qt/graphics/QtLineItemAngled.h"
|
||||
#include "qt/graphics/QtLineItemBezier.h"
|
||||
@@ -251,8 +252,11 @@ void QtGraphEdge::onClick()
|
||||
{
|
||||
if (isTrailEdge())
|
||||
{
|
||||
TokenComponentEdgeIds* componentEdgeIds = getData()->getComponent<TokenComponentEdgeIds>();
|
||||
std::vector<Id> ids = { getData()->getId() };
|
||||
|
||||
MessageActivateTrailEdge(
|
||||
getData()->getId(),
|
||||
componentEdgeIds ? componentEdgeIds->edgeIds : ids,
|
||||
getData()->getType(),
|
||||
getData()->getFrom()->getNameHierarchy(),
|
||||
getData()->getTo()->getNameHierarchy()
|
||||
|
||||
@@ -330,6 +330,11 @@ bool QtGraphNode::isTextNode() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QtGraphNode::isGroupNode() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Id QtGraphNode::getTokenId() const
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -87,6 +87,7 @@ public:
|
||||
virtual bool isBundleNode() const;
|
||||
virtual bool isQualifierNode() const;
|
||||
virtual bool isTextNode() const;
|
||||
virtual bool isGroupNode() const;
|
||||
|
||||
virtual Id getTokenId() const;
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
#include "qt/view/graphElements/QtGraphNodeGroup.h"
|
||||
|
||||
#include <QBrush>
|
||||
#include <QGraphicsRectItem>
|
||||
#include <QPen>
|
||||
|
||||
#include "qt/graphics/QtRoundedRectItem.h"
|
||||
|
||||
QtGraphNodeGroup::QtGraphNodeGroup(Id tokenId, const std::wstring& name, NodeType::GroupType type)
|
||||
: m_tokenId(tokenId)
|
||||
, m_type(type)
|
||||
{
|
||||
setName(name);
|
||||
setZValue(-10.0f);
|
||||
m_rect->setZValue(-10.0f);
|
||||
|
||||
if (type == NodeType::GROUP_FRAMELESS)
|
||||
{
|
||||
m_rect->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!name.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_background = new QtRoundedRectItem(this);
|
||||
m_backgroundTopRight = new QGraphicsRectItem(this);
|
||||
m_backgroundBottomLeft = new QGraphicsRectItem(this);
|
||||
|
||||
m_background->setZValue(-10.0f);
|
||||
m_backgroundTopRight->setZValue(-10.0f);
|
||||
m_backgroundBottomLeft->setZValue(-10.0f);
|
||||
|
||||
GraphViewStyle::NodeStyle style = GraphViewStyle::getStyleOfGroupNode(type, false);
|
||||
GraphViewStyle::NodeMargins margins = GraphViewStyle::getMarginsOfGroupNode(type, true);
|
||||
|
||||
int width = style.textOffset.x * 2 + style.borderWidth + margins.charWidth * name.size();
|
||||
int height = margins.top * 2 + margins.charHeight;
|
||||
|
||||
m_background->setRadius(style.cornerRadius);
|
||||
m_background->setRect(0, 0, width, height);
|
||||
|
||||
m_backgroundTopRight->setRect(width - style.cornerRadius, 0, style.cornerRadius, style.cornerRadius);
|
||||
m_backgroundBottomLeft->setRect(0, height - style.cornerRadius, style.cornerRadius, style.cornerRadius);
|
||||
}
|
||||
|
||||
QtGraphNodeGroup::~QtGraphNodeGroup()
|
||||
{
|
||||
}
|
||||
|
||||
bool QtGraphNodeGroup::isGroupNode() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Id QtGraphNodeGroup::getTokenId() const
|
||||
{
|
||||
return m_tokenId;
|
||||
}
|
||||
|
||||
void QtGraphNodeGroup::updateStyle()
|
||||
{
|
||||
GraphViewStyle::NodeStyle style = GraphViewStyle::getStyleOfGroupNode(m_type, false);
|
||||
|
||||
if (m_background)
|
||||
{
|
||||
m_background->setBrush(QColor(style.color.border.c_str()));
|
||||
m_background->setPen(QPen(Qt::transparent));
|
||||
|
||||
m_backgroundTopRight->setBrush(QColor(style.color.border.c_str()));
|
||||
m_backgroundTopRight->setPen(QPen(Qt::transparent));
|
||||
|
||||
m_backgroundBottomLeft->setBrush(QColor(style.color.border.c_str()));
|
||||
m_backgroundBottomLeft->setPen(QPen(Qt::transparent));
|
||||
}
|
||||
|
||||
setStyle(style);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef QT_GRAPH_NODE_GROUP_H
|
||||
#define QT_GRAPH_NODE_GROUP_H
|
||||
|
||||
#include "data/NodeType.h"
|
||||
#include "qt/view/graphElements/QtGraphNode.h"
|
||||
|
||||
class QGraphicsRectItem;
|
||||
class QtRoundedRectItem;
|
||||
|
||||
class QtGraphNodeGroup
|
||||
: public QtGraphNode
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtGraphNodeGroup(Id tokenId, const std::wstring& name, NodeType::GroupType type);
|
||||
virtual ~QtGraphNodeGroup();
|
||||
|
||||
// QtGraphNode implementation
|
||||
virtual bool isGroupNode() const;
|
||||
virtual Id getTokenId() const;
|
||||
|
||||
virtual void updateStyle();
|
||||
|
||||
private:
|
||||
Id m_tokenId;
|
||||
NodeType::GroupType m_type;
|
||||
|
||||
QtRoundedRectItem* m_background = nullptr;
|
||||
QGraphicsRectItem* m_backgroundTopRight = nullptr;
|
||||
QGraphicsRectItem* m_backgroundBottomLeft = nullptr;
|
||||
};
|
||||
|
||||
#endif // QT_GRAPH_NODE_GROUP_H
|
||||
Reference in New Issue
Block a user