MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TransferFunctionViewer.hpp
1 #ifndef QTRANSFERFUNCTIONVIEWER_HPP
2 #define QTRANSFERFUNCTIONVIEWER_HPP
3 
4 #include "Config.hpp"
5 #include <QLinearGradient>
6 #include <QWidget>
7 #include <QColor>
8 #include <QPainterPath>
9 #include "TransferFunction.hpp"
10 
11 #include <vector>
12 
13 class QMouseEvent;
14 class QPixmap;
15 class QAction;
16 class QPaintEvent;
17 
18 class mgxBase_EXPORT QTransferFunctionViewer : public QWidget
19 {
20  Q_OBJECT
21 public:
22  typedef TransferFunction::Colorf Colorf;
23  enum BackgroundType
24  {
25  BG_CHECKS,
26  BG_WHITE,
27  BG_BLACK
28  };
29 
30  QTransferFunctionViewer(QWidget *parent = 0, Qt::WindowFlags f = 0);
31  virtual ~QTransferFunctionViewer() {}
32 
33  size_t nbValues() const;
34 
35  const TransferFunction& transferFunction() const { return transfer_fct; }
36 
37 public slots:
38  void changeNbValues(int n);
39  void reverseFunction();
40  void changeTransferFunction(const TransferFunction& fct);
41  void setupGradient();
42  void setHistogram(const std::vector<double>& h);
43  void setBounds(double min, double max);
44  void setStickers(const std::vector<double>& s);
45  void setMarkerSize(int s);
46  void setCheckSize(int s);
47  void setBackgroundType(BackgroundType type);
48  void setInterpolation(TransferFunction::Interpolation i);
49  void setSelectionColor(QColor col);
50  void editMarkers();
51  void autoAdjust();
52 
53 signals:
54  void changedTransferFunction(const TransferFunction& fct);
55 
56 protected:
57  void paintEvent(QPaintEvent *event);
61  void mouseMoveEvent(QMouseEvent *e);
62  void resetMouseInteraction();
63 
64  void prepareHistogram();
65 
66  void createBackground();
67  QPixmap createChecks();
68 
69  TransferFunction transfer_fct;
70  std::vector<double> histogram, hist_values;
71  double minValue, maxValue;
72  QPainterPath hist_shape;
73  bool use_histogram;
74  std::vector<double> stickers;
75  bool sticking;
76  int marker_size;
77  bool select_pos;
78  double current_pos;
79  int bg_size;
80  double bg_bright;
81  double bg_dark;
82  QColor activ_pos_color;
83  Colorf saved_color;
84  double saved_pos;
85  QAction *reverse_act, *edit_markers;
86  QLinearGradient gradient;
87  BackgroundType bg_type;
88  size_t _nb_values;
89 };
90 
91 #endif
92 
mouseReleaseEvent(QMouseEvent *event)
paintEvent(QPaintEvent *event)
mousePressEvent(QMouseEvent *event)
mouseMoveEvent(QMouseEvent *event)
mouseDoubleClickEvent(QMouseEvent *event)
Definition: TransferFunctionViewer.hpp:18