Commit bd2538bb authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - intermediate screenshotter removed and replaced

parent 53f1a6ba
......@@ -446,6 +446,8 @@ void WMainWindow::setupGUI()
m_permanentToolBar->addAction( projectLoadButton );
m_permanentToolBar->addAction( projectSaveButton );
m_permanentToolBar->addSeparator();
m_permanentToolBar->addAction( m_mainGLWidgetScreenCapture->getScreenshotTrigger() );
m_permanentToolBar->addSeparator();
m_permanentToolBar->addAction( resetButton );
m_permanentToolBar->addAction( roiButton );
m_permanentToolBar->addSeparator();
......
......@@ -131,6 +131,12 @@ WQtGLScreenCapture::WQtGLScreenCapture( WGEViewer::SPtr viewer, WMainWindow* par
m_screenshotWidget->setLayout( screenshotLayout );
m_screenshotButton = new QPushButton( "Screenshot" );
m_screenshotButton->setToolTip( "Take a screenshot of the 3D view." );
m_screenshotAction = new QAction( parent->getIconManager()->getIcon( "image" ), "Screenshot", this );
m_screenshotAction->setToolTip( "Take a screenshot of the 3D view." );
m_screenshotAction->setShortcut( QKeySequence( Qt::Key_F12 ) );
m_screenshotAction->setShortcutContext( Qt::ApplicationShortcut );
connect( m_screenshotAction, SIGNAL( triggered( bool ) ), this, SLOT( screenShot() ) );
connect( m_screenshotButton, SIGNAL( clicked( bool ) ), this, SLOT( screenShot() ) );
QLabel* screenshotLabel = new QLabel();
......@@ -238,6 +244,11 @@ WQtGLScreenCapture::~WQtGLScreenCapture()
m_imageConnection.disconnect();
}
QAction* WQtGLScreenCapture::getScreenshotTrigger() const
{
return m_screenshotAction;
}
void WQtGLScreenCapture::handleImage( size_t /* framesLeft */, size_t totalFrames, osg::ref_ptr< osg::Image > image ) const
{
std::string filename = m_configFileEdit->text().toStdString();
......
......@@ -67,6 +67,12 @@ public:
*/
virtual ~WQtGLScreenCapture();
/**
* Returns the trigger used for screenshotting.
*
* \return the action.
*/
QAction* getScreenshotTrigger() const;
protected:
/**
* Custom event dispatcher. Gets called by QT's Event system every time an event got sent to this widget. This event handler
......@@ -205,6 +211,11 @@ private:
*/
QPushButton* m_screenshotButton;
/**
* This action triggers a screenshot.
*/
QAction* m_screenshotAction;
/**
* Shows recorded time in movie-time.
*/
......
......@@ -265,9 +265,6 @@ void WQtGLWidget::keyReleaseEvent( QKeyEvent* event )
case Qt::Key_2:
setCameraManipulator( TWO_D );
break;
case Qt::Key_F12:
makeScreenshot();
break;
}
switch( event->modifiers() )
......@@ -379,23 +376,6 @@ void WQtGLWidget::changeBGColor()
updateViewerBackground();
}
void WQtGLWidget::makeScreenshot()
{
// TODO(ebaum): replace this with the better screenshotter which resides in my branch
// grab content first to avoid making a screenshot of the file dialog :)
QPixmap q = QPixmap::grabWindow( this->winId() );
QString path = QDir::currentPath() + tr( "/screenshot.png" );
QString fileName = QFileDialog::getSaveFileName( this, tr( "Save As" ), path, tr( "PNG Files (*.png);;All Files (*)" ) );
if( !fileName.isEmpty() )
{
q.save( fileName, tr( "png" ).toAscii() );
WLogger::getLogger()->addLogMessage( std::string( "Screenshot saved to " ) + fileName.toStdString(), "QtGLWidget", LL_INFO );
}
}
void WQtGLWidget::notifyFirstRenderedFrame()
{
QCoreApplication::postEvent( this, new WRenderedFrameEvent() );
......
......@@ -264,11 +264,6 @@ protected:
*/
WGECamera::ProjectionMode m_initialProjectionMode;
/**
* Saves a screenshot of the widget's current content, opens a file dialog to get the filename.
*/
void makeScreenshot();
/**
* Custom event dispatcher. Gets called by QT's Event system every time an event got sent to this widget. This event handler
* processes the notifyrender events. Others get forwarded.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment