ctkVTKChartView.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifndef __ctkVTKChartView_h
  15. #define __ctkVTKChartView_h
  16. // CTK includes
  17. #include <ctkPimpl.h>
  18. #include "ctkVisualizationVTKWidgetsExport.h"
  19. class ctkVTKChartViewPrivate;
  20. // VTK includes
  21. #include <QVTKWidget.h>
  22. class vtkChartXY;
  23. class vtkContextScene;
  24. class vtkPlot;
  25. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKChartView : public QVTKWidget
  26. {
  27. Q_OBJECT
  28. Q_PROPERTY(QString title READ title WRITE setTitle)
  29. public:
  30. ctkVTKChartView(QWidget* parent = 0);
  31. virtual ~ctkVTKChartView();
  32. /// Generic function to add a custom plot. \a plot is added into the chart
  33. virtual void addPlot(vtkPlot* plot);
  34. /// Utility function that returns the view chart. It can be used for customizing
  35. /// the chart display options (axes, legend...)
  36. vtkChartXY* chart()const;
  37. vtkContextScene* scene()const;
  38. /// Title that appears inside the view
  39. QString title()const;
  40. void setTitle(const QString& title);
  41. /// Return the chart bounds for the 4 chart axes.
  42. /// bounds must be an array of 8 doubles.
  43. /// If no bounds is provided by the user, compute the bounds for the 4 chart
  44. /// axes from the vtkPlots bounds.
  45. void chartBounds(double* bounds)const;
  46. void setChartUserBounds(double* bounds);
  47. void chartUserBounds(double* bounds)const;
  48. ///
  49. virtual void setAxesToChartBounds();
  50. virtual void boundAxesToChartBounds();
  51. signals:
  52. void plotAdded(vtkPlot* plot);
  53. void boundsChanged();
  54. protected:
  55. QScopedPointer<ctkVTKChartViewPrivate> d_ptr;
  56. virtual void mouseDoubleClickEvent(QMouseEvent* event);
  57. virtual void onChartUpdated();
  58. void chartBoundsToPlotBounds(double bounds[8], double plotBounds[4])const;
  59. private:
  60. Q_DECLARE_PRIVATE(ctkVTKChartView);
  61. Q_DISABLE_COPY(ctkVTKChartView);
  62. };
  63. #endif