mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4847 Command Line Snapshots : Make sure image size is handled correctly
This commit is contained in:
parent
71760b0e34
commit
69ff4d25f2
@ -39,6 +39,7 @@
|
||||
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
|
||||
#include "HoloLensCommands/RicHoloLensSessionManager.h"
|
||||
#include "RicImportGeneralDataFeature.h"
|
||||
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
|
||||
|
||||
#include "Rim2dIntersectionViewCollection.h"
|
||||
#include "RimAnnotationCollection.h"
|
||||
@ -90,6 +91,7 @@
|
||||
#include "Riu3dSelectionManager.h"
|
||||
#include "RiuDockWidgetTools.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuMainWindowTools.h"
|
||||
#include "RiuMdiMaximizeWindowGuard.h"
|
||||
#include "RiuMessagePanel.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
@ -133,7 +135,6 @@
|
||||
#ifdef USE_UNIT_TESTS
|
||||
#include "gtest/gtest.h"
|
||||
#endif // USE_UNIT_TESTS
|
||||
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@ -647,14 +648,30 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( cvf::Progr
|
||||
setStartDir( cvfqt::Utils::toQString( o.value( 0 ) ) );
|
||||
}
|
||||
|
||||
int snapshotWidth = -1;
|
||||
int snapshotHeight = -1;
|
||||
|
||||
if ( cvf::Option o = progOpt->option( "size" ) )
|
||||
{
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
int width = o.safeValue( 0 ).toInt( -1 );
|
||||
int height = o.safeValue( 1 ).toInt( -1 );
|
||||
if ( mainWnd && width > 0 && height > 0 )
|
||||
|
||||
if ( width > 0 && height > 0 )
|
||||
{
|
||||
mainWnd->resize( width, height );
|
||||
snapshotWidth = width;
|
||||
snapshotHeight = height;
|
||||
|
||||
auto mainWindow = RiuMainWindow::instance();
|
||||
if ( mainWindow )
|
||||
{
|
||||
mainWindow->resize( width, height );
|
||||
}
|
||||
|
||||
auto plotWindow = mainPlotWindow();
|
||||
if ( plotWindow )
|
||||
{
|
||||
plotWindow->resize( width, height );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -823,29 +840,50 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( cvf::Progr
|
||||
|
||||
QString exportFolder = QDir::currentPath() + "/snapshots";
|
||||
|
||||
if ( snapshotViews )
|
||||
{
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
CVF_ASSERT( mainWnd );
|
||||
mainWnd->hideAllDockWidgets();
|
||||
|
||||
RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( exportFolder );
|
||||
|
||||
mainWnd->loadWinGeoAndDockToolBarLayout();
|
||||
}
|
||||
|
||||
if ( snapshotPlots )
|
||||
{
|
||||
if ( mainPlotWindow() )
|
||||
auto mainPlotWnd = mainPlotWindow();
|
||||
if ( mainPlotWnd )
|
||||
{
|
||||
mainPlotWindow()->hideAllDockWidgets();
|
||||
mainPlotWnd->show();
|
||||
mainPlotWnd->raise();
|
||||
|
||||
if ( snapshotHeight > -1 && snapshotWidth > -1 )
|
||||
{
|
||||
RiuMainWindowTools::setWindowSizeOnWidgetsInMdiWindows( mainPlotWnd, snapshotWidth, snapshotHeight );
|
||||
}
|
||||
|
||||
processEvents();
|
||||
|
||||
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( exportFolder );
|
||||
}
|
||||
}
|
||||
|
||||
mainPlotWindow()->loadWinGeoAndDockToolBarLayout();
|
||||
if ( snapshotViews )
|
||||
{
|
||||
auto mainWnd = RiuMainWindow::instance();
|
||||
mainWnd->show();
|
||||
mainWnd->raise();
|
||||
|
||||
if ( snapshotHeight > -1 && snapshotWidth > -1 )
|
||||
{
|
||||
QSize windowSize( snapshotWidth, snapshotHeight );
|
||||
RiaRegressionTestRunner::setFixedWindowSizeFor3dViews( windowSize );
|
||||
}
|
||||
|
||||
processEvents();
|
||||
|
||||
RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( exportFolder );
|
||||
}
|
||||
|
||||
auto mainPlotWnd = mainPlotWindow();
|
||||
if ( mainPlotWnd )
|
||||
{
|
||||
mainPlotWnd->loadWinGeoAndDockToolBarLayout();
|
||||
}
|
||||
|
||||
RiuMainWindow::instance()->loadWinGeoAndDockToolBarLayout();
|
||||
|
||||
closeProject();
|
||||
|
||||
return EXIT_COMPLETED;
|
||||
|
@ -203,7 +203,7 @@ void RiaRegressionTestRunner::runRegressionTest()
|
||||
// Wait until all command objects have completed
|
||||
app->waitUntilCommandObjectsHasBeenProcessed();
|
||||
|
||||
regressionTestConfigureProject();
|
||||
setDefaultFixedWindowSizeFor3dViews();
|
||||
|
||||
resizePlotWindows();
|
||||
|
||||
@ -469,7 +469,7 @@ void RiaRegressionTestRunner::removeDirectoryWithContent( QDir& dirToDelete )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaRegressionTestRunner::regressionTestConfigureProject()
|
||||
void RiaRegressionTestRunner::setFixedWindowSizeFor3dViews( const QSize& snapshotImageSize )
|
||||
{
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
if ( !mainWnd ) return;
|
||||
@ -498,12 +498,20 @@ void RiaRegressionTestRunner::regressionTestConfigureProject()
|
||||
}
|
||||
|
||||
// This size is set to match the regression test reference images
|
||||
riv->viewer()->setFixedSize( RiaRegressionTestRunner::regressionDefaultImageSize() );
|
||||
riv->viewer()->setFixedSize( snapshotImageSize );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaRegressionTestRunner::setDefaultFixedWindowSizeFor3dViews()
|
||||
{
|
||||
setFixedWindowSizeFor3dViews( RiaRegressionTestRunner::regressionDefaultImageSize() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -42,7 +42,8 @@ public:
|
||||
bool useOpenMPForGeometryCreation() const;
|
||||
|
||||
static void updateRegressionTest( const QString& testRootPath );
|
||||
static void regressionTestConfigureProject();
|
||||
static void setFixedWindowSizeFor3dViews( const QSize& snapshotImageSize );
|
||||
static void setDefaultFixedWindowSizeFor3dViews();
|
||||
|
||||
private:
|
||||
RiaRegressionTestRunner();
|
||||
|
@ -59,7 +59,7 @@ RicfCommandResponse RicfOpenProject::execute()
|
||||
|
||||
if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
|
||||
{
|
||||
RiaRegressionTestRunner::regressionTestConfigureProject();
|
||||
RiaRegressionTestRunner::setDefaultFixedWindowSizeFor3dViews();
|
||||
}
|
||||
|
||||
RicfCommandFileExecutor::instance()->setLastProjectPath( projectPath );
|
||||
|
@ -20,12 +20,19 @@
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include "RiuInterfaceToViewWindow.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuMainWindowBase.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cafPdmUiTreeView.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMdiSubWindow>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -82,3 +89,30 @@ void RiuMainWindowTools::collapseSiblings( const caf::PdmUiItem* sourceUiItem )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindowTools::setWindowSizeOnWidgetsInMdiWindows( RiuMainWindowBase* mainWindow, int width, int height )
|
||||
{
|
||||
if ( mainWindow )
|
||||
{
|
||||
auto widgets = mainWindow->findChildren<QMdiSubWindow*>();
|
||||
for ( auto w : widgets )
|
||||
{
|
||||
if ( w )
|
||||
{
|
||||
w->showNormal();
|
||||
|
||||
auto viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget( w->widget() );
|
||||
|
||||
if ( viewWindow && viewWindow->viewWidget() )
|
||||
{
|
||||
QWidget* viewWidget = viewWindow->viewWidget();
|
||||
|
||||
viewWidget->resize( width, height );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,14 @@ namespace caf
|
||||
class PdmUiItem;
|
||||
} // namespace caf
|
||||
|
||||
class RiuMainWindowBase;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiuMainWindowTools
|
||||
{
|
||||
public:
|
||||
static void collapseSiblings( const caf::PdmUiItem* uiItem );
|
||||
static void setWindowSizeOnWidgetsInMdiWindows( RiuMainWindowBase* mainWindow, int width, int height );
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user