Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Slice Class Reference

#include <slice.h>

List of all members.

Public Types

enum  { XY, XZ, YZ }

Public Methods

 Slice ()
 ~Slice ()
bool SetType (int tp)
int GetType ()
int GetSliceNumber (Data *dat=NULL)
void SetTransferfunction (Transfunc *transferfunction)
bool SetPixels (Data *dat, int dp)
void SetZoom (bool zoom)
bool GetZoom ()
void SetTransfer (bool transfer)
bool GetTransfer ()
bool SetPixels (Transfunc *tf, Data *dat, int dp)
bool DrawSlice (int width, int height)
void GetImageInfo (int &width, int &height, int &x, int &y, int &plane, int &depth)
rgbGetScreenShotImage (int &width, int &height)

Private Attributes

int m_depth
int m_type
int m_x
int m_y
int m_width
int m_height
rgbslice_data
bool m_bZoom
bool m_bUseTransfer
int m_dSliceNumber
Transfuncm_tTransferfunction


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
XY 
XZ 
YZ 

Definition at line 27 of file slice.h.

00027 { XY, XZ, YZ };


Constructor & Destructor Documentation

Slice::Slice  
 

Definition at line 4 of file slice.cpp.

References m_bUseTransfer, m_bZoom, m_depth, m_dSliceNumber, m_height, m_tTransferfunction, m_type, m_width, and slice_data.

00005 {
00006         m_depth=0;
00007         m_height=0;
00008         m_width=0;
00009         m_type=0; // xy Plane as default value
00010         slice_data = NULL;
00011         m_dSliceNumber = -1;
00012         m_bZoom = false;
00013         m_bUseTransfer = false;
00014         m_tTransferfunction = NULL;
00015 }

Slice::~Slice  
 

Definition at line 18 of file slice.cpp.

References slice_data.

00019 {
00020         if(slice_data != NULL) delete slice_data;
00021 }


Member Function Documentation

bool Slice::DrawSlice int    width,
int    height
 

Definition at line 157 of file slice.cpp.

References m_bZoom, m_height, m_width, m_x, m_y, and slice_data.

Referenced by CMy3dvisView::RenderScene().

00158 {
00159         float zoomx = (float)width / (float)m_width;
00160         float zoomy = (float)height / (float)m_height;
00161         float zoom;
00162 
00163 
00164         if (zoomx < zoomy) {
00165                 zoom = zoomx;
00166                 m_x = 0;
00167                 m_y = height / 2 - (m_height * zoom) / 2;
00168         }
00169         else {
00170                 zoom = zoomy;
00171                 m_y = 0;
00172                 m_x = width / 2 - (m_width * zoom) / 2;
00173         }
00174 
00175 
00176         if (!m_bZoom) {
00177                 zoom = 1.0f;
00178                 m_x = width / 2 - m_width / 2;
00179                 m_y = height / 2 - m_height / 2;
00180         }
00181 
00182 
00183         if(slice_data == NULL) return false;
00184         glRasterPos2i(m_x, m_y);
00185         glPixelStorei(GL_UNPACK_ALIGNMENT,1);
00186         glPixelZoom(zoom, zoom);
00187         glDrawPixels(m_width, m_height, GL_RGB, GL_UNSIGNED_BYTE, slice_data);
00188         return true;
00189 }

void Slice::GetImageInfo int &    width,
int &    height,
int &    x,
int &    y,
int &    plane,
int &    depth
 

Definition at line 194 of file slice.cpp.

References m_depth, m_height, m_type, m_width, m_x, and m_y.

00194                                                                                         {
00195         width = m_width;
00196         height = m_height;
00197         x = m_x;
00198         y = m_y;
00199         plane = m_type;
00200         depth = m_depth;
00201 }

rgb* Slice::GetScreenShotImage int &    width,
int &    height
[inline]
 

Definition at line 48 of file slice.h.

Referenced by CMy3dvisView::OnFileSaveImage().

00048                                                          { width = m_width;
00049                                                                                                                 height = m_height;
00050                                                                                                                 return slice_data; };

int Slice::GetSliceNumber Data   dat = NULL
 

Definition at line 38 of file slice.cpp.

References Data::GetXDim(), Data::GetYDim(), Data::GetZDim(), m_dSliceNumber, XY, XZ, and YZ.

Referenced by dialogbar::OnShowWindow().

00038                                    {
00039         if (dat == NULL)
00040                 return m_dSliceNumber;
00041 
00042         switch (m_type) {
00043                 case XY:
00044                         m_dSliceNumber = dat->GetZDim() - 1;
00045                         break;
00046                 case XZ:
00047                         m_dSliceNumber = dat->GetYDim() - 1;
00048                         break;
00049                 case YZ:
00050                         m_dSliceNumber = dat->GetXDim() - 1;
00051                         break;
00052         }
00053         return m_dSliceNumber;
00054 }

bool Slice::GetTransfer   [inline]
 

Definition at line 43 of file slice.h.

Referenced by dialogbar::OnCheckUseTransfer().

00043 { return m_bUseTransfer; }

int Slice::GetType  
 

Definition at line 32 of file slice.cpp.

References m_type.

00033 {
00034         return m_type;
00035 }

bool Slice::GetZoom   [inline]
 

Definition at line 40 of file slice.h.

Referenced by dialogbar::OnCheckZoom().

00040 { return m_bZoom; }

bool Slice::SetPixels Transfunc   tf,
Data   dat,
int    dp
 

Definition at line 58 of file slice.cpp.

References rgb::b, CLAMP0255, rgb::g, Data::GetDensity(), Data::GetXDim(), Data::GetYDim(), Data::GetZDim(), m_bUseTransfer, m_depth, m_height, m_type, m_width, rgb::r, slice_data, XY, XZ, and YZ.

00059 {
00060         if (m_bUseTransfer && tf == NULL)
00061                 m_bUseTransfer = false;
00062 
00063         int size = 0;
00064         if(slice_data != NULL) delete slice_data;
00065         m_depth = dp;
00066         int density;
00067     
00068         if(m_type == XY)
00069         {                                                                                               // XY Plane
00070                 m_width = (int)dat->GetXDim();
00071                 m_height = (int)dat->GetYDim();
00072                 size = m_width*m_height;
00073                 slice_data = new rgb[size];
00074                 for(int i = 0; i < m_height; i++)
00075                 {
00076                         for(int j = 0; j < m_width; j++)
00077                         {
00078                                 if (m_bUseTransfer) {
00079                                         density = dat->GetDensity(j,i,m_depth);
00080                                         slice_data[i*m_width+j] = tf->GetDensityColor(density);
00081                                 }
00082                                 else {
00083                                         density = dat->GetDensity(j, i, m_depth) / 16;
00084                                         density = CLAMP0255(density);
00085                                         rgb col;
00086                                         col.r = density;
00087                                         col.g = density;
00088                                         col.b = density;
00089                                         slice_data[i * m_width + j] = col;
00090                                 }
00091                         }
00092                 }
00093         }
00094         
00095         if(m_type == XZ)
00096         {                                                                                               // XZ Plane 
00097                 m_width = dat->GetXDim();
00098                 m_height = dat->GetZDim();
00099                 size = m_width*m_height;
00100                 slice_data = new rgb[size];
00101                 for(int i = 0; i < m_height; i++)
00102                 {
00103                         for(int j = 0; j < m_width; j++)
00104                         {
00105                                 if (m_bUseTransfer) {
00106                                         density = dat->GetDensity(j,m_depth,i);
00107                                         slice_data[i*m_width+j] = tf->GetDensityColor(density);
00108                                 }
00109                                 else {
00110                                         density = dat->GetDensity(j, m_depth, i) / 16;
00111                                         density = CLAMP0255(density);
00112                                         rgb col;
00113                                         col.r = density;
00114                                         col.g = density;
00115                                         col.b = density;
00116                                         slice_data[i * m_width + j] = col;
00117                                 }
00118                         }
00119                 }
00120         }
00121         
00122         if(m_type == YZ)
00123         {                                                                                               //YZ Plane
00124                 m_width = dat->GetYDim();
00125                 m_height = dat->GetZDim();
00126                 size = m_width*m_height;
00127                 slice_data = new rgb[size];
00128                 for(int i = 0; i < m_height; i++)
00129                 {
00130                         for(int j = 0; j < m_width; j++)
00131                         {
00132                                 if (m_bUseTransfer) {
00133                                         density = dat->GetDensity(m_depth,j,i);
00134                                         slice_data[i*m_width+j] = tf->GetDensityColor(density);
00135                                 }
00136                                 else {
00137                                         density = dat->GetDensity(m_depth, j, i) / 16;
00138                                         density = CLAMP0255(density);
00139                                         rgb col;
00140                                         col.r = density;
00141                                         col.g = density;
00142                                         col.b = density;
00143                                         slice_data[i * m_width + j] = col;
00144                                 }
00145                         }
00146                 }
00147         }
00148 
00149         return true;
00150 }

bool Slice::SetPixels Data   dat,
int    dp
[inline]
 

Definition at line 37 of file slice.h.

Referenced by ON_BN_CLICKED(), dialogbar::OnCheckUseTransfer(), dialogbar::OnHScroll(), dialogbar::OnRadioXz(), dialogbar::OnRadioYz(), and dialogbar::OnShowWindow().

00037 { return SetPixels(m_tTransferfunction, dat, dp == -1 ? m_depth : dp); }

void Slice::SetTransfer bool    transfer [inline]
 

Definition at line 42 of file slice.h.

Referenced by dialogbar::OnCheckUseTransfer().

00042 { m_bUseTransfer = transfer; }

void Slice::SetTransferfunction Transfunc   transferfunction [inline]
 

Definition at line 36 of file slice.h.

00036 { m_tTransferfunction = transferfunction; }

bool Slice::SetType int    tp
 

Definition at line 24 of file slice.cpp.

References m_type.

Referenced by ON_BN_CLICKED(), dialogbar::OnRadioXz(), and dialogbar::OnRadioYz().

00025 {
00026         if ((tp < 0)||(tp > 2)) return false;
00027         m_type = tp;
00028         return true;
00029 }

void Slice::SetZoom bool    zoom [inline]
 

Definition at line 39 of file slice.h.

Referenced by dialogbar::OnCheckZoom().

00039 { m_bZoom = zoom; }


Member Data Documentation

bool Slice::m_bUseTransfer [private]
 

Definition at line 20 of file slice.h.

Referenced by SetPixels(), and Slice().

bool Slice::m_bZoom [private]
 

Definition at line 19 of file slice.h.

Referenced by DrawSlice(), and Slice().

int Slice::m_depth [private]
 

Definition at line 13 of file slice.h.

Referenced by GetImageInfo(), SetPixels(), and Slice().

int Slice::m_dSliceNumber [private]
 

Definition at line 21 of file slice.h.

Referenced by GetSliceNumber(), and Slice().

int Slice::m_height [private]
 

Definition at line 16 of file slice.h.

Referenced by DrawSlice(), GetImageInfo(), SetPixels(), and Slice().

Transfunc* Slice::m_tTransferfunction [private]
 

Definition at line 22 of file slice.h.

Referenced by Slice().

int Slice::m_type [private]
 

Definition at line 14 of file slice.h.

Referenced by GetImageInfo(), GetType(), SetPixels(), SetType(), and Slice().

int Slice::m_width [private]
 

Definition at line 16 of file slice.h.

Referenced by DrawSlice(), GetImageInfo(), SetPixels(), and Slice().

int Slice::m_x [private]
 

Definition at line 15 of file slice.h.

Referenced by DrawSlice(), and GetImageInfo().

int Slice::m_y [private]
 

Definition at line 15 of file slice.h.

Referenced by DrawSlice(), and GetImageInfo().

rgb* Slice::slice_data [private]
 

Definition at line 17 of file slice.h.

Referenced by DrawSlice(), SetPixels(), Slice(), and ~Slice().


The documentation for this class was generated from the following files:
Generated on Thu Jan 23 12:32:17 2003 by doxygen1.3-rc2