X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvSlicerManager.cxx;h=813ba2258bc1f2b247b342f9176e5b2be8f91a4b;hb=9794609d9607a3bc76aec1d10fb58bcb9aed4357;hp=871c818a64acf3083e4706a5519ce56ae5d6eb33;hpb=8e55faf6d71d39430ea3c9e93a54d2f0399371d9;p=clitk.git diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 871c818..813ba22 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -57,7 +57,7 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers) mPreset = 0; mOverlayColor = 130; - mFusionOpacity = 70; + mFusionOpacity = 30; mFusionThresOpacity = 1; mFusionColorMap = 3; mFusionWindow = 1000; @@ -305,7 +305,11 @@ bool vvSlicerManager::SetVF(std::string filename) if (mVectorReader.IsNull()) mVectorReader = vvImageReader::New(); mVectorReader->SetInputFilename(filename); - mVectorReader->Update(vvImageReader::VECTORFIELD); + + if (mType == vvImageReader::IMAGEWITHTIME) + mVectorReader->Update(vvImageReader::VECTORFIELDWITHTIME); + else + mVectorReader->Update(vvImageReader::VECTORFIELD); if (mVectorReader->GetLastError().size() != 0) { mLastError = mVectorReader->GetLastError(); return false; @@ -508,7 +512,6 @@ void vvSlicerManager::SetColorWindow(double s) } //---------------------------------------------------------------------------- - //---------------------------------------------------------------------------- void vvSlicerManager::SetColorLevel(double s) { @@ -518,6 +521,33 @@ void vvSlicerManager::SetColorLevel(double s) } //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +void vvSlicerManager::SetOverlayColorWindow(double s) +{ + for ( unsigned int i = 0; i < mSlicers.size(); i++) { + mSlicers[i]->SetOverlayColorWindow(s); + } +} +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +void vvSlicerManager::SetOverlayColorLevel(double s) +{ + for ( unsigned int i = 0; i < mSlicers.size(); i++) { + mSlicers[i]->SetOverlayColorLevel(s); + } +} +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +void vvSlicerManager::SetLinkOverlayWindowLevel(bool b) +{ + for ( unsigned int i = 0; i < mSlicers.size(); i++) { + mSlicers[i]->SetLinkOverlayWindowLevel(b); + } +} +//---------------------------------------------------------------------------- + //---------------------------------------------------------------------------- void vvSlicerManager::SetCursorAndCornerAnnotationVisibility(int s) { @@ -732,6 +762,54 @@ double vvSlicerManager::GetColorLevel() } //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +double vvSlicerManager::GetOverlayColorWindow() const +{ + if (mSlicers.size()) + return mSlicers[0]->GetOverlayColorWindow(); + return -1; +} +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +double vvSlicerManager::GetOverlayColorLevel() const +{ + if (mSlicers.size()) + return mSlicers[0]->GetOverlayColorLevel(); + return -1; +} +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +bool vvSlicerManager::GetLinkOverlayWindowLevel() const +{ + if (mSlicers.size()) + return mSlicers[0]->GetLinkOverlayWindowLevel(); + return -1; +} +//---------------------------------------------------------------------------- + +//------------------------------------------------------------------------------ +void vvSlicerManager::ResetTransformationToIdentity(const std::string actorType) +{ + if(actorType == "image") + this->GetImage()->GetTransform()->Identity(); + else if(actorType == "overlay") + this->GetSlicer(0)->GetOverlay()->GetTransform()->Identity(); + else if(actorType == "fusion") + this->GetSlicer(0)->GetFusion()->GetTransform()->Identity(); + else if(actorType == "vf") + this->GetVF()->GetTransform()->Identity(); + else + return; + + for(int i=0; i< this->GetNumberOfSlicers(); i++){ + this->GetSlicer(i)->ForceUpdateDisplayExtent(); + this->GetSlicer(i)->ResetCamera(); + this->GetSlicer(i)->Render(); + } +} +//------------------------------------------------------------------------------ //---------------------------------------------------------------------------- void vvSlicerManager::Render() @@ -925,10 +1003,11 @@ void vvSlicerManager::Picked() } //---------------------------------------------------------------------------- + //---------------------------------------------------------------------------- void vvSlicerManager::UpdateWindowLevel() { - emit WindowLevelChanged(mSlicers[0]->GetColorWindow(),mSlicers[0]->GetColorLevel(),mPreset,mColorMap); + emit WindowLevelChanged(); } //---------------------------------------------------------------------------- @@ -1032,14 +1111,34 @@ void vvSlicerManager::SetPreset(int preset) //---------------------------------------------------------------------------- -void vvSlicerManager::SetLocalColorWindowing(const int slicer) +void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlKey) { double min, max; - this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max); - this->SetColorWindow(max-min); - this->SetColorLevel(0.5*(min+max)); - this->UpdateWindowLevel(); + int t = this->mSlicers[slicer]->GetTSlice(); + if(bCtrlKey && this->mSlicers[slicer]->GetFusion()) { + this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max, this->mSlicers[slicer]->GetFusion()->GetVTKImages()[t]); + this->SetFusionWindow(max-min); + this->SetFusionLevel(0.5*(min+max)); + this->SetColorMap(mColorMap); + } + else if(bCtrlKey && this->mSlicers[slicer]->GetOverlay()) { + this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max, this->mSlicers[slicer]->GetOverlay()->GetVTKImages()[t]); + if(this->mSlicers[slicer]->GetLinkOverlayWindowLevel()){ + this->SetColorWindow(max-min); + this->SetColorLevel(0.5*(min+max)); + } else { + this->SetOverlayColorWindow(max-min); + this->SetOverlayColorLevel(0.5*(min+max)); + } + } + else { + this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max, this->mSlicers[slicer]->GetInput()); + this->SetColorWindow(max-min); + this->SetColorLevel(0.5*(min+max)); + this->SetPreset(6); + } this->Render(); + this->UpdateWindowLevel(); } //---------------------------------------------------------------------------- @@ -1076,6 +1175,13 @@ void vvSlicerManager::SetColorMap(int colormap) LUT->SetHueRange(0.4,0.80); break; case 3: + if (LUT == NULL) + LUT = vtkLookupTable::New(); + LUT->SetValueRange(0.5,1); + LUT->SetSaturationRange(1,1); + LUT->SetHueRange(0.666,0); + break; + case 4: if (LUT == NULL) LUT = vtkLookupTable::New(); LUT->SetValueRange(0,1); @@ -1092,11 +1198,11 @@ void vvSlicerManager::SetColorMap(int colormap) break; } if (LUT) { - LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4); + LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2); LUT->Build(); } vtkWindowLevelLookupTable* fusLUT = NULL; - if (mSlicers[0]->GetFusion()) { // && mFusionColorMap != 0) { + if (mSlicers[0]->GetFusion()) { // && mFusionColorMap >= 0) { fusLUT = vtkWindowLevelLookupTable::New(); double fusRange [2]; fusRange[0] = mFusionLevel - mFusionWindow/2; @@ -1119,22 +1225,25 @@ void vvSlicerManager::SetColorMap(int colormap) } else if (mFusionColorMap == 4) fusLUT->SetHueRange(0,1); - else if (mFusionColorMap == 0) + else if (mFusionColorMap <= 0) { fusLUT->SetValueRange(0,1); fusLUT->SetSaturationRange(0,0); } fusLUT->ForceBuild(); + double v[4]; - // set color table transparancy - double alpha_range_end = frange[0] + (double)mFusionThresOpacity*(frange[1] - frange[0])/100; - for (double i = frange[0]; i < alpha_range_end; i++) { - double v[4]; - vtkIdType index = fusLUT->GetIndex(i); - fusLUT->GetTableValue(index, v); + // set color table transparency + double range_end = frange[0] + (double)mFusionThresOpacity*(frange[1] - frange[0])/100; + double curr_value = frange[0]; + int nvalues = fusLUT->GetNumberOfTableValues(); + //for (double i = frange[0]; i <= alpha_range_end; i++) { + for (double i = 0; curr_value < range_end; i++) { + fusLUT->GetTableValue(i, v); v[3] = 0; - fusLUT->SetTableValue(index, v); + fusLUT->SetTableValue(i, v); + curr_value += (frange[1] - frange[0])/nvalues; } } for ( unsigned int i = 0; i < mSlicers.size(); i++) { @@ -1167,8 +1276,8 @@ void vvSlicerManager::SetColorMap(int colormap) } if (mSlicers[i]->GetFusion()) { - mSlicers[i]->GetFusionActor()->SetOpacity(double(mFusionOpacity)/100); mSlicers[i]->GetFusionMapper()->SetLookupTable(fusLUT); + mSlicers[i]->GetFusionActor()->SetOpacity(double(mFusionOpacity)/100); } } if (fusLUT)