00001
00002
00003
00004 #include "stdafx.h"
00005 #include "3dvis.h"
00006 #include "volumebar.h"
00007
00008
00009 #include "data.h"
00010 #include "raycaster.h"
00011 extern Data *data3D;
00012 extern Raycaster *raycaster;
00013
00014
00015 #ifdef _DEBUG
00016 #define new DEBUG_NEW
00017 #undef THIS_FILE
00018 static char THIS_FILE[] = __FILE__;
00019 #endif
00020
00022
00023
00024 volumebar::volumebar()
00025
00026 : CDialogBar()
00027 {
00028
00029 m_fVolumeStepLength = 1.0f;
00030
00031
00032
00033 m_dRenderType = NN;
00034 m_dRayType = RAYCASTER;
00035 }
00036
00037
00038 void volumebar::DoDataExchange(CDataExchange* pDX)
00039 {
00040
00041
00042 DDX_Text(pDX, IDC_EDIT_STEP_LENGTH, m_fVolumeStepLength);
00043 DDV_MinMaxFloat(pDX, m_fVolumeStepLength, 1.f, 10.f);
00044
00045 }
00046
00047
00048 BEGIN_MESSAGE_MAP(volumebar, CDialogBar)
00049
00050 ON_BN_CLICKED(IDC_BUTTON_RENDER_VOLUME, OnButtonRenderVolume)
00051 ON_BN_CLICKED(IDC_RADIO_VOLUME_NN, OnRadioVolumeNn)
00052 ON_BN_CLICKED(IDC_RADIO_VOLUME_TRI, OnRadioVolumeTri)
00053 ON_WM_SHOWWINDOW()
00054 ON_BN_CLICKED(IDC_RADIO_RAYCASTER, OnRadioRaycaster)
00055 ON_BN_CLICKED(IDC_RADIO_PERSPECTIVE, OnRadioPerspective)
00056
00057 ON_UPDATE_COMMAND_UI(IDC_BUTTON_RENDER_VOLUME, OnUpdateButtonRenderVolume)
00058 END_MESSAGE_MAP()
00059
00060
00061
00062
00063 void volumebar::OnUpdateButtonRenderVolume(CCmdUI* pCmdUI) {
00064 pCmdUI->Enable();
00065 }
00066
00067
00068 void volumebar::OnRadioVolumeNn()
00069 {
00070
00071 if (!raycaster)
00072 return;
00073
00074 raycaster->SetRaytype(NN);
00075 m_dRenderType = NN;
00076 }
00077
00078 void volumebar::OnRadioVolumeTri()
00079 {
00080
00081 if (!raycaster)
00082 return;
00083
00084 raycaster->SetRaytype(TRI);
00085 m_dRenderType = TRI;
00086 }
00087
00088 void volumebar::OnShowWindow(BOOL bShow, UINT nStatus)
00089 {
00090 CDialogBar::OnShowWindow(bShow, nStatus);
00091
00092 UpdateData(FALSE);
00093
00094
00095 int button;
00096 switch (m_dRenderType) {
00097 case NN:
00098 button = IDC_RADIO_VOLUME_NN;
00099 break;
00100 case TRI:
00101 button = IDC_RADIO_VOLUME_TRI;
00102 break;
00103 }
00104 ((CButton *)GetDlgItem(button))->SetCheck(1);
00105
00106
00107 switch (m_dRayType) {
00108 case RAYCASTER:
00109 button = IDC_RADIO_RAYCASTER;
00110 break;
00111 case PERSPECTIVE:
00112 button = IDC_RADIO_PERSPECTIVE;
00113 break;
00114 }
00115 ((CButton *)GetDlgItem(button))->SetCheck(1);
00116 }
00117
00118
00119 void volumebar::OnButtonRenderVolume()
00120 {
00121
00122 if (!raycaster)
00123 return;
00124
00125
00126 raycaster->Raycast();
00127
00128 }
00129
00130 void volumebar::OnRadioRaycaster()
00131 {
00132
00133 if (raycaster->m_dOwnType == RAYCASTER)
00134 return;
00135
00136 m_dRayType = RAYCASTER;
00137
00138 if (raycaster)
00139 delete raycaster;
00140
00141 raycaster = new Raycaster();
00142
00143 raycaster->SetViewingCondition(VECTOR(300,300,300),Color(0.0f,1.0f,0.0f),0.2f,0.2f,0.2f,8);
00144 raycaster->Initialize(VECTOR(92,-20,85),400,400,1.0f,data3D,((CMy3dvisApp *)AfxGetApp())->transferFunction);
00145 raycaster->Zoom(1.1f);
00146
00147 raycaster->SetTreshold(1500);
00148 raycaster->SetRaytype(NN);
00149 raycaster->SetRendermode(FH);
00150 raycaster->SetPreCalcGradients(true);
00151 }
00152
00153 void volumebar::OnRadioPerspective() {
00154
00155 if (raycaster->m_dOwnType == PERSPECTIVE)
00156 return;
00157
00158 m_dRayType = PERSPECTIVE;
00159
00160 if (raycaster)
00161 delete raycaster;
00162
00163 raycaster = new Perspective();
00164 raycaster->SetViewingCondition(VECTOR(300,300,300),Color(0.0f,1.0f,0.0f),0.2f,0.2f,0.2f,8);
00165 ((Perspective *)raycaster)->Initialize(VECTOR(92,-20,85),40,400,400,1.0f,data3D,((CMy3dvisApp *)AfxGetApp())->transferFunction);
00166 raycaster->Zoom(1.1f);
00167
00168 raycaster->SetTreshold(1500);
00169 raycaster->SetRaytype(NN);
00170 raycaster->SetRendermode(FH);
00171 raycaster->SetPreCalcGradients(true);
00172 }