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-2026 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 if (listIndex >= 0 && listIndex < (int)myFilteredACs.size()) {
63 GNEAttributeCarrier* ac = myFilteredACs[listIndex];
66 } else {
68 }
69 }
70}
71
72
73void
75 if (listIndex >= 0 && listIndex < (int)myFilteredACs.size()) {
76 GNEAttributeCarrier* ac = myFilteredACs[listIndex];
77 if (!ac->isAttributeCarrierSelected()) {
79 }
80 }
81}
82
83
84void
86 if (listIndex >= 0 && listIndex < (int)myFilteredACs.size()) {
87 GNEAttributeCarrier* ac = myFilteredACs[listIndex];
90 }
91 }
92}
93
94
95void
96GNEACChooserDialog::filterACs(const std::vector<GUIGlID>& GLIDs) {
97 myFilteredACs.clear();
98 for (const auto glID : GLIDs) {
100 GNEAttributeCarrier* ac = dynamic_cast<GNEAttributeCarrier*>(o);
101 if (ac) {
102 myFilteredACs.push_back(ac);
103 if (std::find(myACs.begin(), myACs.end(), ac) == myACs.end()) {
104 myACs.push_back(ac);
105 }
106 } else {
107 for (const auto& candidate : myACs) {
108 if (candidate->getGUIGlObject()->getGlID() == glID) {
109 myFilteredACs.push_back(candidate);
110 break;
111 }
112 }
113 }
115 }
116}
117
118
119std::string
121 // check if we're locating a TLS
122 if (myLocateTLS) {
123 // obtain junction
124 GNEJunction* junction = dynamic_cast<GNEJunction*>(o);
125 // check that junction exist
126 if (junction == nullptr) {
127 throw ProcessError(TL("Invalid Junction"));
128 }
129 // get definitions
130 const std::set<NBTrafficLightDefinition*>& defs = junction->getNBNode()->getControllingTLS();
131 // check that traffic light exists
132 if (defs.empty()) {
133 throw ProcessError(TL("Invalid number of TLSs"));
134 }
135 // get TLDefinition
136 const std::string& tlDefID = (*defs.begin())->getID();
137 if (tlDefID == o->getMicrosimID()) {
138 return o->getMicrosimID();
139 } else {
140 return tlDefID + " (" + o->getMicrosimID() + ")";
141 }
142 } else {
144 }
145}
146
147
148/****************************************************************************/
unsigned int GUIGlID
Definition GUIGlObject.h:44
#define TL(string)
Definition MsgHandler.h:304
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 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.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
GUIGlObject * getObjectBlocking(GUIGlID id) const
Returns the object from the container locking it.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
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:347
Definition json.hpp:5639