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