Skip to content

Commit

Permalink
draw graph into SVG
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Špirk authored and fvacek committed Oct 29, 2024
1 parent 9796a6c commit b9e1e9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libshvvisu/include/shv/visu/timeline/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <QTimeZone>
#endif

class QSvgGenerator;

namespace shv::visu::timeline {

class SHVVISU_DECL_EXPORT Graph : public QObject
Expand Down Expand Up @@ -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();

Expand Down
10 changes: 10 additions & 0 deletions libshvvisu/src/timeline/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <shv/core/exception.h>
#include <shv/coreqt/log.h>
#include <shv/chainpack/rpcvalue.h>
#include <QtSvg/QSvgGenerator>

#include <QPainter>
#include <QFontMetrics>
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b9e1e9b

Please sign in to comment.