Eclipse 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-2019 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 
26 #include <netedit/GNENet.h>
27 #include <netedit/GNEViewParent.h>
29 
30 #include "GNEDialogACChooser.h"
31 
32 
33 // ===========================================================================
34 // method definitions
35 // ===========================================================================
36 
37 GNEDialogACChooser::GNEDialogACChooser(GNEViewParent* viewParent, FXIcon* icon, const std::string& title, const std::vector<GNEAttributeCarrier*>& ACs):
38  GUIDialog_GLObjChooser(viewParent, icon, title.c_str(), std::vector<GUIGlID>(), GUIGlObjectStorage::gIDStorage),
39  myACs(ACs),
40  myViewParent(viewParent),
41  myLocateTLS(title.find("TLS") != std::string::npos) {
42  // @note refresh must be called here because the base class constructor cannot
43  // call the virtual function getObjectName
44  std::vector<GUIGlID> ids;
45  for (auto ac : ACs) {
46  ids.push_back(dynamic_cast<GUIGlObject*>(ac)->getGlID());
47  }
48  refreshList(ids);
49 }
50 
51 
54 }
55 
56 
57 void
59  GNEAttributeCarrier* ac = myACs[listIndex];
60  if (ac->isAttributeCarrierSelected()) {
62  } else {
64  }
65 }
66 
67 
68 std::string
70  if (myLocateTLS) {
71  GNEJunction* junction = dynamic_cast<GNEJunction*>(o);
72  assert(junction != nullptr);
73  const std::set<NBTrafficLightDefinition*>& defs = junction->getNBNode()->getControllingTLS();
74  assert(defs.size() > 0);
75  NBTrafficLightDefinition* tlDef = *defs.begin();
76  if (tlDef->getID() == o->getMicrosimID()) {
77  return o->getMicrosimID();
78  } else {
79  return tlDef->getID() + " (" + o->getMicrosimID() + ")";
80  }
81  } else {
83  }
84 }
85 
86 /****************************************************************************/
87 
GNEViewParent::eraseACChooserDialog
void eraseACChooserDialog(GNEDialogACChooser *chooserDialog)
remove created chooser dialog
Definition: GNEViewParent.cpp:319
GUIGlObjectStorage
A storage for of displayed objects via their numerical id.
Definition: GUIGlObjectStorage.h:52
GNEDialogACChooser::myLocateTLS
bool myLocateTLS
whether the current locator is for TLS
Definition: GNEDialogACChooser.h:80
GNEAttributeCarrier::selectAttributeCarrier
virtual void selectAttributeCarrier(bool changeFlag=true)=0
GNEDialogACChooser::getObjectName
std::string getObjectName(GUIGlObject *o) const override
@bbrief retrieve name for the given object (special case for TLS)
Definition: GNEDialogACChooser.cpp:69
GNEViewParent
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:72
GUIGlObjectStorage.h
GUIDialog_GLObjChooser::getObjectName
virtual std::string getObjectName(GUIGlObject *o) const
@bbrief retrieve name for the given object
Definition: GUIDialog_GLObjChooser.cpp:217
GNEJunction.h
GNEJunction::getNBNode
NBNode * getNBNode() const
Return net build node.
Definition: GNEJunction.cpp:452
GUIGlObject
Definition: GUIGlObject.h:66
GNEDialogACChooser.h
GNEDialogACChooser::~GNEDialogACChooser
~GNEDialogACChooser()
Destructor.
Definition: GNEDialogACChooser.cpp:52
GNEAttributeCarrier::isAttributeCarrierSelected
virtual bool isAttributeCarrierSelected() const =0
check if attribute carrier is selected
GNEViewParent.h
GNEDialogACChooser::myViewParent
GNEViewParent * myViewParent
Definition: GNEDialogACChooser.h:76
GUIGlID
unsigned int GUIGlID
Definition: GUIGlObject.h:43
NBNode::getControllingTLS
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:322
GNEDialogACChooser::GNEDialogACChooser
GNEDialogACChooser()
FOX needs this.
Definition: GNEDialogACChooser.h:66
config.h
GNEDialogACChooser::toggleSelection
void toggleSelection(int listIndex) override
toggle selection (handled differently in NETEDIT)
Definition: GNEDialogACChooser.cpp:58
GUIDialog_GLObjChooser::refreshList
void refreshList(const std::vector< GUIGlID > &ids)
update the list with the given ids
Definition: GUIDialog_GLObjChooser.cpp:226
GNEJunction
Definition: GNEJunction.h:48
GUIGlObject::getMicrosimID
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.cpp:164
GNEAttributeCarrier
Definition: GNEAttributeCarrier.h:54
GNEDialogACChooser::myACs
std::vector< GNEAttributeCarrier * > myACs
list of displayed ACs
Definition: GNEDialogACChooser.h:75
GNENet.h
NBTrafficLightDefinition
The base class for traffic light logic definitions.
Definition: NBTrafficLightDefinition.h:68
GNEAttributeCarrier::unselectAttributeCarrier
virtual void unselectAttributeCarrier(bool changeFlag=true)=0
unselect attribute carrier using GUIGlobalSelection
GUIDialog_GLObjChooser
Definition: GUIDialog_GLObjChooser.h:52