GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
vtkViewImage2D.h
Go to the documentation of this file.
1 /*========================================================================
2  Copyright (c) INRIA - ASCLEPIOS Project (http://www-sop.inria.fr/asclepios).
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10 
11  * Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  * Neither the name of INRIA or ASCLEPIOS, nor the names of any contributors
16  may be used to endorse or promote products derived from this software
17  without specific prior written permission.
18 
19  * Modified source versions must be plainly marked as such, and must not be
20  misrepresented as being the original software.
21 
22  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
23  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
26  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  =========================================================================*/
33 
34 /*=========================================================================
35  Modifications were made by the GoFigure Dev. Team.
36  while at Megason Lab, Systems biology, Harvard Medical school, 2009-11
37 
38  Copyright (c) 2009-11, President and Fellows of Harvard College.
39  All rights reserved.
40 
41  Redistribution and use in source and binary forms, with or without
42  modification, are permitted provided that the following conditions are met:
43 
44  Redistributions of source code must retain the above copyright notice,
45  this list of conditions and the following disclaimer.
46  Redistributions in binary form must reproduce the above copyright notice,
47  this list of conditions and the following disclaimer in the documentation
48 // and/or other materials provided with the distribution.
49  Neither the name of the President and Fellows of Harvard College
50  nor the names of its contributors may be used to endorse or promote
51  products derived from this software without specific prior written
52  permission.
53 
54  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
55  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
56  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
57  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
58  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
59  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
60  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
61  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
62  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
63  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
64  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65 
66  =========================================================================*/
67 
68 #ifndef _vtkViewImage2D_h_
69 #define _vtkViewImage2D_h_
70 
71 #include "vtkViewImage.h"
72 #include "MegaVTK2Configure.h"
73 
74 #include <map>
75 #include <list>
76 
77 #include "vtkTransform.h"
78 #include "vtkImageActor.h"
80 #include "vtkSmartPointer.h"
81 
82 class vtkPlane;
84 class vtkTransform;
85 class vtkInteractorStyle;
86 class vtkInteractorStyleRubberBandZoom;
88 class vtkPointHandleRepresentation2D;
89 class vtkCursor2D;
90 class vtkCellPicker;
91 class vtkActor;
92 // class vtkQuadricLODActor;
93 
100 class VTK_RENDERINGADDON2_EXPORT vtkViewImage2D:public vtkViewImage
101 {
102 public:
103 
107  static vtkViewImage2D * New();
108 
131  //BTX
132  enum {
133  VIEW_ORIENTATION_SAGITTAL = 0,
134  VIEW_ORIENTATION_CORONAL = 1,
135  VIEW_ORIENTATION_AXIAL = 2
136  };
137  //ETX
141  //BTX
142  enum {
143  VIEW_CONVENTION_RADIOLOGICAL = 0,
144  VIEW_CONVENTION_NEUROLOGICAL = 1
145  };
146  //ETX
152  //BTX
153  enum {
154  INTERACTOR_STYLE_NAVIGATION = 0,
155  INTERACTOR_STYLE_RUBBER_ZOOM
156  };
157  //ETX
158 
159  enum ORIENTATION {
160  XY = 0,
161  XZ = 1,
162  YZ = 2
163  };
164 
173  vtkGetObjectMacro(SlicePlane, vtkPolyData);
174 
181  vtkGetObjectMacro(OrientationAnnotation, vtkOrientationAnnotation);
182 
190  virtual void SetWorldCoordinates(double pos[3]);
191 
196  virtual void SetSlice(int s);
197 
207  vtkGetMacro(ViewOrientation, int);
208 
209  virtual void SetViewOrientation(int orientation);
210 
211  virtual void SetOrientationMatrix(vtkMatrix4x4 *matrix);
212 
224  vtkGetMacro(ViewConvention, int);
225  virtual void SetViewConvention(int convention);
226 
231  virtual double * GetWorldCoordinatesForSlice(int slice);
232 
236  virtual int GetSliceForWorldCoordinates(double pos[3]);
240  virtual void ResetPosition(void);
241 
245  virtual void Reset(void);
246 
250  virtual void ResetCamera(void);
251 
255  vtkSetMacro(Zoom, double);
256 
261  vtkGetMacro(Zoom, double);
262 
266  virtual double *GetWorldCoordinatesFromDisplayPosition(int xy[2]);
267  virtual double * GetWorldCoordinatesFromDisplayPosition(const int & x,
268  const int & y);
269 
270  //BTX
277  //ETX
278 
284  virtual void SetInterpolate(const int & val);
285 
291  virtual int GetInterpolate();
292 
293  vtkBooleanMacro (Interpolate, int);
294 
308  virtual vtkActor * AddDataSet(vtkPolyData *polydata,
309  vtkProperty *property = NULL,
310  const bool & intersection = true,
311  const bool & iDataVisibility = false);
312 
316  vtkSetVector3Macro(CameraMotionVector, double);
317 
322  vtkGetVector3Macro(CameraMotionVector, double);
323 
327  virtual void SetShowAnnotations(const int & iShowAnnotations);
332  vtkGetMacro(ShowAnnotations, int);
336  vtkBooleanMacro(ShowAnnotations, int);
337 
343  void SetCameraFocalAndPosition(double focal[3], double pos[3]);
344 
350  void GetCameraFocalAndPosition(double focal[3], double pos[3]);
351 
361  vtkGetVector3Macro (ViewCenter, double);
362 
366  virtual void Update(void)
367  { this->UpdateOrientation(); }
368 
377  {
378  vtkInteractorStyleImage2D *t = vtkInteractorStyleImage2D::SafeDownCast (this->InteractorStyle);
379 
380  if ( t )
381  {
382  t->SetDefaultMode();
383  }
384  }
385 
391  {
392  vtkInteractorStyleImage2D *t = vtkInteractorStyleImage2D::SafeDownCast (this->InteractorStyle);
393 
394  if ( t )
395  {
396  t->SetZoomMode();
397  }
398  }
399 
405  {
406  vtkInteractorStyleImage2D *t = vtkInteractorStyleImage2D::SafeDownCast (this->InteractorStyle);
407 
408  if ( t )
409  {
410  t->SetPanMode();
411  }
412  }
413 
419  {
420  vtkInteractorStyleImage2D *t = vtkInteractorStyleImage2D::SafeDownCast (this->InteractorStyle);
421 
422  if ( t )
423  {
424  t->SetPickMode();
425  }
426  }
427 
428 
429  /*
430  * \brief Synchronize the views
431  * \param[in] iSynchronize Enable/disable synchronization
432  */
433  void SynchronizeViews( bool iSynchronize)
434  {
435  vtkInteractorStyleImage2D *t = vtkInteractorStyleImage2D::SafeDownCast (this->InteractorStyle);
436  if ( t )
437  {
438  t->SynchronizeViews(iSynchronize);
439  }
440  }
441 
446  vtkGetObjectMacro (Cursor, vtkPointHandleRepresentation2D);
447  vtkGetObjectMacro (CursorGenerator, vtkCursor2D);
448 
452  template< class TContourContainer,
453  class TPropertyContainer >
454  void AddContours(TContourContainer & iContours,
455  TPropertyContainer & iProperty,
456  const bool & iIntersection = true)
457  {
458  if ( iContours.size() != iProperty.size() )
459  {
460  vtkWarningMacro(<< "iContours.size() != iProperty.size()");
461  return;
462  }
463 
464  typedef typename TContourContainer::iterator ContourContainerIterator;
465  typedef typename TPropertyContainer::iterator PropertyContainerIterator;
466 
467  ContourContainerIterator contour_it = iContours.begin();
468  ContourContainerIterator contour_end = iContours.end();
469 
470  PropertyContainerIterator prop_it = iProperty.begin();
471  PropertyContainerIterator prop_end = iProperty.end();
472 
473  while ( contour_it != contour_end )
474  {
475  this->AddDataSet(*contour_it, *prop_it, iIntersection);
476  ++contour_it;
477  ++prop_it;
478  }
479  }
480 
484 /*
485  template<class TContourContainer>
486  void RemoveContours(TContourContainer& iContours)
487  {
488  typedef typename TContourContainer::iterator ContourContainerIterator;
489  ContourContainerIterator contour_it = iContours.begin();
490  ContourContainerIterator contour_end = iContours.end();
491 
492  while (contour_it != contour_end)
493  {
494  this->RemoveDataSet(*contour_it);
495  ++contour_it;
496  }
497  }
498 */
499  std::map<double, vtkActor *> ExtractActors(
500  vtkPolyData *iDataSet, ORIENTATION iOrientation);
501 
502 protected:
503 
504  vtkViewImage2D();
505  ~vtkViewImage2D();
506 
507  virtual void UpdateSlicePlane(void);
508 
509  virtual void UpdateCenter(void);
510 
511  virtual void UpdateOrientation();
512 
513  virtual void PostUpdateOrientation(void);
514 
515  virtual void SetSlicePlaneFromOrientation(void);
516 
517  virtual int SetCameraFromOrientation(void);
518 
519  virtual void SetAnnotationsFromOrientation(void);
520 
528  virtual void SetImplicitPlaneFromOrientation(void);
529 
534  // no possibility of changing the upper-left corner annotation because it is
536  // bypassed by this method at each mouse movement.
537  virtual void UpdateCursor(void);
538 
546  virtual void InitializeSlicePlane(void);
547 
552  virtual void InstallPipeline(void);
553 
554  virtual int SetCameraToConvention(void);
555 
556  virtual void SetAnnotationToConvention(void);
557 
558  virtual void SetSlicePlaneToConvention(unsigned int axis);
559 
560  vtkMatrix4x4 *ConventionMatrix;
561 
562  vtkSmartPointer< vtkPlane > SliceImplicitPlane;
563 
569  vtkPolyData *SlicePlane;
576 
577  vtkInteractorStyle *InteractorStyleSwitcher;
583  vtkInteractorStyleRubberBandZoom *InteractorStyleRubberZoom;
594  vtkPointHandleRepresentation2D *Cursor;
599  vtkCursor2D *CursorGenerator;
600 
604 
605  double ViewCenter[3];
606 
607  char SliceAndWindowInformation[64];
608  char ImageInformation[64];
609 
610  double Zoom;
611  double CameraMotionVector[3];
612 };
613 
614 #endif /* _vtkViewImage2D_h_ */
vtkMatrix4x4 * ConventionMatrix
virtual void SetShowAnnotations(const int &iShowAnnotations)
Change the visibility of the annotations.
vtkSmartPointer< vtkPlane > SliceImplicitPlane
void AddContours(TContourContainer &iContours, TPropertyContainer &iProperty, const bool &iIntersection=true)
Add contours with specific properties to the view.
void SynchronizeViews(bool iSynchronize)
vtkViewImage2DCommand * Command
Access to the command of the viewer. This instance is in charge of observing the interactorstyle (Get...
vtkGetObjectMacro(CornerAnnotation, vtkCornerAnnotation)
Get the corner annotation.
void SynchronizeViews(bool iSynchronize)
void SetDefaultInteractionStyle(void)
Set interaction style to Default mode: Left button: Window level Right button: Zoom Middle button: Pa...
void SetPanInteractionStyle(void)
Set interaction style to Pan mode: All buttons: Pan.
void SetWorldCoordinates(const double &x, const double &y, const double &z)
Set the world coordinates.
Define the interactor behavior withing a vtkImage2D. 4 modes (Default, Zoom, Pan and Pick) ...
vtkPointHandleRepresentation2D * Cursor
Access to the actor corresponding to the cursor. It follows the mouse cursor everywhere it goes...
Text annotation in four corners.
virtual void Update(void)
Update the orientation.
void SetZoomInteractionStyle(void)
Set interaction style to Zoom mode: All buttons: Zoom.
vtkTypeRevisionMacro(vtkViewImage, vtkImageViewer2)
vtkGetMacro(ShowAnnotations, int)
Get the annotation status. 0: annotations are not visible 1: annotations are visible.
void SetPanMode()
Start the Pan Mode.
vtkInteractorStyleRubberBandZoom * InteractorStyleRubberZoom
InteractorStyle used in this view. It is a vtkInteractorStyleImage2D by default but can be set to vtk...
virtual void SetOrientationMatrix(vtkMatrix4x4 *matrix)
vtkOrientationAnnotation * OrientationAnnotation
Get the orientation annotation. This annotation describes the orientation of the slice plane...
This class is a top-level convenience class for displaying a scalar - or RGB image in a 2D or 3D scen...
Definition: vtkViewImage.h:183
virtual void Reset(void)
Reset position - zoom - window/level to default.
void SetZoomMode()
Start the Zoom Mode.
void SetPickInteractionStyle(void)
Set interaction style to Zoom mode: The actor the mouse is highlighted in addition to the Default Mod...
virtual void SetSlice(int iSlice)
Set/Get the current slice to display (depending on the orientation this can be in X...
Definition: vtkViewImage.h:276
vtkBooleanMacro(ShowAnnotations, int)
Set the annotation status. 0: annotations are not visible 1: annotations are visible.
vtkSetMacro(IntersectionLineWidth, float)
Set the linewidth for added dataset in the scene (when using AddDataSet)
vtkCursor2D * CursorGenerator
Access to the actor corresponding to the cursor. It follows the mouse cursor everywhere it goes...
void SetPickMode()
Start the Pick Mode.
void SetDefaultMode()
Start the Default Mode.
vtkPolyData * SlicePlane
This polydata instance is a square colored (see InitializeSlicePlane()) according to the orientation ...
vtkInteractorStyle * InteractorStyleSwitcher
Manage events occuring in 2D view.
Basic class to handle 2D/3D items such as images and polydatas visualization in 2D.
virtual void ResetCamera(void)
Reset the camera.