-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPointPlotAction.h
More file actions
137 lines (106 loc) · 4.3 KB
/
PointPlotAction.h
File metadata and controls
137 lines (106 loc) · 4.3 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
#pragma once
#include <actions/VerticalGroupAction.h>
#include "ScalarAction.h"
class ScatterplotPlugin;
using namespace mv::gui;
/**
* Point plot action class
*
* Action class for configuring point plot settings
*
* @author Thomas Kroes
*/
class PointPlotAction : public VerticalGroupAction
{
Q_OBJECT
public:
/**
* Construct with \p parent and \p title
* @param parent Pointer to parent object
* @param title Title of the action
*/
Q_INVOKABLE PointPlotAction(QObject* parent, const QString& title);
/**
* Initialize the selection action with \p scatterplotPlugin
* @param scatterplotPlugin Pointer to scatterplot plugin
*/
void initialize(ScatterplotPlugin* scatterplotPlugin);
/**
* Get action context menu
* @return Pointer to menu
*/
QMenu* getContextMenu();
/**
* Override to show/hide child actions
* @param visible Whether the action is visible or not
*/
void setVisible(bool visible);
/**
* Add point size dataset
* @param pointSizeDataset Smart pointer to point size dataset
*/
void addPointSizeDataset(const Dataset<DatasetImpl>& pointSizeDataset);
/**
* Add point opacity dataset
* @param pointOpacityDataset Smart pointer to point opacity dataset
*/
void addPointOpacityDataset(const Dataset<DatasetImpl>& pointOpacityDataset);
/**
* Set the current point size dataset
* @param pointSizeDataset Smart pointer to point size dataset
*/
void setCurrentPointSizeDataset(const Dataset<DatasetImpl>& pointSizeDataset);
/**
* Set the current opacity size dataset
* @param pointOpacityDataset Smart pointer to opacity size dataset
*/
void setCurrentPointOpacityDataset(const Dataset<DatasetImpl>& pointOpacityDataset);
protected:
/** Update default datasets (candidates are children of points type and with matching number of points) */
void updateDefaultDatasets();
/** Update the scatter plot widget point size scalars */
void updateScatterPlotWidgetPointSizeScalars();
/** Update the scatter plot widget point opacity scalars */
void updateScatterPlotWidgetPointOpacityScalars();
protected: // Linking
/**
* Connect this action to a public action
* @param publicAction Pointer to public action to connect to
* @param recursive Whether to also connect descendant child actions
*/
void connectToPublicAction(WidgetAction* publicAction, bool recursive) override;
/**
* Disconnect this action from its public action
* @param recursive Whether to also disconnect descendant child actions
*/
void disconnectFromPublicAction(bool recursive) override;
public: // Serialization
/**
* Load widget action from variant map
* @param Variant map representation of the widget action
*/
void fromVariantMap(const QVariantMap& variantMap) override;
/**
* Save widget action to variant map
* @return Variant map representation of the widget action
*/
QVariantMap toVariantMap() const override;
public: // Action getters
ScalarAction& getSizeAction() { return _sizeAction; }
ScalarAction& getOpacityAction() { return _opacityAction; }
ToggleAction& getFocusSelection() { return _focusSelection; }
private:
ScatterplotPlugin* _scatterplotPlugin; /** Pointer to scatterplot plugin */
ScalarAction _sizeAction; /** Point size action */
ScalarAction _opacityAction; /** Point opacity action */
std::vector<float> _pointSizeScalars; /** Cached point size scalars */
std::vector<float> _pointOpacityScalars; /** Cached point opacity scalars */
ToggleAction _focusSelection; /** Focus selection action */
std::int32_t _lastOpacitySourceIndex; /** Last opacity source index that was selected */
static constexpr double DEFAULT_POINT_SIZE = 10.0; /** Default point size */
static constexpr double DEFAULT_POINT_OPACITY = 50.0; /** Default point opacity */
friend class ScatterplotPlugin;
friend class mv::AbstractActionsManager;
};
Q_DECLARE_METATYPE(PointPlotAction)
inline const auto pointPlotActionMetaTypeId = qRegisterMetaType<PointPlotAction*>("PointPlotAction");