GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GoTransferFunctionEditorWidget.cxx
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 
78 
79 // Gofigure
81 #include "QGoLUTDialog.h"
82 #include "hoverpoints.h"
83 
84 //qt
85 #include <QSpacerItem>
86 #include <QColorDialog>
87 
88 //vtk
89 #include "vtkLookupTable.h"
90 #include "vtkImageAccumulate.h"
91 #include "vtkImageData.h"
92 #include "vtkPointData.h"
93 #include "vtkPiecewiseFunction.h"
94 
95 // std
96 #include <iostream>
97 
98 //-------------------------------------------------------------------------
99 
102  const std::vector<double>& iColor,
103  std::vector<int> iLUTParameters,
104  double iMax,
105  QWidget *parent ) : QWidget(parent )
106 {
107  // set current color of the channel
108  m_Color.setRedF(iColor[0]/255);
109  m_Color.setGreenF(iColor[1]/255);
110  m_Color.setBlueF(iColor[2]/255);
111  m_Color.setAlphaF(iColor[3]/255);
112 
113  // save original color of the channel if the user want to reset it
115 
116  // set the maximum value in the image
117  m_Max = iMax;
118  // init LUT to NULL
119  m_LUT = NULL;
120  // set channel name
121  m_Channel = iChannel;
122 
123  // global layout of the widget
124  QVBoxLayout *vbox = new QVBoxLayout(this);
125  vbox->setSpacing(1);
126  vbox->setMargin(1);
127 
128  // first part of the widget: the color
129  /*
130  ---------------------------
131  | _____________ |
132  | Color: |_P_U_S_H_____| |
133  | |
134  ---------------------------
135  */
136  // items
137  //label
138  QLabel *color = new QLabel("Color: ");
139  // push button
140  m_ColorPushButton = new QPushButton(this);
141  m_ColorPushButton->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
142  QString style = "background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop: 0 black, stop: 1 rgb(%1, %2, %3)); border-radius: 4px;";
144  style.arg(m_Color.red()).arg(m_Color .green()).arg(m_Color.blue()));
145  m_ColorPushButton->setToolTip("Click to modify the color of this channel");
146  // add items to layout
147  QHBoxLayout *colorLayout = new QHBoxLayout;
148  colorLayout->addWidget(color);
149  colorLayout->addWidget(m_ColorPushButton);
150  // connect signals
151  connect(m_ColorPushButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
152 
153  // add layout to the widget
154  vbox->addLayout(colorLayout);
155 
156 
157  // second part of the widget: the TH Widget
158  /*
159  -----------------------------
160  | |------------------|--| |
161  | _____________________ |
162  | | | |
163  | | | |
164  | | | |
165  | | | |
166  | |_____________________| |
167  | |
168  | |---|-----------------| |
169  -----------------------------
170  */
171  // items
172  // Left spacer
173  QSpacerItem* spacer_red1 = new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Minimum);
174  // right spacer
175  QSpacerItem* spacer_red2 = new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Minimum);
176  // TF widget
178  m_Color,
179  m_Max,
180  this);
181  //min slider
182  m_MinSlider = new QSlider(this);
183  m_MinSlider->setObjectName("min");
184  m_MinSlider->setOrientation(Qt::Horizontal);
186  m_MinSlider->setValue(iLUTParameters[1]);
187  m_MinSlider->setStyleSheet("QSlider::groove:horizontal {border: 1px solid #bbb;background: rgba(0, 0, 0, 0);height: 4px;position: absolute; right: 10px;left: 10px; }QSlider::handle:horizontal {image: url(/home/nr52/gitroot/gofigure/Resources/widget/arrow_up.png);width: 20px;height: 6px;margin-top: -2px;margin-bottom: -2px; right: -10px; left:-10px; border: 1px solid black; background: rgba(255, 255, 255, 200); border-radius: 4px;}QSlider::sub-page:horizontal {background: #909090;border: 1px solid black;}QSlider::add-page:horizontal {background: rgba(0, 0, 0, 0);border: 1px solid black;}");
188  // max slider
189  m_MaxSlider = new QSlider(this);
190  m_MaxSlider->setObjectName("max");
191  m_MaxSlider->setOrientation(Qt::Horizontal);
194  m_MaxSlider->setStyleSheet("QSlider::groove:horizontal {border: 1px solid #bbb;background: rgba(0, 0, 0, 0);height: 4px;position: absolute; right: 10px;left: 10px; }QSlider::handle:horizontal {image: url(/home/nr52/gitroot/gofigure/Resources/widget/arrow_down.png);width: 20px;height: 6px;margin-top: -2px;margin-bottom: -2px; right: -10px; left:-10px; border: 1px solid black; background: rgba(255, 255, 255, 200); border-radius: 4px;}QSlider::sub-page:horizontal {background: rgba(0, 0, 0, 0);border: 1px solid black;}QSlider::add-page:horizontal {background: #909090;border: 1px solid black;}");
195  // more spacer
196  QSpacerItem* spacerShade1 =
197  new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Minimum);
198  // more spacer
199  QSpacerItem* spacerShade2 =
200  new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Minimum);
201  // connect signals
202  connect(m_MinSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSliders(int)));
203  connect(m_MaxSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSliders(int)));
204  // add items to layout 1
205  QHBoxLayout *m_TFWidget_layout = new QHBoxLayout;
206  m_TFWidget_layout->addSpacerItem(spacer_red1);
207  m_TFWidget_layout->addWidget(m_TFWidget);
208  m_TFWidget_layout->addSpacerItem(spacer_red2);
209  // add items to layout 2
210  QVBoxLayout* shadeVerticalLayout = new QVBoxLayout;
211  shadeVerticalLayout->addWidget(m_MaxSlider);
212  shadeVerticalLayout->addLayout(m_TFWidget_layout);
213  shadeVerticalLayout->addWidget(m_MinSlider);
214  // add items to layout 3
215  QHBoxLayout* shadeHorizontalLayout= new QHBoxLayout;
216  shadeHorizontalLayout->addItem(spacerShade1);
217  shadeHorizontalLayout->addLayout(shadeVerticalLayout);
218  shadeHorizontalLayout->addItem(spacerShade2);
219  // connect signals
220  connect(m_TFWidget, SIGNAL(opacityChanged()), this, SLOT(updateOpacityTF()));
221 
222  // add layout to the widget
223  vbox->addLayout(shadeHorizontalLayout);
224 
225 
226  // third part: the gamma slider
227  /*
228  ------------------------------
229  | Gamma: |---|------------| |
230  ------------------------------
231  */
232  // items
233  // gamma label
234  QLabel* gammaName = new QLabel((QChar)(0x0263));
235  // gamma slider
236  m_GammaSlider = new QSlider(this);
237  m_GammaSlider->setOrientation(Qt::Horizontal);
240  m_GammaSlider->setValue(iLUTParameters[0]);
241  // connect signals
242  connect(m_GammaSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdateLUT()));
243  // add items to layout
244  QHBoxLayout *gammaLayout = new QHBoxLayout;
245  gammaLayout->addWidget(gammaName);
246  gammaLayout->addWidget(m_GammaSlider);
247 
248  // add layout to the widget
249  vbox->addLayout(gammaLayout);
250 
251 
252  // fourth part: the visibility checkboxes
253  /*
254  ------------------------------
255  | + Color TF |
256  | - Opacity TF |
257  | + Log Histogram |
258  ------------------------------
259  */
260  // items
261  // color TF checkbox
262  QCheckBox* tfCB = new QCheckBox("Color Transfer Function");
263  tfCB->setChecked(true);
264  QString style5 = "color: black; border: 1px solid rgb(0, 0, 0); background-color: rgba(255, 255, 255, 150); border-radius: 4px;";
265  tfCB->setStyleSheet(style5);
266  // opacity TF checkbox
267  QCheckBox* tfoCB = new QCheckBox("Opacity Transfer Function");
268  tfoCB->setChecked(false);
269  QString style2 = "color: white; border: 1px solid rgb(0, 0, 0); background-color: rgba(0, 0, 0, 150); border-radius: 4px;";
270  tfoCB->setStyleSheet(style2);
271  // histogram checkbox
272  QCheckBox* histogramCB = new QCheckBox("Log Histogram");
273  histogramCB->setChecked(true);
274  QString style3 = "border: 1px solid rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0); border-radius: 4px;";
275  histogramCB->setStyleSheet(style3);
276  // connect signals
277  connect(tfoCB, SIGNAL(clicked(bool)), m_TFWidget, SIGNAL(enableOpacityTF(bool)));
278  connect(tfCB, SIGNAL(clicked(bool)), m_TFWidget, SIGNAL(enableLUTCurve(bool)));
279  connect(histogramCB, SIGNAL(clicked(bool)), this, SLOT(ShowHistogram(bool)));
280 
281  // add items to the widget
282  vbox->addWidget(tfCB);
283  vbox->addWidget(tfoCB);
284  vbox->addWidget(histogramCB);
285 
286  // fith part: apply/reset pushbutton
287  /*
288  ---------------------------
289  | _________ _________ |
290  | |_A_PPL_Y_| |_R_ESE_T_| |
291  | |
292  ---------------------------
293  */
294  // items
295  // apply pushbutton
296  QPushButton *okPushButton = new QPushButton("Apply", this);
297  // reset pushbutton
298  QPushButton *ResetLUTPushButton = new QPushButton("Reset", this);
299  // connect signals
300  connect(okPushButton, SIGNAL(released()), this, SLOT(ApplyChanges()));
301  connect(ResetLUTPushButton, SIGNAL(pressed()), this, SLOT(ResetLUT()));
302  // layout
304  layout->addWidget(okPushButton);
305  layout->addWidget(ResetLUTPushButton);
306 
307  // add layout to widget
308  vbox->addLayout(layout);
309 
310  this->setLayout(vbox);
311 }
312 //-------------------------------------------------------------------------
313 
314 //-------------------------------------------------------------------------
315 void
318 {
319  if(m_LUT)
320  {
321  qreal side = m_GammaSlider->value()/(100);
322  int ope = pow(-1, side + 1);
323  qreal value = (qreal)(ope*(m_GammaSlider->value()-100) + ope);
324 
325  qreal gamma_value;
326  if(value > 2)
327  {
328  qreal temp = log(value);
329  gamma_value = pow(temp, ope);
330  }
331  else
332  {
333  gamma_value = 1;
334  }
335 
336  // update the LUT
338  gamma_value,
339  (qreal)m_MinSlider->value(),
340  (qreal)m_MaxSlider->value());
341 
342  // send signal to update the visualization
343  emit updateVisualization();
344  }
345 }
346 //-------------------------------------------------------------------------
347 
348 //-------------------------------------------------------------------------
349 void
351 AddPoints( const std::map< unsigned int, unsigned int>& iPoints)
352 {
353  // points
354  QPolygonF points;
355  // convert points
356  ConvertSTDMapToQPolygonF(iPoints, points);
357  // add points to the opacity TF
359  // add points to the LUT
360  m_TFWidget->AddPointsToLUT(points);
361  // update LUT in widget and visualization
362  UpdateLUT();
363 }
364 //-------------------------------------------------------------------------
365 
366 //-------------------------------------------------------------------------
367 void
369 ConvertSTDMapToQPolygonF(const std::map< unsigned int, unsigned int>& iMap,
370  QPolygonF& iPoints)
371 {
372  // all shades have same width and height
373  qreal width = m_TFWidget->width();
374  qreal height = m_TFWidget->height();
375 
376  std::map< unsigned int, unsigned int>::const_iterator it0;
377  std::map< unsigned int, unsigned int>::const_iterator it255;
378  it0 = iMap.begin();
379  it255 = iMap.end();
380 
381  // check x and y
382  while(it0!=it255)
383  {
384  iPoints << QPointF((qreal)(it0->first)*width/m_Max,
385  height*(1-(qreal)(it0->second)/m_Max));
386  ++it0;
387  }
388 }
389 //-------------------------------------------------------------------------
390 
391 //-------------------------------------------------------------------------
392 void
394 AddLookupTable(vtkLookupTable* iLUT)
395 {
396  m_LUT = iLUT;
397 }
398 //-------------------------------------------------------------------------
399 
400 //-------------------------------------------------------------------------
401 void
403 AddOpacityTransferFunction(vtkPiecewiseFunction* iOpacity)
404 {
405  m_OpacityTF = iOpacity;
406 }
407 //-------------------------------------------------------------------------
408 
409 //-------------------------------------------------------------------------
410 void
412 AddHistogram(vtkImageAccumulate* iHistogram)
413 {
414  // get the x range
415  int x_range = iHistogram->GetOutput()->GetNumberOfPoints();
416  // get the y values
417  vtkDataArray* scalars = iHistogram->GetOutput()->GetPointData()->GetScalars();
418  // get the scalar values to normalize
419  double* range = iHistogram->GetOutput()->GetScalarRange();
420 
421  QVector<qreal> histogram;
422 
423  for(int i=0; i<x_range; ++i)
424  {
425  double value;
426  value = scalars->GetTuple1(i);
427  histogram.push_back(log(value)/log(range[1]));
428  }
429 
430  m_Histogram = histogram;
431 
432  // add histogram the the TF Widget
434 
435  // update the widget so the histogram is visible
436  m_TFWidget->update();
437 }
438 //-------------------------------------------------------------------------
439 
440 //-------------------------------------------------------------------------
441 void
443 AddColor(const std::vector<double>& iColor)
444 {
445  m_Color.setRedF(iColor[0]/255);
446  m_Color.setGreenF(iColor[1]/255);
447  m_Color.setBlueF(iColor[2]/255);
448  m_Color.setAlphaF(iColor[3]/255);
449 }
450 //-------------------------------------------------------------------------
451 
452 //-------------------------------------------------------------------------
453 void
455 AddName(QString iChannel)
456 {
457  m_Channel = iChannel;
458 }
459 //-------------------------------------------------------------------------
460 
461 //-------------------------------------------------------------------------
462 void
465 {
466  // reset the color
468  // reset the opacity TF
470  // reset the color
472 
473  // reset button color
474  QString style = "background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop: 0 black, stop: 1 rgb(%1, %2, %3)); border-radius: 4px;";
476  style.arg(m_Color.red()).arg(m_Color .green()).arg(m_Color.blue()));
477 
478  // Reset Gamma, Min and Max
479  m_GammaSlider->setValue(100);
480  m_MinSlider->setValue(0);
482  // Update LUT
483  UpdateLUT();
484 
485  // might be buggy
486  updateOpacityTF();
487 }
488 //-------------------------------------------------------------------------
489 
490 //-------------------------------------------------------------------------
491 void
494 {
495  // opacity
496  std::map< unsigned int, unsigned int> pointsVector;
497  QPolygonF opacityPoints = m_TFWidget->points();
498  ConvertQPolygonFToSTDMap(opacityPoints, pointsVector);
499 
500  // send values to the image structure
502  pointsVector,
503  m_Color,
504  m_MinSlider->value(),
505  m_MaxSlider->value(),
506  m_GammaSlider->value());
507 }
508 //-------------------------------------------------------------------------
509 
510 //-------------------------------------------------------------------------
511 void
513 ConvertQPolygonFToSTDMap(const QPolygonF& iPoints, std::map< unsigned int, unsigned int>& iMap)
514 {
515  qreal width = m_TFWidget->width();
516  qreal height = m_TFWidget->height();
517  int numberOfPoints = iPoints.size();
518 
519  if(numberOfPoints>m_Max)
520  {
521  qDebug() << "Too many points: " << numberOfPoints << " points";
522  return;
523  }
524 
525  for(int i=0; i<numberOfPoints; ++i)
526  {
527  unsigned int x = (iPoints.at(i).x())*m_Max/width;
528  unsigned int y = (1-(iPoints.at(i).y())/height)*m_Max;
529  iMap[x] = y;
530  }
531 }
532 //-------------------------------------------------------------------------
533 
534 //-------------------------------------------------------------------------
535 void
538 {
539  // all shades have same width and height
540  qreal width = m_TFWidget->width();
541  qreal height = m_TFWidget->height();
542  int numberOfPoints = m_TFWidget->points().size();
543 
544  m_OpacityTF->Initialize();
545 
546  for(int i=0; i<numberOfPoints; ++i)
547  {
548  // x 0 to 255
549  double x = (m_TFWidget->points().at(i).x())*m_Max/width;
550  // y 0 to 1
551  double y = (1-(m_TFWidget->points().at(i).y())/height);
552  m_OpacityTF->AddPoint(x, y);
553  }
554  m_OpacityTF->Modified();
555 
556  emit updateVisualization();
557 }
558 //-------------------------------------------------------------------------
559 
560 //-------------------------------------------------------------------------
561 void
564 {
565  QColor color = QColorDialog::getColor();
566  // if we selected a color and clicked on "OK"
567  if(color.isValid())
568  {
569  m_Color = color;
570  }
571 
572  // update button
573  QString style = "background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop: 0 black, stop: 1 rgb(%1, %2, %3)); border-radius: 4px;";
575  style.arg(m_Color.red()).arg(m_Color .green()).arg(m_Color.blue()));
576 
577  // update shade
579 
580  // update LUT
581  UpdateLUT();
582 }
583 //-------------------------------------------------------------------------
584 
585 //-------------------------------------------------------------------------
586 void
588 ShowHistogram(bool iShow){
589 
590  if(iShow)
591  {
593  }
594  else
595  {
596  QVector<qreal> removeHisto;
597  m_TFWidget->SetHistogram(removeHisto);
598  }
599 
600  // to be tested might be buggy
601  // update might be better?
602  m_TFWidget->repaint();
603 }
604 //-------------------------------------------------------------------------
605 
606 //-------------------------------------------------------------------------
607 void
609 AdjustWindowLevel(double iMin, double iMax){
610 
611  this->m_MinSlider->blockSignals(true);
612  this->m_MinSlider->setValue(iMin);
613  this->m_MinSlider->blockSignals(false);
614  this->m_MaxSlider->blockSignals(true);
615  this->m_MaxSlider->setValue(iMax);
616  this->m_MaxSlider->blockSignals(false);
617 
618  UpdateLUT();
619 }
620 //-------------------------------------------------------------------------
621 
622 //-------------------------------------------------------------------------
623 void
625 SetMaximumValue( double iMax)
626 {
627  m_Max = iMax;
629 
630  if(m_MaxSlider->maximum() > m_Max)
631  {
632  m_MaxSlider->setValue(iMax);
633  }
634  else
635  {
637  }
638 
641 }
642 //-------------------------------------------------------------------------
643 
644 //-------------------------------------------------------------------------
645 void
647 updateSliders( int iValue)
648 {
649  // min and max must be separated by at least 2 to create a consitent LUT
650  // since a consistent LUT need 2 values at least.
651  /*
652  need value in between
653  ^
654  LUT: MIN VALUE | color 1 | color 2 | MAX VALUE
655  */
656  if(m_MinSlider->value() > m_MaxSlider->value() - 2)
657  {
659  if(! name.compare("min") )
660  {
661  m_MinSlider->setValue(iValue - 1);
662  }
663  else
664  {
665  m_MaxSlider->setValue(iValue + 1);
666  }
667  return;
668  }
669 
670  UpdateLUT();
671 }
672 
QLayout * layout() const
QSlider * m_MinSlider
Slider to modify the min value.
void setStyleSheet(const QString &styleSheet)
void setRedF(qreal red)
void ChangeColor()
Opens a QColorDialog. If chosen color is valid, then: 1- Modify push button color 2- Modify m_TFWidge...
void addSpacerItem(QSpacerItem *spacerItem)
GoTransferFunctionWidget * m_TFWidget
The widget containing the shade, histogram, LUT and opacity TF.
QObject * sender() const
void setBlueF(qreal blue)
QStyle * style() const
int y() const
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.
void update()
QVector< qreal > m_Histogram
Histogram of the current channel for current time point.
int width() const
const char * name() const
void AddLookupTable(vtkLookupTable *iLUT)
Add LUT to the GoTransferFunctionEditorWidget.
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
void AddPointsToOpacityTF(const QPolygonF &iPoints)
Add points to the opacity transfer function. Called at initialization or reset.
double m_Max
Maximum pixel intensity for the channel at current time point.
void setLayout(QLayout *layout)
void setOrientation(Qt::Orientation)
int x() const
int red() const
void setGreenF(qreal green)
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.
virtual void addItem(QLayoutItem *item)
void setObjectName(const QString &name)
void AddPointsToLUT(const QPolygonF &iPoints)
Add points to the LUT. Called at initialization or reset.
void AdjustWindowLevel(double iMin, double iMax)
Adjust window/level between the input values. LUT (using the gamma value) will be calculated between ...
void setMinimum(int)
void setMargin(int margin)
void setSizePolicy(QSizePolicy)
bool blockSignals(bool block)
void UpdateLookupTable(vtkLookupTable *iLUT, qreal iGamma, qreal iMin, qreal iMax)
Modify LUT with given parameters.
void setValue(int)
QColor getColor(const QColor &initial, QWidget *parent, const QString &title, QFlags< QColorDialog::ColorDialogOption > options)
void repaint()
void ShowHistogram(bool iShow)
Show/hide histogram in m_TFWidget.
void setChecked(bool)
int blue() const
const T & at(int i) const
void setMax(double iMax)
Set maximum pixel intensity for current channel at current T point.
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 push_back(const T &value)
void setAlphaF(qreal alpha)
void ConvertSTDMapToQPolygonF(const std::map< unsigned int, unsigned int > &iMap, QPolygonF &iPoints)
Convenience method to convert a std::map to a QPolygonF.
void setColor(QColor iColor)
Set the color of the channel. 1- Modify the color 2- Update the shade 3- Update the visualization...
QColor m_Color
Current color of the channel.
void setToolTip(const QString &)
void AddOpacityTransferFunction(vtkPiecewiseFunction *iOpacity)
Add pointer to the opacity TF for a direct access.
void setMaximum(int)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
int size() const
void ConvertQPolygonFToSTDMap(const QPolygonF &iPoints, std::map< unsigned int, unsigned int > &iMap)
Convenience method to convert a QPolygonF to a std::map.
int compare(const QString &other) const
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QSlider * m_MaxSlider
Slider to modify the max value.
void SetHistogram(QVector< qreal > iHistogram)
Set the histogram.
void ResetOpacity()
Reset the opacity TF from min to max, from 0 to 1.
void setSpacing(int spacing)
int height() const
void updateVisualization()
Modify the visualization when the LUT or opacity changed.
QSlider * m_GammaSlider
Slider to modify the value of gamma.
bool isValid() const
void addLayout(QLayout *layout, int stretch)
void UpdateImageStructure(QString, std::map< unsigned int, unsigned int >, QColor, int, int, int)
Modify the image structure when apply clicked.