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

skew-T: skew-T actor uses a movable pole actor to highlight profile location;...

skew-T: skew-T actor uses a movable pole actor to highlight profile location; picking and dragging is forwarded to the pole to simplify the skew-T code
parent 1980910c
......@@ -48,6 +48,7 @@ namespace Met3D
MMovablePoleActor::MMovablePoleActor()
: MActor(),
tickLength(0.8),
ticksOnRightSide(true),
lineColour(QColor(0, 104, 139, 255)),
bottomPressure_hPa(1050.f),
topPressure_hPa(100.f),
......@@ -109,6 +110,11 @@ MMovablePoleActor::MMovablePoleActor()
properties->setDDouble(tickLengthProperty, tickLength,
0.05, 20., 2, 0.05, " (world space)");
ticksOnRightSideProperty = addProperty(BOOL_PROPERTY,
"ticks on right side",
ticksGroupProperty);
properties->mBool()->setValue(ticksOnRightSideProperty, ticksOnRightSide);
tickPressureThresholdProperty = addProperty(DECORATEDDOUBLE_PROPERTY,
"tick interval threshold",
ticksGroupProperty);
......@@ -246,6 +252,9 @@ void MMovablePoleActor::saveConfiguration(QSettings *settings)
settings->setValue("tickLength",
properties->mDDouble()->value(tickLengthProperty));
settings->setValue("ticksOnRightSide",
properties->mBool()->value(ticksOnRightSideProperty));
settings->setValue("lineColour",
properties->mColor()->value(colourProperty));
......@@ -300,6 +309,10 @@ void MMovablePoleActor::loadConfiguration(QSettings *settings)
properties->mDDouble()->setValue(tickLengthProperty,
settings->value("tickLength", 0.8).toDouble());
properties->mBool()->setValue(
ticksOnRightSideProperty,
settings->value("ticksOnRightSide", true).toBool());
properties->mColor()->setValue(
colourProperty,
settings->value("lineColour", QColor(Qt::black)).value<QColor>());
......@@ -416,6 +429,9 @@ void MMovablePoleActor::renderToCurrentContext(MSceneViewGLWidget *sceneView)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); CHECK_GL_ERROR;
glDrawArrays(GL_LINES, 0, poleVertices.size()); CHECK_GL_ERROR;
// Unbind VBO.
glBindBuffer(GL_ARRAY_BUFFER, 0); CHECK_GL_ERROR;
// B) Render tick marks and adjust label positions.
// ================================================
......@@ -448,7 +464,8 @@ void MMovablePoleActor::renderToCurrentContext(MSceneViewGLWidget *sceneView)
// Offset for the "other end" of the tick line and anchor offset for
// the labels.
QVector3D anchorOffset = tickLength * sceneView->getCamera()->getXAxis();
QVector3D anchorOffset = (ticksOnRightSide ? 1 : -1) *
tickLength * sceneView->getCamera()->getXAxis();
simpleGeometryEffect->setUniformValue(
"offsetDirection", anchorOffset);
......@@ -457,7 +474,8 @@ void MMovablePoleActor::renderToCurrentContext(MSceneViewGLWidget *sceneView)
for (int i = 0; i < labels.size(); i++)
{
labels[i]->anchorOffset = anchorOffset
+ tubeRadius * sceneView->getCamera()->getXAxis();
+ ((ticksOnRightSide ? 1 : -1) * tubeRadius)
* sceneView->getCamera()->getXAxis();
}
// Render tick marks.
......@@ -478,7 +496,7 @@ void MMovablePoleActor::renderToCurrentContext(MSceneViewGLWidget *sceneView)
if (sceneView->interactionModeEnabled() && movementEnabled)
{
// Bind shader program.
positionSpheresShader->bind();
positionSpheresShader->bindProgram("Normal");
// Set MVP-matrix and parameters to map pressure to world space in the
// vertex shader.
......@@ -804,6 +822,51 @@ void MMovablePoleActor::setMovement(bool enabled)
}
void MMovablePoleActor::enablePoleProperties(bool enabled)
{
addPoleProperty->setEnabled(enabled);
individualPoleHeightsProperty->setEnabled(enabled);
bottomPressureProperty->setEnabled(enabled);
topPressureProperty->setEnabled(enabled);
for (int i = 0; i < poles.size(); i++)
{
poles.at(i)->groupProperty->setEnabled(enabled);
}
}
void MMovablePoleActor::setTubeRadius(float radius)
{
properties->mDouble()->setValue(tubeRadiusProperty, radius);
}
void MMovablePoleActor::setVerticalExtent(float pbot_hPa, float ptop_hPa)
{
enableActorUpdates(false);
properties->mDDouble()->setValue(bottomPressureProperty, pbot_hPa);
enableActorUpdates(true);
properties->mDDouble()->setValue(topPressureProperty, ptop_hPa);
}
void MMovablePoleActor::setPolePosition(int index, QPointF lonlatPos)
{
if (index < poles.size())
{
properties->mPointF()->setValue(poles[index]->positionProperty,
lonlatPos);
}
}
void MMovablePoleActor::setTicksOnRightSide(bool rightSide)
{
properties->mBool()->setValue(ticksOnRightSideProperty, rightSide);
}
/******************************************************************************
*** PUBLIC SLOTS ***
*******************************************************************************/
......@@ -846,14 +909,25 @@ void MMovablePoleActor::onQtPropertyChanged(QtProperty *property)
emitActorChangedSignal();
}
else if (property == addPoleProperty)
else if (property == ticksOnRightSideProperty)
{
generatePole();
ticksOnRightSide = properties->mBool()->value(ticksOnRightSideProperty);
if (suppressActorUpdates()) return;
generateGeometry();
emitActorChangedSignal();
}
else if (property == addPoleProperty)
{
if (addPoleProperty->isEnabled())
{
generatePole();
if (suppressActorUpdates()) return;
generateGeometry();
emitActorChangedSignal();
}
}
else if (property == tickPressureThresholdProperty
|| property == tickIntervalAboveThreshold
|| property == tickIntervalBelowThreshold
......@@ -1036,7 +1110,9 @@ void MMovablePoleActor::generateGeometry()
QString("%1").arg(p),
MTextManager::LONLATP,
polePos.x(), polePos.y(), p,
labelsize, labelColour, MTextManager::MIDDLELEFT,
labelsize, labelColour, (ticksOnRightSide ?
MTextManager::MIDDLELEFT :
MTextManager::MIDDLERIGHT),
labelbbox, labelBBoxColour)
);
}
......
......@@ -99,6 +99,24 @@ public:
void setMovement(bool enabled);
/**
Programatically enable/disable the "add pole" property and the properties
that control position and vertical extent of a pole. Used e.g. by the
SkewT-Actor that keep a pole as a subactor that should only have exactly
one pole.
*/
void enablePoleProperties(bool enabled);
void setTubeRadius(float radius);
void setVerticalExtent(float pbot_hPa, float ptop_hPa);
void setPolePosition(int index, QPointF lonlatPos);
void setTicksOnRightSide(bool rightSide);
const QVector<QVector3D>& getAxisTicks() { return axisTicks; }
protected:
void initializeActorResources();
......@@ -125,6 +143,8 @@ protected:
QtProperty *ticksGroupProperty;
QtProperty *tickLengthProperty;
float tickLength;
QtProperty *ticksOnRightSideProperty;
bool ticksOnRightSide;
QtProperty *colourProperty;
QColor lineColour;
......
This diff is collapsed.
......@@ -47,9 +47,8 @@
#include "gxfw/nwpmultivaractor.h"
#include "gxfw/nwpactorvariable.h"
#include "gxfw/gl/shadereffect.h"
#include "actors/transferfunction1d.h"
#include "actors/graticuleactor.h"
#include "gxfw/textmanager.h"
#include "actors/movablepoleactor.h"
class MSceneViewGLWidget;
......@@ -84,12 +83,19 @@ public:
MNWPActorVariable* createActorVariable(
const MSelectableDataSource& dataSource) override;
virtual int checkIntersectionWithHandle(
int checkIntersectionWithHandle(
MSceneViewGLWidget* sceneView, float clipX, float clipY) override;
virtual void dragEvent(MSceneViewGLWidget*
sceneView, int handleID, float clipX,
float clipY) override;
void addPositionLabel(MSceneViewGLWidget *sceneView, int handleID,
float clipX, float clipY);
void dragEvent(MSceneViewGLWidget*
sceneView, int handleID, float clipX,
float clipY) override;
QList<MLabel*> getPositionLabelToRender() override;
void removePositionLabel() override;
virtual bool supportsMultipleEnsembleMemberVisualization() override
{ return true; }
......@@ -408,7 +414,6 @@ private:
void updateVariableEnums(MNWPActorVariable *deletedVar = nullptr);
void drawDiagramHandle(MSceneViewGLWidget *sceneView);
void setShaderGeneralVars(MSceneViewGLWidget *sceneView,
ModeSpecificDiagramConfiguration *config);
void drawProbabilityTube(MNWPSkewTActorVariable *max,
......@@ -503,6 +508,9 @@ private:
void updateVerticalProfilesAndLabels();
void removeAllSkewTLabels();
MMovablePoleActor *poleActor;
bool dragEventActive;
};
......
......@@ -221,7 +221,7 @@ public:
/**
Returns the position labe in a list if it shall be rendered for this actor.
*/
QList<MLabel*> getPositionLabelToRender();
virtual QList<MLabel*> getPositionLabelToRender();
/**
Returns @p true if the actor can be picked and dragged in modify mode.
......@@ -263,7 +263,7 @@ public:
Called by a @ref MSceneViewGLWidget in modification mode.
*/
void removePositionLabel();
virtual void removePositionLabel();
/**
Drags the handle with ID @p handleID to the clip space point (@p clipX,
......
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