"Fossies" - the Fresh Open Source Software Archive

Member "cutter-1.9.0/src/widgets/GraphLayout.h" (6 Sep 2019, 1153 Bytes) of package /linux/privat/cutter-1.9.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "GraphLayout.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.8.3_vs_1.9.0.

    1 #ifndef GRAPHLAYOUT_H
    2 #define GRAPHLAYOUT_H
    3 
    4 #include "core/Cutter.h"
    5 
    6 #include <unordered_map>
    7 
    8 class GraphLayout
    9 {
   10 public:
   11     struct GraphEdge {
   12         ut64 target;
   13         QPolygonF polyline;
   14         enum ArrowDirection {
   15             Down, Left, Up, Right, None
   16         };
   17         ArrowDirection arrow = ArrowDirection::Down;
   18 
   19         explicit GraphEdge(ut64 target): target(target) {}
   20     };
   21 
   22     struct GraphBlock {
   23         int x = 0;
   24         int y = 0;
   25         int width = 0;
   26         int height = 0;
   27         // This is a unique identifier, e.g. offset in the case of r2 blocks
   28         ut64 entry;
   29         // Edges
   30         std::vector<GraphEdge> edges;
   31     };
   32     using Graph = std::unordered_map<ut64, GraphBlock>;
   33 
   34     struct LayoutConfig {
   35         int block_vertical_margin = 40;
   36         int block_horizontal_margin = 10;
   37     };
   38 
   39     GraphLayout(const LayoutConfig &layout_config) : layoutConfig(layout_config) {}
   40     virtual ~GraphLayout() {}
   41     virtual void CalculateLayout(Graph &blocks, ut64 entry, int &width,
   42                                  int &height) const = 0;
   43 protected:
   44     LayoutConfig layoutConfig;
   45 };
   46 
   47 #endif // GRAPHLAYOUT_H