From deef29288a3540e5459cb37c88ad5c5872256889 Mon Sep 17 00:00:00 2001 From: srit Date: Mon, 21 Mar 2011 16:09:05 +0000 Subject: [PATCH] Romulo: - 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 | 9 +++++++ vv/vvLinkPanel.h | 3 +++ vv/vvMainWindow.cxx | 45 +++++++++++++++++++++++++++++++++-- vv/vvMainWindow.h | 5 +++- vv/vvSlicerManager.cxx | 7 ++++++ vv/vvSlicerManager.h | 2 ++ vv/vvSlicerManagerCommand.cxx | 4 ++++ 7 files changed, 72 insertions(+), 3 deletions(-) diff --git a/vv/vvLinkPanel.cxx b/vv/vvLinkPanel.cxx index 7dc2e88..4c29183 100644 --- a/vv/vvLinkPanel.cxx +++ b/vv/vvLinkPanel.cxx @@ -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; } //------------------------------------------------------------------------------ diff --git a/vv/vvLinkPanel.h b/vv/vvLinkPanel.h index 857a731..bc1316b 100644 --- a/vv/vvLinkPanel.h +++ b/vv/vvLinkPanel.h @@ -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 imageNames; std::vector image1Ids; std::vector image2Ids; + + bool mLinkAll; }; // end class vvLinkPanel //==================================================================== diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index fb76458..772cdea 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -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 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)), diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index 3625923..7918d0f 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -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 mListOfRunningTool; @@ -198,7 +201,7 @@ private: static vvMainWindow * mSingleton; int mCurrentTime; - + }; #include "vvMainWindow.txx" diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index e5f6caf..efcb585 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -939,6 +939,13 @@ void vvSlicerManager::Activated() //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +void vvSlicerManager::Picked() +{ + emit currentPickedImageChanged(mId); +} +//---------------------------------------------------------------------------- + //---------------------------------------------------------------------------- void vvSlicerManager::UpdateWindowLevel() { diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index 5cca97c..13c6970 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -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); diff --git a/vv/vvSlicerManagerCommand.cxx b/vv/vvSlicerManagerCommand.cxx index d73bcfc..78745bc 100644 --- a/vv/vvSlicerManagerCommand.cxx +++ b/vv/vvSlicerManagerCommand.cxx @@ -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); -- 2.47.1