Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use DataMgrUtils instead of CE #3608

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion apps/vaporgui/PRegionSelector.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <string>
#include "PRegionSelector.h"
#include "QRangeSliderTextCombo.h"
#include <vapor/RenderParams.h>
#include <vapor/DataMgrUtils.h>
#include <assert.h>
#include "POrientationSelector.h"

Expand Down Expand Up @@ -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<int> axes;
VAPoR::CoordType minExts, maxExts;
vector<string> 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);
Expand All @@ -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]);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/render/ImageRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down
6 changes: 6 additions & 0 deletions lib/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <vapor/glutil.h> // Must be included first!!!
#include <vapor/Renderer.h>
#include <vapor/TwoDDataRenderer.h>
#include <vapor/DataMgrUtils.h>
#include "vapor/GLManager.h"
#include "vapor/FontManager.h"
Expand Down Expand Up @@ -120,6 +121,11 @@ int Renderer::paintGL(bool fast)

mm->MatrixModeModelView();
mm->PushMatrix();

if (dynamic_cast<TwoDDataRenderer*>(this) != nullptr) {
float zOffset = GetDefaultZ(_dataMgr, GetActiveParams()->GetCurrentTimestep());
_glManager->matrixManager->Translate(0, 0, zOffset);
}
ApplyTransform(_glManager, GetDatasetTransform(), rParams->GetTransform());

int rc = _paintGL(fast);
Expand Down
10 changes: 2 additions & 8 deletions lib/render/TwoDRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -100,12 +97,10 @@ 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);

_renderMeshUnAligned();
} else {
VAssert(_meshWidth == _texWidth);
Expand Down Expand Up @@ -285,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);
Expand Down