summaryrefslogtreecommitdiff
path: root/gr-qtgui
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2012-11-10 15:46:33 -0500
committerTom Rondeau <trondeau@vt.edu>2012-11-10 15:46:33 -0500
commit0cf561018b60bd00b2315f77c7ee073acb6a8758 (patch)
tree66890496e31aa9d5b65bb976ca317e4f3b6ce094 /gr-qtgui
parent611f7e45e7a793f2489d76670a61493327838e3e (diff)
parent2329b7126c313e1492942655e28a2f59c89d30b4 (diff)
Merge branch 'next' into next_analog
Diffstat (limited to 'gr-qtgui')
-rw-r--r--gr-qtgui/lib/displayform.cc45
-rw-r--r--gr-qtgui/lib/displayform.h4
2 files changed, 49 insertions, 0 deletions
diff --git a/gr-qtgui/lib/displayform.cc b/gr-qtgui/lib/displayform.cc
index 92f7ca59b6..4daf5c76ef 100644
--- a/gr-qtgui/lib/displayform.cc
+++ b/gr-qtgui/lib/displayform.cc
@@ -22,6 +22,8 @@
#include <displayform.h>
#include <iostream>
+#include <QPixmap>
+#include <QFileDialog>
DisplayForm::DisplayForm(int nplots, QWidget* parent)
: QWidget(parent), _nplots(nplots), _systemSpecifiedFlag(false)
@@ -95,6 +97,12 @@ DisplayForm::DisplayForm(int nplots, QWidget* parent)
_menu->addMenu(_lines_menu[i]);
}
+
+ _save_act = new QAction("Save", this);
+ _save_act->setStatusTip(tr("Save Figure"));
+ connect(_save_act, SIGNAL(triggered()), this, SLOT(saveFigure()));
+ _menu->addAction(_save_act);
+
Reset();
// Create a timer to update plots at the specified rate
@@ -278,3 +286,40 @@ DisplayForm::setGrid()
else
setGrid(false);
}
+
+void
+DisplayForm::saveFigure()
+{
+ QPixmap qpix = QPixmap::grabWidget(this);
+
+ QString types = QString(tr("JPEG file (*.jpg);;Portable Network Graphics file (*.png);;Bitmap file (*.bmp);;TIFF file (*.tiff)"));
+
+ QString filename, filetype;
+ QFileDialog *filebox = new QFileDialog(0, "Save Image", "./", types);
+ filebox->setViewMode(QFileDialog::Detail);
+ if(filebox->exec()) {
+ filename = filebox->selectedFiles()[0];
+ filetype = filebox->selectedNameFilter();
+ }
+ else {
+ return;
+ }
+
+ if(filetype.contains(".jpg")) {
+ qpix.save(filename, "JPEG");
+ }
+ else if(filetype.contains(".png")) {
+ qpix.save(filename, "PNG");
+ }
+ else if(filetype.contains(".bmp")) {
+ qpix.save(filename, "BMP");
+ }
+ else if(filetype.contains(".tiff")) {
+ qpix.save(filename, "TIFF");
+ }
+ else {
+ qpix.save(filename, "JPEG");
+ }
+
+ delete filebox;
+}
diff --git a/gr-qtgui/lib/displayform.h b/gr-qtgui/lib/displayform.h
index f436b526ac..99b0e714f4 100644
--- a/gr-qtgui/lib/displayform.h
+++ b/gr-qtgui/lib/displayform.h
@@ -67,6 +67,8 @@ public slots:
void setGrid(bool on);
void setGrid();
+ void saveFigure();
+
private slots:
virtual void newData(const QEvent*) = 0;
void updateGuiTimer();
@@ -100,6 +102,8 @@ protected:
QList<LineMarkerMenu*> _line_marker_menu;
QList<MarkerAlphaMenu*> _marker_alpha_menu;
+ QAction *_save_act;
+
QTimer *d_displayTimer;
double d_update_time;
};