53 #ifdef CHECK_MEMORY_LEAKS 55 #endif // CHECK_MEMORY_LEAKS 73 FXIMPLEMENT(
GNEConnector, FXScrollWindow, GNEConnectorMap, ARRAYNUMBER(GNEConnectorMap))
89 FXScrollWindow(parent, LAYOUT_FILL_Y | LAYOUT_FIX_WIDTH, 0, 0, WIDTH, 0),
90 myHeaderFont(
new FXFont(getApp(), "Arial", 11, FXFont::Bold)),
93 myUpdateTarget(updateTarget) {
95 myContentFrame =
new FXVerticalFrame(
this, LAYOUT_FILL_Y | LAYOUT_FIX_WIDTH, 0, 0, WIDTH, 0);
96 FXLabel* heading =
new FXLabel(myContentFrame,
"Edit Connections", 0, JUSTIFY_LEFT);
97 heading->setFont(myHeaderFont);
98 myDescription =
new FXLabel(myContentFrame,
"", 0, JUSTIFY_LEFT);
99 new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
104 new FXButton(myContentFrame,
"Cancel\t\tDiscard connection modifications (Esc)", 0,
this,
MID_CANCEL,
105 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
106 0, 0, 0, 0, 4, 4, 3, 3);
108 new FXButton(myContentFrame,
"OK\t\tSave connection modifications (Enter)", 0,
this,
MID_OK,
109 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
110 0, 0, 0, 0, 4, 4, 3, 3);
111 new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
113 new FXButton(myContentFrame,
114 "Select Dead Ends\t\tSelects all lanes that have no outgoing connection (clears previous selection)",
116 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
117 0, 0, 0, 0, 4, 4, 3, 3);
119 new FXButton(myContentFrame,
120 "Select Dead Starts\t\tSelects all lanes that have no incoming connection (clears previous selection)",
122 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
123 0, 0, 0, 0, 4, 4, 3, 3);
125 new FXButton(myContentFrame,
126 "Select Conflicts\t\tSelects all lanes with more than one incoming connection from the same edge (clears previous selection)",
128 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
129 0, 0, 0, 0, 4, 4, 3, 3);
131 new FXButton(myContentFrame,
132 "Select Passing\t\tSelects all lanes with a connection that has has the 'pass' attribute set",
134 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
135 0, 0, 0, 0, 4, 4, 3, 3);
137 new FXButton(myContentFrame,
138 "Clear Selected\t\tClears all connections of all selected objects",
140 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
141 0, 0, 0, 0, 4, 4, 3, 3);
143 new FXButton(myContentFrame,
144 "Reset Selected\nJunctions\t\tRecomputes connections at all selected junctions",
146 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
147 0, 0, 0, 0, 4, 4, 3, 3);
149 new FXHorizontalSeparator(
this, SEPARATOR_GROOVE | LAYOUT_FILL_X);
151 new FXLabel(myContentFrame,
"Hold <SHIFT> while\nclicking to create\nunyielding conn's.\n", 0, JUSTIFY_LEFT);
152 new FXLabel(myContentFrame,
"Hold <CTRL> while\nclicking to create\nconflicting conn's.\n", 0, JUSTIFY_LEFT);
156 potentialTargetColor =
RGBColor(0, 64, 0, 255);
161 new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
163 new FXLabel(myContentFrame,
"Color Legend:", 0, JUSTIFY_LEFT);
164 l =
new FXLabel(myContentFrame,
"Source", 0, JUSTIFY_LEFT);
166 l =
new FXLabel(myContentFrame,
"Target", 0, JUSTIFY_LEFT);
168 l =
new FXLabel(myContentFrame,
"Possible Target", 0, JUSTIFY_LEFT);
170 l =
new FXLabel(myContentFrame,
"Target (pass)", 0, JUSTIFY_LEFT);
172 l =
new FXLabel(myContentFrame,
"Conflict", 0, JUSTIFY_LEFT);
197 bool changed =
false;
207 destEdgeID, lane->
getIndex(), mayDefinitelyPass,
true),
true);
270 std::vector<GUIGlID> selectIDs;
273 for (std::vector<GNEEdge*>::const_iterator edge_it = edges.begin(); edge_it != edges.end(); edge_it++) {
275 for (GNEEdge::LaneVector::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
276 if ((*edge_it)->getNBEdge()->getConnectionsFromLane((*it_lane)->getIndex()).size() == 0) {
277 selectIDs.push_back((*it_lane)->getGlID());
289 std::set<GUIGlID> selectIDs;
292 for (std::vector<GNEJunction*>::const_iterator junction_it = junctions.begin(); junction_it != junctions.end(); junction_it++) {
294 const EdgeVector& outgoing = (*junction_it)->getNBNode()->getOutgoingEdges();
295 for (EdgeVector::const_iterator it = outgoing.begin(); it != outgoing.end(); it++) {
298 for (std::set<GUIGlID>::const_iterator lid_it = laneIDs.begin(); lid_it != laneIDs.end(); lid_it++) {
299 selectIDs.insert(*lid_it);
303 const EdgeVector& incoming = (*junction_it)->getNBNode()->getIncomingEdges();
304 for (EdgeVector::const_iterator it = incoming.begin(); it != incoming.end(); it++) {
307 const std::vector<NBEdge::Connection>& connections = nbe->
getConnections();
308 for (std::vector<NBEdge::Connection>::const_iterator con_it = connections.begin(); con_it != connections.end(); con_it++) {
311 selectIDs.erase(approachedLane->
getGlID());
316 std::vector<GUIGlID>(selectIDs.begin(), selectIDs.end()),
324 std::vector<GUIGlID> selectIDs;
327 for (std::vector<GNEEdge*>::const_iterator edge_it = edges.begin(); edge_it != edges.end(); edge_it++) {
328 NBEdge* nbe = (*edge_it)->getNBEdge();
330 const std::vector<NBEdge::Connection>& connections = nbe->
getConnections();
331 for (EdgeVector::const_iterator dest_it = destinations.begin(); dest_it != destinations.end(); dest_it++) {
334 for (GNEEdge::LaneVector::const_iterator it_lane = destLanes.begin(); it_lane != destLanes.end(); it_lane++) {
335 const bool isConflicted = count_if(
336 connections.begin(), connections.end(),
339 selectIDs.push_back((*it_lane)->getGlID());
352 std::vector<GUIGlID> selectIDs;
354 for (std::vector<GNEEdge*>::const_iterator edge_it = edges.begin(); edge_it != edges.end(); edge_it++) {
357 const std::vector<NBEdge::Connection>& connections = nbe->
getConnections();
358 for (std::vector<NBEdge::Connection>::const_iterator it = connections.begin(); it != connections.end(); ++it) {
359 if (it->mayDefinitelyPass) {
361 selectIDs.push_back(lane->
getGlID());
373 myUndoList->
p_begin(
"clear connections from selected lanes, edges and junctions");
375 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
388 for (GNEEdge::LaneVector::const_iterator l_it = lanes.begin(); l_it != lanes.end(); ++l_it) {
421 for (std::set<GUIGlID>::const_iterator nid_it = nodeIDs.begin(); nid_it != nodeIDs.end(); nid_it++) {
428 throw ProcessError(
"Wrong object type returned from gIDStorage");
455 for (EdgeVector::const_iterator it = outgoing.begin(); it != outgoing.end(); it++) {
458 for (GNEEdge::LaneVector::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); it_lane++) {
489 (*it)->setSpecialColor(0);
505 const unsigned int toIndex = targetLane->
getIndex();
506 std::vector<NBEdge::Connection>::const_iterator con_it = find_if(
507 connections.begin(), connections.end(),
509 const bool isConnected = con_it != connections.end();
511 if (con_it->mayDefinitelyPass) {
528 const unsigned int toIndex = targetLane->
getIndex();
529 std::vector<NBEdge::Connection>::const_iterator it = find_if(
530 connections.begin(), connections.end(),
532 assert(it != connections.end());
547 const int NUM_POINTS = 5;
549 std::string innerID =
":" + node->
getID();
553 for (EdgeVector::const_iterator it_edg = incoming.begin(); it_edg != incoming.end(); it_edg++) {
554 const std::vector<NBEdge::Connection>& conns = (*it_edg)->getConnections();
555 for (std::vector<NBEdge::Connection>::const_iterator it_con = conns.begin(); it_con != conns.end(); ++it_con) {
557 LinkState state = node->
getLinkState(*it_edg, it_con->toEdge, it_con->fromLane, it_con->toLane, it_con->mayDefinitelyPass, it_con->tlID);
unsigned int getTLLLinkNumber(const std::vector< NBEdge::Connection > &connections, GNELane *targetLane)
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
bool hasConnectionTo(NBEdge *destEdge, unsigned int destLane, int fromLane=-1) const
Retrieves info about a connection to a certain lane of a certain edge.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges.
std::map< int, GNEInternalLane * > myInternalLanes
the internal lanes belonging the the current junction indexed by their tl-index
FXDEFMAP(GNEConnector) GNEConnectorMap[]
long onCmdSelectDeadEnds(FXObject *, FXSelector, void *)
Called when the user presses the Corresponding-button.
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
static RGBColor targetPassColor
color for the to-lane of a connection with pass attribute
LaneStatus getLaneStatus(const std::vector< NBEdge::Connection > &connections, GNELane *targetLane)
long onCmdSelectDeadStarts(FXObject *, FXSelector, void *)
FXLabel * myDescription
the label that shows the current editing state
GNELane * myCurrentLane
the lane of which connections are to be modified
void handleLaneClick(GNELane *lane, bool mayDefinitelyPass, bool allowConflict, bool toggle)
either sets the current lane or toggles the connection of the current lane to this lane (if they shar...
static const NBConnection InvalidConnection
std::set< GUIGlID > getLaneGlIDs()
void setLogicValid(bool valid, GNEUndoList *undoList=0, const std::string &status=GUESSED)
long onCmdOK(FXObject *, FXSelector, void *)
Called when the user presses the OK-Button saves any connection modifications.
The representation of a single edge during network building.
GNEEdge & getParentEdge()
Returns underlying parent edge.
std::vector< GNELane * > LaneVector
Definition of the lane's positions vector.
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
void removeAdditionalGLObject(GUIGlObject *o)
Removes an additional object (detector/shape/trigger) from being visualised.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
A NBNetBuilder extended by visualisation and editing capabilities.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
void p_begin(const std::string &description)
~GNEConnector()
Destructor.
unsigned int getIndex() const
std::vector< Connection > getConnectionsFromLane(unsigned int lane) const
Returns connections from a given lane.
A RT-tree for efficient storing of SUMO's GL-objects.
GUIGlID getGlID() const
Returns the numerical id of the object.
static RGBColor conflictColor
color for a to-lane that cannot be used because another connection conflicts
void removeConnections(GNELane *lane)
static RGBColor sourceColor
color for the from-lane of a connection
EdgeVector getConnectedEdges() const
Returns the list of outgoing edges unsorted.
long onCmdClearSelectedConnections(FXObject *, FXSelector, void *)
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges.
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button discards any connection modifications.
const std::string & getID() const
Returns the id.
static const std::string MODIFIED
feature has been manually modified (implies approval)
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GNESelector * getSelector()
static const RGBColor GREEN
LaneStatus
the status of a target lane
GNEViewNet * myUpdateTarget
const std::set< GUIGlID > & getSelected() const
Returns the list of ids of all selected objects.
long onCmdSelectPass(FXObject *, FXSelector, void *)
void setSpecialColor(const RGBColor *color)
GNEJunction * retrieveJunction(const std::string &id, bool failHard=true)
get junction by id
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
void updateDescription() const
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
static const RGBColor MAGENTA
NBNode * getNBNode()
returns the internal NBNode
LinkState getLinkState(const NBEdge *incoming, NBEdge *outgoing, int fromLane, int toLane, bool mayDefinitelyPass, const std::string &tlID) const
long onCmdResetSelectedConnections(FXObject *, FXSelector, void *)
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
void p_abort()
reverts and discards ALL active command groups
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection)
NBEdge * getNBEdge()
returns the internal NBEdge
A road/street connecting two junctions (netedit-version)
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
static const RGBColor YELLOW
NBNode * getToNode() const
Returns the destination node of the edge.
PositionVector computeInternalLaneShape(NBEdge *fromE, const NBEdge::Connection &con, int numPoints) const
Compute the shape for an internal lane.
static const RGBColor CYAN
std::set< GNELane * > myPotentialTargets
the set of lanes to which the current lane may be connected
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
std::vector< NBEdge * > EdgeVector
unsigned int myNumChanges
GNEJunction * getDest() const
returns the destination-junction
long onCmdSelectConflicts(FXObject *, FXSelector, void *)
FXFont * myHeaderFont
Font for the widget.
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Represents a single node (junction) during network building.
void setStatusBarText(const std::string &text)
void handleIDs(std::vector< GUIGlID > ids, bool selectEdges, SetOperation setop=SET_DEFAULT)
void buildIinternalLanes(NBNode *node)
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
static RGBColor targetColor
color for the to-lane of a connection
GUISelectedStorage gSelected
A global holder of selected objects.
const std::vector< Connection > & getConnections() const
Returns the connections.
static RGBColor potentialTargetColor
color for potential to-lane targets (currently unconnected)
const LaneVector & getLanes()