X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvSlicer.cxx;h=1de1738c030f39925a49c96fe740945d07bea407;hb=26c6b8e9d0333a9e0be98c3fb9d57f133477d97d;hp=ec225e2066be3558524d2ffc6c421b29e55c7dd5;hpb=f6bfd7ec2781c83bd818e93d3628a36d67bf5a63;p=clitk.git diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index ec225e2..1de1738 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,7 @@ #include #include #include +#include vtkCxxRevisionMacro(vvSlicer, "DummyRevision"); vtkStandardNewMacro(vvSlicer); @@ -87,6 +89,7 @@ vvSlicer::vvSlicer() mSubSampling = 5; mScale = 1; mVFLog = 0; + mVFWidth = 1; std::string text = "F1 = sagital; F2 = coronal; F3 = axial\n"; text += "F5 = horizontal flip; F6 = vertical flip\n\n"; @@ -140,6 +143,7 @@ vvSlicer::vvSlicer() this->WindowLevel->Delete(); this->WindowLevel = vvImageMapToWLColors::New(); this->InstallPipeline(); + } //------------------------------------------------------------------------------ @@ -152,7 +156,7 @@ vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper() { //------------------------------------------------------------------------------ -vtkImageActor* vvSlicer::GetOverlayActor() { +vvBlendImageActor* vvSlicer::GetOverlayActor() { return mOverlayActor.GetPointer(); } //------------------------------------------------------------------------------ @@ -279,6 +283,26 @@ void vvSlicer::SetImage(vvImage::Pointer image) { mImage = image; this->Superclass::SetInput(image->GetVTKImages()[0]); + + // Prevent crash when reload -> change slice if outside extent + int extent[6]; + this->GetInput()->GetWholeExtent(extent); + if (SliceOrientation == 0) { + if (Slice >= extent[1]) { + Slice = (extent[1]-extent[0])/2.0; + } + } + if (SliceOrientation == 1) { + if (Slice >= extent[3]) { + Slice = (extent[3]-extent[2])/2.0; + } + } + if (SliceOrientation == 2) { + if (Slice >= extent[5]) { + Slice = (extent[5]-extent[4])/2.0; + } + } + this->UpdateDisplayExtent(); mCurrentTSlice = 0; ca->SetText(0,mFileName.c_str()); @@ -300,7 +324,7 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay) if (!mOverlayActor) { - mOverlayActor = vtkImageActor::New(); + mOverlayActor = vvBlendImageActor::New(); mOverlayActor->SetInput(mOverlayMapper->GetOutput()); mOverlayActor->SetPickable(0); mOverlayActor->SetVisibility(false); @@ -421,6 +445,7 @@ void vvSlicer::SetVF(vvImage::Pointer vf) mVFActor = vtkActor::New(); mVFActor->SetMapper(mVFMapper); mVFActor->SetPickable(0); + mVFActor->GetProperty()->SetLineWidth(mVFWidth); this->UpdateDisplayExtent(); this->GetRenderer()->AddActor(mVFActor); @@ -543,6 +568,17 @@ void vvSlicer::SetVFScale(int scale) } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvSlicer::SetVFWidth(int width) +{ + mVFWidth = width; + if (mVFActor) + mVFActor->GetProperty()->SetLineWidth(mVFWidth); + UpdateDisplayExtent(); + Render(); +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvSlicer::SetVFLog(int log) @@ -1220,8 +1256,8 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max) //---------------------------------------------------------------------------- void vvSlicer::Render() { - // DD("Render"); - //DD(SliceOrientation); + // DD("vvSlicer::Render"); + // DD(SliceOrientation); if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay && !this->mFusion) { legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable()); @@ -1286,10 +1322,9 @@ void vvSlicer::Render() pixel2 << (int)Y; pixel3 << (int)Z; temps << mCurrentTSlice; - double value = this->GetInput()->GetScalarComponentAsDouble( - (int)X, - (int)Y, - (int)Z,0); + double value = this->GetInput()->GetScalarComponentAsDouble(lrint(X), + lrint(Y), + lrint(Z),0); std::stringstream val; val << value; @@ -1374,7 +1409,11 @@ void vvSlicer::SetSlice(int slice) SetContourSlice(); this->Modified(); this->UpdateDisplayExtent(); - this->Render(); + + // DD("SetSlice de slicer = Render"); + + // Seems to work without this line + // this->Render(); } //---------------------------------------------------------------------------- @@ -1415,3 +1454,8 @@ void vvSlicer::PrintSelf(ostream& os, vtkIndent indent) //---------------------------------------------------------------------------- + + + + +