mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 07:30:20 -05:00
A new "Show Cumulative Curve" checkbox on the grid statistics data source adds a cumulative curve on the right axis, in addition to the regular histogram curve. The cumulative curve shares the data source of its non-cumulative counterpart and follows all changes to it. The cumulative sum works with all frequency types and both graph types. Remove the legacy Grid Statistics dialog (RicGridStatisticsDialog) and its context menu command, which provided the previous cumulative display.
172 lines
6.2 KiB
C++
172 lines
6.2 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2016 Statoil ASA
|
|
//
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
// for more details.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RicSnapshotAllViewsToFileFeature.h"
|
|
|
|
#include "RiaGuiApplication.h"
|
|
#include "RiaLogging.h"
|
|
#include "RiaPlotWindowRedrawScheduler.h"
|
|
#include "RiaQStringFormatter.h"
|
|
#include "RiaViewRedrawScheduler.h"
|
|
|
|
#include "Rim3dView.h"
|
|
#include "RimCase.h"
|
|
#include "RimMainPlotCollection.h"
|
|
#include "RimProject.h"
|
|
#include "RimViewWindow.h"
|
|
|
|
#include "RicSnapshotFilenameGenerator.h"
|
|
#include "RicSnapshotViewToFileFeature.h"
|
|
|
|
#include "Riu3DMainWindowTools.h"
|
|
#include "RiuViewer.h"
|
|
|
|
#include "RigFemResultPosEnum.h"
|
|
|
|
#include "cafUtils.h"
|
|
|
|
#include <QAction>
|
|
#include <QClipboard>
|
|
#include <QDebug>
|
|
#include <QDir>
|
|
#include <QFileInfo>
|
|
#include <QImage>
|
|
|
|
CAF_CMD_SOURCE_INIT( RicSnapshotAllViewsToFileFeature, "RicSnapshotAllViewsToFileFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicSnapshotAllViewsToFileFeature::saveAllViews()
|
|
{
|
|
RiaApplication* app = RiaApplication::instance();
|
|
RimProject* proj = app->project();
|
|
if ( !proj ) return;
|
|
|
|
// Save images in snapshot catalog relative to project directory
|
|
QString snapshotFolderName = app->createAbsolutePathFromProjectRelativePath( "snapshots" );
|
|
|
|
exportSnapshotOfViewsIntoFolder( snapshotFolderName );
|
|
|
|
QString text = QString( "Exported snapshots to folder : \n%1" ).arg( snapshotFolderName );
|
|
RiaLogging::info( text.toStdString() );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// Export snapshots of a given view (or viewId == -1 for all views) for the given case (or caseId == -1 for all cases)
|
|
/// <= 0 for width and height means to use the existing view size
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( const QString& snapshotFolderName,
|
|
int width,
|
|
int height,
|
|
const QString& prefix,
|
|
int caseId,
|
|
int viewId )
|
|
{
|
|
RimProject* project = RimProject::current();
|
|
if ( project == nullptr ) return;
|
|
|
|
QDir snapshotPath( snapshotFolderName );
|
|
if ( !snapshotPath.exists() )
|
|
{
|
|
if ( !snapshotPath.mkpath( "." ) ) return;
|
|
}
|
|
|
|
std::vector<Rim3dView*> viewsForSnapshot;
|
|
if ( caseId == -1 && viewId == -1 )
|
|
{
|
|
viewsForSnapshot = project->allViews();
|
|
}
|
|
else
|
|
{
|
|
for ( auto gridCase : project->allGridCases() )
|
|
{
|
|
if ( !gridCase ) continue;
|
|
|
|
bool matchingCaseId = caseId == -1 || caseId == gridCase->caseId();
|
|
if ( !matchingCaseId ) continue;
|
|
|
|
for ( auto view : gridCase->views() )
|
|
{
|
|
if ( view && view->viewer() && ( viewId == -1 || viewId == view->id() ) )
|
|
{
|
|
viewsForSnapshot.push_back( view );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
const QString absSnapshotPath = snapshotPath.absolutePath();
|
|
RiaLogging::info( std::format( "Exporting snapshot of all views to {}", snapshotFolderName ) );
|
|
|
|
for ( auto riv : viewsForSnapshot )
|
|
{
|
|
RiuViewer* viewer = riv->viewer();
|
|
if ( !viewer ) continue;
|
|
if ( !viewer->ownerViewWindow() ) continue;
|
|
|
|
RiaApplication::instance()->setActiveReservoirView( riv );
|
|
|
|
Riu3DMainWindowTools::setActiveViewer( viewer->ownerViewWindow()->dockWindowName() );
|
|
|
|
RiaViewRedrawScheduler::instance()->clearViewsScheduledForUpdate();
|
|
RiaPlotWindowRedrawScheduler::instance()->clearAllScheduledUpdates();
|
|
|
|
riv->createDisplayModelAndRedraw();
|
|
viewer->repaint();
|
|
|
|
QString fileName = RicSnapshotFilenameGenerator::generateSnapshotFileName( riv );
|
|
if ( !prefix.isEmpty() )
|
|
{
|
|
fileName = prefix + fileName;
|
|
}
|
|
|
|
QString absoluteFileName = caf::Utils::constructFullFileName( absSnapshotPath, fileName, ".png" );
|
|
|
|
RicSnapshotViewToFileFeature::saveSnapshotAs( absoluteFileName, riv, width, height );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicSnapshotAllViewsToFileFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
QString currentActiveViewerName;
|
|
if ( RiaGuiApplication::activeViewWindow() )
|
|
{
|
|
currentActiveViewerName = RiaGuiApplication::activeViewWindow()->dockWindowName();
|
|
}
|
|
|
|
RicSnapshotAllViewsToFileFeature::saveAllViews();
|
|
|
|
if ( !currentActiveViewerName.isEmpty() )
|
|
{
|
|
Riu3DMainWindowTools::setActiveViewer( currentActiveViewerName );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicSnapshotAllViewsToFileFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setText( "Snapshot All Views To File" );
|
|
actionToSetup->setIcon( QIcon( ":/SnapShotSaveViews.svg" ) );
|
|
}
|