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);
186 FXScrollWindow* scrollWindow =
new FXScrollWindow(
this, LAYOUT_FILL_X | LAYOUT_FILL_Y | HSCROLLER_NEVER | FRAME_NONE);
187 FXHorizontalFrame* spacerFrame =
new FXHorizontalFrame(scrollWindow, LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_NONE);
188 new FXScrollWindow(spacerFrame, LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT | FRAME_NONE, 0, 0, 0, newHeight - 40);
189 FXVerticalFrame* glcanvasFrame =
190 new FXVerticalFrame(spacerFrame,
191 FRAME_SUNKEN | LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y,
192 0, 0, 0, 0, 0, 0, 0, 0);
194 setTitle((logic.getID() +
" - " + logic.getProgramID() +
" - tracker").c_str());
196 setHeight(newHeight);
204 FXMainWindow(app.getApp(),
"TLS-Tracker", nullptr, nullptr, DECOR_ALL, 20, 20, 300, 200),
217 FXScrollWindow* scrollWindow =
new FXScrollWindow(
this, LAYOUT_FILL_X | LAYOUT_FILL_Y | HSCROLLER_NEVER | FRAME_NONE);
218 FXHorizontalFrame* spacerFrame =
new FXHorizontalFrame(scrollWindow, LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_NONE);
219 new FXScrollWindow(spacerFrame, LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT | FRAME_NONE, 0, 0, 0, newHeight - 40);
220 FXVerticalFrame* glcanvasFrame =
221 new FXVerticalFrame(spacerFrame,
222 FRAME_SUNKEN | LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y,
223 0, 0, 0, 0, 0, 0, 0, 0);
227 setHeight(newHeight);
254 new FXLabel(
myToolBar,
"range (s):",
nullptr, LAYOUT_CENTER_Y);
263 new FXLabel(
myToolBar,
"time style:",
nullptr, LAYOUT_CENTER_Y);
270 new FXLabel(
myToolBar,
"green time",
nullptr, LAYOUT_CENTER_Y);
291 FXMainWindow::create();
331 if (simpleTLLogic ==
nullptr) {
356 DurationsVector::reverse_iterator i =
myDurations.rbegin();
358 if (durs + (*i) > beginOffset) {
371 leftOffset = beginOffset - durs;
379 if (durs + (*i) > beginOffset) {
399 if (durs + (*i) > beginOffset) {
416 glMatrixMode(GL_PROJECTION);
418 glMatrixMode(GL_MODELVIEW);
420 glTranslated(-1, -1, 0);
422 glDisable(GL_TEXTURE_2D);
426 const double panelHeight = (double) caller.getHeight();
427 const double panelWidth = (double) caller.getWidth();
428 const double barWidth =
MAX2(1.0, panelWidth - 31);
429 const double fontHeight = 0.06 * 300. / panelHeight;
430 const double fontWidth = 0.06 * 300. / panelWidth;
431 const double h9 = 9. / panelHeight;
432 const double hTop = 20. / panelHeight;
433 const double h11 = 11. / panelHeight;
434 const double stateHeight = 16. / panelHeight;
435 const double h20 = 20. / panelHeight;
436 const double h30 = 15. / panelHeight;
437 const double h35 = 34. / panelHeight;
438 const double h60 = 70. / panelHeight;
439 const double h75 = 73. / panelHeight;
440 const double h80 = 90. / panelHeight;
441 const double w30 = 30 / panelWidth;
442 double h = 1. - hTop;
452 glVertex2d(0, h + h20);
453 glVertex2d(1.0, h + h20);
468 const double top = h;
475 glVertex2d(0, h + h20);
476 glVertex2d(1.0, h + h20);
481 glVertex2d(30. / panelWidth, top);
482 glVertex2d(30. / panelWidth, h + h20);
488 const double top = h;
495 glVertex2d(0, h + h20);
496 glVertex2d(1.0, h + h20);
501 glVertex2d(30. / panelWidth, top);
502 glVertex2d(30. / panelWidth, h + h20);
511 double x = 31. / panelWidth;
512 double ta = (double) leftOffset / panelWidth;
521 const bool phaseNames =
myIndexMode->getCheck() == TRUE;
522 std::string lastName =
"";
523 double spaceForName = 0;
532 double a = (double) duration / panelWidth;
534 const double x2 = x + a;
547 glVertex2d(x, h - h11);
548 glVertex2d(x, h - h9);
549 glVertex2d(x2, h - h9);
550 glVertex2d(x2, h - h11);
556 glVertex2d(x, h - stateHeight);
559 glVertex2d(x2, h - stateHeight);
570 runningGreen[j] += *pd;
572 drawnDuration = runningGreen[j];
573 xOffset = -(double)(drawnDuration - *pd) / panelWidth * (barWidth / ((double)(
myLastTime -
myBeginTime)));
577 if (runningGreen[j] > 0) {
578 drawnDuration = runningGreen[j];
583 if (drawnDuration > 0) {
594 std::string name = phaseNames ? pi->getName() :
toString(*ii);
595 if (name != lastName) {
597 if (spaceForName < lastNameWidth) {
601 glVertex2d(x, 1 - fontHeight);
604 glVertex2d(1, 1 - fontHeight);
624 glColor3d(0.7, 0.7, 1.0);
626 panelWidth, (
double)leftOffset, barWidth, stateHeight, h20, h);
630 glColor3d(0.9, 0.6, 0.9);
632 panelWidth, (
double)leftOffset, barWidth, stateHeight, h20, h);
643 while (t > barWidth / 4.) {
653 double glpos = 31. / panelWidth;
654 const double ticSize = 4. / panelHeight;
655 if (leftOffset > 0) {
656 const double a =
STEPS2TIME(leftOffset) * barWidth / timeRange;
657 glpos += a / panelWidth;
658 currTime += leftOffset;
661 glpos += a / panelWidth;
673 ticShift = (ticShift % 3) + 1;
674 const std::string timeStr = (mmSS
678 const double w = 10 * (double)timeStr.size() / panelWidth;
679 glTranslated(glpos - w / 2., glh - h20 * ticShift, 0);
681 glTranslated(-glpos + w / 2., -glh + h20 * ticShift, 0);
686 glVertex2d(glpos, glh);
687 glVertex2d(glpos, glh - ticSize * ticShift);
693 if (!phaseNames || (pi->getName() != lastName)) {
694 glColor3d(0.4, 0.4, 0.4);
696 glVertex2d(glpos, hStart);
698 glVertex2d(glpos, hStart);
701 lastName = pi->getName();
705 glColor3d(0.4, 0.4, 0.4);
707 glVertex2d(glpos, hStart);
709 glVertex2d(glpos, hStart);
714 glColor3d(0.4, 0.4, 0.4);
716 glVertex2d(glpos, hStart);
723 if (timeInCycle == 0 || timeInCycle < lastTimeInCycle) {
724 const double cycle0pos = glpos -
STEPS2TIME(timeInCycle) * barWidth / timeRange / panelWidth;
725 if (cycle0pos >= 31 / panelWidth) {
726 glColor3d(0.6, 0.6, 0.6);
728 glVertex2d(cycle0pos, 1);
729 glVertex2d(cycle0pos, glh);
735 lastTimeInCycle = timeInCycle;
737 const double a =
STEPS2TIME(tickDist) * barWidth / timeRange;
738 glpos += a / panelWidth;
739 currTime += tickDist;
749 while (t > barWidth / 4.) {
757 glpos = (double) pos / panelWidth;
758 if (leftOffset > 0) {
759 const double a =
STEPS2TIME(leftOffset) * barWidth / timeRange;
761 glpos += a / panelWidth;
762 currTime += leftOffset;
766 glpos += a / panelWidth;
769 while (pos < panelWidth + 50.) {
770 const std::string timeStr = (mmSS
774 const double w = 10. * (double)timeStr.size() / panelWidth;
775 glTranslated(glpos - w / 2., glh - h20, 0);
777 glTranslated(-glpos + w / 2., -glh + h20, 0);
780 glVertex2d(glpos, glh);
781 glVertex2d(glpos, glh - ticSize);
786 glpos += a / panelWidth;
787 currTime += tickDist;
797 for (
const std::string& name : names) {
801 glVertex2d(divWidth, h);
804 glTranslated(0, h - divHeight, 0);
806 glTranslated(0, -h + divHeight, 0);
808 if (extraLines > 0 && i > 0 && i % extraLines == 0) {
809 glColor3d(0.4, 0.4, 0.4);
811 glVertex2d(divWidth, h);
827 double panelWidth,
double leftOffset,
double barWidth,
double stateHeight,
double h20,
double& h) {
828 double x = 31. / panelWidth;
829 double ta = leftOffset / panelWidth;
832 auto di = states.begin() + first2Show;
835 double mx = caller.
getMousePos().
x() / caller.getWidth();
836 double my = 1 - caller.
getMousePos().
y() / caller.getHeight();
837 std::string tooltip =
"";
839 for (
auto pd = durations.begin() + first2Show; pd != durations.end(); ++pd) {
844 double a = (double) duration / panelWidth;
846 const double x2 = x + a;
847 const bool tooltipX = x < mx && mx < x2;
850 for (
double j : *di) {
854 glVertex2d(x, h - stateHeight);
857 glVertex2d(x2, h - stateHeight);
860 const bool tooltipY = (h - stateHeight) < my && my < h;
892 while (lookBack > 0 && i > 1) {
899 return timeInCycle - lookBack;
922 std::vector<double> detectorStates;
924 detectorStates.push_back(item.second);
933 std::vector<double> conditionStates;
935 conditionStates.push_back(item.second);
953 return FXMainWindow::onConfigure(sender, sel, ptr);
960 return FXMainWindow::onPaint(sender, sel, ptr);
982 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"x", getX());
983 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"y", getY());
984 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"width", getWidth());
985 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"timeRange", (
int)
myBeginOffset->getValue());
988 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"indexMode", (
int)(
myIndexMode->getCheck()));
989 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"detectorMode", (
int)(
myDetectorMode->getCheck()));
990 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"conditionMode", (
int)(
myConditionMode->getCheck()));
997 const FXint minSize = 400;
998 const FXint minTitlebarHeight = 20;
999 setX(
MAX2(0,
MIN2(getApp()->reg().readIntEntry(
"TL_TRACKER",
"x", 150),
1000 getApp()->getRootWindow()->getWidth() - minSize)));
1003 MIN2(getApp()->reg().readIntEntry(
"TL_TRACKER",
"y", 150),
1004 getApp()->getRootWindow()->getHeight() - minSize));
1009 setWidth(
MAX2(getApp()->reg().readIntEntry(
"TL_TRACKER",
"width", 700), minSize));
1013 myIndexMode->setCheck((FXbool)getApp()->reg().readIntEntry(
"TL_TRACKER",
"indexMode", (
int)(
myIndexMode->getCheck())));
@ MID_SIMSTEP
A Simulation step was performed.
#define GUIDesignViewSettingsComboBox1
Combo boxes.
#define GUIDesignToolBarGrip
design for toolbar grip (used to change the position of toolbar with mouse)
#define GUIDesignToolBar
design for default toolbar
#define GUIDesignComboBoxVisibleItemsMedium
combo box medium small
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
const Position & getMousePos() const
}
long onPaint(FXObject *, FXSelector, void *)
called if the widget shall be repainted
~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.
MFXComboBoxIcon * myGreenMode
Whether green durations are printed.
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
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.
MFXComboBoxIcon * myTimeMode
The time mode.
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
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
long setCurrentItem(const FXint index, FXbool notify=FALSE)
Set the current item (index is zero-based)
FXint getCurrentItem() const
Get the current item's index.
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon item in the last position
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.
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 > getDetectorStates() const
return activation state of all detectors that affect this traffic light
virtual std::map< std::string, double > getConditions() const
return all named conditions defined for this traffic light
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
const std::string & getProgramID() const
Returns this tl-logic's id.
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)