82 #ifdef CHECK_MEMORY_LEAKS
109 FXMAPFUNC(SEL_COMMAND,
MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
163 const std::
string& configPattern)
165 myLoadThread(0), myRunThread(0),
167 myAlternateSimDelay(0),
168 myRecentNets(a, "nets"), myConfigPattern(configPattern),
169 hadDependentBuild(false),
170 myShowTimeAsHMS(false) {
189 LAYOUT_SIDE_TOP | LAYOUT_FILL_X | FRAME_RAISED);
200 myStatusbar =
new FXStatusBar(
this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X | FRAME_RAISED);
204 0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
208 0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
214 SPLITTER_REVERSED | SPLITTER_VERTICAL | LAYOUT_FILL_X | LAYOUT_FILL_Y | SPLITTER_TRACKING | FRAME_RAISED | FRAME_THICK);
216 LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK);
219 FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT);
221 FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED | LAYOUT_RIGHT);
223 FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED | LAYOUT_RIGHT);
225 FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED | LAYOUT_RIGHT);
257 if (getApp()->reg().readIntEntry(
"SETTINGS",
"maximized", 0) == 0) {
258 setX(getApp()->reg().readIntEntry(
"SETTINGS",
"x", 150));
259 setY(getApp()->reg().readIntEntry(
"SETTINGS",
"y", 150));
260 setWidth(getApp()->reg().readIntEntry(
"SETTINGS",
"width", 600));
261 setHeight(getApp()->reg().readIntEntry(
"SETTINGS",
"height", 400));
263 gCurrentFolder = getApp()->reg().readStringEntry(
"SETTINGS",
"basedir",
"");
264 FXMainWindow::create();
276 FXint width = getApp()->getNormalFont()->getTextWidth(
"8", 1) * 24;
280 show(PLACEMENT_SCREEN);
281 if (getApp()->reg().readIntEntry(
"SETTINGS",
"maximized", 0) == 1) {
284 myShowTimeAsHMS = (getApp()->reg().readIntEntry(
"gui",
"timeasHMS", 0) == 1);
321 FXMainWindow::detach();
333 "&Open Simulation...\tCtl-O\tOpen a simulation (Configuration file).",
336 "Open &Network...\tCtl-N\tOpen a network.",
339 "&Reload\tCtl-R\tReloads the simulation / the network.",
343 "&Close\tCtl-W\tClose the simulation.",
346 FXMenuSeparator* sep1 =
new FXMenuSeparator(
myFileMenu);
348 sep1->setSelector(FXRecentFiles::ID_ANYFILES);
362 FXMenuSeparator* sep2 =
new FXMenuSeparator(
myFileMenu);
364 sep2->setSelector(FXRecentFiles::ID_ANYFILES);
380 "&Quit\tCtl-Q\tQuit the Application.",
387 "Edit Selected...\tCtl-E\tOpens a Dialog for editing the List of Selected Items.",
391 "Edit Breakpoints...\tCtl-B\tOpens a Dialog for editing breakpoints.",
398 "Application Settings...\t\tOpen a Dialog for Application Settings editing.",
401 "Gaming Mode\t\tToggle gaming mode on/off.",
407 "Locate &Junctions\t\tOpen a Dialog for Locating a Junction.",
410 "Locate &Edges\t\tOpen a Dialog for Locating an Edge.",
414 "Locate &Vehicles\t\tOpen a Dialog for Locating a Vehicle.",
418 "Locate &TLS\t\tOpen a Dialog for Locating a Traffic Light.",
421 "Locate &Additional\t\tOpen a Dialog for Locating an Additional Structure.",
424 "Locate &POI\t\tOpen a Dialog for Locating a Point of Intereset.",
427 "Locate P&olygon\t\tOpen a Dialog for Locating a Polygon.",
431 "Show Internal Structures\t\tShow internal junctions and streets in locator Dialog.",
437 "Run\tCtl-A\tStart running the simulation.",
440 "Stop\tCtl-S\tStop running the simulation.",
443 "Step\tCtl-D\tPerform one simulation step.",
450 "Show Status Line\t\tToggle the Status Bar on/off.",
453 "Show Message Window\t\tToggle the Message Window on/off.",
456 "Show Simulation Time\t\tToggle the Simulation Time on/off.",
459 "Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off.",
476 sep1->setSelector(FXMDIClient::ID_MDI_ANY);
484 "Clear Message Window\t\tClear the message window.",
502 LAYOUT_DOCK_NEXT | LAYOUT_SIDE_TOP | FRAME_RAISED);
508 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
511 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
514 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
520 LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
525 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
528 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
531 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
537 LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
541 BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
553 LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED | LAYOUT_FILL_Y);
557 BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
560 LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FILL_Y);
570 LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
576 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
580 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
588 getApp()->reg().writeIntEntry(
"SETTINGS",
"x", getX());
589 getApp()->reg().writeIntEntry(
"SETTINGS",
"y", getY());
590 getApp()->reg().writeIntEntry(
"SETTINGS",
"width", getWidth());
591 getApp()->reg().writeIntEntry(
"SETTINGS",
"height", getHeight());
592 getApp()->reg().writeStringEntry(
"SETTINGS",
"basedir",
gCurrentFolder.text());
593 getApp()->reg().writeIntEntry(
"SETTINGS",
"maximized", isMaximized() ? 1 : 0);
594 getApp()->reg().writeIntEntry(
"gui",
"timeasHMS",
myShowTimeAsHMS ? 1 : 0);
623 FXFileDialog opendialog(
this,
"Open Simulation Configuration");
625 opendialog.setSelectMode(SELECTFILE_EXISTING);
630 if (opendialog.execute()) {
632 std::string file = opendialog.getFilename().text();
643 FXFileDialog opendialog(
this,
"Open Network");
645 opendialog.setSelectMode(SELECTFILE_EXISTING);
646 opendialog.setPatternList(
"SUMO nets (*.net.xml)\nAll files (*)");
650 if (opendialog.execute()) {
652 std::string file = opendialog.getFilename().text();
662 load(
"",
false,
true);
670 myStatusbar->getStatusLine()->setText(
"Already loading!");
673 std::string file((
const char*)data);
689 myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
699 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
708 myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
718 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
728 myStatusbar->getStatusLine()->setText(
"No simulation loaded!");
752 myStatusbar->getStatusLine()->setText(
"No simulation loaded!");
795 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
805 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
815 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
825 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
846 d->show(PLACEMENT_OWNER);
877 GUIApplicationWindow::onCmdNewOSG(
FXObject*, FXSelector,
void*) {
889 about->show(PLACEMENT_OWNER);
895 FXEvent*
event = (FXEvent*)ptr;
897 setDNDData(FROM_CLIPBOARD, event->target,
string);
954 if (ec->
myNet != 0) {
956 std::map<int, TraCIServer::CmdExecutor> execs;
971 if (ec->
myNet == 0) {
1007 std::string settingsName = settings.
addSettings(view);
1023 setTitle(
"SUMO Traffic Light Game");
1033 getApp()->endWaitCursor();
1068 FXMessageBox::warning(
this, MBOX_OK,
"Simulation ended",
"%s", text.c_str());
1076 getApp()->beginWaitCursor();
1094 myStatusbar->getStatusLine()->setText(
"No simulation loaded!");
1098 FXuint opts = MDI_TRACKING;
1164 return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1182 myStatusbar->getStatusLine()->setText(text.c_str());
1183 myStatusbar->getStatusLine()->setNormalText(text.c_str());
1190 const bool hideFraction =
myAmGaming || fmod(
TS, 1.) == 0.;
1191 const int BuffSize = 100;
1192 char buffer[BuffSize];
1194 const int hours = (
int)fracSeconds / 3600;
1195 const int minutes = ((
int)fracSeconds % 3600) / 60;
1196 fracSeconds = fracSeconds - 3600 * hours - 60 * minutes;
1197 const std::string format = (hideFraction ?
1198 "%02d-%02d-%02.0f" :
"%02d-%02d-%06.3f");
1199 snprintf(buffer, BuffSize, format.c_str(), hours, minutes, fracSeconds);
1201 const std::string format = (hideFraction ?
1202 "%13.0f" :
"%13.3f");
1203 snprintf(buffer, BuffSize, format.c_str(), fracSeconds);