forked from Rsnelllenberg/VolumeProjectorPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaterialTransitionsAction.h
More file actions
89 lines (64 loc) · 3.59 KB
/
Copy pathMaterialTransitionsAction.h
File metadata and controls
89 lines (64 loc) · 3.59 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
#pragma once
#include "actions/WidgetAction.h"
#include "InteractiveShape.h"
#include <QVBoxLayout>
#include <QColorDialog>
#include <QTableWidget>
using namespace mv::gui;
class TransferFunctionPlugin;
class MaterialTransitionsAction : public WidgetAction
{
Q_OBJECT
public:
/**
* Constructor
* @param parent Pointer to parent object
* @param title Title of the action
*/
Q_INVOKABLE MaterialTransitionsAction(QObject* parent, const QString& title);
void initialize(TransferFunctionPlugin* transferFunctionPlugin);
std::vector<std::vector<QColor>> getTransitions() const { return _materialTransitionTable; }
std::tuple<int, int> getSelectedTransition() const { return _selectedTransition; }
void setColorOfCell(int row, int column, const QColor& color);
void setUseGlobalAlpha(bool useGlobalAlpha);
void setGlobalAlphaValue(int globalAlphaValue);
protected: // Linking
void setTransitions(const std::vector<std::vector<QColor>>& transitions);
void setSelectedTransition(const std::tuple<int, int>& selectedTransition);
void connectToPublicAction(WidgetAction* publicAction, bool recursive) override;
void disconnectFromPublicAction(bool recursive) override;
public: // Serialization
void fromVariantMap(const QVariantMap& variantMap) override;
QVariantMap toVariantMap() const override;
signals:
void transitionChanged(const std::vector<std::vector<QColor>>& transitions);
void headersChanged(const std::vector<InteractiveShape>& interactiveShapes);
void transitionSelected(int row, int column);
void globalAlphaToggled(bool useGlobalAlpha);
void globalAlphaChanged(int globalAlphaValue);
void tableUpdateNeeded(const std::vector<InteractiveShape>& interactiveShapes, const std::vector<std::vector<QColor>>& transitions);
protected:
TransferFunctionPlugin* _transferFunctionPlugin; /** Pointer to scatterplot plugin */
std::vector<std::vector<QColor>> _materialTransitionTable; /** Table of colors for the transitions */
std::vector<InteractiveShape> _interactiveShapes; /** Most recent list of interactive shapes */
std::tuple<int, int> _selectedTransition; /** Currently selected transition */
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 */
friend class mv::AbstractActionsManager;
class Widget : public WidgetActionWidget {
protected:
Widget(QWidget* parent, MaterialTransitionsAction* materialTransitionsAction);
protected:
QVBoxLayout _layout; /** Main layout */
QTableWidget _tableWidget; /** Table widget to display colored cubes */
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;
void updateTable(const std::vector<std::vector<QColor>>& transitions);
void updateHeaderColors(const std::vector<InteractiveShape>& interactiveShapes);
friend class MaterialTransitionsAction;
};
QWidget* getWidget(QWidget* parent, const std::int32_t& widgetFlags) override {
return new Widget(parent, this);
};
};
Q_DECLARE_METATYPE(MaterialTransitionsAction)
inline const auto materialTransitionsActionMetaTypeId = qRegisterMetaType<MaterialTransitionsAction*>("MaterialTransitionsAction*");