Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/NCAR/VAPOR
Browse files Browse the repository at this point in the history
  • Loading branch information
sgpearse committed Jun 24, 2020
2 parents 669a896 + a9d19c5 commit 54db3b7
Show file tree
Hide file tree
Showing 49 changed files with 1,786 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ endif()

# compiler warning flags
if (NOT WIN32)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -Wno-overloaded-virtual")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -Wno-overloaded-virtual -Wno-parentheses")
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-sign-compare")
else ()
# Enable multithread compiling on Visual Studio
Expand Down
4 changes: 3 additions & 1 deletion apps/vaporgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ set (SRCS
QPaintUtils.cpp
QPaintUtils.h
VSection.cpp
VSection.h
VSubGroup.cpp
VSubGroup.h
VFrame.h
VFrame.cpp
VSection.h
VLineItem.cpp
VLineItem.h
VContainer.cpp
Expand Down
65 changes: 64 additions & 1 deletion apps/vaporgui/FlowSubtabs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "vapor/DataMgrUtils.h"
#include "vapor/Box.h"
#include "ErrorReporter.h"
#include <cfloat>

#include "VFrame.h"
#include "VIntSpinBox.h"
Expand All @@ -14,10 +15,19 @@
#include "VGeometry2.h"
#include "VPushButton.h"

#include "PSliderEdit.h"
#include "PEnumDropdown.h"
#include "PCheckbox.h"
#include "PGroup.h"
#include "PSection.h"
#include "PDoubleInput.h"

#include <QScrollArea>

#define verbose 1

using VAPoR::FlowParams;

namespace {
const std::string UNSTEADY_STRING = "Pathlines";
const std::string STEADY_STRING = "Streamlines";
Expand Down Expand Up @@ -119,9 +129,61 @@ void FlowVariablesSubtab::_dimensionalityChanged( int nDims ) const {
FlowAppearanceSubtab::FlowAppearanceSubtab(QWidget* parent) : QVaporSubtab(parent)
{
_TFEditor = new TFEditor(true);
_pw = new PGroup;

_layout->addWidget( _TFEditor, 0, 0 );

_layout->addWidget(_pw);

PSection *ps;

_pw->Add(ps = new PSection("Appearance"));
ps->Add(new PEnumDropdown(FlowParams::RenderTypeTag, {"Tubes", "Samples"}, {FlowParams::RenderTypeStream, FlowParams::RenderTypeSamples}, "Render Type"));
ps->Add((new PEnumDropdown(FlowParams::RenderGlyphTypeTag, {"Circle", "Arrow"}, {FlowParams::GlpyhTypeSphere, FlowParams::GlpyhTypeArrow}, "Glyph Type"))->ShowBasedOnParam(FlowParams::RenderTypeTag, FlowParams::RenderTypeSamples));
ps->Add(new PCheckbox(FlowParams::RenderGeom3DTag, "3D Geometry"));
// ps->Add((new PCheckbox(FlowParams::RenderLightAtCameraTag, "Light From Camera"))->ShowBasedOnParam(FlowParams::RenderGeom3DTag));
// ps->Add((new PDoubleInput(FlowParams::RenderRadiusBaseTag, "Radius")));
ps->Add((new PDoubleSliderEdit(FlowParams::RenderRadiusScalarTag, "Radius Scalar"))->SetRange(0.1, 5)->EnableDynamicUpdate());


PGroup *streamGroup = new PGroup;
streamGroup->ShowBasedOnParam(FlowParams::RenderTypeTag, FlowParams::RenderTypeStream);
ps->Add(streamGroup);

streamGroup->Add((new PCheckbox(FlowParams::RenderShowStreamDirTag, "Show Stream Direction"))->ShowBasedOnParam(FlowParams::RenderTypeTag, FlowParams::RenderTypeStream));
PGroup *showDirGroup = new PSubGroup;
showDirGroup->ShowBasedOnParam(FlowParams::RenderShowStreamDirTag);
streamGroup->Add(showDirGroup);
showDirGroup->Add((new PIntegerSliderEdit(FlowParams::RenderGlyphStrideTag, "Every N Samples"))->SetRange(1, 20)->EnableDynamicUpdate());

streamGroup->Add((new PCheckbox(FlowParams::RenderFadeTailTag, "Fade Flow Tails")));
PGroup *fadeGroup = new PSubGroup;
fadeGroup->ShowBasedOnParam(FlowParams::RenderFadeTailTag);
streamGroup->Add(fadeGroup);
fadeGroup->Add((new PIntegerSliderEdit(FlowParams::RenderFadeTailStartTag, "Fade Start Sample"))->SetRange(0, 100)->EnableDynamicUpdate()->SetTooltip("How far behind leading sample fade begins."));
fadeGroup->Add((new PIntegerSliderEdit(FlowParams::RenderFadeTailLengthTag, "Fade Over N Samples"))->SetRange(1, 100)->EnableDynamicUpdate()->SetTooltip("Number of samples from opaque to transparent."));
fadeGroup->Add((new PIntegerSliderEdit(FlowParams::RenderFadeTailStopTag, "Animate Steady"))->SetRange(0, 200)->EnableDynamicUpdate()->SetTooltip("Temporary solution for animating steady flow particles."));

PGroup *sampleGroup = new PGroup;
sampleGroup->ShowBasedOnParam(FlowParams::RenderTypeTag, FlowParams::RenderTypeSamples);
ps->Add(sampleGroup);
sampleGroup->Add((new PIntegerSliderEdit(FlowParams::RenderGlyphStrideTag, "Every N Samples"))->SetRange(1, 20)->EnableDynamicUpdate()->EnableBasedOnParam(FlowParams::RenderGlyphOnlyLeadingTag, false));
sampleGroup->Add(new PCheckbox(FlowParams::RenderGlyphOnlyLeadingTag, "Only Show Leading Sample"));


_pw->Add(ps = new PSection("Lighting"));
ps->ShowBasedOnParam(FlowParams::RenderGeom3DTag);
ps->Add((new PDoubleSliderEdit(FlowParams::PhongAmbientTag, "Ambient" ))->EnableDynamicUpdate());
ps->Add((new PDoubleSliderEdit(FlowParams::PhongDiffuseTag, "Diffuse" ))->EnableDynamicUpdate());
ps->Add((new PDoubleSliderEdit(FlowParams::PhongSpecularTag, "Specular"))->EnableDynamicUpdate());
ps->Add((new PDoubleSliderEdit(FlowParams::PhongShininessTag, "Specular"))->SetRange(1, 100)->EnableDynamicUpdate());



#ifndef NDEBUG
_pw->Add((ps = new PSection("Debug"))->SetTooltip("Only accessible in debug build."));
ps->Add((new PCheckbox("old_render", "Old Render Code (Regressing Testing)")));
#endif

_params = NULL;
}

Expand All @@ -132,6 +194,7 @@ void FlowAppearanceSubtab::Update( VAPoR::DataMgr *dataMgr,
_params = dynamic_cast<VAPoR::FlowParams*>(rParams);
assert(_params);
_TFEditor->Update(dataMgr, paramsMgr, rParams);
_pw->Update(rParams, paramsMgr, dataMgr);
}


Expand Down
2 changes: 2 additions & 0 deletions apps/vaporgui/FlowSubtabs.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class VFrame;
class VIntSpinBox;
class VGeometry2;
class VPushButton;
class PGroup;

namespace VAPoR {
class ControlExec;
Expand Down Expand Up @@ -96,6 +97,7 @@ class FlowAppearanceSubtab : public QVaporSubtab {
private:
VAPoR::FlowParams* _params;
TFEditor* _TFEditor;
PGroup *_pw;
};

//
Expand Down
1 change: 1 addition & 0 deletions apps/vaporgui/NavigationEventRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <qcheckbox.h>
#include <QTextEdit>
#include <QScrollArea>
#include <cfloat>

#include <qcombobox.h>
#include <qfiledialog.h>
Expand Down
10 changes: 9 additions & 1 deletion apps/vaporgui/PGroup.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#include "PGroup.h"
#include <vapor/ParamsBase.h>
#include <QVBoxLayout>
#include "VSubGroup.h"

PGroup::PGroup()
: PWidget("", _widget = new QWidget)
: PGroup(new QWidget)
{
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
_widget->setLayout(layout);
}

PGroup::PGroup(QWidget *w)
: PWidget("", _widget = w) {}

PGroup *PGroup::Add(PWidget *pw)
{
_children.push_back(pw);
Expand All @@ -26,3 +30,7 @@ void PGroup::updateGUI() const
for (PWidget *child : _children)
child->Update(params, paramsMgr, dataMgr);
}



PSubGroup::PSubGroup() : PGroup(new VSubGroup) {}
13 changes: 13 additions & 0 deletions apps/vaporgui/PGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,18 @@ class PGroup : public PWidget {
PGroup *Add(PWidget *pw);

protected:
PGroup(QWidget *w);
void updateGUI() const override;
};


//! \class PSubGroup
//! Groups together PWidgets in a subgroup.
//! \copydoc PGroup

class PSubGroup : public PGroup {
Q_OBJECT

public:
PSubGroup();
};
1 change: 1 addition & 0 deletions apps/vaporgui/PRegionSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "VLineItem.h"
#include <vapor/ParamsBase.h>
#include <QVBoxLayout>
#include <assert.h>

PRegionSelector::PRegionSelector(const std::string &tag, const std::string &label)
: PWidget(tag, _container = new QWidget)
Expand Down
1 change: 1 addition & 0 deletions apps/vaporgui/PWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "PWidget.h"
#include <assert.h>
#include <vapor/VAssert.h>
#include <vapor/ParamsBase.h>
#include <vapor/ParamsMgr.h>
Expand Down
3 changes: 0 additions & 3 deletions apps/vaporgui/PythonVariablesGUI.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1120,9 +1120,6 @@
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="tabStopDistance">
<number>40</number>
</property>
</widget>
</item>
<item>
Expand Down
9 changes: 9 additions & 0 deletions apps/vaporgui/VSubGroup.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "VSubGroup.h"
#include <QVBoxLayout>

VSubGroup::VSubGroup()
{
QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins(12, 0, 0, 0);
setLayout(layout);
}
13 changes: 13 additions & 0 deletions apps/vaporgui/VSubGroup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <QWidget>

//! \class VSubGroup
//! Creates a subgroup for parameter controls in the sidebar

class VSubGroup : public QWidget {
Q_OBJECT

public:
VSubGroup();
};
1 change: 1 addition & 0 deletions apps/vaporgui/VizWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <glm/gtc/type_ptr.hpp>
#include "vapor/GLManager.h"
#include "vapor/LegacyGL.h"
#include "vapor/FontManager.h"
#include "vapor/FileUtils.h"
#include "vapor/Visualizer.h"
#include <vapor/FlowParams.h>
Expand Down
27 changes: 26 additions & 1 deletion include/vapor/FlowParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ enum class FlowDir : int
FORWARD = 0,
BACKWARD = 1,
BI_DIR = 2
};
};



class PARAMS_API FlowParams : public RenderParams
{
public:

enum RenderType { RenderTypeStream, RenderTypeSamples};
enum GlpyhType { GlpyhTypeSphere, GlpyhTypeArrow };

// Constructors
FlowParams( DataMgr* dataManager,
Expand Down Expand Up @@ -115,6 +118,28 @@ class PARAMS_API FlowParams : public RenderParams

int GetSeedInjInterval() const;
void SetSeedInjInterval( int );

static const std::string RenderTypeTag;
static const std::string RenderRadiusBaseTag;
static const std::string RenderRadiusScalarTag;
static const std::string RenderGeom3DTag;
static const std::string RenderLightAtCameraTag;
static const std::string RenderShowStreamDirTag;

static const std::string RenderGlyphTypeTag;
static const std::string RenderGlyphStrideTag;
static const std::string RenderGlyphOnlyLeadingTag;

static const std::string RenderFadeTailTag;
static const std::string RenderFadeTailStartTag;
static const std::string RenderFadeTailStopTag;
static const std::string RenderFadeTailLengthTag;

static const std::string PhongAmbientTag;
static const std::string PhongDiffuseTag;
static const std::string PhongSpecularTag;
static const std::string PhongShininessTag;


private:

Expand Down
12 changes: 10 additions & 2 deletions include/vapor/FlowRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class RENDER_API FlowRenderer final : public Renderer
FlowDir _cache_flowDir = FlowDir::FORWARD;
FlowStatus _velocityStatus = FlowStatus::SIMPLE_OUTOFDATE;
FlowStatus _colorStatus = FlowStatus::SIMPLE_OUTOFDATE;
FlowStatus _renderStatus = FlowStatus::SIMPLE_OUTOFDATE;
std::string _cache_rakeBiasVariable;
std::string _cache_seedInputFilename;

Expand All @@ -100,6 +101,10 @@ class RENDER_API FlowRenderer final : public Renderer
GLuint _vertexArrayId = 0;
GLuint _vertexBufferId = 0;
GLuint _colorMapTexId = 0;

unsigned int _VAO = 0;
unsigned int _VBO = 0;
vector<int> _streamSizes;

//
// Member functions
Expand All @@ -109,11 +114,14 @@ class RENDER_API FlowRenderer final : public Renderer
int _genSeedsRakeRandom( std::vector<flow::Particle>& seeds ) const;
int _genSeedsRakeRandomBiased( std::vector<flow::Particle>& seeds ) const;

int _renderFromAnAdvection( const flow::Advection*, FlowParams*, bool fast );
int _renderFromAnAdvectionLegacy( const flow::Advection*, FlowParams*, bool fast );
int _renderAdvection(const flow::Advection* adv);
int _renderAdvectionHelper(bool renderDirection = false);
void _prepareColormap( FlowParams* );
void _particleHelper1( std::vector<float>& vec, const flow::Particle& p, bool singleColor ) const;
int _drawALineStrip( const float* buf, size_t numOfParts, bool singleColor ) const;
int _drawALineStrip( const float* buf, size_t numOfParts, bool singleColor ) const;
void _restoreGLState() const;
glm::vec3 _getScales();

// Update values of _cache_* and _state_* member variables.
int _updateFlowCacheAndStates( const FlowParams* );
Expand Down
3 changes: 2 additions & 1 deletion include/vapor/GLManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#include "vapor/ShaderManager.h"
#include "vapor/MatrixManager.h"
#include "vapor/FontManager.h"

namespace VAPoR {

class LegacyGL;
class FontManager;

//! \class GLManager
//! \ingroup Public_Render
Expand All @@ -27,6 +27,7 @@ struct RENDER_API GLManager {
//! \retval vector<int>[4] from glGetIntegerv(GL_VIEWPORT)
//!
static std::vector<int> GetViewport();
static glm::vec2 GetViewportSize();

//! Utility function that pushes the current matrix state and
//! sets up a pixel coorinate 2D orthographic projection
Expand Down
3 changes: 3 additions & 0 deletions include/vapor/MatrixManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class RENDER_API MatrixManager {
glm::vec2 ProjectToScreen(float x, float y, float z) const;
glm::vec2 ProjectToScreen(const glm::vec3 &v) const;

float GetProjectionAspectRatio() const;

#ifndef NDEBUG
int GetGLMatrixMode();
const char *GetGLMatrixModeStr();
Expand All @@ -72,6 +74,7 @@ class RENDER_API MatrixManager {
stack<glm::mat4> _projectionStack;
stack<glm::mat4> *_currentStack;
Mode _mode;
float _projectionAspectRatio = 0;

glm::mat4 &top();
const glm::mat4 &top() const;
Expand Down
Loading

0 comments on commit 54db3b7

Please sign in to comment.