From b9e1e9b2f33ed09219b1b0f0bf3729f0f99d6d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0pirk?= Date: Tue, 29 Oct 2024 09:56:06 +0100 Subject: [PATCH] draw graph into SVG --- libshvvisu/include/shv/visu/timeline/graph.h | 4 ++++ libshvvisu/src/timeline/graph.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/libshvvisu/include/shv/visu/timeline/graph.h b/libshvvisu/include/shv/visu/timeline/graph.h index 05176ba2c..0bdbfb82b 100644 --- a/libshvvisu/include/shv/visu/timeline/graph.h +++ b/libshvvisu/include/shv/visu/timeline/graph.h @@ -23,6 +23,8 @@ #include #endif +class QSvgGenerator; + namespace shv::visu::timeline { class SHVVISU_DECL_EXPORT Graph : public QObject @@ -236,6 +238,8 @@ class SHVVISU_DECL_EXPORT Graph : public QObject void loadVisualSettings(const QString &settings_id, const QString &name); QString loadedVisualSettingsId(); + void draw(QSvgGenerator *svg_generator, const QRect &rect); + protected: void sanityXRangeZoom(); diff --git a/libshvvisu/src/timeline/graph.cpp b/libshvvisu/src/timeline/graph.cpp index 2d07a1a87..933facb73 100644 --- a/libshvvisu/src/timeline/graph.cpp +++ b/libshvvisu/src/timeline/graph.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -1296,6 +1297,15 @@ int Graph::maximizedChannelIndex() const return -1; } +void Graph::draw(QSvgGenerator *svg_generator, const QRect &rect) +{ + auto orig_layout = m_layout.rect; + makeLayout(rect); + QPainter painter(svg_generator); + draw(&painter, rect, rect); + makeLayout(orig_layout); +} + void Graph::draw(QPainter *painter, const QRect &dirty_rect, const QRect &view_rect) { drawBackground(painter, dirty_rect);