6.5.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 22e94059 authored by mostajab's avatar mostajab

+ Untabifying the datacontainerinspectorcanvas.cpp and datacontainerinspectorcanvas.h

+ Moving the geomteryshader vertex and fragment shader to application folder as they belong to it.
+ Removing unndeeded shader code.
+ Opening braces convention is considered for datacontainerinspectorcanvas.cpp and datacontainerinspectorcanvas.h  also.
+ Reusing textues for color and depth buffers instead of creating and deleting them.
+ adding gettrackball function to trackball event handler.
+ modifying resetcontent, mouse events in datacontainerinspectorcanvas class
+ using one depth buffer for datacontainerinspectorcanvas instead of one for every color buffer
+ using one frame buffer for whole datacontainerinspectorcanvas instead of one for every frame
parent c8eb1d0e
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
in vec3 in_Position; ///< incoming vertex position
out vec4 ex_Position; ///< outgoing world coordinates
/// Matrix defining model-to-world transformation
uniform mat4 _modelMatrix = mat4(
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
/// Matrix defining view transformation
uniform mat4 _viewMatrix = mat4(
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
/// Matrix defining projection transformation
uniform mat4 _projectionMatrix = mat4(
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
void main() {
gl_Position = _projectionMatrix * (_viewMatrix * (_modelMatrix * vec4(in_Position, 1.0)));
ex_Position = gl_Position;
}
......@@ -27,12 +27,7 @@
//
// ================================================================================================
//#include "tools/shading.frag"
in vec3 ex_TexCoord; ///< incoming texture coordinate
in vec4 ex_Position; ///< incoming texture coordinate
in vec3 ex_Local_Position; ///< incoming local coordinate
uniform vec4 _Color = vec4(0, 1, 0, 1); ///< outgoing colorin
......@@ -40,13 +35,4 @@ out vec4 out_Color; ///< outgoing fragment color
void main() {
out_Color = _Color;
//out_Color = vec4(normalize(ex_Local_Position), 1);
//out_Color = vec4(0, 1, 0, 1);
//out_Color = _color;
#ifdef ENABLE_SHADING
// compute gradient (needed for shading and normals)
vec3 gradient = ex_TexCoord;
out_Color.rgb = calculatePhongShading(ex_Position.xyz / ex_Position.z, _lightSource, _cameraPosition, gradient, _color.rgb, _color.rgb, vec3(1.0, 1.0, 1.0));
#endif
}
......@@ -63,6 +63,23 @@ namespace campvis {
class FaceGeometry;
class DataContainerInspectorWidget;
struct GeometryTextureInfo {
campvis::QtDataHandle _geomData;
tgt::Texture* _texture;
int _trackballIndx;
GeometryTextureInfo(): _geomData(0), _texture(0){
}
void destroy() {
// _texture->destroy();
delete _texture;
}
~GeometryTextureInfo() {
}
};
class DataContainerInspectorCanvas : public tgt::QtThreadedCanvas, tgt::Painter, public tgt::EventListener, public HasPropertyCollection {
Q_OBJECT;
......@@ -98,15 +115,15 @@ namespace campvis {
void setDataHandles(const std::vector< std::pair<QString, QtDataHandle> >& handles);
/**
/**
* returns the color value which is captured with the mouse.
*/
const tgt::Color& getCapturedColor();
const tgt::Color& getCapturedColor();
/**
/**
* returns the depth value which is captured with the mouse.
*/
const float& getCapturedDepth();
const float& getCapturedDepth();
/**
* Size hint for the default window size
......@@ -159,7 +176,7 @@ namespace campvis {
virtual void onPropertyChanged(const AbstractProperty* prop);
IntProperty p_currentSlice;
IVec4Property p_meshSolidColor; ///< Color used to render the mesh object
IVec4Property p_meshSolidColor; ///< Color used to render the mesh object
TransferFunctionProperty p_transferFunction; ///< Transfer function
private slots:
......@@ -176,7 +193,7 @@ namespace campvis {
*/
virtual void paint();
/**
/**
* Performs the painting.
*/
virtual void paintMeshGeomTextures();
......@@ -195,7 +212,7 @@ namespace campvis {
*/
void updateTextures();
/**
/**
* Updates the textures vector elements that belongs to mesh geomteries.
* \note Only call with acquired lock and valid OpenGL context!!
*/
......@@ -206,12 +223,12 @@ namespace campvis {
*/
void invalidate();
/**
/**
* To be called when the mesh geometry parts of the scene is invalidated, issues new paint job only for textures that belong to mesh geomteries.
*/
void invalidateMeshGeomTextures();
/**
/**
* Renders the given 2D texture.
* Binds the texture to the shader, sets the uniforms and renders the quad.
* \param texture The texture to render.
......@@ -220,7 +237,7 @@ namespace campvis {
*/
void paintTexture(const tgt::Texture* texture, const tgt::TextureUnit& unit2d, const tgt::TextureUnit& unit3d);
/**
/**
* Renders the Meshgeometry into the geometry renderer color buffer and depth buffer.
* Binds the texture to the shader, sets the uniforms and renders the mesh geometry.
* \param meshgeometry The mesh to be rendered.
......@@ -228,7 +245,7 @@ namespace campvis {
* \param depthBuffer The depth buffer that the object will be rendered to.
* \param meshIndex The index of the rendered mesh in the texture array.
*/
void drawMeshgeometry(const campvis::MeshGeometry* meshgeometry, tgt::Texture* colorBuffer, tgt::Texture* depthBuffer, const unsigned int& meshIndex);
void drawGeomteryData(const campvis::GeometryData* meshgeometry, tgt::Texture* colorBuffer, const int& trackballIndx);
/**
* Creates the quad used for rendering the textures.
......@@ -238,7 +255,7 @@ namespace campvis {
std::map<QString, QtDataHandle> _handles;
std::vector<const tgt::Texture*> _textures; ///< vector of textures
bool _texturesDirty; ///< Flag that shows that the textures need update or not.
bool _meshGeomTexturesDirty; ///< Flag that shows that the mesh geometry textures need updare or not.
bool _meshGeomTexturesDirty; ///< Flag that shows that the mesh geometry textures need updare or not.
DataContainer* _dataContainer; ///< The DataContainer this widget is inspecting
tbb::mutex _localMutex; ///< Mutex protecting the local members
......@@ -247,27 +264,28 @@ namespace campvis {
FaceGeometry* _quad; ///< Quad used for rendering
tgt::Color _color; ///< Color under the mouse cursor
float _depth; ///< Depth under the mouse cursor
float _depth; ///< Depth under the mouse cursor
DataContainerInspectorWidget* _widget; ///< Pointer to the widget which has access to this canvas
tgt::ivec2 _numTiles; ///< number of tiles on texture overview
tgt::ivec2 _quadSize; ///< size in pixels for each tile in overview
size_t _selectedTexture; ///< index of selected texture by mouse
int _selectedTrackball; ///< index of selected trackball which will be updated currently
int _selectedTrackball; ///< index of selected trackball which will be updated currently
bool _renderFullscreen; ///< flag whether to render in full screen
int _currentSlice; ///< current slice if rendering a 3D image fullscreen, render MIP if negative
tgt::Shader* _geometryRenderingShader; ///< GLSL shader for rendering the mesh geomteries
std::vector<tgt::Texture*> _geometryRendering_ColorBuffers; ///< Color Buffer used to render the geometry for the debugging mode
std::vector<tgt::Texture*> _geometryRendering_DepthBuffers; ///< Depth Buffer used to render the geometry for the debugging mode
const campvis::MeshGeometry* _meshgeometryPtr; ///< Pointer to the mesh geometry objects
tgt::Shader* _geometryRenderingShader; ///< GLSL shader for rendering the mesh geomteries
//std::vector<tgt::Texture*> _geometryRendering_ColorBuffers; ///< Color Buffer used to render the geometry for the debugging mode
//std::vector<tgt::Texture*> _geometryRendering_DepthBuffers; ///< Depth Buffer used to render the geometry for the debugging mode
tgt::FramebufferObject* _frameBuffer;
tgt::Texture* _depthBuffer;
tgt::ivec2 _renderingWndSize;
std::vector<campvis::CameraProperty*> _trackballCameraProperties; ///< The property of the trackball camera. Used to pass the trackball camera to the shader.
std::vector<TrackballNavigationEventListener*> _trackballEHs; ///< TrackBall Event Handler for the camera rotating around the object in the canvas
std::vector<int> _geomTextureIndices; ///< Array of Indices in the texture which are achieved by rendering a geometry
// tgt::ivec2 _renderingWndSize;
std::vector<campvis::CameraProperty*> _trackballCameraProperties; ///< The property of the trackball camera. Used to pass the trackball camera to the shader.
std::vector<TrackballNavigationEventListener*> _trackballEHs; ///< TrackBall Event Handler for the camera rotating around the object in the canvas
std::vector<GeometryTextureInfo> _geomTextureInfos; ///< Array of data regarding the rendered geomteries
};
}
#endif // DATACONTAINERINSPECTORCANVAS_H__
#endif // DATACONTAINERINSPECTORCANVAS_H__
\ No newline at end of file
......@@ -124,8 +124,8 @@ namespace campvis {
reinitializeCamera(pos, worldBounds.center(), _cameraProperty->getValue().getUpVector());
}
}
void TrackballNavigationEventListener::setCenter(const tgt::vec3& center) {
void TrackballNavigationEventListener::setCenter(const tgt::vec3& center) {
_trackball->setCenter(center);
}
......@@ -137,6 +137,10 @@ namespace campvis {
return _trackball->getSceneBounds();
}
tgt::Trackball* TrackballNavigationEventListener::getTrackball() {
return _trackball;
}
void TrackballNavigationEventListener::addLqModeProcessor(VisualizationProcessor* vp) {
tgtAssert(vp != 0, "Pointer to processor must not be 0.");
tgtAssert(std::find(_lqModeProcessors.begin(), _lqModeProcessors.end(), vp) == _lqModeProcessors.end(), "Processor already in list of LQ mode processors.");
......
......@@ -149,6 +149,11 @@ namespace campvis {
*/
const tgt::Bounds& getSceneBounds() const;
/**
* Returns the trackball of the event handler.
*/
tgt::Trackball* getTrackball();
/**
* Adds \a vp to the list of LQ mode processors.
* During interaction, TrackballNavigationEventListener will set the LQ mode flag of all
......@@ -173,7 +178,7 @@ namespace campvis {
CameraProperty* _cameraProperty; ///< The CameraProperty to apply the navigation to
IVec2Property* _viewportSizeProp; ///< Pointer to the property defining the viewport size
CamPropNavigationWrapper _cpnw; ///< The CamPropNavigationWrapper used to adapt to the tgt::Trackball interface
public:
tgt::Trackball* _trackball; ///< The tgt::Trackball for the navigation logic
protected:
tgt::Bounds _sceneBounds; ///< The extent of the scene (in world coordinates)
......
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