Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others. 4 : // This program and the accompanying materials are made available under the 5 : // terms of the Eclipse Public License 2.0 which is available at 6 : // https://www.eclipse.org/legal/epl-2.0/ 7 : // This Source Code may also be made available under the following Secondary 8 : // Licenses when the conditions for such availability set forth in the Eclipse 9 : // Public License 2.0 are satisfied: GNU General Public License, version 2 10 : // or later which is available at 11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html 12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later 13 : /****************************************************************************/ 14 : /// @file GUIMainWindow.h 15 : /// @author Daniel Krajzewicz 16 : /// @author Jakob Erdmann 17 : /// @author Michael Behrisch 18 : /// @date Fri, 29.04.2005 19 : /// 20 : // 21 : /****************************************************************************/ 22 : #pragma once 23 : #include <config.h> 24 : 25 : #include <utils/foxtools/fxheader.h> 26 : #include <vector> 27 : #include <string> 28 : #include <map> 29 : #include <utils/common/StdDefs.h> 30 : #include <utils/common/SUMOTime.h> 31 : #include "GUIAppEnum.h" 32 : 33 : 34 : // =========================================================================== 35 : // class declarations 36 : // =========================================================================== 37 : class GUIEvent; 38 : class GUIGlChildWindow; 39 : class GUISUMOAbstractView; 40 : class MFXStaticToolTip; 41 : 42 : 43 : // =========================================================================== 44 : // class definitions 45 : // =========================================================================== 46 : class GUIMainWindow : public FXMainWindow { 47 : 48 : public: 49 : /// @brief constructor 50 : GUIMainWindow(FXApp* app); 51 : 52 : /// @brief destructor 53 : virtual ~GUIMainWindow(); 54 : 55 : /// @brief Adds a further child window to the list (GUIGlChildWindow) 56 : void addGLChild(GUIGlChildWindow* child); 57 : 58 : /// @brief Adds a further child window to the list (FXMainWindow) 59 : void addChild(FXMainWindow* child); 60 : 61 : /// @brief removes the given child window from the list (GUIGlChildWindow) 62 : void removeGLChild(GUIGlChildWindow* child); 63 : 64 : /// @brief removes the given child window from the list (FXMainWindow) 65 : void removeChild(FXMainWindow* child); 66 : 67 : /// @brief get top dock 68 : FXDockSite* getTopDock(); 69 : 70 : /// @brief get view IDs 71 : std::vector<std::string> getViewIDs() const; 72 : 73 : /// @brief get specific view by ID 74 : GUIGlChildWindow* getViewByID(const std::string& id) const; 75 : 76 : void removeViewByID(const std::string& id); 77 : 78 : /// @brief get views 79 : const std::vector<GUIGlChildWindow*>& getViews() const; 80 : 81 : /// @brief update childrens 82 : void updateChildren(int msg = MID_SIMSTEP); 83 : 84 : /// @brief get bold front 85 : FXFont* getBoldFont(); 86 : 87 : /// @brief get fallback front 88 : FXFont* getFallbackFont(); 89 : 90 : /// @brief get GL Visual 91 : FXGLVisual* getGLVisual() const; 92 : 93 : /// @brief get static toolTip for menus 94 : MFXStaticToolTip* getStaticTooltipMenu() const; 95 : 96 : /// @brief get static toolTip for view 97 : MFXStaticToolTip* getStaticTooltipView() const; 98 : 99 : /// @brief get build GL Canvas (must be implemented in all children) 100 : virtual FXGLCanvas* getBuildGLCanvas() const = 0; 101 : 102 : /// @brief get current sim time (must be implemented in all children) 103 : virtual SUMOTime getCurrentSimTime() const = 0; 104 : 105 : /// @brief get tracker interval (must be implemented in all children) 106 : virtual double getTrackerInterval() const = 0; 107 : 108 : /// @brief get status bar text (can be implemented in children) 109 0 : virtual void setStatusBarText(const std::string&) { } 110 : 111 : /// @brief get cartesian label 112 : FXLabel* getCartesianLabel(); 113 : 114 : /// @brief get geo label 115 : FXLabel* getGeoLabel(); 116 : 117 : /// @brief get test label 118 : FXLabel* getTestLabel(); 119 : 120 : /// @brief get test frame 121 : FXHorizontalFrame* getTestFrame(); 122 : 123 : /// @brief return whether the gui is in gaming mode 124 : bool isGaming() const; 125 : 126 : /// @brief return whether to list internal structures 127 : bool listInternal() const; 128 : 129 : /// @brief return whether to list parking vehicles 130 : bool listParking() const; 131 : 132 : /// @brief return whether to list teleporting vehicles 133 : bool listTeleporting() const; 134 : 135 : /// @brief get instance 136 : static GUIMainWindow* getInstance(); 137 : 138 : /** @brief Returns the delay (should be overwritten by subclasses if applicable) 139 : * @return parsed delay in milliseconds 140 : */ 141 0 : virtual double getDelay() const { 142 0 : return 0.; 143 : } 144 : 145 : /// @brief Sets the delay of the parent application 146 0 : virtual void setDelay(double) {} 147 : 148 : /// @brief Sets the breakpoints of the parent application 149 0 : virtual void setBreakpoints(const std::vector<SUMOTime>&) {} 150 : 151 : /** @brief Sends an event from the application thread to the GUI and waits until it is handled 152 : * @param event the event to send 153 : */ 154 0 : virtual void sendBlockingEvent(GUIEvent* event) { 155 : UNUSED_PARAMETER(event); 156 0 : } 157 : 158 : /// @brief get the active view or 0 159 : GUISUMOAbstractView* getActiveView() const; 160 : 161 : /// @brief Toggle full screen mode 162 0 : virtual long onCmdFullScreen(FXObject*, FXSelector, void*) { 163 0 : return 1; 164 : } 165 : 166 : bool isFullScreen() { 167 0 : return myAmFullScreen; 168 : } 169 : 170 : const std::map<std::string, std::string>& getOnlineMaps() const { 171 : return myOnlineMaps; 172 : } 173 : 174 : void addOnlineMap(const std::string& name, const std::string& url) { 175 0 : myOnlineMaps[name] = url; 176 0 : } 177 : 178 : /// @brief retrieve breakpoints if provided by the application 179 0 : virtual const std::vector<SUMOTime> retrieveBreakpoints() const { 180 0 : return std::vector<SUMOTime>(); 181 : } 182 : 183 : // @brief called when changes language 184 : long onCmdChangeLanguage(FXObject*, FXSelector, void*); 185 : 186 : // @brief called when language is updated 187 : long onUpdChangeLanguage(FXObject*, FXSelector, void*); 188 : 189 : protected: 190 : /// @brief FOX need this 191 0 : FOX_CONSTRUCTOR(GUIMainWindow) 192 : 193 : /// @brief whether to show the window in full screen mode 194 : bool myAmFullScreen; 195 : 196 : /// @brief list of GLWindows 197 : std::vector<GUIGlChildWindow*> myGLWindows; 198 : 199 : /// @brief list of tracker windows 200 : std::vector<FXMainWindow*> myTrackerWindows; 201 : 202 : /// @brief A lock to make the removal and addition of trackers secure 203 : FXMutex myTrackerLock; 204 : 205 : /// @brief Font used for popup-menu titles 206 : FXFont* myBoldFont = nullptr; 207 : 208 : /// @brief Fallback font for extended characters support 209 : FXFont* myFallbackFont = nullptr; 210 : 211 : /// @brief The multi view panel 212 : FXMDIClient* myMDIClient = nullptr; 213 : 214 : /// @brief The status bar 215 : FXStatusBar* myStatusbar = nullptr; 216 : 217 : /// @brief Labels for the current cartesian, geo-coordinate and test coordinates 218 : FXLabel* myCartesianCoordinate = nullptr; 219 : FXLabel* myGeoCoordinate = nullptr; 220 : FXLabel* myTestCoordinate = nullptr; 221 : 222 : /// @brief frames for coordinates 223 : FXHorizontalFrame* myTraCiFrame = nullptr; 224 : FXHorizontalFrame* myCartesianFrame = nullptr; 225 : FXHorizontalFrame* myGeoFrame = nullptr; 226 : FXHorizontalFrame* myTestFrame = nullptr; 227 : 228 : /// @brief The gl-visual used 229 : FXGLVisual* myGLVisual = nullptr; 230 : 231 : /// @brief dock sites 232 : FXDockSite* myTopDock = nullptr; 233 : FXDockSite* myBottomDock = nullptr; 234 : FXDockSite* myLeftDock = nullptr; 235 : FXDockSite* myRightDock = nullptr; 236 : 237 : /// @brief Language menu common to all applications 238 : FXMenuPane* myLanguageMenu = nullptr; 239 : 240 : /// @brief static toolTip used in menus 241 : MFXStaticToolTip* myStaticTooltipMenu = nullptr; 242 : 243 : /// @brief static toolTip used in view 244 : MFXStaticToolTip* myStaticTooltipView = nullptr; 245 : 246 : /// @brief information whether the gui is currently in gaming mode 247 : bool myAmGaming; 248 : 249 : /// @brief information whether the locator should list internal structures 250 : bool myListInternal; 251 : 252 : /// @brief information whether the locator should list parking vehicles 253 : bool myListParking; 254 : 255 : /// @brief information whether the locator should list teleporting vehicles 256 : bool myListTeleporting; 257 : 258 : /// @brief online mapping services for the context menu 259 : std::map<std::string, std::string> myOnlineMaps; 260 : 261 : /// @brief the singleton window instance 262 : static GUIMainWindow* myInstance; 263 : 264 : /// @brief perform initial window positioning and sizing according to user options / previous call 265 : void setWindowSizeAndPos(); 266 : 267 : /// @brief record window position and size in registry 268 : void storeWindowSizeAndPos(); 269 : 270 : void buildLanguageMenu(FXMenuBar* menuBar); 271 : 272 : };