mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#266) Refactoring
Limit usage of RivGridBoxGenerator to only RiuViewer Update colors of grid box based on background color Use dark gray instead of pure black
This commit is contained in:
parent
a7656e2367
commit
401cfe81a1
@ -35,6 +35,8 @@
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGridBoxGenerator::RivGridBoxGenerator()
|
||||
: m_gridColor(cvf::Color3f::LIGHT_GRAY),
|
||||
m_gridLegendColor(cvf::Color3f::BLACK)
|
||||
{
|
||||
m_gridBoxModel = new cvf::ModelBasicList;
|
||||
|
||||
@ -94,7 +96,7 @@ void RivGridBoxGenerator::createGridBoxParts()
|
||||
{
|
||||
computeDisplayCoords();
|
||||
|
||||
createGridBoxSideParts();
|
||||
createGridBoxFaceParts();
|
||||
createGridBoxLegendParts();
|
||||
}
|
||||
|
||||
@ -105,9 +107,9 @@ void RivGridBoxGenerator::updateFromCamera(const cvf::Camera* camera)
|
||||
{
|
||||
m_gridBoxModel->removeAllParts();
|
||||
|
||||
if (m_gridBoxSideParts.size() == 0) return;
|
||||
if (m_gridBoxFaceParts.size() == 0) return;
|
||||
|
||||
std::vector<bool> sideVisibility(6, false);
|
||||
std::vector<bool> faceVisibility(6, false);
|
||||
for (size_t i = POS_X; i <= NEG_Z; i++)
|
||||
{
|
||||
cvf::Vec3f sideNorm = sideNormalOutwards((FaceType)i);
|
||||
@ -117,20 +119,20 @@ void RivGridBoxGenerator::updateFromCamera(const cvf::Camera* camera)
|
||||
|
||||
if (sideNorm.dot(cvf::Vec3f(camToSide)) < 0.0)
|
||||
{
|
||||
m_gridBoxModel->addPart(m_gridBoxSideParts[i].p());
|
||||
sideVisibility[i] = true;
|
||||
m_gridBoxModel->addPart(m_gridBoxFaceParts[i].p());
|
||||
faceVisibility[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<bool> edgeVisibility(12, false);
|
||||
computeEdgeVisibility(sideVisibility, edgeVisibility);
|
||||
computeEdgeVisibility(faceVisibility, edgeVisibility);
|
||||
|
||||
// We have two parts for each edge - line and text
|
||||
CVF_ASSERT(m_gridBoxLegendParts.size() == (NEG_X_NEG_Y + 1)*2);
|
||||
for (size_t i = POS_Z_POS_X; i <= NEG_X_NEG_Y; i++)
|
||||
{
|
||||
if (edgeVisibility[i])
|
||||
{
|
||||
// We have two parts for each edge - line and text
|
||||
m_gridBoxModel->addPart(m_gridBoxLegendParts[2 * i].p());
|
||||
m_gridBoxModel->addPart(m_gridBoxLegendParts[2 * i + 1].p());
|
||||
}
|
||||
@ -142,8 +144,8 @@ void RivGridBoxGenerator::updateFromCamera(const cvf::Camera* camera)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGridBoxGenerator::computeEdgeVisibility(const std::vector<bool>& faceVisibility, std::vector<bool>& edgeVisibility)
|
||||
{
|
||||
CVF_ASSERT(faceVisibility.size() == NEG_Z);
|
||||
CVF_ASSERT(edgeVisibility.size() == NEG_X_NEG_Y);
|
||||
CVF_ASSERT(faceVisibility.size() == NEG_Z + 1);
|
||||
CVF_ASSERT(edgeVisibility.size() == NEG_X_NEG_Y + 1);
|
||||
|
||||
// POS Z
|
||||
if (faceVisibility[POS_Z] ^ faceVisibility[POS_X])
|
||||
@ -213,9 +215,9 @@ cvf::Model* RivGridBoxGenerator::model()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGridBoxGenerator::createGridBoxSideParts()
|
||||
void RivGridBoxGenerator::createGridBoxFaceParts()
|
||||
{
|
||||
m_gridBoxSideParts.clear();
|
||||
m_gridBoxFaceParts.clear();
|
||||
|
||||
CVF_ASSERT(m_displayCoordsBoundingBox.isValid());
|
||||
CVF_ASSERT(m_displayCoordsXValues.size() > 0);
|
||||
@ -292,12 +294,12 @@ void RivGridBoxGenerator::createGridBoxSideParts()
|
||||
part->updateBoundingBox();
|
||||
|
||||
cvf::ref<cvf::Effect> eff;
|
||||
caf::MeshEffectGenerator effGen(cvf::Color3f::GRAY);
|
||||
caf::MeshEffectGenerator effGen(m_gridColor);
|
||||
eff = effGen.generateCachedEffect();
|
||||
|
||||
part->setEffect(eff.p());
|
||||
|
||||
m_gridBoxSideParts.push_back(part.p());
|
||||
m_gridBoxFaceParts.push_back(part.p());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -495,13 +497,12 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
|
||||
geo->addPrimitiveSet(primSet.p());
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("Legend lines ");
|
||||
part->setName("Legend lines");
|
||||
part->setDrawable(geo.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
|
||||
cvf::ref<cvf::Effect> eff;
|
||||
caf::MeshEffectGenerator effGen(cvf::Color3f::WHITE);
|
||||
caf::MeshEffectGenerator effGen(m_gridLegendColor);
|
||||
eff = effGen.generateCachedEffect();
|
||||
|
||||
part->setEffect(eff.p());
|
||||
@ -514,10 +515,9 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
|
||||
|
||||
cvf::ref<cvf::DrawableText> geo = new cvf::DrawableText;
|
||||
geo->setFont(new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD));
|
||||
geo->setTextColor(cvf::Color3::WHITE);
|
||||
geo->setTextColor(m_gridLegendColor);
|
||||
geo->setDrawBackground(false);
|
||||
geo->setDrawBorder(false);
|
||||
//textGeo->setCheckPosVisible(false);
|
||||
|
||||
for (size_t idx = 0; idx < domainCoordsTickValues->size(); idx++)
|
||||
{
|
||||
@ -525,15 +525,13 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("Legend text");
|
||||
part->setDrawable(geo.p());
|
||||
part->updateBoundingBox();
|
||||
|
||||
cvf::ref<cvf::Effect> eff = new cvf::Effect;
|
||||
part->setEffect(eff.p());
|
||||
|
||||
//textPart->setPriority(11);
|
||||
part->setName("Legend text");
|
||||
|
||||
parts->push_back(part.p());
|
||||
}
|
||||
}
|
||||
@ -598,6 +596,23 @@ cvf::Vec3f RivGridBoxGenerator::cornerDirection(FaceType face1, FaceType face2)
|
||||
return dir;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGridBoxGenerator::updateFromBackgroundColor(const cvf::Color3f backgroundColor)
|
||||
{
|
||||
if (backgroundColor.r() + backgroundColor.g() + backgroundColor.b() > 1.5f)
|
||||
{
|
||||
m_gridColor = cvf::Color3f::LIGHT_GRAY;
|
||||
m_gridLegendColor = cvf::Color3f::fromByteColor(10, 10, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gridColor = cvf::Color3f::DARK_GRAY;
|
||||
m_gridLegendColor = cvf::Color3f::WHITE;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -47,6 +47,8 @@ public:
|
||||
void setScaleZ(double scaleZ);
|
||||
void setDisplayModelOffset(cvf::Vec3d offset);
|
||||
void setGridBoxDomainCoordBoundingBox(const cvf::BoundingBox& boundingBox);
|
||||
void updateFromBackgroundColor(const cvf::Color3f backgroundColor);
|
||||
|
||||
void createGridBoxParts();
|
||||
|
||||
void updateFromCamera(const cvf::Camera* camera);
|
||||
@ -90,7 +92,7 @@ private:
|
||||
};
|
||||
|
||||
private:
|
||||
void createGridBoxSideParts();
|
||||
void createGridBoxFaceParts();
|
||||
void createGridBoxLegendParts();
|
||||
void createLegend(EdgeType edge, cvf::Collection<cvf::Part>* parts);
|
||||
|
||||
@ -102,7 +104,6 @@ private:
|
||||
cvf::Vec3f sideNormalOutwards(FaceType face);
|
||||
cvf::Vec3d pointOnSide(FaceType face);
|
||||
cvf::Vec3f cornerDirection(FaceType face1, FaceType face2);
|
||||
|
||||
private:
|
||||
cvf::BoundingBox m_domainCoordsBoundingBox;
|
||||
std::vector<double> m_domainCoordsXValues;
|
||||
@ -117,9 +118,12 @@ private:
|
||||
double m_scaleZ;
|
||||
cvf::Vec3d m_displayModelOffset;
|
||||
|
||||
cvf::Collection<cvf::Part> m_gridBoxSideParts;
|
||||
cvf::Collection<cvf::Part> m_gridBoxFaceParts;
|
||||
cvf::Collection<cvf::Part> m_gridBoxLegendParts;
|
||||
|
||||
cvf::ref<cvf::ModelBasicList> m_gridBoxModel;
|
||||
|
||||
cvf::Color3f m_gridColor;
|
||||
cvf::Color3f m_gridLegendColor;
|
||||
};
|
||||
|
||||
|
@ -70,7 +70,6 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <limits.h>
|
||||
#include "RivGridBoxGenerator.h"
|
||||
|
||||
|
||||
|
||||
@ -1647,6 +1646,14 @@ void RimEclipseView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalV
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEclipseView::showActiveCellsOnly()
|
||||
{
|
||||
return !showInactiveCells;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1677,32 +1684,6 @@ void RimEclipseView::createPartCollectionFromSelection(cvf::Collection<cvf::Part
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseView::updateGridBoxData()
|
||||
{
|
||||
if (viewer())
|
||||
{
|
||||
RivGridBoxGenerator* gridBoxGen = viewer()->gridBoxGenerator();
|
||||
|
||||
gridBoxGen->setScaleZ(scaleZ);
|
||||
|
||||
if (showInactiveCells)
|
||||
{
|
||||
gridBoxGen->setGridBoxDomainCoordBoundingBox(ownerCase()->allCellsBoundingBox());
|
||||
}
|
||||
else
|
||||
{
|
||||
gridBoxGen->setGridBoxDomainCoordBoundingBox(ownerCase()->activeCellsBoundingBox());
|
||||
}
|
||||
|
||||
gridBoxGen->setDisplayModelOffset(ownerCase()->displayModelOffset());
|
||||
|
||||
gridBoxGen->createGridBoxParts();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -126,8 +126,6 @@ public:
|
||||
const std::vector<RivCellSetEnum>& visibleGridParts() const { return m_visibleGridParts;}
|
||||
cvf::cref<RivReservoirViewPartMgr> reservoirGridPartManager() const { return m_reservoirGridPartManager.p(); }
|
||||
|
||||
virtual void updateGridBoxData();
|
||||
|
||||
// Does this belong here, really ?
|
||||
void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid);
|
||||
|
||||
@ -141,6 +139,7 @@ protected:
|
||||
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "");
|
||||
|
||||
virtual void createPartCollectionFromSelection(cvf::Collection<cvf::Part>* parts);
|
||||
virtual bool showActiveCellsOnly();
|
||||
|
||||
private:
|
||||
void createDisplayModel();
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include "RivGeoMechPartMgr.h"
|
||||
#include "RivGeoMechPartMgrCache.h"
|
||||
#include "RivGeoMechVizLogic.h"
|
||||
#include "RivGridBoxGenerator.h"
|
||||
#include "RivSingleCellPartGenerator.h"
|
||||
|
||||
#include "cafCadNavigation.h"
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "RivGridBoxGenerator.h"
|
||||
#include "RivWellPathCollectionPartMgr.h"
|
||||
|
||||
#include "cafFrameAnimationControl.h"
|
||||
@ -181,7 +180,6 @@ void RimView::updateViewerWidget()
|
||||
|
||||
m_viewer = new RiuViewer(glFormat, NULL);
|
||||
m_viewer->setOwnerReservoirView(this);
|
||||
this->updateGridBoxData();
|
||||
|
||||
RiuMainWindow::instance()->addViewer(m_viewer->layoutWidget(), windowGeometry());
|
||||
m_viewer->setMinNearPlaneDistance(10);
|
||||
@ -199,6 +197,8 @@ void RimView::updateViewerWidget()
|
||||
if (isViewerCreated) m_viewer->mainCamera()->setViewMatrix(cameraPosition);
|
||||
m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor()));
|
||||
|
||||
this->updateGridBoxData();
|
||||
|
||||
m_viewer->update();
|
||||
}
|
||||
else
|
||||
@ -787,15 +787,9 @@ void RimView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimView::updateGridBoxData()
|
||||
{
|
||||
if (viewer())
|
||||
if (m_viewer)
|
||||
{
|
||||
RivGridBoxGenerator* gridBoxGen = viewer()->gridBoxGenerator();
|
||||
|
||||
gridBoxGen->setScaleZ(scaleZ);
|
||||
gridBoxGen->setDisplayModelOffset(cvf::Vec3d::ZERO);
|
||||
gridBoxGen->setGridBoxDomainCoordBoundingBox(ownerCase()->allCellsBoundingBox());
|
||||
|
||||
gridBoxGen->createGridBoxParts();
|
||||
m_viewer->updateGridBoxData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -839,9 +833,17 @@ void RimView::createOverlayDisplayModel()
|
||||
|
||||
if (showGridBox)
|
||||
{
|
||||
overlayScene->addModel(m_viewer->gridBoxGenerator()->model());
|
||||
overlayScene->addModel(m_viewer->gridBoxModel());
|
||||
}
|
||||
|
||||
m_viewer->setOverlayScene(overlayScene.p());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimView::showActiveCellsOnly()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ public:
|
||||
|
||||
cvf::ref<cvf::UByteArray> currentTotalCellVisibility();
|
||||
|
||||
virtual void updateGridBoxData();
|
||||
virtual bool showActiveCellsOnly();
|
||||
|
||||
public:
|
||||
virtual void loadDataAndUpdate() = 0;
|
||||
@ -164,6 +164,8 @@ protected:
|
||||
virtual void createDisplayModel() = 0;
|
||||
|
||||
void createOverlayDisplayModel();
|
||||
void updateGridBoxData();
|
||||
|
||||
virtual void createPartCollectionFromSelection(cvf::Collection<cvf::Part>* parts) = 0;
|
||||
|
||||
virtual void updateDisplayModelVisibility() = 0;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaBaseDefs.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimView.h"
|
||||
#include "RimViewController.h"
|
||||
@ -526,14 +527,6 @@ RimView* RiuViewer::ownerReservoirView()
|
||||
return m_rimView;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGridBoxGenerator* RiuViewer::gridBoxGenerator() const
|
||||
{
|
||||
return m_gridBoxGenerator;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -598,3 +591,38 @@ void RiuViewer::resizeGL(int width, int height)
|
||||
|
||||
m_overlayRendering->camera()->viewport()->set(0, 0, width, height);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::updateGridBoxData()
|
||||
{
|
||||
if (ownerReservoirView() && ownerReservoirView()->ownerCase())
|
||||
{
|
||||
RimView* rimView = ownerReservoirView();
|
||||
RimCase* rimCase = rimView->ownerCase();
|
||||
|
||||
m_gridBoxGenerator->setScaleZ(rimView->scaleZ);
|
||||
m_gridBoxGenerator->setDisplayModelOffset(rimCase->displayModelOffset());
|
||||
m_gridBoxGenerator->updateFromBackgroundColor(rimView->backgroundColor);
|
||||
|
||||
if (rimView->showActiveCellsOnly())
|
||||
{
|
||||
m_gridBoxGenerator->setGridBoxDomainCoordBoundingBox(rimCase->activeCellsBoundingBox());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gridBoxGenerator->setGridBoxDomainCoordBoundingBox(rimCase->allCellsBoundingBox());
|
||||
}
|
||||
|
||||
m_gridBoxGenerator->createGridBoxParts();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Model* RiuViewer::gridBoxModel() const
|
||||
{
|
||||
return m_gridBoxGenerator->model();
|
||||
}
|
||||
|
@ -39,8 +39,9 @@ class QProgressBar;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class Part;
|
||||
class Model;
|
||||
class OverlayItem;
|
||||
class Part;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
@ -71,7 +72,8 @@ public:
|
||||
void setHistogram(double min, double max, const std::vector<size_t>& histogram);
|
||||
void setHistogramPercentiles(double pmin, double pmax, double mean);
|
||||
|
||||
RivGridBoxGenerator* gridBoxGenerator() const;
|
||||
void updateGridBoxData();
|
||||
cvf::Model* gridBoxModel() const;
|
||||
|
||||
void showAnimationProgress(bool enable);
|
||||
|
||||
@ -100,7 +102,6 @@ private:
|
||||
|
||||
void setupRenderingSequence();
|
||||
static void copyCameraView(cvf::Camera* srcCamera, cvf::Camera* dstCamera);
|
||||
|
||||
private:
|
||||
QLabel* m_InfoLabel;
|
||||
QLabel* m_versionInfoLabel;
|
||||
|
Loading…
Reference in New Issue
Block a user