GUIJunctionWrapper.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include <string>
00031 #include <utility>
00032 #include <microsim/MSLane.h>
00033 #include <utils/geom/Position2D.h>
00034 #include <microsim/MSNet.h>
00035 #include <gui/GUIApplicationWindow.h>
00036 #include <gui/GUIGlobals.h>
00037 #include <utils/gui/windows/GUIAppEnum.h>
00038 #include <utils/gui/windows/GUISUMOAbstractView.h>
00039 #include "GUIJunctionWrapper.h"
00040 #include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
00041 #include <utils/gui/div/GUIGlobalSelection.h>
00042 #include <utils/gui/div/GUIParameterTableWindow.h>
00043 #include <utils/gui/div/GLHelper.h>
00044 #include <foreign/polyfonts/polyfonts.h>
00045
00046 #ifdef CHECK_MEMORY_LEAKS
00047 #include <foreign/nvwa/debug_new.h>
00048 #endif // CHECK_MEMORY_LEAKS
00049
00050
00051
00052
00053
00054 GUIJunctionWrapper::GUIJunctionWrapper(GUIGlObjectStorage &idStorage,
00055 MSJunction &junction) throw()
00056 : GUIGlObject(idStorage, "junction:"+junction.getID()),
00057 myJunction(junction) {
00058 if (myJunction.getShape().size()==0) {
00059 Position2D pos = myJunction.getPosition();
00060 myBoundary = Boundary(pos.x()-1., pos.y()-1., pos.x()+1., pos.y()+1.);
00061 } else {
00062 myBoundary = myJunction.getShape().getBoxBoundary();
00063 }
00064 myMaxSize = MAX2(myBoundary.getWidth(), myBoundary.getHeight());
00065 }
00066
00067
00068 GUIJunctionWrapper::~GUIJunctionWrapper() throw() {}
00069
00070
00071 GUIGLObjectPopupMenu *
00072 GUIJunctionWrapper::getPopUpMenu(GUIMainWindow &app,
00073 GUISUMOAbstractView &parent) throw() {
00074 GUIGLObjectPopupMenu *ret = new GUIGLObjectPopupMenu(app, parent, *this);
00075 buildPopupHeader(ret, app);
00076 buildCenterPopupEntry(ret);
00077 buildNameCopyPopupEntry(ret);
00078 buildSelectionPopupEntry(ret);
00079 buildPositionCopyEntry(ret, false);
00080 return ret;
00081 }
00082
00083
00084 GUIParameterTableWindow *
00085 GUIJunctionWrapper::getParameterWindow(GUIMainWindow &app,
00086 GUISUMOAbstractView &) throw() {
00087 return 0;
00088 }
00089
00090
00091 const std::string &
00092 GUIJunctionWrapper::getMicrosimID() const throw() {
00093 return myJunction.getID();
00094 }
00095
00096
00097 Boundary
00098 GUIJunctionWrapper::getCenteringBoundary() const throw() {
00099 Boundary b = myBoundary;
00100 b.grow(20);
00101 return b;
00102 }
00103
00104
00105 void
00106 GUIJunctionWrapper::drawGL(const GUIVisualizationSettings &s) const throw() {
00107
00108 if (s.scale*myMaxSize<1.) {
00109 return;
00110 }
00111
00112 if (s.needsGlID) {
00113 glPushName(getGlID());
00114 }
00115 glColor3d(0, 0, 0);
00116 glTranslated(0, 0, .01);
00117 GLHelper::drawFilledPoly(myJunction.getShape(), true);
00118 glTranslated(0, 0, -.01);
00119
00120 if (s.drawJunctionName) {
00121 glPushMatrix();
00122 glTranslated(0, 0, -.06);
00123 Position2D p = myJunction.getPosition();
00124 glTranslated(p.x(), p.y(), 0);
00125 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00126 pfSetPosition(0, 0);
00127 pfSetScale(s.junctionNameSize / s.scale);
00128 glColor3d(s.junctionNameColor.red(), s.junctionNameColor.green(), s.junctionNameColor.blue());
00129 SUMOReal w = pfdkGetStringWidth(getMicrosimID().c_str());
00130 glRotated(180, 1, 0, 0);
00131 glTranslated(-w/2., 0.4, 0);
00132 pfDrawString(getMicrosimID().c_str());
00133 glPopMatrix();
00134 }
00135
00136 if (s.needsGlID) {
00137 glPopName();
00138 }
00139 }
00140
00141
00142
00143