Commit b5107420 authored by Marc R.'s avatar Marc R.

skew-T: implemented poor-man's version of a spaghetti plot, loops over all...

skew-T: implemented poor-man's version of a spaghetti plot, loops over all members to draw multiple profiles
parent c45e6e8c
......@@ -1297,18 +1297,53 @@ void MSkewTActor::drawProfiles(MSceneViewGLWidget *sceneView)
if ( !var->hasData() ) continue;
var->profileVertexBuffer->attachToVertexAttribute(
SHADER_VERTEX_ATTRIBUTE, 2,
GL_FALSE, 0, (const GLvoid *)(0 * sizeof(float)));
skewTShader->setUniformValue("colour", var->profileColour);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(float(var->lineThickness));
glDrawArrays(GL_LINE_STRIP, 0, var->profile.getScalarPressureData().size());
// Unbind VBO.
glBindBuffer(GL_ARRAY_BUFFER, 0); CHECK_GL_ERROR;
int numVertices = var->profile.getScalarPressureData().size();
// Distinguish between single-profile and multi-member modes:
// ==========================================================
if (var->ensembleFilterOperation != "MULTIPLE_MEMBERS")
{
// Draw a single profile (no multi-member mode).
// =============================================
var->profileVertexBuffer->attachToVertexAttribute(
SHADER_VERTEX_ATTRIBUTE, 2,
GL_FALSE, 0, (const GLvoid *)(0 * sizeof(float)));
glDrawArrays(GL_LINE_STRIP, 0, numVertices);
// Unbind VBO.
glBindBuffer(GL_ARRAY_BUFFER, 0); CHECK_GL_ERROR;
}
else
{
// Multi-member mode: Draw spaghetti plot.
// =======================================
//NOTE (mr, 2019Apr02): This is a "poor-man's" version of spaghetti plot
// rendering. Having a separate vertex buffer for each member profile could
// easily be avoided and all profiles could be combined into a single vb to
// improve performance. Possibly refactor this part once more ensemble vis
// techniques are being implemented.
for (GL::MVertexBuffer* vb : var->profileVertexBufferAggregation)
{
vb->attachToVertexAttribute(
SHADER_VERTEX_ATTRIBUTE, 2,
GL_FALSE, 0, (const GLvoid *)(0 * sizeof(float)));
// Assume all profiles have the same length.
glDrawArrays(GL_LINE_STRIP, 0, numVertices);
// Unbind VBO.
glBindBuffer(GL_ARRAY_BUFFER, 0); CHECK_GL_ERROR;
}
}
}
}
......
......@@ -3989,6 +3989,11 @@ MNWPSkewTActorVariable::~MNWPSkewTActorVariable()
{
profile.releaseVertexBuffer();
}
for (int m : profileVertexBufferAggregation.keys())
{
profileAggregation[m].releaseVertexBuffer();
}
}
......@@ -4044,6 +4049,15 @@ void MNWPSkewTActorVariable::loadConfiguration(QSettings *settings)
void MNWPSkewTActorVariable::dataFieldChangedEvent()
{
// Remove all shortcut pointers to vertex buffers in case the set of
// selected members has changed (otherwise removed members would remain
// in the set).
for (int m : profileVertexBufferAggregation.keys())
{
profileAggregation[m].releaseVertexBuffer();
profileVertexBufferAggregation.remove(m);
}
updateProfile(profile.getLonLatLocation());
}
......@@ -4062,6 +4076,33 @@ void MNWPSkewTActorVariable::updateProfile(QVector2D lonLatLocation)
{
profileVertexBuffer = profile.getVertexBuffer();
}
// If multiple member mode is active (ensemble displays, e.g. spaghettis):
// =======================================================================
if (ensembleFilterOperation == "MULTIPLE_MEMBERS"
&& gridAggregation != nullptr)
{
// For each member grid in the grid aggregation, extract the vertical
// profile and obtain a vertex buffer.
for (MStructuredGrid* g : gridAggregation->getGrids())
{
profileData = g->extractVerticalProfile(
lonLatLocation.x(), lonLatLocation.y());
//NOTE (mr, 2019Apr02): This implementation could be improved by combining
// all profiles into a single vertex buffer. Also see comment in
// MSkewTActor::drawProfiles().
int m = g->getEnsembleMember();
profileAggregation[m].updateData(lonLatLocation, profileData);
if (!profileVertexBufferAggregation.contains(m))
{
profileVertexBufferAggregation.insert(
m, profileAggregation[m].getVertexBuffer());
}
}
}
}
......
......@@ -804,6 +804,9 @@ protected:
MVerticalProfile profile;
GL::MVertexBuffer *profileVertexBuffer;
QMap<int, MVerticalProfile> profileAggregation;
QMap<int, GL::MVertexBuffer*> profileVertexBufferAggregation;
void updateProfile(QVector2D lonLatLocation);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment