Files
Sourcetrail/src/lib/component/controller/helper/BucketLayouter.h
T
Eberhard Graether 5f56a167d1 ui: Fixed group related issues in graph
* fixed aggregation layout within group
* fixed moving of group did not resize view
* fixed edges behind group could not be hovered
* fixed overlapping lines in sublayout
* fixed use of correct column width in sublayout
2018-04-11 14:11:53 +02:00

73 lines
1.5 KiB
C++

#ifndef BUCKET_LAYOUTER_H
#define BUCKET_LAYOUTER_H
#include <map>
#include "utility/math/Vector2.h"
#include "utility/types.h"
#include "component/controller/helper/DummyNode.h"
struct DummyEdge;
class Bucket
{
public:
Bucket();
Bucket(int i, int j);
int getWidth() const;
int getHeight() const;
bool hasNode(std::shared_ptr<DummyNode> node) const;
void addNode(std::shared_ptr<DummyNode> node);
const DummyNode::BundledNodesSet& getNodes() const;
void preLayout(Vec2i viewSize, bool addVerticalSplit, bool forceVerticalSplit);
void layout(int x, int y, int width, int height);
int i;
int j;
private:
int m_width;
int m_height;
DummyNode::BundledNodesSet m_nodes;
};
class BucketLayouter
{
public:
BucketLayouter(Vec2i viewSize);
void createBuckets(
std::vector<std::shared_ptr<DummyNode>>& nodes,
const std::vector<std::shared_ptr<DummyEdge>>& edges);
void layoutBuckets(bool addVerticalSplit);
std::vector<std::shared_ptr<DummyNode>> getSortedNodes();
private:
std::shared_ptr<DummyNode> findTopMostDummyNodeRecursive(
std::vector<std::shared_ptr<DummyNode>>& nodes, Id tokenId, std::shared_ptr<DummyNode> top);
void addNode(std::shared_ptr<DummyNode> node);
bool addNode(std::shared_ptr<DummyNode> owner, std::shared_ptr<DummyNode> target, bool horizontal);
Bucket* getBucket(int i, int j);
Bucket* getBucket(std::shared_ptr<DummyNode> node);
Vec2i m_viewSize;
std::map<int, std::map<int, Bucket>> m_buckets;
int m_i1;
int m_j1;
int m_i2;
int m_j2;
DummyNode* m_activeParentNode = nullptr;
};
#endif // BUCKET_LAYOUTER_H