ui: Improved graph layouting to properly place and resize subnodes
This change moves the toplevel node resizing from the QtPostProcessor to the GraphController to place and resize their subnodes accordingly as well.
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
#include "QtGraphPostprocessor.h"
|
||||
|
||||
// remark: maybe those two values could at some point be moved to an external config file (?)
|
||||
unsigned int QtGraphPostprocessor::s_cellSize = 5;
|
||||
unsigned int QtGraphPostprocessor::s_cellPadding = 10;
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
|
||||
unsigned int QtGraphPostprocessor::s_cellSize = GraphViewStyle::s_gridCellSize;
|
||||
unsigned int QtGraphPostprocessor::s_cellPadding = GraphViewStyle::s_gridCellPadding;
|
||||
|
||||
void QtGraphPostprocessor::doPostprocessing(std::list<std::shared_ptr<QtGraphNode>>& nodes)
|
||||
{
|
||||
unsigned int atomarGridSize = s_cellSize;
|
||||
|
||||
resizeNodes(nodes);
|
||||
|
||||
if (nodes.size() < 2)
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "Skipping postprocessing, need at least 2 nodes but got " << nodes.size());
|
||||
@@ -415,31 +414,6 @@ Vec2f QtGraphPostprocessor::heatMapRayCast(const MatrixDynamicBase<unsigned int>
|
||||
return length;
|
||||
}
|
||||
|
||||
void QtGraphPostprocessor::resizeNodes(std::list<std::shared_ptr<QtGraphNode>>& nodes)
|
||||
{
|
||||
std::list<std::shared_ptr<QtGraphNode>>::iterator it = nodes.begin();
|
||||
for (; it != nodes.end(); it++)
|
||||
{
|
||||
Vec2i size = (*it)->getSize();
|
||||
|
||||
int newWidth = s_cellSize;
|
||||
while(size.x - newWidth > 3)
|
||||
{
|
||||
newWidth += s_cellPadding + s_cellSize;
|
||||
}
|
||||
size.x = newWidth;
|
||||
|
||||
int newHeight = s_cellSize;
|
||||
while(size.y - newHeight > 3)
|
||||
{
|
||||
newHeight += s_cellPadding + s_cellSize;
|
||||
}
|
||||
size.y = newHeight;
|
||||
|
||||
(*it)->setSize(size);
|
||||
}
|
||||
}
|
||||
|
||||
Vec2i QtGraphPostprocessor::calculateRasterNodeSize(const std::shared_ptr<QtGraphNode>& node)
|
||||
{
|
||||
Vec2i size = node->getSize();
|
||||
|
||||
@@ -26,7 +26,6 @@ private:
|
||||
static void modifyHeatmapArea(MatrixDynamicBase<unsigned int>& heatMap, const Vec2i& leftUpperCorner, const Vec2i& size, const int modifier);
|
||||
static bool getHeatmapGradient(Vec2f& outGradient, const MatrixDynamicBase<unsigned int>& heatMap, const Vec2i& leftUpperCorner, const Vec2i& size);
|
||||
static Vec2f heatMapRayCast(const MatrixDynamicBase<unsigned int>& heatMap, const Vec2f& startPosition, const Vec2f& direction, const int minValue);
|
||||
static void resizeNodes(std::list<std::shared_ptr<QtGraphNode>>& nodes);
|
||||
static Vec2i calculateRasterNodeSize(const std::shared_ptr<QtGraphNode>& node);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user