From 88c071c5ed526be1e19fe8bdda79605ef642844d Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 21 Feb 2013 05:49:19 -0600 Subject: [PATCH] re-simplify library info window. start to unify glview.save() --- src/MainWindow.h | 2 +- src/OffscreenView.cc | 2 +- src/OffscreenView.h | 6 +++--- src/QGLView.h | 3 ++- src/mainwin.cc | 24 +++++++++--------------- src/qglview.cc | 7 +++++++ 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/MainWindow.h b/src/MainWindow.h index b685bf16..4848db67 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -87,7 +87,7 @@ private: void loadViewSettings(); void loadDesignSettings(); - class QDialog *openglbox; + class QMessageBox *openglbox; private slots: void actionNew(); diff --git a/src/OffscreenView.cc b/src/OffscreenView.cc index 6f9b2da0..bc1b97c9 100644 --- a/src/OffscreenView.cc +++ b/src/OffscreenView.cc @@ -147,7 +147,7 @@ bool OffscreenView::save(std::ostream &output) return save_framebuffer(this->ctx, output); } -const std::string &OffscreenView::getRendererInfo() +std::string OffscreenView::getRendererInfo() { std::stringstream out; diff --git a/src/OffscreenView.h b/src/OffscreenView.h index c27277ec..97d8198a 100644 --- a/src/OffscreenView.h +++ b/src/OffscreenView.h @@ -24,9 +24,9 @@ public: void setupPerspective(); void setupOrtho(bool offset=false); void paintGL(); - bool save(const char *filename); - bool save(std::ostream &output); - const std::string &getRendererInfo(); + bool save(const char *filename); // + bool save(std::ostream &output); // not implemented in qgl? + std::string getRendererInfo(); // GLint shaderinfo[11]; // diff --git a/src/QGLView.h b/src/QGLView.h index 862d751b..57e5faf1 100644 --- a/src/QGLView.h +++ b/src/QGLView.h @@ -35,7 +35,8 @@ public: void setShowCrosshairs(bool enabled) { this->showcrosshairs = enabled; } bool orthoMode() const { return this->orthomode; } void setOrthoMode(bool enabled) { this->orthomode = enabled; } - const std::string &getRendererInfo() const { return this->rendererInfo; } + std::string getRendererInfo() const { return this->rendererInfo; } + bool save(const char *filename); public: QLabel *statusLabel; diff --git a/src/mainwin.cc b/src/mainwin.cc index 52020eca..b4e1f50d 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1452,20 +1452,17 @@ void MainWindow::actionExportCSG() void MainWindow::actionExportImage() { - QImage img = this->qglview->grabFrameBuffer(); setCurrentOutput(); QString img_filename = QFileDialog::getSaveFileName(this, "Export Image", "", "PNG Files (*.png)"); if (img_filename.isEmpty()) { PRINT("No filename specified. Image export aborted."); - clearCurrentOutput(); - return; + } else { + qglview->save(img_filename.toStdString().c_str()); } - - img.save(img_filename, "PNG"); - clearCurrentOutput(); + return; } void MainWindow::actionFlushCaches() @@ -1745,16 +1742,13 @@ void MainWindow::helpLibrary() qVersion()); if (!this->openglbox) { - this->openglbox = new QDialog( this ); - QVBoxLayout *ql = new QVBoxLayout( openglbox ); - QTextEdit *qte = new QTextEdit( openglbox ); - ql->addWidget( qte ); + this->openglbox = new QMessageBox(QMessageBox::Information, + "OpenGL Info", "Detailed Library Info", + QMessageBox::Ok, this); + this->openglbox->setMinimumSize( QSize(400,200) ); } - QTextEdit *qte = openglbox->findChild(); - qte->setText(libinfo + QString(this->qglview->getRendererInfo().c_str())); - qte->setReadOnly( true ); - openglbox->setMinimumSize( QSize(400,200) ); - openglbox->show(); + this->openglbox->setDetailedText(libinfo + QString(qglview->getRendererInfo().c_str())); + this->openglbox->show(); } /*! diff --git a/src/qglview.cc b/src/qglview.cc index 5310eac9..c80d1552 100644 --- a/src/qglview.cc +++ b/src/qglview.cc @@ -637,3 +637,10 @@ void QGLView::mouseReleaseEvent(QMouseEvent*) mouse_drag_active = false; releaseMouse(); } + +bool QGLView::save(const char *filename) +{ + QImage img = grabFrameBuffer(); + return img.save(filename, "PNG"); +} +