ui: bundling nodes in the graph view
This change bundles similar nodes in the graph view together. When the bundled node or it's aggregation edge are clicked, then the bundle is split. This change also adds an arrow to the aggregation edge based on the direction of it's edges.
This commit is contained in:
@@ -1,6 +1,21 @@
|
||||
#include "data/graph/token_component/TokenComponentAggregation.h"
|
||||
|
||||
TokenComponentAggregation::Direction TokenComponentAggregation::opposite(Direction direction)
|
||||
{
|
||||
if (direction == DIRECTION_FORWARD)
|
||||
{
|
||||
return DIRECTION_BACKWARD;
|
||||
}
|
||||
else if (direction == DIRECTION_BACKWARD)
|
||||
{
|
||||
return DIRECTION_FORWARD;
|
||||
}
|
||||
|
||||
return direction;
|
||||
}
|
||||
|
||||
TokenComponentAggregation::TokenComponentAggregation()
|
||||
: m_direction(DIRECTION_INVALID)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -18,17 +33,53 @@ int TokenComponentAggregation::getAggregationCount() const
|
||||
return m_ids.size();
|
||||
}
|
||||
|
||||
const std::set<Id>& TokenComponentAggregation::getAggregationIds() const
|
||||
std::set<Id> TokenComponentAggregation::getAggregationIds() const
|
||||
{
|
||||
return m_ids;
|
||||
std::set<Id> ids;
|
||||
|
||||
for (const std::pair<Id, Direction>& p : m_ids)
|
||||
{
|
||||
ids.insert(p.first);
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
void TokenComponentAggregation::addAggregationId(Id id)
|
||||
void TokenComponentAggregation::addAggregationId(Id id, bool forward)
|
||||
{
|
||||
m_ids.insert(id);
|
||||
m_ids.emplace(id, forward ? DIRECTION_FORWARD : DIRECTION_BACKWARD);
|
||||
|
||||
m_direction = DIRECTION_INVALID;
|
||||
}
|
||||
|
||||
void TokenComponentAggregation::removeAggregationId(Id id)
|
||||
{
|
||||
m_ids.erase(id);
|
||||
|
||||
m_direction = DIRECTION_INVALID;
|
||||
}
|
||||
|
||||
TokenComponentAggregation::Direction TokenComponentAggregation::getDirection()
|
||||
{
|
||||
if (m_direction != DIRECTION_INVALID)
|
||||
{
|
||||
return m_direction;
|
||||
}
|
||||
|
||||
m_direction = DIRECTION_NONE;
|
||||
|
||||
for (const std::pair<Id, Direction>& p : m_ids)
|
||||
{
|
||||
if (m_direction == DIRECTION_NONE)
|
||||
{
|
||||
m_direction = p.second;
|
||||
}
|
||||
else if (m_direction != p.second)
|
||||
{
|
||||
m_direction = DIRECTION_NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return m_direction;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef TOKEN_COMPONENT_AGGREGATION_H
|
||||
#define TOKEN_COMPONENT_AGGREGATION_H
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include "utility/types.h"
|
||||
@@ -11,19 +12,32 @@ class TokenComponentAggregation
|
||||
: public TokenComponent
|
||||
{
|
||||
public:
|
||||
enum Direction
|
||||
{
|
||||
DIRECTION_NONE,
|
||||
DIRECTION_FORWARD,
|
||||
DIRECTION_BACKWARD,
|
||||
DIRECTION_INVALID
|
||||
};
|
||||
|
||||
static Direction opposite(Direction direction);
|
||||
|
||||
TokenComponentAggregation();
|
||||
virtual ~TokenComponentAggregation();
|
||||
|
||||
virtual std::shared_ptr<TokenComponent> copy() const;
|
||||
|
||||
int getAggregationCount() const;
|
||||
const std::set<Id>& getAggregationIds() const;
|
||||
std::set<Id> getAggregationIds() const;
|
||||
|
||||
void addAggregationId(Id id);
|
||||
void addAggregationId(Id id, bool forward);
|
||||
void removeAggregationId(Id id);
|
||||
|
||||
Direction getDirection();
|
||||
|
||||
private:
|
||||
std::set<Id> m_ids;
|
||||
std::map<Id, Direction> m_ids;
|
||||
Direction m_direction;
|
||||
};
|
||||
|
||||
#endif // TOKEN_COMPONENT_AGGREGATION_H
|
||||
|
||||
Reference in New Issue
Block a user