NorMIT-nav  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
cx::ShaderCallback::ShaderItem::mLUT
vtkTextureObjectPtr mLUT
Definition: cxShaderCallback.h:53
cxLogger.h
cx::ShaderCallback::ShaderItem::mLUTUid
QString mLUTUid
Definition: cxShaderCallback.h:52
vtkOpenGLBufferObjectPtr
vtkSmartPointer< class vtkOpenGLBufferObject > vtkOpenGLBufferObjectPtr
Definition: cxShaderCallback.h:27
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::ShaderCallback::ShaderItem
Definition: cxShaderCallback.h:44
cxForwardDeclarations.h
cx::ShaderCallback::ShaderItem::mLLR
float mLLR
Definition: cxShaderCallback.h:58
cx::ShaderCallback::ShaderItem::mTextureUid
QString mTextureUid
Definition: cxShaderCallback.h:46
vtkTextureObjectPtr
vtkSmartPointer< class vtkTextureObject > vtkTextureObjectPtr
Definition: cxShaderCallback.h:24
cx::ShaderCallback::ShaderItem::mAlpha
float mAlpha
Definition: cxShaderCallback.h:59
cx::ShaderCallback::ShaderItem::mTextureCoordinates
vtkOpenGLBufferObjectPtr mTextureCoordinates
Definition: cxShaderCallback.h:50
cx::ShaderCallback::ShaderItem::mTexture
vtkTextureObjectPtr mTexture
Definition: cxShaderCallback.h:47
cx::ShaderCallback::ShaderItem::mLevel
float mLevel
Definition: cxShaderCallback.h:57
vtkTextureObjectPtr
vtkSmartPointer< class vtkTextureObject > vtkTextureObjectPtr
Definition: vtkForwardDeclarations.h:139
vtkOpenGLBufferObjectPtr
vtkSmartPointer< class vtkOpenGLBufferObject > vtkOpenGLBufferObjectPtr
Definition: vtkForwardDeclarations.h:102
cx::ShaderCallback::ShaderItem::mWindow
float mWindow
Definition: cxShaderCallback.h:56
cx::ShaderCallback::ShaderItem::mTextureCoordinatesUid
QString mTextureCoordinatesUid
Definition: cxShaderCallback.h:49
cx::ShaderCallbackPtr
vtkSmartPointer< class ShaderCallback > ShaderCallbackPtr
Definition: cxShaderCallback.h:31
cx::ShaderCallback
The ShaderCallback class is used to update information sent to our custom OpenGL shaders.
Definition: cxShaderCallback.h:37
cx::ShaderCallback::ShaderItemPtr
boost::shared_ptr< ShaderItem > ShaderItemPtr
Definition: cxShaderCallback.h:61