Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/gui/tracker/TrackerValueDesc.h
169684 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file TrackerValueDesc.h
15
/// @author Daniel Krajzewicz
16
/// @author Michael Behrisch
17
/// @date Sept 2002
18
///
19
// Representation of a timeline of floats with their names and moments
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
#include <utils/foxtools/fxheader.h>
25
#include <string>
26
#include <vector>
27
#include <utils/common/RGBColor.h>
28
#include <utils/common/SUMOTime.h>
29
#include <utils/common/ValueRetriever.h>
30
31
32
// ===========================================================================
33
// class definitions
34
// ===========================================================================
35
/**
36
* @class TrackerValueDesc
37
* @brief Representation of a timeline of floats with their names and moments
38
*
39
* This class contains the information needed to display a time line of
40
* float values.
41
*/
42
class TrackerValueDesc : public ValueRetriever<double> {
43
public:
44
/// Constructor
45
TrackerValueDesc(const std::string& name, const RGBColor& col,
46
SUMOTime recordBegin,
47
double aggregationSeconds);
48
49
/// Destructor
50
~TrackerValueDesc();
51
52
/// returns the maximum value range
53
double getRange() const;
54
55
/// Returns the values minimum
56
double getMin() const;
57
58
/// Returns the values maximum
59
double getMax() const;
60
61
/// Returns the center of the value
62
double getYCenter() const;
63
64
/// Returns the color to use to display the value
65
const RGBColor& getColor() const;
66
67
/** @brief returns the vector of collected values
68
The values will be locked - no further addition will be perfomed until
69
the method "unlockValues" will be called */
70
const std::vector<double>& getValues();
71
72
/** @brief returns the vector of aggregated values
73
The values will be locked - no further addition will be perfomed until
74
the method "unlockValues" will be called */
75
const std::vector<double>& getAggregatedValues();
76
77
/// Returns the name of the value
78
const std::string& getName() const;
79
80
/// Adds a new value to the list
81
void addValue(double value);
82
83
/// Releases the locking after the values have been drawn
84
void unlockValues();
85
86
/// set the aggregation amount
87
void setAggregationSpan(SUMOTime as);
88
89
/// get the aggregation amount
90
SUMOTime getAggregationSpan() const;
91
92
/// Returns the timestep the recording started
93
SUMOTime getRecordingBegin() const;
94
95
96
private:
97
/// The name of the value
98
std::string myName;
99
100
/// The color to use when the value is set as "active"
101
RGBColor myActiveCol;
102
103
/// The color to use when the value is set as "inactive"
104
RGBColor myInactiveCol;
105
106
/// Values collected
107
std::vector<double> myValues;
108
109
/// Collected values in their aggregated form
110
std::vector<double> myAggregatedValues;
111
112
/// The minimum and the maximum of the value
113
double myMin, myMax;
114
115
// Mutex to avoid parallel drawing and insertion of new items
116
FXMutex myLock;
117
118
/// The aggregation interval in simulation steps
119
int myAggregationInterval;
120
121
/// Values like this shall not be counted on aggregation
122
double myInvalidValue;
123
124
/// Counter for valid numbers within the current aggregation interval
125
int myValidNo;
126
127
/// The time step the values are added from
128
SUMOTime myRecordingBegin;
129
130
/// Temporary storage for the last aggregation interval
131
double myTmpLastAggValue;
132
133
};
134
135