#ifndef BUCKET_LAYOUTER_H #define BUCKET_LAYOUTER_H #include #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 node) const; void addNode(std::shared_ptr 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>& nodes, const std::vector>& edges); void layoutBuckets(bool addVerticalSplit); std::vector> getSortedNodes(); private: std::shared_ptr findTopMostDummyNodeRecursive( std::vector>& nodes, Id tokenId, std::shared_ptr top); void addNode(std::shared_ptr node); bool addNode(std::shared_ptr owner, std::shared_ptr target, bool horizontal); Bucket* getBucket(int i, int j); Bucket* getBucket(std::shared_ptr node); Vec2i m_viewSize; std::map> m_buckets; int m_i1; int m_j1; int m_i2; int m_j2; DummyNode* m_activeParentNode = nullptr; }; #endif // BUCKET_LAYOUTER_H