 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
84 myCurrentLaneLabel->setText(
"No lane selected");
86 myCurrentLaneLabel->setText((std::string(
"Current Lane: ") + laneID).c_str());
96 myConnectorFrameParent(connectorFrameParent) {
99 myCancelButton =
new FXButton(
this,
"Cancel\t\tDiscard connection modifications (Esc)",
102 mySaveButton =
new FXButton(
this,
"OK\t\tSave connection modifications (Enter)",
115 if (myConnectorFrameParent->myCurrentEditedLane != 0) {
116 myConnectorFrameParent->getViewNet()->getUndoList()->p_abort();
117 if (myConnectorFrameParent->myNumChanges) {
118 myConnectorFrameParent->getViewNet()->setStatusBarText(
"Changes reverted");
120 myConnectorFrameParent->cleanup();
121 myConnectorFrameParent->getViewNet()->update();
129 if (myConnectorFrameParent->myCurrentEditedLane != 0) {
131 if (myProtectRoutesCheckBox->isEnabled() && (myProtectRoutesCheckBox->getCheck() == TRUE)) {
132 for (
const auto& i : myConnectorFrameParent->myCurrentEditedLane->getParentEdge()->getChildDemandElements()) {
133 if (!i->isDemandElementValid()) {
134 FXMessageBox::warning(getApp(), MBOX_OK,
135 "Error saving connection operations",
"%s",
136 (
"Connection edition cannot be saved because route '" + i->getID() +
"' is broken.").c_str());
142 myConnectorFrameParent->getViewNet()->getUndoList()->p_end();
143 if (myConnectorFrameParent->myNumChanges) {
144 myConnectorFrameParent->getViewNet()->setStatusBarText(
"Changes accepted");
146 myConnectorFrameParent->cleanup();
147 myConnectorFrameParent->getViewNet()->update();
158 myConnectorFrameParent(connectorFrameParent) {
161 mySelectDeadEndsButton =
new FXButton(
this,
"Select Dead Ends\t\tSelects all lanes that have no outgoing connection (clears previous selection)",
164 mySelectDeadStartsButton =
new FXButton(
this,
"Select Dead Starts\t\tSelects all lanes that have no incoming connection (clears previous selection)",
167 mySelectConflictsButton =
new FXButton(
this,
"Select Conflicts\t\tSelects all lanes with more than one incoming connection from the same edge (clears previous selection)",
170 mySelectPassingButton =
new FXButton(
this,
"Select Passing\t\tSelects all lanes with a connection that has has the 'pass' attribute set",
173 myClearSelectedButton =
new FXButton(
this,
"Clear Selected\t\tClears all connections of all selected objects",
176 myResetSelectedButton =
new FXButton(
this,
"Reset Selected\t\tRecomputes connections at all selected junctions",
187 std::vector<GNEAttributeCarrier*> deadEnds;
189 const std::vector<GNEEdge*> edges = myConnectorFrameParent->getViewNet()->getNet()->retrieveEdges();
190 for (
auto i : edges) {
191 for (
auto j : i->getLanes()) {
192 if (i->getNBEdge()->getConnectionsFromLane(j->getIndex()).size() == 0) {
193 deadEnds.push_back(j);
205 std::set<GNEAttributeCarrier*> deadStarts;
209 for (
auto i : junctions) {
211 for (
auto j : i->getNBNode()->getOutgoingEdges()) {
214 deadStarts.insert(k);
218 for (
auto j : i->getNBNode()->getIncomingEdges()) {
225 std::vector<GNEAttributeCarrier*> selectObjects(deadStarts.begin(), deadStarts.end());
233 std::vector<GNEAttributeCarrier*> conflicts;
235 const std::vector<GNEEdge*> edges = myConnectorFrameParent->getViewNet()->getNet()->retrieveEdges();
236 for (
auto i : edges) {
237 const EdgeVector destinations = i->getNBEdge()->getConnectedEdges();
238 for (
auto j : destinations) {
241 const bool isConflicted = count_if(i->getNBEdge()->getConnections().begin(), i->getNBEdge()->getConnections().end(),
244 conflicts.push_back(k);
257 std::vector<GNEAttributeCarrier*> pass;
258 const std::vector<GNEEdge*> edges = myConnectorFrameParent->getViewNet()->getNet()->retrieveEdges();
259 for (
auto i : edges) {
260 for (
auto j : i->getNBEdge()->getConnections()) {
261 if (j.mayDefinitelyPass) {
262 pass.push_back(i->getLanes()[j.fromLane]);
273 myConnectorFrameParent->myConnectionModifications->onCmdCancelModifications(0, 0, 0);
274 myConnectorFrameParent->getViewNet()->getUndoList()->p_begin(
"clear connections from selected lanes, edges and " +
toString(
SUMO_TAG_JUNCTION) +
"s");
276 auto junctions = myConnectorFrameParent->getViewNet()->getNet()->retrieveJunctions(
true);
277 for (
auto i : junctions) {
278 i->setLogicValid(
false, myConnectorFrameParent->getViewNet()->getUndoList());
282 auto edges = myConnectorFrameParent->getViewNet()->getNet()->retrieveEdges(
true);
283 for (
auto i : edges) {
284 for (
auto j : i->getLanes()) {
285 myConnectorFrameParent->removeConnections(j);
289 auto lanes = myConnectorFrameParent->getViewNet()->getNet()->retrieveLanes(
true);
290 for (
auto i : lanes) {
291 myConnectorFrameParent->removeConnections(
dynamic_cast<GNELane*
>(i));
293 myConnectorFrameParent->getViewNet()->getUndoList()->p_end();
300 myConnectorFrameParent->myConnectionModifications->onCmdCancelModifications(0, 0, 0);
301 myConnectorFrameParent->getViewNet()->getUndoList()->p_begin(
"reset connections from selected lanes");
302 auto junctions = myConnectorFrameParent->getViewNet()->getNet()->retrieveJunctions(
true);
303 for (
auto i : junctions) {
304 i->setLogicValid(
false, myConnectorFrameParent->getViewNet()->getUndoList());
306 myConnectorFrameParent->getViewNet()->getUndoList()->p_end();
332 myPotentialTargetColor(
RGBColor(0, 64, 0, 255)),
333 myTargetPassColor(
RGBColor::MAGENTA),
363 return mySourceColor;
369 return myTargetColor;
375 return myPotentialTargetColor;
381 return myTargetPassColor;
387 return myConflictColor;
395 GNEFrame(horizontalFrameParent, viewNet,
"Edit Connections"),
458 bool changed =
false;
497 }
else if ((fromPermissions & toPermissions) == 0) {
521 for (
auto it_lane : edge->
getLanes()) {
550 it->setSpecialColor(0);
567 const int toIndex = targetLane->
getIndex();
568 std::vector<NBEdge::Connection>::const_iterator con_it = find_if(
569 connections.begin(), connections.end(),
571 const bool isConnected = con_it != connections.end();
573 if (con_it->mayDefinitelyPass) {
ConnectionLegend * myConnectionLegend
ConnectionLegend modul.
static const NBConnection InvalidConnection
ConnectionModifications * getConnectionModifications() const
get pointer to ConnectionModifications modul
RGBColor myTargetColor
color for the to-lane of a connection
@ SVC_PEDESTRIAN
pedestrian
FXButton * mySelectConflictsButton
"Select Conflicts" button
long onCmdResetSelectedConnections(FXObject *, FXSelector, void *)
Called when the user presses the reset selected connections button.
~GNEConnectorFrame()
Destructor.
long onCmdSaveModifications(FXObject *, FXSelector, void *)
Called when the user presses the OK-Button saves any connection modifications.
@ MID_GNE_CONNECTORFRAME_SELECTDEADSTARTS
select lanes that have no connection leading to it
bool shiftKeyPressed() const
check if SHIFT key was pressed during click
FXLabel * myPossibleTargetLabel
possible target label
const std::string getID() const
function to support debugging
void removeConnections(GNELane *lane)
remove connections
long onCmdClearSelectedConnections(FXObject *, FXSelector, void *)
Called when the user presses the clear selected connections button.
ConnectionSelection * myConnectionSelection
ConnectionSelection modul.
~ConnectionOperations()
destructor
GNEEdge * getParentEdge() const
Returns underlying parent edge.
ConnectionSelection(GNEConnectorFrame *connectorFrameParent)
constructor
A NBNetBuilder extended by visualisation and editing capabilities.
~ConnectionSelection()
destructor
bool controlKeyPressed() const
check if CONTROL key was pressed during click
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
const RGBColor & getPotentialTargetColor() const
get color for potential to-lane targets (currently unconnected)
@ MID_CHOOSEN_CLEAR
Clear set.
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
std::vector< Connection > getConnectionsFromLane(int lane, NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
void setStatusBarText(const std::string &text)
set staturBar text
@ MID_GNE_CONNECTORFRAME_SELECTDEADENDS
select dead end lanes
~ConnectionLegend()
destructor
long onCmdSelectPass(FXObject *, FXSelector, void *)
Called when the user presses the select pass button.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
int tlLinkIndex
The index of this connection within the controlling traffic light.
@ MID_CANCEL
Cancel-button pressed.
@ MID_GNE_SET_ATTRIBUTE
attribute edited
const RGBColor & getTargetColor() const
get color for the to-lane of a connection
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
LaneStatus getLaneStatus(const std::vector< NBEdge::Connection > &connections, GNELane *targetLane)
return the status of toLane
FXCheckButton * myProtectRoutesCheckBox
protect routes checkbox
ConnectionLegend(GNEConnectorFrame *connectorFrameParent)
constructor
The representation of a single edge during network building.
CurrentLane * myCurrentLane
CurrentLane modul.
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
int getIndex() const
returns the index of the lane
A road/street connecting two junctions (netedit-version)
ConnectionModifications * myConnectionModifications
ConnectionModifications modul.
GNENet * getNet() const
get the net object
NBNode * getNBNode() const
Return net build node.
ConnectionModifications(GNEConnectorFrame *connectorFrameParent)
FOX-declaration.
ConnectionOperations * myConnectionOperations
ConnectionOperations modul.
@ MID_GNE_CONNECTORFRAME_SELECTCONFLICTS
select lanes that are connected from concurrent lanes
const RGBColor & getSourceColor() const
get color for the from-lane of a connection
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection, const NBConnection &addedConnection=NBConnection::InvalidConnection)
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
FXButton * myResetSelectedButton
"Reset Selected"
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
long onCmdSelectDeadStarts(FXObject *, FXSelector, void *)
Called when the user presses the select dead starts button.
FXDEFMAP(GNEConnectorFrame::ConnectionModifications) ConnectionModificationsMap[]
void initTargets()
init targets
NBEdge * getNBEdge() const
returns the internal NBEdge
class used to group all variables related with objects under cursor after a click over view
NBEdge::Connection & getNBEdgeConnection() const
get Edge::Connection
void handleLaneClick(const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor)
either sets the current lane or toggles the connection of the
FXButton * mySaveButton
"OK" button
int myNumChanges
number of changes
FXLabel * myTargetPassLabel
target pass label
@ MID_CHOOSEN_RESET
Reset set.
RGBColor myTargetPassColor
color for the to-lane of a connection with pass attribute
@ MID_OK
Ok-button pressed.
FXButton * myCancelButton
"Cancel" button
long onCmdSelectConflicts(FXObject *, FXSelector, void *)
Called when the user presses the select conflicts button.
std::set< GNELane * > myPotentialTargets
the set of lanes to which the current lane may be connected
LaneStatus
the status of a target lane
#define GUIDesignLabelLeft
const GNEViewNetHelper::KeyPressed & getKeyPressed() const
get Key Pressed modul
FXLabel * myHoldControlLabel
hold control label
#define GUIDesignCheckButton
checkButton placed in left position
GNEViewNet * myViewNet
View Net.
GNEUndoList * getUndoList() const
get the undoList object
void cleanup()
clean up when deselecting current lane
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
void updateCurrentLaneLabel(const std::string &laneID)
set current junction label
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
GNEConnection * retrieveGNEConnection(int fromLane, NBEdge *to, int toLane, bool createIfNoExist=true)
get GNEConnection if exist, and if not create it if create is enabled
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
void deleteConnection(GNEConnection *connection, GNEUndoList *undoList)
remove connection
void setSpecialColor(const RGBColor *Color2, double colorValue=std::numeric_limits< double >::max())
const RGBColor & getTargetPassColor() const
get color for the to-lane of a connection with pass attribute
GNEViewNet * getViewNet() const
get view net
RGBColor myPotentialTargetColor
color for potential to-lane targets (currently unconnected)
long onCmdCancelModifications(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button discards any connection modifications.
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
GNEJunction * getGNEJunctionSource() const
returns the source-junction
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
GNEConnectorFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet)
Constructor.
FXLabel * myTargetLabel
target label
@ MID_GNE_CONNECTORFRAME_SELECTPASS
select lanes with connections that have the pass attribute set to 'true'
GNENet * getNet() const
get Net in which this element is placed
FXLabel * myHoldShiftLabel
Selection Hint.
static const std::string FEATURE_MODIFIED
feature has been manually modified (implies approval)
std::vector< NBEdge::Connection > myDeletedConnections
vector of connections deleted in the current editing step
FXButton * mySelectDeadStartsButton
"Select Dead Starts" button
void buildConnection(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...
@ SUMO_TAG_CONNECTION
connectio between two lanes
ConnectionOperations(GNEConnectorFrame *connectorFrameParent)
FOX-declaration.
FXButton * myClearSelectedButton
"Clear Selected"
GNELane * myCurrentEditedLane
the lane of which connections are to be modified
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
FXButton * mySelectPassingButton
"Select Edges which may always pass"
~ConnectionModifications()
destructor
GNELane * getLaneFront() const
get front lane (or a pointer to nullptr if there isn't)
C++ TraCI client API implementation.
const RGBColor & getConflictColor() const
get color for a to-lane that cannot be used because another connection conflicts
RGBColor myConflictColor
color for a to-lane that cannot be used because another connection conflicts
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Represents a single node (junction) during network building.
RGBColor mySourceColor
color for the from-lane of a connection
bool hasConnectionTo(NBEdge *destEdge, int destLane, int fromLane=-1) const
Retrieves info about a connection to a certain lane of a certain edge.
A structure which describes a connection between edges or lanes.
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
long onCmdSelectDeadEnds(FXObject *, FXSelector, void *)
Called when the user presses the select dead ends button.
FXLabel * mySourceLabel
source label
FXLabel * myConflictLabel
conflict label
const std::vector< Connection > & getConnections() const
Returns the connections.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
FXButton * mySelectDeadEndsButton
"Select Dead Ends" button
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction