X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvSlicer.cxx;h=1e1245f425b787523aeb69d7e9cf87c7086c851d;hb=fbd1f3ace65ab9540cb4e0b2d4af83b60232479e;hp=17aa41b81a9619b928a3268fea886d6d4c858fad;hpb=ce1141cd3b333bd25fd79abe933208d322b5a9e3;p=clitk.git diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 17aa41b..1e1245f 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -21,7 +21,6 @@ #include "vvSlicerManagerCommand.h" #include "vvGlyphSource.h" #include "vvGlyph2D.h" -#include "vvImageMapToWLColors.h" #include #include @@ -41,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -90,10 +90,10 @@ vvSlicer::vvSlicer() mCurrent[1] = -VTK_DOUBLE_MAX; mCurrent[2] = -VTK_DOUBLE_MAX; - mCursor[0] = -VTK_DOUBLE_MAX; - mCursor[1] = -VTK_DOUBLE_MAX; - mCursor[2] = -VTK_DOUBLE_MAX; - mCursor[3] = -VTK_DOUBLE_MAX; + mCursor[0] = 0;//-VTK_DOUBLE_MAX; + mCursor[1] = 0;//-VTK_DOUBLE_MAX; + mCursor[2] = 0;//-VTK_DOUBLE_MAX; + mCursor[3] = 0;//-VTK_DOUBLE_MAX; mSubSampling = 5; mScale = 1; @@ -137,9 +137,6 @@ vvSlicer::vvSlicer() this->GetRenderer()->AddActor(legend); showFusionLegend = false; - this->WindowLevel->Delete(); - this->WindowLevel = vvImageMapToWLColors::New(); - this->InstallPipeline(); mLinkOverlayWindowLevel = true; @@ -580,36 +577,40 @@ void vvSlicer::SetLandmarks(vvLandmarks* landmarks) if (!mCross) mCross = vtkSmartPointer::New(); + if (!mClipBox) + mClipBox = vtkSmartPointer::New(); + if (!mLandClipper) + mLandClipper = vtkSmartPointer::New(); + if (!mLandGlyph) + mLandGlyph = vtkSmartPointer::New(); + if (!mLandMapper) + mLandMapper = vtkSmartPointer::New(); + if (!mLandActor) + mLandActor = vtkSmartPointer::New(); + mCross->SetFocalPoint(0.0,0.0,0.0); mCross->SetModelBounds(-10,10,-10,10,-10,10); mCross->AllOff(); mCross->AxesOn(); - if (!mLandGlyph) - mLandGlyph = vtkSmartPointer::New(); + mLandClipper->SetClipFunction(mClipBox); + mLandClipper->InsideOutOn(); + mLandClipper->SetInput(mLandmarks->GetOutput()); + mLandGlyph->SetSource(mCross->GetOutput()); - mLandGlyph->SetInput(landmarks->GetOutput()); + mLandGlyph->SetInput(mLandClipper->GetOutput()); //mLandGlyph->SetIndexModeToScalar(); - mLandGlyph->SetRange(0,1); - mLandGlyph->ScalingOff(); + //mLandGlyph->SetRange(0,1); + //mLandGlyph->ScalingOff(); - mLandGlyph->SetColorModeToColorByScalar(); - - if (!mClipBox) - mClipBox = vtkSmartPointer::New(); - if (!mLandClipper) - mLandClipper = vtkSmartPointer::New(); - mLandClipper->InsideOutOn(); - mLandClipper->SetInput(mLandGlyph->GetOutput()); - mLandClipper->SetClipFunction(mClipBox); + //mLandGlyph->SetColorModeToColorByScalar(); + + mLandGlyph->SetScaleModeToDataScalingOff(); + mLandGlyph->SetIndexModeToOff(); - if (!mLandMapper) - mLandMapper = vtkSmartPointer::New(); - mLandMapper->SetInputConnection(mLandClipper->GetOutputPort()); + mLandMapper->SetInputConnection(mLandGlyph->GetOutputPort()); //mLandMapper->ScalarVisibilityOff(); - if (!mLandActor) - mLandActor = vtkSmartPointer::New(); mLandActor->SetMapper(mLandMapper); mLandActor->GetProperty()->SetColor(255,10,212); mLandActor->SetPickable(0); @@ -813,15 +814,22 @@ void vvSlicer::SetSliceOrientation(int orientation) AdjustResliceToSliceOrientation(mOverlayReslice); // Update the viewer - int *range = this->GetSliceRange(); - if (range) - this->Slice = static_cast((range[0] + range[1]) * 0.5); - + // Go to current cursor position // double* cursorPos = GetCursorPosition(); // DDV(cursorPos, 3); // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]); + if (this->Renderer && this->GetInput()) { + double s = mCursor[orientation]; + double sCursor = (s - this->GetInput()->GetOrigin()[orientation])/this->GetInput()->GetSpacing()[orientation]; + this->Slice = static_cast(sCursor); + } + +// int *range = this->GetSliceRange(); +// if (range) +// this->Slice = static_cast((range[0] + range[1]) * 0.5); + this->UpdateOrientation(); this->UpdateDisplayExtent(); @@ -901,15 +909,15 @@ void vvSlicer::UpdateDisplayExtent() return; } input->UpdateInformation(); + this->SetSlice( this->GetSlice() ); //SR: make sure the update let the slice in extents // Local copy of extent int w_ext[6]; int* ext = GetExtent(); copyExtent(ext, w_ext); // Set slice value - int s = this->Slice > ext[this->SliceOrientation*2+1] ? ext[this->SliceOrientation*2 + 1] : this->Slice; - w_ext[ this->SliceOrientation*2 ] = s; - w_ext[ this->SliceOrientation*2+1 ] = s; + w_ext[ this->SliceOrientation*2 ] = this->Slice; + w_ext[ this->SliceOrientation*2+1 ] = this->Slice; // Image actor this->ImageActor->SetDisplayExtent(w_ext); @@ -1441,13 +1449,38 @@ void vvSlicer::UpdateLandmarks() { vtkPolyData *pd = static_cast(mLandClipper->GetInput()); if (pd->GetPoints()) { - mLandGlyph->SetRange(0,1); - mLandGlyph->Modified(); - mLandGlyph->Update(); + //mLandGlyph->SetRange(0,1); + //mLandGlyph->Modified(); + //mLandGlyph->Update(); mClipBox->Modified(); mLandClipper->Update(); mLandMapper->Update(); + //Let's add the captions + //First remove all captions: + for(unsigned int i=0;iRenderer->RemoveActor2D(mLandLabelActors[i]); + //allActors2D->Remove (mLandLabelActors[i]); + } + mLandLabelActors.clear(); + //Next add the captions to the displayed points + for (vtkIdType id=0; idGetOutput()->GetNumberOfPoints(); id++) { + double *position = mLandClipper->GetOutput()->GetPoint(id); + vtkStdString label = static_cast(mLandClipper->GetOutput()->GetPointData()->GetAbstractArray("labels"))->GetValue(id); + vtkSmartPointer label_actor = vtkSmartPointer::New(); + label_actor->SetCaption(label); + label_actor->SetAttachmentPoint(position); + label_actor->GetCaptionTextProperty()->SetColor(1,0,0); + label_actor->GetCaptionTextProperty()->SetOrientation(33.333333); + label_actor->GetCaptionTextProperty()->SetFontFamilyToTimes(); + label_actor->GetCaptionTextProperty()->SetBold(0); + label_actor->GetCaptionTextProperty()->SetFontSize(6); + label_actor->BorderOff(); + label_actor->LeaderOff(); + label_actor->ThreeDimensionalLeaderOff(); + mLandLabelActors.push_back(label_actor); + this->Renderer->AddActor2D(mLandLabelActors[id]); + } } }