Some cleanup

This commit is contained in:
Jon Jenssen
2026-06-17 13:55:32 +02:00
committed by JJ
parent 44488996f3
commit 18cf162ce0
14 changed files with 26 additions and 51 deletions
@@ -1854,9 +1854,11 @@ bool RiaGuiApplication::notify( QObject* receiver, QEvent* event )
{ {
if ( activeWindow() != mainWindow() ) if ( activeWindow() != mainWindow() )
{ {
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>( event ); QWheelEvent* wheelEvent = static_cast<QWheelEvent*>( event );
RimPlotWindow* plot = dynamic_cast<RimPlotWindow*>( activePlotWindow() ); if ( RimPlotWindow* plot = dynamic_cast<RimPlotWindow*>( activePlotWindow() ) )
if ( plot ) done = plot->handleGlobalWheelEvent( wheelEvent ); {
done = plot->handleGlobalWheelEvent( wheelEvent );
}
} }
} }
if ( !done ) if ( !done )
@@ -21,8 +21,6 @@
#include "RiaLogging.h" #include "RiaLogging.h"
#include "RiuMainWindow.h"
#include "cafPdmFieldScriptingCapability.h" #include "cafPdmFieldScriptingCapability.h"
CAF_PDM_SOURCE_INIT( RicfSetMainWindowSize, "setMainWindowSize" ); CAF_PDM_SOURCE_INIT( RicfSetMainWindowSize, "setMainWindowSize" );
@@ -41,6 +39,7 @@ RicfSetMainWindowSize::RicfSetMainWindowSize()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmScriptResponse RicfSetMainWindowSize::execute() caf::PdmScriptResponse RicfSetMainWindowSize::execute()
{ {
RiaLogging::warning( "Method set_main_window_size has been obsoleted. Set size of image snapshots directly in the snapshot methods." ); RiaLogging::warning( "Method set_main_window_size has been obsoleted. Set image sizes directly in the snapshot methods." );
return caf::PdmScriptResponse(); return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_WARNING,
"Obsolete command. Set image sizes directly in the snapshot methods." );
} }
@@ -18,8 +18,7 @@
#include "RicfSetPlotWindowSize.h" #include "RicfSetPlotWindowSize.h"
#include "RiaGuiApplication.h" #include "RiaLogging.h"
#include "RiuPlotMainWindow.h"
#include "cafPdmFieldScriptingCapability.h" #include "cafPdmFieldScriptingCapability.h"
@@ -39,11 +38,7 @@ RicfSetPlotWindowSize::RicfSetPlotWindowSize()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmScriptResponse RicfSetPlotWindowSize::execute() caf::PdmScriptResponse RicfSetPlotWindowSize::execute()
{ {
RiaGuiApplication* guiApp = RiaGuiApplication::instance(); RiaLogging::warning( "Method set_plot_window_size has been obsoleted. Set image sizes directly in the snapshot methods." );
if ( guiApp ) return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_WARNING,
{ "Obsolete command. Set image sizes directly in the snapshot methods." );
guiApp->getOrCreateAndShowMainPlotWindow()->resize( m_width, m_height );
return caf::PdmScriptResponse();
}
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, "Need GUI ResInsight to set plot window size" );
} }
@@ -70,7 +70,7 @@ void RicSnapshotAllViewsToFileFeature::saveAllViews()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Export snapshots of a given view (or viewId == -1 for all views) for the given case (or caseId == -1 for all cases) /// Export snapshots of a given view (or viewId == -1 for all views) for the given case (or caseId == -1 for all cases)
/// -1 for width and height means to use the existing view size /// <= 0 for width and height means to use the existing view size
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( const QString& snapshotFolderName, void RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( const QString& snapshotFolderName,
int width, int width,
@@ -500,8 +500,6 @@ void Rim3dView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOr
m_annotationCountHint.uiCapability()->setUiReadOnly( m_annotationCountHint.uiCapability()->setUiReadOnly(
!m_useCustomAnnotationStrategy || ( m_annotationStrategy() != RivAnnotationTools::LabelPositionStrategy::COUNT_HINT ) ); !m_useCustomAnnotationStrategy || ( m_annotationStrategy() != RivAnnotationTools::LabelPositionStrategy::COUNT_HINT ) );
uiOrdering.add( &m_dockWindowId );
uiOrdering.skipRemainingFields( true ); uiOrdering.skipRemainingFields( true );
} }
@@ -35,7 +35,6 @@
#include "cafPdmUiToolButtonEditor.h" #include "cafPdmUiToolButtonEditor.h"
#include <QPaintDevice> #include <QPaintDevice>
#include <QPainter>
#include <QRegularExpression> #include <QRegularExpression>
#include <cvfAssert.h> #include <cvfAssert.h>
@@ -651,7 +650,7 @@ QImage RimMultiPlot::captureSnapshot( int width, int height )
QSize orgViewSize = m_viewer->size(); QSize orgViewSize = m_viewer->size();
image = RimViewWindow::captureSnapshot( m_viewer->bookWidget(), width, height ); image = RimViewWindow::internalCaptureSnapshot( m_viewer->bookWidget(), width, height );
m_viewer->resize( orgViewSize ); m_viewer->resize( orgViewSize );
doUpdateLayout(); doUpdateLayout();
@@ -196,8 +196,7 @@ void RimPlot::doRenderWindowContent( QPaintDevice* paintDevice )
{ {
if ( plotWidget() ) if ( plotWidget() )
{ {
auto rect = plotWidget()->frameGeometry(); plotWidget()->renderTo( paintDevice, plotWidget()->frameGeometry() );
plotWidget()->renderTo( paintDevice, rect );
} }
} }
@@ -69,7 +69,7 @@ RimViewWindow::RimViewWindow()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimViewWindow::~RimViewWindow() RimViewWindow::~RimViewWindow()
{ {
if ( m_windowController ) delete m_windowController; if ( m_windowController() ) delete m_windowController();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -234,13 +234,13 @@ QImage RimViewWindow::snapshotWindowContent()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QImage RimViewWindow::captureSnapshot( int width, int height ) QImage RimViewWindow::captureSnapshot( int width, int height )
{ {
return captureSnapshot( viewWidget(), width, height ); return internalCaptureSnapshot( viewWidget(), width, height );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QImage RimViewWindow::captureSnapshot( QWidget* widget, int width, int height ) QImage RimViewWindow::internalCaptureSnapshot( QWidget* widget, int width, int height )
{ {
if ( !widget ) return QImage(); if ( !widget ) return QImage();
@@ -400,7 +400,7 @@ void RimViewWindow::defineObjectEditorAttribute( QString uiConfigName, caf::PdmU
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
ads::CDockWidget* RimViewWindow::dockWidget() ads::CDockWidget* RimViewWindow::dockWidget() const
{ {
return m_dockWidget; return m_dockWidget;
} }
@@ -65,7 +65,7 @@ public:
virtual QWidget* viewWidget() = 0; virtual QWidget* viewWidget() = 0;
ads::CDockWidget* dockWidget(); ads::CDockWidget* dockWidget() const;
ads::CDockWidget* createDockWidget(); ads::CDockWidget* createDockWidget();
virtual QImage captureSnapshot( int width, int height ); virtual QImage captureSnapshot( int width, int height );
@@ -103,7 +103,7 @@ protected:
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
QImage captureSnapshot( QWidget* widget, int width, int height ); static QImage internalCaptureSnapshot( QWidget* widget, int width, int height );
private: private:
friend class RimProject; friend class RimProject;
@@ -327,14 +327,6 @@ QString RiuDockWidgetTools::dockStateHideAll3DWindowName()
return "Hide All"; return "Hide All";
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuDockWidgetTools::viewWindowPrefix()
{
return "DockViewWindow_";
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -91,8 +91,6 @@ public:
static QString dockStateHideAllPlotWindowName(); static QString dockStateHideAllPlotWindowName();
static QString dockStateHideAll3DWindowName(); static QString dockStateHideAll3DWindowName();
static QString viewWindowPrefix();
static void setDockLayout( RiuMainWindowBase* mainWindow, const QString& layoutName ); static void setDockLayout( RiuMainWindowBase* mainWindow, const QString& layoutName );
static QAction* toggleActionForWidget( const ads::CDockManager* dockManager, const QString& dockWidgetName ); static QAction* toggleActionForWidget( const ads::CDockManager* dockManager, const QString& dockWidgetName );
@@ -9,9 +9,6 @@ import rips
resinsight = rips.Instance.find() resinsight = rips.Instance.find()
cases = resinsight.project.cases() cases = resinsight.project.cases()
# Set main window size
# resinsight.set_main_window_size(width=1280, height=900)
n = 5 # every n-th time_step for snapshot n = 5 # every n-th time_step for snapshot
property_list = ["SOIL", "PRESSURE"] # list of parameter for snapshot property_list = ["SOIL", "PRESSURE"] # list of parameter for snapshot
@@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# This example will show setting time step, window size and export snapshots and properties # This example will show setting time step and export snapshots and properties
############################################################################### ###############################################################################
import os import os
import tempfile import tempfile
@@ -8,11 +8,6 @@ import rips
# Load instance # Load instance
resinsight = rips.Instance.find() resinsight = rips.Instance.find()
# Set window sizes
resinsight.set_main_window_size(width=800, height=500)
resinsight.set_plot_window_size(width=1000, height=1000)
# Retrieve first case # Retrieve first case
case = resinsight.project.cases()[0] case = resinsight.project.cases()[0]
@@ -30,7 +25,6 @@ view1.apply_cell_result(
result_type=rips.PropertyType.DYNAMIC_NATIVE, result_variable="SOIL" result_type=rips.PropertyType.DYNAMIC_NATIVE, result_variable="SOIL"
) )
# Create a temporary directory which will disappear at the end of this script # Create a temporary directory which will disappear at the end of this script
# If you want to keep the files, provide a good path name instead of tmpdirname # If you want to keep the files, provide a good path name instead of tmpdirname
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname: with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
@@ -41,7 +35,7 @@ with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
resinsight.set_export_folder(export_type="PROPERTIES", path=tmpdirname) resinsight.set_export_folder(export_type="PROPERTIES", path=tmpdirname)
# Export all snapshots # Export all snapshots
resinsight.project.export_snapshots() resinsight.project.export_snapshots(width=1024, height=768)
assert len(os.listdir(tmpdirname)) > 0 assert len(os.listdir(tmpdirname)) > 0
+3 -1
View File
@@ -283,7 +283,7 @@ def export_multi_case_snapshots(self, grid_list_file):
@add_method(Project) @add_method(Project)
def export_snapshots(self, snapshot_type="ALL", prefix="", plot_format="PNG"): def export_snapshots(self, snapshot_type="ALL", prefix="", plot_format="PNG", width=-1, height=-1):
"""Export all snapshots of a given type """Export all snapshots of a given type
Arguments: Arguments:
@@ -298,6 +298,8 @@ def export_snapshots(self, snapshot_type="ALL", prefix="", plot_format="PNG"):
caseId=-1, caseId=-1,
viewId=-1, viewId=-1,
plotOutputFormat=plot_format, plotOutputFormat=plot_format,
width=width,
height=height
) )
) )