mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-08 22:38:42 -05:00
Always refer to the extra quantities used for coloring lines as quantities, never variables.
This commit is contained in:
@@ -54,10 +54,10 @@ namespace {
|
||||
const char* VALUE_INPUT_FILE_TYPE_OSFLS = "osfls";
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo ColorMethodInfo = {
|
||||
"colorMethod", "Color Method", "Color lines uniformly or using color tables based on extra variables like e.g. temperature or particle density."
|
||||
"colorMethod", "Color Method", "Color lines uniformly or using color tables based on extra quantities like e.g. temperature or particle density."
|
||||
};
|
||||
static const openspace::properties::Property::PropertyInfo ColorQuantityInfo = {
|
||||
"colorQuantity", "Quantity to Color By", "Quantity/variable used to color lines if the \"By Quantity\" color method is selected."
|
||||
"colorQuantity", "Quantity to Color By", "Quantity used to color lines if the \"By Quantity\" color method is selected."
|
||||
};
|
||||
static const openspace::properties::Property::PropertyInfo ColorQuantityMinInfo = {
|
||||
"colorQuantityMin", "ColorTable Min Value", "Value to map to the lowest end of the color table."
|
||||
@@ -194,10 +194,10 @@ void RenderableFieldlinesSequence::initialize() {
|
||||
_colorMethod.addOption(ColorMethod::BY_QUANTITY, "By Quantity");
|
||||
|
||||
// Add option for each extra quantity. We assume that there are just as many names to
|
||||
// extra variables as there are extra variables. We also assume that all states in the
|
||||
// given sequence have the same extra variables!
|
||||
const size_t N_EXTRA_QUANTITIES = _states[0].nExtraVariables();
|
||||
auto EXTRA_VARIABLE_NAMES_VEC = _states[0].extraVariableNames();
|
||||
// extra quantities as there are extra quantities. We also assume that all states in
|
||||
// the given sequence have the same extra quantities!
|
||||
const size_t N_EXTRA_QUANTITIES = _states[0].nExtraQuantities();
|
||||
auto EXTRA_VARIABLE_NAMES_VEC = _states[0].extraQuantityNames();
|
||||
for (size_t i = 0; i < N_EXTRA_QUANTITIES; ++i) {
|
||||
_colorQuantity.addOption(i, EXTRA_VARIABLE_NAMES_VEC[i]);
|
||||
}
|
||||
@@ -337,8 +337,8 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
// Check if current time in OpenSpace is within sequence interval
|
||||
if (isWithinSequenceInterval(CURRENT_TIME)) {
|
||||
const int NEXT_IDX = _activeTriggerTimeIndex + 1;
|
||||
if (_activeTriggerTimeIndex < 0 // true => Previous frame was not within the sequence interval
|
||||
|| CURRENT_TIME < _startTimes[_activeTriggerTimeIndex] // true => OpenSpace has stepped back to a time represented by another state
|
||||
if (_activeTriggerTimeIndex < 0 // true => Previous frame was not within the sequence interval
|
||||
|| CURRENT_TIME < _startTimes[_activeTriggerTimeIndex] // true => OpenSpace has stepped back to a time represented by another state
|
||||
|| (NEXT_IDX < _nStates && CURRENT_TIME >= _startTimes[NEXT_IDX])) { // true => OpenSpace has stepped forward to a time represented by another state
|
||||
|
||||
updateActiveTriggerTimeIndex(CURRENT_TIME);
|
||||
@@ -376,7 +376,7 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
|
||||
updateVertexPositionBuffer();
|
||||
|
||||
if (_states[_activeStateIndex].nExtraVariables() > 0) {
|
||||
if (_states[_activeStateIndex].nExtraQuantities() > 0) {
|
||||
_shouldUpdateColorBuffer = true;
|
||||
} else {
|
||||
_colorMethod = ColorMethod::UNIFORM;
|
||||
@@ -451,7 +451,7 @@ void RenderableFieldlinesSequence::updateVertexColorBuffer() {
|
||||
|
||||
bool isSuccessful;
|
||||
const std::vector<float>& QUANTITY_VEC =
|
||||
_states[_activeStateIndex].extraVariable(_colorQuantity, isSuccessful);
|
||||
_states[_activeStateIndex].extraQuantity(_colorQuantity, isSuccessful);
|
||||
|
||||
if (isSuccessful) {
|
||||
glBufferData(GL_ARRAY_BUFFER, QUANTITY_VEC.size() * sizeof(float),
|
||||
|
||||
@@ -96,7 +96,7 @@ private:
|
||||
// ----------------------------- Properties -----------------------------
|
||||
properties::PropertyOwner _colorGroup; // Group to hold the color properties
|
||||
properties::OptionProperty _colorMethod; // Uniform/transfer function/topology?
|
||||
properties::OptionProperty _colorQuantity; // Index of the extra variable to color lines by
|
||||
properties::OptionProperty _colorQuantity; // Index of the extra quantity to color lines by
|
||||
properties::StringProperty _colorQuantityMin; // Color table/transfer function min
|
||||
properties::StringProperty _colorQuantityMax; // Color table/transfer function max
|
||||
properties::StringProperty _colorTablePath; // Color table/transfer function for "By Quantity" coloring
|
||||
|
||||
@@ -75,21 +75,21 @@ bool FieldlinesState::loadStateFromOsfls(const std::string& PATH_TO_OSFLS_FILE)
|
||||
_lineStart.resize(numLines);
|
||||
_lineCount.resize(numLines);
|
||||
_vertexPositions.resize(numPoints);
|
||||
_extraVariables.resize(numExtras);
|
||||
_extraVariableNames.reserve(numExtras);
|
||||
_extraQuantities.resize(numExtras);
|
||||
_extraQuantityNames.reserve(numExtras);
|
||||
|
||||
// Read vertex position data
|
||||
ifs.read( reinterpret_cast<char*>(_lineStart.data()), sizeof(GLint)*numLines);
|
||||
ifs.read( reinterpret_cast<char*>(_lineCount.data()), sizeof(GLsizei)*numLines);
|
||||
ifs.read( reinterpret_cast<char*>(_vertexPositions.data()), sizeof(glm::vec3)*numPoints);
|
||||
|
||||
// Read all extra variables
|
||||
for (std::vector<float>& vec : _extraVariables) {
|
||||
// Read all extra quantities
|
||||
for (std::vector<float>& vec : _extraQuantities) {
|
||||
vec.resize(numPoints);
|
||||
ifs.read( reinterpret_cast<char*>(vec.data()), sizeof(float) * numPoints);
|
||||
}
|
||||
|
||||
// Read all extra variables' names. Stored as multiple c-strings
|
||||
// Read all extra quantities' names. Stored as multiple c-strings
|
||||
std::string allNamesInOne;
|
||||
char* s = new char[byteSizeAllNames];
|
||||
ifs.read(s, byteSizeAllNames);
|
||||
@@ -102,19 +102,19 @@ bool FieldlinesState::loadStateFromOsfls(const std::string& PATH_TO_OSFLS_FILE)
|
||||
endOfVarName -= offset;
|
||||
std::string varName = allNamesInOne.substr(offset, endOfVarName);
|
||||
offset += varName.size() + 1;
|
||||
_extraVariableNames.push_back(varName);
|
||||
_extraQuantityNames.push_back(varName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns one of the extra variable vectors, _extraVariables[INDEX].
|
||||
// Returns one of the extra quantity vectors, _extraQuantities[INDEX].
|
||||
// If INDEX is out of scope an empty vector is returned and the referenced bool will be false.
|
||||
const vector<float>& FieldlinesState::extraVariable(const size_t INDEX,
|
||||
const vector<float>& FieldlinesState::extraQuantity(const size_t INDEX,
|
||||
bool& isSuccessful) const {
|
||||
if (INDEX < _extraVariables.size()) {
|
||||
if (INDEX < _extraQuantities.size()) {
|
||||
isSuccessful = true;
|
||||
return _extraVariables[INDEX];
|
||||
return _extraQuantities[INDEX];
|
||||
}
|
||||
isSuccessful = false;
|
||||
// return empty vector which goes out of scope hence unusable!
|
||||
|
||||
@@ -49,17 +49,17 @@ public:
|
||||
bool loadStateFromOsfls(const std::string& PATH_TO_OSFLS_FILE);
|
||||
|
||||
// ------------------------------GETTERS-----------------------------------------//
|
||||
const vector<vector<float>>& extraVariables() const { return _extraVariables; }
|
||||
const vector<std::string>& extraVariableNames() const { return _extraVariableNames; }
|
||||
const vector<vector<float>>& extraQuantities() const { return _extraQuantities; }
|
||||
const vector<std::string>& extraQuantityNames() const { return _extraQuantityNames; }
|
||||
const vector<GLsizei>& lineCount() const { return _lineCount; }
|
||||
const vector<GLint>& lineStart() const { return _lineStart; }
|
||||
size_t nExtraVariables() const { return _extraVariables.size(); }
|
||||
size_t nExtraQuantities() const { return _extraQuantities.size(); }
|
||||
Model model() const { return _model; }
|
||||
double triggerTime() const { return _triggerTime; }
|
||||
const vector<glm::vec3>& vertexPositions() const { return _vertexPositions; }
|
||||
|
||||
// Special getter. Returns extraVariables[INDEX].
|
||||
const vector<float>& extraVariable(const size_t INDEX, bool& isSuccesful) const;
|
||||
// Special getter. Returns extraQuantities[INDEX].
|
||||
const vector<float>& extraQuantity(const size_t INDEX, bool& isSuccesful) const;
|
||||
|
||||
private:
|
||||
bool _isMorphable = false;
|
||||
@@ -69,8 +69,8 @@ private:
|
||||
vector<glm::vec3> _vertexPositions;
|
||||
vector<GLint> _lineStart;
|
||||
vector<GLsizei> _lineCount;
|
||||
vector<vector<float>> _extraVariables;
|
||||
vector<std::string> _extraVariableNames;
|
||||
vector<vector<float>> _extraQuantities;
|
||||
vector<std::string> _extraQuantityNames;
|
||||
// TODO: Maybe introduce a vector containing seed point indices
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user