00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __mitkSurfaceProperty_h
00013 #define __mitkSurfaceProperty_h
00014
00015 #include "mitkObject.h"
00016 #include "mitkVisualizationIncludes.h"
00017
00021 #define mitkSetColorMacro(name, type) \
00022 void Set##name(type red, type green, type blue, type alpha = 1.0f) \
00023 { \
00024 m_##name[0] = red; \
00025 m_##name[1] = green; \
00026 m_##name[2] = blue; \
00027 m_##name[3] = alpha; \
00028 m_Modified = true; \
00029 } \
00030 void Set##name(type const color[4]) \
00031 { this->Set##name(color[0], color[1], color[2], color[3]); }
00032
00036 #define mitkGetColorMacro(name, type) \
00037 type const* Get##name() const { return this->m_##name; } \
00038 void Get##name(type &red, type &green, type &blue, type &alpha) const \
00039 { \
00040 red = m_##name[0]; \
00041 green = m_##name[1]; \
00042 blue = m_##name[2]; \
00043 alpha = m_##name[3]; \
00044 } \
00045 void Get##name(type color[4]) const \
00046 { this->Get##name(color[0], color[1], color[2], color[3]); }
00047
00048
00049 const int MITK_MESH_POINTS = 0;
00050 const int MITK_MESH_WIREFRAME = 1;
00051 const int MITK_MESH_SURFACE = 2;
00052
00053 const int MITK_SURFACE_FLAT = 0;
00054 const int MITK_SURFACE_GOURAUD = 1;
00055 const int MITK_SURFACE_PHONG = 2;
00056
00061 class MITK_VISUALIZATION_API mitkSurfaceProperty : public mitkObject
00062 {
00063 public:
00064 MITK_TYPE(mitkSurfaceProperty, mitkObject)
00065
00066 virtual void PrintSelf(ostream &os);
00067
00071 mitkSurfaceProperty();
00072
00078 bool IsModified() const { return m_Modified; }
00079
00084 void SetUnmodified() { m_Modified = false; }
00085
00094 void SetInterpolationType(int intpType) { m_InterpolationType = intpType; m_Modified = true; }
00095
00104 int GetInterpolationType() const { return m_InterpolationType; }
00105
00109 void SetInterpolationTypeToFlat() { this->SetInterpolationType(MITK_SURFACE_FLAT); }
00110
00114 void SetInterpolationTypeToGouraud() { this->SetInterpolationType(MITK_SURFACE_GOURAUD); }
00115
00119 void SetInterpolationTypeToPhong() { this->SetInterpolationType(MITK_SURFACE_PHONG); }
00120
00125 inline const char* GetInterpolationTypeAsString() const;
00126
00135 void SetRepresentationType(int repType) { m_RepresentationType = repType; m_Modified = true; }
00136
00145 int GetRepresentationType() const { return m_RepresentationType; }
00146
00150 void SetRepresentationTypeToPoints() { this->SetRepresentationType(MITK_MESH_POINTS); }
00151
00155 void SetRepresentationTypeToWireframe() { this->SetRepresentationType(MITK_MESH_WIREFRAME); }
00156
00160 void SetRepresentationTypeToSurface() { this->SetRepresentationType(MITK_MESH_SURFACE); }
00161
00166 inline const char* GetRepresentationTypeAsString() const;
00167
00172 void SetAmbient(float value) { m_Ambient = value; m_Modified = true; }
00173
00178 float GetAmbient() const { return m_Ambient; }
00179
00184 void SetDiffuse(float value) { m_Diffuse = value; m_Modified = true; }
00185
00190 float GetDiffuse() const { return m_Diffuse; }
00191
00196 void SetSpecular(float value) { m_Specular = value; m_Modified = true; }
00197
00202 float GetSpecular() const { return m_Specular; }
00203
00208 void SetSpecularPower(float value) { m_SpecularPower = value; m_Modified = true; }
00209
00214 float GetSpecularPower() const { return m_SpecularPower; }
00215
00221 void SetOpacity(float value) { m_Opacity = m_DiffuseColor[3] = value; m_Modified = true; }
00222
00228 float GetOpacity() const { return m_DiffuseColor[3]; }
00229
00235 void SetLineWidth(float value) { m_LineWidth = value; m_Modified = true; }
00236
00241 float GetLineWidth() const { return m_LineWidth; }
00242
00248 void SetPointSize(float value) { m_PointSize = value; m_Modified = true; }
00249
00254 float GetPointSize() const { return m_PointSize; }
00255
00263 void SetLineStipplePattern(unsigned short value) { m_LineStipplePattern = value; m_Modified = true; }
00264
00272 unsigned short GetLineStipplePattern() const { return m_LineStipplePattern; }
00273
00281 void SetLineStippleRepeatFactor(int value) { m_LineStippleRepeatFactor = value; m_Modified = true; }
00282
00289 int GetLineStippleRepeatFactor() const { return m_LineStippleRepeatFactor; }
00290
00300 void SetColor(float red, float green, float blue, float alpha = 1.0f);
00301
00311 void SetColor(float color[4]) { this->SetColor(color[0],color[1],color[2],color[4]); }
00312
00319 float* GetColor();
00320
00327 void GetColor(float color[4]);
00328
00335 mitkSetColorMacro(AmbientColor,float);
00336
00344 mitkGetColorMacro(AmbientColor,float);
00345
00352 mitkSetColorMacro(DiffuseColor,float);
00353
00361 mitkGetColorMacro(DiffuseColor,float);
00362
00369 mitkSetColorMacro(SpecularColor,float);
00370
00378 mitkGetColorMacro(SpecularColor,float);
00379
00386 mitkSetColorMacro(EmissionColor,float);
00387
00395 mitkGetColorMacro(EmissionColor,float);
00396
00403 mitkSetColorMacro(EdgeColor,float);
00404
00412 mitkGetColorMacro(EdgeColor,float);
00413
00414 protected:
00415 virtual ~mitkSurfaceProperty();
00416
00417 float m_Color[4];
00418 float m_AmbientColor[4];
00419 float m_DiffuseColor[4];
00420 float m_SpecularColor[4];
00421 float m_EmissionColor[4];
00422 float m_EdgeColor[4];
00423 float m_Ambient;
00424 float m_Diffuse;
00425 float m_Specular;
00426 float m_Emission;
00427 float m_SpecularPower;
00428 float m_Opacity;
00429 float m_PointSize;
00430 float m_LineWidth;
00431
00432 int m_RepresentationType;
00433 int m_InterpolationType;
00434 int m_LineStippleRepeatFactor;
00435 unsigned short m_LineStipplePattern;
00436 bool m_Modified;
00437
00438 private:
00439 mitkSurfaceProperty(const mitkSurfaceProperty&);
00440 void operator = (const mitkSurfaceProperty&);
00441 };
00442
00443 inline const char* mitkSurfaceProperty::GetInterpolationTypeAsString() const
00444 {
00445 switch (this->m_InterpolationType)
00446 {
00447 case MITK_SURFACE_FLAT:
00448 return "Flat";
00449
00450 case MITK_SURFACE_GOURAUD:
00451 return "Gouraud";
00452
00453 case MITK_SURFACE_PHONG:
00454 return "Phong";
00455
00456 default:
00457 return "Unknown";
00458 }
00459 }
00460
00461 inline const char* mitkSurfaceProperty::GetRepresentationTypeAsString() const
00462 {
00463 switch (this->m_RepresentationType)
00464 {
00465 case MITK_MESH_POINTS:
00466 return "Points";
00467
00468 case MITK_MESH_WIREFRAME:
00469 return "Wireframe";
00470
00471 case MITK_MESH_SURFACE:
00472 return "Surface";
00473
00474 default:
00475 return "Unknown";
00476 }
00477 }
00478
00479
00480
00481
00482
00483
00484 #endif
00485
00486