-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathVisualizer.h
203 lines (137 loc) · 5.14 KB
/
Visualizer.h
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#pragma once
#include <Data/Preferences.h>
#include <Data/Session.h>
#include <Visualization/Lightbox.h>
#include <map>
#include <string>
namespace shapeworks {
class Visualizer;
typedef QSharedPointer<Visualizer> VisualizerHandle;
//! Controls display of objects in viewers
/*!
* The Visualizer class maintains state and control over viewer properties.
* Additionally, it performs all shape-based statistical functions.
*/
class Visualizer : public QObject {
Q_OBJECT;
public:
Visualizer(Preferences& prefs);
~Visualizer();
/// set the lightbox
void set_lightbox(LightboxHandle lightbox);
/// set the session
void set_session(SessionHandle session);
/// turn automatic centering on/off
void set_center(bool center);
//! get centering on/off
bool get_center();
//! set the alignment domain
void set_alignment_domain(int domain);
//! get the current alignment domain
int get_alignment_domain();
/// turn on/off glyph display
void set_show_glyphs(bool show);
/// turn on/off surface display
void set_show_surface(bool show);
/// update the display using the current settings
void display_samples();
void update_samples();
void update_landmarks();
void update_planes();
void update_paint_mode();
void display_sample(int i);
void display_shape(ShapeHandle shape);
void display_shapes(ShapeList shapes);
void set_selected_point_one(int id);
void set_selected_point_two(int id);
void set_mean(const Eigen::VectorXd& mean);
void set_mean_shape(ShapeHandle mean_shape);
ShapeHandle get_mean_shape();
void reset_camera();
void update_lut();
void update_annotations();
Particles get_current_shape();
vtkFloatArray* get_current_particle_scalars();
vtkSmartPointer<vtkPolyData> get_current_particle_poly_data();
void handle_new_mesh();
vtkSmartPointer<vtkPolyData> get_current_mesh(int index);
std::vector<vtkSmartPointer<vtkPolyData>> get_current_meshes_transformed(int index);
//! Get the currently selected feature map
const std::string& get_feature_map() const;
//! Set if we are using a uniform feature range
void set_uniform_feature_range(bool value);
//! Return if we are using a uniform feature range
bool get_uniform_feature_range(void);
//! Set the currently selected feature map
void set_feature_map(const std::string& feature_map);
//! clear out the viewers
void clear_viewers();
//! Reset the feature range (e.g. for a new feature)
void reset_feature_range();
//! Get the current feature range
double* get_feature_range();
//! Get the current raw feature range
double* get_feature_raw_range();
//! Return if the feature range is valid or not
bool get_feature_range_valid();
//! Update the feature range with a given range
void update_feature_range(double* range);
//! Update the feature range with a given range
void update_feature_range(double min, double max);
//! Request the transform for a given shape and domain
vtkSmartPointer<vtkTransform> get_transform(std::shared_ptr<Shape> shape, int alignment_domain, int domain);
//! Request the transform for a given shape and domain and display mode
vtkSmartPointer<vtkTransform> get_transform(std::shared_ptr<Shape> shape, DisplayMode display_mode,
int alignment_domain, int domain);
//! Set domain opacities
void set_opacities(std::vector<float> opacities);
//! Get domain opacities
std::vector<float> get_opacities();
//! Set the per-domain particle visibilities
void set_domain_particle_visibilities(std::vector<bool> visibilities);
//! Get the per-domain particle visibilities
std::vector<bool> get_domain_particle_visibilities();
//! Get the current glyph size
double get_current_glyph_size();
//! Handle ctrl click
void handle_ctrl_click(PickResult result);
//! Redraw renderers
void redraw();
//! Export render window to pixmap
QPixmap export_to_pixmap(QSize size, bool transparent_background, bool show_orientation_marker, bool show_color_scale,
bool& ready);
//! Return render window size
QSize get_render_size();
LightboxHandle get_lightbox() { return this->lightbox_; }
public Q_SLOTS:
/// update viewer properties (e.g. glyph size, quality, etc)
void update_viewer_properties();
void handle_feature_range_changed();
void handle_image_slice_settings_changed();
private:
Preferences& preferences_;
void compute_measurements();
void setup_single_selected_point_lut();
std::string feature_map_;
int alignment_domain_;
bool center_;
bool needs_camera_reset_ = true;
bool show_glyphs_ = true;
bool show_surface_ = true;
LightboxHandle lightbox_;
SessionHandle session_;
vtkSmartPointer<vtkLookupTable> glyph_lut_;
int selected_point_one_;
int selected_point_two_;
Eigen::VectorXd cached_mean_;
ShapeHandle mean_shape_;
Particles current_shape_;
double feature_range_[2] = {0, 0};
double feature_manual_range_[2] = {0, 0};
bool feature_range_valid_ = false;
bool feature_range_uniform_ = true;
std::vector<bool> domain_particle_visibilities_;
std::vector<float> opacities_;
double current_glyph_size_{0};
};
} // namespace shapeworks