18 #include "milxQtMain.h" 22 #include <vtkWindowToImageFilter.h> 23 #include <vtkRendererCollection.h> 24 #include <vtkCamera.h> 25 #include <vtkLookupTable.h> 26 #include <vtkImageBlend.h> 27 #include <vtkTensor.h> 28 #include <vtkMultiThreader.h> 31 #include "milxQtFile.h" 32 #include "milxQtPlot.h" 35 #include "milxQtAboutForm.h" 36 #include "milxQtPreferencesForm.h" 66 Connector = vtkSmartPointer<vtkEventQtSlotConnect>::New();
82 actionConsole->setIcon(QIcon(
":/resources/toolbar/console.png"));
84 QObject::connect(
console->dockWidget(), SIGNAL(dockLocationChanged(Qt::DockWidgetArea)),
console, SLOT(setDockDefaultArea(Qt::DockWidgetArea)));
107 setAcceptDrops(
true);
109 setToolTip(
"<p style='white-space:pre'>Welcome to SMILX. Use the <b>context menu</b> (right click) for all operations.\n Load data from the <b>File Menu</b>.</p>");
115 itk::MultiThreader::SetGlobalDefaultNumberOfThreads(
maxProcessors);
116 vtkMultiThreader::SetGlobalDefaultNumberOfThreads(
maxProcessors);
119 printInfo(
"--------------------------------------------------------");
120 printInfo(
"sMILX Visualisation Tool for Medical Imaging");
122 printInfo(
"University of Queensland, Australia.");
123 printInfo(
"Australian e-Health Research Centre, CSIRO.");
124 printInfo(
"SMILI Version: " + QString::number(milx::Version));
125 printInfo(
"Application Version: " + QString::number(milxQtVersion));
127 printInfo(
"--------------------------------------------------------\n");
136 foreach (QPointer<milxQtPluginInterface> loadedPlugin,
plugins)
138 if(loadedPlugin->isThreaded() && loadedPlugin->isRunning())
139 loadedPlugin->quit();
154 if(qobject_cast<QWorkspace *>(
workspaces->currentWidget())->activeWindow() == 0)
177 return "Unrecognised Display";
183 if(qobject_cast<QWorkspace *>(
workspaces->currentWidget())->activeWindow() == 0)
208 return webViewer->windowTitle();
211 return "Unrecognised Display";
217 QWorkspace *tmpPtr =
new QWorkspace;
220 tmpPtr->setAttribute(Qt::WA_DeleteOnClose);
228 qobject_cast<QWorkspace *>(
workspaces->currentWidget())->addWindow(rnd);
234 connect(rnd, SIGNAL(nameChanged(
const QString &)),
this, SLOT(
setTabName(
const QString &)));
236 connect(rnd, SIGNAL(
done(
int)),
this, SLOT(
done(
int)));
281 if(qobject_cast<milxQtRenderWindow *>(win) == 0)
297 if(QWidget *activeWin = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->activeWindow())
298 return qobject_cast<milxQtRenderWindow *>(activeWin);
304 if(qobject_cast<milxQtImage *>(win) == 0)
320 if(QWidget *activeWin = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->activeWindow())
321 return qobject_cast<milxQtImage *>(activeWin);
327 if(qobject_cast<milxQtModel *>(win) == 0)
343 if(QWidget *activeWin = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->activeWindow())
344 return qobject_cast<milxQtModel *>(activeWin);
350 if(qobject_cast<milxQtPlot *>(win) == 0)
366 if(QWidget *activeWin = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->activeWindow())
367 return qobject_cast<milxQtPlot *>(activeWin);
373 if(qobject_cast<milxQtUnifiedWindow *>(win) == 0)
389 if(QWidget *activeWin = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->activeWindow())
390 return qobject_cast<milxQtUnifiedWindow *>(activeWin);
404 if(QWidget *activeWin = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->activeWindow())
405 return qobject_cast<QWebView *>(activeWin);
419 QFileDialog *fileOpener =
new QFileDialog(
this);
420 QSettings settings(
"Shekhar Chandra",
"milxQt");
423 QString exts =
"Supported Files (" +
openSupport +
");;";
424 QString path = settings.value(
"recentPath").toString();
426 exts += openExts.c_str();
428 foreach (QPointer<milxQtPluginInterface> loadedPlugin,
plugins)
430 if(loadedPlugin->openFileSupport() !=
"")
433 exts += loadedPlugin->openFileSupport();
437 QStringList filenames = fileOpener->getOpenFileNames(
this,
438 tr(
"Select File(s) to Open"),
440 tr(exts.toStdString().c_str()) );
442 if(filenames.isEmpty())
453 QStringList filenames;
484 vtkPolyDataCollection* modelCollection = vtkPolyDataCollection::New();
486 if(!file->openModelCollection(modelCollection, filenames))
492 display(modelCollection, filenames);
501 printDebug(
"Supported Image formats: " + reader->supportedImageFormats());
502 bool success = reader->openImageSeries(img);
508 img->generateImage();
513 printError(
"An error was encountered in reading the image series");
518 QAction *action = qobject_cast<QAction *>(sender());
520 loadFile(action->data().toString());
525 for(
int j = 0; j < filenames.size(); j ++)
532 bool success =
false;
534 if (filename.isEmpty())
538 QString nativeFilename = QDir::toNativeSeparators(filename);
541 printDebug(
"Check Plugins if they can open the file.");
542 foreach (QPointer<milxQtPluginInterface> loadedPlugin,
plugins)
544 if(!loadedPlugin->hasOpenSupport())
547 QStringList extensionsList = loadedPlugin->openExtensions();
549 foreach (QString extension, extensionsList)
552 if(filename.contains(extension, Qt::CaseInsensitive))
554 loadedPlugin->setFileName(filename);
555 if(loadedPlugin->isThreaded())
557 printInfo(
"Using threaded opening for plugin.");
558 loadedPlugin->preStartTasks();
559 loadedPlugin->start();
565 printInfo(
"Using standard opening for plugin.");
566 loadedPlugin->open(nativeFilename);
569 QPointer<milxQtRenderWindow> renWin = loadedPlugin->genericResult();
572 printInfo(
"Loading Plugin Generic Result");
573 if(renWin->getName() ==
"")
574 renWin->setName(filename);
576 renWin->generateRender();
581 QPointer<milxQtModel> model = loadedPlugin->modelResult();
584 printInfo(
"Loading Plugin Model Result");
585 if(model->getName() ==
"")
586 model->setName(filename);
588 model->generateModel();
593 QPointer<milxQtImage> image = loadedPlugin->imageResult();
596 printInfo(
"Loading Plugin Image Result");
597 if(image->getName() ==
"")
598 image->setName(filename);
600 image->generateImage();
610 if(success && !loadedPlugin->isThreaded())
612 printInfo(
"Loaded File via Plugin, now Updating");
613 loadedPlugin->update();
620 printDebug(
"File format not supported by plugins, load using standard methods.");
621 if(filename.contains(
".vtp", Qt::CaseInsensitive) || filename.contains(
".vtk", Qt::CaseInsensitive)
622 || filename.contains(
".ply", Qt::CaseInsensitive) || filename.contains(
".obj", Qt::CaseInsensitive) || filename.contains(
".stl", Qt::CaseInsensitive))
626 success = reader->openModel(nativeFilename, model);
632 model->generateModel();
636 else if(filename.contains(
".csv", Qt::CaseInsensitive) || filename.contains(
".dat", Qt::CaseInsensitive) || filename.contains(
".txt", Qt::CaseInsensitive))
640 vtkSmartPointer<vtkTable> table;
644 int surfaceRet = QMessageBox::No, dimensionRet = QMessageBox::No;
645 int xCol = 0, yCol = 1, zCol = 2;
646 if(table->GetNumberOfColumns() > 2)
649 msgBox.setText(
"Choose Plot Type");
650 msgBox.setInformativeText(
"Do you want a surface plot instead of a scatter plot?");
651 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
652 msgBox.setDefaultButton(QMessageBox::No);
653 surfaceRet = msgBox.exec();
655 if(surfaceRet == QMessageBox::No)
657 msgBox.setText(
"Choose Plot Dimension");
658 msgBox.setInformativeText(
"Do you want a 3D scatter plot?");
659 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
660 msgBox.setDefaultButton(QMessageBox::No);
661 dimensionRet = msgBox.exec();
663 bool ok1 =
true, ok2 =
true, ok3 =
true;
664 xCol = QInputDialog::getInt(
this, tr(
"Please Provide column number for x axis"),
665 tr(
"Column:"), 0, 0, numeric_limits<int>::max(), 1, &ok1);
666 yCol = QInputDialog::getInt(
this, tr(
"Please Provide column number for y axis"),
667 tr(
"Column:"), 1, 0, numeric_limits<int>::max(), 1, &ok2);
669 if(dimensionRet == QMessageBox::Yes)
671 zCol = QInputDialog::getInt(
this, tr(
"Please Provide column number for z axis"),
672 tr(
"Column:"), 2, 0, numeric_limits<int>::max(), 1, &ok3);
675 if(!ok1 || !ok2 || !ok3)
678 if(dimensionRet == QMessageBox::No)
679 plot->setPlotType2D(xCol, yCol);
681 plot->setPlotType3D(xCol, yCol, zCol);
685 plot->setPlotTypeSurface();
695 plot->setName(filename);
697 plot->SetSource(table);
698 plot->generatePlot();
706 printDebug(
"Supported Image formats: " + reader->supportedImageFormats());
707 success = reader->openImage(nativeFilename, img);
709 printInfo(
"Image Pixel Type: " + reader->getPixelType());
710 printInfo(
"Image Component Type: " + reader->getComponentType());
711 printInfo(
"Image Number of Components: " + QString::number(reader->getNumberOfComponents()));
712 printInfo(
"Image Dimensions: " + QString::number(reader->getNumberOfDimensions()));
716 img->setName(filename);
718 img->generateImage();
723 printError(
"File format didn't appear to be supported. Check the file or add plugins for support.");
734 QSettings settings(
"Shekhar Chandra",
"milxQt");
735 QString path = settings.value(
"recentPath").toString();
736 QWidget *activeWindow = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->activeWindow();
738 bool pluginSave =
false, success =
false;
744 filename = QDir::toNativeSeparators(filename);
746 QFileDialog *fileSaver =
new QFileDialog(
this);
749 foreach (QPointer<milxQtPluginInterface> loadedPlugin,
plugins)
751 if(!loadedPlugin->hasSaveSupport())
754 if(loadedPlugin->isPluginWindow(activeWindow))
756 printInfo(
"Window is a " + loadedPlugin->name() +
" plugin window");
757 if(filename.isEmpty())
759 filename = fileSaver->getSaveFileName(
this,
760 tr(
"Select File Name to Save"),
762 tr(loadedPlugin->saveFileSupport().toStdString().c_str()));
765 if(!filename.isEmpty())
767 loadedPlugin->save(filename);
778 printDebug(
"Saving Image with Built-in Capability");
781 if(filename.isEmpty())
783 filename = fileSaver->getSaveFileName(
this,
784 tr(
"Select File Name to Save"),
786 tr(saveExtsForImages.c_str()));
789 if(!filename.isEmpty())
799 printDebug(
"Saving Plot with Built-in Capability");
802 if(filename.isEmpty())
804 filename = fileSaver->getSaveFileName(
this,
805 tr(
"Select File Name to Save"),
807 tr(saveOtherExts.c_str()));
810 if(!filename.isEmpty())
818 printDebug(
"Saving Model with Built-in Capability");
821 if(filename.isEmpty())
823 filename = fileSaver->getSaveFileName(
this,
824 tr(
"Select File Name to Save"),
826 tr(saveExtsForModels.c_str()));
829 if(!filename.isEmpty())
833 writer->
saveModel(filename, model,
false);
853 QSettings settings(
"Shekhar Chandra",
"milxQt");
854 QString path = settings.value(
"recentPath").toString();
855 QWidget *activeWindow = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->activeWindow();
858 filename = QDir::toNativeSeparators(filename);
864 QFileDialog *fileSaver =
new QFileDialog(
this);
865 vtkSmartPointer<vtkWindowToImageFilter> windowToImage = vtkSmartPointer<vtkWindowToImageFilter>::New();
866 QVTKWidget* windowVTK = qobject_cast<QVTKWidget *>(activeWindow);
875 windowVTK->GetRenderWindow()->Render();
877 windowToImage->SetInput(windowVTK->GetRenderWindow());
880 windowToImage->ReadFrontBufferOff();
881 windowToImage->Update();
883 if(filename.isEmpty())
885 filename = fileSaver->getSaveFileName(
this,
886 tr(
"Select File Name to Save"),
888 tr(saveExtsForScreens.c_str()));
892 windowVTK->GetRenderWindow()->Render();
896 windowToImage->GetOutput()->GetExtent(extent);
897 printDebug(
"Screenshot Size: " + QString::number(extent[1]-extent[0]) +
", " + QString::number(extent[3]-extent[2]) +
", " + QString::number(extent[5]-extent[4]));
898 bool success = writer->saveImage(filename, windowToImage->GetOutput());
901 windowVTK->GetRenderWindow()->Render();
905 printError(
"Unable to save screenshot. Ignoring.");
918 if(fromWindow == NULL)
937 QWorkspace *tmpWorkspace = qobject_cast<QWorkspace *>(
workspaces->widget(index));
939 tmpWorkspace->closeAllWindows();
940 tmpWorkspace->close();
944 if(index > 0 &&
workspaces->currentIndex() == index)
954 QWorkspace *wrkSpc = qobject_cast<QWorkspace *>(
workspaces->currentWidget());
955 QWidgetList windows = wrkSpc->windowList();
956 if (windows.count() < 2) {
960 int wHeight = wrkSpc->height() / windows.count();
962 foreach(QWidget *widget, windows)
964 widget->parentWidget()->resize(wrkSpc->width(), wHeight);
965 widget->parentWidget()->move(0, y);
972 QWorkspace *wrkSpc = qobject_cast<QWorkspace *>(
workspaces->currentWidget());
973 QWidgetList windows = wrkSpc->windowList();
974 if (windows.count() < 2) {
978 int wWidth = wrkSpc->width() / windows.count();
980 foreach(QWidget *widget, windows)
982 widget->parentWidget()->resize(wWidth, wrkSpc->height());
983 widget->parentWidget()->move(x, 0);
992 QFile file(
":/resources/smilx_doc/home.html");
993 QWebView *view =
new QWebView(
this);
994 if(file.open(QIODevice::ReadOnly))
995 view->setHtml(file.readAll());
996 view->setWindowTitle(
"sMILX Help");
997 qobject_cast<QWorkspace *>(
workspaces->currentWidget())->addWindow(view);
1001 QToolBar *toolBar = addToolBar(QObject::tr(
"Navigation"));
1002 toolBar->addAction(view->pageAction(QWebPage::Back));
1003 toolBar->addAction(view->pageAction(QWebPage::Forward));
1004 toolBar->addAction(view->pageAction(QWebPage::Reload));
1005 toolBar->addAction(view->pageAction(QWebPage::Stop));
1013 milxQtPreferencesForm prefsForm(
this);
1021 QPixmap pixmap(
":resources/controls_splash.png");
1022 QSplashScreen *controlsSplash =
new QSplashScreen(
this);
1023 controlsSplash->setPixmap(pixmap);
1024 controlsSplash->setMask(pixmap.mask());
1025 controlsSplash->show();
1027 qApp->processEvents();
1032 milxQtAboutForm aboutForm(
this);
1069 newRender->setToolTip(
"<p style='white-space:pre'>VTK Image Viewer 2 Keys - <b>f:</b> Move to, <b>r:</b> Reset, <b>Shift+r:</b> Reset Camera,\n<b>Shift+Mouse1:</b> Translate, <b>Shift+Ctrl+Mouse1:</b> Zoom</p>");
1080 connect(
this, SIGNAL(
updatedImportFromMenu(QMenu*)), newRender, SLOT(createCustomConnections(QMenu*)));
1081 connect(
this, SIGNAL(
updatedImportFromMenu(QActionGroup*)), newRender, SLOT(setCustomActionGroup(QActionGroup*)));
1082 connect(newRender, SIGNAL(imageAvailable(vtkImageData*, QString )),
this, SLOT(
display(vtkImageData*, QString )));
1083 connect(newRender, SIGNAL(modelAvailable(vtkPolyData*, QString )),
this, SLOT(
display(vtkPolyData*, QString )));
1084 Connector->Connect(newRender->GetRenderWindow(),
1085 vtkCommand::ModifiedEvent,
1106 const QString filename = newImage->
getName();
1107 const size_t numberOfWindows = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->windowList().size();
1119 int ret = QMessageBox::Yes;
1123 msgBox.setText(
"Linked Views mode detected and has to be disabled for multi-view.");
1124 msgBox.setInformativeText(
"Do you want to disable link views and continue?");
1125 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
1126 msgBox.setDefaultButton(QMessageBox::Yes);
1127 ret = msgBox.exec();
1129 if (ret == QMessageBox::No)
1139 newImage->viewToAxial();
1143 QPointer<milxQtImage> imgSagittal =
new milxQtImage;
1145 imgSagittal->setNamePrefix(
"Sagittal: ");
1146 imgSagittal->setName(filename);
1147 imgSagittal->setConsole(
console);
1148 imgSagittal->disableDefaultView();
1149 imgSagittal->generateImage();
1151 imgSagittal->viewToSagittal();
1155 QPointer<milxQtImage> imgCoronal =
new milxQtImage;
1157 imgCoronal->setNamePrefix(
"Coronal: ");
1158 imgCoronal->setName(filename);
1159 imgCoronal->setConsole(
console);
1160 imgCoronal->disableDefaultView();
1161 imgCoronal->generateImage();
1163 imgCoronal->viewToCoronal();
1169 slicesView->setName(filename);
1170 slicesView->setConsole(
console);
1172 slicesView->addImageActor(imgSagittal->GetImageActor(), imgSagittal->getTransformMatrix());
1173 slicesView->addImageActor(imgCoronal->GetImageActor(), imgCoronal->getTransformMatrix());
1175 slicesView->generateRender();
1178 newImage->
trackView(imgSagittal, AXIAL);
1180 imgSagittal->trackView(newImage, SAGITTAL);
1181 imgSagittal->trackView(imgCoronal, SAGITTAL);
1182 imgCoronal->trackView(newImage, CORONAL);
1183 imgCoronal->trackView(imgSagittal, CORONAL);
1187 connect(newImage, SIGNAL(modified(vtkSmartPointer<vtkImageActor> )), slicesView, SLOT(updateImageActor(vtkSmartPointer<vtkImageActor>)));
1188 connect(imgSagittal, SIGNAL(modified(vtkSmartPointer<vtkImageActor> )), slicesView, SLOT(updateImageActor(vtkSmartPointer<vtkImageActor>)));
1189 connect(imgCoronal, SIGNAL(modified(vtkSmartPointer<vtkImageActor> )), slicesView, SLOT(updateImageActor(vtkSmartPointer<vtkImageActor>)));
1191 connect(newImage, SIGNAL(modified(QPointer<milxQtImage> )), imgSagittal, SLOT(updateDisplay(QPointer<milxQtImage>)));
1192 connect(newImage, SIGNAL(modified(QPointer<milxQtImage> )), imgCoronal, SLOT(updateDisplay(QPointer<milxQtImage>)));
1193 connect(imgSagittal, SIGNAL(modified(QPointer<milxQtImage> )), newImage, SLOT(updateDisplay(QPointer<milxQtImage>)));
1194 connect(imgSagittal, SIGNAL(modified(QPointer<milxQtImage> )), imgCoronal, SLOT(updateDisplay(QPointer<milxQtImage>)));
1195 connect(imgCoronal, SIGNAL(modified(QPointer<milxQtImage> )), newImage, SLOT(updateDisplay(QPointer<milxQtImage>)));
1196 connect(imgCoronal, SIGNAL(modified(QPointer<milxQtImage> )), imgSagittal, SLOT(updateDisplay(QPointer<milxQtImage>)));
1209 printError(
"Image not loaded properly. Aborting Display.");
1215 newImage->setToolTip(
"<p style='white-space:pre'>VTK Image Viewer 2 Keys - <b>f:</b> Move to, <b>r:</b> Reset, <b>Shift+r:</b> Reset Camera,\n<b>Shift+Mouse1:</b> Translate, <b>Shift+Ctrl+Mouse1:</b> Zoom</p>");
1233 connect(newImage, SIGNAL(
imageToSurface(vtkSmartPointer<vtkImageData>,
const float) ),
this, SLOT(
imageToSurface(vtkSmartPointer<vtkImageData>,
const float) ));
1236 connect(newImage, SIGNAL(
imageToVectorField(vectorImageType::Pointer, floatImageType::Pointer,
int,
float) ),
this, SLOT(
imageToVectorField(vectorImageType::Pointer, floatImageType::Pointer,
int,
float) ));
1237 connect(newImage, SIGNAL(
imageToTensorField(vectorImageType::Pointer, floatImageType::Pointer,
int,
float) ),
this, SLOT(
imageToTensorField(vectorImageType::Pointer, floatImageType::Pointer,
int,
float) ));
1238 connect(newImage, SIGNAL(
imageToStreamLines(vectorImageType::Pointer, floatImageType::Pointer) ),
this, SLOT(
imageToStreamLines(vectorImageType::Pointer, floatImageType::Pointer) ));
1239 connect(newImage, SIGNAL(
imageToVolume(vtkSmartPointer<vtkImageData>,
bool) ),
this, SLOT(
imageToVolume(vtkSmartPointer<vtkImageData>,
bool) ));
1240 connect(newImage, SIGNAL(
imageToPlot(vtkSmartPointer<vtkImageData>,
int) ),
this, SLOT(
imageToPlot(vtkSmartPointer<vtkImageData>,
int) ));
1241 connect(newImage, SIGNAL(
tableToPlot(vtkSmartPointer<vtkTable>, QString) ),
this, SLOT(
tableToPlot(vtkSmartPointer<vtkTable>, QString) ));
1242 connect(newImage, SIGNAL(imageAvailable(vtkImageData*, QString )),
this, SLOT(
display(vtkImageData*, QString )));
1243 connect(newImage, SIGNAL(modelAvailable(vtkPolyData*, QString )),
this, SLOT(
display(vtkPolyData*, QString )));
1244 connect(newImage, SIGNAL(closing(QWidget *)),
this, SLOT(
cleanUpOnClose(QWidget *)));
1245 connect(
this, SIGNAL(
updatedImportFromMenu(QMenu*)), newImage, SLOT(createCustomConnections(QMenu*)));
1246 connect(
this, SIGNAL(
updatedImportFromMenu(QActionGroup*)), newImage, SLOT(setCustomActionGroup(QActionGroup*)));
1247 Connector->Connect(newImage->GetRenderWindow(),
1248 vtkCommand::ModifiedEvent,
1263 newImage->disableInterpolateDisplay();
1265 newImage->disableApplyOrientDisplay();
1282 image->SetInput(newImage);
1284 image->generateImage();
1292 printError(
"Model/Surface not loaded properly. Aborting Display.");
1298 newModel->setToolTip(
"<p style='white-space:pre'>VTK Model Viewer 2 Keys - <b>f:</b> Move to, <b>r:</b> Reset, <b>Shift+r:</b> Reset Camera,\n<b>Shift+Mouse1:</b> Translate, <b>Shift+Ctrl+Mouse1:</b> Zoom</p>");
1315 connect(
this, SIGNAL(
updatedImportFromMenu(QMenu*)), newModel, SLOT(createCustomConnections(QMenu*)));
1316 connect(
this, SIGNAL(
updatedImportFromMenu(QActionGroup*)), newModel, SLOT(setCustomActionGroup(QActionGroup*)));
1317 connect(newModel, SIGNAL(imageAvailable(vtkImageData*, QString )),
this, SLOT(
display(vtkImageData*, QString )));
1318 connect(newModel, SIGNAL(modelAvailable(vtkPolyData*, QString )),
this, SLOT(
display(vtkPolyData*, QString )));
1319 connect(newModel, SIGNAL(closing(QWidget *)),
this, SLOT(
cleanUpOnClose(QWidget *)));
1320 Connector->Connect(newModel->GetRenderWindow(),
1321 vtkCommand::ModifiedEvent,
1327 connect(newModel, SIGNAL( surfaceToImage(vtkSmartPointer<vtkPolyData>) ),
this, SLOT(
voxeliseSurface(vtkSmartPointer<vtkPolyData>) ));
1341 newModel->enableInterpolateDisplay();
1355 mdl->SetInput(newModel);
1356 mdl->generateModel();
1363 newUni->setToolTip(
"<p style='white-space:pre'>VTK Model Viewer 2 Keys - <b>f:</b> Move to, <b>r:</b> Reset, <b>Shift+r:</b> Reset Camera,\n<b>Shift+Mouse1:</b> Translate, <b>Shift+Ctrl+Mouse1:</b> Zoom</p>");
1384 bool success =
false;
1385 size_t n = modelCollection->GetNumberOfItems();
1388 foreach (QPointer<milxQtPluginInterface> loadedPlugin,
plugins)
1390 if(loadedPlugin->hasCollectionSupport())
1392 printInfo(loadedPlugin->name() +
" plugin has collection support.");
1395 msgBox.setText(loadedPlugin->name() +
" plugin has collection support.");
1396 msgBox.setInformativeText(
"Do you want to load the collection with this plugin?");
1397 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::NoToAll);
1398 msgBox.setDefaultButton(QMessageBox::Yes);
1399 int ret = msgBox.exec();
1401 if(ret == QMessageBox::No)
1403 else if(ret == QMessageBox::NoToAll)
1406 loadedPlugin->SetInputCollection(modelCollection, filenames);
1408 QPointer<milxQtRenderWindow> renWin = loadedPlugin->genericResult();
1411 renWin->setName(
"Collection");
1412 renWin->generateRender();
1417 QPointer<milxQtModel> model = loadedPlugin->modelResult();
1420 model->setName(
"Collection Model");
1421 model->generateModel();
1426 QPointer<milxQtImage> image = loadedPlugin->imageResult();
1429 image->setName(
"Collection Image");
1430 image->generateImage();
1438 loadedPlugin->update();
1447 vtkSmartPointer<vtkLookupTable> lookupTable = vtkSmartPointer<vtkLookupTable>::New();
1448 lookupTable->SetTableRange(0.0, n+1);
1449 lookupTable->Build();
1452 QList< QPointer<milxQtModel> > alignedModels;
1453 modelCollection->InitTraversal();
1454 for(
size_t j = 0; j < n; j ++)
1459 lookupTable->GetColor(j, colour);
1462 QPointer<milxQtModel> alignedModel =
new milxQtModel;
1463 alignedModel->
setName( QString::number(j) );
1464 alignedModel->setConsole(
console);
1467 alignedModel->SetInput(modelCollection->GetNextItem());
1468 alignedModel->generatePoints(colour[0], colour[2], colour[1]);
1469 alignedModel->SetOpacity(0.2);
1471 alignedModels.append(alignedModel);
1473 allModels->AddActor(alignedModel->GetActor());
1478 msgBox.setText(
"Open the mean data file?");
1479 msgBox.setInformativeText(
"Would you like to open the mean file?\nThis will be shown as a solid model.");
1480 msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
1481 msgBox.setDefaultButton(QMessageBox::Ok);
1482 int ret = msgBox.exec();
1484 if(ret == QMessageBox::Ok)
1490 allModels->setName(
"Collection");
1491 allModels->setConsole(
console);
1492 allModels->generateRender();
1500 QFileInfo fi(fileName);
1502 if(!fileName.isEmpty())
1503 setWindowTitle(tr(
"%1 - %2").arg(
strippedName(fileName)).arg(tr(
"milxQt")));
1505 setWindowTitle(tr(
"sMILX"));
1507 QSettings settings(
"Shekhar Chandra",
"milxQt");
1508 QStringList files = settings.value(
"recentFileList").toStringList();
1509 files.removeAll(fileName);
1510 files.prepend(fileName);
1511 while (files.size() > MaxRecentFiles)
1514 settings.setValue(
"recentFileList", files);
1515 settings.setValue(
"recentPath",fi.absolutePath());
1517 foreach (QWidget *widget, QApplication::topLevelWidgets())
1528 QSettings settings(
"Shekhar Chandra",
"milxQt");
1529 QStringList files = settings.value(
"recentFileList").toStringList();
1531 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1533 for (
int i = 0; i < numRecentFiles; ++i)
1535 QString text = tr(
"&%1 %2").arg(i + 1).arg(
strippedName(files[i]));
1540 actionsRecentFile[i]->setShortcut(
"Ctrl+" + text.setNum( (i+1)%numRecentFiles ));
1543 for (
int j = numRecentFiles; j < MaxRecentFiles; ++j)
1556 menuWindows->addSeparator()->setText(tr(
"Docked Windows"));
1561 menuWindows->addSeparator()->setText(tr(
"Windows"));
1605 imageLevelSlider->setStatusTip(
"Image Contrast at "+QString::number(value)+
"%");
1673 QWidgetList windows = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->windowList();
1675 if(windows.isEmpty())
1680 msgBox.setText(
"Window View type changed to Single");
1682 msgBox.setText(
"Window View type changed to Multiple");
1683 msgBox.setInformativeText(
"This will take effect once you reload your data.");
1684 msgBox.setStandardButtons(QMessageBox::Ok);
1690 QWidgetList windows = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->windowList();
1692 if(windows.isEmpty())
1697 msgBox.setText(
"View Orientation Convention changed to Radiological");
1699 msgBox.setText(
"View Orientation Convention changed to Neurological");
1700 msgBox.setInformativeText(
"This will take effect once you reload your data.");
1701 msgBox.setStandardButtons(QMessageBox::Ok);
1707 QWidgetList windows = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->windowList();
1709 QActionGroup *winGp =
new QActionGroup(
this);
1726 QAction *action =
new QAction(currentWindow);
1727 action->setText(text);
1728 menuForList->addAction(action);
1731 action->setCheckable(
true);
1732 action->setChecked(currentWindow == qobject_cast<QWorkspace *>(
workspaces->currentWidget())->activeWindow());
1733 winGp->addAction(action);
1738 connect(action, SIGNAL(triggered()),
windowMapper, SLOT(map()));
1752 for(
int j = 0; j < n; j ++)
1758 printDebug(
"Number of Image Windows: " + QString::number(m));
1769 for(
int j = 0; j < n; j ++)
1775 printDebug(
"Number of Model Windows: " + QString::number(m));
1782 QWidgetList windows = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->windowList();
1793 QWidgetList windows = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->windowList();
1807 QWidgetList windows = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->windowList();
1827 QWidgetList windows = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->windowList();
1847 QWidgetList windows = qobject_cast<QWorkspace *>(
workspaces->currentWidget())->windowList();
1850 printDebug(
"Number of Windows: " + QString::number(windows.size()));
1872 printDebug(
"Updating Views in Other Windows");
1875 vtkRenderWindow* rndWindow = vtkRenderWindow::SafeDownCast(obj);
1876 vtkRenderer* rnd = rndWindow->GetRenderers()->GetFirstRenderer();
1884 vtkCamera* srcCamera = rnd->GetActiveCamera();
1891 vtkRenderer* distRnd = window->GetRenderWindow()->GetRenderers()->GetFirstRenderer();
1892 vtkCamera* distCamera = distRnd->GetActiveCamera();
1894 if(distCamera != srcCamera)
1896 if(srcIsImage &&
isImage(window))
1899 QPointer<milxQtImage> img = qobject_cast<
milxQtImage *>(window);
1903 img->setCrosshairPosition(
activeImage()->getCrosshairPosition());
1918 if( !(srcIsImage &&
isModel(window)) && !(srcIsModel &&
isImage(window)))
1919 distCamera->DeepCopy(srcCamera);
1942 int contourNumber = 1;
1943 if(value == numeric_limits<float>::max())
1950 model->generateIsoSurface(img, contourNumber, value);
1951 model->generateModel();
1959 model->generatePolyDataFromImage(img);
1960 model->generateModel();
1969 vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New();
1975 field->GetPointData()->SetActiveVectors(
"ImageScalars");
1977 QPointer<milxQtImage> pseudoimage =
new milxQtImage;
1979 pseudoimage->SetInput(field);
1980 pseudoimage->generateImage();
1987 if(subsampleFactor == 0)
1989 subsampleFactor = QInputDialog::getInt(
this, tr(
"Please Provide the sub-sample factor of the data"),
1990 tr(
"Sub-sample Factor:"), 8, 1, 1000, 1, &ok1);
1996 floatImageType::SizeType subsampleSizes;
1997 subsampleSizes.Fill(subsampleFactor);
2001 std::cout <<
"Subsampled size: " << imgSubSampled->GetLargestPossibleRegion().GetSize() << std::endl;
2008 vtkSmartPointer<vtkPoints> fieldPoints = vtkSmartPointer<vtkPoints>::New();
2009 vtkSmartPointer<vtkFloatArray> magnitudes = vtkSmartPointer<vtkFloatArray>::New();
2010 magnitudes->SetNumberOfComponents(1);
2011 vtkSmartPointer<vtkFloatArray> vectors = vtkSmartPointer<vtkFloatArray>::New();
2012 vectors->SetNumberOfComponents(3);
2014 typedef itk::Point<double, 3> InputImagePointType;
2015 itk::ImageRegionConstIteratorWithIndex<vectorImageType> imageIterator(imgSubSampled, imgSubSampled->GetLargestPossibleRegion());
2016 itk::ImageRegionConstIteratorWithIndex<floatImageType> magImageIterator(magImgSubSampled, magImgSubSampled->GetLargestPossibleRegion());
2018 InputImagePointType point;
2019 while(!imageIterator.IsAtEnd())
2021 coordinate position, direction;
2025 magImgSubSampled->TransformIndexToPhysicalPoint(magImageIterator.GetIndex(), point);
2027 position[0] = point[0];
2028 position[1] = point[1];
2029 position[2] = point[2];
2031 direction.fill(0.0);
2032 if(magImageIterator.Get() != 0)
2034 direction[0] = imageIterator.Get()[0];
2035 direction[1] = imageIterator.Get()[1];
2036 if(img->GetNumberOfComponentsPerPixel() > 2)
2037 direction[2] = imageIterator.Get()[2];
2040 fieldPoints->InsertNextPoint(position.data_block());
2042 value = magImageIterator.Get();
2043 magnitudes->InsertNextTuple1(value);
2044 vectors->InsertNextTuple3(direction[0], direction[1], direction[2]);
2050 vtkSmartPointer<vtkPolyData> field = vtkSmartPointer<vtkPolyData>::New();
2051 field->SetPoints(fieldPoints);
2052 field->GetPointData()->SetScalars(magnitudes);
2053 field->GetPointData()->SetVectors(vectors);
2058 model->SetInput(field);
2059 model->generateModel();
2060 model->generateVectorField(scaling);
2068 if(subsampleFactor == 0)
2070 subsampleFactor = QInputDialog::getInt(
this, tr(
"Please Provide the sub-sample factor of the data"),
2071 tr(
"Sub-sample Factor:"), 8, 1, 1000, 1, &ok1);
2077 const size_t components = img->GetNumberOfComponentsPerPixel();
2078 floatImageType::SizeType subsampleSizes;
2079 subsampleSizes.Fill(subsampleFactor);
2083 std::cout <<
"Subsampled size: " << imgSubSampled->GetLargestPossibleRegion().GetSize() << std::endl;
2090 vtkSmartPointer<vtkPoints> fieldPoints = vtkSmartPointer<vtkPoints>::New();
2091 vtkSmartPointer<vtkFloatArray> magnitudes = vtkSmartPointer<vtkFloatArray>::New();
2092 magnitudes->SetNumberOfComponents(1);
2093 vtkSmartPointer<vtkFloatArray> tensors = vtkSmartPointer<vtkFloatArray>::New();
2094 tensors->SetNumberOfComponents(9);
2096 typedef itk::Point<double, 3> InputImagePointType;
2097 itk::ImageRegionConstIteratorWithIndex<vectorImageType> imageIterator(imgSubSampled, imgSubSampled->GetLargestPossibleRegion());
2098 itk::ImageRegionConstIteratorWithIndex<floatImageType> magImageIterator(magImgSubSampled, magImgSubSampled->GetLargestPossibleRegion());
2100 InputImagePointType point;
2101 while(!imageIterator.IsAtEnd())
2107 magImgSubSampled->TransformIndexToPhysicalPoint(magImageIterator.GetIndex(), point);
2109 position[0] = point[0];
2110 position[1] = point[1];
2111 position[2] = point[2];
2113 vtkSmartPointer<vtkTensor> tens = vtkSmartPointer<vtkTensor>::New();
2114 if(magImageIterator.Get() != 0)
2118 tens->SetComponent(0,0, imageIterator.Get()[0]);
2119 tens->SetComponent(1,1, imageIterator.Get()[1]);
2120 tens->SetComponent(2,2, imageIterator.Get()[2]);
2121 tens->SetComponent(0,1, imageIterator.Get()[3]);
2122 tens->SetComponent(1,0, imageIterator.Get()[3]);
2123 tens->SetComponent(0,2, imageIterator.Get()[4]);
2124 tens->SetComponent(2,0, imageIterator.Get()[4]);
2125 tens->SetComponent(1,2, imageIterator.Get()[5]);
2126 tens->SetComponent(2,1, imageIterator.Get()[5]);
2130 tens->SetComponent(0,0, imageIterator.Get()[0]);
2131 tens->SetComponent(1,1, imageIterator.Get()[1]);
2132 tens->SetComponent(2,2, imageIterator.Get()[2]);
2133 tens->SetComponent(0,1, imageIterator.Get()[3]);
2134 tens->SetComponent(1,0, imageIterator.Get()[4]);
2135 tens->SetComponent(0,2, imageIterator.Get()[5]);
2136 tens->SetComponent(2,0, imageIterator.Get()[6]);
2137 tens->SetComponent(1,2, imageIterator.Get()[7]);
2138 tens->SetComponent(2,1, imageIterator.Get()[8]);
2143 tens->SetComponent(0,0, 0.0);
2144 tens->SetComponent(1,1, 0.0);
2145 tens->SetComponent(2,2, 0.0);
2146 tens->SetComponent(0,1, 0.0);
2147 tens->SetComponent(1,0, 0.0);
2148 tens->SetComponent(0,2, 0.0);
2149 tens->SetComponent(2,0, 0.0);
2150 tens->SetComponent(1,2, 0.0);
2151 tens->SetComponent(2,1, 0.0);
2154 fieldPoints->InsertNextPoint(position);
2156 value = magImageIterator.Get();
2157 magnitudes->InsertNextTuple1(value);
2158 tensors->InsertNextTuple(tens->T);
2164 vtkSmartPointer<vtkPolyData> field = vtkSmartPointer<vtkPolyData>::New();
2165 field->SetPoints(fieldPoints);
2166 field->GetPointData()->SetScalars(magnitudes);
2167 field->GetPointData()->SetTensors(tensors);
2171 model->SetInput(field);
2172 model->generateModel();
2173 model->generateTensorField(scaling);
2180 if(subsampleFactor == 0)
2182 subsampleFactor = QInputDialog::getInt(
this, tr(
"Please Provide the sub-sample factor of the data"),
2183 tr(
"Sub-sample Factor:"), 8, 1, 1000, 1, &ok1);
2189 floatImageType::SizeType imageSize = magImg->GetLargestPossibleRegion().GetSize();
2190 size_t sliceDimension = 0;
2191 for(
size_t j = 0; j < floatImageType::ImageDimension; j ++)
2193 if(imageSize[j] == 1)
2198 const size_t sliceSubsampleFactor = subsampleFactor;
2199 floatImageType::SizeType subsampleSizes;
2200 subsampleSizes.Fill(subsampleFactor);
2201 floatImageType::SizeType sliceSubsampleSizes;
2202 sliceSubsampleSizes.Fill(sliceSubsampleFactor);
2203 sliceSubsampleSizes[sliceDimension] = 1;
2209 cout <<
"Slice Information: " << endl;
2217 printDebug(
"Setting up seed points for streamlines using the current slice");
2218 vtkSmartPointer<vtkPoints> slicePoints = vtkSmartPointer<vtkPoints>::New();
2220 typedef itk::Point<double, 3> InputImagePointType;
2221 typedef itk::Point<double, 2> InputSlicePointType;
2222 itk::ImageRegionConstIteratorWithIndex<vectorImageType> imageIterator(imgSubSampled, imgSubSampled->GetLargestPossibleRegion());
2223 itk::ImageRegionConstIteratorWithIndex<floatImageType> magImageIterator(magImgSubSampled, magImgSubSampled->GetLargestPossibleRegion());
2226 InputImagePointType point;
2227 while(!magImageIterator.IsAtEnd())
2231 magImgSubSampled->TransformIndexToPhysicalPoint(magImageIterator.GetIndex(), point);
2233 position[0] = point[0];
2234 position[1] = point[1];
2235 position[2] = point[2];
2237 slicePoints->InsertNextPoint(position);
2242 vtkSmartPointer<vtkPolyData> slice = vtkSmartPointer<vtkPolyData>::New();
2243 slice->SetPoints(slicePoints);
2246 printDebug(
"Converting ITK Vector Image to VTK Vector Image");
2247 vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New();
2249 printDebug(
"Applying orientation to VTK Vector Image");
2250 if(!fieldRaw || fieldRaw->GetNumberOfScalarComponents() < 3)
2251 printWarning(
"Possible problem with the VTK Vector image");
2254 field->GetPointData()->SetActiveVectors(
"ImageScalars");
2259 model->SetInput(slice);
2260 model->generateStreamLines(field);
2268 plot->
setName(
"Volume Rendering");
2270 plot->setPlotTypeVolume();
2271 plot->SetSource(img, eightbit,
false);
2272 plot->generatePlot();
2274 display( qobject_cast<milxQtRenderWindow *>(plot) );
2279 printDebug(
"Attempting Surface plot of image data");
2281 plot->
setName(
"Image Surface");
2283 plot->setPlotTypeSurface(displaceAxis);
2284 plot->SetSource(img,
false,
true);
2285 plot->generatePlot();
2296 plot->SetSource(tbl);
2297 plot->generatePlot();
2300 if(tbl->GetNumberOfColumns() < 10)
2301 display( qobject_cast<milxQtRenderWindow *>(plot) );
2311 image->generateImage();
2320 printError(
"Need more than 1 window open to blend.");
2325 QPointer<milxQtImage> firstImg =
nextImage();
2328 QVector< QSlider* > sliders;
2329 QVector< QCheckBox* > checkBoxes;
2330 QSlider *opacitySldr =
new QSlider(
this);
2331 opacitySldr->setMinimum(0);
2332 opacitySldr->setMaximum(10);
2333 opacitySldr->setValue(10);
2334 QCheckBox *initialCheckbox =
new QCheckBox(
this);
2335 initialCheckbox->setChecked(
true);
2337 initialCheckbox->setToolTip(firstImg->strippedBaseName());
2338 QVBoxLayout *initialLayout =
new QVBoxLayout(
this);
2339 initialLayout->addWidget(initialCheckbox);
2340 initialLayout->addWidget(opacitySldr);
2341 QHBoxLayout *sliderLayout =
new QHBoxLayout(
this);
2342 sliderLayout->addLayout(initialLayout);
2343 sliders.push_back(opacitySldr);
2344 checkBoxes.push_back(initialCheckbox);
2346 if(firstImg->GetLookupTable() == NULL)
2349 msgBox.setText(
"Colormap not set?");
2350 msgBox.setInformativeText(
"Image " + firstImg->strippedBaseName() +
" has no colormap set. Result could be unexpected.");
2351 msgBox.setStandardButtons(QMessageBox::Ok);
2352 msgBox.setDefaultButton(QMessageBox::Ok);
2356 for(
int j = 1; j < n; j ++)
2358 QPointer<milxQtImage> secondImg =
nextImage();
2360 if(secondImg->GetLookupTable() == NULL)
2363 msgBox.setText(
"Colormap not set?");
2364 msgBox.setInformativeText(
"Image " + secondImg->strippedBaseName() +
" has no colormap set. Result could be unexpected.");
2365 msgBox.setStandardButtons(QMessageBox::Ok);
2366 msgBox.setDefaultButton(QMessageBox::Ok);
2370 QVBoxLayout *layout =
new QVBoxLayout(
this);
2371 QSlider *opacitySldr2 =
new QSlider(
this);
2372 opacitySldr2->setMinimum(0);
2373 opacitySldr2->setMaximum(10);
2374 opacitySldr2->setValue(5);
2375 QCheckBox *checkbox =
new QCheckBox(
this);
2376 checkbox->setChecked(
true);
2377 checkbox->setToolTip(secondImg->strippedBaseName());
2378 layout->addWidget(checkbox);
2379 layout->addWidget(opacitySldr2);
2380 sliderLayout->addLayout(layout);
2381 sliders.push_back(opacitySldr2);
2382 checkBoxes.push_back(checkbox);
2385 QHBoxLayout *dlgLayout =
new QHBoxLayout(
this);
2386 QVBoxLayout *btnlayout =
new QVBoxLayout(
this);
2387 QPushButton *btnOK =
new QPushButton(
"OK",
this);
2388 QPushButton *btnCancel =
new QPushButton(
"Cancel",
this);
2389 btnlayout->addWidget(btnOK);
2390 btnlayout->addWidget(btnCancel);
2391 dlgLayout->addLayout(sliderLayout);
2392 dlgLayout->addLayout(btnlayout);
2394 QDialog *slidersDlg =
new QDialog(
this);
2395 slidersDlg->setLayout(dlgLayout);
2396 connect(btnOK, SIGNAL(clicked()), slidersDlg, SLOT(accept()));
2397 connect(btnCancel, SIGNAL(clicked()), slidersDlg, SLOT(reject()));
2398 int ret = slidersDlg->exec();
2400 if(ret == QDialog::Rejected)
2403 QVector<float> opacities;
2404 for(
size_t j = 0; j < sliders.size(); j ++)
2406 float value = sliders[j]->value()*0.1;
2407 if(!checkBoxes[j]->isChecked())
2409 opacities.push_back(value);
2420 printError(
"Need more than 1 window open to blend.");
2424 if(opacities.empty() || opacities.size() < n)
2426 printError(
"Size of opacities list does not match number of open images.");
2431 QPointer<milxQtImage> firstImg =
nextImage();
2433 vtkSmartPointer<vtkImageMapToColors> filterColorsImage = vtkSmartPointer<vtkImageMapToColors>::New();
2434 filterColorsImage->SetLookupTable(firstImg->GetLookupTable());
2435 #if VTK_MAJOR_VERSION <= 5 2436 filterColorsImage->SetInput(firstImg->GetOutput());
2438 filterColorsImage->SetInputData(firstImg->GetOutput());
2440 filterColorsImage->PassAlphaToOutputOn();
2441 filterColorsImage->Update();
2442 vtkSmartPointer<vtkImageData> ucharData1 = filterColorsImage->GetOutput();
2444 int initialExtent[6];
2445 firstImg->GetOutput()->GetExtent(initialExtent);
2449 vtkSmartPointer<vtkImageBlend> blend = vtkSmartPointer<vtkImageBlend>::New();
2451 blend->SetOpacity(0,opacities[0]);
2452 #if VTK_MAJOR_VERSION <= 5 2453 blend->AddInput(ucharData1);
2455 blend->AddInputData(ucharData1);
2458 blend->SetBlendModeToNormal();
2460 for(
int j = 1; j < n; j ++)
2462 QPointer<milxQtImage> secondImg =
nextImage();
2464 if(opacities[j] == 0.0)
2467 printInfo(
"Blending with Image: " + secondImg->strippedName() +
" with Opacity: " + QString::number(opacities[j]));
2469 vtkSmartPointer<vtkImageMapToColors> filterColorsOverlay = vtkSmartPointer<vtkImageMapToColors>::New();
2470 filterColorsOverlay->SetLookupTable(secondImg->GetLookupTable());
2471 #if VTK_MAJOR_VERSION <= 5 2472 filterColorsOverlay->SetInput(secondImg->GetOutput());
2474 filterColorsOverlay->SetInputData(secondImg->GetOutput());
2476 filterColorsOverlay->PassAlphaToOutputOn();
2477 filterColorsOverlay->Update();
2478 vtkSmartPointer<vtkImageData> ucharData2 = filterColorsOverlay->GetOutput();
2480 if(!secondImg->GetLookupTable())
2481 printWarning(
"Colourmap is not set. Please set a colour map to ensure proper blending.");
2483 int actualExtent[6];
2484 secondImg->GetOutput()->GetExtent(actualExtent);
2486 if(initialExtent[1] == actualExtent[1] && initialExtent[3] == actualExtent[3] && initialExtent[5] == actualExtent[5])
2488 #if VTK_MAJOR_VERSION <= 5 2489 blend->AddInput(ucharData2);
2491 blend->AddInputData(ucharData2);
2493 blend->SetOpacity(j,opacities[j]);
2496 printError(
"Images are not the same size. Skipping.");
2501 printDebug(
"Number of components: " + QString::number(blend->GetOutput()->GetNumberOfScalarComponents()));
2504 QPointer<milxQtImage> blendResult =
new milxQtImage;
2505 blendResult->
setName(
"Blended Images");
2506 blendResult->setConsole(
console);
2507 blendResult->setData(blend->GetOutput());
2508 blendResult->generateImage();
2520 QPointer<milxQtImage> firstImg =
nextImage();
2522 QPointer<milxQtImage> resultImg =
new milxQtImage;
2523 printInfo(
"Assigning " + firstImg->getName());
2524 resultImg->setName(
"Sum Image");
2525 resultImg->setConsole(
console);
2526 resultImg->setData(firstImg,
true);
2529 QPointer<milxQtImage> img =
nextImage();
2532 resultImg->add(img);
2546 QPointer<milxQtImage> firstImg =
nextImage();
2548 QPointer<milxQtImage> resultImg =
new milxQtImage;
2549 printInfo(
"Assigning " + firstImg->getName());
2550 resultImg->setName(
"Difference Image");
2551 resultImg->setConsole(
console);
2552 resultImg->setData(firstImg,
true);
2555 QPointer<milxQtImage> img =
nextImage();
2557 printInfo(
"Subtracting " + img->getName());
2558 resultImg->subtract(img);
2572 QPointer<milxQtImage> firstImg =
nextImage();
2574 QPointer<milxQtImage> resultImg =
new milxQtImage;
2575 printInfo(
"Assigning " + firstImg->getName());
2576 resultImg->setName(
"Product Image");
2577 resultImg->setConsole(
console);
2578 resultImg->setData(firstImg,
true);
2581 QPointer<milxQtImage> img =
nextImage();
2583 printInfo(
"Multiplying " + img->getName());
2584 resultImg->multiply(img);
2595 #if (ITK_REVIEW || ITK_VERSION_MAJOR > 3) //Review only members 2598 QPointer<milxQtImage> firstImg =
nextImage();
2600 QPointer<milxQtImage> resultImg =
new milxQtImage;
2601 printInfo(
"Assigning " + firstImg->getName());
2602 resultImg->setName(
"Convolution");
2603 resultImg->setConsole(
console);
2604 resultImg->setData(firstImg,
true);
2607 QPointer<milxQtImage> img =
nextImage();
2609 printInfo(
"Convolving with " + img->getName());
2610 resultImg->convolve(img);
2622 #if (ITK_REVIEW || ITK_VERSION_MAJOR > 3) //Review only members 2625 std::vector< charImageType::Pointer > images;
2626 std::vector<unsigned char> values;
2629 QPointer<milxQtImage> img =
nextImage();
2631 if(!img->is8BitImage() && !img->isFloatingPointImage())
2633 printWarning(
"Ignoring non-labelled or float image " + img->getName());
2636 else if(img->isFloatingPointImage())
2644 images.push_back(img->GetCharImage());
2645 printInfo(
"Merging with " + img->getName());
2648 values.push_back(j);
2653 printError(
"No labelled image found. Ignoring operation.");
2659 QPointer<milxQtImage> resultImg =
new milxQtImage;
2660 resultImg->
setName(
"Merged Labels");
2661 resultImg->setData(mergedImg,
true);
2662 resultImg->setConsole(
console);
2663 resultImg->generateImage();
2715 vtkCommand::ProgressEvent,
2725 if(customWindow == 0)
2726 widget->setAttribute(Qt::WA_DeleteOnClose);
2730 customWindow->setAttribute(Qt::WA_DeleteOnClose);
2734 widget->setFocusPolicy(Qt::StrongFocus);
2752 for (
int i = 0; i < MaxRecentFiles; ++i)
2791 menuFile->setTitle(QApplication::translate(
"MainWindow",
"File", 0, QApplication::UnicodeUTF8));
2792 actionNewTab->setIcon(QIcon(
":/resources/toolbar/new_tab.png"));
2793 actionNewTab->setText(QApplication::translate(
"MainWindow",
"New Tab", 0, QApplication::UnicodeUTF8));
2796 actionOpen->setIcon(QIcon(
":/resources/toolbar/open.png"));
2797 actionOpen->setText(QApplication::translate(
"MainWindow",
"Open", 0, QApplication::UnicodeUTF8));
2801 actionOpenSeries->setText(QApplication::translate(
"MainWindow",
"Open DICOM Series", 0, QApplication::UnicodeUTF8));
2805 actionOpenCollect->setText(QApplication::translate(
"MainWindow",
"Open Model Collection", 0, QApplication::UnicodeUTF8));
2808 actionSave->setIcon(QIcon(
":/resources/toolbar/save.png"));
2809 actionSave->setText(QApplication::translate(
"MainWindow",
"Save", 0, QApplication::UnicodeUTF8));
2813 actionSaveScreen->setText(QApplication::translate(
"MainWindow",
"Save Screenshot", 0, QApplication::UnicodeUTF8));
2820 actionCloseActive->setText(QApplication::translate(
"MainWindow",
"Close", 0, QApplication::UnicodeUTF8));
2823 actionCloseAll->setIcon(QIcon(
":/resources/toolbar/close_all.png"));
2824 actionCloseAll->setText(QApplication::translate(
"MainWindow",
"Close All", 0, QApplication::UnicodeUTF8));
2829 for (
int i = 0; i < MaxRecentFiles; ++i)
2836 actionPreferences->setText(QApplication::translate(
"MainWindow",
"Preferences ...", 0, QApplication::UnicodeUTF8));
2838 actionExit->setIcon(QIcon(
":/resources/toolbar/exit.png"));
2839 actionExit->setText(QApplication::translate(
"MainWindow",
"Exit", 0, QApplication::UnicodeUTF8));
2844 menuData->setTitle(QApplication::translate(
"MainWindow",
"Data", 0, QApplication::UnicodeUTF8));
2846 menuImages->setTitle(QApplication::translate(
"MainWindow",
"Images", 0, QApplication::UnicodeUTF8));
2848 actionBlendImages->setText(QApplication::translate(
"MainWindow",
"Blend Images", 0, QApplication::UnicodeUTF8));
2851 actionAddImages->setText(QApplication::translate(
"MainWindow",
"Add Images", 0, QApplication::UnicodeUTF8));
2854 actionAverageImages->setText(QApplication::translate(
"MainWindow",
"Average Images", 0, QApplication::UnicodeUTF8));
2857 actionSubtractImages->setText(QApplication::translate(
"MainWindow",
"Difference Images", 0, QApplication::UnicodeUTF8));
2860 actionMultiplyImages->setText(QApplication::translate(
"MainWindow",
"Multiply Images", 0, QApplication::UnicodeUTF8));
2863 actionConvolveImages->setText(QApplication::translate(
"MainWindow",
"Convolve Images", 0, QApplication::UnicodeUTF8));
2866 actionMergeLabels->setText(QApplication::translate(
"MainWindow",
"Merge Labels", 0, QApplication::UnicodeUTF8));
2871 menuWindows->setTitle(QApplication::translate(
"MainWindow",
"Windows", 0, QApplication::UnicodeUTF8));
2872 actionLinkWindows->setText(QApplication::translate(
"MainWindow",
"Link All Windows", 0, QApplication::UnicodeUTF8));
2876 actionCascade->setIcon(QIcon(
":/resources/toolbar/cascade.png"));
2877 actionCascade->setText(QApplication::translate(
"MainWindow",
"Cascade", 0, QApplication::UnicodeUTF8));
2879 actionTile->setIcon(QIcon(
":/resources/toolbar/tile.png"));
2880 actionTile->setText(QApplication::translate(
"MainWindow",
"Tile", 0, QApplication::UnicodeUTF8));
2883 actionTileVertically->setText(QApplication::translate(
"MainWindow",
"Tile Vertically", 0, QApplication::UnicodeUTF8));
2886 actionTileHorizontally->setText(QApplication::translate(
"MainWindow",
"Tile Horizontally", 0, QApplication::UnicodeUTF8));
2891 menuHelp->setTitle(QApplication::translate(
"MainWindow",
"Help", 0, QApplication::UnicodeUTF8));
2893 actionContents->setText(QApplication::translate(
"MainWindow",
"sMILX Help Contents", 0, QApplication::UnicodeUTF8));
2897 actionControls->setText(QApplication::translate(
"MainWindow",
"Controls", 0, QApplication::UnicodeUTF8));
2899 actionControls->setIcon(QIcon(
":/resources/toolbar/controls.png"));
2901 actionAbout->setText(QApplication::translate(
"MainWindow",
"About", 0, QApplication::UnicodeUTF8));
2907 actionCompare->setText(QApplication::translate(
"MainWindow",
"Compare", 0, QApplication::UnicodeUTF8));
2910 menuWindowList->setTitle(QApplication::translate(
"MainWindow",
"Switch Window To", 0, QApplication::UnicodeUTF8));
2912 importFromMenu->setTitle(QApplication::translate(
"MainWindow",
"Import View From", 0, QApplication::UnicodeUTF8));
2915 #if !(ITK_REVIEW || ITK_VERSION_MAJOR > 3) //Review only members 2922 actionImageText->setText(QApplication::translate(
"MainWindow",
"Text", 0, QApplication::UnicodeUTF8));
2925 statusBar()->showMessage(tr(
"Ready"));
2982 QLabel *defaultBarLabel =
new QLabel(
this);
3005 refreshButton->setIcon(QIcon(
":/resources/toolbar/refresh.png"));
3008 cursorButton->setIcon(QIcon(
":/resources/toolbar/crosshairs_2D.png"));
3027 qRegisterMetaType< milxQtRenderWindow* >(
"milxQtRenderWindow*");
3028 qRegisterMetaType< milxQtModel* >(
"milxQtModel*");
3029 qRegisterMetaType< milxQtImage* >(
"milxQtImage*");
3031 QObject::connect(
workspaces, SIGNAL(tabCloseRequested(
int)),
this, SLOT(
closeTab(
int)));
3036 QObject::connect(
actionOpen, SIGNAL(activated()),
this, SLOT(
open()));
3039 QObject::connect(
actionSave, SIGNAL(activated()),
this, SLOT(
save()));
3043 QObject::connect(
actionExit, SIGNAL(activated()),
this, SLOT(close()));
3052 #if (ITK_REVIEW || ITK_VERSION_MAJOR > 3) //Review only members 3083 actionNewTab->setToolTip(
"Create a new tab for display");
3084 actionNewTab->setStatusTip(
"Create a new tab for display");
3085 actionOpen->setToolTip(
"Open a file (all supported formats, including those by plugins) for display");
3086 actionOpen->setStatusTip(
"Open a file (all supported formats, including those by plugins) for display");
3087 actionOpenSeries->setToolTip(
"Open a DICOM series by choosing a directory");
3088 actionOpenSeries->setStatusTip(
"Open a DICOM series by choosing a directory");
3089 actionOpenCollect->setToolTip(
"Open a model collection by choosing a set of files");
3090 actionOpenCollect->setStatusTip(
"Open a model collection by choosing a set of files");
3091 actionSave->setToolTip(
"Saves the data in the active window (as a supported file format, including those in plugins)");
3092 actionSave->setStatusTip(
"Saves the data in the active window (as a supported file format, including those in plugins)");
3093 actionSaveScreen->setToolTip(
"Save a screenshot of the active window exactly as displayed");
3094 actionSaveScreen->setStatusTip(
"Save a screenshot of the active window exactly as displayed");
3099 actionCascade->setToolTip(
"Cascade windows in current tab");
3100 actionCascade->setStatusTip(
"Cascade windows in current tab");
3101 actionTile->setToolTip(
"Tile windows in current tab");
3102 actionTile->setStatusTip(
"Tile windows in current tab");
3107 actionConsole->setToolTip(
"Hide/Show console docking window");
3108 actionConsole->setStatusTip(
"Hide/Show console docking window");
3116 actionCompare->setToolTip(
"Compare the data in window with others by placing it into a multi-display window");
3117 actionCompare->setStatusTip(
"Compare the data in window with others by placing it into a multi-display window");
3119 refreshButton->setToolTip(
"Refresh the window views, levels and camera to default.");
3120 refreshButton->setStatusTip(
"Refresh the window views, levels and camera to default.");
3121 imageLevelButton->setToolTip(
"Auto level the image intensities based on inter-quartile ranges.");
3122 imageLevelButton->setStatusTip(
"Auto level the image intensities based on inter-quartile ranges.");
3123 cursorButton->setToolTip(
"Enable crosshairs for all images.");
3124 cursorButton->setStatusTip(
"Enable crosshairs for all images.");
3129 QMenu* contextMenu =
new QMenu(
this);
3137 contextMenu->addSeparator();
3141 contextMenu->addSeparator();
3146 contextMenu->addSeparator();
3149 contextMenu->exec(currentEvent->globalPos());
3154 if(currentEvent->mimeData()->hasFormat(
"text/uri-list") || currentEvent->mimeData()->hasFormat(
"text/plain"))
3155 currentEvent->acceptProposedAction();
3160 QList<QUrl> urlsList = currentEvent->mimeData()->urls();
3163 for(
int j = 0; j < urlsList.size(); j ++)
3165 if(urlsList[j].isValid())
3168 tmp = urlsList[j].path().remove(0,1);
3170 tmp = urlsList[j].path();
3177 currentEvent->acceptProposedAction();
3188 QDir pluginsDir(qApp->applicationDirPath());
3189 QString sharedObjectSuffix =
"";
3190 #if defined(Q_OS_WIN) 3191 if (pluginsDir.dirName().toLower() ==
"debug" || pluginsDir.dirName().toLower() ==
"release")
3193 sharedObjectSuffix =
"dll";
3194 #elif defined(Q_OS_MAC) 3201 sharedObjectSuffix =
"dylib";
3203 sharedObjectSuffix =
"so";
3206 pluginsDir.cd(
"plugins");
3207 printInfo(
"Plugin Path to be searched: " + pluginsDir.path());
3209 QStringList pluginFileNames = pluginsDir.entryList(QDir::Files);
3210 foreach (QString fileName, pluginFileNames)
3212 QFileInfo fi(fileName);
3214 #if defined(Q_OS_WIN) 3215 if(!fi.completeSuffix().contains(sharedObjectSuffix, Qt::CaseInsensitive))
3219 if(!fi.completeSuffix().contains(sharedObjectSuffix, Qt::CaseSensitive))
3223 printDebug(
"Attempting to Load " + fileName);
3224 QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
3225 QObject *plugin = pluginLoader.instance();
3232 QPointer<milxQtPluginInterface> loadedPlugin = pluginFactory->newPlugin(
this);
3233 plugins.append( loadedPlugin );
3238 connect(loadedPlugin, SIGNAL( resultAvailable(vtkPolyDataCollection*, QStringList&) ),
this, SLOT(
display(vtkPolyDataCollection*, QStringList&) ));
3240 if(loadedPlugin->isThreaded())
3243 connect(loadedPlugin, SIGNAL(finished()), loadedPlugin, SLOT(postStartTasks()));
3246 if(loadedPlugin->isDockable())
3248 if(!loadedPlugin->isConsole())
3250 addDockWidget(loadedPlugin->dockDefaultArea(), loadedPlugin->dockWidget());
3251 dockActions.append(loadedPlugin->dockWidget()->toggleViewAction());
3256 console->setTab(loadedPlugin->dockWidget()->widget());
3260 if(loadedPlugin->isExtension())
3262 QString tmpName =
"[" + loadedPlugin->name() +
" Extension]";
3264 QAction *extAction =
new QAction(
this);
3265 extAction->setText(QApplication::translate(
"Plugin", tmpName.toStdString().c_str(), 0, QApplication::UnicodeUTF8));
3266 extAction->setShortcut(tr(
"Alt+n"));
3268 if(loadedPlugin->genericResult())
3271 if(loadedPlugin->modelResult())
3274 if(loadedPlugin->imageResult())
3277 connect(extAction, SIGNAL(triggered()), loadedPlugin, SLOT(loadExtension()));
3280 foreach(QMenu *menuToAdd, loadedPlugin->addToMenuBar())
3285 loadedPlugin->setConsole(
console);
3288 foreach (QString ext, loadedPlugin->saveExtensions())
3292 foreach (QString ext, loadedPlugin->openExtensions())
3303 printError(
"Failed to load plugin: " + pluginLoader.errorString());
3313 QSettings settings(
"Shekhar Chandra",
"milxQt");
3315 settings.beginGroup(
"milxQtMain");
3317 settings.setValue(
"size", size());
3318 settings.setValue(
"pos", pos());
3319 settings.setValue(
"geometry", saveGeometry());
3320 settings.setValue(
"windowState", saveState());
3321 settings.setValue(
"defaultView",
defaultViewBox->currentIndex());
3336 settings.endGroup();
3341 QSettings settings(
"Shekhar Chandra",
"milxQt");
3344 QSize desktopSize = qApp->desktop()->availableGeometry().size();
3345 int newWidth = 2.0*desktopSize.width()/3.0 + 0.5;
3346 int newHeight = 4.0*desktopSize.height()/5.0 + 0.5;
3347 int xOffset = (desktopSize.width()-newWidth)/2.0;
3348 int yOffset = (desktopSize.height()-newHeight)/2.0;
3349 int defaultViewMode = 2;
3350 int defaultViewTypeMode = 0;
3351 int defaultOrientationTypeMode = 0;
3353 settings.beginGroup(
"milxQtMain");
3354 resize( settings.value(
"size", QSize(newWidth, newHeight)).toSize() );
3355 move( settings.value(
"pos", QPoint(xOffset, yOffset)).toPoint() );
3356 restoreGeometry(settings.value(
"geometry").toByteArray());
3357 restoreState(settings.value(
"windowState").toByteArray());
3358 defaultViewBox->setCurrentIndex( settings.value(
"defaultView", defaultViewMode).toInt() );
3359 defaultViewTypeBox->setCurrentIndex( settings.value(
"defaultViewType", defaultViewTypeMode).toInt() );
3360 defaultOrientationTypeBox->setCurrentIndex( settings.value(
"defaultOrientationType", defaultOrientationTypeMode).toInt() );
3374 restoreDockWidget(
console->dockWidget());
3377 settings.endGroup();
virtual void createMenu(QMenu *menu)
Create the menu for the data in this object. Used for context menu and file menus.
void imageToTensorField(vectorImageType::Pointer img, floatImageType::Pointer magImg, int subsampleFactor=0, float scaling=0.0)
Compute tensor field from image.
milxQtRenderWindow * nextRenderWindow()
Get the next render window opened in the current tab.
QString saveSupport
Save file extension support list, cats all known extensions.
void update()
Update the GUI elements, such as menus etc. to most up-to-date status.
bool isPlot(QWidget *win)
Returns true if window is an Plot (milxQtPlot object)
bool humanGlyph
Prefer showing human glyph?
void cascadeTab()
Cascade all the windows in the current tab.
QString strippedName(const QString &fullFileName)
Returns the filename with the path stripped.
void closeTab(int index)
Close the tab.
void loadFiles(const QStringList &filenames)
Opens multiple files for viewing in the current tab.
QAction * actionSave
save action
void printError(QString msg)
Error message wrapper for console.
void generateVoxelisedSurface(vtkSmartPointer< vtkPolyData > surfaceToVoxelise, double *bounds=NULL, double *spacing=NULL)
Converts or Voxelises a surface (vtkPolyData) to an image.
QAction * actionSubtractImages
subtract images batch operation action
void disableDefaultView()
Disables the default view whenever data is process or displayed. Enabled by default.
void transferViewToWindows(vtkObject *obj, unsigned long, void *client_data, void *, vtkCommand *command)
If the windows are linked, copy viewing options from one window to all others.
QComboBox * defaultViewBox
Box for default view.
void setCurrentFile(const QString &fileName)
Saves the recent opened/saved file into the recent files list.
int maxProcessors
Max processors to use.
QAction * actionAbout
Action for showing about information.
void setName(const QString filename)
Set the name of the data.
void cleanUpOnClose(QWidget *win)
Removes references to windows that are closed so they are no longer "open".
bool loadPlugins()
Loads plugins (which are assumed to be DLLs) according to the milxQtPluginInterface.
bool whiteBackground
Prefer white backgrounds?
void updateWindowsWithView(int value)
Updates the windows view, such as from a combo box etc.
bool scalarBarModels
Show scalar bar for models?
QList< QAction *> imageExtsActions
List of image extenstion actions loaded succesfully.
QAction * actionCascade
Cascade windows in workspace action.
QAction * actionMergeLabels
Merge labelled images batch operation action.
This class represents the MILX Qt Render Window Display object using QVTK.
vtkSmartPointer< vtkEventQtSlotConnect > Connector
VTK Events to slots convertor.
void imageToStreamLines(vectorImageType::Pointer img, floatImageType::Pointer magImg, size_t subsampleFactor=0)
Compute streamlines from vector image from the extents supplied (pixels of which are used as start po...
QList< QAction *> renderExtsActions
List of render window extenstion actions loaded succesfully.
static bool OpenDelimitedText(const std::string filename, vtkSmartPointer< vtkTable > &data, const std::string delimiter=",")
Opens ASCII Delimited text files such as CSV files. Data is loaded into the table.
QAction * actionTile
Tile windows in workspace action.
void updateQtEvents()
Update the Qt events, used to keep UI responsive.
QMenu * menuFile
File menu.
bool saveImage(const QString filename, vtkImageData *data)
Saves data as an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI, HDR etc.
virtual QString strippedNamePrefix()
Returns the stripped (path removed) name of the data with "Generic" prefix.
QMenu * menuImages
File menu.
QAction * actionControls
Action for showing about information.
bool isUnifiedWindow(QWidget *win)
Returns true if window is an UnifiedWindow (milxQtUnifiedWindow object)
void addToUnifiedWindow(milxQtImage *img)
Adds an image to the unified window and links its results.
void setActiveWindow(QWidget *currentWindow)
Makes the window the active window.
void done(int value)
Hide progress bar when done computing.
void createProgressBar()
Creates the progress bar in the status bar within the main window.
void updatedWindowListMenu(QActionGroup *)
Signal for when the window list menu is updated.
This class represents the MILX Qt Image Display object using VTK.
void predisplay(milxQtImage *img)
Handles the pre-displaying tasks for images, such as checking view type and if 3D viewing is needed e...
void setNamePrefix(const QString newPrefix)
Sets the prefix of the name of the data provided.
int subWindowSize
Window size of child windows to use.
bool orientationImages
Prefer applying orientation to images?
QList< QAction *> modelExtsActions
List of model extenstion actions loaded succesfully.
QAction * actionTileVertically
Tile vertically windows in workspace action.
void tileTabHorizontally()
Tile all the windows horizontally in the current tab.
void setLevel(int level)
Set window level the display to proportion of maxValue.
vtkSmartPointer< vtkTable > GetSource()
Returns the current table source for plot held.
QToolBar * imageToolBar
Some actions for images, like view etc.
This class represents the MILX Qt File I/O object using VTK/ITK/Qt.
QToolBar * windowToolBar
Some actions from window menu, like tile, cascade etc.
QString strippedName()
Returns the stripped (path removed) name of the data.
QComboBox * defaultViewTypeBox
Box for default view type (1 view or scanner type/4 view)
bool isRender(QWidget *win)
Returns true if window is a generic render (milxQtRenderWindow object)
QAction * actionPreferences
Action for showing program preferences.
void scale(float scaling)
scales the intensities of current images.
static vtkSmartPointer< vtkImageData > ConvertITKVectorImageToVTKImage(itk::SmartPointer< TImage > img)
Converts a ITK Vector image object to an VTK image object. You MUST DeepCopy the result as the ITK sm...
void closeEvent(QCloseEvent *event)
Tasks to complete when closing.
bool interpolationImages
Prefer showing interpolation for images?
void tileTabVertically()
Tile all the windows vertically in the current tab.
QSlider * imageLevelSlider
adjust window level of image display
static bool SaveDelimitedText(const std::string filename, const vtkSmartPointer< vtkTable > data, const std::string delimiter=",")
Saves table as an ASCII Delimited text files such as a CSV file.
This class represents the MILX Qt Window Display object using QVTK.
int getNumberOfWindows()
Return the number of windows in the current tab.
void setDisplayData(QPointer< milxQtImage > newImg)
Shares the milxQtImage data to current image. You will need to call generate image after this...
void updateWindowsWithCursors()
Updates the windows with cursors.
vtkImageActor * GetImageActor()
Returns the internal image actor used for display.
bool isActiveImage()
Returns true if active window is an Image (milxQtImage object)
void printDebug(QString msg)
Debug message wrapper for console.
QPointer< milxQtUnifiedWindow > currentUnifiedWindow
Current window for multi-display.
bool saveModel(const QString filename, vtkPolyData *data, const bool binary=false)
Saves a model as a file, which can be a VTK XML or Legacy VTK PolyData File (i.e. either a *...
QList< QAction *> dockActions
List of dock actions of dock widgets loaded succesfully.
virtual ~milxQtMain()
The standard destructor.
void imagesSubtract()
Subtract all open images together to create new image.
QMenu * menuWindows
Windows menu.
void imageToPolyData(vtkSmartPointer< vtkImageData > img)
Compute image to poly data process.
void display(milxQtRenderWindow *rnd)
Handles the displaying of renders as they are produced.
void tileTab()
Tile all the windows in the current tab.
QAction * actionOpenCollect
open collection action
bool open()
Opens data for viewing in the current tab.
QAction * actionCompare
Action for comparing data.
QPushButton * refreshButton
window refresh button
QAction * actionContents
Action for showing contents of help.
bool isActiveUnifiedWindow()
Returns true if active window is an UnifiedWindow (milxQtUnifiedWindow object)
void updatedImportFromMenu(QActionGroup *)
Signal for when the import from menu is updated.
void readSettings()
Load the necessary GUI settings/state for the main class.
QAction * actionImageText
toggle text annotate mode
void controls()
Show the controls information.
QAction * actionTileHorizontally
Tile horizontally windows in workspace action.
void addToContextMenu(QAction *act)
Adds (prepends) the action to the context menu. Connections are assumed to be made before hand...
QProgressBar * progressBar
Progress bar for computation.
QString activeNamePrefix()
Returns the name with prefix of the active window regardless of being an image, table or surface plot...
void appendToContextMenu(QAction *act)
Adds (appends) the action to the context menu. Connections are assumed to be made before hand...
int getNumberOfModelWindows()
Return the number of model windows in the current tab.
void imagesMergeLabels()
Merge all open labelled images together to create new labelled image.
This class represents the MILX Qt Model/Mesh Display object using VTK.
QAction * actionOpenSeries
open series action
virtual void scaleDisplay(const bool forceDisplay=false)
Toggles the scale bar display.
bool isImage(QWidget *win)
Returns true if window is an Image (milxQtImage object)
void printInfo(QString msg)
Info message wrapper for console.
void setDefaultOrientation(int orientMode)
Change orientation mode to one of the supported standards. Default: Radiological. ...
void setConsole(milxQtConsole *con)
Set the console for log output.
void enableUpdates(QStatusBar *bar)
Enables the update of coordinates to the status bar provided directly. Update is done on mouse moveme...
void addExtensionAction(QAction *act)
Adds (in extension section) the action as an extension action. Connections are assumed to be made bef...
void dataMenu()
Create the data menu based on Window selected.
QAction * actionCloseAll
Close all windows in tab action.
void closeTabActiveWindow()
Close active window in the tab.
void refresh()
Refresh the display of the model.
virtual void enableCrosshair()
Enables the cursor/crosshair for marking. Image must be generated before calling. ...
void setView(int viewMode)
Change view to view mode identified by number. 0-axial, 1-coronal, 2-sagittal.
void modelInfo()
Computes and prints the centroid, centroid size and covariance matrix to standard out...
void imageToVolume(vtkSmartPointer< vtkImageData > img, bool eightbit)
Display image as volume rendering.
QSignalMapper * windowMapper
Mapper of mulit-connections.
QList< QPointer< milxQtModel > > modelWindows
List of model windows opened.
void createConnections()
Creates the signals and slots connections within the main window.
The class maintains a state and render of multiple display objects (such as a milxQtModel or milxQtIm...
void newTab()
Creates a new tab for the workspace.
void imageToPseudoImage(vectorImageType::Pointer img)
Compute pseudo image from vector image.
void windowActivated(QWidget *win)
Signal for when a window has been activated.
void helpContents()
Show the help contents browser.
bool isModel(QWidget *win)
Returns true if window is an Model (milxQtModel object)
The class provides 1D/2D and 3D plotting capability. This includes scatter and surface plots...
bool isCrosshair()
Returns true if cursor shown to the display of the image.
bool loadFile(const QString &filename)
Opens a file for viewing in the current tab.
QActionGroup * windowActionList(QMenu *menuForList, bool groupTogether=true, bool applyMapper=false)
Creates an action list of windows currently opened to the menu provided.
void addModel(milxQtModel *mdl)
Adds a model widget and links its results.
QAction * actionConsole
toggle action for console
QMenu * menuWindowList
Menu for list of windows.
Represents an image (i.e. an regular rectangular array with scalar values) and their common operation...
QAction * actionBlendImages
blend images batch operation action
QList< QPointer< milxQtPluginInterface > > plugins
List of plugins loaded succesfully.
QMenu * importFromMenu
Menu import from data menu.
static vtkSmartPointer< vtkImageData > ApplyOrientationToVTKImage(vtkSmartPointer< vtkImageData > img, itk::SmartPointer< TImage > refImage, vtkSmartPointer< vtkMatrix4x4 > &transformMatrix, const bool labelledImage, const bool flipY=true)
Applies orientation/direction and origin to a VTK image from a reference image.
QAction * actionsRecentFile[MaxRecentFiles]
Array of recent file actions.
void addRender(milxQtRenderWindow *rnd)
Adds a generic render widget and links its results.
bool interpolationModels
Prefer applying interpolation to models?
void imagesConvolve()
Convolve all open images together to create new image.
QMenuBar * menuBar
Menu bar for the window.
QPushButton * cursorButton
crosshairs button
QComboBox * defaultOrientationTypeBox
Box for default orientation type (radiological or neurological orientation)
void contextMenuEvent(QContextMenuEvent *event)
The context menu setup member.
QPushButton * imageLevelButton
auto level button
void updateWindowsWithValue(int value)
Updates the windows based on single value (in percent), such as from a slider etc.
milxQtWindow * nextWindow()
Get the next window opened in the current tab.
QWebView * activeWebView()
Returns the QWebView object, returns 0 if active window is not a QWebView object. ...
void voxeliseSurface(vtkSmartPointer< vtkPolyData > surface)
Convert poly data to an image volume.
void trackView(milxQtImage *windowToTrack, ViewType viewTo)
Enables tracking of the view (axial etc.) to imgToTrack provided.
milxQtImage * activeImage()
Returns the milxQtImage object, returns 0 if active window is not a milxQtImage object.
vtkSmartPointer< vtkDataArray > GetScalars()
Returns the scalars of the model currently held.
bool isLoaded()
Is the data successfully loaded? Use this to check if all is ok with data display.
QAction * actionRecentFileSeparator
Pointer to separator so it can be turned on and off.
QAction * actionExit
Exit action.
void imageToVectorField(vectorImageType::Pointer img, floatImageType::Pointer magImg, int subsampleFactor=0, float scaling=0.0)
Compute vector field from image.
void createComboBoxes()
Creates the combo boxes for main window.
QMenu * menuData
Data menu.
milxQtImage * nextImage()
Get the next image opened in the current tab.
void displayed(milxQtRenderWindow *)
Signal for when a render window has been displayed.
QString strippedNamePrefix()
Returns the stripped (path removed) name of the data with "Image" prefix.
QString activeName()
Returns the name of the active window regardless of being an image, table or surface plot...
QString getName()
Returns the name of the data.
QActionGroup * updateWindowListMenu(bool applyMapper=true)
Updates the windows list in the windows list menu. This is a raw list for children to use...
void addUnifiedWindow(milxQtUnifiedWindow *uni)
Adds a unified window and links its results.
bool isActiveWebView()
Returns true if active window is a web viewer.
QString strippedNamePrefix()
Returns the stripped (path removed) name of the data with "Model" prefix.
bool isDeletableOnClose()
Is the window deletable on close?
void updateWindowsWithViewType(int value)
Updates the windows view type based on type set, such as from a combo box etc.
void setupTooltips()
Assign tooltips to each action for users benefit. The tooltips explains the function of each action...
void imagesBlend(QVector< float > opacities)
Blend all open images together to create new image. 'opacities' would hold a list of floats for blend...
void tableToPlot(vtkSmartPointer< vtkTable > tbl, QString title)
Display table as a plot.
QActionGroup * updateImportFromMenu(bool applyMapper=false)
Updates the Import form menu in the windows list menu. This is a raw list for children to use...
QAction * actionConvolveImages
Convolve images batch operation action.
void commonChildProperties(QWidget *widget)
Sets all the common child properties of the data windows such as images, plots etc.
int getNumberOfImageWindows()
Return the number of image windows in the current tab.
void imagesAverage()
Average all open images together to create new image.
void imagesMix()
Blend all open images together to create new image usaing a mixer dialog.
milxQtModel * activePlot()
Returns the milxQtPlot object, returns 0 if active window is not a milxQtPlot object.
static void Information(itk::SmartPointer< TImage > img)
Prints the information of the image to standard output.
QToolBar * fileToolBar
Some actions from file menu.
void updateWindowsWithAutoLevel()
Updates the windows with auto levelling.
void SetSize(int height, int width)
Set the size of the display window.
milxQtWindow * currentWindow()
Get the current window opened in the current tab.
milxQtModel * activeModel()
Returns the milxQtModel object, returns 0 if active window is not a milxQtModel object.
QMenu * menuHelp
Help menu.
bool isActiveModel()
Returns true if active window is an Model (milxQtModel object)
int windowIterator
Keep track of current window being traversed.
void unify()
Add the active window to the current multi (unified) display.
QString openSupport
Load file extension support list, cats all known extensions.
void setView(int viewMode)
Change view to view mode identified by number. 0-axial, 1-coronal, 2-sagittal.
void openRecentFile()
Opens recent file (from recent file menu) for analysis and display.
bool timestamping
Prefer showing timestamp?
void updateWindowsWithViewOrientation(int value)
Updates the windows view orientation based on orientation set, such as from a combo box etc...
void imageToSurface(vtkSmartPointer< vtkImageData > img, const float value=numeric_limits< float >::max())
Compute image to surface process.
bool debugMode
Debug output mode?
void preferences()
Show the preferences for the program.
vtkSmartPointer< vtkMatrix4x4 > getTransformMatrix()
Internal transform matrix used to transform actors appropriately for direction and coordinate systems...
void initialiseWindowTraversal()
Initialise the window iterator to the first window opened.
void linkProgressEventOf(vtkObject *obj)
Link the progress of filters etc to keep the UI responsive.
void background(bool white=false)
Changes background to white.
milxQtMain(QWidget *theParent=0)
The standard constructor.
milxQtModel * nextModel()
Get the next model opened in the current tab.
void setDefaultView(int viewMode)
Change default view to view mode identified by number. 0-axial, 1-coronal, 2-sagittal.
QAction * actionAverageImages
average images batch operation action
QAction * actionCloseActive
Close active window in tab action.
QAction * actionNewTab
New Tab action.
void createMenu()
Creates the menu actions.
void about()
Show the about information.
void save(QString filename="")
Saves the data in the current tab to file. The saving is content sensitive and depends on the extensi...
void openSeries()
Opens a DICOM series for viewing in the same window.
void refresh()
Refresh the display of the model including widgets. Camera remains as is.
milxQtRenderWindow * activeRender()
Returns the milxQtRenderWindow object, returns 0 if active window is not a milxQtRenderWindow object...
QAction * actionLinkWindows
Using linked cameras for all windows in a tab?
bool isActivePlot()
Returns true if active window is an Plot (milxQtPlot object)
void writeSettings()
Write the necessary GUI settings/state for the main class.
void autoLevel(float percentile=0.99)
Auto window level the display. Uses Otsu threshold value.
void printWarning(QString msg)
Warning message wrapper for console.
bool isActiveRender()
Returns true if active window is a generic render (milxQtRenderWindow object)
void saveScreen(QString filename="")
Saves a screenshot of the active window in the current tab to file. The saving is content sensitive a...
A console (tabbed) widget class for displaying information such as logs, terminals and consoles...
This class represents the MILX Qt Main Window object using Qt.
void setTabName(QWidget *fromWindow)
Set the tab name.
void updateWindowsWithRefresh()
Updates the windows with default views and window levels.
void dragEnterEvent(QDragEnterEvent *event)
Part of the Drag and Drop feature members. Tells what drags to accept.
QToolBar * defaultToolBar
Some actions from default stuff menu, like view etc.
void dropEvent(QDropEvent *event)
Part of the Drag and Drop feature members. Opens the dropped files.
QAction * actionMultiplyImages
multiply images batch operation action
QActionGroup * updateWindowMenu()
Updates the windows list in the windows menu.
void openCollection()
Opens a collection of models for viewing in the same window.
void imageToPlot(vtkSmartPointer< vtkImageData > img, int displaceAxis=2)
Display image as a surface plot.
void setDefaultOrientation(int orientMode)
Change orientation mode to one of the supported standards. Default: Radiological. ...
void setSlice(int slice)
Sets the slice of the volume to slice value given.
void refresh()
Refresh display.
void updateRecentFileActions()
Updates the recent files list in the file menu.
milxQtUnifiedWindow * activeUnifiedWindow()
Returns the milxQtUnifiedWindow object, returns 0 if active window is not a milxQtUnifiedWindow objec...
virtual void background(bool white=false)
Changes background to white.
void createToolBars()
Creates the toolbar for the main window.
void imagesAdd()
Add all open images together to create new image.
QAction * actionAddImages
add images batch operation action
QTabWidget * workspaces
Pointer to the Workspace environment for the user.
void closeTabAllWindows()
Close all the windows in the current tab.
unsigned NumberOfProcessors()
Number of processors or cores on the machine.
void working(int value)
Show progress bar when computing work. NEgative value shows a busy bar.
static itk::SmartPointer< TImage > SubsampleImage(itk::SmartPointer< TImage > img, typename TImage::SizeType factors)
Subsamples or shrinks the current image using the factors provided.
int magnifyFactor
Screenshot magnify factor.
size_t progressCallCount
Takes account of how many calls of working have been made.
void redirectWindowActivated(QWidget *win)
Redirect the workspace signal to milxQtMain object level.
QPointer< milxQtConsole > console
console docked window
QAction * actionOpen
open action
void disableOrient()
Disables orientation marker.
void imagesMultiply()
Multiply all open images together to create new image.
QList< QPointer< milxQtImage > > imageWindows
List of model windows opened.
virtual void colourMapToJet(double minRange=0.0, double maxRange=0.0)
Change the colour map to Jet.
QAction * actionSaveScreen
save action
void addImage(milxQtImage *img)
Adds an image widget and links its results.