]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of /home/dsarrut/clitk3.server
authorRomulo Pinho <pinho@lyon.fnclcc.fr>
Mon, 6 Jun 2011 12:40:03 +0000 (14:40 +0200)
committerRomulo Pinho <pinho@lyon.fnclcc.fr>
Mon, 6 Jun 2011 12:40:03 +0000 (14:40 +0200)
1  2 
vv/vvMainWindow.cxx
vv/vvSlicer.cxx
vv/vvSlicerManager.cxx

diff --combined vv/vvMainWindow.cxx
index 7f23d51afb3d1f208196921e8119988ff7d2ab00,a15a11440143ddb4b71c99918d12d762c7fea5e4..c60c04da4771dd2c4ec64c753449161ae410189c
@@@ -290,8 -290,8 +290,8 @@@ vvMainWindow::vvMainWindow():vvMainWind
    connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString)));
    connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int,int,double,double,double)),this,SLOT(SetVFProperty(int,int,int,int,double,double,double)));
    connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int)),this,SLOT(SetOverlayProperty(int)));
 -  connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,double,double)),
 -          this,SLOT(SetFusionProperty(int,int,double,double)));
 +  connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,int,double,double)),
 +          this,SLOT(SetFusionProperty(int,int,int,double,double)));
    connect(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows()));
  
    playMode = 0;//pause
@@@ -1168,13 -1168,12 +1168,13 @@@ void vvMainWindow::ImageInfoChanged(
      if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
        overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
        overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(),
 +                                      mSlicerManagers[index]->GetFusionThresholdOpacity(),
                                        mSlicerManagers[index]->GetFusionColorMap(),
                                        mSlicerManagers[index]->GetFusionWindow(),
                                        mSlicerManagers[index]->GetFusionLevel());
      } else {
        overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
 -      overlayPanel->getFusionProperty(-1, -1,-1,-1);
 +      overlayPanel->getFusionProperty(-1, -1, -1, -1, -1);
      }
    }
  }
@@@ -1383,7 -1382,7 +1383,7 @@@ void vvMainWindow::DisplayChanged(QTree
        mSlicerManagers[slicerManagerIndex]->UpdateInfoOnCursorPosition(column-1);
        DisplaySliders(slicerManagerIndex, column-1);
        if(clickedParentItem == clickedItem) {
-         // Toggle or force visibility if it was not on this branch so far
+         // Toggle
          vis = !draw || !vis;
        }
        clickedSlicer->SetActorVisibility("image", 0, vis);
@@@ -2141,12 -2140,11 +2141,12 @@@ void vvMainWindow::SetOverlayProperty(i
  //------------------------------------------------------------------------------
  
  //------------------------------------------------------------------------------
 -void vvMainWindow::SetFusionProperty(int opacity, int colormap,double window, double level)
 +void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap,double window, double level)
  {
    int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
    if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
      mSlicerManagers[index]->SetFusionOpacity(opacity);
 +    mSlicerManagers[index]->SetFusionThresholdOpacity(thresOpacity);
      mSlicerManagers[index]->SetFusionColorMap(colormap);
      mSlicerManagers[index]->SetFusionWindow(window);
      mSlicerManagers[index]->SetFusionLevel(level);
diff --combined vv/vvSlicer.cxx
index af3f0e6d864f06ca90203c4b4419599f131dfa5a,74f2fc570fa9e160d84b68b0d9171d061fce1ae5..43583571456b3d12d6253bc27e7fb17449eb893a
@@@ -172,7 -172,7 +172,7 @@@ vvBlendImageActor* vvSlicer::GetOverlay
  
  
  //------------------------------------------------------------------------------
 -vtkImageMapToWindowLevelColors* vvSlicer::GetFusionMapper()
 +vtkImageMapToColors* vvSlicer::GetFusionMapper()
  {
    return mFusionMapper.GetPointer();
  }
@@@ -408,14 -408,7 +408,14 @@@ void vvSlicer::SetFusion(vvImage::Point
      mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
  
      if (!mFusionMapper)
 -      mFusionMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
 +      mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
 +    
 +    vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
 +    lut->SetRange(0, 1);
 +    lut->SetValueRange(0, 1);
 +    lut->SetSaturationRange(0, 0);
 +    lut->Build();
 +    mFusionMapper->SetLookupTable(lut);
      mFusionMapper->SetInput(mFusionReslice->GetOutput());
  
      if (!mFusionActor) {
@@@ -1243,7 -1236,9 +1243,9 @@@ void vvSlicer::Render(
        int ix, iy, iz;
        double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz);
  
-       worldPos << "data value : " << value << std::endl;
+       if(ImageActor->GetVisibility())
+         worldPos << "data value : " << value << std::endl;
        worldPos << "mm : " << lrint(mCurrent[0]) << ' '
                            << lrint(mCurrent[1]) << ' '
                            << lrint(mCurrent[2]) << ' '
  //----------------------------------------------------------------------------
  void vvSlicer::UpdateCursorPosition()
  {
-   if (this->GetImageActor()->GetVisibility()) {
-     pdmA->SetVisibility(true);
-     mCursor[0] = mCurrent[0];
-     mCursor[1] = mCurrent[1];
-     mCursor[2] = mCurrent[2];
-     mCursor[3] = mCurrentTSlice;
-   }
+   pdmA->SetVisibility(true);
+   mCursor[0] = mCurrent[0];
+   mCursor[1] = mCurrent[1];
+   mCursor[2] = mCurrent[2];
+   mCursor[3] = mCurrentTSlice;
  }
  //----------------------------------------------------------------------------
  
diff --combined vv/vvSlicerManager.cxx
index 08d8f5ac329af1d10a29645ab93c4e779fc411b3,fbbc7946febc1a75bbbe2905f8e20f14d2f636a0..871c818a64acf3083e4706a5519ce56ae5d6eb33
@@@ -58,7 -58,6 +58,7 @@@ vvSlicerManager::vvSlicerManager(int nu
    mOverlayColor = 130;
  
    mFusionOpacity = 70;
 +  mFusionThresOpacity = 1;
    mFusionColorMap = 3;
    mFusionWindow = 1000;
    mFusionLevel = 1000;
@@@ -293,7 -292,6 +293,7 @@@ bool vvSlicerManager::SetFusion(std::st
    double *fusRange = mFusionReader->GetOutput()->GetVTKImages()[0]->GetScalarRange();
    mFusionLevel = (fusRange[0]+fusRange[1])/2;
    mFusionWindow = fusRange[1]-fusRange[0];
 +
    return true;
  }
  //----------------------------------------------------------------------------
@@@ -433,7 -431,6 +433,6 @@@ void vvSlicerManager::SetTSlice(int sli
    for ( unsigned int i = 0; i < mSlicers.size(); i++) {
      if (slice != mSlicers[i]->GetTSlice()) {
        mSlicers[i]->SetTSlice(slice);
-       if (mSlicers[i]->GetImageActor()->GetVisibility())
          UpdateTSlice(i);
      }
    }
@@@ -495,8 -492,7 +494,7 @@@ void vvSlicerManager::SetTSliceInSlicer
    if (mSlicers[slicer]->GetTSlice() == tslice) return;
  
    mSlicers[slicer]->SetTSlice(tslice);
-   if (mSlicers[slicer]->GetImageActor()->GetVisibility())
-     UpdateTSlice(slicer);
+   UpdateTSlice(slicer);
  }
  //----------------------------------------------------------------------------
  
@@@ -576,7 -572,8 +574,8 @@@ void vvSlicerManager::UpdateViews(int c
      mSlicers[slicer]->Render();
  
      for ( unsigned int i = 0; i < mSlicers.size(); i++) {
-       if (i != (unsigned int)slicer && mSlicers[i]->GetImageActor()->GetVisibility()
+       if (i != (unsigned int)slicer
+           && mSlicers[i]->GetRenderer()->GetDraw()
            && mSlicers[i]->GetRenderWindow()->GetSize()[0] > 2
            && mSlicers[i]->GetRenderWindow()->GetSize()[1] > 2) {
          mSlicers[i]->SetCurrentPosition(mSlicers[slicer]->GetCurrentPosition()[0],
@@@ -865,7 -862,7 +864,7 @@@ void vvSlicerManager::UpdateInfoOnCurso
        Z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]) {
      value = this->GetScalarComponentAsDouble(mSlicers[slicer]->GetInput(), X, Y, Z);
  
-     if (mSlicers[slicer]->GetVFActor() && mSlicers[slicer]->GetVFActor()->GetVisibility()) {
+     if (mSlicers[slicer]->GetVFActor() ) {
        displayVec = 1;
        unsigned int currentTime = mSlicers[slicer]->GetTSlice();
        vtkImageData *vf = NULL;
          valueVec = sqrt(xVec*xVec + yVec*yVec + zVec*zVec);
        }
      }
-     if (mSlicers[slicer]->GetOverlayActor() && mSlicers[slicer]->GetOverlayActor()->GetVisibility()) {
+     if (mSlicers[slicer]->GetOverlayActor() ) {
        displayOver = 1;
        vtkImageData *overlay = dynamic_cast<vtkImageData*>(mSlicers[slicer]->GetOverlayMapper()->GetInput());
        double Xover = (x - overlay->GetOrigin()[0]) / overlay->GetSpacing()[0];
        double Zover = (z - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2];
        valueOver = this->GetScalarComponentAsDouble(overlay, Xover, Yover, Zover);
      }
-     if (mSlicers[slicer]->GetFusionActor() && mSlicers[slicer]->GetFusionActor()->GetVisibility()) {
+     if (mSlicers[slicer]->GetFusionActor() ) {
        displayFus = 1;
        vtkImageData *fusion = dynamic_cast<vtkImageData*>(mSlicers[slicer]->GetFusionMapper()->GetInput());
        double Xover = (x - fusion->GetOrigin()[0]) / fusion->GetSpacing()[0];
      emit UpdateVector(displayVec,xVec, yVec, zVec, valueVec);
      emit UpdateOverlay(displayOver,valueOver,value);
      emit UpdateFusion(displayFus,valueFus);
-     for (unsigned int i = 0; i < mSlicers.size(); i++) {
-       if (mSlicers[i]->GetImageActor()->GetVisibility() == 1)
-         emit UpdateWindows(i,mSlicers[i]->GetSliceOrientation(),mSlicers[i]->GetSlice());
-       else
-         emit UpdateWindows(i,-1,-1);
-     }
    }
  }
  //----------------------------------------------------------------------------
@@@ -1102,50 -1093,26 +1095,50 @@@ void vvSlicerManager::SetColorMap(int c
      LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4);
      LUT->Build();
    }
 -  vtkLookupTable* fusLUT = NULL;
 -  if (mSlicers[0]->GetFusion()) {
 -    fusLUT = vtkLookupTable::New();
 +  vtkWindowLevelLookupTable* fusLUT = NULL;
 +  if (mSlicers[0]->GetFusion()) { // && mFusionColorMap != 0) {
 +    fusLUT = vtkWindowLevelLookupTable::New();
      double fusRange [2];
      fusRange[0] = mFusionLevel - mFusionWindow/2;
      fusRange[1] = mFusionLevel + mFusionWindow/2;
 -    fusLUT->SetTableRange(fusRange[0],fusRange[1]);
 +    double* frange = mFusionReader->GetOutput()->GetVTKImages()[0]->GetScalarRange();
 +    fusLUT->SetTableRange(frange);
      fusLUT->SetValueRange(1,1);
      fusLUT->SetSaturationRange(1,1);
 +    fusLUT->SetAlphaRange(1, 1);
 +    fusLUT->SetWindow(mFusionWindow);
 +    fusLUT->SetLevel(mFusionLevel);
      if (mFusionColorMap == 1)
        fusLUT->SetHueRange(0,0.18);
      else if (mFusionColorMap == 2)
        fusLUT->SetHueRange(0.4,0.80);
      else if (mFusionColorMap == 3)
 +    {
 +      fusLUT->SetHueRange(0.666, 0);
 +      fusLUT->SetValueRange(0.5, 1);
 +    }
 +    else if (mFusionColorMap == 4)
        fusLUT->SetHueRange(0,1);
 -    fusLUT->Build();
 -    if (mFusionColorMap == 0)
 -      fusLUT = NULL;
 +    else if (mFusionColorMap == 0)
 +    {
 +      fusLUT->SetValueRange(0,1);
 +      fusLUT->SetSaturationRange(0,0);
 +    }
 +    
 +    fusLUT->ForceBuild();
 +    
 +    // 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);
 +      v[3] = 0;
 +      fusLUT->SetTableValue(index, v);
 +    }
    }
    for ( unsigned int i = 0; i < mSlicers.size(); i++) {
 +    
      if (mSlicers[i]->GetOverlay()) {
        vtkLookupTable* supLUT = vtkLookupTable::New();
        supLUT->SetTableRange(range[0],range[1]);
      } else {
        mSlicers[i]->GetWindowLevel()->SetLookupTable(LUT);
      }
 +    
      if (mSlicers[i]->GetFusion()) {
        mSlicers[i]->GetFusionActor()->SetOpacity(double(mFusionOpacity)/100);
        mSlicers[i]->GetFusionMapper()->SetLookupTable(fusLUT);
 -      mSlicers[i]->GetFusionMapper()->SetWindow(mFusionWindow);
 -      mSlicers[i]->GetFusionMapper()->SetLevel(mFusionLevel);
      }
    }
    if (fusLUT)