]> Creatis software - clitk.git/commitdiff
Manage current selected image
authordsarrut <dsarrut>
Wed, 30 Jun 2010 06:19:13 +0000 (06:19 +0000)
committerdsarrut <dsarrut>
Wed, 30 Jun 2010 06:19:13 +0000 (06:19 +0000)
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvMainWindowBase.h

index abdbd1ae45393729c662180780208c0373505500..28094dfdd661eb3b8768ee03ac2a7efeb3181d9d 100644 (file)
@@ -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;
 }
 //------------------------------------------------------------------------------
 
index ffae061112b828f7bd3fc5db982183eb0394a32b..52da158a330657369604c1b5f1bad1d6c42ea483 100644 (file)
@@ -45,9 +45,10 @@ class vvMainWindow: public vvMainWindowBase,
   vvMainWindow();
   ~vvMainWindow();
   void LoadImages(std::vector<std::string> 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<QSlider*> horizontalSliders;
   std::vector<QSlider*> verticalSliders;
   int mFrameRate;
+  
+  std::string mCurrentSelectedImageId;
 
   // vvMainWindowToolInfo * mCurrentToolInfo;
   // std::vector<vvToolCreatorBase*> mListOfRunningTool;
index fffbc2810e0f37b8da2712fec359f2562319074d..77e5539a59af56cb817656176e5c297651f8830a 100644 (file)
@@ -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<vvSlicerManager*> & GetSlicerManagers() const { return mSlicerManagers; }