GraphView

class GraphView : public QAbstractScrollArea

Base class for rendering and interacting with control-flow graphs.

Supports both QPainter and OpenGL rendering

Subclassed by CutterGraphView, OverviewView

Public Types

enum class Layout : ut8

Values:

enumerator GridNarrow
enumerator GridMedium
enumerator GridWide
enumerator GridAAA
enumerator GridAAB
enumerator GridABA
enumerator GridABB
enumerator GridBAA
enumerator GridBAB
enumerator GridBBA
enumerator GridBBB
using GraphBlock = GraphLayout::GraphBlock
using GraphEdge = GraphLayout::GraphEdge

Public Functions

explicit GraphView(QWidget *parent)
~GraphView() override
void showBlock(GraphBlock &block, bool anywhere = false)
void showRectangle(const QRect &rect, bool anywhere = false)

Move view so that area is visible.

Parameters:
  • rect – Rectangle to show

  • anywhere – - set to true for minimizing movement

GraphView::GraphBlock *getBlockContaining(QPoint p)

Get block containing specified point logical coordinates.

Parameters:

p – positionin graph logical coordinates

Returns:

Block or nullptr if position is outside all blocks.

QPoint viewToLogicalCoordinates(QPoint p)
QPoint logicalToViewCoordinates(QPoint p)
void setGraphLayout(std::unique_ptr<GraphLayout> layout)
inline GraphLayout &getGraphLayout() const
void setLayoutConfig(const GraphLayout::LayoutConfig &config)
void paint(QPainter &p, QPoint offset, QRect area, qreal scale = 1.0, bool interactive = true)
void saveAsBitmap(const QString &path, const char *format = nullptr, double scaler = 1.0, bool transparent = false)
void saveAsSvg(const QString &path)
void computeGraphPlacement()
inline QPoint getViewOffset() const
void setViewOffset(QPoint offset)
inline qreal getViewScale() const
void setViewScale(qreal scale)
void center()
inline void centerX()
inline void centerY()

Signals

void viewOffsetChanged(QPoint offset)
void viewScaleChanged(qreal scale)

Public Static Functions

static std::unique_ptr<GraphLayout> makeGraphLayout(Layout layout, bool horizontal = false)
static void cleanupEdges(GraphLayout::Graph &graph)

Remove duplicate edges and edges without target in graph.

Parameters:

graph

struct EdgeConfiguration

Public Members

QColor color = QColor(128, 128, 128)
bool startArrow = false
bool endArrow = true
qreal widthScale = 1.0
Qt::PenStyle lineStyle = Qt::PenStyle::SolidLine