#3966 Add buttons for creating/editing fracture templates from fractures (#3973)

* #3966 Add buttons for creating/editing fracture templates from fractures

* Make sure view is updated whenever a new template is created from the fracture
This commit is contained in:
Gaute Lindkvist
2019-01-16 14:57:43 +01:00
committed by GitHub
parent 0b9b7e8eb7
commit fb92b548c5
12 changed files with 201 additions and 70 deletions

View File

@@ -88,7 +88,7 @@ void RicCreateDuplicateTemplateInOtherUnitSystemFeature::onActionTriggered(bool
copyOfTemplate->loadDataAndUpdate();
copyOfTemplate->updateConnectedEditors();
RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateCollection, copyOfTemplate);
RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(copyOfTemplate);
}
//--------------------------------------------------------------------------------------------------

View File

@@ -1,6 +1,7 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
// Copyright (C) 2016-2018 Statoil ASA
// Copyright (C) 2018- Equinor 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
@@ -25,6 +26,7 @@
#include "RimFractureTemplateCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimWellPathFracture.h"
#include "Riu3DMainWindowTools.h"
@@ -39,25 +41,27 @@ CAF_CMD_SOURCE_INIT(RicNewEllipseFractureTemplateFeature, "RicNewEllipseFracture
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(RimFractureTemplateCollection* templateCollection,
RimFractureTemplate* fractureTemplate)
void RicNewEllipseFractureTemplateFeature::createNewTemplateForFractureAndUpdate(RimFracture* fracture)
{
RimEllipseFractureTemplate* fractureTemplate = createNewTemplate();
fracture->setFractureTemplate(fractureTemplate);
selectFractureTemplateAndUpdate(fractureTemplate);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(RimFractureTemplate* fractureTemplate)
{
fractureTemplate->loadDataAndUpdate();
RimFractureTemplateCollection* templateCollection = nullptr;
fractureTemplate->firstAncestorOrThisOfTypeAsserted(templateCollection);
templateCollection->updateConnectedEditors();
RimProject* project = RiaApplication::instance()->project();
std::vector<Rim3dView*> views;
project->allVisibleViews(views);
for (Rim3dView* view : views)
{
if (dynamic_cast<RimEclipseView*>(view))
{
view->updateConnectedEditors();
}
}
project->scheduleCreateDisplayModelAndRedrawAllViews();
Riu3DMainWindowTools::selectAsCurrentItem(fractureTemplate);
}
@@ -65,13 +69,13 @@ void RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(RimFr
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked)
RimEllipseFractureTemplate* RicNewEllipseFractureTemplateFeature::createNewTemplate()
{
RimProject* project = RiaApplication::instance()->project();
RimProject* project = RiaApplication::instance()->project();
CVF_ASSERT(project);
RimOilField* oilfield = project->activeOilField();
if (oilfield == nullptr) return;
if (oilfield == nullptr) return nullptr;
RimFractureTemplateCollection* fracDefColl = oilfield->fractureDefinitionCollection();
@@ -84,8 +88,18 @@ void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked)
ellipseFractureTemplate->setUnitSystem(fracDefColl->defaultUnitSystemType());
ellipseFractureTemplate->setDefaultValuesFromUnit();
selectFractureTemplateAndUpdate(fracDefColl, ellipseFractureTemplate);
return ellipseFractureTemplate;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked)
{
RimEllipseFractureTemplate* ellipseFractureTemplate = createNewTemplate();
selectFractureTemplateAndUpdate(ellipseFractureTemplate);
}
//--------------------------------------------------------------------------------------------------

View File

@@ -1,6 +1,8 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
// Copyright (C) 2016-2018 Statoil ASA
// Copyright (C) 2018- Equinor 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
@@ -22,6 +24,8 @@
#include <vector>
class RimEllipseFractureTemplate;
class RimFracture;
class RimFractureTemplate;
class RimFractureTemplateCollection;
@@ -33,10 +37,10 @@ class RicNewEllipseFractureTemplateFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
public:
static void selectFractureTemplateAndUpdate(RimFractureTemplateCollection* templateCollection,
RimFractureTemplate* ellipseFractureTemplate);
static void createNewTemplateForFractureAndUpdate(RimFracture* fracture);
static void selectFractureTemplateAndUpdate(RimFractureTemplate* fractureTemplate);
protected:
static RimEllipseFractureTemplate* createNewTemplate();
void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override;
bool isCommandEnabled() override;

View File

@@ -1,6 +1,7 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
// Copyright (C) 2017-2018 Statoil ASA
// Copyright (C) 2018- Equinor 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
@@ -25,6 +26,7 @@
#include "RimOilField.h"
#include "RimProject.h"
#include "RimStimPlanFractureTemplate.h"
#include "RimWellPathFracture.h"
#include "Riu3DMainWindowTools.h"
@@ -39,26 +41,60 @@
CAF_CMD_SOURCE_INIT(RicNewStimPlanFractureTemplateFeature, "RicNewStimPlanFractureTemplateFeature");
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked)
void RicNewStimPlanFractureTemplateFeature::createNewTemplateForFractureAndUpdate(RimFracture* fracture)
{
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID");
QStringList fileNames = QFileDialog::getOpenFileNames(nullptr, "Open StimPlan XML File", defaultDir, "StimPlan XML File (*.xml);;All files(*.*)");
std::vector<RimStimPlanFractureTemplate*> newTemplates = createNewTemplates();
if (!newTemplates.empty())
{
RimStimPlanFractureTemplate* lastTemplateCreated = newTemplates.back();
fracture->setFractureTemplate(lastTemplateCreated);
selectFractureTemplateAndUpdate(lastTemplateCreated);
}
}
if (fileNames.isEmpty()) return;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewStimPlanFractureTemplateFeature::selectFractureTemplateAndUpdate(RimFractureTemplate* fractureTemplate)
{
fractureTemplate->loadDataAndUpdate();
RimFractureTemplateCollection* templateCollection = nullptr;
fractureTemplate->firstAncestorOrThisOfTypeAsserted(templateCollection);
templateCollection->updateConnectedEditors();
RimProject* project = RiaApplication::instance()->project();
project->scheduleCreateDisplayModelAndRedrawAllViews();
Riu3DMainWindowTools::selectAsCurrentItem(fractureTemplate);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimStimPlanFractureTemplate*> RicNewStimPlanFractureTemplateFeature::createNewTemplates()
{
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID");
QStringList fileNames =
QFileDialog::getOpenFileNames(nullptr, "Open StimPlan XML File", defaultDir, "StimPlan XML File (*.xml);;All files(*.*)");
if (fileNames.isEmpty()) return std::vector<RimStimPlanFractureTemplate*>();
RimProject* project = RiaApplication::instance()->project();
CVF_ASSERT(project);
RimOilField* oilfield = project->activeOilField();
if (oilfield == nullptr) return;
if (oilfield == nullptr) return std::vector<RimStimPlanFractureTemplate*>();
RimFractureTemplateCollection* fracDefColl = oilfield->fractureDefinitionCollection();
if (!fracDefColl) return;
if (!fracDefColl) return std::vector<RimStimPlanFractureTemplate*>();
for(auto fileName : fileNames)
std::vector<RimStimPlanFractureTemplate*> newFractures;
for (auto fileName : fileNames)
{
if (fileName.isEmpty()) continue;
@@ -66,7 +102,7 @@ void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked)
fracDefColl->addFractureTemplate(fractureDef);
QFileInfo stimplanfileFileInfo(fileName);
QString name = stimplanfileFileInfo.baseName();
QString name = stimplanfileFileInfo.baseName();
if (name.isEmpty())
{
name = "StimPlan Fracture Template";
@@ -79,22 +115,18 @@ void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked)
fractureDef->setDefaultsBasedOnXMLfile();
fractureDef->setDefaultWellDiameterFromUnit();
fractureDef->updateFractureGrid();
fracDefColl->updateConnectedEditors();
std::vector<Rim3dView*> views;
project->allVisibleViews(views);
for (Rim3dView* view : views)
{
if (dynamic_cast<RimEclipseView*>(view))
{
view->updateConnectedEditors();
}
}
Riu3DMainWindowTools::selectAsCurrentItem(fractureDef);
newFractures.push_back(fractureDef);
}
return newFractures;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked)
{
std::vector<RimStimPlanFractureTemplate*> newFractures = createNewTemplates();
selectFractureTemplateAndUpdate(newFractures.back());
}
//--------------------------------------------------------------------------------------------------

View File

@@ -1,6 +1,7 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
// Copyright (C) 2017-2018 Statoil ASA
// Copyright (C) 2018- Equinor 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
@@ -22,6 +23,9 @@
#include <vector>
class RimFracture;
class RimFractureTemplate;
class RimStimPlanFractureTemplate;
//==================================================================================================
///
@@ -29,8 +33,11 @@
class RicNewStimPlanFractureTemplateFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
static void createNewTemplateForFractureAndUpdate(RimFracture* fracture);
static void selectFractureTemplateAndUpdate(RimFractureTemplate* fractureTemplate);
protected:
static std::vector<RimStimPlanFractureTemplate*> createNewTemplates();
void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override;
bool isCommandEnabled() override;

View File

@@ -1,6 +1,7 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
// Copyright (C) 2016-2018 Statoil ASA
// Copyright (C) 2018- Equinor 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
@@ -26,7 +27,6 @@
#include "RimCase.h"
#include "RimEclipseView.h"
#include "RimEllipseFractureTemplate.h"
#include "RimFractureTemplateCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
@@ -90,7 +90,10 @@ void RicNewWellPathFractureFeature::addFracture(RimWellPath* wellPath, double me
fracture->setFractureUnit(unitSet);
RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection()->firstFractureOfUnit(unitSet);
fracture->setFractureTemplate(fracDef);
if (fracDef)
{
fracture->setFractureTemplate(fracDef);
}
wellPath->updateConnectedEditors();
Riu3DMainWindowTools::selectAsCurrentItem(fracture);
@@ -108,9 +111,6 @@ void RicNewWellPathFractureFeature::addFracture(RimWellPath* wellPath, double me
//--------------------------------------------------------------------------------------------------
void RicNewWellPathFractureFeature::onActionTriggered(bool isChecked)
{
RimProject* proj = RiaApplication::instance()->project();
if (proj->allFractureTemplates().empty()) return;
RimWellPathFractureCollection* fractureColl = RicNewWellPathFractureFeature::selectedWellPathFractureCollection();
if (!fractureColl) return;
@@ -135,9 +135,6 @@ void RicNewWellPathFractureFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
bool RicNewWellPathFractureFeature::isCommandEnabled()
{
RimProject* proj = RiaApplication::instance()->project();
if (proj->allFractureTemplates().empty()) return false;
if (selectedWellPathFractureCollection())
{
return true;

View File

@@ -78,7 +78,7 @@ void RicPasteEllipseFractureFeature::onActionTriggered(bool isChecked)
fractureTemplateColl->addFractureTemplate(templ);
RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateColl, templ);
RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(templ);
}
return;

View File

@@ -78,7 +78,7 @@ void RicPasteStimPlanFractureFeature::onActionTriggered(bool isChecked)
fractureTemplateColl->addFractureTemplate(copyOfStimPlanTemplate);
RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateColl, copyOfStimPlanTemplate);
RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(copyOfStimPlanTemplate);
}
return;