2012-05-18 02:45:23 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-03-22 10:12:00 -05:00
|
|
|
#include "RiaStdInclude.h"
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
Known problems:
- Well paths are not shown in some types of reservoir views, for instance reservoir views showing well pipes. Will look into this later.
p4#: 21658
2013-05-16 07:10:22 -05:00
|
|
|
|
2013-05-06 03:55:00 -05:00
|
|
|
#include "RiaApplication.h"
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
#include "cafEffectCache.h"
|
|
|
|
#include "cafUtils.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
#include "cafAppEnum.h"
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-03-22 10:12:00 -05:00
|
|
|
#include "RiaVersionInfo.h"
|
|
|
|
#include "RiaBaseDefs.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
//
|
2013-03-22 11:30:50 -05:00
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
#include "RiuViewer.h"
|
|
|
|
#include "RiuProcessMonitor.h"
|
2013-03-22 10:24:42 -05:00
|
|
|
#include "RiaPreferences.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
//
|
2013-03-22 10:40:41 -05:00
|
|
|
#include "RimResultCase.h"
|
|
|
|
#include "RimInputCase.h"
|
2012-06-26 09:10:41 -05:00
|
|
|
#include "RimReservoirView.h"
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
Known problems:
- Well paths are not shown in some types of reservoir views, for instance reservoir views showing well pipes. Will look into this later.
p4#: 21658
2013-05-16 07:10:22 -05:00
|
|
|
#include "RimWellPath.h"
|
|
|
|
#include "RimWellPathCollection.h"
|
2013-06-06 08:07:31 -05:00
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimAnalysisModels.h"
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
#include "cafCeetronNavigation.h"
|
|
|
|
#include "cafCadNavigation.h"
|
|
|
|
#include "RiaSocketServer.h"
|
|
|
|
#include "cafUiProcess.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
//
|
2012-05-18 02:45:23 -05:00
|
|
|
#include "RimUiTreeModelPdm.h"
|
2013-02-08 10:04:35 -06:00
|
|
|
#include "RiaImageCompareReporter.h"
|
|
|
|
#include "RiaImageFileCompare.h"
|
2013-03-05 06:10:26 -06:00
|
|
|
#include "cafProgressInfo.h"
|
2013-04-07 10:27:45 -05:00
|
|
|
#include "RigGridManager.h"
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-05-06 03:55:00 -05:00
|
|
|
#include "RimProject.h"
|
|
|
|
|
|
|
|
#include "RimResultSlot.h"
|
|
|
|
|
|
|
|
#include "RimIdenticalGridCaseGroup.h"
|
|
|
|
#include "RimInputPropertyCollection.h"
|
|
|
|
|
|
|
|
#include "RimDefines.h"
|
|
|
|
#include "RimScriptCollection.h"
|
|
|
|
#include "RimCaseCollection.h"
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
|
|
|
#include "cafPdmFieldCvfColor.h"
|
|
|
|
#include "cafPdmFieldCvfMat4d.h"
|
|
|
|
#include "RimReservoirCellResultsCacher.h"
|
|
|
|
#include "RimCellEdgeResultSlot.h"
|
|
|
|
#include "RimCellRangeFilterCollection.h"
|
|
|
|
#include "RimCellPropertyFilterCollection.h"
|
|
|
|
#include "Rim3dOverlayInfoConfig.h"
|
|
|
|
#include "RimWellCollection.h"
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
template<>
|
2013-03-22 09:50:44 -05:00
|
|
|
void AppEnum< RiaApplication::RINavigationPolicy >::setUp()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-03-22 09:50:44 -05:00
|
|
|
addItem(RiaApplication::NAVIGATION_POLICY_CEETRON, "NAVIGATION_POLICY_CEETRON", "Ceetron");
|
|
|
|
addItem(RiaApplication::NAVIGATION_POLICY_CAD, "NAVIGATION_POLICY_CAD", "CAD");
|
|
|
|
setDefault(RiaApplication::NAVIGATION_POLICY_CAD);
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-11 04:29:55 -06:00
|
|
|
namespace RegTestNames
|
2013-02-08 10:04:35 -06:00
|
|
|
{
|
|
|
|
const QString generatedFolderName = "RegTestGeneratedImages";
|
|
|
|
const QString diffFolderName = "RegTestDiffImages";
|
|
|
|
const QString baseFolderName = "RegTestBaseImages";
|
|
|
|
const QString testProjectName = "RegressionTest.rip";
|
|
|
|
const QString testFolderFilter = "TestCase*";
|
|
|
|
const QString imageCompareExeName = "compare";
|
|
|
|
const QString reportFileName = "ResInsightRegressionTestReport.html";
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
//==================================================================================================
|
|
|
|
///
|
2013-03-22 10:24:42 -05:00
|
|
|
/// \class RiaApplication
|
2012-05-18 02:45:23 -05:00
|
|
|
///
|
|
|
|
/// Application class
|
|
|
|
///
|
|
|
|
//==================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
RiaApplication::RiaApplication(int& argc, char** argv)
|
2012-05-18 02:45:23 -05:00
|
|
|
: QApplication(argc, argv)
|
|
|
|
{
|
|
|
|
// USed to get registry settings in the right place
|
|
|
|
QCoreApplication::setOrganizationName(RI_COMPANY_NAME);
|
|
|
|
QCoreApplication::setApplicationName(RI_APPLICATION_NAME);
|
|
|
|
|
|
|
|
// For idle processing
|
|
|
|
// m_idleTimerStarted = false;
|
|
|
|
installEventFilter(this);
|
|
|
|
|
|
|
|
//cvf::Trace::enable(false);
|
|
|
|
|
2013-03-22 09:50:44 -05:00
|
|
|
m_preferences = new RiaPreferences;
|
2012-05-18 02:45:23 -05:00
|
|
|
readPreferences();
|
|
|
|
applyPreferences();
|
|
|
|
|
|
|
|
if (useShaders())
|
|
|
|
{
|
|
|
|
caf::EffectGenerator::setRenderingMode(caf::EffectGenerator::SHADER_BASED);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
caf::EffectGenerator::setRenderingMode(caf::EffectGenerator::FIXED_FUNCTION);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start with a project
|
|
|
|
m_project = new RimProject;
|
|
|
|
|
|
|
|
setWindowIcon(QIcon(":/AppLogo48x48.png"));
|
|
|
|
|
|
|
|
m_socketServer = new RiaSocketServer( this);
|
|
|
|
m_workerProcess = NULL;
|
2012-10-23 02:59:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
m_startupDefaultDirectory = QDir::homePath();
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
//m_startupDefaultDirectory += "/My Documents/";
|
|
|
|
#endif
|
2013-03-07 05:25:27 -06:00
|
|
|
setDefaultFileDialogDirectory("MULTICASEIMPORT", "/");
|
2013-04-19 01:02:36 -05:00
|
|
|
|
|
|
|
// The creation of a font is time consuming, so make sure you really need your own font
|
|
|
|
// instead of using the application font
|
|
|
|
m_standardFont = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD);
|
2013-09-08 15:59:46 -05:00
|
|
|
m_resViewUpdateTimer = NULL;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
RiaApplication::~RiaApplication()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2012-10-23 06:36:48 -05:00
|
|
|
delete m_preferences;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
RiaApplication* RiaApplication::instance()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-03-22 09:50:44 -05:00
|
|
|
return static_cast<RiaApplication*>qApp;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::setWindowCaptionFromAppState()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-03-22 11:17:56 -05:00
|
|
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
2012-05-18 02:45:23 -05:00
|
|
|
if (!mainWnd) return;
|
|
|
|
|
|
|
|
// The stuff being done here should really be handled by Qt automatically as a result of
|
|
|
|
// setting applicationName and windowFilePath
|
|
|
|
// Was unable to make this work in Qt4.4.0!
|
|
|
|
|
|
|
|
QString capt = RI_APPLICATION_NAME;
|
|
|
|
#ifdef _DEBUG
|
|
|
|
capt += " ##DEBUG##";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
{
|
2012-06-26 09:10:41 -05:00
|
|
|
QString projFileName = m_project->fileName();
|
2012-05-18 02:45:23 -05:00
|
|
|
if (projFileName.isEmpty()) projFileName = "Untitled project";
|
|
|
|
|
|
|
|
capt = projFileName + QString("[*]") + QString(" - ") + capt;
|
|
|
|
}
|
|
|
|
|
|
|
|
mainWnd->setWindowTitle(capt);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::processNonGuiEvents()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
processEvents(QEventLoop::ExcludeUserInputEvents);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
const char* RiaApplication::getVersionStringApp(bool includeCrtInfo)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
// Use static buf so we can return ptr
|
|
|
|
static char szBuf[1024];
|
|
|
|
|
|
|
|
cvf::String crtInfo;
|
|
|
|
if (includeCrtInfo)
|
|
|
|
{
|
|
|
|
#ifdef _MT
|
|
|
|
#ifdef _DLL
|
|
|
|
crtInfo = " (DLL CRT)";
|
|
|
|
#else
|
|
|
|
crtInfo = " (static CRT)";
|
|
|
|
#endif
|
|
|
|
#endif //_MT
|
|
|
|
}
|
|
|
|
|
|
|
|
cvf::System::sprintf(szBuf, 1024, "%s%s", STRPRODUCTVER, crtInfo.toAscii().ptr());
|
|
|
|
|
|
|
|
return szBuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::loadProject(const QString& projectFileName)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-03-21 09:31:47 -05:00
|
|
|
// First Close the current project
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
if (!closeProject(true)) return false;
|
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
// Open the project file and read the serialized data.
|
|
|
|
// Will initialize itself.
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
if (!QFile::exists(projectFileName)) return false;
|
|
|
|
|
|
|
|
m_project->fileName = projectFileName;
|
|
|
|
m_project->readFile();
|
2013-04-08 01:36:34 -05:00
|
|
|
|
2013-04-09 08:38:37 -05:00
|
|
|
// Propagate possible new location of project
|
|
|
|
|
|
|
|
m_project->setProjectFileNameAndUpdateDependencies(projectFileName);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
// On error, delete everything, and bail out.
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
if (m_project->projectFileVersionString().isEmpty())
|
|
|
|
{
|
|
|
|
closeProject(false);
|
|
|
|
|
|
|
|
QString tmp = QString("Unknown project file version detected in file \n%1\n\nCould not open project.").arg(projectFileName);
|
|
|
|
QMessageBox::warning(NULL, "Error when opening project file", tmp);
|
|
|
|
|
2013-03-22 11:17:56 -05:00
|
|
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
2012-05-18 02:45:23 -05:00
|
|
|
mainWnd->setPdmRoot(NULL);
|
|
|
|
|
|
|
|
// Delete all object possibly generated by readFile()
|
|
|
|
delete m_project;
|
|
|
|
m_project = new RimProject;
|
2013-03-21 09:31:47 -05:00
|
|
|
|
|
|
|
onProjectOpenedOrClosed();
|
|
|
|
|
|
|
|
return true;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
2013-03-21 09:31:47 -05:00
|
|
|
|
|
|
|
///////
|
|
|
|
// Load the external data, and initialize stuff that needs specific ordering
|
2013-06-06 08:07:31 -05:00
|
|
|
|
|
|
|
// VL check regarding specific order mentioned in comment above...
|
2013-03-21 09:31:47 -05:00
|
|
|
|
|
|
|
m_preferences->lastUsedProjectFileName = projectFileName;
|
|
|
|
writePreferences();
|
|
|
|
|
2013-06-06 08:07:31 -05:00
|
|
|
for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-06-06 08:07:31 -05:00
|
|
|
RimOilField* oilField = m_project->oilFields[oilFieldIdx];
|
|
|
|
RimAnalysisModels* analysisModels = oilField ? oilField->analysisModels() : NULL;
|
|
|
|
if (analysisModels == NULL) continue;
|
2013-03-20 10:35:36 -05:00
|
|
|
|
2013-06-06 08:07:31 -05:00
|
|
|
for (size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); ++cgIdx)
|
2013-03-20 10:35:36 -05:00
|
|
|
{
|
2013-06-06 08:07:31 -05:00
|
|
|
// Load the Main case of each IdenticalGridCaseGroup
|
|
|
|
RimIdenticalGridCaseGroup* igcg = analysisModels->caseGroups[cgIdx];
|
|
|
|
igcg->loadMainCaseAndActiveCellInfo(); // VL is this supposed to be done for each RimOilField?
|
2013-04-29 04:07:57 -05:00
|
|
|
}
|
2013-03-21 09:31:47 -05:00
|
|
|
}
|
2013-03-20 10:35:36 -05:00
|
|
|
|
2013-06-06 08:07:31 -05:00
|
|
|
// Add well paths for each oil field
|
|
|
|
for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++)
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
Known problems:
- Well paths are not shown in some types of reservoir views, for instance reservoir views showing well pipes. Will look into this later.
p4#: 21658
2013-05-16 07:10:22 -05:00
|
|
|
{
|
2013-06-06 08:07:31 -05:00
|
|
|
RimOilField* oilField = m_project->oilFields[oilFieldIdx];
|
|
|
|
if (oilField == NULL) continue;
|
|
|
|
if (oilField->wellPathCollection == NULL)
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
Known problems:
- Well paths are not shown in some types of reservoir views, for instance reservoir views showing well pipes. Will look into this later.
p4#: 21658
2013-05-16 07:10:22 -05:00
|
|
|
{
|
2013-06-12 03:52:46 -05:00
|
|
|
//printf("Create well path collection for oil field %i in loadProject.\n", oilFieldIdx);
|
2013-06-06 08:07:31 -05:00
|
|
|
oilField->wellPathCollection = new RimWellPathCollection();
|
|
|
|
oilField->wellPathCollection->setProject(m_project);
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
Known problems:
- Well paths are not shown in some types of reservoir views, for instance reservoir views showing well pipes. Will look into this later.
p4#: 21658
2013-05-16 07:10:22 -05:00
|
|
|
}
|
2013-06-06 08:07:31 -05:00
|
|
|
|
|
|
|
if (oilField->wellPathCollection) oilField->wellPathCollection->readWellPathFiles();
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
Known problems:
- Well paths are not shown in some types of reservoir views, for instance reservoir views showing well pipes. Will look into this later.
p4#: 21658
2013-05-16 07:10:22 -05:00
|
|
|
}
|
|
|
|
|
2013-06-06 08:07:31 -05:00
|
|
|
// Now load the ReservoirViews for the cases
|
|
|
|
// Add all "native" cases in the project
|
|
|
|
std::vector<RimCase*> casesToLoad;
|
|
|
|
m_project->allCases(casesToLoad);
|
2013-03-20 10:35:36 -05:00
|
|
|
|
2013-06-06 08:07:31 -05:00
|
|
|
caf::ProgressInfo caseProgress(casesToLoad.size() , "Reading Cases");
|
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
for (size_t cIdx = 0; cIdx < casesToLoad.size(); ++cIdx)
|
|
|
|
{
|
2013-03-22 09:43:42 -05:00
|
|
|
RimCase* ri = casesToLoad[cIdx];
|
2013-03-21 09:31:47 -05:00
|
|
|
CVF_ASSERT(ri);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-04-11 05:06:38 -05:00
|
|
|
caseProgress.setProgressDescription(ri->caseUserDescription());
|
2013-03-07 02:43:25 -06:00
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
caf::ProgressInfo viewProgress(ri->reservoirViews().size() , "Creating Views");
|
2013-03-07 02:43:25 -06:00
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
size_t j;
|
|
|
|
for (j = 0; j < ri->reservoirViews().size(); j++)
|
|
|
|
{
|
|
|
|
RimReservoirView* riv = ri->reservoirViews[j];
|
|
|
|
CVF_ASSERT(riv);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
viewProgress.setProgressDescription(riv->name());
|
2013-03-07 02:43:25 -06:00
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
riv->loadDataAndUpdate();
|
2013-06-14 06:53:52 -05:00
|
|
|
this->setActiveReservoirView(riv);
|
2013-03-21 09:31:47 -05:00
|
|
|
viewProgress.incrementProgress();
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
2013-03-21 09:31:47 -05:00
|
|
|
|
|
|
|
caseProgress.incrementProgress();
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
2013-09-12 01:11:56 -05:00
|
|
|
// Loop over command objects and execute them
|
|
|
|
for (size_t i = 0; i < m_project->commandObjects.size(); i++)
|
|
|
|
{
|
|
|
|
m_commandQueue.push_back(m_project->commandObjects[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
executeCommandObjects();
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
onProjectOpenedOrClosed();
|
2013-03-21 09:31:47 -05:00
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
Known problems:
- Well paths are not shown in some types of reservoir views, for instance reservoir views showing well pipes. Will look into this later.
p4#: 21658
2013-05-16 07:10:22 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Add a list of well path file paths (JSON files) to the well path collection
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiaApplication::addWellPathsToModel(QList<QString> wellPathFilePaths)
|
|
|
|
{
|
2013-06-06 08:07:31 -05:00
|
|
|
if (m_project == NULL || m_project->oilFields.size() < 1) return;
|
|
|
|
|
|
|
|
RimOilField* oilField = m_project->activeOilField();
|
|
|
|
if (oilField == NULL) return;
|
|
|
|
|
|
|
|
if (oilField->wellPathCollection == NULL)
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
Known problems:
- Well paths are not shown in some types of reservoir views, for instance reservoir views showing well pipes. Will look into this later.
p4#: 21658
2013-05-16 07:10:22 -05:00
|
|
|
{
|
2013-06-12 03:52:46 -05:00
|
|
|
//printf("Create well path collection.\n");
|
2013-06-06 08:07:31 -05:00
|
|
|
oilField->wellPathCollection = new RimWellPathCollection();
|
|
|
|
oilField->wellPathCollection->setProject(m_project);
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
Known problems:
- Well paths are not shown in some types of reservoir views, for instance reservoir views showing well pipes. Will look into this later.
p4#: 21658
2013-05-16 07:10:22 -05:00
|
|
|
RiuMainWindow::instance()->uiPdmModel()->updateUiSubTree(m_project);
|
|
|
|
}
|
|
|
|
|
2013-06-06 08:07:31 -05:00
|
|
|
if (oilField->wellPathCollection) oilField->wellPathCollection->addWellPaths(wellPathFilePaths);
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
Known problems:
- Well paths are not shown in some types of reservoir views, for instance reservoir views showing well pipes. Will look into this later.
p4#: 21658
2013-05-16 07:10:22 -05:00
|
|
|
|
2013-06-06 08:07:31 -05:00
|
|
|
RiuMainWindow::instance()->uiPdmModel()->updateUiSubTree(oilField->wellPathCollection);
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
Known problems:
- Well paths are not shown in some types of reservoir views, for instance reservoir views showing well pipes. Will look into this later.
p4#: 21658
2013-05-16 07:10:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::loadLastUsedProject()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
return loadProject(m_preferences->lastUsedProjectFileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::saveProject()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2012-06-26 09:10:41 -05:00
|
|
|
CVF_ASSERT(m_project.notNull());
|
|
|
|
|
|
|
|
if (!QFile::exists(m_project->fileName()))
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
return saveProjectPromptForFileName();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-06-26 09:10:41 -05:00
|
|
|
return saveProjectAs(m_project->fileName());
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::saveProjectPromptForFileName()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
//if (m_project.isNull()) return true;
|
|
|
|
|
2013-03-22 09:50:44 -05:00
|
|
|
RiaApplication* app = RiaApplication::instance();
|
2012-10-23 02:59:57 -05:00
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
QString startPath;
|
2012-06-26 09:10:41 -05:00
|
|
|
if (!m_project->fileName().isEmpty())
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2012-06-26 09:10:41 -05:00
|
|
|
QFileInfo fi(m_project->fileName());
|
2012-05-18 02:45:23 -05:00
|
|
|
startPath = fi.absolutePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-23 02:59:57 -05:00
|
|
|
startPath = app->defaultFileDialogDirectory("BINARY_GRID");
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
startPath += "/ResInsightProject.rip";
|
|
|
|
|
|
|
|
QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save File"), startPath, tr("Project Files (*.rip *.xml)"));
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-10-23 02:59:57 -05:00
|
|
|
// Remember the directory to next time
|
|
|
|
app->setDefaultFileDialogDirectory("BINARY_GRID", QFileInfo(fileName).absolutePath());
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
bool bSaveOk = saveProjectAs(fileName);
|
|
|
|
|
|
|
|
setWindowCaptionFromAppState();
|
|
|
|
|
|
|
|
return bSaveOk;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::saveProjectAs(const QString& fileName)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
m_project->fileName = fileName;
|
|
|
|
m_project->writeFile();
|
|
|
|
|
|
|
|
m_preferences->lastUsedProjectFileName = fileName;
|
|
|
|
writePreferences();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::closeProject(bool askToSaveIfDirty)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-03-22 11:17:56 -05:00
|
|
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2012-08-31 12:12:47 -05:00
|
|
|
terminateProcess();
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
if (false)
|
|
|
|
{
|
|
|
|
QMessageBox msgBox(mainWnd);
|
|
|
|
msgBox.setIcon(QMessageBox::Warning);
|
|
|
|
msgBox.setText("The project being closed has been modified.");
|
|
|
|
msgBox.setInformativeText("Do you want to save your changes?");
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
|
|
|
//msgBox.setDefaultButton(QMessageBox::Save);
|
|
|
|
|
|
|
|
int ret = msgBox.exec();
|
|
|
|
if (ret == QMessageBox::Save)
|
|
|
|
{
|
|
|
|
//m_sceneManager->saveAll();
|
|
|
|
}
|
|
|
|
else if (ret == QMessageBox::Cancel)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mainWnd->cleanupGuiBeforeProjectClose();
|
|
|
|
|
2012-08-31 12:12:47 -05:00
|
|
|
caf::EffectGenerator::clearEffectCache();
|
2012-05-18 02:45:23 -05:00
|
|
|
m_project->close();
|
|
|
|
|
2013-09-12 01:11:56 -05:00
|
|
|
m_commandQueue.clear();
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
onProjectOpenedOrClosed();
|
|
|
|
|
2013-06-06 08:07:31 -05:00
|
|
|
return true;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::onProjectOpenedOrClosed()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-03-22 11:17:56 -05:00
|
|
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
2012-05-18 02:45:23 -05:00
|
|
|
if (!mainWnd) return;
|
|
|
|
|
|
|
|
mainWnd->initializeGuiNewProjectLoaded();
|
|
|
|
//mainWnd->redrawAllViews();
|
|
|
|
|
|
|
|
setWindowCaptionFromAppState();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
QString RiaApplication::currentProjectFileName() const
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2012-06-26 09:10:41 -05:00
|
|
|
return m_project->fileName();
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::openEclipseCaseFromFile(const QString& fileName)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
if (!QFile::exists(fileName)) return false;
|
|
|
|
|
|
|
|
QFileInfo gridFileName(fileName);
|
|
|
|
QString caseName = gridFileName.completeBaseName();
|
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
return openEclipseCase(caseName, fileName);
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::openEclipseCase(const QString& caseName, const QString& caseFileName)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-04-08 07:29:43 -05:00
|
|
|
RimResultCase* rimResultReservoir = new RimResultCase();
|
2013-04-11 05:06:38 -05:00
|
|
|
rimResultReservoir->setCaseInfo(caseName, caseFileName);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-06-06 08:07:31 -05:00
|
|
|
RimAnalysisModels* analysisModels = m_project->activeOilField() ? m_project->activeOilField()->analysisModels() : NULL;
|
|
|
|
if (analysisModels == NULL) return false;
|
|
|
|
|
|
|
|
analysisModels->cases.push_back(rimResultReservoir);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
RimReservoirView* riv = rimResultReservoir->createAndAddReservoirView();
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-04-10 04:21:41 -05:00
|
|
|
// Select SOIL as default result variable
|
2013-04-30 06:41:53 -05:00
|
|
|
riv->cellResult()->setResultType(RimDefines::DYNAMIC_NATIVE);
|
|
|
|
riv->cellResult()->setResultVariable("SOIL");
|
2013-04-10 04:21:41 -05:00
|
|
|
riv->animationMode = true;
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
riv->loadDataAndUpdate();
|
|
|
|
|
|
|
|
if (!riv->cellResult()->hasResult())
|
|
|
|
{
|
2013-04-30 06:41:53 -05:00
|
|
|
riv->cellResult()->setResultVariable(RimDefines::undefinedResultName());
|
2012-06-26 09:10:41 -05:00
|
|
|
}
|
|
|
|
|
2013-04-22 04:54:41 -05:00
|
|
|
RimUiTreeModelPdm* uiModel = RiuMainWindow::instance()->uiPdmModel();
|
|
|
|
|
2013-06-07 07:54:02 -05:00
|
|
|
uiModel->updateUiSubTree(analysisModels);
|
2012-06-26 09:10:41 -05:00
|
|
|
|
2013-04-23 01:11:52 -05:00
|
|
|
RiuMainWindow::instance()->setCurrentObjectInTreeView(riv->cellResult());
|
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames)
|
2012-06-26 09:10:41 -05:00
|
|
|
{
|
2013-03-22 09:43:42 -05:00
|
|
|
RimInputCase* rimInputReservoir = new RimInputCase();
|
2013-05-08 03:41:56 -05:00
|
|
|
m_project->assignCaseIdToCase(rimInputReservoir);
|
|
|
|
|
2013-04-11 05:06:38 -05:00
|
|
|
rimInputReservoir->caseUserDescription = caseName;
|
2012-06-26 09:10:41 -05:00
|
|
|
rimInputReservoir->openDataFileSet(caseFileNames);
|
|
|
|
|
2013-06-06 08:07:31 -05:00
|
|
|
RimAnalysisModels* analysisModels = m_project->activeOilField() ? m_project->activeOilField()->analysisModels() : NULL;
|
|
|
|
if (analysisModels == NULL) return false;
|
|
|
|
|
|
|
|
analysisModels->cases.push_back(rimInputReservoir);
|
2012-06-26 09:10:41 -05:00
|
|
|
|
|
|
|
RimReservoirView* riv = rimInputReservoir->createAndAddReservoirView();
|
|
|
|
|
2013-04-30 06:41:53 -05:00
|
|
|
riv->cellResult()->setResultType(RimDefines::INPUT_PROPERTY);
|
2012-06-26 09:10:41 -05:00
|
|
|
riv->animationMode = true;
|
|
|
|
|
|
|
|
riv->loadDataAndUpdate();
|
|
|
|
|
|
|
|
if (!riv->cellResult()->hasResult())
|
|
|
|
{
|
2013-04-30 06:41:53 -05:00
|
|
|
riv->cellResult()->setResultVariable(RimDefines::undefinedResultName());
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
2013-04-22 04:54:41 -05:00
|
|
|
RimUiTreeModelPdm* uiModel = RiuMainWindow::instance()->uiPdmModel();
|
2013-06-07 07:54:02 -05:00
|
|
|
uiModel->updateUiSubTree(analysisModels);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-04-23 01:11:52 -05:00
|
|
|
RiuMainWindow::instance()->setCurrentObjectInTreeView(riv->cellResult());
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::createMockModel()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2012-06-26 09:10:41 -05:00
|
|
|
openEclipseCase("Result Mock Debug Model Simple", "Result Mock Debug Model Simple");
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::createResultsMockModel()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2012-06-26 09:10:41 -05:00
|
|
|
openEclipseCase("Result Mock Debug Model With Results", "Result Mock Debug Model With Results");
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::createLargeResultsMockModel()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2012-06-26 09:10:41 -05:00
|
|
|
openEclipseCase("Result Mock Debug Model Large With Results", "Result Mock Debug Model Large With Results");
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::createInputMockModel()
|
2012-06-26 09:10:41 -05:00
|
|
|
{
|
|
|
|
openInputEclipseCase("Input Mock Debug Model Simple", QStringList("Input Mock Debug Model Simple"));
|
|
|
|
}
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
const RimReservoirView* RiaApplication::activeReservoirView() const
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
return m_activeReservoirView;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
RimReservoirView* RiaApplication::activeReservoirView()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
return m_activeReservoirView;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::setActiveReservoirView(RimReservoirView* rv)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
m_activeReservoirView = rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::setUseShaders(bool enable)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
m_preferences->useShaders = enable;
|
|
|
|
writePreferences();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::useShaders() const
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2012-08-31 12:12:47 -05:00
|
|
|
if (!m_preferences->useShaders) return false;
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
bool isShadersSupported = caf::Viewer::isShadersSupported();
|
|
|
|
if (!isShadersSupported) return false;
|
|
|
|
|
2012-08-31 12:12:47 -05:00
|
|
|
return true;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
RiaApplication::RINavigationPolicy RiaApplication::navigationPolicy() const
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
return m_preferences->navigationPolicy();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::setShowPerformanceInfo(bool enable)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
m_preferences->showHud = enable;
|
|
|
|
writePreferences();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::showPerformanceInfo() const
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
return m_preferences->showHud;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::parseArguments()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
QStringList arguments = QCoreApplication::arguments();
|
|
|
|
|
|
|
|
bool openLatestProject = false;
|
|
|
|
QString projectFilename;
|
|
|
|
QStringList caseNames;
|
2013-02-08 10:04:35 -06:00
|
|
|
QString regressionTestPath;
|
|
|
|
|
|
|
|
enum ArgumentParsingType
|
|
|
|
{
|
|
|
|
PARSE_PROJECT_FILE_NAME,
|
|
|
|
PARSE_CASE_NAMES,
|
|
|
|
PARSE_START_DIR,
|
|
|
|
PARSE_REGRESSION_TEST_PATH,
|
|
|
|
PARSING_NONE
|
|
|
|
};
|
|
|
|
|
|
|
|
ArgumentParsingType argumentParsingType = PARSING_NONE;
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
bool showHelp = false;
|
2013-02-06 06:23:46 -06:00
|
|
|
bool isSaveSnapshotsForAllViews = false;
|
2013-02-08 10:04:35 -06:00
|
|
|
bool isRunRegressionTest = false;
|
|
|
|
bool isUpdateRegressionTest = false;
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i = 1; i < arguments.size(); i++)
|
|
|
|
{
|
|
|
|
QString arg = arguments[i];
|
2012-10-23 02:59:57 -05:00
|
|
|
bool foundKnownOption = false;
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
if (arg.toLower() == "-help" || arg.toLower() == "-?")
|
|
|
|
{
|
|
|
|
showHelp = true;
|
2012-10-23 02:59:57 -05:00
|
|
|
foundKnownOption = true;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (arg.toLower() == "-last")
|
|
|
|
{
|
|
|
|
openLatestProject = true;
|
2012-10-23 02:59:57 -05:00
|
|
|
foundKnownOption = true;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
else if (arg.toLower() == "-project")
|
|
|
|
{
|
2013-02-08 10:04:35 -06:00
|
|
|
argumentParsingType = PARSE_PROJECT_FILE_NAME;
|
2012-10-23 02:59:57 -05:00
|
|
|
|
|
|
|
foundKnownOption = true;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
else if (arg.toLower() == "-case")
|
|
|
|
{
|
2013-02-08 10:04:35 -06:00
|
|
|
argumentParsingType = PARSE_CASE_NAMES;
|
2012-10-23 02:59:57 -05:00
|
|
|
|
|
|
|
foundKnownOption = true;
|
|
|
|
}
|
|
|
|
else if (arg.toLower() == "-startdir")
|
|
|
|
{
|
2013-02-08 10:04:35 -06:00
|
|
|
argumentParsingType = PARSE_START_DIR;
|
2012-10-23 02:59:57 -05:00
|
|
|
|
|
|
|
foundKnownOption = true;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
2013-02-06 06:23:46 -06:00
|
|
|
else if (arg.toLower() == "-savesnapshots")
|
|
|
|
{
|
|
|
|
isSaveSnapshotsForAllViews = true;
|
|
|
|
|
|
|
|
foundKnownOption = true;
|
|
|
|
}
|
2013-02-08 10:04:35 -06:00
|
|
|
else if (arg.toLower() == "-regressiontest")
|
|
|
|
{
|
|
|
|
isRunRegressionTest = true;
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-02-08 10:04:35 -06:00
|
|
|
argumentParsingType = PARSE_REGRESSION_TEST_PATH;
|
|
|
|
|
|
|
|
foundKnownOption = true;
|
|
|
|
}
|
|
|
|
else if (arg.toLower() == "-updateregressiontestbase")
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-02-08 10:04:35 -06:00
|
|
|
isUpdateRegressionTest = true;
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-02-08 10:04:35 -06:00
|
|
|
argumentParsingType = PARSE_REGRESSION_TEST_PATH;
|
2012-10-23 02:59:57 -05:00
|
|
|
|
2013-02-08 10:04:35 -06:00
|
|
|
foundKnownOption = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!foundKnownOption)
|
|
|
|
{
|
|
|
|
switch (argumentParsingType)
|
2012-10-23 02:59:57 -05:00
|
|
|
{
|
2013-02-08 10:04:35 -06:00
|
|
|
case PARSE_PROJECT_FILE_NAME:
|
|
|
|
if (QFile::exists(arg))
|
|
|
|
{
|
|
|
|
projectFilename = arg;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PARSE_CASE_NAMES:
|
|
|
|
{
|
|
|
|
caseNames.append(arg);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PARSE_START_DIR:
|
|
|
|
{
|
|
|
|
m_startupDefaultDirectory = arg;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PARSE_REGRESSION_TEST_PATH:
|
|
|
|
{
|
|
|
|
regressionTestPath = arg;
|
|
|
|
}
|
2012-10-23 02:59:57 -05:00
|
|
|
}
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (showHelp)
|
|
|
|
{
|
2013-08-08 04:09:18 -05:00
|
|
|
QString helpText = commandLineParameterHelp();
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-08-08 04:09:18 -05:00
|
|
|
#if defined(_MSC_VER) && defined(_WIN32)
|
|
|
|
showFormattedTextInMessageBox(helpText);
|
|
|
|
#else
|
2012-05-18 02:45:23 -05:00
|
|
|
fprintf(stdout, "%s\n", helpText.toAscii().data());
|
|
|
|
fflush(stdout);
|
2013-08-08 04:09:18 -05:00
|
|
|
#endif
|
2012-05-18 02:45:23 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-02-08 10:04:35 -06:00
|
|
|
if (isRunRegressionTest)
|
|
|
|
{
|
2013-03-22 11:17:56 -05:00
|
|
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
2013-02-11 04:47:45 -06:00
|
|
|
if (mainWnd)
|
|
|
|
{
|
|
|
|
mainWnd->hideAllDockWindows();
|
|
|
|
}
|
|
|
|
|
2013-02-08 10:04:35 -06:00
|
|
|
runRegressionTest(regressionTestPath);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isUpdateRegressionTest)
|
|
|
|
{
|
|
|
|
updateRegressionTest(regressionTestPath);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
if (openLatestProject)
|
|
|
|
{
|
|
|
|
loadLastUsedProject();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!projectFilename.isEmpty())
|
|
|
|
{
|
|
|
|
loadProject(projectFilename);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!caseNames.isEmpty())
|
|
|
|
{
|
|
|
|
QString caseName;
|
|
|
|
foreach (caseName, caseNames)
|
|
|
|
{
|
|
|
|
QString tmpCaseFileName = caseName + ".EGRID";
|
|
|
|
|
|
|
|
if (QFile::exists(tmpCaseFileName))
|
|
|
|
{
|
|
|
|
openEclipseCaseFromFile(tmpCaseFileName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmpCaseFileName = caseName + ".GRID";
|
|
|
|
if (QFile::exists(tmpCaseFileName))
|
|
|
|
{
|
|
|
|
openEclipseCaseFromFile(tmpCaseFileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-06 06:23:46 -06:00
|
|
|
if (m_project.notNull() && !m_project->fileName().isEmpty() && isSaveSnapshotsForAllViews)
|
|
|
|
{
|
2013-02-08 10:04:35 -06:00
|
|
|
saveSnapshotForAllViews("snapshots");
|
2013-02-06 06:23:46 -06:00
|
|
|
|
|
|
|
// Returning false will exit the application
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-02-08 10:04:35 -06:00
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-04-24 00:35:31 -05:00
|
|
|
QString RiaApplication::scriptDirectories() const
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-04-24 00:35:31 -05:00
|
|
|
return m_preferences->scriptDirectories();
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
QString RiaApplication::scriptEditorPath() const
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
return m_preferences->scriptEditorExecutable();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
QString RiaApplication::octavePath() const
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
return m_preferences->octaveExecutable();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-03-22 11:17:56 -05:00
|
|
|
RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
// Execute delete later so that other slots that are hooked up
|
|
|
|
// get a chance to run before we delete the object
|
|
|
|
if (m_workerProcess)
|
|
|
|
{
|
2012-08-31 12:12:47 -05:00
|
|
|
m_workerProcess->close();
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
m_workerProcess = NULL;
|
|
|
|
|
|
|
|
// Either the work process crashed or was aborted by the user
|
|
|
|
if (exitStatus == QProcess::CrashExit)
|
|
|
|
{
|
|
|
|
// MFLog::error("Simulation execution crashed or was aborted.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-12 01:11:56 -05:00
|
|
|
|
|
|
|
executeCommandObjects();
|
|
|
|
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
// Exit code != 0 means we have an error
|
|
|
|
if (exitCode != 0)
|
|
|
|
{
|
|
|
|
// MFLog::error(QString("Simulation execution failed (exit code %1).").arg(exitCode));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-27 08:38:03 -05:00
|
|
|
// If multiple cases are present, invoke launchProcess() which will set next current case, and run script on this case
|
|
|
|
if (m_currentCaseIds.size() > 0)
|
|
|
|
{
|
|
|
|
launchProcess(m_currentProgram, m_currentArguments);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Disable concept of current case
|
|
|
|
m_socketServer->setCurrentCaseId(-1);
|
|
|
|
}
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::launchProcess(const QString& program, const QStringList& arguments)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2012-08-31 12:12:47 -05:00
|
|
|
if (m_workerProcess == NULL)
|
|
|
|
{
|
2013-05-27 08:38:03 -05:00
|
|
|
// If multiple cases are present, pop the first case ID from the list and set as current case
|
|
|
|
if (m_currentCaseIds.size() > 0)
|
|
|
|
{
|
|
|
|
int nextCaseId = m_currentCaseIds.front();
|
|
|
|
m_currentCaseIds.pop_front();
|
|
|
|
|
|
|
|
m_socketServer->setCurrentCaseId(nextCaseId);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Disable current case concept
|
|
|
|
m_socketServer->setCurrentCaseId(-1);
|
|
|
|
}
|
|
|
|
|
2012-08-31 12:12:47 -05:00
|
|
|
m_workerProcess = new caf::UiProcess(this);
|
|
|
|
connect(m_workerProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(slotWorkerProcessFinished(int, QProcess::ExitStatus)));
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-03-22 11:17:56 -05:00
|
|
|
RiuMainWindow::instance()->processMonitor()->startMonitorWorkProcess(m_workerProcess);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2012-08-31 12:12:47 -05:00
|
|
|
m_workerProcess->start(program, arguments);
|
|
|
|
if (!m_workerProcess->waitForStarted(1000))
|
|
|
|
{
|
|
|
|
m_workerProcess->close();
|
|
|
|
m_workerProcess = NULL;
|
|
|
|
|
2013-03-22 11:17:56 -05:00
|
|
|
RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-03-22 11:17:56 -05:00
|
|
|
QMessageBox::warning(RiuMainWindow::instance(), "Script execution", "Failed to start script executable located at\n" + program);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2012-08-31 12:12:47 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QMessageBox::warning(NULL, "Script execution", "An Octave process is still running. Please stop this process before executing a new script.");
|
2012-05-18 02:45:23 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-27 08:38:03 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RiaApplication::launchProcessForMultipleCases(const QString& program, const QStringList& arguments, const std::vector<int>& caseIds)
|
|
|
|
{
|
|
|
|
m_currentCaseIds.clear();
|
|
|
|
std::copy( caseIds.begin(), caseIds.end(), std::back_inserter( m_currentCaseIds ) );
|
|
|
|
|
|
|
|
m_currentProgram = program;
|
|
|
|
m_currentArguments = arguments;
|
|
|
|
|
|
|
|
return launchProcess(m_currentProgram, m_currentArguments);
|
|
|
|
}
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Read fields of a Pdm object using QSettings
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::readPreferences()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
std::vector<caf::PdmFieldHandle*> fields;
|
|
|
|
|
|
|
|
m_preferences->fields(fields);
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < fields.size(); i++)
|
|
|
|
{
|
|
|
|
caf::PdmFieldHandle* fieldHandle = fields[i];
|
|
|
|
|
|
|
|
if (settings.contains(fieldHandle->keyword()))
|
|
|
|
{
|
|
|
|
QVariant val = settings.value(fieldHandle->keyword());
|
|
|
|
fieldHandle->setValueFromUi(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Write fields of a Pdm object using QSettings
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::writePreferences()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
|
|
|
|
std::vector<caf::PdmFieldHandle*> fields;
|
|
|
|
m_preferences->fields(fields);
|
|
|
|
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < fields.size(); i++)
|
|
|
|
{
|
|
|
|
caf::PdmFieldHandle* fieldHandle = fields[i];
|
|
|
|
|
|
|
|
settings.setValue(fieldHandle->keyword(), fieldHandle->uiValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
RiaPreferences* RiaApplication::preferences()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
return m_preferences;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::applyPreferences()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
if (m_activeReservoirView && m_activeReservoirView->viewer())
|
|
|
|
{
|
|
|
|
if (m_preferences->navigationPolicy() == NAVIGATION_POLICY_CAD)
|
|
|
|
{
|
|
|
|
m_activeReservoirView->viewer()->setNavigationPolicy(new caf::CadNavigation);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_activeReservoirView->viewer()->setNavigationPolicy(new caf::CeetronNavigation);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_activeReservoirView->viewer()->enablePerfInfoHud(m_preferences->showHud());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (useShaders())
|
|
|
|
{
|
|
|
|
caf::EffectGenerator::setRenderingMode(caf::EffectGenerator::SHADER_BASED);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
caf::EffectGenerator::setRenderingMode(caf::EffectGenerator::FIXED_FUNCTION);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this->project())
|
|
|
|
{
|
2013-04-24 00:35:31 -05:00
|
|
|
this->project()->setScriptDirectories(m_preferences->scriptDirectories());
|
2013-03-22 11:17:56 -05:00
|
|
|
RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel();
|
2013-05-13 05:00:52 -05:00
|
|
|
if (treeModel) treeModel->updateUiSubTree(this->project()->scriptCollection());
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-08-31 12:12:47 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::terminateProcess()
|
2012-08-31 12:12:47 -05:00
|
|
|
{
|
|
|
|
if (m_workerProcess)
|
|
|
|
{
|
|
|
|
m_workerProcess->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_workerProcess = NULL;
|
|
|
|
}
|
2012-10-23 02:59:57 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
QString RiaApplication::defaultFileDialogDirectory(const QString& dialogName)
|
2012-10-23 02:59:57 -05:00
|
|
|
{
|
|
|
|
QString defaultDirectory = m_startupDefaultDirectory;
|
|
|
|
std::map<QString, QString>::iterator it;
|
|
|
|
it = m_fileDialogDefaultDirectories.find(dialogName);
|
|
|
|
|
|
|
|
if ( it != m_fileDialogDefaultDirectories.end())
|
|
|
|
{
|
|
|
|
defaultDirectory = it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
return defaultDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::setDefaultFileDialogDirectory(const QString& dialogName, const QString& defaultDirectory)
|
2012-10-23 02:59:57 -05:00
|
|
|
{
|
|
|
|
m_fileDialogDefaultDirectories[dialogName] = defaultDirectory;
|
|
|
|
}
|
2013-02-06 04:43:26 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::saveSnapshotPromtpForFilename()
|
2013-02-06 04:43:26 -06:00
|
|
|
{
|
|
|
|
QString startPath;
|
|
|
|
if (!m_project->fileName().isEmpty())
|
|
|
|
{
|
|
|
|
QFileInfo fi(m_project->fileName());
|
|
|
|
startPath = fi.absolutePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
startPath = defaultFileDialogDirectory("IMAGE_SNAPSHOT");
|
|
|
|
}
|
|
|
|
|
|
|
|
startPath += "/image.png";
|
|
|
|
|
|
|
|
QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save File"), startPath, tr("Image files (*.bmp *.png * *.jpg)"));
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remember the directory to next time
|
|
|
|
setDefaultFileDialogDirectory("IMAGE_SNAPSHOT", QFileInfo(fileName).absolutePath());
|
|
|
|
|
|
|
|
saveSnapshotAs(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::saveSnapshotAs(const QString& fileName)
|
2013-02-06 04:43:26 -06:00
|
|
|
{
|
2013-05-03 03:07:53 -05:00
|
|
|
QImage image = grabFrameBufferImage();
|
|
|
|
if (!image.isNull())
|
2013-02-06 04:43:26 -06:00
|
|
|
{
|
2013-02-06 06:23:46 -06:00
|
|
|
if (image.save(fileName))
|
|
|
|
{
|
|
|
|
qDebug() << "Saved snapshot image to " << fileName;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug() << "Error when trying to save snapshot image to " << fileName;
|
|
|
|
}
|
2013-02-06 04:43:26 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::copySnapshotToClipboard()
|
2013-02-06 04:43:26 -06:00
|
|
|
{
|
2013-05-06 03:55:00 -05:00
|
|
|
QClipboard* clipboard = QApplication::clipboard();
|
|
|
|
if (clipboard)
|
|
|
|
{
|
2013-05-03 03:07:53 -05:00
|
|
|
QImage image = grabFrameBufferImage();
|
|
|
|
if (!image.isNull())
|
2013-02-06 04:43:26 -06:00
|
|
|
{
|
|
|
|
clipboard->setImage(image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
|
2013-02-06 04:43:26 -06:00
|
|
|
{
|
2013-03-22 11:17:56 -05:00
|
|
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
2013-02-06 04:43:26 -06:00
|
|
|
if (!mainWnd) return;
|
|
|
|
|
|
|
|
if (m_project.isNull()) return;
|
|
|
|
|
|
|
|
if (m_project->fileName().isEmpty()) return;
|
|
|
|
|
|
|
|
QFileInfo fi(m_project->fileName());
|
|
|
|
QDir projectDir(fi.absolutePath());
|
2013-02-08 10:04:35 -06:00
|
|
|
|
2013-02-06 04:43:26 -06:00
|
|
|
if (!projectDir.exists(snapshotFolderName))
|
|
|
|
{
|
|
|
|
if (!projectDir.mkdir(snapshotFolderName)) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString snapshotPath = projectDir.absolutePath();
|
|
|
|
snapshotPath += "/" + snapshotFolderName;
|
|
|
|
|
2013-06-06 08:07:31 -05:00
|
|
|
RimAnalysisModels* analysisModels = m_project->activeOilField() ? m_project->activeOilField()->analysisModels() : NULL;
|
|
|
|
if (analysisModels == NULL) return;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < analysisModels->cases().size(); ++i)
|
2013-02-06 04:43:26 -06:00
|
|
|
{
|
2013-06-06 08:07:31 -05:00
|
|
|
RimCase* ri = analysisModels->cases()[i];
|
2013-02-06 04:43:26 -06:00
|
|
|
if (!ri) continue;
|
|
|
|
|
|
|
|
for (size_t j = 0; j < ri->reservoirViews().size(); j++)
|
|
|
|
{
|
|
|
|
RimReservoirView* riv = ri->reservoirViews()[j];
|
|
|
|
|
|
|
|
if (riv && riv->viewer())
|
|
|
|
{
|
|
|
|
setActiveReservoirView(riv);
|
|
|
|
|
2013-03-22 11:17:56 -05:00
|
|
|
RiuViewer* viewer = riv->viewer();
|
2013-02-06 04:43:26 -06:00
|
|
|
mainWnd->setActiveViewer(viewer);
|
|
|
|
|
|
|
|
// Process all events to avoid a black image when grabbing frame buffer
|
|
|
|
QCoreApplication::processEvents();
|
|
|
|
|
2013-04-11 05:06:38 -05:00
|
|
|
QString fileName = ri->caseUserDescription() + "-" + riv->name();
|
2013-02-06 04:43:26 -06:00
|
|
|
|
2013-02-08 10:04:35 -06:00
|
|
|
QString absoluteFileName = caf::Utils::constructFullFileName(snapshotPath, fileName, ".png");
|
2013-02-06 04:43:26 -06:00
|
|
|
saveSnapshotAs(absoluteFileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-08 10:04:35 -06:00
|
|
|
|
|
|
|
void removeDirectoryWithContent(QDir dirToDelete )
|
|
|
|
{
|
|
|
|
QStringList files = dirToDelete.entryList();
|
|
|
|
for (int fIdx = 0; fIdx < files.size(); ++fIdx)
|
|
|
|
{
|
|
|
|
dirToDelete.remove(files[fIdx]);
|
|
|
|
}
|
|
|
|
dirToDelete.rmdir(".");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::runRegressionTest(const QString& testRootPath)
|
2013-02-08 10:04:35 -06:00
|
|
|
{
|
2013-02-11 04:29:55 -06:00
|
|
|
QString generatedFolderName = RegTestNames::generatedFolderName;
|
|
|
|
QString diffFolderName = RegTestNames::diffFolderName;
|
|
|
|
QString baseFolderName = RegTestNames::baseFolderName;
|
|
|
|
QString regTestProjectName = RegTestNames::testProjectName;
|
|
|
|
QString regTestFolderFilter = RegTestNames::testFolderFilter;
|
2013-02-08 10:04:35 -06:00
|
|
|
|
|
|
|
// Find all sub folders
|
|
|
|
|
|
|
|
QDir testDir(testRootPath); // If string is empty it will end up as cwd
|
|
|
|
testDir.setFilter(QDir::Dirs);
|
|
|
|
QStringList dirNameFilter;
|
|
|
|
dirNameFilter.append(regTestFolderFilter);
|
|
|
|
testDir.setNameFilters(dirNameFilter);
|
|
|
|
|
|
|
|
QFileInfoList folderList = testDir.entryInfoList();
|
|
|
|
|
|
|
|
// delete diff and generated images
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < folderList.size(); ++i)
|
|
|
|
{
|
|
|
|
QDir testCaseFolder(folderList[i].filePath());
|
|
|
|
|
|
|
|
QDir genDir(testCaseFolder.filePath(generatedFolderName));
|
|
|
|
removeDirectoryWithContent(genDir);
|
|
|
|
|
|
|
|
QDir diffDir(testCaseFolder.filePath(diffFolderName));
|
|
|
|
removeDirectoryWithContent(diffDir);
|
|
|
|
|
|
|
|
QDir baseDir(testCaseFolder.filePath(baseFolderName));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate html report
|
|
|
|
|
|
|
|
RiaImageCompareReporter imageCompareReporter;
|
|
|
|
|
|
|
|
for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
|
|
|
|
{
|
|
|
|
QDir testCaseFolder(folderList[dirIdx].filePath());
|
|
|
|
|
|
|
|
QString testFolderName = testCaseFolder.dirName();
|
|
|
|
QString reportBaseFolderName = testCaseFolder.filePath(baseFolderName);
|
|
|
|
QString reportGeneratedFolderName = testCaseFolder.filePath(generatedFolderName);
|
|
|
|
QString reportDiffFolderName = testCaseFolder.filePath(diffFolderName);
|
|
|
|
|
|
|
|
imageCompareReporter.addImageDirectoryComparisonSet(testFolderName.toStdString(), reportBaseFolderName.toStdString(), reportGeneratedFolderName.toStdString(), reportDiffFolderName.toStdString());
|
|
|
|
}
|
|
|
|
|
2013-02-11 04:29:55 -06:00
|
|
|
imageCompareReporter.generateHTMLReport(testDir.filePath(RegTestNames::reportFileName).toStdString());
|
2013-02-08 10:04:35 -06:00
|
|
|
|
|
|
|
// Generate diff images
|
2013-04-12 06:15:41 -05:00
|
|
|
this->preferences()->resetToDefaults();
|
2013-02-08 10:04:35 -06:00
|
|
|
|
|
|
|
for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
|
|
|
|
{
|
|
|
|
QDir testCaseFolder(folderList[dirIdx].filePath());
|
|
|
|
if (testCaseFolder.exists(regTestProjectName))
|
|
|
|
{
|
|
|
|
loadProject(testCaseFolder.filePath(regTestProjectName));
|
|
|
|
saveSnapshotForAllViews(generatedFolderName);
|
|
|
|
|
|
|
|
QDir baseDir(testCaseFolder.filePath(baseFolderName));
|
|
|
|
QDir genDir(testCaseFolder.filePath(generatedFolderName));
|
|
|
|
QDir diffDir(testCaseFolder.filePath(diffFolderName));
|
|
|
|
if (!diffDir.exists()) testCaseFolder.mkdir(diffFolderName);
|
|
|
|
baseDir.setFilter(QDir::Files);
|
|
|
|
QStringList baseImageFileNames = baseDir.entryList();
|
|
|
|
|
|
|
|
for (int fIdx = 0; fIdx < baseImageFileNames.size(); ++fIdx)
|
|
|
|
{
|
|
|
|
QString fileName = baseImageFileNames[fIdx];
|
2013-02-11 04:29:55 -06:00
|
|
|
RiaImageFileCompare imgComparator(RegTestNames::imageCompareExeName);
|
2013-02-08 10:04:35 -06:00
|
|
|
bool ok = imgComparator.runComparison(genDir.filePath(fileName), baseDir.filePath(fileName), diffDir.filePath(fileName));
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
qDebug() << "Error comparing :" << imgComparator.errorMessage() << "\n" << imgComparator.errorDetails();
|
|
|
|
}
|
|
|
|
}
|
2013-02-22 03:12:06 -06:00
|
|
|
|
|
|
|
closeProject(false);
|
2013-02-08 10:04:35 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
void RiaApplication::updateRegressionTest(const QString& testRootPath)
|
2013-02-08 10:04:35 -06:00
|
|
|
{
|
|
|
|
// Find all sub folders
|
|
|
|
|
|
|
|
QDir testDir(testRootPath); // If string is empty it will end up as cwd
|
|
|
|
testDir.setFilter(QDir::Dirs);
|
|
|
|
QStringList dirNameFilter;
|
2013-02-11 04:29:55 -06:00
|
|
|
dirNameFilter.append(RegTestNames::testFolderFilter);
|
2013-02-08 10:04:35 -06:00
|
|
|
testDir.setNameFilters(dirNameFilter);
|
|
|
|
|
|
|
|
QFileInfoList folderList = testDir.entryInfoList();
|
|
|
|
|
|
|
|
for (int i = 0; i < folderList.size(); ++i)
|
|
|
|
{
|
|
|
|
QDir testCaseFolder(folderList[i].filePath());
|
|
|
|
|
2013-02-11 04:29:55 -06:00
|
|
|
QDir baseDir(testCaseFolder.filePath(RegTestNames::baseFolderName));
|
2013-02-08 10:04:35 -06:00
|
|
|
removeDirectoryWithContent(baseDir);
|
2013-02-11 04:29:55 -06:00
|
|
|
testCaseFolder.mkdir(RegTestNames::baseFolderName);
|
2013-02-08 10:04:35 -06:00
|
|
|
|
2013-02-11 04:29:55 -06:00
|
|
|
QDir genDir(testCaseFolder.filePath(RegTestNames::generatedFolderName));
|
2013-02-08 10:04:35 -06:00
|
|
|
|
|
|
|
QStringList imageFileNames = genDir.entryList();
|
|
|
|
|
|
|
|
for (int fIdx = 0; fIdx < imageFileNames.size(); ++fIdx)
|
|
|
|
{
|
|
|
|
QString fileName = imageFileNames[fIdx];
|
|
|
|
QFile::copy(genDir.filePath(fileName), baseDir.filePath(fileName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-21 09:46:34 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-14 03:28:49 -05:00
|
|
|
/// Make sure changes in this functions is validated to RimIdenticalGridCaseGroup::initAfterRead()
|
2013-02-21 09:46:34 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:50:44 -05:00
|
|
|
bool RiaApplication::addEclipseCases(const QStringList& fileNames)
|
2013-02-21 09:46:34 -06:00
|
|
|
{
|
2013-02-27 08:27:33 -06:00
|
|
|
if (fileNames.size() == 0) return true;
|
2013-02-21 09:46:34 -06:00
|
|
|
|
2013-02-27 08:27:33 -06:00
|
|
|
// First file is read completely including grid.
|
|
|
|
// The main grid from the first case is reused directly in for the other cases.
|
|
|
|
// When reading active cell info, only the total cell count is tested for consistency
|
2013-04-07 10:27:45 -05:00
|
|
|
RimResultCase* mainResultCase = NULL;
|
|
|
|
std::vector< std::vector<int> > mainCaseGridDimensions;
|
2013-04-23 01:11:52 -05:00
|
|
|
RimIdenticalGridCaseGroup* gridCaseGroup = NULL;
|
2013-02-21 09:46:34 -06:00
|
|
|
|
2013-02-27 08:27:33 -06:00
|
|
|
{
|
|
|
|
QString firstFileName = fileNames[0];
|
|
|
|
QFileInfo gridFileName(firstFileName);
|
|
|
|
|
|
|
|
QString caseName = gridFileName.completeBaseName();
|
|
|
|
|
2013-04-08 07:29:43 -05:00
|
|
|
RimResultCase* rimResultReservoir = new RimResultCase();
|
2013-04-11 05:06:38 -05:00
|
|
|
rimResultReservoir->setCaseInfo(caseName, firstFileName);
|
2013-02-27 08:27:33 -06:00
|
|
|
if (!rimResultReservoir->openEclipseGridFile())
|
|
|
|
{
|
2013-04-07 10:27:45 -05:00
|
|
|
delete rimResultReservoir;
|
|
|
|
|
2013-02-27 08:27:33 -06:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-07 10:27:45 -05:00
|
|
|
rimResultReservoir->readGridDimensions(mainCaseGridDimensions);
|
|
|
|
|
|
|
|
mainResultCase = rimResultReservoir;
|
2013-06-06 08:07:31 -05:00
|
|
|
RimOilField* oilField = m_project->activeOilField();
|
|
|
|
if (oilField && oilField->analysisModels())
|
|
|
|
{
|
|
|
|
gridCaseGroup = oilField->analysisModels->createIdenticalCaseGroupFromMainCase(mainResultCase);
|
|
|
|
}
|
2013-02-27 08:27:33 -06:00
|
|
|
}
|
|
|
|
|
2013-03-05 06:10:26 -06:00
|
|
|
caf::ProgressInfo info(fileNames.size(), "Reading Active Cell data");
|
|
|
|
|
2013-02-27 08:27:33 -06:00
|
|
|
for (int i = 1; i < fileNames.size(); i++)
|
|
|
|
{
|
2013-04-07 10:27:45 -05:00
|
|
|
QString caseFileName = fileNames[i];
|
|
|
|
QFileInfo gridFileName(caseFileName);
|
2013-02-27 08:27:33 -06:00
|
|
|
|
|
|
|
QString caseName = gridFileName.completeBaseName();
|
2013-02-21 09:46:34 -06:00
|
|
|
|
2013-04-08 07:29:43 -05:00
|
|
|
RimResultCase* rimResultReservoir = new RimResultCase();
|
2013-04-11 05:06:38 -05:00
|
|
|
rimResultReservoir->setCaseInfo(caseName, caseFileName);
|
2013-02-21 09:46:34 -06:00
|
|
|
|
2013-04-07 10:27:45 -05:00
|
|
|
std::vector< std::vector<int> > caseGridDimensions;
|
|
|
|
rimResultReservoir->readGridDimensions(caseGridDimensions);
|
2013-02-27 08:27:33 -06:00
|
|
|
|
2013-04-07 10:27:45 -05:00
|
|
|
bool identicalGrid = RigGridManager::isGridDimensionsEqual(mainCaseGridDimensions, caseGridDimensions);
|
|
|
|
if (identicalGrid)
|
2013-02-27 08:27:33 -06:00
|
|
|
{
|
2013-04-07 10:27:45 -05:00
|
|
|
if (rimResultReservoir->openAndReadActiveCellData(mainResultCase->reservoirData()))
|
|
|
|
{
|
2013-06-06 08:07:31 -05:00
|
|
|
RimOilField* oilField = m_project->activeOilField();
|
|
|
|
if (oilField && oilField->analysisModels())
|
|
|
|
{
|
|
|
|
oilField->analysisModels()->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir);
|
|
|
|
}
|
2013-04-07 10:27:45 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delete rimResultReservoir;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delete rimResultReservoir;
|
2013-02-27 08:27:33 -06:00
|
|
|
}
|
2013-03-05 06:10:26 -06:00
|
|
|
|
|
|
|
info.setProgress(i);
|
2013-02-27 08:27:33 -06:00
|
|
|
}
|
2013-02-22 03:12:06 -06:00
|
|
|
|
2013-04-23 01:11:52 -05:00
|
|
|
RimUiTreeModelPdm* uiModel = RiuMainWindow::instance()->uiPdmModel();
|
2013-06-07 07:54:02 -05:00
|
|
|
|
|
|
|
uiModel->updateUiSubTree( m_project->activeOilField()->analysisModels());
|
2013-04-23 01:11:52 -05:00
|
|
|
|
2013-04-26 12:19:33 -05:00
|
|
|
if (gridCaseGroup->statisticsCaseCollection()->reservoirs.size() > 0)
|
|
|
|
{
|
|
|
|
RiuMainWindow::instance()->setCurrentObjectInTreeView(gridCaseGroup->statisticsCaseCollection()->reservoirs[0]);
|
|
|
|
}
|
2013-02-21 09:46:34 -06:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-04-19 01:02:36 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::Font* RiaApplication::standardFont()
|
|
|
|
{
|
|
|
|
CVF_ASSERT(m_standardFont.notNull());
|
|
|
|
|
|
|
|
// The creation of a font is time consuming, so make sure you really need your own font
|
|
|
|
// instead of using the application font
|
|
|
|
|
|
|
|
return m_standardFont.p();
|
|
|
|
}
|
2013-05-03 03:07:53 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QImage RiaApplication::grabFrameBufferImage()
|
|
|
|
{
|
|
|
|
QImage image;
|
|
|
|
if (m_activeReservoirView && m_activeReservoirView->viewer())
|
|
|
|
{
|
|
|
|
m_activeReservoirView->viewer()->repaint();
|
|
|
|
|
|
|
|
GLint currentReadBuffer;
|
|
|
|
glGetIntegerv(GL_READ_BUFFER, ¤tReadBuffer);
|
|
|
|
|
|
|
|
glReadBuffer(GL_FRONT);
|
|
|
|
image = m_activeReservoirView->viewer()->grabFrameBuffer();
|
|
|
|
|
|
|
|
glReadBuffer(currentReadBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
2013-05-06 03:55:00 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimProject* RiaApplication::project()
|
|
|
|
{
|
|
|
|
return m_project;
|
|
|
|
}
|
2013-05-27 08:38:03 -05:00
|
|
|
|
2013-08-08 04:09:18 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiaApplication::showFormattedTextInMessageBox(const QString& text)
|
|
|
|
{
|
|
|
|
QString helpText = text;
|
|
|
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
msgBox.setIcon(QMessageBox::Information);
|
|
|
|
msgBox.setWindowTitle("ResInsight");
|
|
|
|
|
|
|
|
helpText.replace("&", "&");
|
|
|
|
helpText.replace("<", "<");
|
|
|
|
helpText.replace(">", ">");
|
|
|
|
|
|
|
|
helpText = QString("<pre>%1</pre>").arg(helpText);
|
|
|
|
msgBox.setText(helpText);
|
|
|
|
|
|
|
|
msgBox.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RiaApplication::commandLineParameterHelp() const
|
|
|
|
{
|
|
|
|
QString text = QString("\n%1 v. %2\n").arg(RI_APPLICATION_NAME).arg(getVersionStringApp(false));
|
|
|
|
text += "Copyright Statoil ASA, Ceetron AS 2011, 2012\n\n";
|
|
|
|
|
|
|
|
text +=
|
|
|
|
"\nParameter Description\n"
|
|
|
|
"-----------------------------------------------------------------\n"
|
|
|
|
"-last Open last used project\n"
|
|
|
|
"\n"
|
|
|
|
"-project <filename> Open project file <filename>\n"
|
|
|
|
"\n"
|
|
|
|
"-case <casename> Open Eclipse case <casename>\n"
|
|
|
|
" (do not include .GRID/.EGRID)\n"
|
|
|
|
"\n"
|
|
|
|
"-startdir The default directory for open/save commands\n"
|
|
|
|
"\n"
|
|
|
|
"-savesnapshots Save snapshot of all views to 'snapshots' folder in project file folder\n"
|
|
|
|
" Application closes after snapshots are written to file\n"
|
|
|
|
"\n"
|
|
|
|
"-regressiontest <folder> Run a regression test on all sub-folders starting with \"" + RegTestNames::testFolderFilter + "\" of the given folder: \n"
|
|
|
|
" " + RegTestNames::testProjectName + " files in the sub-folders will be opened and \n"
|
|
|
|
" snapshots of all the views is written to the sub-sub-folder " + RegTestNames::generatedFolderName + ". \n"
|
|
|
|
" Then difference images is generated in the sub-sub-folder " + RegTestNames::diffFolderName + " based \n"
|
|
|
|
" on the images in sub-sub-folder " + RegTestNames::baseFolderName + ".\n"
|
|
|
|
" The results are presented in " + RegTestNames::reportFileName + " that is\n"
|
|
|
|
" written in the given folder.\n"
|
|
|
|
"\n"
|
|
|
|
"-updateregressiontestbase <folder> For all sub-folders starting with \"" + RegTestNames::testFolderFilter + "\" of the given folder: \n"
|
|
|
|
" Copy the images in the sub-sub-folder " + RegTestNames::generatedFolderName + " to the sub-sub-folder\n"
|
|
|
|
" " + RegTestNames::baseFolderName + " after deleting " + RegTestNames::baseFolderName + " completely.\n"
|
|
|
|
"\n"
|
|
|
|
"-help, -? Displays help text\n"
|
|
|
|
"-----------------------------------------------------------------";
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2013-09-07 03:27:22 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Schedule a creation of the Display model and redraw of the reservoir view
|
|
|
|
/// The redraw will happen as soon as the event loop is entered
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiaApplication::scheduleDisplayModelUpdateAndRedraw(RimReservoirView* resViewToUpdate)
|
|
|
|
{
|
|
|
|
m_resViewsToUpdate.push_back(resViewToUpdate);
|
|
|
|
|
|
|
|
if (!m_resViewUpdateTimer)
|
|
|
|
{
|
|
|
|
m_resViewUpdateTimer = new QTimer(this);
|
|
|
|
connect(m_resViewUpdateTimer, SIGNAL(timeout()), this, SLOT(slotUpdateScheduledDisplayModels()));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_resViewUpdateTimer->isActive())
|
|
|
|
{
|
|
|
|
m_resViewUpdateTimer->setSingleShot(true);
|
|
|
|
m_resViewUpdateTimer->start(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiaApplication::slotUpdateScheduledDisplayModels()
|
|
|
|
{
|
|
|
|
// Compress to remove duplicates
|
|
|
|
std::set<RimReservoirView*> resViewsToUpdate;
|
|
|
|
for (size_t i = 0; i < m_resViewsToUpdate.size(); ++i)
|
|
|
|
{
|
|
|
|
resViewsToUpdate.insert(m_resViewsToUpdate[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::set<RimReservoirView*>::iterator it = resViewsToUpdate.begin(); it != resViewsToUpdate.end(); ++it )
|
|
|
|
{
|
|
|
|
if (*it)
|
|
|
|
{
|
|
|
|
(*it)->createDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-08 03:53:25 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiaApplication::setCacheDataObject(const QString& key, const QVariant& dataObject)
|
|
|
|
{
|
|
|
|
m_sessionCache[key] = dataObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QVariant RiaApplication::cacheDataObject(const QString& key) const
|
|
|
|
{
|
|
|
|
QMap<QString, QVariant>::const_iterator it = m_sessionCache.find(key);
|
|
|
|
|
|
|
|
if (it != m_sessionCache.end())
|
|
|
|
{
|
|
|
|
return it.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
2013-09-12 01:11:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiaApplication::addCommandObject(RimCommandObject* commandObject)
|
|
|
|
{
|
|
|
|
m_commandQueue.push_back(commandObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiaApplication::executeCommandObjects()
|
|
|
|
{
|
|
|
|
if (m_commandQueue.size() > 0)
|
|
|
|
{
|
|
|
|
std::list< RimCommandObject* >::iterator it = m_commandQueue.begin();
|
|
|
|
|
|
|
|
RimCommandObject* first = *it;
|
|
|
|
first->redo();
|
|
|
|
|
|
|
|
m_commandQueue.pop_front();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|