1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
21 #include "vvSlicerManagerCommand.h"
22 #include "vvGlyphSource.h"
23 #include "vvGlyph2D.h"
24 #include "vvImageMapToWLColors.h"
26 #include <vtkTextProperty.h>
27 #include <vtkTextActor.h>
28 #include <vtkTextSource.h>
29 #include <vtkActor2D.h>
30 #include <vtkCursor2D.h>
31 #include <vtkPolyDataMapper2D.h>
32 #include <vtkProperty2D.h>
33 #include <vtkCornerAnnotation.h>
34 #include <vtkImageMapToWindowLevelColors.h>
35 #include <vtkImageData.h>
36 #include <vtkImageActor.h>
37 #include <vtkToolkits.h>
38 #include <vtkObjectFactory.h>
39 #include <vtkPointData.h>
40 #include <vtkDataArray.h>
41 #include <vtkFloatArray.h>
42 #include <vtkClipPolyData.h>
43 #include <vtkGlyph3D.h>
45 #include <vtkCursor3D.h>
46 #include <vtkProperty.h>
48 #include <vtkLightCollection.h>
49 #include <vtkScalarBarActor.h>
50 #include <vtkLookupTable.h>
52 #include <vtkRenderer.h>
53 #include <vtkRendererCollection.h>
54 #include <vtkRenderWindow.h>
55 #include <vtkRenderWindowInteractor.h>
56 #include <vtkCamera.h>
57 #include <vtkCallbackCommand.h>
58 #include <vtkCommand.h>
59 #include <vtkPolyDataMapper.h>
62 #include <vtkExtractVOI.h>
63 #include <vtkSphereSource.h>
64 #include <vtkCutter.h>
65 #include <vtkAssignAttribute.h>
66 #include <vtkImageAccumulate.h>
67 #include <vtkImageReslice.h>
69 vtkCxxRevisionMacro(vvSlicer, "DummyRevision");
70 vtkStandardNewMacro(vvSlicer);
72 //------------------------------------------------------------------------------
77 mUseReducedExtent = false;
79 mCurrent[0] = -VTK_DOUBLE_MAX;
80 mCurrent[1] = -VTK_DOUBLE_MAX;
81 mCurrent[2] = -VTK_DOUBLE_MAX;
83 mCursor[0] = -VTK_DOUBLE_MAX;
84 mCursor[1] = -VTK_DOUBLE_MAX;
85 mCursor[2] = -VTK_DOUBLE_MAX;
86 mCursor[3] = -VTK_DOUBLE_MAX;
92 std::string text = "F1 = sagital; F2 = coronal; F3 = axial\n";
93 text += "F5 = horizontal flip; F6 = vertical flip\n\n";
94 text += "0,1,2,3,4,5 : preset windowing\n";
95 text += "6,7,8,9 : preset colormap\n";
96 text += "z : local windowing\n";
97 text += "r : reset view\n";
98 text += "l : reload image\n";
99 text += "f : fly to mouse position\n";
100 text += "g : go to cross hair position\n\n";
101 text += "Up,down : change slice\n";
102 text += "Left,right : change tenporal slice\n\n";
103 text += "Scrollbar (or w/x) : zoom in/out\n";
104 text += "left button : synchronize all views\n";
105 text += "middle button : grab image\n";
106 text += "right button : change windowing\n";
108 crossCursor = vtkCursor2D::New();
109 crossCursor->AllOff();
110 crossCursor->AxesOn();
111 crossCursor->SetTranslationMode(1);
112 crossCursor->SetRadius(2);
114 pdm = vtkPolyDataMapper2D::New();
115 pdm->SetInput(crossCursor->GetOutput());
117 pdmA = vtkActor2D::New();
118 pdmA->SetMapper(pdm);
119 pdmA->GetProperty()->SetColor(255,10,212);
120 pdmA->SetVisibility(0);
121 pdmA->SetPickable(0);
123 ca = vtkCornerAnnotation::New();
124 ca->GetTextProperty()->SetColor(255,10,212);
125 ca->SetVisibility(1);
133 legend = vtkSmartPointer<vtkScalarBarActor>::New();
134 //legend->SetTitle("test!");
135 legend->SetPosition(0.82,0.18);
136 legend->SetWidth(0.1);
137 legend->SetVisibility(0);
138 legend->SetLabelFormat("%.1f");
139 this->GetRenderer()->AddActor(legend);
141 this->WindowLevel->Delete();
142 this->WindowLevel = vvImageMapToWLColors::New();
143 this->InstallPipeline();
146 //------------------------------------------------------------------------------
149 //------------------------------------------------------------------------------
150 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper() {
151 return mOverlayMapper.GetPointer();
153 //------------------------------------------------------------------------------
156 //------------------------------------------------------------------------------
157 vtkImageActor* vvSlicer::GetOverlayActor() {
158 return mOverlayActor.GetPointer();
160 //------------------------------------------------------------------------------
163 //------------------------------------------------------------------------------
164 vtkImageMapToWindowLevelColors* vvSlicer::GetFusionMapper() {
165 return mFusionMapper.GetPointer();
167 //------------------------------------------------------------------------------
170 //------------------------------------------------------------------------------
171 vtkImageActor* vvSlicer::GetFusionActor() {
172 return mFusionActor.GetPointer();
174 //------------------------------------------------------------------------------
177 //------------------------------------------------------------------------------
178 vtkActor* vvSlicer::GetVFActor() {
179 return mVFActor.GetPointer();
181 //------------------------------------------------------------------------------
184 //------------------------------------------------------------------------------
185 vtkCornerAnnotation* vvSlicer::GetAnnotation() {
186 return ca.GetPointer();
188 //------------------------------------------------------------------------------
191 //------------------------------------------------------------------------------
192 void vvSlicer::EnableReducedExtent(bool b) {
193 mUseReducedExtent = b;
195 //------------------------------------------------------------------------------
198 //------------------------------------------------------------------------------
199 void vvSlicer::SetReducedExtent(int * ext) {
200 mReducedExtent = ext;
202 //------------------------------------------------------------------------------
205 //------------------------------------------------------------------------------
206 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
209 mSurfaceCutActors.push_back(new vvMeshActor());
211 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
213 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
214 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
215 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
219 //------------------------------------------------------------------------------
222 //------------------------------------------------------------------------------
223 void vvSlicer::ToggleContourSuperposition()
225 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
226 i!=mSurfaceCutActors.end();i++)
227 (*i)->ToggleSuperposition();
229 //------------------------------------------------------------------------------
232 //------------------------------------------------------------------------------
233 void vvSlicer::SetCursorColor(int r,int g, int b)
235 pdmA->GetProperty()->SetColor(r,g,b);
237 //------------------------------------------------------------------------------
240 //------------------------------------------------------------------------------
241 void vvSlicer::SetCursorVisibility(bool s)
243 pdmA->SetVisibility(s);
245 //------------------------------------------------------------------------------
248 //------------------------------------------------------------------------------
249 bool vvSlicer::GetCursorVisibility()
251 return pdmA->GetVisibility();
253 //------------------------------------------------------------------------------
256 //------------------------------------------------------------------------------
257 vvSlicer::~vvSlicer()
259 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
260 i!=mSurfaceCutActors.end();i++)
263 //------------------------------------------------------------------------------
266 //------------------------------------------------------------------------------
267 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
274 //------------------------------------------------------------------------------
277 //------------------------------------------------------------------------------
278 void vvSlicer::SetImage(vvImage::Pointer image)
280 if (image->GetVTKImages().size())
283 this->Superclass::SetInput(image->GetVTKImages()[0]);
285 // Prevent crash when reload -> change slice if outside extent
287 this->GetInput()->GetWholeExtent(extent);
288 if (SliceOrientation == 0) {
289 if (Slice >= extent[1]) {
290 Slice = (extent[1]-extent[0])/2.0;
293 if (SliceOrientation == 1) {
294 if (Slice >= extent[3]) {
295 Slice = (extent[3]-extent[2])/2.0;
298 if (SliceOrientation == 2) {
299 if (Slice >= extent[5]) {
300 Slice = (extent[5]-extent[4])/2.0;
304 this->UpdateDisplayExtent();
306 ca->SetText(0,mFileName.c_str());
309 //------------------------------------------------------------------------------
312 //------------------------------------------------------------------------------
313 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
315 if (overlay->GetVTKImages().size())
320 mOverlayMapper = vtkImageMapToWindowLevelColors::New();
321 mOverlayMapper->SetInput(overlay->GetVTKImages()[0]);
325 mOverlayActor = vtkImageActor::New();
326 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
327 mOverlayActor->SetPickable(0);
328 mOverlayActor->SetVisibility(false);
329 mOverlayActor->SetOpacity(0.5);
330 this->UpdateDisplayExtent();
333 //stupid but necessary : the Overlay need to be rendered before fusion
336 this->GetRenderer()->RemoveActor(mFusionActor);
337 this->GetRenderer()->AddActor(mOverlayActor);
338 this->GetRenderer()->AddActor(mFusionActor);
341 this->GetRenderer()->AddActor(mOverlayActor);
344 SetTSlice(mCurrentTSlice);
347 //------------------------------------------------------------------------------
350 //------------------------------------------------------------------------------
351 void vvSlicer::SetFusion(vvImage::Pointer fusion)
353 if (fusion->GetVTKImages().size())
358 mFusionMapper = vtkImageMapToWindowLevelColors::New();
359 mFusionMapper->SetInput(fusion->GetVTKImages()[0]);
363 mFusionActor = vtkImageActor::New();
364 mFusionActor->SetInput(mFusionMapper->GetOutput());
365 mFusionActor->SetPickable(0);
366 mFusionActor->SetVisibility(false);
367 mFusionActor->SetOpacity(0.7);
368 this->UpdateDisplayExtent();
369 this->GetRenderer()->AddActor(mFusionActor);
373 SetTSlice(mCurrentTSlice);
376 //------------------------------------------------------------------------------
379 //------------------------------------------------------------------------------
380 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
382 if (actor_type == "vector")
384 this->mVFActor->SetVisibility(vis);
386 if (actor_type == "overlay")
388 this->mOverlayActor->SetVisibility(vis);
390 if (actor_type == "fusion")
392 this->mFusionActor->SetVisibility(vis);
394 if (actor_type == "contour")
395 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
396 UpdateDisplayExtent();
398 //------------------------------------------------------------------------------
401 //------------------------------------------------------------------------------
402 void vvSlicer::SetVF(vvImage::Pointer vf)
404 if (vf->GetVTKImages().size())
410 mAAFilter=vtkAssignAttribute::New();
411 mVOIFilter = vtkExtractVOI::New();
412 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
414 mVOIFilter->SetInput(vf->GetVTKImages()[0]);
415 mAAFilter->SetInput(mVOIFilter->GetOutput());
416 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
417 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
420 mArrow = vvGlyphSource::New();
421 mArrow->SetGlyphTypeToSpecificArrow();
422 mArrow->SetScale(mScale);
425 // Glyph the gradient vector (with arrows)
427 mGlyphFilter = vvGlyph2D::New();
428 mGlyphFilter->SetInput(mAAFilter->GetOutput());
429 mGlyphFilter->SetSource(mArrow->GetOutput());
430 mGlyphFilter->ScalingOn();
431 mGlyphFilter->SetScaleModeToScaleByVector();
432 mGlyphFilter->OrientOn();
433 mGlyphFilter->SetVectorModeToUseVector();
434 mGlyphFilter->SetColorModeToColorByVector();
437 mVFMapper = vtkPolyDataMapper::New();
438 //mVFMapper->SetInputConnection(mGlyphFilter->GetOutputPort());
439 mVFMapper->SetInput(mGlyphFilter->GetOutput());
440 mVFMapper->ImmediateModeRenderingOn();
443 mVFActor = vtkActor::New();
444 mVFActor->SetMapper(mVFMapper);
445 mVFActor->SetPickable(0);
446 this->UpdateDisplayExtent();
447 this->GetRenderer()->AddActor(mVFActor);
450 SetTSlice(mCurrentTSlice);
453 //------------------------------------------------------------------------------
456 //------------------------------------------------------------------------------
457 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
459 mLandmarks = landmarks;
464 mCross = vtkCursor3D::New();
465 mCross->SetFocalPoint(0.0,0.0,0.0);
466 mCross->SetModelBounds(-10,10,-10,10,-10,10);
471 mLandGlyph = vtkGlyph3D::New();
472 mLandGlyph->SetSource(mCross->GetOutput());
473 mLandGlyph->SetInput(landmarks->GetOutput());
474 //mLandGlyph->SetIndexModeToScalar();
475 mLandGlyph->SetRange(0,1);
476 mLandGlyph->ScalingOff();
478 mLandGlyph->SetColorModeToColorByScalar();
481 mClipBox = vtkBox::New();
483 mLandClipper = vtkClipPolyData::New();
484 mLandClipper->InsideOutOn();
485 mLandClipper->SetInput(mLandGlyph->GetOutput());
486 mLandClipper->SetClipFunction(mClipBox);
489 mLandMapper = vtkPolyDataMapper::New();
490 mLandMapper->SetInputConnection(mLandClipper->GetOutputPort());
491 //mLandMapper->ScalarVisibilityOff();
494 mLandActor = vtkActor::New();
495 mLandActor->SetMapper(mLandMapper);
496 mLandActor->GetProperty()->SetColor(255,10,212);
497 mLandActor->SetPickable(0);
498 mLandActor->SetVisibility(true);
499 this->UpdateDisplayExtent();
500 this->GetRenderer()->AddActor(mLandActor);
503 //------------------------------------------------------------------------------
505 //------------------------------------------------------------------------------
506 //FIXME: this function leaks memory, we should fix it someday :)
507 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
509 if (actor_type == "vector")
511 Renderer->RemoveActor(mVFActor);
520 if (actor_type == "overlay")
522 Renderer->RemoveActor(mOverlayActor);
524 mOverlayActor = NULL;
525 mOverlayMapper = NULL;
527 if (actor_type == "fusion")
529 Renderer->RemoveActor(mFusionActor);
532 mFusionMapper = NULL;
534 if (actor_type == "contour")
536 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
537 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
540 //------------------------------------------------------------------------------
543 //------------------------------------------------------------------------------
544 void vvSlicer::SetVFSubSampling(int sub)
548 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
551 UpdateDisplayExtent();
554 //------------------------------------------------------------------------------
557 //------------------------------------------------------------------------------
558 void vvSlicer::SetVFScale(int scale)
562 mArrow->SetScale(mScale);
563 UpdateDisplayExtent();
566 //------------------------------------------------------------------------------
569 //------------------------------------------------------------------------------
570 void vvSlicer::SetVFLog(int log)
575 mGlyphFilter->SetUseLog(mVFLog);
576 mGlyphFilter->Modified();
578 UpdateDisplayExtent();
581 //------------------------------------------------------------------------------
584 //------------------------------------------------------------------------------
585 void vvSlicer::SetTSlice(int t)
589 else if ((unsigned int)t >= mImage->GetVTKImages().size())
590 t = mImage->GetVTKImages().size() -1;
592 if (mCurrentTSlice == t) return;
595 this->SetInput(mImage->GetVTKImages()[t]);
596 if (mVF && mVFActor->GetVisibility())
598 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
599 mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
601 if (mOverlay && mOverlayActor->GetVisibility())
603 if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
604 mOverlayMapper->SetInput(mOverlay->GetVTKImages()[mCurrentTSlice]);
606 if (mFusion && mFusionActor->GetVisibility())
608 if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
609 mFusionMapper->SetInput(mFusion->GetVTKImages()[mCurrentTSlice]);
611 if (mSurfaceCutActors.size() > 0)
612 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
613 i!=mSurfaceCutActors.end();i++)
614 (*i)->SetTimeSlice(mCurrentTSlice);
615 UpdateDisplayExtent();
617 //------------------------------------------------------------------------------
620 //------------------------------------------------------------------------------
621 int vvSlicer::GetTSlice()
623 return mCurrentTSlice;
625 //------------------------------------------------------------------------------
628 //------------------------------------------------------------------------------
629 void vvSlicer::SetSliceOrientation(int orientation)
631 //if 2D image, force to watch in Axial View
633 this->GetInput()->GetWholeExtent(extent);
634 if (extent[5]-extent[4] <= 2)
637 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
638 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY)
640 vtkErrorMacro("Error - invalid slice orientation " << orientation);
644 this->SliceOrientation = orientation;
647 int *range = this->GetSliceRange();
649 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
651 this->UpdateOrientation();
652 this->UpdateDisplayExtent();
654 if (this->Renderer && this->GetInput())
656 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
657 this->Renderer->ResetCamera();
658 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
663 //----------------------------------------------------------------------------
666 //----------------------------------------------------------------------------
667 int * vvSlicer::GetExtent() {
669 if (mUseReducedExtent) {
670 w_ext = mReducedExtent;
672 else w_ext = GetInput()->GetWholeExtent();
675 //----------------------------------------------------------------------------
678 //----------------------------------------------------------------------------
679 int vvSlicer::GetOrientation() {
680 return this->SliceOrientation;
682 //----------------------------------------------------------------------------
685 //----------------------------------------------------------------------------
686 void vvSlicer::UpdateDisplayExtent()
688 vtkImageData *input = this->GetInput();
689 if (!input || !this->ImageActor)
693 input->UpdateInformation();
694 int *w_ext;// = input->GetWholeExtent();
696 if (mUseReducedExtent) {
697 w_ext = mReducedExtent;
699 else w_ext = input->GetWholeExtent();
701 switch (this->SliceOrientation)
703 case vtkImageViewer2::SLICE_ORIENTATION_XY:
704 this->ImageActor->SetDisplayExtent(
705 w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice);
706 if (mVF && mVFActor->GetVisibility())
709 ComputeVFDisplayedExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice,vfExtent);
710 mVOIFilter->SetVOI(vfExtent);
711 mGlyphFilter->SetOrientation(1,1,0);
713 // put the vector field between the image and the camera
714 if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice)
715 mVFActor->SetPosition(0,0,ImageActor->GetBounds()[5]+2);
717 mVFActor->SetPosition(0,0,ImageActor->GetBounds()[4]-2);
719 if (mOverlay && mOverlayActor->GetVisibility())
722 ComputeOverlayDisplayedExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice,overExtent);
723 mOverlayActor->SetDisplayExtent(overExtent);
724 if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice)
725 mOverlayActor->SetPosition(0,0,1);
727 mOverlayActor->SetPosition(0,0,-1);
729 if (mFusion && mFusionActor->GetVisibility())
732 ComputeFusionDisplayedExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice,fusExtent);
733 mFusionActor->SetDisplayExtent(fusExtent);
734 if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice)
735 mFusionActor->SetPosition(0,0,1.5);
737 mFusionActor->SetPosition(0,0,-1.5);
744 bounds[0] = ImageActor->GetBounds()[0];
745 bounds[1] = ImageActor->GetBounds()[1];
746 bounds[2] = ImageActor->GetBounds()[2];
747 bounds[3] = ImageActor->GetBounds()[3];
748 bounds[4] = ImageActor->GetBounds()[4]-(0.9/this->GetInput()->GetSpacing()[2]);
749 bounds[5] = ImageActor->GetBounds()[5]+(0.9/this->GetInput()->GetSpacing()[2]);
750 mClipBox->SetBounds(bounds);
753 if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice)
754 mLandActor->SetPosition(0,0,1.5);
756 mLandActor->SetPosition(0,0,-1.5);
760 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
761 this->ImageActor->SetDisplayExtent(
762 w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5]);
763 if (mVF && mVFActor->GetVisibility())
766 ComputeVFDisplayedExtent(w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5],vfExtent);
767 mVOIFilter->SetVOI(vfExtent);
768 mGlyphFilter->SetOrientation(1,0,1);
770 // put the vector field between the image aSpacingnd the camera
771 if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice)
772 mVFActor->SetPosition(0,ImageActor->GetBounds()[3]+2,0);
774 mVFActor->SetPosition(0,ImageActor->GetBounds()[2]-2,0);
776 if (mOverlay && mOverlayActor->GetVisibility())
779 ComputeOverlayDisplayedExtent(w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5],overExtent);
780 mOverlayActor->SetDisplayExtent(overExtent);
781 if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice)
782 mOverlayActor->SetPosition(0,1,0);
784 mOverlayActor->SetPosition(0,-1,0);
786 if (mFusion && mFusionActor->GetVisibility())
789 ComputeFusionDisplayedExtent(w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5],fusExtent);
790 mFusionActor->SetDisplayExtent(fusExtent);
791 if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice)
792 mFusionActor->SetPosition(0,1.5,0);
794 mFusionActor->SetPosition(0,-1.5,0);
801 bounds[0] = ImageActor->GetBounds()[0];
802 bounds[1] = ImageActor->GetBounds()[1];
803 bounds[2] = ImageActor->GetBounds()[2]-(0.5/this->GetInput()->GetSpacing()[1]);
804 bounds[3] = ImageActor->GetBounds()[3]+(0.5/this->GetInput()->GetSpacing()[1]);
805 bounds[4] = ImageActor->GetBounds()[4];
806 bounds[5] = ImageActor->GetBounds()[5];
807 mClipBox->SetBounds(bounds);
810 if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice)
811 mLandActor->SetPosition(0,1.5,0);
813 mLandActor->SetPosition(0,-1.5,0);
817 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
818 this->ImageActor->SetDisplayExtent(
819 this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5]);
820 if (mVF && mVFActor->GetVisibility())
823 ComputeVFDisplayedExtent(this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5],vfExtent);
824 mVOIFilter->SetVOI(vfExtent);
825 mGlyphFilter->SetOrientation(0,1,1);
827 // put the vector field between the image and the camera
828 if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice)
829 mVFActor->SetPosition(ImageActor->GetBounds()[1]+2,0,0);
831 mVFActor->SetPosition(ImageActor->GetBounds()[0]-2,0,0);
833 if (mOverlay && mOverlayActor->GetVisibility())
836 ComputeOverlayDisplayedExtent(this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5],overExtent);
837 mOverlayActor->SetDisplayExtent(overExtent);
838 if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice)
839 mOverlayActor->SetPosition(1,0,0);
841 mOverlayActor->SetPosition(-1,0,0);
843 if (mFusion && mFusionActor->GetVisibility())
846 ComputeFusionDisplayedExtent(this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5],fusExtent);
847 mFusionActor->SetDisplayExtent(fusExtent);
848 if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice)
849 mFusionActor->SetPosition(1.5,0,0);
851 mFusionActor->SetPosition(-1.5,0,0);
858 bounds[0] = ImageActor->GetBounds()[0]-(0.5/this->GetInput()->GetSpacing()[0]);
859 bounds[1] = ImageActor->GetBounds()[1]+(0.5/this->GetInput()->GetSpacing()[0]);
860 bounds[2] = ImageActor->GetBounds()[2];
861 bounds[3] = ImageActor->GetBounds()[3];
862 bounds[4] = ImageActor->GetBounds()[4];
863 bounds[5] = ImageActor->GetBounds()[5];
864 mClipBox->SetBounds(bounds);
867 if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice)
868 mLandActor->SetPosition(1.5,0,0);
870 mLandActor->SetPosition(-1.5,0,0);
875 // Figure out the correct clipping range
879 if (this->InteractorStyle &&
880 this->InteractorStyle->GetAutoAdjustCameraClippingRange())
882 this->Renderer->ResetCameraClippingRange();
886 vtkCamera *cam = this->Renderer->GetActiveCamera();
890 this->ImageActor->GetBounds(bounds);
891 double spos = (double)bounds[this->SliceOrientation * 2];
892 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
893 double range = fabs(spos - cpos);
894 double *spacing = input->GetSpacing();
896 ((double)spacing[0] + (double)spacing[1] + (double)spacing[2]) / 3.0;
897 cam->SetClippingRange(
898 range - avg_spacing * 3.0, range + avg_spacing * 3.0);
903 //----------------------------------------------------------------------------
906 //----------------------------------------------------------------------------
907 void vvSlicer::ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int vfExtent[6])
909 vtkImageData* image=this->GetInput();
910 vfExtent[0] = (( image->GetOrigin()[0] + x1*image->GetSpacing()[0] ) - mVF->GetOrigin()[0]) /
911 mVF->GetSpacing()[0];
912 vfExtent[1] = (( image->GetOrigin()[0] + x2*image->GetSpacing()[0] ) - mVF->GetOrigin()[0]) /
913 mVF->GetSpacing()[0];
914 vfExtent[2] = (( image->GetOrigin()[1] + y1*image->GetSpacing()[1] ) - mVF->GetOrigin()[1]) /
915 mVF->GetSpacing()[1];
916 vfExtent[3] = (( image->GetOrigin()[1] + y2*image->GetSpacing()[1] ) - mVF->GetOrigin()[1]) /
917 mVF->GetSpacing()[1];
918 vfExtent[4] = (( image->GetOrigin()[2] + z1*image->GetSpacing()[2] ) - mVF->GetOrigin()[2]) /
919 mVF->GetSpacing()[2];
920 vfExtent[5] = (( image->GetOrigin()[2] + z2*image->GetSpacing()[2] ) - mVF->GetOrigin()[2]) /
921 mVF->GetSpacing()[2];
923 ClipDisplayedExtent(vfExtent,mVOIFilter->GetInput()->GetWholeExtent());
925 //----------------------------------------------------------------------------
928 //----------------------------------------------------------------------------
929 void vvSlicer::ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6])
931 vtkImageData* image=this->GetInput();
932 overExtent[0] = (( image->GetOrigin()[0] + x1*image->GetSpacing()[0] ) - mOverlay->GetOrigin()[0]) /
933 mOverlay->GetSpacing()[0];
934 overExtent[1] = (( image->GetOrigin()[0] + x2*image->GetSpacing()[0] ) - mOverlay->GetOrigin()[0]) /
935 mOverlay->GetSpacing()[0];
936 overExtent[2] = (( image->GetOrigin()[1] + y1*image->GetSpacing()[1] ) - mOverlay->GetOrigin()[1]) /
937 mOverlay->GetSpacing()[1];
938 overExtent[3] = (( image->GetOrigin()[1] + y2*image->GetSpacing()[1] ) - mOverlay->GetOrigin()[1]) /
939 mOverlay->GetSpacing()[1];
940 overExtent[4] = (( image->GetOrigin()[2] + z1*image->GetSpacing()[2] ) - mOverlay->GetOrigin()[2]) /
941 mOverlay->GetSpacing()[2];
942 overExtent[5] = (( image->GetOrigin()[2] + z2*image->GetSpacing()[2] ) - mOverlay->GetOrigin()[2]) /
943 mOverlay->GetSpacing()[2];
944 ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
946 //----------------------------------------------------------------------------
949 //----------------------------------------------------------------------------
950 void vvSlicer::ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int fusExtent[6])
952 vtkImageData* image=this->GetInput();
953 fusExtent[0] = (( image->GetOrigin()[0] + x1*image->GetSpacing()[0] ) - mFusion->GetOrigin()[0]) /
954 mFusion->GetSpacing()[0];
955 fusExtent[1] = (( image->GetOrigin()[0] + x2*image->GetSpacing()[0] ) - mFusion->GetOrigin()[0]) /
956 mFusion->GetSpacing()[0];
957 fusExtent[2] = (( image->GetOrigin()[1] + y1*image->GetSpacing()[1] ) - mFusion->GetOrigin()[1]) /
958 mFusion->GetSpacing()[1];
959 fusExtent[3] = (( image->GetOrigin()[1] + y2*image->GetSpacing()[1] ) - mFusion->GetOrigin()[1]) /
960 mFusion->GetSpacing()[1];
961 fusExtent[4] = (( image->GetOrigin()[2] + z1*image->GetSpacing()[2] ) - mFusion->GetOrigin()[2]) /
962 mFusion->GetSpacing()[2];
963 fusExtent[5] = (( image->GetOrigin()[2] + z2*image->GetSpacing()[2] ) - mFusion->GetOrigin()[2]) /
964 mFusion->GetSpacing()[2];
965 ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
967 //----------------------------------------------------------------------------
970 //----------------------------------------------------------------------------
971 void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
976 //2D overlay on 3D image specific case
977 if (refExtent[4] == refExtent[5])
980 extent[4] = refExtent[4];
981 extent[5] = refExtent[5];
984 for (int i = 0; i < maxBound; i = i+2)
986 //if we are totally outside the image
987 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] )
992 //crop to the limit of the image
993 extent[i] = (extent[i] > refExtent[i]) ? extent[i] : refExtent[i];
994 extent[i] = (extent[i] < refExtent[i+1]) ? extent[i] : refExtent[i+1];
995 extent[i+1] = (extent[i+1] > refExtent[i]) ? extent[i+1] : refExtent[i];
996 extent[i+1] = (extent[i+1] < refExtent[i+1]) ? extent[i+1] : refExtent[i+1];
999 for (int i = 0; i < maxBound; i = i+2)
1001 extent[i] = refExtent[i];
1002 extent[i+1] = refExtent[i];
1005 //----------------------------------------------------------------------------
1008 //----------------------------------------------------------------------------
1009 void vvSlicer::UpdateOrientation()
1011 // Set the camera position
1012 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1015 switch (this->SliceOrientation)
1017 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1018 cam->SetFocalPoint(0,0,0);
1019 cam->SetPosition(0,0,-1); // -1 if medical ?
1020 cam->SetViewUp(0,-1,0);
1023 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1024 cam->SetFocalPoint(0,0,0);
1025 cam->SetPosition(0,-1,0); // 1 if medical ?
1026 cam->SetViewUp(0,0,1);
1029 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1030 cam->SetFocalPoint(0,0,0);
1031 cam->SetPosition(-1,0,0); // -1 if medical ?
1032 cam->SetViewUp(0,0,1);
1037 //----------------------------------------------------------------------------
1040 //----------------------------------------------------------------------------
1041 void vvSlicer::SetOpacity(double s)
1043 this->GetImageActor()->SetOpacity(s);
1045 //----------------------------------------------------------------------------
1048 //----------------------------------------------------------------------------
1049 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1051 this->Superclass::SetRenderWindow(rw);
1052 this->SetupInteractor(rw->GetInteractor());
1053 ca->SetImageActor(this->GetImageActor());
1054 ca->SetWindowLevel(this->GetWindowLevel());
1055 ca->SetText(2, "<slice>");
1056 ca->SetText(3, "<window>\n<level>");
1068 crossCursor->SetModelBounds(bounds);
1069 this->GetRenderer()->AddActor(pdmA);
1070 this->GetRenderer()->AddActor(ca);
1071 this->GetRenderer()->ResetCamera();
1073 //this is just a mapping between the labeling of the orientations presented to the user and
1074 //the one used by vtk
1075 SetSliceOrientation(2-(orientation%3));
1078 //----------------------------------------------------------------------------
1081 //----------------------------------------------------------------------------
1082 void vvSlicer::ResetCamera()
1084 if (this->GetInput())
1086 double* input_bounds=this->GetInput()->GetBounds();
1087 double bmax=input_bounds[1]-input_bounds[0];
1088 if (bmax < input_bounds[3]-input_bounds[2]) bmax=input_bounds[3]-input_bounds[2];
1089 if (bmax < input_bounds[5]-input_bounds[4]) bmax=input_bounds[5]-input_bounds[4];
1090 this->GetRenderer()->ResetCamera();
1091 this->GetRenderer()->GetActiveCamera()->SetParallelScale(bmax/2);
1094 //----------------------------------------------------------------------------
1097 //----------------------------------------------------------------------------
1098 void vvSlicer::SetDisplayMode(bool i)
1100 this->GetImageActor()->SetVisibility(i);
1101 this->GetAnnotation()->SetVisibility(i);
1102 this->GetRenderer()->SetDraw(i);
1104 mLandActor->SetVisibility(i);
1105 pdmA->SetVisibility(i);
1107 UpdateDisplayExtent();
1109 //----------------------------------------------------------------------------
1112 //----------------------------------------------------------------------------
1113 void vvSlicer::FlipHorizontalView()
1115 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1118 double *position = cam->GetPosition();
1119 switch (this->SliceOrientation)
1121 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1122 cam->SetPosition(position[0],position[1],-position[2]);
1125 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1126 cam->SetPosition(position[0],-position[1],position[2]);
1129 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1130 cam->SetPosition(-position[0],position[1],position[2]);
1133 this->Renderer->ResetCameraClippingRange();
1134 this->UpdateDisplayExtent();
1137 //----------------------------------------------------------------------------
1140 //----------------------------------------------------------------------------
1141 void vvSlicer::FlipVerticalView()
1143 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1146 FlipHorizontalView();
1147 double *viewup = cam->GetViewUp();
1148 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1149 this->UpdateDisplayExtent();
1152 //----------------------------------------------------------------------------
1155 //----------------------------------------------------------------------------
1156 void vvSlicer::SetColorWindow(double window)
1158 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1161 double level = this->GetWindowLevel()->GetLevel();
1162 LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4);
1165 this->vtkImageViewer2::SetColorWindow(window);
1167 //----------------------------------------------------------------------------
1170 //----------------------------------------------------------------------------
1171 void vvSlicer::SetColorLevel(double level)
1173 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1176 double window = this->GetWindowLevel()->GetWindow();
1177 LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4);
1180 this->vtkImageViewer2::SetColorLevel(level);
1182 //----------------------------------------------------------------------------
1184 //----------------------------------------------------------------------------
1185 // Returns the min an the max value in a 41x41 region around the mouse pointer
1186 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max)
1188 //Get mouse pointer position in view coordinates
1189 double fLocalExtents[6];
1190 for(int i=0; i<3; i++)
1192 fLocalExtents[i*2 ] = mCurrent[i];
1193 fLocalExtents[i*2+1] = mCurrent[i];
1195 this->Renderer->WorldToView(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1196 this->Renderer->WorldToView(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1197 for(int i=0; i<3; i++)
1199 if (i!=SliceOrientation) //SR: assumes that SliceOrientation is valid in ViewCoordinates (???)
1201 fLocalExtents[i*2 ] -= 0.2;
1202 fLocalExtents[i*2+1] += 0.2;
1205 this->Renderer->ViewToWorld(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1206 this->Renderer->ViewToWorld(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1208 //Convert to image pixel coordinates (rounded)
1209 int iLocalExtents[6];
1210 for(int i=0; i<3; i++)
1212 fLocalExtents[i*2 ] = (fLocalExtents[i*2 ] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i];
1213 fLocalExtents[i*2+1] = (fLocalExtents[i*2+1] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i];
1215 iLocalExtents[i*2 ] = lrint(fLocalExtents[i*2 ]);
1216 iLocalExtents[i*2+1] = lrint(fLocalExtents[i*2+1]);
1218 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1219 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1222 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkExtractVOI::New();
1223 voiFilter->SetInput(this->GetInput());
1224 voiFilter->SetVOI(iLocalExtents);
1225 voiFilter->Update();
1226 if (!voiFilter->GetOutput()->GetNumberOfPoints())
1233 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkImageAccumulate::New();
1234 accFilter->SetInput(voiFilter->GetOutput());
1235 accFilter->Update();
1237 min = *(accFilter->GetMin());
1238 max = *(accFilter->GetMax());
1240 //----------------------------------------------------------------------------
1242 //----------------------------------------------------------------------------
1243 void vvSlicer::Render()
1246 //DD(SliceOrientation);
1247 if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay && !this->mFusion)
1249 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1250 legend->SetVisibility(1);
1252 else legend->SetVisibility(0);
1254 if (ca->GetVisibility())
1256 std::string worldPos = "";
1257 std::stringstream world1;
1258 std::stringstream world2;
1259 std::stringstream world3;
1260 world1 << (int)mCurrent[0];
1261 world2 << (int)mCurrent[1];
1262 world3 << (int)mCurrent[2];
1263 double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1264 double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1265 double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1267 if (pdmA->GetVisibility())
1269 double x = mCursor[0];
1270 double y = mCursor[1];
1271 double z = mCursor[2];
1272 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1273 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1274 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1276 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0] &&
1277 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+1 &&
1278 yCursor >= this->GetImageActor()->GetDisplayExtent()[2] &&
1279 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+1 &&
1280 zCursor >= this->GetImageActor()->GetDisplayExtent()[4] &&
1281 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+1 )
1283 vtkRenderer * renderer = this->Renderer;
1285 renderer->WorldToView(x,y,z);
1286 renderer->ViewToNormalizedViewport(x,y,z);
1287 renderer->NormalizedViewportToViewport(x,y);
1288 renderer->ViewportToNormalizedDisplay(x,y);
1289 renderer->NormalizedDisplayToDisplay(x,y);
1290 crossCursor->SetFocalPoint(x,y,z);
1293 crossCursor->SetFocalPoint(-1,-1,z);
1296 if (X >= this->GetInput()->GetWholeExtent()[0] &&
1297 X <= this->GetInput()->GetWholeExtent()[1] &&
1298 Y >= this->GetInput()->GetWholeExtent()[2] &&
1299 Y <= this->GetInput()->GetWholeExtent()[3] &&
1300 Z >= this->GetInput()->GetWholeExtent()[4] &&
1301 Z <= this->GetInput()->GetWholeExtent()[5])
1303 std::stringstream pixel1;
1304 std::stringstream pixel2;
1305 std::stringstream pixel3;
1306 std::stringstream temps;
1310 temps << mCurrentTSlice;
1311 double value = this->GetInput()->GetScalarComponentAsDouble(lrint(X),
1315 std::stringstream val;
1317 worldPos += "data value : " + val.str();
1318 worldPos += "\n mm : " + world1.str() + " " + world2.str() + " " +
1319 world3.str() + " " + temps.str();
1320 worldPos += "\n pixel : " + pixel1.str() + " " + pixel2.str() + " " +
1321 pixel3.str() + " " + temps.str();
1323 ca->SetText(1,worldPos.c_str());
1325 if (mOverlay && mOverlayActor->GetVisibility())
1327 mOverlayMapper->SetWindow(this->GetColorWindow());
1328 mOverlayMapper->SetLevel(this->GetColorLevel());
1329 mOverlayMapper->Update();
1333 //this->Superclass::Render();
1334 this->GetRenderWindow()->Render();
1336 //----------------------------------------------------------------------------
1339 //----------------------------------------------------------------------------
1340 void vvSlicer::UpdateCursorPosition()
1342 if (this->GetImageActor()->GetVisibility())
1344 pdmA->SetVisibility(true);
1345 mCursor[0] = mCurrent[0];
1346 mCursor[1] = mCurrent[1];
1347 mCursor[2] = mCurrent[2];
1348 mCursor[3] = mCurrentTSlice;
1351 //----------------------------------------------------------------------------
1354 //----------------------------------------------------------------------------
1355 void vvSlicer::UpdateLandmarks()
1357 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
1358 if (pd->GetPoints())
1360 mLandGlyph->SetRange(0,1);
1361 mLandGlyph->Modified();
1362 mLandGlyph->Update();
1364 mClipBox->Modified();
1365 mLandClipper->Update();
1366 mLandMapper->Update();
1370 //----------------------------------------------------------------------------
1373 //----------------------------------------------------------------------------
1374 void vvSlicer::SetSlice(int slice)
1376 int *range = this->GetSliceRange();
1379 if (slice < range[0])
1383 else if (slice > range[1])
1389 if (this->Slice == slice)
1394 this->Slice = slice;
1397 this->UpdateDisplayExtent();
1399 // DD("SetSlice de slicer = Render");
1401 // Seems to work without this line
1404 //----------------------------------------------------------------------------
1407 //----------------------------------------------------------------------------
1408 void vvSlicer::SetContourSlice()
1410 if (mSurfaceCutActors.size() > 0)
1411 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1412 i!=mSurfaceCutActors.end();i++)
1413 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1414 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1416 //----------------------------------------------------------------------------
1419 //----------------------------------------------------------------------------
1420 void vvSlicer::ForceUpdateDisplayExtent()
1422 this->UpdateDisplayExtent();
1424 //----------------------------------------------------------------------------
1427 //----------------------------------------------------------------------------
1428 int* vvSlicer::GetDisplayExtent()
1430 return this->GetImageActor()->GetDisplayExtent();
1432 //----------------------------------------------------------------------------
1435 //----------------------------------------------------------------------------
1436 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1438 this->Superclass::PrintSelf(os, indent);
1440 //----------------------------------------------------------------------------