#1240 Added checbox to StimPlan Colors

This commit is contained in:
Magne Sjaastad
2017-02-22 15:32:19 +01:00
parent 5ba0a37f34
commit 139590760f
4 changed files with 47 additions and 19 deletions

View File

@@ -119,7 +119,11 @@ void RivWellFracturePartMgr::updatePartGeometryTexture(caf::DisplayCoordTransfor
if (activeView) if (activeView)
{ {
stimPlanColors = activeView->stimPlanColors; stimPlanColors = activeView->stimPlanColors;
legendConfig = stimPlanColors->activeLegend();
if (stimPlanColors->isChecked())
{
legendConfig = stimPlanColors->activeLegend();
}
} }
// Note : If no legend is found, draw geo using a single color // Note : If no legend is found, draw geo using a single color
@@ -152,6 +156,7 @@ void RivWellFracturePartMgr::updatePartGeometryTexture(caf::DisplayCoordTransfor
m_part = new cvf::Part; m_part = new cvf::Part;
m_part->setDrawable(geo.p()); m_part->setDrawable(geo.p());
float opacityLevel = activeView->stimPlanColors->opacityLevel();
if (legendConfig) if (legendConfig)
{ {
cvf::ScalarMapper* scalarMapper = legendConfig->scalarMapper(); cvf::ScalarMapper* scalarMapper = legendConfig->scalarMapper();
@@ -182,7 +187,6 @@ void RivWellFracturePartMgr::updatePartGeometryTexture(caf::DisplayCoordTransfor
caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_NEG_LARGE); caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_NEG_LARGE);
float opacityLevel = activeView->stimPlanColors->opacityLevel();
effGen.setOpacityLevel(opacityLevel); effGen.setOpacityLevel(opacityLevel);
if (activeView && activeView->isLightingDisabled()) if (activeView && activeView->isLightingDisabled())
@@ -190,7 +194,6 @@ void RivWellFracturePartMgr::updatePartGeometryTexture(caf::DisplayCoordTransfor
effGen.disableLighting(true); effGen.disableLighting(true);
} }
m_part->setPriority(RivPartPriority::PartType::Transparent);
cvf::ref<cvf::Effect> eff = effGen.generateCachedEffect(); cvf::ref<cvf::Effect> eff = effGen.generateCachedEffect();
@@ -198,10 +201,15 @@ void RivWellFracturePartMgr::updatePartGeometryTexture(caf::DisplayCoordTransfor
} }
else else
{ {
caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN)), caf::PO_1); cvf::Color4f fractureColor = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN));
fractureColor.a() = opacityLevel;
caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1);
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect(); cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
m_part->setEffect(eff.p()); m_part->setEffect(eff.p());
} }
m_part->setPriority(RivPartPriority::PartType::Transparent);
} }
} }

View File

@@ -1009,7 +1009,7 @@ void RimEclipseView::updateLegends()
{ {
stimPlanColors->updateLegendData(); stimPlanColors->updateLegendData();
if (stimPlanLegend->legend()) if (stimPlanColors()->isChecked() && stimPlanLegend->legend())
{ {
m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->legend()); m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->legend());
} }

View File

@@ -42,12 +42,13 @@ RimStimPlanColors::RimStimPlanColors()
{ {
CAF_PDM_InitObject("StimPlan Colors", ":/draw_style_faults_24x24.png", "", ""); CAF_PDM_InitObject("StimPlan Colors", ":/draw_style_faults_24x24.png", "", "");
CAF_PDM_InitField(&m_resultNameAndUnit, "ResultName", QString(""), "Result Variable", "", "", ""); CAF_PDM_InitField(&m_resultNameAndUnit, "ResultName", QString(""), "Result Variable", "", "", "");
CAF_PDM_InitField(&opacityLevel, "opacityLevel", 0.2f, "Transparency", "", "", ""); CAF_PDM_InitField(&m_opacityLevel, "opacityLevel", 0.2f, "Transparency", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_legendConfigurations, "LegendConfigurations", "", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_legendConfigurations, "LegendConfigurations", "", "", "", "");
m_legendConfigurations.uiCapability()->setUiTreeHidden(true); m_legendConfigurations.uiCapability()->setUiTreeHidden(true);
m_name = "StimPlan Colors";
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -194,6 +195,14 @@ QString RimStimPlanColors::unit() const
return RimStimPlanColors::toUnit(m_resultNameAndUnit()); return RimStimPlanColors::toUnit(m_resultNameAndUnit());
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float RimStimPlanColors::opacityLevel() const
{
return m_opacityLevel();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -281,3 +290,13 @@ void RimStimPlanColors::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrder
uiTreeOrdering.setForgetRemainingFields(true); uiTreeOrdering.setForgetRemainingFields(true);
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanColors::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_resultNameAndUnit);
uiOrdering.add(&m_opacityLevel);
uiOrdering.setForgetRemainingFields(true);
}

View File

@@ -18,10 +18,11 @@
#pragma once #pragma once
#include "RimCheckableNamedObject.h"
#include "cafAppEnum.h" #include "cafAppEnum.h"
#include "cafPdmChildField.h" #include "cafPdmChildField.h"
#include "cafPdmField.h" #include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmChildArrayField.h" #include "cafPdmChildArrayField.h"
namespace caf { namespace caf {
@@ -35,7 +36,7 @@ class RimFractureTemplateCollection;
/// ///
/// ///
//================================================================================================== //==================================================================================================
class RimStimPlanColors : public caf::PdmObject class RimStimPlanColors : public RimCheckableNamedObject
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
@@ -43,22 +44,21 @@ public:
RimStimPlanColors(); RimStimPlanColors();
virtual ~RimStimPlanColors(); virtual ~RimStimPlanColors();
RimLegendConfig* activeLegend() const; RimLegendConfig* activeLegend() const;
QString resultName() const;
QString resultName() const; QString unit() const;
QString unit() const; float opacityLevel() const;
void loadDataAndUpdate(); void loadDataAndUpdate();
void updateLegendData(); void updateLegendData();
caf::PdmField<float> opacityLevel;
protected: protected:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
private: private:
RimFractureTemplateCollection* fractureTemplateCollection() const; RimFractureTemplateCollection* fractureTemplateCollection() const;
static QString toString(const std::pair<QString, QString>& resultNameAndUnit); static QString toString(const std::pair<QString, QString>& resultNameAndUnit);
@@ -67,6 +67,7 @@ private:
static QString toUnit(const QString& resultNameAndUnit); static QString toUnit(const QString& resultNameAndUnit);
private: private:
caf::PdmField<float> m_opacityLevel;
caf::PdmField<QString> m_resultNameAndUnit; caf::PdmField<QString> m_resultNameAndUnit;
caf::PdmChildArrayField<RimLegendConfig*> m_legendConfigurations; caf::PdmChildArrayField<RimLegendConfig*> m_legendConfigurations;
}; };