ctkVTKDiscretizableColorTransferWidget.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #include "ctkVTKDiscretizableColorTransferWidget.h"
  15. // CTK includes
  16. #include "ctkColorPickerButton.h"
  17. #include "ctkDoubleSlider.h"
  18. #include "ctkVTKScalarsToColorsComboBox.h"
  19. #include "ctkVTKScalarsToColorsUtils.h"
  20. #include "ui_ctkVTKDiscretizableColorTransferWidget.h"
  21. #include "vtkScalarsToColorsContextItem.h"
  22. // Qt includes
  23. #include <QColorDialog>
  24. #include <QCheckBox>
  25. #include <QDoubleValidator>
  26. #include <QHBoxLayout>
  27. #include <QIcon>
  28. #include <QLineEdit>
  29. #include <QLabel>
  30. #include <QMenu>
  31. #include <QPushButton>
  32. #include <QSpinBox>
  33. #include <QTimer>
  34. #include <QToolButton>
  35. #include <QVBoxLayout>
  36. #include <QWidgetAction>
  37. // VTK includes
  38. #include <QVTKWidget.h>
  39. #include <vtkCallbackCommand.h>
  40. #include <vtkContextScene.h>
  41. #include <vtkContextView.h>
  42. #include <vtkControlPointsItem.h>
  43. #include <vtkDiscretizableColorTransferFunction.h>
  44. #include <vtkDoubleArray.h>
  45. #include <vtkEventQtSlotConnect.h>
  46. #include <vtkIntArray.h>
  47. #include <vtkImageAccumulate.h>
  48. #include <vtkImageData.h>
  49. #include <vtkPiecewiseFunction.h>
  50. #include <vtkRenderer.h>
  51. #include <vtkRenderWindow.h>
  52. #include <vtkScalarsToColors.h>
  53. #include <vtkTable.h>
  54. // ----------------------------------------------------------------------------
  55. class ctkVTKDiscretizableColorTransferWidgetPrivate :
  56. public Ui_ctkVTKDiscretizableColorTransferWidget
  57. {
  58. Q_DECLARE_PUBLIC(ctkVTKDiscretizableColorTransferWidget);
  59. protected:
  60. ctkVTKDiscretizableColorTransferWidget* const q_ptr;
  61. public:
  62. ctkVTKDiscretizableColorTransferWidgetPrivate(
  63. ctkVTKDiscretizableColorTransferWidget& object);
  64. void setupUi(QWidget* widget);
  65. vtkSmartPointer<vtkScalarsToColorsContextItem> scalarsToColorsContextItem;
  66. vtkSmartPointer<vtkContextView> scalarsToColorsContextView;
  67. vtkSmartPointer<vtkEventQtSlotConnect> eventLink;
  68. ///Option part
  69. ctkColorPickerButton* nanButton;
  70. QCheckBox* discretizeCheckBox;
  71. QSpinBox* nbOfDiscreteValuesSpinBox;
  72. /// Stores the range of the data.
  73. /// Extracted from the histogram
  74. double dataRange[2];
  75. double dataMean;
  76. double previousOpacityValue;
  77. vtkSmartPointer<vtkCallbackCommand> colorTransferFunctionModified;
  78. static void colorTransferFunctionModifiedCallback(vtkObject *caller,
  79. unsigned long eid, void *clientdata, void *calldata);
  80. };
  81. // ----------------------------------------------------------------------------
  82. ctkVTKDiscretizableColorTransferWidgetPrivate
  83. ::ctkVTKDiscretizableColorTransferWidgetPrivate(
  84. ctkVTKDiscretizableColorTransferWidget& object)
  85. : q_ptr(&object)
  86. {
  87. this->scalarsToColorsSelector = nullptr;
  88. // Option menu
  89. this->nanButton = nullptr;
  90. this->discretizeCheckBox = nullptr;
  91. this->nbOfDiscreteValuesSpinBox = nullptr;
  92. this->dataRange[0] = VTK_DOUBLE_MAX;
  93. this->dataRange[1] = VTK_DOUBLE_MIN;
  94. this->dataMean = 0.;
  95. this->previousOpacityValue = 0.;
  96. this->colorTransferFunctionModified =
  97. vtkSmartPointer<vtkCallbackCommand>::New();
  98. this->colorTransferFunctionModified->SetClientData(this);
  99. this->colorTransferFunctionModified->SetCallback(
  100. this->colorTransferFunctionModifiedCallback);
  101. }
  102. //-----------------------------------------------------------------------------
  103. void ctkVTKDiscretizableColorTransferWidgetPrivate::setupUi(QWidget* widget)
  104. {
  105. Q_Q(ctkVTKDiscretizableColorTransferWidget);
  106. this->Ui_ctkVTKDiscretizableColorTransferWidget::setupUi(widget);
  107. this->scalarsToColorsContextItem =
  108. vtkSmartPointer<vtkScalarsToColorsContextItem>::New();
  109. this->scalarsToColorsContextView = vtkSmartPointer<vtkContextView> ::New();
  110. this->scalarsToColorsContextView->GetScene()->AddItem(
  111. this->scalarsToColorsContextItem.Get());
  112. this->scalarsToColorsContextView->SetInteractor(
  113. this->scalarsToColorsView->GetInteractor());
  114. this->scalarsToColorsView->SetRenderWindow(
  115. this->scalarsToColorsContextView->GetRenderWindow());
  116. q->setViewBackgroundColor(QColor(49, 54, 59));
  117. this->previousOpacityValue = opacitySlider->value();
  118. this->scalarsToColorsSelector->addScalarsToColors(nullptr, q->tr("Reset"));
  119. this->scalarsToColorsSelector->setCurrentIndex(-1);
  120. this->eventLink = vtkSmartPointer<vtkEventQtSlotConnect>::New();
  121. this->eventLink->Connect(scalarsToColorsContextItem.Get(),
  122. vtkControlPointsItem::CurrentPointEditEvent,
  123. q, SLOT(onCurrentPointEdit()));
  124. this->scalarsToColorsContextItem->AddObserver(vtkCommand::EndEvent,
  125. this->colorTransferFunctionModified);
  126. QObject::connect(this->scalarsToColorsSelector,
  127. SIGNAL(currentScalarsToColorsChanged(vtkScalarsToColors*)),
  128. q, SLOT(onPaletteIndexChanged(vtkScalarsToColors*)));
  129. QObject::connect(opacitySlider, SIGNAL(valueChanged(double)),
  130. q, SLOT(setGlobalOpacity(double)));
  131. QObject::connect(resetRangeButton, SIGNAL(clicked()),
  132. q, SLOT(resetColorTransferFunctionRange()));
  133. QObject::connect(centerRangeButton, SIGNAL(clicked()),
  134. q, SLOT(centerColorTransferFunctionRange()));
  135. QObject::connect(invertColorTransferFunctionButton, SIGNAL(clicked()),
  136. q, SLOT(invertColorTransferFunction()));
  137. QObject::connect(rangeSlider, SIGNAL(valuesChanged(double, double)),
  138. q, SLOT(setColorTransferFunctionRange(double, double)));
  139. /// Option panel menu
  140. QWidget* nanColorWidget = new QWidget(optionButton);
  141. QHBoxLayout* nanColorLayout = new QHBoxLayout(nanColorWidget);
  142. QWidget* discretizeWidget = new QWidget(optionButton);
  143. QHBoxLayout* discretizeLayout = new QHBoxLayout(discretizeWidget);
  144. nanColorLayout->setContentsMargins(0, 0, 0, 0);
  145. discretizeLayout->setContentsMargins(0, 0, 0, 0);
  146. optionButton->setIcon(q->style()->standardIcon(
  147. QStyle::SP_FileDialogDetailedView, nullptr, optionButton));
  148. QLabel* nanLabel = new QLabel(q->tr("NaN values"));
  149. nanButton = new ctkColorPickerButton;
  150. nanButton->setToolTip(q->tr("NaN color"));
  151. nanColorLayout->addWidget(nanButton);
  152. nanColorLayout->addWidget(nanLabel);
  153. discretizeCheckBox = new QCheckBox;
  154. discretizeCheckBox->setText(q->tr("Discretize"));
  155. discretizeCheckBox->setToolTip(q->tr("Discretize color transfer function"));
  156. nbOfDiscreteValuesSpinBox = new QSpinBox;
  157. nbOfDiscreteValuesSpinBox->setMinimum(1);
  158. nbOfDiscreteValuesSpinBox->setMaximum(255);
  159. nbOfDiscreteValuesSpinBox->setToolTip(q->tr("Number of discrete values"));
  160. nbOfDiscreteValuesSpinBox->setEnabled(discretizeCheckBox->isChecked());
  161. discretizeLayout->addWidget(discretizeCheckBox);
  162. discretizeLayout->addWidget(nbOfDiscreteValuesSpinBox);
  163. QMenu* optionMenu = new QMenu(optionButton);
  164. QWidgetAction* nanColorAction = new QWidgetAction(optionButton);
  165. nanColorAction->setDefaultWidget(nanColorWidget);
  166. QWidgetAction* discretizeAction = new QWidgetAction(optionButton);
  167. discretizeAction->setDefaultWidget(discretizeWidget);
  168. optionMenu->addAction(nanColorAction);
  169. optionMenu->addSeparator();
  170. optionMenu->addAction(discretizeAction);
  171. optionButton->setMenu(optionMenu);
  172. optionButton->setPopupMode(QToolButton::InstantPopup);
  173. QObject::connect(nanButton, SIGNAL(clicked()), q, SLOT(setNaNColor()));
  174. QObject::connect(discretizeCheckBox, SIGNAL(toggled(bool)),
  175. q, SLOT(setDiscretize(bool)));
  176. QObject::connect(nbOfDiscreteValuesSpinBox, SIGNAL(valueChanged(int)),
  177. q, SLOT(setNumberOfDiscreteValues(int)));
  178. ///Enable nbOfValuesSpinBox only if we use discretize
  179. QObject::connect(discretizeCheckBox, SIGNAL(toggled(bool)),
  180. nbOfDiscreteValuesSpinBox, SLOT(setEnabled(bool)));
  181. }
  182. // ----------------------------------------------------------------------------
  183. void
  184. ctkVTKDiscretizableColorTransferWidgetPrivate::colorTransferFunctionModifiedCallback(
  185. vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
  186. {
  187. ctkVTKDiscretizableColorTransferWidgetPrivate* self =
  188. reinterpret_cast<ctkVTKDiscretizableColorTransferWidgetPrivate*>(
  189. clientdata);
  190. vtkSmartPointer<vtkDiscretizableColorTransferFunction> dctf =
  191. self->scalarsToColorsContextItem->GetDiscretizableColorTransferFunction();
  192. if (dctf == nullptr)
  193. {
  194. return;
  195. }
  196. if (self->scalarsToColorsContextItem->IsProcessingColorTransferFunction())
  197. {
  198. return;
  199. }
  200. if (dctf->GetDiscretize())
  201. {
  202. dctf->Build();
  203. }
  204. self->discretizeCheckBox->setChecked(dctf->GetDiscretize());
  205. if (dctf->GetDiscretize())
  206. {
  207. self->nbOfDiscreteValuesSpinBox->setValue(dctf->GetNumberOfValues());
  208. }
  209. double* newRange = self->scalarsToColorsContextItem->GetCurrentRange();
  210. self->rangeSlider->setValues(newRange[0], newRange[1]);
  211. double r, g, b;
  212. self->scalarsToColorsContextItem->GetDiscretizableColorTransferFunction()->
  213. GetNanColor(r, g, b);
  214. QColor selected = QColor::fromRgbF(r, g, b);
  215. self->nanButton->setColor(selected);
  216. self->scalarsToColorsView->GetInteractor()->Render();
  217. }
  218. // ----------------------------------------------------------------------------
  219. ctkVTKDiscretizableColorTransferWidget::ctkVTKDiscretizableColorTransferWidget(
  220. QWidget* parent)
  221. : QWidget(parent)
  222. , d_ptr(new ctkVTKDiscretizableColorTransferWidgetPrivate(*this))
  223. {
  224. Q_D(ctkVTKDiscretizableColorTransferWidget);
  225. d->setupUi(this);
  226. }
  227. // ----------------------------------------------------------------------------
  228. ctkVTKDiscretizableColorTransferWidget::~ctkVTKDiscretizableColorTransferWidget()
  229. {
  230. }
  231. // ----------------------------------------------------------------------------
  232. void ctkVTKDiscretizableColorTransferWidget::setColorTransferFunction(
  233. vtkScalarsToColors* ctf)
  234. {
  235. Q_D(ctkVTKDiscretizableColorTransferWidget);
  236. vtkScalarsToColors* oldCtf =
  237. d->scalarsToColorsContextItem->GetDiscretizableColorTransferFunction();
  238. if (oldCtf != nullptr)
  239. {
  240. oldCtf->RemoveObserver(d->colorTransferFunctionModified);
  241. }
  242. ///Setting the transfer function to the scalarsToColorsContextItem convert
  243. /// it to a vtkDiscretizableTransferFunction
  244. d->scalarsToColorsContextItem->SetColorTransferFunction(ctf);
  245. ctf = d->scalarsToColorsContextItem->GetColorTransferFunction();
  246. emit(currentScalarsToColorsChanged(ctf));
  247. if (ctf == nullptr)
  248. {
  249. d->rangeSlider->setRange(0., 255.);
  250. d->rangeSlider->setValues(0., 1.);
  251. d->rangeSlider->setEnabled(false);
  252. d->previousOpacityValue = 0.0;
  253. d->opacitySlider->setValue(d->previousOpacityValue);
  254. d->opacitySlider->setEnabled(false);
  255. d->optionButton->setEnabled(false);
  256. d->resetRangeButton->setEnabled(false);
  257. d->centerRangeButton->setEnabled(false);
  258. d->invertColorTransferFunctionButton->setEnabled(false);
  259. return;
  260. }
  261. // Set sliders values depending on the new color transfer function
  262. d->rangeSlider->setEnabled(true);
  263. d->opacitySlider->setEnabled(true);
  264. d->optionButton->setEnabled(true);
  265. d->resetRangeButton->setEnabled(true);
  266. d->centerRangeButton->setEnabled(true);
  267. d->invertColorTransferFunctionButton->setEnabled(true);
  268. double* newRange = d->scalarsToColorsContextItem->
  269. GetDiscretizableColorTransferFunction()->GetRange();
  270. d->rangeSlider->setRange(newRange[0], newRange[1]);
  271. d->previousOpacityValue = 1.0;
  272. d->opacitySlider->setValue(d->previousOpacityValue);
  273. ctf->AddObserver(
  274. vtkCommand::ModifiedEvent, d->colorTransferFunctionModified);
  275. d->colorTransferFunctionModified->Execute(ctf, vtkCommand::ModifiedEvent,
  276. this);
  277. }
  278. // ----------------------------------------------------------------------------
  279. vtkScalarsToColors*
  280. ctkVTKDiscretizableColorTransferWidget::colorTransferFunction() const
  281. {
  282. Q_D(const ctkVTKDiscretizableColorTransferWidget);
  283. return d->scalarsToColorsContextItem->GetColorTransferFunction();
  284. }
  285. // ----------------------------------------------------------------------------
  286. void ctkVTKDiscretizableColorTransferWidget::setHistogram(
  287. vtkImageAccumulate* histogram)
  288. {
  289. Q_D(ctkVTKDiscretizableColorTransferWidget);
  290. histogram->Update();
  291. d->dataRange[0] = histogram->GetMin()[0];
  292. d->dataRange[1] = histogram->GetMax()[0];
  293. d->dataMean = histogram->GetMean()[0];
  294. int* output = static_cast<int*>(histogram->GetOutput()->GetScalarPointer());
  295. double spacing = histogram->GetComponentSpacing()[0];
  296. double bin = histogram->GetComponentOrigin()[0];
  297. vtkSmartPointer<vtkDoubleArray> bins =
  298. vtkSmartPointer<vtkDoubleArray>::New();
  299. bins->SetNumberOfComponents(1);
  300. bins->SetNumberOfTuples(255);
  301. bins->SetName("image_extents");
  302. vtkSmartPointer<vtkIntArray> frequencies =
  303. vtkSmartPointer<vtkIntArray>::New();
  304. frequencies->SetNumberOfComponents(1);
  305. frequencies->SetNumberOfTuples(255);
  306. frequencies->SetName("Frequency");
  307. for (unsigned int j = 0; j < 255; ++j)
  308. {
  309. bins->SetTuple1(j, bin);
  310. bin += spacing;
  311. frequencies->SetTuple1(j, *output++);
  312. }
  313. vtkNew<vtkTable> table;
  314. table->AddColumn(bins);
  315. table->AddColumn(frequencies);
  316. d->scalarsToColorsContextItem->SetHistogramTable(table.Get(),
  317. "image_extents", "Frequency");
  318. d->scalarsToColorsContextItem->SetDataRange(d->dataRange[0], d->dataRange[1]);
  319. d->scalarsToColorsView->GetInteractor()->Render();
  320. }
  321. // ----------------------------------------------------------------------------
  322. void ctkVTKDiscretizableColorTransferWidget::onPaletteIndexChanged(
  323. vtkScalarsToColors* ctf)
  324. {
  325. Q_D(ctkVTKDiscretizableColorTransferWidget);
  326. if (ctf == nullptr)
  327. {
  328. this->setColorTransferFunction(ctf);
  329. return;
  330. }
  331. if (ctf->IsA("vtkDiscretizableColorTransferFunction"))
  332. {
  333. vtkNew<vtkDiscretizableColorTransferFunction> newCtf;
  334. vtkNew<vtkPiecewiseFunction> newPf;
  335. newCtf->DeepCopy(vtkDiscretizableColorTransferFunction::SafeDownCast(ctf));
  336. newPf->DeepCopy(vtkDiscretizableColorTransferFunction::SafeDownCast(ctf)->GetScalarOpacityFunction());
  337. newCtf->SetScalarOpacityFunction(newPf.Get());
  338. newCtf->EnableOpacityMappingOn();
  339. this->setColorTransferFunction(newCtf.Get());
  340. }
  341. else if (ctf->IsA("vtkColorTransferFunction"))
  342. {
  343. vtkNew<vtkColorTransferFunction> newCtf;
  344. newCtf->DeepCopy(vtkColorTransferFunction::SafeDownCast(ctf));
  345. this->setColorTransferFunction(newCtf.Get());
  346. }
  347. }
  348. // ----------------------------------------------------------------------------
  349. void ctkVTKDiscretizableColorTransferWidget::setGlobalOpacity(double value)
  350. {
  351. Q_D(ctkVTKDiscretizableColorTransferWidget);
  352. d->scalarsToColorsContextItem->SetGlobalOpacity(
  353. value / d->previousOpacityValue);
  354. d->previousOpacityValue = value;
  355. }
  356. // ----------------------------------------------------------------------------
  357. void ctkVTKDiscretizableColorTransferWidget::setNaNColor()
  358. {
  359. Q_D(ctkVTKDiscretizableColorTransferWidget);
  360. QColor selected = d->nanButton->color();
  361. d->scalarsToColorsContextItem->GetDiscretizableColorTransferFunction()->
  362. SetNanColor(selected.redF(), selected.greenF(), selected.blueF());
  363. }
  364. // ----------------------------------------------------------------------------
  365. void ctkVTKDiscretizableColorTransferWidget::setDiscretize(bool checked)
  366. {
  367. Q_D(ctkVTKDiscretizableColorTransferWidget);
  368. d->scalarsToColorsContextItem->GetDiscretizableColorTransferFunction()->
  369. SetDiscretize(checked);
  370. }
  371. // ----------------------------------------------------------------------------
  372. void ctkVTKDiscretizableColorTransferWidget::setNumberOfDiscreteValues(
  373. int value)
  374. {
  375. Q_D(ctkVTKDiscretizableColorTransferWidget);
  376. d->scalarsToColorsContextItem->GetDiscretizableColorTransferFunction()
  377. ->SetNumberOfValues(value);
  378. }
  379. // ----------------------------------------------------------------------------
  380. void ctkVTKDiscretizableColorTransferWidget::setColorTransferFunctionRange(
  381. double minValue, double maxValue)
  382. {
  383. Q_D(ctkVTKDiscretizableColorTransferWidget);
  384. d->scalarsToColorsContextItem->SetCurrentRange(minValue, maxValue);
  385. }
  386. // ----------------------------------------------------------------------------
  387. void ctkVTKDiscretizableColorTransferWidget::onCurrentPointEdit()
  388. {
  389. Q_D(ctkVTKDiscretizableColorTransferWidget);
  390. double rgb[3];
  391. if (d->scalarsToColorsContextItem->GetCurrentControlPointColor(rgb))
  392. {
  393. QColor color = QColorDialog::getColor(
  394. QColor::fromRgbF(rgb[0], rgb[1], rgb[2]), this, "Select color at point",
  395. QColorDialog::DontUseNativeDialog);
  396. if (color.isValid())
  397. {
  398. rgb[0] = color.redF();
  399. rgb[1] = color.greenF();
  400. rgb[2] = color.blueF();
  401. d->scalarsToColorsContextItem->SetCurrentControlPointColor(rgb);
  402. }
  403. }
  404. }
  405. // ----------------------------------------------------------------------------
  406. void ctkVTKDiscretizableColorTransferWidget::resetColorTransferFunctionRange()
  407. {
  408. Q_D(ctkVTKDiscretizableColorTransferWidget);
  409. if (d->dataRange[0] <= d->dataRange[1])
  410. {
  411. d->scalarsToColorsContextItem->SetCurrentRange(
  412. d->dataRange[0], d->dataRange[1]);
  413. }
  414. }
  415. // ----------------------------------------------------------------------------
  416. void ctkVTKDiscretizableColorTransferWidget::centerColorTransferFunctionRange()
  417. {
  418. Q_D(ctkVTKDiscretizableColorTransferWidget);
  419. d->scalarsToColorsContextItem->CenterRange(d->dataMean);
  420. }
  421. // ----------------------------------------------------------------------------
  422. void ctkVTKDiscretizableColorTransferWidget::invertColorTransferFunction()
  423. {
  424. Q_D(ctkVTKDiscretizableColorTransferWidget);
  425. d->scalarsToColorsContextItem->InvertColorTransferFunction();
  426. }
  427. // ----------------------------------------------------------------------------
  428. void ctkVTKDiscretizableColorTransferWidget::setViewBackgroundColor(
  429. const QColor& i_color)
  430. {
  431. Q_D(ctkVTKDiscretizableColorTransferWidget);
  432. d->scalarsToColorsContextView->GetRenderer()->SetBackground(
  433. i_color.redF(), i_color.greenF(), i_color.blueF());
  434. }
  435. // ----------------------------------------------------------------------------
  436. QColor ctkVTKDiscretizableColorTransferWidget::viewBackgroundColor() const
  437. {
  438. Q_D(const ctkVTKDiscretizableColorTransferWidget);
  439. double rgb[3];
  440. d->scalarsToColorsContextView->GetRenderer()->GetBackground(rgb);
  441. return QColor::fromRgbF(rgb[0], rgb[1], rgb[2]);
  442. }
  443. // ----------------------------------------------------------------------------
  444. ctkVTKScalarsToColorsComboBox*
  445. ctkVTKDiscretizableColorTransferWidget::scalarsToColorsSelector() const
  446. {
  447. Q_D(const ctkVTKDiscretizableColorTransferWidget);
  448. return d->scalarsToColorsSelector;
  449. }