2019-04-04 05:54:42 +00:00
|
|
|
#ifndef GRAPHLAYOUT_H
|
|
|
|
#define GRAPHLAYOUT_H
|
|
|
|
|
|
|
|
#include "core/Cutter.h"
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
class GraphLayout
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct GraphEdge {
|
|
|
|
ut64 target;
|
|
|
|
QPolygonF polyline;
|
2019-08-03 13:10:44 +00:00
|
|
|
enum ArrowDirection {
|
|
|
|
Down, Left, Up, Right, None
|
|
|
|
};
|
|
|
|
ArrowDirection arrow = ArrowDirection::Down;
|
2019-04-07 11:34:53 +00:00
|
|
|
|
|
|
|
explicit GraphEdge(ut64 target): target(target) {}
|
2019-04-04 05:54:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct GraphBlock {
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
2020-12-16 10:59:23 +00:00
|
|
|
// This is a unique identifier, e.g. offset in the case of rizin blocks
|
2019-04-04 05:54:42 +00:00
|
|
|
ut64 entry;
|
|
|
|
// Edges
|
|
|
|
std::vector<GraphEdge> edges;
|
|
|
|
};
|
2019-08-03 13:10:44 +00:00
|
|
|
using Graph = std::unordered_map<ut64, GraphBlock>;
|
2019-04-04 05:54:42 +00:00
|
|
|
|
|
|
|
struct LayoutConfig {
|
2020-06-03 15:36:44 +00:00
|
|
|
int blockVerticalSpacing = 40;
|
2020-07-03 17:09:37 +00:00
|
|
|
int blockHorizontalSpacing = 20;
|
2020-06-03 15:36:44 +00:00
|
|
|
int edgeVerticalSpacing = 10;
|
|
|
|
int edgeHorizontalSpacing = 10;
|
2019-04-04 05:54:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GraphLayout(const LayoutConfig &layout_config) : layoutConfig(layout_config) {}
|
|
|
|
virtual ~GraphLayout() {}
|
2019-08-03 13:10:44 +00:00
|
|
|
virtual void CalculateLayout(Graph &blocks, ut64 entry, int &width,
|
2019-04-04 05:54:42 +00:00
|
|
|
int &height) const = 0;
|
2020-06-05 23:06:38 +00:00
|
|
|
virtual void setLayoutConfig(const LayoutConfig &config)
|
|
|
|
{
|
|
|
|
this->layoutConfig = config;
|
|
|
|
};
|
2019-04-04 05:54:42 +00:00
|
|
|
protected:
|
|
|
|
LayoutConfig layoutConfig;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GRAPHLAYOUT_H
|