Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEACChooserDialog.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 "GNEACChooserDialog.h"
26
27// ===========================================================================
28// method definitions
29// ===========================================================================
30
32 FXIcon* icon, const std::string& title,
33 const std::map<std::string, GNEAttributeCarrier*>& ACs):
34 GUIDialog_ChooserAbstract(viewParent, messageId, icon, title.c_str(),
35 std::vector<GUIGlID>(), GUIGlObjectStorage::gIDStorage),
36 myViewParent(viewParent),
37 myLocateTLS(title.find("TLS") != std::string::npos) {
38 // fill ACs
39 myACs.reserve(ACs.size());
40 myFilteredACs.reserve(ACs.size());
41 for (const auto& AC : ACs) {
42 myACs.push_back(AC.second);
43 myFilteredACs.push_back(AC.second);
44 }
45 // @note refresh must be called here because the base class constructor cannot
46 // call the virtual function getObjectName
47 std::vector<GUIGlID> ids;
48 for (const auto& AC : ACs) {
49 ids.push_back(AC.second->getGUIGlObject()->getGlID());
50 }
51 refreshList(ids);
52}
53
54
58
59
60void
62 // always filtered ACs
63 GNEAttributeCarrier* ac = myFilteredACs[listIndex];
66 } else {
68 }
69}
70
71
72void
74 // always filtered ACs
75 GNEAttributeCarrier* ac = myFilteredACs[listIndex];
76 if (!ac->isAttributeCarrierSelected()) {
78 }
79}
80
81
82void
84 // always filtered ACs
85 GNEAttributeCarrier* ac = myFilteredACs[listIndex];
88 }
89}
90
91
92void
93GNEACChooserDialog::filterACs(const std::vector<GUIGlID>& GLIDs) {
94 if (GLIDs.empty()) {
96 } else {
97 // clear myFilteredACs
98 myFilteredACs.clear();
99 // iterate over myACs
100 for (const auto& AC : myACs) {
101 // search in GLIDs
102 if (std::find(GLIDs.begin(), GLIDs.end(), AC->getGUIGlObject()->getGlID()) != GLIDs.end()) {
103 myFilteredACs.push_back(AC);
104 }
105 }
106 }
107}
108
109
110std::string
112 // check if we're locating a TLS
113 if (myLocateTLS) {
114 // obtain junction
115 GNEJunction* junction = dynamic_cast<GNEJunction*>(o);
116 // check that junction exist
117 if (junction == nullptr) {
118 throw ProcessError(TL("Invalid Junction"));
119 }
120 // get definitions
121 const std::set<NBTrafficLightDefinition*>& defs = junction->getNBNode()->getControllingTLS();
122 // check that traffic light exists
123 if (defs.empty()) {
124 throw ProcessError(TL("Invalid number of TLSs"));
125 }
126 // get TLDefinition
127 const std::string& tlDefID = (*defs.begin())->getID();
128 if (tlDefID == o->getMicrosimID()) {
129 return o->getMicrosimID();
130 } else {
131 return tlDefID + " (" + o->getMicrosimID() + ")";
132 }
133 } else {
135 }
136}
137
138
139/****************************************************************************/
unsigned int GUIGlID
Definition GUIGlObject.h:44
#define TL(string)
Definition MsgHandler.h:305
void deselect(int listIndex) override
unset selection (handled differently in netedit)
GNEACChooserDialog(GNEViewParent *viewParent, int messageId, FXIcon *icon, const std::string &title, const std::map< std::string, GNEAttributeCarrier * > &ACs)
Constructor.
std::vector< GNEAttributeCarrier * > myACs
list of displayed ACs
~GNEACChooserDialog()
Destructor.
GNEViewParent * myViewParent
pointer to view parent
void select(int listIndex) override
set selection (handled differently in netedit)
std::vector< GNEAttributeCarrier * > myFilteredACs
list of filtered ACs
std::string getObjectName(GUIGlObject *o) const override
retrieve name for the given object (special case for TLS)
bool myLocateTLS
whether the current locator is for TLS
void toggleSelection(int listIndex) override
toggle selection
void filterACs(const std::vector< GUIGlID > &GLIDs) override
filter ACs
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void selectAttributeCarrier()
select attribute carrier using GUIGlobalSelection
void unselectAttributeCarrier()
unselect attribute carrier using GUIGlobalSelection
NBNode * getNBNode() const
Return net build node.
A single child window which contains a view of the simulation area.
void eraseACChooserDialog(GNEACChooserDialog *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