00001
00002
00003
00004
00005 #include <QColorDialog>
00006 #include <QFrame>
00007 #include <QLabel>
00008 #include <QImage>
00009 #include <QPixmap>
00010 #include <QGridLayout>
00011
00012 #include "CProperties.h"
00013 #include "vstudio.h"
00014 #include "VStudioRenderer.h"
00015 #include "Volume.h"
00016 #include "CGLHistogram.h"
00017 #include "modules/Math/TVector3.h"
00018
00019
00020
00021
00022
00023 extern CConsole * ptrConsole;
00024
00025
00026
00027
00028
00029
00030 CProperties::CProperties(QSettings & initSettings,QWidget * parent)
00031 : QWidget(parent)
00032 {
00033 pControl = (VStudio *)parent;
00034 ui.setupUi(this);
00035
00036
00037 pTransferProperty = new CTransferProperty("densityTransfer","txDensityTransfer");
00038 connect(pTransferProperty,SIGNAL(Dirty(int)),this,SLOT(UpdateTransferProperty(int)));
00039 QHBoxLayout *l = new QHBoxLayout();
00040 l->setMargin(0);
00041 pTransferProperty->Attach(l);
00042 ui.gridLayout->addLayout(l,0,0);
00043
00044
00045 pGradTransferProperty = new CTransferProperty("gradTransfer","txGradTransfer");
00046 connect(pGradTransferProperty,SIGNAL(Dirty(int)),this,SLOT(UpdateTransferProperty(int)));
00047 QHBoxLayout *m = new QHBoxLayout();
00048 m->setMargin(0);
00049 pGradTransferProperty->Attach(m);
00050 ui.gridLayout2->addLayout(m,0,0);
00051
00052
00053 spLight = new CLight(3);
00054
00055
00056 currentMIP = false;
00057 ui.mipButtonToggle->setText("Enable");
00058 ui.slicingGroup->setEnabled(false);
00059 ui.slideOrthogonalToggle->setText("Switch to Slicing in ObjectSpace");
00060 slideScreenSpace = false;
00061
00062
00063 OpenState(initSettings);
00064 }
00065
00066
00067 CProperties::~CProperties()
00068 {
00069 pTransferProperty = NULL;
00070 pGradTransferProperty = NULL;
00071 spLight = NULL;
00072 }
00073
00074
00075 void CProperties::OpenState(QSettings & openFile)
00076 {
00077
00078 openFile.beginGroup("RENDERING");
00079 renderMode = openFile.value("RenderMode").toInt();
00080 stepSize = (float)openFile.value("StepSize").toDouble();
00081 maxSamples = openFile.value("MaxSamples").toInt();
00082 applyNoise = openFile.value("ApplyNoise").toBool();
00083 fboSize = openFile.value("FBOSize").toInt();
00084 transferSize = openFile.value("TransferSize").toInt();
00085 minClip = openFile.value("MinClip",minClip).toDouble();
00086 openFile.endGroup();
00087
00088
00089 openFile.beginGroup("LIGHTING");
00090 spLight->Enable(openFile.value("enableLighting").toBool());
00091 spLight->SetLocalViewer(openFile.value("setLocalViewer").toBool());
00092
00093 CVector3f dLPos = spLight->GetPos();QRectF dLPR(dLPos.m_X,dLPos.m_Y,dLPos.m_Z,-1);
00094 QRectF lightPos = openFile.value("lightPos",dLPR).value<QRectF>();openFile.setValue("lightPos",lightPos);
00095 spLight->SetPos(CVector3f(lightPos.left(),lightPos.top(),lightPos.width()));
00096
00097 spLight->SetHeadLight(openFile.value("setHeadLight").toBool());
00098 spLight->Show(openFile.value("showLight").toBool());
00099 QColor newColor = openFile.value("lightColor").value<QColor>();
00100 spLight->SetColor(CVector3f(newColor.redF(),newColor.greenF(),newColor.blueF()));
00101 spLight->gradDelta.m_X = openFile.value("gradDeltaX").toDouble();
00102 spLight->gradDelta.m_Y = openFile.value("gradDeltaY").toDouble();
00103 spLight->gradDelta.m_Z = openFile.value("gradDeltaZ").toDouble();
00104 spLight->ambience = openFile.value("ambience").toDouble();
00105 spLight->specularity = openFile.value("specularity").toDouble();
00106 openFile.endGroup();
00107
00108
00109 openFile.beginGroup("SHADOWS");
00110 shadowQuality = openFile.value("ShadowQuality").toDouble();
00111 shadowTreshold = openFile.value("ShadowTreshold").toDouble();
00112 shadowEnable = openFile.value("EnableShadows").toBool();
00113 ui.shadow_quality_slider->setValue(shadowQuality*100);
00114 ui.shadow_quality_text->setText(QString("%1").arg(shadowQuality));
00115 ui.shadow_treshold_slider->setValue(shadowTreshold*100);
00116 ui.shadow_treshold_text->setText(QString("%1").arg(shadowTreshold));
00117 ui.shadow_enableCheckBox->setChecked(shadowEnable);
00118 openFile.endGroup();
00119
00120
00121 pTransferProperty->OpenState(openFile);
00122 pGradTransferProperty->OpenState(openFile);
00123
00124
00125 ui.stepSlider->setValue(stepSize*1000);
00126 ui.stepText->setText(QString("%1").arg(stepSize));
00127
00128 ui.maxSamplesSlider->setValue(maxSamples);
00129 ui.maxSamplesText->setText(QString().number(maxSamples));
00130
00131 ui.minClipSlider->setValue(minClip*100);
00132 ui.minClipText->setText(QString("%1").arg(minClip));
00133
00134 ui.noiseCheck->setChecked(applyNoise);
00135
00136 ui.lightColorShow->setPalette(newColor);
00137 ui.lightColorShow->repaint();
00138
00139 ui.gDeltaXSlider->setValue(spLight->gradDelta.m_X*10);
00140 ui.gDeltaXtext->setText(QString("%1").arg(spLight->gradDelta.m_X));
00141
00142 ui.gDeltaYSlider->setValue(spLight->gradDelta.m_Y*10);
00143 ui.gDeltaYtext->setText(QString("%1").arg(spLight->gradDelta.m_Y));
00144
00145 ui.gDeltaZSlider->setValue(spLight->gradDelta.m_Z*10);
00146 ui.gDeltaZtext->setText(QString("%1").arg(spLight->gradDelta.m_Z));
00147
00148 ui.ambSlider->setValue(spLight->ambience*100);
00149 ui.ambText->setText(QString("%1").arg(spLight->ambience));
00150
00151 ui.specSlider->setValue(spLight->specularity*100);
00152 ui.specText->setText(QString("%1").arg(spLight->specularity));
00153
00154 if(!(spLight->bEnabled)){
00155 ui.LDisableRB->setChecked(true);
00156 }else{
00157 if(spLight->bLocalViewer){
00158 ui.lPointRB->setChecked(true);
00159 }else{
00160 ui.lDirectionalRB->setChecked(true);
00161 }
00162 }
00163 ui.checkBox->setChecked(spLight->bHeadLight);
00164
00165 switch(fboSize){
00166 case 256:
00167 ui.fboSizeCombo->setCurrentIndex(0);
00168 break;
00169 case 512:
00170 ui.fboSizeCombo->setCurrentIndex(1);
00171 break;
00172 case 1024:
00173 ui.fboSizeCombo->setCurrentIndex(2);
00174 break;
00175 case 2048:
00176 ui.fboSizeCombo->setCurrentIndex(3);
00177 break;
00178 default:
00179 fboSize = 256;
00180 ui.fboSizeCombo->setCurrentIndex(0);
00181 break;
00182 }
00183
00184 switch(transferSize){
00185 case 64:
00186 ui.transferSizeCombo->setCurrentIndex(0);
00187 break;
00188 case 128:
00189 ui.transferSizeCombo->setCurrentIndex(1);
00190 break;
00191 case 256:
00192 ui.transferSizeCombo->setCurrentIndex(2);
00193 break;
00194 case 512:
00195 ui.transferSizeCombo->setCurrentIndex(3);
00196 break;
00197 case 1024:
00198 ui.transferSizeCombo->setCurrentIndex(4);
00199 break;
00200 case 2048:
00201 ui.transferSizeCombo->setCurrentIndex(5);
00202 break;
00203 case 4096:
00204 ui.transferSizeCombo->setCurrentIndex(6);
00205 break;
00206 default:
00207 transferSize = 256;
00208 ui.fboSizeCombo->setCurrentIndex(2);
00209 break;
00210 }
00211
00212 switch(renderMode){
00213 case MODE_BACK_TEX:
00214 ui.select_bcolor->setChecked(true);
00215 break;
00216 case MODE_BACK_FRONT_TEX:
00217 ui.select_bfcolor->setChecked(true);
00218 break;
00219 case MODE_DEPTH_TEX:
00220 ui.select_depth->setChecked(true);
00221 break;
00222 }
00223 }
00224
00225
00226 void CProperties::Update()
00227 {
00228 SetActive(true);
00229 pTransferProperty->Show();
00230 pTransferProperty->Update();
00231 pGradTransferProperty->Show();
00232 pGradTransferProperty->Update();
00233 }
00234
00235
00236 void CProperties::SetActive(bool tf)
00237 {
00238 if(tf)
00239 {
00240 currentMIP = ui.mipButtonToggle->text().compare("Disable") == 0;
00241 if(!currentMIP)
00242 {
00243
00244 for(int i = 0 ; i < ui.properties_tab->count() ; i++)
00245 {
00246 ui.properties_tab->setCurrentIndex(i);
00247 ui.properties_tab->setTabEnabled(i,true);
00248 }
00249 ui.properties_tab->setCurrentIndex(0);
00250 ui.properties_tab->currentWidget()->setVisible(true);
00251 }
00252 else
00253 {
00254
00255 if(pControl->GetVolume())
00256 {
00257 pControl->GetVolume()->SetMinClip(0);
00258 pControl->RenderMIP(true);
00259 if(ui.xSlide_Checked->isChecked() || ui.ySlide_Checked->isChecked() || ui.zSlide_Checked->isChecked())
00260 {
00261 pControl->GetVolume()->ViewAspectChange(pControl->GetRenderer().GetViewAspect());
00262 pControl->GetVolume()->SetSliceDepth(0,ui.xSlide_Slider->value()/100.0);
00263 pControl->GetVolume()->SetSliceDepth(1,ui.ySlide_Slider->value()/100.0);
00264 pControl->GetVolume()->SetSliceDepth(2,ui.zSlide_Slider->value()/100.0);
00265 pControl->GetVolume()->SetRenderMode(MODE_SLICE);
00266 pControl->GetVolume()->SetRenderSlice(ui.xSlide_Checked->isChecked(), ui.ySlide_Checked->isChecked(),ui.zSlide_Checked->isChecked());
00267 pControl->GetVolume()->SetSliceInViewSpace(!slideScreenSpace);
00268 }
00269 }
00270 }
00271 }
00272 else
00273 {
00274
00275 for(int i = 0 ; i < ui.properties_tab->count() ; i++)
00276 {
00277 ui.properties_tab->setTabEnabled(i,false);
00278 }
00279 ui.properties_tab->setCurrentIndex(0);
00280 ui.properties_tab->currentWidget()->setVisible(false);
00281 }
00282 }
00283
00284
00285 void CProperties::SaveState(QSettings & saveFile)
00286 {
00287
00288 saveFile.beginGroup("RENDERING");
00289 saveFile.setValue("RenderMode",renderMode);
00290 saveFile.setValue("StepSize",stepSize);
00291 saveFile.setValue("MaxSamples",maxSamples);
00292 saveFile.setValue("ApplyNoise",applyNoise);
00293 saveFile.setValue("FBOSize",fboSize);
00294 saveFile.setValue("TransferSize",transferSize);
00295 saveFile.setValue("MinClip",minClip);
00296 saveFile.endGroup();
00297
00298
00299 saveFile.beginGroup("LIGHTING");
00300 saveFile.setValue("enableLighting",spLight->bEnabled);
00301 saveFile.setValue("setLocalViewer",spLight->bLocalViewer ? true : false);
00302 saveFile.setValue("setHeadLight",spLight->bHeadLight);
00303 saveFile.setValue("showLight",spLight->bShow);
00304 QColor saveColor; saveColor.setRedF(spLight->color.m_X); saveColor.setGreenF(spLight->color.m_Y); saveColor.setBlueF(spLight->color.m_Z);
00305 saveFile.setValue("lightColor",saveColor);
00306 CVector3f lightPos = spLight->GetPos(); QRectF lightPosR(lightPos.m_X,lightPos.m_Y,lightPos.m_Z,-1);
00307 saveFile.setValue("lightPos",lightPosR);
00308 saveFile.setValue("gradDeltaX",ui.gDeltaXtext->text().toFloat());
00309 saveFile.setValue("gradDeltaY",ui.gDeltaYtext->text().toFloat());
00310 saveFile.setValue("gradDeltaZ",ui.gDeltaZtext->text().toFloat());
00311 saveFile.setValue("ambience",ui.ambText->text().toFloat());
00312 saveFile.setValue("specularity",ui.specText->text().toFloat());
00313 saveFile.endGroup();
00314
00315
00316 saveFile.beginGroup("SHADOWS");
00317 saveFile.setValue("ShadowQuality",shadowQuality);
00318 saveFile.setValue("ShadowTreshold",shadowTreshold);
00319 saveFile.setValue("EnableShadows",shadowEnable);
00320 saveFile.endGroup();
00321
00322
00323 pTransferProperty->SaveState(saveFile);
00324 pGradTransferProperty->SaveState(saveFile);
00325 }
00326
00327
00328
00329
00330
00331 void CProperties::showEvent( QShowEvent *event)
00332 {
00333 if((CVolume *)pControl->GetVolume() == NULL)
00334 {
00335 SetActive(false);
00336 }
00337 else
00338 {
00339
00340 }
00341 }
00342
00343
00344
00345
00346
00347 void CProperties::on_properties_tab_currentChanged(int){}
00348
00349
00350 void CProperties::on_select_bcolor_clicked()
00351 {
00352 renderMode = MODE_BACK_TEX;
00353 if(pControl->GetVolume()){
00354 pControl->GetVolume()->SetRenderMode(MODE_BACK_TEX);
00355 UpdateRender();
00356 }
00357 }
00358
00359 void CProperties::on_select_bfcolor_clicked()
00360 {
00361 renderMode = MODE_BACK_FRONT_TEX;
00362 if(pControl->GetVolume()){
00363 pControl->GetVolume()->SetRenderMode(MODE_BACK_FRONT_TEX);
00364 UpdateRender();
00365 }
00366 }
00367
00368 void CProperties::on_select_depth_clicked()
00369 {
00370 renderMode = MODE_DEPTH_TEX;
00371 if(pControl->GetVolume()){
00372 pControl->GetVolume()->SetRenderMode(MODE_DEPTH_TEX);
00373 UpdateRender();
00374 }
00375 }
00376
00377
00378 void CProperties::on_stepSlider_valueChanged(int step)
00379 {
00380 stepSize = step/1000.0;
00381 if(ui.stepSlider->isSliderDown()){
00382 ui.stepText->setText(QString("%1").arg(stepSize));
00383 pControl->GetVolume()->SetStepSize(stepSize);
00384 UpdateRender();
00385 }
00386 }
00387
00388 void CProperties::on_stepText_editingFinished()
00389 {
00390 stepSize = ui.stepText->text().toFloat();
00391 ui.stepSlider->setValue(stepSize*1000);
00392 pControl->GetVolume()->SetStepSize(stepSize);
00393 UpdateRender();
00394 }
00395
00396
00397 void CProperties::on_maxSamplesSlider_valueChanged(int samples)
00398 {
00399 maxSamples = samples;
00400 if(ui.maxSamplesSlider->isSliderDown()){
00401 ui.maxSamplesText->setText(QString("%1").arg(maxSamples));
00402 pControl->GetVolume()->SetMaxSamples(maxSamples);
00403 UpdateRender();
00404 }
00405 }
00406
00407 void CProperties::on_maxSamplesText_editingFinished()
00408 {
00409 maxSamples = ui.maxSamplesText->text().toInt();
00410 ui.maxSamplesSlider->setValue(maxSamples);
00411 pControl->GetVolume()->SetMaxSamples(maxSamples);
00412 UpdateRender();
00413 }
00414
00415
00416 void CProperties::on_minClipSlider_valueChanged(int clip)
00417 {
00418 minClip = clip/100.0;
00419 if(ui.minClipSlider->isSliderDown()){
00420 ui.minClipText->setText(QString("%1").arg(minClip));
00421 pControl->GetVolume()->SetMinClip(minClip);
00422 UpdateRender();
00423 }
00424 }
00425
00426 void CProperties::on_minClipText_editingFinished()
00427 {
00428 minClip = ui.minClipText->text().toFloat();
00429 ui.minClipSlider->setValue(minClip*100);
00430 pControl->GetVolume()->SetMinClip(minClip);
00431 UpdateRender();
00432 }
00433
00434
00435 void CProperties::on_noiseCheck_stateChanged(int state)
00436 {
00437 if(pControl->GetVolume()){
00438 applyNoise = state == Qt::Checked;
00439 pControl->GetVolume()->SetApplyNoise(applyNoise);
00440 UpdateRender();
00441 }
00442 }
00443
00444
00445 void CProperties::on_fboSizeCombo_activated(QString ItemTextSize)
00446 {
00447 fboSize = ItemTextSize.toInt();
00448 pControl->GetVolume()->SetFboSize(fboSize);
00449 UpdateRender();
00450 }
00451
00452
00453 void CProperties::on_transferSizeCombo_activated(QString ItemTextSize)
00454 {
00455 transferSize = ItemTextSize.toInt();
00456 pTransferProperty->SetTransferFuncSize(transferSize);
00457 pGradTransferProperty->SetTransferFuncSize(transferSize);
00458 UpdateRender();
00459 }
00460
00461
00462 void CProperties::on_LDisableRB_clicked(bool tf)
00463 {
00464 spLight->Enable(false);
00465 UpdateRender();
00466 }
00467
00468
00469 void CProperties::on_lPointRB_clicked(bool tf)
00470 {
00471 spLight->Enable(true);
00472 spLight->SetLocalViewer(true);
00473 UpdateRender();
00474 }
00475
00476
00477 void CProperties::on_lDirectionalRB_clicked(bool tf)
00478 {
00479 spLight->Enable(true);
00480 spLight->SetLocalViewer(false);
00481 UpdateRender();
00482 }
00483
00484
00485 void CProperties::on_checkBox_stateChanged(int state)
00486 {
00487 spLight->SetHeadLight(state == Qt::Checked);
00488 UpdateRender();
00489 }
00490
00491 void CProperties::on_lightColorSelect_released()
00492 {
00493 QColor newColor = QColorDialog::getColor();
00494 spLight->SetColor(CVector3f(newColor.redF(),newColor.greenF(),newColor.blueF()));
00495 ui.lightColorShow->setPalette(newColor);
00496 UpdateRender();
00497 }
00498
00499
00500 void CProperties::on_gDeltaXSlider_valueChanged(int newVal)
00501 {
00502 spLight->SetGradientX(newVal/10.0);
00503 if(ui.gDeltaXSlider->isSliderDown()){
00504 ui.gDeltaXtext->setText(QString("%1").arg(spLight->gradDelta.m_X));
00505 UpdateRender();
00506 }
00507 }
00508
00509 void CProperties::on_gDeltaXtext_editingFinished()
00510 {
00511 spLight->SetGradientX(ui.gDeltaXtext->text().toFloat());
00512 ui.gDeltaXSlider->setValue(spLight->gradDelta.m_X*10);
00513 UpdateRender();
00514 }
00515
00516
00517 void CProperties::on_gDeltaYSlider_valueChanged(int newVal)
00518 {
00519 spLight->SetGradientY(newVal/10.0);
00520 if(ui.gDeltaYSlider->isSliderDown()){
00521 ui.gDeltaYtext->setText(QString("%1").arg(spLight->gradDelta.m_Y));
00522 UpdateRender();
00523 }
00524 }
00525
00526 void CProperties::on_gDeltaYtext_editingFinished()
00527 {
00528 spLight->SetGradientY(ui.gDeltaXtext->text().toFloat());
00529 ui.gDeltaYSlider->setValue(spLight->gradDelta.m_Y*10);
00530 UpdateRender();
00531 }
00532
00533
00534 void CProperties::on_gDeltaZSlider_valueChanged(int newVal)
00535 {
00536 spLight->SetGradientZ(newVal/10.0);
00537 if(ui.gDeltaZSlider->isSliderDown()){
00538 ui.gDeltaZtext->setText(QString("%1").arg(spLight->gradDelta.m_Z));
00539 UpdateRender();
00540 }
00541 }
00542
00543 void CProperties::on_gDeltaZtext_editingFinished()
00544 {
00545 spLight->SetGradientZ(ui.gDeltaXtext->text().toFloat());
00546 ui.gDeltaZSlider->setValue(spLight->gradDelta.m_Z*10);
00547 UpdateRender();
00548 }
00549
00550
00551 void CProperties::on_ambSlider_valueChanged(int newVal)
00552 {
00553 spLight->SetAmbience(newVal/100.0);
00554 if(ui.ambSlider->isSliderDown()){
00555 ui.ambText->setText(QString("%1").arg(spLight->ambience));
00556 UpdateRender();
00557 }
00558 }
00559
00560 void CProperties::on_ambText_editingFinished()
00561 {
00562 spLight->SetAmbience(ui.ambText->text().toFloat());
00563 ui.ambSlider->setValue(spLight->ambience*100);
00564 UpdateRender();
00565 }
00566
00567
00568 void CProperties::on_specSlider_valueChanged(int newVal)
00569 {
00570 spLight->SetSpecularity(newVal/100.0);
00571 if(ui.specSlider->isSliderDown()){
00572 ui.specText->setText(QString("%1").arg(spLight->specularity));
00573 UpdateRender();
00574 }
00575 }
00576
00577 void CProperties::on_specText_editingFinished()
00578 {
00579 spLight->SetSpecularity(ui.specText->text().toFloat());
00580 ui.specSlider->setValue(spLight->specularity*100);
00581 UpdateRender();
00582 }
00583
00584
00585 void CProperties::on_shadow_enableCheckBox_stateChanged(int state)
00586 {
00587 shadowEnable = state == Qt::Checked;
00588 if(pControl->GetVolume())
00589 {
00590 pControl->GetVolume()->SetShadowQuality(shadowQuality);
00591 pControl->GetVolume()->SetShadowTreshold(shadowTreshold);
00592 pControl->GetVolume()->SetShadowEnabled(state);
00593 }
00594 UpdateRender();
00595 }
00596
00597
00598 void CProperties::on_shadow_treshold_slider_valueChanged(int sTreshold)
00599 {
00600 shadowTreshold = sTreshold/100.0;
00601 if(ui.shadow_treshold_slider->isSliderDown()){
00602 ui.shadow_treshold_text->setText(QString("%1").arg(shadowTreshold));
00603 pControl->GetVolume()->SetShadowTreshold(shadowTreshold);
00604 UpdateRender();
00605 }
00606 }
00607
00608 void CProperties::on_shadow_treshold_text_editingFinished()
00609 {
00610 shadowTreshold = ui.shadow_treshold_text->text().toFloat();
00611 ui.shadow_treshold_slider->setValue(shadowTreshold*100);
00612 pControl->GetVolume()->SetShadowTreshold(shadowTreshold);
00613 UpdateRender();
00614 }
00615
00616
00617 void CProperties::on_shadow_quality_slider_valueChanged(int sQuality)
00618 {
00619 shadowQuality = sQuality/100.0;
00620 if(ui.shadow_quality_slider->isSliderDown()){
00621 ui.shadow_quality_text->setText(QString("%1").arg(shadowQuality));
00622 pControl->GetVolume()->SetShadowQuality(shadowQuality);
00623 UpdateRender();
00624 }
00625 }
00626
00627 void CProperties::on_shadow_quality_text_editingFinished()
00628 {
00629 shadowQuality = ui.shadow_quality_text->text().toFloat();
00630 ui.shadow_quality_slider->setValue(shadowQuality*100);
00631 pControl->GetVolume()->SetShadowQuality(shadowQuality);
00632 UpdateRender();
00633 }
00634
00635
00636 void CProperties::on_mipButtonToggle_released()
00637 {
00638 static float sminClip = 0;
00639 static bool blightVisible = spLight->bShow;
00640
00641 currentMIP = ui.mipButtonToggle->text().compare("Disable") == 0;
00642
00643 if(currentMIP)
00644 {
00645 ui.properties_tab->setTabEnabled(ui.properties_tab->indexOf(ui.DensityTab),true);
00646 ui.properties_tab->setTabEnabled(ui.properties_tab->indexOf(ui.gradMagTab),true);
00647 ui.properties_tab->setTabEnabled(ui.properties_tab->indexOf(ui.lighting_shadingTab),true);
00648 ui.properties_tab->setTabEnabled(ui.properties_tab->indexOf(ui.shadowTab),true);
00649 ui.properties_tab->setTabEnabled(0,true);
00650
00651 ui.transferSizeCombo->setDisabled(false);
00652
00653 pControl->GetVolume()->SetMinClip(sminClip);
00654 ui.minClipSlider->setDisabled(false);
00655 ui.minClipText->setDisabled(false);
00656
00657 spLight->bShow = blightVisible;
00658
00659 pControl->RenderMIP(false);
00660 pControl->GetVolume()->SetRenderMode(MODE_BACK_FRONT_TEX);
00661
00662 ui.mipButtonToggle->setText("Enable");
00663 ui.slicingGroup->setEnabled(false);
00664 }
00665 else
00666 {
00667 ui.properties_tab->setTabEnabled(ui.properties_tab->indexOf(ui.DensityTab),false);
00668 ui.properties_tab->setTabEnabled(ui.properties_tab->indexOf(ui.gradMagTab),false);
00669 ui.properties_tab->setTabEnabled(ui.properties_tab->indexOf(ui.lighting_shadingTab),false);
00670 ui.properties_tab->setTabEnabled(ui.properties_tab->indexOf(ui.shadowTab),false);
00671 ui.transferSizeCombo->setDisabled(true);
00672
00673 sminClip = minClip;
00674 pControl->GetVolume()->SetMinClip(0);
00675
00676 blightVisible = spLight->bShow;
00677 spLight->bShow = false;
00678
00679 ui.minClipSlider->setDisabled(true);
00680 ui.minClipText->setDisabled(true);
00681
00682 pControl->RenderMIP(true);
00683 if(ui.xSlide_Checked->isChecked() || ui.ySlide_Checked->isChecked() || ui.zSlide_Checked->isChecked())
00684 {
00685 pControl->GetVolume()->SetRenderMode(MODE_SLICE);
00686 ui.properties_tab->setTabEnabled(0,false);
00687 ui.slideOrthogonalToggle->setEnabled(true);
00688 on_xSlide_Checked_stateChanged(1);
00689 }
00690 else
00691 {
00692 ui.slideOrthogonalToggle->setEnabled(false);
00693 }
00694
00695 ui.mipButtonToggle->setText("Disable");
00696 ui.slicingGroup->setEnabled(true);
00697 }
00698 UpdateRender();
00699 }
00700
00701
00702 void CProperties::UpdateRender(){
00703 pControl->GetRenderer().Update();
00704 }
00705
00706
00707 void CProperties::UpdateTransferProperty(int ht)
00708 {
00709 static int prevDHistSize = pTransferProperty->GetHistogramQuality() * pTransferProperty->GetHistogramSize();
00710 static int prevGHistSize = pGradTransferProperty->GetHistogramQuality() * pGradTransferProperty->GetHistogramSize();
00711
00712 if(pVolumeStatistics)
00713 {
00714 CTransferProperty * sO = qobject_cast<CTransferProperty *>(QObject::sender());
00715
00716 int gQ = pGradTransferProperty->GetHistogramQuality();
00717 int gS = pGradTransferProperty->GetHistogramSize();
00718 int dQ = pTransferProperty->GetHistogramQuality();
00719 int dS = pTransferProperty->GetHistogramSize();
00720
00721 switch(ht)
00722 {
00723 case DIRTY_TRANSFER:
00724 UpdateRender();
00725 break;
00726
00727 case DIRTY_HISTOGRAM:
00728
00729 if(sO == pGradTransferProperty)
00730 {
00731 if( prevGHistSize != (gQ * gS))
00732 {
00733 prevGHistSize = gQ * gS;
00734
00735 QString msg("New Gradient Histogram Quantisation: ");
00736 ptrConsole->Log(msg.append(QString().setNum(prevGHistSize)),MAIN_THREAD);
00737
00738 if(pGradTransferProperty->Logarithmic()){
00739 SHistogramData & histogramGradient = pVolumeStatistics->GetGradHistogram(gQ*gS,NORMALIZE_LOG);
00740 pGradTransferProperty->SetHistogramData(histogramGradient.data,histogramGradient.nmbBuckets);
00741 }else{
00742 SHistogramData & histogramGradient = pVolumeStatistics->GetGradHistogram(gQ*gS,NORMALIZE_LINEAR);
00743 pGradTransferProperty->SetHistogramData(histogramGradient.data,histogramGradient.nmbBuckets);
00744 }
00745 }
00746 }
00747 else
00748 {
00749 if( prevDHistSize != (dQ * dS))
00750 {
00751 prevDHistSize = dQ*dS;
00752
00753 QString msg("New Density Histogram Quantisation: ");
00754 ptrConsole->Log(msg.append(QString().setNum(prevDHistSize)),MAIN_THREAD);
00755
00756 if(pTransferProperty->Logarithmic()){
00757 SHistogramData & histogramGradient = pVolumeStatistics->GetHistogram(dQ*dS,NORMALIZE_LOG);
00758 pTransferProperty->SetHistogramData(histogramGradient.data,histogramGradient.nmbBuckets);
00759 }else{
00760 SHistogramData & histogramGradient = pVolumeStatistics->GetHistogram(dQ*dS,NORMALIZE_LINEAR);
00761 pTransferProperty->SetHistogramData(histogramGradient.data,histogramGradient.nmbBuckets);
00762 }
00763 }
00764 }
00765 break;
00766
00767 case DIRTY_LOG:
00768
00769 if(sO == pGradTransferProperty)
00770 {
00771 if(pGradTransferProperty->Logarithmic()){
00772 SHistogramData & histogramGradient = pVolumeStatistics->GetGradHistogram(gQ*gS,NORMALIZE_LOG);
00773 pGradTransferProperty->SetHistogramData(histogramGradient.data,histogramGradient.nmbBuckets);
00774 }else{
00775 SHistogramData & histogramGradient = pVolumeStatistics->GetGradHistogram(gQ*gS,NORMALIZE_LINEAR);
00776 pGradTransferProperty->SetHistogramData(histogramGradient.data,histogramGradient.nmbBuckets);
00777 }
00778 }
00779 else
00780 {
00781 if(pTransferProperty->Logarithmic()){
00782 SHistogramData & histogramGradient = pVolumeStatistics->GetHistogram(dQ*dS,NORMALIZE_LOG);
00783 pTransferProperty->SetHistogramData(histogramGradient.data,histogramGradient.nmbBuckets);
00784 }else{
00785 SHistogramData & histogramGradient = pVolumeStatistics->GetHistogram(dQ*dS,NORMALIZE_LINEAR);
00786 pTransferProperty->SetHistogramData(histogramGradient.data,histogramGradient.nmbBuckets);
00787 }
00788 }
00789 break;
00790
00791 case DIRTY_OVERLAY:
00792
00793 break;
00794 }
00795 }
00796 }
00797
00798 void CProperties::SetVolumeStatistics( TSmartPointer<CVolumeStatistics> newVS )
00799 {
00800 pVolumeStatistics = newVS;
00801 pTransferProperty->Update();
00802 pGradTransferProperty->Update();
00803 }
00804
00805 void CProperties::on_shadingGroup_toggled(bool){}
00806
00807
00808
00809 void CProperties::on_xSlide_Checked_stateChanged(int)
00810 {
00811 bool bslice = ui.xSlide_Checked->isChecked() || ui.ySlide_Checked->isChecked() || ui.zSlide_Checked->isChecked();
00812
00813 if(bslice)
00814 {
00815 pControl->GetVolume()->ViewAspectChange(pControl->GetRenderer().GetViewAspect());
00816 pControl->GetVolume()->SetRenderMode(MODE_SLICE);
00817 ui.properties_tab->setTabEnabled(0,false);
00818 ui.slideOrthogonalToggle->setEnabled(true);
00819 pControl->GetVolume()->SetRenderSlice(ui.xSlide_Checked->isChecked(), ui.ySlide_Checked->isChecked(),ui.zSlide_Checked->isChecked());
00820 }
00821 else
00822 {
00823 pControl->GetVolume()->SetRenderMode(MODE_BACK_FRONT_TEX);
00824 ui.properties_tab->setTabEnabled(0,true);
00825 ui.slideOrthogonalToggle->setEnabled(false);
00826 }
00827 UpdateRender();
00828 }
00829
00830 void CProperties::on_ySlide_Checked_stateChanged(int)
00831 {
00832 bool bslice = ui.xSlide_Checked->isChecked() || ui.ySlide_Checked->isChecked() || ui.zSlide_Checked->isChecked();
00833
00834 if(bslice)
00835 {
00836 pControl->GetVolume()->ViewAspectChange(pControl->GetRenderer().GetViewAspect());
00837 pControl->GetVolume()->SetRenderMode(MODE_SLICE);
00838 ui.properties_tab->setTabEnabled(0,false);
00839 ui.slideOrthogonalToggle->setEnabled(true);
00840 pControl->GetVolume()->SetRenderSlice(ui.xSlide_Checked->isChecked(), ui.ySlide_Checked->isChecked(),ui.zSlide_Checked->isChecked());
00841 }
00842 else
00843 {
00844 pControl->GetVolume()->SetRenderMode(MODE_BACK_FRONT_TEX);
00845 ui.properties_tab->setTabEnabled(0,true);
00846 ui.slideOrthogonalToggle->setEnabled(false);
00847 }
00848 UpdateRender();
00849 }
00850
00851 void CProperties::on_zSlide_Checked_stateChanged(int)
00852 {
00853 bool bslice = ui.xSlide_Checked->isChecked() || ui.ySlide_Checked->isChecked() || ui.zSlide_Checked->isChecked();
00854
00855 if(bslice)
00856 {
00857 pControl->GetVolume()->ViewAspectChange(pControl->GetRenderer().GetViewAspect());
00858 pControl->GetVolume()->SetRenderMode(MODE_SLICE);
00859 ui.properties_tab->setTabEnabled(0,false);
00860 ui.slideOrthogonalToggle->setEnabled(true);
00861 pControl->GetVolume()->SetRenderSlice(ui.xSlide_Checked->isChecked(), ui.ySlide_Checked->isChecked(),ui.zSlide_Checked->isChecked());
00862 }
00863 else
00864 {
00865 pControl->GetVolume()->SetRenderMode(MODE_BACK_FRONT_TEX);
00866 ui.properties_tab->setTabEnabled(0,true);
00867 ui.slideOrthogonalToggle->setEnabled(false);
00868 }
00869 UpdateRender();
00870 }
00871
00872 void CProperties::on_xSlide_Slider_valueChanged(int val)
00873 {
00874 pControl->GetVolume()->SetSliceDepth(0,val/100.0);
00875 UpdateRender();
00876 }
00877
00878 void CProperties::on_ySlide_Slider_valueChanged(int val)
00879 {
00880 pControl->GetVolume()->SetSliceDepth(1,val/100.0);
00881 UpdateRender();
00882 }
00883
00884 void CProperties::on_zSlide_Slider_valueChanged(int val)
00885 {
00886 pControl->GetVolume()->SetSliceDepth(2,val/100.0);
00887 UpdateRender();
00888 }
00889
00890 void CProperties::on_mip_Group_toggled(bool)
00891 {
00892
00893 }
00894
00895 void CProperties::on_slideOrthogonalToggle_released()
00896 {
00897 if(slideScreenSpace)
00898 {
00899 pControl->GetVolume()->SetSliceInViewSpace(true);
00900 ui.slideOrthogonalToggle->setText("Switch to Slicing in ObjectSpace");
00901 }
00902 else
00903 {
00904 pControl->GetVolume()->SetSliceInViewSpace(false);
00905 ui.slideOrthogonalToggle->setText("Switch to Slicing in ScreenSpace");
00906 }
00907 slideScreenSpace = !slideScreenSpace;
00908 UpdateRender();
00909 }
00910
00911 void CProperties::on_checkBox_4_stateChanged(int)
00912 {
00913
00914 }