58FXIMPLEMENT(
GUIParameterTracker, FXMainWindow, GUIParameterTrackerMap, ARRAYNUMBER(GUIParameterTrackerMap))
71 const std::string& name)
72 : FXMainWindow(app.getApp(),
"Tracker", nullptr, nullptr, DECOR_ALL, 20, 20, 300, 200),
76 FXVerticalFrame* glcanvasFrame =
new FXVerticalFrame(
this, FRAME_SUNKEN | LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0);
78 setTitle(name.c_str());
91 for (std::vector<TrackerValueDesc*>::iterator i1 =
myTracked.begin(); i1 !=
myTracked.end(); i1++) {
105 FXMainWindow::create();
116 new FXButton(
myToolBar, (std::string(
"\t\t") +
TL(
"Save the data...")).c_str(),
148 tr->addTracked(o, src, newTracked);
167 return FXMainWindow::onConfigure(sender, sel, ptr);
174 return FXMainWindow::onPaint(sender, sel, ptr);
226 std::vector<TrackerValueDesc*>::iterator i;
246 for (
int j = 0; j < max; j++) {
258 FXMessageBox::error(
this, MBOX_OK,
TL(
"Storing failed!"),
"%s", e.what());
292 : FXGLCanvas(c, app.getGLVisual(), app.getBuildGLCanvas(), (FXObject*)
nullptr, (FXSelector) 0, LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 300, 200),
301 glMatrixMode(GL_PROJECTION);
303 glMatrixMode(GL_MODELVIEW);
305 glDisable(GL_TEXTURE_2D);
306 for (
int i = 0; i < (int)myParent->myTracked.size(); i++) {
319 const double fontWidth = 0.1 * 300. / myWidthInPixels;
320 const double fontHeight = 0.1 * 300. / myHeightInPixels;
321 const bool isMultiPlot = myParent->myTracked.size() > 1;
323 if (values.size() < 2) {
325 glTranslated(-.9, 0.9, 0);
335 glScaled(0.8, 0.8, 1);
337 double ys = (double) 2.0 / (
double) desc.
getRange();
338 glScaled(1.0, ys, 1.0);
344 glVertex2d(0, desc.
getMin());
345 glVertex2d(2.0, desc.
getMin());
348 glVertex2d(0, desc.
getMax());
349 glVertex2d(2.0, desc.
getMax());
352 for (
int a = 1; a < 6; a++) {
353 const double yp = desc.
getRange() / 6.0 * (double) a + desc.
getMin();
361 double mx = (2 * myMouseX / myWidthInPixels - 1) / 0.8 + 1;
363 double mouseValue = std::numeric_limits<double>::max();
364 latest = values.back();
366 const double xStep = 2.0 / (double) values.size();
367 std::vector<double>::const_iterator i = values.begin();
372 for (; i != values.end(); i++) {
374 double xn = xp + xStep;
375 if (xp < mx && mx < xn) {
377 mIndex = (int)(i - values.begin()) - 1;
380 glTranslated(xn, yn, 0);
381 glScaled(20.0 / myWidthInPixels, 10.0 * desc.
getRange() / myHeightInPixels, 0);
402 double w = 50 / myWidthInPixels;
403 glTranslated(-0.8 - w / 2., -0.88, 0);
405 glTranslated(0.8 + w / 2., 0.88, 0);
408 glTranslated(0.75, -0.88, 0);
411 glTranslated(-0.75, 0.88, 0);
414 glTranslated(-0.98, -0.82, 0);
416 glTranslated(0.98, 0.82, 0);
419 glTranslated(-0.98, 0.78, 0);
421 glTranslated(0.98, -0.78, 0);
424 glTranslated(-0.98, .92, 0);
426 glTranslated(0.98, -.92, 0);
429 double p = (double) 0.8 -
431 glTranslated(-0.98, -(p + .02), 0);
433 glTranslated(0.98, p + .02, 0);
436 if (mouseValue != std::numeric_limits<double>::max()) {
439 glTranslated(-0.98, -(p + .02), 0);
441 glTranslated(0.98, p + .02, 0);
446 glTranslated(1.6 * (
double)mIndex / (
double)values.size() - 0.8, -0.9, 0);
458 myWidthInPixels = myParent->getWidth();
459 myHeightInPixels = myParent->getHeight();
460 if (myWidthInPixels != 0 && myHeightInPixels != 0) {
461 glViewport(0, 0, myWidthInPixels - 1, myHeightInPixels - 1);
462 glClearColor(1.0, 1.0, 1.0, 1);
463 glDisable(GL_DEPTH_TEST);
464 glDisable(GL_LIGHTING);
465 glDisable(GL_LINE_SMOOTH);
467 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
468 glEnable(GL_ALPHA_TEST);
469 glDisable(GL_COLOR_MATERIAL);
471 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
486 myWidthInPixels = getWidth();
487 myHeightInPixels = getHeight();
488 if (myWidthInPixels != 0 && myHeightInPixels != 0) {
489 glViewport(0, 0, myWidthInPixels - 1, myHeightInPixels - 1);
490 glClearColor(1.0, 1.0, 1.0, 1);
491 glDisable(GL_DEPTH_TEST);
492 glDisable(GL_LIGHTING);
493 glDisable(GL_LINE_SMOOTH);
495 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
496 glEnable(GL_ALPHA_TEST);
497 glDisable(GL_COLOR_MATERIAL);
499 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
501 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
513 FXEvent*
event = (FXEvent*) ptr;
514 myMouseX =
event->win_x;
@ 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, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
static void popMatrix()
pop matrix
static void pushMatrix()
push matrix
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 addChild(FXMainWindow *child)
Adds a further child window to the list (FXMainWindow)
~GUIParameterTrackerPanel()
Destructor.
long onMouseMove(FXObject *, FXSelector, void *)
called on mouse movement (for updating moused value)
void drawValue(TrackerValueDesc &desc, const RGBColor &col, int index)
Draws a single value.
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)
static std::vector< RGBColor > myColors
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.
GUIParameterTracker(GUIMainWindow &app, const std::string &name)
Constructor (the tracker is empty)
FXComboBox * myAggregationInterval
A combo box to select an aggregation interval.
GUIMainWindow * myApplication
The main application.
long onConfigure(FXObject *, FXSelector, void *)
Called on window resizing.
FXCheckButton * myMultiPlot
Whether phase names shall be printed instead of indices.
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.
static std::set< GUIParameterTracker * > myMultiPlots
all trackers that are opened for plotting multiple values
std::vector< GLObjectValuePassConnector< double > * > myValuePassers
The value sources.
static bool addTrackedMultiplot(GUIGlObject &o, ValueSource< double > *src, TrackerValueDesc *newTracked)
all value source to multiplot trackers
long onMultiPlot(FXObject *, FXSelector, void *)
Called on a simulation step.
void buildToolBar()
Builds the tool bar.
~GUIParameterTracker()
Destructor.
FXToolBarShell * myToolBarDrag
for some menu detaching fun
@ MID_SAVE
Save the current values.
@ MID_MULTIPLOT
toggle multiplot
@ MID_AGGREGATIONINTERVAL
Change aggregation interval.
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, bool usePrefix=true)
Returns the described OutputDevice.
A point in 2D or 3D with translation and scaling methods.
static const RGBColor BLUE
static const RGBColor ORANGE
static const RGBColor CYAN
static const RGBColor GREEN
static const RGBColor BLACK
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
RGBColor changedAlpha(int change) const
Returns a new color with altered opacity.
static const RGBColor MAGENTA
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...
SUMOTime getRecordingBegin() const
Returns the timestep the recording started.
double getMin() const
Returns the values minimum.
virtual ValueSource * copy() const =0