logic: only show edges connected to active node
* split active and visible setting for DummyNodes * set and check visible on DummyEdges * include fix for Mac in MatrixDynamicBase * fix for disappearing style and crashes in GraphView * cleaned up DummyNode fortune cookie message = Du stehst kurz davor etwas Neues zu unternehmen.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
#include "QtGraphView.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QFrame>
|
||||
#include <QGraphicsScene>
|
||||
@@ -153,8 +151,6 @@ void QtGraphView::doRebuildGraph(
|
||||
node->hoverEnter();
|
||||
}
|
||||
}
|
||||
|
||||
m_graph = graph;
|
||||
}
|
||||
|
||||
void QtGraphView::doClear()
|
||||
@@ -233,6 +229,11 @@ std::shared_ptr<QtGraphNode> QtGraphView::createNodeRecursive(
|
||||
|
||||
std::shared_ptr<QtGraphEdge> QtGraphView::createEdge(QGraphicsView* view, const DummyEdge& edge)
|
||||
{
|
||||
if (!edge.visible)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::shared_ptr<QtGraphNode> owner = findNodeRecursive(m_nodes, edge.ownerId);
|
||||
std::shared_ptr<QtGraphNode> target = findNodeRecursive(m_nodes, edge.targetId);
|
||||
|
||||
|
||||
@@ -147,7 +147,8 @@ void GraphController::createDummyGraphForTokenIds(const std::vector<Id>& tokenId
|
||||
|
||||
DummyNode GraphController::createDummyNodeTopDown(Node* node)
|
||||
{
|
||||
DummyNode result(node);
|
||||
DummyNode result;
|
||||
result.data = node;
|
||||
result.tokenId = node->getId();
|
||||
|
||||
// there is a global root node with id 0 afaik, so here we actually want the one node below this global root
|
||||
@@ -200,7 +201,9 @@ DummyNode GraphController::createDummyNodeTopDown(Node* node)
|
||||
|
||||
if (!parent)
|
||||
{
|
||||
result.subNodes.push_back(DummyNode(accessType));
|
||||
DummyNode accessNode;
|
||||
accessNode.accessType = accessType;
|
||||
result.subNodes.push_back(accessNode);
|
||||
parent = &result.subNodes.back();
|
||||
|
||||
DummyNode* oldParent = findDummyNodeAccessRecursive(m_dummyNodes, node->getId(), accessType);
|
||||
@@ -223,15 +226,6 @@ DummyNode GraphController::createDummyNodeTopDown(Node* node)
|
||||
return;
|
||||
}
|
||||
|
||||
if (edge->isType(Edge::EDGE_AGGREGATION))
|
||||
{
|
||||
result.aggregated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.connected = true;
|
||||
}
|
||||
|
||||
for (const DummyEdge& dummy : m_dummyEdges)
|
||||
{
|
||||
if (dummy.data->getId() == edge->getId())
|
||||
@@ -273,23 +267,45 @@ void GraphController::setActiveAndVisibility(const std::vector<Id>& activeTokenI
|
||||
{
|
||||
for (DummyNode& node : m_dummyNodes)
|
||||
{
|
||||
setNodeActiveAndVisibilityRecursiveBottomUp(node, activeTokenIds, false);
|
||||
setNodeActiveRecursive(node, activeTokenIds);
|
||||
}
|
||||
|
||||
for (DummyEdge& edge : m_dummyEdges)
|
||||
{
|
||||
edge.visible = true;
|
||||
edge.active = false;
|
||||
if (find(activeTokenIds.begin(), activeTokenIds.end(), edge.data->getId()) != activeTokenIds.end())
|
||||
{
|
||||
edge.active = true;
|
||||
}
|
||||
|
||||
DummyNode* from = findDummyNodeRecursive(m_dummyNodes, edge.ownerId);
|
||||
DummyNode* to = findDummyNodeRecursive(m_dummyNodes, edge.targetId);
|
||||
|
||||
if (from && to && (from->active || to->active || edge.active))
|
||||
{
|
||||
edge.visible = true;
|
||||
|
||||
if (edge.data->isType(Edge::EDGE_AGGREGATION))
|
||||
{
|
||||
from->aggregated = true;
|
||||
to->aggregated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
from->connected = true;
|
||||
to->connected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (DummyNode& node : m_dummyNodes)
|
||||
{
|
||||
setNodeVisibilityRecursiveBottomUp(node, false);
|
||||
}
|
||||
}
|
||||
|
||||
bool GraphController::setNodeActiveAndVisibilityRecursiveBottomUp(
|
||||
DummyNode& node, const std::vector<Id>& activeTokenIds, bool aggregated
|
||||
) const {
|
||||
void GraphController::setNodeActiveRecursive(DummyNode& node, const std::vector<Id>& activeTokenIds) const
|
||||
{
|
||||
node.visible = false;
|
||||
node.active = false;
|
||||
|
||||
@@ -298,10 +314,18 @@ bool GraphController::setNodeActiveAndVisibilityRecursiveBottomUp(
|
||||
node.active = find(activeTokenIds.begin(), activeTokenIds.end(), node.data->getId()) != activeTokenIds.end();
|
||||
}
|
||||
|
||||
for (DummyNode& subNode : node.subNodes)
|
||||
{
|
||||
setNodeActiveRecursive(subNode, activeTokenIds);
|
||||
}
|
||||
}
|
||||
|
||||
bool GraphController::setNodeVisibilityRecursiveBottomUp(DummyNode& node, bool aggregated) const
|
||||
{
|
||||
bool childVisible = false;
|
||||
for (DummyNode& subNode : node.subNodes)
|
||||
{
|
||||
if (setNodeActiveAndVisibilityRecursiveBottomUp(subNode, activeTokenIds, aggregated | node.aggregated))
|
||||
if (setNodeVisibilityRecursiveBottomUp(subNode, aggregated | node.aggregated))
|
||||
{
|
||||
childVisible = true;
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ private:
|
||||
void autoExpandActiveNode(const std::vector<Id>& activeTokenIds);
|
||||
|
||||
void setActiveAndVisibility(const std::vector<Id>& activeTokenIds);
|
||||
bool setNodeActiveAndVisibilityRecursiveBottomUp(
|
||||
DummyNode& node, const std::vector<Id>& activeTokenIds, bool aggregated) const;
|
||||
void setNodeActiveRecursive(DummyNode& node, const std::vector<Id>& activeTokenIds) const;
|
||||
bool setNodeVisibilityRecursiveBottomUp(DummyNode& node, bool aggregated) const;
|
||||
void setNodeVisibilityRecursiveTopDown(DummyNode& node) const;
|
||||
|
||||
void layoutNesting();
|
||||
|
||||
@@ -58,25 +58,8 @@ public:
|
||||
, autoExpanded(false)
|
||||
, invisibleSubNodeCount(0)
|
||||
, visible(false)
|
||||
{
|
||||
}
|
||||
|
||||
DummyNode(const Node* data)
|
||||
: data(data)
|
||||
, accessType(TokenComponentAccess::ACCESS_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
DummyNode(TokenComponentAccess::AccessType accessType)
|
||||
: data(nullptr)
|
||||
, accessType(accessType)
|
||||
, active(false)
|
||||
, connected(false)
|
||||
, aggregated(false)
|
||||
, expanded(false)
|
||||
, autoExpanded(false)
|
||||
, invisibleSubNodeCount(0)
|
||||
, visible(false)
|
||||
, topLevelAncestorId(0)
|
||||
, tokenId(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -85,45 +68,6 @@ public:
|
||||
return expanded || autoExpanded;
|
||||
}
|
||||
|
||||
bool operator==(const DummyNode& other) const
|
||||
{
|
||||
if (data->getId() == other.data->getId()
|
||||
&& data->getName() == other.data->getName())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator!=(const DummyNode& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
bool operator<(const DummyNode& other) const
|
||||
{
|
||||
if (data->getId() < other.data->getId())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator>(const DummyNode& other) const
|
||||
{
|
||||
return !(*this < other);
|
||||
}
|
||||
|
||||
DummyNode& operator=(const DummyNode& other)
|
||||
{
|
||||
data = other.data;
|
||||
subNodes = other.subNodes;
|
||||
position = other.position;
|
||||
topLevelAncestorId = other.topLevelAncestorId;
|
||||
tokenId = other.tokenId;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const Node* data;
|
||||
TokenComponentAccess::AccessType accessType;
|
||||
|
||||
@@ -139,10 +83,10 @@ public:
|
||||
size_t invisibleSubNodeCount;
|
||||
|
||||
bool visible;
|
||||
|
||||
|
||||
Id topLevelAncestorId;
|
||||
Id tokenId;
|
||||
|
||||
|
||||
std::vector<DummyNode> subNodes;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef MATRIX_DYNAMIC_BASE_H
|
||||
#define MATRIX_DYNAMIC_BASE_H
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user