#2505 CommandFile. Add scaleFractureTemplate command. Currently accepting arguments width and height

This commit is contained in:
Bjørn Erik Jensen
2018-03-02 14:33:47 +01:00
parent ef2179f1ba
commit 48419480fa
11 changed files with 180 additions and 19 deletions

View File

@@ -18,6 +18,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfSetExportFolder.h
${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.h
${CMAKE_CURRENT_LIST_DIR}/RicfSetStartDir.h
${CMAKE_CURRENT_LIST_DIR}/RicfSetTimeStep.h
${CMAKE_CURRENT_LIST_DIR}/RicfScaleFractureTemplate.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -39,6 +40,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfSetExportFolder.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfSetStartDir.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfSetTimeStep.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfScaleFractureTemplate.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -0,0 +1,71 @@
#include "RicfSetExportFolder.h"
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicfScaleFractureTemplate.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimProject.h"
#include "RimFractureTemplate.h"
#include "RimFractureTemplateCollection.h"
CAF_PDM_SOURCE_INIT(RicfScaleFractureTemplate, "scaleFractureTemplate");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfScaleFractureTemplate::RicfScaleFractureTemplate()
{
RICF_InitField(&m_id, "id", -1, "Id", "", "", "");
RICF_InitField(&m_widthScaleFactor, "width", 1.0, "WidthScaleFactor", "", "", "");
RICF_InitField(&m_heightScaleFactor, "height", 1.0, "HeightScaleFactor", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfScaleFractureTemplate::execute()
{
if (m_id < 0)
{
RiaLogging::error("scaleFractureTemplate: Fracture template id not specified");
return;
}
RimProject* project = RiaApplication::instance()->project();
if (!project)
{
RiaLogging::error("scaleFractureTemplate: Project not found");
return;
}
RimFractureTemplateCollection* templColl = !project->allFractureTemplateCollections().empty() ? project->allFractureTemplateCollections()[0] : nullptr;
RimFractureTemplate* templ = templColl ? templColl->fractureTemplate(m_id) : nullptr;
if (!templ)
{
RiaLogging::error(QString("scaleFractureTemplate: Fracture template not found. Id=%1").arg(m_id));
return;
}
templ->setScaleFactors(m_widthScaleFactor, m_heightScaleFactor);
templ->reload();
}

View File

@@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicfCommandObject.h"
#include "RicfCommandFileExecutor.h"
#include "cafPdmField.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RicfScaleFractureTemplate : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfScaleFractureTemplate();
virtual void execute() override;
private:
caf::PdmField<int> m_id;
caf::PdmField<double> m_widthScaleFactor;
caf::PdmField<double> m_heightScaleFactor;
};

View File

@@ -93,16 +93,12 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha
|| changedField == &m_userDefinedEffectivePermeability
|| changedField == &m_sizeScaleApplyButton)
{
m_sizeScaleApplyButton = false;
//Changes to one of these parameters should change all fractures with this fracture template attached.
RimProject* proj;
this->firstAncestorOrThisOfType(proj);
if (proj)
{
//Regenerate geometry
proj->createDisplayModelAndRedrawAllViews();
setupFractureGridCells();
}
reload();
}
if (changedField == &m_width || changedField == &m_userDefinedEffectivePermeability)
{
setupFractureGridCells();
@@ -322,6 +318,21 @@ std::vector<std::pair<QString, QString>> RimEllipseFractureTemplate::uiResultNam
return propertyNamesAndUnits;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEllipseFractureTemplate::reload()
{
RimProject* proj;
this->firstAncestorOrThisOfType(proj);
if (proj)
{
//Regenerate geometry
proj->createDisplayModelAndRedrawAllViews();
setupFractureGridCells();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -64,6 +64,7 @@ public:
void loadDataAndUpdate() override;
std::vector<std::pair<QString, QString>> uiResultNamesWithUnit() const override;
virtual void reload() override;
protected:
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;

View File

@@ -657,6 +657,15 @@ void RimFractureTemplate::setId(int id)
m_id = id;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFractureTemplate::setScaleFactors(double width, double height)
{
m_widthScaleFactor = width;
m_heightScaleFactor = height;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -144,6 +144,8 @@ public:
void disconnectAllFracturesAndRedrawViews() const;
void setId(int id);
void setScaleFactors(double width, double height);
virtual void reload() {}
protected:
virtual caf::PdmFieldHandle* userDescriptionField() override;

View File

@@ -72,6 +72,18 @@ RimFractureTemplateCollection::~RimFractureTemplateCollection()
m_fractureDefinitions.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFractureTemplate* RimFractureTemplateCollection::fractureTemplate(int id) const
{
for (auto templ : m_fractureDefinitions)
{
if (templ->id() == id) return templ;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -38,6 +38,7 @@ public:
RimFractureTemplateCollection(void);
virtual ~RimFractureTemplateCollection(void);
RimFractureTemplate* fractureTemplate(int id) const;
std::vector<RimFractureTemplate*> fractureTemplates() const;
void addFractureTemplate(RimFractureTemplate* templ);
RiaEclipseUnitTools::UnitSystemType defaultUnitSystemType() const;

View File

@@ -155,17 +155,7 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch
if (changedField == &m_sizeScaleApplyButton)
{
m_sizeScaleApplyButton = false;
loadDataAndUpdate();
//setDefaultsBasedOnXMLfile();
updateFractureGrid();
RimProject* proj;
this->firstAncestorOrThisOfType(proj);
if (proj)
{
proj->createDisplayModelAndRedrawAllViews();
}
reload();
}
}
@@ -548,6 +538,22 @@ void RimStimPlanFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitS
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::reload()
{
loadDataAndUpdate();
RimProject* proj;
this->firstAncestorOrThisOfType(proj);
if (proj)
{
proj->createDisplayModelAndRedrawAllViews();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -91,6 +91,7 @@ public:
void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) override;
virtual void reload() override;
protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;