Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/gui/div/GUIParam_PopupMenu.cpp
169684 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
FXIMPLEMENT(GUIParam_PopupMenuInterface, FXMenuPane, GUIParam_PopupMenuInterfaceMap, ARRAYNUMBER(GUIParam_PopupMenuInterfaceMap))
43
44
45
// ===========================================================================
46
// method definitions
47
// ===========================================================================
48
GUIParam_PopupMenuInterface::GUIParam_PopupMenuInterface(GUIMainWindow& app,
49
GUIParameterTableWindow& parentWindow, GUIGlObject& o, const std::string& varName,
50
ValueSource<double>* src)
51
: FXMenuPane(&parentWindow), myObject(&o), myParentWindow(&parentWindow),
52
myApplication(&app), myVarName(varName), mySource(src) {
53
}
54
55
56
GUIParam_PopupMenuInterface::~GUIParam_PopupMenuInterface() {
57
delete mySource;
58
}
59
60
61
long
62
GUIParam_PopupMenuInterface::onCmdOpenTracker(FXObject*, FXSelector, void*) {
63
std::string trackerName = myVarName + " from " + myObject->getFullName();
64
TrackerValueDesc* newTracked = new TrackerValueDesc(myVarName, RGBColor::BLACK, myApplication->getCurrentSimTime(), myApplication->getTrackerInterval());
65
if (!GUIParameterTracker::addTrackedMultiplot(*myObject, mySource->copy(), newTracked)) {
66
GUIParameterTracker* tr = new GUIParameterTracker(*myApplication, trackerName);
67
tr->addTracked(*myObject, mySource->copy(), newTracked);
68
tr->create();
69
tr->show();
70
}
71
return 1;
72
}
73
74
75
/****************************************************************************/
76
77