diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-17 16:09:51 +0100 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-17 16:09:51 +0100 |
commit | a9236429e5691159f1ddc017b28ee0c060e0092d (patch) | |
tree | 73abfac910e8b801105190e74b8fe3251c4c44bf /voronoisplat.cpp | |
parent | 2260996d93e723a55a72bf23447a8f77e98e1371 (diff) |
Added a options panel.
* Added screenshot action that saves two images: one of the main
view (plot + splat) and one of the bottom view (bar chart)
* Added methods/signals/slots to Scatterplot for handling glyph sizes
* Added methods/signals/slots to VoronoiSplat for handling the
alpha/beta parameters, which are now also no longer fixed
* Options panel:
- glyph sizes of both CPs and RPs
- splat opacity
- splat parameters (alpha & beta)
- color scale combo box currently does nothing
Diffstat (limited to 'voronoisplat.cpp')
-rw-r--r-- | voronoisplat.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/voronoisplat.cpp b/voronoisplat.cpp index dcddc11..9154c5e 100644 --- a/voronoisplat.cpp +++ b/voronoisplat.cpp @@ -12,7 +12,8 @@ #include "scatterplot.h" #include "skelft.h" -static const float RAD_BLUR = 5.0f; +static const float DEFAULT_ALPHA = 5.0f; +static const float DEFAULT_BETA = 20.0f; static int nextPow2(int n) { @@ -27,6 +28,8 @@ static int nextPow2(int n) VoronoiSplat::VoronoiSplat(QQuickItem *parent) : QQuickFramebufferObject(parent) , m_cmap(3*Colormap::SAMPLES) + , m_alpha(DEFAULT_ALPHA) + , m_beta(DEFAULT_BETA) { setTextureFollowsItemSize(false); } @@ -87,6 +90,18 @@ void VoronoiSplat::setColorScale(const ColorScale &scale) update(); } +void VoronoiSplat::setAlpha(float alpha) +{ + m_alpha = alpha; + update(); +} + +void VoronoiSplat::setBeta(float beta) +{ + m_beta = beta; + update(); +} + // ---------------------------------------------------------------------------- class VoronoiSplatRenderer @@ -115,6 +130,7 @@ private: QSize m_size; const std::vector<float> *m_sites, *m_values, *m_cmap; + float m_alpha, m_beta; QQuickWindow *m_window; // used to reset OpenGL state (as per docs) QOpenGLFunctions gl; @@ -336,8 +352,8 @@ void VoronoiSplatRenderer::render() // First pass m_program1->bind(); - m_program1->setUniformValue("rad_max", 20.0f); - m_program1->setUniformValue("rad_blur", RAD_BLUR); + m_program1->setUniformValue("rad_max", m_beta); + m_program1->setUniformValue("rad_blur", m_alpha); m_program1->setUniformValue("fb_size", float(m_size.width())); gl.glActiveTexture(GL_TEXTURE0); @@ -368,7 +384,7 @@ void VoronoiSplatRenderer::render() // Second pass m_program2->bind(); - m_program2->setUniformValue("rad_max", 20.0f); + m_program2->setUniformValue("rad_max", m_beta); gl.glActiveTexture(GL_TEXTURE0); gl.glBindTexture(GL_TEXTURE_2D, m_textures[0]); @@ -410,6 +426,8 @@ void VoronoiSplatRenderer::synchronize(QQuickFramebufferObject *item) splat->setValuesChanged(false); splat->setColorScaleChanged(false); + m_alpha = splat->alpha(); + m_beta = splat->beta(); m_sites = &(splat->sites()); m_values = &(splat->values()); m_cmap = &(splat->colorScale()); |