-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathScatterplotPlugin.h
More file actions
160 lines (119 loc) · 5 KB
/
ScatterplotPlugin.h
File metadata and controls
160 lines (119 loc) · 5 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
#pragma once
#include <ViewPlugin.h>
#include <actions/HorizontalToolbarAction.h>
#include <graphics/Vector2f.h>
#include "SettingsAction.h"
#include <QTimer>
using namespace mv::plugin;
using namespace mv::util;
using namespace mv::gui;
class Points;
class ScatterplotWidget;
namespace mv
{
namespace gui {
class DropWidget;
}
}
class ScatterplotPlugin : public ViewPlugin
{
Q_OBJECT
public:
ScatterplotPlugin(const PluginFactory* factory);
~ScatterplotPlugin() override;
void init() override;
/**
* Load one (or more datasets in the view)
* @param datasets Dataset(s) to load
*/
void loadData(const Datasets& datasets) override;
/** Get number of points in the position dataset */
std::uint32_t getNumberOfPoints() const;
public:
void createSubset(const bool& fromSourceData = false, const QString& name = "");
public: // Dimension picking
void setXDimension(const std::int32_t& dimensionIndex);
void setYDimension(const std::int32_t& dimensionIndex);
protected: // Data loading
/** Invoked when the position points dataset changes */
void positionDatasetChanged();
public: // Point colors
/**
* Load color from points dataset
* @param points Smart pointer to points dataset
* @param dimensionIndex Index of the dimension to load
*/
void loadColors(const Dataset<Points>& points, const std::uint32_t& dimensionIndex);
/**
* Load color from clusters dataset
* @param clusters Smart pointer to clusters dataset
*/
void loadColors(const Dataset<Clusters>& clusters);
public: // Miscellaneous
/** Get smart pointer to points dataset for point position */
Dataset<Points>& getPositionDataset();
/** Get smart pointer to source of the points dataset for point position (if any) */
Dataset<Points>& getPositionSourceDataset();
/** Use the pixel selection tool to select data points */
void selectPoints();
/** Use the sampler pixel selection tool to sample data points */
void samplePoints();
public:
/** Get reference to the scatter plot widget */
ScatterplotWidget& getScatterplotWidget();
SettingsAction& getSettingsAction() { return _settingsAction; }
private:
void updateData();
void updateSelection();
void updateHeadsUpDisplay();
void updateHeadsUpDisplayTextColor();
public: // Serialization
/**
* Load plugin from variant map
* @param variantMap Variant map representation of the plugin
*/
void fromVariantMap(const QVariantMap& variantMap) override;
/**
* Save plugin to variant map
* @return Variant map representation of the plugin
*/
QVariantMap toVariantMap() const override;
private:
mv::gui::DropWidget* _dropWidget; /** Widget for dropping datasets */
ScatterplotWidget* _scatterPlotWidget; /** The visualization widget */
Dataset<Points> _positionDataset; /** Smart pointer to points dataset for point position */
Dataset<Points> _positionSourceDataset; /** Smart pointer to source of the points dataset for point position (if any) */
Dataset<DatasetImpl> _colorDataset; /** Smart pointer to dataset used for coloring (if any) */
Dataset<DatasetImpl> _pointSizeDataset; /** Smart pointer to dataset for driving point size (if any) */
Dataset<DatasetImpl> _pointOpacityDataset; /** Smart pointer to dataset for driving point opacity (if any) */
std::vector<mv::Vector2f> _positions; /** Point positions */
unsigned int _numPoints; /** Number of point positions */
SettingsAction _settingsAction; /** Group action for all settings */
HorizontalToolbarAction _primaryToolbarAction; /** Horizontal toolbar for primary content */
QRectF _selectionBoundaries; /** Boundaries of the selection */
static const std::int32_t LAZY_UPDATE_INTERVAL = 2;
};
// =============================================================================
// Factory
// =============================================================================
class ScatterplotPluginFactory : public ViewPluginFactory
{
Q_INTERFACES(mv::plugin::ViewPluginFactory mv::plugin::PluginFactory)
Q_OBJECT
Q_PLUGIN_METADATA(IID "studio.manivault.ScatterplotPlugin"
FILE "PluginInfo.json")
public:
ScatterplotPluginFactory();
ViewPlugin* produce() override;
/**
* Get plugin trigger actions given \p datasets
* @param datasets Vector of input datasets
* @return Vector of plugin trigger actions
*/
PluginTriggerActions getPluginTriggerActions(const mv::Datasets& datasets) const override;
/**
* Get the URL of the GitHub repository
* @return URL of the GitHub repository (or readme markdown URL if set)
*/
QUrl getRepositoryUrl() const override;
};