GUIJunctionWrapper Class Reference

#include <GUIJunctionWrapper.h>

Inheritance diagram for GUIJunctionWrapper:

GUIGlObject

Detailed Description

As MSJunctions do not have a graphical representation but a complex inheritance tree, this class is used to encapsulate the geometry of an abstract junction and to be used as a gl-object.

In the case the represented junction's shape is empty, the boundary is computed using the junction's position to which an offset of 1m to each side is added.

Definition at line 61 of file GUIJunctionWrapper.h.


Public Member Functions

virtual bool active () const throw ()
 Returns the information whether this object is still active.
Boundary getBoundary () const throw ()
 Returns the boundary of the junction.
 GUIJunctionWrapper (GUIGlObjectStorage &idStorage, MSJunction &junction) throw ()
 Constructor.
virtual ~GUIJunctionWrapper () throw ()
 Destructor.
inherited from GUIGlObject
void drawGL (const GUIVisualizationSettings &s) const throw ()
 Draws the object.
Boundary getCenteringBoundary () const throw ()
 Returns the boundary to which the view shall be centered in order to show the object.
const std::string & getMicrosimID () const throw ()
 Returns the id of the object as known to microsim.
GUIParameterTableWindowgetParameterWindow (GUIMainWindow &app, GUISUMOAbstractView &parent) throw ()
 Returns an own parameter window.
GUIGLObjectPopupMenugetPopUpMenu (GUIMainWindow &app, GUISUMOAbstractView &parent) throw ()
 Returns an own popup-menu.
GUIGlObjectType getType () const throw ()
 Returns the type of the object as coded in GUIGlObjectType.
Atomar getter methods
const std::string & getFullName () const throw ()
 Returns the full name appearing in the tool tip.
GLuint getGlID () const throw ()
 Returns the numerical id of the object.

Protected Member Functions

helper methods for building popup-menus
void buildCenterPopupEntry (GUIGLObjectPopupMenu *ret, bool addSeparator=true) throw ()
 Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry (GUIGLObjectPopupMenu *ret, bool addSeparator=true) throw ()
 Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader (GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true) throw ()
 Builds the header.
void buildPositionCopyEntry (GUIGLObjectPopupMenu *ret, bool addSeparator=true) throw ()
 Builds an entry which allows to copy the cursor position.
void buildSelectionPopupEntry (GUIGLObjectPopupMenu *ret, bool addSeparator=true) throw ()
 Builds an entry which allows to (de)select the object.
void buildShowManipulatorPopupEntry (GUIGLObjectPopupMenu *ret, bool addSeparator=true) throw ()
 Builds an entry which allows to open the manipulator window.
void buildShowParamsPopupEntry (GUIGLObjectPopupMenu *ret, bool addSeparator=true) throw ()
 Builds an entry which allows to open the parameter window.

Protected Attributes

Boundary myBoundary
 The represented junction's boundary.
MSJunctionmyJunction
 A reference to the represented junction.
SUMOReal myMaxSize
 The maximum size (in either x-, or y-dimension) for determining whether to draw or not.

Private Member Functions

 GUIJunctionWrapper (const GUIJunctionWrapper &)
 Invalidated copy constructor.
GUIJunctionWrapperoperator= (const GUIJunctionWrapper &)
 Invalidated assignment operator.

Friends

class GUIGlObjectStorage
 Needed to set the id.

Constructor & Destructor Documentation

GUIJunctionWrapper::GUIJunctionWrapper ( GUIGlObjectStorage idStorage,
MSJunction junction 
) throw ()

Constructor.

Parameters:
in,changed] idStorage The storage to retrieve the gl-id from
[in] junction The represented junction

Definition at line 54 of file GUIJunctionWrapper.cpp.

References MAX2(), Position2D::x(), and Position2D::y().

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 }

GUIJunctionWrapper::~GUIJunctionWrapper (  )  throw () [virtual]

Destructor.

Definition at line 68 of file GUIJunctionWrapper.cpp.

00068 {}

GUIJunctionWrapper::GUIJunctionWrapper ( const GUIJunctionWrapper  )  [private]

Invalidated copy constructor.


Member Function Documentation

virtual bool GUIGlObject::active (  )  const throw () [inline, virtual, inherited]

Returns the information whether this object is still active.

Returns:
Whether this object is active (always true in this case)

Reimplemented in GUIVehicle.

Definition at line 171 of file GUIGlObject.h.

Referenced by GLObjectValuePassConnector< std::pair< int, MSPhaseDefinition > >::updateEachTimestep().

00171                                         {
00172         return true;
00173     }

void GUIGlObject::buildCenterPopupEntry ( GUIGLObjectPopupMenu ret,
bool  addSeparator = true 
) throw () [protected, inherited]

Builds an entry which allows to center to the object.

Parameters:
in,filled] ret The popup menu to add the entry to
[in] app The application, needed for callbacks
[in] addSeparator Whether a separator shall be added, too

Definition at line 86 of file GUIGlObject.cpp.

References GUIIconSubSys::getIcon(), ICON_RECENTERVIEW, and MID_CENTER.

Referenced by GUIVehicle::getPopUpMenu(), GUITriggeredRerouter::getPopUpMenu(), GUITrafficLightLogicWrapper::getPopUpMenu(), GUIPolygon2D::getPopUpMenu(), GUIPointOfInterest::getPopUpMenu(), GUINet::getPopUpMenu(), GUILaneWrapper::getPopUpMenu(), GUILaneSpeedTrigger::getPopUpMenu(), getPopUpMenu(), GUIEmitter::getPopUpMenu(), GUIEdge::getPopUpMenu(), GUIDetectorWrapper::getPopUpMenu(), and GUIBusStop::getPopUpMenu().

00087                                                               {
00088     new FXMenuCommand(ret, "Center", GUIIconSubSys::getIcon(ICON_RECENTERVIEW), ret, MID_CENTER);
00089     if (addSeparator) {
00090         new FXMenuSeparator(ret);
00091     }
00092 }

void GUIGlObject::buildNameCopyPopupEntry ( GUIGLObjectPopupMenu ret,
bool  addSeparator = true 
) throw () [protected, inherited]

Builds entries which allow to copy the name / typed name into the clipboard.

Parameters:
in,filled] ret The popup menu to add the entry to
[in] app The application, needed for callbacks
[in] addSeparator Whether a separator shall be added, too

Definition at line 96 of file GUIGlObject.cpp.

References MID_COPY_NAME, and MID_COPY_TYPED_NAME.

Referenced by GUIVehicle::getPopUpMenu(), GUITriggeredRerouter::getPopUpMenu(), GUITrafficLightLogicWrapper::getPopUpMenu(), GUIPolygon2D::getPopUpMenu(), GUIPointOfInterest::getPopUpMenu(), GUILaneWrapper::getPopUpMenu(), GUILaneSpeedTrigger::getPopUpMenu(), getPopUpMenu(), GUIEmitter::getPopUpMenu(), GUIEdge::getPopUpMenu(), GUIDetectorWrapper::getPopUpMenu(), and GUIBusStop::getPopUpMenu().

00097                                                                 {
00098     new FXMenuCommand(ret, "Copy name to clipboard", 0, ret, MID_COPY_NAME);
00099     new FXMenuCommand(ret, "Copy typed name to clipboard", 0, ret, MID_COPY_TYPED_NAME);
00100     if (addSeparator) {
00101         new FXMenuSeparator(ret);
00102     }
00103 }

void GUIGlObject::buildPopupHeader ( GUIGLObjectPopupMenu ret,
GUIMainWindow app,
bool  addSeparator = true 
) throw () [protected, inherited]

Builds the header.

Parameters:
in,filled] ret The popup menu to add the entry to
[in] app The application, needed for callbacks
[in] addSeparator Whether a separator shall be added, too

Definition at line 75 of file GUIGlObject.cpp.

References GUIGlObject::getFullName().

Referenced by GUIVehicle::getPopUpMenu(), GUITriggeredRerouter::getPopUpMenu(), GUITrafficLightLogicWrapper::getPopUpMenu(), GUIPolygon2D::getPopUpMenu(), GUIPointOfInterest::getPopUpMenu(), GUINet::getPopUpMenu(), GUILaneWrapper::getPopUpMenu(), GUILaneSpeedTrigger::getPopUpMenu(), getPopUpMenu(), GUIEmitter::getPopUpMenu(), GUIEdge::getPopUpMenu(), GUIDetectorWrapper::getPopUpMenu(), and GUIBusStop::getPopUpMenu().

00077                                                          {
00078     new MFXMenuHeader(ret, app.getBoldFont(), getFullName().c_str(), 0, 0, 0);
00079     if (addSeparator) {
00080         new FXMenuSeparator(ret);
00081     }
00082 }

void GUIGlObject::buildPositionCopyEntry ( GUIGLObjectPopupMenu ret,
bool  addSeparator = true 
) throw () [protected, inherited]

Builds an entry which allows to copy the cursor position.

Parameters:
in,filled] ret The popup menu to add the entry to
[in] app The application, needed for callbacks
[in] addSeparator Whether a separator shall be added, too

Definition at line 131 of file GUIGlObject.cpp.

References MID_COPY_CURSOR_POSITION.

Referenced by GUIVehicle::getPopUpMenu(), GUITriggeredRerouter::getPopUpMenu(), GUITrafficLightLogicWrapper::getPopUpMenu(), GUIPolygon2D::getPopUpMenu(), GUIPointOfInterest::getPopUpMenu(), GUINet::getPopUpMenu(), GUILaneWrapper::getPopUpMenu(), GUILaneSpeedTrigger::getPopUpMenu(), getPopUpMenu(), GUIEmitter::getPopUpMenu(), GUIEdge::getPopUpMenu(), GUIDetectorWrapper::getPopUpMenu(), and GUIBusStop::getPopUpMenu().

00132                                                                {
00133     new FXMenuCommand(ret, "Copy cursor position to clipboard", 0, ret, MID_COPY_CURSOR_POSITION);
00134     if (addSeparator) {
00135         new FXMenuSeparator(ret);
00136     }
00137 }

void GUIGlObject::buildSelectionPopupEntry ( GUIGLObjectPopupMenu ret,
bool  addSeparator = true 
) throw () [protected, inherited]

Builds an entry which allows to (de)select the object.

Parameters:
in,filled] ret The popup menu to add the entry to
[in] app The application, needed for callbacks
[in] addSeparator Whether a separator shall be added, too

Definition at line 107 of file GUIGlObject.cpp.

References GUIGlObject::getGlID(), GUIIconSubSys::getIcon(), GUIGlObject::getType(), gSelected, ICON_FLAG_MINUS, ICON_FLAG_PLUS, GUISelectedStorage::isSelected(), MID_ADDSELECT, and MID_REMOVESELECT.

Referenced by GUIVehicle::getPopUpMenu(), GUITriggeredRerouter::getPopUpMenu(), GUITrafficLightLogicWrapper::getPopUpMenu(), GUIPolygon2D::getPopUpMenu(), GUIPointOfInterest::getPopUpMenu(), GUILaneWrapper::getPopUpMenu(), GUILaneSpeedTrigger::getPopUpMenu(), getPopUpMenu(), GUIEmitter::getPopUpMenu(), GUIEdge::getPopUpMenu(), GUIDetectorWrapper::getPopUpMenu(), and GUIBusStop::getPopUpMenu().

00108                                                                  {
00109     if (gSelected.isSelected(getType(), getGlID())) {
00110         new FXMenuCommand(ret, "Remove From Selected", GUIIconSubSys::getIcon(ICON_FLAG_MINUS), ret, MID_REMOVESELECT);
00111     } else {
00112         new FXMenuCommand(ret, "Add To Selected", GUIIconSubSys::getIcon(ICON_FLAG_PLUS), ret, MID_ADDSELECT);
00113     }
00114     if (addSeparator) {
00115         new FXMenuSeparator(ret);
00116     }
00117 }

void GUIGlObject::buildShowManipulatorPopupEntry ( GUIGLObjectPopupMenu ret,
bool  addSeparator = true 
) throw () [protected, inherited]

Builds an entry which allows to open the manipulator window.

Parameters:
in,filled] ret The popup menu to add the entry to
[in] app The application, needed for callbacks
[in] addSeparator Whether a separator shall be added, too

Definition at line 141 of file GUIGlObject.cpp.

References GUIIconSubSys::getIcon(), ICON_MANIP, and MID_MANIP.

Referenced by GUITriggeredRerouter::getPopUpMenu(), GUILaneSpeedTrigger::getPopUpMenu(), and GUIEmitter::getPopUpMenu().

00142                                    {
00143     new FXMenuCommand(ret, "Open Manipulator...",
00144                       GUIIconSubSys::getIcon(ICON_MANIP), ret, MID_MANIP);
00145     if (addSeparator) {
00146         new FXMenuSeparator(ret);
00147     }
00148 }

void GUIGlObject::buildShowParamsPopupEntry ( GUIGLObjectPopupMenu ret,
bool  addSeparator = true 
) throw () [protected, inherited]

Builds an entry which allows to open the parameter window.

Parameters:
in,filled] ret The popup menu to add the entry to
[in] app The application, needed for callbacks
[in] addSeparator Whether a separator shall be added, too

Definition at line 121 of file GUIGlObject.cpp.

References GUIIconSubSys::getIcon(), ICON_APP_TABLE, and MID_SHOWPARS.

Referenced by GUIVehicle::getPopUpMenu(), GUINet::getPopUpMenu(), GUILaneWrapper::getPopUpMenu(), GUILaneSpeedTrigger::getPopUpMenu(), GUIEdge::getPopUpMenu(), and GUIDetectorWrapper::getPopUpMenu().

00122                                                                   {
00123     new FXMenuCommand(ret, "Show Parameter", GUIIconSubSys::getIcon(ICON_APP_TABLE), ret, MID_SHOWPARS);
00124     if (addSeparator) {
00125         new FXMenuSeparator(ret);
00126     }
00127 }

void GUIJunctionWrapper::drawGL ( const GUIVisualizationSettings s  )  const throw () [virtual]

Draws the object.

Parameters:
[in] s The settings for the current view (may influence drawing)
See also:
GUIGlObject::drawGL

Implements GUIGlObject.

Definition at line 106 of file GUIJunctionWrapper.cpp.

References GLHelper::drawFilledPoly(), GUIGlObject::getGlID(), getMicrosimID(), MSJunction::getPosition(), MSJunction::getShape(), myJunction, myMaxSize, pfdkGetStringWidth(), pfDrawString(), pfSetPosition(), pfSetScale(), SUMOReal, Position2D::x(), and Position2D::y().

00106                                                                           {
00107     // check whether it is not too small
00108     if (s.scale*myMaxSize<1.) {
00109         return;
00110     }
00111     // (optional) set id
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     // (optional) draw name
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     // (optional) clear id
00136     if (s.needsGlID) {
00137         glPopName();
00138     }
00139 }

Boundary GUIJunctionWrapper::getBoundary (  )  const throw () [inline]

Returns the boundary of the junction.

Returns:
This junction's boundary

Definition at line 140 of file GUIJunctionWrapper.h.

References myBoundary.

Referenced by GUINet::initGUIStructures().

00140                                          {
00141         return myBoundary;
00142     }

Boundary GUIJunctionWrapper::getCenteringBoundary (  )  const throw () [virtual]

Returns the boundary to which the view shall be centered in order to show the object.

Returns:
The boundary the object is within
See also:
GUIGlObject::getCenteringBoundary

Implements GUIGlObject.

Definition at line 98 of file GUIJunctionWrapper.cpp.

References Boundary::grow(), and myBoundary.

00098                                                        {
00099     Boundary b = myBoundary;
00100     b.grow(20);
00101     return b;
00102 }

const std::string& GUIGlObject::getFullName (  )  const throw () [inline, inherited]

GLuint GUIGlObject::getGlID (  )  const throw () [inline, inherited]

const std::string & GUIJunctionWrapper::getMicrosimID (  )  const throw () [virtual]

Returns the id of the object as known to microsim.

Returns:
The id of the junction
See also:
GUIGlObject::getMicrosimID

Implements GUIGlObject.

Definition at line 92 of file GUIJunctionWrapper.cpp.

References MSJunction::getID(), and myJunction.

Referenced by drawGL().

00092                                                 {
00093     return myJunction.getID();
00094 }

GUIParameterTableWindow * GUIJunctionWrapper::getParameterWindow ( GUIMainWindow app,
GUISUMOAbstractView parent 
) throw () [virtual]

Returns an own parameter window.

Parameters:
[in] app The application needed to build the parameter window
[in] parent The parent window needed to build the parameter window
Returns:
The built parameter window
See also:
GUIGlObject::getParameterWindow

Implements GUIGlObject.

Definition at line 85 of file GUIJunctionWrapper.cpp.

00086                                                                       {
00087     return 0;
00088 }

GUIGLObjectPopupMenu * GUIJunctionWrapper::getPopUpMenu ( GUIMainWindow app,
GUISUMOAbstractView parent 
) throw () [virtual]

Returns an own popup-menu.

Parameters:
[in] app The application needed to build the popup-menu
[in] parent The parent window needed to build the popup-menu
Returns:
The built popup-menu
See also:
GUIGlObject::getPopUpMenu

Implements GUIGlObject.

Definition at line 72 of file GUIJunctionWrapper.cpp.

References GUIGlObject::buildCenterPopupEntry(), GUIGlObject::buildNameCopyPopupEntry(), GUIGlObject::buildPopupHeader(), GUIGlObject::buildPositionCopyEntry(), and GUIGlObject::buildSelectionPopupEntry().

00073                                                                       {
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 }

GUIGlObjectType GUIJunctionWrapper::getType (  )  const throw () [inline, virtual]

Returns the type of the object as coded in GUIGlObjectType.

Returns:
GLO_JUNCTION (is a junction)
See also:
GUIGlObject::getType

GUIGlObjectType

Implements GUIGlObject.

Definition at line 115 of file GUIJunctionWrapper.h.

References GLO_JUNCTION.

00115                                             {
00116         return GLO_JUNCTION;
00117     }

GUIJunctionWrapper& GUIJunctionWrapper::operator= ( const GUIJunctionWrapper  )  [private]

Invalidated assignment operator.


Friends And Related Function Documentation

friend class GUIGlObjectStorage [friend, inherited]

Needed to set the id.

Reimplemented in GUI_E2_ZS_CollectorOverLanes::MyWrapper.

Definition at line 111 of file GUIGlObject.h.


Field Documentation

The represented junction's boundary.

Definition at line 153 of file GUIJunctionWrapper.h.

Referenced by getBoundary(), and getCenteringBoundary().

A reference to the represented junction.

Definition at line 147 of file GUIJunctionWrapper.h.

Referenced by drawGL(), and getMicrosimID().

SUMOReal GUIJunctionWrapper::myMaxSize [protected]

The maximum size (in either x-, or y-dimension) for determining whether to draw or not.

Definition at line 150 of file GUIJunctionWrapper.h.

Referenced by drawGL().


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:44 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6