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  FXMenuPane(&parent),
76  myParent(&parent),
77  myObject(&o),
78  myApplication(&app),
79  myNetworkPosition(parent.getPositionInformation()) {
80 }
81 
82 
84  // Delete MenuPaneChilds
85  for (std::vector<FXMenuPane*>::iterator i = myMenuPanes.begin(); i != myMenuPanes.end(); i++) {
86  delete(*i);
87  }
88 }
89 
90 
91 void
93  // Check that MenuPaneChild isn't NULL
94  if (child == NULL) {
95  throw ProcessError("MenuPaneChild cannot be NULL");
96  }
97  // Check that MenuPaneChild wasn't already inserted
98  for (std::vector<FXMenuPane*>::iterator i = myMenuPanes.begin(); i != myMenuPanes.end(); i++) {
99  if ((*i) == child) {
100  throw ProcessError("MenuPaneChild already inserted");
101  }
102  }
103  // Insert MenuPaneChild
104  myMenuPanes.push_back(child);
105 }
106 
107 
108 long
109 GUIGLObjectPopupMenu::onCmdCenter(FXObject*, FXSelector, void*) {
110  // we already know where the object is since we clicked on it -> zoom on Boundary
111  myParent->centerTo(myObject->getGlID(), true, -1);
112  return 1;
113 }
114 
115 
116 long
117 GUIGLObjectPopupMenu::onCmdCopyName(FXObject*, FXSelector, void*) {
119  return 1;
120 }
121 
122 
123 long
124 GUIGLObjectPopupMenu::onCmdCopyTypedName(FXObject*, FXSelector, void*) {
126  return 1;
127 }
128 
129 
130 long
131 GUIGLObjectPopupMenu::onCmdCopyEdgeName(FXObject*, FXSelector, void*) {
132  assert(myObject->getType() == GLO_LANE);
134  return 1;
135 }
136 
137 
138 long
139 GUIGLObjectPopupMenu::onCmdCopyCursorPosition(FXObject*, FXSelector, void*) {
141  return 1;
142 }
143 
144 
145 long
149  // formated for pasting into google maps
150  const std::string posString = toString(pos.y(), GEO_OUTPUT_ACCURACY) + ", " + toString(pos.x(), GEO_OUTPUT_ACCURACY);
151  GUIUserIO::copyToClipboard(*myParent->getApp(), posString);
152  return 1;
153 }
154 
155 
156 long
157 GUIGLObjectPopupMenu::onCmdShowPars(FXObject*, FXSelector, void*) {
159  return 1;
160 }
161 
162 
163 
164 long
165 GUIGLObjectPopupMenu::onCmdShowTypePars(FXObject*, FXSelector, void*) {
167  return 1;
168 }
169 
170 
171 long
172 GUIGLObjectPopupMenu::onCmdAddSelected(FXObject*, FXSelector, void*) {
174  myParent->update();
175 #ifdef DEBUG_VEHICLE_GUI_SELECTION
177 #endif
178  return 1;
179 }
180 
181 
182 long
183 GUIGLObjectPopupMenu::onCmdRemoveSelected(FXObject*, FXSelector, void*) {
185  myParent->update();
186  return 1;
187 }
188 
189 
190 /****************************************************************************/
191 
long onCmdCenter(FXObject *, FXSelector, void *)
Called if the assigned objects shall be centered.
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
#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
std::string gDebugSelectedVehicle
Definition: StdDefs.cpp:95
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
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.
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
std::vector< FXMenuPane * > myMenuPanes
list mit Sub-MenuPanes
Show object parameter - popup entry.
Definition: GUIAppEnum.h:241
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
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.
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.
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...
virtual const std::string & getParentName() const
Returns the name of the parent object (if any)
GUIGlID getGlID() const
Returns the numerical id of the object.
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
GUIMainWindow * myApplication
The main application.
Copy cursor geo-coordinate position - popup entry.
Definition: GUIAppEnum.h:239
const std::string & getFullName() const
GUIGlObject * myObject
The object that belongs to this popup-menu.
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
Copy cursor position - popup entry.
Definition: GUIAppEnum.h:237
GUISelectedStorage gSelected
A global holder of selected objects.
FXDEFMAP(GUIGLObjectPopupMenu) GUIGLObjectPopupMenuMap[]