-
Notifications
You must be signed in to change notification settings - Fork 232
Expand file tree
/
Copy pathscalar_quantity.h
More file actions
93 lines (70 loc) · 2.71 KB
/
scalar_quantity.h
File metadata and controls
93 lines (70 loc) · 2.71 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
// Copyright 2017-2023, Nicholas Sharp and the Polyscope contributors. https://polyscope.run
#pragma once
#include "polyscope/affine_remapper.h"
#include "polyscope/histogram.h"
#include "polyscope/persistent_value.h"
#include "polyscope/polyscope.h"
#include "polyscope/render/engine.h"
#include "polyscope/render/managed_buffer.h"
#include "polyscope/scaled_value.h"
#include "polyscope/standardize_data_array.h"
namespace polyscope {
// Encapsulates logic which is common to all scalar quantities
template <typename QuantityT>
class ScalarQuantity {
public:
ScalarQuantity(QuantityT& quantity, const std::vector<float>& values, DataType dataType);
// Build the ImGUI UIs for scalars
void buildScalarUI();
virtual void buildScalarOptionsUI(); // called inside of an options menu
// Add rules to rendering programs for scalars
std::vector<std::string> addScalarRules(std::vector<std::string> rules);
// Set uniforms in rendering programs for scalars
void setScalarUniforms(render::ShaderProgram& p);
template <class V>
void updateData(const V& newValues);
// === Members
QuantityT& quantity;
// Wrapper around the actual buffer of scalar data stored in the class.
// Interaction with the data (updating it on CPU or GPU side, accessing it, etc) happens through this wrapper.
render::ManagedBuffer<float> values;
// === Get/set visualization parameters
// The color map
QuantityT* setColorMap(std::string val);
std::string getColorMap();
// Substitute colors for inf and nan
QuantityT* setInfColor(glm::vec3 val);
glm::vec3 getInfColor();
QuantityT* setNaNColor(glm::vec3 val);
glm::vec3 getNaNColor();
// Data limits mapped in to colormap
QuantityT* setMapRange(std::pair<double, double> val);
std::pair<double, double> getMapRange();
QuantityT* resetMapRange(); // reset to full range
std::pair<double, double> getDataRange();
// Isolines
QuantityT* setIsolinesEnabled(bool newEnabled);
bool getIsolinesEnabled();
QuantityT* setIsolineWidth(double size, bool isRelative);
double getIsolineWidth();
QuantityT* setIsolineDarkness(double val);
double getIsolineDarkness();
protected:
std::vector<float> valuesData;
const DataType dataType;
// === Visualization parameters
// Affine data maps and limits
std::pair<double, double> dataRange;
PersistentValue<float> vizRangeMin;
PersistentValue<float> vizRangeMax;
Histogram hist;
// Parameters
PersistentValue<std::string> cMap;
PersistentValue<glm::vec3> infColor;
PersistentValue<glm::vec3> nanColor;
PersistentValue<bool> isolinesEnabled;
PersistentValue<ScaledValue<float>> isolineWidth;
PersistentValue<float> isolineDarkness;
};
} // namespace polyscope
#include "polyscope/scalar_quantity.ipp"