GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QGoTabImageViewNDBase.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 
35 #include "QGoTabImageViewNDBase.h"
37 
38 #include "vtkImageData.h"
39 #include "vtkSmartPointer.h"
40 #include "vtkImageExtractComponents.h"
41 
42 //--------------------------------------------------------------------------
45  m_Image(0)
46 {
47 }
48 
49 //--------------------------------------------------------------------------
50 
51 //--------------------------------------------------------------------------
54 {
55 }
56 
57 //--------------------------------------------------------------------------
58 
59 //--------------------------------------------------------------------------
64 void QGoTabImageViewNDBase::SetImage(vtkImageData *iImage)
65 {
66  if ( !iImage )
67  {
68  std::cerr << "QGoTabImageViewNDBase::SetImage( 0x0 )" << std::endl;
69  return;
70  }
71 
72  m_Image = iImage;
73 
74  int n = m_Image->GetNumberOfScalarComponents();
75  //this->m_NavigationDockWidget->SetNumberOfChannels(n);
76 
77  if ( n != 1 )
78  {
79  if ( ( n == 3 ) || ( n == 4 ) )
80  {
81  //this->m_NavigationDockWidget->SetChannel( 0, tr("Red") );
82  //this->m_NavigationDockWidget->SetChannel( 1, tr("Green") );
83  //this->m_NavigationDockWidget->SetChannel( 2, tr("Blue") );
84 
85  if ( n == 4 )
86  {
87  //this->m_NavigationDockWidget->SetChannel( 3, tr("Alpha") );
88  }
89  }
90  else
91  {
92  for ( int i = 0; i < n; i++ )
93  {
94  //this->m_NavigationDockWidget->SetChannel(i);
95  }
96  }
97  }
98 
99  int extent[6];
100  m_Image->GetExtent(extent);
101 
103 
104  this->m_NavigationDockWidget->SetXMinimumAndMaximum(extent[0], extent[1]);
105  this->m_NavigationDockWidget->SetXSlice( ( extent[0] + extent[1] ) / 2 );
106 
107  this->m_NavigationDockWidget->SetYMinimumAndMaximum(extent[2], extent[3]);
108  this->m_NavigationDockWidget->SetYSlice( ( extent[2] + extent[3] ) / 2 );
109 
110  this->m_NavigationDockWidget->SetZMinimumAndMaximum(extent[4], extent[5]);
111  this->m_NavigationDockWidget->SetZSlice( ( extent[4] + extent[5] ) / 2 );
112 }
113 
114 //--------------------------------------------------------------------------
115 
116 //--------------------------------------------------------------------------
117 vtkImageData *
119 {
120  return m_Image;
121 }
122 
123 //--------------------------------------------------------------------------
124 
125 //--------------------------------------------------------------------------
131 {
132  if ( iChecked )
133  {
135  }
136  else
137  {
138  int ch = 0;//this->m_NavigationDockWidget->GetCurrentChannel();
139  if ( ch != -1 )
140  {
141  vtkSmartPointer< vtkImageExtractComponents > extract =
142  vtkSmartPointer< vtkImageExtractComponents >::New();
143  extract->SetInput(m_Image);
144  extract->SetComponents(ch);
145  extract->Update();
146 
147  this->SetImageToImageViewer( extract->GetOutput() );
148  }
149  }
150 }
151 
152 //--------------------------------------------------------------------------
153 
154 //--------------------------------------------------------------------------
160 {
161  if ( m_Image )
162  {
163  if ( iChannel != -1 )
164  {
165  vtkSmartPointer< vtkImageExtractComponents > extract =
166  vtkSmartPointer< vtkImageExtractComponents >::New();
167  extract->SetInput(m_Image);
168  extract->SetComponents(iChannel);
169  extract->Update();
170 
171  this->SetImageToImageViewer( extract->GetOutput() );
172  }
173  }
174 }
175 
176 //--------------------------------------------------------------------------
virtual void SetImageToImageViewer(vtkImageData *image)=0
QGoTabImageViewNDBase(QWidget *parent=0)
Constructor.
void SetZMinimumAndMaximum(const int &iMin, const int &iMax)
Set the extent of the images in the Z direction.
void SetXMinimumAndMaximum(const int &iMin, const int &iMax)
Set the extent of the images in the X direction.
vtkSmartPointer< vtkImageData > m_Image
void ShowOneChannel(int iChannel)
virtual void SetImage(vtkImageData *iImage)
Set the image to be displaid.
void SetYMinimumAndMaximum(const int &iMin, const int &iMax)
Set the extent of the images in the Y direction.
QGoNavigationDockWidget * m_NavigationDockWidget
void ShowAllChannels(bool iChecked)
virtual ~QGoTabImageViewNDBase()
Destructor.