00001 #include "QMain.h"
00002 #include "QtGui/QFileDialog.h"
00003 #include <iostream>
00004
00005 QMain::QMain(QWidget* parent , Qt::WFlags flags )
00006 : QMainWindow(parent, flags),
00007 SLICE_VIEW_TAB(0),
00008 VOL_VIEW_TAB(1),
00009 PARALLELPROJECTION(1),
00010 PERSPECTIVEPROJECTION(0)
00011 {
00012 setupUi(this);
00013 GLenum err = glewInit();
00014 if (err != GLEW_OK)
00015 {
00016
00017 std::cerr << "Error initializing GLEW: " << glewGetErrorString(err) << std::endl;
00018 std::cout << "Press a button to continue" << std::endl;
00019 std::cin.get();
00020
00021 }
00022 std::cout << "- GLEW initialized." << std::endl << std::endl;
00023
00024 renderer_canvas->setTransferFunctionPtr(tf_canvas->getTransferFunctionPtr());
00025 renderer_canvas->setTransferFunction2DPtr(tf_canvas->getTransferFunction2DPtr());
00026
00027
00028 m_BackgroundColor.setX(0.0f);
00029 m_BackgroundColor.setY(0.0f);
00030 m_BackgroundColor.setZ(0.0f);
00031 backgroundSelect->setVolBackColorPtr(&m_BackgroundColor);
00032 renderer_canvas->setBackColorPtr(&m_BackgroundColor);
00033
00034
00035 int _c_x2, _c_y2;
00036 renderer_canvas->geometry().getCoords(&pixposx_rcanvas, &pixposy_rcanvas, &_c_x2, &_c_y2);
00037
00038 w_sizex = size().rwidth();
00039 w_sizey = size().rheight();
00040
00041 pixoffsetx_rcanvas = pixposx_rcanvas + ( (w_sizex -1) - _c_x2 );
00042 pixoffsety_rcanvas = pixposy_rcanvas + ( (w_sizey -1) - _c_y2 );
00043
00044 pTimer = new QTimer( this);
00045 connect( pTimer, SIGNAL(timeout()), this, SLOT(watch()) );
00046 pTimer->start(0);
00047
00048 pTimer_redraw = new QTimer( this);
00049 connect( pTimer_redraw, SIGNAL(timeout()), this, SLOT(redraw()) );
00050 pTimer_redraw->start(30);
00051
00052 setMinimumSize(w_sizex,w_sizey);
00053
00054
00055
00056 connect( actionOpen, SIGNAL(triggered()), this, SLOT(load_data_file()) );
00057 connect( actionSave_Volume, SIGNAL(triggered()), this, SLOT(save_data_file()) );
00058 connect( actionClose, SIGNAL(triggered()), this, SLOT(close()) );
00059 connect( actionLoad, SIGNAL(triggered()), this, SLOT(load_tf_file()) );
00060 connect( actionSave, SIGNAL(triggered()), this, SLOT(save_tf_file()) );
00061 connect( actionSave_Image, SIGNAL(triggered()), this, SLOT(save_image()) );
00062 connect( actionNo_TF, SIGNAL(triggered()), this, SLOT(tf_menu_no()) );
00063 connect( actionTF_1D, SIGNAL(triggered()), this, SLOT(tf_menu_1d()) );
00064 connect( actionTF_2D, SIGNAL(triggered()), this, SLOT(tf_menu_2d()) );
00065
00066 connect( mode_tab, SIGNAL(currentChanged(int)), this, SLOT(modetab_switched(int)) );
00067 connect( tfmode, SIGNAL(activated(int)), this, SLOT(tf_menu(int)) );
00068
00069 connect( sliceslider_corronal, SIGNAL(valueChanged(int)), this, SLOT(slicesslider_corronal_valuechanged(int)) );
00070 connect( sliceslider_saggital, SIGNAL(valueChanged(int)), this, SLOT(slicesslider_saggital_valuechanged(int)) );
00071 connect( sliceslider_transversal, SIGNAL(valueChanged(int)), this, SLOT(slicesslider_transversal_valuechanged(int)) );
00072
00073 connect( modes_combo, SIGNAL(activated(int)), this, SLOT(rendermode_changed(int)) );
00074 connect( lighttf_combo, SIGNAL(activated(int)), this, SLOT(lightmode_changed(int)) );
00075 connect( thresholdL_slider, SIGNAL(valueChanged(int)), this, SLOT(thresholdvalL_valuechanged(int)) );
00076 connect( thresholdH_slider, SIGNAL(valueChanged(int)), this, SLOT(thresholdvalH_valuechanged(int)) );
00077
00078 connect( clipslider_xneg, SIGNAL(valueChanged(int)), this, SLOT(clipxneg_valuechanged(int)) );
00079 connect( clipslider_xpos, SIGNAL(valueChanged(int)), this, SLOT(clipxpos_valuechanged(int)) );
00080 connect( clipslider_yneg, SIGNAL(valueChanged(int)), this, SLOT(clipyneg_valuechanged(int)) );
00081 connect( clipslider_ypos, SIGNAL(valueChanged(int)), this, SLOT(clipypos_valuechanged(int)) );
00082 connect( clipslider_zneg, SIGNAL(valueChanged(int)), this, SLOT(clipzneg_valuechanged(int)) );
00083 connect( clipslider_zpos, SIGNAL(valueChanged(int)), this, SLOT(clipzpos_valuechanged(int)) );
00084
00085 connect( clipcb_xneg, SIGNAL(clicked(bool)), this, SLOT(clipcb_xneg_clicked(bool)) );
00086 connect( clipcb_xpos, SIGNAL(clicked(bool)), this, SLOT(clipcb_xpos_clicked(bool)) );
00087 connect( clipcb_yneg, SIGNAL(clicked(bool)), this, SLOT(clipcb_yneg_clicked(bool)) );
00088 connect( clipcb_ypos, SIGNAL(clicked(bool)), this, SLOT(clipcb_ypos_clicked(bool)) );
00089 connect( clipcb_zneg, SIGNAL(clicked(bool)), this, SLOT(clipcb_zneg_clicked(bool)) );
00090 connect( clipcb_zpos, SIGNAL(clicked(bool)), this, SLOT(clipcb_zpos_clicked(bool)) );
00091
00092 connect( proj_combo, SIGNAL(activated(int)), this, SLOT(projectionMode(int)) );
00093
00094 connect( actionFlip_X, SIGNAL(triggered()), this, SLOT(flipX()));
00095 connect( actionFlip_Y, SIGNAL(triggered()), this, SLOT(flipY()));
00096 connect( actionFlip_Z, SIGNAL(triggered()), this, SLOT(flipZ()));
00097 connect( lightdir_cb, SIGNAL(clicked(bool)), this, SLOT(lightModification(bool)) );
00098 connect( contours_cb, SIGNAL(clicked(bool)), this, SLOT(setContourMode(bool)) );
00099 connect( contours_cb_2, SIGNAL(clicked(bool)), this, SLOT(setShadowMode(bool)) );
00100
00101 connect( tfhorizscroll, SIGNAL(valueChanged(int)), this, SLOT(tf_horizscroll_valuechanged(int)) );
00102 connect( tfvertscroll, SIGNAL(valueChanged(int)), this, SLOT(tf_vertscroll_valuechanged(int)) );
00103
00104
00105 sliceslider_corronal->setEnabled(false);
00106 sliceslider_saggital->setEnabled(false);
00107 sliceslider_transversal->setEnabled(false);
00108
00109 voldimx = 0;
00110 voldimy = 0;
00111 voldimz = 0;
00112
00113 tfmode->setVisible(false);
00114 cb_apply_tf_to_slices->setVisible(false);
00115 cb_pcikdensity->setVisible(false);
00116
00117 thresholdL_slider->setVisible(false);
00118 thresholdH_slider->setVisible(false);
00119 thresholdL_label->setVisible(false);
00120 thresholdH_label->setVisible(false);
00121 thresholdH_name->setVisible(false);
00122 thresholdL_name->setVisible(false);
00123 tfvertscroll->setVisible(false);
00124 tfhorizscroll->setVisible(false);
00125
00126 tf_canvas->setCursor(Qt::CursorShape::ForbiddenCursor);
00127 tf_canvas->modeChanged(0);
00128 tf_canvas->setModePtr(tfmode);
00129 tf_canvas->setVScroll(tfvertscroll);
00130 tf_canvas->setHScroll(tfhorizscroll);
00131 }
00132
00133
00134 QMain::~QMain()
00135 {
00136
00137 delete pTimer;
00138 }
00139
00140 void QMain::redraw()
00141 {
00142 renderer_canvas->repaint();
00143 }
00144
00145 void QMain::tf_vertscroll_valuechanged(int val)
00146 {
00147 int x1, y1, x2, y2;
00148 tf_canvas->geometry().getCoords(&x1, &y1, &x2, &y2);
00149
00150 float sizex = x2-x1 + 1.0f;
00151 float sizey = y2-y1 + 1.0f;
00152
00153 float factor = (100.0f-(float)val)/(100.0f) * (sizey - sizey/3.0f -27.0f);
00154
00155 tf_canvas->setGeometry( QRect(x1, -(int)factor, sizex, sizey));
00156 }
00157
00158 void QMain::tf_horizscroll_valuechanged(int val)
00159 {
00160
00161 int x1, y1, x2, y2;
00162 tf_canvas->geometry().getCoords(&x1, &y1, &x2, &y2);
00163
00164 float sizex = x2-x1 + 1.0f;
00165 float sizey = y2-y1 + 1.0f;
00166
00167 float factor = ((float)val)/100.0f * (sizex - sizex/3);
00168
00169 tf_canvas->setGeometry( QRect(-(int)factor, y1, sizex, sizey));
00170
00171 }
00172
00173 void QMain::watch()
00174 {
00175
00176 int _w_sizex, _w_sizey;
00177 _w_sizex = size().rwidth();
00178 _w_sizey = size().rheight();
00179
00180 if (_w_sizex != w_sizex || _w_sizey != w_sizey)
00181 {
00182
00183 int _c_sizex, _c_sizey;
00184 _c_sizex = _w_sizex - pixoffsetx_rcanvas;
00185 _c_sizey = _w_sizey - pixoffsety_rcanvas;
00186
00187 renderer_canvas->setGeometry(
00188 QRect(pixposx_rcanvas, pixposy_rcanvas, _c_sizex, _c_sizey));
00189
00190
00191 renderer_canvas->resizeGL( _c_sizex, _c_sizey );
00192
00193 w_sizex = _w_sizex;
00194 w_sizey = _w_sizey;
00195 }
00196
00197 tf_canvas->checkForLongClick();
00198
00199 }
00200 void QMain::thresholdvalL_valuechanged(int val)
00201 {
00202
00203 renderer_canvas->m_VolumeRenderer.setThresholdL((float)val/100.0f);
00204
00205 char buffer[16];
00206 sprintf_s(buffer, "%f", (float)val/100.0f);
00207 thresholdL_label->setText(buffer);
00208
00209 if(thresholdH_slider->value() < val)
00210 {
00211 thresholdvalH_valuechanged(val);
00212 thresholdH_slider->setValue(val);
00213 }
00214
00215 }
00216
00217 void QMain::thresholdvalH_valuechanged(int val)
00218 {
00219
00220 renderer_canvas->m_VolumeRenderer.setThresholdH((float)val/100.0f);
00221
00222 char buffer[16];
00223 sprintf_s(buffer, "%f", (float)val/100.0f);
00224 thresholdH_label->setText(buffer);
00225
00226 if(thresholdL_slider->value() > val)
00227 {
00228 thresholdvalL_valuechanged(val);
00229 thresholdL_slider->setValue(val);
00230 }
00231 }
00232
00233 void QMain::clipxneg_valuechanged(int val)
00234 {
00235 char buffer[16];
00236 sprintf_s(buffer, "%f", (float)val/100.0f);
00237 clipxneg_val->setText(buffer);
00238
00239 if (val > clipslider_xpos->value())
00240 {
00241 clipslider_xpos->setValue(val);
00242 clipxpos_val->setText(buffer);
00243 if(clipcb_xpos->checkState() == Qt::Checked)
00244 renderer_canvas->setClipPlane(RIGHT_LEFT, (float)val/100.0f);
00245
00246 }
00247 if(clipcb_xneg->checkState() == Qt::Checked)
00248 renderer_canvas->setClipPlane(LEFT_RIGHT, (float)val/100.0f);
00249 }
00250
00251 void QMain::clipxpos_valuechanged(int val)
00252 {
00253 char buffer[16];
00254 sprintf_s(buffer, "%f", (float)val/100.0f);
00255 clipxpos_val->setText(buffer);
00256
00257 if (val < clipslider_xneg->value())
00258 {
00259 clipslider_xneg->setValue(val);
00260 clipxneg_val->setText(buffer);
00261 if(clipcb_xneg->checkState() == Qt::Checked)
00262 renderer_canvas->setClipPlane(LEFT_RIGHT, (float)val/100.0f);
00263
00264 }
00265 if(clipcb_xpos->checkState() == Qt::Checked)
00266 renderer_canvas->setClipPlane(RIGHT_LEFT, (float)val/100.0f);
00267 }
00268
00269 void QMain::clipyneg_valuechanged(int val)
00270 {
00271 char buffer[16];
00272 sprintf_s(buffer, "%f", (float)val/100.0f);
00273 clipyneg_val->setText(buffer);
00274
00275 if (val > clipslider_ypos->value())
00276 {
00277 clipslider_ypos->setValue(val);
00278 clipypos_val->setText(buffer);
00279 if(clipcb_ypos->checkState() == Qt::Checked)
00280 renderer_canvas->setClipPlane(TOP_BOTTOM, (float)val/100.0f);
00281 }
00282 if(clipcb_yneg->checkState() == Qt::Checked)
00283 renderer_canvas->setClipPlane(BOTTOM_TOP, (float)val/100.0f);
00284 }
00285
00286 void QMain::clipypos_valuechanged(int val)
00287 {
00288 char buffer[16];
00289 sprintf_s(buffer, "%f", (float)val/100.0f);
00290 clipypos_val->setText(buffer);
00291
00292 if (val < clipslider_yneg->value())
00293 {
00294 clipslider_yneg->setValue(val);
00295 clipyneg_val->setText(buffer);
00296 if(clipcb_yneg->checkState() == Qt::Checked)
00297 renderer_canvas->setClipPlane(BOTTOM_TOP, (float)val/100.0f);
00298 }
00299 if(clipcb_ypos->checkState() == Qt::Checked)
00300 renderer_canvas->setClipPlane(TOP_BOTTOM, (float)val/100.0f);
00301 }
00302
00303 void QMain::clipzneg_valuechanged(int val)
00304 {
00305 char buffer[16];
00306 sprintf_s(buffer, "%f", (float)val/100.0f);
00307 clipzneg_val->setText(buffer);
00308
00309 if (val > clipslider_zpos->value())
00310 {
00311 clipslider_zpos->setValue(val);
00312 clipzpos_val->setText(buffer);
00313 if(clipcb_zneg->checkState() == Qt::Checked)
00314 renderer_canvas->setClipPlane(BACK_FRONT, (float)val/100.0f);
00315 }
00316 if(clipcb_zpos->checkState() == Qt::Checked)
00317 renderer_canvas->setClipPlane(FRONT_BACK, (float)val/100.0f);
00318 }
00319
00320 void QMain::clipzpos_valuechanged(int val)
00321 {
00322 char buffer[16];
00323 sprintf_s(buffer, "%f", (float)val/100.0f);
00324 clipzpos_val->setText(buffer);
00325
00326 if (val < clipslider_zneg->value())
00327 {
00328 clipslider_zneg->setValue(val);
00329 clipzneg_val->setText(buffer);
00330 if(clipcb_zpos->checkState() == Qt::Checked)
00331 renderer_canvas->setClipPlane(FRONT_BACK, (float)val/100.0f);
00332 }
00333 if(clipcb_zneg->checkState() == Qt::Checked)
00334 renderer_canvas->setClipPlane(BACK_FRONT, (float)val/100.0f);
00335 }
00336
00337 void QMain::clipcb_xneg_clicked(bool val)
00338 {
00339 if(val)
00340 {
00341 renderer_canvas->setClipPlane(LEFT_RIGHT, (float)clipslider_xneg->value()/100.0f);
00342 }
00343 else
00344 {
00345 renderer_canvas->setClipPlane(LEFT_RIGHT, 0.0f);
00346 }
00347 }
00348
00349 void QMain::clipcb_xpos_clicked(bool val)
00350 {
00351 if(val)
00352 {
00353 renderer_canvas->setClipPlane(RIGHT_LEFT, (float)clipslider_xpos->value()/100.0f);
00354 }
00355 else
00356 {
00357 renderer_canvas->setClipPlane(RIGHT_LEFT, 1.0f);
00358 }
00359 }
00360
00361 void QMain::clipcb_yneg_clicked(bool val)
00362 {
00363 if(val)
00364 {
00365 renderer_canvas->setClipPlane(BOTTOM_TOP, (float)clipslider_yneg->value()/100.0f);
00366 }
00367 else
00368 {
00369 renderer_canvas->setClipPlane(BOTTOM_TOP, 0.0f);
00370 }
00371 }
00372
00373 void QMain::clipcb_ypos_clicked(bool val)
00374 {
00375 if(val)
00376 {
00377 renderer_canvas->setClipPlane(TOP_BOTTOM, (float)clipslider_ypos->value()/100.0f);
00378 }
00379 else
00380 {
00381 renderer_canvas->setClipPlane(TOP_BOTTOM, 1.0f);
00382 }
00383 }
00384
00385 void QMain::clipcb_zneg_clicked(bool val)
00386 {
00387 if(val)
00388 {
00389 renderer_canvas->setClipPlane(BACK_FRONT, (float)clipslider_zpos->value()/100.0f);
00390 }
00391 else
00392 {
00393 renderer_canvas->setClipPlane(BACK_FRONT, 1.0f);
00394 }
00395 }
00396
00397 void QMain::clipcb_zpos_clicked(bool val)
00398 {
00399 if(val)
00400 {
00401 renderer_canvas->setClipPlane(FRONT_BACK, (float)clipslider_zneg->value()/100.0f);
00402 }
00403 else
00404 {
00405 renderer_canvas->setClipPlane(FRONT_BACK, 0.0f);
00406 }
00407 }
00408
00409 void QMain::rendermode_changed(int mod)
00410 {
00411 renderer_canvas->rendermode_changed(mod);
00412
00413 thresholdH_slider->setVisible(mod>=3);
00414 thresholdH_label->setVisible(mod>=3);
00415 thresholdL_slider->setVisible(mod>=3);
00416 thresholdL_label->setVisible(mod>=3);
00417 thresholdH_name->setVisible(mod>=3);
00418 thresholdL_name->setVisible(mod>=3);
00419
00420 }
00421
00422 void QMain::lightmode_changed(int mod)
00423 {
00424 renderer_canvas->lightmode_changed(mod);
00425 }
00426
00427 void QMain::tf_menu(int index)
00428 {
00429
00430 switch(index)
00431 {
00432 case 0:
00433 {
00434 std::cout << "Transfer function disabled" << std::endl;
00435 tf->setTitle("Transfer function (Disabled)");
00436 tf_canvas->setCursor(Qt::CursorShape::ForbiddenCursor);
00437 renderer_canvas->setApplyTFInSV(0);
00438 tf_canvas->modeChanged(0);
00439 renderer_canvas->repaint();
00440 tf_canvas->repaint();
00441 break;
00442 }
00443 case 1:
00444 {
00445 std::cout << "Transfer function 1D set" << std::endl;
00446 tf->setTitle("Transfer function (1D)");
00447 tf_canvas->setCursor(Qt::CursorShape::CrossCursor);
00448 renderer_canvas->setApplyTFInSV(1);
00449 tf_canvas->modeChanged(1);
00450 renderer_canvas->repaint();
00451 tf_canvas->repaint();
00452 break;
00453 }
00454 case 2:
00455 {
00456 std::cout << "Transfer function 2D set" << std::endl;
00457 tf->setTitle("Transfer function (2D)");
00458 tf_canvas->setCursor(Qt::CursorShape::CrossCursor);
00459 renderer_canvas->setApplyTFInSV(2);
00460 tf_canvas->modeChanged(2);
00461 renderer_canvas->repaint();
00462 tf_canvas->repaint();
00463 break;
00464 }
00465 }
00466
00467 tf_canvas->modeChanged(index);
00468 tfmode->setVisible(false);
00469 }
00470
00471
00472
00473
00474
00475 void QMain::modetab_switched(int id){
00476
00477 if(id == SLICE_VIEW_TAB)
00478 {
00479 renderer_canvas->activate_sliceview();
00480 }
00481
00482 if(id == VOL_VIEW_TAB)
00483 {
00484 renderer_canvas->activate_volview();
00485 }
00486
00487 renderer_canvas->repaint();
00488
00489 renderer_canvas->repaint();
00490
00491 };
00492
00493
00494 void QMain::slicesslider_corronal_valuechanged(int val){
00495
00496 renderer_canvas->setActiveCorronalSlice(val);
00497
00498 char buffer[16];
00499 sprintf_s(buffer, "(%d/%d)", val, voldimy);
00500 cor_slicenum->setText(buffer);
00501
00502 renderer_canvas->repaint();
00503 };
00504
00505 void QMain::slicesslider_saggital_valuechanged(int val){
00506
00507 renderer_canvas->setActiveSaggitalSlice(val);char buffer[16];
00508 sprintf_s(buffer, "(%d/%d)", val, voldimx);
00509 sag_slicenum->setText(buffer);
00510 renderer_canvas->repaint();
00511 };
00512
00513 void QMain::slicesslider_transversal_valuechanged(int val){
00514
00515 renderer_canvas->setActiveTransversalSlice(val);
00516 char buffer[16];
00517 sprintf_s(buffer, "(%d/%d)", val, voldimz);
00518 tran_slicenum->setText(buffer);
00519 renderer_canvas->repaint();
00520 };
00521
00522 void QMain::apply_tf_in_slicieviewer(bool val)
00523 {
00524 renderer_canvas->setApplyTFInSV(val);
00525 renderer_canvas->repaint();
00526 }
00527
00528 void QMain::load_data_file()
00529 {
00530
00531 std::cout << "load data" << std::endl;
00532
00533
00534 QString filename = QFileDialog::getOpenFileName(this,
00535 tr("Open Volume"), ".", tr("Volume Files (*.dat *.gdat)"));
00536
00537 std::string tmp(filename.toAscii());
00538
00539 if(tmp == "")
00540 {
00541 return;
00542 }
00543
00544 int data[4];
00545 if ( !( renderer_canvas->load_data(filename, data) ) )
00546 {
00547 std::cerr << "Error loading file" << std::endl;
00548 return;
00549 }
00550
00551 voldimx = data[0];
00552 voldimy = data[1];
00553 voldimz = data[2];
00554
00555 tf_canvas->setHistogram(renderer_canvas->getDataHistogram(), renderer_canvas->getData2DHistogram());
00556
00557 sliceslider_corronal->setEnabled(true);
00558 sliceslider_saggital->setEnabled(true);
00559 sliceslider_transversal->setEnabled(true);
00560
00561 sliceslider_saggital->setRange( 1, voldimx);
00562 sliceslider_corronal->setRange( 1, voldimy);
00563 sliceslider_transversal->setRange( 1, voldimz);
00564
00565 sliceslider_corronal->setValue(1);
00566 sliceslider_saggital->setValue(1);
00567 sliceslider_transversal->setValue(1);
00568
00569 char buffer[16];
00570 sprintf_s(buffer, "(1/%d)", voldimy);
00571 cor_slicenum->setText(QString(buffer));
00572 sprintf_s(buffer, "(1/%d)", voldimx);
00573 sag_slicenum->setText(QString(buffer));
00574 sprintf_s(buffer, "(1/%d)", voldimz);
00575 tran_slicenum->setText(QString(buffer));
00576
00577 apply_tf_in_slicieviewer(false);
00578 cb_apply_tf_to_slices->setCheckState(Qt::Unchecked);
00579 renderer_canvas->repaint();
00580
00581 this->tf_menu_no();
00582 this->tf_menu(0);
00583 tfmode->setCurrentIndex(0);
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593 std::string tmpfilename(filename.toAscii());
00594
00595 tmpfilename = tmpfilename.substr(tmpfilename.find_last_of('/') + 1, filename.length() - 1);
00596
00597 std::string test = "VisLU Volume Renderer: ";
00598 test += tmpfilename;
00599
00600 this->setWindowTitle(QApplication::translate("QMain", test.c_str() , 0, QApplication::UnicodeUTF8));
00601 }
00602
00603 void QMain::save_data_file()
00604 {
00605
00606 std::cout << "saving data" << std::endl;
00607
00608
00609 QString filename = QFileDialog::getSaveFileName(this,
00610 tr("Save Volume with Gradient"), ".", tr("Volume Files with Gradient(*.gdat)"));
00611
00612 std::string tmp(filename.toAscii());
00613
00614 if(tmp == "")
00615 {
00616 return;
00617 }
00618
00619 std::string fileend = tmp.substr(tmp.size()-5, tmp.size()-1);
00620 if(fileend.compare(".gdat") != 0)
00621 {
00622 tmp += ".gdat";
00623 }
00624
00625 if ( !( renderer_canvas->save_data(tmp) ) )
00626 {
00627 std::cerr << "Error saving file" << std::endl;
00628 return;
00629 }
00630 }
00631
00632 void QMain::load_tf_file()
00633 {
00634 QString filename = QFileDialog::getOpenFileName(this,
00635 tr("Open TransferFunction"), ".", tr("Transferfunction Files (*.btf *.bt2f)"));
00636
00637 std::string tmp(filename.toAscii());
00638
00639 if(tmp == "")
00640 {
00641 return;
00642 }
00643
00644 tf_canvas->loadTf(tmp);
00645 tf_canvas->defaultSize();
00646
00647 std::string filend = tmp.substr(tmp.find_last_of('.'), tmp.size()-1);
00648
00649 if(filend.compare(".btf") == 0)
00650 {
00651 this->tf_menu_1d();
00652 this->tf_menu(1);
00653 tfmode->setCurrentIndex(1);
00654 }
00655 else if(filend.compare(".bt2f") == 0)
00656 {
00657 this->tf_menu_2d();
00658 this->tf_menu(2);
00659 tfmode->setCurrentIndex(2);
00660 }
00661
00662
00663 renderer_canvas->repaint();
00664 }
00665
00666 void QMain::save_tf_file()
00667 {
00668 QString filename = QFileDialog::getSaveFileName(this,
00669 tr("Save TransferFunction"), ".", tr("Transferfunction Files (*.btf *.bt2f)"));
00670
00671 std::string tmp(filename.toAscii());
00672
00673 if(tmp == "")
00674 {
00675 return;
00676 }
00677
00678 tf_canvas->saveTf(tmp);
00679 }
00680
00681 void QMain::save_image()
00682 {
00683 QString filename = QFileDialog::getSaveFileName(this,
00684 tr("Save Image"), ".", tr("Image Files (*.tga)"));
00685
00686 std::string tmp(filename.toAscii());
00687
00688 if(tmp == "")
00689 {
00690 return;
00691 }
00692
00693 std::string fileend = tmp.substr(tmp.size()-4, tmp.size()-1);
00694 if(fileend.compare(".tga") != 0)
00695 {
00696 tmp += ".tga";
00697 }
00698 renderer_canvas->saveImage(tmp);
00699 }
00700
00701 void QMain::tf_menu_no()
00702 {
00703 std::cout << "Transfer function disabled" << std::endl;
00704 tf->setTitle("Transfer function (Disabled)");
00705 tf_canvas->setCursor(Qt::CursorShape::ForbiddenCursor);
00706 renderer_canvas->setApplyTFInSV(0);
00707 tf_canvas->modeChanged(0);
00708 renderer_canvas->repaint();
00709 tf_canvas->repaint();
00710 }
00711
00712 void QMain::tf_menu_1d()
00713 {
00714
00715 std::cout << "Transfer function 1D set" << std::endl;
00716 tf->setTitle("Transfer function (1D)");
00717 tf_canvas->setCursor(Qt::CursorShape::CrossCursor);
00718 renderer_canvas->setApplyTFInSV(1);
00719 renderer_canvas->repaint();
00720 tf_canvas->modeChanged(1);
00721 }
00722
00723 void QMain::tf_menu_2d()
00724 {
00725
00726
00727 std::cout << "Transfer function 2D set" << std::endl;
00728 tf->setTitle("Transfer function (2D)");
00729 tf_canvas->setCursor(Qt::CursorShape::CrossCursor);
00730 renderer_canvas->setApplyTFInSV(2);
00731 renderer_canvas->repaint();
00732 tf_canvas->modeChanged(2);
00733 }
00734
00735 void QMain::projectionMode(int id)
00736 {
00737 if(id == PERSPECTIVEPROJECTION)
00738 {
00739 renderer_canvas->setOrthoProjection(false);
00740 }
00741 else if(id == PARALLELPROJECTION)
00742 {
00743 renderer_canvas->setOrthoProjection(true);
00744 }
00745 }
00746
00747 void QMain::flipX()
00748 {
00749 renderer_canvas->flipX();
00750 }
00751
00752 void QMain::flipY()
00753 {
00754 renderer_canvas->flipY();
00755 }
00756
00757 void QMain::flipZ()
00758 {
00759 renderer_canvas->flipZ();
00760 }
00761
00762 void QMain::lightModification(bool val)
00763 {
00764 renderer_canvas->modifyLight(val);
00765 }
00766
00767 void QMain::setContourMode(bool val)
00768 {
00769 renderer_canvas->setContourMode(val);
00770 }
00771
00772 void QMain::setShadowMode(bool val)
00773 {
00774 renderer_canvas->setShadowMode(val);
00775 }