Merge branch 'fishbones' into pre-proto

This commit is contained in:
Magne Sjaastad 2017-05-23 10:28:42 +02:00
commit a45aee0cc2
3995 changed files with 17802 additions and 174762 deletions

View File

@ -145,7 +145,7 @@ namespace RegTestNames
const QString generatedFolderName = "RegTestGeneratedImages";
const QString diffFolderName = "RegTestDiffImages";
const QString baseFolderName = "RegTestBaseImages";
const QString testProjectName = "RegressionTest.rip";
const QString testProjectName = "RegressionTest";
const QString testFolderFilter = "TestCase*";
const QString imageCompareExeName = "compare";
const QString reportFileName = "ResInsightRegressionTestReport.html";
@ -350,7 +350,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi
// Open the project file and read the serialized data.
// Will initialize itself.
if (!QFile::exists(projectFileName))
if (!caf::Utils::fileExists(projectFileName))
{
RiaLogging::info(QString("File does not exist : '%1'").arg(projectFileName));
return false;
@ -718,7 +718,7 @@ bool RiaApplication::saveProject()
{
CVF_ASSERT(m_project.notNull());
if (!QFile::exists(m_project->fileName()))
if (!caf::Utils::fileExists(m_project->fileName()))
{
return saveProjectPromptForFileName();
}
@ -944,7 +944,7 @@ QString RiaApplication::createAbsolutePathFromProjectRelativePath(QString projec
//--------------------------------------------------------------------------------------------------
bool RiaApplication::openEclipseCaseFromFile(const QString& fileName)
{
if (!QFile::exists(fileName)) return false;
if (!caf::Utils::fileExists(fileName)) return false;
QFileInfo gridFileName(fileName);
QString caseName = gridFileName.completeBaseName();
@ -1138,7 +1138,7 @@ bool RiaApplication::openInputEclipseCaseFromFileNames(const QStringList& fileNa
//--------------------------------------------------------------------------------------------------
bool RiaApplication::openOdbCaseFromFile(const QString& fileName)
{
if (!QFile::exists(fileName)) return false;
if (!caf::Utils::fileExists(fileName)) return false;
QFileInfo gridFileName(fileName);
QString caseName = gridFileName.completeBaseName();
@ -1424,7 +1424,8 @@ bool RiaApplication::parseArguments()
std::vector<QString> gridFiles = readFileListFromTextFile(gridListFile);
runMultiCaseSnapshots(projectFileName, gridFiles, "multiCaseSnapshots");
closeProject();
closeAllWindows();
processEvents();
return false;
}
@ -1503,14 +1504,14 @@ bool RiaApplication::parseArguments()
foreach (QString caseName, caseNames)
{
QString caseFileNameWithExt = caseName + ".EGRID";
if (QFile::exists(caseFileNameWithExt))
if (!caf::Utils::fileExists(caseFileNameWithExt))
{
openEclipseCaseFromFile(caseFileNameWithExt);
}
else
{
caseFileNameWithExt = caseName + ".GRID";
if (QFile::exists(caseFileNameWithExt))
if (!caf::Utils::fileExists(caseFileNameWithExt))
{
openEclipseCaseFromFile(caseFileNameWithExt);
}
@ -1577,7 +1578,8 @@ bool RiaApplication::parseArguments()
}
}
closeProject();
closeAllWindows();
processEvents();
}
// Returning false will exit the application
@ -1733,6 +1735,24 @@ RimViewWindow* RiaApplication::activeViewWindow()
return viewWindow;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication::isMain3dWindowVisible() const
{
return RiuMainWindow::instance()->isVisible();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication::isMainPlotWindowVisible() const
{
if (!m_mainPlotWindow) return false;
return m_mainPlotWindow->isVisible();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -2140,7 +2160,7 @@ void RiaApplication::setLastUsedDialogDirectory(const QString& dialogName, const
//--------------------------------------------------------------------------------------------------
bool RiaApplication::openFile(const QString& fileName)
{
if (!QFile::exists(fileName)) return false;
if (!caf::Utils::fileExists(fileName)) return false;
bool loadingSucceded = false;
@ -2284,6 +2304,18 @@ void removeDirectoryWithContent(QDir dirToDelete )
dirToDelete.rmdir(".");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void logInfoTextWithTimeInSeconds(const QTime& time, const QString& msg)
{
double timeRunning = time.elapsed() / 1000.0;
QString timeText = QString("(%1 s) ").arg(timeRunning, 0, 'f', 1);
RiaLogging::info(timeText + msg);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -2340,6 +2372,11 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
}
}
QTime timeStamp;
timeStamp.start();
logInfoTextWithTimeInSeconds(timeStamp, "Starting regression tests\n");
for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
{
QDir testCaseFolder(folderList[dirIdx].filePath());
@ -2361,49 +2398,103 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
{
QDir testCaseFolder(folderList[dirIdx].filePath());
if (testCaseFolder.exists(regTestProjectName))
QString projectFileName;
if (testCaseFolder.exists(regTestProjectName + ".rip"))
{
loadProject(testCaseFolder.filePath(regTestProjectName));
projectFileName = regTestProjectName + ".rip";
}
// Wait until all command objects have completed
while (!m_commandQueueLock.tryLock())
{
processEvents();
}
m_commandQueueLock.unlock();
if (testCaseFolder.exists(regTestProjectName + ".rsp"))
{
projectFileName = regTestProjectName + ".rsp";
}
regressionTestConfigureProject();
if (!projectFileName.isEmpty())
{
logInfoTextWithTimeInSeconds(timeStamp, "Initializing test :" + testCaseFolder.absolutePath());
QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName);
saveSnapshotForAllViews(fullPathGeneratedFolder);
loadProject(testCaseFolder.filePath(projectFileName));
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder);
// Wait until all command objects have completed
while (!m_commandQueueLock.tryLock())
{
processEvents();
}
m_commandQueueLock.unlock();
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();
regressionTestConfigureProject();
for (int fIdx = 0; fIdx < baseImageFileNames.size(); ++fIdx)
{
QString fileName = baseImageFileNames[fIdx];
RiaImageFileCompare imgComparator(RegTestNames::imageCompareExeName);
bool ok = imgComparator.runComparison(genDir.filePath(fileName), baseDir.filePath(fileName), diffDir.filePath(fileName));
if (!ok)
{
resizeMaximizedPlotWindows();
QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName);
saveSnapshotForAllViews(fullPathGeneratedFolder);
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder);
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];
RiaImageFileCompare imgComparator(RegTestNames::imageCompareExeName);
bool ok = imgComparator.runComparison(genDir.filePath(fileName), baseDir.filePath(fileName), diffDir.filePath(fileName));
if (!ok)
{
qDebug() << "Error comparing :" << imgComparator.errorMessage() << "\n" << imgComparator.errorDetails();
}
}
}
}
closeProject();
closeProject();
logInfoTextWithTimeInSeconds(timeStamp, "Completed test :" + testCaseFolder.absolutePath());
}
}
RiaLogging::info("\n");
logInfoTextWithTimeInSeconds(timeStamp, "Completed regression tests");
m_runningRegressionTests = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::resizeMaximizedPlotWindows()
{
std::vector<RimViewWindow*> viewWindows;
m_project->mainPlotCollection()->descendantsIncludingThisOfType(viewWindows);
for (auto viewWindow : viewWindows)
{
if (viewWindow->isMdiWindow())
{
RimMdiWindowGeometry wndGeo = viewWindow->mdiWindowGeometry();
if (wndGeo.isMaximized)
{
QWidget* viewWidget = viewWindow->viewWidget();
if (viewWidget)
{
QMdiSubWindow* mdiWindow = m_mainPlotWindow->findMdiSubWindow(viewWidget);
if (mdiWindow)
{
mdiWindow->showNormal();
viewWidget->resize(RiaApplication::regressionDefaultImageSize());
}
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -2798,7 +2889,6 @@ void RiaApplication::executeRegressionTests(const QString& regressionTestPath)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -2833,8 +2923,16 @@ void RiaApplication::regressionTestConfigureProject()
}
// This size is set to match the regression test reference images
riv->viewer()->setFixedSize(1000, 745);
riv->viewer()->setFixedSize(RiaApplication::regressionDefaultImageSize());
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QSize RiaApplication::regressionDefaultImageSize()
{
return QSize(1000, 745);
}

View File

@ -137,8 +137,6 @@ public:
void saveSnapshotForAllViews(const QString& snapshotFolderName);
void runMultiCaseSnapshots(const QString& templateProjectFileName, std::vector<QString> gridFileNames, const QString& snapshotFolderName);
void runRegressionTest(const QString& testRootPath);
void updateRegressionTest(const QString& testRootPath );
void regressionTestConfigureProject();
void processNonGuiEvents();
@ -187,6 +185,9 @@ public:
static RimViewWindow* activeViewWindow();
bool isMain3dWindowVisible() const;
bool isMainPlotWindowVisible() const;
bool tryCloseMainWindow();
bool tryClosePlotWindow();
@ -215,6 +216,11 @@ private:
void storeTreeViewState();
void resizeMaximizedPlotWindows();
void updateRegressionTest(const QString& testRootPath);
void regressionTestConfigureProject();
static QSize regressionDefaultImageSize();
private slots:
void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotUpdateScheduledDisplayModels();

View File

@ -33,7 +33,7 @@ CAF_PDM_SOURCE_INIT(RiaPreferences, "RiaPreferences");
//--------------------------------------------------------------------------------------------------
RiaPreferences::RiaPreferences(void)
{
CAF_PDM_InitField(&navigationPolicy, "navigationPolicy", caf::AppEnum<RiaApplication::RINavigationPolicy>(RiaApplication::NAVIGATION_POLICY_CEETRON), "Navigation mode", "", "", "");
CAF_PDM_InitField(&navigationPolicy, "navigationPolicy", caf::AppEnum<RiaApplication::RINavigationPolicy>(RiaApplication::NAVIGATION_POLICY_CEETRON), "Navigation Mode", "", "", "");
CAF_PDM_InitFieldNoDefault(&scriptDirectories, "scriptDirectory", "Shared Script Folder(s)", "", "", "");
scriptDirectories.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
@ -41,27 +41,27 @@ RiaPreferences::RiaPreferences(void)
CAF_PDM_InitField(&scriptEditorExecutable, "scriptEditorExecutable", QString("kate"), "Script Editor", "", "", "");
scriptEditorExecutable.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&octaveExecutable, "octaveExecutable", QString("octave"), "Octave executable location", "", "", "");
CAF_PDM_InitField(&octaveExecutable, "octaveExecutable", QString("octave"), "Octave Executable Location", "", "", "");
octaveExecutable.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
octaveExecutable.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
CAF_PDM_InitField(&octaveShowHeaderInfoWhenExecutingScripts, "octaveShowHeaderInfoWhenExecutingScripts", false, "Show text header when executing scripts", "", "", "");
CAF_PDM_InitField(&octaveShowHeaderInfoWhenExecutingScripts, "octaveShowHeaderInfoWhenExecutingScripts", false, "Show Text Header When Executing Scripts", "", "", "");
octaveShowHeaderInfoWhenExecutingScripts.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitField(&ssihubAddress, "ssihubAddress", QString("http://"), "ssihub Address", "", "", "");
CAF_PDM_InitField(&ssihubAddress, "ssihubAddress", QString("http://"), "SSIHUB Address", "", "", "");
ssihubAddress.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
CAF_PDM_InitField(&defaultGridLines, "defaultGridLines", true, "Gridlines", "", "", "");
CAF_PDM_InitField(&defaultGridLineColors, "defaultGridLineColors", cvf::Color3f(0.92f, 0.92f, 0.92f), "Mesh color", "", "", "");
CAF_PDM_InitField(&defaultFaultGridLineColors, "defaultFaultGridLineColors", cvf::Color3f(0.08f, 0.08f, 0.08f), "Mesh color along faults", "", "", "");
CAF_PDM_InitField(&defaultWellLabelColor, "defaultWellLableColor", cvf::Color3f(0.92f, 0.92f, 0.92f), "Well label color", "", "The default well label color in new views", "");
CAF_PDM_InitField(&defaultGridLineColors, "defaultGridLineColors", cvf::Color3f(0.92f, 0.92f, 0.92f), "Mesh Color", "", "", "");
CAF_PDM_InitField(&defaultFaultGridLineColors, "defaultFaultGridLineColors", cvf::Color3f(0.08f, 0.08f, 0.08f), "Mesh Color Along Faults", "", "", "");
CAF_PDM_InitField(&defaultWellLabelColor, "defaultWellLableColor", cvf::Color3f(0.92f, 0.92f, 0.92f), "Well Label Color", "", "The default well label color in new views", "");
CAF_PDM_InitField(&defaultViewerBackgroundColor, "defaultViewerBackgroundColor", cvf::Color3f(0.69f, 0.77f, 0.87f), "Viewer background", "", "The viewer background color for new views", "");
CAF_PDM_InitField(&defaultViewerBackgroundColor, "defaultViewerBackgroundColor", cvf::Color3f(0.69f, 0.77f, 0.87f), "Viewer Background", "", "The viewer background color for new views", "");
CAF_PDM_InitField(&defaultScaleFactorZ, "defaultScaleFactorZ", 5, "Default Z scale factor", "", "", "");
CAF_PDM_InitField(&fontSizeInScene, "fontSizeInScene", QString("8"), "Font size", "", "", "");
CAF_PDM_InitField(&defaultScaleFactorZ, "defaultScaleFactorZ", 5, "Default Z Scale Factor", "", "", "");
CAF_PDM_InitField(&fontSizeInScene, "fontSizeInScene", QString("8"), "Font Size", "", "", "");
CAF_PDM_InitField(&showLasCurveWithoutTvdWarning, "showLasCurveWithoutTvdWarning", true, "Show LAS curve without TVD warning", "", "", "");
CAF_PDM_InitField(&showLasCurveWithoutTvdWarning, "showLasCurveWithoutTvdWarning", true, "Show LAS Curve Without TVD Warning", "", "", "");
showLasCurveWithoutTvdWarning.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitField(&useShaders, "useShaders", true, "Use Shaders", "", "", "");
@ -77,21 +77,22 @@ RiaPreferences::RiaPreferences(void)
CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", "");
lastUsedProjectFileName.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&autocomputeDepthRelatedProperties, "autocomputeDepth", true, "Compute DEPTH related properties", "", "DEPTH, DX, DY, DZ, TOP, BOTTOM", "");
CAF_PDM_InitField(&autocomputeDepthRelatedProperties, "autocomputeDepth", true, "Compute DEPTH Related Properties", "", "DEPTH, DX, DY, DZ, TOP, BOTTOM", "");
autocomputeDepthRelatedProperties.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitField(&loadAndShowSoil, "loadAndShowSoil", true, "Load and show SOIL", "", "", "");
CAF_PDM_InitField(&loadAndShowSoil, "loadAndShowSoil", true, "Load and Show SOIL", "", "", "");
loadAndShowSoil.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitFieldNoDefault(&readerSettings, "readerSettings", "Reader settings", "", "", "");
CAF_PDM_InitFieldNoDefault(&readerSettings, "readerSettings", "Reader Settings", "", "", "");
readerSettings = new RifReaderSettings;
CAF_PDM_InitField(&autoCreatePlotsOnImport, "AutoCreatePlotsOnImport", true, "Create Summary Plots When Importing Eclipse Case", "", "", "");
CAF_PDM_InitField(&autoCreatePlotsOnImport, "AutoCreatePlotsOnImport", true, "Automatically Create Summary Plots On Import", "", "", "");
autoCreatePlotsOnImport.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitField(&defaultCurveFilter, "DefaultCurveFilter", QString("F*PT"), "Default Vector Selection Filter", "", "", "");
m_tabNames << "General";
m_tabNames << "Eclipse";
m_tabNames << "Octave";
m_tabNames << "Summary";
}
@ -113,7 +114,7 @@ void RiaPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QSt
if (field == &scriptDirectories)
{
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectDirectory = true;
@ -129,7 +130,7 @@ void RiaPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QSt
field == &showLasCurveWithoutTvdWarning ||
field == &autoCreatePlotsOnImport)
{
caf::PdmUiCheckBoxEditorAttribute* myAttr = static_cast<caf::PdmUiCheckBoxEditorAttribute*>(attribute);
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_useNativeCheckBoxLabel = true;
@ -144,33 +145,36 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
{
if (uiConfigName == m_tabNames[0])
{
caf::PdmUiGroup* defaultSettingsGroup = uiOrdering.addNewGroup("Default settings");
caf::PdmUiGroup* defaultSettingsGroup = uiOrdering.addNewGroup("Default Settings");
defaultSettingsGroup->add(&defaultViewerBackgroundColor);
defaultSettingsGroup->add(&defaultGridLines);
defaultSettingsGroup->add(&defaultGridLineColors);
defaultSettingsGroup->add(&defaultFaultGridLineColors);
defaultSettingsGroup->add(&defaultWellLabelColor);
defaultSettingsGroup->add(&fontSizeInScene);
defaultSettingsGroup->add(&defaultScaleFactorZ);
caf::PdmUiGroup* viewsGroup = uiOrdering.addNewGroup("3D views");
caf::PdmUiGroup* viewsGroup = uiOrdering.addNewGroup("3D Views");
viewsGroup->add(&navigationPolicy);
viewsGroup->add(&useShaders);
viewsGroup->add(&showHud);
caf::PdmUiGroup* newCaseBehaviourGroup = uiOrdering.addNewGroup("Behavior when loading new case");
newCaseBehaviourGroup->add(&defaultScaleFactorZ);
newCaseBehaviourGroup->add(&autocomputeDepthRelatedProperties);
newCaseBehaviourGroup->add(&loadAndShowSoil);
newCaseBehaviourGroup->add(&showLasCurveWithoutTvdWarning);
readerSettings->defineUiOrdering(uiConfigName, *newCaseBehaviourGroup);
caf::PdmUiGroup* ssihubGroup = uiOrdering.addNewGroup("SSIHUB");
ssihubGroup->add(&ssihubAddress);
caf::PdmUiGroup* otherGroup = uiOrdering.addNewGroup("Other");
otherGroup->add(&ssihubAddress);
otherGroup->add(&showLasCurveWithoutTvdWarning);
uiOrdering.add(&appendClassNameToUiText);
}
else if (uiConfigName == m_tabNames[1])
{
caf::PdmUiGroup* newCaseBehaviourGroup = uiOrdering.addNewGroup("Behavior When Loading Data");
newCaseBehaviourGroup->add(&autocomputeDepthRelatedProperties);
newCaseBehaviourGroup->add(&loadAndShowSoil);
readerSettings->defineUiOrdering(uiConfigName, *newCaseBehaviourGroup);
}
else if (uiConfigName == m_tabNames[2])
{
caf::PdmUiGroup* octaveGroup = uiOrdering.addNewGroup("Octave");
octaveGroup->add(&octaveExecutable);
@ -180,7 +184,7 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
scriptGroup->add(&scriptDirectories);
scriptGroup->add(&scriptEditorExecutable);
}
else if (uiConfigName == m_tabNames[2])
else if (uiConfigName == m_tabNames[3])
{
uiOrdering.add(&autoCreatePlotsOnImport);
uiOrdering.add(&defaultCurveFilter);

View File

@ -51,7 +51,7 @@ void RiaRegressionTest::defineEditorAttribute(const caf::PdmFieldHandle* field,
{
if (field == &applicationWorkingFolder || field == &regressionTestFolder)
{
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectDirectory = true;

View File

@ -49,6 +49,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Summary
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Flow
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Fishbones
${CMAKE_CURRENT_SOURCE_DIR}/ResultStatisticsCache
${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel
@ -107,6 +108,7 @@ list( APPEND REFERENCED_CMAKE_FILES
ProjectDataModel/CMakeLists_files.cmake
ProjectDataModel/Summary/CMakeLists_files.cmake
ProjectDataModel/Flow/CMakeLists_files.cmake
ProjectDataModel/Fishbones/CMakeLists_files.cmake
GeoMech/GeoMechVisualization/CMakeLists_files.cmake
@ -121,6 +123,8 @@ list( APPEND REFERENCED_CMAKE_FILES
Commands/CrossSectionCommands/CMakeLists_files.cmake
Commands/EclipseCommands/CMakeLists_files.cmake
Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake
Commands/FishbonesCommands/CMakeLists_files.cmake
Commands/PerforationCommands/CMakeLists_files.cmake
Commands/FlowCommands/CMakeLists_files.cmake
Commands/IntersectionBoxCommands/CMakeLists_files.cmake
Commands/OctaveScriptCommands/CMakeLists_files.cmake

View File

@ -51,4 +51,5 @@ void RicExitApplicationFeature::onActionTriggered(bool isChecked)
void RicExitApplicationFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("E&xit");
actionToSetup->setShortcuts(QKeySequence::Quit);
}

View File

@ -66,4 +66,5 @@ void RicOpenProjectFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Open Project");
actionToSetup->setIcon(QIcon(":/openFolder24x24.png"));
actionToSetup->setShortcuts(QKeySequence::Open);
}

View File

@ -54,4 +54,5 @@ void RicSaveProjectAsFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Save Project &As");
actionToSetup->setIcon(QIcon(":/Save.png"));
actionToSetup->setShortcuts(QKeySequence::SaveAs);
}

View File

@ -51,6 +51,7 @@ void RicSaveProjectFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("&Save Project");
actionToSetup->setIcon(QIcon(":/Save.png"));
actionToSetup->setShortcuts(QKeySequence::Save);
}
//--------------------------------------------------------------------------------------------------

View File

@ -103,7 +103,8 @@ void RiuQPlainTextEdit::slotSelectAll()
///
///
//--------------------------------------------------------------------------------------------------
RicTextWidget::RicTextWidget(QWidget* parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
RicTextWidget::RicTextWidget(QWidget* parent)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
{
m_textEdit = new RiuQPlainTextEdit(this);
m_textEdit->setReadOnly(true);

View File

@ -66,6 +66,9 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.h
${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.h
${CEE_CURRENT_LIST_DIR}RicCommandFeature.h
${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicFlyToObjectFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -127,6 +130,9 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.cpp
${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.cpp
${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicFlyToObjectFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -94,9 +94,8 @@ void RicSaveEclipseResultAsInputPropertyExec::redo()
if (propertyDialog.exec() == QDialog::Accepted)
{
size_t timeStep = m_cellColors->reservoirView()->currentTimeStep();
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_cellColors->porosityModel());
bool isOk = RifEclipseInputFileTools::writeBinaryResultToTextFile(exportSettings.fileName, m_cellColors->reservoirView()->eclipseCase()->eclipseCaseData(), porosityModel, timeStep, m_cellColors->resultVariable(), exportSettings.eclipseKeyword, exportSettings.undefinedValue);
bool isOk = RifEclipseInputFileTools::writeBinaryResultToTextFile(exportSettings.fileName, m_cellColors->reservoirView()->eclipseCase()->eclipseCaseData(), timeStep, m_cellColors, exportSettings.eclipseKeyword, exportSettings.undefinedValue);
if (!isOk)
{
QMessageBox::critical(NULL, "File export", "Failed to exported current result to " + exportSettings.fileName);

View File

@ -0,0 +1,27 @@
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.h
${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.h
${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsAtMeasuredDepthFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsAtMeasuredDepthFeature.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "CommandFeature\\Fishbones" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )

View File

@ -0,0 +1,168 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicExportFishbonesLateralsFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimFishbonesCollection.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimWellPath.h"
#include "cafSelectionManager.h"
#include "cafUtils.h"
#include "cvfAssert.h"
#include <QAction>
#include <QFileDialog>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT(RicExportFishbonesLateralsFeature, "RicExportFishbonesLateralsFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportFishbonesLateralsFeature::onActionTriggered(bool isChecked)
{
RimFishbonesCollection* fishbonesCollection = selectedFishbonesCollection();
CVF_ASSERT(fishbonesCollection);
RimWellPath* wellPath = nullptr;
fishbonesCollection->firstAncestorOrThisOfType(wellPath);
CVF_ASSERT(wellPath);
RiaApplication* app = RiaApplication::instance();
QString projectFolder = app->currentProjectPath();
QString defaultDir = app->lastUsedDialogDirectoryWithFallback("WELL_PATH_EXPORT_DIR", projectFolder);
QString defaultFileName = defaultDir + "/" + caf::Utils::makeValidFileBasename((wellPath->name())) + ".dev";
QString completeFilename = QFileDialog::getSaveFileName(nullptr, "Select File for Well Path Data Export", defaultFileName, "Well Path Text File(*.dev);;All files(*.*)");
if (completeFilename.isEmpty()) return;
QFile exportFile(completeFilename);
RiaLogging::info("Starting export of Fishbones well path laterals to : " + completeFilename);
if (!exportFile.open(QIODevice::WriteOnly))
{
RiaLogging::error("Could not open the file :\n" + completeFilename);
return;
}
// See RifWellPathAsciiFileReader::readAllWellData for reading of dev files
//
// http://resinsight.org/docs/wellpaths/
// Export format
//
// wellname : <well name>__<sub lateral name>_<sub index>_<lateral index>
//
// for each coordinate along lateral, export
// x y TVD MD
// separate laterals using -999 on a single line
size_t fishboneSubIndex = 0;
QTextStream stream(&exportFile);
for (RimFishbonesMultipleSubs* fishbone : fishbonesCollection->fishbonesSubs())
{
if (!fishbone->isChecked()) continue;
for (size_t subIndex = 0; subIndex < fishbone->locationOfSubs().size(); subIndex++)
{
for (size_t lateralIndex = 0; lateralIndex < fishbone->lateralLengths().size(); lateralIndex++)
{
std::vector<std::pair<cvf::Vec3d, double>> coordsAndMD = fishbone->coordsAndMDForLateral(subIndex, lateralIndex);
// Pad with "0" to get a total of two characters defining the sub index text
QString subIndexText = QString("%1").arg(fishboneSubIndex++, 2, 10, QChar('0'));
QString lateralNameCandidate = QString("%1_%2_%3_%4").arg(wellPath->name()).arg("fishbone").arg(subIndexText).arg(lateralIndex);
QString lateralName = caf::Utils::makeValidFileBasename(lateralNameCandidate);
stream << "WELLNAME: " << lateralName << endl;
for (auto coordMD : coordsAndMD)
{
int numberOfDecimals = 2;
// Export X and Y unchanged, invert sign of Z to get TVD, export MD unchanged
stream << formatNumber( coordMD.first.x(), numberOfDecimals);
stream << " " << formatNumber( coordMD.first.y(), numberOfDecimals);
stream << " " << formatNumber(-coordMD.first.z(), numberOfDecimals);
stream << " " << formatNumber( coordMD.second, numberOfDecimals) << endl;
}
stream << -999 << endl << endl;
}
}
}
RiaLogging::info("Completed export of Fishbones well path laterals to : " + completeFilename);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicExportFishbonesLateralsFeature::formatNumber(double val, int numberOfDecimals)
{
return QString("%1").arg(val, 0, 'f', numberOfDecimals);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFishbonesCollection* RicExportFishbonesLateralsFeature::selectedFishbonesCollection()
{
RimFishbonesCollection* objToFind = nullptr;
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
if (objHandle)
{
objHandle->firstAncestorOrThisOfType(objToFind);
}
return objToFind;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportFishbonesLateralsFeature::setupActionLook(QAction* actionToSetup)
{
//actionToSetup->setIcon(QIcon(":/FractureSymbol16x16.png"));
actionToSetup->setText("Export Laterals");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportFishbonesLateralsFeature::isCommandEnabled()
{
if (selectedFishbonesCollection())
{
return true;
}
return false;
}

View File

@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 RimFishbonesCollection;
//==================================================================================================
///
//==================================================================================================
class RicExportFishbonesLateralsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
virtual bool isCommandEnabled() override;
private:
static QString formatNumber(double val, int numberOfDecimals);
static RimFishbonesCollection* selectedFishbonesCollection();
};

View File

@ -0,0 +1,99 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicNewFishbonesSubsAtMeasuredDepthFeature.h"
#include "RicNewFishbonesSubsFeature.h"
#include "RimFishbonesCollection.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RiuMainWindow.h"
#include "RiuSelectionManager.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicNewFishbonesSubsAtMeasuredDepthFeature, "RicNewFishbonesSubsAtMeasuredDepthFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewFishbonesSubsAtMeasuredDepthFeature::onActionTriggered(bool isChecked)
{
RiuWellPathSelectionItem* wellPathSelItem = wellPathSelectionItem();
CVF_ASSERT(wellPathSelItem);
RimWellPath* wellPath = wellPathSelItem->m_wellpath;
CVF_ASSERT(wellPath);
RimFishbonesMultipleSubs* obj = new RimFishbonesMultipleSubs;
wellPath->fishbonesCollection()->fishbonesSubs.push_back(obj);
obj->setName(QString("Fishbones Subs (%1)").arg(wellPath->fishbonesCollection()->fishbonesSubs.size()));
int integerValue = wellPathSelItem->m_measuredDepth;
obj->setMeasuredDepthAndCount(integerValue, 24, 1);
RicNewFishbonesSubsFeature::askUserToSetUsefulScaling(wellPath->fishbonesCollection());
wellPath->updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem(obj);
RimProject* proj;
wellPath->firstAncestorOrThisOfTypeAsserted(proj);
proj->createDisplayModelAndRedrawAllViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWellPathSelectionItem* RicNewFishbonesSubsAtMeasuredDepthFeature::wellPathSelectionItem()
{
RiuSelectionManager* riuSelManager = RiuSelectionManager::instance();
RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY);
RiuWellPathSelectionItem* wellPathItem = dynamic_cast<RiuWellPathSelectionItem*>(selItem);
return wellPathItem;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewFishbonesSubsAtMeasuredDepthFeature::setupActionLook(QAction* actionToSetup)
{
//actionToSetup->setIcon(QIcon(":/FractureSymbol16x16.png"));
actionToSetup->setText("New Fishbones Subs Definition");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewFishbonesSubsAtMeasuredDepthFeature::isCommandEnabled()
{
if (wellPathSelectionItem())
{
return true;
}
return false;
}

View File

@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 RiuWellPathSelectionItem;
//==================================================================================================
///
//==================================================================================================
class RicNewFishbonesSubsAtMeasuredDepthFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
virtual bool isCommandEnabled() override;
private:
static RiuWellPathSelectionItem* wellPathSelectionItem();
};

View File

@ -0,0 +1,151 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicNewFishbonesSubsFeature.h"
#include "RiaApplication.h"
#include "RimFishboneWellPathCollection.h"
#include "RimFishbonesCollection.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimView.h"
#include "RimWellPathCollection.h"
#include "RiuMainWindow.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT(RicNewFishbonesSubsFeature, "RicNewFishbonesSubsFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewFishbonesSubsFeature::onActionTriggered(bool isChecked)
{
RimFishbonesCollection* fishbonesCollection = selectedFishbonesCollection();
CVF_ASSERT(fishbonesCollection);
RimFishbonesMultipleSubs* obj = new RimFishbonesMultipleSubs;
obj->setName(QString("Fishbones Subs (%1)").arg(fishbonesCollection->fishbonesSubs.size()));
fishbonesCollection->fishbonesSubs.push_back(obj);
RicNewFishbonesSubsFeature::askUserToSetUsefulScaling(fishbonesCollection);
fishbonesCollection->updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem(obj);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFishbonesCollection* RicNewFishbonesSubsFeature::selectedFishbonesCollection()
{
RimFishbonesCollection* objToFind = nullptr;
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
if (objHandle)
{
objHandle->firstAncestorOrThisOfType(objToFind);
}
return objToFind;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewFishbonesSubsFeature::setupActionLook(QAction* actionToSetup)
{
//actionToSetup->setIcon(QIcon(":/FractureSymbol16x16.png"));
actionToSetup->setText("New Fishbones Subs Definition");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewFishbonesSubsFeature::isCommandEnabled()
{
if (selectedFishbonesCollection())
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewFishbonesSubsFeature::askUserToSetUsefulScaling(RimFishbonesCollection* fishboneCollection)
{
// Always reset well path collection scale factor
CVF_ASSERT(fishboneCollection);
RimWellPathCollection* wellPathColl = nullptr;
fishboneCollection->firstAncestorOrThisOfTypeAsserted(wellPathColl);
wellPathColl->wellPathRadiusScaleFactor = 0.01;
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return;
RiaApplication* app = RiaApplication::instance();
QString sessionKey = "AutoAdjustSettingsForFishbones";
bool autoAdjustSettings = false;
QVariant v = app->cacheDataObject(sessionKey);
if (!v.isValid())
{
double currentScaleFactor = activeView->scaleZ();
if (fabs(currentScaleFactor - 1.0) < 0.1) return;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
QString questionText;
questionText = QString("When displaying Fishbones structures, the view scaling should be set to 1.\n\nDo you want ResInsight to automatically set view scaling to 1?");
msgBox.setText(questionText);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
{
autoAdjustSettings = true;
}
app->setCacheDataObject(sessionKey, autoAdjustSettings);
}
else
{
autoAdjustSettings = v.toBool();
}
if (autoAdjustSettings)
{
activeView->setScaleZAndUpdate(1.0);
wellPathColl->scheduleGeometryRegenAndRedrawViews();
RiuMainWindow::instance()->updateScaleValue();
}
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 RimFishbonesCollection;
//==================================================================================================
///
//==================================================================================================
class RicNewFishbonesSubsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void askUserToSetUsefulScaling(RimFishbonesCollection* fishboneCollection);
protected:
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
virtual bool isCommandEnabled() override;
private:
static RimFishbonesCollection* selectedFishbonesCollection();
};

View File

@ -54,8 +54,7 @@ void RicShowContributingWellsFromPlotFeature::onActionTriggered(bool isChecked)
int timeStep = wellAllocationPlot->timeStep();
QString wellName = wellAllocationPlot->wellName();
RimEclipseResultCase* wellAllocationResultCase = nullptr;
wellAllocationPlot->flowDiagSolution()->firstAncestorOrThisOfTypeAsserted(wellAllocationResultCase);
RimEclipseResultCase* wellAllocationResultCase = wellAllocationPlot->rimCase();
RicShowContributingWellsFeatureImpl::maniuplateSelectedView(wellAllocationResultCase, wellName, timeStep);
}

View File

@ -76,7 +76,7 @@ void RicShowTotalAllocationDataFeature::onActionTriggered(bool isChecked)
//--------------------------------------------------------------------------------------------------
void RicShowTotalAllocationDataFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Show Total Allocation");
actionToSetup->setText("Show Total Allocation Data");
//actionToSetup->setIcon(QIcon(":/PlotWindow24x24.png"));
}

View File

@ -29,6 +29,8 @@
#include "RiuMainWindow.h"
#include "cafUtils.h"
#include <QAction>
#include <QFileInfo>
#include <QInputDialog>
@ -76,7 +78,7 @@ void RicNewScriptFeature::onActionTriggered(bool isChecked)
fullPathFilenameNewScript = fullPathNewScript + "/untitled.m";
int num= 1;
while (QFileInfo(fullPathFilenameNewScript).exists())
while (caf::Utils::fileExists(fullPathFilenameNewScript))
{
fullPathFilenameNewScript = fullPathNewScript + "/untitled" + QString::number(num) + ".m";
num++;

View File

@ -38,8 +38,6 @@
#include <QClipboard>
namespace caf
{
CAF_CMD_SOURCE_INIT(RicCopyReferencesToClipboardFeature, "RicCopyReferencesToClipboardFeature");
@ -63,14 +61,14 @@ void RicCopyReferencesToClipboardFeature::onActionTriggered(bool isChecked)
std::vector<QString> referenceList;
std::vector<PdmObject*> selectedFormationNamesCollObjs;
std::vector<caf::PdmObject*> selectedFormationNamesCollObjs;
caf::SelectionManager::instance()->objectsByType(&selectedFormationNamesCollObjs);
for (PdmObject* pdmObject : selectedFormationNamesCollObjs)
for (caf::PdmObject* pdmObject : selectedFormationNamesCollObjs)
{
if (RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(pdmObject))
{
QString itemRef = PdmReferenceHelper::referenceFromRootToObject(SelectionManager::instance()->pdmRootObject(), pdmObject);
QString itemRef = caf::PdmReferenceHelper::referenceFromRootToObject(caf::SelectionManager::instance()->pdmRootObject(), pdmObject);
referenceList.push_back(itemRef);
}
@ -96,16 +94,15 @@ void RicCopyReferencesToClipboardFeature::setupActionLook(QAction* actionToSetup
actionToSetup->setShortcuts(QKeySequence::Copy);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCopyReferencesToClipboardFeature::isAnyCopyableObjectSelected()
{
std::vector<PdmObject*> selectedFormationNamesCollObjs;
std::vector<caf::PdmObject*> selectedFormationNamesCollObjs;
caf::SelectionManager::instance()->objectsByType(&selectedFormationNamesCollObjs);
for (PdmObject* pdmObject : selectedFormationNamesCollObjs)
for (caf::PdmObject* pdmObject : selectedFormationNamesCollObjs)
{
if (RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(pdmObject))
{
@ -116,12 +113,10 @@ bool RicCopyReferencesToClipboardFeature::isAnyCopyableObjectSelected()
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(PdmObject* pdmObject)
bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(caf::PdmObject* pdmObject)
{
RimWellAllocationPlot* wellAllocPlot = nullptr;
pdmObject->firstAncestorOrThisOfType(wellAllocPlot);
@ -161,5 +156,3 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(PdmObject* pdm
return false;
}
} // end namespace caf

View File

@ -22,29 +22,25 @@
#include "cafCmdFeature.h"
namespace caf
namespace caf
{
class PdmObject;
class PdmObject;
}
//==================================================================================================
///
//==================================================================================================
class RicCopyReferencesToClipboardFeature : public CmdFeature
class RicCopyReferencesToClipboardFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
private:
static bool isAnyCopyableObjectSelected();
static bool isCopyOfObjectSupported(PdmObject* pdmObject);
static bool isCopyOfObjectSupported(caf::PdmObject* pdmObject);
};
} // end namespace caf

View File

@ -42,8 +42,6 @@
#include <QAction>
#include <QString>
namespace caf
{
CAF_CMD_SOURCE_INIT(RicPasteEclipseCasesFeature, "RicPasteEclipseCasesFeature");
@ -53,7 +51,7 @@ CAF_CMD_SOURCE_INIT(RicPasteEclipseCasesFeature, "RicPasteEclipseCasesFeature");
//--------------------------------------------------------------------------------------------------
bool RicPasteEclipseCasesFeature::isCommandEnabled()
{
PdmObjectGroup objectGroup;
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
std::vector<caf::PdmPointer<RimEclipseResultCase> > typedObjects;
@ -64,7 +62,7 @@ bool RicPasteEclipseCasesFeature::isCommandEnabled()
return false;
}
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
RimIdenticalGridCaseGroup* gridCaseGroup = RicPasteFeatureImpl::findGridCaseGroup(destinationObject);
if (gridCaseGroup) return true;
@ -77,12 +75,12 @@ bool RicPasteEclipseCasesFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicPasteEclipseCasesFeature::onActionTriggered(bool isChecked)
{
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
RimIdenticalGridCaseGroup* gridCaseGroup = RicPasteFeatureImpl::findGridCaseGroup(destinationObject);
if (!gridCaseGroup) return;
PdmObjectGroup objectGroup;
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
if (objectGroup.objects.size() == 0) return;
@ -105,7 +103,7 @@ void RicPasteEclipseCasesFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup)
void RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup)
{
RimProject* proj = RiaApplication::instance()->project();
CVF_ASSERT(proj);
@ -202,5 +200,3 @@ void RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(PdmObjectGroup& object
}
}
} // end namespace caf

View File

@ -28,6 +28,7 @@ class RimIdenticalGridCaseGroup;
namespace caf
{
class PdmObjectGroup;
}
//==================================================================================================
///
@ -37,15 +38,11 @@ class RicPasteEclipseCasesFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
public:
static void addCasesToGridCaseGroup(PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup);
static void addCasesToGridCaseGroup(caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup);
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered(bool isChecked);
virtual void setupActionLook(QAction* actionToSetup);
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
};
} // end namespace caf

View File

@ -35,8 +35,6 @@
#include <QAction>
namespace caf
{
CAF_CMD_SOURCE_INIT(RicPasteEclipseViewsFeature, "RicPasteEclipseViewsFeature");
@ -45,7 +43,7 @@ CAF_CMD_SOURCE_INIT(RicPasteEclipseViewsFeature, "RicPasteEclipseViewsFeature");
//--------------------------------------------------------------------------------------------------
bool RicPasteEclipseViewsFeature::isCommandEnabled()
{
PdmObjectGroup objectGroup;
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
std::vector<caf::PdmPointer<RimEclipseView> > typedObjects;
@ -56,7 +54,7 @@ bool RicPasteEclipseViewsFeature::isCommandEnabled()
return false;
}
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
RimIdenticalGridCaseGroup* gridCaseGroup = RicPasteFeatureImpl::findGridCaseGroup(destinationObject);
if (gridCaseGroup) return false;
@ -72,12 +70,12 @@ bool RicPasteEclipseViewsFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicPasteEclipseViewsFeature::onActionTriggered(bool isChecked)
{
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
RimEclipseCase* eclipseCase = RicPasteFeatureImpl::findEclipseCase(destinationObject);
assert(eclipseCase);
PdmObjectGroup objectGroup;
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
if (objectGroup.objects.size() == 0) return;
@ -90,7 +88,7 @@ void RicPasteEclipseViewsFeature::onActionTriggered(bool isChecked)
// Add cases to case group
for (size_t i = 0; i < eclipseViews.size(); i++)
{
RimEclipseView* rimReservoirView = dynamic_cast<RimEclipseView*>(eclipseViews[i]->xmlCapability()->copyByXmlSerialization(PdmDefaultObjectFactory::instance()));
RimEclipseView* rimReservoirView = dynamic_cast<RimEclipseView*>(eclipseViews[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
CVF_ASSERT(rimReservoirView);
QString nameOfCopy = QString("Copy of ") + rimReservoirView->name;
@ -124,6 +122,3 @@ void RicPasteEclipseViewsFeature::setupActionLook(QAction* actionToSetup)
RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup);
}
} // end namespace caf

View File

@ -23,8 +23,6 @@
#include "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
@ -35,11 +33,8 @@ CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered(bool isChecked);
virtual void setupActionLook(QAction* actionToSetup);
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
};
} // end namespace caf

View File

@ -32,8 +32,6 @@
#include <QAction>
namespace caf
{
CAF_CMD_SOURCE_INIT(RicPasteGeoMechViewsFeature, "RicPasteGeoMechViewsFeature");
@ -42,7 +40,7 @@ CAF_CMD_SOURCE_INIT(RicPasteGeoMechViewsFeature, "RicPasteGeoMechViewsFeature");
//--------------------------------------------------------------------------------------------------
bool RicPasteGeoMechViewsFeature::isCommandEnabled()
{
PdmObjectGroup objectGroup;
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
std::vector<caf::PdmPointer<RimGeoMechView> > typedObjects;
@ -53,7 +51,7 @@ bool RicPasteGeoMechViewsFeature::isCommandEnabled()
return false;
}
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
RimGeoMechCase* geoMechCase = RicPasteFeatureImpl::findGeoMechCase(destinationObject);
if (geoMechCase) return true;
@ -66,12 +64,12 @@ bool RicPasteGeoMechViewsFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicPasteGeoMechViewsFeature::onActionTriggered(bool isChecked)
{
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
RimGeoMechCase* geomCase = RicPasteFeatureImpl::findGeoMechCase(destinationObject);
assert(geomCase);
PdmObjectGroup objectGroup;
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
if (objectGroup.objects.size() == 0) return;
@ -84,7 +82,7 @@ void RicPasteGeoMechViewsFeature::onActionTriggered(bool isChecked)
// Add cases to case group
for (size_t i = 0; i < geomViews.size(); i++)
{
RimGeoMechView* rimReservoirView = dynamic_cast<RimGeoMechView*>(geomViews[i]->xmlCapability()->copyByXmlSerialization(PdmDefaultObjectFactory::instance()));
RimGeoMechView* rimReservoirView = dynamic_cast<RimGeoMechView*>(geomViews[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
QString nameOfCopy = QString("Copy of ") + rimReservoirView->name;
rimReservoirView->name = nameOfCopy;
geomCase->geoMechViews().push_back(rimReservoirView);
@ -117,6 +115,3 @@ void RicPasteGeoMechViewsFeature::setupActionLook(QAction* actionToSetup)
RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup);
}
} // end namespace caf

View File

@ -22,10 +22,6 @@
#include "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
@ -35,11 +31,7 @@ CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered(bool isChecked);
virtual void setupActionLook(QAction* actionToSetup);
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
};
} // end namespace caf

View File

@ -0,0 +1,27 @@
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicEditPerforationCollectionFeature.h
${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.h
${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalAtMeasuredDepthFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicEditPerforationCollectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalAtMeasuredDepthFeature.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "CommandFeature\\Perforations" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )

View File

@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicEditPerforationCollectionFeature.h"
#include "RiuEditPerforationCollectionWidget.h"
#include "RimPerforationCollection.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicEditPerforationCollectionFeature, "RicEditPerforationCollectionFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicEditPerforationCollectionFeature::isCommandEnabled()
{
return selectedPerforationCollection() != nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEditPerforationCollectionFeature::onActionTriggered(bool isChecked)
{
this->disableModelChangeContribution();
RimPerforationCollection* perforationCollection = selectedPerforationCollection();
if (perforationCollection == nullptr) return;
RiuEditPerforationCollectionWidget dlg(nullptr, perforationCollection);
dlg.exec();
perforationCollection->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicEditPerforationCollectionFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Edit Perforations");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPerforationCollection* RicEditPerforationCollectionFeature::selectedPerforationCollection()
{
RimPerforationCollection* objToFind = nullptr;
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
if (objHandle)
{
objHandle->firstAncestorOrThisOfType(objToFind);
}
return objToFind;
}

View File

@ -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 RimPerforationCollection;
//==================================================================================================
///
//==================================================================================================
class RicEditPerforationCollectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook(QAction* actionToSetup) override;
private:
static RimPerforationCollection* selectedPerforationCollection();
};

View File

@ -0,0 +1,97 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicNewPerforationIntervalAtMeasuredDepthFeature.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimPerforationCollection.h"
#include "RimPerforationInterval.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RiuMainWindow.h"
#include "RiuSelectionManager.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicNewPerforationIntervalAtMeasuredDepthFeature, "RicNewPerforationIntervalAtMeasuredDepthFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPerforationIntervalAtMeasuredDepthFeature::onActionTriggered(bool isChecked)
{
RiuWellPathSelectionItem* wellPathSelItem = wellPathSelectionItem();
CVF_ASSERT(wellPathSelItem);
RimWellPath* wellPath = wellPathSelItem->m_wellpath;
CVF_ASSERT(wellPath);
RimPerforationInterval* perforationInterval = new RimPerforationInterval;
int measuredDepth = wellPathSelItem->m_measuredDepth;
perforationInterval->setStartAndEndMD(measuredDepth, measuredDepth + 50);
wellPath->perforationIntervalCollection()->appendPerforation(perforationInterval);
RimWellPathCollection* wellPathCollection = nullptr;
wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection);
wellPathCollection->uiCapability()->updateConnectedEditors();
wellPathCollection->scheduleGeometryRegenAndRedrawViews();
RiuMainWindow::instance()->selectAsCurrentItem(perforationInterval);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWellPathSelectionItem* RicNewPerforationIntervalAtMeasuredDepthFeature::wellPathSelectionItem()
{
RiuSelectionManager* riuSelManager = RiuSelectionManager::instance();
RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY);
RiuWellPathSelectionItem* wellPathItem = dynamic_cast<RiuWellPathSelectionItem*>(selItem);
return wellPathItem;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPerforationIntervalAtMeasuredDepthFeature::setupActionLook(QAction* actionToSetup)
{
//actionToSetup->setIcon(QIcon(":/FractureSymbol16x16.png"));
actionToSetup->setText("New Perforation Interval");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewPerforationIntervalAtMeasuredDepthFeature::isCommandEnabled()
{
if (wellPathSelectionItem())
{
return true;
}
return false;
}

View File

@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 RiuWellPathSelectionItem;
//==================================================================================================
///
//==================================================================================================
class RicNewPerforationIntervalAtMeasuredDepthFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
virtual bool isCommandEnabled() override;
private:
static RiuWellPathSelectionItem* wellPathSelectionItem();
};

View File

@ -0,0 +1,90 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicNewPerforationIntervalFeature.h"
#include "RiuMainWindow.h"
#include "RimPerforationInterval.h"
#include "RimPerforationCollection.h"
#include "RimWellPathCollection.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicNewPerforationIntervalFeature, "RicNewPerforationIntervalFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewPerforationIntervalFeature::isCommandEnabled()
{
return selectedPerforationCollection() != nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPerforationIntervalFeature::onActionTriggered(bool isChecked)
{
RimPerforationCollection* perforationCollection = selectedPerforationCollection();
if (perforationCollection == nullptr) return;
RimPerforationInterval* perforationInterval = new RimPerforationInterval;
perforationCollection->appendPerforation(perforationInterval);
RimWellPathCollection* wellPathCollection = nullptr;
perforationCollection->firstAncestorOrThisOfType(wellPathCollection);
if (!wellPathCollection) return;
wellPathCollection->uiCapability()->updateConnectedEditors();
wellPathCollection->scheduleGeometryRegenAndRedrawViews();
RiuMainWindow::instance()->selectAsCurrentItem(perforationInterval);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPerforationIntervalFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("New Perforation Interval");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPerforationCollection* RicNewPerforationIntervalFeature::selectedPerforationCollection()
{
RimPerforationCollection* objToFind = nullptr;
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
if (objHandle)
{
objHandle->firstAncestorOrThisOfType(objToFind);
}
return objToFind;
}

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
class RimPerforationCollection;
//==================================================================================================
///
//==================================================================================================
class RicNewPerforationIntervalFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
private:
RimPerforationCollection* selectedPerforationCollection();
};

View File

@ -46,9 +46,6 @@
#include "cafSelectionManager.h"
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -62,15 +59,15 @@ QString RicDeleteItemExec::name()
//--------------------------------------------------------------------------------------------------
void RicDeleteItemExec::redo()
{
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
caf::PdmFieldHandle* field = caf::PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
PdmChildArrayFieldHandle* listField = dynamic_cast<PdmChildArrayFieldHandle*>(field);
caf::PdmChildArrayFieldHandle* listField = dynamic_cast<caf::PdmChildArrayFieldHandle*>(field);
if (listField)
{
std::vector<PdmObjectHandle*> children;
std::vector<caf::PdmObjectHandle*> children;
listField->childObjects(&children);
PdmObjectHandle* obj = children[m_commandData->m_indexToObject];
caf::PdmObjectHandle* obj = children[m_commandData->m_indexToObject];
caf::SelectionManager::instance()->removeObjectFromAllSelections(obj);
std::vector<caf::PdmObjectHandle*> referringObjects;
@ -161,6 +158,7 @@ void RicDeleteItemExec::redo()
if (wellPathColl)
{
wellPathColl->scheduleGeometryRegenAndRedrawViews();
wellPathColl->uiCapability()->updateConnectedEditors();
}
// Update due to deletion of curves (not tracks, handled separatly)
@ -235,12 +233,12 @@ void RicDeleteItemExec::redo()
//--------------------------------------------------------------------------------------------------
void RicDeleteItemExec::undo()
{
PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
caf::PdmFieldHandle* field = caf::PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
PdmChildArrayFieldHandle* listField = dynamic_cast<PdmChildArrayFieldHandle*>(field);
caf::PdmChildArrayFieldHandle* listField = dynamic_cast<caf::PdmChildArrayFieldHandle*>(field);
if (listField)
{
PdmObjectHandle* obj = PdmXmlObjectHandle::readUnknownObjectFromXmlString(m_commandData->m_deletedObjectAsXml(), PdmDefaultObjectFactory::instance());
caf::PdmObjectHandle* obj = caf::PdmXmlObjectHandle::readUnknownObjectFromXmlString(m_commandData->m_deletedObjectAsXml(), caf::PdmDefaultObjectFactory::instance());
listField->insertAt(m_commandData->m_indexToObject, obj);
@ -256,7 +254,7 @@ void RicDeleteItemExec::undo()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicDeleteItemExec::RicDeleteItemExec(NotificationCenter* notificationCenter)
RicDeleteItemExec::RicDeleteItemExec(caf::NotificationCenter* notificationCenter)
: CmdExecuteCommand(notificationCenter)
{
m_commandData = new RicDeleteItemExecData;
@ -269,5 +267,3 @@ RicDeleteItemExecData* RicDeleteItemExec::commandData()
{
return m_commandData;
}
} // end namespace caf

View File

@ -22,18 +22,15 @@
#include "cafCmdExecuteCommand.h"
namespace caf
{
class RicDeleteItemExecData;
//==================================================================================================
///
//==================================================================================================
class RicDeleteItemExec : public CmdExecuteCommand
class RicDeleteItemExec : public caf::CmdExecuteCommand
{
public:
explicit RicDeleteItemExec(NotificationCenter* notificationCenter);
explicit RicDeleteItemExec(caf::NotificationCenter* notificationCenter);
RicDeleteItemExecData* commandData();
@ -44,7 +41,3 @@ public:
private:
RicDeleteItemExecData* m_commandData;
};
} // end namespace caf

View File

@ -21,9 +21,4 @@
#include "RicDeleteItemExecData.h"
namespace caf
{
CAF_PDM_SOURCE_INIT(RicDeleteItemExecData, "RicDeleteItemExecData");
} // end namespace caf

View File

@ -23,14 +23,10 @@
#include "cafPdmObject.h"
#include "cafPdmField.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class RicDeleteItemExecData : public PdmObject
class RicDeleteItemExecData : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
@ -44,13 +40,9 @@ public:
CAF_PDM_InitField(&m_deletedObjectAsXml, "deletedObjectAsXml", QString(), "deletedObjectAsXml", "", "deletedObjectAsXml tooltip", "deletedObjectAsXml whatsthis");
}
caf::PdmPointer<PdmObjectHandle> m_rootObject;
caf::PdmPointer<caf::PdmObjectHandle> m_rootObject;
caf::PdmField<QString> m_pathToField;
caf::PdmField<int> m_indexToObject;
caf::PdmField<QString> m_deletedObjectAsXml;
};
} // end namespace caf

View File

@ -25,6 +25,7 @@
#include "RimEclipseInputProperty.h"
#include "RimEclipsePropertyFilter.h"
#include "RimEclipseView.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimEllipseFractureTemplate.h"
#include "RimFormationNames.h"
#include "RimFormationNamesCollection.h"
@ -46,6 +47,8 @@
#include "RimWellLogCurve.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RimFishboneWellPath.h"
#include "RimPerforationInterval.h"
#include "RimWellPathFracture.h"
#include "RimWellPathFractureCollection.h"
@ -58,11 +61,9 @@
#include <QAction>
namespace caf
{
CAF_CMD_SOURCE_INIT(RicDeleteItemFeature, "RicDeleteItemFeature");
CAF_CMD_SOURCE_INIT(RicDeleteItemFeature, "RicDeleteItemFeature");
bool isDeletable(PdmUiItem * uiItem)
bool isDeletable(caf::PdmUiItem* uiItem)
{
// Enable delete of well allocation plots
if (dynamic_cast<RimWellAllocationPlot*>(uiItem)) return true;
@ -92,12 +93,15 @@ bool isDeletable(PdmUiItem * uiItem)
if (dynamic_cast<RimWellLogCurve*>(uiItem)) return true;
if (dynamic_cast<RimSummaryPlot*>(uiItem)) return true;
if (dynamic_cast<RimSummaryCurve*>(uiItem)) return true;
if (dynamic_cast<RimGridTimeHistoryCurve*>(uiItem)) return true;
if (dynamic_cast<RimGridTimeHistoryCurve*>(uiItem)) return true;
if (dynamic_cast<RimSummaryCurveFilter*>(uiItem)) return true;
if (dynamic_cast<RimIntersection*>(uiItem)) return true;
if (dynamic_cast<RimIntersectionBox*>(uiItem)) return true;
if (dynamic_cast<RimFormationNames*>(uiItem)) return true;
if (dynamic_cast<RimFormationNamesCollection*>(uiItem)) return true;
if (dynamic_cast<RimFishboneWellPath*>(uiItem)) return true;
if (dynamic_cast<RimFishbonesMultipleSubs*>(uiItem)) return true;
if (dynamic_cast<RimPerforationInterval*>(uiItem)) return true;
if (dynamic_cast<RimWellPathFractureCollection*>(uiItem)) return true;
if (dynamic_cast<RimWellPathFracture*>(uiItem)) return true;
if (dynamic_cast<RimEllipseFractureTemplate*>(uiItem)) return true;
@ -114,12 +118,12 @@ bool isDeletable(PdmUiItem * uiItem)
//--------------------------------------------------------------------------------------------------
bool RicDeleteItemFeature::isCommandEnabled()
{
std::vector<PdmUiItem*> items;
std::vector<caf::PdmUiItem*> items;
caf::SelectionManager::instance()->selectedItems(items);
if (items.empty() ) return false;
for (PdmUiItem* item : items)
for (caf::PdmUiItem* item : items)
{
if (!isDeletable(item)) return false;
@ -138,11 +142,11 @@ bool RicDeleteItemFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicDeleteItemFeature::onActionTriggered(bool isChecked)
{
std::vector<PdmUiItem*> items;
SelectionManager::instance()->selectedItems(items);
std::vector<caf::PdmUiItem*> items;
caf::SelectionManager::instance()->selectedItems(items);
assert(items.size() > 0);
for (PdmUiItem* item: items)
for (caf::PdmUiItem* item: items)
{
if (!isDeletable(item)) continue;
@ -154,7 +158,7 @@ void RicDeleteItemFeature::onActionTriggered(bool isChecked)
int indexAfter = -1;
std::vector<PdmObjectHandle*> childObjects;
std::vector<caf::PdmObjectHandle*> childObjects;
childArrayFieldHandle->childObjects(&childObjects);
for ( size_t i = 0; i < childObjects.size(); i++ )
@ -168,15 +172,15 @@ void RicDeleteItemFeature::onActionTriggered(bool isChecked)
// Did not find currently selected pdm object in the current list field
assert(indexAfter != -1);
RicDeleteItemExec* executeCmd = new RicDeleteItemExec(SelectionManager::instance()->notificationCenter());
RicDeleteItemExec* executeCmd = new RicDeleteItemExec(caf::SelectionManager::instance()->notificationCenter());
RicDeleteItemExecData* data = executeCmd->commandData();
data->m_rootObject = PdmReferenceHelper::findRoot(childArrayFieldHandle);
data->m_pathToField = PdmReferenceHelper::referenceFromRootToField(data->m_rootObject, childArrayFieldHandle);
data->m_rootObject = caf::PdmReferenceHelper::findRoot(childArrayFieldHandle);
data->m_pathToField = caf::PdmReferenceHelper::referenceFromRootToField(data->m_rootObject, childArrayFieldHandle);
data->m_indexToObject = indexAfter;
CmdExecCommandManager::instance()->processExecuteCommand(executeCmd);
caf::CmdExecCommandManager::instance()->processExecuteCommand(executeCmd);
}
}
@ -188,5 +192,3 @@ void RicDeleteItemFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setText("Delete");
actionToSetup->setIcon(QIcon(":/Erase.png"));
}
} // end namespace caf

View File

@ -21,23 +21,16 @@
#include "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class RicDeleteItemFeature : public CmdFeature
class RicDeleteItemFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};
} // end namespace caf

View File

@ -95,8 +95,8 @@ void RicExportMultipleSnapshotsFeature::onActionTriggered(bool isChecked)
//--------------------------------------------------------------------------------------------------
void RicExportMultipleSnapshotsFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Export Multiple Snapshots ...");
//actionToSetup->setIcon(QIcon(":/Save.png"));
actionToSetup->setText("Advanced Snapshot Export ...");
actionToSetup->setIcon(QIcon(":/SnapShotSaveViews.png"));
}
//--------------------------------------------------------------------------------------------------

View File

@ -121,7 +121,7 @@ void RicExportToLasFileResampleUi::defineEditorAttribute(const caf::PdmFieldHand
{
if (field == &exportFolder)
{
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectDirectory = true;
@ -130,7 +130,7 @@ void RicExportToLasFileResampleUi::defineEditorAttribute(const caf::PdmFieldHand
if (field == &exportTvdrkb || field == &activateResample)
{
caf::PdmUiCheckBoxEditorAttribute* myAttr = static_cast<caf::PdmUiCheckBoxEditorAttribute*>(attribute);
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_useNativeCheckBoxLabel = true;

View File

@ -0,0 +1,122 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicFlyToObjectFeature.h"
#include "RiaApplication.h"
#include "Rim3dPropertiesInterface.h"
#include "RimView.h"
#include "RiuViewer.h"
#include "cafDisplayCoordTransform.h"
#include "cafPdmObject.h"
#include "cafSelectionManager.h"
#include "cvfCamera.h"
#include <QAction>
#include <algorithm>
CAF_CMD_SOURCE_INIT(RicFlyToObjectFeature, "RicFlyToObjectFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicFlyToObjectFeature::isCommandEnabled()
{
if (RicFlyToObjectFeature::boundingBoxForSelectedObjects().isValid())
{
return true;
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicFlyToObjectFeature::onActionTriggered(bool isChecked)
{
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return;
RiuViewer* destinationViewer = activeView->viewer();
if (!destinationViewer) return;
cvf::BoundingBox bb = RicFlyToObjectFeature::boundingBoxForSelectedObjects();
CVF_ASSERT(bb.isValid());
cvf::ref<caf::DisplayCoordTransform> transForm = activeView->displayCoordTransform();
cvf::Vec3d centerInDisplayCoords = transForm->transformToDisplayCoord(bb.center());
cvf::Vec3d directionNormalToLargesExtent = cvf::Vec3d::X_AXIS;
double largesExtent = fabs(bb.extent().y());
if (fabs(bb.extent().x()) > largesExtent)
{
largesExtent = fabs(bb.extent().x());
directionNormalToLargesExtent = cvf::Vec3d::Y_AXIS;
}
cvf::Vec3d cameraEye = centerInDisplayCoords + directionNormalToLargesExtent * std::max(largesExtent, 30.0);
cvf::Vec3d cameraViewRefPoint = centerInDisplayCoords;
cvf::Vec3d cameraUp = cvf::Vec3d::Z_AXIS;
destinationViewer->mainCamera()->setFromLookAt(cameraEye, cameraViewRefPoint, cameraUp);
destinationViewer->setPointOfInterest(cameraViewRefPoint);
activeView->updateCurrentTimeStepAndRedraw();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicFlyToObjectFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Fly to Object");
//actionToSetup->setIcon(QIcon(":/3DView16x16.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RicFlyToObjectFeature::boundingBoxForSelectedObjects()
{
cvf::BoundingBox bb;
std::vector<Rim3dPropertiesInterface*> objects;
caf::SelectionManager::instance()->objectsByType(&objects);
for (auto obj : objects)
{
if (obj)
{
bb.add(obj->boundingBoxInDomainCoords());
}
}
return bb;
}

View File

@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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"
#include "cvfBoundingBox.h"
namespace caf {
class PdmObject;
}
//==================================================================================================
///
//==================================================================================================
class RicFlyToObjectFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
virtual void onActionTriggered( bool isChecked ) override;
virtual bool isCommandEnabled() override;
virtual void setupActionLook( QAction* actionToSetup ) override;
private:
static cvf::BoundingBox boundingBoxForSelectedObjects();
};

View File

@ -19,6 +19,7 @@
#include "RicImportSummaryCaseFeature.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RimGridSummaryCase.h"
#include "RimMainPlotCollection.h"
@ -102,10 +103,14 @@ bool RicImportSummaryCaseFeature::createAndAddSummaryCaseFromFile(const QString&
RimSummaryCase* newSumCase = sumCaseColl->createAndAddSummaryCaseFromFileName(fileName);
newSumCase->loadCase();
RimMainPlotCollection* mainPlotColl = proj->mainPlotCollection();
RimSummaryPlotCollection* summaryPlotColl = mainPlotColl->summaryPlotCollection();
RicNewSummaryPlotFeature::createNewSummaryPlot(summaryPlotColl, newSumCase);
if (app->preferences()->autoCreatePlotsOnImport())
{
RimMainPlotCollection* mainPlotColl = proj->mainPlotCollection();
RimSummaryPlotCollection* summaryPlotColl = mainPlotColl->summaryPlotCollection();
RicNewSummaryPlotFeature::createNewSummaryPlot(summaryPlotColl, newSumCase);
}
sumCaseColl->updateConnectedEditors();
app->addToRecentFiles(fileName);

View File

@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicReloadCaseFeature.h"
#include "RimEclipseCase.h"
#include "cafPdmObject.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicReloadCaseFeature, "RicReloadCaseFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicReloadCaseFeature::isCommandEnabled()
{
std::vector<caf::PdmObject*> selectedFormationNamesCollObjs;
caf::SelectionManager::instance()->objectsByType(&selectedFormationNamesCollObjs);
for (caf::PdmObject* pdmObject : selectedFormationNamesCollObjs) {
if (dynamic_cast<RimEclipseCase*>(pdmObject))
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicReloadCaseFeature::onActionTriggered(bool isChecked)
{
std::vector<RimEclipseCase*> selectedEclipseCases;
caf::SelectionManager::instance()->objectsByType(&selectedEclipseCases);
for (RimEclipseCase* selectedCase : selectedEclipseCases)
{
selectedCase->reloadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicReloadCaseFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Reload");
actionToSetup->setIcon(QIcon(":/Refresh-32.png"));
}

View File

@ -0,0 +1,32 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
class RicReloadCaseFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
virtual bool isCommandEnabled();
virtual void onActionTriggered(bool isChecked);
virtual void setupActionLook(QAction* actionToSetup);
};

View File

@ -278,6 +278,6 @@ void RicSnapshotAllPlotsToFileFeature::onActionTriggered(bool isChecked)
void RicSnapshotAllPlotsToFileFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Snapshot All Plots To File");
actionToSetup->setIcon(QIcon(":/SnapShotSave.png"));
actionToSetup->setIcon(QIcon(":/SnapShotSaveViews.png"));
}

View File

@ -95,7 +95,7 @@ void RicAsciiExportSummaryPlotFeature::onActionTriggered(bool isChecked)
bool writeFiles = caf::Utils::getSaveDirectoryAndCheckOverwriteFiles(defaultDir, fileNames, &saveDir);
if (!writeFiles) return;
RiaLogging::debug(QString("Writing to directory %1").arg(saveDir));
RiaLogging::info(QString("Writing to directory %1").arg(saveDir));
for (RimSummaryPlot* summaryPlot : selectedSummaryPlots)
{
QString fileName = saveDir + "/" + caf::Utils::makeValidFileBasename(summaryPlot->description()) + ".ascii";

View File

@ -216,6 +216,15 @@ bool RicNewGridTimeHistoryCurveFeature::isCommandEnabled()
if (items.size() > 0)
{
const RiuEclipseSelectionItem* eclSelectionItem = dynamic_cast<const RiuEclipseSelectionItem*>(items[0]);
if (eclSelectionItem)
{
if (eclSelectionItem->m_view->cellResult()->resultType() == RimDefines::FLOW_DIAGNOSTICS)
{
return false;
}
}
return true;
}

View File

@ -19,14 +19,11 @@
#include "RicToggleItemsFeature.h"
#include "cafSelectionManager.h"
#include "RicToggleItemsFeatureImpl.h"
#include <QAction>
#include "cafSelectionManager.h"
namespace caf
{
#include <QAction>
CAF_CMD_SOURCE_INIT(RicToggleItemsFeature, "RicToggleItemsFeature");
@ -56,5 +53,3 @@ void RicToggleItemsFeature::setupActionLook(QAction* actionToSetup)
else
actionToSetup->setText("Toggle");
}
} // end namespace caf

View File

@ -21,23 +21,16 @@
#include "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class RicToggleItemsFeature : public CmdFeature
class RicToggleItemsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};
} // end namespace caf

View File

@ -19,14 +19,11 @@
#include "RicToggleItemsOffFeature.h"
#include "cafSelectionManager.h"
#include "RicToggleItemsFeatureImpl.h"
#include <QAction>
#include "cafSelectionManager.h"
namespace caf
{
#include <QAction>
CAF_CMD_SOURCE_INIT(RicToggleItemsOffFeature, "RicToggleItemsOffFeature");
@ -56,5 +53,3 @@ void RicToggleItemsOffFeature::setupActionLook(QAction* actionToSetup)
else
actionToSetup->setText("Off");
}
} // end namespace caf

View File

@ -21,23 +21,16 @@
#include "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class RicToggleItemsOffFeature : public CmdFeature
class RicToggleItemsOffFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};
} // end namespace caf

View File

@ -19,14 +19,11 @@
#include "RicToggleItemsOnFeature.h"
#include "cafSelectionManager.h"
#include "RicToggleItemsFeatureImpl.h"
#include <QAction>
#include "cafSelectionManager.h"
namespace caf
{
#include <QAction>
CAF_CMD_SOURCE_INIT(RicToggleItemsOnFeature, "RicToggleItemsOnFeature");
@ -56,5 +53,3 @@ void RicToggleItemsOnFeature::setupActionLook(QAction* actionToSetup)
else
actionToSetup->setText("On");
}
} // end namespace caf

View File

@ -21,23 +21,16 @@
#include "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class RicToggleItemsOnFeature : public CmdFeature
class RicToggleItemsOnFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};
} // end namespace caf

View File

@ -43,9 +43,7 @@
#include <QAction>
namespace caf
{
CAF_CMD_SOURCE_INIT(RicAddWellLogToPlotFeature, "RicAddWellLogToPlotFeature");
CAF_CMD_SOURCE_INIT(RicAddWellLogToPlotFeature, "RicAddWellLogToPlotFeature");
//--------------------------------------------------------------------------------------------------
@ -135,5 +133,3 @@ std::vector<RimWellLogFileChannel*> RicAddWellLogToPlotFeature::selectedWellLogs
caf::SelectionManager::instance()->objectsByType(&selection);
return selection;
}
} // end namespace caf

View File

@ -28,26 +28,20 @@ class RimWellLogPlotCollection;
class RimWellLogPlot;
class RimWellLogFileChannel;
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class RicAddWellLogToPlotFeature : public CmdFeature
class RicAddWellLogToPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
private:
std::vector<RimWellLogFileChannel*> selectedWellLogs();
};
} // end namespace caf

View File

@ -93,7 +93,7 @@ void RicAsciiExportWellLogPlotFeature::onActionTriggered(bool isChecked)
bool writeFiles = caf::Utils::getSaveDirectoryAndCheckOverwriteFiles(defaultDir, fileNames, &saveDir);
if (!writeFiles) return;
RiaLogging::debug(QString("Writing to directory %!").arg(saveDir));
RiaLogging::info(QString("Writing to directory %!").arg(saveDir));
for (RimWellLogPlot* wellLogPlot : selectedWellLogPlots)
{
QString fileName = saveDir + "/" + caf::Utils::makeValidFileBasename(wellLogPlot->description()) + ".ascii";

View File

@ -41,6 +41,8 @@
#include <QAction>
#include <vector>
#include "RimEclipseWell.h"
#include "RiuSelectionManager.h"
CAF_CMD_SOURCE_INIT(RicNewWellLogCurveExtractionFeature, "RicNewWellLogCurveExtractionFeature");
@ -51,8 +53,8 @@ CAF_CMD_SOURCE_INIT(RicNewWellLogCurveExtractionFeature, "RicNewWellLogCurveExtr
bool RicNewWellLogCurveExtractionFeature::isCommandEnabled()
{
if (RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot()) return false;
return (selectedWellLogPlotTrack() != NULL || selectedWellPath() != NULL) && caseAvailable();
int branchIndex;
return (selectedWellLogPlotTrack() != nullptr || selectedWellPath() != nullptr || selectedSimulationWell(&branchIndex) != nullptr) && caseAvailable();
}
//--------------------------------------------------------------------------------------------------
@ -65,15 +67,17 @@ void RicNewWellLogCurveExtractionFeature::onActionTriggered(bool isChecked)
RimWellLogTrack* wellLogPlotTrack = selectedWellLogPlotTrack();
if (wellLogPlotTrack)
{
addCurve(wellLogPlotTrack, NULL, NULL);
addCurve(wellLogPlotTrack, NULL, NULL, nullptr, -1);
}
else
{
RimWellPath* wellPath = selectedWellPath();
if (wellPath)
int branchIndex = -1;
RimEclipseWell* simWell = selectedSimulationWell(&branchIndex);
if (wellPath || simWell)
{
RimWellLogTrack* wellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RimWellLogExtractionCurve* plotCurve = addCurve(wellLogPlotTrack, RiaApplication::instance()->activeReservoirView(), wellPath);
RimWellLogExtractionCurve* plotCurve = addCurve(wellLogPlotTrack, RiaApplication::instance()->activeReservoirView(), wellPath, simWell, branchIndex);
plotCurve->loadDataAndUpdate();
@ -118,6 +122,27 @@ RimWellPath* RicNewWellLogCurveExtractionFeature::selectedWellPath() const
return selection.size() > 0 ? selection[0] : NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseWell* RicNewWellLogCurveExtractionFeature::selectedSimulationWell(int * branchIndex) const
{
RiuSelectionItem* selItem = RiuSelectionManager::instance()->selectedItem(RiuSelectionManager::RUI_TEMPORARY);
RiuSimWellSelectionItem* simWellSelItem = dynamic_cast<RiuSimWellSelectionItem*>(selItem);
if (simWellSelItem)
{
(*branchIndex) = static_cast<int>(simWellSelItem->m_branchIndex);
return simWellSelItem->m_simWell;
}
else
{
std::vector<RimEclipseWell*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
(*branchIndex) = 0;
return selection.size() > 0 ? selection[0] : NULL;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -132,14 +157,16 @@ bool RicNewWellLogCurveExtractionFeature::caseAvailable() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogExtractionCurve* RicNewWellLogCurveExtractionFeature::addCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath)
RimWellLogExtractionCurve* RicNewWellLogCurveExtractionFeature::addCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath, const RimEclipseWell* simWell, int branchIndex)
{
CVF_ASSERT(plotTrack);
RimWellLogExtractionCurve* curve = new RimWellLogExtractionCurve();
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(plotTrack->curveCount());
curve->setColor(curveColor);
curve->setWellPath(wellPath);
if (wellPath) curve->setWellPath(wellPath);
if (simWell) curve->setFromSimulationWellName(simWell->name(), branchIndex);
curve->setPropertiesFromView(view);
plotTrack->addCurve(curve);

View File

@ -21,10 +21,11 @@
#include "cafCmdFeature.h"
class RimEclipseWell;
class RimView;
class RimWellLogExtractionCurve;
class RimWellLogTrack;
class RimWellPath;
class RimView;
//==================================================================================================
///
@ -34,7 +35,7 @@ class RicNewWellLogCurveExtractionFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
public:
static RimWellLogExtractionCurve* addCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath);
static RimWellLogExtractionCurve* addCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath, const RimEclipseWell* simWell, int branchIndex);
protected:
@ -46,5 +47,6 @@ protected:
private:
RimWellLogTrack* selectedWellLogPlotTrack() const;
RimWellPath* selectedWellPath() const;
RimEclipseWell* selectedSimulationWell(int * branchIndex) const;
bool caseAvailable() const;
};

View File

@ -51,7 +51,7 @@ bool RicNewWellLogPlotFeature::isCommandEnabled()
void RicNewWellLogPlotFeature::onActionTriggered(bool isChecked)
{
RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RicNewWellLogCurveExtractionFeature::addCurve(plotTrack, NULL, NULL);
RicNewWellLogCurveExtractionFeature::addCurve(plotTrack, NULL, NULL, nullptr, -1);
}
//--------------------------------------------------------------------------------------------------

View File

@ -57,7 +57,7 @@ void RicNewWellLogPlotTrackFeature::onActionTriggered(bool isChecked)
plotTrack->setDescription(QString("Track %1").arg(wellLogPlot->trackCount()));
wellLogPlot->updateConnectedEditors();
RicNewWellLogCurveExtractionFeature::addCurve(plotTrack, NULL, NULL);
RicNewWellLogCurveExtractionFeature::addCurve(plotTrack, NULL, NULL, nullptr, -1);
}
}

View File

@ -26,10 +26,7 @@
#include <QAction>
#include <QFileDialog>
namespace caf
{
CAF_CMD_SOURCE_INIT(RicWellLogsImportFileFeature, "RicWellLogsImportFileFeature");
CAF_CMD_SOURCE_INIT(RicWellLogsImportFileFeature, "RicWellLogsImportFileFeature");
//--------------------------------------------------------------------------------------------------
///
@ -65,5 +62,3 @@ void RicWellLogsImportFileFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setText("Import Well &Logs from File");
actionToSetup->setIcon(QIcon(":/LasFile16x16.png"));
}
} // end namespace caf

View File

@ -21,23 +21,17 @@
#include "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class RicWellLogsImportFileFeature : public CmdFeature
class RicWellLogsImportFileFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};
} // end namespace caf

View File

@ -6,6 +6,8 @@ endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.h
@ -13,6 +15,8 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.h
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.cpp

View File

@ -20,19 +20,14 @@
#include "RicWellPathDeleteFeature.h"
#include "RimWellPathCollection.h"
#include "RimWellPath.h"
#include "cafSelectionManager.h"
#include <QAction>
#include "RimWellPath.h"
namespace caf
{
CAF_CMD_SOURCE_INIT(RicWellPathDeleteFeature, "RicWellPathDeleteFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -83,5 +78,3 @@ void RicWellPathDeleteFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setText("Delete Well Path(s)");
actionToSetup->setIcon(QIcon(":/Erase.png"));
}
} // end namespace caf

View File

@ -21,23 +21,16 @@
#include "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class RicWellPathDeleteFeature : public CmdFeature
class RicWellPathDeleteFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};
} // end namespace caf

View File

@ -0,0 +1,898 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicWellPathExportCompletionDataFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimFishbonesCollection.h"
#include "RimExportCompletionDataSettings.h"
#include "RiuMainWindow.h"
#include "RigWellLogExtractionTools.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RigWellPath.h"
#include "cafSelectionManager.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cvfPlane.h"
#include <QAction>
#include <QFileDialog>
#include <QMessageBox>
CAF_CMD_SOURCE_INIT(RicWellPathExportCompletionDataFeature, "RicWellPathExportCompletionDataFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicWellPathExportCompletionDataFeature::isCommandEnabled()
{
std::vector<RimWellPath*> objects;
caf::SelectionManager::instance()->objectsByType(&objects);
if (objects.size() == 1) {
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked)
{
std::vector<RimWellPath*> objects;
caf::SelectionManager::instance()->objectsByType(&objects);
CVF_ASSERT(objects.size() == 1);
RiaApplication* app = RiaApplication::instance();
QString projectFolder = app->currentProjectPath();
QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder);
RimExportCompletionDataSettings exportSettings;
std::vector<RimCase*> cases;
app->project()->allCases(cases);
for (auto c : cases)
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(c);
if (eclipseCase != nullptr)
{
exportSettings.caseToApply = eclipseCase;
break;
}
}
exportSettings.fileName = QDir(defaultDir).filePath("Completions");
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Completion Data", "");
if (propertyDialog.exec() == QDialog::Accepted)
{
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.fileName).absolutePath());
exportToFolder(objects[0], exportSettings);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Export Completion Data");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::exportToFolder(RimWellPath* wellPath, const RimExportCompletionDataSettings& exportSettings)
{
QFile exportFile(exportSettings.fileName());
if (exportSettings.caseToApply() == nullptr)
{
RiaLogging::error("Export Completions Data: Cannot export completions data without specified eclipse case");
return;
}
if (!exportFile.open(QIODevice::WriteOnly))
{
RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(exportSettings.fileName()));
return;
}
RiaLogging::debug(QString("Exporting completion data for well path %1 to %2 [WPIMULT: %3, REM BORE CELLS: %4]").arg(wellPath->name).arg(exportSettings.fileName()).arg(exportSettings.includeWpimult()).arg(exportSettings.removeLateralsInMainBoreCells()));
// Generate data
const RigEclipseCaseData* caseData = exportSettings.caseToApply()->eclipseCaseData();
std::vector<WellSegmentLocation> wellSegmentLocations = findWellSegmentLocations(exportSettings.caseToApply, wellPath);
// Filter out cells where main bore is present
if (exportSettings.removeLateralsInMainBoreCells())
{
std::vector<size_t> wellPathCells = findIntersectingCells(caseData, wellPath->wellPathGeometry()->m_wellPathPoints);
markWellPathCells(wellPathCells, &wellSegmentLocations);
}
// Print data
QTextStream stream(&exportFile);
RifEclipseOutputTableFormatter formatter(stream);
generateCompdatTable(formatter, wellPath, exportSettings, wellSegmentLocations);
if (exportSettings.includeWpimult())
{
std::map<size_t, double> lateralsPerCell = computeLateralsPerCell(wellSegmentLocations, exportSettings.removeLateralsInMainBoreCells());
generateWpimultTable(formatter, wellPath, exportSettings, lateralsPerCell);
}
generateWelsegsTable(formatter, wellPath, exportSettings, wellSegmentLocations);
generateCompsegsTable(formatter, wellPath, exportSettings, wellSegmentLocations);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseOutputTableFormatter& formatter, const RimWellPath* wellPath, const RimExportCompletionDataSettings& settings, const std::vector<WellSegmentLocation>& locations)
{
RigMainGrid* grid = settings.caseToApply->eclipseCaseData()->mainGrid();
std::vector<RifEclipseOutputTableColumn> header = {
RifEclipseOutputTableColumn("Well"),
RifEclipseOutputTableColumn("I"),
RifEclipseOutputTableColumn("J"),
RifEclipseOutputTableColumn("K1"),
RifEclipseOutputTableColumn("K2"),
RifEclipseOutputTableColumn("Status"),
RifEclipseOutputTableColumn("SAT"),
RifEclipseOutputTableColumn("TR"),
RifEclipseOutputTableColumn("DIAM"),
RifEclipseOutputTableColumn("KH"),
RifEclipseOutputTableColumn("S"),
RifEclipseOutputTableColumn("Df"),
RifEclipseOutputTableColumn("DIR"),
RifEclipseOutputTableColumn("r0")
};
formatter.keyword("COMPDAT");
formatter.header(header);
for (const WellSegmentLocation& location : locations)
{
for (const WellSegmentLateral& lateral : location.laterals)
{
formatter.comment(QString("Fishbone %1 - Sub: %2 - Lateral: %3").arg(location.fishbonesSubs->name()).arg(location.subIndex).arg(lateral.lateralIndex));
for (const WellSegmentLateralIntersection& intersection : lateral.intersections)
{
if (settings.removeLateralsInMainBoreCells && intersection.mainBoreCell) continue;
size_t i, j, k;
grid->ijkFromCellIndex(intersection.cellIndex, &i, &j, &k);
formatter.add(wellPath->name());
formatter.addZeroBasedCellIndex(i).addZeroBasedCellIndex(j).addZeroBasedCellIndex(k).addZeroBasedCellIndex(k);
formatter.add("'OPEN'").add("1*").add("1*");
formatter.add(location.fishbonesSubs->holeRadius() / 1000);
formatter.add("1*").add("1*").add("1*");
switch (intersection.direction)
{
case POS_I:
case NEG_I:
formatter.add("'X'");
break;
case POS_J:
case NEG_J:
formatter.add("'Y'");
break;
case POS_K:
case NEG_K:
formatter.add("'Z'");
break;
}
formatter.add("1*");
formatter.rowCompleted();
}
}
}
formatter.tableCompleted();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::generateWpimultTable(RifEclipseOutputTableFormatter& formatter, const RimWellPath* wellPath, const RimExportCompletionDataSettings& settings, const std::map<size_t, double>& lateralsPerCell)
{
RigMainGrid* grid = settings.caseToApply->eclipseCaseData()->mainGrid();
std::vector<RifEclipseOutputTableColumn> header = {
RifEclipseOutputTableColumn("Well"),
RifEclipseOutputTableColumn("Mult"),
RifEclipseOutputTableColumn("I"),
RifEclipseOutputTableColumn("J"),
RifEclipseOutputTableColumn("K"),
};
formatter.keyword("WPIMULT");
formatter.header(header);
for (auto lateralsInCell : lateralsPerCell)
{
size_t i, j, k;
grid->ijkFromCellIndex(lateralsInCell.first, &i, &j, &k);
formatter.add(wellPath->name());
formatter.add(lateralsInCell.second);
formatter.addZeroBasedCellIndex(i).addZeroBasedCellIndex(j).addZeroBasedCellIndex(k);
formatter.rowCompleted();
}
formatter.tableCompleted();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::generateWelsegsTable(RifEclipseOutputTableFormatter& formatter, const RimWellPath* wellPath, const RimExportCompletionDataSettings& settings, const std::vector<WellSegmentLocation>& locations)
{
formatter.keyword("WELSEGS");
const WellSegmentLocation& firstLocation = locations[0];
{
std::vector<RifEclipseOutputTableColumn> header = {
RifEclipseOutputTableColumn("Name"),
RifEclipseOutputTableColumn("Dep 1"),
RifEclipseOutputTableColumn("Tlen 1"),
RifEclipseOutputTableColumn("Vol 1"),
RifEclipseOutputTableColumn("Len&Dep"),
RifEclipseOutputTableColumn("PresDrop"),
};
formatter.header(header);
formatter.add(wellPath->name());
formatter.add(firstLocation.trueVerticalDepth);
formatter.add(firstLocation.measuredDepth);
formatter.add("1*");
formatter.add("INC");
formatter.add("H--");
formatter.rowCompleted();
}
{
std::vector<RifEclipseOutputTableColumn> header = {
RifEclipseOutputTableColumn("First Seg"),
RifEclipseOutputTableColumn("Last Seg"),
RifEclipseOutputTableColumn("Branch Num"),
RifEclipseOutputTableColumn("Outlet Seg"),
RifEclipseOutputTableColumn("Length"),
RifEclipseOutputTableColumn("Depth Change"),
RifEclipseOutputTableColumn("Diam"),
RifEclipseOutputTableColumn("Rough"),
};
formatter.header(header);
}
{
WellSegmentLocation previousLocation = firstLocation;
formatter.comment("Main stem");
for (size_t i = 0; i < locations.size(); ++i)
{
const WellSegmentLocation& location = locations[i];
formatter.comment(QString("Segment for sub %1").arg(location.subIndex));
formatter.add(location.segmentNumber).add(location.segmentNumber);
formatter.add(1); // All segments on main stem are branch 1
formatter.add(location.segmentNumber - 1); // All main stem segments are connected to the segment below them
formatter.add(location.fishbonesSubs->locationOfSubs()[location.subIndex] - previousLocation.fishbonesSubs->locationOfSubs()[previousLocation.subIndex]);
formatter.add(location.trueVerticalDepth - previousLocation.trueVerticalDepth);
formatter.add(-1.0); // FIXME : Diam of main stem?
formatter.add(-1.0); // FIXME : Rough of main stem?
formatter.rowCompleted();
previousLocation = location;
}
}
{
formatter.comment("Laterals");
formatter.comment("Diam: MSW - Tubing Radius");
formatter.comment("Rough: MSW - Open Hole Roughness Factor");
for (const WellSegmentLocation& location : locations)
{
for (const WellSegmentLateral& lateral : location.laterals)
{
formatter.comment(QString("%1 : Sub index %2 - Lateral %3").arg(location.fishbonesSubs->name()).arg(location.subIndex).arg(lateral.lateralIndex));
for (const WellSegmentLateralIntersection& intersection : lateral.intersections)
{
formatter.add(intersection.segmentNumber);
formatter.add(intersection.segmentNumber);
formatter.add(lateral.branchNumber);
formatter.add(intersection.attachedSegmentNumber);
formatter.add(intersection.length);
formatter.add(intersection.depth);
formatter.add(location.fishbonesSubs->tubingRadius());
formatter.add(location.fishbonesSubs->openHoleRoughnessFactor());
formatter.rowCompleted();
}
}
}
}
formatter.tableCompleted();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::generateCompsegsTable(RifEclipseOutputTableFormatter& formatter, const RimWellPath* wellPath, const RimExportCompletionDataSettings& settings, const std::vector<WellSegmentLocation>& locations)
{
RigMainGrid* grid = settings.caseToApply->eclipseCaseData()->mainGrid();
formatter.keyword("COMPSEGS");
{
std::vector<RifEclipseOutputTableColumn> header = {
RifEclipseOutputTableColumn("Name")
};
formatter.header(header);
formatter.add(wellPath->name());
formatter.rowCompleted();
}
{
std::vector<RifEclipseOutputTableColumn> header = {
RifEclipseOutputTableColumn("I"),
RifEclipseOutputTableColumn("J"),
RifEclipseOutputTableColumn("K"),
RifEclipseOutputTableColumn("Branch no"),
RifEclipseOutputTableColumn("Start Length"),
RifEclipseOutputTableColumn("End Length"),
RifEclipseOutputTableColumn("Dir Pen"),
RifEclipseOutputTableColumn("End Range"),
RifEclipseOutputTableColumn("Connection Depth")
};
formatter.header(header);
}
for (const WellSegmentLocation& location : locations)
{
for (const WellSegmentLateral& lateral : location.laterals)
{
double length = 0;
for (const WellSegmentLateralIntersection& intersection : lateral.intersections)
{
length += intersection.length;
if (settings.removeLateralsInMainBoreCells && intersection.mainBoreCell) continue;
size_t i, j, k;
grid->ijkFromCellIndex(intersection.cellIndex, &i, &j, &k);
formatter.addZeroBasedCellIndex(i).addZeroBasedCellIndex(j).addZeroBasedCellIndex(k);
formatter.add(lateral.branchNumber);
formatter.add(length);
formatter.add("1*");
switch (intersection.direction)
{
case POS_I:
case NEG_I:
formatter.add("I");
break;
case POS_J:
case NEG_J:
formatter.add("J");
break;
case POS_K:
case NEG_K:
formatter.add("K");
break;
}
formatter.add(-1);
formatter.rowCompleted();
}
}
}
formatter.tableCompleted();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<size_t> RicWellPathExportCompletionDataFeature::findCloseCells(const RigEclipseCaseData* caseData, const cvf::BoundingBox& bb)
{
std::vector<size_t> closeCells;
caseData->mainGrid()->findIntersectingCells(bb, &closeCells);
return closeCells;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<EclipseCellIndexRange> RicWellPathExportCompletionDataFeature::getCellIndexRange(const RigMainGrid* grid, const std::vector<size_t>& cellIndices)
{
// Retrieve I, J, K indices
std::vector<EclipseCellIndex> eclipseCellIndices;
for (auto cellIndex : cellIndices)
{
size_t i, j, k;
if (!grid->ijkFromCellIndex(cellIndex, &i, &j, &k)) continue;
eclipseCellIndices.push_back(std::make_tuple(i, j, k));
}
// Group cell indices in K-ranges
std::sort(eclipseCellIndices.begin(), eclipseCellIndices.end(), RicWellPathExportCompletionDataFeature::cellOrdering);
std::vector<EclipseCellIndexRange> eclipseCellRanges;
size_t lastI = std::numeric_limits<size_t>::max();
size_t lastJ = std::numeric_limits<size_t>::max();
size_t lastK = std::numeric_limits<size_t>::max();
size_t startK = std::numeric_limits<size_t>::max();
for (EclipseCellIndex cell : eclipseCellIndices)
{
size_t i, j, k;
std::tie(i, j, k) = cell;
if (i != lastI || j != lastJ || k != lastK + 1)
{
if (startK != std::numeric_limits<size_t>::max())
{
EclipseCellIndexRange cellRange = {lastI, lastJ, startK, lastK};
eclipseCellRanges.push_back(cellRange);
}
lastI = i;
lastJ = j;
lastK = k;
startK = k;
}
else
{
lastK = k;
}
}
// Append last cell range
if (startK != std::numeric_limits<size_t>::max())
{
EclipseCellIndexRange cellRange = {lastI, lastJ, startK, lastK};
eclipseCellRanges.push_back(cellRange);
}
return eclipseCellRanges;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicWellPathExportCompletionDataFeature::cellOrdering(const EclipseCellIndex& cell1, const EclipseCellIndex& cell2)
{
size_t i1, i2, j1, j2, k1, k2;
std::tie(i1, j1, k1) = cell1;
std::tie(i2, j2, k2) = cell2;
if (i1 == i2)
{
if (j1 == j2)
{
return k1 < k2;
}
else
{
return j1 < j2;
}
}
else
{
return i1 < i2;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RicWellPathExportCompletionDataFeature::findCellFromCoords(const RigEclipseCaseData* caseData, const cvf::Vec3d& coords)
{
const std::vector<cvf::Vec3d>& nodeCoords = caseData->mainGrid()->nodes();
cvf::BoundingBox bb;
bb.add(coords);
std::vector<size_t> closeCells = findCloseCells(caseData, bb);
cvf::Vec3d hexCorners[8];
for (size_t closeCell : closeCells)
{
const RigCell& cell = caseData->mainGrid()->globalCellArray()[closeCell];
if (cell.isInvalid()) continue;
setHexCorners(cell, nodeCoords, hexCorners);
if (RigHexIntersector::isPointInCell(coords, hexCorners, closeCell))
{
return closeCell;
}
}
// Coordinate is outside any cells?
CVF_ASSERT(false);
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<size_t> RicWellPathExportCompletionDataFeature::findIntersectingCells(const RigEclipseCaseData* caseData, const std::vector<cvf::Vec3d>& coords)
{
const std::vector<cvf::Vec3d>& nodeCoords = caseData->mainGrid()->nodes();
std::set<size_t> cells;
// Find starting cell
if (coords.size() > 0)
{
size_t startCell = findCellFromCoords(caseData, coords[0]);
if (startCell > 0)
{
cells.insert(startCell);
}
}
std::vector<HexIntersectionInfo> intersections = findIntersections(caseData, coords);
for (auto intersection : intersections)
{
cells.insert(intersection.m_hexIndex);
}
// Ensure only unique cells are included
std::vector<size_t> cellsVector;
cellsVector.assign(cells.begin(), cells.end());
// Sort cells
std::sort(cellsVector.begin(), cellsVector.end());
return cellsVector;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<HexIntersectionInfo> RicWellPathExportCompletionDataFeature::findIntersections(const RigEclipseCaseData* caseData, const std::vector<cvf::Vec3d>& coords)
{
const std::vector<cvf::Vec3d>& nodeCoords = caseData->mainGrid()->nodes();
std::vector<HexIntersectionInfo> intersections;
for (size_t i = 0; i < coords.size() - 1; ++i)
{
cvf::BoundingBox bb;
bb.add(coords[i]);
bb.add(coords[i + 1]);
std::vector<size_t> closeCells = findCloseCells(caseData, bb);
cvf::Vec3d hexCorners[8];
for (size_t closeCell : closeCells)
{
const RigCell& cell = caseData->mainGrid()->globalCellArray()[closeCell];
if (cell.isInvalid()) continue;
setHexCorners(cell, nodeCoords, hexCorners);
RigHexIntersector::lineHexCellIntersection(coords[i], coords[i + 1], hexCorners, closeCell, &intersections);
}
}
return intersections;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::setHexCorners(const RigCell& cell, const std::vector<cvf::Vec3d>& nodeCoords, cvf::Vec3d* hexCorners)
{
const caf::SizeTArray8& cornerIndices = cell.cornerIndices();
hexCorners[0] = nodeCoords[cornerIndices[0]];
hexCorners[1] = nodeCoords[cornerIndices[1]];
hexCorners[2] = nodeCoords[cornerIndices[2]];
hexCorners[3] = nodeCoords[cornerIndices[3]];
hexCorners[4] = nodeCoords[cornerIndices[4]];
hexCorners[5] = nodeCoords[cornerIndices[5]];
hexCorners[6] = nodeCoords[cornerIndices[6]];
hexCorners[7] = nodeCoords[cornerIndices[7]];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::markWellPathCells(const std::vector<size_t>& wellPathCells, std::vector<WellSegmentLocation>* locations)
{
std::set<size_t> wellPathCellSet(wellPathCells.begin(), wellPathCells.end());
for (WellSegmentLocation& location : *locations)
{
for (WellSegmentLateral& lateral : location.laterals)
{
for (WellSegmentLateralIntersection& intersection : lateral.intersections)
{
if (wellPathCellSet.find(intersection.cellIndex) != wellPathCellSet.end())
{
intersection.mainBoreCell = true;
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<size_t, double> RicWellPathExportCompletionDataFeature::computeLateralsPerCell(const std::vector<WellSegmentLocation>& segmentLocations, bool removeMainBoreCells)
{
std::map<size_t, double> lateralsPerCell;
for (const WellSegmentLocation& location : segmentLocations)
{
for (const WellSegmentLateral& lateral : location.laterals)
{
for (const WellSegmentLateralIntersection& intersection : lateral.intersections)
{
if (removeMainBoreCells && intersection.mainBoreCell) continue;
auto match = lateralsPerCell.find(intersection.cellIndex);
if (match == lateralsPerCell.end())
{
lateralsPerCell[intersection.cellIndex] = 1;
}
else
{
lateralsPerCell[intersection.cellIndex] = match->second + 1;
}
}
}
}
return lateralsPerCell;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicWellPathExportCompletionDataFeature::wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second)
{
return first.measuredDepth < second.measuredDepth;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicWellPathExportCompletionDataFeature::isPointBetween(const cvf::Vec3d& pointA, const cvf::Vec3d& pointB, const cvf::Vec3d& needle)
{
cvf::Plane plane;
plane.setFromPointAndNormal(needle, pointB - pointA);
return plane.side(pointA) != plane.side(pointB);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::filterIntersections(std::vector<HexIntersectionInfo>* intersections)
{
// Erase intersections that are marked as entering
for (auto it = intersections->begin(); it != intersections->end();)
{
if (it->m_isIntersectionEntering)
{
it = intersections->erase(it);
}
else
{
++it;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<WellSegmentLocation> RicWellPathExportCompletionDataFeature::findWellSegmentLocations(const RimEclipseCase* caseToApply, RimWellPath* wellPath)
{
std::vector<WellSegmentLocation> wellSegmentLocations;
for (RimFishbonesMultipleSubs* subs : wellPath->fishbonesCollection()->fishbonesSubs())
{
for (size_t subIndex = 0; subIndex < subs->locationOfSubs().size(); ++subIndex)
{
double measuredDepth = subs->locationOfSubs()[subIndex];
cvf::Vec3d position = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(measuredDepth);
WellSegmentLocation location = WellSegmentLocation(subs, measuredDepth, -position.z(), subIndex);
for (size_t lateralIndex = 0; lateralIndex < subs->lateralLengths().size(); ++lateralIndex)
{
location.laterals.push_back(WellSegmentLateral(lateralIndex));
}
wellSegmentLocations.push_back(location);
}
}
std::sort(wellSegmentLocations.begin(), wellSegmentLocations.end(), wellSegmentLocationOrdering);
assignBranchAndSegmentNumbers(caseToApply, &wellSegmentLocations);
return wellSegmentLocations;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::calculateLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum)
{
for (WellSegmentLateral& lateral : location->laterals)
{
lateral.branchNumber = ++(*branchNum);
std::vector<cvf::Vec3d> coords = location->fishbonesSubs->coordsForLateral(location->subIndex, lateral.lateralIndex);
std::vector<HexIntersectionInfo> intersections = findIntersections(caseToApply->eclipseCaseData(), coords);
filterIntersections(&intersections);
const HexIntersectionInfo* prevIntersection = nullptr;
{
double length = 0;
double depth = 0;
cvf::Vec3d startPoint = coords[0];
auto intersection = intersections.cbegin();
int attachedSegmentNumber = location->segmentNumber;
for (size_t i = 1; i < coords.size() && intersection != intersections.cend(); i++)
{
if (isPointBetween(startPoint, coords[i], intersection->m_intersectionPoint))
{
cvf::Vec3d between = intersection->m_intersectionPoint - startPoint;
length += between.length();
depth += intersection->m_intersectionPoint.z() - startPoint.z();
// Find the direction of the previous cell
if (prevIntersection != nullptr)
{
std::pair<WellSegmentCellDirection, double> direction = calculateDirectionAndDistanceInCell(caseToApply->eclipseCaseData()->mainGrid(), prevIntersection->m_hexIndex, prevIntersection->m_intersectionPoint, intersection->m_intersectionPoint);
WellSegmentLateralIntersection& lateralIntersection = lateral.intersections[lateral.intersections.size() - 1];
lateralIntersection.direction = direction.first;
lateralIntersection.directionLength = direction.second;
}
lateral.intersections.push_back(WellSegmentLateralIntersection(++(*segmentNum), attachedSegmentNumber, intersection->m_hexIndex, length, depth));
length = 0;
depth = 0;
startPoint = intersection->m_intersectionPoint;
attachedSegmentNumber = *segmentNum;
++intersection;
prevIntersection = &*intersection;
}
else
{
const cvf::Vec3d between = coords[i] - startPoint;
length += between.length();
depth += coords[i].z() - startPoint.z();
startPoint = coords[i];
}
}
}
// Find the direction of the last cell
if (prevIntersection != nullptr && !coords.empty())
{
std::pair<WellSegmentCellDirection, double> direction = calculateDirectionAndDistanceInCell(caseToApply->eclipseCaseData()->mainGrid(), prevIntersection->m_hexIndex, prevIntersection->m_intersectionPoint, coords[coords.size()-1]);
WellSegmentLateralIntersection& lateralIntersection = lateral.intersections[lateral.intersections.size() - 1];
lateralIntersection.direction = direction.first;
lateralIntersection.directionLength = direction.second;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::assignBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector<WellSegmentLocation>* locations)
{
int segmentNumber = 1;
int branchNumber = 1;
// First loop over the locations so that each segment on the main stem is an incremental number
for (WellSegmentLocation& location : *locations)
{
location.segmentNumber = ++segmentNumber;
}
// Then assign branch and segment numbers to each lateral parts
for (WellSegmentLocation& location : *locations)
{
calculateLateralIntersections(caseToApply, &location, &branchNumber, &segmentNumber);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::calculateCellMainAxisDirections(const RigMainGrid* grid, size_t cellIndex, cvf::Vec3d* iAxisDirection, cvf::Vec3d* jAxisDirection, cvf::Vec3d* kAxisDirection)
{
const std::vector<cvf::Vec3d>& nodeCoords = grid->nodes();
cvf::Vec3d hexCorners[8];
const RigCell& cell = grid->globalCellArray()[cellIndex];
setHexCorners(cell, nodeCoords, hexCorners);
*iAxisDirection = calculateCellMainAxisDirection(hexCorners, cvf::StructGridInterface::FaceType::NEG_I, cvf::StructGridInterface::POS_I);
*jAxisDirection = calculateCellMainAxisDirection(hexCorners, cvf::StructGridInterface::FaceType::NEG_J, cvf::StructGridInterface::POS_J);
*kAxisDirection = calculateCellMainAxisDirection(hexCorners, cvf::StructGridInterface::FaceType::NEG_K, cvf::StructGridInterface::POS_K);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RicWellPathExportCompletionDataFeature::calculateCellMainAxisDirection(const cvf::Vec3d* hexCorners, cvf::StructGridInterface::FaceType startFace, cvf::StructGridInterface::FaceType endFace)
{
cvf::ubyte faceVertexIndices[4];
cvf::StructGridInterface::cellFaceVertexIndices(startFace, faceVertexIndices);
cvf::Vec3d startFaceCenter = cvf::GeometryTools::computeFaceCenter(hexCorners[faceVertexIndices[0]], hexCorners[faceVertexIndices[1]], hexCorners[faceVertexIndices[2]], hexCorners[faceVertexIndices[3]]);
cvf::StructGridInterface::cellFaceVertexIndices(endFace, faceVertexIndices);
cvf::Vec3d endFaceCenter = cvf::GeometryTools::computeFaceCenter(hexCorners[faceVertexIndices[0]], hexCorners[faceVertexIndices[1]], hexCorners[faceVertexIndices[2]], hexCorners[faceVertexIndices[3]]);
return endFaceCenter - startFaceCenter;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<WellSegmentCellDirection, double> RicWellPathExportCompletionDataFeature::calculateDirectionAndDistanceInCell(const RigMainGrid* grid, size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint)
{
cvf::Vec3d vec = endPoint - startPoint;
cvf::Vec3d iAxisDirection;
cvf::Vec3d jAxisDirection;
cvf::Vec3d kAxisDirection;
calculateCellMainAxisDirections(grid, cellIndex, &iAxisDirection, &jAxisDirection, &kAxisDirection);
double iLength = iAxisDirection.dot(vec);
double jLength = jAxisDirection.dot(vec);
double kLength = kAxisDirection.dot(vec);
double iNormalizedLength = abs(iLength / iAxisDirection.length());
double jNormalizedLength = abs(jLength / jAxisDirection.length());
double kNormalizedLength = abs(kLength / kAxisDirection.length());
if (iNormalizedLength > jNormalizedLength && iNormalizedLength > kNormalizedLength)
{
WellSegmentCellDirection direction = POS_I;
if (iLength < 0)
{
direction = NEG_I;
}
return std::make_pair(direction, iLength);
}
else if (jNormalizedLength > iNormalizedLength && jNormalizedLength > kNormalizedLength)
{
WellSegmentCellDirection direction = POS_J;
if (jLength < 0)
{
direction = NEG_J;
}
return std::make_pair(direction, jLength);
}
else
{
WellSegmentCellDirection direction = POS_K;
if (kLength < 0)
{
direction = NEG_K;
}
return std::make_pair(direction, kLength);
}
}

View File

@ -0,0 +1,166 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RifEclipseOutputTableFormatter.h"
#include "RigWellLogExtractionTools.h"
#include "RimExportCompletionDataSettings.h"
#include "cafCmdFeature.h"
#include "cvfBoundingBox.h"
class RimWellPath;
class RimEclipseCase;
class RigEclipseCaseData;
class RigMainGrid;
class RigCell;
class RimFishbonesMultipleSubs;
//==================================================================================================
///
//==================================================================================================
enum WellSegmentCellDirection {
POS_I,
NEG_I,
POS_J,
NEG_J,
POS_K,
NEG_K
};
//==================================================================================================
///
//==================================================================================================
struct WellSegmentLateralIntersection {
WellSegmentLateralIntersection(int segmentNumber, int attachedSegmentNumber, size_t cellIndex, double length, double depth)
: segmentNumber(segmentNumber),
attachedSegmentNumber(attachedSegmentNumber),
cellIndex(cellIndex),
length(length),
depth(depth),
direction(POS_I),
directionLength(-1.0),
mainBoreCell(false)
{}
int segmentNumber;
int attachedSegmentNumber;
size_t cellIndex;
bool mainBoreCell;
double length;
double depth;
WellSegmentCellDirection direction;
double directionLength;
};
//==================================================================================================
///
//==================================================================================================
struct WellSegmentLateral {
WellSegmentLateral(size_t lateralIndex) : lateralIndex(lateralIndex) {}
size_t lateralIndex;
int branchNumber;
std::vector<WellSegmentLateralIntersection> intersections;
};
//==================================================================================================
///
//==================================================================================================
struct WellSegmentLocation {
WellSegmentLocation(const RimFishbonesMultipleSubs* subs, double measuredDepth, double trueVerticalDepth, size_t subIndex, int segmentNumber = -1)
: fishbonesSubs(subs),
measuredDepth(measuredDepth),
trueVerticalDepth(trueVerticalDepth),
subIndex(subIndex),
segmentNumber(segmentNumber)
{
}
const RimFishbonesMultipleSubs* fishbonesSubs;
double measuredDepth;
double trueVerticalDepth;
size_t subIndex;
int segmentNumber;
std::vector<WellSegmentLateral> laterals;
};
//==================================================================================================
///
//==================================================================================================
struct EclipseCellIndexRange {
size_t i;
size_t j;
size_t k1;
size_t k2;
};
//==================================================================================================
///
//==================================================================================================
typedef std::tuple<size_t, size_t, size_t> EclipseCellIndex;
//==================================================================================================
///
//==================================================================================================
class RicWellPathExportCompletionDataFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
private:
static void exportToFolder(RimWellPath* wellPath, const RimExportCompletionDataSettings& exportSettings);
static void generateCompdatTable(RifEclipseOutputTableFormatter& formatter, const RimWellPath* wellPath, const RimExportCompletionDataSettings& settings, const std::vector<WellSegmentLocation>& locations);
static void generateWpimultTable(RifEclipseOutputTableFormatter& formatter, const RimWellPath* wellPath, const RimExportCompletionDataSettings& settings, const std::map<size_t, double>& lateralsPerCell);
static void generateWelsegsTable(RifEclipseOutputTableFormatter& formatter, const RimWellPath* wellPath, const RimExportCompletionDataSettings& settings, const std::vector<WellSegmentLocation>& locations);
static void generateCompsegsTable(RifEclipseOutputTableFormatter& formatter, const RimWellPath* wellPath, const RimExportCompletionDataSettings& settings, const std::vector<WellSegmentLocation>& locations);
static std::map<size_t, double> computeLateralsPerCell(const std::vector<WellSegmentLocation>& segmentLocations, bool removeMainBoreCells);
static std::vector<size_t> findCloseCells(const RigEclipseCaseData* caseData, const cvf::BoundingBox& bb);
static size_t findCellFromCoords(const RigEclipseCaseData* caseData, const cvf::Vec3d& coords);
static std::vector<EclipseCellIndexRange> getCellIndexRange(const RigMainGrid* grid, const std::vector<size_t>& cellIndices);
static bool cellOrdering(const EclipseCellIndex& cell1, const EclipseCellIndex& cell2);
static std::vector<size_t> findIntersectingCells(const RigEclipseCaseData* grid, const std::vector<cvf::Vec3d>& coords);
static void setHexCorners(const RigCell& cell, const std::vector<cvf::Vec3d>& nodeCoords, cvf::Vec3d* hexCorners);
static void markWellPathCells(const std::vector<size_t>& wellPathCells, std::vector<WellSegmentLocation>* locations);
static bool wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second);
static std::vector<HexIntersectionInfo> findIntersections(const RigEclipseCaseData* caseData, const std::vector<cvf::Vec3d>& coords);
static bool isPointBetween(const cvf::Vec3d& pointA, const cvf::Vec3d& pointB, const cvf::Vec3d& needle);
static void filterIntersections(std::vector<HexIntersectionInfo>* intersections);
static std::vector<WellSegmentLocation> findWellSegmentLocations(const RimEclipseCase* caseToApply, RimWellPath* wellPath);
static void calculateLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum);
static void assignBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector<WellSegmentLocation>* locations);
// Calculate direction
static void calculateCellMainAxisDirections(const RigMainGrid* grid, size_t cellIndex, cvf::Vec3d* iAxisDirection, cvf::Vec3d* jAxisDirection, cvf::Vec3d* kAxisDirection);
static cvf::Vec3d calculateCellMainAxisDirection(const cvf::Vec3d* hexCorners, cvf::StructGridInterface::FaceType startFace, cvf::StructGridInterface::FaceType endFace);
static std::pair<WellSegmentCellDirection, double> calculateDirectionAndDistanceInCell(const RigMainGrid* grid, size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint);
};

View File

@ -0,0 +1,103 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicWellPathImportCompletionsFileFeature.h"
#include "RiaApplication.h"
#include "RimFishboneWellPathCollection.h"
#include "RimFishbonesCollection.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathCompletions.h"
#include "RiuMainWindow.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QFileDialog>
CAF_CMD_SOURCE_INIT(RicWellPathImportCompletionsFileFeature, "RicWellPathImportCompletionsFileFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicWellPathImportCompletionsFileFeature::isCommandEnabled()
{
if (RicWellPathImportCompletionsFileFeature::selectedWellPathCollection() != nullptr)
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathImportCompletionsFileFeature::onActionTriggered(bool isChecked)
{
RimFishboneWellPathCollection* wellPathCollection = RicWellPathImportCompletionsFileFeature::selectedWellPathCollection();
CVF_ASSERT(wellPathCollection);
// Open dialog box to select well path files
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectory("WELLPATH_DIR");
QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Path Completions", defaultDir, "Well Path Completions (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)");
if (wellPathFilePaths.size() < 1) return;
// Remember the path to next time
app->setLastUsedDialogDirectory("WELLPATH_DIR", QFileInfo(wellPathFilePaths.last()).absolutePath());
wellPathCollection->importCompletionsFromFile(wellPathFilePaths);
if (app->project())
{
app->project()->createDisplayModelAndRedrawAllViews();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathImportCompletionsFileFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Import Completions from File");
actionToSetup->setIcon(QIcon(":/Well.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFishboneWellPathCollection* RicWellPathImportCompletionsFileFeature::selectedWellPathCollection()
{
std::vector<caf::PdmObject*> objects;
caf::SelectionManager::instance()->objectsByType(&objects);
if (objects.size() > 0)
{
RimFishboneWellPathCollection* fbWellColl = nullptr;
objects[0]->firstAncestorOrThisOfType(fbWellColl);
return fbWellColl;
}
return nullptr;
}

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 RimFishboneWellPathCollection;
//==================================================================================================
///
//==================================================================================================
class RicWellPathImportCompletionsFileFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
private:
static RimFishboneWellPathCollection* selectedWellPathCollection();
};

View File

@ -26,9 +26,7 @@
#include <QAction>
#include <QFileDialog>
namespace caf
{
CAF_CMD_SOURCE_INIT(RicWellPathsImportFileFeature, "RicWellPathsImportFileFeature");
CAF_CMD_SOURCE_INIT(RicWellPathsImportFileFeature, "RicWellPathsImportFileFeature");
//--------------------------------------------------------------------------------------------------
@ -69,5 +67,3 @@ void RicWellPathsImportFileFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setText("Import &Well Paths from File");
actionToSetup->setIcon(QIcon(":/Well.png"));
}
} // end namespace caf

View File

@ -21,23 +21,16 @@
#include "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class RicWellPathsImportFileFeature : public CmdFeature
class RicWellPathsImportFileFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};
} // end namespace caf

View File

@ -27,13 +27,13 @@
#include "RiuMainWindow.h"
#include "RiuWellImportWizard.h"
#include "cafUtils.h"
#include <QAction>
#include <QDir>
#include <QFile>
namespace caf
{
CAF_CMD_SOURCE_INIT(RicWellPathsImportSsihubFeature, "RicWellPathsImportSsihubFeature");
CAF_CMD_SOURCE_INIT(RicWellPathsImportSsihubFeature, "RicWellPathsImportSsihubFeature");
//--------------------------------------------------------------------------------------------------
@ -47,7 +47,7 @@ bool RicWellPathsImportSsihubFeature::isCommandEnabled()
return false;
}
if (!QFile::exists(app->project()->fileName()))
if (!caf::Utils::fileExists(app->project()->fileName()))
{
return false;
}
@ -66,7 +66,7 @@ void RicWellPathsImportSsihubFeature::onActionTriggered(bool isChecked)
return;
}
if (!QFile::exists(app->project()->fileName()))
if (!caf::Utils::fileExists(app->project()->fileName()))
{
return;
}
@ -123,5 +123,3 @@ void RicWellPathsImportSsihubFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setText("Import Well Paths from &SSI-hub");
actionToSetup->setIcon(QIcon(":/WellCollection.png"));
}
} // end namespace caf

View File

@ -21,23 +21,16 @@
#include "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class RicWellPathsImportSsihubFeature : public CmdFeature
class RicWellPathsImportSsihubFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};
} // end namespace caf

View File

@ -7,6 +7,7 @@ endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.h
${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.h
${CEE_CURRENT_LIST_DIR}RifEclipseOutputTableFormatter.h
${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.h
${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.h
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.h
@ -19,6 +20,7 @@ ${CEE_CURRENT_LIST_DIR}RifReaderInterface.h
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.h
${CEE_CURRENT_LIST_DIR}RifReaderSettings.h
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.h
${CEE_CURRENT_LIST_DIR}RifWellPathImporter.h
${CEE_CURRENT_LIST_DIR}RifEclipseWellCompletionExporter.h
${CEE_CURRENT_LIST_DIR}RifFractureExportTools.h
)
@ -26,6 +28,7 @@ ${CEE_CURRENT_LIST_DIR}RifFractureExportTools.h
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseOutputTableFormatter.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.cpp
@ -38,6 +41,7 @@ ${CEE_CURRENT_LIST_DIR}RifReaderInterface.cpp
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.cpp
${CEE_CURRENT_LIST_DIR}RifReaderSettings.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.cpp
${CEE_CURRENT_LIST_DIR}RifWellPathImporter.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseWellCompletionExporter.cpp
${CEE_CURRENT_LIST_DIR}RifFractureExportTools.cpp
)

View File

@ -121,22 +121,22 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC
bool allKwReadOk = true;
fseek(gridFilePointer, specgridPos, SEEK_SET);
allKwReadOk = allKwReadOk && NULL != (specGridKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_INT_TYPE));
allKwReadOk = allKwReadOk && NULL != (specGridKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_INT_TYPE)));
progress.setProgress(1);
fseek(gridFilePointer, zcornPos, SEEK_SET);
allKwReadOk = allKwReadOk && NULL != (zCornKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_FLOAT_TYPE));
allKwReadOk = allKwReadOk && NULL != (zCornKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE)));
progress.setProgress(2);
fseek(gridFilePointer, coordPos, SEEK_SET);
allKwReadOk = allKwReadOk && NULL != (coordKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_FLOAT_TYPE));
allKwReadOk = allKwReadOk && NULL != (coordKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE)));
progress.setProgress(3);
// If ACTNUM is not defined, this pointer will be NULL, which is a valid condition
if (actnumPos >= 0)
{
fseek(gridFilePointer, actnumPos, SEEK_SET);
allKwReadOk = allKwReadOk && NULL != (actNumKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_INT_TYPE));
allKwReadOk = allKwReadOk && NULL != (actNumKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_INT_TYPE)));
progress.setProgress(4);
}
@ -144,7 +144,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC
if (mapaxesPos >= 0)
{
fseek(gridFilePointer, mapaxesPos, SEEK_SET);
mapAxesKw = ecl_kw_fscanf_alloc_current_grdecl__( gridFilePointer, false , ECL_FLOAT_TYPE);
mapAxesKw = ecl_kw_fscanf_alloc_current_grdecl__( gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE));
}
if (!allKwReadOk)
@ -228,7 +228,7 @@ std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QStrin
fseek(gridFilePointer, fileKeywords[i].filePos, SEEK_SET);
ecl_kw_type* eclipseKeywordData = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false, ECL_FLOAT_TYPE);
ecl_kw_type* eclipseKeywordData = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false, ecl_type_create_from_type(ECL_FLOAT_TYPE));
if (eclipseKeywordData)
{
QString newResultName = caseData->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(fileKeywords[i].keyword);
@ -261,7 +261,7 @@ bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigEclipseC
FILE* filePointer = util_fopen(fileName.toLatin1().data(), "r");
if (!filePointer) return false;
ecl_kw_type* eclipseKeywordData = ecl_kw_fscanf_alloc_grdecl_dynamic__(filePointer, eclipseKeyWord.toLatin1().data(), false, ECL_FLOAT_TYPE);
ecl_kw_type* eclipseKeywordData = ecl_kw_fscanf_alloc_grdecl_dynamic__(filePointer, eclipseKeyWord.toLatin1().data(), false, ecl_type_create_from_type(ECL_FLOAT_TYPE));
bool isOk = false;
if (eclipseKeywordData)
{
@ -474,18 +474,17 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName,
/// Create and write a result vector with values for all cells.
/// undefinedValue is used for cells with no result
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileName,
RigEclipseCaseData* eclipseCase,
RifReaderInterface::PorosityModelResultType porosityModel,
size_t timeStep,
const QString& resultName,
const QString& eclipseKeyWord,
bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileName,
RigEclipseCaseData* eclipseCase,
size_t timeStep,
RimEclipseResultDefinition* resultDefinition,
const QString& eclipseKeyWord,
const double undefinedValue)
{
CVF_ASSERT(eclipseCase);
size_t resultIndex = eclipseCase->results(porosityModel)->findScalarResultIndex(resultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::createFromResultDefinition(eclipseCase, eclipseCase->mainGrid()->gridIndex(), timeStep, resultDefinition);
if (resultAccessor.isNull())
{
return false;
}
@ -496,12 +495,6 @@ bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileNa
return false;
}
cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::createFromUiResultName(eclipseCase, eclipseCase->mainGrid()->gridIndex(), porosityModel, timeStep, resultName);
if (resultAccessor.isNull())
{
return false;
}
std::vector<double> resultData;
size_t i, j, k;
for (k = 0; k < eclipseCase->mainGrid()->cellCountK(); k++)

View File

@ -36,6 +36,7 @@
class RigEclipseCaseData;
class QFile;
class RimEclipseResultDefinition;
//--------------------------------------------------------------------------------------------------
@ -76,7 +77,7 @@ public:
static bool writePropertyToTextFile(const QString& fileName, RigEclipseCaseData* eclipseCase, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord);
static bool writeBinaryResultToTextFile(const QString& fileName, RigEclipseCaseData* eclipseCase, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue);
static bool writeBinaryResultToTextFile(const QString& fileName, RigEclipseCaseData* eclipseCase, size_t timeStep, RimEclipseResultDefinition* resultdefinition, const QString& eclipseKeyWord, const double undefinedValue);
static bool readFaultsAndParseIncludeStatementsRecursively( QFile& file,
qint64 startPos,

View File

@ -115,7 +115,7 @@ void getDayMonthYear(const ecl_kw_type* intehead_kw, int* day, int* month, int*
//--------------------------------------------------------------------------------------------------
/// Get list of time step texts (dates)
//--------------------------------------------------------------------------------------------------
void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<QDateTime>* timeSteps)
void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<QDateTime>* timeSteps, std::vector<double>* daysSinceSimulationStart)
{
if (!ecl_file) return;
@ -127,7 +127,7 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<Q
// Get the number of occurrences of the DOUBHEAD keyword
int numDOUBHEAD = ecl_file_get_num_named_kw(ecl_file, DOUBHEAD_KW);
std::vector<double> dayFractions(numINTEHEAD, 0.0); // Init fraction to zero
std::vector<double> dayValues(numINTEHEAD, 0.0); // Init fraction to zero
// Read out fraction of day if number of keywords are identical
if (numINTEHEAD == numDOUBHEAD)
@ -137,12 +137,7 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<Q
ecl_kw_type* kwDOUBHEAD = ecl_file_iget_named_kw(ecl_file, DOUBHEAD_KW, i);
if (kwDOUBHEAD)
{
double dayValue = ecl_kw_iget_double(kwDOUBHEAD, DOUBHEAD_DAYS_INDEX);
double floorDayValue = cvf::Math::floor(dayValue);
double dayDelta = dayValue - floorDayValue;
dayFractions[i] = dayDelta;
dayValues[i] = ecl_kw_iget_double(kwDOUBHEAD, DOUBHEAD_DAYS_INDEX);
}
}
}
@ -159,7 +154,8 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<Q
QDateTime reportDateTime(QDate(year, month, day));
CVF_ASSERT(reportDateTime.isValid());
double dayFraction = dayFractions[i];
double dayValue = dayValues[i];
double dayFraction = dayValue - cvf::Math::floor(dayValue);
int milliseconds = static_cast<int>(dayFraction * 24.0 * 60.0 * 60.0 * 1000.0);
int seconds = milliseconds % 1000;
milliseconds -= seconds * 1000;
@ -172,6 +168,7 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<Q
if (std::find(timeSteps->begin(), timeSteps->end(), reportDateTime) == timeSteps->end())
{
timeSteps->push_back(reportDateTime);
daysSinceSimulationStart->push_back(dayValue);
}
}
}
@ -382,8 +379,9 @@ void RifEclipseOutputFileTools::createReportStepsMetaData(std::vector<ecl_file_t
int namedKeywordCount = ecl_file_get_num_named_kw(ecl_file, kw);
for (int iOcc = 0; iOcc < namedKeywordCount; iOcc++)
{
ecl_type_enum dataType = ecl_file_iget_named_type(ecl_file, kw, iOcc);
if (dataType != ECL_DOUBLE_TYPE && dataType != ECL_FLOAT_TYPE && dataType != ECL_INT_TYPE)
ecl_data_type dataType = ecl_file_iget_named_data_type(ecl_file, kw, iOcc);
ecl_type_enum dataTypeEmum = ecl_type_get_type(dataType);
if (dataTypeEmum != ECL_DOUBLE_TYPE && dataTypeEmum != ECL_FLOAT_TYPE && dataTypeEmum != ECL_INT_TYPE)
{
continue;
}

View File

@ -51,7 +51,7 @@ public:
static bool keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<double>* values);
static bool keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<int>* values);
static void timeSteps(ecl_file_type* ecl_file, std::vector<QDateTime>* timeSteps);
static void timeSteps(ecl_file_type* ecl_file, std::vector<QDateTime>* timeSteps, std::vector<double>* daysSinceSimulationStart);
static bool findSiblingFilesWithSameBaseName(const QString& fileName, QStringList* fileSet);

View File

@ -0,0 +1,281 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RifEclipseOutputTableFormatter.h"
#include "cvfAssert.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseOutputTableFormatter::RifEclipseOutputTableFormatter(QTextStream& out) : m_out(out)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseOutputTableFormatter::~RifEclipseOutputTableFormatter()
{
CVF_ASSERT(m_buffer.empty());
CVF_ASSERT(m_columns.empty());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseOutputTableFormatter::outputBuffer()
{
if (m_columns.size() > 0)
{
m_out << "-- ";
for (RifEclipseOutputTableColumn& column : m_columns)
{
m_out << formatColumn(column.title, column);
}
m_out << "\n";
}
for (auto line : m_buffer)
{
if (line.lineType == COMMENT)
{
outputComment(line);
}
else if (line.lineType == CONTENTS)
{
m_out << " ";
for (size_t i = 0; i < line.data.size(); ++i)
{
m_out << formatColumn(line.data[i], m_columns[i]);
}
m_out << " /" << "\n";
}
}
m_columns.clear();
m_buffer.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseOutputTableFormatter::outputComment(RifEclipseOutputTableLine& comment)
{
m_out << "-- " << comment.data[0] << "\n";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseOutputTableFormatter::tableCompleted()
{
outputBuffer();
// Output an "empty" line after a finished table
m_out << "/\n";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseOutputTableFormatter& RifEclipseOutputTableFormatter::keyword(const QString keyword)
{
CVF_ASSERT(m_buffer.empty());
CVF_ASSERT(m_columns.empty());
m_out << keyword << "\n";
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseOutputTableFormatter& RifEclipseOutputTableFormatter::header(const std::vector<RifEclipseOutputTableColumn> header)
{
outputBuffer();
m_columns = header;
for (RifEclipseOutputTableColumn& column : m_columns)
{
column.width = measure(column.title);
}
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseOutputTableFormatter& RifEclipseOutputTableFormatter::comment(const QString comment)
{
RifEclipseOutputTableLine line;
line.data.push_back(comment);
line.lineType = COMMENT;
if (m_columns.empty())
{
outputComment(line);
}
else
{
m_buffer.push_back(line);
}
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseOutputTableFormatter& RifEclipseOutputTableFormatter::add(const QString str)
{
size_t column = m_lineBuffer.size();
CVF_ASSERT(column < m_columns.size());
m_columns[column].width = std::max(measure(str), m_columns[column].width);
m_lineBuffer.push_back(str);
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseOutputTableFormatter& RifEclipseOutputTableFormatter::add(double num)
{
size_t column = m_lineBuffer.size();
CVF_ASSERT(column < m_columns.size());
m_columns[column].width = std::max(measure(num), m_columns[column].width);
m_lineBuffer.push_back(format(num));
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseOutputTableFormatter& RifEclipseOutputTableFormatter::add(int num)
{
size_t column = m_lineBuffer.size();
CVF_ASSERT(column < m_columns.size());
m_columns[column].width = std::max(measure(num), m_columns[column].width);
m_lineBuffer.push_back(format(num));
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseOutputTableFormatter& RifEclipseOutputTableFormatter::add(size_t num)
{
size_t column = m_lineBuffer.size();
CVF_ASSERT(column < m_columns.size());
m_columns[column].width = std::max(measure(num), m_columns[column].width);
m_lineBuffer.push_back(format(num));
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseOutputTableFormatter& RifEclipseOutputTableFormatter::addZeroBasedCellIndex(size_t index)
{
size_t column = m_lineBuffer.size();
CVF_ASSERT(column < m_columns.size());
// Increase index by 1 to use Eclipse 1-based cell index instead of ResInsight 0-based
index++;
m_columns[column].width = std::max(measure(index), m_columns[column].width);
m_lineBuffer.push_back(format(index));
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseOutputTableFormatter::rowCompleted()
{
RifEclipseOutputTableLine line;
line.data = m_lineBuffer;
line.lineType = CONTENTS;
m_buffer.push_back(line);
m_lineBuffer.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifEclipseOutputTableFormatter::measure(const QString str)
{
return str.length();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifEclipseOutputTableFormatter::measure(double num)
{
return format(num).length();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifEclipseOutputTableFormatter::measure(int num)
{
return format(num).length();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifEclipseOutputTableFormatter::measure(size_t num)
{
return format(num).length();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RifEclipseOutputTableFormatter::format(double num)
{
return QString("%1").arg(num, 0, 'f', m_doubleDecimals);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RifEclipseOutputTableFormatter::format(int num)
{
return QString("%1").arg(num);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RifEclipseOutputTableFormatter::format(size_t num)
{
return QString("%1").arg(num);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RifEclipseOutputTableFormatter::formatColumn(const QString str, RifEclipseOutputTableColumn column)
{
if (column.alignment == LEFT)
{
return str.leftJustified(column.width + m_colSpacing, ' ');
}
else
{
return str.rightJustified(column.width, ' ').leftJustified(m_colSpacing, ' ');
}
}

View File

@ -0,0 +1,112 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 <QString>
#include <QTextStream>
#include <vector>
//==================================================================================================
//
//==================================================================================================
enum RifEclipseOutputTableLineType
{
COMMENT,
CONTENTS
};
//==================================================================================================
//
//==================================================================================================
enum RifEclipseOutputTableAlignment
{
LEFT,
RIGHT
};
//==================================================================================================
//
//==================================================================================================
struct RifEclipseOutputTableLine
{
RifEclipseOutputTableLineType lineType;
std::vector< QString > data;
};
//==================================================================================================
//
//==================================================================================================
struct RifEclipseOutputTableColumn
{
RifEclipseOutputTableColumn(const QString& title, RifEclipseOutputTableAlignment alignment = LEFT, int width = -1)
: title(title),
alignment(alignment),
width(width)
{
}
QString title;
RifEclipseOutputTableAlignment alignment;
int width;
};
//==================================================================================================
//
//==================================================================================================
class RifEclipseOutputTableFormatter
{
public:
RifEclipseOutputTableFormatter(QTextStream& out);
virtual ~RifEclipseOutputTableFormatter();
RifEclipseOutputTableFormatter& keyword(const QString keyword);
RifEclipseOutputTableFormatter& header(std::vector<RifEclipseOutputTableColumn> tableHeader);
RifEclipseOutputTableFormatter& add(const QString str);
RifEclipseOutputTableFormatter& add(double num);
RifEclipseOutputTableFormatter& add(int num);
RifEclipseOutputTableFormatter& add(size_t num);
RifEclipseOutputTableFormatter& addZeroBasedCellIndex(size_t index);
RifEclipseOutputTableFormatter& comment(const QString str);
void rowCompleted();
void tableCompleted();
private:
int measure(const QString str);
int measure(double num);
int measure(int num);
int measure(size_t num);
QString format(double num);
QString format(int num);
QString format(size_t num);
QString formatColumn(const QString str, RifEclipseOutputTableColumn column);
void outputBuffer();
void outputComment(RifEclipseOutputTableLine& comment);
private:
std::vector<RifEclipseOutputTableColumn> m_columns;
std::vector<RifEclipseOutputTableLine> m_buffer;
std::vector<QString> m_lineBuffer;
QTextStream& m_out;
int m_doubleDecimals = 5;
int m_colSpacing = 5;
};

View File

@ -98,7 +98,7 @@ public:
virtual void setTimeSteps(const std::vector<QDateTime>& timeSteps) {};
virtual size_t timeStepCount() = 0;
virtual std::vector<QDateTime> timeSteps() = 0;
virtual void timeSteps(std::vector<QDateTime>* timeSteps, std::vector<double>* daysSinceSimulationStart) = 0;
virtual std::vector<int> reportNumbers() = 0;
virtual void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts) = 0;

View File

@ -119,7 +119,7 @@ size_t RifEclipseRestartFilesetAccess::timeStepCount()
//--------------------------------------------------------------------------------------------------
/// Get the time steps
//--------------------------------------------------------------------------------------------------
std::vector<QDateTime> RifEclipseRestartFilesetAccess::timeSteps()
void RifEclipseRestartFilesetAccess::timeSteps(std::vector<QDateTime>* timeSteps, std::vector<double>* daysSinceSimulationStart)
{
if (m_timeSteps.size() == 0)
{
@ -128,24 +128,28 @@ std::vector<QDateTime> RifEclipseRestartFilesetAccess::timeSteps()
for (i = 0; i < numSteps; i++)
{
std::vector<QDateTime> stepTime;
std::vector<double> stepDays;
openTimeStep(i);
RifEclipseOutputFileTools::timeSteps(m_ecl_files[i], &stepTime);
RifEclipseOutputFileTools::timeSteps(m_ecl_files[i], &stepTime, &stepDays);
if (stepTime.size() == 1)
{
m_timeSteps.push_back(stepTime[0]);
m_daysSinceSimulationStart.push_back(stepDays[0]);
}
else
{
m_timeSteps.push_back(QDateTime());
m_daysSinceSimulationStart.push_back(0.0);
}
}
}
return m_timeSteps;
*timeSteps = m_timeSteps;
*daysSinceSimulationStart = m_daysSinceSimulationStart;
}
//--------------------------------------------------------------------------------------------------

View File

@ -43,7 +43,7 @@ public:
void setTimeSteps(const std::vector<QDateTime>& timeSteps);
size_t timeStepCount();
std::vector<QDateTime> timeSteps();
void timeSteps(std::vector<QDateTime>* timeSteps, std::vector<double>* daysSinceSimulationStart) override;
std::vector<int> reportNumbers();
void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts);
@ -58,6 +58,7 @@ private:
private:
QStringList m_fileNames;
std::vector<QDateTime> m_timeSteps;
std::vector<double> m_daysSinceSimulationStart;
std::vector< ecl_file_type* > m_ecl_files;
};

View File

@ -85,23 +85,23 @@ size_t RifEclipseUnifiedRestartFileAccess::timeStepCount()
{
return 0;
}
std::vector<QDateTime> timeSteps;
std::vector<double> daysSinceSimulationStart;
return timeSteps().size();
this->timeSteps(&timeSteps, &daysSinceSimulationStart);
return timeSteps.size();
}
//--------------------------------------------------------------------------------------------------
/// Get the time steps
//--------------------------------------------------------------------------------------------------
std::vector<QDateTime> RifEclipseUnifiedRestartFileAccess::timeSteps()
void RifEclipseUnifiedRestartFileAccess::timeSteps(std::vector<QDateTime>* timeSteps, std::vector<double>* daysSinceSimulationStart)
{
std::vector<QDateTime> timeSteps;
if (openFile())
{
RifEclipseOutputFileTools::timeSteps(m_ecl_file, &timeSteps);
RifEclipseOutputFileTools::timeSteps(m_ecl_file, timeSteps, daysSinceSimulationStart);
}
return timeSteps;
}

View File

@ -46,7 +46,7 @@ public:
void close();
size_t timeStepCount();
std::vector<QDateTime> timeSteps();
void timeSteps(std::vector<QDateTime>* timeSteps, std::vector<double>* daysSinceSimulationStart) override;
std::vector<int> reportNumbers();
void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts);

View File

@ -657,7 +657,7 @@ void RifReaderEclipseOutput::buildMetaData()
progInfo.incrementProgress();
// Get time steps
m_timeSteps = m_dynamicResultsAccess->timeSteps();
m_dynamicResultsAccess->timeSteps(&m_timeSteps, &m_daysSinceSimulationStart);
std::vector<int> reportNumbers = m_dynamicResultsAccess->reportNumbers();
QStringList resultNames;
@ -673,7 +673,7 @@ void RifReaderEclipseOutput::buildMetaData()
for (int i = 0; i < matrixResultNames.size(); ++i)
{
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, matrixResultNames[i], false);
matrixModelResults->setTimeStepDates(resIndex, m_timeSteps, reportNumbers);
matrixModelResults->setTimeStepDates(resIndex, m_timeSteps, m_daysSinceSimulationStart, reportNumbers);
}
}
@ -686,7 +686,7 @@ void RifReaderEclipseOutput::buildMetaData()
for (int i = 0; i < fractureResultNames.size(); ++i)
{
size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, fractureResultNames[i], false);
fractureModelResults->setTimeStepDates(resIndex, m_timeSteps, reportNumbers);
fractureModelResults->setTimeStepDates(resIndex, m_timeSteps, m_daysSinceSimulationStart, reportNumbers);
}
}
@ -723,12 +723,17 @@ void RifReaderEclipseOutput::buildMetaData()
RifEclipseOutputFileTools::findKeywordsAndItemCount(filesUsedToFindAvailableKeywords, &resultNames, &resultNamesDataItemCounts);
std::vector<QDateTime> staticDate;
std::vector<double> staticDay;
std::vector<int> staticReportNumber;
{
if ( m_timeSteps.size() > 0 )
{
staticDate.push_back(m_timeSteps.front());
}
if (m_daysSinceSimulationStart.size() > 0)
{
staticDay.push_back(m_daysSinceSimulationStart.front());
}
std::vector<int> reportNumbers;
if (m_dynamicResultsAccess.notNull())
@ -754,7 +759,7 @@ void RifReaderEclipseOutput::buildMetaData()
for (int i = 0; i < matrixResultNames.size(); ++i)
{
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i], false);
matrixModelResults->setTimeStepDates(resIndex, staticDate, staticReportNumber);
matrixModelResults->setTimeStepDates(resIndex, staticDate, staticDay, staticReportNumber);
}
}
@ -769,7 +774,7 @@ void RifReaderEclipseOutput::buildMetaData()
for (int i = 0; i < fractureResultNames.size(); ++i)
{
size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i], false);
fractureModelResults->setTimeStepDates(resIndex, staticDate, staticReportNumber);
fractureModelResults->setTimeStepDates(resIndex, staticDate, staticDay, staticReportNumber);
}
}
}
@ -908,6 +913,9 @@ RigWellResultPoint RifReaderEclipseOutput::createWellResultPoint(const RigGridBa
int cellK = well_conn_get_k( ert_connection );
bool isCellOpen = well_conn_open( ert_connection );
double volumeRate = well_conn_get_volume_rate( ert_connection);
double oilRate = well_conn_get_oil_rate(ert_connection) ;
double gasRate = well_conn_get_gas_rate(ert_connection);
double waterRate = well_conn_get_water_rate(ert_connection);
// If a well is defined in fracture region, the K-value is from (cellCountK - 1) -> cellCountK*2 - 1
// Adjust K so index is always in valid grid region
@ -960,6 +968,18 @@ RigWellResultPoint RifReaderEclipseOutput::createWellResultPoint(const RigGridBa
resultPoint.m_ertBranchId = ertBranchId;
resultPoint.m_ertSegmentId = ertSegmentId;
resultPoint.m_flowRate = volumeRate;
resultPoint.m_oilRate = oilRate;
resultPoint.m_waterRate = waterRate;
// If field unit, the Gas is in Mega ft^3 while the others are in [stb] (barrel)
// we convert gas to stb as well. Based on
// 1 [stb] = 0.15898729492800007 [m^3]
// 1 [ft] = 0.3048 [m]
// megaFt3ToStbFactor = 1.0 / (1.0e-6 * 0.15898729492800007 * ( 1.0 / 0.3048 )^3 )
double megaFt3ToStbFactor = 178107.60668;
if (m_eclipseCase->unitsType() == RigEclipseCaseData::UNITS_FIELD) gasRate = megaFt3ToStbFactor * gasRate;
resultPoint.m_gasRate = gasRate;
}
return resultPoint;
@ -1118,7 +1138,9 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo
m_dynamicResultsAccess->readWellData(ert_well_info, importCompleteMswData);
std::vector<QDateTime> timeSteps = m_dynamicResultsAccess->timeSteps();
std::vector<double> daysSinceSimulationStart;
std::vector<QDateTime> timeSteps;
m_dynamicResultsAccess->timeSteps(&timeSteps, &daysSinceSimulationStart);
std::vector<int> reportNumbers = m_dynamicResultsAccess->reportNumbers();
bool sameCount = false;

View File

@ -69,7 +69,7 @@ private:
std::string ertGridName( size_t gridNr );
static RigWellResultPoint createWellResultPoint(const RigGridBase* grid, const well_conn_type* ert_connection, int ertBranchId, int ertSegmentId, const char* wellName);
RigWellResultPoint createWellResultPoint(const RigGridBase* grid, const well_conn_type* ert_connection, int ertBranchId, int ertSegmentId, const char* wellName);
void importFaults(const QStringList& fileSet, cvf::Collection<RigFault>* faults);
@ -93,6 +93,7 @@ private:
RigEclipseCaseData* m_eclipseCase;
std::vector<QDateTime> m_timeSteps;
std::vector<double> m_daysSinceSimulationStart;
ecl_file_type* m_ecl_init_file; // File access to static results
cvf::ref<RifEclipseRestartDataAccess> m_dynamicResultsAccess; // File access to dynamic results

View File

@ -38,24 +38,28 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCaseData* eclip
std::vector<QDateTime> dates;
std::vector<double> days;
std::vector<int> repNumbers;
for (int i = 0; i < static_cast<int>(m_reservoirBuilder.timeStepCount()); i++)
{
dates.push_back(QDateTime(QDate(2012+i, 6, 1)));
days.push_back(i);
repNumbers.push_back(i);
}
for (size_t i = 0; i < m_reservoirBuilder.resultCount(); i++)
{
size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, QString("Dynamic_Result_%1").arg(i), false);
cellResults->setTimeStepDates(resIdx, dates, repNumbers);
cellResults->setTimeStepDates(resIdx, dates, days, repNumbers);
}
if (m_reservoirBuilder.timeStepCount() == 0) return true;
std::vector<QDateTime> staticDates;
staticDates.push_back(dates[0]);
std::vector<double> staticDays;
staticDays.push_back(days[0]);
std::vector<int> staticRepNumbers;
staticRepNumbers.push_back(0);
@ -68,7 +72,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCaseData* eclip
if (i > 1) resIndex = i;
size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, QString("Static_Result_%1%2").arg(resIndex).arg(varEnd), false);
cellResults->setTimeStepDates(resIdx, staticDates, staticRepNumbers);
cellResults->setTimeStepDates(resIdx, staticDates, staticDays, staticRepNumbers);
}
@ -77,7 +81,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCaseData* eclip
size_t resIdx; \
QString resultName(Name); \
resIdx = cellResults->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, resultName, false); \
cellResults->setTimeStepDates(resIdx, staticDates, staticRepNumbers); \
cellResults->setTimeStepDates(resIdx, staticDates, staticDays, staticRepNumbers); \
cellResults->cellScalarResults(resIdx).resize(1); \
std::vector<double>& values = cellResults->cellScalarResults(resIdx)[0]; \
this->inputProperty(resultName, &values); \

View File

@ -31,13 +31,13 @@ RifReaderSettings::RifReaderSettings()
{
CAF_PDM_InitObject("RifReaderSettings", "", "", "");
CAF_PDM_InitField(&importFaults, "importFaults", true, "Import faults", "", "", "");
CAF_PDM_InitField(&importFaults, "importFaults", true, "Import Faults", "", "", "");
importFaults.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitField(&importNNCs, "importSimulationNNCs", true, "Import NNCs", "", "", "");
importNNCs.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitField(&importAdvancedMswData, "importAdvancedMswData", false, "Import advanced MSW data", "", "", "");
CAF_PDM_InitField(&importAdvancedMswData, "importAdvancedMswData", false, "Import Advanced MSW Data", "", "", "");
importAdvancedMswData.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
CAF_PDM_InitField(&faultIncludeFileAbsolutePathPrefix, "faultIncludeFileAbsolutePathPrefix", QString(), "Fault Include File Absolute Path Prefix", "", "Path used to prefix absolute UNIX paths in fault include statements on Windows", "");
@ -52,7 +52,7 @@ void RifReaderSettings::defineEditorAttribute(const caf::PdmFieldHandle* field,
field == &importAdvancedMswData ||
field == &importNNCs)
{
caf::PdmUiCheckBoxEditorAttribute* myAttr = static_cast<caf::PdmUiCheckBoxEditorAttribute*>(attribute);
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_useNativeCheckBoxLabel = true;

View File

@ -0,0 +1,378 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifWellPathImporter.h"
#include "RifJsonEncodeDecode.h"
#include <fstream>
#include "cafUtils.h"
#include <QFileInfo>
#include <cmath>
#include <algorithm>
#define ASCII_FILE_DEFAULT_START_INDEX 0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellData RifWellPathImporter::readWellData(const QString& filePath, size_t indexInFile)
{
CVF_ASSERT(caf::Utils::fileExists(filePath));
if (isJsonFile(filePath))
{
return readJsonWellData(filePath);
}
else
{
return readAsciiWellData(filePath, indexInFile);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellData RifWellPathImporter::readWellData(const QString& filePath)
{
return readWellData(filePath, ASCII_FILE_DEFAULT_START_INDEX);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellMetaData RifWellPathImporter::readWellMetaData(const QString& filePath, size_t indexInFile)
{
CVF_ASSERT(caf::Utils::fileExists(filePath));
if (isJsonFile(filePath))
{
return readJsonWellMetaData(filePath);
}
else
{
return readAsciiWellMetaData(filePath, indexInFile);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellMetaData RifWellPathImporter::readWellMetaData(const QString& filePath)
{
return readWellMetaData(filePath, ASCII_FILE_DEFAULT_START_INDEX);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RifWellPathImporter::wellDataCount(const QString& filePath)
{
if (isJsonFile(filePath))
{
// Only support JSON files with single well data currently
return 1;
}
else
{
std::map<QString, std::vector<RifWellPathImporter::WellData> >::iterator it = m_fileNameToWellDataGroupMap.find(filePath);
// If we have the file in the map, assume it is already read.
if (it != m_fileNameToWellDataGroupMap.end())
{
return it->second.size();
}
readAllAsciiWellData(filePath);
it = m_fileNameToWellDataGroupMap.find(filePath);
CVF_ASSERT(it != m_fileNameToWellDataGroupMap.end());
return it->second.size();;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifWellPathImporter::isJsonFile(const QString & filePath)
{
QFileInfo fileInfo(filePath);
if (fileInfo.suffix().compare("json") == 0)
{
return true;
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellMetaData RifWellPathImporter::readJsonWellMetaData(const QString & filePath)
{
ResInsightInternalJson::JsonReader jsonReader;
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(filePath);
WellMetaData metadata;
metadata.m_id = jsonMap["id"].toString();
metadata.m_name = jsonMap["name"].toString();
metadata.m_sourceSystem = jsonMap["sourceSystem"].toString();
metadata.m_utmZone = jsonMap["utmZone"].toString();
metadata.m_updateUser = jsonMap["updateUser"].toString();
metadata.m_surveyType = jsonMap["surveyType"].toString();
// Convert updateDate from the following format:
// "Number of milliseconds elapsed since midnight Coordinated Universal Time (UTC)
// of January 1, 1970, not counting leap seconds"
QString updateDateStr = jsonMap["updateDate"].toString().trimmed();
uint updateDateUint = updateDateStr.toULongLong() / 1000; // Should be within 32 bit, maximum number is 4294967295 which corresponds to year 2106
metadata.m_updateDate.setTime_t(updateDateUint);
return metadata;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellData RifWellPathImporter::readJsonWellData(const QString& filePath)
{
ResInsightInternalJson::JsonReader jsonReader;
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(filePath);
double datumElevation = jsonMap["datumElevation"].toDouble();
QList<QVariant> pathList = jsonMap["path"].toList();
WellData wellData;
wellData.m_wellPathGeometry->setDatumElevation(datumElevation);
wellData.m_name = jsonMap["name"].toString();
foreach(QVariant point, pathList)
{
QMap<QString, QVariant> coordinateMap = point.toMap();
cvf::Vec3d vec3d(coordinateMap["east"].toDouble(), coordinateMap["north"].toDouble(), -(coordinateMap["tvd"].toDouble() - datumElevation));
wellData.m_wellPathGeometry->m_wellPathPoints.push_back(vec3d);
double measuredDepth = coordinateMap["md"].toDouble();
wellData.m_wellPathGeometry->m_measuredDepths.push_back(measuredDepth);
}
return wellData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifWellPathImporter::readAllAsciiWellData(const QString& filePath)
{
std::map<QString, std::vector<RifWellPathImporter::WellData> >::iterator it = m_fileNameToWellDataGroupMap.find(filePath);
// If we have the file in the map, assume it is already read.
if (it != m_fileNameToWellDataGroupMap.end())
{
return;
}
// Create the data container
std::vector<RifWellPathImporter::WellData>& fileWellDataArray = m_fileNameToWellDataGroupMap[filePath];
std::ifstream stream(filePath.toLatin1().data());
double x(HUGE_VAL), y(HUGE_VAL), tvd(HUGE_VAL), md(HUGE_VAL);
bool hasReadWellPointInCurrentWell = false;
while (stream.good())
{
// First check if we can read a number
stream >> x;
if (stream.good()) // If we can, assume this line is a well point entry
{
stream >> y >> tvd >> md;
if (!stream.good())
{
// -999 or otherwise to few numbers before some word
if (x != -999)
{
// Error in file: missing numbers at this line
}
stream.clear();
}
else
{
if (!fileWellDataArray.size())
{
fileWellDataArray.push_back(RifWellPathImporter::WellData());
fileWellDataArray.back().m_wellPathGeometry = new RigWellPath();
}
cvf::Vec3d wellPoint(x, y, -tvd);
fileWellDataArray.back().m_wellPathGeometry->m_wellPathPoints.push_back(wellPoint);
fileWellDataArray.back().m_wellPathGeometry->m_measuredDepths.push_back(md);
x = HUGE_VAL;
y = HUGE_VAL;
tvd = HUGE_VAL;
md = HUGE_VAL;
hasReadWellPointInCurrentWell = true;
}
}
else
{
// Could not read one double.
// we assume there is a comment line or a well path description
stream.clear();
std::string line;
std::getline(stream, line, '\n');
// Skip possible comment lines (-- is used in eclipse, so Haakon Høgstøl considered it smart to skip these here as well)
// The first "-" is eaten by the stream >> x above
if (line.find("-") == 0 || line.find("#") == 0)
{
// Comment line, just ignore
}
else
{
// Find the first and the last position of any quotes (and do not care to match quotes)
size_t quoteStartIdx = line.find_first_of("'`´");
size_t quoteEndIdx = line.find_last_of("'`´");
std::string wellName;
bool haveAPossibleWellStart = false;
if (quoteStartIdx < line.size() -1)
{
// Extract the text between the quotes
wellName = line.substr(quoteStartIdx + 1, quoteEndIdx - 1 - quoteStartIdx);
haveAPossibleWellStart = true;
}
else if (quoteStartIdx > line.length())
{
// We did not find any quotes
// Supported alternatives are
// name <WellNameA>
// wellname: <WellNameA>
std::string lineLowerCase = line;
transform(lineLowerCase.begin(), lineLowerCase.end(), lineLowerCase.begin(), ::tolower);
std::string tokenName = "name";
std::size_t foundNameIdx = lineLowerCase.find(tokenName);
if (foundNameIdx != std::string::npos)
{
std::string tokenColon = ":";
std::size_t foundColonIdx = lineLowerCase.find(tokenColon, foundNameIdx);
if (foundColonIdx != std::string::npos)
{
wellName = line.substr(foundColonIdx + tokenColon.length());
}
else
{
wellName = line.substr(foundNameIdx + tokenName.length());
}
haveAPossibleWellStart = true;
}
else
{
// Interpret the whole line as the well name.
QString name = line.c_str();
if (!name.trimmed().isEmpty())
{
wellName = name.trimmed().toStdString();
haveAPossibleWellStart = true;
}
}
}
if (haveAPossibleWellStart)
{
// Create a new Well data if we have read some data into the previous one.
// if not, just overwrite the name
if (hasReadWellPointInCurrentWell || fileWellDataArray.size() == 0)
{
fileWellDataArray.push_back(RifWellPathImporter::WellData());
fileWellDataArray.back().m_wellPathGeometry = new RigWellPath();
}
QString name = wellName.c_str();
if (!name.trimmed().isEmpty())
{
// Do not overwrite the name aquired from a line above, if this line is empty
fileWellDataArray.back().m_name = name.trimmed();
}
hasReadWellPointInCurrentWell = false;
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellData RifWellPathImporter::readAsciiWellData(const QString& filePath, size_t indexInFile)
{
readAllAsciiWellData(filePath);
std::map<QString, std::vector<RifWellPathImporter::WellData> >::iterator it = m_fileNameToWellDataGroupMap.find(filePath);
CVF_ASSERT(it != m_fileNameToWellDataGroupMap.end());
if (indexInFile < it->second.size())
{
return it->second[indexInFile];
}
else
{
// Error : The ascii well path file does not contain that many well paths
return RifWellPathImporter::WellData();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellMetaData RifWellPathImporter::readAsciiWellMetaData(const QString & filePath, size_t indexInFile)
{
// No metadata in ASCII files
return WellMetaData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifWellPathImporter::clear()
{
m_fileNameToWellDataGroupMap.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifWellPathImporter::removeFilePath(const QString& filePath)
{
m_fileNameToWellDataGroupMap.erase(filePath);
}

View File

@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RigWellPath.h"
#include "cvfObject.h"
#include <map>
#include <vector>
#include <QString>
#include <QDateTime>
//==================================================================================================
///
///
//==================================================================================================
class RifWellPathImporter
{
public:
struct WellData
{
QString m_name;
cvf::ref<RigWellPath> m_wellPathGeometry;
};
struct WellMetaData
{
QString m_name;
QString m_id;
QString m_sourceSystem;
QString m_utmZone;
QString m_updateUser;
QString m_surveyType;
QDateTime m_updateDate;
};
WellData readWellData(const QString& filePath, size_t indexInFile);
WellData readWellData(const QString& filePath);
WellMetaData readWellMetaData(const QString& filePath, size_t indexInFile);
WellMetaData readWellMetaData(const QString& filePath);
size_t wellDataCount(const QString& filePath);
void clear();
void removeFilePath(const QString& filePath);
private:
WellData readJsonWellData(const QString& filePath);
WellMetaData readJsonWellMetaData(const QString& filePath);
WellData readAsciiWellData(const QString& filePath, size_t indexInFile);
WellMetaData readAsciiWellMetaData(const QString& filePath, size_t indexInFile);
void readAllAsciiWellData(const QString& filePath);
inline bool isJsonFile(const QString& filePath);
std::map<QString, std::vector<RifWellPathImporter::WellData> > m_fileNameToWellDataGroupMap;
};

View File

@ -36,9 +36,11 @@ ${CEE_CURRENT_LIST_DIR}RivSimWellPipeSourceInfo.h
${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.h
${CEE_CURRENT_LIST_DIR}RivPartPriority.h
${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.h
${CEE_CURRENT_LIST_DIR}RivObjectSourceInfo.h
${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.h
${CEE_CURRENT_LIST_DIR}RivFishbonesSubsPartMgr.h
${CEE_CURRENT_LIST_DIR}RivWellFracturePartMgr.h
${CEE_CURRENT_LIST_DIR}RivObjectSourceInfo.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -70,8 +72,10 @@ ${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivSimWellPipeSourceInfo.cpp
${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivWellFracturePartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivObjectSourceInfo.cpp
${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivFishbonesSubsPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivWellFracturePartMgr.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RivFishbonesSubsPartMgr.h"
#include "RigWellPath.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimWellPath.h"
#include "RivObjectSourceInfo.h"
#include "RivPipeGeometryGenerator.h"
#include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h"
#include "cvfDrawableGeo.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfTransform.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivFishbonesSubsPartMgr::RivFishbonesSubsPartMgr(RimFishbonesMultipleSubs* subs)
: m_rimFishbonesSubs(subs)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivFishbonesSubsPartMgr::~RivFishbonesSubsPartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFishbonesSubsPartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize)
{
clearGeometryCache();
if (!m_rimFishbonesSubs->isChecked()) return;
if (m_parts.size() == 0)
{
buildParts(displayCoordTransform, characteristicCellSize);
}
for (auto part : m_parts)
{
model->addPart(part.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFishbonesSubsPartMgr::clearGeometryCache()
{
m_parts.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFishbonesSubsPartMgr::buildParts(caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize)
{
RimWellPath* wellPath = nullptr;
m_rimFishbonesSubs->firstAncestorOrThisOfTypeAsserted(wellPath);
RivPipeGeometryGenerator geoGenerator;
for (size_t subIndex = 0; subIndex < m_rimFishbonesSubs->locationOfSubs().size(); subIndex++)
{
for (size_t lateralIndex = 0; lateralIndex < m_rimFishbonesSubs->lateralLengths().size(); lateralIndex++)
{
std::vector<cvf::Vec3d> lateralDomainCoords = m_rimFishbonesSubs->coordsForLateral(subIndex, lateralIndex);
std::vector<cvf::Vec3d> displayCoords;
for (auto domainCoord : lateralDomainCoords)
{
displayCoords.push_back(displayCoordTransform->transformToDisplayCoord(domainCoord));
}
geoGenerator.cylinderWithCenterLineParts(&m_parts, displayCoords, wellPath->wellPathColor(), wellPath->combinedScaleFactor() * characteristicCellSize * 0.5);
}
}
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo(m_rimFishbonesSubs);
for (auto part : m_parts)
{
part->setSourceInfo(objectSourceInfo.p());
}
}

View File

@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "cafPdmPointer.h"
#include "cvfBase.h"
#include "cvfMatrix4.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cvfCollection.h"
#include "cvfColor3.h"
namespace cvf
{
class ModelBasicList;
class DrawableGeo;
class Part;
class Transform;
}
namespace caf
{
class DisplayCoordTransform;
}
class RimFishbonesMultipleSubs;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RivFishbonesSubsPartMgr : public cvf::Object
{
public:
RivFishbonesSubsPartMgr(RimFishbonesMultipleSubs* subs);
~RivFishbonesSubsPartMgr();
void appendGeometryPartsToModel(cvf::ModelBasicList* model, caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize);
void clearGeometryCache();
private:
void buildParts(caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize);
private:
caf::PdmPointer<RimFishbonesMultipleSubs> m_rimFishbonesSubs;
cvf::Collection<cvf::Part> m_parts;
};

Some files were not shown because too many files have changed in this diff Show More