25 #include <graphviz/gvc.h> 28 #include <QGraphicsView> 29 #include <QGraphicsScene> 30 #include <QGraphicsPathItem> 32 #include <QContextMenuEvent> 33 #include <QMouseEvent> 46 QY2Graph(
const std::string& filename,
const std::string& layoutAlgorithm, QWidget* parent = 0);
48 QY2Graph(graph_t* graph, QWidget* parent = 0);
52 virtual void renderGraph(
const std::string& filename,
const std::string& layoutAlgorithm);
53 virtual void renderGraph(graph_t* graph);
59 void backgroundContextMenuEvent(QContextMenuEvent* event);
60 void nodeContextMenuEvent(QContextMenuEvent* event,
const QString& name);
61 void nodeDoubleClickEvent(QMouseEvent* event,
const QString& name);
65 void keyPressEvent(QKeyEvent* event);
66 void wheelEvent(QWheelEvent* event);
67 void contextMenuEvent(QContextMenuEvent* event);
68 void mouseDoubleClickEvent(QMouseEvent* event);
74 void scaleView(qreal scaleFactor);
76 QGraphicsScene* scene;
80 QPointF gToQ(
const pointf& p,
bool upside_down =
true)
const;
82 QString aggetToQString(
void* obj,
const char* name,
const QString& fallback)
const;
83 QColor aggetToQColor(
void* obj,
const char* name,
const QColor& fallback)
const;
84 Qt::PenStyle aggetToQPenStyle(
void* obj,
const char* name,
const Qt::PenStyle fallback)
const;
86 QPainterPath makeShape(node_t* node)
const;
87 QPolygonF makeShapeHelper(node_t* node)
const;
89 QPainterPath makeBezier(
const bezier& bezier)
const;
91 void drawLabel(
const textlabel_t* textlabel, QPainter* painter)
const;
93 void drawArrow(
const QLineF& line,
const QColor& color, QPainter* painter)
const;
98 class QY2Node :
public QObject,
public QGraphicsPathItem
104 QY2Node(
const QPainterPath& path,
const QPicture& picture,
const QString& name);
106 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option, QWidget* widget);
124 QY2Edge(
const QPainterPath& path,
const QPicture& picture);
126 QRectF boundingRect()
const;
128 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option, QWidget* widget);
The QY2Graph widget shows a graph layouted by graphviz in a QGraphicsView/QGraphicsScene.