SUMO - Simulation of Urban MObility
GUIGLObjectPopupMenu.cpp
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // The popup menu of a globject
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 
00023 
00024 // ===========================================================================
00025 // included modules
00026 // ===========================================================================
00027 #ifdef _MSC_VER
00028 #include <windows_config.h>
00029 #else
00030 #include <config.h>
00031 #endif
00032 
00033 #include <iostream>
00034 #include <cassert>
00035 #include <utils/geom/GeoConvHelper.h>
00036 #include <utils/gui/windows/GUISUMOAbstractView.h>
00037 #include <utils/gui/globjects/GUIGlObject.h>
00038 #include <utils/gui/windows/GUIAppEnum.h>
00039 #include <utils/gui/div/GUIParameterTableWindow.h>
00040 #include <utils/gui/div/GUIGlobalSelection.h>
00041 #include <utils/gui/div/GUIUserIO.h>
00042 #include <utils/common/ToString.h>
00043 #include "GUIGLObjectPopupMenu.h"
00044 
00045 #ifdef CHECK_MEMORY_LEAKS
00046 #include <foreign/nvwa/debug_new.h>
00047 #endif // CHECK_MEMORY_LEAKS
00048 
00049 
00050 // ===========================================================================
00051 // FOX callback mapping
00052 // ===========================================================================
00053 FXDEFMAP(GUIGLObjectPopupMenu) GUIGLObjectPopupMenuMap[] = {
00054     FXMAPFUNC(SEL_COMMAND,  MID_CENTER,                  GUIGLObjectPopupMenu::onCmdCenter),
00055     FXMAPFUNC(SEL_COMMAND,  MID_COPY_NAME,               GUIGLObjectPopupMenu::onCmdCopyName),
00056     FXMAPFUNC(SEL_COMMAND,  MID_COPY_TYPED_NAME,         GUIGLObjectPopupMenu::onCmdCopyTypedName),
00057     FXMAPFUNC(SEL_COMMAND,  MID_COPY_CURSOR_POSITION,    GUIGLObjectPopupMenu::onCmdCopyCursorPosition),
00058     FXMAPFUNC(SEL_COMMAND,  MID_COPY_CURSOR_GEOPOSITION, GUIGLObjectPopupMenu::onCmdCopyCursorGeoPosition),
00059     FXMAPFUNC(SEL_COMMAND,  MID_SHOWPARS,                GUIGLObjectPopupMenu::onCmdShowPars),
00060     FXMAPFUNC(SEL_COMMAND,  MID_ADDSELECT,               GUIGLObjectPopupMenu::onCmdAddSelected),
00061     FXMAPFUNC(SEL_COMMAND,  MID_REMOVESELECT,            GUIGLObjectPopupMenu::onCmdRemoveSelected)
00062 };
00063 
00064 // Object implementation
00065 FXIMPLEMENT(GUIGLObjectPopupMenu, FXMenuPane, GUIGLObjectPopupMenuMap, ARRAYNUMBER(GUIGLObjectPopupMenuMap))
00066 
00067 
00068 // ===========================================================================
00069 // method definitions
00070 // ===========================================================================
00071 GUIGLObjectPopupMenu::GUIGLObjectPopupMenu(GUIMainWindow& app,
00072         GUISUMOAbstractView& parent,
00073         GUIGlObject& o)
00074     : FXMenuPane(&parent), myParent(&parent), myObject(&o),
00075       myApplication(&app), myNetworkPosition(parent.getPositionInformation()) {
00076 }
00077 
00078 
00079 GUIGLObjectPopupMenu::~GUIGLObjectPopupMenu() {}
00080 
00081 
00082 long
00083 GUIGLObjectPopupMenu::onCmdCenter(FXObject*, FXSelector, void*) {
00084     // we already know where the object is since we clicked on it -> zoom on Boundary
00085     myParent->centerTo(myObject->getGlID(), true, -1);
00086     return 1;
00087 }
00088 
00089 
00090 long
00091 GUIGLObjectPopupMenu::onCmdCopyName(FXObject*, FXSelector, void*) {
00092     GUIUserIO::copyToClipboard(*myParent->getApp(), myObject->getMicrosimID());
00093     return 1;
00094 }
00095 
00096 
00097 long
00098 GUIGLObjectPopupMenu::onCmdCopyTypedName(FXObject*, FXSelector, void*) {
00099     GUIUserIO::copyToClipboard(*myParent->getApp(), myObject->getFullName());
00100     return 1;
00101 }
00102 
00103 
00104 long
00105 GUIGLObjectPopupMenu::onCmdCopyCursorPosition(FXObject*, FXSelector, void*) {
00106     GUIUserIO::copyToClipboard(*myParent->getApp(), toString(myNetworkPosition));
00107     return 1;
00108 }
00109 
00110 
00111 long
00112 GUIGLObjectPopupMenu::onCmdCopyCursorGeoPosition(FXObject*, FXSelector, void*) {
00113     Position pos = myNetworkPosition;
00114     GeoConvHelper::getFinal().cartesian2geo(pos);
00115     // formated for pasting into google maps
00116     const std::string posString = toString(pos.y(), GEO_OUTPUT_ACCURACY) + ", " + toString(pos.x(), GEO_OUTPUT_ACCURACY);
00117     GUIUserIO::copyToClipboard(*myParent->getApp(), posString);
00118     return 1;
00119 }
00120 
00121 
00122 long
00123 GUIGLObjectPopupMenu::onCmdShowPars(FXObject*, FXSelector, void*) {
00124     myObject->getParameterWindow(*myApplication, *myParent); // !!! showParameterWindow would be more appropriate
00125     return 1;
00126 }
00127 
00128 
00129 long
00130 GUIGLObjectPopupMenu::onCmdAddSelected(FXObject*, FXSelector, void*) {
00131     gSelected.select(myObject->getGlID());
00132     myParent->update();
00133     return 1;
00134 }
00135 
00136 
00137 long
00138 GUIGLObjectPopupMenu::onCmdRemoveSelected(FXObject*, FXSelector, void*) {
00139     gSelected.deselect(myObject->getGlID());
00140     myParent->update();
00141     return 1;
00142 }
00143 
00144 
00145 /****************************************************************************/
00146 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines