82 #ifdef CHECK_MEMORY_LEAKS
109 FXMAPFUNC(SEL_COMMAND,
MID_NEW_OSGVIEW, GUIApplicationWindow::onCmdNewOSG),
147 const std::
string& configPattern)
149 myLoadThread(0), myRunThread(0),
151 myAlternateSimDelay(0),
152 myRecentNets(a, "nets"), myConfigPattern(configPattern),
153 hadDependentBuild(false),
154 myShowTimeAsHMS(false) {
173 LAYOUT_SIDE_TOP | LAYOUT_FILL_X | FRAME_RAISED);
184 myStatusbar =
new FXStatusBar(
this, LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X | FRAME_RAISED);
188 0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
192 0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
198 SPLITTER_REVERSED | SPLITTER_VERTICAL | LAYOUT_FILL_X | LAYOUT_FILL_Y | SPLITTER_TRACKING | FRAME_RAISED | FRAME_THICK);
200 LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK);
203 FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT);
205 FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED | LAYOUT_RIGHT);
207 FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED | LAYOUT_RIGHT);
209 FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED | LAYOUT_RIGHT);
241 if (getApp()->reg().readIntEntry(
"SETTINGS",
"maximized", 0) == 0) {
242 setX(getApp()->reg().readIntEntry(
"SETTINGS",
"x", 150));
243 setY(getApp()->reg().readIntEntry(
"SETTINGS",
"y", 150));
244 setWidth(getApp()->reg().readIntEntry(
"SETTINGS",
"width", 600));
245 setHeight(getApp()->reg().readIntEntry(
"SETTINGS",
"height", 400));
247 gCurrentFolder = getApp()->reg().readStringEntry(
"SETTINGS",
"basedir",
"");
248 FXMainWindow::create();
258 FXint width = getApp()->getNormalFont()->getTextWidth(
"8", 1) * 24;
262 show(PLACEMENT_SCREEN);
263 if (getApp()->reg().readIntEntry(
"SETTINGS",
"maximized", 0) == 1) {
266 myShowTimeAsHMS = (getApp()->reg().readIntEntry(
"gui",
"timeasHMS", 0) == 1);
301 FXMainWindow::detach();
313 "&Open Simulation...\tCtl-O\tOpen a simulation (Configuration file).",
316 "Open &Network...\tCtl-N\tOpen a network.",
319 "&Reload\tCtl-R\tReloads the simulation / the network.",
323 "&Close\tCtl-W\tClose the simulation.",
326 FXMenuSeparator* sep1 =
new FXMenuSeparator(
myFileMenu);
328 sep1->setSelector(FXRecentFiles::ID_ANYFILES);
342 FXMenuSeparator* sep2 =
new FXMenuSeparator(
myFileMenu);
344 sep2->setSelector(FXRecentFiles::ID_ANYFILES);
360 "&Quit\tCtl-Q\tQuit the Application.",
367 "Edit Chosen...\t\tOpens a Dialog for editing the List of chosen Items.",
371 "Edit Breakpoints...\t\tOpens a Dialog for editing breakpoints.",
378 "Application Settings...\t\tOpen a Dialog for Application Settings editing.",
381 "Gaming Mode\t\tToggle gaming mode on/off.",
384 "Locate Internal Structures\t\tList internal junctions and streets in the object locator.",
391 "Show Status Line\t\tToggle this Status Bar on/off.",
394 "Show Message Window\t\tToggle the Message Window on/off.",
397 "Show Simulation Time\t\tToggle the Simulation Time on/off.",
400 "Show Simulation Delay\t\tToggle the Simulation Delay Entry on/off.",
417 sep1->setSelector(FXMDIClient::ID_MDI_ANY);
425 "Clear Message Window\t\tClear the message window.",
443 LAYOUT_DOCK_NEXT | LAYOUT_SIDE_TOP | FRAME_RAISED);
449 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
452 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
455 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
461 LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
466 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
469 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
472 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
478 LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
482 BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
494 LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED | LAYOUT_FILL_Y);
498 BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
501 LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FILL_Y);
511 LAYOUT_DOCK_SAME | LAYOUT_SIDE_TOP | FRAME_RAISED);
517 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
521 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
529 getApp()->reg().writeIntEntry(
"SETTINGS",
"x", getX());
530 getApp()->reg().writeIntEntry(
"SETTINGS",
"y", getY());
531 getApp()->reg().writeIntEntry(
"SETTINGS",
"width", getWidth());
532 getApp()->reg().writeIntEntry(
"SETTINGS",
"height", getHeight());
533 getApp()->reg().writeStringEntry(
"SETTINGS",
"basedir",
gCurrentFolder.text());
534 getApp()->reg().writeIntEntry(
"SETTINGS",
"maximized", isMaximized() ? 1 : 0);
535 getApp()->reg().writeIntEntry(
"gui",
"timeasHMS",
myShowTimeAsHMS ? 1 : 0);
564 FXFileDialog opendialog(
this,
"Open Simulation Configuration");
566 opendialog.setSelectMode(SELECTFILE_EXISTING);
571 if (opendialog.execute()) {
573 std::string file = opendialog.getFilename().text();
584 FXFileDialog opendialog(
this,
"Open Network");
586 opendialog.setSelectMode(SELECTFILE_EXISTING);
587 opendialog.setPatternList(
"SUMO nets (*.net.xml)\nAll files (*)");
591 if (opendialog.execute()) {
593 std::string file = opendialog.getFilename().text();
603 load(
"",
false,
true);
611 myStatusbar->getStatusLine()->setText(
"Already loading!");
614 std::string file((
const char*)data);
630 myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
640 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
649 myAmLoading ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
659 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
669 myStatusbar->getStatusLine()->setText(
"No simulation loaded!");
693 myStatusbar->getStatusLine()->setText(
"No simulation loaded!");
736 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
746 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
756 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
766 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
776 ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE),
786 d->show(PLACEMENT_OWNER);
817 GUIApplicationWindow::onCmdNewOSG(
FXObject*, FXSelector,
void*) {
829 about->show(PLACEMENT_OWNER);
835 FXEvent*
event = (FXEvent*)ptr;
837 setDNDData(FROM_CLIPBOARD, event->target,
string);
894 if (ec->
myNet != 0) {
896 std::map<int, traci::TraCIServer::CmdExecutor> execs;
911 if (ec->
myNet == 0) {
947 std::string settingsName = settings.
addSettings(view);
963 setTitle(
"SUMO Traffic Light Game");
973 getApp()->endWaitCursor();
1008 FXMessageBox::warning(
this, MBOX_OK,
"Simulation ended",
"%s", text.c_str());
1016 getApp()->beginWaitCursor();
1034 myStatusbar->getStatusLine()->setText(
"No simulation loaded!");
1038 FXuint opts = MDI_TRACKING;
1104 return getApp()->getDefaultCursor(DEF_ARROW_CURSOR);
1122 myStatusbar->getStatusLine()->setText(text.c_str());
1123 myStatusbar->getStatusLine()->setNormalText(text.c_str());
1130 const bool hideFraction =
myAmGaming || fmod(
TS, 1.) == 0.;
1131 const int BuffSize = 100;
1132 char buffer[BuffSize];
1134 const int hours = (
int)fracSeconds / 3600;
1135 const int minutes = ((
int)fracSeconds % 3600) / 60;
1136 fracSeconds = fracSeconds - 3600 * hours - 60 * minutes;
1137 const std::string format = (hideFraction ?
1138 "%02d-%02d-%02.0f" :
"%02d-%02d-%06.3f");
1139 snprintf(buffer, BuffSize, format.c_str(), hours, minutes, fracSeconds);
1141 const std::string format = (hideFraction ?
1142 "%13.0f" :
"%13.3f");
1143 snprintf(buffer, BuffSize, format.c_str(), fracSeconds);
std::vector< FXMainWindow * > myTrackerWindows
Event sent when the the simulation is over.
FXLabel * myGeoCoordinate
virtual ~GUIApplicationWindow()
Destructor.
GUILoadThread * myLoadThread
GUICompleteSchemeStorage gSchemeStorage
long onCmdStep(FXObject *, FXSelector, void *)
Called on "step".
static std::string clipped
void handleEvent_SimulationLoaded(GUIEvent *e)
long onCmdReload(FXObject *, FXSelector, void *)
Called on reload.
virtual bool simulationIsStepable() const
std::string addSettings(GUISUMOAbstractView *view=0) const
Adds the parsed settings to the global list of settings.
MSNet::SimulationState getReason() const
Returns the reason the simulation has ended due.
The Simulation execution thread.
SUMOTime myAlternateSimDelay
The alternate simulation delay for toggling.
send when a message occured
static bool processSet(traci::TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xcc: Change GUI State)
FXSplitter * myMainSplitter
The splitter that divides the main window into vies and the log window.
virtual bool init(GUINet *net, SUMOTime start, SUMOTime end)
initialises the thread with the new simulation
long onUpdOpenRecent(FXObject *, FXSelector, void *)
Determines whether opening a recent file is enabled.
const std::string & getViewType() const
Returns the parsed view type.
long onCmdEditChosen(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Chosen.
static void openSocket(const std::map< int, CmdExecutor > &execs)
Initialises the server.
MFXEventQue myEvents
List of got requests.
const bool myOsgView
whether to load the OpenSceneGraph view
const std::string & getMsg() const
Returns the message.
virtual long onUpdStart(FXObject *, FXSelector, void *)
Determines whether "play" is enabled.
void load(const std::string &file, bool isNet)
begins the loading of the given file
FXToolBarShell * myToolBarDrag4
long onUpdStop(FXObject *, FXSelector, void *)
Determines whether "stop" is enabled.
long onClipboardRequest(FXObject *sender, FXSelector sel, void *ptr)
Somebody wants our clipped text.
virtual void setValue(FXdouble value)
Change current value.
virtual long onUpdEditBreakpoints(FXObject *, FXSelector, void *)
Determines whether editing breakpoints is enabled.
void setNumberFormat(FXint prec, FXbool bExp=FALSE)
virtual bool simulationIsStartable() const
static bool gRunAfterLoad
the simulation shall start direct after loading
std::string time2string(SUMOTime t)
Edit simulation breakpoints.
virtual void detach()
Detaches the tool/menu bar.
Editor for the list of chosen objects.
void setThickness(const FXint width)
set/get segment width - must be less than half the segment length
Reload the previously loaded simulation.
FXGLVisual * myGLVisual
The gl-visual used.
GUISUMOAbstractView * openNewView(GUISUMOViewParent::ViewType vt=GUISUMOViewParent::VIEW_2D_OPENGL)
long onCmdStop(FXObject *, FXSelector, void *)
Called on "stop".
const std::vector< SUMOTime > & getBreakpoints() const
Returns the parsed breakpoints.
FXString gCurrentFolder
The folder used as last.
static bool processGet(traci::TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xac: Get GUI Variable)
#define CMD_SET_GUI_VARIABLE
Loads a file previously loaded.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step (in s)
bool isGaming() const
return whether the gui is in gaming mode
const SUMOTime myBegin
the time the simulation shall start with
long onCmdNewView(FXObject *, FXSelector, void *)
Called if a new view shall be opened (2D view)
long onUpdOpen(FXObject *, FXSelector, void *)
Determines whether opening is enabled.
virtual FXGLCanvas * getBuildGLCanvas() const
const std::vector< GUISUMOAbstractView::Decal > & getDecals() const
Returns the parsed decals.
void addDecals(const std::vector< Decal > &decals)
FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[]
long onUpdEditChosen(FXObject *sender, FXSelector, void *ptr)
Determines whether editing chosen is enabled.
FXToolBarShell * myToolBarDrag2
void setViewport(GUISUMOAbstractView *view) const
Sets the viewport which has been parsed.
FXMenuPane * myFileMenu
the submenus
void addSeparator()
Adds a a separator to this log window.
static std::vector< SUMOTime > gBreakpoints
List of breakpoints.
Application settings - menu entry.
virtual void create()
Creates the main window (required by FOX)
FXHorizontalFrame * myCartesianFrame
SUMOReal getDelay() const
Returns the parsed delay.
FXRecentFiles myRecentNets
List of recent nets.
const std::vector< std::string > mySettingsFiles
the name of the settings file to load
Editor for simulation breakpoints.
bool myAmGaming
information whether the gui is currently in gaming mode
bool myShowTimeAsHMS
whether to show time as hour:minute:second
void handleEvent_Message(GUIEvent *e)
std::vector< FXMDIChild * > mySubWindows
static void clearTextures()
clears loaded textures
GUIEventType getOwnType() const
returns the event type
long onCmdOpenRecent(FXObject *, FXSelector, void *)
Called on opening a recent file.
An error occured during the simulation step.
void setRange(FXdouble lo, FXdouble hi)
Change the spinner's range.
Locator configuration - menu entry.
void handleEvent_SimulationEnded(GUIEvent *e)
FXdouble getValue() const
Return current value.
std::string myConfigPattern
Input file pattern.
long onCmdEditBreakpoints(FXObject *, FXSelector, void *)
Called on menu Edit->Edit Breakpoints.
long onCmdStart(FXObject *, FXSelector, void *)
Called on "play".
long onCmdAppSettings(FXObject *, FXSelector, void *)
Opens the application settings menu (Settings->Application Settings...)
virtual void buildToolBars()
Builds the tool bar.
void setHorizontal(const FXint len)
set/get segment horizontal length - must be more than twice the segment width
FXMenuPane * mySettingsMenu
static void init(FXApp *a)
size_t myViewNumber
The current view number.
FXMDIMenu * myMDIMenu
The menu used for the MDI-windows.
void load(const std::string &file, bool isNet, bool isReload=false)
void setSnapshots(GUISUMOAbstractView *view) const
Makes a snapshot if it has been parsed.
void setVertical(const FXint len)
set/get segment vertical length - must be more than twice the segment width
FXToolBarShell * myMenuBarDrag
SUMOTime getCurrentSimTime() const
ViewType
Available view types.
virtual void eventOccured()
GUIRunThread * myRunThread
long onCmdListInternal(FXObject *, FXSelector, void *)
Toggle listing of internal structures.
Gaming mode - menu entry.
Perform a single simulation step.
long onUpdReload(FXObject *, FXSelector, void *)
Determines whether reloading is enabled.
long onCmdDelayToggle(FXObject *, FXSelector, void *)
Called on "delay toggle".
const std::string myFile
the name of the loaded file
FXToolBarShell * myToolBarDrag3
The application's "About" - dialog.
void setStatusBarText(const std::string &)
The Simulation delay control.
long onCmdAbout(FXObject *, FXSelector, void *)
Shows the about dialog.
#define CMD_GET_GUI_VARIABLE
FXCursor * getDefaultCursor()
long onCmdClose(FXObject *, FXSelector, void *)
Called on menu File->Close.
void saveViewport(const SUMOReal x, const SUMOReal y, const SUMOReal zoom)
Makes the given viewport the default.
send when a error occured
void dependentBuild(bool game)
void setTarget(FXObject *tgt)
set the target
bool myListInternal
information whether the locator should list internal structures
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
virtual bool simulationIsStopable() const
The dialog to change the application (gui) settings.
Send when the simulation is over; The reason and the time step are stored within the event...
long onCmdClearMsgWindow(FXObject *, FXSelector, void *)
Called if the message window shall be cleared.
virtual void fillMenuBar()
Builds the menu bar.
Open a new microscopic 3D view.
A single child window which contains a view of the simulation area.
static bool gQuitOnEnd
the window shall be closed when the simulation has ended
long onCmdGaming(FXObject *, FXSelector, void *)
Toggle gaming mode.
FXStatusBar * myStatusbar
The status bar.
void appendText(GUIEventType eType, const std::string &msg)
Adds new text to the window.
void unlock()
release mutex lock
FXMenuBar * myMenuBar
The application menu bar.
FXMenuPane * myWindowsMenu
FXToolBarShell * myToolBarDrag5
FXGLCanvas * getBuildGLCanvas() const
long onCmdOpenConfiguration(FXObject *, FXSelector, void *)
Called on menu File->Open Configuration.
long onRunThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the simulation thread.
void setGroove(const FXint width)
set/get groove width - must be less than segment width
FXLabel * myCartesianCoordinate
Labels for the current cartesian and geo-coordinate.
void prepareDestruction()
MFXMutex myTrackerLock
A lock to make the removal and addition of trackers secure.
void setSelector(FXSelector sel)
set the selector
void updateTimeLCD(const SUMOTime time)
updates the simulation time display
long onUpdAddView(FXObject *, FXSelector, void *)
Determines whether adding a view is enabled.
FXRealSpinDial * mySimDelayTarget
FXHorizontalFrame * myGeoFrame
FXRecentFiles myRecentConfigs
List of recent config files.
void create()
Creates the widget (and the icons)
void clear()
Clears the list of selected objects.
FXToolBarShell * myToolBarDrag1
for some menu detaching fun
FXEX::FXThreadEvent myLoadThreadEvent
io-event with the load-thread
FXEX::FXThreadEvent myRunThreadEvent
io-event with the run-thread
toogle delay between alternative value
FXMDIClient * myMDIClient
The multi view panel.
send when a simulation has been loaded
bool simulationAvailable() const
send when a warning occured
FXToolBar * myToolBar1
The application tool bar.
long onCmdOpenNetwork(FXObject *, FXSelector, void *)
Called on menu File->Open Network.
SUMOTime getTimeStep() const
Returns the time step the simulation has ended at.
void setIncrements(FXdouble fine, FXdouble norm, FXdouble coarse)
Change all spinner increment.
An XML-handler for visualisation schemes.
static std::string getStateMessage(SimulationState state)
Returns the message to show if a certain state occurs.
static FXString getTitleText(const FXString &appname, FXString filename="")
Returns the title text in dependance to an optional file name.
long onLoadThreadEvent(FXObject *, FXSelector, void *)
Called on an event from the loading thread.
virtual GUISUMOAbstractView * init(FXGLCanvas *share, GUINet &net, ViewType type)
"Initialises" this window by building the contents
void setText(FXString lbl)
manipulate text in LCD label
GUIMessageWindow * myMessageWindow
A window to display messages, warnings and error in.
const SUMOTime myEnd
the time the simulation shall end with
void clear()
Clears the window.
bool myAmLoading
information whether the gui is currently loading and the load-options shall be greyed out ...
long onCmdTimeToggle(FXObject *, FXSelector, void *)
Called on "time toggle".
void handleEvent_SimulationStep(GUIEvent *e)
FXEX::FXLCDLabel * myLCDLabel
the simulation step display
GUISelectedStorage gSelected
A global holder of selected objects.
A logging window for the gui.
send when a simulation step has been performed
long onUpdStep(FXObject *, FXSelector, void *)
Determines whether "step" is enabled.
Open a new microscopic view.
static FXIcon * getIcon(GUIIcon which)
long onCmdQuit(FXObject *, FXSelector, void *)
Called by FOX if the application shall be closed.
GUINet * myNet
the loaded net
virtual void addToWindowsMenu(FXMenuPane *)
The main window of the SUMO-gui.