From 095b3f14beafe4ce1c62146f2e5726a4b3f3c874 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Wed, 30 Jun 2010 06:19:13 +0000 Subject: [PATCH] Manage current selected image --- vv/vvMainWindow.cxx | 46 +++++++++++++++++++++++++++++++++++++++---- vv/vvMainWindow.h | 5 ++++- vv/vvMainWindowBase.h | 2 +- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index abdbd1a..28094df 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -102,6 +102,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() mMenuExperimentalTools = menuExperimental; mMainWidget = this; mCurrentTime = -1; + mCurrentSelectedImageId = ""; //Init the contextMenu this->setContextMenuPolicy(Qt::CustomContextMenu); @@ -899,7 +900,10 @@ void vvMainWindow::UpdateTree() //------------------------------------------------------------------------------ void vvMainWindow::CurrentImageChanged(std::string id) { - // DD("CurrentImageChanged"); + // DD("CurrentImageChanged"); +// DD(id); +// DD(mCurrentSelectedImageId); + if (id == mCurrentSelectedImageId) return; // Do nothing int selected = 0; for (int i = 0; i < DataTree->topLevelItemCount(); i++) { if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString().toStdString() == id) { @@ -912,7 +916,8 @@ void vvMainWindow::CurrentImageChanged(std::string id) } DataTree->topLevelItem(selected)->setSelected(1); - // DD(mSlicerManagers[selected]->GetFileName()); + // DD(mSlicerManagers[selected]->GetFileName()); + mCurrentSelectedImageId = id; emit SelectedImageHasChanged(mSlicerManagers[selected]); } //------------------------------------------------------------------------------ @@ -1875,7 +1880,38 @@ void vvMainWindow::AddOverlayImage(int index, QString file) QMessageBox::information(this,tr("Problem reading image !"),error); } } +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvMainWindow::AddROI(int index, QString file) +{ + DD("AddImageAndROI"); + /* + // Get slice manager + + // Load image + + vvImageReader * mReader = new vvImageReader; + mReader->SetInputFilename(filename.toStdString()); + mReader->Update(IMAGE); + if (mReader->GetLastError().size() != 0) { + std::cerr << "Error while reading " << filename.toStdString() << std::endl; + QString error = "Cannot open file \n"; + error += mReader->GetLastError().c_str(); + QMessageBox::information(this,tr("Reading problem"),error); + delete mReader; + return; + } + vvImage::Pointer roi = mReader->GetOutput(); + + // Create roi in new tool + vvToolStructureSetManager::AddImage(mCurrentSlicerManager, roi); +*/ +} +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void vvMainWindow::AddFusionImage() { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2360,7 +2396,6 @@ void vvMainWindow::NEVerticalSliderChanged() //------------------------------------------------------------------------------ void vvMainWindow::SOVerticalSliderChanged() { - // DD("SOVerticalSliderChanged"); static int value=-1; // DD(value); // DD(SOVerticalSlider->value()); @@ -2682,7 +2717,7 @@ void vvMainWindow::SurfaceViewerLaunch() } //------------------------------------------------------------------------------ -void vvMainWindow::AddImage(vvImage::Pointer image,std::string filename) +vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filename) { vvSlicerManager* slicer_manager = new vvSlicerManager(4); slicer_manager->SetImage(image); @@ -2758,6 +2793,9 @@ void vvMainWindow::AddImage(vvImage::Pointer image,std::string filename) ShowLastImage(); InitDisplay(); qApp->processEvents(); + + // End + return slicer_manager; } //------------------------------------------------------------------------------ diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index ffae061..52da158 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -45,9 +45,10 @@ class vvMainWindow: public vvMainWindowBase, vvMainWindow(); ~vvMainWindow(); void LoadImages(std::vector filenames, LoadedImageType type); - void AddImage(vvImage::Pointer image,std::string filename); + vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename); void AddField(QString file,int index); void AddOverlayImage(int index, QString filename); + void AddROI(int index, QString filename); ///Adds a mesh to a SlicerManager, with optional warping by vector field void AddContour(int image_index, vvMesh::Pointer contour, bool propagation); ///This is used to show an image when opened or computed @@ -179,6 +180,8 @@ private: std::vector horizontalSliders; std::vector verticalSliders; int mFrameRate; + + std::string mCurrentSelectedImageId; // vvMainWindowToolInfo * mCurrentToolInfo; // std::vector mListOfRunningTool; diff --git a/vv/vvMainWindowBase.h b/vv/vvMainWindowBase.h index fffbc28..77e5539 100644 --- a/vv/vvMainWindowBase.h +++ b/vv/vvMainWindowBase.h @@ -35,7 +35,7 @@ public: vvMainWindowBase() { mSlicerManagerCurrentIndex = -1; } ~vvMainWindowBase() { } - virtual void AddImage(vvImage::Pointer image,std::string filename) = 0; + virtual vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename) = 0; virtual void UpdateCurrentSlicer() = 0; virtual QTabWidget * GetTab() = 0; const std::vector & GetSlicerManagers() const { return mSlicerManagers; } -- 2.47.1