]> Creatis software - clitk.git/commitdiff
Romulo:
authorsrit <srit>
Mon, 21 Mar 2011 16:09:05 +0000 (16:09 +0000)
committersrit <srit>
Mon, 21 Mar 2011 16:09:05 +0000 (16:09 +0000)
- set Link/Link All functionality
  + when linking two images: take the one in the first combo box (left) as the reference for viewing adjustments
  + when linking all images: take the last manipulated image as the reference. The last manipulated image is the one with which the user last interacted using the mouse (mouseclick, mousewheel, but NOT mousemove)

vv/vvLinkPanel.cxx
vv/vvLinkPanel.h
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h
vv/vvSlicerManagerCommand.cxx

index 7dc2e887362442dc4bb8f7473a0e1783fddc9aa9..4c29183111a70a3d055ea7fe0e8c26e0f17468c4 100644 (file)
@@ -57,6 +57,13 @@ void vvLinkPanel::addImage(std::string name, std::string id)
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+bool vvLinkPanel::isLinkAll()
+{
+  return mLinkAll;
+}
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 void vvLinkPanel::removeImage(int index)
 {
@@ -129,6 +136,7 @@ void vvLinkPanel::UpdateComboBox2(int index)
 //------------------------------------------------------------------------------
 void vvLinkPanel::linkAll()
 {
+  mLinkAll = true;
   //First remove all links
   while (linkTableWidget->rowCount())
     removeLink(1,1);
@@ -140,6 +148,7 @@ void vvLinkPanel::linkAll()
     for (int i=0; i< count-j; i++)
       addLink();
   }
+  mLinkAll = false;
 }
 //------------------------------------------------------------------------------
 
index 857a7315f88126ab64c3d22f430783070da73b12..bc1316b12b3945c067c050ffb48af4e436494279 100644 (file)
@@ -35,6 +35,7 @@ public:
 
     void addImage(std::string name, std::string id);
     void removeImage(int i);
+    bool isLinkAll();
 
 public slots :
     void UpdateComboBox2(int i);
@@ -52,6 +53,8 @@ private:
     std::vector<std::string> imageNames;
     std::vector<std::string> image1Ids;
     std::vector<std::string> image2Ids;
+    
+    bool mLinkAll;
 
 }; // end class vvLinkPanel
 //====================================================================
index fb764580f224f30bb6fe8cd3fd8655b0171dc2dc..772cdea60df5bd24fe3127b0da15e5195ef42993 100644 (file)
@@ -109,6 +109,8 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   mMainWidget = this;
   mCurrentTime = -1;
   mCurrentSelectedImageId = "";
+  mCurrentPickedImageId = "";
+  mCurrentPickedImageIndex = 0;
 
   //Init the contextMenu
   this->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -327,6 +329,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   //timerMemory->setInterval(5);
   connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage()));
   timerMemory->start(2000);
+  
 }
 //------------------------------------------------------------------------------
 
@@ -876,6 +879,8 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, LoadedImageType fi
 
         connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)),
                 this,SLOT(CurrentImageChanged(std::string)));
+       connect(mSlicerManagers.back(), SIGNAL(currentPickedImageChanged(std::string)),
+               this, SLOT(CurrentPickedImageChanged(std::string)));
         connect(mSlicerManagers.back(), SIGNAL(UpdatePosition(int, double, double, double, double, double, double, double)),
                 this,SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
         connect(mSlicerManagers.back(), SIGNAL(UpdateVector(int, double, double, double, double)),
@@ -963,6 +968,27 @@ void vvMainWindow::CurrentImageChanged(std::string id)
 }
 //------------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+void vvMainWindow::CurrentPickedImageChanged(std::string id)
+{
+  if (id == mCurrentPickedImageId) 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) {
+      selected = i;
+    } else {
+      DataTree->topLevelItem(i)->setSelected(0);
+    }
+    for (int child = 0; child < DataTree->topLevelItem(i)->childCount(); child++)
+      DataTree->topLevelItem(i)->child(child)->setSelected(0);
+
+  }
+  DataTree->topLevelItem(selected)->setSelected(1);
+  mCurrentPickedImageId = id;
+  mCurrentPickedImageIndex = selected;
+}
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 void vvMainWindow::ImageInfoChanged()
 {
@@ -1081,8 +1107,6 @@ void vvMainWindow::ImageInfoChanged()
       inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
     }
 
-    transformation = imageSelected->GetTransform()->GetMatrix();
-
     QString dim = QString::number(dimension) + " (";
     dim += pixelType + ")";
 
@@ -1093,6 +1117,7 @@ void vvMainWindow::ImageInfoChanged()
     infoPanel->setOrigin(GetVectorDoubleAsString(origin));
     infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
     infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
+    transformation = imageSelected->GetTransform()->GetMatrix();
     infoPanel->setTransformation(Get4x4MatrixDoubleAsString(transformation));
 
     landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
@@ -2211,15 +2236,29 @@ void vvMainWindow::SaveAs()
 //------------------------------------------------------------------------------
 void vvMainWindow::AddLink(QString image1,QString image2)
 {
+  unsigned int sm1 = 0;
+  unsigned int sm2 = 0;
+  
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
     if (image1.toStdString() == mSlicerManagers[i]->GetId()) {
       mSlicerManagers[i]->AddLink(image2.toStdString());
+      sm1 = i;
     }
     if (image2.toStdString() == mSlicerManagers[i]->GetId()) {
       mSlicerManagers[i]->AddLink(image1.toStdString());
+      sm2 = i;
     }
   }
+
+  if (linkPanel->isLinkAll())  {
+    emit UpdateLinkedNavigation(mSlicerManagers[sm1]->GetId(), mSlicerManagers[mCurrentPickedImageIndex]);
+    emit UpdateLinkedNavigation(mSlicerManagers[sm2]->GetId(), mSlicerManagers[mCurrentPickedImageIndex]);
+  }
+  else {
+    emit UpdateLinkedNavigation(mSlicerManagers[sm2]->GetId(), mSlicerManagers[sm1]);
+  }
 }
+
 //------------------------------------------------------------------------------
 
 
@@ -2746,6 +2785,8 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen
 
   connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)),
           this, SLOT(CurrentImageChanged(std::string)));
+  connect(mSlicerManagers.back(), SIGNAL(currentPickedImageChanged(std::string)),
+          this, SLOT(CurrentPickedImageChanged(std::string)));
   connect(mSlicerManagers.back(), SIGNAL(UpdatePosition(int, double, double, double, double, double, double, double)),
           this, SLOT(MousePositionChanged(int,double, double, double, double, double, double, double)));
   connect(mSlicerManagers.back(), SIGNAL(UpdateVector(int, double, double, double, double)),
index 362592382572171920e87f17c6feaac40bb83c4a..7918d0f6793be7acd761d9fc989522944bd1b2e0 100644 (file)
@@ -84,6 +84,7 @@ public slots:
   void OpenVTKContour();
   void SaveAs();
   void CurrentImageChanged(std::string id);
+  void CurrentPickedImageChanged(std::string id);
   void ImageInfoChanged();
   void ShowHelpDialog();
   void ShowDocumentation();
@@ -191,6 +192,8 @@ private:
   int mFrameRate;
   
   std::string mCurrentSelectedImageId;
+  std::string mCurrentPickedImageId;
+  unsigned int mCurrentPickedImageIndex;
 
   // vvMainWindowToolInfo * mCurrentToolInfo;
   // std::vector<vvToolCreatorBase*> mListOfRunningTool;
@@ -198,7 +201,7 @@ private:
   static vvMainWindow * mSingleton;
 
   int mCurrentTime;
-
+  
 };
 
 #include "vvMainWindow.txx"
index e5f6caf3f196e60337c6849c0445969f7a624f0b..efcb58532ff33a98e6790915c83d958a8d6e11a9 100644 (file)
@@ -939,6 +939,13 @@ void vvSlicerManager::Activated()
 //----------------------------------------------------------------------------
 
 
+//----------------------------------------------------------------------------
+void vvSlicerManager::Picked()
+{
+  emit currentPickedImageChanged(mId);
+}
+//----------------------------------------------------------------------------
+
 //----------------------------------------------------------------------------
 void vvSlicerManager::UpdateWindowLevel()
 {
index 5cca97c439d2ee45238c0bf72c6fb57cad549537..13c6970206ee37551f767caac9629d1625ac7de0 100644 (file)
@@ -176,6 +176,7 @@ class vvSlicerManager : public QObject {
   void ReloadVF();
 
   void Activated();
+  void Picked();
   void UpdateInfoOnCursorPosition(int slicer);
   void UpdateWindowLevel();
   void UpdateSlice(int slicer);
@@ -193,6 +194,7 @@ class vvSlicerManager : public QObject {
 
 signals :
   void currentImageChanged(std::string id);
+  void currentPickedImageChanged(std::string id);
   void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
   void UpdateVector(int display, double x, double y, double z, double value);
   void UpdateOverlay(int display, double valueOver, double valueRef);
index d73bcfcd2ca1bd80510bf6043c357dc0f5fd7d36..78745bc52324511e8ed534b4bf0ac38334170adf 100644 (file)
@@ -292,6 +292,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
       }
 
       if (event == vtkCommand::EndInteractionEvent) {
+       this->SM->Picked();
         this->SM->UpdateLinkedNavigation(this->SM->GetSlicer(VisibleInWindow),true);
         return;
       }
@@ -302,6 +303,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
       this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetVisibility(1);
 
       if (event == vtkCommand::MouseWheelForwardEvent && !isi->GetInteractor()->GetControlKey()) {
+       this->SM->Picked();
         this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
         this->SM->UpdateSlice(VisibleInWindow);
       } else if (event == vtkCommand::MouseWheelForwardEvent && isi->GetInteractor()->GetControlKey()) {
@@ -309,6 +311,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
         this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
         Execute(caller, vtkCommand::EndInteractionEvent, NULL);
       } else if (event == vtkCommand::MouseWheelBackwardEvent && !isi->GetInteractor()->GetControlKey()) {
+       this->SM->Picked();
         this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
         this->SM->UpdateSlice(VisibleInWindow);
       } else if (event == vtkCommand::MouseWheelBackwardEvent && isi->GetInteractor()->GetControlKey()) {
@@ -360,6 +363,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
         this->SM->Render();
       }
       if (event == vtkCommand::PickEvent || event == vtkCommand::StartPickEvent) {
+       this->SM->Picked();
         this->SM->UpdateViews(1,VisibleInWindow);
         this->SM->UpdateLinked(VisibleInWindow);
         this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);