GOFIGURE2
0.9.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
Code
GUI
lib
SynchronizedViews
QGoSynchronizedView3D.cxx
Go to the documentation of this file.
1
/*=========================================================================
2
Authors: The GoFigure Dev. Team.
3
at Megason Lab, Systems biology, Harvard Medical school, 2009-11
4
5
Copyright (c) 2009-11, President and Fellows of Harvard College.
6
All rights reserved.
7
8
Redistribution and use in source and binary forms, with or without
9
modification, are permitted provided that the following conditions are met:
10
11
Redistributions of source code must retain the above copyright notice,
12
this list of conditions and the following disclaimer.
13
Redistributions in binary form must reproduce the above copyright notice,
14
this list of conditions and the following disclaimer in the documentation
15
and/or other materials provided with the distribution.
16
Neither the name of the President and Fellows of Harvard College
17
nor the names of its contributors may be used to endorse or promote
18
products derived from this software without specific prior written
19
permission.
20
21
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33
=========================================================================*/
34
#include "
QGoSynchronizedView3D.h
"
35
36
#include "
QGoSynchronizedView3DCallbacks.h
"
37
#include "vtkImageData.h"
38
#include "
vtkViewImage3D.h
"
39
#include "
vtkViewImage2D.h
"
40
#include "vtkEventQtSlotConnect.h"
41
#include "
QGoImageView3D.h
"
42
#include "
QGoSynchronizedViewManager.h
"
43
#include "
SnapshotHelper.h
"
44
45
//--------------------------------------------------------------------------
46
QGoSynchronizedView3D::QGoSynchronizedView3D
(
QString
iViewName,
47
QWidget
*iParent) :
48
QGoSynchronizedView
(iViewName, iParent),
49
m_View (NULL)
50
{
51
}
52
53
//--------------------------------------------------------------------------
54
QGoSynchronizedView3D::
55
~QGoSynchronizedView3D
()
56
{
57
// remove the SynchronizedView from the orchestra
58
if
(
m_ViewManager
)
59
{
60
m_ViewManager
->
removeSynchronizedView3D
(
this
);
61
m_ViewManager
= NULL;
62
}
63
64
// delete the view if any
65
if
(
m_View
)
66
{
67
// we delete the viewer
68
delete
(
m_View
);
69
m_View
= NULL;
70
}
71
}
72
73
//--------------------------------------------------------------------------
74
/* Update the viewer contained in the widget */
75
void
76
QGoSynchronizedView3D::Update
()
77
{
78
if
(
m_View
)
79
{
80
this->
m_View
->
Update
();
81
// in addition to standard parameters, we don't want to interpolate data
82
this->
m_View
->
SetInterpolate
(0);
83
}
84
}
85
86
//--------------------------------------------------------------------------
87
void
88
QGoSynchronizedView3D::PrintOs
(ostream & os)
89
{
90
// if we have an imageview, the we print its image information
91
if
(
m_Image
!= NULL )
92
{
93
os <<
"SynchronizedView 3D "
<<
this
<<
" contains :"
<< std::endl;
94
m_Image
->Print(os);
95
}
96
else
97
{
98
os <<
"SynchronizedView 3D "
<<
this
<<
" contains no Image :"
<< std::endl;
99
}
100
}
101
102
//--------------------------------------------------------------------------
103
/* returns the type of SynchronizedView (2 for 2D, 3 for 3D) */
104
int
105
QGoSynchronizedView3D::GetSynchronizedViewType
()
106
{
107
return
3;
108
}
109
110
//--------------------------------------------------------------------------
111
void
112
QGoSynchronizedView3D::SetImage
(vtkImageData *iImage)
113
{
114
if
( iImage )
115
{
116
// if there is no viewer, we create one
117
if
( !
m_View
)
118
{
119
createViewer
();
120
}
121
// set the image to the current view
122
m_View
->
SetImage
(iImage);
123
// update current image
124
m_Image
= iImage;
125
this->
Update
();
126
}
127
}
128
129
//--------------------------------------------------------------------------
130
void
131
QGoSynchronizedView3D::Render
()
132
{
133
if
(
HasViewer
() )
134
{
135
m_View
->
GetImageViewer
(0)->
Render
();
136
m_View
->
GetImageViewer
(1)->
Render
();
137
m_View
->
GetImageViewer
(2)->
Render
();
138
m_View
->
GetImageViewer3D
()->
Render
();
139
}
140
}
141
142
//--------------------------------------------------------------------------
143
void
144
QGoSynchronizedView3D::Render
(
const
int
& iId)
145
{
146
if
(
HasViewer
() )
147
{
148
if
( ( iId >= 0 ) && ( iId <= 2 ) )
// if we want to render one of the 2D
149
// view
150
{
151
m_View
->
GetImageViewer
(iId)->
Render
();
152
}
153
else
// if we want to render the 3D view
154
{
155
m_View
->
GetImageViewer3D
()->
Render
();
156
}
157
}
158
}
159
160
//--------------------------------------------------------------------------
161
/* get the camera of the current viewer */
162
vtkCamera *
163
QGoSynchronizedView3D::GetCamera
()
164
{
165
int
currentView =
GetFullScreenView
();
166
167
if
(
HasViewer
() )
168
{
169
if
( ( currentView >= 1 ) && ( currentView <= 3 ) )
170
{
171
return
m_View
->
GetImageViewer
(currentView)
172
->GetRenderer()
173
->GetActiveCamera();
174
}
175
else
176
{
177
return
m_View
->
GetImageViewer3D
()
178
->GetRenderer()
179
->GetActiveCamera();
180
}
181
}
182
return
NULL;
183
}
184
185
//--------------------------------------------------------------------------
186
/* get the camera of the current viewer */
187
vtkCamera *
188
QGoSynchronizedView3D::GetCamera
(
const
int
& iId)
189
{
190
if
(
HasViewer
() )
191
{
192
if
( ( iId >= 0 ) && ( iId <= 2 ) )
193
{
194
return
m_View
->
GetImageViewer
(iId)
195
->GetRenderer()
196
->GetActiveCamera();
197
}
198
else
199
{
200
return
m_View
->
GetImageViewer3D
()
201
->GetRenderer()
202
->GetActiveCamera();
203
}
204
}
205
return
NULL;
206
}
207
208
//--------------------------------------------------------------------------
209
/* true if the widget has a viewer */
210
bool
211
QGoSynchronizedView3D::HasViewer
()
212
{
213
return
(
m_View
!= NULL );
214
}
215
216
//--------------------------------------------------------------------------
217
int
218
QGoSynchronizedView3D::GetFullScreenView
()
219
{
220
if
(
HasViewer
() )
221
{
222
return
m_View
->
GetFullScreenView
();
223
}
224
else
225
{
226
return
-1;
227
}
228
}
229
230
//--------------------------------------------------------------------------
231
QGoImageView3D
*
232
QGoSynchronizedView3D::GetImageView
()
233
{
234
if
(
HasViewer
() )
235
{
236
return
m_View
;
237
}
238
else
239
{
240
return
NULL;
241
}
242
}
243
244
//--------------------------------------------------------------------------
245
QString
246
QGoSynchronizedView3D::SnapshotViewXY
(
const
GoFigure::FileType
& iType,
const
QString
& iBaseName)
247
{
248
QGoImageView3D
*viewer = this->
GetImageView
();
249
250
if
(
HasViewer
() )
251
{
252
return
viewer->
SnapshotViewXY
(iType, iBaseName);
253
}
254
else
255
{
256
return
QString
();
257
}
258
}
259
260
//--------------------------------------------------------------------------
261
QString
262
QGoSynchronizedView3D::SnapshotViewXZ
(
const
GoFigure::FileType
& iType,
const
QString
& iBaseName)
263
{
264
QGoImageView3D
*viewer = this->
GetImageView
();
265
266
if
( viewer )
267
{
268
return
viewer->
SnapshotViewXZ
(iType, iBaseName);
269
}
270
else
271
{
272
return
QString
();
273
}
274
}
275
276
//--------------------------------------------------------------------------
277
QString
278
QGoSynchronizedView3D::SnapshotViewYZ
(
const
GoFigure::FileType
& iType,
const
QString
& iBaseName)
279
{
280
QGoImageView3D
*viewer = this->
GetImageView
();
281
282
if
( viewer )
283
{
284
return
viewer->
SnapshotViewYZ
(iType, iBaseName);
285
}
286
else
287
{
288
return
QString
();
289
}
290
}
291
292
//--------------------------------------------------------------------------
293
QString
294
QGoSynchronizedView3D::SnapshotViewXYZ
(
const
GoFigure::FileType
& iType,
const
QString
& iBaseName)
295
{
296
QGoImageView3D
*viewer = this->
GetImageView
();
297
298
if
( viewer )
299
{
300
return
viewer->
SnapshotViewXYZ
(iType, iBaseName);
301
}
302
else
303
{
304
return
QString
();
305
}
306
}
307
308
//--------------------------------------------------------------------------
309
void
310
QGoSynchronizedView3D::SetFullScreenView
(
const
int
& iId)
311
{
312
if
(
HasViewer
() )
313
{
314
m_View
->
SetFullScreenView
(iId);
315
}
316
}
317
318
//--------------------------------------------------------------------------
319
void
320
QGoSynchronizedView3D::SetFullXYScreenView
()
321
{
322
SetFullScreenView
(1);
323
}
324
325
//--------------------------------------------------------------------------
326
void
327
QGoSynchronizedView3D::SetFullXZScreenView
()
328
{
329
SetFullScreenView
(2);
330
}
331
332
//--------------------------------------------------------------------------
333
void
334
QGoSynchronizedView3D::SetFullYZScreenView
()
335
{
336
SetFullScreenView
(3);
337
}
338
339
//--------------------------------------------------------------------------
340
void
341
QGoSynchronizedView3D::SetFullXYZScreenView
()
342
{
343
SetFullScreenView
(4);
344
}
345
346
//--------------------------------------------------------------------------
347
void
348
QGoSynchronizedView3D::SetQuadView
()
349
{
350
SetFullScreenView
(0);
351
}
352
353
// ########################################################################
354
// Private
355
356
//--------------------------------------------------------------------------
357
/* delete the viewer contained in the widget */
358
void
359
QGoSynchronizedView3D::deleteViewer
()
360
{
361
// if there is no viewer
362
if
(
m_View
)
363
{
364
// delete object
365
delete
(
m_View
);
366
// set pointer to NULL
367
m_View
= NULL;
368
}
369
}
370
371
//--------------------------------------------------------------------------
372
/* Create the viewer in the widget */
373
void
374
QGoSynchronizedView3D::createViewer
()
375
{
376
// if there is no viewer
377
if
( !
HasViewer
() )
378
{
379
// we create one
380
m_View
=
new
QGoImageView3D
(
this
);
381
dynamic_cast<
QGoImageView3D
*
>
382
(
m_View
)->
setContentsMargins
(1, 1, 1, 1);
383
// setup position of the widget
384
gridLayout->addWidget(
m_View
);
385
}
386
}
Generated on Mon May 27 2013 08:47:30 for GOFIGURE2 by
1.8.1.2