From: Simon Rit Date: Thu, 6 Sep 2012 07:53:08 +0000 (+0200) Subject: Allow for overlay images with differing temporal length X-Git-Tag: v1.4.0~281^2~8 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=58b9eaff4d486cb20d94ff4921d851e93c62c84f;p=clitk.git Allow for overlay images with differing temporal length --- diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index e82590e..8f94ff6 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -1086,7 +1086,8 @@ void vvMainWindow::ImageInfoChanged() QString inputSizeInBytes; QString image = DataTree->selectedItems()[0]->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString(); - if (mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size() > 1 || playMode == 1) { + int nframes = mSlicerManagers[index]->GetSlicer(0)->GetTMax(); + if (nframes > 1 || playMode == 1) { playButton->setEnabled(1); frameRateLabel->setEnabled(1); frameRateSpinBox->setEnabled(1); @@ -1500,17 +1501,12 @@ void vvMainWindow::DisplaySliders(int slicer, int window) int tRange[2]; tRange[0] = 0; tRange[1] = mSlicerManagers[slicer]->GetSlicer(window)->GetTMax(); - int tPosition = mSlicerManagers[slicer]->GetSlicer(window)->GetTSlice(); + int tPosition = mSlicerManagers[slicer]->GetSlicer(window)->GetMaxCurrentTSlice(); bool showHorizontal = false; bool showVertical = false; - if (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 3 - || (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 2 - && mSlicerManagers[slicer]->GetType() != vvImageReader::IMAGEWITHTIME - && mSlicerManagers[slicer]->GetType() != vvImageReader::MERGEDWITHTIME)) + if (range[1]>0) showVertical = true; - if (mSlicerManagers[slicer]->GetSlicer(window)->GetImage()->GetNumberOfDimensions() > 3 - || mSlicerManagers[slicer]->GetType() == vvImageReader::IMAGEWITHTIME - || mSlicerManagers[slicer]->GetType() == vvImageReader::MERGEDWITHTIME) + if (tRange[1]>0) showHorizontal = true; if (showVertical) @@ -1932,6 +1928,10 @@ void vvMainWindow::AddOverlayImage(int index, std::vector fileNames qApp->processEvents(); ImageInfoChanged(); QApplication::restoreOverrideCursor(); + + // Update the display to update, e.g., the sliders + for(int i=0; i<4; i++) + DisplaySliders(index, i); } else { QApplication::restoreOverrideCursor(); QString error = "Cannot import the new image.\n"; @@ -2895,9 +2895,8 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) vidwriter->SetInput(image); vidwriter->SetFileName(fileName.toStdString().c_str()); vidwriter->Start(); - vvImage * vvImg = mSlicerManagers[smIndex]->GetImage(); - int nSlice = vvImg->GetVTKImages().size(); - for(int i=0; iGetSlicer(0)->GetTMax(); + for(int i=0; i<=nSlice; i++) { mSlicerManagers[smIndex]->SetNextTSlice(0); vtkSmartPointer w2i = vtkSmartPointer::New(); w2i->SetInput(widget->GetRenderWindow()); @@ -2945,7 +2944,7 @@ void vvMainWindow::PlayPause() int image_number=DataTree->topLevelItemCount(); bool has_temporal; for (int i=0; iGetImage()->GetVTKImages().size() > 1) { + if (mSlicerManagers[i]->GetSlicer(0)->GetTMax() > 0) { has_temporal=true; break; } @@ -2966,7 +2965,7 @@ void vvMainWindow::PlayNext() ///Only play one slicer per SM, and only if the SM is being displayed for (int i=0; iGetImage()->GetVTKImages().size() > 1 && + if (mSlicerManagers[i]->GetSlicer(0)->GetTMax() > 0 && DataTree->topLevelItem(i)->data(j+1,Qt::CheckStateRole).toInt() > 0) { mSlicerManagers[i]->SetNextTSlice(j); break; diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index cc5662b..17aa41b 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -708,17 +708,18 @@ void vvSlicer::SetVFLog(int log) void vvSlicer::SetTSlice(int t) { if (t < 0) - t = 0; + mCurrentTSlice = 0; else if ((unsigned int)t >= mImage->GetVTKImages().size()) - t = mImage->GetVTKImages().size() -1; + mCurrentTSlice = mImage->GetVTKImages().size() -1; + else + mCurrentTSlice = t; // Update transform mConcatenatedTransform->Identity(); - mConcatenatedTransform->Concatenate(mImage->GetTransform()[t]); + mConcatenatedTransform->Concatenate(mImage->GetTransform()[mCurrentTSlice]); mConcatenatedTransform->Concatenate(mSlicingTransform); // Update image data - mCurrentTSlice = t; mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] ); if (mVF && mVFActor->GetVisibility()) { if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice) @@ -762,6 +763,18 @@ int vvSlicer::GetTSlice() } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +int vvSlicer::GetMaxCurrentTSlice() +{ + int t = mCurrentTSlice; + if(mOverlay) + t = std::max(t, mCurrentOverlayTSlice); + if(mFusion) + t = std::max(t, mCurrentFusionTSlice); + return t; +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ int vvSlicer::GetFusionTSlice() { @@ -1467,6 +1480,14 @@ void vvSlicer::SetSlice(int slice) } //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +int vvSlicer::GetTMax() { + int tmax = (int)mImage->GetVTKImages().size() - 1; + if(mOverlay) + tmax = std::max(tmax, (int)mOverlay->GetVTKImages().size()-1); + return tmax; +} +//---------------------------------------------------------------------------- //---------------------------------------------------------------------------- void vvSlicer::SetContourSlice() diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index 71f7ece..9a750e1 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -101,11 +101,10 @@ public: int GetTSlice(); int GetFusionTSlice(); int GetOverlayTSlice(); + int GetMaxCurrentTSlice(); ///Reimplemented from vtkImageViewer2 to add polydata support void SetSlice(int s); - int GetTMax() { - return (unsigned int)mImage->GetVTKImages().size() - 1; - } + int GetTMax(); void SetOpacity(double s); void SetRenderWindow(int orientation, vtkRenderWindow * rw); diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index bc03ebd..c0e652d 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -442,7 +442,7 @@ void vvSlicerManager::SetTSlice(int slice) if (mLandmarks) mLandmarks->SetTime(slice); for ( unsigned int i = 0; i < mSlicers.size(); i++) { - if (slice != mSlicers[i]->GetTSlice()) { + if (slice != mSlicers[i]->GetMaxCurrentTSlice()) { mSlicers[i]->SetTSlice(slice); UpdateTSlice(i); } @@ -454,7 +454,7 @@ void vvSlicerManager::SetTSlice(int slice) //---------------------------------------------------------------------------- void vvSlicerManager::SetNextTSlice(int originating_slicer) { - int t = mSlicers[0]->GetTSlice(); + int t = mSlicers[0]->GetMaxCurrentTSlice(); t++; if (t > mSlicers[0]->GetTMax()) t = 0; @@ -467,7 +467,7 @@ void vvSlicerManager::SetNextTSlice(int originating_slicer) //---------------------------------------------------------------------------- void vvSlicerManager::SetPreviousTSlice(int originating_slicer) { - int t = mSlicers[0]->GetTSlice(); + int t = mSlicers[0]->GetMaxCurrentTSlice(); t--; if (t < 0) t = mSlicers[0]->GetTMax(); @@ -502,16 +502,17 @@ void vvSlicerManager::SetTSliceInSlicer(int tslice, int slicer) if (mLandmarks) mLandmarks->SetTime(tslice); - if (mSlicers[slicer]->GetTSlice() == tslice) return; + if (mSlicers[slicer]->GetMaxCurrentTSlice() == tslice) return; + + mSlicers[slicer]->SetTSlice(tslice); if(mSlicingPreset==VOXELS_SLICING) { vtkMatrix4x4 *imageTransformInverse = vtkMatrix4x4::New(); - mImage->GetTransform()[tslice]->GetInverse(imageTransformInverse); + mImage->GetTransform()[mSlicers[slicer]->GetTSlice()]->GetInverse(imageTransformInverse); this->GetSlicer(slicer)->GetSlicingTransform()->SetMatrix(imageTransformInverse); imageTransformInverse->Delete(); } - mSlicers[slicer]->SetTSlice(tslice); UpdateTSlice(slicer); } //---------------------------------------------------------------------------- @@ -628,11 +629,11 @@ void vvSlicerManager::UpdateViews(int current,int slicer) && mSlicers[i]->GetRenderer()->GetDraw() && mSlicers[i]->GetRenderWindow()->GetSize()[0] > 2 && mSlicers[i]->GetRenderWindow()->GetSize()[1] > 2) { - mSlicers[i]->SetCurrentPosition(p[0], p[1], p[2], mSlicers[slicer]->GetTSlice()); + mSlicers[i]->SetCurrentPosition(p[0], p[1], p[2], mSlicers[slicer]->GetMaxCurrentTSlice()); mSlicers[i]->UpdateCursorPosition(); if (current) { //do not display corner annotation if image is the one picked mSlicers[i]->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX, - -VTK_DOUBLE_MAX, mSlicers[slicer]->GetTSlice()); + -VTK_DOUBLE_MAX, mSlicers[slicer]->GetMaxCurrentTSlice()); mSlicers[i]->SetCursorColor(255,10,212); } else { mSlicers[i]->SetCursorColor(150,10,282); @@ -684,7 +685,7 @@ void vvSlicerManager::UpdateLinked(int slicer) z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4]-0.5 && z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]+0.5) { for (std::list::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++) { - emit UpdateLinkManager(*i, slicer, p[0], p[1], p[2], mSlicers[slicer]->GetTSlice()); + emit UpdateLinkManager(*i, slicer, p[0], p[1], p[2], mSlicers[slicer]->GetMaxCurrentTSlice()); } } } @@ -939,7 +940,7 @@ void vvSlicerManager::UpdateInfoOnCursorPosition(int slicer) if (mSlicers[slicer]->GetVFActor() ) { displayVec = 1; - unsigned int currentTime = mSlicers[slicer]->GetTSlice(); + unsigned int currentTime = mSlicers[slicer]->GetMaxCurrentTSlice(); vtkImageData *vf = NULL; if (mSlicers[slicer]->GetVF()->GetVTKImages().size() > currentTime) @@ -1026,7 +1027,7 @@ void vvSlicerManager::UpdateSlice(int slicer) void vvSlicerManager::UpdateTSlice(int slicer) { int slice = mSlicers[slicer]->GetSlice(); - int tslice = mSlicers[slicer]->GetTSlice(); + int tslice = mSlicers[slicer]->GetMaxCurrentTSlice(); if (mPreviousSlice[slicer] == slice) { if (mPreviousTSlice[slicer] == tslice) { // DD("************** NOTHING ***********"); diff --git a/vv/vvSlicerManagerCommand.cxx b/vv/vvSlicerManagerCommand.cxx index 9929e9d..73a0ab5 100644 --- a/vv/vvSlicerManagerCommand.cxx +++ b/vv/vvSlicerManagerCommand.cxx @@ -271,7 +271,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, //All type of mouse events if (event == vtkCommand::LeaveEvent) { this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX, - -VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice()); + -VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetMaxCurrentTSlice()); this->SM->GetSlicer(VisibleInWindow)->Render(); return; } @@ -368,7 +368,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, this->SM->GetSlicer(VisibleInWindow)->GetSlicingTransform()->TransformPoint(p, pt); this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(pt[0],pt[1],pt[2], - this->SM->GetSlicer(VisibleInWindow)->GetTSlice()); + this->SM->GetSlicer(VisibleInWindow)->GetMaxCurrentTSlice()); if (newLandmark) { this->SM->AddLandmark(xWorld,yWorld,zWorld, this->SM->GetSlicer(VisibleInWindow)->GetTSlice());