00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date: 2007-12-11 14:46:19 +0100 (Di, 11 Dez 2007) $ 00006 Version: $Revision: 13129 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include <vtkAbstractMapper.h> 00019 #include "mitkShaderProperty.h" 00020 #include "mitkShaderRepository.h" 00021 00022 #include <itkDirectory.h> 00023 #include <itksys/SystemTools.hxx> 00024 00025 mitk::ShaderProperty::ShaderProperty( ) 00026 { 00027 AddShaderTypes(); 00028 SetShader( (IdType)0 ); 00029 } 00030 00031 mitk::ShaderProperty::ShaderProperty( const IdType& value ) 00032 { 00033 AddShaderTypes(); 00034 SetShader(value); 00035 } 00036 00037 mitk::ShaderProperty::ShaderProperty( const std::string& value ) 00038 { 00039 AddShaderTypes(); 00040 SetShader(value); 00041 } 00042 00043 00044 void mitk::ShaderProperty::SetShader( const IdType& value ) 00045 { 00046 if ( IsValidEnumerationValue( value ) ) 00047 SetValue( value ); 00048 else 00049 SetValue( (IdType)0 ); 00050 } 00051 00052 void mitk::ShaderProperty::SetShader( const std::string& value ) 00053 { 00054 if ( IsValidEnumerationValue( value ) ) 00055 SetValue( value ); 00056 else 00057 SetValue( (IdType)0 ); 00058 } 00059 00060 mitk::EnumerationProperty::IdType mitk::ShaderProperty::GetShaderId() 00061 { 00062 return GetValueAsId(); 00063 } 00064 00065 std::string mitk::ShaderProperty::GetShaderName() 00066 { 00067 return GetValueAsString(); 00068 } 00069 00070 00071 void mitk::ShaderProperty::AddShaderTypes() 00072 { 00073 AddEnum( "fixed" ); 00074 00075 std::list<mitk::ShaderRepository::Shader::Pointer> *l 00076 = mitk::ShaderRepository::GetGlobalShaderRepository()->GetShaders(); 00077 00078 std::list<mitk::ShaderRepository::Shader::Pointer>::const_iterator i = l->begin(); 00079 00080 while( i != l->end() ) 00081 { 00082 AddEnum( (*i)->name ); 00083 i++; 00084 } 00085 } 00086 00087 bool mitk::ShaderProperty::AddEnum( const std::string& name ) 00088 { 00089 Element e; 00090 00091 e.name=name; 00092 00093 bool success=Superclass::AddEnum( e.name, (IdType)shaderList.size() ); 00094 00095 shaderList.push_back(e); 00096 00097 return success; 00098 } 00099 00100