72 FXGLCanvas(c, app.getGLVisual(), app.getBuildGLCanvas(), (FXObject*)
nullptr, (FXSelector) 0, LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y),
83 int widthInPixels = getWidth();
84 int heightInPixels = getHeight();
85 if (widthInPixels != 0 && heightInPixels != 0) {
86 glViewport(0, 0, widthInPixels - 1, heightInPixels - 1);
87 glClearColor(0, 0, 0, 1);
88 glDisable(GL_DEPTH_TEST);
89 glDisable(GL_LIGHTING);
90 glDisable(GL_LINE_SMOOTH);
92 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
93 glEnable(GL_ALPHA_TEST);
94 glDisable(GL_COLOR_MATERIAL);
96 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
105 FXObject*, FXSelector,
void*) {
110 int widthInPixels = getWidth();
111 int heightInPixels = getHeight();
112 if (widthInPixels != 0 && heightInPixels != 0) {
113 glViewport(0, 0, widthInPixels - 1, heightInPixels - 1);
114 glClearColor(0, 0, 0, 1);
115 glDisable(GL_DEPTH_TEST);
116 glDisable(GL_LIGHTING);
117 glDisable(GL_LINE_SMOOTH);
119 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
120 glEnable(GL_ALPHA_TEST);
121 glDisable(GL_COLOR_MATERIAL);
123 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
125 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
126 myParent->drawValues(*
this);
137 FXEvent*
event = (FXEvent*) ptr;
138 myMousePos.setx(event->win_x);
139 myMousePos.sety(event->win_y);
164 FXMainWindow(app.getApp(), "
TLS-Tracker",
nullptr,
nullptr, DECOR_ALL, 20, 20, 300, 200),
175 std::string detID = item.first;
176 if (detID.size() > 4) {
177 detID = detID.substr(detID.size() - 4);
184 FXVerticalFrame* glcanvasFrame =
185 new FXVerticalFrame(
this,
186 FRAME_SUNKEN | LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y,
187 0, 0, 0, 0, 0, 0, 0, 0);
189 setTitle((logic.getID() +
" - " + logic.getProgramID() +
" - tracker").c_str());
200 FXMainWindow(app.getApp(),
"TLS-Tracker", nullptr, nullptr, DECOR_ALL, 20, 20, 300, 200),
212 FXVerticalFrame* glcanvasFrame =
213 new FXVerticalFrame(
this,
214 FRAME_SUNKEN | LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y,
215 0, 0, 0, 0, 0, 0, 0, 0);
246 new FXLabel(
myToolBar,
"range (s):",
nullptr, LAYOUT_CENTER_Y);
255 new FXLabel(
myToolBar,
"time style:",
nullptr, LAYOUT_CENTER_Y);
262 new FXLabel(
myToolBar,
"green time",
nullptr, LAYOUT_CENTER_Y);
283 FXMainWindow::create();
322 if (simpleTLLogic ==
nullptr) {
347 DurationsVector::reverse_iterator i =
myDurations.rbegin();
349 if (durs + (*i) > beginOffset) {
362 leftOffset = beginOffset - durs;
370 if (durs + (*i) > beginOffset) {
390 if (durs + (*i) > beginOffset) {
407 glMatrixMode(GL_PROJECTION);
409 glMatrixMode(GL_MODELVIEW);
411 glTranslated(-1, -1, 0);
413 glDisable(GL_TEXTURE_2D);
417 const double panelHeight = (double) caller.getHeight();
418 const double panelWidth = (double) caller.getWidth();
419 const double barWidth =
MAX2(1.0, panelWidth - 31);
420 const double fontHeight = 0.06 * 300. / panelHeight;
421 const double fontWidth = 0.06 * 300. / panelWidth;
422 const double h9 = 9. / panelHeight;
423 const double hTop = 20. / panelHeight;
424 const double h11 = 11. / panelHeight;
425 const double stateHeight = 16. / panelHeight;
426 const double h20 = 20. / panelHeight;
427 const double h30 = 15. / panelHeight;
428 const double h35 = 34. / panelHeight;
429 const double h60 = 70. / panelHeight;
430 const double h75 = 73. / panelHeight;
431 const double h80 = 90. / panelHeight;
432 const double w30 = 30 / panelWidth;
433 double h = 1. - hTop;
443 glVertex2d(0, h + h20);
444 glVertex2d(1.0, h + h20);
459 const double top = h;
466 glVertex2d(0, h + h20);
467 glVertex2d(1.0, h + h20);
472 glVertex2d(30. / panelWidth, top);
473 glVertex2d(30. / panelWidth, h + h20);
479 const double top = h;
486 glVertex2d(0, h + h20);
487 glVertex2d(1.0, h + h20);
492 glVertex2d(30. / panelWidth, top);
493 glVertex2d(30. / panelWidth, h + h20);
502 double x = 31. / panelWidth;
503 double ta = (double) leftOffset / panelWidth;
512 const bool phaseNames =
myIndexMode->getCheck() == TRUE;
513 std::string lastName =
"";
514 double spaceForName = 0;
523 double a = (double) duration / panelWidth;
525 const double x2 = x + a;
538 glVertex2d(x, h - h11);
539 glVertex2d(x, h - h9);
540 glVertex2d(x2, h - h9);
541 glVertex2d(x2, h - h11);
547 glVertex2d(x, h - stateHeight);
550 glVertex2d(x2, h - stateHeight);
561 runningGreen[j] += *pd;
563 drawnDuration = runningGreen[j];
564 xOffset = -(double)(drawnDuration - *pd) / panelWidth * (barWidth / ((double)(
myLastTime -
myBeginTime)));
568 if (runningGreen[j] > 0) {
569 drawnDuration = runningGreen[j];
574 if (drawnDuration > 0) {
585 std::string name = phaseNames ? pi->getName() :
toString(*ii);
586 if (name != lastName) {
588 if (spaceForName < lastNameWidth) {
592 glVertex2d(x, 1 - fontHeight);
595 glVertex2d(1, 1 - fontHeight);
615 glColor3d(0.7, 0.7, 1.0);
617 panelWidth, (
double)leftOffset, barWidth, stateHeight, h20, h);
621 glColor3d(0.9, 0.6, 0.9);
623 panelWidth, (
double)leftOffset, barWidth, stateHeight, h20, h);
634 while (t > barWidth / 4.) {
644 double glpos = 31. / panelWidth;
645 const double ticSize = 4. / panelHeight;
646 if (leftOffset > 0) {
647 const double a =
STEPS2TIME(leftOffset) * barWidth / timeRange;
648 glpos += a / panelWidth;
649 currTime += leftOffset;
652 glpos += a / panelWidth;
656 const bool mmSS =
myTimeMode->getCurrentItem() == 1;
657 const bool cycleTime =
myTimeMode->getCurrentItem() == 2;
664 ticShift = (ticShift % 3) + 1;
665 const std::string timeStr = (mmSS
669 const double w = 10 * (double)timeStr.size() / panelWidth;
670 glTranslated(glpos - w / 2., glh - h20 * ticShift, 0);
672 glTranslated(-glpos + w / 2., -glh + h20 * ticShift, 0);
677 glVertex2d(glpos, glh);
678 glVertex2d(glpos, glh - ticSize * ticShift);
684 if (!phaseNames || (pi->getName() != lastName)) {
685 glColor3d(0.4, 0.4, 0.4);
687 glVertex2d(glpos, hStart);
689 glVertex2d(glpos, hStart);
692 lastName = pi->getName();
696 glColor3d(0.4, 0.4, 0.4);
698 glVertex2d(glpos, hStart);
700 glVertex2d(glpos, hStart);
705 glColor3d(0.4, 0.4, 0.4);
707 glVertex2d(glpos, hStart);
714 if (timeInCycle == 0 || timeInCycle < lastTimeInCycle) {
715 const double cycle0pos = glpos -
STEPS2TIME(timeInCycle) * barWidth / timeRange / panelWidth;
716 if (cycle0pos >= 31 / panelWidth) {
717 glColor3d(0.6, 0.6, 0.6);
719 glVertex2d(cycle0pos, 1);
720 glVertex2d(cycle0pos, glh);
726 lastTimeInCycle = timeInCycle;
728 const double a =
STEPS2TIME(tickDist) * barWidth / timeRange;
729 glpos += a / panelWidth;
730 currTime += tickDist;
740 while (t > barWidth / 4.) {
748 glpos = (double) pos / panelWidth;
749 if (leftOffset > 0) {
750 const double a =
STEPS2TIME(leftOffset) * barWidth / timeRange;
752 glpos += a / panelWidth;
753 currTime += leftOffset;
757 glpos += a / panelWidth;
760 while (pos < panelWidth + 50.) {
761 const std::string timeStr = (mmSS
765 const double w = 10. * (double)timeStr.size() / panelWidth;
766 glTranslated(glpos - w / 2., glh - h20, 0);
768 glTranslated(-glpos + w / 2., -glh + h20, 0);
771 glVertex2d(glpos, glh);
772 glVertex2d(glpos, glh - ticSize);
777 glpos += a / panelWidth;
778 currTime += tickDist;
788 for (
const std::string& name : names) {
792 glVertex2d(divWidth, h);
795 glTranslated(0, h - divHeight, 0);
797 glTranslated(0, -h + divHeight, 0);
799 if (extraLines > 0 && i > 0 && i % extraLines == 0) {
800 glColor3d(0.4, 0.4, 0.4);
802 glVertex2d(divWidth, h);
818 double panelWidth,
double leftOffset,
double barWidth,
double stateHeight,
double h20,
double& h) {
819 double x = 31. / panelWidth;
820 double ta = leftOffset / panelWidth;
823 auto di = states.begin() + first2Show;
826 double mx = caller.
getMousePos().
x() / caller.getWidth();
827 double my = 1 - caller.
getMousePos().
y() / caller.getHeight();
828 std::string tooltip =
"";
830 for (
auto pd = durations.begin() + first2Show; pd != durations.end(); ++pd) {
835 double a = (double) duration / panelWidth;
837 const double x2 = x + a;
838 const bool tooltipX = x < mx && mx < x2;
841 for (
double j : *di) {
845 glVertex2d(x, h - stateHeight);
848 glVertex2d(x2, h - stateHeight);
851 const bool tooltipY = (h - stateHeight) < my && my < h;
883 while (lookBack > 0 && i > 1) {
890 return timeInCycle - lookBack;
913 std::vector<double> detectorStates;
915 detectorStates.push_back(item.second);
924 std::vector<double> conditionStates;
926 conditionStates.push_back(item.second);
944 return FXMainWindow::onConfigure(sender, sel, ptr);
951 return FXMainWindow::onPaint(sender, sel, ptr);
973 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"x", getX());
974 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"y", getY());
975 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"width", getWidth());
976 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"timeRange", (
int)
myBeginOffset->getValue());
977 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"timeMode",
myTimeMode->getCurrentItem());
978 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"greenMode", (
myGreenMode->getCurrentItem()));
979 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"indexMode", (
int)(
myIndexMode->getCheck()));
980 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"detectorMode", (
int)(
myDetectorMode->getCheck()));
981 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"conditionMode", (
int)(
myConditionMode->getCheck()));
988 const FXint minSize = 400;
989 const FXint minTitlebarHeight = 20;
990 setX(
MAX2(0,
MIN2(getApp()->reg().readIntEntry(
"TL_TRACKER",
"x", 150),
991 getApp()->getRootWindow()->getWidth() - minSize)));
994 MIN2(getApp()->reg().readIntEntry(
"TL_TRACKER",
"y", 150),
995 getApp()->getRootWindow()->getHeight() - minSize));
1000 setWidth(
MAX2(getApp()->reg().readIntEntry(
"TL_TRACKER",
"width", 700), minSize));
1002 myTimeMode->setCurrentItem(getApp()->reg().readIntEntry(
"TL_TRACKER",
"timeMode",
myTimeMode->getCurrentItem()));
1003 myGreenMode->setCurrentItem(getApp()->reg().readIntEntry(
"TL_TRACKER",
"greenMode",
myGreenMode->getCurrentItem()));
1004 myIndexMode->setCheck((FXbool)getApp()->reg().readIntEntry(
"TL_TRACKER",
"indexMode", (
int)(
myIndexMode->getCheck())));
@ MID_SIMSTEP
A Simulation step was performed.
#define GUIDesignViewSettingsComboBox1
Combo boxs.
#define GUIDesignToolBarGrip
design for toolbar grip (used to change the position of toolbar with mouse)
#define GUIDesignToolBar
design for default toolbar
FXDEFMAP(GUITLLogicPhasesTrackerWindow::GUITLLogicPhasesTrackerPanel) GUITLLogicPhasesTrackerPanelMap[]
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_TL_REDYELLOW
The link has red light (must brake) but indicates upcoming green.
@ LINKSTATE_TL_GREEN_MAJOR
The link has green light, may pass.
@ LINKSTATE_TL_RED
The link has red light (must brake)
@ LINKSTATE_TL_GREEN_MINOR
The link has green light, has to brake.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
static double getTextWidth(const std::string &text, double size)
get required width of text
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)
The canvas for the visualisation of phases.
long onConfigure(FXObject *, FXSelector, void *)
called on size change
long onPaint(FXObject *, FXSelector, void *)
called if the widget shall be repainted
const Position & getMousePos() const
}
~GUITLLogicPhasesTrackerPanel()
Destructor.
long onMouseMove(FXObject *, FXSelector, void *)
called on mouse movement (for updating tooltip)
This window displays a phase diagram for a chosen tl-logic.
GUITLLogicPhasesTrackerWindow()
protected constructor for FOX
AdditionalStatesVector myDetectorStates
The state of all used detectors of the current phase.
FXMutex myLock
A lock to avoid addition of new values while drawing.
SUMOTime myBeginTime
The first time a phase was added at.
static int myLastY
y-Position of previously opened window
DurationsVector myTimeInCycle
The time within the cycle for the current phase.
std::vector< std::string > myLinkNames
The names of links.
DurationsVector myDetectorDurations
The list of detector state durations.
FXCheckButton * myDetectorMode
Whether detector states are drawn.
~GUITLLogicPhasesTrackerWindow()
Destructor.
FXRealSpinner * myBeginOffset
The offset changer (tracking mode)
long onSimStep(FXObject *sender, FXSelector sel, void *ptr)
called on a simulation step
GUITLLogicPhasesTrackerPanel * myPanel
The panel to draw on.
int computeHeight()
compute required windowHeight
void setBeginTime(SUMOTime time)
Sets the time the display shall be shown as beginning at.
FXToolBarShell * myToolBarDrag
The tool bar drag (tracking mode)
SUMOTime myFirstCondOffset
FXToolBar * myToolBar
The tool bar (tracking mode)
PhasesVector myPhases
The list of phases.
SUMOTime myFirstPhaseOffset
The offset to draw the first phase (left offset)
std::vector< std::string > myDetectorNames
FXComboBox * myGreenMode
Whether green durations are printed.
IndexVector myPhaseIndex
The index of the current phase.
void addValue(std::pair< SUMOTime, MSPhaseDefinition > def)
Adds a further phase definition.
GLObjectValuePassConnector< std::pair< SUMOTime, MSPhaseDefinition > > * myConnector
The connector for retrieval of further phases.
SUMOTime myFirstDetOffset
std::vector< std::string > myConditionNames
int myFirstPhase2Show
The index of the first phase that fits into the window.
AdditionalStatesVector myConditionStates
long onPaint(FXObject *sender, FXSelector sel, void *ptr)
called if the widget shall be repainted
SUMOTime findTimeInCycle(SUMOTime t)
find time in cycle based on myTimeInCycle
FXCheckButton * myConditionMode
Whether detector states are drawn.
long onConfigure(FXObject *sender, FXSelector sel, void *ptr)
called on size change
FXComboBox * myTimeMode
The time mode.
SUMOTime myLastTime
The last time a phase was added at.
void create()
Creates the window (FOX-Toolkit)
MSTrafficLightLogic * myTLLogic
The logic to display.
std::vector< std::vector< double > > AdditionalStatesVector
Definition of a storage for detector and condition states.
void drawNames(const std::vector< std::string > &names, double fontHeight, double fontWidth, double divHeight, double divWidth, double &h, int extraLines)
draw row title
FXCheckButton * myIndexMode
Whether phase names shall be printed instead of indices.
std::vector< SUMOTime > DurationsVector
Definition of a storage for durations.
DurationsVector myConditionDurations
void drawAdditionalStates(GUITLLogicPhasesTrackerPanel &caller, const AdditionalStatesVector &states, const DurationsVector &durations, SUMOTime firstOffset, int first2Show, double hStart, double panelWidth, double leftOffset, double barWidth, double stateHeight, double h20, double &h)
draw detector and condition states
SUMOTime myFirstTime2Show
The time the diagram begins at.
GUIMainWindow * myApplication
The main application.
bool myAmInTrackingMode
Information whether the tracking mode is on.
void drawValues(GUITLLogicPhasesTrackerPanel &caller)
Draws all values.
DurationsVector myDurations
The list of phase durations.
static const RGBColor & getLinkColor(const LinkState &ls, bool realistic=false)
map from LinkState to color constants
The definition of a single phase of a tls logic.
A fixed traffic light logic.
const Phases & getPhases() const override
Returns the phases of this tls program.
The parent class for traffic light logics.
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
virtual SUMOTime mapTimeInCycle(SUMOTime t) const
map the given time into the current cycle
virtual int getCurrentPhaseIndex() const =0
Returns the current index within the program.
virtual std::map< std::string, double > getConditions() const
return all named conditions defined for this traffic light
const std::string & getProgramID() const
Returns this tl-logic's id.
virtual std::map< std::string, double > getDetectorStates() const
return activation state of all detectors that affect this traffic light
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
const std::string & getID() const
Returns the id.
A point in 2D or 3D with translation and scaling methods.
double x() const
Returns the x-position.
double y() const
Returns the y-position.
static const RGBColor WHITE
static const RGBColor YELLOW
static const RGBColor BLACK
static std::string padFront(const std::string &str, int length, char padding)