SUMO - Simulation of Urban MObility

GUIGLObjectPopupMenu.cpp

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