81 #ifdef CHECK_MEMORY_LEAKS
108 FXMAPFUNC(SEL_COMMAND,
MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
167 const std::
string& configPattern)
169 myLoadThread(0), myRunThread(0),
171 myAlternateSimDelay(0),
172 myRecentNets(a, "nets"), myConfigPattern(configPattern),
173 hadDependentBuild(false),
174 myShowTimeAsHMS(false),
197 LAYOUT_SIDE_TOP | LAYOUT_FILL_X | FRAME_RAISED);
208 myStatusbar =
new FXStatusBar(
this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X | FRAME_RAISED);
212 0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
216 0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
222 SPLITTER_REVERSED | SPLITTER_VERTICAL | LAYOUT_FILL_X | LAYOUT_FILL_Y | SPLITTER_TRACKING | FRAME_RAISED | FRAME_THICK);
224 LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK);
227 FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT);
229 FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED | LAYOUT_RIGHT);
231 FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED | LAYOUT_RIGHT);
233 FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED | LAYOUT_RIGHT);
262 if (getApp()->reg().readIntEntry(
"SETTINGS",
"maximized", 0) == 0) {
263 setX(getApp()->reg().readIntEntry(
"SETTINGS",
"x", 150));
264 setY(getApp()->reg().readIntEntry(
"SETTINGS",
"y", 150));
265 setWidth(getApp()->reg().readIntEntry(
"SETTINGS",
"width", 600));
266 setHeight(getApp()->reg().readIntEntry(
"SETTINGS",
"height", 400));
268 gCurrentFolder = getApp()->reg().readStringEntry(
"SETTINGS",
"basedir",
"");
287 FXint width = getApp()->getNormalFont()->getTextWidth(
"8", 1) * 24;
291 show(PLACEMENT_SCREEN);
292 if (getApp()->reg().readIntEntry(
"SETTINGS",
"maximized", 0) == 1) {
295 myShowTimeAsHMS = (getApp()->reg().readIntEntry(
"gui",
"timeasHMS", 0) == 1);
345 "&Open Simulation...\tCtl-O\tOpen a simulation (Configuration file).",
348 "Open &Network...\tCtl-N\tOpen a network.",
351 "&Reload\tCtl-R\tReloads the simulation / the network.",
355 "&Close\tCtl-W\tClose the simulation.",
358 FXMenuSeparator* sep1 =
new FXMenuSeparator(
myFileMenu);
360 sep1->setSelector(FXRecentFiles::ID_ANYFILES);
374 FXMenuSeparator* sep2 =
new FXMenuSeparator(
myFileMenu);
376 sep2->setSelector(FXRecentFiles::ID_ANYFILES);
392 "&Quit\tCtl-Q\tQuit the Application.",
398 for (std::vector<std::string>::iterator it = vehicleClasses.begin(); it != vehicleClasses.end(); ++it) {
406 "Edit Selected...\tCtl-E\tOpens a Dialog for editing the List of Selected Items.",
409 "Select lanes which allow...\t\tOpens a menu for selecting a vehicle class by which to selected lanes.",
413 "Edit Breakpoints...\tCtl-B\tOpens a Dialog for editing breakpoints.",
420 "Application Settings...\t\tOpen a Dialog for Application Settings editing.",
423 "Gaming Mode\tCtl-G\tToggle gaming mode on/off.",
429 "Locate &Junctions\t\tOpen a Dialog for Locating a Junction.",
432 "Locate &Edges\t\tOpen a Dialog for Locating an Edge.",
436 "Locate &Vehicles\t\tOpen a Dialog for Locating a Vehicle.",
440 "Locate &TLS\t\tOpen a Dialog for Locating a Traffic Light.",
443 "Locate &Additional\t\tOpen a Dialog for Locating an Additional Structure.",
446 "Locate &PoI\t\tOpen a Dialog for Locating a Point of Intereset.",
449 "Locate P&olygon\t\tOpen a Dialog for Locating a Polygon.",
453 "Show Internal Structures\t\tShow internal junctions and streets in locator Dialog.",
459 "Run\tCtl-A\tStart running the simulation.",
462 "Stop\tCtl-S\tStop running the simulation.",
465 "Step\tCtl-D\tPerform one simulation step.",
472 "Show Status Line\t\tToggle the Status Bar on/off.",
475 "Show Message Window\t\tToggle the Message Window on/off.",
478 "Show Simulation Time\t\tToggle the Simulation Time on/off.",
481 "Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off.",
498 sep1->setSelector(FXMDIClient::ID_MDI_ANY);
506 "Clear Message Window\t\tClear the message window.",
524 LAYOUT_DOCK_NEXT | LAYOUT_SIDE_TOP | FRAME_RAISED);
530 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
533 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
536 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
542 LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
547 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
550 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
553 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
559 LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
563 BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
575 LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED | LAYOUT_FILL_Y);
579 BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
582 LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FILL_Y);
592 LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
598 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
602 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
611 new FXLabel(
myToolBar6,
"Waiting Time:\t\tTime spent waiting accumulated for all vehicles", 0, LAYOUT_TOP | LAYOUT_LEFT);
623 new FXLabel(
myToolBar7,
"Time Loss:\t\tTime lost due to being unable to drive with maximum speed for all vehicles", 0, LAYOUT_TOP | LAYOUT_LEFT);
636 getApp()->reg().writeIntEntry(
"SETTINGS",
"x", getX());
637 getApp()->reg().writeIntEntry(
"SETTINGS",
"y", getY());
638 getApp()->reg().writeIntEntry(
"SETTINGS",
"width", getWidth());
639 getApp()->reg().writeIntEntry(
"SETTINGS",
"height", getHeight());
640 getApp()->reg().writeStringEntry(
"SETTINGS",
"basedir",
gCurrentFolder.text());
641 getApp()->reg().writeIntEntry(
"SETTINGS",
"maximized", isMaximized() ? 1 : 0);
642 getApp()->reg().writeIntEntry(
"gui",
"timeasHMS",
myShowTimeAsHMS ? 1 : 0);
652 if (mc->getText() ==
"Edit Selected...") {
662 for (std::vector<MSLane*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
696 FXFileDialog opendialog(
this,
"Open Simulation Configuration");
698 opendialog.setSelectMode(SELECTFILE_EXISTING);
703 if (opendialog.execute()) {
705 std::string file = opendialog.getFilename().text();
716 FXFileDialog opendialog(
this,
"Open Network");
718 opendialog.setSelectMode(SELECTFILE_EXISTING);
719 opendialog.setPatternList(
"SUMO nets (*.net.xml)\nAll files (*)");
723 if (opendialog.execute()) {
725 std::string file = opendialog.getFilename().text();
735 load(
"",
false,
true);
743 myStatusbar->getStatusLine()->setText(
"Already loading!");
746 std::string file((
const char*)data);
762 myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
772 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
781 myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
791 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
801 myStatusbar->getStatusLine()->setText(
"No simulation loaded!");
825 myStatusbar->getStatusLine()->setText(
"No simulation loaded!");
868 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
878 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
888 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
898 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
919 d->show(PLACEMENT_OWNER);
975 GUIApplicationWindow::onCmdNewOSG(
FXObject*, FXSelector,
void*) {
987 about->show(PLACEMENT_OWNER);
993 FXEvent*
event = (FXEvent*)ptr;
995 setDNDData(FROM_CLIPBOARD, event->target,
string);
1053 if (ec->
myNet == 0) {
1089 std::string settingsName = settings.
addSettings(view);
1111 setTitle(
"SUMO Traffic Light Game");
1121 getApp()->endWaitCursor();
1159 FXMessageBox::warning(
this, MBOX_OK,
"Simulation ended",
"%s", text.c_str());
1171 for (; it != end; ++it) {
1203 getApp()->beginWaitCursor();
1221 myStatusbar->getStatusLine()->setText(
"No simulation loaded!");
1225 FXuint opts = MDI_TRACKING;
1291 return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1309 myStatusbar->getStatusLine()->setText(text.c_str());
1310 myStatusbar->getStatusLine()->setNormalText(text.c_str());
1322 const bool hideFraction =
myAmGaming || fmod(
TS, 1.) == 0.;
1323 const int BuffSize = 100;
1324 char buffer[BuffSize];
1326 const int hours = (
int)fracSeconds / 3600;
1327 const int minutes = ((
int)fracSeconds % 3600) / 60;
1328 fracSeconds = fracSeconds - 3600 * hours - 60 * minutes;
1329 const std::string format = (hideFraction ?
1330 "%02d-%02d-%02.0f" :
"%02d-%02d-%06.3f");
1331 snprintf(buffer, BuffSize, format.c_str(), hours, minutes, fracSeconds);
1333 const std::string format = (hideFraction ?
1334 "%13.0f" :
"%13.3f");
1335 snprintf(buffer, BuffSize, format.c_str(), fracSeconds);