LCOV - code coverage report
Current view: top level - src/guisim - GUIInstantInductLoop.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 62 74 83.8 %
Date: 2024-04-27 15:34:54 Functions: 10 12 83.3 %

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2003-2024 German Aerospace Center (DLR) and others.
       4             : // This program and the accompanying materials are made available under the
       5             : // terms of the Eclipse Public License 2.0 which is available at
       6             : // https://www.eclipse.org/legal/epl-2.0/
       7             : // This Source Code may also be made available under the following Secondary
       8             : // Licenses when the conditions for such availability set forth in the Eclipse
       9             : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10             : // or later which is available at
      11             : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12             : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13             : /****************************************************************************/
      14             : /// @file    GUIInstantInductLoop.cpp
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Jakob Erdmann
      17             : /// @author  Michael Behrisch
      18             : /// @date    Aug 2003
      19             : ///
      20             : // The gui-version of the MSInstantInductLoop
      21             : /****************************************************************************/
      22             : #include <config.h>
      23             : 
      24             : #include <utils/common/MsgHandler.h>
      25             : #include <utils/gui/globjects/GUIGlObject.h>
      26             : #include <utils/geom/PositionVector.h>
      27             : #include "GUIInstantInductLoop.h"
      28             : #include <utils/gui/div/GLHelper.h>
      29             : #include <utils/gui/div/GUIParameterTableWindow.h>
      30             : #include <microsim/logging/FunctionBinding.h>
      31             : #include <microsim/output/MSInstantInductLoop.h>
      32             : #include <microsim/MSLane.h>
      33             : #include "GUIEdge.h"
      34             : #include <utils/gui/globjects/GLIncludes.h>
      35             : 
      36             : 
      37             : // ===========================================================================
      38             : // method definitions
      39             : // ===========================================================================
      40             : /* -------------------------------------------------------------------------
      41             :  * GUIInstantInductLoop-methods
      42             :  * ----------------------------------------------------------------------- */
      43         118 : GUIInstantInductLoop::GUIInstantInductLoop(const std::string& id, OutputDevice& od,
      44             :         MSLane* const lane, double positionInMeters,
      45             :         const std::string name, const std::string& vTypes,
      46         118 :         const std::string& nextEdges) :
      47         236 :     MSInstantInductLoop(id, od, lane, positionInMeters, name, vTypes, nextEdges) {}
      48             : 
      49             : 
      50         236 : GUIInstantInductLoop::~GUIInstantInductLoop() {}
      51             : 
      52             : 
      53             : GUIDetectorWrapper*
      54         106 : GUIInstantInductLoop::buildDetectorGUIRepresentation() {
      55         106 :     return new MyWrapper(*this, myPosition);
      56             : }
      57             : 
      58             : // -------------------------------------------------------------------------
      59             : // GUIInstantInductLoop::MyWrapper-methods
      60             : // -------------------------------------------------------------------------
      61             : 
      62         106 : GUIInstantInductLoop::MyWrapper::MyWrapper(GUIInstantInductLoop& detector, double pos) :
      63             :     GUIDetectorWrapper(GLO_E1DETECTOR_INSTANT, detector.getID(), GUIIconSubSys::getIcon(GUIIcon::E1INSTANT)),
      64         106 :     myDetector(detector), myPosition(pos) {
      65         106 :     myFGPosition = detector.getLane()->geometryPositionAtOffset(pos);
      66         106 :     myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
      67         106 :     myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
      68         106 :     myFGRotation = -detector.getLane()->getShape().rotationDegreeAtOffset(pos);
      69         106 : }
      70             : 
      71             : 
      72         212 : GUIInstantInductLoop::MyWrapper::~MyWrapper() {}
      73             : 
      74             : 
      75             : double
      76         997 : GUIInstantInductLoop::MyWrapper::getExaggeration(const GUIVisualizationSettings& s) const {
      77         997 :     return s.addSize.getExaggeration(s, this);
      78             : }
      79             : 
      80             : 
      81             : Boundary
      82        1103 : GUIInstantInductLoop::MyWrapper::getCenteringBoundary() const {
      83             :     Boundary b(myBoundary);
      84        1103 :     b.grow(20);
      85        1103 :     return b;
      86           0 : }
      87             : 
      88             : 
      89             : 
      90             : GUIParameterTableWindow*
      91           0 : GUIInstantInductLoop::MyWrapper::getParameterWindow(GUIMainWindow& app,
      92             :         GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
      93           0 :     GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
      94             :     // add items
      95             :     // parameter
      96           0 :     ret->mkItem(TL("name"), false, myDetector.myName);
      97           0 :     ret->mkItem(TL("position [m]"), false, myPosition);
      98           0 :     ret->mkItem(TL("lane"), false, myDetector.getLane()->getID());
      99           0 :     if (myDetector.isTyped()) {
     100           0 :         ret->mkItem(TL("vTypes"), false, toString(myDetector.getVehicleTypes()));
     101             :     }
     102             :     // values
     103             :     // close building
     104           0 :     ret->closeBuilding(&myDetector);
     105           0 :     return ret;
     106             : }
     107             : 
     108             : 
     109             : void
     110         997 : GUIInstantInductLoop::MyWrapper::drawGL(const GUIVisualizationSettings& s) const {
     111         997 :     GLHelper::pushName(getGlID());
     112         997 :     double width = (double) 2.0 * s.scale;
     113         997 :     glLineWidth(1.0);
     114         997 :     const double exaggeration = getExaggeration(s);
     115             :     // shape
     116         997 :     glColor3d(1, 0, 1);
     117         997 :     GLHelper::pushMatrix();
     118         997 :     glTranslated(0, 0, GLO_JUNCTION + 0.4); // do not draw on top of linkRules
     119         997 :     glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
     120         997 :     glRotated(myFGRotation, 0, 0, 1);
     121         997 :     glScaled(exaggeration, exaggeration, 1);
     122         997 :     glBegin(GL_QUADS);
     123         997 :     glVertex2d(0 - 1.0, 2);
     124         997 :     glVertex2d(-1.0, -2);
     125         997 :     glVertex2d(1.0, -2);
     126         997 :     glVertex2d(1.0, 2);
     127         997 :     glEnd();
     128         997 :     glTranslated(0, 0, .01);
     129         997 :     glBegin(GL_LINES);
     130         997 :     glVertex2d(0, 2 - .1);
     131         997 :     glVertex2d(0, -2 + .1);
     132         997 :     glEnd();
     133             : 
     134             :     // outline
     135         997 :     if (width * exaggeration > 1) {
     136         988 :         glColor3d(1, 1, 1);
     137         988 :         glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
     138         988 :         glBegin(GL_QUADS);
     139         988 :         glVertex2d(0 - 1.0, 2);
     140         988 :         glVertex2d(-1.0, -2);
     141         988 :         glVertex2d(1.0, -2);
     142         988 :         glVertex2d(1.0, 2);
     143         988 :         glEnd();
     144         988 :         glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
     145             :     }
     146             : 
     147             :     // position indicator
     148         997 :     if (width * exaggeration > 1) {
     149         988 :         glRotated(90, 0, 0, -1);
     150         988 :         glColor3d(1, 1, 1);
     151         988 :         glBegin(GL_LINES);
     152         988 :         glVertex2d(0, 1.7);
     153         988 :         glVertex2d(0, -1.7);
     154         988 :         glEnd();
     155             :     }
     156         997 :     GLHelper::popMatrix();
     157         997 :     drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
     158         997 :     GLHelper::popName();
     159         997 : }
     160             : 
     161             : 
     162             : GUIInstantInductLoop&
     163           0 : GUIInstantInductLoop::MyWrapper::getLoop() {
     164           0 :     return myDetector;
     165             : }
     166             : 
     167             : 
     168             : /****************************************************************************/

Generated by: LCOV version 1.14