SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svkDataView.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2009-2014 The Regents of the University of California.
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  * • Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * • Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * • None of the names of any campus of the University of California, the name
13  * "The Regents of the University of California," or the names of any of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26  * OF SUCH DAMAGE.
27  */
28 
29 
30 
31 /*
32  * $URL$
33  * $Rev$
34  * $Author$
35  * $Date$
36  *
37  * Authors:
38  * Jason C. Crane, Ph.D.
39  * Beck Olson
40  */
41 
42 
43 #ifndef SVK_DATA_VIEW_H
44 #define SVK_DATA_VIEW_H
45 
46 
47 #include <vtkRenderWindowInteractor.h>
48 #include <vtkRendererCollection.h>
49 #include <vtkCallbackCommand.h>
50 #include <vtkObject.h>
51 
52 #include <svkImageData.h>
53 #include <vtkPlane.h>
54 #include <vtkPlaneCollection.h>
55 #include <vtkCollectionIterator.h>
56 #include <vtkAbstractMapper.h>
57 #include <svkDataViewController.h>
58 
59 #include <vector>
60 #ifdef WIN32
61  #include <windows.h>
62 #endif
63 namespace svk {
64 
65 
66 using namespace std;
67 
68 
69 // Note forward declaration to avoid self refererncing includes.
70 class svkDataViewController;
71 
72 
73 class svkDataView : public vtkObject
74 {
75  friend class svkDataViewController;
76 
77  // if these are accessed only via the corresponding controller, then these don't need to be public
78  public:
79 
80  vtkTypeMacro( svkDataView, vtkObject);
81 
82  svkDataView();
83  ~svkDataView();
84 
85  // Methods
86  // for DataViews with multiple data objects (e.g. reference view has image and spec data)
87  virtual void SetInput( svkImageData* data, int index = 0 ) = 0;
88 
89  virtual svkImageData* GetInput( int index = 0 );
91  virtual void RemoveInput( int index = 0 );
92 
93  // probably set this in an "Init" method (no constructor for abstract classes). Also,
94  // doesn't need to be virtual or abstract, just
95  // implement this setting in the base class.
96  virtual void SetController( svkDataViewController* controller );
97 
98  // implement in base class - not virtual
99  virtual svkDataViewController* GetController();
100 
101  virtual void SetSlice( int slice ) = 0;
102  virtual int GetSlice( );
103  virtual void SetWindowLevelRange( double lower, double upper, int index );
104 
105  // intended to represent setting of real world FOV of data in renderer
106  virtual void Refresh();
107 
108  /*
109  * Note (promote to main class docs after cleaning up)
110  * that each view is placed within it's own vtkRenderWindow. The renderWindow may be
111  * obtained from the rwi so the getRendererCollection isn't necessary. So, it then
112  * becomes the responsibility of the DataView to place it's renderers within the
113  * renderWindow obtained from the rwi.
114  * Q: how to prevent a renderwindow (or rwi) from being passed to multiple DataViews?
115  */
116  virtual void SetRWInteractor( vtkRenderWindowInteractor* rwi );
117 
122  // Are they toggled on or off
123  virtual void SetPropState(int propIndex, bool visible);
124  virtual void TurnPropOn(int propIndex);
125  virtual void TurnPropOff(int propIndex);
126  virtual bool IsPropOn(int propIndex);
127 
128  virtual void SetRendererState(int rendererIndex, bool visible);
129  virtual void TurnRendererOn(int rendererIndex);
130  virtual void TurnRendererOff(int rendererIndex);
131  virtual bool IsRendererOn(int rendererIndex);
132 
133  // Is it in the views current displayed FOV?
134  virtual void SetVisibility(int actorIndex, bool visible);
135 
136  virtual vtkRenderer* GetRenderer(int index);
137  virtual void SetRenderer(int index, vtkRenderer* ren);
138  virtual vtkProp* GetProp(int index);
139  virtual void SetProp(int index, vtkProp* prop);
140 
141  virtual void SetOrientation( svkDcmHeader::Orientation orientation );
142  virtual svkDcmHeader::Orientation GetOrientation( );
143  static void ClipMapperToTlcBrc( svkImageData* data, vtkAbstractMapper* mapper, int tlcBrc[2], double clip_tolerance_row , double clip_tolerance_column, double clip_tolerance_slice);
144  static void GetClippingIndexFromTlcBrc( svkImageData* data, int indexRange[2][3], int tlcBrc[2] );
145  static void GetClippingPlanes( vtkPlaneCollection* planes, svkImageData* data, int* tlcBrc, double clip_tolerance_row, double clip_tolerance_column, double clip_tolerance_slice );
146  static bool IsTlcBrcWithinData(svkImageData* data, int tlcBrc[2]);
147  static bool IsTlcBrcWithinData( svkImageData* data, int tlcID, int brcID);
148  static void ResetTlcBrcForNewOrientation( svkImageData* data, svkDcmHeader::Orientation orientation, int tlcBrc[2], int &slice);
149 
150  void ValidationOff();
151 
152 
153  protected:
154 
155  // Members:
156  vector < vtkRenderer* > renCollection;
157  vector < vtkProp* > propCollection;
158  vtkRenderWindowInteractor* rwi;
159  vector <svkImageData*> dataVector;
161  vtkCallbackCommand* dataModifiedCallback;
163 
165  int tlcBrc[2];
166  int slice;
167 
168  vector < bool > isPropOn; //Is the actor turned on or off?
169  vector < bool > isRendererOn; //Is the renderer turned on or off?
170  vector < bool > isPropVisible; //Is the actor in the views FOV?
172 
180  virtual void UpdateProps() {;};
181 
182  // Methods:
183  void ObserveData( svkImageData* data );
184  static void UpdateView(
185  vtkObject* subject,
186  unsigned long eid,
187  void* thisObject,
188  void *callData
189  );
190 
191 };
192 
193 
194 } //svk
195 
196 
197 #endif //SVK_DATA_VIEW_H
198 
vtkCallbackCommand * dataModifiedCallback
Definition: svkDataView.h:161
vector< bool > isPropVisible
Definition: svkDataView.h:170
vector< vtkRenderer * > renCollection
Definition: svkDataView.h:156
Definition: svkDataView.h:73
svkDcmHeader::Orientation orientation
Definition: svkDataView.h:162
vector< bool > isPropOn
Definition: svkDataView.h:168
vtkRenderWindowInteractor * rwi
Definition: svkDataView.h:158
Orientation
Definition: svkDcmHeader.h:101
int slice
Definition: svkDataView.h:166
Definition: svkDataViewController.h:72
vector< svkImageData * > dataVector
Definition: svkDataView.h:159
svkDataViewController * controller
Definition: svkDataView.h:160
virtual void UpdateProps()
Definition: svkDataView.h:180
vector< vtkProp * > propCollection
Definition: svkDataView.h:157
Definition: svkImageData.h:107
bool isValidationOn
Definition: svkDataView.h:171
vector< bool > isRendererOn
Definition: svkDataView.h:169