From: tbaudier Date: Wed, 11 Jan 2017 08:27:32 +0000 (+0100) Subject: Debug camera position with large image X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f646e78d42d15488dd11a7e36745fc6e806e5094;p=clitk.git Debug camera position with large image Still bug with registration/translation --- diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index d3e056a..561e6b5 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -998,7 +998,7 @@ void vvSlicer::SetSliceOrientation(int orientation) if (this->Renderer && this->GetInput()) { double scale = this->Renderer->GetActiveCamera()->GetParallelScale(); - this->Renderer->ResetCamera(); + ResetCamera(); this->Renderer->GetActiveCamera()->SetParallelScale(scale); } @@ -1226,80 +1226,15 @@ void vvSlicer::UpdateDisplayExtent() mLandActor->SetPosition(position); } - //std::cout << "1 " << this->Renderer->GetActiveCamera()->GetPosition()[0] << std::endl; // Figure out the correct clipping range if (this->Renderer) { if (this->InteractorStyle && this->InteractorStyle->GetAutoAdjustCameraClippingRange()) { - double scaleCamera = this->Renderer->GetActiveCamera()->GetParallelScale(); - double positionCamera[3], focalCamera[3]; - this->Renderer->GetActiveCamera()->GetPosition(positionCamera); - this->Renderer->GetActiveCamera()->GetFocalPoint(focalCamera); + double positionCamera[3]; + this->Renderer->GetActiveCamera()->GetPosition(positionCamera); this->Renderer->ResetCameraClippingRange(); - //this->Renderer->ResetCamera(); - this->Renderer->GetActiveCamera()->SetParallelScale(scaleCamera); - - - - - //////////////////////////////// - -double center[3]; -double distance; -double vn[3], *vup; -double bounds[6]; -this->ImageActor->GetBounds(bounds); -this->Renderer->GetActiveCamera()->GetViewPlaneNormal(vn); -// Reset the perspective zoom factors, otherwise subsequent zooms will cause -// the view angle to become very small and cause bad depth sorting. -center[0] = (bounds[0] + bounds[1])/2.0; -center[1] = (bounds[2] + bounds[3])/2.0; -center[2] = (bounds[4] + bounds[5])/2.0; -double w1 = bounds[1] - bounds[0]; -double w2 = bounds[3] - bounds[2]; -double w3 = bounds[5] - bounds[4]; -w1 *= w1; -w2 *= w2; -w3 *= w3; -double radius = w1 + w2 + w3; -// If we have just a single point, pick a radius of 1.0 -radius = (radius==0)?(1.0):(radius); -// compute the radius of the enclosing sphere -radius = sqrt(radius)*0.5; -double angle=vtkMath::RadiansFromDegrees(this->Renderer->GetActiveCamera()->GetViewAngle()); -this->Renderer->ComputeAspect(); -double aspect[2]; -this->Renderer->GetAspect(aspect); -if(aspect[0]>=1.0) // horizontal window, deal with vertical angle|scale -{ -if(this->Renderer->GetActiveCamera()->GetUseHorizontalViewAngle()) -{ -angle=2.0*atan(tan(angle*0.5)/aspect[0]); -} -} -else // vertical window, deal with horizontal angle|scale -{ -if(!this->Renderer->GetActiveCamera()->GetUseHorizontalViewAngle()) -{ -angle=2.0*atan(tan(angle*0.5)*aspect[0]); -} -} -distance =radius/sin(angle*0.5); -//std::cout << "exp " << center[this->SliceOrientation] << " " << distance << " " << vn[this->SliceOrientation] << std::endl; -positionCamera[this->SliceOrientation] = center[this->SliceOrientation]+distance*vn[this->SliceOrientation]; -focalCamera[this->SliceOrientation] = center[this->SliceOrientation]; - - - - - - ////////////////////////////// - - //if (this->SliceOrientation ==2) - // std::cout << positionCamera[0] << " " << positionCamera[1] << " " << positionCamera[2] << std::endl; - this->Renderer->GetActiveCamera()->SetFocalPoint(focalCamera); - this->Renderer->GetActiveCamera()->SetPosition(positionCamera); - + positionCamera[this->SliceOrientation] = mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[this->SliceOrientation]-1; + this->Renderer->GetActiveCamera()->SetPosition(positionCamera); } else { vtkCamera *cam = this->Renderer->GetActiveCamera(); if (cam) { @@ -1307,20 +1242,12 @@ focalCamera[this->SliceOrientation] = center[this->SliceOrientation]; this->ImageActor->GetBounds(bounds); double spos = (double)bounds[this->SliceOrientation * 2]; double cpos = (double)cam->GetPosition()[this->SliceOrientation]; - if (cpos >= spos) { - double positionCamera[3]; - cam->GetPosition(positionCamera); - positionCamera[this->SliceOrientation] = spos - 1; - cam->SetPosition(positionCamera); - } double range = fabs(spos - cpos); double *spacing = input->GetSpacing(); double sumSpacing = spacing[0] + spacing[1] + spacing[2]; cam->SetClippingRange(range - sumSpacing, range + sumSpacing); } } - //this->Renderer->GetActiveCamera()->Print(std::cout); - //std::cout << "2 " << this->Renderer->GetActiveCamera()->GetPosition()[0] << std::endl; if (mLandActor) { if (mClipBox) { @@ -1469,7 +1396,6 @@ void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw) this->GetRenderer()->AddActor(pdmA); this->GetRenderer()->AddActor(ca); - this->GetRenderer()->ResetCamera(); //this is just a mapping between the labeling of the orientations presented to the user and //the one used by vtk diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index cb95d35..fc6c6f2 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -939,15 +939,6 @@ void vvSlicerManager::ResetTransformationToIdentity(const std::string actorType) } //------------------------------------------------------------------------------ -//---------------------------------------------------------------------------- -void vvSlicerManager::ForceUpdateDisplayExtent() -{ - for ( unsigned int i = 0; i < mSlicers.size(); i++) { - mSlicers[i]->ForceUpdateDisplayExtent(); - } -} -//---------------------------------------------------------------------------- - //---------------------------------------------------------------------------- void vvSlicerManager::Render() { diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index 84bd136..e80ef48 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -236,7 +236,6 @@ class vvSlicerManager : public QObject { void UpdateLinked(int slicer); void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false); void ResetTransformationToIdentity(const std::string actorType); - void ForceUpdateDisplayExtent(); void Render(); void AddLink(std::string newId) { diff --git a/vv/vvSlicerManagerCommand.cxx b/vv/vvSlicerManagerCommand.cxx index 4d2e921..c645a27 100644 --- a/vv/vvSlicerManagerCommand.cxx +++ b/vv/vvSlicerManagerCommand.cxx @@ -278,7 +278,6 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, // Mouse release HERE if (event == vtkCommand::EndPickEvent) { - std::cout << "coucou End" << std::endl; // DD(VisibleInWindow); if (VisibleInWindow > -1) this->SM->LeftButtonReleaseEvent(VisibleInWindow); @@ -392,12 +391,9 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, this->SM->Render(); } if (event == vtkCommand::PickEvent || event == vtkCommand::StartPickEvent) { - std::cout << "coucou Start" << std::endl; this->SM->Picked(); this->SM->UpdateViews(1,VisibleInWindow); this->SM->UpdateLinked(VisibleInWindow); - this->SM->ForceUpdateDisplayExtent(); - this->SM->Render(); this->SM->UpdateInfoOnCursorPosition(VisibleInWindow); } else { this->SM->GetSlicer(VisibleInWindow)->Render();