GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GoTransferFunctionEditorWidget.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the demonstration applications of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** Commercial Usage
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
15 **
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23 **
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27 **
28 ** GNU General Public License Usage
29 ** Alternatively, this file may be used under the terms of the GNU
30 ** General Public License version 3.0 as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL included in the
32 ** packaging of this file. Please review the following information to
33 ** ensure the GNU General Public License version 3.0 requirements will be
34 ** met: http://www.gnu.org/copyleft/gpl.html.
35 **
36 ** If you have questions regarding the use of this file, please contact
37 ** Nokia at qt-info@nokia.com.
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 
43 /*=========================================================================
44  Modifications were made by the GoFigure Dev. Team.
45  while at Megason Lab, Systems biology, Harvard Medical school, 2009-11
46 
47  Copyright (c) 2009-11, President and Fellows of Harvard College.
48  All rights reserved.
49 
50  Redistribution and use in source and binary forms, with or without
51  modification, are permitted provided that the following conditions are met:
52 
53  Redistributions of source code must retain the above copyright notice,
54  this list of conditions and the following disclaimer.
55  Redistributions in binary form must reproduce the above copyright notice,
56  this list of conditions and the following disclaimer in the documentation
57 // and/or other materials provided with the distribution.
58  Neither the name of the President and Fellows of Harvard College
59  nor the names of its contributors may be used to endorse or promote
60  products derived from this software without specific prior written
61  permission.
62 
63  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
64  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
65  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
66  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
67  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
68  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
69  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
70  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
71  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
72  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
73  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74 
75  =========================================================================*/
76 #ifndef __GoTransferFunctionEditorWidget_h
77 #define __GoTransferFunctionEditorWidget_h
78 
79 #include "QGoGUILibConfigure.h"
80 
81 // Qt
82 #include <QWidget>
83 #include <QBrush>
84 
85 //std
86 #include <vector>
87 #include <map>
88 
89 // gofigure
90 class HoverPoints;
92 
93 // qt
94 class QPolygonF;
95 class QTextStream;
96 class QPushButton;
97 class QSlider;
98 
99 //vtk
100 class vtkLookupTable;
101 class vtkImageAccumulate;
102 class vtkPiecewiseFunction;
103 
105 {
106  Q_OBJECT
107 public:
108  explicit GoTransferFunctionEditorWidget( QString iChannel,
109  const std::vector<double>& iColor,
110  std::vector<int> iLUTParameters,
111  double iMax,
112  QWidget *parent = 0 );
113 
119  void AddPoints( const std::map<unsigned int, unsigned int >& iPoints);
120 
125  void AddLookupTable(vtkLookupTable* iLUT);
126 
134  void AddHistogram(vtkImageAccumulate* iHistogram);
135 
143  void AddColor(const std::vector<double>& iColor);
144 
149  void AddName(QString iChannel);
150 
154  void AddOpacityTransferFunction(vtkPiecewiseFunction* iOpacity);
155 
160  void SetMaximumValue( double iMax);
161 
162 public slots:
167  void UpdateLUT();
174  void ChangeColor();
175 
179  void ResetLUT();
180 
185  void ApplyChanges();
186 
187  // opacity TF
188  // might be buggy, to be checked
189  void updateOpacityTF();
190 
195  void ShowHistogram(bool iShow);
196 
206  void AdjustWindowLevel(double iMin, double iMax);
207 
208 
214  void updateSliders(int iValue);
215 
216 signals:
220  void updateVisualization();
221 
226  std::map< unsigned int, unsigned int>,
227  QColor,
228  int,
229  int,
230  int);
231 
232 private:
239  const QPolygonF& iPoints, std::map< unsigned int, unsigned int>& iMap);
240 
247  const std::map< unsigned int, unsigned int>& iMap, QPolygonF& iPoints);
248 
253 
258 
263 
268 
273 
278 
283 
288 
292  vtkLookupTable *m_LUT;
293 
297  vtkPiecewiseFunction *m_OpacityTF;
298 
303 
307  double m_Max;
308 };
309 
310 #endif
QSlider * m_MinSlider
Slider to modify the min value.
void ChangeColor()
Opens a QColorDialog. If chosen color is valid, then: 1- Modify push button color 2- Modify m_TFWidge...
GoTransferFunctionWidget * m_TFWidget
The widget containing the shade, histogram, LUT and opacity TF.
void updateSliders(int iValue)
When Min and Max sliders change, update the value of the one which sent the signal, if it doesn't overlap with the other one. param[in] iValue new value. Else modify its value back to original.
GoTransferFunctionEditorWidget(QString iChannel, const std::vector< double > &iColor, std::vector< int > iLUTParameters, double iMax, QWidget *parent=0)
void AddName(QString iChannel)
Add name of the channel to the GoTransferFunctionEditorWidget.
QVector< qreal > m_Histogram
Histogram of the current channel for current time point.
void AddLookupTable(vtkLookupTable *iLUT)
Add LUT to the GoTransferFunctionEditorWidget.
double m_Max
Maximum pixel intensity for the channel at current time point.
void AddPoints(const std::map< unsigned int, unsigned int > &iPoints)
Add points to both LUT and Opacity transfer function.
vtkLookupTable * m_LUT
Pointer to the channel LUT.
void AdjustWindowLevel(double iMin, double iMax)
Adjust window/level between the input values. LUT (using the gamma value) will be calculated between ...
void ShowHistogram(bool iShow)
Show/hide histogram in m_TFWidget.
void ResetLUT()
Reset the channel to its original state (color, LUT, opacity)
QColor m_Color_original
Original color of the channel.
void UpdateLUT()
Update the LUT based on the min, max and gamma. It updates the m_TFWidget and the visualition...
void AddHistogram(vtkImageAccumulate *iHistogram)
1- Add Histogram to the GoTransferFunctionEditorWidget 2- Convert it to QVector<qreal> 3- Add it to t...
void AddColor(const std::vector< double > &iColor)
Add color of the channel to the GoTransferFunctionEditorWidget. It modifies m_Color. m_Color is necessary for reset and to initialize the m_TFWidget;.
vtkPiecewiseFunction * m_OpacityTF
Pointer to the channel opacity LUT.
QPushButton * m_ColorPushButton
Push button to modify the color.
void ApplyChanges()
Apply changes (color, min, manx, gamma, opacity TF) to the channel. It modifies informations relative...
void ConvertSTDMapToQPolygonF(const std::map< unsigned int, unsigned int > &iMap, QPolygonF &iPoints)
Convenience method to convert a std::map to a QPolygonF.
QColor m_Color
Current color of the channel.
void AddOpacityTransferFunction(vtkPiecewiseFunction *iOpacity)
Add pointer to the opacity TF for a direct access.
QObject * parent() const
void ConvertQPolygonFToSTDMap(const QPolygonF &iPoints, std::map< unsigned int, unsigned int > &iMap)
Convenience method to convert a QPolygonF to a std::map.
QSlider * m_MaxSlider
Slider to modify the max value.
void updateVisualization()
Modify the visualization when the LUT or opacity changed.
QSlider * m_GammaSlider
Slider to modify the value of gamma.
void UpdateImageStructure(QString, std::map< unsigned int, unsigned int >, QColor, int, int, int)
Modify the image structure when apply clicked.