mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use several colors for faults to be able to separate them
This commit is contained in:
@@ -24,7 +24,8 @@
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
cvf::ref<cvf::Color3fArray> RivColorTableArray::colorTableArray()
|
cvf::ref<cvf::Color3fArray> RivColorTableArray::colorTableArray()
|
||||||
{
|
{
|
||||||
cvf::Color3fArray* partColors = new cvf::Color3fArray();
|
cvf::ref<cvf::Color3fArray> partColors = new cvf::Color3fArray();
|
||||||
|
partColors->reserve(10);
|
||||||
|
|
||||||
partColors->add(cvf::Color3f(101.0f/255, 132.0f/255, 96.0f/255)); // Dark green
|
partColors->add(cvf::Color3f(101.0f/255, 132.0f/255, 96.0f/255)); // Dark green
|
||||||
partColors->add(cvf::Color3f(255.0f/255, 131.0f/255, 140.0f/255)); // Old pink
|
partColors->add(cvf::Color3f(255.0f/255, 131.0f/255, 140.0f/255)); // Old pink
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ RivFaultPart::RivFaultPart(const RigGridBase* grid, const RimFault* rimFault)
|
|||||||
m_rimFault(rimFault),
|
m_rimFault(rimFault),
|
||||||
m_opacityLevel(1.0f),
|
m_opacityLevel(1.0f),
|
||||||
m_defaultColor(cvf::Color3::WHITE)
|
m_defaultColor(cvf::Color3::WHITE)
|
||||||
|
|
||||||
{
|
{
|
||||||
m_faultFacesTextureCoords = new cvf::Vec2fArray;
|
m_faultFacesTextureCoords = new cvf::Vec2fArray;
|
||||||
}
|
}
|
||||||
@@ -74,44 +73,9 @@ void RivFaultPart::setCellVisibility(cvf::UByteArray* cellVisibilities)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RivFaultPart::updateCellColor(cvf::Color4f color)
|
void RivFaultPart::updateCellColor(cvf::Color4f color)
|
||||||
{
|
{
|
||||||
/*
|
m_defaultColor = color;
|
||||||
if (m_surfaceFaces.isNull() && m_faultFaces.isNull()) return;
|
|
||||||
|
|
||||||
// Set default effect
|
|
||||||
caf::SurfaceEffectGenerator geometryEffgen(color, true);
|
|
||||||
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateEffect();
|
|
||||||
|
|
||||||
if (m_surfaceFaces.notNull()) m_surfaceFaces->setEffect(geometryOnlyEffect.p());
|
|
||||||
if (m_faultFaces.notNull()) m_faultFaces->setEffect(geometryOnlyEffect.p());
|
|
||||||
|
|
||||||
if (color.a() < 1.0f)
|
|
||||||
{
|
|
||||||
// Set priority to make sure this transparent geometry are rendered last
|
|
||||||
if (m_surfaceFaces.notNull()) m_surfaceFaces->setPriority(100);
|
|
||||||
if (m_faultFaces.notNull()) m_faultFaces->setPriority(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_opacityLevel = color.a();
|
|
||||||
m_defaultColor = color.toColor3f();
|
|
||||||
|
|
||||||
// Update mesh colors as well, in case of change
|
|
||||||
RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
|
||||||
|
|
||||||
cvf::ref<cvf::Effect> eff;
|
|
||||||
if (m_faultFaces.notNull())
|
|
||||||
{
|
|
||||||
caf::MeshEffectGenerator faultEffGen(prefs->defaultFaultGridLineColors());
|
|
||||||
eff = faultEffGen.generateEffect();
|
|
||||||
m_faultGridLines->setEffect(eff.p());
|
|
||||||
}
|
|
||||||
if (m_surfaceFaces.notNull())
|
|
||||||
{
|
|
||||||
caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors());
|
|
||||||
eff = effGen.generateEffect();
|
|
||||||
m_surfaceGridLines->setEffect(eff.p());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
updatePartEffect();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -251,13 +215,8 @@ void RivFaultPart::generatePartGeometry()
|
|||||||
part->setSourceInfo(m_faultGenerator.triangleToSourceGridCellMap().p());
|
part->setSourceInfo(m_faultGenerator.triangleToSourceGridCellMap().p());
|
||||||
|
|
||||||
part->updateBoundingBox();
|
part->updateBoundingBox();
|
||||||
|
|
||||||
// Set default effect
|
|
||||||
caf::SurfaceEffectGenerator geometryEffgen(cvf::Color4f(cvf::Color3f::WHITE), true);
|
|
||||||
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateEffect();
|
|
||||||
part->setEffect(geometryOnlyEffect.p());
|
|
||||||
|
|
||||||
part->setEnableMask(faultBit);
|
part->setEnableMask(faultBit);
|
||||||
|
|
||||||
m_faultFaces = part;
|
m_faultFaces = part;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,16 +237,53 @@ void RivFaultPart::generatePartGeometry()
|
|||||||
|
|
||||||
//part->setTransform(m_scaleTransform.p());
|
//part->setTransform(m_scaleTransform.p());
|
||||||
part->updateBoundingBox();
|
part->updateBoundingBox();
|
||||||
|
|
||||||
RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
|
||||||
|
|
||||||
caf::MeshEffectGenerator effGen(prefs->defaultFaultGridLineColors());
|
|
||||||
cvf::ref<cvf::Effect> eff = effGen.generateEffect();
|
|
||||||
|
|
||||||
part->setEnableMask(meshFaultBit);
|
part->setEnableMask(meshFaultBit);
|
||||||
part->setEffect(eff.p());
|
|
||||||
m_faultGridLines = part;
|
m_faultGridLines = part;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatePartEffect();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RivFaultPart::updatePartEffect()
|
||||||
|
{
|
||||||
|
if (m_faultFaces.notNull())
|
||||||
|
{
|
||||||
|
cvf::Color3f partColor = m_defaultColor.toColor3f();
|
||||||
|
|
||||||
|
if (m_rimFault->showFaultColor())
|
||||||
|
{
|
||||||
|
partColor = m_rimFault->faultColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_defaultColor.a() < 1.0f)
|
||||||
|
{
|
||||||
|
// Set priority to make sure this transparent geometry are rendered last
|
||||||
|
m_faultFaces->setPriority(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_opacityLevel = m_defaultColor.a();
|
||||||
|
|
||||||
|
// Set default effect
|
||||||
|
caf::SurfaceEffectGenerator geometryEffgen(partColor, true);
|
||||||
|
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateEffect();
|
||||||
|
|
||||||
|
m_faultFaces->setEffect(geometryOnlyEffect.p());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_faultGridLines.notNull())
|
||||||
|
{
|
||||||
|
// Update mesh colors as well, in case of change
|
||||||
|
RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
||||||
|
|
||||||
|
cvf::ref<cvf::Effect> eff;
|
||||||
|
caf::MeshEffectGenerator faultEffGen(prefs->defaultFaultGridLineColors());
|
||||||
|
eff = faultEffGen.generateEffect();
|
||||||
|
m_faultGridLines->setEffect(eff.p());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "RigGridBase.h"
|
#include "RigGridBase.h"
|
||||||
#include "RimFault.h"
|
#include "RimFault.h"
|
||||||
#include "RivFaultGeometryGenerator.h"
|
#include "RivFaultGeometryGenerator.h"
|
||||||
|
#include "cvfColor4.h"
|
||||||
|
|
||||||
namespace cvf
|
namespace cvf
|
||||||
{
|
{
|
||||||
@@ -46,7 +47,9 @@ class RivFaultPart : public cvf::Object
|
|||||||
public:
|
public:
|
||||||
RivFaultPart(const RigGridBase* grid, const RimFault* rimFault);
|
RivFaultPart(const RigGridBase* grid, const RimFault* rimFault);
|
||||||
|
|
||||||
void setCellVisibility(cvf::UByteArray* cellVisibilities );
|
void setCellVisibility(cvf::UByteArray* cellVisibilities);
|
||||||
|
|
||||||
|
void updatePartEffect();
|
||||||
|
|
||||||
void updateCellColor(cvf::Color4f color);
|
void updateCellColor(cvf::Color4f color);
|
||||||
void updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot);
|
void updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot);
|
||||||
@@ -65,7 +68,7 @@ private:
|
|||||||
cvf::ref<cvf::Vec2fArray> m_faultFacesTextureCoords;
|
cvf::ref<cvf::Vec2fArray> m_faultFacesTextureCoords;
|
||||||
|
|
||||||
float m_opacityLevel;
|
float m_opacityLevel;
|
||||||
cvf::Color3f m_defaultColor;
|
cvf::Color4f m_defaultColor;
|
||||||
|
|
||||||
|
|
||||||
cvf::ref<cvf::Part> m_faultGridLines;
|
cvf::ref<cvf::Part> m_faultGridLines;
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ RimFault::RimFault()
|
|||||||
|
|
||||||
CAF_PDM_InitField(&showFaultLabel, "ShowFaultLabel", true, "Show fault label", "", "", "");
|
CAF_PDM_InitField(&showFaultLabel, "ShowFaultLabel", true, "Show fault label", "", "", "");
|
||||||
|
|
||||||
|
CAF_PDM_InitField(&showFaultColor, "ShowFaultColor", true, "Show fault color", "", "", "");
|
||||||
|
CAF_PDM_InitField(&faultColor, "Color", cvf::Color3f(0.588f, 0.588f, 0.804f), "Fault color", "", "", "");
|
||||||
|
|
||||||
|
|
||||||
m_rigFault = NULL;
|
m_rigFault = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +85,17 @@ void RimFault::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const Q
|
|||||||
reservoirView->scheduleCreateDisplayModelAndRedraw();
|
reservoirView->scheduleCreateDisplayModelAndRedraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (&faultColor == changedField)
|
||||||
|
{
|
||||||
|
RimReservoirView* reservoirView = NULL;
|
||||||
|
this->firstAncestorOfType(reservoirView);
|
||||||
|
|
||||||
|
if (reservoirView)
|
||||||
|
{
|
||||||
|
reservoirView->scheduleCreateDisplayModelAndRedraw();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
#include "cafPdmObject.h"
|
#include "cafPdmObject.h"
|
||||||
#include "cafPdmPointer.h"
|
#include "cafPdmPointer.h"
|
||||||
|
|
||||||
|
#include "cvfBase.h"
|
||||||
|
#include "cvfColor3.h"
|
||||||
|
|
||||||
class RigFault;
|
class RigFault;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
@@ -49,6 +52,10 @@ public:
|
|||||||
caf::PdmField<QString> name;
|
caf::PdmField<QString> name;
|
||||||
caf::PdmField<bool> showFaultLabel;
|
caf::PdmField<bool> showFaultLabel;
|
||||||
|
|
||||||
|
caf::PdmField<bool> showFaultColor;
|
||||||
|
caf::PdmField<cvf::Color3f> faultColor;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const RigFault* m_rigFault;
|
const RigFault* m_rigFault;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,6 +33,11 @@
|
|||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
#include "RiaPreferences.h"
|
#include "RiaPreferences.h"
|
||||||
|
|
||||||
|
#include "RimCase.h"
|
||||||
|
#include "RimReservoirCellResultsCacher.h"
|
||||||
|
#include "RigCaseData.h"
|
||||||
|
#include "RivColorTableArray.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT(RimFaultCollection, "Faults");
|
CAF_PDM_SOURCE_INIT(RimFaultCollection, "Faults");
|
||||||
@@ -124,3 +129,37 @@ RimFault* RimFaultCollection::findFaultByName(QString name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimFaultCollection::syncronizeFaults()
|
||||||
|
{
|
||||||
|
if (!(m_reservoirView && m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData()) ) return;
|
||||||
|
|
||||||
|
cvf::ref<cvf::Color3fArray> partColors = RivColorTableArray::colorTableArray();
|
||||||
|
|
||||||
|
const cvf::Collection<RigFault> rigFaults = m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->faults();
|
||||||
|
|
||||||
|
std::vector<caf::PdmPointer<RimFault> > newFaults;
|
||||||
|
|
||||||
|
// Find corresponding fault from data model, or create a new
|
||||||
|
|
||||||
|
for (size_t fIdx = 0; fIdx < rigFaults.size(); ++fIdx)
|
||||||
|
{
|
||||||
|
RimFault* rimFault = this->findFaultByName(rigFaults[fIdx]->name());
|
||||||
|
|
||||||
|
if (!rimFault)
|
||||||
|
{
|
||||||
|
rimFault = new RimFault();
|
||||||
|
rimFault->faultColor = partColors->get(fIdx % partColors->size());
|
||||||
|
}
|
||||||
|
|
||||||
|
rimFault->setFaultGeometry(rigFaults[fIdx].p());
|
||||||
|
|
||||||
|
newFaults.push_back(rimFault);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->faults().clear();
|
||||||
|
this->faults().insert(0, newFaults);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public:
|
|||||||
virtual ~RimFaultCollection();
|
virtual ~RimFaultCollection();
|
||||||
|
|
||||||
void setReservoirView(RimReservoirView* ownerReservoirView);
|
void setReservoirView(RimReservoirView* ownerReservoirView);
|
||||||
|
void syncronizeFaults();
|
||||||
|
|
||||||
caf::PdmField<bool> showGeometryDetectedFaults;
|
caf::PdmField<bool> showGeometryDetectedFaults;
|
||||||
|
|
||||||
@@ -55,11 +56,12 @@ public:
|
|||||||
|
|
||||||
caf::PdmPointersField<RimFault*> faults;
|
caf::PdmPointersField<RimFault*> faults;
|
||||||
|
|
||||||
RimFault* findFaultByName(QString name);
|
|
||||||
|
|
||||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||||
virtual caf::PdmFieldHandle* objectToggleField();
|
virtual caf::PdmFieldHandle* objectToggleField();
|
||||||
|
|
||||||
|
private:
|
||||||
|
RimFault* findFaultByName(QString name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RimReservoirView* m_reservoirView;
|
RimReservoirView* m_reservoirView;
|
||||||
|
|
||||||
|
|||||||
@@ -890,7 +890,8 @@ void RimReservoirView::loadDataAndUpdate()
|
|||||||
|
|
||||||
this->propertyFilterCollection()->loadAndInitializePropertyFilters();
|
this->propertyFilterCollection()->loadAndInitializePropertyFilters();
|
||||||
|
|
||||||
syncronizeFaults();
|
this->faultCollection()->setReservoirView(this);
|
||||||
|
this->faultCollection()->syncronizeFaults();
|
||||||
|
|
||||||
m_reservoirGridPartManager->clearGeometryCache();
|
m_reservoirGridPartManager->clearGeometryCache();
|
||||||
|
|
||||||
@@ -1406,41 +1407,6 @@ void RimReservoirView::syncronizeWellsWithResults()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimReservoirView::syncronizeFaults()
|
|
||||||
{
|
|
||||||
if (!(m_reservoir && m_reservoir->reservoirData()) ) return;
|
|
||||||
|
|
||||||
const cvf::Collection<RigFault> rigFaults = m_reservoir->reservoirData()->mainGrid()->faults();
|
|
||||||
|
|
||||||
std::vector<caf::PdmPointer<RimFault> > newFaults;
|
|
||||||
|
|
||||||
// Find corresponding fault from data model, or create a new
|
|
||||||
|
|
||||||
for (size_t fIdx = 0; fIdx < rigFaults.size(); ++fIdx)
|
|
||||||
{
|
|
||||||
RimFault* rimFault = this->faultCollection()->findFaultByName(rigFaults[fIdx]->name());
|
|
||||||
|
|
||||||
if (!rimFault)
|
|
||||||
{
|
|
||||||
rimFault = new RimFault();
|
|
||||||
}
|
|
||||||
|
|
||||||
rimFault->setFaultGeometry(rigFaults[fIdx].p());
|
|
||||||
|
|
||||||
newFaults.push_back(rimFault);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->faultCollection()->faults().clear();
|
|
||||||
this->faultCollection()->faults().insert(0, newFaults);
|
|
||||||
|
|
||||||
// Make sure all the faults have their reservoirView ptr setup correctly
|
|
||||||
this->faultCollection()->setReservoirView(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -202,7 +202,6 @@ protected:
|
|||||||
// Really private
|
// Really private
|
||||||
private:
|
private:
|
||||||
void syncronizeWellsWithResults();
|
void syncronizeWellsWithResults();
|
||||||
void syncronizeFaults();
|
|
||||||
void clampCurrentTimestep();
|
void clampCurrentTimestep();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user