#817 #815 Improved commands for xyz - slices intersection boxes.

This commit is contained in:
Jacob Støren
2016-09-28 12:39:43 +02:00
parent c84b7ab6d9
commit fa6a6b4f08
10 changed files with 89 additions and 147 deletions

View File

@@ -24,6 +24,7 @@
#include "cafPdmUiSliderEditor.h"
#include "RimCase.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "RimEclipseView.h"
namespace caf
@@ -111,76 +112,74 @@ RimIntersectionBox::SinglePlaneState RimIntersectionBox::singlePlaneState() cons
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionBox::setModelBoundingBox(cvf::BoundingBox& boundingBox)
void RimIntersectionBox::setToDefaultSizeBox()
{
m_boundingBox = boundingBox;
cvf::BoundingBox boundingBox = currentCellBoundingBox();
cvf::Vec3d center = boundingBox.center();
double defaultWidthFactor = 0.5;
m_minXCoord = boundingBox.min().x() + boundingBox.extent().x() / 4.0;
m_minYCoord = boundingBox.min().y() + boundingBox.extent().y() / 4.0;
m_minZCoord = boundingBox.min().z() + boundingBox.extent().z() / 4.0;
m_maxXCoord = boundingBox.max().x() - boundingBox.extent().x() / 4.0;
m_maxYCoord = boundingBox.max().y() - boundingBox.extent().y() / 4.0;
m_maxZCoord = boundingBox.max().z() - boundingBox.extent().z() / 4.0;
updateLabelsFromBoundingBox();
m_minXCoord = center.x() - 0.5 * boundingBox.extent().x() * defaultWidthFactor;
m_minYCoord = center.y() - 0.5 * boundingBox.extent().y() * defaultWidthFactor;
m_minZCoord = center.z() - 0.5 * boundingBox.extent().z() * defaultWidthFactor;
m_maxXCoord = center.x() + 0.5 * boundingBox.extent().x() * defaultWidthFactor;
m_maxYCoord = center.y() + 0.5 * boundingBox.extent().y() * defaultWidthFactor;
m_maxZCoord = center.z() + 0.5 * boundingBox.extent().z() * defaultWidthFactor;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionBox::setXSlice(double xValue)
void RimIntersectionBox::setToDefaultSizeSlice(SinglePlaneState plane, const cvf::Vec3d& position)
{
m_singlePlaneState = PLANE_STATE_X;
m_minXCoord = xValue;
m_maxXCoord = xValue;
m_singlePlaneState = plane;
cvf::BoundingBox boundingBox = currentCellBoundingBox();
cvf::Vec3d center = position;
if (center.isUndefined()) center = boundingBox.center();
double defaultWidthFactor = 0.5;
m_minXCoord = center[0] - 0.5 * boundingBox.extent().x() * defaultWidthFactor;
m_minYCoord = center[1] - 0.5 * boundingBox.extent().y() * defaultWidthFactor;
m_minZCoord = center[2] - 0.5 * boundingBox.extent().z() * defaultWidthFactor;
m_maxXCoord = center[0] + 0.5 * boundingBox.extent().x() * defaultWidthFactor;
m_maxYCoord = center[1] + 0.5 * boundingBox.extent().y() * defaultWidthFactor;
m_maxZCoord = center[2] + 0.5 * boundingBox.extent().z() * defaultWidthFactor;
switch (plane)
{
case PLANE_STATE_X: m_minXCoord = m_maxXCoord = center[0]; break;
case PLANE_STATE_Y: m_minYCoord = m_maxYCoord = center[1]; break;
case PLANE_STATE_Z: m_minZCoord = m_maxZCoord = center[2]; break;
}
updateVisibility();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionBox::setYSlice(double yValue)
{
m_singlePlaneState = PLANE_STATE_Y;
m_minYCoord = yValue;
m_maxYCoord = yValue;
updateVisibility();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionBox::setZSlice(double zValue)
{
m_singlePlaneState = PLANE_STATE_Z;
m_minZCoord = zValue;
m_maxZCoord = zValue;
updateVisibility();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionBox::updateLabelsFromBoundingBox()
{
cvf::BoundingBox cellsBoundingBox = currentCellBoundingBox();
{
QString range = QString(" [%1 - %2]").arg(m_boundingBox.min().x()).arg(m_boundingBox.max().x());
QString range = QString(" [%1 - %2]").arg(cellsBoundingBox.min().x()).arg(cellsBoundingBox.max().x());
m_minXCoord.uiCapability()->setUiName(QString("Min X") + range);
m_maxXCoord.uiCapability()->setUiName(QString("Max X") + range);
}
{
QString range = QString(" [%1 - %2]").arg(m_boundingBox.min().y()).arg(m_boundingBox.max().y());
QString range = QString(" [%1 - %2]").arg(cellsBoundingBox.min().y()).arg(cellsBoundingBox.max().y());
m_minYCoord.uiCapability()->setUiName(QString("Min Y") + range);
m_maxYCoord.uiCapability()->setUiName(QString("Max Y") + range);
}
{
QString range = QString(" [%1 - %2]").arg(m_boundingBox.min().z()).arg(m_boundingBox.max().z());
QString range = QString(" [%1 - %2]").arg(cellsBoundingBox.min().z()).arg(cellsBoundingBox.max().z());
m_minZCoord.uiCapability()->setUiName(QString("Min Z") + range);
m_maxZCoord.uiCapability()->setUiName(QString("Max Z") + range);
}
@@ -196,21 +195,6 @@ RivIntersectionBoxPartMgr* RimIntersectionBox::intersectionBoxPartMgr()
return m_intersectionBoxPartMgr.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionBox::initialize()
{
RimCase* rimCase = NULL;
firstAnchestorOrThisOfType(rimCase);
if (rimCase)
{
m_boundingBox = rimCase->activeCellsBoundingBox();
}
updateLabelsFromBoundingBox();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -265,20 +249,21 @@ void RimIntersectionBox::defineEditorAttribute(const caf::PdmFieldHandle* field,
if (myAttr)
{
cvf::BoundingBox cellsBoundingBox = currentCellBoundingBox();
if (field == &m_minXCoord || field == &m_maxXCoord)
{
myAttr->m_minimum = m_boundingBox.min().x();
myAttr->m_maximum = m_boundingBox.max().x();
myAttr->m_minimum = cellsBoundingBox.min().x();
myAttr->m_maximum = cellsBoundingBox.max().x();
}
else if (field == &m_minYCoord || field == &m_maxYCoord)
{
myAttr->m_minimum = m_boundingBox.min().y();
myAttr->m_maximum = m_boundingBox.max().y();
myAttr->m_minimum = cellsBoundingBox.min().y();
myAttr->m_maximum = cellsBoundingBox.max().y();
}
else if (field == &m_minZCoord || field == &m_maxZCoord)
{
myAttr->m_minimum = m_boundingBox.min().z();
myAttr->m_maximum = m_boundingBox.max().z();
myAttr->m_minimum = cellsBoundingBox.min().z();
myAttr->m_maximum = cellsBoundingBox.max().z();
}
}
}
@@ -308,6 +293,8 @@ void RimIntersectionBox::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi
group->add(&m_minZCoord);
group->add(&m_maxZCoord);
}
updateLabelsFromBoundingBox();
}
//--------------------------------------------------------------------------------------------------
@@ -391,3 +378,29 @@ void RimIntersectionBox::clampSinglePlaneValues()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RimIntersectionBox::currentCellBoundingBox()
{
RimCase* rimCase = NULL;
this->firstAnchestorOrThisOfType(rimCase);
CVF_ASSERT(rimCase);
RimEclipseView* eclView = nullptr;
this->firstAnchestorOrThisOfType(eclView);
bool useAllCells = true;
if (eclView)
{
useAllCells = eclView->showInactiveCells();
}
if(false)//useAllCells) // For now, only use the active CellsBBox.
return rimCase->allCellsBoundingBox();
else
return rimCase->activeCellsBoundingBox();
}