Skip to content

Commit

Permalink
Merge branch 'feature-webui-vfr' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
GPMueller committed Jul 31, 2019
2 parents e2ec4ff + 6aac2fd commit 0d9aa8e
Show file tree
Hide file tree
Showing 108 changed files with 4,111 additions and 20,950 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ input_*

### Executables and Libraries ###
/spirit
spirit.js
spirit.js.mem
spirit.wasm
libSpirit.js
libSpirit.js.mem
libSpirit.wasm
libSpirit.wast

### Generated Files
core/python/LICENSE.txt
Expand Down
6 changes: 3 additions & 3 deletions CMake/ChooseCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ MESSAGE( STATUS ">> ------------------------------------------------------------
MESSAGE( STATUS ">> --------------------- ChooseCompiler.cmake ------------------------- <<" )
######## UI Web - this means we need emcc ###########################
if (SPIRIT_BUILD_FOR_JS)
###
###
MESSAGE( STATUS ">> Choosing compiler: emcc" )
### Set the path to emscripten
# SET(EMSCRIPTEN_ROOT_PATH "/usr/local/emsdk/emscripten/1.38.29/")
SET(EMSCRIPTEN_ROOT_PATH "/usr/local/emsdk/emscripten/1.38.29/")
### Use the Emscripten toolchain file
# SET(CMAKE_TOOLCHAIN_FILE /usr/local/emsdk/emscripten/1.38.13/cmake/Modules/Platform/Emscripten)
SET(CMAKE_TOOLCHAIN_FILE Emscripten)
######################################################################


Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ endif( )
add_subdirectory( core )
### Web UI
if( SPIRIT_BUILD_FOR_JS )
add_subdirectory( VFRendering )
add_subdirectory( ui-web )
### CXX UI
elseif( SPIRIT_BUILD_FOR_CXX )
Expand Down
7 changes: 7 additions & 0 deletions VFRendering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(ExternalProject)
ExternalProject_add(qhull
GIT_REPOSITORY https://github.com/qhull/qhull.git
GIT_TAG v7.3.1
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/thirdparty-install;-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
PREFIX qhull-prefix
)
Expand Down Expand Up @@ -56,11 +57,13 @@ endif()
set(SOURCE_FILES
src/ArrowRenderer.cxx
src/BoundingBoxRenderer.cxx
src/ParallelepipedRenderer.cxx
src/CombinedRenderer.cxx
src/CoordinateSystemRenderer.cxx
src/FPSCounter.cxx
src/Geometry.cxx
src/GlyphRenderer.cxx
src/DotRenderer.cxx
src/IsosurfaceRenderer.cxx
src/Options.cxx
src/RendererBase.cxx
Expand All @@ -79,10 +82,12 @@ set(HEADER_FILES
include/VectorfieldIsosurface.hxx
include/VFRendering/ArrowRenderer.hxx
include/VFRendering/BoundingBoxRenderer.hxx
include/VFRendering/ParallelepipedRenderer.hxx
include/VFRendering/CombinedRenderer.hxx
include/VFRendering/CoordinateSystemRenderer.hxx
include/VFRendering/FPSCounter.hxx
include/VFRendering/GlyphRenderer.hxx
include/VFRendering/DotRenderer.hxx
include/VFRendering/Geometry.hxx
include/VFRendering/IsosurfaceRenderer.hxx
include/VFRendering/Options.hxx
Expand All @@ -95,6 +100,8 @@ set(HEADER_FILES
include/VFRendering/VectorSphereRenderer.hxx
include/VFRendering/View.hxx
include/shaders
include/shaders/dot.frag.glsl.hxx
include/shaders/dot.vert.glsl.hxx
include/shaders/glyphs.frag.glsl.hxx
include/shaders/glyphs.vert.glsl.hxx
include/shaders/boundingbox.frag.glsl.hxx
Expand Down
2 changes: 1 addition & 1 deletion VFRendering/Version.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.0
0.14.0
4 changes: 2 additions & 2 deletions VFRendering/demo.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from PyQt5.QtCore import pyqtSlot, QTimer
from PyQt5.QtCore import Qt

import build.pyVFRendering as vfr
import pyVFRendering as vfr


class MainWindow(QMainWindow):
Expand Down Expand Up @@ -85,7 +85,7 @@ def initializeGL(self):
renderer_cs.setNormalize(True)
# Add renderers to view
self.renderers = [ (renderer_arrows, [0.0, 0.0, 1.0, 1.0]), (renderer_boundingbox, [0.0, 0.0, 1.0, 1.0]), (renderer_cs, [0.0, 0.0, 0.2, 0.2]) ]
self.view.renderers(self.renderers)
self.view.renderers(self.renderers, True)

# Options
self.options = vfr.Options()
Expand Down
16 changes: 15 additions & 1 deletion VFRendering/include/VFRendering/BoundingBoxRenderer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ namespace VFRendering {
class BoundingBoxRenderer : public RendererBase {
public:
enum Option {
COLOR = 600
COLOR = 600,
LEVEL_OF_DETAIL,
LINE_WIDTH
};


Expand All @@ -21,6 +23,7 @@ public:

protected:
virtual void update(bool keep_geometry) override;
void updateVertexData();

private:
void initialize();
Expand All @@ -30,6 +33,7 @@ private:
unsigned int m_vao = 0;
unsigned int m_vbo = 0;
unsigned int m_dash_vbo = 0;
unsigned int num_vertices = 0;
std::vector<glm::vec3> m_vertices;
std::vector<float> m_dashing_values;
};
Expand All @@ -39,6 +43,16 @@ template<>
struct Options::Option<BoundingBoxRenderer::Option::COLOR>{
glm::vec3 default_value = {1.0, 1.0, 1.0};
};

template<>
struct Options::Option<BoundingBoxRenderer::Option::LEVEL_OF_DETAIL>{
int default_value = 10;
};

template<>
struct Options::Option<BoundingBoxRenderer::Option::LINE_WIDTH>{
float default_value = 0.0;
};
}
}

Expand Down
62 changes: 62 additions & 0 deletions VFRendering/include/VFRendering/DotRenderer.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#ifndef VFRENDERING_DOT_RENDERER_HXX
#define VFRENDERING_DOT_RENDERER_HXX

#include <VFRendering/VectorFieldRenderer.hxx>

namespace VFRendering {
class DotRenderer : public VectorFieldRenderer {
public:

enum Option {
COLORMAP_IMPLEMENTATION = 140,
IS_VISIBLE_IMPLEMENTATION,
DOT_RADIUS,
DOT_STYLE
};

enum DotStyle {
CIRCLE,
SQUARE
};

DotRenderer(const View& view, const VectorField& vf);
virtual ~DotRenderer();
virtual void update(bool keep_geometry) override;
virtual void draw(float aspect_ratio) override;
virtual void optionsHaveChanged(const std::vector<int>& changed_options) override;
std::string getDotStyle(const DotStyle& dotstyle);

private:
void updateShaderProgram();
void updateVertexData();
void initialize();

bool m_is_initialized = false;

unsigned int m_program = 0;
unsigned int m_vao = 0;

unsigned int m_instance_position_vbo = 0;
unsigned int m_instance_direction_vbo = 0;

unsigned int m_num_instances = 0;
};

namespace Utilities {

template<>
struct Options::Option<DotRenderer::Option::DOT_RADIUS> {
float default_value = 1.f;
};

template<>
struct Options::Option<DotRenderer::Option::DOT_STYLE> {
DotRenderer::DotStyle default_value = DotRenderer::DotStyle::CIRCLE;
};

// COLORMAP_IMPLEMENTATION & IS_VISIBLE_IMPLEMENTATION define in View.hxx

}

}
#endif
10 changes: 10 additions & 0 deletions VFRendering/include/VFRendering/GlyphRenderer.hxx
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
namespace VFRendering {
class GlyphRenderer : public VectorFieldRenderer {
public:
enum Option {
ROTATE_GLYPHS = 1000
};

GlyphRenderer(const View& view, const VectorField& vf);
virtual ~GlyphRenderer();
Expand Down Expand Up @@ -33,6 +36,13 @@ private:
unsigned int m_num_indices = 0;
unsigned int m_num_instances = 0;
};

namespace Utilities {
template<>
struct Options::Option<GlyphRenderer::Option::ROTATE_GLYPHS> {
bool default_value = true;
};
}
}

#endif
41 changes: 41 additions & 0 deletions VFRendering/include/VFRendering/ParallelepipedRenderer.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef VFRENDERING_PARALLELEPIPED_RENDERER_HXX
#define VFRENDERING_PARALLELEPIPED_RENDERER_HXX

#include <VFRendering/GlyphRenderer.hxx>

namespace VFRendering {

class ParallelepipedRenderer : public GlyphRenderer {
public:
enum Option {
LENGTH_A = 100,
LENGTH_B,
LENGTH_C
};

ParallelepipedRenderer(const View& view, const VectorField& vf);
virtual void optionsHaveChanged(const std::vector<int>& changed_options) override;
};

namespace Utilities {

template<>
struct Options::Option<ParallelepipedRenderer::Option::LENGTH_A> {
float default_value = 1.f;
};

template<>
struct Options::Option<ParallelepipedRenderer::Option::LENGTH_B> {
float default_value = 1.f;
};

template<>
struct Options::Option<ParallelepipedRenderer::Option::LENGTH_C> {
float default_value = 1.f;
};

}

}

#endif
9 changes: 4 additions & 5 deletions VFRendering/include/VFRendering/RendererBase.hxx
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ public:
void setOption(const typename Options::Type<index>::type& value);
const Options& options() const;
template<int index>
const typename Options::Type<index>::type& getOption() const;
typename Options::Type<index>::type getOption() const;
virtual void optionsHaveChanged(const std::vector<int>& changed_options);
virtual void updateIfNecessary();

protected:
virtual void options(const Options& options);

private:
const View& m_view;
private:
Options m_options;
};

Expand All @@ -40,8 +39,8 @@ void RendererBase::setOption(const typename Options::Type<index>::type& value) {
}

template<int index>
const typename Options::Type<index>::type& RendererBase::getOption() const {
return m_options.get<index>();;
typename Options::Type<index>::type RendererBase::getOption() const {
return m_options.get<index>();
}

}
Expand Down
Empty file modified VFRendering/include/VFRendering/VectorField.hxx
100644 → 100755
Empty file.
5 changes: 3 additions & 2 deletions VFRendering/include/VFRendering/View.hxx
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ public:
void mouseScroll(const float& wheel_delta);
void setFramebufferSize(float width, float height);
float getFramerate() const;
glm::vec2 getFramebufferSize() const;

void updateOptions(const Options& options);
template<int index>
void setOption(const typename Options::Type<index>::type& value);
void options(const Options& options);
const Options& options() const;
template<int index>
const typename Options::Type<index>::type& getOption() const;
typename Options::Type<index>::type getOption() const;

void renderers(const std::vector<std::pair<std::shared_ptr<RendererBase>, std::array<float, 4>>>& renderers, bool update_renderer_options=true);

Expand All @@ -74,7 +75,7 @@ void View::setOption(const typename Options::Type<index>::type& value) {
}

template<int index>
const typename Options::Type<index>::type& View::getOption() const {
typename Options::Type<index>::type View::getOption() const {
return m_options.get<index>();
}

Expand Down
9 changes: 4 additions & 5 deletions VFRendering/include/shaders/boundingbox.frag.glsl.hxx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#ifndef BOUNDINGBOX_FRAG_GLSL_HXX
#define BOUNDINGBOX_FRAG_GLSL_HXX

static const std::string BOUNDINGBOX_FRAG_GLSL = R"LITERAL(
#version 330
#include "shader_header.hxx"

static const std::string BOUNDINGBOX_FRAG_GLSL = FRAG_SHADER_HEADER + R"LITERAL(
uniform vec3 uColor;
in float vfDashingValue;
out vec4 fo_FragColor;
void main(void) {
if (int(floor(vfDashingValue)) % 2 != 0) {
if (mod(floor(vfDashingValue), 2.0) != 0.0) {
discard;
}
fo_FragColor = vec4(uColor, 1.0);
Expand Down
5 changes: 3 additions & 2 deletions VFRendering/include/shaders/boundingbox.vert.glsl.hxx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#ifndef BOUNDINGBOX_VERT_GLSL_HXX
#define BOUNDINGBOX_VERT_GLSL_HXX

static const std::string BOUNDINGBOX_VERT_GLSL = R"LITERAL(
#version 330
#include "shader_header.hxx"

static const std::string BOUNDINGBOX_VERT_GLSL = VERT_SHADER_HEADER + R"LITERAL(
uniform mat4 uProjectionMatrix;
uniform mat4 uModelviewMatrix;
Expand Down
4 changes: 2 additions & 2 deletions VFRendering/include/shaders/colormap.bluewhitered.glsl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

static const std::string COLORMAP_BLUEWHITERED_GLSL = R"LITERAL(
vec3 colormap(vec3 direction) {
if (direction.z < 0) {
if (direction.z < 0.0) {
vec3 color_down = vec3(0.0, 0.0, 1.0);
vec3 color_up = vec3(1.0, 1.0, 1.0);
return mix(color_down, color_up, normalize(direction).z+1);
return mix(color_down, color_up, normalize(direction).z+1.0);
} else {
vec3 color_down = vec3(1.0, 1.0, 1.0);
vec3 color_up = vec3(1.0, 0.0, 0.0);
Expand Down
6 changes: 3 additions & 3 deletions VFRendering/include/shaders/coordinatesystem.frag.glsl.hxx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef COORDINATESYSTEM_FRAG_GLSL_HXX
#define COORDINATESYSTEM_FRAG_GLSL_HXX

static const std::string COORDINATESYSTEM_FRAG_GLSL = R"LITERAL(
#version 330
#include "shader_header.hxx"

static const std::string COORDINATESYSTEM_FRAG_GLSL = FRAG_SHADER_HEADER + R"LITERAL(
in vec3 vfColor;
in vec3 vfNormal;
out vec4 fo_FragColor;
void main(void) {
fo_FragColor = vec4(vfColor*abs(normalize(vfNormal).z), 1.0);
Expand Down
Loading

0 comments on commit 0d9aa8e

Please sign in to comment.