ctkVTKScalarsToColorsView.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  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. // Qt includes
  15. #include <QColorDialog>
  16. // CTK includes
  17. #include "ctkLogger.h"
  18. #include "ctkVTKScalarsToColorsView.h"
  19. // VTK includes
  20. #include <vtkAxis.h>
  21. #include <vtkChartXY.h>
  22. #include <vtkColorTransferControlPointsItem.h>
  23. #include <vtkColorTransferFunction.h>
  24. #include <vtkColorTransferFunctionItem.h>
  25. #include <vtkCompositeControlPointsItem.h>
  26. #include <vtkCompositeTransferFunctionItem.h>
  27. #include <vtkIdTypeArray.h>
  28. #include <vtkLookupTable.h>
  29. #include <vtkLookupTableItem.h>
  30. #include <vtkPen.h>
  31. #include <vtkPiecewiseControlPointsItem.h>
  32. #include <vtkPiecewiseFunction.h>
  33. #include <vtkPiecewiseFunctionItem.h>
  34. #include <vtkSmartPointer.h>
  35. //----------------------------------------------------------------------------
  36. static ctkLogger logger("org.commontk.visualization.vtk.widgets.ctkVTKScalarsToColorsView");
  37. //----------------------------------------------------------------------------
  38. class ctkVTKScalarsToColorsViewPrivate
  39. {
  40. Q_DECLARE_PUBLIC(ctkVTKScalarsToColorsView);
  41. protected:
  42. ctkVTKScalarsToColorsView* const q_ptr;
  43. public:
  44. ctkVTKScalarsToColorsViewPrivate(ctkVTKScalarsToColorsView& object);
  45. void init();
  46. void updateBounds();
  47. void showBorders(bool);
  48. double ValidBounds[4];
  49. };
  50. // ----------------------------------------------------------------------------
  51. // ctkVTKScalarsToColorsViewPrivate methods
  52. // ----------------------------------------------------------------------------
  53. ctkVTKScalarsToColorsViewPrivate::ctkVTKScalarsToColorsViewPrivate(ctkVTKScalarsToColorsView& object)
  54. :q_ptr(&object)
  55. {
  56. this->ValidBounds[0] = this->ValidBounds[2] = 0.;
  57. this->ValidBounds[1] = this->ValidBounds[3] = -1.;
  58. }
  59. // ----------------------------------------------------------------------------
  60. void ctkVTKScalarsToColorsViewPrivate::init()
  61. {
  62. Q_Q(ctkVTKScalarsToColorsView);
  63. vtkChartXY* chart = q->chart();
  64. chart->SetAutoAxes(false);
  65. chart->SetHiddenAxisBorder(0);
  66. this->showBorders(true);
  67. QObject::connect(q, SIGNAL(boundsChanged()), q, SLOT(onBoundsChanged()));
  68. q->onChartUpdated();
  69. }
  70. // ----------------------------------------------------------------------------
  71. void ctkVTKScalarsToColorsViewPrivate::showBorders(bool visible)
  72. {
  73. Q_Q(ctkVTKScalarsToColorsView);
  74. vtkChartXY* chart = q->chart();
  75. for (int i = 0; i < 4; ++i)
  76. {
  77. chart->GetAxis(i)->SetVisible(true);
  78. chart->GetAxis(i)->GetPen()->SetOpacityF(0.3);
  79. chart->GetAxis(i)->SetTitle("");
  80. chart->GetAxis(i)->SetNumberOfTicks(0);
  81. chart->GetAxis(i)->SetLabelsVisible(false);
  82. chart->GetAxis(i)->SetMargins(7.,7.);
  83. if (visible)
  84. {
  85. chart->GetAxis(i)->SetBehavior(2);
  86. }
  87. else
  88. {
  89. chart->GetAxis(i)->SetBehavior(1);
  90. }
  91. }
  92. }
  93. // ----------------------------------------------------------------------------
  94. // ctkVTKScalarsToColorsView methods
  95. // ----------------------------------------------------------------------------
  96. ctkVTKScalarsToColorsView::ctkVTKScalarsToColorsView(QWidget* parentWidget)
  97. :ctkVTKChartView(parentWidget)
  98. , d_ptr(new ctkVTKScalarsToColorsViewPrivate(*this))
  99. {
  100. Q_D(ctkVTKScalarsToColorsView);
  101. d->init();
  102. }
  103. // ----------------------------------------------------------------------------
  104. ctkVTKScalarsToColorsView::~ctkVTKScalarsToColorsView()
  105. {
  106. }
  107. // ----------------------------------------------------------------------------
  108. void ctkVTKScalarsToColorsView::addPlot(vtkPlot* plot)
  109. {
  110. if (vtkColorTransferControlPointsItem::SafeDownCast(plot))
  111. {
  112. this->qvtkConnect(plot, vtkControlPointsItem::CurrentPointEditEvent,
  113. this, SLOT(editPoint(vtkObject*,void*)));
  114. }
  115. this->Superclass::addPlot(plot);
  116. }
  117. // ----------------------------------------------------------------------------
  118. void ctkVTKScalarsToColorsView::onBoundsChanged()
  119. {
  120. this->boundAxesToChartBounds();
  121. // Set range to bounds only if range is invalid. Otherwise keep it as is, because
  122. // the user wants to keep the range they set after a transfer function is shifted
  123. double extent[8];
  124. this->chartExtent(extent);
  125. if (extent[0] >= extent[1])
  126. {
  127. this->setAxesToChartBounds();
  128. }
  129. this->Superclass::onChartUpdated();
  130. }
  131. // ----------------------------------------------------------------------------
  132. vtkPlot* ctkVTKScalarsToColorsView::addLookupTable(vtkLookupTable* lut)
  133. {
  134. vtkSmartPointer<vtkLookupTableItem> item =
  135. vtkSmartPointer<vtkLookupTableItem>::New();
  136. item->SetLookupTable(lut);
  137. this->addPlot(item);
  138. return item;
  139. }
  140. // ----------------------------------------------------------------------------
  141. vtkPlot* ctkVTKScalarsToColorsView
  142. ::addColorTransferFunction(vtkColorTransferFunction* colorTF,
  143. bool editable)
  144. {
  145. vtkSmartPointer<vtkColorTransferFunctionItem> item =
  146. vtkSmartPointer<vtkColorTransferFunctionItem>::New();
  147. item->SetColorTransferFunction(colorTF);
  148. this->addPlot(item);
  149. if (editable)
  150. {
  151. this->addColorTransferFunctionControlPoints(colorTF);
  152. }
  153. return item;
  154. }
  155. // ----------------------------------------------------------------------------
  156. vtkPlot* ctkVTKScalarsToColorsView
  157. ::addOpacityFunction(vtkPiecewiseFunction* opacityTF,
  158. bool editable)
  159. {
  160. return this->addPiecewiseFunction(opacityTF, editable);
  161. }
  162. // ----------------------------------------------------------------------------
  163. vtkPlot* ctkVTKScalarsToColorsView
  164. ::addPiecewiseFunction(vtkPiecewiseFunction* piecewiseTF,
  165. bool editable)
  166. {
  167. vtkSmartPointer<vtkPiecewiseFunctionItem> item =
  168. vtkSmartPointer<vtkPiecewiseFunctionItem>::New();
  169. item->SetPiecewiseFunction(piecewiseTF);
  170. QColor defaultColor = this->palette().highlight().color();
  171. item->SetColor(defaultColor.redF(), defaultColor.greenF(), defaultColor.blueF());
  172. item->SetMaskAboveCurve(true);
  173. this->addPlot(item);
  174. if (editable)
  175. {
  176. this->addPiecewiseFunctionControlPoints(piecewiseTF);
  177. }
  178. return item;
  179. }
  180. // ----------------------------------------------------------------------------
  181. vtkPlot* ctkVTKScalarsToColorsView
  182. ::addCompositeFunction(vtkColorTransferFunction* colorTF,
  183. vtkPiecewiseFunction* opacityTF,
  184. bool colorTFEditable, bool opacityTFEditable)
  185. {
  186. vtkSmartPointer<vtkCompositeTransferFunctionItem> item =
  187. vtkSmartPointer<vtkCompositeTransferFunctionItem>::New();
  188. item->SetColorTransferFunction(colorTF);
  189. item->SetOpacityFunction(opacityTF);
  190. item->SetMaskAboveCurve(true);
  191. this->addPlot(item);
  192. if (colorTFEditable && opacityTFEditable)
  193. {
  194. this->addCompositeFunctionControlPoints(colorTF, opacityTF);
  195. }
  196. else if (colorTFEditable)
  197. {
  198. this->addColorTransferFunctionControlPoints(colorTF);
  199. }
  200. else if (opacityTFEditable)
  201. {
  202. this->addOpacityFunctionControlPoints(opacityTF);
  203. }
  204. return item;
  205. }
  206. // ----------------------------------------------------------------------------
  207. vtkPlot* ctkVTKScalarsToColorsView
  208. ::addColorTransferFunctionControlPoints(vtkColorTransferFunction* colorTF)
  209. {
  210. Q_D(ctkVTKScalarsToColorsView);
  211. vtkSmartPointer<vtkColorTransferControlPointsItem> controlPointsItem =
  212. vtkSmartPointer<vtkColorTransferControlPointsItem>::New();
  213. controlPointsItem->SetColorTransferFunction(colorTF);
  214. controlPointsItem->SetValidBounds(d->ValidBounds);
  215. this->addPlot(controlPointsItem);
  216. return controlPointsItem;
  217. }
  218. // ----------------------------------------------------------------------------
  219. vtkPlot* ctkVTKScalarsToColorsView
  220. ::addOpacityFunctionControlPoints(vtkPiecewiseFunction* opacityTF)
  221. {
  222. return this->addPiecewiseFunctionControlPoints(opacityTF);
  223. }
  224. // ----------------------------------------------------------------------------
  225. vtkPlot* ctkVTKScalarsToColorsView
  226. ::addCompositeFunctionControlPoints(vtkColorTransferFunction* colorTF,
  227. vtkPiecewiseFunction* opacityTF)
  228. {
  229. Q_D(ctkVTKScalarsToColorsView);
  230. vtkSmartPointer<vtkCompositeControlPointsItem> controlPointsItem =
  231. vtkSmartPointer<vtkCompositeControlPointsItem>::New();
  232. controlPointsItem->SetColorTransferFunction(colorTF);
  233. controlPointsItem->SetOpacityFunction(opacityTF);
  234. controlPointsItem->SetValidBounds(d->ValidBounds);
  235. this->addPlot(controlPointsItem);
  236. return controlPointsItem;
  237. }
  238. // ----------------------------------------------------------------------------
  239. vtkPlot* ctkVTKScalarsToColorsView
  240. ::addPiecewiseFunctionControlPoints(vtkPiecewiseFunction* piecewiseTF)
  241. {
  242. Q_D(ctkVTKScalarsToColorsView);
  243. vtkSmartPointer<vtkPiecewiseControlPointsItem> controlPointsItem =
  244. vtkSmartPointer<vtkPiecewiseControlPointsItem>::New();
  245. controlPointsItem->SetPiecewiseFunction(piecewiseTF);
  246. controlPointsItem->SetValidBounds(d->ValidBounds);
  247. this->addPlot(controlPointsItem);
  248. return controlPointsItem;
  249. }
  250. // ----------------------------------------------------------------------------
  251. QList<vtkPlot*> ctkVTKScalarsToColorsView::plots()const
  252. {
  253. QList<vtkPlot*> res;
  254. const vtkIdType count = this->chart()->GetNumberOfPlots();
  255. for(vtkIdType i = 0; i < count; ++i)
  256. {
  257. res << this->chart()->GetPlot(i);
  258. }
  259. return res;
  260. }
  261. // ----------------------------------------------------------------------------
  262. QList<vtkControlPointsItem*> ctkVTKScalarsToColorsView
  263. ::controlPointsItems()const
  264. {
  265. QList<vtkControlPointsItem*> res;
  266. foreach(vtkPlot* plot, this->plots())
  267. {
  268. vtkControlPointsItem* controlPointsItem =
  269. vtkControlPointsItem::SafeDownCast(plot);
  270. if (controlPointsItem)
  271. {
  272. res << controlPointsItem;
  273. }
  274. }
  275. return res;
  276. }
  277. // ----------------------------------------------------------------------------
  278. QList<vtkPlot*> ctkVTKScalarsToColorsView::lookupTablePlots()const
  279. {
  280. QList<vtkPlot*> res;
  281. foreach(vtkPlot* plot, this->plots())
  282. {
  283. if (vtkLookupTableItem::SafeDownCast(plot))
  284. {
  285. res << plot;
  286. }
  287. }
  288. return res;
  289. }
  290. // ----------------------------------------------------------------------------
  291. QList<vtkPlot*> ctkVTKScalarsToColorsView::lookupTablePlots(vtkLookupTable* lut)const
  292. {
  293. QList<vtkPlot*> res;
  294. foreach(vtkPlot* plot, this->lookupTablePlots())
  295. {
  296. vtkLookupTableItem* item = vtkLookupTableItem::SafeDownCast(plot);
  297. if (item->GetLookupTable() == lut)
  298. {
  299. res << plot;
  300. }
  301. }
  302. return res;
  303. }
  304. // ----------------------------------------------------------------------------
  305. QList<vtkPlot*> ctkVTKScalarsToColorsView::colorTransferFunctionPlots()const
  306. {
  307. QList<vtkPlot*> res;
  308. foreach(vtkPlot* plot, this->plots())
  309. {
  310. if (vtkColorTransferFunctionItem::SafeDownCast(plot) ||
  311. vtkColorTransferControlPointsItem::SafeDownCast(plot))
  312. {
  313. res << plot;
  314. }
  315. }
  316. return res;
  317. }
  318. // ----------------------------------------------------------------------------
  319. QList<vtkPlot*> ctkVTKScalarsToColorsView
  320. ::colorTransferFunctionPlots(vtkColorTransferFunction* colorTF)const
  321. {
  322. QList<vtkPlot*> res;
  323. foreach(vtkPlot* plot, this->colorTransferFunctionPlots())
  324. {
  325. vtkColorTransferFunctionItem* item =
  326. vtkColorTransferFunctionItem::SafeDownCast(plot);
  327. if (item
  328. && item->GetColorTransferFunction() == colorTF)
  329. {
  330. res << plot;
  331. }
  332. vtkColorTransferControlPointsItem* controlPointsItem =
  333. vtkColorTransferControlPointsItem::SafeDownCast(plot);
  334. if (controlPointsItem
  335. && controlPointsItem->GetColorTransferFunction() == colorTF)
  336. {
  337. res << plot;
  338. }
  339. }
  340. return res;
  341. }
  342. // ----------------------------------------------------------------------------
  343. QList<vtkPlot*> ctkVTKScalarsToColorsView::opacityFunctionPlots()const
  344. {
  345. QList<vtkPlot*> res;
  346. foreach(vtkPlot* plot, this->plots())
  347. {
  348. if (vtkPiecewiseFunctionItem::SafeDownCast(plot) ||
  349. vtkPiecewiseControlPointsItem::SafeDownCast(plot) ||
  350. vtkCompositeTransferFunctionItem::SafeDownCast(plot) ||
  351. vtkCompositeControlPointsItem::SafeDownCast(plot))
  352. {
  353. res << plot;
  354. }
  355. }
  356. return res;
  357. }
  358. // ----------------------------------------------------------------------------
  359. QList<vtkPlot*> ctkVTKScalarsToColorsView
  360. ::opacityFunctionPlots(vtkPiecewiseFunction* opacityTF)const
  361. {
  362. QList<vtkPlot*> res;
  363. foreach(vtkPlot* plot, this->opacityFunctionPlots())
  364. {
  365. vtkPiecewiseFunctionItem* item =
  366. vtkPiecewiseFunctionItem::SafeDownCast(plot);
  367. if (item
  368. && item->GetPiecewiseFunction() == opacityTF)
  369. {
  370. res << plot;
  371. }
  372. vtkPiecewiseControlPointsItem* controlPointsItem =
  373. vtkPiecewiseControlPointsItem::SafeDownCast(plot);
  374. if (controlPointsItem
  375. && controlPointsItem->GetPiecewiseFunction() == opacityTF)
  376. {
  377. res << plot;
  378. }
  379. vtkCompositeTransferFunctionItem* compositeItem =
  380. vtkCompositeTransferFunctionItem::SafeDownCast(plot);
  381. if (compositeItem
  382. && compositeItem->GetOpacityFunction() == opacityTF)
  383. {
  384. res << plot;
  385. }
  386. vtkCompositeControlPointsItem* compositeControlPointsItem =
  387. vtkCompositeControlPointsItem::SafeDownCast(plot);
  388. if (compositeControlPointsItem
  389. && compositeControlPointsItem->GetOpacityFunction() == opacityTF)
  390. {
  391. res << plot;
  392. }
  393. }
  394. return res;
  395. }
  396. // ----------------------------------------------------------------------------
  397. void ctkVTKScalarsToColorsView::setLookuptTableToPlots(vtkLookupTable* lut)
  398. {
  399. foreach(vtkLookupTableItem* plot,
  400. this->plots<vtkLookupTableItem>())
  401. {
  402. plot->SetLookupTable(lut);
  403. }
  404. this->onChartUpdated();
  405. }
  406. // ----------------------------------------------------------------------------
  407. void ctkVTKScalarsToColorsView
  408. ::setColorTransferFunctionToPlots(vtkColorTransferFunction* colorTF)
  409. {
  410. foreach(vtkColorTransferFunctionItem* plot,
  411. this->plots<vtkColorTransferFunctionItem>())
  412. {
  413. plot->SetColorTransferFunction(colorTF);
  414. }
  415. foreach(vtkColorTransferControlPointsItem* plot,
  416. this->plots<vtkColorTransferControlPointsItem>())
  417. {
  418. plot->SetColorTransferFunction(colorTF);
  419. }
  420. this->onChartUpdated();
  421. }
  422. // ----------------------------------------------------------------------------
  423. void ctkVTKScalarsToColorsView
  424. ::setOpacityFunctionToPlots(vtkPiecewiseFunction* opacityTF)
  425. {
  426. this->setPiecewiseFunctionToPlots(opacityTF);
  427. foreach(vtkCompositeTransferFunctionItem* plot,
  428. this->plots<vtkCompositeTransferFunctionItem>())
  429. {
  430. plot->SetOpacityFunction(opacityTF);
  431. }
  432. foreach(vtkCompositeControlPointsItem* plot,
  433. this->plots<vtkCompositeControlPointsItem>())
  434. {
  435. plot->SetOpacityFunction(opacityTF);
  436. }
  437. this->onChartUpdated();
  438. }
  439. // ----------------------------------------------------------------------------
  440. void ctkVTKScalarsToColorsView
  441. ::setPiecewiseFunctionToPlots(vtkPiecewiseFunction* piecewiseTF)
  442. {
  443. foreach(vtkPiecewiseFunctionItem* plot,
  444. this->plots<vtkPiecewiseFunctionItem>())
  445. {
  446. plot->SetPiecewiseFunction(piecewiseTF);
  447. }
  448. foreach(vtkPiecewiseControlPointsItem* plot,
  449. this->plots<vtkPiecewiseControlPointsItem>())
  450. {
  451. plot->SetPiecewiseFunction(piecewiseTF);
  452. }
  453. this->onChartUpdated();
  454. }
  455. // ----------------------------------------------------------------------------
  456. bool ctkVTKScalarsToColorsView
  457. ::areBordersVisible()const
  458. {
  459. return this->chart()->GetAxis(0)->GetVisible();
  460. }
  461. // ----------------------------------------------------------------------------
  462. void ctkVTKScalarsToColorsView
  463. ::setBordersVisible(bool show)
  464. {
  465. Q_D(ctkVTKScalarsToColorsView);
  466. d->showBorders(show);
  467. }
  468. // ----------------------------------------------------------------------------
  469. void ctkVTKScalarsToColorsView
  470. ::validBounds(double* bounds)const
  471. {
  472. Q_D(const ctkVTKScalarsToColorsView);
  473. memcpy(bounds, d->ValidBounds, 4 * sizeof(double));
  474. }
  475. // ----------------------------------------------------------------------------
  476. void ctkVTKScalarsToColorsView
  477. ::setValidBounds(double* bounds)
  478. {
  479. Q_D(ctkVTKScalarsToColorsView);
  480. foreach(vtkControlPointsItem* plot, this->controlPointsItems())
  481. {
  482. plot->SetValidBounds(bounds);
  483. }
  484. memcpy(d->ValidBounds, bounds, 4 * sizeof(double));
  485. }
  486. // ----------------------------------------------------------------------------
  487. void ctkVTKScalarsToColorsView
  488. ::setPlotsUserBounds(double* bounds)
  489. {
  490. double plotBounds[4];
  491. this->chartBoundsToPlotBounds(bounds, plotBounds);
  492. foreach(vtkScalarsToColorsItem* plot,
  493. this->plots<vtkScalarsToColorsItem>())
  494. {
  495. plot->SetUserBounds(plotBounds);
  496. }
  497. foreach(vtkControlPointsItem* plot, this->controlPointsItems())
  498. {
  499. plot->SetUserBounds(plotBounds);
  500. }
  501. }
  502. // ----------------------------------------------------------------------------
  503. void ctkVTKScalarsToColorsView::editPoint(vtkObject* caller, void* callData)
  504. {
  505. vtkControlPointsItem* controlPoints = reinterpret_cast<vtkControlPointsItem*>(caller);
  506. int pointToEdit = reinterpret_cast<unsigned long>(callData);
  507. if (!controlPoints || pointToEdit < 0)
  508. {
  509. return;
  510. }
  511. vtkColorTransferControlPointsItem* colorTransferFunctionItem =
  512. vtkColorTransferControlPointsItem::SafeDownCast(controlPoints);
  513. vtkCompositeControlPointsItem* compositeControlPoints =
  514. vtkCompositeControlPointsItem::SafeDownCast(controlPoints);
  515. if (colorTransferFunctionItem &&
  516. (!compositeControlPoints ||
  517. compositeControlPoints->GetPointsFunction() == vtkCompositeControlPointsItem::ColorPointsFunction ||
  518. compositeControlPoints->GetPointsFunction() == vtkCompositeControlPointsItem::ColorAndOpacityPointsFunction))
  519. {
  520. double xrgbms[6];
  521. vtkColorTransferFunction* colorTF = colorTransferFunctionItem->GetColorTransferFunction();
  522. colorTF->GetNodeValue(pointToEdit, xrgbms);
  523. QColor oldColor = QColor::fromRgbF(xrgbms[1], xrgbms[2], xrgbms[3]);
  524. QColor newColor = QColorDialog::getColor(oldColor, this);
  525. if (newColor.isValid())
  526. {
  527. xrgbms[1] = newColor.redF();
  528. xrgbms[2] = newColor.greenF();
  529. xrgbms[3] = newColor.blueF();
  530. colorTF->SetNodeValue(pointToEdit, xrgbms);
  531. }
  532. }
  533. }
  534. // ----------------------------------------------------------------------------
  535. void ctkVTKScalarsToColorsView::boundAxesToChartBounds()
  536. {
  537. this->Superclass::boundAxesToChartBounds();
  538. /// We only set the plot user bounds if the chart is using User bounds.
  539. double userBounds[8];
  540. this->chartUserBounds(userBounds);
  541. if (userBounds[0] < userBounds[1])
  542. {
  543. this->setPlotsUserBounds(userBounds);
  544. }
  545. }
  546. // ----------------------------------------------------------------------------
  547. void ctkVTKScalarsToColorsView::moveAllPoints(double xOffset, double yOffset,
  548. bool dontMoveFirstAndLast)
  549. {
  550. vtkVector2f offset(xOffset, yOffset);
  551. foreach(vtkControlPointsItem* controlPointsItem, this->controlPointsItems())
  552. {
  553. controlPointsItem->MovePoints(offset, dontMoveFirstAndLast);
  554. }
  555. }
  556. // ----------------------------------------------------------------------------
  557. void ctkVTKScalarsToColorsView::spreadAllPoints(double factor,
  558. bool dontSpreadFirstAndLast)
  559. {
  560. foreach(vtkControlPointsItem* controlPointsItem, this->controlPointsItems())
  561. {
  562. controlPointsItem->SpreadPoints(factor, dontSpreadFirstAndLast);
  563. }
  564. }