+ setupUi(this); // this sets up the GUI
+
+ mInputPathName = "";
+ mMenuTools = menuTools;
+ // mMenuSegmentation = menuSegmentation;
+ mContextMenu = &contextMenu;
+ mMenuExperimentalTools = menuExperimental;
+ mMainWidget = this;
+ mCurrentTime = -1;
+ mCurrentSelectedImageId = "";
+ mCurrentPickedImageId = "";
+ mCurrentPickedImageIndex = 0;
+
+ //Init the contextMenu
+ this->setContextMenuPolicy(Qt::CustomContextMenu);
+ contextActions.resize(0);
+ QAction* actionOpen_new_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/fileopen.png")),
+ tr("O&pen new Image"));
+ actionOpen_new_image->setShortcut(QKeySequence(tr("Ctrl+O")));
+ connect(actionOpen_new_image,SIGNAL(triggered()),this,SLOT(OpenImages()));
+ contextActions.push_back(actionOpen_new_image);
+ contextMenu.addSeparator();
+
+ QAction* actionClose_Image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/exit.png")),
+ tr("Close Current Image"));
+ connect(actionClose_Image,SIGNAL(triggered()),this,SLOT(CloseImage()));
+ contextActions.push_back(actionClose_Image);
+
+ QAction* actionReload_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/rotateright.png")),
+ tr("Reload Current Image"));
+ connect(actionReload_image,SIGNAL(triggered()),this,SLOT(ReloadImage()));
+ contextActions.push_back(actionReload_image);
+
+ QAction* actionSave_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/filesave.png")),
+ tr("Save Current Image"));
+ connect(actionSave_image,SIGNAL(triggered()),this,SLOT(SaveAs()));
+ contextActions.push_back(actionSave_image);
+
+ contextMenu.addSeparator();
+
+ contextMenu.addAction(actionAdd_VF_to_current_Image);
+ contextActions.push_back(actionAdd_VF_to_current_Image);
+
+ QAction* actionAdd_Overlay_to_current_Image = menuOverlay->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
+ tr("Add overlay image to current image"));
+ contextMenu.addAction(actionAdd_Overlay_to_current_Image);
+ contextActions.push_back(actionAdd_Overlay_to_current_Image);
+
+ connect(actionAdd_Overlay_to_current_Image,SIGNAL(triggered()), this,SLOT(SelectOverlayImage()));
+
+ contextMenu.addAction(actionAdd_fusion_image);
+ connect(actionAdd_fusion_image,SIGNAL(triggered()),this,SLOT(SelectFusionImage()));
+ contextActions.push_back(actionAdd_fusion_image);
+
+ // TRIAL DS
+ /*
+ QMenu * m = new QMenu(menubar);
+ m->setTitle("TOTO");
+ // m->setObjectName(QString::fromUtf8("TOTOTO"));
+ contextMenu.addMenu(m);
+ QAction * a = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
+ tr("BIDON"));
+ QAction * b = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
+ tr("BIDON2"));
+ m->addAction(a);
+ m->addAction(b);
+ connect(a,SIGNAL(triggered()),this,SLOT(AddFusionImage()));
+ */
+
+ //init the DataTree
+ mSlicerManagers.resize(0);
+
+ QStringList header;
+ header.append("");
+ header.append("TL");
+ header.append("TR");
+ header.append("BL");
+ header.append("BR");
+ header.append("");
+ header.append("");
+ header.append("Name");
+
+ DataTree->setHeaderLabels(header);
+ DataTree->resizeColumnToContents(COLUMN_TREE);
+ DataTree->resizeColumnToContents(COLUMN_UL_VIEW);
+ DataTree->resizeColumnToContents(COLUMN_UR_VIEW);
+ DataTree->resizeColumnToContents(COLUMN_DL_VIEW);
+ DataTree->resizeColumnToContents(COLUMN_DR_VIEW);
+ DataTree->resizeColumnToContents(COLUMN_CLOSE_IMAGE);
+ DataTree->resizeColumnToContents(COLUMN_RELOAD_IMAGE);
+ DataTree->resizeColumnToContents(COLUMN_IMAGE_NAME);
+
+ viewMode = 1;
+ documentation = new vvDocumentation();
+ help_dialog = new vvHelpDialog();
+ dicomSeriesSelector = new vvDicomSeriesSelector();
+
+ inverseButton->setEnabled(0);
+ actionAdd_Overlay_to_current_Image->setEnabled(0);
+ actionSave_As->setEnabled(0);
+ actionAdd_VF_to_current_Image->setEnabled(0);
+ actionAdd_fusion_image->setEnabled(0);
+
+ //init the sliders
+ verticalSliders.push_back(NOVerticalSlider);
+ verticalSliders.push_back(NEVerticalSlider);
+ verticalSliders.push_back(SOVerticalSlider);
+ verticalSliders.push_back(SEVerticalSlider);
+
+ for (int i =0; i < 4; i++)
+ verticalSliders[i]->hide();
+
+ horizontalSliders.push_back(NOHorizontalSlider);
+ horizontalSliders.push_back(NEHorizontalSlider);
+ horizontalSliders.push_back(SOHorizontalSlider);
+ horizontalSliders.push_back(SEHorizontalSlider);
+
+ for (int i =0; i < 4; i++)
+ horizontalSliders[i]->hide();
+
+
+ connect(NOVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(NOVerticalSliderChanged()));
+ connect(NEVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(NEVerticalSliderChanged()));
+ connect(SOVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(SOVerticalSliderChanged()));
+ connect(SEVerticalSlider,SIGNAL(valueChanged(int)),this,SLOT(SEVerticalSliderChanged()));
+
+ connect(NOHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(NOHorizontalSliderMoved()));
+ connect(NEHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(NEHorizontalSliderMoved()));
+ connect(SOHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(SOHorizontalSliderMoved()));
+ connect(SEHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(SEHorizontalSliderMoved()));
+
+ //connect everything
+ connect(actionCompute_mid_position_image,SIGNAL(triggered()),this,SLOT(ComputeMidPosition()));
+ connect(actionDeformable_Registration,SIGNAL(triggered()),this,SLOT(ComputeDeformableRegistration()));
+ connect(actionWarp_image_with_vector_field,SIGNAL(triggered()),this,SLOT(WarpImage()));
+ connect(actionLoad_images,SIGNAL(triggered()),this,SLOT(OpenImages()));
+ connect(actionOpen_Dicom,SIGNAL(triggered()),this,SLOT(OpenDicom()));
+ connect(actionOpen_Dicom_Struct,SIGNAL(triggered()),this,SLOT(OpenDCStructContour()));
+ connect(actionOpen_VTK_contour,SIGNAL(triggered()),this,SLOT(OpenVTKContour()));
+ connect(actionOpen_Multiple_Images_As_One,SIGNAL(triggered()),this,SLOT(MergeImages()));
+ connect(actionSlice_Image_As_Multiple_Images,SIGNAL(triggered()),this,SLOT(SliceImages()));
+ connect(actionOpen_Image_With_Time,SIGNAL(triggered()),this,SLOT(OpenImageWithTime()));
+ connect(actionMerge_images_as_n_dim_t, SIGNAL(triggered()), this, SLOT(MergeImagesWithTime()));
+ connect(actionSave_As,SIGNAL(triggered()),this,SLOT(SaveAs()));
+ connect(actionExit,SIGNAL(triggered()),this,SLOT(close()));
+ connect(actionAdd_VF_to_current_Image,SIGNAL(triggered()),this,SLOT(OpenField()));
+ connect(actionNavigation_Help,SIGNAL(triggered()),this,SLOT(ShowHelpDialog()));
+ connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation()));
+ connect(actionRegister_vv,SIGNAL(triggered()),this,SLOT(PopupRegisterForm()));
+
+ ///////////////////////////////////////////////
+ connect(actionSegmentation,SIGNAL(triggered()),this,SLOT(SegmentationOnCurrentImage()));
+ connect(actionSurface_Viewer,SIGNAL(triggered()),this,SLOT(SurfaceViewerLaunch()));
+ ///////////////////////////////////////////////
+
+ actionNorth_East_Window->setEnabled(0);
+ actionNorth_West_Window->setEnabled(0);
+ actionSouth_East_Window->setEnabled(0);
+ actionSouth_West_Window->setEnabled(0);
+
+ connect(actionNorth_East_Window,SIGNAL(triggered()),this,SLOT(SaveNEScreenshot()));
+ connect(actionNorth_West_Window,SIGNAL(triggered()),this,SLOT(SaveNOScreenshot()));
+ connect(actionSouth_East_Window,SIGNAL(triggered()),this,SLOT(SaveSEScreenshot()));
+ connect(actionSouth_West_Window,SIGNAL(triggered()),this,SLOT(SaveSOScreenshot()));
+
+ connect(DataTree,SIGNAL(itemSelectionChanged()),this,SLOT(ImageInfoChanged()));
+ connect(DataTree,SIGNAL(itemClicked(QTreeWidgetItem*, int)),this,
+ SLOT(DisplayChanged(QTreeWidgetItem*, int)));
+
+ connect(viewButton,SIGNAL(clicked()),this, SLOT(ChangeViewMode()) );
+ connect(windowSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited()));
+ connect(levelSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited()));
+ connect(colorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateColorMap()));
+ connect(presetComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateWindowLevel()));
+ connect(inverseButton,SIGNAL(clicked()),this,SLOT(SwitchWindowLevel()));
+ connect(applyWindowLevelToAllButton,SIGNAL(clicked()),this,SLOT(ApplyWindowLevelToAllImages()));
+
+
+ connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(ShowContextMenu(QPoint)));
+
+ connect(linkPanel,SIGNAL(addLink(QString,QString)),this,SLOT(AddLink(QString,QString)));
+ connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString)));
+ connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int,int,double,double,double)),this,SLOT(SetVFProperty(int,int,int,int,double,double,double)));
+ connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int)),this,SLOT(SetOverlayProperty(int)));
+ connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,double,double)),
+ this,SLOT(SetFusionProperty(int,int,double,double)));
+ connect(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows()));
+
+ playMode = 0;//pause
+ mFrameRate = 10;
+ playButton->setEnabled(0);
+ frameRateLabel->setEnabled(0);
+ frameRateSpinBox->setEnabled(0);
+ connect(playButton, SIGNAL(clicked()),this,SLOT(PlayPause()));
+ connect(frameRateSpinBox, SIGNAL(valueChanged(int)),this,SLOT(ChangeFrameRate(int)));
+
+ goToCursorPushButton->setEnabled(0);
+ connect(goToCursorPushButton, SIGNAL(clicked()),this,SLOT(GoToCursor()));
+
+ NOViewWidget->hide();
+ NEViewWidget->hide();
+ SOViewWidget->hide();
+ SEViewWidget->hide();
+
+ //Recently opened files
+ std::list<std::string> recent_files = GetRecentlyOpenedImages();
+ recentlyOpenedFilesMenu=NULL;
+ if ( !recent_files.empty() ) {
+ createRecentlyOpenedFilesMenu();
+ updateRecentlyOpenedFilesMenu(recent_files);
+ }
+
+ // Adding all new tools (insertion in the menu)
+ vvToolManager::GetInstance()->InsertToolsInMenu(this);
+ vvToolManager::GetInstance()->EnableToolsInMenu(this, false);
+
+ if (!CLITK_EXPERIMENTAL)
+ menuExperimental->menuAction()->setVisible(false);
+
+
+ QTimer * timerMemory = new QTimer(this);
+ //timerMemory->setInterval(5);
+ connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage()));
+ timerMemory->start(2000);
+}
+//------------------------------------------------------------------------------
+void vvMainWindow::show(){
+ vvMainWindowBase::show();
+ PopupRegisterForm(true);
+}
+//------------------------------------------------------------------------------
+void vvMainWindow::UpdateMemoryUsage()
+{
+ // clitk::PrintMemory(true);
+ if (clitk::GetMemoryUsageInMb() == 0) infoPanel->setMemoryInMb("NA");
+ else infoPanel->setMemoryInMb(QString::number(clitk::GetMemoryUsageInMb())+" MiB");