From f289cd8e05a92c02e747d61191aaa3eee6202fd8 Mon Sep 17 00:00:00 2001 From: sgpearse Date: Wed, 1 May 2024 11:30:59 -0600 Subject: [PATCH 1/2] Use DataMgrUtils instead of CE --- apps/vaporgui/PRegionSelector.cpp | 22 +++++++++++++++++++++- lib/render/Renderer.cpp | 6 ++++++ lib/render/TwoDRenderer.cpp | 4 ---- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/apps/vaporgui/PRegionSelector.cpp b/apps/vaporgui/PRegionSelector.cpp index 6f0697cd49..483d14645f 100644 --- a/apps/vaporgui/PRegionSelector.cpp +++ b/apps/vaporgui/PRegionSelector.cpp @@ -1,6 +1,8 @@ +#include #include "PRegionSelector.h" #include "QRangeSliderTextCombo.h" #include +#include #include #include "POrientationSelector.h" @@ -29,6 +31,25 @@ void PRegionSelector1D::updateGUI() const int lod = rp->GetCompressionLevel(); string varName = rp->GetFirstVariableName(); + Box *box = getBox(); + + // In some cases (ImageRenderer), there may be no 2D variable to configure extents with. + // Therefore, configure the sliders with the extents of a random 3D variable + if (varName == "") { + string varName; + VAPoR::DataMgrUtils::GetFirstExistingVariable(getDataMgr(), 0, 0, 0, 3, varName); + std::vector axes; + VAPoR::CoordType minExts, maxExts; + vector vvarName = {varName}; + VAPoR::DataMgrUtils::GetExtents(getDataMgr(), 0, vvarName, 0, 0, minExts, maxExts, axes); + + box->GetExtents(min, max); + _slider->SetValue(min[_dim], max[_dim]); + _slider->SetRange(minExts[_dim], maxExts[_dim]); + + return; + } + int ret = getDataMgr()->GetVariableExtents(ts, varName, level, lod, min, max); if (ret < 0) { _slider->SetRange(0, 0); @@ -38,7 +59,6 @@ void PRegionSelector1D::updateGUI() const _slider->SetRange(min[_dim], max[_dim]); - Box *box = getBox(); box->GetExtents(min, max); _slider->SetValue(min[_dim], max[_dim]); } diff --git a/lib/render/Renderer.cpp b/lib/render/Renderer.cpp index 7c357e885b..c93eed3cb3 100644 --- a/lib/render/Renderer.cpp +++ b/lib/render/Renderer.cpp @@ -26,6 +26,7 @@ #include // Must be included first!!! #include +#include #include #include "vapor/GLManager.h" #include "vapor/FontManager.h" @@ -120,6 +121,11 @@ int Renderer::paintGL(bool fast) mm->MatrixModeModelView(); mm->PushMatrix(); + + if (dynamic_cast(this) != nullptr) { + float zOffset = GetDefaultZ(_dataMgr, GetActiveParams()->GetCurrentTimestep()); + _glManager->matrixManager->Translate(0, 0, zOffset); + } ApplyTransform(_glManager, GetDatasetTransform(), rParams->GetTransform()); int rc = _paintGL(fast); diff --git a/lib/render/TwoDRenderer.cpp b/lib/render/TwoDRenderer.cpp index b92a4f6c8c..40f4a45b5f 100644 --- a/lib/render/TwoDRenderer.cpp +++ b/lib/render/TwoDRenderer.cpp @@ -82,9 +82,6 @@ int TwoDRenderer::_initializeGL() int TwoDRenderer::_paintGL(bool) { - float zOffset = GetDefaultZ(_dataMgr, GetActiveParams()->GetCurrentTimestep()); - _glManager->matrixManager->Translate(0, 0, zOffset); - // Get the 2D texture // _texture = GetTexture(_dataMgr, _texWidth, _texHeight, _texInternalFormat, _texFormat, _texType, _texelSize, _gridAligned); @@ -105,7 +102,6 @@ int TwoDRenderer::_paintGL(bool) _texCoords = (GLfloat *)_sb_texCoords.Alloc(_meshWidth * _meshHeight * 2 * sizeof(*_texCoords)); _computeTexCoords(_texCoords, _meshWidth, _meshHeight); - _renderMeshUnAligned(); } else { VAssert(_meshWidth == _texWidth); From 5c657336d220a8d9a0361dc1e9232bd4ea9f2988 Mon Sep 17 00:00:00 2001 From: sgpearse Date: Wed, 8 May 2024 13:15:15 -0600 Subject: [PATCH 2/2] Return from texture generation functions when textures are too small, instead of VAsserting --- lib/render/ImageRenderer.cpp | 3 +-- lib/render/TwoDRenderer.cpp | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/render/ImageRenderer.cpp b/lib/render/ImageRenderer.cpp index 57f96182da..cd9698d241 100644 --- a/lib/render/ImageRenderer.cpp +++ b/lib/render/ImageRenderer.cpp @@ -33,8 +33,7 @@ namespace { // void conform(GLfloat *verts, int nx, int ny) { - VAssert(nx >= 2); - VAssert(ny >= 2); + if (nx<2 || ny<2) return; // x values // diff --git a/lib/render/TwoDRenderer.cpp b/lib/render/TwoDRenderer.cpp index 40f4a45b5f..4633a5dffa 100644 --- a/lib/render/TwoDRenderer.cpp +++ b/lib/render/TwoDRenderer.cpp @@ -97,8 +97,7 @@ int TwoDRenderer::_paintGL(bool) if (!_gridAligned) { VAssert(_structuredMesh); - VAssert(_meshWidth >= 2); - VAssert(_meshHeight >= 2); + if (_meshWidth<2 || _meshHeight<2) return 0; // If mesh with or height is too small for a texture, harmlessly return _texCoords = (GLfloat *)_sb_texCoords.Alloc(_meshWidth * _meshHeight * 2 * sizeof(*_texCoords)); _computeTexCoords(_texCoords, _meshWidth, _meshHeight); @@ -281,8 +280,7 @@ void TwoDRenderer::ComputeNormals(const GLfloat *verts, GLsizei w, GLsizei h, GL void TwoDRenderer::_computeTexCoords(GLfloat *tcoords, size_t w, size_t h) const { - VAssert(_meshWidth >= 2); - VAssert(_meshHeight >= 2); + if (_meshWidth<2 || _meshHeight<2) return; double deltax = 1.0 / (_meshWidth - 1); double deltay = 1.0 / (_meshHeight - 1);