Eclipse SUMO - Simulation of Urban MObility
GNETAZRelDataFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 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 /****************************************************************************/
18 // The Widget for add TAZRelationData elements
19 /****************************************************************************/
20 #include <config.h>
21 
25 #include <netedit/GNEViewNet.h>
27 
28 #include "GNETAZRelDataFrame.h"
29 
30 
31 // ===========================================================================
32 // method definitions
33 // ===========================================================================
34 
35 
36 // ---------------------------------------------------------------------------
37 // GNETAZRelDataFrame::TAZRelLegend - methods
38 // ---------------------------------------------------------------------------
39 
41  FXGroupBoxModule(TAZRelDataFrame->myContentFrame, "Information"),
42  myFromTAZLabel(nullptr),
43  myToTAZLabel(nullptr) {
44  // create from TAZ label
45  myFromTAZLabel = new FXLabel(getCollapsableFrame(), "From TAZ", 0, GUIDesignLabelLeft);
47  // create to TAZ Label
48  myToTAZLabel = new FXLabel(getCollapsableFrame(), "To TAZ", 0, GUIDesignLabelLeft);
50 }
51 
52 
54 
55 
56 void
58  // from TAZ
59  if (fromTAZ) {
60  myFromTAZLabel->setText(("From TAZ: " + fromTAZ->getID()).c_str());
61  } else {
62  myFromTAZLabel->setText("From TAZ");
63  }
64  // to TAZ
65  if (toTAZ) {
66  myToTAZLabel->setText(("To TAZ: " + toTAZ->getID()).c_str());
67  } else {
68  myToTAZLabel->setText("To TAZ");
69  }
70 }
71 
72 // ---------------------------------------------------------------------------
73 // GNETAZRelDataFrame - methods
74 // ------------------------------------------------------------------------
75 
76 GNETAZRelDataFrame::GNETAZRelDataFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet) :
77  GNEGenericDataFrame(horizontalFrameParent, viewNet, SUMO_TAG_TAZREL, false),
78  myFirstTAZ(nullptr),
79  mySecondTAZ(nullptr),
80  myLegend(nullptr) {
81  // create legend
82  myLegend = new Legend(this);
83 }
84 
85 
87 
88 
89 bool
91  // check if myFirstTAZElement is empty
92  if (myFirstTAZ) {
93  if (mySecondTAZ) {
94  // both already defined
95  return false;
96  } else {
97  mySecondTAZ = objectsUnderCursor.getTAZElementFront();
99  return true;
100  }
101  } else if (objectsUnderCursor.getTAZElementFront()) {
102  myFirstTAZ = objectsUnderCursor.getTAZElementFront();
104  return true;
105  } else {
106  return false;
107  }
108 }
109 
110 
111 void
113  // check conditions
114  if (myFirstTAZ && mySecondTAZ) {
116  WRITE_WARNING("A " + toString(SUMO_TAG_TAZREL) + " must be defined within an interval.");
118  WRITE_WARNING("There is already a " + toString(SUMO_TAG_TAZREL) + " defined in TAZ'" + myFirstTAZ->getID() + "'.");
120  WRITE_WARNING("There is already a " + toString(SUMO_TAG_TAZREL) + " defined between TAZ'" + myFirstTAZ->getID() + "' and '" + mySecondTAZ->getID() + "'.");
121  } else {
122  // declare data handler
123  GNEDataHandler dataHandler(myViewNet->getNet(), "", true);
124  // build data interval object and fill it
129  // create TAZRelData
130  CommonXMLStructure::SumoBaseObject* TAZRelData = new CommonXMLStructure::SumoBaseObject(dataIntervalObject);
131  // finally create TAZRelationData
133  delete dataIntervalObject;
134  // reset both TAZs
135  myFirstTAZ = nullptr;
136  mySecondTAZ = nullptr;
138  }
139  }
140 }
141 
142 
145  return myFirstTAZ;
146 }
147 
148 
151  return mySecondTAZ;
152 }
153 
154 
155 void
157  myFirstTAZ = nullptr;
158  mySecondTAZ = nullptr;
160 }
161 
162 /****************************************************************************/
#define GUIDesignLabelLeft
Definition: GUIDesigns.h:193
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
@ SUMO_TAG_TAZREL
a relation between two TAZs
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
void addDoubleAttribute(const SumoXMLAttr attr, const double value)
add double attribute into current SumoBaseObject node
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
FXGroupBoxModule (based on FXGroupBox)
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toogled)
void buildTAZRelationData(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &fromTAZID, const std::string &toTAZID, const std::map< std::string, std::string > &parameters)
Builds TAZRelationData.
double getAttributeDouble(SumoXMLAttr key) const
const std::string & getID() const
get ID
bool TAZRelExists(const GNETAZElement *TAZ) const
check if there is already a TAZRel defined in one TAZ
const std::map< std::string, std::string > & getParametersMap() const
get parameters as map
GNEViewNet * myViewNet
View Net.
Definition: GNEFrame.h:114
GNEDataInterval * getDataInterval() const
get current select data set ID
GNEFrameAttributeModules::GenericDataAttributes * myGenericDataAttributes
parameters editor creator
IntervalSelector * myIntervalSelector
interval selector modul
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNETAZElement.h:45
const std::string & getID() const
get ID
FXLabel * myToTAZLabel
to TAZ Label
void setLabels(const GNETAZElement *fromTAZ, const GNETAZElement *toTAZ)
set labels
FXLabel * myFromTAZLabel
from TAZ label
Legend(GNETAZRelDataFrame *TAZRelDataFrame)
constructor
bool setTAZ(const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor)
set clicked TAZ
GNETAZElement * myFirstTAZ
first selected TAZ Element
GNETAZRelDataFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet)
Constructor.
void buildTAZRelationData()
build TAZRelation data
~GNETAZRelDataFrame()
Destructor.
GNETAZRelDataFrame::Legend * myLegend
TAZRel legend.
GNETAZElement * getSecondTAZ() const
get first selected TAZ Element
void clearTAZSelection()
clear TAZ selection
GNETAZElement * getFirstTAZ() const
get first selected TAZ Element
GNETAZElement * mySecondTAZ
first selected TAZ Element
class used to group all variables related with objects under cursor after a click over view
GNETAZElement * getTAZElementFront() const
get front TAZElement or a pointer to nullptr
GNENet * getNet() const
get the net object
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:112
static const RGBColor GREEN
Definition: RGBColor.h:186
static const RGBColor MAGENTA
Definition: RGBColor.h:190