Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkVtkShaderRepository.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #define SR_INFO MITK_INFO("shader.repository")
18 #define SR_WARN MITK_WARN("shader.repository")
19 #define SR_ERROR MITK_ERROR("shader.repository")
20 
22 #include "mitkDataNode.h"
23 #include "mitkProperties.h"
24 #include "mitkShaderProperty.h"
25 #include "mitkVtkShaderProgram.h"
26 
27 #include <mitkBaseRenderer.h>
28 #include <vtkActor.h>
29 #include <vtkOpenGLRenderWindow.h>
30 #include <vtkProperty.h>
31 #include <vtkShader2.h>
32 #include <vtkShader2Collection.h>
33 #include <vtkShaderProgram2.h>
34 #include <vtkSmartPointer.h>
35 #include <vtkUniformVariables.h>
36 #include <vtkVersionMacros.h>
37 #include <vtkXMLDataElement.h>
38 #include <vtkXMLMaterial.h>
39 #include <vtkXMLMaterialParser.h>
40 #include <vtkXMLShader.h>
41 
42 #include <itkDirectory.h>
43 #include <itksys/SystemTools.hxx>
44 
45 int mitk::VtkShaderRepository::shaderId = 0;
46 const bool mitk::VtkShaderRepository::debug = false;
47 
49 {
50  LoadShaders();
51 }
52 
54 {
55 }
56 
58 {
60  return shaderProg;
61 }
62 
64 {
66 
67  std::string dirPath = "./vtk_shader";
68 
69  if (dir->Load(dirPath.c_str()))
70  {
71  int n = dir->GetNumberOfFiles();
72  for (int r = 0; r < n; r++)
73  {
74  const char *filename = dir->GetFile(r);
75 
76  std::string extension = itksys::SystemTools::GetFilenameExtension(filename);
77 
78  if (extension.compare(".xml") == 0)
79  {
80  Shader::Pointer element = Shader::New();
81 
82  element->SetName(itksys::SystemTools::GetFilenameWithoutExtension(filename));
83  std::string filePath = dirPath + std::string("/") + element->GetName() + std::string(".xml");
84 
85  SR_INFO(debug) << "found shader '" << element->GetName() << "'";
86 
87  std::ifstream fileStream(filePath.c_str());
88  element->LoadXmlShader(fileStream);
89 
90  shaders.push_back(element);
91  }
92  }
93  }
94 }
95 
97 {
98  std::list<Shader::Pointer>::const_iterator i = shaders.begin();
99 
100  while (i != shaders.end())
101  {
102  if ((*i)->GetName() == name)
103  return (*i);
104 
105  i++;
106  }
107 
108  return Shader::Pointer();
109 }
110 
111 int mitk::VtkShaderRepository::LoadShader(std::istream &stream, const std::string &filename)
112 {
113  Shader::Pointer element = Shader::New();
114  element->SetName(filename);
115  element->SetId(shaderId++);
116  element->LoadXmlShader(stream);
117  shaders.push_back(element);
118  SR_INFO(debug) << "found shader '" << element->GetName() << "'";
119  return element->GetId();
120 }
121 
123 {
124  for (std::list<Shader::Pointer>::iterator i = shaders.begin(); i != shaders.end(); ++i)
125  {
126  if ((*i)->GetId() == id)
127  {
128  shaders.erase(i);
129  return true;
130  }
131  }
132  return false;
133 }
134 
136 {
137 }
138 
140 {
141 }
142 
144 {
145  this->m_VertexShaderCode = code;
146 }
147 
149 {
150  return this->m_VertexShaderCode;
151 }
152 
154 {
155  this->m_FragmentShaderCode = code;
156 }
157 
159 {
160  return this->m_FragmentShaderCode;
161 }
162 
164 {
165  this->m_GeometryShaderCode = code;
166 }
167 
169 {
170  return this->m_GeometryShaderCode;
171 }
172 
173 std::list<mitk::VtkShaderRepository::Shader::Uniform::Pointer> mitk::VtkShaderRepository::Shader::GetUniforms() const
174 {
175  return uniforms;
176 }
177 
178 void mitk::VtkShaderRepository::Shader::LoadXmlShader(std::istream &stream)
179 {
180  std::string content;
181  content.reserve(2048);
182  char buffer[2048];
183  while (stream.read(buffer, sizeof(buffer)))
184  {
185  content.append(buffer, sizeof(buffer));
186  }
187  content.append(buffer, static_cast<std::size_t>(stream.gcount()));
188 
189  if (content.empty())
190  return;
191 
192  this->SetMaterialXml(content);
193 
195  vtkXMLMaterial *material = vtkXMLMaterial::New();
196  parser->SetMaterial(material);
197  parser->Parse(content.c_str());
198  parser->Delete();
199  if (material == NULL)
200  return;
201 
202  // Vertexshader uniforms
203  {
204  vtkXMLShader *s = material->GetVertexShader();
205  if (s)
206  {
207  SetVertexShaderCode(s->GetCode());
208  vtkXMLDataElement *x = s->GetRootElement();
209  int n = x->GetNumberOfNestedElements();
210  for (int r = 0; r < n; r++)
211  {
212  vtkXMLDataElement *y = x->GetNestedElement(r);
213  if (strcmp(y->GetName(), "ApplicationUniform") == 0 || strcmp(y->GetName(), "Uniform") == 0)
214  {
215  Uniform::Pointer element = Uniform::New();
216  element->LoadFromXML(y);
217  uniforms.push_back(element);
218  }
219  }
220  }
221  }
222 
223  // Fragmentshader uniforms
224  {
225  vtkXMLShader *s = material->GetFragmentShader();
226  if (s)
227  {
228  SetFragmentShaderCode(s->GetCode());
229  vtkXMLDataElement *x = s->GetRootElement();
230  int n = x->GetNumberOfNestedElements();
231  for (int r = 0; r < n; r++)
232  {
233  vtkXMLDataElement *y = x->GetNestedElement(r);
234  if (strcmp(y->GetName(), "ApplicationUniform") == 0 || strcmp(y->GetName(), "Uniform") == 0)
235  {
236  Uniform::Pointer element = Uniform::New();
237  element->LoadFromXML(y);
238  uniforms.push_back(element);
239  }
240  }
241  }
242  }
243 
244  // Geometryshader uniforms
245  {
246  vtkXMLShader *s = material->GetGeometryShader();
247  if (s)
248  {
249  SetGeometryShaderCode(s->GetCode());
250  vtkXMLDataElement *x = s->GetRootElement();
251  int n = x->GetNumberOfNestedElements();
252  for (int r = 0; r < n; r++)
253  {
254  vtkXMLDataElement *y = x->GetNestedElement(r);
255  if (strcmp(y->GetName(), "ApplicationUniform") == 0 || strcmp(y->GetName(), "Uniform") == 0)
256  {
257  Uniform::Pointer element = Uniform::New();
258  element->LoadFromXML(y);
259  uniforms.push_back(element);
260  }
261  }
262  }
263  }
264  material->Delete();
265 }
266 
268 {
269 }
270 
272 {
273 }
274 
276 {
277  // MITK_INFO << "found uniform '" << y->GetAttribute("name") << "' type=" << y->GetAttribute("type");// << " default="
278  // << y->GetAttribute("value");
279 
280  name = y->GetAttribute("name");
281 
282  const char *sType = y->GetAttribute("type");
283 
284  if (!strcmp(sType, "float"))
285  type = glsl_float;
286  else if (!strcmp(sType, "vec2"))
287  type = glsl_vec2;
288  else if (!strcmp(sType, "vec3"))
289  type = glsl_vec3;
290  else if (!strcmp(sType, "vec4"))
291  type = glsl_vec4;
292  else if (!strcmp(sType, "int"))
293  type = glsl_int;
294  else if (!strcmp(sType, "ivec2"))
295  type = glsl_ivec2;
296  else if (!strcmp(sType, "ivec3"))
297  type = glsl_ivec3;
298  else if (!strcmp(sType, "ivec4"))
299  type = glsl_ivec4;
300  else
301  {
302  type = glsl_none;
303  SR_WARN << "unknown type for uniform '" << name << "'";
304  }
305 
306  defaultFloat[0] = defaultFloat[1] = defaultFloat[2] = defaultFloat[3] = 0;
307 
308  const char *sDefault = y->GetAttribute("value");
309 
310  if (sDefault)
311  {
312  switch (type)
313  {
314  case glsl_float:
315  sscanf(sDefault, "%f", &defaultFloat[0]);
316  break;
317 
318  case glsl_vec2:
319  sscanf(sDefault, "%f %f", &defaultFloat[0], &defaultFloat[1]);
320  break;
321 
322  case glsl_vec3:
323  sscanf(sDefault, "%f %f %f", &defaultFloat[0], &defaultFloat[1], &defaultFloat[2]);
324  break;
325 
326  case glsl_vec4:
327  sscanf(sDefault, "%f %f %f %f", &defaultFloat[0], &defaultFloat[1], &defaultFloat[2], &defaultFloat[3]);
328  break;
329 
330  case glsl_int:
331  sscanf(sDefault, "%d", &defaultInt[0]);
332  break;
333 
334  case glsl_ivec2:
335  sscanf(sDefault, "%d %d", &defaultInt[0], &defaultInt[1]);
336  break;
337 
338  case glsl_ivec3:
339  sscanf(sDefault, "%d %d %d", &defaultInt[0], &defaultInt[1], &defaultInt[2]);
340  break;
341 
342  case glsl_ivec4:
343  sscanf(sDefault, "%d %d %d %d", &defaultInt[0], &defaultInt[1], &defaultInt[2], &defaultInt[3]);
344  break;
345 
346  case glsl_none:
347  break;
348  }
349  }
350 }
351 
353  mitk::BaseRenderer *renderer,
354  bool overwrite) const
355 {
356  node->AddProperty("shader", mitk::ShaderProperty::New(), renderer, overwrite);
357 
358  std::list<Shader::Pointer>::const_iterator i = shaders.begin();
359 
360  while (i != shaders.end())
361  {
362  std::list<Shader::Uniform::Pointer> uniforms = (*i)->GetUniforms();
363 
364  std::string shaderName = (*i)->GetName();
365 
366  std::list<Shader::Uniform::Pointer>::const_iterator j = uniforms.begin();
367 
368  while (j != uniforms.end())
369  {
370  std::string propertyName = "shader." + shaderName + "." + (*j)->name;
371 
372  switch ((*j)->type)
373  {
374  case Shader::Uniform::glsl_float:
375  node->AddProperty(propertyName.c_str(), mitk::FloatProperty::New((*j)->defaultFloat[0]), renderer, overwrite);
376  break;
377 
378  case Shader::Uniform::glsl_vec2:
379  node->AddProperty(
380  (propertyName + ".x").c_str(), mitk::FloatProperty::New((*j)->defaultFloat[0]), renderer, overwrite);
381  node->AddProperty(
382  (propertyName + ".y").c_str(), mitk::FloatProperty::New((*j)->defaultFloat[1]), renderer, overwrite);
383  break;
384 
385  case Shader::Uniform::glsl_vec3:
386  node->AddProperty(
387  (propertyName + ".x").c_str(), mitk::FloatProperty::New((*j)->defaultFloat[0]), renderer, overwrite);
388  node->AddProperty(
389  (propertyName + ".y").c_str(), mitk::FloatProperty::New((*j)->defaultFloat[1]), renderer, overwrite);
390  node->AddProperty(
391  (propertyName + ".z").c_str(), mitk::FloatProperty::New((*j)->defaultFloat[2]), renderer, overwrite);
392  break;
393 
394  case Shader::Uniform::glsl_vec4:
395  node->AddProperty(
396  (propertyName + ".x").c_str(), mitk::FloatProperty::New((*j)->defaultFloat[0]), renderer, overwrite);
397  node->AddProperty(
398  (propertyName + ".y").c_str(), mitk::FloatProperty::New((*j)->defaultFloat[1]), renderer, overwrite);
399  node->AddProperty(
400  (propertyName + ".z").c_str(), mitk::FloatProperty::New((*j)->defaultFloat[2]), renderer, overwrite);
401  node->AddProperty(
402  (propertyName + ".w").c_str(), mitk::FloatProperty::New((*j)->defaultFloat[3]), renderer, overwrite);
403  break;
404 
405  case Shader::Uniform::glsl_int:
406  node->AddProperty(propertyName.c_str(), mitk::IntProperty::New((*j)->defaultInt[0]), renderer, overwrite);
407  break;
408 
409  case Shader::Uniform::glsl_ivec2:
410  node->AddProperty(
411  (propertyName + ".x").c_str(), mitk::IntProperty::New((*j)->defaultInt[0]), renderer, overwrite);
412  node->AddProperty(
413  (propertyName + ".y").c_str(), mitk::IntProperty::New((*j)->defaultInt[1]), renderer, overwrite);
414  break;
415 
416  case Shader::Uniform::glsl_ivec3:
417  node->AddProperty(
418  (propertyName + ".x").c_str(), mitk::IntProperty::New((*j)->defaultInt[0]), renderer, overwrite);
419  node->AddProperty(
420  (propertyName + ".y").c_str(), mitk::IntProperty::New((*j)->defaultInt[1]), renderer, overwrite);
421  node->AddProperty(
422  (propertyName + ".z").c_str(), mitk::IntProperty::New((*j)->defaultInt[2]), renderer, overwrite);
423  break;
424 
425  case Shader::Uniform::glsl_ivec4:
426  node->AddProperty(
427  (propertyName + ".x").c_str(), mitk::IntProperty::New((*j)->defaultInt[0]), renderer, overwrite);
428  node->AddProperty(
429  (propertyName + ".y").c_str(), mitk::IntProperty::New((*j)->defaultInt[1]), renderer, overwrite);
430  node->AddProperty(
431  (propertyName + ".z").c_str(), mitk::IntProperty::New((*j)->defaultInt[2]), renderer, overwrite);
432  node->AddProperty(
433  (propertyName + ".w").c_str(), mitk::IntProperty::New((*j)->defaultInt[3]), renderer, overwrite);
434  break;
435 
436  case Shader::Uniform::glsl_none:
437  break;
438  }
439 
440  j++;
441  }
442 
443  i++;
444  }
445 }
446 
447 std::list<mitk::IShaderRepository::Shader::Pointer> mitk::VtkShaderRepository::GetShaders() const
448 {
449  std::list<mitk::IShaderRepository::Shader::Pointer> result;
450  for (std::list<Shader::Pointer>::const_iterator i = shaders.begin(); i != shaders.end(); ++i)
451  {
452  result.push_back(i->GetPointer());
453  }
454  return result;
455 }
456 
458 {
459  for (std::list<Shader::Pointer>::const_iterator i = shaders.begin(); i != shaders.end(); ++i)
460  {
461  if ((*i)->GetName() == name)
462  return i->GetPointer();
463  }
465 }
466 
468 {
469  for (std::list<Shader::Pointer>::const_iterator i = shaders.begin(); i != shaders.end(); ++i)
470  {
471  if ((*i)->GetId() == id)
472  return i->GetPointer();
473  }
475 }
476 
478  DataNode *node,
479  BaseRenderer *renderer) const
480 {
481  VtkShaderProgram *mitkVtkShaderProgram = dynamic_cast<VtkShaderProgram *>(shaderProgram);
482  mitk::ShaderProperty *sep = dynamic_cast<mitk::ShaderProperty *>(node->GetProperty("shader", renderer));
483  if (!sep)
484  {
485  mitkVtkShaderProgram->SetVtkShaderProgram(0);
486  return;
487  }
488 
489  Shader::Pointer s = GetShaderImpl(sep->GetValueAsString());
490 
491  // Need update pipeline mode
492  if (sep->GetMTime() > mitkVtkShaderProgram->GetShaderTimestampUpdate().GetMTime())
493  {
494  if (s.IsNull())
495  {
496  mitkVtkShaderProgram->SetVtkShaderProgram(0);
497  mitkVtkShaderProgram->GetShaderTimestampUpdate().Modified();
498  return;
499  }
500 
501  vtkSmartPointer<vtkShaderProgram2> program = vtkSmartPointer<vtkShaderProgram2>::New();
502 #if ((VTK_MAJOR_VERSION < 6) || ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION == 0)))
503  program->SetContext(dynamic_cast<vtkOpenGLRenderWindow *>(renderer->GetRenderWindow()));
504 #else
505  program->SetContext(renderer->GetRenderWindow());
506 #endif
507  // The vertext shader
508  vtkShader2 *shader = vtkShader2::New();
509  shader->SetType(VTK_SHADER_TYPE_VERTEX);
510  shader->SetSourceCode(s->GetVertexShaderCode().c_str());
511 #if ((VTK_MAJOR_VERSION < 6) || ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION == 0)))
512  shader->SetContext(dynamic_cast<vtkOpenGLRenderWindow *>(renderer->GetRenderWindow()));
513 #else
514  shader->SetContext(renderer->GetRenderWindow());
515 #endif
516  program->GetShaders()->AddItem(shader);
517  shader->Delete();
518 
519  // The fragment shader
520  shader = vtkShader2::New();
521  shader->SetType(VTK_SHADER_TYPE_FRAGMENT);
522  shader->SetSourceCode(s->GetFragmentShaderCode().c_str());
523 #if ((VTK_MAJOR_VERSION < 6) || ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION == 0)))
524  shader->SetContext(dynamic_cast<vtkOpenGLRenderWindow *>(renderer->GetRenderWindow()));
525 #else
526  shader->SetContext(renderer->GetRenderWindow());
527 #endif
528  program->GetShaders()->AddItem(shader);
529  shader->Delete();
530 
531  if (s->GetGeometryShaderCode().size() > 0)
532  {
533  // The Geometry shader
534  shader = vtkShader2::New();
535  shader->SetType(VTK_SHADER_TYPE_GEOMETRY);
536  shader->SetSourceCode(s->GetGeometryShaderCode().c_str());
537 #if ((VTK_MAJOR_VERSION < 6) || ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION == 0)))
538  shader->SetContext(dynamic_cast<vtkOpenGLRenderWindow *>(renderer->GetRenderWindow()));
539 #else
540  shader->SetContext(renderer->GetRenderWindow());
541 #endif
542  program->GetShaders()->AddItem(shader);
543  shader->Delete();
544  }
545 
546  program->Build();
547 
548  mitkVtkShaderProgram->SetVtkShaderProgram(program);
549 
550  mitkVtkShaderProgram->GetShaderTimestampUpdate().Modified();
551  }
552 
553  if (s.IsNull())
554  return;
555 
556  // update uniforms
557  vtkShaderProgram2 *p = mitkVtkShaderProgram->GetVtkShaderProgram();
558 
559  if (!p)
560  return;
561 
562  std::list<Shader::Uniform::Pointer>::const_iterator j = s->uniforms.begin();
563 
564  while (j != s->uniforms.end())
565  {
566  std::string propertyName = "shader." + s->GetName() + "." + (*j)->name;
567 
568  // MITK_INFO << "querying property: " << propertyName;
569 
570  // mitk::BaseProperty *p = node->GetProperty( propertyName.c_str(), renderer );
571 
572  // if( p && p->GetMTime() > MTime.GetMTime() )
573  {
574  float fval[4];
575  int ival[4];
576 
577  // MITK_INFO << "copying property " << propertyName << " ->->- " << (*j)->name << " type=" << (*j)->type ;
578 
579  switch ((*j)->type)
580  {
581  case Shader::Uniform::glsl_float:
582  node->GetFloatProperty(propertyName.c_str(), fval[0], renderer);
583  p->GetUniformVariables()->SetUniformf((*j)->name.c_str(), 1, fval);
584  break;
585 
586  case Shader::Uniform::glsl_vec2:
587  node->GetFloatProperty((propertyName + ".x").c_str(), fval[0], renderer);
588  node->GetFloatProperty((propertyName + ".y").c_str(), fval[1], renderer);
589  p->GetUniformVariables()->SetUniformf((*j)->name.c_str(), 2, fval);
590  break;
591 
592  case Shader::Uniform::glsl_vec3:
593  node->GetFloatProperty((propertyName + ".x").c_str(), fval[0], renderer);
594  node->GetFloatProperty((propertyName + ".y").c_str(), fval[1], renderer);
595  node->GetFloatProperty((propertyName + ".z").c_str(), fval[2], renderer);
596  // p->SetUniform3f( (*j)->name.c_str(), fval );
597  p->GetUniformVariables()->SetUniformf((*j)->name.c_str(), 3, fval);
598  break;
599 
600  case Shader::Uniform::glsl_vec4:
601  node->GetFloatProperty((propertyName + ".x").c_str(), fval[0], renderer);
602  node->GetFloatProperty((propertyName + ".y").c_str(), fval[1], renderer);
603  node->GetFloatProperty((propertyName + ".z").c_str(), fval[2], renderer);
604  node->GetFloatProperty((propertyName + ".w").c_str(), fval[3], renderer);
605  p->GetUniformVariables()->SetUniformf((*j)->name.c_str(), 4, fval);
606  break;
607 
608  case Shader::Uniform::glsl_int:
609  node->GetIntProperty(propertyName.c_str(), ival[0], renderer);
610  p->GetUniformVariables()->SetUniformi((*j)->name.c_str(), 1, ival);
611  break;
612 
613  case Shader::Uniform::glsl_ivec2:
614  node->GetIntProperty((propertyName + ".x").c_str(), ival[0], renderer);
615  node->GetIntProperty((propertyName + ".y").c_str(), ival[1], renderer);
616  p->GetUniformVariables()->SetUniformi((*j)->name.c_str(), 2, ival);
617  break;
618 
619  case Shader::Uniform::glsl_ivec3:
620  node->GetIntProperty((propertyName + ".x").c_str(), ival[0], renderer);
621  node->GetIntProperty((propertyName + ".y").c_str(), ival[1], renderer);
622  node->GetIntProperty((propertyName + ".z").c_str(), ival[2], renderer);
623  // p->SetUniform3f( (*j)->name.c_str(), fval );
624  p->GetUniformVariables()->SetUniformi((*j)->name.c_str(), 3, ival);
625  break;
626 
627  case Shader::Uniform::glsl_ivec4:
628  node->GetIntProperty((propertyName + ".x").c_str(), ival[0], renderer);
629  node->GetIntProperty((propertyName + ".y").c_str(), ival[1], renderer);
630  node->GetIntProperty((propertyName + ".z").c_str(), ival[2], renderer);
631  node->GetIntProperty((propertyName + ".w").c_str(), ival[3], renderer);
632  p->GetUniformVariables()->SetUniformi((*j)->name.c_str(), 4, ival);
633  break;
634 
635  case Shader::Uniform::glsl_none:
636  break;
637  }
638  }
639 
640  j++;
641  }
642 
643  return;
644 }
void AddDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer, bool overwrite) const override
Adds all parsed shader uniforms to property list of the given DataNode; used by mappers.
virtual std::string GetValueAsString() const override
itk::SmartPointer< Self > Pointer
#define SR_WARN
IShaderRepository::Shader::Pointer GetShader(const std::string &name) const override
Return the named shader.
bool GetIntProperty(const char *propertyKey, int &intValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for int properties (instances of IntProperty)
void SetVertexShaderCode(const std::string &code)
Organizes the rendering process.
vtkXMLShader * GetVertexShader(int id=0)
void SetMaterial(vtkXMLMaterial *)
void UpdateShaderProgram(mitk::IShaderRepository::ShaderProgram *shaderProgram, DataNode *node, BaseRenderer *renderer) const override
Applies shader and shader specific variables of the specified DataNode to the VTK object by updating ...
#define SR_INFO
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
ShaderProgram::Pointer CreateShaderProgram() override
static vtkXMLMaterial * New()
static Pointer New()
const char * GetCode()
vtkXMLShader * GetGeometryShader(int id=0)
Shader::Pointer GetShaderImpl(const std::string &name) const
void AddProperty(const char *propertyKey, BaseProperty *property, const mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Add the property (instance of BaseProperty) if it does not exist (or always ifoverwrite istrue) with ...
static const std::string filename
void SetGeometryShaderCode(const std::string &code)
bool GetFloatProperty(const char *propertyKey, float &floatValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for float properties (instances of FloatProperty)
std::list< Uniform::Pointer > GetUniforms() const
virtual int Parse() override
std::list< IShaderRepository::Shader::Pointer > GetShaders() const override
static Pointer New()
static Pointer New()
int LoadShader(std::istream &stream, const std::string &name) override
Applies shader and shader specific variables of the specified DataNode to the VTK object by updating ...
vtkXMLShader * GetFragmentShader(int id=0)
itk::SmartPointer< Self > Pointer
bool UnloadShader(int id) override
Unload a previously loaded shader.
static vtkXMLMaterialParser * New()
itk::TimeStamp & GetShaderTimestampUpdate()
void SetVtkShaderProgram(vtkSmartPointer< vtkShaderProgram2 > p)
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
vtkSmartPointer< vtkShaderProgram2 > GetVtkShaderProgram() const
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
void SetFragmentShaderCode(const std::string &code)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.