#3591 Improve edges on contour map.

This commit is contained in:
Gaute Lindkvist
2018-10-31 16:09:14 +01:00
parent f87f1430dc
commit ee388ca4b0
11 changed files with 131 additions and 45 deletions

View File

@@ -58,7 +58,7 @@ Rim2dEclipseView::Rim2dEclipseView()
wellCollection()->isActive = false;
faultCollection()->showFaultCollection = false;
m_grid2dProjectionPartMgr = new Riv2dGridProjectionPartMgr(grid2dProjection());
m_grid2dProjectionPartMgr = new Riv2dGridProjectionPartMgr(grid2dProjection(), this);
((RiuViewerToViewInterface*)this)->setCameraPosition(defaultViewMatrix);
}
@@ -81,6 +81,7 @@ void Rim2dEclipseView::initAfterRead()
setShowGridBox(false);
meshMode.setValue(NO_MESH);
surfaceMode.setValue(FAULTS);
scheduleCreateDisplayModelAndRedraw();
}
//--------------------------------------------------------------------------------------------------
@@ -129,12 +130,13 @@ void Rim2dEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrderi
//--------------------------------------------------------------------------------------------------
void Rim2dEclipseView::updateCurrentTimeStep()
{
RimEclipseView::updateCurrentTimeStep();
if (m_2dGridProjection->isChecked())
{
m_2dGridProjection->generateResults();
}
RimEclipseView::updateCurrentTimeStep();
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
if (m_2dGridProjection->isChecked())
@@ -166,10 +168,13 @@ void Rim2dEclipseView::updateLegends()
if (m_2dGridProjection && m_2dGridProjection->isChecked())
{
RimRegularLegendConfig* projectionLegend = m_2dGridProjection->legendConfig();
if (projectionLegend && projectionLegend->showLegend())
if (projectionLegend)
{
m_2dGridProjection->updateLegend();
m_viewer->addColorLegendToBottomLeftCorner(projectionLegend->titledOverlayFrame());
if (projectionLegend->showLegend())
{
m_viewer->addColorLegendToBottomLeftCorner(projectionLegend->titledOverlayFrame());
}
}
}
}
@@ -212,13 +217,15 @@ void Rim2dEclipseView::onLoadDataAndUpdate()
//--------------------------------------------------------------------------------------------------
void Rim2dEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
RimEclipseView::fieldChangedByUi(changedField, oldValue, newValue);
if (changedField == &m_showAxisLines)
{
m_viewer->showEdgeTickMarksXY(true, m_showAxisLines());
scheduleCreateDisplayModelAndRedraw();
}
else
else if (changedField == backgroundColorField())
{
RimEclipseView::fieldChangedByUi(changedField, oldValue, newValue);
scheduleCreateDisplayModelAndRedraw();
}
}

View File

@@ -69,6 +69,16 @@ Rim2dGridProjection::~Rim2dGridProjection()
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox Rim2dGridProjection::expandedBoundingBox() const
{
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
//boundingBox.expand(m_sampleSpacing * 0.5);
return boundingBox;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -79,8 +89,7 @@ void Rim2dGridProjection::generateGridMapping()
calculateCellRangeVisibility();
calculatePropertyFilterVisibility();
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
cvf::Vec3d gridExtent = boundingBox.extent();
cvf::Vec3d gridExtent = expandedBoundingBox().extent();
cvf::Vec2ui gridSize2d = surfaceGridSize();
@@ -110,7 +119,7 @@ void Rim2dGridProjection::generateVertices(cvf::Vec3fArray* vertices, const caf:
vertices->resize(vertexCount());
cvf::Vec2ui gridSize2d = surfaceGridSize();
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
cvf::BoundingBox boundingBox = expandedBoundingBox();
int nVertices = vertexCount();
@@ -135,7 +144,7 @@ Rim2dGridProjection::ContourPolygons Rim2dGridProjection::generateContourPolygon
{
std::vector<cvf::ref<cvf::Vec3fArray>> contourPolygons;
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
cvf::BoundingBox boundingBox = expandedBoundingBox();
std::vector<double> contourLevels;
legendConfig()->scalarMapper()->majorTickValues(&contourLevels);
@@ -150,14 +159,17 @@ Rim2dGridProjection::ContourPolygons Rim2dGridProjection::generateContourPolygon
contourPolygons.reserve(contourLines.size());
for (size_t i = 0; i < contourLines.size(); ++i)
{
cvf::ref<cvf::Vec3fArray> contourPolygon = new cvf::Vec3fArray(contourLines[i].size());
for (size_t j = 0; j < contourLines[i].size(); ++j)
if (!contourLines[i].empty())
{
cvf::Vec3d contourPoint3d = cvf::Vec3d(contourLines[i][j], boundingBox.min().z());
cvf::Vec3d displayPoint3d = displayCoordTransform->transformToDisplayCoord(contourPoint3d);
(*contourPolygon)[j] = cvf::Vec3f(displayPoint3d);
cvf::ref<cvf::Vec3fArray> contourPolygon = new cvf::Vec3fArray(contourLines[i].size());
for (size_t j = 0; j < contourLines[i].size(); ++j)
{
cvf::Vec3d contourPoint3d = cvf::Vec3d(contourLines[i][j], boundingBox.min().z());
cvf::Vec3d displayPoint3d = displayCoordTransform->transformToDisplayCoord(contourPoint3d);
(*contourPolygon)[j] = cvf::Vec3f(displayPoint3d);
}
contourPolygons.push_back(contourPolygon);
}
contourPolygons.push_back(contourPolygon);
}
}
return contourPolygons;
@@ -331,7 +343,7 @@ bool Rim2dGridProjection::hasResultAt(uint i, uint j) const
//--------------------------------------------------------------------------------------------------
cvf::Vec2ui Rim2dGridProjection::surfaceGridSize() const
{
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
cvf::BoundingBox boundingBox = expandedBoundingBox();
cvf::Vec3d gridExtent = boundingBox.extent();
uint projectionSizeX = static_cast<uint>(std::ceil(gridExtent.x() / m_sampleSpacing)) + 1u;
@@ -425,7 +437,7 @@ void Rim2dGridProjection::calculatePropertyFilterVisibility()
//--------------------------------------------------------------------------------------------------
cvf::Vec2d Rim2dGridProjection::globalPos2d(uint i, uint j) const
{
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
cvf::BoundingBox boundingBox = expandedBoundingBox();
cvf::Vec3d gridExtent = boundingBox.extent();
cvf::Vec2d origin(boundingBox.min().x(), boundingBox.min().y());
cvf::Vec2ui gridSize2d = surfaceGridSize();
@@ -447,7 +459,7 @@ const std::vector<std::pair<size_t, float>>& Rim2dGridProjection::cellsAtPos2d(u
//--------------------------------------------------------------------------------------------------
std::vector<std::pair<size_t, float>> Rim2dGridProjection::visibleCellsAndWeightMatching2dPoint(const cvf::Vec2d& globalPos2d) const
{
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
cvf::BoundingBox boundingBox = expandedBoundingBox();
cvf::Vec3d highestPoint(globalPos2d, boundingBox.max().z());
cvf::Vec3d lowestPoint(globalPos2d, boundingBox.min().z());
@@ -471,7 +483,7 @@ std::vector<std::pair<size_t, float>> Rim2dGridProjection::visibleCellsAndWeight
localGrid->cellCornerVertices(localCellIdx, hexCorners);
std::vector<HexIntersectionInfo> intersections;
float weight = 1.0f;
if (false && RigHexIntersectionTools::lineHexCellIntersection(highestPoint, lowestPoint, hexCorners, 0, &intersections))
if (RigHexIntersectionTools::lineHexCellIntersection(highestPoint, lowestPoint, hexCorners, 0, &intersections))
{
weight = std::max(1.0, (intersections.back().m_intersectionPoint - intersections.front().m_intersectionPoint).length());
}
@@ -539,7 +551,7 @@ void Rim2dGridProjection::updateLegend()
//--------------------------------------------------------------------------------------------------
std::vector<double> Rim2dGridProjection::xPositions() const
{
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
cvf::BoundingBox boundingBox = expandedBoundingBox();
cvf::Vec3d gridExtent = boundingBox.extent();
double origin = boundingBox.min().x();
@@ -560,7 +572,7 @@ std::vector<double> Rim2dGridProjection::xPositions() const
//--------------------------------------------------------------------------------------------------
std::vector<double> Rim2dGridProjection::yPositions() const
{
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
cvf::BoundingBox boundingBox = expandedBoundingBox();
cvf::Vec3d gridExtent = boundingBox.extent();
double origin = boundingBox.min().y();
cvf::Vec2ui gridSize2d = surfaceGridSize();

View File

@@ -27,6 +27,7 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cvfBoundingBox.h"
#include "cvfGeometryBuilderFaceList.h"
#include "cvfVector2.h"
@@ -76,6 +77,7 @@ public:
void updateLegend();
protected:
cvf::BoundingBox expandedBoundingBox() const;
void generateGridMapping();
void calculateCellRangeVisibility();
void calculatePropertyFilterVisibility();

View File

@@ -101,6 +101,9 @@ public:
void setName(const QString& name);
QString name() const;
// Implementation of RiuViewerToViewInterface
cvf::Color3f backgroundColor() const override { return m_backgroundColor(); }
void setMeshOnlyDrawstyle();
void setMeshSurfDrawstyle();
void setSurfOnlyDrawstyle();
@@ -166,7 +169,6 @@ protected:
void createHighlightAndGridBoxDisplayModel();
// Implementation of RiuViewerToViewInterface
cvf::Color3f backgroundColor() const override { return m_backgroundColor(); }
void applyBackgroundColor();
// Abstract methods to implement in subclasses

View File

@@ -361,6 +361,7 @@ Rim2dEclipseView* RimEclipseCase::create2dContourMap()
contourMap->fractureColors()->setDefaultResultName();
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f));
contourMap->initAfterReadRecursively();
contourMap->zoomAll();
}
caf::PdmDocument::updateUiIconStateRecursively(contourMap);