MeVisLab Toolbox Reference
SoView2DShaderOverlay.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2015, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #pragma once
14 
15 #include "SoView2DExtension.h"
16 #include "SoView2DShaderState.h"
20 
23 
26 
28 {
29 
30  SO_NODE_HEADER(SoView2DShaderOverlay);
31 
32 public:
33 
34  static void initClass();
35 
37 
39  SoSFEnum blendMode;
40 
43 
45  void draw(View2DSliceList *dsl, View2DSlice* dslice, int slice) override;
46 
48 
50  void addOverlay(SoGLShaderProgram* program, SoView2DShaderOverlayInfo* overlay, float dx1, float dy1, float dx2, float dy2);
51 
52  void GLRender(SoGLRenderAction* action) override;
53 
54 protected:
55  struct ActionState {
56  std::vector<SoView2DShaderCustomInclude*> _includes;
57  std::vector<SoView2DShaderOperation*> _operations;
58  std::vector<SoView2DShaderOverlayInfo*> _overlays;
59  SoNodeList _shaderParameters;
60  std::vector<size_t> _nodeIds;
62  };
63 
65 
66  struct CachedShader {
68 
69  std::string _vertexShaderString;
70  std::string _fragmentShaderString;
72  SoRef<SoVertexShader> _vertexShader;
73  SoRef<SoFragmentShader> _fragmentShader;
74  SoRef<SoShaderProgram> _shaderProgram;
75  };
76 
77  void initPipeline();
78 
79  void fillDiagnosis(CachedShader& current, SoView2DShaderDiagnosis* diagnosisModule, SoState* state);
80 
81  void createShaders(std::string& vertexShader, std::string& fragmentShader, SoState* state, const SoView2DShaderState& currentState);
82 
83  void combineShaderString(const SoView2DShaderState& currentState, const ShaderPipelineCodeTarget& source, std::string& output);
84 
85  void applyFragmentOperations(const std::vector<SoView2DShaderOperation*>& operations);
86  void addFragmentIncludes(const std::vector<SoView2DShaderCustomInclude*>& includes);
87 
88  void appendFunction(ShaderPipeline& pipeline, int step, SoView2DShaderBuiltInFunctions::SoView2DShaderFunction* function,
89  const SoView2DShaderState& currentState);
90 
92 
94 
96  ShaderPipeline _fragmentPipeline;
97 
98  SoView2DShaderBuiltInFunctions::SetupState _setupState;
99  SoView2DShaderBuiltInFunctions::WriteFragment _writeFragment;
100 };
#define SOVIEW2D_API
File to resolve system dependencies in View2D library.
Class managing an OpenGL shader program.
SoView2DExtension Base class for all View2DExtensions used for drawing and event handling on the View...
Container class to specify a change operation for the shader pipeline shader.
Stores information for each overlay to render.
void combineShaderString(const SoView2DShaderState &currentState, const ShaderPipelineCodeTarget &source, std::string &output)
void applyFragmentOperations(const std::vector< SoView2DShaderOperation * > &operations)
void overwriteDrawingSettings(SoView2DDrawingSettings &settings) override
SoView2DShaderBuiltInFunctions::SetupState _setupState
SoView2DShaderBuiltInIncludes::IncludeContainer _builtInIncludes
void appendFunction(ShaderPipeline &pipeline, int step, SoView2DShaderBuiltInFunctions::SoView2DShaderFunction *function, const SoView2DShaderState &currentState)
static void initClass()
void addFragmentIncludes(const std::vector< SoView2DShaderCustomInclude * > &includes)
ShaderPipeline _fragmentPipeline
The fragment shader pipeline.
void draw(View2DSliceList *dsl, View2DSlice *dslice, int slice) override
Draws a border on the given slice.
void addOverlay(SoGLShaderProgram *program, SoView2DShaderOverlayInfo *overlay, float dx1, float dy1, float dx2, float dy2)
Adds the overlay uniforms to the shader program.
void fillDiagnosis(CachedShader &current, SoView2DShaderDiagnosis *diagnosisModule, SoState *state)
SoSFEnum blendMode
select the blend mode of the shader
SoView2DShaderBuiltInFunctions::WriteFragment _writeFragment
void GLRender(SoGLRenderAction *action) override
SoSFBool disableBaseImageDrawing
If enabled, the SoView2D does not draw its base image.
void createShaders(std::string &vertexShader, std::string &fragmentShader, SoState *state, const SoView2DShaderState &currentState)
Stores the state that defines the shader of the shader pipeline, used to detect if a regeneration of ...
a list that holds all View2DSlice objects (lazily created) of a SoView2D
a single slice that is stored in a View2DSliceList, typically created by a View2DSliceList
Definition: View2DSlice.h:48
boost::graph_traits< ml_graph_ptr >::vertex_descriptor source(graph_traits< ml_graph_ptr >::edge_descriptor e, const ml_graph_ptr)
Returns the vertex descriptor for u of the edge (u,v) represented by e.
Drawing settings that can be overwritten by extensions.
SoView2DShaderDiagnosis * _diagnosis
std::vector< SoView2DShaderOperation * > _operations
std::vector< SoView2DShaderCustomInclude * > _includes
std::vector< SoView2DShaderOverlayInfo * > _overlays
SoRef< SoFragmentShader > _fragmentShader