-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExportAction.h
More file actions
130 lines (106 loc) · 4.87 KB
/
ExportAction.h
File metadata and controls
130 lines (106 loc) · 4.87 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
#pragma once
#include <actions/ColorAction.h>
#include <actions/DecimalRangeAction.h>
#include <actions/DirectoryPickerAction.h>
#include <actions/IntegralAction.h>
#include <actions/StatusAction.h>
#include <actions/StringAction.h>
#include <actions/ToggleAction.h>
#include <actions/TriggersAction.h>
#include <actions/VerticalGroupAction.h>
#include <PointData/DimensionsPickerAction.h>
using namespace mv::gui;
class ScatterplotPlugin;
/**
* Export action class
*
* Action for exporting to image(s) (and maybe in the future also videos)
*
* @author Thomas Kroes
*/
class ExportAction : public VerticalGroupAction
{
Q_OBJECT
public:
/** Scale options */
enum Scale {
Eighth, /** Scale by one-eight */
Quarter, /** Scale by a quarter */
Half, /** Scale by a half */
One, /** Do not scale */
Twice, /** Scale by a factor of two */
Thrice, /** Scale by a factor of three */
Four, /** Scale by a factor of four */
Eight /** Scale by a factor of eight */
};
static const QMap<Scale, TriggersAction::Trigger> triggers; /** Maps scale enum to trigger */
static const QMap<Scale, float> scaleFactors; /** Maps scale enum to scale factor */
public:
/**
* Construct with \p parent object and \p title
* @param parent Pointer to parent object
* @param title Title
*/
Q_INVOKABLE ExportAction(QObject* parent, const QString& title);
/**
* Initialize the selection action with \p scatterplotPlugin
* @param scatterplotPlugin Pointer to scatterplot plugin
*/
void initialize(ScatterplotPlugin* scatterplotPlugin);
/** Grab target size from scatter plot widget */
void initializeTargetSize();
/** Export images to disk */
void exportImages();
protected:
/** Update the input points dataset of the dimensions picker action */
void updateDimensionsPickerAction();
/**
* Establish whether export can take place
* @return Whether export can take place
*/
bool mayExport() const;
/**
* Get the number of selected dimensions
* @return Number of selected dimensions
*/
std::int32_t getNumberOfSelectedDimensions() const;
/** Updates the export trigger text, tooltip and read-only */
void updateExportTrigger();
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
DimensionsPickerAction& getDimensionsPickerAction() { return _dimensionSelectionAction; }
IntegralAction& getTargetWidthAction() { return _targetWidthAction; }
IntegralAction& getTargetHeightAction() { return _targetHeightAction; }
ToggleAction& getLockAspectRatioAction() { return _lockAspectRatioAction; }
TriggersAction& getScaleAction() { return _scaleAction; }
ColorAction& getBackgroundColorAction() { return _backgroundColorAction; }
ToggleAction& getOverrideRangesAction() { return _overrideRangesAction; }
DecimalRangeAction& getFixedRangeAction() { return _fixedRangeAction; }
DirectoryPickerAction& getDirectoryPickerAction() { return _outputDirectoryAction; }
TriggersAction& getExportCancelAction() { return _exportCancelAction; }
private:
ScatterplotPlugin* _scatterplotPlugin; /** Pointer to scatterplot plugin */
DimensionsPickerAction _dimensionSelectionAction; /** Dimension selection picker action */
IntegralAction _targetWidthAction; /** Screenshot target width action */
IntegralAction _targetHeightAction; /** Screenshot target height action */
ToggleAction _lockAspectRatioAction; /** Lock aspect ratio action */
TriggersAction _scaleAction; /** Scale action */
ColorAction _backgroundColorAction; /** Background color action */
ToggleAction _overrideRangesAction; /** Override ranges action */
DecimalRangeAction _fixedRangeAction; /** Fixed range action */
DirectoryPickerAction _outputDirectoryAction; /** Output directory picker action */
StringAction _fileNamePrefixAction; /** File name prefix action */
StatusAction _statusAction; /** Status action */
TriggersAction _exportCancelAction; /** Create and cancel triggers action */
float _aspectRatio; /** Export image aspect ratio */
};