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

[CHANGE #239] the screen recorder is now created per view -> each view dock...

[CHANGE #239] the screen recorder is now created per view -> each view dock has its own. Still missing is the configuration for it.
parent 53968fda
......@@ -244,10 +244,10 @@ void WMainWindow::setupGUI()
WQtGLDockWidget* mainGLDock = new WQtGLDockWidget( "Main View", "3D View", m_glDock );
mainGLDock->getGLWidget()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_mainGLWidget = mainGLDock->getGLWidget();
m_mainGLWidgetScreenCapture = m_mainGLWidget->getScreenCapture( this );
// m_mainGLWidgetScreenCapture = mainGLDock->getScreenCapture();
m_glDock->addDockWidget( Qt::RightDockWidgetArea, mainGLDock );
addDockWidget( Qt::RightDockWidgetArea, m_mainGLWidgetScreenCapture );
tabifyDockWidget( m_controlPanel->getRoiDock(), m_mainGLWidgetScreenCapture );
// addDockWidget( Qt::RightDockWidgetArea, m_mainGLWidgetScreenCapture );
// tabifyDockWidget( m_controlPanel->getRoiDock(), m_mainGLWidgetScreenCapture );
connect( m_mainGLWidget.get(), SIGNAL( renderedFirstFrame() ), this, SLOT( handleGLVendor() ) );
addDockWidget( Qt::RightDockWidgetArea, m_controlPanel );
......@@ -415,7 +415,7 @@ void WMainWindow::setupGUI()
m_permanentToolBar->addAction( m_loadButton );
m_permanentToolBar->addAction( m_saveAction );
m_permanentToolBar->addSeparator();
m_permanentToolBar->addAction( m_mainGLWidgetScreenCapture->getScreenshotTrigger() );
// m_permanentToolBar->addAction( m_mainGLWidgetScreenCapture->getScreenshotTrigger() );
m_permanentToolBar->addSeparator();
m_permanentToolBar->addAction( roiButton );
m_permanentToolBar->addSeparator();
......@@ -1144,19 +1144,6 @@ void WMainWindow::handleStartMessages()
showWelcomeDialog( false );
}
void WMainWindow::forceMainGLWidgetSize( size_t w, size_t h )
{
m_mainGLWidget->setFixedSize( w, h );
}
void WMainWindow::restoreMainGLWidgetSize()
{
m_mainGLWidget->setMinimumHeight( 250 );
m_mainGLWidget->setMaximumHeight( QWIDGETSIZE_MAX );
m_mainGLWidget->setMinimumWidth( 250 );
m_mainGLWidget->setMaximumWidth( QWIDGETSIZE_MAX );
}
void WMainWindow::handleDrop( QDropEvent* event )
{
if( event->mimeData()->hasUrls() )
......
......@@ -151,19 +151,6 @@ public:
*/
static QSettings& getSettings();
/**
* Forces the main gl widget to have the desired size. This is mainly useful for screenshots and similar.
*
* \param w width
* \param h height
*/
void forceMainGLWidgetSize( size_t w, size_t h );
/**
* Restores the main GL widget size if it was fixed with forceMainGLWidgetSize() previously.
*/
void restoreMainGLWidgetSize();
/**
* Get the current splash screen
*
......
......@@ -39,7 +39,8 @@
WQtGLDockWidget::WQtGLDockWidget( QString viewTitle, QString dockTitle, QWidget* parent, WGECamera::ProjectionMode projectionMode,
const QWidget* shareWidget )
: QDockWidget( dockTitle, parent )
: QDockWidget( dockTitle, parent ),
m_dockTitle( dockTitle )
{
setObjectName( QString( "GL - " ) + dockTitle );
......@@ -66,6 +67,11 @@ WQtGLDockWidget::WQtGLDockWidget( QString viewTitle, QString dockTitle, QWidget*
// we need to know whether the dock is visible or not
connect( this, SIGNAL( visibilityChanged( bool ) ), this, SLOT( handleVisibilityChange( bool ) ) );
// all view docks have a screen capture object
m_screenCapture = new WQtGLScreenCapture( this );
// hide the screen capture object by default
m_screenCapture->setHidden( true );
// set custom title
setTitleBarWidget( new WQtGLDockWidgetTitle( this, dockTitle ) );
}
......@@ -114,6 +120,11 @@ void setupButton( QToolButton* btn )
WQtGLDockWidgetTitle::WQtGLDockWidgetTitle( WQtGLDockWidget* parent, const QString& dockTitle ):
QWidget( parent )
{
// screen capture trigger
QToolButton* screenShotBtn = new QToolButton( this );
screenShotBtn->setDefaultAction( parent->getScreenCapture()->getScreenshotTrigger() );
setupButton( screenShotBtn );
// camera presets
QAction* camPresets = new QAction( WQt4Gui::getIconManager()->getIcon( "view" ), "Camera Presets", this );
camPresets->setMenu( parent->getGLWidget()->getCameraPresetsAndResetMenu() );
......@@ -153,6 +164,7 @@ WQtGLDockWidgetTitle::WQtGLDockWidgetTitle( WQtGLDockWidget* parent, const QStri
layout->addWidget( title );
layout->addStretch( 100000 );
layout->addWidget( screenShotBtn );
layout->addWidget( presetBtn );
layout->addWidget( settingsBtn );
layout->addWidget( closeBtn );
......@@ -168,3 +180,26 @@ WQtGLDockWidgetTitle::WQtGLDockWidgetTitle( WQtGLDockWidget* parent, const QStri
"}"
);
}
WQtGLScreenCapture* WQtGLDockWidget::getScreenCapture()
{
return m_screenCapture;
}
void WQtGLDockWidget::forceGLWidgetSize( size_t w, size_t h )
{
m_glWidget->setFixedSize( w, h );
}
void WQtGLDockWidget::restoreGLWidgetSize()
{
m_glWidget->setMinimumHeight( 250 );
m_glWidget->setMaximumHeight( QWIDGETSIZE_MAX );
m_glWidget->setMinimumWidth( 250 );
m_glWidget->setMaximumWidth( QWIDGETSIZE_MAX );
}
const QString& WQtGLDockWidget::getDockTitle() const
{
return m_dockTitle;
}
......@@ -65,6 +65,34 @@ public:
*/
boost::shared_ptr< WQtGLWidget > getGLWidget() const;
/**
* Adds a screen capture dock using this view's screen capture callback.
*
* \return the capture dock instance.
*/
WQtGLScreenCapture* getScreenCapture();
/**
* Forces the GL widget to have the desired size. This is mainly useful for screenshots and similar.
*
* \param w width
* \param h height
*/
void forceGLWidgetSize( size_t w, size_t h );
/**
* Restores the GL widget size if it was fixed with forceMainGLWidgetSize() previously.
*/
void restoreGLWidgetSize();
/**
* Return the title of the view/dock.
*
* \return the title text
*/
const QString& getDockTitle() const;
protected:
/**
* Layout of this widget. Use this to extend the dock width other widgets (i.e. PropWidgets).
......@@ -103,6 +131,16 @@ private:
* My GL widget.
*/
boost::shared_ptr<WQtGLWidget> m_glWidget;
/**
* The view name and dock title.
*/
QString m_dockTitle;
/**
* Manager for screen capturing of this view
*/
WQtGLScreenCapture* m_screenCapture;
};
/**
......
......@@ -36,14 +36,16 @@
#include "core/common/WLogger.h"
#include "events/WEventTypes.h"
#include "WMainWindow.h"
#include "WQtGLWidget.h"
#include "WQtGLDockWidget.h"
#include "WQt4Gui.h"
#include "WQtGLScreenCapture.h"
#include "WQtGLScreenCapture.moc"
WQtGLScreenCapture::WQtGLScreenCapture( WGEViewer::SPtr viewer, WMainWindow* parent ):
WQtGLScreenCapture::WQtGLScreenCapture( WQtGLDockWidget* parent ):
QDockWidget( "Recorder", parent ),
m_mainWindow( parent ),
m_viewer( viewer ),
m_iconManager( parent->getIconManager() )
m_glDockWidget( parent ),
m_viewer( m_glDockWidget->getGLWidget()->getViewer() )
{
// initialize
setObjectName( "Recorder Dock" );
......@@ -117,7 +119,8 @@ WQtGLScreenCapture::WQtGLScreenCapture( WGEViewer::SPtr viewer, WMainWindow* par
);
m_configFileEdit = new QLineEdit();
std::string defaultFilename = ( QDir::homePath() + QDir::separator() + "OpenWalnut_Frame_%f.jpg" ).toStdString();
std::string defaultFilename = ( QDir::homePath() + QDir::separator() +
"OpenWalnut - " + parent->getDockTitle() + " - Frame %f.png" ).toStdString();
m_configFileEdit->setText( QString::fromStdString( defaultFilename ) );
fileGroupLayout->addWidget( configFileHint );
......@@ -137,9 +140,9 @@ 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_screenshotButton->setToolTip( "Take a screenshot of this view" );
m_screenshotAction = new QAction( WQt4Gui::getIconManager()->getIcon( "image" ), "Screenshot", this );
m_screenshotAction->setToolTip( "Take a screenshot of this view" );
m_screenshotAction->setShortcut( QKeySequence( Qt::Key_F12 ) );
m_screenshotAction->setShortcutContext( Qt::ApplicationShortcut );
connect( m_screenshotAction, SIGNAL( triggered( bool ) ), this, SLOT( screenShot() ) );
......@@ -242,10 +245,13 @@ WQtGLScreenCapture::WQtGLScreenCapture( WGEViewer::SPtr viewer, WMainWindow* par
QCoreApplication::postEvent( this, new QEvent( static_cast< QEvent::Type >( WQT_SCREENCAPTURE_EVENT ) ) );
// add them
m_toolbox->insertItem( 0, m_configWidget, m_iconManager->getIcon( "preferences" ), "Configuration" );
m_toolbox->insertItem( 1, m_screenshotWidget, m_iconManager->getIcon( "image" ), "Screenshot" );
m_toolbox->insertItem( 2, m_movieWidget, m_iconManager->getIcon( "video" ), "Movie" );
m_toolbox->insertItem( 3, m_animationWidget, m_iconManager->getIcon( "video" ), "Animation" );
m_toolbox->insertItem( 0, m_configWidget, WQt4Gui::getIconManager()->getIcon( "preferences" ), "Configuration" );
m_toolbox->insertItem( 1, m_screenshotWidget, WQt4Gui::getIconManager()->getIcon( "image" ), "Screenshot" );
m_toolbox->insertItem( 2, m_movieWidget, WQt4Gui::getIconManager()->getIcon( "video" ), "Movie" );
// hide it as long as issue #127 is not done.
// m_toolbox->insertItem( 3, m_animationWidget, WQt4Gui::getIconManager()->getIcon( "video" ), "Animation" );
m_animationWidget->setHidden( true );
// we need to be notified about the screen grabbers state
m_recordConnection = m_viewer->getScreenCapture()->getRecordCondition()->subscribeSignal( boost::bind( &WQtGLScreenCapture::recCallback, this ) );
......@@ -402,32 +408,32 @@ void WQtGLScreenCapture::resolutionChange( bool force )
switch( m_resolutionCombo->currentIndex() )
{
case 0:
m_mainWindow->forceMainGLWidgetSize( 640, 480 );
m_glDockWidget->forceGLWidgetSize( 640, 480 );
break;
case 1:
m_mainWindow->forceMainGLWidgetSize( 800, 600 );
m_glDockWidget->forceGLWidgetSize( 800, 600 );
break;
case 2:
m_mainWindow->forceMainGLWidgetSize( 1024, 768 );
m_glDockWidget->forceGLWidgetSize( 1024, 768 );
break;
case 3:
m_mainWindow->forceMainGLWidgetSize( 1280, 1024 );
m_glDockWidget->forceGLWidgetSize( 1280, 1024 );
break;
case 4:
m_mainWindow->forceMainGLWidgetSize( 1280, 720 );
m_glDockWidget->forceGLWidgetSize( 1280, 720 );
break;
case 5:
m_mainWindow->forceMainGLWidgetSize( 1920, 1080 );
m_glDockWidget->forceGLWidgetSize( 1920, 1080 );
break;
case 6: // custom size
m_mainWindow->forceMainGLWidgetSize( m_customWidth->text().toInt(), m_customHeight->text().toInt() );
m_glDockWidget->forceGLWidgetSize( m_customWidth->text().toInt(), m_customHeight->text().toInt() );
break;
}
}
else
{
wlog::debug( "WQtGLScreenCapture" ) << "Restoring resolution";
m_mainWindow->restoreMainGLWidgetSize();
m_glDockWidget->restoreGLWidgetSize();
}
}
......@@ -44,7 +44,7 @@
#include "WIconManager.h"
class WMainWindow;
class WQtGLDockWidget;
/**
* This class is a screen recorder adapter in QT. It uses WGEScreenCapture and provides a nice widget around it.
......@@ -56,10 +56,9 @@ public:
/**
* Creates screen capture gui for the specified capture callback of a certain view.
*
* \param viewer the viewer to control
* \param parent the parent
*/
WQtGLScreenCapture( WGEViewer::SPtr viewer, WMainWindow* parent );
explicit WQtGLScreenCapture( WQtGLDockWidget* parent );
/**
* Destructor. Cleans up.
......@@ -139,7 +138,7 @@ private:
/**
* My parent.
*/
WMainWindow* m_mainWindow;
WQtGLDockWidget* m_glDockWidget;
/**
* The actual screen capture instance.
......@@ -175,11 +174,6 @@ private:
*/
QToolBox* m_toolbox;
/**
* The icons used here.
*/
WIconManager* m_iconManager;
/**
* The configuration widget. It contains the common config stuff
*/
......
......@@ -449,12 +449,6 @@ void WQtGLWidget::notifyFirstRenderedFrame()
QCoreApplication::postEvent( this, new WRenderedFrameEvent() );
}
WQtGLScreenCapture* WQtGLWidget::getScreenCapture( WMainWindow* parent ) const
{
WQtGLScreenCapture* sc = new WQtGLScreenCapture( getViewer(), parent );
return sc;
}
void WQtGLWidget::setPresetViewLeft()
{
osg::ref_ptr<osgGA::TrackballManipulator> cm = osg::dynamic_pointer_cast<osgGA::TrackballManipulator>( m_Viewer->getCameraManipulator() );
......
......@@ -138,14 +138,6 @@ public:
*/
QAction* getBackgroundColorAction() const;
/**
* Adds a screen capture dock using this view's screen capture callback.
*
* \param parent the main window parent
* \return the capture dock instance.
*/
WQtGLScreenCapture* getScreenCapture( WMainWindow* parent ) const;
/**
* The presets menu.
*
......
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