78 myCurrentLaneLabel->setText(
"No lane selected");
80 myCurrentLaneLabel->setText((std::string(
"Current Lane: ") + laneID).c_str());
90 myConnectorFrameParent(connectorFrameParent) {
93 myCancelButton =
new FXButton(
this,
"Cancel\t\tDiscard connection modifications (Esc)",
96 mySaveButton =
new FXButton(
this,
"OK\t\tSave connection modifications (Enter)",
109 if (myConnectorFrameParent->myCurrentEditedLane != 0) {
110 myConnectorFrameParent->getViewNet()->getUndoList()->p_abort();
111 if (myConnectorFrameParent->myNumChanges) {
112 myConnectorFrameParent->getViewNet()->setStatusBarText(
"Changes reverted");
114 myConnectorFrameParent->cleanup();
115 myConnectorFrameParent->getViewNet()->updateViewNet();
123 if (myConnectorFrameParent->myCurrentEditedLane != 0) {
125 if (myProtectRoutesCheckBox->isEnabled() && (myProtectRoutesCheckBox->getCheck() == TRUE)) {
126 for (
const auto& i : myConnectorFrameParent->myCurrentEditedLane->getParentEdge()->getChildDemandElements()) {
127 if (!i->isDemandElementValid()) {
128 FXMessageBox::warning(getApp(), MBOX_OK,
129 "Error saving connection operations",
"%s",
130 (
"Connection edition cannot be saved because route '" + i->getID() +
"' is broken.").c_str());
136 myConnectorFrameParent->getViewNet()->getUndoList()->p_end();
137 if (myConnectorFrameParent->myNumChanges) {
138 myConnectorFrameParent->getViewNet()->setStatusBarText(
"Changes accepted");
140 myConnectorFrameParent->cleanup();
141 myConnectorFrameParent->getViewNet()->updateViewNet();
152 myConnectorFrameParent(connectorFrameParent) {
155 mySelectDeadEndsButton =
new FXButton(
this,
"Select Dead Ends\t\tSelects all lanes that have no outgoing connection (clears previous selection)",
158 mySelectDeadStartsButton =
new FXButton(
this,
"Select Dead Starts\t\tSelects all lanes that have no incoming connection (clears previous selection)",
161 mySelectConflictsButton =
new FXButton(
this,
"Select Conflicts\t\tSelects all lanes with more than one incoming connection from the same edge (clears previous selection)",
164 mySelectPassingButton =
new FXButton(
this,
"Select Passing\t\tSelects all lanes with a connection that has has the 'pass' attribute set",
167 myClearSelectedButton =
new FXButton(
this,
"Clear Selected\t\tClears all connections of all selected objects",
170 myResetSelectedButton =
new FXButton(
this,
"Reset Selected\t\tRecomputes connections at all selected junctions",
181 std::vector<GNEAttributeCarrier*> deadEnds;
183 const std::vector<GNEEdge*> edges = myConnectorFrameParent->getViewNet()->getNet()->retrieveEdges();
184 for (
auto i : edges) {
185 for (
auto j : i->getLanes()) {
186 if (i->getNBEdge()->getConnectionsFromLane(j->getIndex()).size() == 0) {
187 deadEnds.push_back(j);
199 std::set<GNEAttributeCarrier*> deadStarts;
203 for (
auto i : junctions) {
205 for (
auto j : i->getNBNode()->getOutgoingEdges()) {
208 deadStarts.insert(k);
212 for (
auto j : i->getNBNode()->getIncomingEdges()) {
219 std::vector<GNEAttributeCarrier*> selectObjects(deadStarts.begin(), deadStarts.end());
227 std::vector<GNEAttributeCarrier*> conflicts;
229 const std::vector<GNEEdge*> edges = myConnectorFrameParent->getViewNet()->getNet()->retrieveEdges();
230 for (
auto i : edges) {
231 const EdgeVector destinations = i->getNBEdge()->getConnectedEdges();
232 for (
auto j : destinations) {
235 const bool isConflicted = count_if(i->getNBEdge()->getConnections().begin(), i->getNBEdge()->getConnections().end(),
238 conflicts.push_back(k);
251 std::vector<GNEAttributeCarrier*> pass;
252 const std::vector<GNEEdge*> edges = myConnectorFrameParent->getViewNet()->getNet()->retrieveEdges();
253 for (
auto i : edges) {
254 for (
auto j : i->getNBEdge()->getConnections()) {
255 if (j.mayDefinitelyPass) {
256 pass.push_back(i->getLanes()[j.fromLane]);
267 myConnectorFrameParent->myConnectionModifications->onCmdCancelModifications(0, 0, 0);
268 myConnectorFrameParent->getViewNet()->getUndoList()->p_begin(
"clear connections from selected lanes, edges and " +
toString(
SUMO_TAG_JUNCTION) +
"s");
270 auto junctions = myConnectorFrameParent->getViewNet()->getNet()->retrieveJunctions(
true);
271 for (
auto i : junctions) {
272 i->setLogicValid(
false, myConnectorFrameParent->getViewNet()->getUndoList());
276 auto edges = myConnectorFrameParent->getViewNet()->getNet()->retrieveEdges(
true);
277 for (
auto i : edges) {
278 for (
auto j : i->getLanes()) {
279 myConnectorFrameParent->removeConnections(j);
283 auto lanes = myConnectorFrameParent->getViewNet()->getNet()->retrieveLanes(
true);
284 for (
auto i : lanes) {
285 myConnectorFrameParent->removeConnections(
dynamic_cast<GNELane*
>(i));
287 myConnectorFrameParent->getViewNet()->getUndoList()->p_end();
294 myConnectorFrameParent->myConnectionModifications->onCmdCancelModifications(0, 0, 0);
295 myConnectorFrameParent->getViewNet()->getUndoList()->p_begin(
"reset connections from selected lanes");
296 auto junctions = myConnectorFrameParent->getViewNet()->getNet()->retrieveJunctions(
true);
297 for (
auto i : junctions) {
298 i->setLogicValid(
false, myConnectorFrameParent->getViewNet()->getUndoList());
300 myConnectorFrameParent->getViewNet()->getUndoList()->p_end();
326 FXLabel* possibleTargetLabel =
new FXLabel(
this,
"Possible Target", 0,
GUIDesignLabelLeft);
355 GNEFrame(horizontalFrameParent, viewNet,
"Edit Connections"),
419 bool changed =
false;
441 if (mayDefinitelyPass) {
464 }
else if ((fromPermissions & toPermissions) == 0) {
488 for (
const auto& lane : edge->
getLanes()) {
517 it->setSpecialColor(0);
534 const int toIndex = targetLane->
getIndex();
535 std::vector<NBEdge::Connection>::const_iterator con_it = find_if(
536 connections.begin(), connections.end(),
538 const bool isConnected = con_it != connections.end();
540 if (con_it->mayDefinitelyPass) {
FXDEFMAP(GNEConnectorFrame::ConnectionModifications) ConnectionModificationsMap[]
@ MID_GNE_CONNECTORFRAME_SELECTDEADENDS
select dead end lanes
@ MID_GNE_SET_ATTRIBUTE
attribute edited
@ MID_CANCEL
Cancel-button pressed.
@ MID_CHOOSEN_CLEAR
Clear set.
@ MID_OK
Ok-button pressed.
@ MID_GNE_CONNECTORFRAME_SELECTDEADSTARTS
select lanes that have no connection leading to it
@ MID_GNE_CONNECTORFRAME_SELECTCONFLICTS
select lanes that are connected from concurrent lanes
@ MID_CHOOSEN_RESET
Reset set.
@ MID_GNE_CONNECTORFRAME_SELECTPASS
select lanes with connections that have the pass attribute set to 'true'
#define GUIDesignLabelLeft
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
#define GUIDesignCheckButton
checkButton placed in left position
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
@ SVC_PEDESTRIAN
pedestrian
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SUMO_TAG_CONNECTION
connectio between two lanes
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
GNENet * getNet() const
get pointer to net
static const std::string FEATURE_MODIFIED
feature has been manually modified (implies approval)
NBEdge::Connection & getNBEdgeConnection() const
get Edge::Connection
~ConnectionLegend()
destructor
ConnectionLegend(GNEConnectorFrame *connectorFrameParent)
constructor
~ConnectionModifications()
destructor
long onCmdSaveModifications(FXObject *, FXSelector, void *)
Called when the user presses the OK-Button saves any connection modifications.
ConnectionModifications(GNEConnectorFrame *connectorFrameParent)
FOX-declaration.
long onCmdCancelModifications(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button discards any connection modifications.
FXButton * mySaveButton
"OK" button
FXButton * myCancelButton
"Cancel" button
FXCheckButton * myProtectRoutesCheckBox
protect routes checkbox
~ConnectionOperations()
destructor
FXButton * mySelectDeadStartsButton
"Select Dead Starts" button
FXButton * mySelectConflictsButton
"Select Conflicts" button
long onCmdSelectDeadEnds(FXObject *, FXSelector, void *)
Called when the user presses the select dead ends button.
long onCmdResetSelectedConnections(FXObject *, FXSelector, void *)
Called when the user presses the reset selected connections button.
long onCmdSelectDeadStarts(FXObject *, FXSelector, void *)
Called when the user presses the select dead starts button.
long onCmdSelectPass(FXObject *, FXSelector, void *)
Called when the user presses the select pass button.
FXButton * mySelectDeadEndsButton
"Select Dead Ends" button
long onCmdClearSelectedConnections(FXObject *, FXSelector, void *)
Called when the user presses the clear selected connections button.
FXButton * myClearSelectedButton
"Clear Selected"
long onCmdSelectConflicts(FXObject *, FXSelector, void *)
Called when the user presses the select conflicts button.
ConnectionOperations(GNEConnectorFrame *connectorFrameParent)
FOX-declaration.
FXButton * myResetSelectedButton
"Reset Selected"
FXButton * mySelectPassingButton
"Select Edges which may always pass"
~ConnectionSelection()
destructor
FXLabel * myHoldShiftLabel
Selection Hint.
ConnectionSelection(GNEConnectorFrame *connectorFrameParent)
constructor
FXLabel * myHoldControlLabel
hold control label
void updateCurrentLaneLabel(const std::string &laneID)
set current junction label
int myNumChanges
number of changes
ConnectionModifications * myConnectionModifications
ConnectionModifications modul.
std::vector< NBEdge::Connection > myDeletedConnections
vector of connections deleted in the current editing step
void cleanup()
clean up when deselecting current lane
void initTargets()
init targets
ConnectionModifications * getConnectionModifications() const
get pointer to ConnectionModifications modul
ConnectionSelection * myConnectionSelection
ConnectionSelection modul.
void buildConnection(GNELane *lane, const bool mayDefinitelyPass, const bool allowConflict, const bool toggle)
either sets the current lane or toggles the connection of the current lane to this lane (if they shar...
void handleLaneClick(const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor)
either sets the current lane or toggles the connection of the
~GNEConnectorFrame()
Destructor.
void removeConnections(GNELane *lane)
remove connections
ConnectionOperations * myConnectionOperations
ConnectionOperations modul.
std::set< GNELane * > myPotentialTargets
the set of lanes to which the current lane may be connected
LaneStatus getLaneStatus(const std::vector< NBEdge::Connection > &connections, const GNELane *targetLane) const
return the status of toLane
GNEConnectorFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet)
Constructor.
GNELane * myCurrentEditedLane
the lane of which connections are to be modified
ConnectionLegend * myConnectionLegend
ConnectionLegend modul.
LaneStatus
the status of a target lane
CurrentLane * myCurrentLane
CurrentLane modul.
A road/street connecting two junctions (netedit-version)
NBEdge * getNBEdge() const
returns the internal NBEdge
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
GNEConnection * retrieveGNEConnection(int fromLane, NBEdge *to, int toLane, bool createIfNoExist=true)
get GNEConnection if exist, and if not create it if create is enabled
GNEViewNet * getViewNet() const
get view net
GNEViewNet * myViewNet
View Net.
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
const std::vector< GNEJunction * > & getParentJunctions() const
get parent junctions
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
int getIndex() const
returns the index of the lane
void setSpecialColor(const RGBColor *Color2, double colorValue=std::numeric_limits< double >::max())
GNEEdge * getParentEdge() const
get arent edge
A NBNetBuilder extended by visualisation and editing capabilities.
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true) const
get edge by id
void deleteConnection(GNEConnection *connection, GNEUndoList *undoList)
remove connection
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
GNEViewNet * getViewNet() const
get view net
const std::string & getID() const
get ID
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...
class used to group all variables related with objects under cursor after a click over view
GNELane * getLaneFront() const
get front lane or a pointer to nullptr
GNENet * getNet() const
get the net object
const GNEViewNetHelper::MouseButtonKeyPressed & getMouseButtonKeyPressed() const
get Key Pressed modul
GNEUndoList * getUndoList() const
get the undoList object
void setStatusBarText(const std::string &text)
set staturBar text
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings
GUIVisualizationCandidateColorSettings candidateColorSettings
candidate color settings
C++ TraCI client API implementation.
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
static const NBConnection InvalidConnection
The representation of a single edge during network building.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
std::vector< Connection > getConnectionsFromLane(int lane, NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
const std::vector< Connection > & getConnections() const
Returns the connections.
bool hasConnectionTo(NBEdge *destEdge, int destLane, int fromLane=-1) const
Retrieves info about a connection to a certain lane of a certain edge.
Represents a single node (junction) during network building.
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
static const RGBColor WHITE
static const RGBColor special
color for selected special candidate element (Usually selected using shift+click)
static const RGBColor conflict
color for selected conflict candidate element (Usually selected using ctrl+click)
static const RGBColor target
color for selected candidate target
static const RGBColor possible
color for possible candidate element
static const RGBColor source
color for selected candidate source
A structure which describes a connection between edges or lanes.
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
int tlLinkIndex
The index of this connection within the controlling traffic light.