#1148 Use tristate to indicate visibility of simulation well geometry

This commit is contained in:
Magne Sjaastad 2017-02-01 08:16:30 +01:00
parent 8c01c23e5e
commit a4ce5f532d
4 changed files with 129 additions and 35 deletions

View File

@ -293,7 +293,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
m_wellHeadArrowPart = part;
}
if (m_rimReservoirView->wellCollection()->showWellLabel() && well->showWellLabel() && !well->name().isEmpty())
if (well->showWellLabel() && !well->name().isEmpty())
{
cvf::Font* font = RiaApplication::instance()->customFont();
@ -355,15 +355,13 @@ void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList*
if (m_wellHeadPipeCenterPart.notNull()) model->addPart(m_wellHeadPipeCenterPart.p());
if (m_wellHeadPipeSurfacePart.notNull()) model->addPart(m_wellHeadPipeSurfacePart.p());
if (wellCollection->showWellLabel() &&
m_rimWell->showWellLabel() &&
if (m_rimWell->showWellLabel() &&
m_wellHeadLabelPart.notNull())
{
model->addPart(m_wellHeadLabelPart.p());
}
if (wellCollection->showWellHead() &&
m_rimWell->showWellHead() &&
if (m_rimWell->showWellHead() &&
m_wellHeadArrowPart.notNull())
{
model->addPart(m_wellHeadArrowPart.p());

View File

@ -275,9 +275,6 @@ bool RimEclipseWell::isWellPipeVisible(size_t frameIndex) const
if (!this->showWellPipe())
return false;
if (!reservoirView->wellCollection()->showWellPipe())
return false;
if (reservoirView->crossSectionCollection()->hasActiveIntersectionForSimulationWell(this))
return true;
@ -319,9 +316,6 @@ bool RimEclipseWell::isWellSpheresVisible(size_t frameIndex) const
if (!this->showWell())
return false;
if (!m_reservoirView->wellCollection()->showWellSpheres())
return false;
if (!this->showWellSpheres())
return false;

View File

@ -32,6 +32,7 @@
#include "RivReservoirViewPartMgr.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiCheckBoxTristateEditor.h"
namespace caf
@ -109,10 +110,26 @@ RimEclipseWellCollection::RimEclipseWellCollection()
CAF_PDM_InitField(&showWellsIntersectingVisibleCells, "ShowWellsIntersectingVisibleCells", true, "Show Wells Intersecting Visible Cells", "", "", "");
// Appearance
CAF_PDM_InitField(&showWellHead, "ShowWellHead", true, "Show Well Head", "", "", "");
CAF_PDM_InitField(&showWellLabel, "ShowWellLabel", true, "Show Well Label", "", "", "");
CAF_PDM_InitField(&showWellPipe, "ShowWellPipe", true, "Show Well Pipe", "", "", "");
CAF_PDM_InitField(&showWellSpheres, "ShowWellSpheres", true, "Show Well Spheres", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_showWellHead, "ShowWellHead", "Show Well Head", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_showWellLabel, "ShowWellLabel", "Show Well Label", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_showWellPipe, "ShowWellPipe", "Show Well Pipe", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_showWellSpheres, "ShowWellSpheres", "Show Well Spheres", "", "", "");
m_showWellHead.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName());
m_showWellHead.xmlCapability()->setIOReadable(false);
m_showWellHead.xmlCapability()->setIOWritable(false);
m_showWellLabel.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName());
m_showWellLabel.xmlCapability()->setIOReadable(false);
m_showWellLabel.xmlCapability()->setIOWritable(false);
m_showWellPipe.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName());
m_showWellPipe.xmlCapability()->setIOReadable(false);
m_showWellPipe.xmlCapability()->setIOWritable(false);
m_showWellSpheres.uiCapability()->setUiEditorTypeName(caf::PdmUiCheckBoxTristateEditor::uiEditorTypeName());
m_showWellSpheres.xmlCapability()->setIOReadable(false);
m_showWellSpheres.xmlCapability()->setIOWritable(false);
// Scaling
CAF_PDM_InitField(&wellHeadScaleFactor, "WellHeadScale", 1.0, "Well Head Scale Factor", "", "", "");
@ -243,10 +260,43 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang
this->updateUiIconFromToggleField();
}
if (&m_showWellLabel == changedField)
{
for (RimEclipseWell* w : wells)
{
w->showWellLabel = !(m_showWellLabel().isFalse());
}
}
if (&m_showWellHead == changedField)
{
for (RimEclipseWell* w : wells)
{
w->showWellHead = !(m_showWellHead().isFalse());
}
}
if (&m_showWellPipe == changedField)
{
for (RimEclipseWell* w : wells)
{
w->showWellPipe = !(m_showWellPipe().isFalse());
}
}
if (&m_showWellSpheres == changedField)
{
for (RimEclipseWell* w : wells)
{
w->showWellSpheres = !(m_showWellSpheres().isFalse());
}
}
if (m_reservoirView)
{
if ( &isActive == changedField
|| &showWellLabel == changedField
|| &m_showWellLabel == changedField
|| &showWellCells == changedField
|| &showWellCellFence == changedField
|| &wellCellFenceType == changedField)
@ -259,7 +309,7 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang
m_reservoirView->scheduleCreateDisplayModelAndRedraw();
}
else if ( &spheresScaleFactor == changedField
|| &showWellSpheres == changedField
|| &m_showWellSpheres == changedField
|| &showConnectionStatusColors == changedField)
{
m_reservoirView->schedulePipeGeometryRegen();
@ -268,23 +318,23 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang
else if ( &pipeCrossSectionVertexCount == changedField
|| &pipeScaleFactor == changedField
|| &wellHeadScaleFactor == changedField
|| &showWellHead == changedField
|| &m_showWellHead == changedField
|| &isAutoDetectingBranches == changedField
|| &wellHeadPosition == changedField
|| &wellLabelColor == changedField
|| &showWellsIntersectingVisibleCells == changedField
|| &wellPipeCoordType == changedField
|| &showWellPipe == changedField)
|| &m_showWellPipe == changedField)
{
m_reservoirView->schedulePipeGeometryRegen();
m_reservoirView->scheduleCreateDisplayModelAndRedraw();
}
}
if ( &showWellPipe == changedField
|| &showWellSpheres == changedField
|| &showWellHead == changedField
|| &showWellLabel == changedField)
if ( &m_showWellPipe == changedField
|| &m_showWellSpheres == changedField
|| &m_showWellHead == changedField
|| &m_showWellLabel == changedField)
{
for (RimEclipseWell* w : wells)
{
@ -341,13 +391,15 @@ void RimEclipseWellCollection::setReservoirView(RimEclipseView* ownerReservoirVi
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
updateStateForVisibilityCheckboxes();
uiOrdering.add(&showWellsIntersectingVisibleCells);
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Visibility");
appearanceGroup->add(&showWellLabel);
appearanceGroup->add(&showWellHead);
appearanceGroup->add(&showWellPipe);
appearanceGroup->add(&showWellSpheres);
appearanceGroup->add(&m_showWellLabel);
appearanceGroup->add(&m_showWellHead);
appearanceGroup->add(&m_showWellPipe);
appearanceGroup->add(&m_showWellSpheres);
caf::PdmUiGroup* sizeScalingGroup = uiOrdering.addNewGroup("Size Scaling");
sizeScalingGroup->add(&wellHeadScaleFactor);
@ -381,6 +433,53 @@ void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi
wellCellFenceType.uiCapability()->setUiReadOnly(!showWellCells());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection::updateStateForVisibilityCheckboxes()
{
size_t showLabelCount = 0;
size_t showWellHeadCount = 0;
size_t showPipeCount = 0;
size_t showSphereCount = 0;
for (RimEclipseWell* w : wells)
{
if (w->showWellLabel()) showLabelCount++;
if (w->showWellHead()) showWellHeadCount++;
if (w->showWellPipe()) showPipeCount++;
if (w->showWellSpheres()) showSphereCount++;
}
updateStateFromEnabledChildCount(showLabelCount, &m_showWellLabel);
updateStateFromEnabledChildCount(showWellHeadCount, &m_showWellHead);
updateStateFromEnabledChildCount(showPipeCount, &m_showWellPipe);
updateStateFromEnabledChildCount(showSphereCount, &m_showWellSpheres);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection::updateStateFromEnabledChildCount(size_t enabledChildCount, caf::PdmField<caf::Tristate>* fieldToUpdate)
{
caf::Tristate tristate;
if (enabledChildCount == 0)
{
tristate = caf::Tristate::State::False;
}
else if (enabledChildCount == wells.size())
{
tristate = caf::Tristate::State::True;
}
else
{
tristate = caf::Tristate::State::PartiallyTrue;
}
fieldToUpdate->setValue(tristate);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -23,11 +23,10 @@
#include "cafAppEnum.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmFieldCvfColor.h" // Include to make Pdm work for cvf::Color
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
// Include to make Pdm work for cvf::Color
#include "cafPdmFieldCvfColor.h"
#include "cafTristate.h"
class RimEclipseView;
class RimEclipseWell;
@ -89,11 +88,6 @@ public:
caf::PdmField<bool> isActive;
caf::PdmField<bool> showWellsIntersectingVisibleCells;
caf::PdmField<bool> showWellLabel;
caf::PdmField<bool> showWellHead;
caf::PdmField<bool> showWellPipe;
caf::PdmField<bool> showWellSpheres;
caf::PdmField<double> wellHeadScaleFactor;
caf::PdmField<double> pipeScaleFactor;
caf::PdmField<double> spheresScaleFactor;
@ -126,6 +120,8 @@ public:
protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual caf::PdmFieldHandle* objectToggleField() override;
virtual void initAfterRead() override;
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
@ -133,6 +129,8 @@ protected:
private:
void calculateWellGeometryVisibility(size_t frameIndex);
static cvf::Color3f cycledPaletteColor(size_t colorIndex);
void updateStateForVisibilityCheckboxes();
void updateStateFromEnabledChildCount(size_t showLabelCount, caf::PdmField<caf::Tristate>* fieldToUpdate);
private:
RimEclipseView* m_reservoirView;
@ -143,6 +141,11 @@ private:
caf::PdmField<bool> m_applySingleColorToWells;
caf::PdmField<bool> m_applyIndividualColorsToWells;
caf::PdmField<caf::Tristate> m_showWellLabel;
caf::PdmField<caf::Tristate> m_showWellHead;
caf::PdmField<caf::Tristate> m_showWellPipe;
caf::PdmField<caf::Tristate> m_showWellSpheres;
// Obsolete fields
caf::PdmField<WellVisibilityEnum> obsoleteField_wellPipeVisibility;
caf::PdmField<WellCellsRangeFilterEnum> obsoleteField_wellCellsToRangeFilterMode;