From: tbaudier Date: Mon, 1 Feb 2016 07:38:48 +0000 (+0100) Subject: Display a line between the 2 profile points. X-Git-Tag: v1.4.0~73 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=ae5640b3937e3d0d7b54c7af1f311ebbe2dd7a9a;p=clitk.git Display a line between the 2 profile points. Debug problem of extent + Try to debug the line display with landmark --- diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 0dce60f..b1a2e11 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -3526,10 +3526,10 @@ void vvMainWindow::ShowLastImage() void vvMainWindow::UpdateRenderWindows() { for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { - mSlicerManagers[i]->GetSlicer(0)->UpdateLandmarks(); - mSlicerManagers[i]->GetSlicer(1)->UpdateLandmarks(); - mSlicerManagers[i]->GetSlicer(2)->UpdateLandmarks(); - mSlicerManagers[i]->GetSlicer(3)->UpdateLandmarks(); + for (unsigned int j = 0; j < 4; ++j) { + mSlicerManagers[i]->GetSlicer(j)->RemoveLandmarks(); + mSlicerManagers[i]->GetSlicer(j)->DisplayLandmarks(); + } } if (NOViewWidget->GetRenderWindow()) NOViewWidget->GetRenderWindow()->Render(); if (NEViewWidget->GetRenderWindow()) NEViewWidget->GetRenderWindow()->Render(); diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 4bad01b..de7055d 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -1187,17 +1187,19 @@ void vvSlicer::UpdateDisplayExtent() } else if(mVF) mVFActor->SetVisibility(false); + + + double boundsT [6]; + for(unsigned int i=0; i<6; i++) + boundsT[i] = ImageActor->GetBounds()[i]; + boundsT[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]); + boundsT[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]); + // Landmarks actor if (mLandActor) { if (mClipBox) { - double bounds [6]; - for(unsigned int i=0; i<6; i++) - bounds[i] = ImageActor->GetBounds()[i]; - bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]); - bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]); - mClipBox->SetBounds(bounds); - UpdateLandmarks(); + RemoveLandmarks(); } position[this->SliceOrientation] = offset; @@ -1222,6 +1224,12 @@ void vvSlicer::UpdateDisplayExtent() cam->SetClippingRange(range - sumSpacing, range + sumSpacing); } } + + if (mLandActor) { + if (mClipBox) { + DisplayLandmarks(); + } + } } emit UpdateDisplayExtentEnd(mSlicerNumber); } @@ -1732,8 +1740,10 @@ void vvSlicer::Render() #endif mFusionMapper->Update(); } - if (mLandMapper) - UpdateLandmarks(); + if (mLandMapper) { + RemoveLandmarks(); + DisplayLandmarks(); + } this->GetRenderWindow()->Render(); } @@ -1753,24 +1763,43 @@ void vvSlicer::UpdateCursorPosition() //---------------------------------------------------------------------------- -void vvSlicer::UpdateLandmarks() +void vvSlicer::RemoveLandmarks() { vtkPolyData *pd = static_cast(mLandClipper->GetInput()); if (pd->GetPoints()) { - //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(); + } +} +//---------------------------------------------------------------------------- + + +//---------------------------------------------------------------------------- +void vvSlicer::DisplayLandmarks() +{ + + double bounds [6]; + for(unsigned int i=0; i<6; i++) + bounds[i] = ImageActor->GetBounds()[i]; + bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]); + bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]); + mClipBox->SetBounds(bounds); + + + vtkPolyData *pd = static_cast(mLandClipper->GetInput()); + if (pd->GetPoints()) { + //mLandGlyph->SetRange(0,1); + //mLandGlyph->Modified(); + //mLandGlyph->Update(); + + mClipBox->Modified(); + mLandClipper->Update(); + mLandMapper->Update(); //Next add the captions to the displayed points for (vtkIdType id=0; idGetOutput()->GetNumberOfPoints(); id++) { double *position = mLandClipper->GetOutput()->GetPoint(id); diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index e5d7922..20111e1 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -170,7 +170,8 @@ public: void GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform); - void UpdateLandmarks(); + void RemoveLandmarks(); + void DisplayLandmarks(); void ForceUpdateDisplayExtent(); int* GetDisplayExtent(); diff --git a/vv/vvSlicerManagerCommand.cxx b/vv/vvSlicerManagerCommand.cxx index 661dd21..07164f6 100644 --- a/vv/vvSlicerManagerCommand.cxx +++ b/vv/vvSlicerManagerCommand.cxx @@ -383,7 +383,8 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, if (newLandmark) { this->SM->AddNewLandmark(xWorld,yWorld,zWorld, this->SM->GetSlicer(VisibleInWindow)->GetTSlice()); - this->SM->GetSlicer(VisibleInWindow)->UpdateLandmarks(); + this->SM->GetSlicer(VisibleInWindow)->RemoveLandmarks(); + //this->SM->GetSlicer(VisibleInWindow)->DisplayLandmarks(); this->SM->Render(); } if (event == vtkCommand::PickEvent || event == vtkCommand::StartPickEvent) { diff --git a/vv/vvToolProfile.cxx b/vv/vvToolProfile.cxx index c8540a0..f0c47d5 100644 --- a/vv/vvToolProfile.cxx +++ b/vv/vvToolProfile.cxx @@ -19,6 +19,8 @@ #include #include +#include + // vv #include "vvToolProfile.h" #include "vvProgressDialog.h" @@ -125,6 +127,8 @@ void vvToolProfile::selectPoint1() { QString position = ""; + if(mCurrentSlicerManager) { + cout << mCurrentSlicerManager->GetSelectedSlicer() << endl; if (mPoint1Selected) { ProfileWidget->hide(); vtkSmartPointer chart = vtkSmartPointer::New(); @@ -139,27 +143,23 @@ void vvToolProfile::selectPoint1() } mPoint1Selected = false; - if(mCurrentSlicerManager) { + if(mCurrentSlicerManager->GetSelectedSlicer() != -1) { double *pos; - int *index; pos = new double [4]; pos[0] = pos[1] = pos[2] = pos[3] = 0; - index = new int [mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()]; int i(0); while (iGetImage()->GetNumberOfDimensions() && i<3) { pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i]; - index[i] = (int) (pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i]; position += QString::number(pos[i],'f',1) + " "; - mPoint1[i] = index[i]; + mPoint1[i] = round((pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i]); ++i; } if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() == 4) { pos[3] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetTSlice(); - index[3] = (int)pos[3]; position += QString::number(pos[3],'f',1) + " "; - mPoint1[3] = index[3]; + mPoint1[3] = round(pos[3]); } mPoint1Selected = true; mCurrentSlicerManager->AddLandmarkProfile(pos[0], pos[1], pos[2], pos[3]); @@ -180,6 +180,7 @@ void vvToolProfile::selectPoint2() { QString position = ""; + if(mCurrentSlicerManager) { if (mPoint2Selected) { ProfileWidget->hide(); vtkSmartPointer chart = vtkSmartPointer::New(); @@ -194,27 +195,22 @@ void vvToolProfile::selectPoint2() } mPoint2Selected = false; - if(mCurrentSlicerManager) { if(mCurrentSlicerManager->GetSelectedSlicer() != -1) { double *pos; - int *index; pos = new double [4]; pos[0] = pos[1] = pos[2] = pos[3] = 0;; - index = new int [mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()]; int i(0); while (iGetImage()->GetNumberOfDimensions() &&i<3) { pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i]; - index[i] = (int) (pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i]; position += QString::number(pos[i],'f',1) + " "; - mPoint2[i] = index[i]; + mPoint2[i] = round((pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i]); ++i; } if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() == 4) { pos[3] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetTSlice(); - index[3] = (int)pos[3]; position += QString::number(pos[3],'f',1) + " "; - mPoint2[3] = index[3]; + mPoint2[3] = round(pos[3]); } mPoint2Selected = true; mCurrentSlicerManager->AddLandmarkProfile(pos[0], pos[1], pos[2], pos[3]); @@ -261,16 +257,14 @@ bool vvToolProfile::isPointsSelected() void vvToolProfile::computeProfile() { if (!mCurrentSlicerManager) close(); - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); GetArgsInfoFromGUI(); ProfileWidget->hide(); - + // Main filter mFilter->SetInputVVImage(mCurrentImage); mFilter->SetArgsInfo(mArgsInfo); mFilter->Update(); - //mImageLine = mFilter->GetOutputVVImage(); vtkSmartPointer table = vtkSmartPointer::New(); vtkSmartPointer arrX = vtkSmartPointer::New(); @@ -432,6 +426,8 @@ void vvToolProfile::GetArgsInfoFromGUI() mArgsInfo.input_arg = new char; mArgsInfo.output_arg = new char; + + } //------------------------------------------------------------------------------ @@ -565,6 +561,7 @@ void vvToolProfile::DisplayLine(int slicer) if(mCurrentSlicerManager) { if(mCurrentSlicerManager->GetSelectedSlicer() != -1) { + if (std::min(mPoint1[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()],mPoint2[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()]) <= mCurrentSlicerManager->GetSlicer(slicer)->GetSlice() && std::max(mPoint1[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()],mPoint2[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()]) >= mCurrentSlicerManager->GetSlicer(slicer)->GetSlice()) { vtkSmartPointer clippingBox = vtkSmartPointer::New(); double extent[6]; for (int j=0; j<6; ++j) { @@ -594,6 +591,7 @@ void vvToolProfile::DisplayLine(int slicer) mLineActors[slicer]->GetProperty()->SetOpacity(0.995); mCurrentSlicerManager->GetSlicer(slicer)->GetRenderer()->AddActor(mLineActors[slicer]); + } } } }