Skip to content

Commit

Permalink
Merge remote branch 'origin/bugfix/6238_save_instrument_image'
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellTaylor committed Nov 21, 2013
2 parents 33baa82 + 688e017 commit d04ed15
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 d04ed15

Please sign in to comment.