Fraxinus  17.12-rc4
An IGT application
cxShaderCallback.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #ifndef CXSINGLEVOLUMEPAINTERHELPER_H
34 #define CXSINGLEVOLUMEPAINTERHELPER_H
35 
36 #include "cxResourceVisualizationExport.h"
37 #include "cxForwardDeclarations.h"
38 #include <vtkCommand.h>
39 
40 #include "cxLogger.h"
41 
42 
43 class vtkOpenGLHelper;
44 class vtkShaderProgram;
45 class vtkOpenGLVertexArrayObject;
46 
47 typedef vtkSmartPointer<class vtkTextureObject> vtkTextureObjectPtr;
48 typedef vtkSmartPointer<class vtkOpenGLBufferObject> vtkOpenGLBufferObjectPtr;
49 
50 namespace cx
51 {
52 typedef vtkSmartPointer<class ShaderCallback> ShaderCallbackPtr;
53 
58 class cxResourceVisualization_EXPORT ShaderCallback : public vtkCommand
59 {
60 
61 public:
65  struct ShaderItem
66  {
67  QString mTextureUid;
69 
72 
73  QString mLUTUid;
75 
76  //int mLutSize; //basically: used to check if lut should be applied, also a check if it is RED or RGB(A)
77  float mWindow;
78  float mLevel;
79  float mLLR; //low level reject
80  float mAlpha;
81  };
82  typedef boost::shared_ptr<ShaderItem> ShaderItemPtr;
83 
84  static ShaderCallback *New();
86  virtual ~ShaderCallback();
87 
88  virtual void Execute(vtkObject *, unsigned long eventId, void*cbo);
89 
90  ShaderItemPtr getShaderItem(QString image_uid) const;
91  int getNumberOfUploadedTextures() const;
92 
93  void add(ShaderItemPtr item);
94  void clearShaderItems();
95 
96 private:
97  static void addArrayToAttributeArray(vtkShaderProgram *program, vtkOpenGLBufferObjectPtr buffer, std::string name, int vector_index);
98  static void addUniformiArray(vtkShaderProgram *program, std::string name, int value);
99  static void addUniformfArray(vtkShaderProgram *program, std::string name, float value);
100  static void bindFSOutputVariable(vtkShaderProgram *program);
101 
102  std::string getVectorNameFromName(std::string name, int index_of_vector) const;
103  void printDebugInfo(vtkOpenGLHelper *OpenGLHelper);
104 
105  std::vector<ShaderItemPtr> mShaderItems;
106 };
107 
108 }//cx
109 
110 #endif // CXSINGLEVOLUMEPAINTERHELPER_H
vtkOpenGLBufferObjectPtr mTextureCoordinates
vtkSmartPointer< class vtkTextureObject > vtkTextureObjectPtr
vtkSmartPointer< class ShaderCallback > ShaderCallbackPtr
vtkSmartPointer< class vtkOpenGLBufferObject > vtkOpenGLBufferObjectPtr
vtkSmartPointer< class vtkTextureObject > vtkTextureObjectPtr
The ShaderCallback class is used to update information sent to our custom OpenGL shaders.
boost::shared_ptr< ShaderItem > ShaderItemPtr
vtkSmartPointer< class vtkOpenGLBufferObject > vtkOpenGLBufferObjectPtr
Namespace for all CustusX production code.