Eclipse SUMO - Simulation of Urban MObility
GNECrossing.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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A class for visualizing Inner Lanes (used when editing traffic lights)
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEUndoList.h>
24 #include <netedit/GNEViewNet.h>
26 #include <utils/gui/div/GLHelper.h>
32 
33 #include "GNECrossing.h"
34 
35 
36 // ===========================================================================
37 // method definitions
38 // ===========================================================================
39 
41  GNENetworkElement(net, "", GLO_CROSSING, SUMO_TAG_CROSSING, GUIIconSubSys::getIcon(GUIIcon::CROSSING), {}, {}, {}, {}, {}, {}),
42  myParentJunction(nullptr),
43 myTemplateNBCrossing(new NBNode::Crossing(nullptr, {}, 0, false, 0, 0, {})) {
44  // reset default values
45  resetDefaultValues();
46 }
47 
48 GNECrossing::GNECrossing(GNEJunction* parentJunction, std::vector<NBEdge*> crossingEdges) :
49  GNENetworkElement(parentJunction->getNet(), parentJunction->getNBNode()->getCrossing(crossingEdges)->id, GLO_CROSSING,
50  SUMO_TAG_CROSSING, GUIIconSubSys::getIcon(GUIIcon::CROSSING), {}, {}, {}, {}, {}, {}),
51 myParentJunction(parentJunction),
52 myCrossingEdges(crossingEdges),
53 myTemplateNBCrossing(nullptr) {
54  // update centering boundary without updating grid
55  updateCenteringBoundary(false);
56 }
57 
58 
61  delete myTemplateNBCrossing;
62  }
63 }
64 
65 
66 bool
68  return getNBCrossing()->valid;
69 }
70 
71 
72 std::string
74  return "Crossing's edges don't support pedestrians";
75 }
76 
77 
78 const PositionVector&
80  const auto crossing = getNBCrossing();
81  return (crossing->customShape.size() > 0) ? crossing->customShape : crossing->shape;
82 }
83 
84 
85 void
87  const auto crossing = getNBCrossing();
88  // update crossing geometry
89  myCrossingGeometry.updateGeometry(crossing->customShape.size() > 0 ? crossing->customShape : crossing->shape);
90 }
91 
92 
95  // currently unused
96  return Position(0, 0);
97 }
98 
99 
102  // edit depending if shape is being edited
103  if (isShapeEdited()) {
104  // calculate move shape operation
107  } else {
108  return nullptr;
109  }
110 }
111 
112 
113 void
114 GNECrossing::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) {
115  // edit depending if shape is being edited
116  if (isShapeEdited()) {
117  // get original shape
119  // check shape size
120  if (shape.size() > 2) {
121  // obtain index
122  int index = shape.indexOfClosest(clickedPosition);
123  // get snap radius
125  // check if we have to create a new index
126  if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
127  // remove geometry point
128  shape.erase(shape.begin() + index);
129  // commit new shape
130  undoList->begin(GUIIcon::CROSSING, "remove geometry point of " + getTagStr());
132  undoList->end();
133  }
134  }
135  }
136 }
137 
138 
141  return myParentJunction;
142 }
143 
144 
145 const std::vector<NBEdge*>&
147  return myCrossingEdges;
148 }
149 
150 
153  if (myTemplateNBCrossing) {
154  return myTemplateNBCrossing;
155  } else {
157  }
158 }
159 
160 
161 void
163  // check if draw start und end
164  const bool drawExtremeSymbols = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
166  // declare flag for drawing crossing
167  bool drawCrossing = s.drawCrossingsAndWalkingareas;
168  // don't draw in supermode data
170  drawCrossing = false;
171  }
172  // check shape rotations
173  if (myCrossingGeometry.getShapeRotations().empty()) {
174  drawCrossing = false;
175  }
176  // check shape lengths
177  if (myCrossingGeometry.getShapeLengths().empty()) {
178  drawCrossing = false;
179  }
180  // check zoom
181  if (s.scale < 3.0) {
182  drawCrossing = false;
183  }
184  // continue depending of drawCrossing flag
185  if (drawCrossing) {
186  // get NBCrossing
187  const auto NBCrossing = getNBCrossing();
188  // draw crossing checking whether it is not too small if isn't being drawn for selecting
189  const double selectionScale = isAttributeCarrierSelected() ? s.selectorFrameScale : 1;
190  // set default values
191  const double length = 0.5 * selectionScale;
192  const double spacing = 1.0 * selectionScale;
193  const double halfWidth = NBCrossing->width * 0.5 * selectionScale;
194  // get color
195  RGBColor crossingColor;
196  // first check if we're editing shape
197  if (myShapeEdited) {
198  crossingColor = s.colorSettings.editShapeColor;
199  } else if (drawUsingSelectColor()) {
200  crossingColor = s.colorSettings.selectedCrossingColor;
201  } else if (!NBCrossing->valid) {
202  crossingColor = s.colorSettings.crossingInvalidColor;
203  } else if (NBCrossing->priority) {
204  crossingColor = s.colorSettings.crossingPriorityColor;
206  crossingColor = s.laneColorer.getSchemes()[0].getColor(8);
207  } else {
208  crossingColor = s.colorSettings.crossingColor;
209  }
210  // check that current mode isn't TLS
212  // push name
214  // push layer matrix
216  // translate to front
218  // set color
219  GLHelper::setColor(crossingColor);
220  // draw depending of selection
222  // just drawn a box line
224  } else {
225  // push rail matrix
227  // draw on top of of the white area between the rails
228  glTranslated(0, 0, 0.1);
229  for (int i = 0; i < (int)myCrossingGeometry.getShape().size() - 1; i++) {
230  // push draw matrix
232  // translate and rotate
233  glTranslated(myCrossingGeometry.getShape()[i].x(), myCrossingGeometry.getShape()[i].y(), 0.0);
234  glRotated(myCrossingGeometry.getShapeRotations()[i], 0, 0, 1);
235  // draw crossing depending if isn't being drawn for selecting
236  for (double t = 0; t < myCrossingGeometry.getShapeLengths()[i]; t += spacing) {
237  glBegin(GL_QUADS);
238  glVertex2d(-halfWidth, -t);
239  glVertex2d(-halfWidth, -t - length);
240  glVertex2d(halfWidth, -t - length);
241  glVertex2d(halfWidth, -t);
242  glEnd();
243  }
244  // pop draw matrix
246  }
247  // pop rail matrix
249  }
250  // draw shape points only in Network supemode
252  // color
253  const RGBColor darkerColor = crossingColor.changedBrightness(-32);
254  // draw geometry points
257  myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
258  // draw moving hint
262  }
263  }
264  // pop layer matrix
266  // pop name
268  }
269  // link indices must be drawn in all edit modes if isn't being drawn for selecting
271  drawTLSLinkNo(s, NBCrossing);
272  }
273  // draw crosing name
274  if (s.cwaEdgeName.show(this)) {
276  }
277  // draw lock icon
279  // check if mouse is over element
281  // inspect contour
284  selectionScale, true, true);
285  }
286  // front contour
287  if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
289  selectionScale, true, true);
290  }
291  // delete contour
292  if (myNet->getViewNet()->drawDeleteContour(this, this)) {
294  selectionScale, true, true);
295  }
296  // delete contour
297  if (myNet->getViewNet()->drawSelectContour(this, this)) {
299  selectionScale, true, true);
300  }
301  }
302 }
303 
304 
307 }
308 
309 
310 void
312  updateGeometry();
313 }
314 
315 
316 void
318  // push matrix
320  // move to GLO_Crossing
321  glTranslated(0, 0, GLO_CROSSING + 0.5);
322  // make a copy of shape
323  PositionVector shape = crossing->shape;
324  // extrapolate
325  shape.extrapolate(0.5); // draw on top of the walking area
326  // get link indexes
327  const int linkNo = crossing->tlLinkIndex;
328  const int linkNo2 = crossing->tlLinkIndex2 > 0 ? crossing->tlLinkIndex2 : linkNo;
329  // draw link indexes
330  GLHelper::drawTextAtEnd(toString(linkNo2), shape, 0, s.drawLinkTLIndex, s.scale);
331  GLHelper::drawTextAtEnd(toString(linkNo), shape.reverse(), 0, s.drawLinkTLIndex, s.scale);
332  // push matrix
334 }
335 
336 
339  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
340  buildPopupHeader(ret, app);
343  // build selection and show parameters menu
346  // build position copy entry
347  buildPositionCopyEntry(ret, app);
348  // check if we're in supermode network
350  // create menu commands
351  FXMenuCommand* mcCustomShape = GUIDesigns::buildFXMenuCommand(ret, "Set custom crossing shape", nullptr, &parent, MID_GNE_CROSSING_EDIT_SHAPE);
352  // check if menu commands has to be disabled
354  if ((editMode == NetworkEditMode::NETWORK_CONNECT) || (editMode == NetworkEditMode::NETWORK_TLS) || (editMode == NetworkEditMode::NETWORK_CREATE_EDGE)) {
355  mcCustomShape->disable();
356  }
357  }
358  return ret;
359 }
360 
361 
362 double
364  return 1;
365 }
366 
367 
368 void
369 GNECrossing::updateCenteringBoundary(const bool /*updateGrid*/) {
370  const auto crossing = getNBCrossing();
371  if (crossing) {
372  if (crossing->customShape.size() > 0) {
373  myBoundary = crossing->customShape.getBoxBoundary();
374  myBoundary.grow(10);
375  } else if (crossing->shape.size() > 0) {
376  myBoundary = crossing->shape.getBoxBoundary();
377  myBoundary.grow(10);
378  } else {
380  }
381  } else {
382  // in other case use boundary of parent junction
384  }
385 }
386 
387 
388 std::string
390  const auto crossing = getNBCrossing();
391  switch (key) {
392  case SUMO_ATTR_ID:
393  // get attribute requires a special case
394  if (crossing) {
395  return crossing->id;
396  } else {
397  return "Temporal Unreferenced";
398  }
399  case SUMO_ATTR_WIDTH:
400  return toString(crossing->customWidth);
401  case SUMO_ATTR_PRIORITY:
402  return crossing->priority ? "true" : "false";
403  case SUMO_ATTR_EDGES:
404  return toString(crossing->edges);
406  return toString(crossing->customTLIndex < 0 ? crossing->tlLinkIndex : crossing->customTLIndex);
408  return toString(crossing->customTLIndex2 < 0 ? crossing->tlLinkIndex2 : crossing->customTLIndex2);
410  return toString(crossing->customShape);
411  case GNE_ATTR_SELECTED:
413  case GNE_ATTR_PARAMETERS:
414  return crossing->getParametersStr();
415  default:
416  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
417  }
418 }
419 
420 
421 void
422 GNECrossing::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
423  if (value == getAttribute(key)) {
424  return; //avoid needless changes, later logic relies on the fact that attributes have changed
425  }
426  switch (key) {
427  case SUMO_ATTR_ID:
428  throw InvalidArgument("Modifying attribute '" + toString(key) + "' of " + getTagStr() + " isn't allowed");
429  case SUMO_ATTR_EDGES:
430  case SUMO_ATTR_WIDTH:
431  case SUMO_ATTR_PRIORITY:
435  case GNE_ATTR_SELECTED:
436  case GNE_ATTR_PARAMETERS:
437  undoList->add(new GNEChange_Attribute(this, key, value), true);
438  break;
439  default:
440  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
441  }
442 }
443 
444 
445 bool
447  switch (key) {
448  case SUMO_ATTR_ID:
449  // id isn't editable
450  return false;
453  return (getNBCrossing()->tlID != "");
454  default:
455  return true;
456  }
457 }
458 
459 
460 bool
461 GNECrossing::isValid(SumoXMLAttr key, const std::string& value) {
462  const auto crossing = getNBCrossing();
463  switch (key) {
464  case SUMO_ATTR_ID:
465  return false;
466  case SUMO_ATTR_EDGES:
467  if (canParse<std::vector<GNEEdge*> >(myNet, value, false)) {
468  // parse edges and save their IDs in a set
469  std::vector<GNEEdge*> parsedEdges = parse<std::vector<GNEEdge*> >(myNet, value);
470  EdgeVector nbEdges;
471  for (auto i : parsedEdges) {
472  nbEdges.push_back(i->getNBEdge());
473  }
474  std::sort(nbEdges.begin(), nbEdges.end());
475  //
476  EdgeVector originalEdges = crossing->edges;
477  std::sort(originalEdges.begin(), originalEdges.end());
478  // return true if we're setting the same edges
479  if (toString(nbEdges) == toString(originalEdges)) {
480  return true;
481  } else {
483  }
484  } else {
485  return false;
486  }
487  case SUMO_ATTR_WIDTH:
488  return canParse<double>(value) && ((parse<double>(value) > 0) || (parse<double>(value) == -1)); // can not be 0, or -1 (it means default)
489  case SUMO_ATTR_PRIORITY:
490  return canParse<bool>(value);
493  // -1 means that tlLinkIndex2 takes on the same value as tlLinkIndex when setting indices
494  return (isAttributeEnabled(key) &&
495  canParse<int>(value)
496  && (parse<double>(value) >= 0 || parse<double>(value) == -1)
497  && myParentJunction->getNBNode()->getControllingTLS().size() > 0
498  && (*myParentJunction->getNBNode()->getControllingTLS().begin())->getMaxValidIndex() >= parse<int>(value));
499  case SUMO_ATTR_CUSTOMSHAPE: {
500  // empty shapes are allowed
501  return canParse<PositionVector>(value);
502  }
503  case GNE_ATTR_SELECTED:
504  return canParse<bool>(value);
505  case GNE_ATTR_PARAMETERS:
506  return Parameterised::areParametersValid(value);
507  default:
508  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
509  }
510 }
511 
512 
513 const Parameterised::Map&
515  return getNBCrossing()->getParametersMap();
516 }
517 
518 
519 bool
521  const auto crossing = getNBCrossing();
522  if (std::find(crossing->edges.begin(), crossing->edges.end(), edge->getNBEdge()) != crossing->edges.end()) {
523  return true;
524  } else {
525  return false;
526  }
527 }
528 
529 
530 bool
531 GNECrossing::checkEdgeBelong(const std::vector<GNEEdge*>& edges) const {
532  for (auto i : edges) {
533  if (checkEdgeBelong(i)) {
534  return true;
535  }
536  }
537  return false;
538 }
539 
540 // ===========================================================================
541 // private
542 // ===========================================================================
543 
544 void
545 GNECrossing::setAttribute(SumoXMLAttr key, const std::string& value) {
546  const auto crossing = getNBCrossing();
547  switch (key) {
548  case SUMO_ATTR_ID:
549  throw InvalidArgument("Modifying attribute '" + toString(key) + "' of " + getTagStr() + " isn't allowed");
550  case SUMO_ATTR_EDGES: {
551  // obtain GNEEdges
552  std::vector<GNEEdge*> edges = parse<std::vector<GNEEdge*> >(myNet, value);
553  // remove NBEdges of crossing
554  crossing->edges.clear();
555  // set NBEdge of every GNEEdge into Crossing Edges
556  for (auto i : edges) {
557  crossing->edges.push_back(i->getNBEdge());
558  }
559  // sort new edges
560  std::sort(crossing->edges.begin(), crossing->edges.end());
561  // change myCrossingEdges by the new edges
562  myCrossingEdges = crossing->edges;
563  // update geometry of parent junction
565  break;
566  }
567  case SUMO_ATTR_WIDTH:
568  // Change width an refresh element
569  crossing->customWidth = parse<double>(value);
570  // update boundary
571  if (myParentJunction) {
573  }
574  break;
575  case SUMO_ATTR_PRIORITY:
576  crossing->priority = parse<bool>(value);
577  break;
579  crossing->customTLIndex = parse<int>(value);
580  // make new value visible immediately
581  crossing->tlLinkIndex = crossing->customTLIndex;
582  break;
584  crossing->customTLIndex2 = parse<int>(value);
585  // make new value visible immediately
586  crossing->tlLinkIndex2 = crossing->customTLIndex2;
587  break;
588  case SUMO_ATTR_CUSTOMSHAPE: {
589  // set custom shape
590  crossing->customShape = parse<PositionVector>(value);
591  // update boundary
592  if (myParentJunction) {
594  }
595  break;
596  }
597  case GNE_ATTR_SELECTED:
598  if (parse<bool>(value)) {
600  } else {
602  }
603  break;
604  case GNE_ATTR_PARAMETERS:
605  crossing->setParametersStr(value);
606  break;
607  default:
608  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
609  }
610  // Crossing are a special case and we need ot update geometry of junction instead of crossing
611  if (myParentJunction && (key != SUMO_ATTR_ID) && (key != GNE_ATTR_PARAMETERS) && (key != GNE_ATTR_SELECTED)) {
613  }
614  // invalidate path calculator
616 }
617 
618 
619 void
621  // set custom shape
622  getNBCrossing()->customShape = moveResult.shapeToUpdate;
623  // update geometry
624  updateGeometry();
625 }
626 
627 
628 void
630  // commit new shape
631  undoList->begin(GUIIcon::CROSSING, "moving " + toString(SUMO_ATTR_CUSTOMSHAPE) + " of " + getTagStr());
633  undoList->end();
634 }
635 
636 /****************************************************************************/
NetworkEditMode
@brie enum for network edit modes
@ NETWORK_MOVE
mode for moving network elements
@ NETWORK_CREATE_EDGE
mode for creating new edges
@ NETWORK_TLS
mode for editing tls
@ NETWORK_CONNECT
mode for connecting lanes
@ MID_GNE_CROSSING_EDIT_SHAPE
edit crossing shape
Definition: GUIAppEnum.h:1205
@ GLO_CROSSING
a tl-logic
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:35
@ SUMO_TAG_CROSSING
crossing between edges for pedestrians
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_TLLINKINDEX2
link: the index of the opposite direction link of a pedestrian crossing
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_CUSTOMSHAPE
whether a given shape is user-defined
@ SUMO_ATTR_EDGES
the edges of a route
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_PRIORITY
@ SUMO_ATTR_ID
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_TLLINKINDEX
link: the index of the link within the traffic light
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:583
static void drawTextAtEnd(const std::string &text, const PositionVector &shape, double x, const GUIVisualizationTextSettings &settings, const double scale)
draw text and the end of shape
Definition: GLHelper.cpp:767
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:329
static void popName()
pop Name
Definition: GLHelper.cpp:148
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
friend class GNEChange_Attribute
declare friend class
const std::string & getTagStr() const
get tag assigned to this object in string format
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
GNENet * myNet
pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
std::string getAttribute(SumoXMLAttr key) const
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
std::vector< NBEdge * > myCrossingEdges
Crossing Edges (It works as ID because a junction can only ONE Crossing with the same edges)
Definition: GNECrossing.h:167
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
const Parameterised::Map & getACParametersMap() const
get parameters map
bool isNetworkElementValid() const
check if current network element is valid to be written into XML
Definition: GNECrossing.cpp:67
void deleteGLObject()
delete element
GNECrossing(GNENet *net)
default constructor
Definition: GNECrossing.cpp:40
void updateGeometry()
update pre-computed geometry information
Definition: GNECrossing.cpp:86
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void updateGLObject()
update GLObject (geometry, ID, etc.)
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition: GNECrossing.cpp:94
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void drawTLSLinkNo(const GUIVisualizationSettings &s, const NBNode::Crossing *crossing) const
draw TLS Link Number
bool checkEdgeBelong(GNEEdge *edges) const
return true if a edge belongs to crossing's edges
GNEJunction * myParentJunction
the parent junction of this crossing
Definition: GNECrossing.h:164
const std::vector< NBEdge * > & getCrossingEdges() const
get crossingEdges
GUIGeometry myCrossingGeometry
crossing geometry
Definition: GNECrossing.h:170
bool isAttributeEnabled(SumoXMLAttr key) const
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
GNEJunction * getParentJunction() const
get parent Junction
NBNode::Crossing * getNBCrossing() const
get referente to NBode::Crossing
std::string getNetworkElementProblem() const
return a string with the current network element problem
Definition: GNECrossing.cpp:73
const PositionVector & getCrossingShape() const
Definition: GNECrossing.cpp:79
~GNECrossing()
Destructor.
Definition: GNECrossing.cpp:59
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
NBNode::Crossing * myTemplateNBCrossing
template NBCrossing
Definition: GNECrossing.h:173
bool isValid(SumoXMLAttr key, const std::string &value)
GNEMoveOperation * getMoveOperation()
get move operation
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:481
void updateGeometry()
update pre-computed geometry information (including crossings)
NBNode * getNBNode() const
Return net build node.
GNEMoveOperation * calculateMoveShapeOperation(const PositionVector originalShape, const Position mousePosition, const double snapRadius, const bool onlyContour)
calculate move shape operation
move operation
move result
PositionVector shapeToUpdate
shape to update (edited in moveElement)
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
void deleteNetworkElement(GNENetworkElement *networkElement, GNEUndoList *undoList)
delete network element
Definition: GNENet.cpp:334
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:138
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1987
bool myShapeEdited
flag to check if element shape is being edited
bool isShapeEdited() const
check if shape is being edited
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Boundary myBoundary
object boundary
void invalidatePathCalculator()
invalidate pathCalculator
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:632
bool drawSelectContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw select contour
bool drawDeleteContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw delete contour
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:644
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEUndoList * getUndoList() const
get the undoList object
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:474
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:42
static void drawDottedContourShape(const GUIVisualizationSettings &s, const DottedContourType type, const PositionVector &shape, const double width, const double exaggeration, const bool drawFirstExtrem, const bool drawLastExtrem)
draw dotted contour for the given shape (used by additionals)
The popup menu of a globject.
static void drawGeometryPoints(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &geometryPointColor, const RGBColor &textColor, const double radius, const double exaggeration, const bool editingElevation, const bool drawExtremeSymbols)
draw geometry points
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
Definition: GUIGeometry.cpp:58
static void drawMovingHint(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &hintColor, const double radius, const double exaggeration)
draw moving hint
const std::vector< double > & getShapeLengths() const
The lengths of the single shape parts.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void mouseWithinGeometry(const Position center, const double radius) const
check if mouse is within elements geometry (for circles)
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:154
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:102
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
const std::vector< T > & getSchemes() const
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
GUIVisualizationTextSettings cwaEdgeName
bool drawMovingGeometryPoint(const double exaggeration, const double radius) const
check if moving geometry point can be draw
GUIVisualizationColorSettings colorSettings
color settings
double scale
information about a lane's width (temporary, used for a single view)
GUIColorer laneColorer
The lane colorer.
GUIVisualizationTextSettings edgeName
GUIVisualizationTextSettings drawLinkTLIndex
bool drawCrossingsAndWalkingareas
whether crosings and walkingareas shall be drawn
double selectorFrameScale
the current selection scaling in NETEDIT (set in SelectorFrame)
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
A definition of a pedestrian crossing.
Definition: NBNode.h:129
int tlLinkIndex
the traffic light index of this crossing (if controlled)
Definition: NBNode.h:154
PositionVector customShape
optional customShape for this crossing
Definition: NBNode.h:152
PositionVector shape
The crossing's shape.
Definition: NBNode.h:138
int tlLinkIndex2
Definition: NBNode.h:155
bool valid
whether this crossing is valid (and can be written to the net.xml). This is needed for netedit becaus...
Definition: NBNode.h:162
Crossing * getCrossing(const std::string &id) const
return the crossing with the given id
Definition: NBNode.cpp:3550
bool checkCrossingDuplicated(EdgeVector edges)
return true if there already exist a crossing with the same edges as the input
Definition: NBNode.cpp:2701
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:326
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
int indexOfClosest(const Position &p, bool twoD=false) const
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
PositionVector reverse() const
reverse position vector
static const RGBColor BLACK
Definition: RGBColor.h:193
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:200
NetworkEditMode networkEditMode
the current Network edit mode
bool isCurrentSupermodeData() const
@check if current supermode is Data
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static void drawLockIcon(const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position viewPosition, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool editingElevation() const
check if we're editing elevation
RGBColor selectedCrossingColor
crossings selection color
static const RGBColor crossingPriorityColor
color for priority crossing
static const RGBColor crossingInvalidColor
color for invalid crossing
static const RGBColor crossingColor
color for crossings
static const RGBColor editShapeColor
color for edited shapes (Junctions, crossings and connections)
static const double crossingGeometryPointRadius
moving crossing geometry point radius
bool show(const GUIGlObject *o) const
whether to show the text