mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 06:55:56 -06:00
Merge branch 'dev' into pre-proto
This commit is contained in:
commit
c481a275ee
@ -90,7 +90,8 @@
|
||||
#include "RiuFlowCharacteristicsPlot.h"
|
||||
|
||||
#include "RicImportSummaryCaseFeature.h"
|
||||
#include "ExportCommands/RicSnapshotViewToClipboardFeature.h"
|
||||
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
|
||||
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
|
||||
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
|
||||
|
||||
#include "RicfCommandFileExecutor.h"
|
||||
@ -2183,6 +2184,7 @@ void RiaApplication::waitForProcess() const
|
||||
#else
|
||||
usleep(100000);
|
||||
#endif
|
||||
processEvents();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ CAF_PDM_SOURCE_INIT(RicfComputeCaseGroupStatistics, "computeCaseGroupStatistics"
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfComputeCaseGroupStatistics::RicfComputeCaseGroupStatistics()
|
||||
{
|
||||
RICF_InitField(&m_caseIds, "cases", std::vector<int>(), "Case IDs", "", "", "");
|
||||
RICF_InitField(&m_caseIds, "caseIds", std::vector<int>(), "Case IDs", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -41,8 +41,8 @@ CAF_PDM_SOURCE_INIT(RicfExportMsw, "exportMsw");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfExportMsw::RicfExportMsw()
|
||||
{
|
||||
RICF_InitField(&m_caseId, "case", -1, "Case", "", "", "");
|
||||
RICF_InitField(&m_wellPathName, "wellPath", QString(), "Case", "", "", "");
|
||||
RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", "");
|
||||
RICF_InitField(&m_wellPathName, "wellPath", QString(), "Well Path Name", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -41,7 +41,7 @@ CAF_PDM_SOURCE_INIT(RicfExportProperty, "exportProperty");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfExportProperty::RicfExportProperty()
|
||||
{
|
||||
RICF_InitField(&m_caseId, "case", -1, "Case", "", "", "");
|
||||
RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", "");
|
||||
RICF_InitField(&m_timeStepIndex, "timeStep", -1, "Time Step Index", "", "", "");
|
||||
RICF_InitField(&m_propertyName, "property", QString(), "Property Name", "", "", "");
|
||||
RICF_InitField(&m_eclipseKeyword, "eclipseKeyword", QString(), "Eclipse Keyword", "", "", "");
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "RicfCommandFileExecutor.h"
|
||||
|
||||
#include "ExportCommands/RicSnapshotViewToClipboardFeature.h"
|
||||
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
@ -46,7 +46,7 @@ namespace caf {
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfExportSnapshots::RicfExportSnapshots()
|
||||
{
|
||||
RICF_InitField(&m_type, "type", RicfExportSnapshots::SnapshotsTypeEnum(), "Type", "", "", "");
|
||||
RICF_InitField(&m_type, "type", RicfExportSnapshots::SnapshotsTypeEnum(), "Type", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -39,7 +39,7 @@ CAF_PDM_SOURCE_INIT(RicfExportWellPathCompletions, "exportWellPathCompletions");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfExportWellPathCompletions::RicfExportWellPathCompletions()
|
||||
{
|
||||
RICF_InitField(&m_caseId, "case", -1, "Case ID", "", "", "");
|
||||
RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", "");
|
||||
RICF_InitField(&m_timeStep, "timeStep", -1, "Time Step Index", "", "", "");
|
||||
RICF_InitField(&m_wellPathNames, "wellPathNames", std::vector<QString>(), "Well Path Names", "", "", "");
|
||||
RICF_InitField(&m_wellSelection, "wellSelection", RicExportCompletionDataSettingsUi::WellSelectionType(), "Well Selection", "", "", "");
|
||||
|
@ -31,7 +31,7 @@ CAF_PDM_SOURCE_INIT(RicfReplaceCase, "replaceCase");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfReplaceCase::RicfReplaceCase()
|
||||
{
|
||||
RICF_InitField(&m_caseId, "case", -1, "Case ID", "", "", "");
|
||||
RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", "");
|
||||
RICF_InitField(&m_newGridFile, "newGridFile", QString(), "New Grid File", "", "", "");
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ CAF_PDM_SOURCE_INIT(RicfReplaceSourceCases, "replaceSourceCases");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfReplaceSourceCases::RicfReplaceSourceCases()
|
||||
{
|
||||
RICF_InitField(&m_caseGroupId, "group", -1, "Group ID", "", "", "");
|
||||
RICF_InitField(&m_caseGroupId, "caseGroupId", -1, "Case Group ID", "", "", "");
|
||||
RICF_InitField(&m_gridListFile, "gridListFile", QString(), "Grid List File", "", "", "");
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,8 @@ CAF_PDM_SOURCE_INIT(RicfRunOctaveScript, "runOctaveScript");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfRunOctaveScript::RicfRunOctaveScript()
|
||||
{
|
||||
RICF_InitField(&m_path, "path", QString(), "Path", "", "", "");
|
||||
RICF_InitField(&m_caseIds, "cases", std::vector<int>(), "Case IDs", "", "", "");
|
||||
RICF_InitField(&m_path, "path", QString(), "Path", "", "", "");
|
||||
RICF_InitField(&m_caseIds, "caseIds", std::vector<int>(), "Case IDs", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -34,7 +34,7 @@ CAF_PDM_SOURCE_INIT(RicfSetTimeStep, "setTimeStep");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfSetTimeStep::RicfSetTimeStep()
|
||||
{
|
||||
RICF_InitField(&m_caseId, "case", -1, "Case ID", "", "", "");
|
||||
RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", "");
|
||||
RICF_InitField(&m_timeStepIndex, "timeStep", -1, "Time Step Index", "", "", "");
|
||||
}
|
||||
|
||||
|
@ -5,31 +5,35 @@ if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
|
||||
endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicCellRangeUi.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportCarfin.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportCarfinUi.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportFaultsFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicCellRangeUi.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToFileFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicCellRangeUi.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportCarfin.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportCarfinUi.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportFaultsFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicCellRangeUi.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToFileFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicSnapshotViewToClipboardFeature.h"
|
||||
#include "RicSnapshotViewToFileFeature.h"
|
||||
|
||||
#include "RigFemResultPosEnum.h"
|
||||
|
||||
|
@ -0,0 +1,152 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicSnapshotAllPlotsToFileFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include "RicSnapshotViewToFileFeature.h"
|
||||
|
||||
#include "RiuMainPlotWindow.h"
|
||||
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QClipboard>
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QMdiSubWindow>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicSnapshotAllPlotsToFileFeature, "RicSnapshotAllPlotsToFileFeature");
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotAllPlotsToFileFeature::saveAllPlots()
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
|
||||
RiuMainPlotWindow* mainPlotWindow = app->mainPlotWindow();
|
||||
if (!mainPlotWindow) return;
|
||||
|
||||
RimProject* proj = app->project();
|
||||
if (!proj) return;
|
||||
|
||||
// Save images in snapshot catalog relative to project directory
|
||||
QString snapshotFolderName = app->createAbsolutePathFromProjectRelativePath("snapshots");
|
||||
|
||||
exportSnapshotOfAllPlotsIntoFolder(snapshotFolderName);
|
||||
|
||||
QString text = QString("Exported snapshots to folder : \n%1").arg(snapshotFolderName);
|
||||
QMessageBox::information(nullptr, "Export Snapshots To Folder", text);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(QString snapshotFolderName)
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
|
||||
RimProject* proj = app->project();
|
||||
if (!proj) return;
|
||||
|
||||
QDir snapshotPath(snapshotFolderName);
|
||||
if (!snapshotPath.exists())
|
||||
{
|
||||
if (!snapshotPath.mkpath(".")) return;
|
||||
}
|
||||
|
||||
const QString absSnapshotPath = snapshotPath.absolutePath();
|
||||
|
||||
std::vector<RimViewWindow*> viewWindows;
|
||||
proj->mainPlotCollection()->descendantsIncludingThisOfType(viewWindows);
|
||||
|
||||
for (auto viewWindow : viewWindows)
|
||||
{
|
||||
if (viewWindow->isMdiWindow() && viewWindow->viewWidget())
|
||||
{
|
||||
QString fileName;
|
||||
if ( viewWindow->userDescriptionField())
|
||||
{
|
||||
fileName = viewWindow->userDescriptionField()->uiCapability()->uiValue().toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = viewWindow->uiCapability()->uiName();
|
||||
}
|
||||
|
||||
fileName = caf::Utils::makeValidFileBasename(fileName);
|
||||
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
|
||||
absoluteFileName.replace(" ", "_");
|
||||
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, viewWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicSnapshotAllPlotsToFileFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotAllPlotsToFileFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
QWidget* currentActiveWidget = nullptr;
|
||||
if (RiaApplication::activeViewWindow())
|
||||
{
|
||||
currentActiveWidget = RiaApplication::activeViewWindow()->viewWidget();
|
||||
}
|
||||
|
||||
RicSnapshotAllPlotsToFileFeature::saveAllPlots();
|
||||
|
||||
if (currentActiveWidget)
|
||||
{
|
||||
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
|
||||
if (mainPlotWindow)
|
||||
{
|
||||
mainPlotWindow->setActiveViewer(currentActiveWidget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotAllPlotsToFileFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Snapshot All Plots To File");
|
||||
actionToSetup->setIcon(QIcon(":/SnapShotSaveViews.png"));
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimViewWindow;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSnapshotAllPlotsToFileFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void saveAllPlots();
|
||||
|
||||
static void exportSnapshotOfAllPlotsIntoFolder(QString snapshotFolderName);
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered(bool isChecked) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
};
|
||||
|
||||
|
@ -78,206 +78,3 @@ void RicSnapshotViewToClipboardFeature::setupActionLook(QAction* actionToSetup)
|
||||
actionToSetup->setText("Snapshot To Clipboard");
|
||||
actionToSetup->setIcon(QIcon(":/SnapShot.png"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicSnapshotViewToFileFeature, "RicSnapshotViewToFileFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotViewToFileFeature::saveSnapshotAs(const QString& fileName, RimViewWindow* viewWindow)
|
||||
{
|
||||
if (viewWindow)
|
||||
{
|
||||
QImage image = viewWindow->snapshotWindowContent();
|
||||
if (!image.isNull())
|
||||
{
|
||||
if (image.save(fileName))
|
||||
{
|
||||
qDebug() << "Exported snapshot image to " << fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Error when trying to export snapshot image to " << fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicSnapshotViewToFileFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotViewToFileFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
RimProject* proj = app->project();
|
||||
|
||||
// Get active view window before displaying the file selection dialog
|
||||
// If this is done after the file save dialog is displayed (and closed)
|
||||
// app->activeViewWindow() returns NULL on Linux
|
||||
RimViewWindow* viewWindow = app->activeViewWindow();
|
||||
if (!viewWindow)
|
||||
{
|
||||
RiaLogging::error("No view window is available, nothing to do");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QString startPath;
|
||||
if (!proj->fileName().isEmpty())
|
||||
{
|
||||
QFileInfo fi(proj->fileName());
|
||||
startPath = fi.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
startPath = app->lastUsedDialogDirectory("IMAGE_SNAPSHOT");
|
||||
}
|
||||
|
||||
startPath += "/image.png";
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(NULL, tr("Export to File"), startPath);
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Remember the directory to next time
|
||||
app->setLastUsedDialogDirectory("IMAGE_SNAPSHOT", QFileInfo(fileName).absolutePath());
|
||||
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(fileName, viewWindow);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotViewToFileFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Snapshot To File");
|
||||
actionToSetup->setIcon(QIcon(":/SnapShotSave.png"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicSnapshotAllPlotsToFileFeature, "RicSnapshotAllPlotsToFileFeature");
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotAllPlotsToFileFeature::saveAllPlots()
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
|
||||
RiuMainPlotWindow* mainPlotWindow = app->mainPlotWindow();
|
||||
if (!mainPlotWindow) return;
|
||||
|
||||
RimProject* proj = app->project();
|
||||
if (!proj) return;
|
||||
|
||||
// Save images in snapshot catalog relative to project directory
|
||||
QString snapshotFolderName = app->createAbsolutePathFromProjectRelativePath("snapshots");
|
||||
|
||||
exportSnapshotOfAllPlotsIntoFolder(snapshotFolderName);
|
||||
|
||||
QString text = QString("Exported snapshots to folder : \n%1").arg(snapshotFolderName);
|
||||
QMessageBox::information(nullptr, "Export Snapshots To Folder", text);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(QString snapshotFolderName)
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
|
||||
RimProject* proj = app->project();
|
||||
if (!proj) return;
|
||||
|
||||
QDir snapshotPath(snapshotFolderName);
|
||||
if (!snapshotPath.exists())
|
||||
{
|
||||
if (!snapshotPath.mkpath(".")) return;
|
||||
}
|
||||
|
||||
const QString absSnapshotPath = snapshotPath.absolutePath();
|
||||
|
||||
std::vector<RimViewWindow*> viewWindows;
|
||||
proj->mainPlotCollection()->descendantsIncludingThisOfType(viewWindows);
|
||||
|
||||
for (auto viewWindow : viewWindows)
|
||||
{
|
||||
if (viewWindow->isMdiWindow() && viewWindow->viewWidget())
|
||||
{
|
||||
QString fileName;
|
||||
if ( viewWindow->userDescriptionField())
|
||||
{
|
||||
fileName = viewWindow->userDescriptionField()->uiCapability()->uiValue().toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = viewWindow->uiCapability()->uiName();
|
||||
}
|
||||
|
||||
fileName = caf::Utils::makeValidFileBasename(fileName);
|
||||
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
|
||||
absoluteFileName.replace(" ", "_");
|
||||
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, viewWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicSnapshotAllPlotsToFileFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotAllPlotsToFileFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
QWidget* currentActiveWidget = nullptr;
|
||||
if (RiaApplication::activeViewWindow())
|
||||
{
|
||||
currentActiveWidget = RiaApplication::activeViewWindow()->viewWidget();
|
||||
}
|
||||
|
||||
RicSnapshotAllPlotsToFileFeature::saveAllPlots();
|
||||
|
||||
if (currentActiveWidget)
|
||||
{
|
||||
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
|
||||
if (mainPlotWindow)
|
||||
{
|
||||
mainPlotWindow->setActiveViewer(currentActiveWidget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotAllPlotsToFileFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Snapshot All Plots To File");
|
||||
actionToSetup->setIcon(QIcon(":/SnapShotSaveViews.png"));
|
||||
}
|
||||
|
||||
|
@ -37,42 +37,3 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSnapshotViewToFileFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void saveSnapshotAs(const QString& fileName, RimViewWindow* viewWindow);
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered(bool isChecked) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSnapshotAllPlotsToFileFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void saveAllPlots();
|
||||
|
||||
static void exportSnapshotOfAllPlotsIntoFolder(QString snapshotFolderName);
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered(bool isChecked) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -0,0 +1,123 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicSnapshotViewToFileFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimViewWindow.h"
|
||||
#include "RiuMainPlotWindow.h"
|
||||
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QClipboard>
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QMdiSubWindow>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicSnapshotViewToFileFeature, "RicSnapshotViewToFileFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotViewToFileFeature::saveSnapshotAs(const QString& fileName, RimViewWindow* viewWindow)
|
||||
{
|
||||
if (viewWindow)
|
||||
{
|
||||
QImage image = viewWindow->snapshotWindowContent();
|
||||
if (!image.isNull())
|
||||
{
|
||||
if (image.save(fileName))
|
||||
{
|
||||
qDebug() << "Exported snapshot image to " << fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Error when trying to export snapshot image to " << fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicSnapshotViewToFileFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotViewToFileFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
RimProject* proj = app->project();
|
||||
|
||||
// Get active view window before displaying the file selection dialog
|
||||
// If this is done after the file save dialog is displayed (and closed)
|
||||
// app->activeViewWindow() returns NULL on Linux
|
||||
RimViewWindow* viewWindow = app->activeViewWindow();
|
||||
if (!viewWindow)
|
||||
{
|
||||
RiaLogging::error("No view window is available, nothing to do");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QString startPath;
|
||||
if (!proj->fileName().isEmpty())
|
||||
{
|
||||
QFileInfo fi(proj->fileName());
|
||||
startPath = fi.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
startPath = app->lastUsedDialogDirectory("IMAGE_SNAPSHOT");
|
||||
}
|
||||
|
||||
startPath += "/image.png";
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(NULL, tr("Export to File"), startPath);
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Remember the directory to next time
|
||||
app->setLastUsedDialogDirectory("IMAGE_SNAPSHOT", QFileInfo(fileName).absolutePath());
|
||||
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(fileName, viewWindow);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSnapshotViewToFileFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Snapshot To File");
|
||||
actionToSetup->setIcon(QIcon(":/SnapShotSave.png"));
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimViewWindow;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSnapshotViewToFileFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void saveSnapshotAs(const QString& fileName, RimViewWindow* viewWindow);
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered(bool isChecked) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
};
|
@ -63,7 +63,7 @@ public:
|
||||
void centerlineTextureCoords(cvf::Vec2fArray* textureCoords, const std::vector<double>& segmentResults, const cvf::ScalarMapper* mapper) const;
|
||||
|
||||
void setFirstVisibleSegmentIndex(size_t segmentIndex);
|
||||
size_t pipeSegmentIndexFromTriangleIndex(size_t triangleIndex) const;
|
||||
size_t segmentIndexFromTriangleIndex(size_t triangleIndex) const;
|
||||
|
||||
void cylinderWithCenterLineParts(cvf::Collection<cvf::Part>* destinationParts, const std::vector<cvf::Vec3d>& centerCoords, const cvf::Color3f& color, double radius);
|
||||
private:
|
||||
|
@ -711,9 +711,16 @@ std::vector<double> RimFishbonesMultipleSubs::locationsFromStartSpacingAndCount(
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimFishbonesMultipleSubs::randomValueFromRange(int min, int max)
|
||||
{
|
||||
// See http://www.cplusplus.com/reference/cstdlib/rand/
|
||||
|
||||
int range = abs(max - min);
|
||||
int random_integer = min + int(range*rand() / (RAND_MAX + 1.0));
|
||||
|
||||
|
||||
return random_integer;
|
||||
int randomNumberInRange = rand() % range;
|
||||
|
||||
int randomValue = min + randomNumberInRange;
|
||||
|
||||
return randomValue;
|
||||
}
|
||||
|
||||
|
@ -32,14 +32,14 @@ double RigTransmissibilityEquations::peacemanRadius(double permeabilityNormalDir
|
||||
double cellSizeNormalDirection1,
|
||||
double cellSizeNormalDirection2)
|
||||
{
|
||||
double nominator = cvf::Math::sqrt(
|
||||
pow(cellSizeNormalDirection2, 2) + pow(permeabilityNormalDirection1 / permeabilityNormalDirection2, 1 / 2)
|
||||
+ pow(cellSizeNormalDirection1, 2) + pow(permeabilityNormalDirection2 / permeabilityNormalDirection1, 1 / 2));
|
||||
double numerator = cvf::Math::sqrt(
|
||||
pow(cellSizeNormalDirection2, 2) * pow(permeabilityNormalDirection1 / permeabilityNormalDirection2, 1 / 2)
|
||||
+ pow(cellSizeNormalDirection1, 2) * pow(permeabilityNormalDirection2 / permeabilityNormalDirection1, 1 / 2));
|
||||
|
||||
double denominator = pow((permeabilityNormalDirection1 / permeabilityNormalDirection2), 1 / 4)
|
||||
+ pow((permeabilityNormalDirection2 / permeabilityNormalDirection1), 1 / 4);
|
||||
|
||||
double r0 = 0.28 * nominator / denominator;
|
||||
double r0 = 0.28 * numerator / denominator;
|
||||
|
||||
return r0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user