CustusX  2023.01.05-dev+develop.0da12
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) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXSINGLEVOLUMEPAINTERHELPER_H
13 #define CXSINGLEVOLUMEPAINTERHELPER_H
14 
15 #include "cxResourceVisualizationExport.h"
16 #include "cxForwardDeclarations.h"
17 #include <vtkCommand.h>
18 
19 #include "cxLogger.h"
20 
21 
22 class vtkOpenGLHelper;
23 class vtkShaderProgram;
24 class vtkOpenGLVertexArrayObject;
25 
26 typedef vtkSmartPointer<class vtkTextureObject> vtkTextureObjectPtr;
27 typedef vtkSmartPointer<class vtkOpenGLBufferObject> vtkOpenGLBufferObjectPtr;
28 
29 namespace cx
30 {
31 typedef vtkSmartPointer<class ShaderCallback> ShaderCallbackPtr;
32 
37 class cxResourceVisualization_EXPORT ShaderCallback : public vtkCommand
38 {
39 
40 public:
44  struct ShaderItem
45  {
46  QString mTextureUid;
48 
51 
52  QString mLUTUid;
54 
55  //int mLutSize; //basically: used to check if lut should be applied, also a check if it is RED or RGB(A)
56  float mWindow;
57  float mLevel;
58  float mLLR; //low level reject
59  float mAlpha;
60  };
61  typedef boost::shared_ptr<ShaderItem> ShaderItemPtr;
62 
63  static ShaderCallback *New();
65  virtual ~ShaderCallback();
66 
67  virtual void Execute(vtkObject *, unsigned long eventId, void*cbo);
68 
69  ShaderItemPtr getShaderItem(QString image_uid) const;
70  int getNumberOfUploadedTextures() const;
71 
72  void add(ShaderItemPtr item);
73  void clearShaderItems();
74 
75 private:
76  static void addArrayToAttributeArray(vtkShaderProgram *program, vtkOpenGLBufferObjectPtr buffer, std::string name, int vector_index);
77  static void addUniformiArray(vtkShaderProgram *program, std::string name, int value);
78  static void addUniformfArray(vtkShaderProgram *program, std::string name, float value);
79  static void bindFSOutputVariable(vtkShaderProgram *program);
80 
81  std::string getVectorNameFromName(std::string name, int index_of_vector) const;
82  void printDebugInfo(vtkOpenGLHelper *OpenGLHelper);
83 
84  std::vector<ShaderItemPtr> mShaderItems;
85 };
86 
87 }//cx
88 
89 #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.