mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3058 Implement a memory cleanup dialog for GeoMech data.
This commit is contained in:
parent
e3bffafb46
commit
d13a52a8b4
@ -9,6 +9,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaRftPltCurveDefinition.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaMemoryCleanup.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -22,6 +23,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaRftPltCurveDefinition.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaMemoryCleanup.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
228
ApplicationCode/Application/RiaMemoryCleanup.cpp
Normal file
228
ApplicationCode/Application/RiaMemoryCleanup.cpp
Normal file
@ -0,0 +1,228 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- 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 "RiaMemoryCleanup.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RigFemResultAddress.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "Rim3dView.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechResultDefinition.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RiaMemoryCleanup, "RiaMemoryCleanup");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaMemoryCleanup::RiaMemoryCleanup()
|
||||
{
|
||||
// clang-format off
|
||||
CAF_PDM_InitFieldNoDefault(&m_case, "DataCase", "Case", "", "", "");
|
||||
m_case = nullptr;
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_resultsToDelete, "ResultsToDelete", "Results In Memory", "", "", "");
|
||||
m_resultsToDelete.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
|
||||
m_resultsToDelete.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_performDelete, "ClearSelectedData", "", "", "", "");
|
||||
caf::PdmUiPushButtonEditor::configureEditorForField(&m_performDelete);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaMemoryCleanup::setPropertiesFromView(Rim3dView* view)
|
||||
{
|
||||
if (!view) return;
|
||||
|
||||
m_case = view->ownerCase();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaMemoryCleanup::clearSelectedResultsFromMemory()
|
||||
{
|
||||
RimGeoMechCase* geoMechCase = dynamic_cast<RimGeoMechCase*>(m_case());
|
||||
if (geoMechCase)
|
||||
{
|
||||
RigGeoMechCaseData* data = geoMechCase->geoMechData();
|
||||
if (data)
|
||||
{
|
||||
RigFemPartResultsCollection* resultsCollection = data->femPartResults();
|
||||
if (resultsCollection)
|
||||
{
|
||||
std::vector<RigFemResultAddress> resultsToDelete = selectedGeoMechResults();
|
||||
for (RigFemResultAddress result : resultsToDelete)
|
||||
{
|
||||
resultsCollection->deleteResult(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_resultsToDelete.v().clear();
|
||||
m_geomResultAddresses.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RigFemResultAddress> RiaMemoryCleanup::selectedGeoMechResults() const
|
||||
{
|
||||
std::vector<RigFemResultAddress> results;
|
||||
for (size_t index : m_resultsToDelete())
|
||||
{
|
||||
results.push_back(m_geomResultAddresses[index]);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RigFemResultAddress> RiaMemoryCleanup::findGeoMechCaseResultsInUse() const
|
||||
{
|
||||
std::set<RigFemResultAddress> resultsInUse;
|
||||
RimGeoMechCase* geoMechCase = dynamic_cast<RimGeoMechCase*>(m_case());
|
||||
if (geoMechCase)
|
||||
{
|
||||
std::vector<RimFemResultObserver*> geoMechResults;
|
||||
geoMechCase->descendantsIncludingThisOfType(geoMechResults);
|
||||
for (RimFemResultObserver* resultDef : geoMechResults)
|
||||
{
|
||||
caf::PdmField<bool>* field = dynamic_cast<caf::PdmField<bool>*>(resultDef->objectToggleField());
|
||||
if (!field || (*field)())
|
||||
{
|
||||
std::vector<RigFemResultAddress> required = resultDef->observedResults();
|
||||
resultsInUse.insert(required.begin(), required.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultsInUse;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaMemoryCleanup::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &m_case)
|
||||
{
|
||||
m_resultsToDelete.uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
else if (changedField == &m_performDelete)
|
||||
{
|
||||
clearSelectedResultsFromMemory();
|
||||
m_resultsToDelete.uiCapability()->updateConnectedEditors();
|
||||
m_performDelete = false;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RiaMemoryCleanup::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
if (fieldNeedingOptions == &m_case)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
if (proj)
|
||||
{
|
||||
std::vector<RimGeoMechCase*> cases = proj->geoMechCases();
|
||||
|
||||
for (RimGeoMechCase* c : cases)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(c->caseUserDescription(), c, false, c->uiIcon()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fieldNeedingOptions == &m_resultsToDelete)
|
||||
{
|
||||
RimGeoMechCase* geoMechCase = dynamic_cast<RimGeoMechCase*>(m_case());
|
||||
if (geoMechCase)
|
||||
{
|
||||
std::set<RigFemResultAddress> resultsInUse = findGeoMechCaseResultsInUse();
|
||||
RigGeoMechCaseData* caseData = geoMechCase->geoMechData();
|
||||
if (caseData)
|
||||
{
|
||||
RigFemPartResultsCollection* results = caseData->femPartResults();
|
||||
m_geomResultAddresses = results->loadedResults();
|
||||
|
||||
for (size_t i = 0; i < m_geomResultAddresses.size(); ++i)
|
||||
{
|
||||
const RigFemResultAddress& result = m_geomResultAddresses[i];
|
||||
bool inUse = resultsInUse.count(result);
|
||||
QString posText = caf::AppEnum<RigFemResultPosEnum>::uiTextFromIndex(result.resultPosType);
|
||||
QString resultsText = QString("%1, %2").arg(posText).arg(QString::fromStdString(result.fieldName));
|
||||
if (!result.componentName.empty())
|
||||
{
|
||||
resultsText += QString(", %1").arg(QString::fromStdString(result.componentName));
|
||||
}
|
||||
if (inUse)
|
||||
{
|
||||
resultsText += QString(" [shown in view]");
|
||||
}
|
||||
options.push_back(caf::PdmOptionItemInfo(resultsText, (qulonglong) i, inUse));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaMemoryCleanup::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
uiOrdering.add(&m_case);
|
||||
uiOrdering.add(&m_resultsToDelete);
|
||||
uiOrdering.add(&m_performDelete);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaMemoryCleanup::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
||||
{
|
||||
if (field == &m_performDelete)
|
||||
{
|
||||
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>(attribute);
|
||||
if (attrib)
|
||||
{
|
||||
attrib->m_buttonText = "Clear Checked Data From Memory";
|
||||
}
|
||||
}
|
||||
}
|
55
ApplicationCode/Application/RiaMemoryCleanup.h
Normal file
55
ApplicationCode/Application/RiaMemoryCleanup.h
Normal file
@ -0,0 +1,55 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- 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 "RigFemResultAddress.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmUiItem.h"
|
||||
|
||||
class RimCase;
|
||||
class Rim3dView;
|
||||
|
||||
class RiaMemoryCleanup : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
RiaMemoryCleanup();
|
||||
|
||||
void setPropertiesFromView(Rim3dView* view);
|
||||
void clearSelectedResultsFromMemory();
|
||||
protected:
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
private:
|
||||
std::vector<RigFemResultAddress> selectedGeoMechResults() const;
|
||||
std::set<RigFemResultAddress> findGeoMechCaseResultsInUse() const;
|
||||
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly) override;
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
|
||||
private:
|
||||
caf::PdmPtrField<RimCase*> m_case;
|
||||
caf::PdmField<std::vector<size_t>> m_resultsToDelete;
|
||||
std::vector<RigFemResultAddress> m_geomResultAddresses;
|
||||
caf::PdmField<bool> m_performDelete;
|
||||
};
|
@ -15,6 +15,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicEditPreferencesFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicLaunchRegressionTestsFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicRunCommandFileFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowMemoryCleanupDialogFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -33,6 +34,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicEditPreferencesFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicLaunchRegressionTestsFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicRunCommandFileFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowMemoryCleanupDialogFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,65 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicShowMemoryCleanupDialogFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaMemoryCleanup.h"
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicShowMemoryCleanupDialogFeature, "RicShowMemoryCleanupDialogFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicShowMemoryCleanupDialogFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicShowMemoryCleanupDialogFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RiaMemoryCleanup memoryCleanup;
|
||||
Rim3dView* view = RiaApplication::instance()->activeReservoirView();
|
||||
if (view)
|
||||
{
|
||||
memoryCleanup.setPropertiesFromView(view);
|
||||
}
|
||||
|
||||
caf::PdmUiPropertyViewDialog dialog(RiuMainWindow::instance(), &memoryCleanup, "Clear Results From Memory", "", QDialogButtonBox::Close);
|
||||
dialog.resize(QSize(400, 400));
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
memoryCleanup.clearSelectedResultsFromMemory();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicShowMemoryCleanupDialogFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("&Memory Cleanup...");
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- 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 RicShowMemoryCleanupDialogFeature : 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;
|
||||
};
|
||||
|
||||
|
@ -26,8 +26,10 @@ add_library( ${PROJECT_NAME}
|
||||
RigFemPartGrid.cpp
|
||||
RigFemResultAddress.h
|
||||
RigFemResultPosEnum.h
|
||||
RimGeoMechGeometrySelectionItem.h
|
||||
RimGeoMechGeometrySelectionItem.cpp
|
||||
RimFemResultObserver.h
|
||||
RimFemResultObserver.cpp
|
||||
RimGeoMechGeometrySelectionItem.h
|
||||
RimGeoMechGeometrySelectionItem.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
|
@ -92,3 +92,16 @@ void RigFemPartResults::deleteScalarResult(const RigFemResultAddress& resVarAddr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RigFemResultAddress> RigFemPartResults::loadedResults() const
|
||||
{
|
||||
std::vector<RigFemResultAddress> currentResults;
|
||||
for (const auto& result : resultSets)
|
||||
{
|
||||
currentResults.push_back(result.first);
|
||||
}
|
||||
return currentResults;
|
||||
}
|
||||
|
@ -39,9 +39,10 @@ public:
|
||||
|
||||
void initResultSteps(const std::vector<std::string>& stepNames);
|
||||
|
||||
RigFemScalarResultFrames* createScalarResult(const RigFemResultAddress& resVarAddr);
|
||||
RigFemScalarResultFrames* findScalarResult(const RigFemResultAddress& resVarAddr);
|
||||
void deleteScalarResult(const RigFemResultAddress& resVarAddr);
|
||||
RigFemScalarResultFrames* createScalarResult(const RigFemResultAddress& resVarAddr);
|
||||
RigFemScalarResultFrames* findScalarResult(const RigFemResultAddress& resVarAddr);
|
||||
void deleteScalarResult(const RigFemResultAddress& resVarAddr);
|
||||
std::vector<RigFemResultAddress> loadedResults() const;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -2243,6 +2243,20 @@ void RigFemPartResultsCollection::deleteResult(const RigFemResultAddress& resVar
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RigFemResultAddress> RigFemPartResultsCollection::loadedResults() const
|
||||
{
|
||||
std::vector<RigFemResultAddress> currentResults;
|
||||
for (auto & femPartResult : m_femPartResults)
|
||||
{
|
||||
std::vector<RigFemResultAddress> partResults = femPartResult->loadedResults();
|
||||
currentResults.insert(currentResults.end(), partResults.begin(), partResults.end());
|
||||
}
|
||||
return currentResults;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -2263,40 +2277,19 @@ std::vector<caf::Ten3f> RigFemPartResultsCollection::tensors(const RigFemResultA
|
||||
|
||||
std::vector<caf::Ten3f> outputTensors;
|
||||
|
||||
RigFemResultAddress address11(resVarAddr.resultPosType, resVarAddr.fieldName, "");
|
||||
RigFemResultAddress address22(resVarAddr.resultPosType, resVarAddr.fieldName, "");
|
||||
RigFemResultAddress address33(resVarAddr.resultPosType, resVarAddr.fieldName, "");
|
||||
RigFemResultAddress address12(resVarAddr.resultPosType, resVarAddr.fieldName, "");
|
||||
RigFemResultAddress address13(resVarAddr.resultPosType, resVarAddr.fieldName, "");
|
||||
RigFemResultAddress address23(resVarAddr.resultPosType, resVarAddr.fieldName, "");
|
||||
std::vector<RigFemResultAddress> addresses = tensorComponentAddresses(resVarAddr);
|
||||
|
||||
if (resVarAddr.fieldName == "SE" || resVarAddr.fieldName == "ST")
|
||||
if (addresses.empty())
|
||||
{
|
||||
address11.componentName = "S11";
|
||||
address22.componentName = "S22";
|
||||
address33.componentName = "S33";
|
||||
address12.componentName = "S12";
|
||||
address13.componentName = "S13";
|
||||
address23.componentName = "S23";
|
||||
}
|
||||
else if (resVarAddr.fieldName == "NE")
|
||||
{
|
||||
address11.componentName = "E11";
|
||||
address22.componentName = "E22";
|
||||
address33.componentName = "E33";
|
||||
address12.componentName = "E12";
|
||||
address13.componentName = "E13";
|
||||
address23.componentName = "E23";
|
||||
}
|
||||
else
|
||||
return outputTensors;
|
||||
}
|
||||
|
||||
const std::vector<float>& v11 = resultValues(address11, partIndex, frameIndex);
|
||||
const std::vector<float>& v22 = resultValues(address22, partIndex, frameIndex);
|
||||
const std::vector<float>& v33 = resultValues(address33, partIndex, frameIndex);
|
||||
const std::vector<float>& v12 = resultValues(address12, partIndex, frameIndex);
|
||||
const std::vector<float>& v13 = resultValues(address13, partIndex, frameIndex);
|
||||
const std::vector<float>& v23 = resultValues(address23, partIndex, frameIndex);
|
||||
const std::vector<float>& v11 = resultValues(addresses[caf::Ten3f::SXX], partIndex, frameIndex);
|
||||
const std::vector<float>& v22 = resultValues(addresses[caf::Ten3f::SYY], partIndex, frameIndex);
|
||||
const std::vector<float>& v33 = resultValues(addresses[caf::Ten3f::SZZ], partIndex, frameIndex);
|
||||
const std::vector<float>& v12 = resultValues(addresses[caf::Ten3f::SXY], partIndex, frameIndex);
|
||||
const std::vector<float>& v13 = resultValues(addresses[caf::Ten3f::SZX], partIndex, frameIndex);
|
||||
const std::vector<float>& v23 = resultValues(addresses[caf::Ten3f::SYZ], partIndex, frameIndex);
|
||||
|
||||
size_t valCount = v11.size();
|
||||
outputTensors.resize(valCount);
|
||||
@ -2568,6 +2561,38 @@ void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents(con
|
||||
*globalNegClosestToZero = currentNegClosestToZero;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RigFemResultAddress> RigFemPartResultsCollection::tensorComponentAddresses(const RigFemResultAddress& resVarAddr)
|
||||
{
|
||||
std::vector<RigFemResultAddress> addresses(6, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, ""));
|
||||
|
||||
if (resVarAddr.fieldName == "SE" || resVarAddr.fieldName == "ST")
|
||||
{
|
||||
addresses[caf::Ten3f::SXX].componentName = "S11";
|
||||
addresses[caf::Ten3f::SYY].componentName = "S22";
|
||||
addresses[caf::Ten3f::SZZ].componentName = "S33";
|
||||
addresses[caf::Ten3f::SXY].componentName = "S12";
|
||||
addresses[caf::Ten3f::SZX].componentName = "S13";
|
||||
addresses[caf::Ten3f::SYZ].componentName = "S23";
|
||||
}
|
||||
else if (resVarAddr.fieldName == "NE")
|
||||
{
|
||||
addresses[caf::Ten3f::SXX].componentName = "E11";
|
||||
addresses[caf::Ten3f::SYY].componentName = "E22";
|
||||
addresses[caf::Ten3f::SZZ].componentName = "E33";
|
||||
addresses[caf::Ten3f::SXY].componentName = "E12";
|
||||
addresses[caf::Ten3f::SZX].componentName = "E13";
|
||||
addresses[caf::Ten3f::SYZ].componentName = "E23";
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::vector<RigFemResultAddress>();
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -68,6 +68,8 @@ public:
|
||||
bool assertResultsLoaded(const RigFemResultAddress& resVarAddr);
|
||||
void deleteResult(const RigFemResultAddress& resVarAddr);
|
||||
|
||||
std::vector<RigFemResultAddress> loadedResults() const;
|
||||
|
||||
const std::vector<float>& resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex);
|
||||
std::vector<caf::Ten3f> tensors(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex);
|
||||
int partCount() const;
|
||||
@ -92,6 +94,10 @@ public:
|
||||
void minMaxScalarValuesOverAllTensorComponents(const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax);
|
||||
void posNegClosestToZeroOverAllTensorComponents(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero);
|
||||
void posNegClosestToZeroOverAllTensorComponents(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero);
|
||||
|
||||
static std::vector<RigFemResultAddress> tensorComponentAddresses(const RigFemResultAddress& resVarAddr);
|
||||
static std::vector<RigFemResultAddress> tensorPrincipalComponentAdresses(const RigFemResultAddress& resVarAddr);
|
||||
|
||||
private:
|
||||
RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex,
|
||||
const RigFemResultAddress& resVarAddr);
|
||||
@ -127,9 +133,7 @@ private:
|
||||
RigFemScalarResultFrames* calculateST_12_13_23(int partIndex, const RigFemResultAddress &resVarAddr);
|
||||
RigFemScalarResultFrames* calculateGamma(int partIndex, const RigFemResultAddress &resVarAddr);
|
||||
RigFemScalarResultFrames* calculateFormationIndices(int partIndex, const RigFemResultAddress &resVarAddr);
|
||||
|
||||
static std::vector<RigFemResultAddress> tensorPrincipalComponentAdresses(const RigFemResultAddress& resVarAddr);
|
||||
|
||||
|
||||
private:
|
||||
cvf::Collection<RigFemPartResults> m_femPartResults;
|
||||
cvf::ref<RifGeoMechReaderInterface> m_readerInterface;
|
||||
|
@ -0,0 +1,4 @@
|
||||
#include "RimFemResultObserver.h"
|
||||
|
||||
CAF_PDM_ABSTRACT_SOURCE_INIT(RimFemResultObserver, "RimFemResultObserver");
|
||||
|
@ -0,0 +1,32 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- 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 "RigFemResultAddress.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimFemResultObserver : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
virtual std::vector<RigFemResultAddress> observedResults() const = 0;
|
||||
};
|
@ -509,7 +509,7 @@ void RimGeoMechResultDefinition::setAddWellPathDerivedResults(bool addWellPathDe
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigFemResultAddress RimGeoMechResultDefinition::resultAddress()
|
||||
RigFemResultAddress RimGeoMechResultDefinition::resultAddress() const
|
||||
{
|
||||
return RigFemResultAddress(resultPositionType(),
|
||||
resultFieldName().toStdString(),
|
||||
@ -518,6 +518,38 @@ RigFemResultAddress RimGeoMechResultDefinition::resultAddress()
|
||||
resultFieldName().toStdString() == RigFemPartResultsCollection::FIELD_NAME_COMPACTION ? m_compactionRefLayer() : RigFemResultAddress::NO_COMPACTION);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RigFemResultAddress> RimGeoMechResultDefinition::observedResults() const
|
||||
{
|
||||
return std::vector<RigFemResultAddress>(1, resultAddress());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigFemResultPosEnum RimGeoMechResultDefinition::resultPositionType() const
|
||||
{
|
||||
return m_resultPositionType();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimGeoMechResultDefinition::resultFieldName() const
|
||||
{
|
||||
return m_resultFieldName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimGeoMechResultDefinition::resultComponentName() const
|
||||
{
|
||||
return m_resultComponentName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "cafAppEnum.h"
|
||||
#include "RigFemResultPosEnum.h"
|
||||
#include "RigFemResultAddress.h"
|
||||
#include "RimFemResultObserver.h"
|
||||
|
||||
class RimGeoMechView;
|
||||
class RimGeoMechPropertyFilter;
|
||||
@ -36,7 +37,7 @@ class RimGeoMechCase;
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimGeoMechResultDefinition : public caf::PdmObject
|
||||
class RimGeoMechResultDefinition : public RimFemResultObserver
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
@ -50,11 +51,12 @@ public:
|
||||
void loadResult();
|
||||
void setAddWellPathDerivedResults(bool addWellPathDerivedResults);
|
||||
|
||||
RigFemResultAddress resultAddress();
|
||||
RigFemResultAddress resultAddress() const;
|
||||
virtual std::vector<RigFemResultAddress> observedResults() const override;
|
||||
|
||||
RigFemResultPosEnum resultPositionType() { return m_resultPositionType();}
|
||||
QString resultFieldName() { return m_resultFieldName();}
|
||||
QString resultComponentName() { return m_resultComponentName();}
|
||||
RigFemResultPosEnum resultPositionType() const;
|
||||
QString resultFieldName() const;
|
||||
QString resultComponentName() const;
|
||||
void setResultAddress(const RigFemResultAddress& resultAddress);
|
||||
|
||||
QString resultFieldUiName();
|
||||
|
@ -214,6 +214,18 @@ void RimTensorResults::mappingRange(double* min, double* max) const
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RigFemResultAddress> RimTensorResults::observedResults() const
|
||||
{
|
||||
RigFemResultAddress mainResult = selectedTensorResult();
|
||||
std::vector<RigFemResultAddress> tensorComponents = RigFemPartResultsCollection::tensorComponentAddresses(mainResult);
|
||||
std::vector<RigFemResultAddress> principleComponents = RigFemPartResultsCollection::tensorPrincipalComponentAdresses(mainResult);
|
||||
tensorComponents.insert(tensorComponents.end(), principleComponents.begin(), principleComponents.end());
|
||||
return tensorComponents;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "RimFemResultObserver.h"
|
||||
#include "RigFemResultPosEnum.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
|
||||
@ -36,7 +37,7 @@ class RimRegularLegendConfig;
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimTensorResults : public caf::PdmObject
|
||||
class RimTensorResults : public RimFemResultObserver
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
@ -72,9 +73,10 @@ public:
|
||||
|
||||
void mappingRange(double *min, double* max) const;
|
||||
|
||||
static RigFemResultPosEnum resultPositionType();
|
||||
QString resultFieldName() const;
|
||||
static QString uiFieldName(const QString& fieldName);
|
||||
std::vector<RigFemResultAddress> observedResults() const;
|
||||
static RigFemResultPosEnum resultPositionType();
|
||||
QString resultFieldName() const;
|
||||
static QString uiFieldName(const QString& fieldName);
|
||||
|
||||
caf::PdmChildField<RimRegularLegendConfig*> arrowColorLegendConfig;
|
||||
|
||||
|
@ -26,6 +26,10 @@
|
||||
#include "RiaRegressionTest.h"
|
||||
#include "RiaRegressionTestRunner.h"
|
||||
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
|
||||
#include "Rim2dIntersectionView.h"
|
||||
#include "Rim3dView.h"
|
||||
#include "RimCellEdgeColors.h"
|
||||
@ -54,6 +58,7 @@
|
||||
#include "RiuRelativePermeabilityPlotPanel.h"
|
||||
#include "RiuResultInfoPanel.h"
|
||||
#include "RiuResultQwtPlot.h"
|
||||
#include "RiuTextDialog.h"
|
||||
#include "RiuToolTipMenu.h"
|
||||
#include "RiuTreeViewEventFilter.h"
|
||||
#include "RiuViewer.h"
|
||||
@ -84,6 +89,7 @@
|
||||
#include <QLayout>
|
||||
#include <QMdiSubWindow>
|
||||
#include <QMenuBar>
|
||||
#include <QToolButton>
|
||||
#include <QSpinBox>
|
||||
#include <QStatusBar>
|
||||
#include <QTimer>
|
||||
@ -145,13 +151,17 @@ RiuMainWindow::RiuMainWindow()
|
||||
//caf::CmdExecCommandManager::instance()->enableUndoCommandSystem(true);
|
||||
|
||||
m_memoryCriticalWarning = new QLabel("");
|
||||
m_memoryUsedStatus = new QLabel("");
|
||||
m_memoryUsedButton = new QToolButton(nullptr);
|
||||
m_memoryTotalStatus = new QLabel("");
|
||||
|
||||
m_memoryUsedButton->setDefaultAction(caf::CmdFeatureManager::instance()->action("RicShowMemoryCleanupDialogFeature"));
|
||||
|
||||
statusBar()->addPermanentWidget(m_memoryCriticalWarning);
|
||||
statusBar()->addPermanentWidget(m_memoryUsedStatus);
|
||||
statusBar()->addPermanentWidget(m_memoryUsedButton);
|
||||
statusBar()->addPermanentWidget(m_memoryTotalStatus);
|
||||
|
||||
|
||||
|
||||
updateMemoryUsage();
|
||||
|
||||
m_memoryRefreshTimer = new QTimer(this);
|
||||
@ -456,6 +466,8 @@ void RiuMainWindow::createMenus()
|
||||
QMenu* editMenu = menuBar()->addMenu("&Edit");
|
||||
editMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToClipboardFeature"));
|
||||
editMenu->addSeparator();
|
||||
editMenu->addAction(cmdFeatureMgr->action("RicShowMemoryCleanupDialogFeature"));
|
||||
editMenu->addSeparator();
|
||||
editMenu->addAction(cmdFeatureMgr->action("RicEditPreferencesFeature"));
|
||||
|
||||
connect(editMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshEditActions()));
|
||||
@ -1732,10 +1744,10 @@ void RiuMainWindow::updateMemoryUsage()
|
||||
m_memoryCriticalWarning->setText(QString(""));
|
||||
}
|
||||
|
||||
m_memoryUsedStatus->setText(QString("Physical Memory Used: %1 MiB").arg(currentUsage));
|
||||
m_memoryUsedButton->setText(QString("Memory Used: %1 MiB").arg(currentUsage));
|
||||
m_memoryTotalStatus->setText(QString("Total Physical Memory: %1 MiB").arg(totalPhysicalMemory));
|
||||
|
||||
m_memoryUsedStatus->setStyleSheet(QString("QLabel {color: %1; padding: 0px 5px 0px 0px;}").arg(usageColor.name()));
|
||||
m_memoryUsedButton->setStyleSheet(QString("QLabel {color: %1; padding: 0px 5px 0px 0px;}").arg(usageColor.name()));
|
||||
m_memoryTotalStatus->setStyleSheet(QString("QLabel {padding: 0px 5px 0px 0px; }"));
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
class QActionGroup;
|
||||
class QMdiSubWindow;
|
||||
class QToolButton;
|
||||
class QSpinBox;
|
||||
class QTimer;
|
||||
class QUndoView;
|
||||
@ -183,7 +184,7 @@ private:
|
||||
|
||||
QMenu* m_windowMenu;
|
||||
QLabel* m_memoryCriticalWarning;
|
||||
QLabel* m_memoryUsedStatus;
|
||||
QToolButton* m_memoryUsedButton;
|
||||
QLabel* m_memoryTotalStatus;
|
||||
QTimer* m_memoryRefreshTimer;
|
||||
|
||||
|
@ -314,15 +314,20 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
QModelIndexList indices = allVisibleSourceModelIndices();
|
||||
if (indices.size() > 0)
|
||||
{
|
||||
bool allItemsChecked = true;
|
||||
size_t editableItems = 0u;
|
||||
size_t checkedEditableItems = 0u;
|
||||
for (auto mi : indices)
|
||||
{
|
||||
if (m_model->data(mi, Qt::CheckStateRole).toBool() == false)
|
||||
if (!m_model->isReadOnly(mi))
|
||||
{
|
||||
allItemsChecked = false;
|
||||
editableItems++;
|
||||
if (m_model->isChecked(mi))
|
||||
{
|
||||
checkedEditableItems++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool allItemsChecked = (editableItems > 0u && checkedEditableItems == editableItems);
|
||||
m_toggleAllCheckBox->setChecked(allItemsChecked);
|
||||
}
|
||||
}
|
||||
|
@ -108,14 +108,22 @@ void caf::PdmUiTreeSelectionQModel::setCheckedStateForItems(const QModelIndexLis
|
||||
{
|
||||
for (auto mi : sourceModelIndices)
|
||||
{
|
||||
selectedIndices.insert(static_cast<unsigned int>(optionIndex(mi)));
|
||||
const caf::PdmOptionItemInfo* optionItemInfo = optionItem(mi);
|
||||
if (!optionItemInfo->isReadOnly())
|
||||
{
|
||||
selectedIndices.insert(static_cast<unsigned int>(optionIndex(mi)));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto mi : sourceModelIndices)
|
||||
{
|
||||
selectedIndices.erase(static_cast<unsigned int>(optionIndex(mi)));
|
||||
const caf::PdmOptionItemInfo* optionItemInfo = optionItem(mi);
|
||||
if (!optionItemInfo->isReadOnly())
|
||||
{
|
||||
selectedIndices.erase(static_cast<unsigned int>(optionIndex(mi)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,6 +202,22 @@ void caf::PdmUiTreeSelectionQModel::resetUiValueCache()
|
||||
m_uiValueCache = nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::PdmUiTreeSelectionQModel::isReadOnly(const QModelIndex& index) const
|
||||
{
|
||||
return optionItem(index)->isReadOnly();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::PdmUiTreeSelectionQModel::isChecked(const QModelIndex& index) const
|
||||
{
|
||||
return data(index, Qt::CheckStateRole).toBool();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -71,6 +71,8 @@ public:
|
||||
void setOptions(caf::PdmUiFieldEditorHandle* field, const QList<caf::PdmOptionItemInfo>& options);
|
||||
void setUiValueCache(const QVariant* uiValuesCache );
|
||||
void resetUiValueCache();
|
||||
bool isReadOnly(const QModelIndex& index) const;
|
||||
bool isChecked(const QModelIndex& index) const;
|
||||
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
Loading…
Reference in New Issue
Block a user