Skip to content

Commit

Permalink
Re #6238. Enabled saving instrument image in non-gl mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Nov 19, 2013
1 parent 23cf945 commit 688e017
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,14 @@ void InstrumentWindow::saveImage(QString filename)
}
}

if ( m_InstrumentDisplay )
if ( isGLEnabled() )
{
m_InstrumentDisplay->saveToFile(filename);
}
else
{
m_simpleDisplay->saveToFile(filename);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "ProjectionSurface.h"

#include <QApplication>
#include <QPixmap>

/// Constructor
SimpleWidget::SimpleWidget(QWidget* parent):QWidget(parent)
Expand Down Expand Up @@ -45,6 +46,17 @@ void SimpleWidget::updateDetectors()
}
}

/**
* Save widget content to a file.
* @param filename :: A file to save to.
*/
void SimpleWidget::saveToFile(const QString &filename)
{
QPixmap image( size() );
render( &image );
image.save( filename );
}

void SimpleWidget::paintEvent(QPaintEvent*)
{
if(m_surface)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class SimpleWidget : public QWidget
void updateView(bool picking = true);
/// Update the detector information (count values) and redraw
void updateDetectors();
/// Save the image into a file
void saveToFile(const QString & filename);
protected:
void paintEvent(QPaintEvent*);
void resizeEvent(QResizeEvent*);
Expand Down

0 comments on commit 688e017

Please sign in to comment.