GlobeEngine
TransferFunctionEditor.h
Go to the documentation of this file.
1 
9 #ifndef GlobeEngine_TransferFunctionEditor_h
10 #define GlobeEngine_TransferFunctionEditor_h
11 
12 #include "OpenGL_Includes.h"
13 #include "VBOVertex.h"
14 
15 #include <QDebug>
16 #include <QObject>
17 #include <QMouseEvent>
18 #include <QPaintEvent>
19 #include <QPainter>
20 #include <QColorDialog>
21 #include <QLabel>
22 #include <QFileDialog>
23 #include <QPushButton>
24 #include <QGroupBox>
25 #include <QRadioButton>
26 #include <QHBoxLayout>
27 #include <QEasingCurve>
28 #include <QComboBox>
29 
30 namespace geQT {
31 
33  QMap<int, int> points;
34  QMap<int, QColor> colors;
35  QMap<int, int> gradients;
36  QMap<int, QPointF> controls1;
37  QMap<int, QPointF> controls2;
38  };
39 
40  class TransferFunctionEditor : public QWidget
41  {
42  Q_OBJECT
43 
44  public:
45  TransferFunctionEditor(QWidget* _parent, QColorDialog* _colorDialog);
47 
48  unsigned char* getTextureData();
49 
50  void setHistogramData(std::vector<std::vector<std::vector<long>>> histograms, std::vector<std::vector<float>> minimumHistValue, std::vector<std::vector<float>> maximumHistValue);
51  void initialize(int _numberOfTimesteps);
52 
53  void setSomething();
54 
55  //std::vector<ge::Color4ub> getColors();
56  std::vector<float> getHeights();
57 
58  void setCurrent(int _currentAttribute, int _currentTimestep, int _currentMarching) {
59  this->activePoint = -1;
60  this->currentAttribute = _currentAttribute;
61  this->currentTimestep = _currentTimestep;
62  this->currentMarching = _currentMarching;
63  }
64 
65  public slots:
66  void test();
67 
68  void save();
69  void load();
70  void loadFromFile(std::string _file);
71  void setInterpolationType();
72 
73 
74  signals:
76 
77  private:
78  void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
79  void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
80  void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
81 
82  void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
83 
84  void keepMouseWithinScope(QPoint pos);
85  QPoint keepControlPointWithinScope(int left, int up, int right, int down);
86 
87  void setGradientType(int _gradientType);
88  int getGradientType();
89 
90  bool multiplied = false;
91 
92  QColor interpolate(QColor color1, QColor color2, float t);
93 
94  std::vector<std::vector<TransferFunctionProperties>> tempStore;
95  std::vector<std::vector<float>> minimumHistValues;
96  std::vector<std::vector<float>> maximumHistValues;
97  std::vector<std::vector<std::vector<long>>> histograms;
98 
99  int currentAttribute = 0;
100  int currentTimestep = 0;
101  int currentMarching = 0;
102 
103  // user intentions
104  QPoint currentPosition;
105  QPoint lastPosition; // make int only?!?!
106 
107  // current variables
108  bool interacting = false;
109  bool leftClick;
110  bool clickedStartPoint;
111  int activePoint;
112 
113  // ui settings
114  int pointRadius = 5;
115  const int border = 20;
116  QColorDialog* colorDialog;
117 
118  // histogram
119  QList<float> list;
120  const int binSize = 20;
121 
122  QVector<float> binLimits;
123 
124  int movedControl1;
125  int movedControl2;
126 
127  qreal resolution;
128  int textureWidth = 1000;
129 
130  unsigned char* data;
131 
132  QRadioButton* linear;
133  QRadioButton* bezier;
134  QRadioButton* staircase;
135  QComboBox* colorInterpolation;
136  };
137 }
138 #endif // TRANSFERFUNCTIONEDITORTWO_H
void load()
Definition: TransferFunctionEditor.cpp:781
std::vector< float > getHeights()
Definition: TransferFunctionEditor.cpp:937
void save()
Definition: TransferFunctionEditor.cpp:714
TransferFunctionEditor(QWidget *_parent, QColorDialog *_colorDialog)
Definition: TransferFunctionEditor.cpp:6
QMap< int, QPointF > controls1
Definition: TransferFunctionEditor.h:36
void setHistogramData(std::vector< std::vector< std::vector< long >>> histograms, std::vector< std::vector< float >> minimumHistValue, std::vector< std::vector< float >> maximumHistValue)
Definition: TransferFunctionEditor.cpp:919
unsigned char * getTextureData()
Definition: TransferFunctionEditor.cpp:674
Definition: TransferFunctionEditor.h:40
Definition: TransferFunctionEditor.h:32
QMap< int, QColor > colors
Definition: TransferFunctionEditor.h:34
void initialize(int _numberOfTimesteps)
Definition: TransferFunctionEditor.cpp:49
void setInterpolationType()
Definition: TransferFunctionEditor.cpp:947
void setCurrent(int _currentAttribute, int _currentTimestep, int _currentMarching)
Definition: TransferFunctionEditor.h:58
Definition: ClickableQLabel.h:8
void test()
Definition: TransferFunctionEditor.cpp:661
void loadFromFile(std::string _file)
Definition: TransferFunctionEditor.cpp:735
~TransferFunctionEditor()
Definition: TransferFunctionEditor.h:46
QMap< int, int > points
Definition: TransferFunctionEditor.h:33
QMap< int, int > gradients
Definition: TransferFunctionEditor.h:35
QMap< int, QPointF > controls2
Definition: TransferFunctionEditor.h:37