forked from Rsnelllenberg/VolumeProjectorPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransferFunctionWidget.h
More file actions
185 lines (142 loc) · 6.97 KB
/
Copy pathTransferFunctionWidget.h
File metadata and controls
185 lines (142 loc) · 6.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#pragma once
#include <renderers/DensityRenderer.h>
#include <renderers/PointRenderer.h>
#include <util/PixelSelectionTool.h>
#include <graphics/Vector2f.h>
#include <QOpenGLFunctions_3_3_Core>
#include <QOpenGLWidget>
#include <QPoint>
#include "InteractiveShape.h"
#include "ImageData/Images.h"
class TransferFunctionPlugin;
using namespace mv::gui;
using namespace mv::util;
struct widgetSizeInfo {
float width;
float height;
float minWH;
float ratioWidth;
float ratioHeight;
};
class TransferFunctionWidget : public QOpenGLWidget, protected QOpenGLFunctions_3_3_Core
{
Q_OBJECT
public:
TransferFunctionWidget();
~TransferFunctionWidget();
QRect getMousePositionsBounds(QPoint newMousePosition);
/** Returns true when the widget was initialized and is ready to be used. */
bool isInitialized() const;
// This method is public because the UI decides when to update the widget
void updateMaterialTransitionTexture(const std::vector<std::vector<QColor>>& transitionsTable);
InteractiveShape* getSelectedObject() { return _selectedObject; }
std::vector<InteractiveShape>& getInteractiveShapes() { return _interactiveShapes; }
/**
* Get the pixel selection tool
* @return Reference to the pixel selection tool
*/
PixelSelectionTool& getPixelSelectionTool();
/**
* Feed 2-dimensional data to the transferFunction.
*/
void setData(const std::vector<mv::Vector2f>* points);
void setHighlights(const std::vector<char>& highlights, const std::int32_t& numSelectedPoints);
/**
* Set point size
*/
void setPointSize(float pointSize);
/**
* Set point opacity
*/
void setPointOpacity(float pointOpacity);
void showHighlights(bool show);
void setGlobalAlphaToggle(bool useGlobalAlpha);
void setGlobalAlphaValue(int globalAlphaValue);
public: // Selection
/**
* Get the selection display mode color
* @return Selection display mode
*/
PointSelectionDisplayMode getSelectionDisplayMode() const;
/**
* Set the selection display mode
* @param selectionDisplayMode Selection display mode
*/
void setSelectionDisplayMode(PointSelectionDisplayMode selectionDisplayMode);
/**
* Set whether the selection outline halo is enabled or not
* @param randomizedDepth Boolean determining whether the selection outline halo is enabled or not
*/
void setRandomizedDepthEnabled(bool randomizedDepth);
/**
* Set whether the z-order of each point is to be randomized or not
* @param selectionOutlineHaloEnabled Boolean determining whether the z-order of each point is to be randomized or not
*/
void setSelectionOutlineHaloEnabled(bool selectionOutlineHaloEnabled);
/**
* Get whether the z-order of each point is to be randomized or not
* @return Boolean determining whether the z-order of each point is to be randomized or not
*/
bool getRandomizedDepthEnabled() const;
public: // Navigators
/**
* Get the navigator for the point renderer
* @return Reference to the navigator
*/
mv::Navigator2D& getPointRendererNavigator() { return _pointRenderer.getNavigator(); }
protected:
void initializeGL() Q_DECL_OVERRIDE;
void resizeGL(int w, int h) Q_DECL_OVERRIDE;
void paintGL() Q_DECL_OVERRIDE;
void paintPixelSelectionToolNative(PixelSelectionTool& pixelSelectionTool, QImage& image) const;
void updateTfTexture();
void updateMaterialPositionsTexture();
void createDatasets();
void cleanup();
void showEvent(QShowEvent* event) Q_DECL_OVERRIDE
{
emit created();
QWidget::showEvent(event);
}
bool event(QEvent* event) override;
public: // Const access to renderers
const PointRenderer& getPointRenderer() const {
return _pointRenderer;
}
signals:
void initialized();
void created();
// Signals when a new shape gets selected and passes a pointer of it
void shapeSelected(InteractiveShape* shape);
void shapeCreated(const std::vector<InteractiveShape>& interactiveShapes);
void shapeDeleted(const std::vector<InteractiveShape>& interactiveShapes);
private slots:
void updatePixelRatio();
private:
mv::Dataset<Images> _tfTextures; /** Smart pointer to images dataset for point color */
mv::Dataset<Points> _tfSourceDataset; /** Smart pointer to points dataset for point position */
mv::Dataset<Images> _materialTransitionTexture; /** Smart pointer to images dataset for material transition texture */
mv::Dataset<Points> _materialTransitionSourceDataset; /** Smart pointer to points dataset for material transition points */
mv::Dataset<Images> _materialPositionTexture; /** Smart pointer to images dataset for material positions texture */
mv::Dataset<Points> _materialPositionSourceDataset; /** Smart pointer to points dataset for material positions points */
PointRenderer _pointRenderer; /** For rendering point data as points */
bool _isInitialized; /** Boolean determining whether the widget it properly initialized or not */
QColor _backgroundColor; /** Background color */
widgetSizeInfo _widgetSizeInfo; /** Info about size of the transferFunction widget */
DecimalRectangleAction _dataRectangleAction; /** Rectangle action for the bounds of the loaded data */
PixelSelectionTool _pixelSelectionTool; /** 2D pixel selection tool */
float _pixelRatio; /** Current pixel ratio */
QVector<QPoint> _mousePositions; /** Recorded mouse positions */
bool _mouseIsPressed; /** Boolean determining the mouse state */
QRect _areaSelectionBounds; /** Area selection bounds */
QRect _boundsPointsWindow; /** Bounds of the points in the UI window */
std::vector<InteractiveShape> _interactiveShapes; /** Stores all the interactive shapes in the transferfunction widget*/
InteractiveShape* _selectedObject = nullptr; /** Pointer to the selected object */
SelectedSide _selectedSide = SelectedSide::None; /** Selected side of the object */
bool _createShape = false; /** Boolean determining whether a shape is to be created or not */
bool _useGlobalAlpha = false; /** The global alpha changes the alpha value of all the colors the user sees on their screen not the colors that are passes along */
int _globalAlphaValue = 100;
const int _tfTextureSize = 512;
const int _materialTextureSize = 128;
const int _materialPositionTextureSize = 1024;
};