From 243016633d31f8225fc4d1475463cd0477cf9505 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sat, 4 May 2013 16:12:43 -0300 Subject: Started the code for the Profile Plotting This small patch adds a new class - ProfileGraphicsView it's a QGraphicsView based class that will holds all graphics-items for the plotting. The setup is simple, just call ui->ListView->plot( dive ) ( that's already a ProfileGraphicsView and magic will happen. Since Im using a QGraphicsView , the size of the canvas doesn't matter and I'm fixing it at 0,0,100,100. when a resize is done, the resizeEvent will be called, fitting the scene's rectangle on the view. Signed-off-by: Tomaz Canabrava --- qt-ui/profilegraphics.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 qt-ui/profilegraphics.cpp (limited to 'qt-ui/profilegraphics.cpp') diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp new file mode 100644 index 000000000..59a47826f --- /dev/null +++ b/qt-ui/profilegraphics.cpp @@ -0,0 +1,26 @@ +#include "profilegraphics.h" + +#include +#include + +#include + +ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent) +{ + setScene(new QGraphicsScene()); + scene()->setSceneRect(0,0,100,100); +} + +void ProfileGraphicsView::plot(struct dive *d) +{ + qDebug() << "Start the plotting of the dive here."; +} + +void ProfileGraphicsView::resizeEvent(QResizeEvent *event) +{ + // Fits the scene's rectangle on the view. + // I can pass some parameters to this - + // like Qt::IgnoreAspectRatio or Qt::KeepAspectRatio + QRectF r = scene()->sceneRect(); + fitInView ( r.x() - 2, r.y() -2, r.width() + 4, r.height() + 4); // do a little bit of spacing; +} -- cgit v1.2.3-70-g09d2