ctkVTKScalarsToColorsView.cpp 19 KB

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