ui: fixes and improvements in graph
* use bezier edges for aggregations * fixed expanding nodes in trail graph makes trouble * fixed hovering of edges at arrow
This commit is contained in:
@@ -209,8 +209,6 @@ void BookmarkController::handleMessage(MessageActivateBookmark* message)
|
||||
|
||||
void BookmarkController::handleMessage(MessageActivateTokens* message)
|
||||
{
|
||||
LOG_INFO_STREAM(<< "Registering new active token");
|
||||
|
||||
m_activeEdgeIds.clear();
|
||||
|
||||
if (message->isEdge || message->isAggregation)
|
||||
@@ -228,8 +226,6 @@ void BookmarkController::handleMessage(MessageActivateTokens* message)
|
||||
}
|
||||
else if (!message->isEdge)
|
||||
{
|
||||
LOG_INFO_STREAM(<< "Registering new Node");
|
||||
|
||||
m_activeNodeIds = message->tokenIds;
|
||||
|
||||
if (getBookmarkForActiveToken())
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <set>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageActivateNodes.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/tracing.h"
|
||||
#include "utility/utility.h"
|
||||
@@ -55,7 +56,14 @@ void GraphController::handleMessage(MessageActivateTokens* message)
|
||||
{
|
||||
m_activeEdgeIds = message->tokenIds;
|
||||
setActiveAndVisibility(utility::concat(m_activeNodeIds, m_activeEdgeIds));
|
||||
buildGraph(message, false, false, false);
|
||||
|
||||
Id edgeId = 0;
|
||||
if (message->isEdge && message->tokenIds.size() == 1)
|
||||
{
|
||||
edgeId = message->tokenIds[0];
|
||||
}
|
||||
|
||||
getView()->activateEdge(edgeId, message->isReplayed());
|
||||
return;
|
||||
}
|
||||
else if (message->isAggregation)
|
||||
@@ -252,6 +260,14 @@ void GraphController::handleMessage(MessageGraphNodeExpand* message)
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_graph && m_graph->getTrailMode() != Graph::TRAIL_NONE)
|
||||
{
|
||||
MessageActivateNodes msg;
|
||||
msg.addNode(message->tokenId, m_storageAccess->getNameHierarchyForNodeId(message->tokenId));
|
||||
msg.dispatch();
|
||||
return;
|
||||
}
|
||||
|
||||
DummyNode* node = getDummyGraphNodeById(message->tokenId);
|
||||
if (node)
|
||||
{
|
||||
@@ -1548,6 +1564,13 @@ void GraphController::buildGraph(
|
||||
params.animatedTransition = animatedTransition;
|
||||
params.scrollToTop = scrollToTop;
|
||||
params.isIndexedList = scrollToTop;
|
||||
params.bezierEdges = false;
|
||||
|
||||
MessageActivateTokens* msg = dynamic_cast<MessageActivateTokens*>(message);
|
||||
if (msg && msg->isAggregation)
|
||||
{
|
||||
params.bezierEdges = true;
|
||||
}
|
||||
|
||||
getView()->rebuildGraph(m_graph, m_dummyNodes, m_dummyEdges, params);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
bool centerActiveNode;
|
||||
bool scrollToTop;
|
||||
bool isIndexedList;
|
||||
bool bezierEdges;
|
||||
};
|
||||
|
||||
GraphView(ViewLayout* viewLayout);
|
||||
|
||||
@@ -25,7 +25,7 @@ QPainterPath QtLineItemAngled::shape() const
|
||||
path.addRect(QRectF(poly.at(i), poly.at(i + 1)).normalized().adjusted(-5, -5, 5, 5));
|
||||
}
|
||||
|
||||
path.addRect(getArrowBoundingRect(poly).adjusted(-3, -3, 3, 3));
|
||||
// path.addRect(getArrowBoundingRect(poly).adjusted(-3, -3, 3, 3));
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,11 @@ void QtGraphView::activateEdge(Id edgeId, bool centerOrigin)
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
clickedInEmptySpace();
|
||||
for (std::shared_ptr<QtGraphEdge> edge : m_oldEdges)
|
||||
{
|
||||
edge->setIsActive(false);
|
||||
edge->setIsFocused(false);
|
||||
}
|
||||
|
||||
for (std::shared_ptr<QtGraphEdge> edge : m_oldEdges)
|
||||
{
|
||||
@@ -627,7 +631,7 @@ void QtGraphView::doRebuildGraph(
|
||||
{
|
||||
if (!edge->data || !edge->data->isType(Edge::EDGE_AGGREGATION))
|
||||
{
|
||||
createEdge(view, edge.get(), &visibleEdgeIds, trailMode, offset);
|
||||
createEdge(view, edge.get(), &visibleEdgeIds, trailMode, offset, params.bezierEdges);
|
||||
}
|
||||
}
|
||||
for (const std::shared_ptr<DummyEdge> edge : edges)
|
||||
@@ -790,7 +794,12 @@ std::shared_ptr<QtGraphNode> QtGraphView::createNodeRecursive(
|
||||
}
|
||||
|
||||
std::shared_ptr<QtGraphEdge> QtGraphView::createEdge(
|
||||
QGraphicsView* view, const DummyEdge* edge, std::set<Id>* visibleEdgeIds, Graph::TrailMode trailMode, QPointF pathOffset)
|
||||
QGraphicsView* view,
|
||||
const DummyEdge* edge,
|
||||
std::set<Id>* visibleEdgeIds,
|
||||
Graph::TrailMode trailMode,
|
||||
QPointF pathOffset,
|
||||
bool useBezier)
|
||||
{
|
||||
if (!edge->visible)
|
||||
{
|
||||
@@ -803,7 +812,7 @@ std::shared_ptr<QtGraphEdge> QtGraphView::createEdge(
|
||||
if (owner != NULL && target != NULL)
|
||||
{
|
||||
std::shared_ptr<QtGraphEdge> qtEdge =
|
||||
std::make_shared<QtGraphEdge>(owner, target, edge->data, edge->getWeight(), edge->active, edge->getDirection());
|
||||
std::make_shared<QtGraphEdge>(owner, target, edge->data, edge->getWeight(), edge->active && !useBezier, edge->getDirection());
|
||||
|
||||
if (trailMode != Graph::TRAIL_NONE)
|
||||
{
|
||||
@@ -823,6 +832,10 @@ std::shared_ptr<QtGraphEdge> QtGraphView::createEdge(
|
||||
|
||||
qtEdge->setIsTrailEdge(path, trailMode == Graph::TRAIL_HORIZONTAL);
|
||||
}
|
||||
else if (useBezier)
|
||||
{
|
||||
qtEdge->setUseBezier(true);
|
||||
}
|
||||
|
||||
qtEdge->updateLine();
|
||||
|
||||
@@ -869,7 +882,7 @@ std::shared_ptr<QtGraphEdge> QtGraphView::createAggregationEdge(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return createEdge(view, edge, visibleEdgeIds, Graph::TRAIL_NONE, QPointF());
|
||||
return createEdge(view, edge, visibleEdgeIds, Graph::TRAIL_NONE, QPointF(), false);
|
||||
}
|
||||
|
||||
QRectF QtGraphView::itemsBoundingRect(const std::list<std::shared_ptr<QtGraphNode>>& items) const
|
||||
|
||||
@@ -98,7 +98,7 @@ private:
|
||||
std::shared_ptr<QtGraphNode> createNodeRecursive(
|
||||
QGraphicsView* view, std::shared_ptr<QtGraphNode> parentNode, const DummyNode* node, bool multipleActive);
|
||||
std::shared_ptr<QtGraphEdge> createEdge(
|
||||
QGraphicsView* view, const DummyEdge* edge, std::set<Id>* visibleEdgeIds, Graph::TrailMode trailMode, QPointF pathOffset);
|
||||
QGraphicsView* view, const DummyEdge* edge, std::set<Id>* visibleEdgeIds, Graph::TrailMode trailMode, QPointF pathOffset, bool useBezier);
|
||||
std::shared_ptr<QtGraphEdge> createAggregationEdge(
|
||||
QGraphicsView* view, const DummyEdge* edge, std::set<Id>* visibleEdgeIds);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "utility/messaging/type/MessageGraphNodeBundleSplit.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
QtGraphEdge* QtGraphEdge::s_focusedTrailEdge = nullptr;
|
||||
QtGraphEdge* QtGraphEdge::s_focusedBezierEdge = nullptr;
|
||||
|
||||
QtGraphEdge::QtGraphEdge(
|
||||
const std::weak_ptr<QtGraphNode>& owner,
|
||||
@@ -39,6 +39,7 @@ QtGraphEdge::QtGraphEdge(
|
||||
, m_direction(direction)
|
||||
, m_isTrailEdge(false)
|
||||
, m_isHorizontalTrail(false)
|
||||
, m_useBezier(false)
|
||||
, m_mousePos(0.0f, 0.0f)
|
||||
, m_mouseMoved(false)
|
||||
{
|
||||
@@ -50,7 +51,7 @@ QtGraphEdge::QtGraphEdge(
|
||||
m_fromActive = m_owner.lock()->getIsActive();
|
||||
m_toActive = m_target.lock()->getIsActive();
|
||||
|
||||
s_focusedTrailEdge = nullptr;
|
||||
s_focusedBezierEdge = nullptr;
|
||||
}
|
||||
|
||||
QtGraphEdge::~QtGraphEdge()
|
||||
@@ -105,7 +106,7 @@ void QtGraphEdge::updateLine()
|
||||
|
||||
GraphViewStyle::EdgeStyle style = GraphViewStyle::getStyleForEdgeType(type, m_isActive | m_isFocused, false, m_isTrailEdge);
|
||||
|
||||
if (m_isTrailEdge)
|
||||
if (m_useBezier)
|
||||
{
|
||||
for (QGraphicsItem* item : childItems())
|
||||
{
|
||||
@@ -322,36 +323,38 @@ void QtGraphEdge::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
|
||||
|
||||
void QtGraphEdge::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
|
||||
{
|
||||
if (!getData() || isTrailEdge())
|
||||
if (m_useBezier)
|
||||
{
|
||||
if (isTrailEdge())
|
||||
if (s_focusedBezierEdge && s_focusedBezierEdge != this)
|
||||
{
|
||||
if (s_focusedTrailEdge && s_focusedTrailEdge != this)
|
||||
{
|
||||
s_focusedTrailEdge->focusOut();
|
||||
}
|
||||
|
||||
s_focusedTrailEdge = this;
|
||||
s_focusedBezierEdge->focusOut();
|
||||
}
|
||||
|
||||
focusIn();
|
||||
return;
|
||||
s_focusedBezierEdge = this;
|
||||
}
|
||||
|
||||
MessageFocusIn(std::vector<Id>(1, getData()->getId())).dispatch();
|
||||
if (getData() && !m_useBezier)
|
||||
{
|
||||
MessageFocusIn(std::vector<Id>(1, getData()->getId())).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
focusIn();
|
||||
}
|
||||
}
|
||||
|
||||
void QtGraphEdge::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
|
||||
{
|
||||
s_focusedTrailEdge = nullptr;
|
||||
s_focusedBezierEdge = nullptr;
|
||||
|
||||
if (!getData() || isTrailEdge())
|
||||
if (getData() && !m_useBezier)
|
||||
{
|
||||
MessageFocusOut(std::vector<Id>(1, getData()->getId())).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
focusOut();
|
||||
return;
|
||||
}
|
||||
|
||||
MessageFocusOut(std::vector<Id>(1, getData()->getId())).dispatch();
|
||||
}
|
||||
|
||||
void QtGraphEdge::setDirection(TokenComponentAggregation::Direction direction)
|
||||
@@ -372,5 +375,12 @@ void QtGraphEdge::setIsTrailEdge(std::vector<Vec4i> path, bool horizontal)
|
||||
{
|
||||
m_path = path;
|
||||
m_isTrailEdge = true;
|
||||
m_useBezier = true;
|
||||
m_isHorizontalTrail = horizontal;
|
||||
}
|
||||
|
||||
void QtGraphEdge::setUseBezier(bool useBezier)
|
||||
{
|
||||
m_useBezier = useBezier;
|
||||
m_isHorizontalTrail = true;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ public:
|
||||
bool isTrailEdge() const;
|
||||
void setIsTrailEdge(std::vector<Vec4i> path, bool horizontal);
|
||||
|
||||
void setUseBezier(bool useBezier);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||
@@ -62,8 +64,8 @@ protected:
|
||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
|
||||
|
||||
private:
|
||||
// used to unfocus recent edge, because hover leave event is not always received for trail edges (bezier)
|
||||
static QtGraphEdge* s_focusedTrailEdge;
|
||||
// used to unfocus recent edge, because hover leave event is not always received for bezier edges
|
||||
static QtGraphEdge* s_focusedBezierEdge;
|
||||
|
||||
const Edge* m_data;
|
||||
|
||||
@@ -86,6 +88,8 @@ private:
|
||||
bool m_isHorizontalTrail;
|
||||
std::vector<Vec4i> m_path;
|
||||
|
||||
bool m_useBezier;
|
||||
|
||||
Vec2i m_mousePos;
|
||||
bool m_mouseMoved;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user