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

VolumeDialog.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 // VolumeDialog.cpp : implementation file
00006 //
00007 
00008 #include "stdafx.h"
00009 #include "3dvis.h"
00010 #include "VolumeDialog.h"
00011 
00012 
00013 #include "raycaster.h"
00014 extern Raycaster *raycaster;
00015 
00016 
00017 
00018 #ifndef XY
00019 #define XY 0
00020 #endif
00021 
00022 #ifndef XZ
00023 #define XZ 1
00024 #endif
00025 
00026 #ifndef YZ
00027 #define YZ 2
00028 #endif
00029 
00030 
00031 
00032 
00033 #ifdef _DEBUG
00034 #define new DEBUG_NEW
00035 #undef THIS_FILE
00036 static char THIS_FILE[] = __FILE__;
00037 #endif
00038 
00040 // CVolumeDialog dialog
00041 
00042 
00043 CVolumeDialog::CVolumeDialog(CWnd* pParent /*=NULL*/)
00044         : CDialog(CVolumeDialog::IDD, pParent) {
00045         //{{AFX_DATA_INIT(CVolumeDialog)
00046         m_dFHTreshold = 1500;
00047         m_fAmbient = 0.2f;
00048         m_fDiffuse = 0.2f;
00049         m_dHeight = 0;
00050         m_dWidth = 0;
00051         m_fZoom = 1.1f;
00052         m_dHighlight = 8.0f;
00053         m_dLX = 300;
00054         m_dLY = 300;
00055         m_dLZ = 300;
00056         m_fSpecular = 0.2f;
00057         m_bLight = FALSE;
00058         m_dXRayMax = 4095;
00059         m_dXRayMin = 0;
00060         m_dXAngle = 0;
00061         m_dYAngle = 0;
00062         m_dZAngle = 0;
00063         //}}AFX_DATA_INIT
00064 
00065 
00066         m_dRotateTo = NONE;
00067         m_dRenderPlane = XZ;
00068         m_dRenderMode = FH;
00069 
00070         //black
00071         m_BGColor = 0x00000000;
00072 
00073         m_bfirst = true;
00074 }
00075 
00076 
00077 void CVolumeDialog::DoDataExchange(CDataExchange* pDX) {
00078         CDialog::DoDataExchange(pDX);
00079         //{{AFX_DATA_MAP(CVolumeDialog)
00080         DDX_Text(pDX, IDC_EDIT_FH_THRESHOLD, m_dFHTreshold);
00081         DDV_MinMaxInt(pDX, m_dFHTreshold, 0, 4095);
00082         DDX_Text(pDX, IDC_EDIT_AMBIENT, m_fAmbient);
00083         DDV_MinMaxFloat(pDX, m_fAmbient, 0.f, 1.f);
00084         DDX_Text(pDX, IDC_EDIT_DIFFUSE, m_fDiffuse);
00085         DDV_MinMaxFloat(pDX, m_fDiffuse, 0.f, 1.f);
00086         DDX_Text(pDX, IDC_EDIT_HEIGHT, m_dHeight);
00087         DDV_MinMaxInt(pDX, m_dHeight, 0, 1600);
00088         DDX_Text(pDX, IDC_EDIT_WIDTH, m_dWidth);
00089         DDV_MinMaxInt(pDX, m_dWidth, 0, 1800);
00090         DDX_Text(pDX, IDC_EDIT_ZOOM, m_fZoom);
00091         DDV_MinMaxFloat(pDX, m_fZoom, 0.1f, 10.f);
00092         DDX_Text(pDX, IDC_EDIT_HIGHLIGHT, m_dHighlight);
00093         DDX_Text(pDX, IDC_EDIT_LIGHTPOS_X, m_dLX);
00094         DDX_Text(pDX, IDC_EDIT_LIGHTPOS_Y, m_dLY);
00095         DDX_Text(pDX, IDC_EDIT_LIGHTPOS_Z, m_dLZ);
00096         DDX_Text(pDX, IDC_EDIT_SPECULAR, m_fSpecular);
00097         DDX_Check(pDX, IDC_CHECK_LIGHT, m_bLight);
00098         DDX_Text(pDX, IDC_EDIT_XRAY_MAX, m_dXRayMax);
00099         DDV_MinMaxInt(pDX, m_dXRayMax, 0, 4095);
00100         DDX_Text(pDX, IDC_EDIT_XRAY_MIN, m_dXRayMin);
00101         DDV_MinMaxInt(pDX, m_dXRayMin, 0, 4095);
00102         DDX_Text(pDX, IDC_EDIT_X_ANGLE, m_dXAngle);
00103         DDV_MinMaxInt(pDX, m_dXAngle, 0, 180);
00104         DDX_Text(pDX, IDC_EDIT_Y_ANGLE, m_dYAngle);
00105         DDV_MinMaxInt(pDX, m_dYAngle, 0, 180);
00106         DDX_Text(pDX, IDC_EDIT_Z_ANGLE, m_dZAngle);
00107         DDV_MinMaxInt(pDX, m_dZAngle, 0, 180);
00108         //}}AFX_DATA_MAP
00109 }
00110 
00111 
00112 BEGIN_MESSAGE_MAP(CVolumeDialog, CDialog)
00113         //{{AFX_MSG_MAP(CVolumeDialog)
00114         ON_WM_SHOWWINDOW()
00115         ON_BN_CLICKED(IDC_RADIO_FIRSTHIT, OnRadioFirsthit)
00116         ON_BN_CLICKED(IDC_RADIO_STANDARD, OnRadioStandard)
00117         ON_BN_CLICKED(IDC_RADIO_MIP, OnRadioMip)
00118         ON_EN_CHANGE(IDC_EDIT_FH_THRESHOLD, OnChangeEditFhThreshold)
00119         ON_EN_CHANGE(IDC_EDIT_ZOOM, OnChangeEditZoom)
00120         ON_EN_CHANGE(IDC_EDIT_HEIGHT, OnChangeEditHeight)
00121         ON_EN_CHANGE(IDC_EDIT_WIDTH, OnChangeEditWidth)
00122         ON_EN_CHANGE(IDC_EDIT_AMBIENT, OnChangeEditAmbient)
00123         ON_EN_CHANGE(IDC_EDIT_DIFFUSE, OnChangeEditDiffuse)
00124         ON_BN_CLICKED(IDC_BUTTON_BGCOLOR, OnButtonBgcolor)
00125         ON_WM_PAINT()
00126         ON_BN_CLICKED(IDC_CHECK_LIGHT, OnCheckLight)
00127         ON_EN_CHANGE(IDC_EDIT_LIGHTPOS_X, OnChangeEditLightposX)
00128         ON_EN_CHANGE(IDC_EDIT_LIGHTPOS_Y, OnChangeEditLightposY)
00129         ON_EN_CHANGE(IDC_EDIT_LIGHTPOS_Z, OnChangeEditLightposZ)
00130         ON_EN_CHANGE(IDC_EDIT_HIGHLIGHT, OnChangeEditHighlight)
00131         ON_EN_CHANGE(IDC_EDIT_SPECULAR, OnChangeEditSpecular)
00132         ON_BN_CLICKED(IDC_RADIO_XRAY, OnRadioXray)
00133         ON_EN_CHANGE(IDC_EDIT_XRAY_MAX, OnChangeEditXrayMax)
00134         ON_EN_CHANGE(IDC_EDIT_XRAY_MIN, OnChangeEditXrayMin)
00135         ON_EN_CHANGE(IDC_EDIT_X_ANGLE, OnChangeEditXAngle)
00136         ON_EN_CHANGE(IDC_EDIT_Y_ANGLE, OnChangeEditYAngle)
00137         ON_BN_CLICKED(IDC_BUTTON_X_PLUS, OnButtonXPlus)
00138         ON_BN_CLICKED(IDC_BUTTON_X_MINUS, OnButtonXMinus)
00139         ON_BN_CLICKED(IDC_BUTTON_Y_PLUS, OnButtonYPlus)
00140         ON_BN_CLICKED(IDC_BUTTON_Y_MINUS, OnButtonYMinus)
00141         ON_EN_CHANGE(IDC_EDIT_Z_ANGLE, OnChangeEditZAngle)
00142         ON_BN_CLICKED(IDC_BUTTON_Z_PLUS, OnButtonZPlus)
00143         ON_BN_CLICKED(IDC_BUTTON_Z_MINUS, OnButtonZMinus)
00144         //}}AFX_MSG_MAP
00145 END_MESSAGE_MAP()
00146 
00147 
00148 // CVolumeDialog message handlers
00149 
00150 void CVolumeDialog::OnShowWindow(BOOL bShow, UINT nStatus) {
00151         CDialog::OnShowWindow(bShow, nStatus);
00152         // TODO: Add your message handler code here
00153         if (!bShow || !raycaster)
00154                 return;
00155 
00156         
00157         int button;
00158         
00159         switch (m_dRenderMode) {
00160                 case FH:
00161                         button = IDC_RADIO_FIRSTHIT;
00162                         break;
00163                 case STANDARD:
00164                         button = IDC_RADIO_STANDARD;
00165                         break;
00166                 case MI:
00167                         button = IDC_RADIO_MIP;
00168                         break;
00169                 case XRAY:
00170                         button = IDC_RADIO_XRAY;
00171                         break;
00172                 default:
00173                         button = -1;
00174                         break;
00175         }
00176 
00177         if (button != -1)
00178                 ((CButton *)GetDlgItem(button))->SetCheck(1);
00179 
00180 
00181         
00182         CDC *cdc = (CDC *)this->GetDC();
00183         cdc->FillSolidRect(114, 443, 30, 22, m_BGColor);
00184 
00185 
00186         raycaster->GetScreenShotImage(m_dWidth, m_dHeight);
00187 
00188         UpdateData(FALSE);
00189 }
00190 
00191 
00192 void CVolumeDialog::OnRadioFirsthit() {
00193         if (!raycaster)
00194                 return;
00195         
00196         raycaster->SetRendermode(FH);
00197         m_dRenderMode = FH;
00198 }
00199 
00200 void CVolumeDialog::OnRadioStandard() {
00201         raycaster->SetRendermode(STANDARD);
00202         raycaster->SetLight(true);
00203         m_dRenderMode = STANDARD;
00204         m_bLight = TRUE;
00205         UpdateData(FALSE);
00206 }
00207 
00208 
00209 void CVolumeDialog::OnRadioMip() {
00210         raycaster->SetRendermode(MI);
00211         m_dRenderMode = MI;
00212 }
00213 
00214 
00215 void CVolumeDialog::OnRadioXray() {
00216         raycaster->SetRendermode(XRAY);
00217         m_dRenderMode = XRAY;
00218 }
00219 
00220 void CVolumeDialog::OnChangeEditFhThreshold() {
00221         UpdateData(TRUE);
00222         raycaster->SetTreshold(m_dFHTreshold);
00223 }
00224 
00225 void CVolumeDialog::OnChangeEditZoom() {
00226         UpdateData(TRUE);
00227         raycaster->Zoom(m_fZoom);
00228 }
00229 
00230 void CVolumeDialog::OnChangeEditHeight() {
00231         UpdateData(TRUE);
00232         raycaster->SetHeight(m_dHeight);
00233 }
00234 
00235 void CVolumeDialog::OnChangeEditWidth() {
00236         UpdateData(TRUE);
00237         raycaster->SetWidth(m_dWidth);
00238 }
00239 
00240 void CVolumeDialog::OnChangeEditAmbient() {
00241         UpdateData(TRUE);
00242         raycaster->SetAmbient(m_fAmbient);
00243 }
00244 
00245 void CVolumeDialog::OnChangeEditDiffuse() {
00246         UpdateData(TRUE);
00247         raycaster->SetDiffuse(m_fDiffuse);
00248 }
00249 
00250 void CVolumeDialog::OnButtonBgcolor() {
00251         CColorDialog colDiag;
00252         if (colDiag.DoModal() != IDOK)
00253                 return;
00254 
00255         m_BGColor = colDiag.GetColor();
00256 
00257         CDC *cdc = (CDC *)this->GetDC();
00258         cdc->FillSolidRect(114, 443, 30, 22, m_BGColor);
00259 
00260         unsigned char col[3] = { m_BGColor & 0x000000FF,
00261                                                         (m_BGColor & 0x0000FF00) >> 8,
00262                                                         (m_BGColor & 0x00FF0000) >> 16 };
00263 
00264         raycaster->SetBackgroundColor(col[0], col[1], col[2]);
00265 }
00266 
00267 void CVolumeDialog::OnPaint() {
00268         CPaintDC dc(this); // device context for painting
00269         
00270         dc.FillSolidRect(114, 443, 30, 22, m_BGColor);
00271 }
00272 
00273 
00274 #pragma warning ( push )
00275 #pragma warning (disable : 4800)
00276 
00277 void CVolumeDialog::OnCheckLight() {
00278         UpdateData(TRUE);
00279         raycaster->SetLight(m_bLight);
00280 }
00281 
00282 #pragma warning ( pop )
00283 
00284 
00285 void CVolumeDialog::OnChangeEditLightposX() {
00286         UpdateData(TRUE);
00287         raycaster->SetLightpos(VECTOR(m_dLX, m_dLY, m_dLZ));
00288 }
00289 
00290 void CVolumeDialog::OnChangeEditLightposY() {
00291         UpdateData(TRUE);
00292         raycaster->SetLightpos(VECTOR(m_dLX, m_dLY, m_dLZ));
00293 }
00294 
00295 void CVolumeDialog::OnChangeEditLightposZ() {
00296         UpdateData(TRUE);
00297         raycaster->SetLightpos(VECTOR(m_dLX, m_dLY, m_dLZ));
00298 }
00299 
00300 void CVolumeDialog::OnChangeEditHighlight() {
00301         UpdateData(TRUE);
00302         raycaster->SetHighlight(m_dHighlight);
00303 }
00304 
00305 void CVolumeDialog::OnChangeEditSpecular() {
00306         UpdateData(TRUE);
00307         raycaster->SetSpecular(m_fSpecular);
00308 }
00309 
00310 void CVolumeDialog::OnChangeEditXrayMax() {
00311         UpdateData(TRUE);
00312         raycaster->SetDensRange(m_dXRayMin, m_dXRayMax);
00313 }
00314 
00315 void CVolumeDialog::OnChangeEditXrayMin() {
00316         UpdateData(TRUE);
00317         raycaster->SetDensRange(m_dXRayMin, m_dXRayMax);
00318 }
00319 
00320 void CVolumeDialog::OnChangeEditXAngle() {
00321         UpdateData(TRUE);
00322 }
00323 
00324 void CVolumeDialog::OnChangeEditYAngle() {
00325         UpdateData(TRUE);
00326 }
00327 
00328 void CVolumeDialog::OnChangeEditZAngle() {
00329         UpdateData(TRUE);
00330 }
00331 
00332 void CVolumeDialog::OnButtonXPlus() {
00333         if (m_dXAngle == 0)
00334                 return;
00335         raycaster->RotateX(m_dXAngle);
00336 }
00337 
00338 void CVolumeDialog::OnButtonXMinus() {
00339         if (m_dXAngle == 0)
00340                 return;
00341         raycaster->RotateX(-m_dXAngle);
00342 }
00343 
00344 void CVolumeDialog::OnButtonYPlus() {
00345         if (m_dYAngle == 0)
00346                 return;
00347         raycaster->RotateY(m_dYAngle);
00348 }
00349 
00350 void CVolumeDialog::OnButtonYMinus() {
00351         if (m_dYAngle == 0)
00352                 return;
00353         raycaster->RotateY(-m_dYAngle);
00354 }
00355 
00356 void CVolumeDialog::OnButtonZPlus() {
00357         if (m_dZAngle == 0)
00358                 return;
00359         raycaster->RotateZ(m_dZAngle);
00360 }
00361 
00362 void CVolumeDialog::OnButtonZMinus() {
00363         if (m_dZAngle == 0)
00364                 return;
00365         raycaster->RotateZ(-m_dZAngle);
00366 }

Generated on Thu Jan 30 21:35:43 2003 for 3DVis by doxygen1.3-rc2