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 GUISUMOViewParent.h 15 : /// @author Daniel Krajzewicz 16 : /// @author Jakob Erdmann 17 : /// @author Michael Behrisch 18 : /// @author Andreas Gaubatz 19 : /// @date Sept 2002 20 : /// 21 : // A single child window which contains a view of the simulation area 22 : /****************************************************************************/ 23 : #pragma once 24 : #include <config.h> 25 : 26 : #include <utils/gui/windows/GUIGlChildWindow.h> 27 : #include <utils/distribution/RandomDistributor.h> 28 : #include <utils/foxtools/MFXSynchQue.h> 29 : #include <utils/foxtools/MFXThreadEvent.h> 30 : 31 : // =========================================================================== 32 : // class declarations 33 : // =========================================================================== 34 : class GUINet; 35 : class GUISUMOAbstractView; 36 : class GUIDialog_GLObjChooser; 37 : class GUIDialog_ChooserAbstract; 38 : 39 : 40 : // =========================================================================== 41 : // class declarations 42 : // =========================================================================== 43 : /** 44 : * @class GUISUMOViewParent 45 : * @brief A single child window which contains a view of the simulation area 46 : * 47 : * It is made of a tool-bar containing a field to change the type of display, 48 : * buttons that allow to choose an artifact and some other view controlling 49 : * options. 50 : * 51 : * The rest of the window is a canvas that contains the display itself 52 : */ 53 : class GUISUMOViewParent : public GUIGlChildWindow { 54 : // FOX-declarations 55 0 : FXDECLARE(GUISUMOViewParent) 56 : 57 : public: 58 : /// @brief Available view types 59 : enum ViewType { 60 : /// @brief plain 2D openGL view (@see GUIViewTraffic) 61 : VIEW_2D_OPENGL, 62 : /// @brief plain 3D OSG view (@see GUIOSGView) 63 : VIEW_3D_OSG 64 : }; 65 : 66 : /** @brief Constructor 67 : * @param[in] p The MDI-pane this window is shown within 68 : * @param[in] mdimenu The MDI-menu for alignment 69 : * @param[in] name The name of the window 70 : * @param[in] parentWindow The main window 71 : * @param[in] ic The icon of this window 72 : * @param[in] opts Window options 73 : * @param[in] x Initial x-position 74 : * @param[in] y Initial x-position 75 : * @param[in] w Initial width 76 : * @param[in] h Initial height 77 : */ 78 : GUISUMOViewParent(FXMDIClient* p, FXMDIMenu* mdimenu, 79 : const FXString& name, GUIMainWindow* parentWindow, 80 : FXIcon* ic = NULL, FXuint opts = 0, FXint x = 0, FXint y = 0, FXint w = 0, FXint h = 0); 81 : 82 : 83 : /** @brief "Initialises" this window by building the contents 84 : * @param[in] share A canvas tor get the shared context from 85 : * @param[in] net The network to show 86 : * @param[in] vt The view type to use 87 : * @todo Check whether this could be done in the constructor 88 : */ 89 : virtual GUISUMOAbstractView* init(FXGLCanvas* share, GUINet& net, ViewType type); 90 : 91 : /// @brief Destructor 92 : ~GUISUMOViewParent(); 93 : 94 : /// @brief Called if the user wants to make a snapshot (screenshot) 95 : long onCmdMakeSnapshot(FXObject* sender, FXSelector, void*); 96 : 97 : /// @brief Called on a simulation step 98 : long onSimStep(FXObject* sender, FXSelector, void*); 99 : 100 : /// @brief locator-callback 101 : long onCmdLocate(FXObject*, FXSelector, void*); 102 : 103 : /// @brief speedFactor-callback 104 : long onCmdSpeedFactor(FXObject*, FXSelector, void*); 105 : long onUpdSpeedFactor(FXObject*, FXSelector, void*); 106 : 107 : /// @brief handle keys 108 : long onKeyPress(FXObject* o, FXSelector sel, void* data); 109 : long onKeyRelease(FXObject* o, FXSelector sel, void* data); 110 : 111 : /// @brief true if the object is selected (may include extra logic besides calling gSelected) 112 : bool isSelected(GUIGlObject* o) const; 113 : 114 : /// @brief about toggled gaming status 115 : void setToolBarVisibility(const bool value); 116 : 117 : /// @brief get all objects of the given type 118 : std::vector<GUIGlID> getObjectIDs(int messageId) const; 119 : 120 : /// @brief erase GLObjChooser 121 : void eraseGLObjChooser(GUIDialog_GLObjChooser* GLObjChooser); 122 : 123 : protected: 124 : /// @brief fox need this 125 0 : FOX_CONSTRUCTOR(GUISUMOViewParent) 126 : 127 : /// @brief build speed control toolbar 128 : void buildSpeedControlToolbar(); 129 : 130 : /// @brief toolbar shell for speed 131 : FXToolBarShell* myToolBarDragSpeed = nullptr; 132 : 133 : /// @brief toolbar for speed 134 : FXToolBar* myToolBarSpeed = nullptr; 135 : 136 : /// @brief slider for speedfactor 137 : FXSlider* mySpeedFactorSlider = nullptr; 138 : 139 : private: 140 : /// @brief map for existing dialogs 141 : std::map<int, GUIDialog_ChooserAbstract*> myGLObjChooser; 142 : };