mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#814 Clamp values and added support for collapse to single plane
This commit is contained in:
parent
d9f71ad054
commit
c16daff875
@ -25,6 +25,19 @@
|
||||
#include "RimCase.h"
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template<>
|
||||
void AppEnum< RimIntersectionBox::SinglePlaneState >::setUp()
|
||||
{
|
||||
addItem(RimIntersectionBox::PLANE_STATE_NONE, "PLANE_STATE_NONE", "None");
|
||||
addItem(RimIntersectionBox::PLANE_STATE_X, "PLANE_STATE_X", "X Plane");
|
||||
addItem(RimIntersectionBox::PLANE_STATE_Y, "PLANE_STATE_Y", "Y Plane");
|
||||
addItem(RimIntersectionBox::PLANE_STATE_Z, "PLANE_STATE_Z", "Z Plane");
|
||||
setDefault(RimIntersectionBox::PLANE_STATE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimIntersectionBox, "IntersectionBox");
|
||||
|
||||
@ -39,6 +52,8 @@ RimIntersectionBox::RimIntersectionBox()
|
||||
CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", "");
|
||||
isActive.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&singlePlaneState, "singlePlaneState", caf::AppEnum<SinglePlaneState>(SinglePlaneState::PLANE_STATE_NONE), "Collapse box to plane", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&minXCoord, "MinXCoord", 0.0, "MinXCoord", "", "", "");
|
||||
minXCoord.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
|
||||
|
||||
@ -157,6 +172,40 @@ void RimIntersectionBox::initialize()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimIntersectionBox::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &singlePlaneState)
|
||||
{
|
||||
updateVisibility();
|
||||
clampSinglePlaneValues();
|
||||
}
|
||||
else if (changedField == &minXCoord)
|
||||
{
|
||||
clampSinglePlaneValues();
|
||||
minXCoord = CVF_MIN(maxXCoord, minXCoord);
|
||||
}
|
||||
else if (changedField == &minYCoord)
|
||||
{
|
||||
clampSinglePlaneValues();
|
||||
minYCoord = CVF_MIN(maxYCoord, minYCoord);
|
||||
}
|
||||
else if (changedField == &minZCoord)
|
||||
{
|
||||
clampSinglePlaneValues();
|
||||
minZCoord = CVF_MIN(maxZCoord, minZCoord);
|
||||
}
|
||||
else if (changedField == &maxXCoord)
|
||||
{
|
||||
maxXCoord = CVF_MAX(maxXCoord, minXCoord);
|
||||
}
|
||||
else if (changedField == &maxYCoord)
|
||||
{
|
||||
maxYCoord = CVF_MAX(maxYCoord, minYCoord);
|
||||
}
|
||||
else if (changedField == &maxZCoord)
|
||||
{
|
||||
maxZCoord = CVF_MAX(maxZCoord, minZCoord);
|
||||
}
|
||||
|
||||
|
||||
if (changedField != &name)
|
||||
{
|
||||
rebuildGeometryAndScheduleCreateDisplayModel();
|
||||
@ -196,6 +245,7 @@ void RimIntersectionBox::defineEditorAttribute(const caf::PdmFieldHandle* field,
|
||||
void RimIntersectionBox::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
uiOrdering.add(&name);
|
||||
uiOrdering.add(&singlePlaneState);
|
||||
|
||||
{
|
||||
caf::PdmUiGroup* group = uiOrdering.addNewGroup("X Coordinates");
|
||||
@ -216,6 +266,14 @@ void RimIntersectionBox::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimIntersectionBox::initAfterRead()
|
||||
{
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -247,3 +305,45 @@ void RimIntersectionBox::rebuildGeometryAndScheduleCreateDisplayModel()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimIntersectionBox::updateVisibility()
|
||||
{
|
||||
maxXCoord.uiCapability()->setUiReadOnly(false);
|
||||
maxYCoord.uiCapability()->setUiReadOnly(false);
|
||||
maxZCoord.uiCapability()->setUiReadOnly(false);
|
||||
|
||||
if (singlePlaneState == PLANE_STATE_X)
|
||||
{
|
||||
maxXCoord.uiCapability()->setUiReadOnly(true);
|
||||
}
|
||||
else if (singlePlaneState == PLANE_STATE_Y)
|
||||
{
|
||||
maxYCoord.uiCapability()->setUiReadOnly(true);
|
||||
}
|
||||
else if (singlePlaneState == PLANE_STATE_Z)
|
||||
{
|
||||
maxZCoord.uiCapability()->setUiReadOnly(true);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimIntersectionBox::clampSinglePlaneValues()
|
||||
{
|
||||
if (singlePlaneState == PLANE_STATE_X)
|
||||
{
|
||||
maxXCoord = minXCoord;
|
||||
}
|
||||
else if (singlePlaneState == PLANE_STATE_Y)
|
||||
{
|
||||
maxYCoord = minYCoord;
|
||||
}
|
||||
else if (singlePlaneState == PLANE_STATE_Z)
|
||||
{
|
||||
maxZCoord = minZCoord;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,15 @@ class RimIntersectionBox : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum SinglePlaneState
|
||||
{
|
||||
PLANE_STATE_NONE,
|
||||
PLANE_STATE_X,
|
||||
PLANE_STATE_Y,
|
||||
PLANE_STATE_Z
|
||||
};
|
||||
|
||||
public:
|
||||
RimIntersectionBox();
|
||||
~RimIntersectionBox();
|
||||
@ -59,11 +68,16 @@ protected:
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override;
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
virtual void initAfterRead() override;
|
||||
|
||||
private:
|
||||
void rebuildGeometryAndScheduleCreateDisplayModel();
|
||||
void updateVisibility();
|
||||
void clampSinglePlaneValues();
|
||||
|
||||
private:
|
||||
caf::PdmField<caf::AppEnum< SinglePlaneState > > singlePlaneState;
|
||||
|
||||
caf::PdmField<double> minXCoord;
|
||||
caf::PdmField<double> minYCoord;
|
||||
caf::PdmField<double> minZCoord;
|
||||
|
Loading…
Reference in New Issue
Block a user