Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNETAZRelDataFrame.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-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/****************************************************************************/
18// The Widget for add TAZRelationData elements
19/****************************************************************************/
20
22#include <netedit/GNEViewNet.h>
29
30#include "GNETAZRelDataFrame.h"
31
32// ===========================================================================
33// FOX callback mapping
34// ===========================================================================
35
41
42// Object implementation
43FXIMPLEMENT(GNETAZRelDataFrame::ConfirmTAZRelation, MFXGroupBoxModule, ConfirmTAZRelationMap, ARRAYNUMBER(ConfirmTAZRelationMap))
44
45// ===========================================================================
46// method definitions
47// ===========================================================================
48
49// ---------------------------------------------------------------------------
50// GNETAZRelDataFrame::ConfirmTAZRelation - methods
51// ---------------------------------------------------------------------------
52
54 MFXGroupBoxModule(TAZRelDataFrame, TL("Confirm TAZRelation")),
55 myTAZRelDataFrame(TAZRelDataFrame) {
56 myConfirmTAZButton = GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Create TAZRelation"), "", TL("Click fromTaz and toTaz (confirm hotkey <ENTER>)"), GUIIconSubSys::getIcon(GUIIcon::TAZRELDATA), this, MID_GNE_CREATE, GUIDesignButton);
57 myConfirmTAZButton->disable();
59 myClearTAZButton->disable();
60}
61
62
64
65
66long
68 myTAZRelDataFrame->buildTAZRelationData();
69 return 1;
70}
71
72
73long
75 if (myTAZRelDataFrame->myFirstTAZ && myTAZRelDataFrame->mySecondTAZ) {
76 myConfirmTAZButton->enable();
77 } else {
78 myConfirmTAZButton->disable();
79 }
80 if (myTAZRelDataFrame->myFirstTAZ || myTAZRelDataFrame->mySecondTAZ) {
81 myClearTAZButton->enable();
82 } else {
83 myClearTAZButton->disable();
84 }
85 return 1;
86}
87
88
89long
91 myTAZRelDataFrame->clearTAZSelection();
92 myTAZRelDataFrame->getViewNet()->update();
93 return 1;
94}
95
96// ---------------------------------------------------------------------------
97// GNETAZRelDataFrame::TAZRelLegend - methods
98// ---------------------------------------------------------------------------
99
101 MFXGroupBoxModule(TAZRelDataFrame, TL("Information")),
102 myFromTAZLabel(nullptr),
103 myToTAZLabel(nullptr) {
104 // create from TAZ label
105 myFromTAZLabel = new FXLabel(getCollapsableFrame(), "From TAZ", 0, GUIDesignLabel(JUSTIFY_LEFT));
107 // create to TAZ Label
108 myToTAZLabel = new FXLabel(getCollapsableFrame(), "To TAZ", 0, GUIDesignLabel(JUSTIFY_LEFT));
110}
111
112
114
115
116void
118 // from TAZ
119 if (fromTAZ) {
120 myFromTAZLabel->setText(("From TAZ: " + fromTAZ->getID()).c_str());
121 } else {
122 myFromTAZLabel->setText(TL("From TAZ"));
123 }
124 // to TAZ
125 if (toTAZ) {
126 myToTAZLabel->setText(("To TAZ: " + toTAZ->getID()).c_str());
127 } else {
128 myToTAZLabel->setText(TL("To TAZ"));
129 }
130}
131
132// ---------------------------------------------------------------------------
133// GNETAZRelDataFrame - methods
134// ------------------------------------------------------------------------
135
137 GNEGenericDataFrame(viewParent, viewNet, SUMO_TAG_TAZREL, false) {
138 // create confirm TAZ Relation
140 // create legend
141 myLegend = new Legend(this);
142}
143
144
146
147
148bool
150 // check if myFirstTAZElement is empty
151 if (myFirstTAZ) {
152 if (mySecondTAZ) {
153 // both already defined
154 return false;
155 } else if (viewObjects.getTAZFront()) {
156 mySecondTAZ = viewObjects.getTAZFront();
157 myLegend->setLabels(myFirstTAZ, mySecondTAZ);
158 return true;
159 } else {
160 return false;
161 }
162 } else if (viewObjects.getTAZFront()) {
163 myFirstTAZ = viewObjects.getTAZFront();
164 myLegend->setLabels(myFirstTAZ, mySecondTAZ);
165 return true;
166 } else {
167 return false;
168 }
169}
170
171
172void
174 // check conditions
175 if (myFirstTAZ && mySecondTAZ) {
176 if (!myIntervalSelector->getDataInterval()) {
177 WRITE_WARNINGF(TL("A % must be defined within an interval."), toString(SUMO_TAG_TAZREL));
178 } else if ((myFirstTAZ == mySecondTAZ) && myIntervalSelector->getDataInterval()->TAZRelExists(myFirstTAZ)) {
179 WRITE_WARNINGF(TL("There is already a % defined in TAZ'%'."), toString(SUMO_TAG_TAZREL), myFirstTAZ->getID());
180 } else if ((myFirstTAZ != mySecondTAZ) && myIntervalSelector->getDataInterval()->TAZRelExists(myFirstTAZ, mySecondTAZ)) {
181 WRITE_WARNINGF(TL("There is already a % defined between TAZ'%' and '%'."), toString(SUMO_TAG_TAZREL), myFirstTAZ->getID(), mySecondTAZ->getID());
182 } else if (myGenericDataAttributesEditor->checkAttributes(true)) {
183 // declare data handler
184 GNEDataHandler dataHandler(myViewNet->getNet(), "", myViewNet->getViewParent()->getGNEAppWindows()->isUndoRedoAllowed());
185 // build data interval object and fill it
187 dataIntervalObject->addStringAttribute(SUMO_ATTR_ID, myIntervalSelector->getDataInterval()->getID());
188 dataIntervalObject->addDoubleAttribute(SUMO_ATTR_BEGIN, myIntervalSelector->getDataInterval()->getAttributeDouble(SUMO_ATTR_BEGIN));
189 dataIntervalObject->addDoubleAttribute(SUMO_ATTR_END, myIntervalSelector->getDataInterval()->getAttributeDouble(SUMO_ATTR_END));
190 // create TAZRelData
192 // obtain parameters
193 myGenericDataAttributesEditor->fillSumoBaseObject(TAZRelData);
194 // create TAZRelationData
195 dataHandler.buildTAZRelationData(TAZRelData, myFirstTAZ->getID(), mySecondTAZ->getID(), TAZRelData->getParameters());
196 // delete data interval object (and child)
197 delete dataIntervalObject;
198 // reset both TAZs
199 myFirstTAZ = nullptr;
200 mySecondTAZ = nullptr;
201 myLegend->setLabels(myFirstTAZ, mySecondTAZ);
202 }
203 }
204}
205
206
211
212
217
218
219void
221 myFirstTAZ = nullptr;
222 mySecondTAZ = nullptr;
223 myLegend->setLabels(myFirstTAZ, mySecondTAZ);
224}
225
226/****************************************************************************/
FXDEFMAP(GNETAZRelDataFrame::ConfirmTAZRelation) ConfirmTAZRelationMap[]
@ MID_GNE_CREATE
create element
Definition GUIAppEnum.h:995
@ MID_GNE_ABORT
abort lane path creation
#define GUIDesignButton
Definition GUIDesigns.h:100
#define GUIDesignLabel(justify)
Definition GUIDesigns.h:245
@ CLEARMESSAGEWINDOW
Definition GUIIcons.h:65
@ TAZRELDATA
Definition GUIIcons.h:569
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define TL(string)
Definition MsgHandler.h:304
@ 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
const std::map< std::string, std::string > & getParameters() const
get parameters
void addDoubleAttribute(const SumoXMLAttr attr, const double value)
add double attribute into current SumoBaseObject node
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
add string attribute into current SumoBaseObject node
const std::string getID() const override
get ID (all Attribute Carriers have one)
bool buildTAZRelationData(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &fromTAZID, const std::string &toTAZID, const Parameterised::Map &parameters)
Builds TAZRelationData.
GNEViewNet * myViewNet
FOX need this.
Definition GNEFrame.h:122
IntervalSelector * myIntervalSelector
interval selector modul
GNEGenericDataFrame(GNEViewParent *viewParent, GNEViewNet *viewNet, SumoXMLTag tag, const bool pathCreator)
Constructor (protected due GNEGenericDataFrame is abtract).
GNEAttributesEditor * myGenericDataAttributesEditor
parameters editor creator
FXButton * myClearTAZButton
clear TAZ Button
long onCmdConfirmTAZRelation(FXObject *, FXSelector, void *)
called when user press confirm TAZ Relation button
GNETAZRelDataFrame * myTAZRelDataFrame
FOX needs this.
long onUpdConfirmTAZRelation(FXObject *, FXSelector, void *)
called when TAZ Relation button is updated
long onCmdClearSelection(FXObject *, FXSelector, void *)
called when user press clear TAZ Relation button
FXButton * myConfirmTAZButton
confirm TAZ Button
ConfirmTAZRelation(GNETAZRelDataFrame *TAZRelDataFrame)
FOX-declaration.
void setLabels(const GNETAZ *fromTAZ, const GNETAZ *toTAZ)
set labels
FXLabel * myToTAZLabel
to TAZ Label
FXLabel * myFromTAZLabel
from TAZ label
Legend(GNETAZRelDataFrame *TAZRelDataFrame)
constructor
GNETAZ * mySecondTAZ
first selected TAZ Element
bool setTAZ(const GNEViewNetHelper::ViewObjectsSelector &viewObjects)
set clicked TAZ
void buildTAZRelationData()
build TAZRelation data
GNETAZRelDataFrame::Legend * myLegend
TAZRel legend.
GNEAdditional * getSecondTAZ() const
get first selected TAZ Element
GNETAZRelDataFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
void clearTAZSelection()
clear TAZ selection
GNETAZRelDataFrame::ConfirmTAZRelation * myConfirmTAZRelation
confirm TAZ Relation
GNETAZ * myFirstTAZ
first selected TAZ Element
GNEAdditional * getFirstTAZ() const
get first selected TAZ Element
class used to group all variables related with objects under cursor after a click over view
GNETAZ * getTAZFront() const
get front TAZ or a pointer to nullptr
A single child window which contains a view of the simulation area.
static FXButton * buildFXButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXIcon *ic, FXObject *tgt, FXSelector sel, FXuint opts=BUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build button
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
MFXGroupBoxModule (based on FXGroupBox).
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toggled)
MFXGroupBoxModule(GNEFrame *frame, const std::string &text, const int options=Options::COLLAPSIBLE)
constructor for frames
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition MFXUtils.cpp:145
static const RGBColor GREEN
Definition RGBColor.h:189
static const RGBColor MAGENTA
Definition RGBColor.h:193