Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEDialogACChooser.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// Class for the window that allows to choose a street, junction or vehicle
19/****************************************************************************/
20
21#include <netedit/GNENet.h>
24
25#include "GNEDialogACChooser.h"
26
27// ===========================================================================
28// method definitions
29// ===========================================================================
30
31GNEDialogACChooser::GNEDialogACChooser(GNEViewParent* viewParent, int messageId, FXIcon* icon, const std::string& title, const std::vector<GNEAttributeCarrier*>& ACs):
32 GUIDialog_ChooserAbstract(viewParent, messageId, icon, title.c_str(), std::vector<GUIGlID>(), GUIGlObjectStorage::gIDStorage),
33 myViewParent(viewParent),
34 myACs(ACs),
35 myFilteredACs(ACs),
36 myLocateTLS(title.find("TLS") != std::string::npos) {
37 // @note refresh must be called here because the base class constructor cannot
38 // call the virtual function getObjectName
39 std::vector<GUIGlID> ids;
40 for (const auto& AC : ACs) {
41 ids.push_back(AC->getGUIGlObject()->getGlID());
42 }
43 refreshList(ids);
44}
45
46
50
51
52void
54 // always filtered ACs
55 GNEAttributeCarrier* ac = myFilteredACs[listIndex];
58 } else {
60 }
61}
62
63
64void
66 // always filtered ACs
67 GNEAttributeCarrier* ac = myFilteredACs[listIndex];
68 if (!ac->isAttributeCarrierSelected()) {
70 }
71}
72
73
74void
76 // always filtered ACs
77 GNEAttributeCarrier* ac = myFilteredACs[listIndex];
80 }
81}
82
83
84void
85GNEDialogACChooser::filterACs(const std::vector<GUIGlID>& GLIDs) {
86 if (GLIDs.empty()) {
88 } else {
89 // clear myFilteredACs
90 myFilteredACs.clear();
91 // iterate over myACs
92 for (const auto& AC : myACs) {
93 // search in GLIDs
94 if (std::find(GLIDs.begin(), GLIDs.end(), AC->getGUIGlObject()->getGlID()) != GLIDs.end()) {
95 myFilteredACs.push_back(AC);
96 }
97 }
98 }
99}
100
101
102std::string
104 // check if we're locating a TLS
105 if (myLocateTLS) {
106 // obtain junction
107 GNEJunction* junction = dynamic_cast<GNEJunction*>(o);
108 // check that junction exist
109 if (junction == nullptr) {
110 throw ProcessError(TL("Invalid Junction"));
111 }
112 // get definitions
113 const std::set<NBTrafficLightDefinition*>& defs = junction->getNBNode()->getControllingTLS();
114 // check that traffic light exists
115 if (defs.empty()) {
116 throw ProcessError(TL("Invalid number of TLSs"));
117 }
118 // get TLDefinition
119 const std::string& tlDefID = (*defs.begin())->getID();
120 if (tlDefID == o->getMicrosimID()) {
121 return o->getMicrosimID();
122 } else {
123 return tlDefID + " (" + o->getMicrosimID() + ")";
124 }
125 } else {
127 }
128}
129
130
131/****************************************************************************/
unsigned int GUIGlID
Definition GUIGlObject.h:44
#define TL(string)
Definition MsgHandler.h:305
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void selectAttributeCarrier()
select attribute carrier using GUIGlobalSelection
void unselectAttributeCarrier()
unselect attribute carrier using GUIGlobalSelection
GNEDialogACChooser(GNEViewParent *viewParent, int messageId, FXIcon *icon, const std::string &title, const std::vector< GNEAttributeCarrier * > &ACs)
Constructor.
std::vector< GNEAttributeCarrier * > myACs
list of displayed ACs
void select(int listIndex) override
set selection (handled differently in netedit)
bool myLocateTLS
whether the current locator is for TLS
~GNEDialogACChooser()
Destructor.
void filterACs(const std::vector< GUIGlID > &GLIDs) override
filter ACs
GNEViewParent * myViewParent
pointer to view parent
void toggleSelection(int listIndex) override
toggle selection
std::string getObjectName(GUIGlObject *o) const override
retrieve name for the given object (special case for TLS)
std::vector< GNEAttributeCarrier * > myFilteredACs
list of filtered ACs
void deselect(int listIndex) override
unset selection (handled differently in netedit)
NBNode * getNBNode() const
Return net build node.
A single child window which contains a view of the simulation area.
void eraseACChooserDialog(GNEDialogACChooser *chooserDialog)
remove created chooser dialog
void refreshList(const std::vector< GUIGlID > &ids)
update the list with the given ids
virtual std::string getObjectName(GUIGlObject *o) const
retrieve name for the given object
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
A storage for of displayed objects via their numerical id.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
Definition NBNode.h:340
Definition json.hpp:4471