ctkVTKScalarsToColorsView.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  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. this->setAxesToChartBounds();
  122. this->Superclass::onChartUpdated();
  123. }
  124. // ----------------------------------------------------------------------------
  125. vtkPlot* ctkVTKScalarsToColorsView::addLookupTable(vtkLookupTable* lut)
  126. {
  127. vtkSmartPointer<vtkLookupTableItem> item =
  128. vtkSmartPointer<vtkLookupTableItem>::New();
  129. item->SetLookupTable(lut);
  130. this->addPlot(item);
  131. return item;
  132. }
  133. // ----------------------------------------------------------------------------
  134. vtkPlot* ctkVTKScalarsToColorsView
  135. ::addColorTransferFunction(vtkColorTransferFunction* colorTF,
  136. bool editable)
  137. {
  138. vtkSmartPointer<vtkColorTransferFunctionItem> item =
  139. vtkSmartPointer<vtkColorTransferFunctionItem>::New();
  140. item->SetColorTransferFunction(colorTF);
  141. this->addPlot(item);
  142. if (editable)
  143. {
  144. this->addColorTransferFunctionControlPoints(colorTF);
  145. }
  146. return item;
  147. }
  148. // ----------------------------------------------------------------------------
  149. vtkPlot* ctkVTKScalarsToColorsView
  150. ::addOpacityFunction(vtkPiecewiseFunction* opacityTF,
  151. bool editable)
  152. {
  153. return this->addPiecewiseFunction(opacityTF, editable);
  154. }
  155. // ----------------------------------------------------------------------------
  156. vtkPlot* ctkVTKScalarsToColorsView
  157. ::addPiecewiseFunction(vtkPiecewiseFunction* piecewiseTF,
  158. bool editable)
  159. {
  160. vtkSmartPointer<vtkPiecewiseFunctionItem> item =
  161. vtkSmartPointer<vtkPiecewiseFunctionItem>::New();
  162. item->SetPiecewiseFunction(piecewiseTF);
  163. QColor defaultColor = this->palette().highlight().color();
  164. item->SetColor(defaultColor.redF(), defaultColor.greenF(), defaultColor.blueF());
  165. item->SetMaskAboveCurve(true);
  166. this->addPlot(item);
  167. if (editable)
  168. {
  169. this->addPiecewiseFunctionControlPoints(piecewiseTF);
  170. }
  171. return item;
  172. }
  173. // ----------------------------------------------------------------------------
  174. vtkPlot* ctkVTKScalarsToColorsView
  175. ::addCompositeFunction(vtkColorTransferFunction* colorTF,
  176. vtkPiecewiseFunction* opacityTF,
  177. bool colorTFEditable, bool opacityTFEditable)
  178. {
  179. vtkSmartPointer<vtkCompositeTransferFunctionItem> item =
  180. vtkSmartPointer<vtkCompositeTransferFunctionItem>::New();
  181. item->SetColorTransferFunction(colorTF);
  182. item->SetOpacityFunction(opacityTF);
  183. item->SetMaskAboveCurve(true);
  184. this->addPlot(item);
  185. if (colorTFEditable && opacityTFEditable)
  186. {
  187. this->addCompositeFunctionControlPoints(colorTF, opacityTF);
  188. }
  189. else if (colorTFEditable)
  190. {
  191. this->addColorTransferFunctionControlPoints(colorTF);
  192. }
  193. else if (opacityTFEditable)
  194. {
  195. this->addOpacityFunctionControlPoints(opacityTF);
  196. }
  197. return item;
  198. }
  199. // ----------------------------------------------------------------------------
  200. vtkPlot* ctkVTKScalarsToColorsView
  201. ::addColorTransferFunctionControlPoints(vtkColorTransferFunction* colorTF)
  202. {
  203. Q_D(ctkVTKScalarsToColorsView);
  204. vtkSmartPointer<vtkColorTransferControlPointsItem> controlPointsItem =
  205. vtkSmartPointer<vtkColorTransferControlPointsItem>::New();
  206. controlPointsItem->SetColorTransferFunction(colorTF);
  207. controlPointsItem->SetValidBounds(d->ValidBounds);
  208. this->addPlot(controlPointsItem);
  209. return controlPointsItem;
  210. }
  211. // ----------------------------------------------------------------------------
  212. vtkPlot* ctkVTKScalarsToColorsView
  213. ::addOpacityFunctionControlPoints(vtkPiecewiseFunction* opacityTF)
  214. {
  215. return this->addPiecewiseFunctionControlPoints(opacityTF);
  216. }
  217. // ----------------------------------------------------------------------------
  218. vtkPlot* ctkVTKScalarsToColorsView
  219. ::addCompositeFunctionControlPoints(vtkColorTransferFunction* colorTF,
  220. vtkPiecewiseFunction* opacityTF)
  221. {
  222. Q_D(ctkVTKScalarsToColorsView);
  223. vtkSmartPointer<vtkCompositeControlPointsItem> controlPointsItem =
  224. vtkSmartPointer<vtkCompositeControlPointsItem>::New();
  225. controlPointsItem->SetColorTransferFunction(colorTF);
  226. controlPointsItem->SetOpacityFunction(opacityTF);
  227. controlPointsItem->SetValidBounds(d->ValidBounds);
  228. this->addPlot(controlPointsItem);
  229. return controlPointsItem;
  230. }
  231. // ----------------------------------------------------------------------------
  232. vtkPlot* ctkVTKScalarsToColorsView
  233. ::addPiecewiseFunctionControlPoints(vtkPiecewiseFunction* piecewiseTF)
  234. {
  235. Q_D(ctkVTKScalarsToColorsView);
  236. vtkSmartPointer<vtkPiecewiseControlPointsItem> controlPointsItem =
  237. vtkSmartPointer<vtkPiecewiseControlPointsItem>::New();
  238. controlPointsItem->SetPiecewiseFunction(piecewiseTF);
  239. controlPointsItem->SetValidBounds(d->ValidBounds);
  240. this->addPlot(controlPointsItem);
  241. return controlPointsItem;
  242. }
  243. // ----------------------------------------------------------------------------
  244. QList<vtkPlot*> ctkVTKScalarsToColorsView::plots()const
  245. {
  246. QList<vtkPlot*> res;
  247. const vtkIdType count = this->chart()->GetNumberOfPlots();
  248. for(vtkIdType i = 0; i < count; ++i)
  249. {
  250. res << this->chart()->GetPlot(i);
  251. }
  252. return res;
  253. }
  254. // ----------------------------------------------------------------------------
  255. QList<vtkControlPointsItem*> ctkVTKScalarsToColorsView
  256. ::controlPointsItems()const
  257. {
  258. QList<vtkControlPointsItem*> res;
  259. foreach(vtkPlot* plot, this->plots())
  260. {
  261. vtkControlPointsItem* controlPointsItem =
  262. vtkControlPointsItem::SafeDownCast(plot);
  263. if (controlPointsItem)
  264. {
  265. res << controlPointsItem;
  266. }
  267. }
  268. return res;
  269. }
  270. // ----------------------------------------------------------------------------
  271. QList<vtkPlot*> ctkVTKScalarsToColorsView::lookupTablePlots()const
  272. {
  273. QList<vtkPlot*> res;
  274. foreach(vtkPlot* plot, this->plots())
  275. {
  276. if (vtkLookupTableItem::SafeDownCast(plot))
  277. {
  278. res << plot;
  279. }
  280. }
  281. return res;
  282. }
  283. // ----------------------------------------------------------------------------
  284. QList<vtkPlot*> ctkVTKScalarsToColorsView::lookupTablePlots(vtkLookupTable* lut)const
  285. {
  286. QList<vtkPlot*> res;
  287. foreach(vtkPlot* plot, this->lookupTablePlots())
  288. {
  289. vtkLookupTableItem* item = vtkLookupTableItem::SafeDownCast(plot);
  290. if (item->GetLookupTable() == lut)
  291. {
  292. res << plot;
  293. }
  294. }
  295. return res;
  296. }
  297. // ----------------------------------------------------------------------------
  298. QList<vtkPlot*> ctkVTKScalarsToColorsView::colorTransferFunctionPlots()const
  299. {
  300. QList<vtkPlot*> res;
  301. foreach(vtkPlot* plot, this->plots())
  302. {
  303. if (vtkColorTransferFunctionItem::SafeDownCast(plot) ||
  304. vtkColorTransferControlPointsItem::SafeDownCast(plot))
  305. {
  306. res << plot;
  307. }
  308. }
  309. return res;
  310. }
  311. // ----------------------------------------------------------------------------
  312. QList<vtkPlot*> ctkVTKScalarsToColorsView
  313. ::colorTransferFunctionPlots(vtkColorTransferFunction* colorTF)const
  314. {
  315. QList<vtkPlot*> res;
  316. foreach(vtkPlot* plot, this->colorTransferFunctionPlots())
  317. {
  318. vtkColorTransferFunctionItem* item =
  319. vtkColorTransferFunctionItem::SafeDownCast(plot);
  320. if (item
  321. && item->GetColorTransferFunction() == colorTF)
  322. {
  323. res << plot;
  324. }
  325. vtkColorTransferControlPointsItem* controlPointsItem =
  326. vtkColorTransferControlPointsItem::SafeDownCast(plot);
  327. if (controlPointsItem
  328. && controlPointsItem->GetColorTransferFunction() == colorTF)
  329. {
  330. res << plot;
  331. }
  332. }
  333. return res;
  334. }
  335. // ----------------------------------------------------------------------------
  336. QList<vtkPlot*> ctkVTKScalarsToColorsView::opacityFunctionPlots()const
  337. {
  338. QList<vtkPlot*> res;
  339. foreach(vtkPlot* plot, this->plots())
  340. {
  341. if (vtkPiecewiseFunctionItem::SafeDownCast(plot) ||
  342. vtkPiecewiseControlPointsItem::SafeDownCast(plot) ||
  343. vtkCompositeTransferFunctionItem::SafeDownCast(plot) ||
  344. vtkCompositeControlPointsItem::SafeDownCast(plot))
  345. {
  346. res << plot;
  347. }
  348. }
  349. return res;
  350. }
  351. // ----------------------------------------------------------------------------
  352. QList<vtkPlot*> ctkVTKScalarsToColorsView
  353. ::opacityFunctionPlots(vtkPiecewiseFunction* opacityTF)const
  354. {
  355. QList<vtkPlot*> res;
  356. foreach(vtkPlot* plot, this->opacityFunctionPlots())
  357. {
  358. vtkPiecewiseFunctionItem* item =
  359. vtkPiecewiseFunctionItem::SafeDownCast(plot);
  360. if (item
  361. && item->GetPiecewiseFunction() == opacityTF)
  362. {
  363. res << plot;
  364. }
  365. vtkPiecewiseControlPointsItem* controlPointsItem =
  366. vtkPiecewiseControlPointsItem::SafeDownCast(plot);
  367. if (controlPointsItem
  368. && controlPointsItem->GetPiecewiseFunction() == opacityTF)
  369. {
  370. res << plot;
  371. }
  372. vtkCompositeTransferFunctionItem* compositeItem =
  373. vtkCompositeTransferFunctionItem::SafeDownCast(plot);
  374. if (compositeItem
  375. && compositeItem->GetOpacityFunction() == opacityTF)
  376. {
  377. res << plot;
  378. }
  379. vtkCompositeControlPointsItem* compositeControlPointsItem =
  380. vtkCompositeControlPointsItem::SafeDownCast(plot);
  381. if (compositeControlPointsItem
  382. && compositeControlPointsItem->GetOpacityFunction() == opacityTF)
  383. {
  384. res << plot;
  385. }
  386. }
  387. return res;
  388. }
  389. // ----------------------------------------------------------------------------
  390. void ctkVTKScalarsToColorsView::setLookuptTableToPlots(vtkLookupTable* lut)
  391. {
  392. foreach(vtkLookupTableItem* plot,
  393. this->plots<vtkLookupTableItem>())
  394. {
  395. plot->SetLookupTable(lut);
  396. }
  397. this->onChartUpdated();
  398. }
  399. // ----------------------------------------------------------------------------
  400. void ctkVTKScalarsToColorsView
  401. ::setColorTransferFunctionToPlots(vtkColorTransferFunction* colorTF)
  402. {
  403. foreach(vtkColorTransferFunctionItem* plot,
  404. this->plots<vtkColorTransferFunctionItem>())
  405. {
  406. plot->SetColorTransferFunction(colorTF);
  407. }
  408. foreach(vtkColorTransferControlPointsItem* plot,
  409. this->plots<vtkColorTransferControlPointsItem>())
  410. {
  411. plot->SetColorTransferFunction(colorTF);
  412. }
  413. this->onChartUpdated();
  414. }
  415. // ----------------------------------------------------------------------------
  416. void ctkVTKScalarsToColorsView
  417. ::setOpacityFunctionToPlots(vtkPiecewiseFunction* opacityTF)
  418. {
  419. this->setPiecewiseFunctionToPlots(opacityTF);
  420. foreach(vtkCompositeTransferFunctionItem* plot,
  421. this->plots<vtkCompositeTransferFunctionItem>())
  422. {
  423. plot->SetOpacityFunction(opacityTF);
  424. }
  425. foreach(vtkCompositeControlPointsItem* plot,
  426. this->plots<vtkCompositeControlPointsItem>())
  427. {
  428. plot->SetOpacityFunction(opacityTF);
  429. }
  430. this->onChartUpdated();
  431. }
  432. // ----------------------------------------------------------------------------
  433. void ctkVTKScalarsToColorsView
  434. ::setPiecewiseFunctionToPlots(vtkPiecewiseFunction* piecewiseTF)
  435. {
  436. foreach(vtkPiecewiseFunctionItem* plot,
  437. this->plots<vtkPiecewiseFunctionItem>())
  438. {
  439. plot->SetPiecewiseFunction(piecewiseTF);
  440. }
  441. foreach(vtkPiecewiseControlPointsItem* plot,
  442. this->plots<vtkPiecewiseControlPointsItem>())
  443. {
  444. plot->SetPiecewiseFunction(piecewiseTF);
  445. }
  446. this->onChartUpdated();
  447. }
  448. // ----------------------------------------------------------------------------
  449. bool ctkVTKScalarsToColorsView
  450. ::areBordersVisible()const
  451. {
  452. return this->chart()->GetAxis(0)->GetVisible();
  453. }
  454. // ----------------------------------------------------------------------------
  455. void ctkVTKScalarsToColorsView
  456. ::setBordersVisible(bool show)
  457. {
  458. Q_D(ctkVTKScalarsToColorsView);
  459. d->showBorders(show);
  460. }
  461. // ----------------------------------------------------------------------------
  462. void ctkVTKScalarsToColorsView
  463. ::validBounds(double* bounds)const
  464. {
  465. Q_D(const ctkVTKScalarsToColorsView);
  466. memcpy(bounds, d->ValidBounds, 4 * sizeof(double));
  467. }
  468. // ----------------------------------------------------------------------------
  469. void ctkVTKScalarsToColorsView
  470. ::setValidBounds(double* bounds)
  471. {
  472. Q_D(ctkVTKScalarsToColorsView);
  473. foreach(vtkControlPointsItem* plot, this->controlPointsItems())
  474. {
  475. plot->SetValidBounds(bounds);
  476. }
  477. memcpy(d->ValidBounds, bounds, 4 * sizeof(double));
  478. }
  479. // ----------------------------------------------------------------------------
  480. void ctkVTKScalarsToColorsView
  481. ::setPlotsUserBounds(double* bounds)
  482. {
  483. double plotBounds[4];
  484. this->chartBoundsToPlotBounds(bounds, plotBounds);
  485. foreach(vtkScalarsToColorsItem* plot,
  486. this->plots<vtkScalarsToColorsItem>())
  487. {
  488. plot->SetUserBounds(plotBounds);
  489. }
  490. foreach(vtkControlPointsItem* plot, this->controlPointsItems())
  491. {
  492. plot->SetUserBounds(plotBounds);
  493. }
  494. }
  495. // ----------------------------------------------------------------------------
  496. void ctkVTKScalarsToColorsView::editPoint(vtkObject* caller, void* callData)
  497. {
  498. vtkControlPointsItem* controlPoints = reinterpret_cast<vtkControlPointsItem*>(caller);
  499. int pointToEdit = reinterpret_cast<unsigned long>(callData);
  500. if (!controlPoints || pointToEdit < 0)
  501. {
  502. return;
  503. }
  504. vtkColorTransferControlPointsItem* colorTransferFunctionItem =
  505. vtkColorTransferControlPointsItem::SafeDownCast(controlPoints);
  506. vtkCompositeControlPointsItem* compositeControlPoints =
  507. vtkCompositeControlPointsItem::SafeDownCast(controlPoints);
  508. if (colorTransferFunctionItem &&
  509. (!compositeControlPoints ||
  510. compositeControlPoints->GetPointsFunction() == vtkCompositeControlPointsItem::ColorPointsFunction ||
  511. compositeControlPoints->GetPointsFunction() == vtkCompositeControlPointsItem::ColorAndOpacityPointsFunction))
  512. {
  513. double xrgbms[6];
  514. vtkColorTransferFunction* colorTF = colorTransferFunctionItem->GetColorTransferFunction();
  515. colorTF->GetNodeValue(pointToEdit, xrgbms);
  516. QColor oldColor = QColor::fromRgbF(xrgbms[1], xrgbms[2], xrgbms[3]);
  517. QColor newColor = QColorDialog::getColor(oldColor, this);
  518. if (newColor.isValid())
  519. {
  520. xrgbms[1] = newColor.redF();
  521. xrgbms[2] = newColor.greenF();
  522. xrgbms[3] = newColor.blueF();
  523. colorTF->SetNodeValue(pointToEdit, xrgbms);
  524. }
  525. }
  526. }
  527. // ----------------------------------------------------------------------------
  528. void ctkVTKScalarsToColorsView::boundAxesToChartBounds()
  529. {
  530. this->Superclass::boundAxesToChartBounds();
  531. /// We only set the plot user bounds if the chart is using User bounds.
  532. double userBounds[8];
  533. this->chartUserBounds(userBounds);
  534. if (userBounds[0] < userBounds[1])
  535. {
  536. this->setPlotsUserBounds(userBounds);
  537. }
  538. }
  539. // ----------------------------------------------------------------------------
  540. void ctkVTKScalarsToColorsView::moveAllPoints(double xOffset, double yOffset,
  541. bool dontMoveFirstAndLast)
  542. {
  543. vtkVector2f offset(xOffset, yOffset);
  544. foreach(vtkControlPointsItem* controlPointsItem, this->controlPointsItems())
  545. {
  546. controlPointsItem->MovePoints(offset, dontMoveFirstAndLast);
  547. }
  548. }
  549. // ----------------------------------------------------------------------------
  550. void ctkVTKScalarsToColorsView::spreadAllPoints(double factor,
  551. bool dontSpreadFirstAndLast)
  552. {
  553. foreach(vtkControlPointsItem* controlPointsItem, this->controlPointsItems())
  554. {
  555. controlPointsItem->SpreadPoints(factor, dontSpreadFirstAndLast);
  556. }
  557. }