SUMO - Simulation of Urban MObility
GNEDialogACChooser.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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // Class for the window that allows to choose a street, junction or vehicle
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 
23 #include <config.h>
24 
25 #include <string>
26 #include <vector>
27 #include <fxkeys.h>
37 #include <netedit/GNENet.h>
38 #include <netedit/GNEViewNet.h>
40 #include <netedit/GNEViewParent.h>
42 
43 #include "GNEDialogACChooser.h"
44 
45 
46 // ===========================================================================
47 // method definitions
48 // ===========================================================================
49 
50 GNEDialogACChooser::GNEDialogACChooser(GNEViewParent* viewParent, FXIcon* icon, const std::string& title, const std::vector<GNEAttributeCarrier*>& ACs):
51  GUIDialog_GLObjChooser(viewParent, icon, title.c_str(), std::vector<GUIGlID>(), GUIGlObjectStorage::gIDStorage),
52  myACs(ACs),
53  myViewParent(viewParent),
54  myLocateTLS(title.find("TLS") != std::string::npos)
55 {
56  // @note refresh must be called here because the base class constructor cannot
57  // call the virtual function getObjectName
58  std::vector<GUIGlID> ids;
59  for (auto ac : ACs) {
60  ids.push_back(dynamic_cast<GUIGlObject*>(ac)->getGlID());
61  }
62  refreshList(ids);
63 }
64 
65 
68 }
69 
70 
71 void
73  GNEAttributeCarrier* ac = myACs[listIndex];
74  if (ac->isAttributeCarrierSelected()) {
76  } else {
78  }
79 }
80 
81 
82 std::string
84  if (myLocateTLS) {
85  GNEJunction* junction = dynamic_cast<GNEJunction*>(o);
86  assert(junction != nullptr);
87  const std::set<NBTrafficLightDefinition*>& defs = junction->getNBNode()->getControllingTLS();
88  assert(defs.size() > 0);
89  NBTrafficLightDefinition* tlDef = *defs.begin();
90  if (tlDef->getID() == o->getMicrosimID()) {
91  return o->getMicrosimID();
92  } else {
93  return tlDef->getID() + " (" + o->getMicrosimID() + ")";
94  }
95  } else {
96  return o->getMicrosimID();
97  }
98 }
99 
100 /****************************************************************************/
101 
The base class for traffic light logic definitions.
bool myLocateTLS
whether the current locator is for TLS
virtual void selectAttributeCarrier(bool changeFlag=true)=0
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:63
~GNEDialogACChooser()
Destructor.
virtual bool isAttributeCarrierSelected() const =0
check if attribute carrier is selected
virtual 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 refreshList(const std::vector< GUIGlID > &ids)
update the list with the given ids
GNEDialogACChooser()
FOX needs this.
unsigned int GUIGlID
Definition: GUIGlObject.h:43
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:308
virtual void unselectAttributeCarrier(bool changeFlag=true)=0
unselect attribute carrier using GUIGlobalSelection
void eraseACChooserDialog(GNEDialogACChooser *chooserDialog)
remove created chooser dialog
std::vector< GNEAttributeCarrier * > myACs
list of displayed ACs
NBNode * getNBNode() const
Return net build node.
void toggleSelection(int listIndex) override
toggle selection (handled differently in NETEDIT)
std::string getObjectName(GUIGlObject *o) const override
retrieve name for the given object (special case for TLS)
GNEViewParent * myViewParent