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

CMy3dvisApp Class Reference

#include <3dvis.h>

List of all members.

Public Methods

 CMy3dvisApp ()
virtual BOOL InitInstance ()
virtual int ExitInstance ()
afx_msg void OnAppAbout ()
afx_msg void OnFileOpen ()
afx_msg void OnFClose ()
afx_msg void OnRenderVolume ()
afx_msg void OnOptionsTransfer ()
afx_msg void OnPreset0 ()
afx_msg void OnPreset1 ()
afx_msg void OnPreset2 ()
afx_msg void OnPreset3 ()
afx_msg void OnPreset4 ()
afx_msg void OnPreset5 ()
afx_msg void OnPreset6 ()
afx_msg void OnPreset7 ()
afx_msg void OnPreset8 ()
afx_msg void OnPreset9 ()
afx_msg void OnFileInfo ()
afx_msg void OnMenuVolume ()
afx_msg void OnFileIni ()

Public Attributes

bool m_bRenderVolume
int m_dNumPresets
TransfunctransferFunction
string programPath

Private Methods

void m_BuildTransferFunction (INDEXLIST &function, int num)
void m_ProcessIniFile (bool store=false)

Private Attributes

int m_dOperation
bool m_bOpen
bool m_bClicked
int m_dFileThres
int m_dPacketSize
transferfuncform m_Transferdiag
INDEXLISTpresetTransformFunctions


Constructor & Destructor Documentation

CMy3dvisApp::CMy3dvisApp  
 

3dvis.cpp class CMy3dvisApp

Definition at line 57 of file 3dvis.cpp.

References m_bClicked, m_bRenderVolume, m_dFileThres, m_dOperation, m_dPacketSize, programPath, and transferFunction.

00058 {
00059         // TODO: add construction code here,
00060         // Place all significant initialization in InitInstance
00061         m_bRenderVolume = false;
00062         m_bClicked = false;
00063         transferFunction = NULL;
00064 
00065         m_dFileThres = 40;
00066         m_dPacketSize = 10;
00067 
00068         m_dOperation = 0;
00069 
00070         char path[_MAX_PATH + 1];
00071 
00072         GetModuleFileName(m_hInstance, path, sizeof(path));
00073 
00074         string temp = path;
00075         int pos = temp.find_last_of('\\', temp.size());
00076         programPath = temp.substr(0, pos + 1);
00077 }


Member Function Documentation

int CMy3dvisApp::ExitInstance   [virtual]
 

Definition at line 199 of file 3dvis.cpp.

References transferFunction.

00200 {
00201         // TODO: Add your specialized code here and/or call the base class
00202         if (data3D != NULL) {
00203                 delete data3D;
00204                 data3D = NULL;
00205         }
00206 
00207         if (slice != NULL) {
00208                 delete slice;
00209                 slice = NULL;
00210         }
00211 
00212         if (raycaster != NULL) {
00213                 delete raycaster;
00214                 raycaster = NULL;
00215         }
00216 
00217         if (transferFunction != NULL) {
00218                 delete transferFunction;
00219                 transferFunction = NULL;
00220         }
00221         
00222         return CWinApp::ExitInstance();
00223 }

BOOL CMy3dvisApp::InitInstance   [virtual]
 

Definition at line 87 of file 3dvis.cpp.

References CTransfuncFile::LoadPresets(), m_ProcessIniFile(), and presetTransformFunctions.

00088 {
00089 
00090         CTransfuncFile funcFile;
00091         presetTransformFunctions = funcFile.LoadPresets(m_dNumPresets);
00092 
00093 
00094         // Standard initialization
00095         // If you are not using these features and wish to reduce the size
00096         //  of your final executable, you should remove from the following
00097         //  the specific initialization routines you do not need.
00098 
00099 #ifdef _AFXDLL
00100         Enable3dControls();                     // Call this when using MFC in a shared DLL
00101 #else
00102         Enable3dControlsStatic();       // Call this when linking to MFC statically
00103 #endif
00104 
00105         // Change the registry key under which our settings are stored.
00106         // TODO: You should modify this string to be something appropriate
00107         // such as the name of your company or organization.
00108         SetRegistryKey(_T("Local AppWizard-Generated Applications"));
00109 
00110         LoadStdProfileSettings();  // Load standard INI file options (including MRU)
00111 
00112         // Register the application's document templates.  Document templates
00113         //  serve as the connection between documents, frame windows and views.
00114 
00115         CSingleDocTemplate* pDocTemplate;
00116         pDocTemplate = new CSingleDocTemplate(
00117                 IDR_MAINFRAME,
00118                 RUNTIME_CLASS(CMy3dvisDoc),
00119                 RUNTIME_CLASS(CMainFrame),       // main SDI frame window
00120                 RUNTIME_CLASS(CMy3dvisView));
00121         AddDocTemplate(pDocTemplate);
00122 
00123         // Parse command line for standard shell commands, DDE, file open
00124         CCommandLineInfo cmdInfo;
00125         ParseCommandLine(cmdInfo);
00126 
00127         // Dispatch commands specified on the command line
00128         if (!ProcessShellCommand(cmdInfo))
00129                 return FALSE;
00130 
00131         
00132         m_ProcessIniFile();
00133 
00134 
00135         // The one and only window has been initialized, so show and update it.
00136         m_pMainWnd->ShowWindow(SW_SHOW);
00137         m_pMainWnd->UpdateWindow();
00138         return TRUE;
00139 }

void CMy3dvisApp::m_BuildTransferFunction INDEXLIST   function,
int    num
[private]
 

void CMy3dvisApp::m_BuildTransferFunction(INDEXLIST &function, int num) speichert die übergebene transferfunktion im globalen transferfunktions-objekt

Definition at line 399 of file 3dvis.cpp.

References rgb::b, rgb::g, rgb::r, Transfunc::SetDensityColor(), Transfunc::SetOpacity(), and transferFunction.

Referenced by OnOptionsTransfer(), OnPreset0(), OnPreset1(), OnPreset2(), OnPreset3(), OnPreset4(), OnPreset5(), OnPreset6(), OnPreset7(), OnPreset8(), and OnPreset9().

00399                                                                       {
00400         if (!data3D)
00401                 return;
00402         
00403         if (!transferFunction)
00404                 transferFunction = new Transfunc();
00405 
00406         rgb col;
00407 
00408         float alpha_begin = 0.0;
00409         float alpha_end = 1.0;
00410 
00411 
00412         for (int i = 1; i <= num; i++) {
00413                 COLORREF c = function[i].m_scColor;
00414                 col.r = (unsigned char)(function[i].m_scColor & 0x000000FF);
00415                 col.g = (unsigned char)((function[i].m_scColor & 0x0000FF00) >> 8);
00416                 col.b = (unsigned char)((function[i].m_scColor & 0x00FF0000) >> 16);
00417 
00418                 float thres = function[i].m_sdEnd - function[i].m_sdBegin;
00419                 float size = thres * 0.1;
00420                 
00421                 if (i > 1)
00422                         alpha_begin = (float)function[i - 1].m_ucAlpha / 255;
00423                 else
00424                         alpha_begin = 0.0;
00425 
00426 
00427                 if (i == num)
00428                         alpha_end = 0.0;
00429                 else
00430                         alpha_end = (float)function[i].m_ucAlpha / 255;
00431 
00432                 float alpha = alpha_end - alpha_begin;
00433                 float step = alpha / size;
00434                 if (i > 1)
00435                         alpha = (float)function[i].m_ucAlpha / 255;
00436 
00437 
00438                 for (int j = function[i].m_sdBegin;     j < function[i].m_sdEnd; j++) {
00439                         transferFunction->SetDensityColor(j, col);
00440                         if ((alpha > 0.0) && ((alpha + step) <= alpha_end))
00441                                 alpha += step;
00442 //                      transferFunction->SetOpacity(j, ((float)function[i].m_ucAlpha / 255));
00443                         transferFunction->SetOpacity(j, alpha);
00444                 }
00445         }
00446 
00447         if (slice == NULL)
00448                 slice = new Slice();
00449 
00450         slice->SetTransferfunction(transferFunction);
00451         slice->SetPixels(data3D, -1);
00452 }

void CMy3dvisApp::m_ProcessIniFile bool    store = false [private]
 

void CMy3dvisApp::m_ProcessIniFile(bool store) lädt wenn vorhanden die dateigrößen schwelle und die packetgröße für den dateilade vorgang

Definition at line 476 of file 3dvis.cpp.

References m_dFileThres, m_dPacketSize, and programPath.

Referenced by InitInstance(), OnFileIni(), and OnFileOpen().

00476                                              {
00477         FILE *file;
00478 
00479         string filename = programPath + "config.ini";
00480 
00481         if (!store && (file = fopen(filename.c_str(), "r")) != NULL) {
00482                 if (!data3D)
00483                         return;
00484                 
00485                 fscanf(file, "%d\n%d", &m_dFileThres, &m_dPacketSize);
00486                 data3D->SetFileThreshold(m_dFileThres);
00487                 data3D->SetDataPackets(m_dPacketSize);
00488 
00489                 fclose(file);
00490 
00491                 return;
00492         }
00493 
00494 
00495         if ((file = fopen(filename.c_str(), "w")) != NULL) {
00496                 m_dFileThres = 40;
00497                 m_dPacketSize = 10;
00498 
00499                 fprintf(file, "%d\n%d", m_dFileThres, m_dPacketSize);
00500                 fclose(file);
00501         }
00502 
00503 
00504 }

void CMy3dvisApp::OnAppAbout  
 

Definition at line 189 of file 3dvis.cpp.

00190 {
00191         CAboutDlg aboutDlg;
00192         aboutDlg.DoModal();
00193 }

void CMy3dvisApp::OnFClose  
 

void CMy3dvisApp::OnFClose() fragt nach ob die datei geschlossen werden soll und schließt diese danach

Definition at line 296 of file 3dvis.cpp.

References m_bOpen.

Referenced by OnFileOpen().

00297 {
00298         // TODO: Add your command handler code here
00299 
00300         if (data3D && !m_bOpen && MessageBox(m_pMainWnd->m_hWnd, "do you really want to close the\ncurrent data-set?",
00301                                         "close data-set", MB_YESNO) == IDNO)
00302                 return;
00303 
00304         
00305         AfxGetMainWnd()->SendMessage(MYWM_HIDE_BARS);
00306 
00307         
00308         if (slice != NULL) {
00309                 delete slice;
00310                 slice = NULL;
00311         }
00312 
00313         if (data3D != NULL) {
00314                 delete data3D;
00315                 data3D = NULL;
00316         }
00317 
00318         m_pMainWnd->SetWindowText("3D Visualisation");
00319 }

void CMy3dvisApp::OnFileInfo  
 

Definition at line 455 of file 3dvis.cpp.

References CFileInfoDialog::SetInfo().

00456 {
00457         // TODO: Add your command handler code here
00458         if (!data3D)
00459                 return;
00460         
00461         CFileInfoDialog fid;
00462         fid.SetInfo(data3D->filename, data3D->GetXDim(), data3D->GetYDim(), data3D->GetZDim());
00463         fid.DoModal();
00464 }

void CMy3dvisApp::OnFileIni  
 

Definition at line 506 of file 3dvis.cpp.

References IniFile::GetData(), m_ProcessIniFile(), and IniFile::SetupData().

00507 {
00508         // TODO: Add your command handler code here
00509         IniFile inifile;
00510         inifile.SetupData(m_dFileThres, m_dPacketSize);
00511         int answer = inifile.DoModal();
00512 
00513         if (answer == IDCANCEL)
00514                 return;
00515         
00516         
00517         inifile.GetData(m_dFileThres, m_dPacketSize);   
00518         m_ProcessIniFile(true);
00519 }

void CMy3dvisApp::OnFileOpen  
 

void CMy3dvisApp::OnFileOpen() öffnet einen dateidialog und versucht die ausgewähle datei zu laden wenn bereits eine datei geladen ist, wird diese zuerst geschlossen nach erfolgreichem laden, wird die slicer oberfläche angezeigt

Definition at line 229 of file 3dvis.cpp.

References m_bOpen, m_bRenderVolume, m_ProcessIniFile(), and OnFClose().

00230 {
00231         // TODO: Add your command handler code here
00232         CFileDialog fd(TRUE, NULL, NULL, OFN_FILEMUSTEXIST,
00233                                         "Dat Files (*.dat)|*.dat| AllFiles (*.*)|* *|", m_pMainWnd);
00234         
00235 
00236         int returnVal = fd.DoModal();
00237 
00238         if(returnVal == IDOK) {
00239 
00240                 m_bOpen = true;
00241                 this->OnFClose();
00242                 m_bOpen = false;
00243                         
00244                 if (data3D != NULL) {
00245                         if (MessageBox(m_pMainWnd->m_hWnd, "Already data loaded! Unload currend data?",
00246                                                                                                         "load new data", MB_YESNO) == IDYES) {
00247                                 delete data3D;
00248                                 data3D = NULL;
00249                         }
00250                         else
00251                                 return;
00252                 }
00253 
00254 
00255                 CString filename = fd.GetFileName();
00256                 char *fn = new char[filename.GetLength() + 1];
00257                 for (int i = 0; i < filename.GetLength(); i++) {
00258                         fn[i] = filename.GetAt(i);
00259                 }
00260                 fn[i] = '\0';
00261 
00262                 
00263                 data3D = new Data();
00264                 m_ProcessIniFile();
00265 
00266 
00267                 SetWindowText(m_pMainWnd->m_hWnd, "3D Visualisation - loading visualisation data, please wait,...");
00268 
00269                 data3D->LoadData(fn);
00270                 delete[] fn;
00271 
00272         
00273                 m_bRenderVolume = false;
00274 
00275 
00276                 if (slice == NULL)
00277                         slice = new Slice();
00278 
00279                 slice->SetPixels(data3D, 0);
00280                 int num = slice->GetSliceNumber(data3D);
00281 
00282 
00283                 
00284                 if (!m_bRenderVolume)
00285                         AfxGetMainWnd()->SendMessage(MYWM_SHOW_BAR, (WPARAM) 0, (LPARAM) 0);
00286                 else
00287                         AfxGetMainWnd()->SendMessage(MYWM_SHOW_BAR, (WPARAM) 1, (LPARAM) 0);
00288                 
00289 
00290                 SetWindowText(m_pMainWnd->m_hWnd, CString("3D Visualisation - loaded \"" + filename + "\""));
00291    }
00292 }

void CMy3dvisApp::OnMenuVolume  
 

Definition at line 466 of file 3dvis.cpp.

00467 {
00468         // TODO: Add your command handler code here
00469         AfxGetMainWnd()->SendMessage(MYWM_CHANGE_RENDERING, (WPARAM) 1, 1);
00470 }

void CMy3dvisApp::OnOptionsTransfer  
 

void CMy3dvisApp::OnOptionsTransfer() öffnet den transferfunktionsdialog

Definition at line 323 of file 3dvis.cpp.

References m_BuildTransferFunction(), m_Transferdiag, and transferfuncform::m_vTransferIndices.

00324 {
00325         // TODO: Add your command handler code here
00326         if (data3D == NULL)
00327                 return;
00328 
00329         int response = m_Transferdiag.DoModal();
00330 
00331 
00332         if (response == IDOK) {
00333                 int num = m_Transferdiag.m_vTransferIndices.size() - 1;
00334 
00335                 if (num <= 0)
00336                         return;
00337 
00338                 m_BuildTransferFunction(m_Transferdiag.m_vTransferIndices, num);
00339         }
00340 
00341 
00342         m_pMainWnd->Invalidate();
00343         m_pMainWnd->UpdateWindow();
00344 }

void CMy3dvisApp::OnPreset0  
 

Definition at line 347 of file 3dvis.cpp.

References m_BuildTransferFunction().

00347                             {
00348         m_BuildTransferFunction(presetTransformFunctions[0],
00349                                                         presetTransformFunctions[0].size() - 1);
00350 }

void CMy3dvisApp::OnPreset1  
 

Definition at line 352 of file 3dvis.cpp.

References m_BuildTransferFunction().

00352                             {
00353         m_BuildTransferFunction(presetTransformFunctions[1],
00354                                                         presetTransformFunctions[1].size() - 1);
00355 }

void CMy3dvisApp::OnPreset2  
 

Definition at line 357 of file 3dvis.cpp.

References m_BuildTransferFunction().

00357                             {
00358         m_BuildTransferFunction(presetTransformFunctions[2],
00359                                                         presetTransformFunctions[2].size() - 1);
00360 }

void CMy3dvisApp::OnPreset3  
 

Definition at line 362 of file 3dvis.cpp.

References m_BuildTransferFunction().

00362                             {
00363         m_BuildTransferFunction(presetTransformFunctions[3],
00364                                                         presetTransformFunctions[3].size() - 1);
00365 }

void CMy3dvisApp::OnPreset4  
 

Definition at line 367 of file 3dvis.cpp.

References m_BuildTransferFunction().

00367                             {
00368         m_BuildTransferFunction(presetTransformFunctions[4],
00369                                                         presetTransformFunctions[4].size() - 1);
00370 }

void CMy3dvisApp::OnPreset5  
 

Definition at line 372 of file 3dvis.cpp.

References m_BuildTransferFunction().

00372                             {
00373         m_BuildTransferFunction(presetTransformFunctions[5],
00374                                                         presetTransformFunctions[5].size() - 1);
00375 }

void CMy3dvisApp::OnPreset6  
 

Definition at line 377 of file 3dvis.cpp.

References m_BuildTransferFunction().

00377                             {
00378         m_BuildTransferFunction(presetTransformFunctions[6],
00379                                                         presetTransformFunctions[6].size() - 1);
00380 }

void CMy3dvisApp::OnPreset7  
 

Definition at line 382 of file 3dvis.cpp.

References m_BuildTransferFunction().

00382                             {
00383         m_BuildTransferFunction(presetTransformFunctions[7],
00384                                                         presetTransformFunctions[7].size() - 1);
00385 }

void CMy3dvisApp::OnPreset8  
 

Definition at line 387 of file 3dvis.cpp.

References m_BuildTransferFunction().

00387                             {
00388         m_BuildTransferFunction(presetTransformFunctions[8],
00389                                                         presetTransformFunctions[8].size() - 1);
00390 }

void CMy3dvisApp::OnPreset9  
 

Definition at line 392 of file 3dvis.cpp.

References m_BuildTransferFunction().

00392                             {
00393         m_BuildTransferFunction(presetTransformFunctions[9],
00394                                                         presetTransformFunctions[9].size() - 1);
00395 }

void CMy3dvisApp::OnRenderVolume  
 

void CMy3dvisApp::OnRenderVolume() schlatet bei betätigen des "V" buttons zwischen dem slicer und dem volume-renderer um

Definition at line 525 of file 3dvis.cpp.

00526 {
00527         // TODO: Add your command handler code here
00528         if (!data3D || !slice)
00529                 return;
00530 
00531         if (!((CMy3dvisApp *)AfxGetApp())->transferFunction) {
00532                 MessageBox(m_pMainWnd->m_hWnd,
00533                                         "please select or create a transferfunction",
00534                                         "transferfunction missing",
00535                                         MB_OK);
00536                 return;
00537         }
00538                 
00539 
00540         if (((CMy3dvisApp *)AfxGetApp())->m_bRenderVolume) {
00541                 ((CMy3dvisApp *)AfxGetApp())->m_bRenderVolume = false;
00542 
00543                 AfxGetMainWnd()->SendMessage(MYWM_CHANGE_RENDERING, (WPARAM) 0, (LPARAM) 0);
00544         }
00545         else {
00546                 ((CMy3dvisApp *)AfxGetApp())->m_bRenderVolume = true;
00547 
00548                 AfxGetMainWnd()->SendMessage(MYWM_CHANGE_RENDERING, (WPARAM) 1, (LPARAM) 0);
00549 
00550                 raycaster = new Raycaster();
00551                 raycaster->SetViewingCondition(VECTOR(300,300,300),Color(0.0f,1.0f,0.0f),0.3f,0.4f,0.2f,8);
00552 
00553                 raycaster->Initialize(/*VECTOR(92,-20,85),*/400,400,1.0f,data3D,((CMy3dvisApp *)AfxGetApp())->transferFunction);
00554                 raycaster->Zoom(1.1f); // werte > 1.0 hinein zoomen <1.0 wegzoomen
00555 
00556                 raycaster->SetTreshold(1500);
00557                 raycaster->SetRaytype(NN);
00558                 raycaster->SetRendermode(FH);
00559                 raycaster->SetPreCalcGradients(true);
00560         }
00561 }


Member Data Documentation

bool CMy3dvisApp::m_bClicked [private]
 

Definition at line 35 of file 3dvis.h.

Referenced by CMy3dvisApp().

bool CMy3dvisApp::m_bOpen [private]
 

Definition at line 34 of file 3dvis.h.

Referenced by OnFClose(), and OnFileOpen().

bool CMy3dvisApp::m_bRenderVolume
 

Definition at line 50 of file 3dvis.h.

Referenced by CMy3dvisApp(), and OnFileOpen().

int CMy3dvisApp::m_dFileThres [private]
 

Definition at line 37 of file 3dvis.h.

Referenced by CMy3dvisApp(), and m_ProcessIniFile().

int CMy3dvisApp::m_dNumPresets
 

Definition at line 51 of file 3dvis.h.

int CMy3dvisApp::m_dOperation [private]
 

Definition at line 32 of file 3dvis.h.

Referenced by CMy3dvisApp().

int CMy3dvisApp::m_dPacketSize [private]
 

Definition at line 38 of file 3dvis.h.

Referenced by CMy3dvisApp(), and m_ProcessIniFile().

transferfuncform CMy3dvisApp::m_Transferdiag [private]
 

Definition at line 40 of file 3dvis.h.

Referenced by OnOptionsTransfer().

INDEXLIST* CMy3dvisApp::presetTransformFunctions [private]
 

Definition at line 42 of file 3dvis.h.

Referenced by InitInstance().

string CMy3dvisApp::programPath
 

Definition at line 54 of file 3dvis.h.

Referenced by CMy3dvisApp(), and m_ProcessIniFile().

Transfunc* CMy3dvisApp::transferFunction
 

Definition at line 52 of file 3dvis.h.

Referenced by CMy3dvisApp(), ExitInstance(), and m_BuildTransferFunction().


The documentation for this class was generated from the following files:
Generated on Thu Jan 30 21:35:44 2003 for 3DVis by doxygen1.3-rc2