LCOV - code coverage report
Current view: top level - src/utils/shapes - Shape.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 56.9 % 65 37
Test Date: 2025-12-06 15:35:27 Functions: 72.2 % 18 13

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2012-2025 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    Shape.cpp
      15              : /// @author  Jakob Erdmann
      16              : /// @author  Michael Behrisch
      17              : /// @date    Oct 2012
      18              : ///
      19              : // A 2D- or 3D-Shape
      20              : /****************************************************************************/
      21              : #include <config.h>
      22              : 
      23              : #include <utils/gui/globjects/GUIGlObjectTypes.h>
      24              : #include <utils/iodevices/OutputDevice.h>
      25              : 
      26              : #include "Shape.h"
      27              : 
      28              : // ===========================================================================
      29              : // static member definitions
      30              : // ===========================================================================
      31              : 
      32              : const std::string Shape::DEFAULT_TYPE = "";
      33              : const double Shape::DEFAULT_LAYER = 0;
      34              : const double Shape::DEFAULT_LINEWIDTH = 1;
      35              : const double Shape::DEFAULT_LAYER_POI = (double)GLO_POI;
      36              : const double Shape::DEFAULT_ANGLE = 0;
      37              : const std::string Shape::DEFAULT_IMG_FILE = "";
      38              : const double Shape::DEFAULT_IMG_WIDTH = 2.6;
      39              : const double Shape::DEFAULT_IMG_HEIGHT = 1;
      40              : const std::string Shape::DEFAULT_NAME = "";
      41              : const Parameterised::Map Shape::DEFAULT_PARAMETERS = Parameterised::Map();
      42              : 
      43              : // ===========================================================================
      44              : // member definitions
      45              : // ===========================================================================
      46              : 
      47            0 : Shape::Shape(const std::string& id) :
      48              :     Named(id),
      49            0 :     myType(DEFAULT_TYPE),
      50            0 :     myColor(RGBColor::BLACK),
      51            0 :     myLayer(DEFAULT_LAYER),
      52            0 :     myNaviDegreeAngle(DEFAULT_ANGLE),
      53            0 :     myImgFile(DEFAULT_IMG_FILE),
      54            0 :     myName(DEFAULT_NAME) {
      55            0 : }
      56              : 
      57              : 
      58       126684 : Shape::Shape(const std::string& id, const std::string& type, const RGBColor& color, double layer,
      59       253368 :              double angle, const std::string& imgFile, const std::string& name) :
      60              :     Named(id),
      61       126684 :     myType(type),
      62       126684 :     myColor(color),
      63       126684 :     myLayer(layer),
      64       126684 :     myNaviDegreeAngle(angle),
      65       126684 :     myImgFile(imgFile),
      66       253368 :     myName(name) {
      67       126684 : }
      68              : 
      69              : 
      70       125867 : Shape::~Shape() {}
      71              : 
      72              : 
      73              : void
      74            0 : Shape::writeShapeAttributes(OutputDevice& device, const RGBColor& defaultColor, const double defaultLayer) const {
      75              :     // name
      76            0 :     if (myName != DEFAULT_NAME) {
      77            0 :         device.writeAttr(SUMO_ATTR_NAME, myName);
      78              :     }
      79              :     // type
      80            0 :     if (myType != DEFAULT_TYPE) {
      81            0 :         device.writeAttr(SUMO_ATTR_TYPE, StringUtils::escapeXML(myType));
      82              :     }
      83              :     // color
      84            0 :     if (myColor != defaultColor) {
      85            0 :         device.writeAttr(SUMO_ATTR_COLOR, myColor);
      86              :     }
      87              :     // layer
      88            0 :     if (myLayer != defaultLayer) {
      89            0 :         device.writeAttr(SUMO_ATTR_LAYER, myLayer);
      90              :     }
      91              :     // angle
      92            0 :     if (myNaviDegreeAngle != Shape::DEFAULT_ANGLE) {
      93            0 :         device.writeAttr(SUMO_ATTR_ANGLE, myNaviDegreeAngle);
      94              :     }
      95              :     // img file
      96            0 :     if (myImgFile != Shape::DEFAULT_IMG_FILE) {
      97            0 :         device.writeAttr(SUMO_ATTR_IMGFILE, myImgFile);
      98              :     }
      99            0 : }
     100              : 
     101              : 
     102              : const std::string&
     103        13521 : Shape::getShapeType() const {
     104        13521 :     return myType;
     105              : }
     106              : 
     107              : 
     108              : const RGBColor&
     109        79973 : Shape::getShapeColor() const {
     110        79973 :     return myColor;
     111              : }
     112              : 
     113              : 
     114              : double
     115        80979 : Shape::getShapeLayer() const {
     116        80979 :     return myLayer;
     117              : }
     118              : 
     119              : 
     120              : double
     121        71599 : Shape::getShapeNaviDegree() const {
     122        71599 :     return myNaviDegreeAngle;
     123              : }
     124              : 
     125              : 
     126              : const std::string&
     127       120592 : Shape::getShapeImgFile() const {
     128       120592 :     return myImgFile;
     129              : }
     130              : 
     131              : 
     132              : const std::string&
     133         6553 : Shape::getShapeName() const {
     134         6553 :     return myName;
     135              : }
     136              : 
     137              : 
     138              : void
     139           12 : Shape::setShapeType(const std::string& type) {
     140           12 :     myType = type;
     141           12 : }
     142              : 
     143              : 
     144              : void
     145           17 : Shape::setShapeColor(const RGBColor& col) {
     146           17 :     myColor = col;
     147           17 : }
     148              : 
     149              : 
     150              : void
     151          801 : Shape::setShapeAlpha(unsigned char alpha) {
     152          801 :     myColor.setAlpha(alpha);
     153          801 : }
     154              : 
     155              : 
     156              : void
     157            0 : Shape::setShapeLayer(const double layer) {
     158            0 :     myLayer = layer;
     159            0 : }
     160              : 
     161              : 
     162              : void
     163            5 : Shape::setShapeNaviDegree(const double angle) {
     164            5 :     myNaviDegreeAngle = angle;
     165            5 : }
     166              : 
     167              : 
     168              : void
     169            5 : Shape::setShapeImgFile(const std::string& imgFile) {
     170            5 :     myImgFile = imgFile;
     171            5 : }
     172              : 
     173              : void
     174            0 : Shape::setShapeName(const std::string& name) {
     175            0 :     myName = name;
     176            0 : }
     177              : 
     178              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1