56 FXIMPLEMENT(
GUIParameterTracker, FXMainWindow, GUIParameterTrackerMap, ARRAYNUMBER(GUIParameterTrackerMap))
63 const std::
string& name)
64 : FXMainWindow(app.getApp(), "Tracker",
nullptr,
nullptr, DECOR_ALL, 20, 20, 300, 200),
68 FXVerticalFrame* glcanvasFrame =
new FXVerticalFrame(
this, FRAME_SUNKEN | LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0);
70 setTitle(name.c_str());
77 for (std::vector<TrackerValueDesc*>::iterator i1 =
myTracked.begin(); i1 !=
myTracked.end(); i1++) {
91 FXMainWindow::create();
102 new FXButton(
myToolBar,
"\t\tSave the data...",
130 return FXMainWindow::onConfigure(sender, sel, ptr);
137 return FXMainWindow::onPaint(sender, sel, ptr);
175 for (std::vector<TrackerValueDesc*>::iterator i1 =
myTracked.begin(); i1 !=
myTracked.end(); i1++) {
176 (*i1)->setAggregationSpan(
TIME2STEPS(aggInt));
191 std::vector<TrackerValueDesc*>::iterator i;
212 for (
int j = 0; j < max; j++) {
225 FXMessageBox::error(
this, MBOX_OK,
"Storing failed!",
"%s", e.what());
248 : FXGLCanvas(c, app.getGLVisual(), app.getBuildGLCanvas(), (FXObject*)
nullptr, (FXSelector) 0, LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 300, 200),
249 myParent(&parent), myApplication(&app) {}
257 glMatrixMode(GL_PROJECTION);
259 glMatrixMode(GL_MODELVIEW);
261 glDisable(GL_TEXTURE_2D);
263 for (std::vector<TrackerValueDesc*>::iterator i = myParent->myTracked.begin(); i != myParent->myTracked.end(); i++) {
266 (
double) myWidthInPixels / (
double) myParent->myTracked.size() * (
double) run);
275 const double fontWidth = 0.1 * 300. / myWidthInPixels;
276 const double fontHeight = 0.1 * 300. / myHeightInPixels;
282 glScaled(0.8, 0.8, 1);
284 double ys = (double) 2.0 / (
double) desc.
getRange();
285 glScaled(1.0, ys, 1.0);
295 glVertex2d(0, desc.
getMin());
296 glVertex2d(2.0, desc.
getMin());
299 glVertex2d(0, desc.
getMax());
300 glVertex2d(2.0, desc.
getMax());
302 glColor4ub(red, green, blue, 77);
303 for (
int a = 1; a < 6; a++) {
304 const double yp = desc.
getRange() / 6.0 * (double) a + desc.
getMin();
312 if (values.size() < 2) {
317 latest = values.back();
319 const double xStep = 2.0 / (double) values.size();
320 std::vector<double>::const_iterator i = values.begin();
324 glColor4ub(red, green, blue, 255);
325 for (; i != values.end(); i++) {
327 double xn = xp + xStep;
340 glColor3b(red, green, blue);
345 double w = 50 / myWidthInPixels;
346 glTranslated(-0.8 - w / 2., -0.88, 0);
348 glTranslated(0.8 + w / 2., 0.88, 0);
351 glTranslated(0.75, -0.88, 0);
354 glTranslated(-0.75, 0.88, 0);
357 glTranslated(-0.98, -0.82, 0);
359 glTranslated(0.98, 0.82, 0);
362 glTranslated(-0.98, 0.78, 0);
364 glTranslated(0.98, -0.78, 0);
367 glTranslated(-0.98, .92, 0);
369 glTranslated(0.98, -.92, 0);
372 double p = (double) 0.8 -
374 glTranslated(-0.98, -(p + .02), 0);
376 glTranslated(0.98, p + .02, 0);
385 myWidthInPixels = myParent->getWidth();
386 myHeightInPixels = myParent->getHeight();
387 if (myWidthInPixels != 0 && myHeightInPixels != 0) {
388 glViewport(0, 0, myWidthInPixels - 1, myHeightInPixels - 1);
389 glClearColor(1.0, 1.0, 1.0, 1);
390 glDisable(GL_DEPTH_TEST);
391 glDisable(GL_LIGHTING);
392 glDisable(GL_LINE_SMOOTH);
394 glEnable(GL_ALPHA_TEST);
395 glDisable(GL_COLOR_MATERIAL);
397 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
412 myWidthInPixels = getWidth();
413 myHeightInPixels = getHeight();
414 if (myWidthInPixels != 0 && myHeightInPixels != 0) {
415 glViewport(0, 0, myWidthInPixels - 1, myHeightInPixels - 1);
416 glClearColor(1.0, 1.0, 1.0, 1);
417 glDisable(GL_DEPTH_TEST);
418 glDisable(GL_LIGHTING);
419 glDisable(GL_LINE_SMOOTH);
421 glEnable(GL_ALPHA_TEST);
422 glDisable(GL_COLOR_MATERIAL);
424 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
426 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
@ MID_SIMSTEP
A Simulation step was performed.
#define GUIDesignComboBoxStatic
Combo box static (not editable)
#define GUIDesignToolBarGrip
design for toolbar grip (used to change the position of toolbar with mouse)
#define GUIDesignButtonToolbar
little button with icon placed in navigation toolbar
#define GUIDesignToolBar
design for default toolbar
FXString gCurrentFolder
The folder used as last.
FXDEFMAP(GUIParameterTracker) GUIParameterTrackerMap[]
std::string time2string(SUMOTime t)
convert SUMOTime to string
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
Class passing values from a GUIGlObject to another object.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
void removeChild(FXMainWindow *child)
removes the given child window from the list (FXMainWindow)
void drawValue(TrackerValueDesc &desc, double namePos)
Draws a single value.
~GUIParameterTrackerPanel()
Destructor.
void drawValues()
Draws all values.
long onConfigure(FXObject *, FXSelector, void *)
Called on window resizing.
long onPaint(FXObject *, FXSelector, void *)
Called if the window shall be repainted.
A window which displays the time line of one (or more) value(s)
long onCmdChangeAggregation(FXObject *, FXSelector, void *)
Called when the aggregation interval (combo) has been changed.
void addTracked(GUIGlObject &o, ValueSource< double > *src, TrackerValueDesc *newTracked)
Adds a further time line to display.
GUIParameterTrackerPanel * myPanel
The panel to display the values in.
void create()
Creates the window.
FXComboBox * myAggregationInterval
A combo box to select an aggregation interval.
GUIMainWindow * myApplication
The main application.
long onConfigure(FXObject *, FXSelector, void *)
Called on window resizing.
std::vector< TrackerValueDesc * > myTracked
The list of tracked values.
long onSimStep(FXObject *, FXSelector, void *)
Called on a simulation step.
long onCmdSave(FXObject *, FXSelector, void *)
Called when the data shall be saved.
long onPaint(FXObject *, FXSelector, void *)
Called if the window shall be repainted.
FXToolBar * myToolBar
The tracker tool bar.
@ MID_SAVE
Save the current values.
@ MID_AGGREGATIONINTERVAL
Change aggregation interval.
std::vector< GLObjectValuePassConnector< double > * > myValuePassers
The value sources.
void buildToolBar()
Builds the tool bar.
~GUIParameterTracker()
Destructor.
FXToolBarShell * myToolBarDrag
for some menu detaching fun
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString ¤tFolder)
Returns the file name to write.
Static storage of an output device and its base (abstract) implementation.
void close()
Closes the device and removes it from the dictionary.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
A point in 2D or 3D with translation and scaling methods.
unsigned char red() const
Returns the red-amount of the color.
unsigned char green() const
Returns the green-amount of the color.
unsigned char blue() const
Returns the blue-amount of the color.
static const RGBColor BLACK
static const RGBColor RED
named colors
Representation of a timeline of floats with their names and moments.
const std::string & getName() const
Returns the name of the value.
double getMax() const
Returns the values maximum.
void unlockValues()
Releases the locking after the values have been drawn.
double getYCenter() const
Returns the center of the value.
double getRange() const
returns the maximum value range
SUMOTime getAggregationSpan() const
get the aggregation amount
const std::vector< double > & getAggregatedValues()
returns the vector of aggregated values The values will be locked - no further addition will be perfo...
const RGBColor & getColor() const
Returns the color to use to display the value.
SUMOTime getRecordingBegin() const
Returns the timestep the recording started.
double getMin() const
Returns the values minimum.