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 GUIParam_PopupMenu.cpp 15 : /// @author Daniel Krajzewicz 16 : /// @author Michael Behrisch 17 : /// @date Mai 2003 18 : /// 19 : // A popup-menu for dynamic patameter table entries 20 : /****************************************************************************/ 21 : #include <config.h> 22 : 23 : #include <iostream> 24 : #include <string> 25 : #include "GUIParameterTableWindow.h" 26 : #include <utils/gui/globjects/GUIGlObject.h> 27 : #include "GUIParam_PopupMenu.h" 28 : #include <utils/gui/tracker/GUIParameterTracker.h> 29 : #include <utils/gui/tracker/TrackerValueDesc.h> 30 : #include <utils/gui/windows/GUIAppEnum.h> 31 : #include <utils/gui/windows/GUIMainWindow.h> 32 : 33 : 34 : // =========================================================================== 35 : // FOX callback mapping 36 : // =========================================================================== 37 : FXDEFMAP(GUIParam_PopupMenuInterface) GUIParam_PopupMenuInterfaceMap[] = { 38 : FXMAPFUNC(SEL_COMMAND, MID_OPENTRACKER, GUIParam_PopupMenuInterface::onCmdOpenTracker), 39 : }; 40 : 41 : // Object implementation 42 0 : FXIMPLEMENT(GUIParam_PopupMenuInterface, FXMenuPane, GUIParam_PopupMenuInterfaceMap, ARRAYNUMBER(GUIParam_PopupMenuInterfaceMap)) 43 : 44 : 45 : // =========================================================================== 46 : // method definitions 47 : // =========================================================================== 48 0 : GUIParam_PopupMenuInterface::GUIParam_PopupMenuInterface(GUIMainWindow& app, 49 : GUIParameterTableWindow& parentWindow, GUIGlObject& o, const std::string& varName, 50 0 : ValueSource<double>* src) 51 0 : : FXMenuPane(&parentWindow), myObject(&o), myParentWindow(&parentWindow), 52 0 : myApplication(&app), myVarName(varName), mySource(src) { 53 0 : } 54 : 55 : 56 0 : GUIParam_PopupMenuInterface::~GUIParam_PopupMenuInterface() { 57 0 : delete mySource; 58 0 : } 59 : 60 : 61 : long 62 0 : GUIParam_PopupMenuInterface::onCmdOpenTracker(FXObject*, FXSelector, void*) { 63 0 : std::string trackerName = myVarName + " from " + myObject->getFullName(); 64 0 : TrackerValueDesc* newTracked = new TrackerValueDesc(myVarName, RGBColor::BLACK, myApplication->getCurrentSimTime(), myApplication->getTrackerInterval()); 65 0 : if (!GUIParameterTracker::addTrackedMultiplot(*myObject, mySource->copy(), newTracked)) { 66 0 : GUIParameterTracker* tr = new GUIParameterTracker(*myApplication, trackerName); 67 0 : tr->addTracked(*myObject, mySource->copy(), newTracked); 68 0 : tr->create(); 69 0 : tr->show(); 70 : } 71 0 : return 1; 72 : } 73 : 74 : 75 : /****************************************************************************/