mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-21 20:39:08 -06:00
Performance optimization of ImageSequencer::instrumentActive
This commit is contained in:
@@ -191,15 +191,16 @@ std::map<std::string, bool> ImageSequencer::getActiveInstruments(){
|
||||
// return entire map, seen in GUI.
|
||||
return _switchingMap;
|
||||
}
|
||||
bool ImageSequencer::instrumentActive(std::string instrumentID){
|
||||
for (auto i : _instrumentTimes){
|
||||
|
||||
bool ImageSequencer::instrumentActive(std::string instrumentID) {
|
||||
for (const auto& i : _instrumentTimes) {
|
||||
//check if this instrument is in range
|
||||
if (i.second.inRange(_currentTime)){
|
||||
if (i.second.inRange(_currentTime)) {
|
||||
//if so, then get the corresponding spiceID
|
||||
std::vector<std::string> spiceIDs = _fileTranslation[i.first]->getTranslation();
|
||||
//check which specific subinstrument is firing
|
||||
for (auto s : spiceIDs){
|
||||
if (s == instrumentID){
|
||||
for (auto s : spiceIDs) {
|
||||
if (s == instrumentID) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -209,7 +210,7 @@ bool ImageSequencer::instrumentActive(std::string instrumentID){
|
||||
}
|
||||
|
||||
float ImageSequencer::instrumentActiveTime(const std::string& instrumentID) const {
|
||||
for (auto i : _instrumentTimes){
|
||||
for (const auto& i : _instrumentTimes){
|
||||
//check if this instrument is in range
|
||||
if (i.second.inRange(_currentTime)){
|
||||
//if so, then get the corresponding spiceID
|
||||
@@ -319,6 +320,14 @@ void ImageSequencer::sortData() {
|
||||
std::sort(_subsetMap[sub.first]._subset.begin(),
|
||||
_subsetMap[sub.first]._subset.end(), imageComparer);
|
||||
}
|
||||
|
||||
std::sort(
|
||||
_instrumentTimes.begin(),
|
||||
_instrumentTimes.end(),
|
||||
[](const std::pair<std::string, TimeRange>& a, const std::pair<std::string, TimeRange>& b) {
|
||||
return a.second._min < b.second._min;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void ImageSequencer::runSequenceParser(SequenceParser* parser){
|
||||
|
||||
@@ -54,7 +54,7 @@ struct TimeRange {
|
||||
bool inRange(double min, double max){
|
||||
return (min >= _min && max <= _max);
|
||||
}
|
||||
bool inRange(double val){
|
||||
bool inRange(double val) const {
|
||||
return (val >= _min && val <= _max);
|
||||
}
|
||||
double _min;
|
||||
|
||||
@@ -142,7 +142,7 @@ void GuiPerformanceComponent::render() {
|
||||
std::sort(
|
||||
indices.begin(),
|
||||
indices.end(),
|
||||
[sortIndex, &averages](int a, int b) {
|
||||
[sortIndex, &averages](size_t a, size_t b) {
|
||||
return averages[a][sortIndex] > averages[b][sortIndex];
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user