mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3499 Add seperate legend for 2d projection view
This commit is contained in:
parent
222ac5137f
commit
e053ec211a
@ -96,7 +96,6 @@ void Riv2dGridProjectionPartMgr::removeTrianglesWithNoResult(cvf::UIntArray* ver
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> Riv2dGridProjectionPartMgr::createDrawable(const caf::DisplayCoordTransform* displayCoordTransform) const
|
||||
{
|
||||
m_2dGridProjection->updateDefaultSampleSpacingFromGrid();
|
||||
m_2dGridProjection->extractGridData();
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray;
|
||||
|
@ -48,6 +48,7 @@ Rim2dGridProjection::Rim2dGridProjection()
|
||||
|
||||
setName("2d Grid Projection");
|
||||
nameField()->uiCapability()->setUiReadOnly(true);
|
||||
setCheckState(false); // Default is off
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -63,10 +64,17 @@ Rim2dGridProjection::~Rim2dGridProjection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim2dGridProjection::extractGridData()
|
||||
{
|
||||
updateDefaultSampleSpacingFromGrid();
|
||||
|
||||
if (vertexCount() == m_projected3dGridIndices.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
|
||||
cvf::Vec3d gridExtent = boundingBox.extent();
|
||||
|
||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||
|
||||
RimEclipseResultCase* eclipseCase = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(eclipseCase);
|
||||
@ -93,8 +101,7 @@ void Rim2dGridProjection::extractGridData()
|
||||
m_projected3dGridIndices[gridIndex(i, j)] = activeCellMatches;
|
||||
|
||||
}
|
||||
}
|
||||
m_legendConfig->setAutomaticRanges(minValue(), maxValue(), minValue(), maxValue());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -221,6 +228,14 @@ double Rim2dGridProjection::value(uint i, uint j) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool Rim2dGridProjection::hasResultAt(uint i, uint j) const
|
||||
{
|
||||
RimEclipseView* view = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(view);
|
||||
RimEclipseCellColors* cellColors = view->cellResult();
|
||||
|
||||
if (cellColors->isTernarySaturationSelected())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return !cellsAtPos2d(i, j).empty();
|
||||
}
|
||||
|
||||
@ -309,12 +324,26 @@ cvf::Vec2ui Rim2dGridProjection::ijFromGridIndex(size_t index) const
|
||||
|
||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||
|
||||
unsigned int quotientX = index / gridSize2d.x();
|
||||
unsigned int remainderX = index % gridSize2d.x();
|
||||
uint quotientX = static_cast<uint>(index) / gridSize2d.x();
|
||||
uint remainderX = static_cast<uint>(index) % gridSize2d.x();
|
||||
|
||||
return cvf::Vec2ui(remainderX, quotientX);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim2dGridProjection::updateLegendData()
|
||||
{
|
||||
RimEclipseView* view = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(view);
|
||||
RimEclipseCellColors* cellColors = view->cellResult();
|
||||
|
||||
extractGridData();
|
||||
m_legendConfig->setAutomaticRanges(minValue(), maxValue(), minValue(), maxValue());
|
||||
m_legendConfig->setTitle(QString("2d Projection:\n%1").arg(cellColors->resultVariableUiShortName()));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
|
||||
size_t gridIndex(uint i, uint j) const;
|
||||
cvf::Vec2ui ijFromGridIndex(size_t gridIndex) const;
|
||||
void updateLegendData();
|
||||
protected:
|
||||
cvf::Vec2d globalPos2d(uint i, uint j) const;
|
||||
const std::vector<size_t>& cellsAtPos2d(uint i, uint j) const;
|
||||
|
@ -1137,6 +1137,16 @@ void RimEclipseView::updateLegends()
|
||||
RimRegularLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig();
|
||||
m_viewer->addColorLegendToBottomLeftCorner(virtLegend->titledOverlayFrame());
|
||||
}
|
||||
|
||||
if (m_2dGridProjection && m_2dGridProjection->isChecked())
|
||||
{
|
||||
RimRegularLegendConfig* projectionLegend = m_2dGridProjection->legendConfig();
|
||||
if (projectionLegend && projectionLegend->showLegend())
|
||||
{
|
||||
m_2dGridProjection->updateLegendData();
|
||||
m_viewer->addColorLegendToBottomLeftCorner(projectionLegend->titledOverlayFrame());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user