SUMO - Simulation of Urban MObility
GUIGLObjectPopupMenu.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // The popup menu of a globject
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <iostream>
34 #include <cassert>
42 #include <utils/common/ToString.h>
43 #include "GUIGLObjectPopupMenu.h"
44 
45 #ifdef CHECK_MEMORY_LEAKS
46 #include <foreign/nvwa/debug_new.h>
47 #endif // CHECK_MEMORY_LEAKS
48 
49 #define DEBUG_VEHICLE_GUI_SELECTION 1
50 
51 // ===========================================================================
52 // FOX callback mapping
53 // ===========================================================================
54 FXDEFMAP(GUIGLObjectPopupMenu) GUIGLObjectPopupMenuMap[] = {
55  FXMAPFUNC(SEL_COMMAND, MID_CENTER, GUIGLObjectPopupMenu::onCmdCenter),
56  FXMAPFUNC(SEL_COMMAND, MID_COPY_NAME, GUIGLObjectPopupMenu::onCmdCopyName),
61  FXMAPFUNC(SEL_COMMAND, MID_SHOWPARS, GUIGLObjectPopupMenu::onCmdShowPars),
65 };
66 
67 // Object implementation
68 FXIMPLEMENT(GUIGLObjectPopupMenu, FXMenuPane, GUIGLObjectPopupMenuMap, ARRAYNUMBER(GUIGLObjectPopupMenuMap))
69 
70 
71 // ===========================================================================
72 // method definitions
73 // ===========================================================================
75  GUISUMOAbstractView& parent,
76  GUIGlObject& o)
77  : FXMenuPane(&parent), myParent(&parent), myObject(&o),
78  myApplication(&app), myNetworkPosition(parent.getPositionInformation()) {
79 }
80 
81 
83 
84 
85 long
86 GUIGLObjectPopupMenu::onCmdCenter(FXObject*, FXSelector, void*) {
87  // we already know where the object is since we clicked on it -> zoom on Boundary
88  myParent->centerTo(myObject->getGlID(), true, -1);
89  return 1;
90 }
91 
92 
93 long
94 GUIGLObjectPopupMenu::onCmdCopyName(FXObject*, FXSelector, void*) {
96  return 1;
97 }
98 
99 
100 long
101 GUIGLObjectPopupMenu::onCmdCopyTypedName(FXObject*, FXSelector, void*) {
103  return 1;
104 }
105 
106 
107 long
108 GUIGLObjectPopupMenu::onCmdCopyEdgeName(FXObject*, FXSelector, void*) {
109  assert(myObject->getType() == GLO_LANE);
111  return 1;
112 }
113 
114 
115 long
116 GUIGLObjectPopupMenu::onCmdCopyCursorPosition(FXObject*, FXSelector, void*) {
118  return 1;
119 }
120 
121 
122 long
126  // formated for pasting into google maps
127  const std::string posString = toString(pos.y(), GEO_OUTPUT_ACCURACY) + ", " + toString(pos.x(), GEO_OUTPUT_ACCURACY);
128  GUIUserIO::copyToClipboard(*myParent->getApp(), posString);
129  return 1;
130 }
131 
132 
133 long
134 GUIGLObjectPopupMenu::onCmdShowPars(FXObject*, FXSelector, void*) {
136  return 1;
137 }
138 
139 
140 
141 long
142 GUIGLObjectPopupMenu::onCmdShowTypePars(FXObject*, FXSelector, void*) {
144  return 1;
145 }
146 
147 
148 long
149 GUIGLObjectPopupMenu::onCmdAddSelected(FXObject*, FXSelector, void*) {
151  myParent->update();
152 #ifdef DEBUG_VEHICLE_GUI_SELECTION
154 #endif
155  return 1;
156 }
157 
158 
159 long
160 GUIGLObjectPopupMenu::onCmdRemoveSelected(FXObject*, FXSelector, void*) {
162  myParent->update();
163  return 1;
164 }
165 
166 
167 /****************************************************************************/
168 
long onCmdCenter(FXObject *, FXSelector, void *)
Called if the assigned objects shall be centered.
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
Position myNetworkPosition
The position within the network the cursor was above when instanting the popup.
long onCmdCopyName(FXObject *, FXSelector, void *)
Called if the name shall be copied to clipboard.
static void copyToClipboard(const FXApp &app, const std::string &text)
Copies the given text to clipboard.
Definition: GUIUserIO.cpp:49
Center view to object - popup entry.
Definition: GUIAppEnum.h:229
long onCmdAddSelected(FXObject *, FXSelector, void *)
Called if the object shall be added to the list of selected objects.
virtual void centerTo(GUIGlID id, bool applyZoom, SUMOReal zoomDist=20)
centers to the chosen artifact
long onCmdCopyCursorPosition(FXObject *, FXSelector, void *)
Called if the cursor position shall be copied to clipboard.
Copy edge name (for lanes only)
Definition: GUIAppEnum.h:235
const std::string & getFullName() const
#define GEO_OUTPUT_ACCURACY
Definition: config.h:16
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
long onCmdCopyCursorGeoPosition(FXObject *, FXSelector, void *)
Called if the cursor geo-position shall be copied to clipboard.
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:233
GUISUMOAbstractView * myParent
The parent window.
long onCmdShowTypePars(FXObject *, FXSelector, void *)
Called if the type parameter of this object shall be shown.
Show object type parameter - popup entry.
Definition: GUIAppEnum.h:243
Remove from selected items - Menu Etry.
Definition: GUIAppEnum.h:253
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
GUIGlID getGlID() const
Returns the numerical id of the object.
std::string gDebugSelectedVehicle
Definition: StdDefs.cpp:95
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
long onCmdCopyEdgeName(FXObject *, FXSelector, void *)
Called if the edge name shall be copied to clipboard (for lanes only)
virtual ~GUIGLObjectPopupMenu()
Destructor.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
virtual GUIParameterTableWindow * getTypeParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own type parameter window (optional)
Copy object name - popup entry.
Definition: GUIAppEnum.h:231
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)=0
Returns an own parameter window.
Show object parameter - popup entry.
Definition: GUIAppEnum.h:241
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
long onCmdCopyTypedName(FXObject *, FXSelector, void *)
Called if the typed name shall be copied to clipboard.
void deselect(GUIGlID id)
Deselects the object with the given id.
virtual const std::string & getParentName() const
Returns the name of the parent object (if any)
Add to selected items - menu entry.
Definition: GUIAppEnum.h:251
long onCmdRemoveSelected(FXObject *, FXSelector, void *)
Called if the object shall be removed from the list of selected objects.
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
The popup menu of a globject.
long onCmdShowPars(FXObject *, FXSelector, void *)
Called if the parameter of this object shall be shown.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
GUIMainWindow * myApplication
The main application.
Copy cursor geo-coordinate position - popup entry.
Definition: GUIAppEnum.h:239
GUIGlObject * myObject
The object that belongs to this popup-menu.
Copy cursor position - popup entry.
Definition: GUIAppEnum.h:237
GUISelectedStorage gSelected
A global holder of selected objects.
FXDEFMAP(GUIGLObjectPopupMenu) GUIGLObjectPopupMenuMap[]