00001
00022 #include "DGVSurfacePlotVTK.h"
00023
00024 #include "vtkMergeFilter.h"
00025 #include "vtkImageThreshold.h"
00026 #include "vtkProperty2D.h"
00027 #include "vtkTextProperty.h"
00028 #include "vtkXMLImageDataWriter.h"
00029
00030 DGVSurfacePlotVTK::DGVSurfacePlotVTK(QWidget *parent) : QVTKWidget(parent)
00031 {
00032 loaded = false;
00033 generated = false;
00034 axisGenerated = false;
00035 externalData = false;
00036 verboseMode = true;
00037 consoleAssigned = false;
00038 closestTriad = true;
00039 antiAliasing = false;
00040 thresholded = false;
00041 autoScaleZ = false;
00042 logScaled = false;
00043 animating = false;
00044 pausedAnimation = false;
00045
00046 scaling = 1.0;
00047
00048 currentSlice = 0;
00049
00050 createActions();
00051 }
00052
00053 DGVSurfacePlotVTK::~DGVSurfacePlotVTK()
00054 {
00055 if(loaded)
00056 {
00057 if(!externalData)
00058 plotData->Delete();
00059 }
00060 if(generated)
00061 {
00062 geometry->Delete();
00063 warp->Delete();
00064 surfaceNormals->Delete();
00065 mapper->Delete();
00066 lod->Delete();
00067
00068
00069 renderer->Delete();
00070 renderWin->Delete();
00071
00072 if(logScaled)
00073 logData->Delete();
00074
00075
00076
00077 }
00078 if(axisGenerated)
00079 {
00080 axes->Delete();
00081 }
00082 }
00083
00084 void DGVSurfacePlotVTK::setName(QString filename)
00085 {
00086 name = filename;
00087 setWindowTitle(strippedNamePrefix());
00088 }
00089
00090 void DGVSurfacePlotVTK::setData(Array<imageType,2> data)
00091 {
00092 QString tmp1, tmp2, tmp3;
00093
00094 plotArray.resizeAndPreserve(data.shape());
00095 plotArray = data;
00096
00097 plotData = Blitz.arrayToVTKImageData(plotArray);
00098
00099 loaded = true;
00100 externalData = false;
00101 printInfo("SPlot Min: " + tmp1.setNum(Blitz.getMin()) + ", Data Max: " + tmp2.setNum(Blitz.getMax()) + ". Mean: " + tmp3.setNum(Blitz.getMean()));
00102 }
00103
00104 void DGVSurfacePlotVTK::SetInput(vtkImageData *newData)
00105 {
00106 QString tmp1, tmp2, tmp3;
00107
00108 plotData = newData;
00109 externalData = true;
00110 loaded = true;
00111 Blitz.vtkImageDataToArray(plotData,plotArray);
00112 printInfo("SPlot Min: " + tmp1.setNum(Blitz.getMin()) + ", Data Max: " + tmp2.setNum(Blitz.getMax()) + ". Mean: " + tmp3.setNum(Blitz.getMean()));
00113 }
00114
00115 void DGVSurfacePlotVTK::setScaleFactor(double factor)
00116 {
00117 if(loaded && generated)
00118 {
00119 scaling = factor;
00120 warp->SetScaleFactor(factor);
00121 warp->Update();
00122
00123 renderer->ResetCamera();
00124 renderWin->Render();
00125 }
00126 }
00127
00128 void DGVSurfacePlotVTK::setXLabel(QString text)
00129 {
00130 if(axisGenerated)
00131 {
00132 axes->SetXLabel(text.toStdString().c_str());
00133 }
00134 }
00135
00136 void DGVSurfacePlotVTK::setYLabel(QString text)
00137 {
00138 if(axisGenerated)
00139 {
00140 axes->SetYLabel(text.toStdString().c_str());
00141 }
00142 }
00143
00144 void DGVSurfacePlotVTK::setZLabel(QString text)
00145 {
00146 if(axisGenerated)
00147 {
00148 axes->SetZLabel(text.toStdString().c_str());
00149 }
00150 }
00151
00152 void DGVSurfacePlotVTK::setAxesAsClosestTriad()
00153 {
00154 if(axisGenerated)
00155 {
00156 axes->SetFlyModeToClosestTriad();
00157 }
00158 }
00159
00160 void DGVSurfacePlotVTK::setAxesAsOuterEdges()
00161 {
00162 if(axisGenerated)
00163 {
00164 axes->SetFlyModeToOuterEdges();
00165 }
00166 }
00167
00168 void DGVSurfacePlotVTK::setBackground(double r, double g, double b)
00169 {
00170 if(loaded && generated)
00171 {
00172 renderer->SetBackground(r, g, b);
00173 renderWin->Render();
00174 }
00175 }
00176
00177 bool DGVSurfacePlotVTK::saveVTI(const QString filename)
00178 {
00179 if(loaded && generated)
00180 {
00181 vtkXMLImageDataWriter* writer = vtkXMLImageDataWriter::New();
00182
00183 writer->SetInput(plotData);
00184 writer->SetFileName(filename.toStdString().c_str());
00185 writer->SetDataModeToBinary();
00186 writer->Write();
00187 writer->Delete();
00188
00189 return true;
00190 }
00191 else
00192 return false;
00193 }
00194
00195 void DGVSurfacePlotVTK::generatePlot()
00196 {
00197 if(loaded)
00198 {
00199 geometry = vtkImageDataGeometryFilter::New();
00200 warp = vtkWarpScalar::New();
00201 surfaceNormals = vtkPolyDataNormals::New();
00202 mapper = vtkPolyDataMapper::New();
00203
00204 setupSurface();
00205
00206 lod = vtkLODActor::New();
00207 renderer = vtkRenderer::New();
00208 renderWin = vtkRenderWindow::New();
00209
00210 lod->SetMapper(mapper);
00211 renderer->TwoSidedLightingOn();
00212 renderer->LightFollowCameraOn();
00213 renderer->AddActor(lod);
00214 renderer->ResetCamera();
00215 renderer->SetBackground(0.1, 0.2, 0.4);
00216 renderer->ResetCameraClippingRange();
00217 renderWin->AddRenderer(renderer);
00218 QVTKWidget::SetRenderWindow(renderWin);
00219
00220 setupEvents();
00221
00222 if(bounds[1] > minWindowSize || bounds[3] > minWindowSize)
00223 {
00224 renderWin->SetSize(bounds[1],bounds[3]);
00225 QVTKWidget::resize(bounds[1],bounds[3]);
00226 }
00227 else
00228 {
00229 renderWin->SetSize(minWindowSize,minWindowSize);
00230 QVTKWidget::resize(minWindowSize,minWindowSize);
00231 }
00232
00233 generated = true;
00234 }
00235 }
00236
00237 void DGVSurfacePlotVTK::generatePlotMergedWith(vtkImageData *image)
00238 {
00239 if(loaded)
00240 {
00241 if(!generated)
00242 {
00243 QString tmp1, tmp2, tmp3;
00244
00245 geometry = vtkImageDataGeometryFilter::New();
00246 warp = vtkWarpScalar::New();
00247 surfaceNormals = vtkPolyDataNormals::New();
00248 mapper = vtkPolyDataMapper::New();
00249 vtkMergeFilter *merge = vtkMergeFilter::New();
00250
00252
00253 plotData = image;
00254 externalData = true;
00255 geometry->SetInput(image);
00256 image->GetExtent(bounds);
00259 warp->SetInputConnection(geometry->GetOutputPort());
00260 printInfo("SPlot Min: " + tmp1.setNum(Blitz.getMin()) + ", Data Max: " + tmp2.setNum(Blitz.getMax()) + ". Mean: " + tmp3.setNum(Blitz.getMean()));
00261 scaling = 0.2*( 1.0 / ( 2.0*(Blitz.getMax()-Blitz.getMin()) / (bounds[1]+bounds[3]) ) );
00262 warp->SetScaleFactor(scaling);
00263 warp->SetNormal(0, 0, 1);
00264 warp->UseNormalOn();
00265
00266
00267 merge->SetGeometry(warp->GetOutput());
00268 merge->SetScalars(image);
00269 surfaceNormals->SetInputConnection(merge->GetOutputPort());
00270
00271 mapper->SetInputConnection(surfaceNormals->GetOutputPort());
00272 mapper->SetScalarRange(Blitz.getMin(),Blitz.getMax());
00273
00274 mapper->Update();
00275
00276 lod = vtkLODActor::New();
00277 renderer = vtkRenderer::New();
00278 renderWin = vtkRenderWindow::New();
00279
00280 lod->SetMapper(mapper);
00281 renderer->TwoSidedLightingOn();
00282 renderer->LightFollowCameraOn();
00283 renderer->AddActor(lod);
00284 renderer->ResetCamera();
00285 renderer->SetBackground(0.1, 0.2, 0.4);
00286 renderer->ResetCameraClippingRange();
00287 renderWin->AddRenderer(renderer);
00288 QVTKWidget::SetRenderWindow(renderWin);
00289
00290 setupEvents();
00291
00292 if(bounds[1] > minWindowSize || bounds[3] > minWindowSize)
00293 {
00294 renderWin->SetSize(bounds[1],bounds[3]);
00295 QVTKWidget::resize(bounds[1],bounds[3]);
00296 }
00297 else
00298 {
00299 renderWin->SetSize(minWindowSize,minWindowSize);
00300 QVTKWidget::resize(minWindowSize,minWindowSize);
00301 }
00302 generated = true;
00303 Blitz.alignmentForImages(false);
00304
00305 merge->Delete();
00306 }
00307 }
00308 }
00309
00310 void DGVSurfacePlotVTK::generateAxes()
00311 {
00312 if(loaded && generated)
00313 {
00314 double ranges[6];
00315 if(!axisGenerated)
00316 axes = vtkCubeAxesActor2D::New();
00317
00319 axes->SetInput(warp->GetOutput());
00320 axes->SetCamera(renderer->GetActiveCamera());
00321 axes->SetLabelFormat("%6.4g");
00322 if(!closestTriad)
00323 axes->SetFlyModeToOuterEdges();
00324 else
00325 axes->SetFlyModeToClosestTriad();
00326 axes->SetFontFactor(0.8);
00327
00329 axes->UseRangesOn();
00330 ranges[0] = 1.0;
00331 ranges[1] = static_cast<double>(bounds[1]+1);
00332 ranges[2] = 1.0;
00333 ranges[3] = static_cast<double>(bounds[3]+1);
00334 if(!logAct->isChecked())
00335 {
00336 ranges[4] = static_cast<double>(Blitz.getMin());
00337 ranges[5] = static_cast<double>(Blitz.getMax());
00338 }
00339 else
00340 {
00341 ranges[4] = static_cast<double>( log(1+Blitz.getMin()) );
00342 ranges[5] = static_cast<double>( log(1+Blitz.getMax()) );
00343 }
00344 axes->SetRanges(ranges);
00345
00346 renderer->AddViewProp(axes);
00347 renderer->ResetCamera();
00348 renderer->SetBackground(0.1, 0.2, 0.4);
00349 renderer->ResetCameraClippingRange();
00350 renderWin->AddRenderer(renderer);
00351 QVTKWidget::SetRenderWindow(renderWin);
00352
00353 axisGenerated = true;
00354 }
00355 }
00356
00357 void DGVSurfacePlotVTK::refresh()
00358 {
00359 if(loaded && generated)
00360 {
00361 QString tmp, tmp1, tmp2, tmp3;
00362
00363 plotData = Blitz.arrayToVTKImageData(plotArray);
00364 plotData->GetExtent(bounds);
00365 printInfo("Refreshing " + strippedNamePrefix() + ", z = " + tmp3.setNum(currentSlice) + ", " + tmp1.setNum(bounds[1]) + "x" + tmp2.setNum(bounds[3]));
00366
00367 updateDisplayData();
00368
00369 if(axisGenerated)
00370 generateAxes();
00371
00372 renderWin->Render();
00373 }
00374 }
00375
00376 void DGVSurfacePlotVTK::renameData()
00377 {
00378 bool ok;
00379
00380 QString newName = QInputDialog::getText(this, tr("Rename Data"), tr("New Name: "), QLineEdit::Normal, name, &ok);
00381
00382 if(ok)
00383 setName(newName);
00384 }
00385
00386 void DGVSurfacePlotVTK::animateFromSlices(Array<imageType,3> *data, int interval)
00387 {
00388
00389
00390 QTimer *timer = new QTimer(this);
00391
00392 volumeData = data;
00393 connect(timer, SIGNAL(timeout()), this, SLOT(updateSlice()));
00394 cerr << "Volume Array Size: " << volumeData->rows() << "x" << volumeData->cols() << "x" << volumeData->depth() << endl;
00395
00396 currentSlice = 0;
00397 setData((*volumeData)(Range::all(),Range::all(),currentSlice));
00398 currentSlice ++;
00399 generatePlot();
00400 generateAxes();
00401 animating = true;
00402
00403 timer->start(interval);
00404
00405 }
00406
00407 QString DGVSurfacePlotVTK::strippedName()
00408 {
00409 return QFileInfo(name).fileName();
00410 }
00411
00412 QString DGVSurfacePlotVTK::strippedNamePrefix()
00413 {
00414 return "SPlot: " + QFileInfo(name).fileName();
00415 }
00416
00417 void DGVSurfacePlotVTK::setConsole(DGVConsole *newConsole)
00418 {
00419 if(newConsole != NULL)
00420 {
00421 console = newConsole;
00422 consoleAssigned = true;
00423 }
00424 }
00425
00426 void DGVSurfacePlotVTK::scale()
00427 {
00428 bool ok;
00429
00430 double newScaling = QInputDialog::getDouble(this, tr("z-axis Scale Factor"),
00431 tr("Scale Factor:"), scaling, 0, 2147483647, 16, &ok);
00432 cerr << "Scaling : " << scaling << endl;
00433 if(ok)
00434 setScaleFactor(newScaling);
00435 }
00436
00437 void DGVSurfacePlotVTK::threshold()
00438 {
00439 if(loaded && generated)
00440 {
00441 thresholder = new ThresholdForm(parentWidget(),Qt::Horizontal,QwtSlider::TopScale);
00442
00443
00444 thresholder->setMax(Blitz.getMax());
00445 thresholder->setMin(Blitz.getMin());
00446
00447
00448 thresholder->setUpperValue(Blitz.getMax());
00449 connect(thresholder, SIGNAL(upperValueChanged(double)), this, SLOT(thresholdUpper(double)));
00450 connect(thresholder, SIGNAL(lowerValueChanged(double)), this, SLOT(thresholdLower(double)));
00451 thresholded = true;
00452
00453 thresholder->show();
00454 }
00455 }
00456
00457 void DGVSurfacePlotVTK::thresholdUpper(double value)
00458 {
00459 QString tmp;
00460
00461 if(loaded && generated && thresholded)
00462 {
00463 printWarning("Thresholding Upper at: " + tmp.setNum(value));
00464
00465 vtkImageThreshold *thres = vtkImageThreshold::New();
00466
00467 thres->SetInput(plotData);
00468 thres->ThresholdBetween(thresholder->getLowerValue(),value);
00469 thres->Update();
00470
00471 geometry->SetInput(thres->GetOutput());
00472 geometry->Update();
00473
00474 if(axisGenerated)
00475 generateAxes();
00476
00477 renderWin->Render();
00478 }
00479 }
00480
00481 void DGVSurfacePlotVTK::thresholdLower(double value)
00482 {
00483 QString tmp;
00484
00485 if(loaded && generated && thresholded)
00486 {
00487 printWarning("Thresholding Lower at: " + tmp.setNum(value));
00488
00489 vtkImageThreshold *thres = vtkImageThreshold::New();
00490
00491 thres->SetInput(plotData);
00492 thres->ThresholdBetween(value,thresholder->getUpperValue());
00493 thres->Update();
00494
00495 geometry->SetInput(thres->GetOutput());
00496
00497 if(axisGenerated)
00498 generateAxes();
00499
00500 renderWin->Render();
00501 }
00502 }
00503
00504 void DGVSurfacePlotVTK::xLabel()
00505 {
00506 bool ok;
00507 QString text = QInputDialog::getText(this, tr("x-axis Label"),
00508 tr("New Label:"), QLineEdit::Normal,
00509 "x", &ok);
00510 if(ok)
00511 setXLabel(text);
00512 }
00513
00514 void DGVSurfacePlotVTK::yLabel()
00515 {
00516 bool ok;
00517 QString text = QInputDialog::getText(this, tr("y-axis Label"),
00518 tr("New Label:"), QLineEdit::Normal,
00519 "y", &ok);
00520 if(ok)
00521 setYLabel(text);
00522 }
00523
00524 void DGVSurfacePlotVTK::zLabel()
00525 {
00526 bool ok;
00527 QString text = QInputDialog::getText(this, tr("z-axis Label"),
00528 tr("New Label:"), QLineEdit::Normal,
00529 "z", &ok);
00530 if(ok)
00531 setZLabel(text);
00532 }
00533
00534 void DGVSurfacePlotVTK::background()
00535 {
00536 double colours[3];
00537 bool ok1, ok2, ok3;
00538
00539 if(generated)
00540 {
00541 renderer->GetBackground(colours);
00542 double red = QInputDialog::getDouble(this, tr("New Background Colour"), tr("Red Component (0.0-1.0): "), colours[0], 0, 1, 2, &ok1);
00543 double green = QInputDialog::getDouble(this, tr("New Background Colour"), tr("Green Component (0.0-1.0): "), colours[1], 0, 1, 2, &ok2);
00544 double blue = QInputDialog::getDouble(this, tr("New Background Colour"), tr("Blue Component (0.0-1.0): "), colours[2], 0, 1, 2, &ok3);
00545
00546 if(ok1 && ok2 && ok3)
00547 setBackground(red,green,blue);
00548 }
00549 }
00550
00551 void DGVSurfacePlotVTK::axesProperties()
00552 {
00553 bool ok1, ok2, ok3, ok4;
00554
00555 if(axisGenerated)
00556 {
00557 double colours[3], factor = 1.0;
00558 vtkProperty2D *properties = axes->GetProperty();
00559 vtkTextProperty *txtProperties = axes->GetAxisTitleTextProperty();
00560
00561 properties->GetColor(colours);
00562 factor = axes->GetFontFactor();
00563 double red = QInputDialog::getDouble(this, tr("New Axis Colour"), tr("Red Component (0.0-1.0): "), colours[0], 0, 1, 2, &ok1);
00564 double green = QInputDialog::getDouble(this, tr("New Axis Colour"), tr("Green Component (0.0-1.0): "), colours[1], 0, 1, 2, &ok2);
00565 double blue = QInputDialog::getDouble(this, tr("New Axis Colour"), tr("Blue Component (0.0-1.0): "), colours[2], 0, 1, 2, &ok3);
00566 factor = QInputDialog::getDouble(this, tr("New Axis Font Factor"), tr("Font Factor: "), factor, 0, 100, 3, &ok4);
00567
00568 if(ok1 && ok2 && ok3 && ok4)
00569 {
00570 properties->SetColor(red,green,blue);
00571 txtProperties->ShadowOff();
00572 txtProperties->SetColor(red,green,blue);
00573 axes->SetFontFactor(factor);
00574 axes->SetProperty(properties);
00575 axes->SetAxisTitleTextProperty(txtProperties);
00576 axes->SetAxisLabelTextProperty(txtProperties);
00577 renderWin->Render();
00578 }
00579 }
00580 }
00581
00582 void DGVSurfacePlotVTK::updateDisplayData()
00583 {
00584 if(loaded && generated)
00585 {
00586 if(logAct->isChecked())
00587 {
00588 printWarning("Using Log Scale: This is experimental.");
00589
00590 if(!logScaled)
00591 logData = vtkImageLogarithmicScale::New();
00592
00593 logData->SetInput(plotData);
00594
00595
00596 geometry->SetInput(logData->GetOutput());
00597 geometry->Update();
00598
00599 if(autoScaleZ || !logScaled)
00600 {
00601 scaling = 1.0/( 2.0*(log(1+Blitz.getMax())-log(1+Blitz.getMin())) / (bounds[1]+bounds[3]) );
00602 setScaleFactor(scaling);
00603 }
00604
00605 logScaled = true;
00606 if(!logScaled)
00607 renderer->ResetCamera();
00608 }
00609 else
00610 {
00611 geometry->SetInput(plotData);
00612 geometry->Update();
00613 if(autoScaleZ)
00614 {
00615 scaling = 1.0/( 2.0*(Blitz.getMax()-Blitz.getMin()) / (bounds[1]+bounds[3]) );
00616 setScaleFactor(scaling);
00617 }
00618
00619 if(logScaled)
00620 {
00621 logData->Delete();
00622 scaling = 1.0/( 2.0*(Blitz.getMax()-Blitz.getMin()) / (bounds[1]+bounds[3]) );
00623 setScaleFactor(scaling);
00624 logScaled = false;
00625 renderer->ResetCamera();
00626 }
00627 }
00628 renderWin->Render();
00629 }
00630 }
00631
00632 void DGVSurfacePlotVTK::toggleAxesAsClosestTriad()
00633 {
00634 closestTriad = triadAct->isChecked();
00635 if(closestTriad)
00636 setAxesAsClosestTriad();
00637 else
00638 setAxesAsOuterEdges();
00639 }
00640
00641 void DGVSurfacePlotVTK::toggleAntiAliasing()
00642 {
00643 if(generated)
00644 {
00645 antiAliasing = antiAliasingAct->isChecked();
00646 if(antiAliasing)
00647 {
00648 renderWin->SetAAFrames(maxAASamples);
00649 renderWin->Render();
00650 }
00651 else
00652 {
00653 renderWin->SetAAFrames(0);
00654 renderWin->Render();
00655 }
00656 }
00657 }
00658
00659 void DGVSurfacePlotVTK::save()
00660 {
00661 if(loaded && generated)
00662 {
00663 QFileDialog *fileSaver = new QFileDialog(this);
00664 QSettings settings("Shakes", "DGV");
00665
00666 QString path = settings.value("recentPath").toString();
00667 QString filename = fileSaver->getSaveFileName(this,
00668 tr("Select File Name to Save"),
00669 path,
00670 tr("VTK XML Image Files (*.vti)"));
00671
00672 saveVTI(filename);
00673 }
00674 }
00675
00676 void DGVSurfacePlotVTK::setupEvents()
00677 {
00679 QVTKWidget::GetRenderWindow()->GetInteractor()->RemoveObservers(vtkCommand::RightButtonPressEvent);
00680 QVTKWidget::GetRenderWindow()->GetInteractor()->RemoveObservers(vtkCommand::RightButtonReleaseEvent);
00681 }
00682
00683 void DGVSurfacePlotVTK::setupSurface()
00684 {
00685 QString tmp, tmp1, tmp2, tmp3;
00686
00687 geometry->SetInput(plotData);
00688 geometry->Update();
00689 plotData->GetExtent(bounds);
00690 printInfo("Surface plot size: " + tmp1.setNum(bounds[1]) + "x" + tmp2.setNum(bounds[3]));
00691
00693 warp->SetInputConnection(geometry->GetOutputPort());
00694 scaling = 1.0/( 2.0*(Blitz.getMax()-Blitz.getMin()) / (bounds[1]+bounds[3]) );
00695 printInfo("Scaled z-axis by " + tmp.setNum(scaling));
00696 printInfo("SPlot Min: " + tmp1.setNum(Blitz.getMin()) + ", Data Max: " + tmp2.setNum(Blitz.getMax()) + ". Mean: " + tmp3.setNum(Blitz.getMean()));
00697 warp->SetScaleFactor(scaling);
00698 warp->SetNormal(0, 0, 1);
00699 warp->UseNormalOn();
00700
00701
00702 surfaceNormals->SetInputConnection(warp->GetOutputPort());
00703
00704 surfaceNormals->Update();
00705 mapper->SetInputConnection(surfaceNormals->GetOutputPort());
00706 mapper->SetScalarRange(Blitz.getMin(),Blitz.getMax());
00707 mapper->Update();
00708
00709 }
00710
00711 void DGVSurfacePlotVTK::updateSlice()
00712 {
00713 if(!pausedAnimation)
00714 {
00715 plotArray = (*volumeData)(Range::all(),Range::all(),currentSlice);
00716 currentSlice ++;
00717 currentSlice %= volumeData->depth();
00718 refresh();
00719 }
00720 }
00721
00722 void DGVSurfacePlotVTK::pauseAnimation()
00723 {
00724 if(pausedAnimation)
00725 pausedAnimation = false;
00726 else
00727 pausedAnimation = true;
00728 }
00729
00730 void DGVSurfacePlotVTK::contextMenuEvent(QContextMenuEvent *event)
00731 {
00732 contextMenu = new QMenu(this);
00733
00735 scaleAct = contextMenu->addAction(tr("&Scale Factor"));
00736 scaleAct->setShortcut(tr("Ctrl+s"));
00737 connect(scaleAct, SIGNAL(triggered()), this, SLOT(scale()));
00738 thresholdAct = contextMenu->addAction(tr("&Threshold"));
00739 thresholdAct->setShortcut(tr("Ctrl+t"));
00740 thresholdAct->setDisabled(true);
00741 connect(thresholdAct, SIGNAL(triggered()), this, SLOT(threshold()));
00742 contextMenu->addSeparator()->setText("Axes");
00744 xLabelAct = contextMenu->addAction(tr("Set &x Label"));
00745 xLabelAct->setShortcut(tr("Ctrl+x"));
00746 connect(xLabelAct, SIGNAL(triggered()), this, SLOT(xLabel()));
00747 yLabelAct = contextMenu->addAction(tr("Set &y Label"));
00748 yLabelAct->setShortcut(tr("Ctrl+y"));
00749 connect(yLabelAct, SIGNAL(triggered()), this, SLOT(yLabel()));
00750 zLabelAct = contextMenu->addAction(tr("Set &z Label"));
00751 zLabelAct->setShortcut(tr("Ctrl+z"));
00752 connect(zLabelAct, SIGNAL(triggered()), this, SLOT(zLabel()));
00753 backgroundAct = contextMenu->addAction(tr("Set &Background Colour"));
00754 backgroundAct->setShortcut(tr("Ctrl+b"));
00755 connect(backgroundAct, SIGNAL(triggered()), this, SLOT(background()));
00756 axesAct = contextMenu->addAction(tr("Set &Axes Colour/Font"));
00757 axesAct->setShortcut(tr("Ctrl+a"));
00758 connect(axesAct, SIGNAL(triggered()), this, SLOT(axesProperties()));
00759 contextMenu->addAction(logAct);
00761 triadAct = contextMenu->addAction(tr("Axes as Closest Triad"));
00762 triadAct->setCheckable(true);
00763 triadAct->setChecked(closestTriad);
00764 connect(triadAct, SIGNAL(triggered()), this, SLOT(toggleAxesAsClosestTriad()));
00765 antiAliasingAct = contextMenu->addAction(tr("Anti-Aliasing"));
00766 antiAliasingAct->setCheckable(true);
00767 antiAliasingAct->setChecked(antiAliasing);
00768 connect(antiAliasingAct, SIGNAL(triggered()), this, SLOT(toggleAntiAliasing()));
00769 contextMenu->addSeparator()->setText(tr("Animation"));
00771 startAct = contextMenu->addAction(tr("&Restart"));
00772 startAct->setDisabled(!animating);
00773 connect(startAct, SIGNAL(triggered()), this, SLOT(firstSlice()));
00774 pauseAct = contextMenu->addAction(tr("&Pause/Unpause"));
00775 pauseAct->setDisabled(!animating);
00776 connect(pauseAct, SIGNAL(triggered()), this, SLOT(pauseAnimation()));
00777 contextMenu->addSeparator();
00780 saveAct = contextMenu->addAction(tr("Save Surface Data..."));
00781 saveAct->setShortcut(tr("Ctrl+s"));
00782 connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
00783 refreshAct = contextMenu->addAction(tr("Re&fresh"));
00784 connect(refreshAct, SIGNAL(triggered()), this, SLOT(refresh()));
00785 renameAct = contextMenu->addAction(tr("Rename"));
00786 renameAct->setShortcut(tr("Ctrl+r"));
00787 connect(renameAct, SIGNAL(triggered()), this, SLOT(renameData()));
00788 closeAct = contextMenu->addAction(tr("Close"));
00789 closeAct->setShortcut(tr("Ctrl+q"));
00790 connect(closeAct, SIGNAL(triggered()), this, SLOT(close()));
00791
00792 contextMenu->exec(event->globalPos());
00793 }
00794
00795 void DGVSurfacePlotVTK::printError(QString msg)
00796 {
00797 if(verboseMode)
00798 {
00799 if(consoleAssigned)
00800 {
00801 console->printError(msg);
00802 }
00803 else
00804 cerr << msg.toStdString() << endl;
00805 }
00806 }
00807
00808 void DGVSurfacePlotVTK::printWarning(QString msg)
00809 {
00810 if(verboseMode)
00811 {
00812 if(consoleAssigned)
00813 {
00814 console->printWarning(msg);
00815 }
00816 else
00817 cerr << msg.toStdString() << endl;
00818 }
00819 }
00820
00821 void DGVSurfacePlotVTK::printInfo(QString msg)
00822 {
00823 if(verboseMode)
00824 {
00825 if(consoleAssigned)
00826 {
00827 console->printInfo(msg);
00828 }
00829 else
00830 cerr << msg.toStdString() << endl;
00831 }
00832 }
00833
00834 void DGVSurfacePlotVTK::createActions()
00835 {
00836 logAct = new QAction(this);
00837 logAct->setText(QApplication::translate("Plot", "&Log Scale", 0, QApplication::UnicodeUTF8));
00838 logAct->setShortcut(tr("Ctrl+l"));
00839 logAct->setCheckable(true);
00840 }
00841
00842 void DGVSurfacePlotVTK::createConnections()
00843 {
00844 connect(logAct, SIGNAL(triggered()), this, SLOT(refresh()));
00845 }