-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathColoringAction.h
More file actions
148 lines (111 loc) · 4.67 KB
/
ColoringAction.h
File metadata and controls
148 lines (111 loc) · 4.67 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
#pragma once
#include <actions/ColorMap1DAction.h>
#include <actions/ColorMap2DAction.h>
#include <actions/VerticalGroupAction.h>
#include <PointData/DimensionPickerAction.h>
#include "ColorSourceModel.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QStackedWidget>
using namespace mv::gui;
class ScatterplotPlugin;
/**
* Coloring action class
*
* Action class for configuring the coloring of points
*
* @author Thomas Kroes
*/
class ColoringAction : public VerticalGroupAction
{
Q_OBJECT
public:
/**
* Construct with \p parent object and \p title
* @param parent Pointer to parent object
* @param title Title
*/
Q_INVOKABLE ColoringAction(QObject* parent, const QString& title);
/**
* Get the context menu for the action
* @param parent Parent widget
* @return Context menu
*/
QMenu* getContextMenu(QWidget* parent = nullptr) override;
/**
* Add color dataset to the list
* @param colorDataset Smart pointer to color dataset
*/
void addColorDataset(const Dataset<DatasetImpl>& colorDataset);
/** Determines whether a given color dataset is already loaded */
bool hasColorDataset(const Dataset<DatasetImpl>& colorDataset) const;
/** Get smart pointer to current color dataset (if any) */
Dataset<DatasetImpl> getCurrentColorDataset() const;
/**
* Set the current color dataset
* @param colorDataset Smart pointer to color dataset
*/
void setCurrentColorDataset(const Dataset<DatasetImpl>& colorDataset);
protected:
/** Update the color by action options */
void updateColorByActionOptions();
/** Update the colors of the points in the scatter plot widget */
void updateScatterPlotWidgetColors();
protected: // Color map
/** Updates the scalar range in the color map */
void updateColorMapActionScalarRange();
/** Update the scatter plot widget color map */
void updateScatterplotWidgetColorMap();
/** Update the color map range in the scatter plot widget */
void updateScatterPlotWidgetColorMapRange();
/** Determine whether the color map should be enabled */
bool shouldEnableColorMap() const;
/** Enables/disables the color map */
void updateColorMapActionsReadOnly();
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
OptionAction& getColorByAction() { return _colorByAction; }
ColorAction& getConstantColorAction() { return _constantColorAction; }
DimensionPickerAction& getDimensionAction() { return _dimensionAction; }
ColorMapAction& getColorMap1DAction() { return _colorMap1DAction; }
ColorMapAction& getColorMap2DAction() { return _colorMap2DAction; }
signals:
void currentColorDatasetChanged(Dataset<DatasetImpl> currentColorDataset);
private:
ScatterplotPlugin* _scatterplotPlugin; /** Pointer to scatter plot plugin */
ColorSourceModel _colorByModel; /** Color by model (model input for the color by action) */
OptionAction _colorByAction; /** Action for picking the coloring type */
ColorAction _constantColorAction; /** Action for picking the constant color */
DimensionPickerAction _dimensionAction; /** Dimension picker action */
ColorMap1DAction _colorMap1DAction; /** One-dimensional color map action */
ColorMap2DAction _colorMap2DAction; /** Two-dimensional color map action */
Dataset<Points> _currentColorPointsDataset; /** Current color dataset */
/** Default constant color */
static const QColor DEFAULT_CONSTANT_COLOR;
friend class ScatterplotPlugin;
friend class mv::AbstractActionsManager;
};
Q_DECLARE_METATYPE(ColoringAction)
inline const auto coloringActionMetaTypeId = qRegisterMetaType<ColoringAction*>("ColoringAction");