mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #4848 from OPM/command-line-snapshots
#4847 Command Line Snapshots : Make sure image size is handled correctly
This commit is contained in:
commit
715a1c66e5
@ -39,6 +39,7 @@
|
|||||||
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
|
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
|
||||||
#include "HoloLensCommands/RicHoloLensSessionManager.h"
|
#include "HoloLensCommands/RicHoloLensSessionManager.h"
|
||||||
#include "RicImportGeneralDataFeature.h"
|
#include "RicImportGeneralDataFeature.h"
|
||||||
|
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
|
||||||
|
|
||||||
#include "Rim2dIntersectionViewCollection.h"
|
#include "Rim2dIntersectionViewCollection.h"
|
||||||
#include "RimAnnotationCollection.h"
|
#include "RimAnnotationCollection.h"
|
||||||
@ -90,6 +91,7 @@
|
|||||||
#include "Riu3dSelectionManager.h"
|
#include "Riu3dSelectionManager.h"
|
||||||
#include "RiuDockWidgetTools.h"
|
#include "RiuDockWidgetTools.h"
|
||||||
#include "RiuMainWindow.h"
|
#include "RiuMainWindow.h"
|
||||||
|
#include "RiuMainWindowTools.h"
|
||||||
#include "RiuMdiMaximizeWindowGuard.h"
|
#include "RiuMdiMaximizeWindowGuard.h"
|
||||||
#include "RiuMessagePanel.h"
|
#include "RiuMessagePanel.h"
|
||||||
#include "RiuPlotMainWindow.h"
|
#include "RiuPlotMainWindow.h"
|
||||||
@ -133,7 +135,6 @@
|
|||||||
#ifdef USE_UNIT_TESTS
|
#ifdef USE_UNIT_TESTS
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#endif // USE_UNIT_TESTS
|
#endif // USE_UNIT_TESTS
|
||||||
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
|
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
@ -649,15 +650,46 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( cvf::Progr
|
|||||||
|
|
||||||
if ( cvf::Option o = progOpt->option( "size" ) )
|
if ( cvf::Option o = progOpt->option( "size" ) )
|
||||||
{
|
{
|
||||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
int width = o.safeValue( 0 ).toInt( -1 );
|
||||||
int width = o.safeValue( 0 ).toInt( -1 );
|
int height = o.safeValue( 1 ).toInt( -1 );
|
||||||
int height = o.safeValue( 1 ).toInt( -1 );
|
|
||||||
if ( mainWnd && width > 0 && height > 0 )
|
if ( width > 0 && height > 0 )
|
||||||
{
|
{
|
||||||
mainWnd->resize( width, height );
|
auto mainWindow = RiuMainWindow::instance();
|
||||||
|
if ( mainWindow )
|
||||||
|
{
|
||||||
|
mainWindow->resize( width, height );
|
||||||
|
}
|
||||||
|
|
||||||
|
auto plotWindow = mainPlotWindow();
|
||||||
|
if ( plotWindow )
|
||||||
|
{
|
||||||
|
plotWindow->resize( width, height );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int snapshotWidth = -1;
|
||||||
|
int snapshotHeight = -1;
|
||||||
|
if ( cvf::Option o = progOpt->option( "snapshotsize" ) )
|
||||||
|
{
|
||||||
|
int width = o.safeValue( 0 ).toInt( -1 );
|
||||||
|
int height = o.safeValue( 1 ).toInt( -1 );
|
||||||
|
|
||||||
|
if ( width > 0 && height > 0 )
|
||||||
|
{
|
||||||
|
snapshotWidth = width;
|
||||||
|
snapshotHeight = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString snapshotFolderFromCommandLine;
|
||||||
|
if ( cvf::Option o = progOpt->option( "snapshotfolder" ) )
|
||||||
|
{
|
||||||
|
CVF_ASSERT( o.valueCount() == 1 );
|
||||||
|
snapshotFolderFromCommandLine = cvfqt::Utils::toQString( o.value( 0 ) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( cvf::Option o = progOpt->option( "summaryplot" ) )
|
if ( cvf::Option o = progOpt->option( "summaryplot" ) )
|
||||||
{
|
{
|
||||||
RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( cvfqt::Utils::toQStringList( o.values() ) );
|
RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( cvfqt::Utils::toQStringList( o.values() ) );
|
||||||
@ -821,31 +853,60 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( cvf::Progr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString exportFolder = QDir::currentPath() + "/snapshots";
|
QString snapshotFolder;
|
||||||
|
|
||||||
if ( snapshotViews )
|
if ( snapshotFolderFromCommandLine.isEmpty() )
|
||||||
{
|
{
|
||||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
snapshotFolder = QDir::currentPath() + "/snapshots";
|
||||||
CVF_ASSERT( mainWnd );
|
}
|
||||||
mainWnd->hideAllDockWidgets();
|
else
|
||||||
|
{
|
||||||
RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( exportFolder );
|
snapshotFolder = snapshotFolderFromCommandLine;
|
||||||
|
|
||||||
mainWnd->loadWinGeoAndDockToolBarLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( snapshotPlots )
|
if ( snapshotPlots )
|
||||||
{
|
{
|
||||||
if ( mainPlotWindow() )
|
auto mainPlotWnd = mainPlotWindow();
|
||||||
|
if ( mainPlotWnd )
|
||||||
{
|
{
|
||||||
mainPlotWindow()->hideAllDockWidgets();
|
mainPlotWnd->show();
|
||||||
|
mainPlotWnd->raise();
|
||||||
|
|
||||||
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( exportFolder );
|
if ( snapshotHeight > -1 && snapshotWidth > -1 )
|
||||||
|
{
|
||||||
|
RiuMainWindowTools::setWindowSizeOnWidgetsInMdiWindows( mainPlotWnd, snapshotWidth, snapshotHeight );
|
||||||
|
}
|
||||||
|
|
||||||
mainPlotWindow()->loadWinGeoAndDockToolBarLayout();
|
processEvents();
|
||||||
|
|
||||||
|
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( snapshotFolder );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( snapshotViews )
|
||||||
|
{
|
||||||
|
auto mainWnd = RiuMainWindow::instance();
|
||||||
|
mainWnd->show();
|
||||||
|
mainWnd->raise();
|
||||||
|
|
||||||
|
if ( snapshotHeight > -1 && snapshotWidth > -1 )
|
||||||
|
{
|
||||||
|
RiuMainWindowTools::setFixedWindowSizeFor3dViews( mainWnd, snapshotWidth, snapshotHeight );
|
||||||
|
}
|
||||||
|
|
||||||
|
processEvents();
|
||||||
|
|
||||||
|
RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( snapshotFolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mainPlotWnd = mainPlotWindow();
|
||||||
|
if ( mainPlotWnd )
|
||||||
|
{
|
||||||
|
mainPlotWnd->loadWinGeoAndDockToolBarLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
RiuMainWindow::instance()->loadWinGeoAndDockToolBarLayout();
|
||||||
|
|
||||||
closeProject();
|
closeProject();
|
||||||
|
|
||||||
return EXIT_COMPLETED;
|
return EXIT_COMPLETED;
|
||||||
|
@ -100,6 +100,14 @@ bool RiaArgumentParser::parseArguments( cvf::ProgramOptions* progOpt )
|
|||||||
"'commandFileReplaceCases'.\n",
|
"'commandFileReplaceCases'.\n",
|
||||||
cvf::ProgramOptions::SINGLE_VALUE );
|
cvf::ProgramOptions::SINGLE_VALUE );
|
||||||
|
|
||||||
|
progOpt->registerOption( "snapshotsize",
|
||||||
|
"<width> <height>",
|
||||||
|
"Set size of exported snapshot images.",
|
||||||
|
cvf::ProgramOptions::MULTI_VALUE );
|
||||||
|
progOpt->registerOption( "snapshotfolder",
|
||||||
|
"<folder>",
|
||||||
|
"Set the destination folder for exported snapshot images.\n",
|
||||||
|
cvf::ProgramOptions::SINGLE_VALUE );
|
||||||
progOpt->registerOption( "savesnapshots",
|
progOpt->registerOption( "savesnapshots",
|
||||||
"all|views|plots",
|
"all|views|plots",
|
||||||
"Save snapshot of all views or plots to project file location sub folder 'snapshots'. "
|
"Save snapshot of all views or plots to project file location sub folder 'snapshots'. "
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
|
|
||||||
#include "RiuMainWindow.h"
|
#include "RiuMainWindow.h"
|
||||||
|
#include "RiuMainWindowTools.h"
|
||||||
#include "RiuPlotMainWindow.h"
|
#include "RiuPlotMainWindow.h"
|
||||||
#include "RiuViewer.h"
|
#include "RiuViewer.h"
|
||||||
|
|
||||||
@ -203,7 +204,7 @@ void RiaRegressionTestRunner::runRegressionTest()
|
|||||||
// Wait until all command objects have completed
|
// Wait until all command objects have completed
|
||||||
app->waitUntilCommandObjectsHasBeenProcessed();
|
app->waitUntilCommandObjectsHasBeenProcessed();
|
||||||
|
|
||||||
regressionTestConfigureProject();
|
setDefaultFixedWindowSizeFor3dViews();
|
||||||
|
|
||||||
resizePlotWindows();
|
resizePlotWindows();
|
||||||
|
|
||||||
@ -469,39 +470,14 @@ void RiaRegressionTestRunner::removeDirectoryWithContent( QDir& dirToDelete )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiaRegressionTestRunner::regressionTestConfigureProject()
|
void RiaRegressionTestRunner::setDefaultFixedWindowSizeFor3dViews()
|
||||||
{
|
{
|
||||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||||
if ( !mainWnd ) return;
|
if ( !mainWnd ) return;
|
||||||
|
|
||||||
RimProject* proj = RiaApplication::instance()->project();
|
QSize defaultSize = RiaRegressionTestRunner::regressionDefaultImageSize();
|
||||||
if ( !proj ) return;
|
|
||||||
|
|
||||||
std::vector<RimCase*> projectCases;
|
RiuMainWindowTools::setFixedWindowSizeFor3dViews( mainWnd, defaultSize.width(), defaultSize.height() );
|
||||||
proj->allCases( projectCases );
|
|
||||||
|
|
||||||
for ( RimCase* cas : projectCases )
|
|
||||||
{
|
|
||||||
if ( !cas ) continue;
|
|
||||||
|
|
||||||
std::vector<Rim3dView*> views = cas->views();
|
|
||||||
|
|
||||||
for ( Rim3dView* riv : views )
|
|
||||||
{
|
|
||||||
if ( riv && riv->viewer() )
|
|
||||||
{
|
|
||||||
// Make sure all views are maximized for snapshotting
|
|
||||||
QMdiSubWindow* subWnd = mainWnd->findMdiSubWindow( riv->viewer()->layoutWidget() );
|
|
||||||
if ( subWnd )
|
|
||||||
{
|
|
||||||
subWnd->showMaximized();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This size is set to match the regression test reference images
|
|
||||||
riv->viewer()->setFixedSize( RiaRegressionTestRunner::regressionDefaultImageSize() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -509,34 +485,12 @@ void RiaRegressionTestRunner::regressionTestConfigureProject()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiaRegressionTestRunner::resizePlotWindows()
|
void RiaRegressionTestRunner::resizePlotWindows()
|
||||||
{
|
{
|
||||||
RimProject* proj = RiaApplication::instance()->project();
|
|
||||||
if ( !proj ) return;
|
|
||||||
|
|
||||||
RiuPlotMainWindow* plotMainWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
RiuPlotMainWindow* plotMainWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
||||||
if ( !plotMainWindow ) return;
|
if ( !plotMainWindow ) return;
|
||||||
|
|
||||||
std::vector<RimViewWindow*> viewWindows;
|
QSize defaultSize = RiaRegressionTestRunner::regressionDefaultImageSize();
|
||||||
|
|
||||||
proj->mainPlotCollection()->descendantsIncludingThisOfType( viewWindows );
|
RiuMainWindowTools::setWindowSizeOnWidgetsInMdiWindows( plotMainWindow, defaultSize.width(), defaultSize.height() );
|
||||||
|
|
||||||
for ( auto viewWindow : viewWindows )
|
|
||||||
{
|
|
||||||
if ( viewWindow->isMdiWindow() )
|
|
||||||
{
|
|
||||||
QWidget* viewWidget = viewWindow->viewWidget();
|
|
||||||
|
|
||||||
if ( viewWidget )
|
|
||||||
{
|
|
||||||
QMdiSubWindow* mdiWindow = plotMainWindow->findMdiSubWindow( viewWidget );
|
|
||||||
if ( mdiWindow )
|
|
||||||
{
|
|
||||||
mdiWindow->showNormal();
|
|
||||||
|
|
||||||
viewWidget->resize( RiaRegressionTestRunner::regressionDefaultImageSize() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
bool useOpenMPForGeometryCreation() const;
|
bool useOpenMPForGeometryCreation() const;
|
||||||
|
|
||||||
static void updateRegressionTest( const QString& testRootPath );
|
static void updateRegressionTest( const QString& testRootPath );
|
||||||
static void regressionTestConfigureProject();
|
static void setDefaultFixedWindowSizeFor3dViews();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RiaRegressionTestRunner();
|
RiaRegressionTestRunner();
|
||||||
|
@ -59,7 +59,7 @@ RicfCommandResponse RicfOpenProject::execute()
|
|||||||
|
|
||||||
if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
|
if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
|
||||||
{
|
{
|
||||||
RiaRegressionTestRunner::regressionTestConfigureProject();
|
RiaRegressionTestRunner::setDefaultFixedWindowSizeFor3dViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
RicfCommandFileExecutor::instance()->setLastProjectPath( projectPath );
|
RicfCommandFileExecutor::instance()->setLastProjectPath( projectPath );
|
||||||
|
@ -20,12 +20,24 @@
|
|||||||
|
|
||||||
#include "RiaGuiApplication.h"
|
#include "RiaGuiApplication.h"
|
||||||
|
|
||||||
|
#include "RimViewWindow.h"
|
||||||
|
|
||||||
|
#include "Rim3dView.h"
|
||||||
|
#include "RimCase.h"
|
||||||
|
#include "RimProject.h"
|
||||||
|
|
||||||
|
#include "RiuInterfaceToViewWindow.h"
|
||||||
#include "RiuMainWindow.h"
|
#include "RiuMainWindow.h"
|
||||||
|
#include "RiuMainWindowBase.h"
|
||||||
#include "RiuPlotMainWindow.h"
|
#include "RiuPlotMainWindow.h"
|
||||||
|
#include "RiuViewer.h"
|
||||||
|
|
||||||
#include "cafPdmUiTreeOrdering.h"
|
#include "cafPdmUiTreeOrdering.h"
|
||||||
#include "cafPdmUiTreeView.h"
|
#include "cafPdmUiTreeView.h"
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QMdiSubWindow>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -82,3 +94,67 @@ void RiuMainWindowTools::collapseSiblings( const caf::PdmUiItem* sourceUiItem )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuMainWindowTools::setWindowSizeOnWidgetsInMdiWindows( RiuMainWindowBase* mainWindow, int width, int height )
|
||||||
|
{
|
||||||
|
if ( !mainWindow ) return;
|
||||||
|
|
||||||
|
auto widgets = mainWindow->findChildren<QMdiSubWindow*>();
|
||||||
|
for ( auto w : widgets )
|
||||||
|
{
|
||||||
|
if ( !w ) continue;
|
||||||
|
|
||||||
|
w->showNormal();
|
||||||
|
|
||||||
|
auto viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget( w->widget() );
|
||||||
|
|
||||||
|
if ( viewWindow && viewWindow->viewWidget() )
|
||||||
|
{
|
||||||
|
QWidget* viewWidget = viewWindow->viewWidget();
|
||||||
|
|
||||||
|
viewWidget->resize( width, height );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuMainWindowTools::setFixedWindowSizeFor3dViews( RiuMainWindowBase* mainWindow, int width, int height )
|
||||||
|
{
|
||||||
|
if ( !mainWindow ) return;
|
||||||
|
|
||||||
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
|
if ( !proj ) return;
|
||||||
|
|
||||||
|
std::vector<RimCase*> projectCases;
|
||||||
|
proj->allCases( projectCases );
|
||||||
|
|
||||||
|
for ( RimCase* cas : projectCases )
|
||||||
|
{
|
||||||
|
if ( !cas ) continue;
|
||||||
|
|
||||||
|
std::vector<Rim3dView*> views = cas->views();
|
||||||
|
|
||||||
|
for ( Rim3dView* riv : views )
|
||||||
|
{
|
||||||
|
if ( riv && riv->viewer() )
|
||||||
|
{
|
||||||
|
// Make sure all views are maximized for snapshotting
|
||||||
|
QMdiSubWindow* subWnd = mainWindow->findMdiSubWindow( riv->viewer()->layoutWidget() );
|
||||||
|
if ( subWnd )
|
||||||
|
{
|
||||||
|
subWnd->showMaximized();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This size is set to match the regression test reference images
|
||||||
|
QSize windowSize( width, height );
|
||||||
|
|
||||||
|
riv->viewer()->setFixedSize( windowSize );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -23,8 +23,16 @@ namespace caf
|
|||||||
class PdmUiItem;
|
class PdmUiItem;
|
||||||
} // namespace caf
|
} // namespace caf
|
||||||
|
|
||||||
|
class RiuMainWindowBase;
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
class RiuMainWindowTools
|
class RiuMainWindowTools
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void collapseSiblings( const caf::PdmUiItem* uiItem );
|
static void collapseSiblings( const caf::PdmUiItem* uiItem );
|
||||||
|
|
||||||
|
static void setWindowSizeOnWidgetsInMdiWindows( RiuMainWindowBase* mainWindow, int width, int height );
|
||||||
|
static void setFixedWindowSizeFor3dViews( RiuMainWindowBase* mainWindow, int width, int height );
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user