Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "vtkMitkRectangleProp.h"
00019 #include "vtkObjectFactory.h"
00020
00021 #include "mitkGL.h"
00022
00023 vtkStandardNewMacro(vtkMitkRectangleProp);
00024
00025 vtkMitkRectangleProp::vtkMitkRectangleProp()
00026 {
00027 }
00028
00029 vtkMitkRectangleProp::~vtkMitkRectangleProp()
00030 {
00031 }
00032
00033 double *vtkMitkRectangleProp::GetBounds()
00034 {
00035 return NULL;
00036 }
00037
00038 int vtkMitkRectangleProp::RenderOverlay(vtkViewport* )
00039 {
00040 m_RenderWindow->MakeCurrent();
00041
00042 Enable2DOpenGL();
00043
00044
00045 glEnable(GL_LINE_SMOOTH);
00046 glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
00047
00048
00049 int * i = m_RenderWindow->GetSize();
00050 GLfloat bbox[8] = {0.f , 0.f, (float)i[0], 0.f, (float)i[0], (float)i[1], 0.f, (float)i[1]};
00051
00052
00053 glLineWidth(5.0f);
00054 glBegin(GL_LINE_LOOP);
00055 for (int j = 0; j < 4; j++)
00056 {
00057 glColor3f(m_Color[0],m_Color[1],m_Color[2]);
00058 glVertex2fv(&bbox[2*j]);
00059 }
00060 glEnd();
00061 glLineWidth(1.0f);
00062
00063 glDisable(GL_LINE_SMOOTH);
00064
00065 Disable2DOpenGL();
00066
00067 return 1;
00068 }
00069
00070 void vtkMitkRectangleProp::SetRenderWindow(vtkRenderWindow* renWin)
00071 {
00072 m_RenderWindow = renWin;
00073 }
00074
00075 void vtkMitkRectangleProp::SetColor(float col1, float col2, float col3)
00076 {
00077 m_Color[0] = col1;
00078 m_Color[1] = col2;
00079 m_Color[2] = col3;
00080 }
00081
00082
00083 int vtkMitkRectangleProp::RenderTranslucentGeometry(vtkViewport* )
00084 {
00085 return 0;
00086 }
00087
00088 int vtkMitkRectangleProp::RenderOpaqueGeometry(vtkViewport* )
00089 {
00090 return 0;
00091 }
00092
00093 void vtkMitkRectangleProp::Enable2DOpenGL()
00094 {
00095 GLint iViewport[4];
00096
00097
00098 glGetIntegerv( GL_VIEWPORT, iViewport );
00099
00100
00101
00102 glMatrixMode( GL_PROJECTION );
00103 glPushMatrix();
00104 glLoadIdentity();
00105
00106
00107 glOrtho( iViewport[0], iViewport[0]+iViewport[2],
00108 iViewport[1]+iViewport[3], iViewport[1], -1, 1 );
00109 glMatrixMode( GL_MODELVIEW );
00110 glPushMatrix();
00111 glLoadIdentity();
00112
00113
00114
00115 glPushAttrib( GL_DEPTH_BUFFER_BIT | GL_LIGHTING_BIT | GL_TEXTURE_2D);
00116 glDisable( GL_DEPTH_TEST );
00117 glDisable( GL_LIGHTING );
00118 glDisable( GL_TEXTURE_2D );
00119 }
00120
00121 void vtkMitkRectangleProp::Disable2DOpenGL()
00122 {
00123 glPopAttrib();
00124 glMatrixMode( GL_PROJECTION );
00125 glPopMatrix();
00126 glMatrixMode( GL_MODELVIEW );
00127 glPopMatrix();
00128 }
00129