1 #ifndef VOLUMERENDERER_H
2 #define VOLUMERENDERER_H
5 #include <qopenglfunctions_3_3_core.h>
23 enum class ProjectionType
54 inline const QString
error()
const {
return m_errString; }
72 void setSize(
int width,
int height);
151 void setRotation(
float x,
float y);
152 void rotationDelta(
float x,
float y);
153 void setDistance(
float d);
154 void distanceDelta(
float d);
156 void setRenderBoundingBox(
bool b);
157 void setFixSlicingMatrix(
bool b);
158 void setShowLightDirection(
bool b);
160 void setSliceDelta(
float sliceDelta);
161 void setProjectionType(ProjectionType pt);
162 void setLowerWindowLimit(
float w);
163 void setUpperWindowLimit(
float w);
165 void setSmoothVolume(
bool b);
166 void setGaussianSigma(
float s);
203 QOpenGLShaderProgram*
createShader(const QString& vShaderName, const QString& fShaderName, const QString& gShaderName="");
244 void traverseSlices(const QVector<QVector3D>& transformedBox,
int count,
float zStart,
float zDelta);
245 int traverseSlicesDOF(const QVector<QVector3D>& transformedBox,
int count,
float zStart,
float zDelta,
float focusZ,QOpenGLFramebufferObject** buffers);
246 bool updateSliceGeometry(const QVector<QVector3D>& box, const
float zPos, GLint& firstIdx, GLsizei& count);
248 void drawBoundingBox();
249 void drawLine(const QVector3D& pointA,const QVector3D& pointB, const QVector3D& color);
252 #endif // VOLUMERENDERER_H
void requestUpdate()
Like requestDraw, but requests that the window call update instead.
void updateProjection()
Calculates a new projection matrix depending on current viewport parameters.
Definition: volumerenderer.cpp:905
QSurfaceFormat getDesiredFormat() const
Returns the surface format the renderer would like to have.
Definition: volumerenderer.cpp:13
void distanceChanged(float d)
Emitted when the camera distance is changed.
bool initBuffers()
Initializes VAOs/VBOs etc, for bounding box, slices ...
Definition: volumerenderer_init.cpp:283
VolumeRenderer(QObject *parent=nullptr)
Sets up basic stuff.
Definition: volumerenderer_init.cpp:10
bool initTextures()
Initializes the required textures, currently rather empty because they are recreated in processVolume...
Definition: volumerenderer_init.cpp:394
void processLogMessage(const QOpenGLDebugMessage &msg)
Currently unused due to a bug in Qt 5.2 with AMD graphics cards.
Definition: volumerenderer_init.cpp:25
bool initialize()
Initializes the volume renderer, using the currently bound OpenGL context.
Definition: volumerenderer_init.cpp:54
A state-based OpenGL renderer for simple volume rendering.
Definition: volumerenderer.h:17
void update()
Needs to be called with a valid GL context to finalize specific operations like volume loading...
Definition: volumerenderer.cpp:117
QVector< float > setupGaussian(int &size)
Calculates a 3D Gaussian convolution kernel depending on current sigma.
Definition: volumerenderer.cpp:127
void updateFBOs()
Creates/updates the required framebuffer objects to fit the current viewport size.
Definition: volumerenderer_init.cpp:400
int getLastSliceCount() const
Gets the total number of slices that were processed in the last frame.
Definition: volumerenderer.cpp:55
bool loadVolume(const QString &metadataFile, VolumeMetaData *loadedVolume=nullptr)
The VolumeRenderer, with help of a VolumeLoader, loads the volume metadata and then the volume specif...
Definition: volumerenderer.cpp:70
VolumeMetaData getCurrentVolume() const
Returns the currently loaded volume meta data, contains garbage if nothing loaded yet...
Definition: volumerenderer.cpp:65
void setBlurAmount(float R)
Sets the rate at which the blurring increases with distance to the focal plane.
Definition: volumerenderer.cpp:1050
QOpenGLShaderProgram * createShader(const QString &vShaderName, const QString &fShaderName, const QString &gShaderName="")
Helper function to create a OpenGL shader program, with vertex, fragment and optional geometry shader...
Definition: volumerenderer_init.cpp:175
float getFPS() const
Returns the current FPS.
Definition: volumerenderer.cpp:45
void processVolume(const QByteArray &data)
Processes the raw volume data passed according to the current metadata and settings.
Definition: volumerenderer.cpp:180
void lightParamsChanged(float azimuth, float angle)
Emitted when the light parameters changed.
int getLastRenderedSliceCount() const
Gets the number of processed slices which were actually rendered.
Definition: volumerenderer.cpp:60
Contains private data of the volume renderer.
Definition: volumerenderer_private.h:55
void setLightParameters(float azimuth, float angle)
Sets the light parameters.
Definition: volumerenderer.cpp:921
void drawCurrent()
Draws the current state.
Definition: volumerenderer.cpp:363
const QString error() const
Returns the current error text of the renderer.
Definition: volumerenderer.h:54
This file includes the VolumeLoader class, as well as the VolumeMetaData structure.
void setFocalPlane(float d)
Sets the distance to the focal plane, .
Definition: volumerenderer.cpp:1056
void rotationChanged(float xRot, float yRot)
Emitted when camera rotation is changed.
int traverseSlicesDOF(const QVector< QVector3D > &transformedBox, int count, float zStart, float zDelta, float focusZ, QOpenGLFramebufferObject **buffers)
Like traverseSlices, but applies the DOF effects.
Definition: volumerenderer.cpp:571
bool initShaders()
Loads, compiles & links all shaders the renderer requires.
Definition: volumerenderer_init.cpp:259
void requestDraw()
Emitted when the state of the renderer is changed in a way that would change the rendered image...
bool checkGLRequirements()
Tests if the current OpenGL context meets the requirements of the renderer.
Definition: volumerenderer_init.cpp:33
void setSize(int width, int height)
Call this to change the viewport and projection matrices.
Definition: volumerenderer.cpp:866
void setApplyDOF(bool v)
Toggles the depth-of-field effect on/off.
Definition: volumerenderer.cpp:1044
void lightDelta(float azimuth, float angle)
-form of setLightParameters which applies a change to the current values.
Definition: volumerenderer.cpp:944
QOpenGLShaderProgram * createComputeShader(const QString &cShaderName)
Helper function to create a OpenGL compute shader program.
Definition: volumerenderer_init.cpp:131
void traverseSlices(const QVector< QVector3D > &transformedBox, int count, float zStart, float zDelta)
Traverses the transformed bounding box from the specified start point in the specified direction (del...
Definition: volumerenderer.cpp:684
bool updateSliceGeometry(const QVector< QVector3D > &box, const float zPos, GLint &firstIdx, GLsizei &count)
Performs slicing of a view-aligned plane with the view-transformed volume bounding box...
Definition: volumerenderer.cpp:740