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) {
336 WRITE_ERROR(
"Overflow in time computation occurred.");
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;
513 std::string lastName =
"";
514 double spaceForName = 0;
524 double a = (double) duration / panelWidth;
526 const double x2 = x + a;
539 glVertex2d(x, h - h11);
540 glVertex2d(x, h - h9);
541 glVertex2d(x2, h - h9);
542 glVertex2d(x2, h - h11);
548 glVertex2d(x, h - stateHeight);
551 glVertex2d(x2, h - stateHeight);
562 runningGreen[j] += *pd;
564 drawnDuration = runningGreen[j];
569 if (runningGreen[j] > 0) {
570 drawnDuration = runningGreen[j];
575 if (drawnDuration > 0) {
586 std::string name = phaseNames ? pi->getName() :
toString(*ii);
587 if (name != lastName) {
589 if (spaceForName < lastNameWidth) {
593 glVertex2d(x, 1 - fontHeight);
596 glVertex2d(1, 1 - fontHeight);
617 glColor3d(0.7, 0.7, 1.0);
619 panelWidth, (
double)leftOffset, barWidth, stateHeight, h20, h);
623 glColor3d(0.9, 0.6, 0.9);
625 panelWidth, (
double)leftOffset, barWidth, stateHeight, h20, h);
636 while (t > barWidth / 4.) {
646 double glpos = (double) 31 / panelWidth;
647 const double ticSize = 4. / panelHeight;
648 if (leftOffset > 0) {
649 const double a =
STEPS2TIME(leftOffset) * barWidth / timeRange;
650 glpos += a / panelWidth;
651 currTime += leftOffset;
654 glpos += a / panelWidth;
658 const bool mmSS =
myTimeMode->getCurrentItem() == 1;
659 const bool cycleTime =
myTimeMode->getCurrentItem() == 2;
666 ticShift = (ticShift % 3) + 1;
667 const std::string timeStr = (mmSS
671 const double w = 10 * timeStr.size() / panelWidth;
672 glTranslated(glpos - w / 2., glh - h20 * ticShift, 0);
674 glTranslated(-glpos + w / 2., -glh + h20 * ticShift, 0);
679 glVertex2d(glpos, glh);
680 glVertex2d(glpos, glh - ticSize * ticShift);
686 if (!phaseNames || (pi->getName() != lastName)) {
687 glColor3d(0.4, 0.4, 0.4);
689 glVertex2d(glpos, hStart);
691 glVertex2d(glpos, hStart);
694 lastName = pi->getName();
698 glColor3d(0.4, 0.4, 0.4);
700 glVertex2d(glpos, hStart);
702 glVertex2d(glpos, hStart);
707 glColor3d(0.4, 0.4, 0.4);
709 glVertex2d(glpos, hStart);
716 if (timeInCycle == 0 || timeInCycle < lastTimeInCycle) {
717 const double cycle0pos = glpos -
STEPS2TIME(timeInCycle) * barWidth / timeRange / panelWidth;
718 if (cycle0pos >= 31 / panelWidth) {
719 glColor3d(0.6, 0.6, 0.6);
721 glVertex2d(cycle0pos, 1);
722 glVertex2d(cycle0pos, glh);
728 lastTimeInCycle = timeInCycle;
730 const double a =
STEPS2TIME(tickDist) * barWidth / timeRange;
731 glpos += a / panelWidth;
732 currTime += tickDist;
742 while (t > barWidth / 4.) {
746 glh = (double)(1.0 -
myLinkNames.size() * h20 - h80);
750 glpos = (double) pos / panelWidth;
751 if (leftOffset > 0) {
752 const double a =
STEPS2TIME(leftOffset) * barWidth / timeRange;
754 glpos += a / panelWidth;
755 currTime += leftOffset;
759 glpos += a / panelWidth;
762 while (pos < panelWidth + 50.) {
763 const std::string timeStr = (mmSS
767 const double w = 10 * timeStr.size() / panelWidth;
768 glTranslated(glpos - w / 2., glh - h20, 0);
770 glTranslated(-glpos + w / 2., -glh + h20, 0);
773 glVertex2d(glpos, glh);
774 glVertex2d(glpos, glh - ticSize);
779 glpos += a / panelWidth;
780 currTime += tickDist;
790 for (
const std::string& name : names) {
794 glVertex2d(divWidth, h);
797 glTranslated(0, h - divHeight, 0);
799 glTranslated(0, -h + divHeight, 0);
801 if (extraLines > 0 && i > 0 && i % extraLines == 0) {
802 glColor3d(0.4, 0.4, 0.4);
804 glVertex2d(divWidth, h);
820 double panelWidth,
double leftOffset,
double barWidth,
double stateHeight,
double h20,
double& h) {
821 double x = 31. / panelWidth;
822 double ta = leftOffset / panelWidth;
825 auto di = states.begin() + first2Show;
828 double mx = caller.
getMousePos().
x() / caller.getWidth();
829 double my = 1 - caller.
getMousePos().
y() / caller.getHeight();
830 std::string tooltip =
"";
832 for (
auto pd = durations.begin() + first2Show; pd != durations.end(); ++pd) {
838 double a = (double) duration / panelWidth;
840 const double x2 = x + a;
841 const bool tooltipX = x < mx && mx < x2;
844 for (
double j : *di) {
848 glVertex2d(x, h - stateHeight);
851 glVertex2d(x2, h - stateHeight);
854 const bool tooltipY = (h - stateHeight) < my && my < h;
887 while (lookBack > 0 && i >= 0) {
894 return timeInCycle - lookBack;
917 std::vector<double> detectorStates;
919 detectorStates.push_back(item.second);
928 std::vector<double> conditionStates;
930 conditionStates.push_back(item.second);
948 return FXMainWindow::onConfigure(sender, sel, ptr);
955 return FXMainWindow::onPaint(sender, sel, ptr);
977 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"x", getX());
978 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"y", getY());
979 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"width", getWidth());
980 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"timeRange", (
int)
myBeginOffset->getValue());
981 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"timeMode",
myTimeMode->getCurrentItem());
982 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"greenMode", (
myGreenMode->getCurrentItem()));
983 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"indexMode", (
int)(
myIndexMode->getCheck()));
984 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"detectorMode", (
int)(
myDetectorMode->getCheck()));
985 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"conditionMode", (
int)(
myConditionMode->getCheck()));
992 const FXint minSize = 400;
993 const FXint minTitlebarHeight = 20;
994 setX(
MAX2(0,
MIN2(getApp()->reg().readIntEntry(
"TL_TRACKER",
"x", 150),
995 getApp()->getRootWindow()->getWidth() - minSize)));
998 MIN2(getApp()->reg().readIntEntry(
"TL_TRACKER",
"y", 150),
999 getApp()->getRootWindow()->getHeight() - minSize));
1004 setWidth(
MAX2(getApp()->reg().readIntEntry(
"TL_TRACKER",
"width", 700), minSize));
1006 myTimeMode->setCurrentItem(getApp()->reg().readIntEntry(
"TL_TRACKER",
"timeMode",
myTimeMode->getCurrentItem()));
1007 myGreenMode->setCurrentItem((
bool)getApp()->reg().readIntEntry(
"TL_TRACKER",
"greenMode", (
int)(
myGreenMode->getCurrentItem())));
1008 myIndexMode->setCheck((
bool)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
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.
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
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)