1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
20 #include <QMessageBox>
21 #include <QInputDialog>
23 #include "QTreePushButton.h"
26 #include "vvMainWindow.h"
27 #include "vvHelpDialog.h"
28 #include "vvDocumentation.h"
29 #include "vvProgressDialog.h"
30 #include "vvQDicomSeriesSelector.h"
31 #include "vvSlicerManager.h"
32 #include "clitkImageCommon.h"
34 #include "vvInteractorStyleNavigator.h"
35 #include "vvImageWriter.h"
36 #include "vvSegmentationDialog.h"
37 #include "vvSurfaceViewerDialog.h"
38 #include "vvDeformationDialog.h"
39 #include "vvImageWarp.h"
41 #include "vvMidPosition.h"
43 #include "vvStructSelector.h"
44 #include "vvMeshReader.h"
45 #include "vvConstants.h"
46 #include "clitkConfiguration.h"
50 #include "itkImageFileReader.h"
51 #include "itkByteSwapper.h"
52 #include "itkCommand.h"
53 #include "itkNumericSeriesFileNames.h"
56 #include "vtkImageData.h"
57 #include "vtkImageActor.h"
58 #include "vtkCornerAnnotation.h"
59 #include "vtkRenderWindow.h"
60 #include "vtkRenderWindowInteractor.h"
61 #include "vtkRenderer.h"
62 #include "vtkRendererCollection.h"
63 #include "vtkWindowToImageFilter.h"
64 #include "vtkBMPWriter.h"
65 #include "vtkTIFFWriter.h"
66 #include "vtkPNMWriter.h"
67 #include "vtkPNGWriter.h"
68 #include "vtkJPEGWriter.h"
69 #include "vtkMatrix4x4.h"
70 #include "vtkTransform.h"
78 #define COLUMN_UL_VIEW 1
79 #define COLUMN_UR_VIEW 2
80 #define COLUMN_DL_VIEW 3
81 #define COLUMN_DR_VIEW 4
82 #define COLUMN_CLOSE_IMAGE 5
83 #define COLUMN_RELOAD_IMAGE 6
84 #define COLUMN_IMAGE_NAME 7
86 #define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.hdr *.vox *.his *.xdr *.SCAN )"
89 0,Qt::UserRole full filename
90 1,Qt::CheckStateRole checkbutton UL View
91 1,Qt::UserRole overlay, fusion or vector
92 2,Qt::CheckStateRole checkbutton UR View
93 3,Qt::CheckStateRole checkbutton DL View
94 4,Qt::CheckStateRole checkbutton DR View
96 5,Qt::UserRole mSlicerManager id*/
98 //------------------------------------------------------------------------------
99 vvMainWindow::vvMainWindow():vvMainWindowBase()
101 setupUi(this); // this sets up the GUI
104 mMenuTools = menuTools;
105 // mMenuSegmentation = menuSegmentation;
106 mContextMenu = &contextMenu;
107 mMenuExperimentalTools = menuExperimental;
110 mCurrentSelectedImageId = "";
111 mCurrentPickedImageId = "";
112 mCurrentPickedImageIndex = 0;
114 //Init the contextMenu
115 this->setContextMenuPolicy(Qt::CustomContextMenu);
116 contextActions.resize(0);
117 QAction* actionOpen_new_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/fileopen.png")),
118 tr("O&pen new Image"));
119 actionOpen_new_image->setShortcut(QKeySequence(tr("Ctrl+O")));
120 connect(actionOpen_new_image,SIGNAL(triggered()),this,SLOT(OpenImages()));
121 contextActions.push_back(actionOpen_new_image);
122 contextMenu.addSeparator();
124 QAction* actionClose_Image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/exit.png")),
125 tr("Close Current Image"));
126 connect(actionClose_Image,SIGNAL(triggered()),this,SLOT(CloseImage()));
127 contextActions.push_back(actionClose_Image);
129 QAction* actionReload_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/rotateright.png")),
130 tr("Reload Current Image"));
131 connect(actionReload_image,SIGNAL(triggered()),this,SLOT(ReloadImage()));
132 contextActions.push_back(actionReload_image);
134 QAction* actionSave_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/filesave.png")),
135 tr("Save Current Image"));
136 connect(actionSave_image,SIGNAL(triggered()),this,SLOT(SaveAs()));
137 contextActions.push_back(actionSave_image);
139 contextMenu.addSeparator();
141 contextMenu.addAction(actionAdd_VF_to_current_Image);
142 contextActions.push_back(actionAdd_VF_to_current_Image);
144 QAction* actionAdd_Overlay_to_current_Image = menuOverlay->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
145 tr("Add overlay image to current image"));
146 contextMenu.addAction(actionAdd_Overlay_to_current_Image);
147 contextActions.push_back(actionAdd_Overlay_to_current_Image);
149 connect(actionAdd_Overlay_to_current_Image,SIGNAL(triggered()), this,SLOT(SelectOverlayImage()));
151 contextMenu.addAction(actionAdd_fusion_image);
152 connect(actionAdd_fusion_image,SIGNAL(triggered()),this,SLOT(SelectFusionImage()));
153 contextActions.push_back(actionAdd_fusion_image);
157 QMenu * m = new QMenu(menubar);
159 // m->setObjectName(QString::fromUtf8("TOTOTO"));
160 contextMenu.addMenu(m);
161 QAction * a = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
163 QAction * b = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
167 connect(a,SIGNAL(triggered()),this,SLOT(AddFusionImage()));
171 mSlicerManagers.resize(0);
181 header.append("Name");
183 DataTree->setHeaderLabels(header);
184 DataTree->resizeColumnToContents(COLUMN_TREE);
185 DataTree->resizeColumnToContents(COLUMN_UL_VIEW);
186 DataTree->resizeColumnToContents(COLUMN_UR_VIEW);
187 DataTree->resizeColumnToContents(COLUMN_DL_VIEW);
188 DataTree->resizeColumnToContents(COLUMN_DR_VIEW);
189 DataTree->resizeColumnToContents(COLUMN_CLOSE_IMAGE);
190 DataTree->resizeColumnToContents(COLUMN_RELOAD_IMAGE);
191 DataTree->resizeColumnToContents(COLUMN_IMAGE_NAME);
194 documentation = new vvDocumentation();
195 help_dialog = new vvHelpDialog();
196 dicomSeriesSelector = new vvDicomSeriesSelector();
198 inverseButton->setEnabled(0);
199 actionAdd_Overlay_to_current_Image->setEnabled(0);
200 actionSave_As->setEnabled(0);
201 actionAdd_VF_to_current_Image->setEnabled(0);
202 actionAdd_fusion_image->setEnabled(0);
205 verticalSliders.push_back(NOVerticalSlider);
206 verticalSliders.push_back(NEVerticalSlider);
207 verticalSliders.push_back(SOVerticalSlider);
208 verticalSliders.push_back(SEVerticalSlider);
210 for (int i =0; i < 4; i++)
211 verticalSliders[i]->hide();
213 horizontalSliders.push_back(NOHorizontalSlider);
214 horizontalSliders.push_back(NEHorizontalSlider);
215 horizontalSliders.push_back(SOHorizontalSlider);
216 horizontalSliders.push_back(SEHorizontalSlider);
218 for (int i =0; i < 4; i++)
219 horizontalSliders[i]->hide();
222 connect(NOVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(NOVerticalSliderChanged()));
223 connect(NEVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(NEVerticalSliderChanged()));
224 connect(SOVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(SOVerticalSliderChanged()));
225 connect(SEVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(SEVerticalSliderChanged()));
227 connect(NOHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(NOHorizontalSliderMoved()));
228 connect(NEHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(NEHorizontalSliderMoved()));
229 connect(SOHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(SOHorizontalSliderMoved()));
230 connect(SEHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(SEHorizontalSliderMoved()));
233 connect(actionCompute_mid_position_image,SIGNAL(triggered()),this,SLOT(ComputeMidPosition()));
234 connect(actionDeformable_Registration,SIGNAL(triggered()),this,SLOT(ComputeDeformableRegistration()));
235 connect(actionWarp_image_with_vector_field,SIGNAL(triggered()),this,SLOT(WarpImage()));
236 connect(actionLoad_images,SIGNAL(triggered()),this,SLOT(OpenImages()));
237 connect(actionOpen_Dicom,SIGNAL(triggered()),this,SLOT(OpenDicom()));
238 connect(actionOpen_Dicom_Struct,SIGNAL(triggered()),this,SLOT(OpenDCStructContour()));
239 connect(actionOpen_VTK_contour,SIGNAL(triggered()),this,SLOT(OpenVTKContour()));
240 connect(actionOpen_Multiple_Images_As_One,SIGNAL(triggered()),this,SLOT(MergeImages()));
241 connect(actionSlice_Image_As_Multiple_Images,SIGNAL(triggered()),this,SLOT(SliceImages()));
242 connect(actionOpen_Image_With_Time,SIGNAL(triggered()),this,SLOT(OpenImageWithTime()));
243 connect(actionMerge_images_as_n_dim_t, SIGNAL(triggered()), this, SLOT(MergeImagesWithTime()));
244 connect(actionSave_As,SIGNAL(triggered()),this,SLOT(SaveAs()));
245 connect(actionExit,SIGNAL(triggered()),this,SLOT(close()));
246 connect(actionAdd_VF_to_current_Image,SIGNAL(triggered()),this,SLOT(OpenField()));
247 connect(actionNavigation_Help,SIGNAL(triggered()),this,SLOT(ShowHelpDialog()));
248 connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation()));
250 ///////////////////////////////////////////////
251 connect(actionSegmentation,SIGNAL(triggered()),this,SLOT(SegmentationOnCurrentImage()));
252 connect(actionSurface_Viewer,SIGNAL(triggered()),this,SLOT(SurfaceViewerLaunch()));
253 ///////////////////////////////////////////////
255 actionNorth_East_Window->setEnabled(0);
256 actionNorth_West_Window->setEnabled(0);
257 actionSouth_East_Window->setEnabled(0);
258 actionSouth_West_Window->setEnabled(0);
260 connect(actionNorth_East_Window,SIGNAL(triggered()),this,SLOT(SaveNEScreenshot()));
261 connect(actionNorth_West_Window,SIGNAL(triggered()),this,SLOT(SaveNOScreenshot()));
262 connect(actionSouth_East_Window,SIGNAL(triggered()),this,SLOT(SaveSEScreenshot()));
263 connect(actionSouth_West_Window,SIGNAL(triggered()),this,SLOT(SaveSOScreenshot()));
265 connect(DataTree,SIGNAL(itemSelectionChanged()),this,SLOT(ImageInfoChanged()));
266 connect(DataTree,SIGNAL(itemClicked(QTreeWidgetItem*, int)),this,
267 SLOT(DisplayChanged(QTreeWidgetItem*, int)));
269 connect(viewButton,SIGNAL(clicked()),this, SLOT(ChangeViewMode()) );
270 connect(windowSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited()));
271 connect(levelSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited()));
272 connect(colorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateColorMap()));
273 connect(presetComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateWindowLevel()));
274 connect(inverseButton,SIGNAL(clicked()),this,SLOT(SwitchWindowLevel()));
275 connect(applyWindowLevelToAllButton,SIGNAL(clicked()),this,SLOT(ApplyWindowLevelToAllImages()));
278 connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(ShowContextMenu(QPoint)));
280 connect(linkPanel,SIGNAL(addLink(QString,QString)),this,SLOT(AddLink(QString,QString)));
281 connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString)));
282 connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int,int,double,double,double)),this,SLOT(SetVFProperty(int,int,int,int,double,double,double)));
283 connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int)),this,SLOT(SetOverlayProperty(int)));
284 connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,double,double)),
285 this,SLOT(SetFusionProperty(int,int,double,double)));
286 connect(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows()));
290 playButton->setEnabled(0);
291 frameRateLabel->setEnabled(0);
292 frameRateSpinBox->setEnabled(0);
293 connect(playButton, SIGNAL(clicked()),this,SLOT(PlayPause()));
294 connect(frameRateSpinBox, SIGNAL(valueChanged(int)),this,SLOT(ChangeFrameRate(int)));
296 goToCursorPushButton->setEnabled(0);
297 connect(goToCursorPushButton, SIGNAL(clicked()),this,SLOT(GoToCursor()));
299 NOViewWidget->hide();
300 NEViewWidget->hide();
301 SOViewWidget->hide();
302 SEViewWidget->hide();
304 //Recently opened files
305 std::list<std::string> recent_files = GetRecentlyOpenedImages();
306 if ( !recent_files.empty() ) {
307 QMenu * rmenu = new QMenu("Recently opened files...");
308 rmenu->setIcon(QIcon(QString::fromUtf8(":/common/icons/open.png")));
309 menuFile->insertMenu(actionOpen_Image_With_Time,rmenu);
310 menuFile->insertSeparator(actionOpen_Image_With_Time);
311 for (std::list<std::string>::iterator i = recent_files.begin(); i!=recent_files.end(); i++) {
312 QAction* current=new QAction(QIcon(QString::fromUtf8(":/common/icons/open.png")),
314 rmenu->addAction(current);
315 connect(current,SIGNAL(triggered()),this,SLOT(OpenRecentImage()));
319 // Adding all new tools (insertion in the menu)
320 vvToolManager::GetInstance()->InsertToolsInMenu(this);
322 if (!CLITK_EXPERIMENTAL)
323 menuExperimental->menuAction()->setVisible(false);
326 QTimer * timerMemory = new QTimer(this);
327 //timerMemory->setInterval(5);
328 connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage()));
329 timerMemory->start(2000);
332 //------------------------------------------------------------------------------
335 //------------------------------------------------------------------------------
336 void vvMainWindow::UpdateMemoryUsage()
338 // clitk::PrintMemory(true);
339 if (clitk::GetMemoryUsageInMb() == 0) infoPanel->setMemoryInMb("NA");
340 else infoPanel->setMemoryInMb(QString::number(clitk::GetMemoryUsageInMb())+" MiB");
342 //------------------------------------------------------------------------------
345 //------------------------------------------------------------------------------
346 void vvMainWindow::ComputeMidPosition()
349 int index=GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
350 int ref = QInputDialog::getInteger(this,"Chose reference phase","Reference phase",0,0,\
351 mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
354 midp.slicer_manager = mSlicerManagers[index];
355 midp.reference_image_index = ref;
356 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
359 QMessageBox::warning(this, "Error computing midposition image",midp.error_message.c_str());
361 QFileInfo info(midp.slicer_manager->GetFileName().c_str());
362 AddImage(midp.output,info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_midposition.mhd");
364 QApplication::restoreOverrideCursor();
367 //------------------------------------------------------------------------------
370 //------------------------------------------------------------------------------
371 void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool propagation)
373 QTreeWidgetItem *item = new QTreeWidgetItem();
374 item->setData(0,Qt::UserRole,"filename.vtk");
375 item->setData(1,Qt::UserRole,tr("contour"));
377 brush.setColor(QColor(contour->r*255,contour->g*255,contour->b*255));
378 brush.setStyle(Qt::SolidPattern);
379 item->setData(COLUMN_IMAGE_NAME,Qt::BackgroundRole,brush);
380 item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,contour->structure_name.c_str());
382 for (int j = 1; j <= 4; j++)
383 item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(image_index)->data(j,Qt::CheckStateRole));
385 QTreePushButton* cButton = new QTreePushButton;
386 cButton->setItem(item);
387 cButton->setColumn(COLUMN_CLOSE_IMAGE);
388 cButton->setToolTip(tr("close image"));
389 cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png")));
390 connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
391 this,SLOT(CloseImage(QTreeWidgetItem*, int)));
393 QTreePushButton* rButton = new QTreePushButton;
394 rButton->setItem(item);
395 rButton->setColumn(COLUMN_RELOAD_IMAGE);
396 rButton->setToolTip(tr("reload image"));
397 rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png")));
398 rButton->setEnabled(false);
400 //connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
401 //this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
403 DataTree->topLevelItem(image_index)->setExpanded(1);
404 DataTree->topLevelItem(image_index)->addChild(item);
405 DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
406 DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
407 QString id = DataTree->topLevelItem(image_index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
408 item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
411 mSlicerManagers[image_index]->AddContour(contour,propagation);
412 mSlicerManagers[image_index]->Render();
414 //------------------------------------------------------------------------------
417 //------------------------------------------------------------------------------
418 void vvMainWindow::OpenVTKContour()
420 if (mSlicerManagers.size() > 0) {
421 QString Extensions = "Images ( *.vtk *.obj)";
422 Extensions += ";;All Files (*)";
423 QString file = QFileDialog::getOpenFileName(this,tr("Open vtkPolyData"),mInputPathName,Extensions);
426 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
427 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
429 reader.SetImage(mSlicerManagers[index]->GetImage());
430 reader.SetModeToVTK();
431 reader.SetFilename(file.toStdString());
433 AddContour(index,reader.GetOutput()[0],false);
434 QApplication::restoreOverrideCursor();
437 //------------------------------------------------------------------------------
440 //------------------------------------------------------------------------------
441 void vvMainWindow::OpenDCStructContour()
443 if (mSlicerManagers.size() > 0) {
444 QString Extensions = "Dicom Files ( *.dcm RS*)";
445 Extensions += ";;All Files (*)";
446 QString file = QFileDialog::getOpenFileName(this,tr("Merge Images"),mInputPathName,Extensions);
449 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
451 reader.SetFilename(file.toStdString());
452 vvStructSelector selector;
453 selector.SetStructures(reader.GetROINames());
454 if (!mSlicerManagers[index]->GetVF().IsNull())
455 selector.EnablePropagationCheckBox();
456 if (selector.exec()) {
457 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
458 reader.SetSelectedItems(selector.getSelectedItems());
459 reader.SetImage(mSlicerManagers[index]->GetImage());
460 if (selector.PropagationEnabled())
461 reader.SetPropagationVF(mSlicerManagers[index]->GetVF());
463 std::vector<vvMesh::Pointer> contours=reader.GetOutput();
464 for (std::vector<vvMesh::Pointer>::iterator i=contours.begin();
465 i!=contours.end(); i++)
466 AddContour(index,*i,selector.PropagationEnabled());
467 QApplication::restoreOverrideCursor();
471 //------------------------------------------------------------------------------
474 //------------------------------------------------------------------------------
475 void vvMainWindow::ComputeDeformableRegistration()
477 if (mSlicerManagers.size() > 0) {
478 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
479 vvDeformationDialog dialog(index,mSlicerManagers);
481 std::string base_name=itksys::SystemTools::GetFilenameWithoutExtension(mSlicerManagers[dialog.GetInputFileIndex()]->GetFileName());
482 AddField(dialog.GetOutput(),dialog.getFieldFile(),dialog.GetInputFileIndex());
483 WarpImage(dialog.GetSelectedSlicer(),dialog.GetReferenceFrameIndex());
485 std::cout << "Error or user cancellation while computing deformation field..." << std::endl;
486 } else QMessageBox::information(this, "Need to open image","You must open an image first.");
488 //------------------------------------------------------------------------------
491 //------------------------------------------------------------------------------
492 void vvMainWindow::WarpImage()
494 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
495 if (!mSlicerManagers[index]->GetVF().IsNull()) {
497 int ref = QInputDialog::getInteger(this,"Chose reference phase","Reference phase",0,0,\
498 mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
500 WarpImage(mSlicerManagers[index],ref);
503 QMessageBox::warning(this,tr("No vector field"),tr("Sorry, can't warp without a vector field"));
505 //------------------------------------------------------------------------------
508 //------------------------------------------------------------------------------
509 void vvMainWindow::WarpImage(vvSlicerManager* selected_slicer,int reference_phase)
511 if (!selected_slicer->GetVF().IsNull()) {
512 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
513 QFileInfo info(selected_slicer->GetFileName().c_str());
514 vvImageWarp warp(selected_slicer->GetImage(),selected_slicer->GetVF(),
515 reference_phase,this);
516 if (warp.ComputeWarpedImage()) {
517 AddImage(warp.GetWarpedImage(),info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_warped.mhd");
518 AddImage(warp.GetDiffImage() ,info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_diff.mhd");
519 AddImage(warp.GetJacobianImage() ,info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_jacobian.mhd");
520 QApplication::restoreOverrideCursor();
522 QApplication::restoreOverrideCursor();
523 QMessageBox::warning(this,tr("Different spacings"),tr("The vector field and image spacings must be the same in order to warp."));
526 QMessageBox::warning(this,tr("No vector field"),tr("Sorry, can't warp without a vector field."));
528 //------------------------------------------------------------------------------
531 //------------------------------------------------------------------------------
532 vvMainWindow::~vvMainWindow()
534 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
535 if (mSlicerManagers[i] != NULL)
536 delete mSlicerManagers[i];
539 //------------------------------------------------------------------------------
541 //------------------------------------------------------------------------------
542 QTabWidget * vvMainWindow::GetTab()
546 //------------------------------------------------------------------------------
549 //------------------------------------------------------------------------------
550 void vvMainWindow::MergeImages()
552 QString Extensions = EXTENSIONS;
553 Extensions += ";;All Files (*)";
554 QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images"),mInputPathName,Extensions);
557 mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
558 std::vector<std::string> vector;
560 unsigned int currentDim = 0;
561 std::vector<double> currentSpacing;
562 std::vector<int> currentSize;
563 std::vector<double> currentOrigin;
565 for (int i = 0; i < files.size(); i++) {
566 itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
567 files[i].toStdString().c_str(), itk::ImageIOFactory::ReadMode);
568 reader->SetFileName(files[i].toStdString().c_str());
569 reader->ReadImageInformation();
571 //NOViewWidget->hide();
572 //NEViewWidget->hide();
573 //SOViewWidget->hide();
574 //SEViewWidget->hide();
576 currentDim = reader->GetNumberOfDimensions();
578 for (unsigned int j = 0; j < currentDim; j++) {
581 currentSpacing.resize(currentDim);
582 currentSize.resize(currentDim);
583 currentOrigin.resize(currentDim);
585 currentOrigin[j] = reader->GetOrigin(j);
586 currentSpacing[j] = reader->GetSpacing(j);
587 currentSize[j] = reader->GetDimensions(j);
588 } else if (currentDim != reader->GetNumberOfDimensions()
589 || currentSpacing[j] != reader->GetSpacing(j)
590 || currentSize[j] != (int)reader->GetDimensions(j)
591 || currentOrigin[j] != reader->GetOrigin(j)) {
592 QString error = "Cannot read file (too different from others ";
593 error += files[i].toStdString().c_str();
594 QMessageBox::information(this,tr("Reading problem"),error);
600 vector.push_back(files[i].toStdString());
603 if (vector.size() > 0)
604 LoadImages(vector, MERGED);
606 //------------------------------------------------------------------------------
608 //------------------------------------------------------------------------------
609 void vvMainWindow::SliceImages()
611 QString Extensions = EXTENSIONS;
612 Extensions += ";;All Files (*)";
614 QStringList files = QFileDialog::getOpenFileNames(this,tr("Slice Images"),mInputPathName,Extensions);
617 mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
618 std::vector<std::string> vector;
619 for (int i = 0; i < files.size(); i++)
620 vector.push_back(files[i].toStdString());
621 LoadImages(vector, SLICED);
623 //------------------------------------------------------------------------------
625 //------------------------------------------------------------------------------
626 void vvMainWindow::MergeImagesWithTime()
628 QString Extensions = EXTENSIONS;
629 Extensions += ";;All Files (*)";
630 QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images With Time"),mInputPathName,Extensions);
633 mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
634 std::vector<std::string> vector;
636 unsigned int currentDim = 0;
637 std::vector<double> currentSpacing;
638 std::vector<int> currentSize;
639 std::vector<double> currentOrigin;
641 for (int i = 0; i < files.size(); i++) {
642 itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
643 files[i].toStdString().c_str(), itk::ImageIOFactory::ReadMode);
645 reader->SetFileName(files[i].toStdString().c_str());
646 reader->ReadImageInformation();
648 currentDim = reader->GetNumberOfDimensions();
650 for (unsigned int j = 0; j < currentDim; j++) {
653 currentSpacing.resize(currentDim);
654 currentSize.resize(currentDim);
655 currentOrigin.resize(currentDim);
657 currentOrigin[j] = reader->GetOrigin(j);
658 currentSpacing[j] = reader->GetSpacing(j);
659 currentSize[j] = reader->GetDimensions(j);
660 } else if (currentDim != reader->GetNumberOfDimensions()
661 || currentSpacing[j] != reader->GetSpacing(j)
662 || currentSize[j] != (int)reader->GetDimensions(j)
663 || currentOrigin[j] != reader->GetOrigin(j)) {
664 QString error = "Cannot read file (too different from others ";
665 error += files[i].toStdString().c_str();
666 QMessageBox::information(this,tr("Reading problem"),error);
672 vector.push_back(files[i].toStdString());
674 QString error = "Cannot read file info for ";
675 error += files[i].toStdString().c_str();
677 error += "Maybe you're trying to open an image in an unsupported format?\n";
678 QMessageBox::information(this,tr("Reading problem"),error);
681 sort(vector.begin(),vector.end());
682 if (vector.size() > 1)
683 LoadImages(vector, MERGEDWITHTIME);
685 QMessageBox::warning(this,tr("Reading problem"),"You need to select at least two images to merge images with time.\nIf you only want to open one image, please use the \"Open Image\" function.");
687 //------------------------------------------------------------------------------
690 //------------------------------------------------------------------------------
691 void vvMainWindow::OpenDicom()
693 std::vector<std::string> files;
695 std::cout << "dicomSeriesSelector " << std::endl;
696 if (dicomSeriesSelector->exec() == QDialog::Accepted) {
697 files = *(dicomSeriesSelector->GetFilenames());
698 LoadImages(files,DICOM);
701 //------------------------------------------------------------------------------
703 //------------------------------------------------------------------------------
704 void vvMainWindow::OpenImages()
706 QString Extensions = EXTENSIONS;
707 Extensions += ";;All Files (*)";
709 QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Images"),mInputPathName,Extensions);
712 mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
713 std::vector<std::string> vector;
714 for (int i = 0; i < files.size(); i++)
715 vector.push_back(files[i].toStdString());
716 LoadImages(vector, IMAGE);
718 //------------------------------------------------------------------------------
719 void vvMainWindow::OpenRecentImage()
721 QAction * caller = qobject_cast<QAction*>(sender());
722 std::vector<std::string> images;
723 images.push_back(caller->text().toStdString());
724 mInputPathName = itksys::SystemTools::GetFilenamePath(images[0]).c_str();
725 LoadImages(images,IMAGE);
727 //------------------------------------------------------------------------------
730 //------------------------------------------------------------------------------
731 void vvMainWindow::OpenImageWithTime()
733 QString Extensions = EXTENSIONS;
734 Extensions += ";;All Files (*)";
736 QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Images With Time"),mInputPathName,Extensions);
739 mInputPathName = itksys::SystemTools::GetFilenamePath(files[0].toStdString()).c_str();
740 std::vector<std::string> vector;
741 for (int i = 0; i < files.size(); i++) {
742 vector.push_back(files[i].toStdString());
744 LoadImages(vector, IMAGEWITHTIME);
746 //------------------------------------------------------------------------------
749 //------------------------------------------------------------------------------
750 void vvMainWindow::LoadImages(std::vector<std::string> files, LoadedImageType filetype)
752 //Separate the way to open images and dicoms
754 if (filetype == IMAGE || filetype == IMAGEWITHTIME)
755 fileSize = files.size();
759 // For SLICED, we need the number of slices (ndim and #slices)
760 std::vector<unsigned int> nSlices;
761 nSlices.resize(files.size());
762 std::fill(nSlices.begin(), nSlices.end(), 1);
763 if (filetype == SLICED) {
764 for (int i = 0; i < fileSize; i++) {
765 itk::ImageIOBase::Pointer header = clitk::readImageHeader(files[i]);
766 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
769 QString error = "Cannot open file \n";
770 error += files[i].c_str();
771 QMessageBox::information(this,tr("Reading problem"),error);
774 if (header->GetNumberOfDimensions() < 3) {
776 QString error = "Dimension problem. Cannot slice \n";
777 error += files[i].c_str();
778 QMessageBox::information(this,tr("Reading problem"),error);
781 nSlices[i] = header->GetDimensions( header->GetNumberOfDimensions()-1 );
785 //Only add to the list of recently opened files when a single file is opened,
786 //to avoid polluting the list of recently opened files
787 if (files.size() == 1) {
788 QFileInfo finfo=tr(files[0].c_str());
789 AddToRecentlyOpenedImages(finfo.absoluteFilePath().toStdString());
791 //init the progress events
792 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
793 vvProgressDialog progress("Opening " + files[0],fileSize>1);
794 qApp->processEvents();
796 int numberofsuccesulreads=0;
797 //open images as 1 or multiples
798 for (int i = 0; i < fileSize; i++) {
800 progress.SetText("Opening " + files[i]);
801 progress.SetProgress(i,fileSize);
802 qApp->processEvents();
804 for (unsigned int j = 0; j < nSlices[i]; j++) {
805 //read the image and put it in mSlicerManagers
806 vvSlicerManager* imageManager = new vvSlicerManager(4);
807 qApp->processEvents();
809 bool SetImageSucceed=false;
811 // Change filename if an image with the same already exist
812 int number = GetImageDuplicateFilenameNumber(files[i] + std::string("_slice"));
814 if (filetype == IMAGE || filetype == IMAGEWITHTIME || filetype == SLICED)
815 SetImageSucceed = imageManager->SetImage(files[i],filetype, number, j);
817 SetImageSucceed = imageManager->SetImages(files,filetype, number);
819 if (!SetImageSucceed) {
820 QApplication::restoreOverrideCursor();
821 QString error = "Cannot open file \n";
822 error += imageManager->GetLastError().c_str();
823 QMessageBox::information(this,tr("Reading problem"),error);
826 mSlicerManagers.push_back(imageManager);
828 //create an item in the tree with good settings
829 QTreeWidgetItem *item = new QTreeWidgetItem();
830 item->setData(0,Qt::UserRole,files[i].c_str());
831 QFileInfo fileinfo(imageManager->GetFileName().c_str()); //Do not show the path
832 item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
833 item->setToolTip(COLUMN_IMAGE_NAME,fileinfo.absoluteFilePath());
834 qApp->processEvents();
836 //Create the buttons for reload and close
837 qApp->processEvents();
838 QTreePushButton* cButton = new QTreePushButton;
839 cButton->setItem(item);
840 cButton->setColumn(COLUMN_CLOSE_IMAGE);
841 cButton->setToolTip(tr("close image"));
842 cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png")));
843 connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
844 this,SLOT(CloseImage(QTreeWidgetItem*, int)));
846 QTreePushButton* rButton = new QTreePushButton;
847 rButton->setItem(item);
848 rButton->setColumn(COLUMN_RELOAD_IMAGE);
849 rButton->setToolTip(tr("reload image"));
850 rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png")));
851 connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
852 this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
854 DataTree->addTopLevelItem(item);
855 DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
856 DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
858 //set the id of the image
859 QString id = files[i].c_str() + QString::number(mSlicerManagers.size()-1);
860 item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
861 mSlicerManagers.back()->SetId(id.toStdString());
863 linkPanel->addImage(imageManager->GetFileName(), id.toStdString());
865 connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)),
866 this,SLOT(CurrentImageChanged(std::string)));
867 connect(mSlicerManagers.back(), SIGNAL(currentPickedImageChanged(std::string)),
868 this, SLOT(CurrentPickedImageChanged(std::string)));
869 connect(mSlicerManagers.back(), SIGNAL(UpdatePosition(int, double, double, double, double, double, double, double)),
870 this,SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
871 connect(mSlicerManagers.back(), SIGNAL(UpdateVector(int, double, double, double, double)),
872 this, SLOT(VectorChanged(int,double,double,double, double)));
873 connect(mSlicerManagers.back(), SIGNAL(UpdateOverlay(int, double, double)),
874 this, SLOT(OverlayChanged(int,double,double)));
875 connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
876 this, SLOT(FusionChanged(int,double)));
877 connect(mSlicerManagers.back(), SIGNAL(UpdateWindows(int, int, int)),
878 this,SLOT(WindowsChanged(int, int, int)));
879 connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)),
880 this,SLOT(WindowLevelChanged(double, double, int, int)));
881 connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
882 this,SLOT(UpdateSlice(int,int)));
883 connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)),
884 this,SLOT(UpdateTSlice(int, int)));
885 connect(mSlicerManagers.back(), SIGNAL(UpdateSliceRange(int,int,int,int,int)),
886 this,SLOT(UpdateSliceRange(int,int,int,int,int)));
887 connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
888 this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int)));
889 connect(mSlicerManagers.back(), SIGNAL(UpdateLinkedNavigation(std::string,vvSlicerManager*)),
890 this,SLOT(UpdateLinkedNavigation(std::string,vvSlicerManager*)));
891 connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)),
892 this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)));
893 connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
895 numberofsuccesulreads++;
899 if (numberofsuccesulreads) {
900 NOViewWidget->show();
901 NEViewWidget->show();
902 SOViewWidget->show();
903 SEViewWidget->show();
908 // Try to guess default WindowLevel
910 mSlicerManagers.back()->GetImage()->GetFirstVTKImageData()->GetScalarRange(range);
911 if ((range[0] == 0) && (range[1] == 1)) {
912 presetComboBox->setCurrentIndex(5);// binary
917 QApplication::restoreOverrideCursor();
919 //------------------------------------------------------------------------------
921 //------------------------------------------------------------------------------
922 void vvMainWindow::UpdateTree()
924 DataTree->resizeColumnToContents(COLUMN_TREE);
925 DataTree->resizeColumnToContents(COLUMN_UL_VIEW);
926 DataTree->resizeColumnToContents(COLUMN_UR_VIEW);
927 DataTree->resizeColumnToContents(COLUMN_DL_VIEW);
928 DataTree->resizeColumnToContents(COLUMN_DR_VIEW);
929 DataTree->resizeColumnToContents(COLUMN_IMAGE_NAME);
930 DataTree->resizeColumnToContents(COLUMN_CLOSE_IMAGE);
931 DataTree->resizeColumnToContents(COLUMN_RELOAD_IMAGE);
933 //------------------------------------------------------------------------------
935 //------------------------------------------------------------------------------
936 void vvMainWindow::CurrentImageChanged(std::string id)
938 if (id == mCurrentSelectedImageId) return; // Do nothing
940 for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
941 if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString().toStdString() == id) {
944 DataTree->topLevelItem(i)->setSelected(0);
946 for (int child = 0; child < DataTree->topLevelItem(i)->childCount(); child++)
947 DataTree->topLevelItem(i)->child(child)->setSelected(0);
950 DataTree->topLevelItem(selected)->setSelected(1);
951 mCurrentSelectedImageId = id;
952 emit SelectedImageHasChanged(mSlicerManagers[selected]);
954 //------------------------------------------------------------------------------
956 //------------------------------------------------------------------------------
957 void vvMainWindow::CurrentPickedImageChanged(std::string id)
959 if (id == mCurrentPickedImageId) return; // Do nothing
961 for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
962 if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString().toStdString() == id) {
965 DataTree->topLevelItem(i)->setSelected(0);
967 for (int child = 0; child < DataTree->topLevelItem(i)->childCount(); child++)
968 DataTree->topLevelItem(i)->child(child)->setSelected(0);
971 DataTree->topLevelItem(selected)->setSelected(1);
972 mCurrentPickedImageId = id;
973 mCurrentPickedImageIndex = selected;
975 //------------------------------------------------------------------------------
977 //------------------------------------------------------------------------------
978 void vvMainWindow::ImageInfoChanged()
980 contextActions[6]->setEnabled(1);
981 contextActions[5]->setEnabled(1);
982 actionSave_As->setEnabled(1);
983 actionAdd_VF_to_current_Image->setEnabled(1);
984 actionAdd_fusion_image->setEnabled(1);
985 actionNorth_East_Window->setEnabled(1);
986 actionNorth_West_Window->setEnabled(1);
987 actionSouth_East_Window->setEnabled(1);
988 actionSouth_West_Window->setEnabled(1);
989 inverseButton->setEnabled(1);
991 goToCursorPushButton->setEnabled(1);
993 if (DataTree->selectedItems().size()) {
994 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
996 colorMapComboBox->setEnabled(1);
997 for (int i = 0; i < DataTree->topLevelItem(index)->childCount(); i++) {
998 if (DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "overlay" ||
999 DataTree->topLevelItem(index)->child(i)->data(1,Qt::UserRole).toString() == "fusion") {
1000 colorMapComboBox->setEnabled(0);
1005 std::vector<double> origin;
1006 std::vector<double> inputSpacing;
1007 std::vector<int> inputSize;
1008 std::vector<double> sizeMM;
1009 vtkSmartPointer<vtkMatrix4x4> transformation;
1012 QString inputSizeInBytes;
1013 QString image = DataTree->selectedItems()[0]->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
1015 if (mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size() > 1 || playMode == 1) {
1016 playButton->setEnabled(1);
1017 frameRateLabel->setEnabled(1);
1018 frameRateSpinBox->setEnabled(1);
1020 playButton->setEnabled(0);
1021 frameRateLabel->setEnabled(0);
1022 frameRateSpinBox->setEnabled(0);
1028 vvImage::Pointer imageSelected;
1029 if (DataTree->topLevelItem(index) == DataTree->selectedItems()[0]) {
1030 imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage();
1031 dimension = imageSelected->GetNumberOfDimensions();
1032 origin.resize(dimension);
1033 inputSpacing.resize(dimension);
1034 inputSize.resize(dimension);
1035 sizeMM.resize(dimension);
1036 pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsITKString().c_str();
1037 for (int i = 0; i < dimension; i++) {
1038 origin[i] = imageSelected->GetOrigin()[i];
1039 inputSpacing[i] = imageSelected->GetSpacing()[i];
1040 inputSize[i] = imageSelected->GetSize()[i];
1041 sizeMM[i] = inputSize[i]*inputSpacing[i];
1042 NPixel *= inputSize[i];
1044 inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
1045 } else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "vector") {
1046 imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetVF();
1047 dimension = imageSelected->GetNumberOfDimensions();
1048 origin.resize(dimension);
1049 inputSpacing.resize(dimension);
1050 inputSize.resize(dimension);
1051 sizeMM.resize(dimension);
1052 pixelType = mSlicerManagers[index]->GetVF()->GetScalarTypeAsITKString().c_str();
1053 for (int i = 0; i < dimension; i++) {
1054 origin[i] = imageSelected->GetOrigin()[i];
1055 inputSpacing[i] = imageSelected->GetSpacing()[i];
1056 inputSize[i] = imageSelected->GetSize()[i];
1057 sizeMM[i] = inputSize[i]*inputSpacing[i];
1058 NPixel *= inputSize[i];
1060 inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
1061 } else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "overlay") {
1062 imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetOverlay();
1063 dimension = imageSelected->GetNumberOfDimensions();
1064 origin.resize(dimension);
1065 inputSpacing.resize(dimension);
1066 inputSize.resize(dimension);
1067 sizeMM.resize(dimension);
1068 pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsITKString().c_str();
1069 for (int i = 0; i < dimension; i++) {
1070 origin[i] = imageSelected->GetOrigin()[i];
1071 inputSpacing[i] = imageSelected->GetSpacing()[i];
1072 inputSize[i] = imageSelected->GetSize()[i];
1073 sizeMM[i] = inputSize[i]*inputSpacing[i];
1074 NPixel *= inputSize[i];
1076 inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
1077 } else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "fusion") {
1078 imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetFusion();
1079 dimension = imageSelected->GetNumberOfDimensions();
1080 origin.resize(dimension);
1081 inputSpacing.resize(dimension);
1082 inputSize.resize(dimension);
1083 sizeMM.resize(dimension);
1084 pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsITKString().c_str();
1085 for (int i = 0; i < dimension; i++) {
1086 origin[i] = imageSelected->GetOrigin()[i];
1087 inputSpacing[i] = imageSelected->GetSpacing()[i];
1088 inputSize[i] = imageSelected->GetSize()[i];
1089 sizeMM[i] = inputSize[i]*inputSpacing[i];
1090 NPixel *= inputSize[i];
1092 inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
1095 QString dim = QString::number(dimension) + " (";
1096 dim += pixelType + ")";
1098 infoPanel->setFileName(image);
1099 infoPanel->setDimension(dim);
1100 infoPanel->setSizePixel(GetVectorIntAsString(inputSize));
1101 infoPanel->setSizeMM(GetVectorDoubleAsString(sizeMM));
1102 infoPanel->setOrigin(GetVectorDoubleAsString(origin));
1103 infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
1104 infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
1105 transformation = imageSelected->GetTransform()->GetMatrix();
1106 infoPanel->setTransformation(Get4x4MatrixDoubleAsString(transformation));
1108 landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
1109 mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size());
1110 landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
1111 landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
1113 overlayPanel->getCurrentImageName(mSlicerManagers[index]->GetFileName().c_str());
1114 for (int i = 0; i < 4; i++) {
1115 if (DataTree->selectedItems()[0]->data(i+1,Qt::CheckStateRole).toInt() > 0 || i == 3) {
1116 mSlicerManagers[index]->UpdateInfoOnCursorPosition(i);
1120 windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow());
1121 levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel());
1122 presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset());
1123 colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap());
1125 infoPanel->setFileName(image);
1126 infoPanel->setDimension(dim);
1127 infoPanel->setSizePixel(GetVectorIntAsString(inputSize));
1128 infoPanel->setSizeMM(GetVectorDoubleAsString(sizeMM));
1129 infoPanel->setOrigin(GetVectorDoubleAsString(origin));
1130 infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
1131 infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
1133 landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
1134 mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size());
1135 landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
1136 landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
1138 overlayPanel->getCurrentImageName(mSlicerManagers[index]->GetFileName().c_str());
1139 for (int i = 0; i < 4; i++) {
1140 if (DataTree->selectedItems()[0]->data(i+1,Qt::CheckStateRole).toInt() > 0 || i == 3) {
1141 mSlicerManagers[index]->UpdateInfoOnCursorPosition(i);
1145 windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow());
1146 levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel());
1147 presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset());
1148 colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap());
1150 if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) {
1151 overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
1152 overlayPanel->getVFProperty(mSlicerManagers[index]->GetSlicer(0)->GetVFSubSampling(),
1153 mSlicerManagers[index]->GetSlicer(0)->GetVFScale(),
1154 mSlicerManagers[index]->GetSlicer(0)->GetVFLog());
1156 overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
1157 overlayPanel->getVFProperty(-1,-1,-1);
1159 if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay()) {
1160 overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
1161 overlayPanel->getOverlayProperty(mSlicerManagers[index]->GetOverlayColor());
1163 overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
1164 overlayPanel->getOverlayProperty(-1);
1166 if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
1167 overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
1168 overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(),
1169 mSlicerManagers[index]->GetFusionColorMap(),
1170 mSlicerManagers[index]->GetFusionWindow(),
1171 mSlicerManagers[index]->GetFusionLevel());
1173 overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
1174 overlayPanel->getFusionProperty(-1, -1,-1,-1);
1178 //------------------------------------------------------------------------------
1180 //------------------------------------------------------------------------------
1181 void vvMainWindow::ShowDocumentation()
1183 documentation->show();
1185 //------------------------------------------------------------------------------
1186 void vvMainWindow::ShowHelpDialog()
1188 help_dialog->show();
1190 //------------------------------------------------------------------------------
1192 //------------------------------------------------------------------------------
1193 void vvMainWindow::ChangeViewMode()
1195 QListIterator<int> it0(splitter_3->sizes());
1196 QListIterator<int> it1(splitter_3->sizes());
1199 while (it0.hasNext()) {
1202 while (it1.hasNext()) {
1207 if (viewMode == 1) {
1209 size0.push_back(max0);
1211 size1.push_back(max1);
1213 splitter_3->setSizes(size0);
1214 OSplitter->setSizes(size1);
1215 DataTree->setColumnHidden(2,1);
1216 DataTree->setColumnHidden(3,1);
1217 DataTree->setColumnHidden(4,1);
1220 size0.push_back(int(max0/2));
1221 size0.push_back(int(max0/2));
1222 size1.push_back(int(max1/2));
1223 size1.push_back(int(max1/2));
1224 splitter_3->setSizes(size0);
1225 OSplitter->setSizes(size1);
1226 DataTree->setColumnHidden(2,0);
1227 DataTree->setColumnHidden(3,0);
1228 DataTree->setColumnHidden(4,0);
1231 //------------------------------------------------------------------------------
1233 //------------------------------------------------------------------------------
1234 QString vvMainWindow::GetSizeInBytes(unsigned long size)
1236 QString result = "";// QString::number(size);
1237 //result += " bytes (";
1238 if (size > 1000000000) {
1240 result += QString::number(size);
1241 result += "Gb";//)";
1242 } else if (size > 1000000) {
1244 result += QString::number(size);
1245 result += "Mb";//)";
1246 } else if (size > 1000) {
1248 result += QString::number(size);
1249 result += "kb";//)";
1253 //------------------------------------------------------------------------------
1255 //------------------------------------------------------------------------------
1256 QString vvMainWindow::Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> matrix)
1258 std::ostringstream strmatrix;
1260 for (unsigned int i = 0; i < 4; i++) {
1261 for (unsigned int j = 0; j < 4; j++) {
1262 strmatrix.flags(ios::showpos);
1263 strmatrix.width(10);
1264 strmatrix.precision(3);
1265 strmatrix.setf(ios::fixed,ios::floatfield);
1266 strmatrix.fill(' ');
1267 strmatrix << std::left << matrix->GetElement(i, j);
1268 //strmatrix.width(10);
1271 strmatrix << std::endl;
1273 QString result = strmatrix.str().c_str();
1276 //------------------------------------------------------------------------------
1278 //------------------------------------------------------------------------------
1279 QString vvMainWindow::GetVectorDoubleAsString(std::vector<double> vectorDouble)
1282 for (unsigned int i= 0; i < vectorDouble.size(); i++) {
1285 result += QString::number(vectorDouble[i]);
1289 //------------------------------------------------------------------------------
1291 //------------------------------------------------------------------------------
1292 QString vvMainWindow::GetVectorIntAsString(std::vector<int> vectorInt)
1295 for (unsigned int i= 0; i < vectorInt.size(); i++) {
1298 result += QString::number(vectorInt[i]);
1302 //------------------------------------------------------------------------------
1304 //------------------------------------------------------------------------------
1305 int vvMainWindow::GetSlicerIndexFromItem(QTreeWidgetItem* item)
1307 QString id = item->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
1308 for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
1309 if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString() == id)
1314 //------------------------------------------------------------------------------
1316 //------------------------------------------------------------------------------
1317 QTreeWidgetItem* vvMainWindow::GetItemFromSlicerManager(vvSlicerManager* sm)
1319 QString id = sm->GetId().c_str();
1320 for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
1321 if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString() == id)
1322 return DataTree->topLevelItem(i);
1326 //------------------------------------------------------------------------------
1328 //------------------------------------------------------------------------------
1329 void vvMainWindow::DisplayChanged(QTreeWidgetItem *clicked_item, int column)
1331 int index = GetSlicerIndexFromItem(clicked_item);
1332 if ( column >= COLUMN_CLOSE_IMAGE || column <= 0)
1334 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
1335 //Trick to avoid redoing twice the job for a key (sr)
1336 mSlicerManagers[i]->GetSlicer(column-1)->GetRenderWindow()-> GetInteractor()->SetKeySym("Crap");
1338 QTreeWidgetItem* current_row=DataTree->topLevelItem(i);
1339 if (DataTree->topLevelItem(index) == current_row) {
1340 vvSlicer* clicked_slicer=mSlicerManagers[i]->GetSlicer(column-1);
1341 if (current_row == clicked_item) {
1342 //If we just activated a slicer
1343 if (current_row->data(column,Qt::CheckStateRole).toInt() > 0) {
1344 mSlicerManagers[i]->UpdateSlicer(column-1,clicked_item->data(column,Qt::CheckStateRole).toInt());
1345 mSlicerManagers[i]->UpdateInfoOnCursorPosition(column-1);
1346 DisplaySliders(i,column-1);
1347 std::map<std::string,int> overlay_counts;
1348 for (int child = 0; child < current_row->childCount(); child++) {
1349 std::string overlay_type =
1350 current_row->child(child)->data(1,Qt::UserRole).toString().toStdString();
1351 overlay_counts[overlay_type]++;
1352 current_row->child(child)->setData(column,Qt::CheckStateRole,
1353 current_row->data(column,Qt::CheckStateRole));
1354 clicked_slicer->SetActorVisibility(overlay_type,overlay_counts[overlay_type]-1,true);
1356 } else { //We don't allow simply desactivating a slicer
1357 clicked_item->setData(column,Qt::CheckStateRole,2);
1361 //if we clicked on the vector(or overlay) and not the image
1363 if (clicked_item->data(column,Qt::CheckStateRole).toInt()) {
1364 current_row->setData(column,Qt::CheckStateRole,2);
1365 mSlicerManagers[i]->UpdateSlicer(column-1,2);
1366 mSlicerManagers[i]->UpdateInfoOnCursorPosition(column-1);
1367 DisplaySliders(i,column-1);
1369 int vis = clicked_item->data(column,Qt::CheckStateRole).toInt();
1370 std::string overlay_type = clicked_item->data(1,Qt::UserRole).toString().toStdString();
1371 int overlay_index=0;
1372 for (int child = 0; child < current_row->childCount(); child++) {
1373 if (current_row->child(child)->data(1,Qt::UserRole).toString().toStdString() == overlay_type)
1375 if (current_row->child(child) == clicked_item) break;
1377 clicked_slicer->SetActorVisibility(
1378 clicked_item->data(1,Qt::UserRole).toString().toStdString(), overlay_index-1,vis);
1380 } else if (current_row->data(column,Qt::CheckStateRole).toInt() > 0) {
1381 current_row->setData(column,Qt::CheckStateRole,0);
1382 mSlicerManagers[i]->UpdateSlicer(column-1,0);
1383 std::map<std::string,int> overlay_counts;
1384 for (int child = 0; child < current_row->childCount(); child++) {
1385 std::string overlay_type =
1386 current_row->child(child)->data(1,Qt::UserRole).toString().toStdString();
1387 overlay_counts[overlay_type]++;
1388 current_row->child(child)->setData(column,Qt::CheckStateRole,0);
1389 vvSlicer * current_slicer=mSlicerManagers[i]->GetSlicer(column-1);
1390 current_slicer->SetActorVisibility(overlay_type,overlay_counts[overlay_type]-1,false);
1393 //mSlicerManagers[i]->SetColorMap(-1);
1394 mSlicerManagers[i]->SetColorMap();
1396 mSlicerManagers[index]->GetSlicer(column-1)->Render();
1398 //------------------------------------------------------------------------------
1400 void vvMainWindow::InitSlicers()
1402 if (mSlicerManagers.size()) {
1403 mSlicerManagers.back()->GenerateDefaultLookupTable();
1405 mSlicerManagers.back()->SetSlicerWindow(0,NOViewWidget->GetRenderWindow());
1406 mSlicerManagers.back()->SetSlicerWindow(1,NEViewWidget->GetRenderWindow());
1407 mSlicerManagers.back()->SetSlicerWindow(2,SOViewWidget->GetRenderWindow());
1408 mSlicerManagers.back()->SetSlicerWindow(3,SEViewWidget->GetRenderWindow());
1412 //------------------------------------------------------------------------------
1413 void vvMainWindow::InitDisplay()
1415 if (mSlicerManagers.size()) {
1416 //BE CAREFUL : this is absolutely necessary to set the interactor style
1417 //in order to have the same style instanciation for all SlicerManagers in
1419 for (int j = 0; j < 4; j++) {
1420 vvInteractorStyleNavigator* style = vvInteractorStyleNavigator::New();
1421 style->SetAutoAdjustCameraClippingRange(1);
1422 bool AlreadySelected = false;
1423 for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
1424 mSlicerManagers[i]->SetInteractorStyleNavigator(j,style);
1426 //select the image only if previous are not selected
1427 if (DataTree->topLevelItem(i)->data(j+1,Qt::CheckStateRole).toInt() > 1) {
1428 mSlicerManagers[i]->UpdateSlicer(j,1);
1429 AlreadySelected = true;
1430 } else if (i == DataTree->topLevelItemCount()-1 && !AlreadySelected) {
1431 if (DataTree->selectedItems().size() == 0)
1432 DataTree->topLevelItem(i)->setSelected(1);
1433 DataTree->topLevelItem(i)->setData(j+1,Qt::CheckStateRole,2);
1434 mSlicerManagers[i]->UpdateSlicer(j,1);
1435 DisplaySliders(i,j);
1437 DataTree->topLevelItem(i)->setData(j+1,Qt::CheckStateRole,0);
1438 mSlicerManagers[i]->UpdateSlicer(j,0);
1445 //------------------------------------------------------------------------------
1447 //------------------------------------------------------------------------------
1448 void vvMainWindow::DisplaySliders(int slicer, int window)
1451 mSlicerManagers[slicer]->GetSlicer(window)->GetSliceRange(range);
1452 int position = mSlicerManagers[slicer]->GetSlicer(window)->GetSlice();
1456 tRange[1] = mSlicerManagers[slicer]->GetSlicer(window)->GetTMax();
1457 int tPosition = mSlicerManagers[slicer]->GetSlicer(window)->GetTSlice();
1458 bool showHorizontal = false;
1459 bool showVertical = false;
1460 if (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 3
1461 || (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 2
1462 && mSlicerManagers[slicer]->GetType() != IMAGEWITHTIME
1463 && mSlicerManagers[slicer]->GetType() != MERGEDWITHTIME))
1464 showVertical = true;
1465 if (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 3
1466 || mSlicerManagers[slicer]->GetType() == IMAGEWITHTIME
1467 || mSlicerManagers[slicer]->GetType() == MERGEDWITHTIME)
1468 showHorizontal = true;
1471 verticalSliders[window]->show();
1473 verticalSliders[window]->hide();
1474 verticalSliders[window]->setRange(range[0],range[1]);
1475 verticalSliders[window]->setValue(position);
1478 horizontalSliders[window]->show();
1480 horizontalSliders[window]->hide();
1481 horizontalSliders[window]->setRange(tRange[0],tRange[1]);
1482 horizontalSliders[window]->setValue(tPosition);
1484 //------------------------------------------------------------------------------
1486 //------------------------------------------------------------------------------
1487 void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column)
1489 int index = GetSlicerIndexFromItem(item);
1491 if (DataTree->topLevelItem(index) != item) {
1492 QString warning = "Do you really want to close the overlay : ";
1493 warning += item->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
1494 QMessageBox msgBox(QMessageBox::Warning, tr("Close Overlay"),
1496 msgBox.addButton(tr("Close"), QMessageBox::AcceptRole);
1497 msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
1498 if (msgBox.exec() == QMessageBox::AcceptRole) {
1499 std::string overlay_type=item->data(1,Qt::UserRole).toString().toStdString();
1500 int overlay_index=0;
1501 for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++) {
1502 if (DataTree->topLevelItem(index)->\
1503 child(child)->data(1,Qt::UserRole).toString().toStdString() == overlay_type)
1505 if (DataTree->topLevelItem(index)->child(child) == item) break;
1507 mSlicerManagers[index]->RemoveActor(overlay_type, overlay_index-1);
1508 mSlicerManagers[index]->SetColorMap(0);
1509 DataTree->topLevelItem(index)->takeChild(DataTree->topLevelItem(index)->indexOfChild(item));
1510 mSlicerManagers[index]->Render();
1512 } else if (DataTree->topLevelItemCount() <= 1) {
1513 QString warning = "Do you really want to close the image : ";
1514 warning += item->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
1515 warning += "\nThis is the last image, you're about to close vv !!!";
1516 QMessageBox msgBox(QMessageBox::Warning, tr("Close Image"),
1518 msgBox.addButton(tr("Close vv"), QMessageBox::AcceptRole);
1519 msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
1520 if (msgBox.exec() == QMessageBox::AcceptRole) {
1524 QString warning = "Do you really want to close the image : ";
1525 warning += item->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
1526 QMessageBox msgBox(QMessageBox::Warning, tr("Close Image"),
1528 msgBox.addButton(tr("Close"), QMessageBox::AcceptRole);
1529 msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
1530 if (msgBox.exec() == QMessageBox::AcceptRole) {
1532 // Tell tools that we close an image
1533 emit AnImageIsBeingClosed(mSlicerManagers[index]);
1535 std::vector<vvSlicerManager*>::iterator Manageriter = mSlicerManagers.begin();
1536 DataTree->takeTopLevelItem(index);
1537 for (int i = 0; i < index; i++) {
1540 linkPanel->removeImage(index);
1541 mSlicerManagers[index]->RemoveActors();
1542 delete mSlicerManagers[index];
1543 mSlicerManagers.erase(Manageriter);
1551 //------------------------------------------------------------------------------
1553 //------------------------------------------------------------------------------
1554 void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column)
1556 // int index = GetSlicerIndexFromItem(item);
1557 // QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1558 // if (item->data(1,Qt::UserRole).toString() == "vector")
1559 // mSlicerManagers[index]->ReloadVF();
1561 // mSlicerManagers[index]->Reload();
1563 // QApplication::restoreOverrideCursor();
1564 int index = GetSlicerIndexFromItem(item);
1565 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1566 QString role=item->data(1,Qt::UserRole).toString();
1567 if ( role == "vector")
1568 mSlicerManagers[index]->ReloadVF();
1569 else if (role == "overlay")
1570 mSlicerManagers[index]->ReloadOverlay();
1571 else if (role == "fusion")
1572 mSlicerManagers[index]->ReloadFusion();
1574 mSlicerManagers[index]->Reload();
1576 // Update view and info
1578 mSlicerManagers[index]->Render();
1579 QApplication::restoreOverrideCursor();
1581 //------------------------------------------------------------------------------
1583 //------------------------------------------------------------------------------
1584 void vvMainWindow::MousePositionChanged(int visibility,double x, double y, double z, double X, double Y, double Z , double value)
1586 infoPanel->setCurrentInfo(visibility,x,y,z,X,Y,Z,value);
1588 //------------------------------------------------------------------------------
1590 //------------------------------------------------------------------------------
1591 void vvMainWindow::VectorChanged(int visibility,double x, double y, double z, double value)
1593 overlayPanel->getCurrentVectorInfo(visibility,x,y,z,value);
1595 //------------------------------------------------------------------------------
1597 //------------------------------------------------------------------------------
1598 void vvMainWindow::OverlayChanged(int visibility, double valueOver, double valueRef)
1600 overlayPanel->getCurrentOverlayInfo(visibility,valueOver, valueRef);
1602 //------------------------------------------------------------------------------
1604 //------------------------------------------------------------------------------
1605 void vvMainWindow::FusionChanged(int visibility, double value)
1607 overlayPanel->getCurrentFusionInfo(visibility,value);
1609 //------------------------------------------------------------------------------
1611 //------------------------------------------------------------------------------
1612 void vvMainWindow::WindowsChanged(int window, int view, int slice)
1614 infoPanel->setViews(window, view, slice);
1616 //------------------------------------------------------------------------------
1618 //------------------------------------------------------------------------------
1619 void vvMainWindow::WindowLevelChanged(double window, double level,int preset,int colormap)
1621 windowSpinBox->setValue(window);
1622 levelSpinBox->setValue(level);
1623 colorMapComboBox->setCurrentIndex(colormap);
1624 presetComboBox->setCurrentIndex(preset);
1626 //------------------------------------------------------------------------------
1628 //------------------------------------------------------------------------------
1629 void vvMainWindow::WindowLevelEdited()
1631 presetComboBox->setCurrentIndex(6);
1632 UpdateWindowLevel();
1634 //------------------------------------------------------------------------------
1636 //------------------------------------------------------------------------------
1637 void vvMainWindow::UpdateWindowLevel()
1639 if (DataTree->selectedItems().size()) {
1640 if (presetComboBox->currentIndex() == 7) //For ventilation
1641 colorMapComboBox->setCurrentIndex(5);
1642 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
1643 mSlicerManagers[index]->SetColorWindow(windowSpinBox->value());
1644 mSlicerManagers[index]->SetColorLevel(levelSpinBox->value());
1645 mSlicerManagers[index]->SetPreset(presetComboBox->currentIndex());
1646 mSlicerManagers[index]->Render();
1647 windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow());
1648 levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel());
1651 //------------------------------------------------------------------------------
1653 //------------------------------------------------------------------------------
1654 void vvMainWindow::UpdateColorMap()
1656 if (DataTree->selectedItems().size()) {
1657 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
1658 mSlicerManagers[index]->SetColorMap(colorMapComboBox->currentIndex());
1659 mSlicerManagers[index]->Render();
1662 //------------------------------------------------------------------------------
1663 void vvMainWindow::SwitchWindowLevel()
1665 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
1666 int window = mSlicerManagers[index]->GetColorWindow();
1667 presetComboBox->setCurrentIndex(6);
1668 windowSpinBox->setValue(-window);
1669 UpdateWindowLevel();
1671 //------------------------------------------------------------------------------
1673 //------------------------------------------------------------------------------
1674 void vvMainWindow::ApplyWindowLevelToAllImages()
1676 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
1677 if (mSlicerManagers[i] == NULL)
1679 mSlicerManagers[i]->SetColorWindow(windowSpinBox->value());
1680 mSlicerManagers[i]->SetColorLevel(levelSpinBox->value());
1681 mSlicerManagers[i]->SetPreset(6);
1682 mSlicerManagers[i]->Render();
1685 //------------------------------------------------------------------------------
1687 //------------------------------------------------------------------------------
1688 void vvMainWindow::UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps)
1690 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
1691 if (mSlicerManagers[i]->GetId() == id) {
1692 //mSlicerManagers[i]->SetTSlice(temps);
1693 mSlicerManagers[i]->GetSlicer(slicer)->SetCurrentPosition(x,y,z,temps);
1694 mSlicerManagers[i]->UpdateViews(0,slicer);
1699 //------------------------------------------------------------------------------
1701 //------------------------------------------------------------------------------
1702 void vvMainWindow::UpdateLinkedNavigation(std::string id, vvSlicerManager * sm)
1704 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
1705 if (id == mSlicerManagers[i]->GetId()) {
1706 mSlicerManagers[i]->UpdateLinkedNavigation(sm->GetSlicer(0));
1710 //------------------------------------------------------------------------------
1712 //------------------------------------------------------------------------------
1713 void vvMainWindow::ShowContextMenu(QPoint point)
1715 if (!DataTree->selectedItems().size()) {
1716 contextActions[1]->setEnabled(0);
1717 contextActions[2]->setEnabled(0);
1718 contextActions[3]->setEnabled(0);
1719 contextActions[4]->setEnabled(0);
1720 contextActions[5]->setEnabled(0);
1721 contextActions[6]->setEnabled(0);
1723 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
1724 contextActions[1]->setEnabled(1);
1725 contextActions[2]->setEnabled(
1726 DataTree->itemWidget(DataTree->selectedItems()[0],
1727 COLUMN_RELOAD_IMAGE)->isEnabled());
1728 contextActions[3]->setEnabled(1);
1729 contextActions[5]->setEnabled(1);
1730 contextActions[6]->setEnabled(1);
1732 if (mSlicerManagers[index]->GetDimension() < 3)
1733 contextActions[4]->setEnabled(0);
1735 contextActions[4]->setEnabled(1);
1737 contextMenu.exec(QCursor::pos());
1739 //------------------------------------------------------------------------------
1741 //------------------------------------------------------------------------------
1742 void vvMainWindow::CloseImage()
1744 CloseImage(DataTree->selectedItems()[0],0);
1746 //------------------------------------------------------------------------------
1748 //------------------------------------------------------------------------------
1749 void vvMainWindow::ReloadImage()
1751 ReloadImage(DataTree->selectedItems()[0],0);
1753 //------------------------------------------------------------------------------
1755 //------------------------------------------------------------------------------
1756 void vvMainWindow::SelectOverlayImage()
1758 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
1760 //check if one overlay image is added
1761 for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
1762 if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "overlay") {
1763 QString error = "Cannot add more than one compared image\n";
1764 error += "Please remove first ";
1765 error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
1766 QMessageBox::information(this,tr("Problem adding compared image !"),error);
1770 QString Extensions = EXTENSIONS;
1771 Extensions += ";;All Files (*)";
1772 QString file = QFileDialog::getOpenFileName(this,tr("Load Overlay image"),mInputPathName,Extensions);
1773 if (!file.isEmpty())
1774 AddOverlayImage(index,file);
1776 //------------------------------------------------------------------------------
1778 //------------------------------------------------------------------------------
1779 void vvMainWindow::AddOverlayImage(int index, QString file)
1782 mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
1783 itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
1784 file.toStdString().c_str(), itk::ImageIOFactory::ReadMode);
1785 reader->SetFileName(file.toStdString().c_str());
1786 reader->ReadImageInformation();
1787 std::string component = reader->GetComponentTypeAsString(reader->GetComponentType());
1788 int dimension = reader->GetNumberOfDimensions();
1789 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1790 vvProgressDialog progress("Opening " + file.toStdString());
1791 qApp->processEvents();
1793 std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str();
1794 if (mSlicerManagers[index]->SetOverlay(file.toStdString(),dimension, component)) {
1795 //create an item in the tree with good settings
1796 QTreeWidgetItem *item = new QTreeWidgetItem();
1797 item->setData(0,Qt::UserRole,file.toStdString().c_str());
1798 item->setData(1,Qt::UserRole,tr("overlay"));
1799 QFileInfo fileinfo(file); //Do not show the path
1800 item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
1801 item->setToolTip(COLUMN_IMAGE_NAME,fileinfo.absoluteFilePath());
1802 qApp->processEvents();
1804 for (int j = 1; j <= 4; j++) {
1805 item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
1806 mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("overlay",0,
1807 DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt());
1810 //Create the buttons for reload and close
1811 qApp->processEvents();
1812 QTreePushButton* cButton = new QTreePushButton;
1813 cButton->setItem(item);
1814 cButton->setColumn(COLUMN_CLOSE_IMAGE);
1815 cButton->setToolTip(tr("close image"));
1816 cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png")));
1817 connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
1818 this,SLOT(CloseImage(QTreeWidgetItem*, int)));
1820 QTreePushButton* rButton = new QTreePushButton;
1821 rButton->setItem(item);
1822 rButton->setColumn(COLUMN_RELOAD_IMAGE);
1823 rButton->setToolTip(tr("reload image"));
1824 rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png")));
1825 connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
1826 this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
1828 DataTree->topLevelItem(index)->setExpanded(1);
1829 DataTree->topLevelItem(index)->addChild(item);
1830 DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
1831 DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
1833 //set the id of the image
1834 QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
1835 item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
1837 qApp->processEvents();
1839 QApplication::restoreOverrideCursor();
1841 QApplication::restoreOverrideCursor();
1842 QString error = "Cannot import the new image.\n";
1843 error += mSlicerManagers[index]->GetLastError().c_str();
1844 QMessageBox::information(this,tr("Problem reading image !"),error);
1847 //------------------------------------------------------------------------------
1850 //------------------------------------------------------------------------------
1851 void vvMainWindow::AddROI(int index, QString file)
1854 // Get slice manager
1858 vvImageReader * mReader = new vvImageReader;
1859 mReader->SetInputFilename(filename.toStdString());
1860 mReader->Update(IMAGE);
1861 if (mReader->GetLastError().size() != 0) {
1862 std::cerr << "Error while reading " << filename.toStdString() << std::endl;
1863 QString error = "Cannot open file \n";
1864 error += mReader->GetLastError().c_str();
1865 QMessageBox::information(this,tr("Reading problem"),error);
1869 vvImage::Pointer roi = mReader->GetOutput();
1871 // Create roi in new tool
1872 vvToolStructureSetManager::AddImage(mCurrentSlicerManager, roi);
1875 //------------------------------------------------------------------------------
1877 //------------------------------------------------------------------------------
1878 void vvMainWindow::SelectFusionImage()
1880 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
1882 //check if one fusion image is added
1883 for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
1884 if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusion") {
1885 QString error = "Cannot add more than one fusion image\n";
1886 error += "Please remove first ";
1887 error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
1888 QMessageBox::information(this,tr("Problem adding fusion image !"),error);
1892 QString Extensions = EXTENSIONS;
1893 Extensions += ";;All Files (*)";
1894 QString file = QFileDialog::getOpenFileName(this,tr("Load Fusion image"),mInputPathName,Extensions);
1895 if (!file.isEmpty())
1896 AddFusionImage(index,file);
1898 //------------------------------------------------------------------------------
1900 //------------------------------------------------------------------------------
1901 void vvMainWindow::AddFusionImage(int index, QString file)
1903 mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
1904 itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
1905 file.toStdString().c_str(), itk::ImageIOFactory::ReadMode);
1906 reader->SetFileName(file.toStdString().c_str());
1907 reader->ReadImageInformation();
1908 std::string component = reader->GetComponentTypeAsString(reader->GetComponentType());
1910 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1911 vvProgressDialog progress("Opening fusion");
1912 qApp->processEvents();
1914 std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str();
1915 if (mSlicerManagers[index]->SetFusion(file.toStdString(),
1916 reader->GetNumberOfDimensions(), component)) {
1917 //create an item in the tree with good settings
1918 QTreeWidgetItem *item = new QTreeWidgetItem();
1919 item->setData(0,Qt::UserRole,file.toStdString().c_str());
1920 item->setData(1,Qt::UserRole,tr("fusion"));
1921 QFileInfo fileinfo(filename.c_str()); //Do not show the path
1922 item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
1923 item->setToolTip(COLUMN_IMAGE_NAME,fileinfo.absoluteFilePath());
1924 qApp->processEvents();
1926 for (int j = 1; j <= 4; j++) {
1927 item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
1928 mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("fusion",0,
1929 DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt());
1932 //Create the buttons for reload and close
1933 qApp->processEvents();
1934 QTreePushButton* cButton = new QTreePushButton;
1935 cButton->setItem(item);
1936 cButton->setColumn(COLUMN_CLOSE_IMAGE);
1937 cButton->setToolTip(tr("close image"));
1938 cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png")));
1939 connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
1940 this,SLOT(CloseImage(QTreeWidgetItem*, int)));
1942 QTreePushButton* rButton = new QTreePushButton;
1943 rButton->setItem(item);
1944 rButton->setColumn(COLUMN_RELOAD_IMAGE);
1945 rButton->setToolTip(tr("reload image"));
1946 rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png")));
1947 connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
1948 this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
1950 DataTree->topLevelItem(index)->setExpanded(1);
1951 DataTree->topLevelItem(index)->addChild(item);
1952 DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
1953 DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
1955 //set the id of the image
1956 QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
1957 item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
1959 qApp->processEvents();
1961 QApplication::restoreOverrideCursor();
1963 QApplication::restoreOverrideCursor();
1964 QString error = "Cannot import the new image.\n";
1965 error += mSlicerManagers[index]->GetLastError().c_str();
1966 QMessageBox::information(this,tr("Problem reading image !"),error);
1969 QString error = "Cannot import the new image.\n";
1970 QMessageBox::information(this,tr("Problem reading image !"),error);
1973 //------------------------------------------------------------------------------
1976 //------------------------------------------------------------------------------
1977 void vvMainWindow::OpenField()
1979 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
1980 //check if a vector field has already been added
1981 for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
1982 if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "vector") {
1983 QString error = "Cannot add more than one vector field\n";
1984 error += "Please remove first ";
1985 error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
1986 QMessageBox::information(this,tr("Problem adding vector field!"),error);
1990 QString Extensions = "Images ( *.mhd)";
1991 Extensions += ";;Images ( *.vf)";
1992 QString file = QFileDialog::getOpenFileName(this,tr("Load deformation field"),mInputPathName,Extensions);
1993 if (!file.isEmpty())
1994 AddField(file,index);
1996 //------------------------------------------------------------------------------
1999 //------------------------------------------------------------------------------
2000 void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk)
2002 //create an item in the tree with good settings
2003 QTreeWidgetItem *item = new QTreeWidgetItem();
2004 item->setData(0,Qt::UserRole,filename.toStdString().c_str());
2005 item->setData(1,Qt::UserRole,tr("vector"));
2006 QFileInfo fileinfo(filename); //Do not show the path
2007 item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
2008 item->setToolTip(COLUMN_IMAGE_NAME,fileinfo.absoluteFilePath());
2009 qApp->processEvents();
2011 for (int j = 1; j <= 4; j++) {
2012 item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
2013 mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("vector",0,
2014 DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt());
2017 //Create the buttons for reload and close
2018 qApp->processEvents();
2019 QTreePushButton* cButton = new QTreePushButton;
2020 cButton->setItem(item);
2021 cButton->setColumn(COLUMN_CLOSE_IMAGE);
2022 cButton->setToolTip(tr("close vector field"));
2023 cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png")));
2024 connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
2025 this,SLOT(CloseImage(QTreeWidgetItem*, int)));
2027 QTreePushButton* rButton = new QTreePushButton;
2028 rButton->setItem(item);
2029 rButton->setColumn(COLUMN_RELOAD_IMAGE);
2030 rButton->setToolTip(tr("reload vector field"));
2031 rButton->setEnabled(from_disk);
2032 rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png")));
2033 connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
2034 this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
2036 DataTree->topLevelItem(index)->setExpanded(1);
2037 DataTree->topLevelItem(index)->addChild(item);
2038 DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
2039 DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
2041 //set the id of the image
2042 QString id = DataTree->topLevelItem(index)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
2043 item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
2045 qApp->processEvents();
2047 QApplication::restoreOverrideCursor();
2049 //------------------------------------------------------------------------------
2052 //------------------------------------------------------------------------------
2053 void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index)
2055 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2056 vvSlicerManager* imageManager = mSlicerManagers[index];
2057 if (imageManager->SetVF(vf,file.toStdString())) {
2058 AddFieldEntry(file,index,false);
2060 QString error = "Cannot import the vector field for this image.\n";
2061 error += imageManager->GetLastError().c_str();
2062 QMessageBox::information(this,tr("Problem reading VF !"),error);
2064 QApplication::restoreOverrideCursor();
2066 //------------------------------------------------------------------------------
2069 //------------------------------------------------------------------------------
2070 void vvMainWindow::AddField(QString file,int index)
2072 if (QFile::exists(file)) {
2073 mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
2075 //init the progress events
2076 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2077 vvProgressDialog progress("Opening " + file.toStdString());
2078 qApp->processEvents();
2080 //read the vector and put it in the current mSlicerManager
2081 vvSlicerManager* imageManager = mSlicerManagers[index];
2082 qApp->processEvents();
2084 std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str();
2085 if (imageManager->SetVF(file.toStdString())) {
2086 imageManager->Render();
2087 AddFieldEntry(file,index,true);
2089 QApplication::restoreOverrideCursor();
2090 QString error = "Cannot import the vector field for this image.\n";
2091 error += imageManager->GetLastError().c_str();
2092 QMessageBox::information(this,tr("Problem reading VF !"),error);
2095 QMessageBox::information(this,tr("Problem reading VF !"),"File doesn't exist!");
2098 //------------------------------------------------------------------------------
2101 //------------------------------------------------------------------------------
2102 void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width, double r, double g, double b)
2104 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
2105 if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) {
2106 for (int i = 0; i < 4; i++) {
2107 mSlicerManagers[index]->GetSlicer(i)->SetVFSubSampling(subsampling);
2108 mSlicerManagers[index]->GetSlicer(i)->SetVFScale(scale);
2109 mSlicerManagers[index]->GetSlicer(i)->SetVFWidth(width);
2110 mSlicerManagers[index]->GetSlicer(i)->SetVFColor(r,g,b);
2112 mSlicerManagers[index]->GetSlicer(i)->SetVFLog(1);
2114 mSlicerManagers[index]->GetSlicer(i)->SetVFLog(0);
2118 //------------------------------------------------------------------------------
2121 //------------------------------------------------------------------------------
2122 void vvMainWindow::SetOverlayProperty(int color)
2124 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
2125 if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay()) {
2126 mSlicerManagers[index]->SetOverlayColor(color);
2127 mSlicerManagers[index]->SetColorMap(0);
2128 mSlicerManagers[index]->Render();
2131 //------------------------------------------------------------------------------
2133 //------------------------------------------------------------------------------
2134 void vvMainWindow::SetFusionProperty(int opacity, int colormap,double window, double level)
2136 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
2137 if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
2138 mSlicerManagers[index]->SetFusionOpacity(opacity);
2139 mSlicerManagers[index]->SetFusionColorMap(colormap);
2140 mSlicerManagers[index]->SetFusionWindow(window);
2141 mSlicerManagers[index]->SetFusionLevel(level);
2142 mSlicerManagers[index]->SetColorMap(0);
2143 mSlicerManagers[index]->Render();
2146 //------------------------------------------------------------------------------
2148 //------------------------------------------------------------------------------
2149 void vvMainWindow::SaveAs()
2151 if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "vector") {
2152 QMessageBox::warning(this,tr("Unsupported type"),tr("Sorry, saving a vector field is unsupported for the moment"));
2156 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
2157 int dimension = mSlicerManagers[index]->GetDimension();
2158 QStringList OutputListeFormat;
2159 OutputListeFormat.clear();
2160 if (dimension == 1) {
2161 OutputListeFormat.push_back(".mhd");
2163 if (dimension == 2) {
2164 OutputListeFormat.push_back(".bmp");
2165 OutputListeFormat.push_back(".png");
2166 OutputListeFormat.push_back(".jpeg");
2167 OutputListeFormat.push_back(".tif");
2168 OutputListeFormat.push_back(".mhd");
2169 OutputListeFormat.push_back(".hdr");
2170 OutputListeFormat.push_back(".vox");
2171 } else if (dimension == 3) {
2172 OutputListeFormat.push_back(".mhd");
2173 OutputListeFormat.push_back(".hdr");
2174 OutputListeFormat.push_back(".vox");
2175 } else if (dimension == 4) {
2176 OutputListeFormat.push_back(".mhd");
2178 QString Extensions = "AllFiles(*.*)";
2179 for (int i = 0; i < OutputListeFormat.count(); i++) {
2180 Extensions += ";;Images ( *";
2181 Extensions += OutputListeFormat[i];
2184 QString fileName = QFileDialog::getSaveFileName(this,
2186 mSlicerManagers[index]->GetFileName().c_str(),
2188 if (!fileName.isEmpty()) {
2189 std::string fileformat = itksys::SystemTools::GetFilenameLastExtension(fileName.toStdString());
2190 if (OutputListeFormat.contains(
2191 fileformat.c_str())) {
2192 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2193 std::string action = "Saving";
2194 vvProgressDialog progress("Saving "+fileName.toStdString());
2195 qApp->processEvents();
2196 vvImageWriter *writer = new vvImageWriter;
2197 writer->SetOutputFileName(fileName.toStdString());
2198 writer->SetInput(mSlicerManagers[index]->GetImage());
2200 QApplication::restoreOverrideCursor();
2201 if (writer->GetLastError().size()) {
2202 QString error = "Saving did not succeed\n";
2203 error += writer->GetLastError().c_str();
2204 QMessageBox::information(this,tr("Saving Problem"),error);
2208 QString error = fileformat.c_str();
2209 if (error.isEmpty())
2210 error += "no file format specified !";
2212 error += " format unknown !!!\n";
2213 QMessageBox::information(this,tr("Saving Problem"),error);
2218 //------------------------------------------------------------------------------
2221 //------------------------------------------------------------------------------
2222 void vvMainWindow::AddLink(QString image1,QString image2)
2224 unsigned int sm1 = 0;
2225 unsigned int sm2 = 0;
2227 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
2228 if (image1.toStdString() == mSlicerManagers[i]->GetId()) {
2229 mSlicerManagers[i]->AddLink(image2.toStdString());
2232 if (image2.toStdString() == mSlicerManagers[i]->GetId()) {
2233 mSlicerManagers[i]->AddLink(image1.toStdString());
2238 if (linkPanel->isLinkAll()) {
2239 emit UpdateLinkedNavigation(mSlicerManagers[sm1]->GetId(), mSlicerManagers[mCurrentPickedImageIndex]);
2240 emit UpdateLinkedNavigation(mSlicerManagers[sm2]->GetId(), mSlicerManagers[mCurrentPickedImageIndex]);
2243 emit UpdateLinkedNavigation(mSlicerManagers[sm2]->GetId(), mSlicerManagers[sm1]);
2247 //------------------------------------------------------------------------------
2250 //------------------------------------------------------------------------------
2251 void vvMainWindow::RemoveLink(QString image1,QString image2)
2253 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
2254 if (image1.toStdString() == mSlicerManagers[i]->GetId()) {
2255 mSlicerManagers[i]->RemoveLink(image2.toStdString());
2257 if (image2.toStdString() == mSlicerManagers[i]->GetId()) {
2258 mSlicerManagers[i]->RemoveLink(image1.toStdString());
2262 //------------------------------------------------------------------------------
2264 //------------------------------------------------------------------------------
2265 void vvMainWindow::ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset)
2268 while(sm != mSlicerManagers[index])
2270 index = (index+offset) % mSlicerManagers.size();
2272 QTreeWidgetItem* item = GetItemFromSlicerManager(mSlicerManagers[index]);
2273 //CurrentImageChanged(mSlicerManagers[index]->GetId()); //select new image
2274 item->setData(slicer+1,Qt::CheckStateRole,2); //change checkbox
2275 DisplayChanged(item,slicer+1);
2277 //------------------------------------------------------------------------------
2279 void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index)
2281 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
2282 if (DataTree->topLevelItem(i)->data(column,Qt::CheckStateRole).toInt() > 1) {
2283 for (int j = 0; j < 4; j++) {
2284 mSlicerManagers[i]->SetTSliceInSlicer(value,j);
2285 //if (mSlicerManagers[i]->GetSlicer(j)->GetImageActor()->GetVisibility())
2286 //UpdateTSlice(j,value);
2288 mSlicerManagers[i]->GetSlicer(slicer_index)->Render();
2293 //------------------------------------------------------------------------------
2296 //------------------------------------------------------------------------------
2297 void vvMainWindow::NOHorizontalSliderMoved()
2299 // if (mCurrentTime == NOHorizontalSlider->value()) return;
2300 HorizontalSliderMoved(NOHorizontalSlider->value(),COLUMN_UL_VIEW,0);
2301 // mCurrentTime = NOHorizontalSlider->value();
2303 //------------------------------------------------------------------------------
2306 //------------------------------------------------------------------------------
2307 void vvMainWindow::NEHorizontalSliderMoved()
2309 // if (mCurrentTime == NEHorizontalSlider->value()) return;
2310 HorizontalSliderMoved(NEHorizontalSlider->value(),COLUMN_UR_VIEW,1);
2311 // mCurrentTime = NEHorizontalSlider->value();
2313 //------------------------------------------------------------------------------
2316 //------------------------------------------------------------------------------
2317 void vvMainWindow::SOHorizontalSliderMoved()
2319 // if (mCurrentTime == SOHorizontalSlider->value()) return;
2320 HorizontalSliderMoved(SOHorizontalSlider->value(),COLUMN_DL_VIEW,2);
2321 // mCurrentTime = SOHorizontalSlider->value();
2323 //------------------------------------------------------------------------------
2326 //------------------------------------------------------------------------------
2327 void vvMainWindow::SEHorizontalSliderMoved()
2329 // if (mCurrentTime == SEHorizontalSlider->value()) return;
2330 HorizontalSliderMoved(SEHorizontalSlider->value(),COLUMN_DR_VIEW,3);
2331 // mCurrentTime = SEHorizontalSlider->value();
2333 //------------------------------------------------------------------------------
2335 //------------------------------------------------------------------------------
2336 void vvMainWindow::NOVerticalSliderChanged()
2338 static int value=-1;
2339 if (value == NOVerticalSlider->value()) return;
2340 else value = NOVerticalSlider->value();
2341 // int value = NOVerticalSlider->value();
2342 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
2343 if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1) {
2344 if (mSlicerManagers[i]->GetSlicer(0)->GetSlice() != value) {
2345 mSlicerManagers[i]->GetSlicer(0)->SetSlice(value);
2346 mSlicerManagers[i]->VerticalSliderHasChanged(0, value);
2348 // If nor Update/Render -> slider not work
2349 // only render = ok navigation, but for contour Update needed but slower ?
2351 mSlicerManagers[i]->UpdateSlice(0); // <-- DS add this. Not too much update ? YES. but needed for ImageContour ...
2352 //mSlicerManagers[i]->GetSlicer(0)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
2358 //------------------------------------------------------------------------------
2361 //------------------------------------------------------------------------------
2362 void vvMainWindow::NEVerticalSliderChanged()
2364 static int value=-1;
2365 if (value == NEVerticalSlider->value()) return;
2366 else value = NEVerticalSlider->value();
2367 // int value = NEVerticalSlider->value();
2368 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
2369 if (DataTree->topLevelItem(i)->data(COLUMN_UR_VIEW,Qt::CheckStateRole).toInt() > 1) {
2370 if (mSlicerManagers[i]->GetSlicer(1)->GetSlice() != value) {
2371 mSlicerManagers[i]->GetSlicer(1)->SetSlice(value);
2372 mSlicerManagers[i]->VerticalSliderHasChanged(1, value);
2373 mSlicerManagers[i]->UpdateSlice(1);
2374 //mSlicerManagers[i]->GetSlicer(1)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
2380 //------------------------------------------------------------------------------
2383 //------------------------------------------------------------------------------
2384 void vvMainWindow::SOVerticalSliderChanged()
2386 static int value=-1;
2387 if (value == SOVerticalSlider->value()) return;
2388 else value = SOVerticalSlider->value();
2389 //int value = SOVerticalSlider->value();
2390 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
2391 if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1) {
2392 if (mSlicerManagers[i]->GetSlicer(2)->GetSlice() != value) {
2393 mSlicerManagers[i]->GetSlicer(2)->SetSlice(value);
2394 mSlicerManagers[i]->VerticalSliderHasChanged(2, value);
2395 mSlicerManagers[i]->UpdateSlice(2);
2396 //mSlicerManagers[i]->GetSlicer(2)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
2398 // else { DD("avoid SOVerticalSlider slicer update"); }
2403 //------------------------------------------------------------------------------
2406 //------------------------------------------------------------------------------
2407 void vvMainWindow::SEVerticalSliderChanged()
2409 static int value=-1;
2410 if (value == SEVerticalSlider->value()) return;
2411 else value = SEVerticalSlider->value();
2412 // int value = SEVerticalSlider->value();
2413 for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
2414 if (DataTree->topLevelItem(i)->data(COLUMN_DR_VIEW,Qt::CheckStateRole).toInt() > 1) {
2415 if (mSlicerManagers[i]->GetSlicer(3)->GetSlice() != value) {
2416 mSlicerManagers[i]->GetSlicer(3)->SetSlice(value);
2417 mSlicerManagers[i]->VerticalSliderHasChanged(3, value);
2418 mSlicerManagers[i]->UpdateSlice(3);
2419 //mSlicerManagers[i]->GetSlicer(3)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
2425 //------------------------------------------------------------------------------
2428 //------------------------------------------------------------------------------
2429 void vvMainWindow::UpdateSlice(int slicer, int slice)
2431 // DD("vvMainWindow::UpdateSlice");
2435 // if (slice != NOVerticalSlider->value())
2436 NOVerticalSlider->setValue(slice);
2439 NEVerticalSlider->setValue(slice);
2442 SOVerticalSlider->setValue(slice);
2445 SEVerticalSlider->setValue(slice);
2449 // DD("vvMainWindow:UpdateSlice END");
2451 //------------------------------------------------------------------------------
2454 //------------------------------------------------------------------------------
2455 void vvMainWindow::UpdateTSlice(int slicer, int slice)
2459 NOHorizontalSlider->setValue(slice);
2462 NEHorizontalSlider->setValue(slice);
2465 SOHorizontalSlider->setValue(slice);
2468 SEHorizontalSlider->setValue(slice);
2472 //------------------------------------------------------------------------------
2475 //------------------------------------------------------------------------------
2476 void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax)
2478 int position = int((min+max)/2);
2479 int tPosition = int((tmin+tmax)/2);
2481 NOVerticalSlider->setValue(position);
2482 NOVerticalSlider->setRange(min,max);
2483 NOHorizontalSlider->setRange(tmin,tmax);
2484 NOHorizontalSlider->setValue(tPosition);
2485 } else if (slicer == 1) {
2486 NEVerticalSlider->setValue(position);
2487 NEVerticalSlider->setRange(min,max);
2488 NEHorizontalSlider->setRange(tmin,tmax);
2489 NEHorizontalSlider->setValue(tPosition);
2490 } else if (slicer == 2) {
2491 SOVerticalSlider->setValue(position);
2492 SOVerticalSlider->setRange(min,max);
2493 SOHorizontalSlider->setRange(tmin,tmax);
2494 SOHorizontalSlider->setValue(tPosition);
2495 } else if (slicer == 3) {
2496 SEVerticalSlider->setValue(position);
2497 SEVerticalSlider->setRange(min,max);
2498 SEHorizontalSlider->setRange(tmin,tmax);
2499 SEHorizontalSlider->setValue(tPosition);
2502 //------------------------------------------------------------------------------
2505 //------------------------------------------------------------------------------
2506 void vvMainWindow::SaveNOScreenshot()
2508 vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
2509 w2i->SetInput(NOViewWidget->GetRenderWindow());
2511 SaveScreenshot(w2i->GetOutput());
2514 //------------------------------------------------------------------------------
2517 //------------------------------------------------------------------------------
2518 void vvMainWindow::SaveNEScreenshot()
2520 vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
2521 w2i->SetInput(NEViewWidget->GetRenderWindow());
2523 SaveScreenshot(w2i->GetOutput());
2526 //------------------------------------------------------------------------------
2529 //------------------------------------------------------------------------------
2530 void vvMainWindow::SaveSOScreenshot()
2532 vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
2533 w2i->SetInput(SOViewWidget->GetRenderWindow());
2535 SaveScreenshot(w2i->GetOutput());
2538 //------------------------------------------------------------------------------
2541 //------------------------------------------------------------------------------
2542 void vvMainWindow::SaveSEScreenshot()
2544 vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
2545 w2i->SetInput(SEViewWidget->GetRenderWindow());
2547 SaveScreenshot(w2i->GetOutput());
2550 //------------------------------------------------------------------------------
2553 //------------------------------------------------------------------------------
2554 void vvMainWindow::SaveScreenshot(vtkImageData* image)
2556 QString Extensions = "Images( *.png);;";
2557 Extensions += "Images( *.jpg);;";
2558 Extensions += "Images( *.bmp);;";
2559 Extensions += "Images( *.tif);;";
2560 Extensions += "Images( *.ppm)";
2561 QString fileName = QFileDialog::getSaveFileName(this,
2563 itksys::SystemTools::GetFilenamePath(
2564 mSlicerManagers[0]->GetFileName()).c_str(),
2566 if (!fileName.isEmpty()) {
2567 const char *ext = fileName.toStdString().c_str() + strlen(fileName.toStdString().c_str()) - 4;
2568 if (!strcmp(ext, ".bmp")) {
2569 vtkBMPWriter *bmp = vtkBMPWriter::New();
2570 bmp->SetInput(image);
2571 bmp->SetFileName(fileName.toStdString().c_str());
2574 } else if (!strcmp(ext, ".tif")) {
2575 vtkTIFFWriter *tif = vtkTIFFWriter::New();
2576 tif->SetInput(image);
2577 tif->SetFileName(fileName.toStdString().c_str());
2580 } else if (!strcmp(ext, ".ppm")) {
2581 vtkPNMWriter *pnm = vtkPNMWriter::New();
2582 pnm->SetInput(image);
2583 pnm->SetFileName(fileName.toStdString().c_str());
2586 } else if (!strcmp(ext, ".png")) {
2587 vtkPNGWriter *png = vtkPNGWriter::New();
2588 png->SetInput(image);
2589 png->SetFileName(fileName.toStdString().c_str());
2592 } else if (!strcmp(ext, ".jpg")) {
2593 vtkJPEGWriter *jpg = vtkJPEGWriter::New();
2594 jpg->SetInput(image);
2595 jpg->SetFileName(fileName.toStdString().c_str());
2599 QMessageBox::information(this,tr("Problem saving screenshot !"),tr("Cannot save image.\nPlease set a file extension !!!"));
2604 //------------------------------------------------------------------------------
2607 //------------------------------------------------------------------------------
2608 void vvMainWindow::GoToCursor()
2610 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
2611 for (int column = 1; column < 5; column++) {
2612 if (DataTree->selectedItems()[0]->data(column,Qt::CheckStateRole).toInt() > 1) {
2613 double* cursorPos = mSlicerManagers[index]->GetSlicer(column-1)->GetCursorPosition();
2614 mSlicerManagers[index]->GetSlicer(column-1)->SetCurrentPosition(
2615 cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
2616 mSlicerManagers[index]->UpdateViews(1,column-1);
2617 mSlicerManagers[index]->UpdateLinked(column-1);
2622 //------------------------------------------------------------------------------
2624 //------------------------------------------------------------------------------
2625 void vvMainWindow::PlayPause()
2629 playButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/player_play.png")));
2633 int image_number=DataTree->topLevelItemCount();
2635 for (int i=0; i<image_number; i++)
2636 if (mSlicerManagers[i]->GetImage()->GetVTKImages().size() > 1) {
2642 playButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/player_pause.png")));
2643 QTimer::singleShot(1000/mFrameRate, this, SLOT(PlayNext()));
2647 //------------------------------------------------------------------------------
2649 //------------------------------------------------------------------------------
2650 void vvMainWindow::PlayNext()
2652 if (playMode && !this->isHidden()) {
2653 int image_number=DataTree->topLevelItemCount();
2654 ///Only play one slicer per SM, and only if the SM is being displayed
2655 for (int i=0; i<image_number; i++)
2656 for (int j=0; j<4; j++)
2657 if (mSlicerManagers[i]->GetImage()->GetVTKImages().size() > 1 &&
2658 DataTree->topLevelItem(i)->data(j+1,Qt::CheckStateRole).toInt() > 0) {
2659 mSlicerManagers[i]->SetNextTSlice(j);
2662 QTimer::singleShot(1000/mFrameRate, this, SLOT(PlayNext()));
2665 //------------------------------------------------------------------------------
2667 void vvMainWindow::ShowLastImage()
2669 if (mSlicerManagers.size() > 1) {
2670 QTreeWidgetItem * item=DataTree->topLevelItem(DataTree->topLevelItemCount()-1);
2671 CurrentImageChanged(mSlicerManagers.back()->GetId()); //select new image
2672 item->setData(1,Qt::CheckStateRole,2); //show the new image in the first panel
2673 DisplayChanged(item,1);
2677 //------------------------------------------------------------------------------
2678 void vvMainWindow::UpdateRenderWindows()
2680 if (NOViewWidget->GetRenderWindow()) NOViewWidget->GetRenderWindow()->Render();
2681 if (NEViewWidget->GetRenderWindow()) NEViewWidget->GetRenderWindow()->Render();
2682 if (SOViewWidget->GetRenderWindow()) SOViewWidget->GetRenderWindow()->Render();
2683 if (SEViewWidget->GetRenderWindow()) SEViewWidget->GetRenderWindow()->Render();
2685 //------------------------------------------------------------------------------
2687 //------------------------------------------------------------------------------
2688 void vvMainWindow::SegmentationOnCurrentImage()
2690 int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
2692 vvSegmentationDialog segmentation;
2693 segmentation.SetImage(mSlicerManagers[index]->GetSlicer(0)->GetImage());
2694 segmentation.exec();
2696 //------------------------------------------------------------------------------
2698 void vvMainWindow::SurfaceViewerLaunch()
2700 vvSurfaceViewerDialog surfaceViewer;
2701 surfaceViewer.exec();
2703 //------------------------------------------------------------------------------
2706 //------------------------------------------------------------------------------
2707 int vvMainWindow::GetImageDuplicateFilenameNumber(std::string filename)
2710 for(unsigned int l=0; l<mSlicerManagers.size(); l++) {
2711 vvSlicerManager * v = mSlicerManagers[l];
2712 if (v->GetBaseFileName() ==
2713 vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename))) {
2714 number = std::max(number, v->GetBaseFileNameNumber()+1);
2719 //------------------------------------------------------------------------------
2722 //------------------------------------------------------------------------------
2723 vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filename)
2725 // Change filename if another image exist with the same name
2726 int number = GetImageDuplicateFilenameNumber(filename);
2728 // Create new SliceManager
2729 vvSlicerManager* slicer_manager = new vvSlicerManager(4);
2730 slicer_manager->SetImage(image);//, IMAGE, number);
2731 // filename = filename+"_"+clitk::toString(number);
2732 slicer_manager->SetFilename(filename, number);
2733 mSlicerManagers.push_back(slicer_manager);
2735 //create an item in the tree with good settings
2736 QTreeWidgetItem *item = new QTreeWidgetItem();
2737 item->setData(0,Qt::UserRole,slicer_manager->GetFileName().c_str());//files[i].c_str());
2738 item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,slicer_manager->GetFileName().c_str());//filename.c_str());
2739 qApp->processEvents();
2741 for (int j = 1; j <= 4; j++) item->setData(j,Qt::CheckStateRole,1);
2743 //Create the buttons for reload and close
2744 qApp->processEvents();
2745 QTreePushButton* cButton = new QTreePushButton;
2746 cButton->setItem(item);
2747 cButton->setColumn(COLUMN_CLOSE_IMAGE);
2748 cButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/exit.png")));
2749 connect(cButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
2750 this,SLOT(CloseImage(QTreeWidgetItem*, int)));
2752 QTreePushButton* rButton = new QTreePushButton;
2753 rButton->setItem(item);
2754 rButton->setColumn(COLUMN_RELOAD_IMAGE);
2755 rButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/rotateright.png")));
2756 rButton->setEnabled(0);
2757 connect(rButton,SIGNAL(clickedInto(QTreeWidgetItem*, int)),
2758 this,SLOT(ReloadImage(QTreeWidgetItem*, int)));
2760 DataTree->addTopLevelItem(item);
2761 DataTree->setItemWidget(item, COLUMN_CLOSE_IMAGE, cButton);
2762 DataTree->setItemWidget(item, COLUMN_RELOAD_IMAGE, rButton);
2764 //set the id of the image
2765 QString id = slicer_manager->GetFileName().c_str() + QString::number(mSlicerManagers.size()-1);
2766 item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str());
2767 mSlicerManagers.back()->SetId(id.toStdString());
2769 linkPanel->addImage(slicer_manager->GetFileName().c_str()// filename
2770 , id.toStdString());
2772 connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)),
2773 this, SLOT(CurrentImageChanged(std::string)));
2774 connect(mSlicerManagers.back(), SIGNAL(currentPickedImageChanged(std::string)),
2775 this, SLOT(CurrentPickedImageChanged(std::string)));
2776 connect(mSlicerManagers.back(), SIGNAL(UpdatePosition(int, double, double, double, double, double, double, double)),
2777 this, SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
2778 connect(mSlicerManagers.back(), SIGNAL(UpdateVector(int, double, double, double, double)),
2779 this, SLOT(VectorChanged(int,double,double,double, double)));
2780 connect(mSlicerManagers.back(), SIGNAL(UpdateOverlay(int, double, double)),
2781 this, SLOT(OverlayChanged(int,double,double)));
2782 connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
2783 this, SLOT(FusionChanged(int,double)));
2784 connect(mSlicerManagers.back(), SIGNAL(UpdateWindows(int, int, int)),
2785 this,SLOT(WindowsChanged(int, int, int)));
2786 connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)),
2787 this,SLOT(WindowLevelChanged(double, double, int, int)));
2788 connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
2789 this,SLOT(UpdateSlice(int,int)));
2790 connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)),
2791 this,SLOT(UpdateTSlice(int, int)));
2792 connect(mSlicerManagers.back(), SIGNAL(UpdateSliceRange(int,int,int,int,int)),
2793 this,SLOT(UpdateSliceRange(int,int,int,int,int)));
2794 connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
2795 this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int)));
2796 connect(mSlicerManagers.back(), SIGNAL(UpdateLinkedNavigation(std::string,vvSlicerManager*)),
2797 this,SLOT(UpdateLinkedNavigation(std::string,vvSlicerManager*)));
2798 connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)),
2799 this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)));
2800 connect(mSlicerManagers.back(), SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
2802 qApp->processEvents();
2806 qApp->processEvents();
2810 return slicer_manager;
2812 //------------------------------------------------------------------------------
2815 //------------------------------------------------------------------------------
2816 void vvMainWindow::UpdateCurrentSlicer()
2819 if (DataTree->selectedItems().size() > 0) {
2820 index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
2822 mSlicerManagerCurrentIndex = index;
2824 //------------------------------------------------------------------------------