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-2015 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),
64 };
65 
66 // Object implementation
67 FXIMPLEMENT(GUIGLObjectPopupMenu, FXMenuPane, GUIGLObjectPopupMenuMap, ARRAYNUMBER(GUIGLObjectPopupMenuMap))
68 
69 
70 // ===========================================================================
71 // method definitions
72 // ===========================================================================
74  GUISUMOAbstractView& parent,
75  GUIGlObject& o)
76  : FXMenuPane(&parent), myParent(&parent), myObject(&o),
77  myApplication(&app), myNetworkPosition(parent.getPositionInformation()) {
78 }
79 
80 
82 
83 
84 long
85 GUIGLObjectPopupMenu::onCmdCenter(FXObject*, FXSelector, void*) {
86  // we already know where the object is since we clicked on it -> zoom on Boundary
87  myParent->centerTo(myObject->getGlID(), true, -1);
88  return 1;
89 }
90 
91 
92 long
93 GUIGLObjectPopupMenu::onCmdCopyName(FXObject*, FXSelector, void*) {
95  return 1;
96 }
97 
98 
99 long
100 GUIGLObjectPopupMenu::onCmdCopyTypedName(FXObject*, FXSelector, void*) {
102  return 1;
103 }
104 
105 
106 long
107 GUIGLObjectPopupMenu::onCmdCopyEdgeName(FXObject*, FXSelector, void*) {
108  assert(myObject->getType() == GLO_LANE);
110  return 1;
111 }
112 
113 
114 long
115 GUIGLObjectPopupMenu::onCmdCopyCursorPosition(FXObject*, FXSelector, void*) {
117  return 1;
118 }
119 
120 
121 long
125  // formated for pasting into google maps
126  const std::string posString = toString(pos.y(), GEO_OUTPUT_ACCURACY) + ", " + toString(pos.x(), GEO_OUTPUT_ACCURACY);
127  GUIUserIO::copyToClipboard(*myParent->getApp(), posString);
128  return 1;
129 }
130 
131 
132 long
133 GUIGLObjectPopupMenu::onCmdShowPars(FXObject*, FXSelector, void*) {
134  myObject->getParameterWindow(*myApplication, *myParent); // !!! showParameterWindow would be more appropriate
135  return 1;
136 }
137 
138 
139 long
140 GUIGLObjectPopupMenu::onCmdAddSelected(FXObject*, FXSelector, void*) {
142  myParent->update();
143 #ifdef DEBUG_VEHICLE_GUI_SELECTION
145 #endif
146  return 1;
147 }
148 
149 
150 long
151 GUIGLObjectPopupMenu::onCmdRemoveSelected(FXObject*, FXSelector, void*) {
153  myParent->update();
154  return 1;
155 }
156 
157 
158 /****************************************************************************/
159 
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:217
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:223
#define GEO_OUTPUT_ACCURACY
Definition: config.h:16
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:154
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:221
GUISUMOAbstractView * myParent
The parent window.
Remove from selected items - Menu Etry.
Definition: GUIAppEnum.h:239
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:123
std::string gDebugSelectedVehicle
Definition: StdDefs.cpp:104
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.
Definition: GUIGlObject.h:167
Copy object name - popup entry.
Definition: GUIAppEnum.h:219
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:229
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
virtual const std::string & getParentName() const
Returns the name of the parent object (if any)
Definition: GUIGlObject.h:115
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.
Add to selected items - menu entry.
Definition: GUIAppEnum.h:237
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:227
GUIGlObject * myObject
The object that belongs to this popup-menu.
const std::string & getFullName() const
Returns the full name appearing in the tool tip.
Definition: GUIGlObject.h:108
Copy cursor position - popup entry.
Definition: GUIAppEnum.h:225
GUISelectedStorage gSelected
A global holder of selected objects.
FXDEFMAP(GUIGLObjectPopupMenu) GUIGLObjectPopupMenuMap[]