Eclipse SUMO - Simulation of Urban MObility
GNEAdditional.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-2020 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 abstract class for representation of additional elements
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEViewNet.h>
24 #include <utils/gui/div/GLHelper.h>
30 
31 #include "GNEAdditional.h"
32 
33 // ===========================================================================
34 // member method definitions
35 // ===========================================================================
36 
37 GNEAdditional::GNEAdditional(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement,
38  const std::vector<GNEJunction*>& junctionParents,
39  const std::vector<GNEEdge*>& edgeParents,
40  const std::vector<GNELane*>& laneParents,
41  const std::vector<GNEAdditional*>& additionalParents,
42  const std::vector<GNEShape*>& shapeParents,
43  const std::vector<GNETAZElement*>& TAZElementParents,
44  const std::vector<GNEDemandElement*>& demandElementParents,
45  const std::vector<GNEGenericData*>& genericDataParents) :
46  GUIGlObject(type, id),
47  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, shapeParents, TAZElementParents, demandElementParents, genericDataParents),
48  GNEPathElements(this),
49  myAdditionalName(additionalName),
50  myBlockMovement(blockMovement),
51  mySpecialColor(nullptr) {
52 }
53 
54 
55 GNEAdditional::GNEAdditional(GNENet* net, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement,
56  const std::vector<GNEJunction*>& junctionParents,
57  const std::vector<GNEEdge*>& edgeParents,
58  const std::vector<GNELane*>& laneParents,
59  const std::vector<GNEAdditional*>& additionalParents,
60  const std::vector<GNEShape*>& shapeParents,
61  const std::vector<GNETAZElement*>& TAZElementParents,
62  const std::vector<GNEDemandElement*>& demandElementParents,
63  const std::vector<GNEGenericData*>& genericDataParents) :
64  GUIGlObject(type, additionalParents.front()->getID()),
65  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, shapeParents, TAZElementParents, demandElementParents, genericDataParents),
66  GNEPathElements(this),
67  myAdditionalName(additionalName),
68  myBlockMovement(blockMovement),
69  mySpecialColor(nullptr) {
70 }
71 
72 
74 
75 
76 void
77 GNEAdditional::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
78  // currently there isn't additionals with removable geometry points
79 }
80 
81 
82 const std::string&
84  return getMicrosimID();
85 }
86 
87 
90  return this;
91 }
92 
93 
96  return myAdditionalGeometry;
97 }
98 
99 
103 }
104 
105 
106 void
108  mySpecialColor = color;
109 }
110 
111 
112 void
114  // first check if minimum number of children is correct
116  WRITE_WARNING(getTagStr() + " with ID='" + getID() + "' cannot be written");
117  } else {
118  // Open Tag or synonym Tag
121  } else {
122  device.openTag(myTagProperty.getTag());
123  }
124  // iterate over attribute properties
125  for (const auto& attrProperty : myTagProperty) {
126  // obtain attribute value
127  const std::string attributeValue = getAttribute(attrProperty.getAttr());
128  // first check if attribute is optional but not vehicle classes
129  if (attrProperty.isOptional() && !attrProperty.isVClasses()) {
130  // Only write attributes with default value if is different from original
131  if (attrProperty.getDefaultValue() != attributeValue) {
132  // check if attribute must be written using a synonim
133  if (attrProperty.hasAttrSynonym()) {
134  device.writeAttr(attrProperty.getAttrSynonym(), attributeValue);
135  } else {
136  // SVC permissions uses their own writting function
137  if (attrProperty.isSVCPermission()) {
138  // disallow attribute musn't be written
139  if (attrProperty.getAttr() != SUMO_ATTR_DISALLOW) {
140  writePermissions(device, parseVehicleClasses(attributeValue));
141  }
142  } else if (myTagProperty.canMaskXYZPositions() && (attrProperty.getAttr() == SUMO_ATTR_POSITION)) {
143  // get position attribute and write it separate
144  Position pos = parse<Position>(getAttribute(SUMO_ATTR_POSITION));
145  device.writeAttr(SUMO_ATTR_X, toString(pos.x()));
146  device.writeAttr(SUMO_ATTR_Y, toString(pos.y()));
147  // write 0 only if is different from 0 (the default value)
148  if (pos.z() != 0) {
149  device.writeAttr(SUMO_ATTR_Z, toString(pos.z()));
150  }
151  } else {
152  device.writeAttr(attrProperty.getAttr(), attributeValue);
153  }
154  }
155  }
156  } else {
157  // Attributes without default values are always writted
158  if (attrProperty.hasAttrSynonym()) {
159  device.writeAttr(attrProperty.getAttrSynonym(), attributeValue);
160  } else {
161  // SVC permissions uses their own writting function
162  if (attrProperty.isSVCPermission()) {
163  // disallow attribute musn't be written
164  if (attrProperty.getAttr() != SUMO_ATTR_DISALLOW) {
165  writePermissions(device, parseVehicleClasses(attributeValue));
166  }
167  } else if (myTagProperty.canMaskXYZPositions() && (attrProperty.getAttr() == SUMO_ATTR_POSITION)) {
168  // get position attribute and write it separate
169  Position pos = parse<Position>(getAttribute(SUMO_ATTR_POSITION));
170  device.writeAttr(SUMO_ATTR_X, toString(pos.x()));
171  device.writeAttr(SUMO_ATTR_Y, toString(pos.y()));
172  // write 0 only if is different from 0 (the default value)
173  if (pos.z() != 0) {
174  device.writeAttr(SUMO_ATTR_Z, toString(pos.z()));
175  }
176  } else {
177  device.writeAttr(attrProperty.getAttr(), attributeValue);
178  }
179  }
180  }
181  }
182  // iterate over children and write it in XML (or in a different file)
184  // we assume that rerouter values files is placed in the same folder as the additional file
186  deviceChildren.writeXMLHeader("rerouterValue", "additional_file.xsd");
187  // save children in a different filename
188  for (const auto& additionalChild : getChildAdditionals()) {
189  // avoid to write two times additionals that haben two parents (Only write as child of first parent)
190  if (additionalChild->getParentAdditionals().size() < 1) {
191  additionalChild->writeAdditional(deviceChildren);
192  } else if (myTagProperty.getTag() == additionalChild->getTagProperty().getMasterTags().front()) {
193  additionalChild->writeAdditional(deviceChildren);
194  }
195  }
196  deviceChildren.close();
197  } else {
198  for (const auto& additionalChild : getChildAdditionals()) {
199  // avoid write symbols
200  if (!additionalChild->getTagProperty().isSymbol()) {
201  // avoid to write two times additionals that haben two parents (Only write as child of first parent)
202  if (additionalChild->getParentAdditionals().size() < 2) {
203  additionalChild->writeAdditional(device);
204  } else if (myTagProperty.getTag() == additionalChild->getTagProperty().getMasterTags().front()) {
205  additionalChild->writeAdditional(device);
206  }
207  }
208  }
209  }
210  // write parameters (Always after children to avoid problems with additionals.xsd)
211  writeParams(device);
212  // Close tag
213  device.closeTag();
214  }
215 }
216 
217 
218 bool
220  return true;
221 }
222 
223 
224 std::string
226  return "";
227 }
228 
229 
230 void
232  throw InvalidArgument(getTagStr() + " cannot fix any problem");
233 }
234 
235 
236 void
238  throw InvalidArgument(getTagStr() + " doesn't have an additional dialog");
239 }
240 
241 
242 Boundary
244  return myBoundary;
245 }
246 
247 
248 Position
250  return myBoundary.getCenter();
251 }
252 
253 
254 bool
256  return myBlockMovement;
257 }
258 
259 
260 void
262  // currently only for E2 Multilane Detectors
264  // declare extreme geometry
265  GNEGeometry::ExtremeGeometry extremeGeometry;
266  // get extremes
267  extremeGeometry.laneStartPosition = GNEAttributeCarrier::parse<double>(getAttribute(SUMO_ATTR_POSITION));
268  extremeGeometry.laneEndPosition = GNEAttributeCarrier::parse<double>(getAttribute(SUMO_ATTR_ENDPOS));
269  // update geometry path for the given lane
271  }
272 }
273 
274 
277  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
278  // build header
279  buildPopupHeader(ret, app);
280  // build menu command for center button and copy cursor position to clipboard
282  buildPositionCopyEntry(ret, false);
283  // buld menu commands for names
284  GUIDesigns::buildFXMenuCommand(ret, "Copy " + getTagStr() + " name to clipboard", nullptr, ret, MID_COPY_NAME);
285  GUIDesigns::buildFXMenuCommand(ret, "Copy " + getTagStr() + " typed name to clipboard", nullptr, ret, MID_COPY_TYPED_NAME);
286  new FXMenuSeparator(ret);
287  // build selection and show parameters menu
290  // show option to open additional dialog
291  if (myTagProperty.hasDialog()) {
292  GUIDesigns::buildFXMenuCommand(ret, "Open " + getTagStr() + " Dialog", getIcon(), &parent, MID_OPEN_ADDITIONAL_DIALOG);
293  new FXMenuSeparator(ret);
294  }
295  // Show position parameters
298  // Show menu command inner position
300  GUIDesigns::buildFXMenuCommand(ret, "Cursor position over additional shape: " + toString(innerPos), nullptr, nullptr, 0);
301  // If shape isn't empty, show menu command lane position
302  if (myAdditionalGeometry.getShape().size() > 0) {
303  const double lanePos = lane->getLaneShape().nearest_offset_to_point2D(myAdditionalGeometry.getShape().front());
304  GUIDesigns::buildFXMenuCommand(ret, "Cursor position over " + toString(SUMO_TAG_LANE) + ": " + toString(innerPos + lanePos), nullptr, nullptr, 0);
305  }
308  // Show menu command inner position
310  GUIDesigns::buildFXMenuCommand(ret, "Cursor position over additional shape: " + toString(innerPos), nullptr, nullptr, 0);
311  // If shape isn't empty, show menu command edge position
312  if (myAdditionalGeometry.getShape().size() > 0) {
313  const double edgePos = edge->getLanes().at(0)->getLaneShape().nearest_offset_to_point2D(myAdditionalGeometry.getShape().front());
314  GUIDesigns::buildFXMenuCommand(ret, "Mouse position over " + toString(SUMO_TAG_EDGE) + ": " + toString(innerPos + edgePos), nullptr, nullptr, 0);
315  }
316  } else {
317  GUIDesigns::buildFXMenuCommand(ret, "Cursor position in view: " + toString(getPositionInView().x()) + "," + toString(getPositionInView().y()), nullptr, nullptr, 0);
318  }
319  return ret;
320 }
321 
322 
325  // Create table
326  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
327  // Iterate over attributes
328  for (const auto& i : myTagProperty) {
329  // Add attribute and set it dynamic if aren't unique
330  if (i.isUnique()) {
331  ret->mkItem(i.getAttrStr().c_str(), false, getAttribute(i.getAttr()));
332  } else {
333  ret->mkItem(i.getAttrStr().c_str(), true, getAttribute(i.getAttr()));
334  }
335  }
336  // close building
337  ret->closeBuilding();
338  return ret;
339 }
340 
341 
342 const std::string&
344  return myAdditionalName;
345 }
346 
347 
348 void
349 GNEAdditional::drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const double offsetFront) const {
350  // calculate E2Detector width
351  const double E2DetectorWidth = s.addSize.getExaggeration(s, lane);
352  // check if E2 can be drawn
353  if (s.drawAdditionals(E2DetectorWidth) && myNet->getViewNet()->getDataViewOptions().showAdditionals()) {
354  // obtain color
356  // Start drawing adding an gl identificator
357  glPushName(getGlID());
358  // Add a draw matrix
359  glPushMatrix();
360  // Start with the drawing of the area traslating matrix to origin
361  glTranslated(0, 0, getType() + offsetFront);
362  // iterate over segments
363  for (const auto& segment : myAdditionalSegmentGeometry) {
364  // draw partial segment
365  if (segment.isLaneSegment() && (segment.getLane() == lane)) {
366  // Set route color (needed due drawShapeDottedContour)
367  GLHelper::setColor(routeColor);
368  // draw box lines
369  GNEGeometry::drawSegmentGeometry(myNet->getViewNet(), segment, E2DetectorWidth);
370  }
371  }
372  // Pop last matrix
373  glPopMatrix();
374  // draw additional ID
375  if (!s.drawForRectangleSelection) {
376  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
377  }
378  // Pop name
379  glPopName();
380  // check if shape dotted contour has to be drawn
382  // iterate over segments
383  for (const auto& segment : myAdditionalSegmentGeometry) {
384  if (segment.isLaneSegment() && (segment.getLane() == lane)) {
385  // draw partial segment
386  if (getParentLanes().front() == lane) {
387  // draw front dotted contour
388  GNEGeometry::drawDottedContourLane(GNEGeometry::DottedContourType::INSPECT, s, GNEGeometry::DottedGeometry(s, segment.getShape(), false), E2DetectorWidth, true, false);
389  } else if (getParentLanes().back() == lane) {
390  // draw back dotted contour
391  GNEGeometry::drawDottedContourLane(GNEGeometry::DottedContourType::INSPECT, s, GNEGeometry::DottedGeometry(s, segment.getShape(), false), E2DetectorWidth, false, true);
392  } else {
393  // draw dotted contour
395  }
396  }
397  }
398  }
399  }
400 }
401 
402 
403 void
404 GNEAdditional::drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const double offsetFront) const {
405  // calculate E2Detector width
406  const double E2DetectorWidth = s.addSize.getExaggeration(s, fromLane);
407  // check if E2 can be drawn
408  if (s.drawAdditionals(E2DetectorWidth) && myNet->getViewNet()->getDataViewOptions().showAdditionals()) {
409  // Start drawing adding an gl identificator
410  glPushName(getGlID());
411  // Add a draw matrix
412  glPushMatrix();
413  // Start with the drawing of the area traslating matrix to origin
414  glTranslated(0, 0, getType() + offsetFront);
415  // Set color of the base
416  if (drawUsingSelectColor()) {
418  } else {
420  }
421  // draw lane2lane
422  if (fromLane->getLane2laneConnections().exist(toLane)) {
424  } else {
425  // Set invalid person plan color
427  // draw line between end of first shape and first position of second shape
428  GLHelper::drawBoxLines({fromLane->getLaneShape().back(), toLane->getLaneShape().front()}, (0.5 * E2DetectorWidth));
429  }
430  // Pop last matrix
431  glPopMatrix();
432  // Pop name
433  glPopName();
434  // check if shape dotted contour has to be drawn
436  // draw lane2lane dotted geometry
437  if (fromLane->getLane2laneConnections().exist(toLane)) {
439  }
440  }
441  }
442 }
443 
444 // ---------------------------------------------------------------------------
445 // GNEAdditional - protected methods
446 // ---------------------------------------------------------------------------
447 
448 void
450  // iterate over attributes and set default value
451  for (const auto& i : myTagProperty) {
452  if (i.hasStaticDefaultValue()) {
453  setAttribute(i.getAttr(), i.getDefaultValue());
454  }
455  }
456 }
457 
458 
459 bool
460 GNEAdditional::isValidAdditionalID(const std::string& newID) const {
461  if (SUMOXMLDefinitions::isValidAdditionalID(newID) && (myNet->retrieveAdditional(myTagProperty.getTag(), newID, false) == nullptr)) {
462  return true;
463  } else {
464  return false;
465  }
466 }
467 
468 
469 bool
470 GNEAdditional::isValidDetectorID(const std::string& newID) const {
471  if (SUMOXMLDefinitions::isValidDetectorID(newID) && (myNet->retrieveAdditional(myTagProperty.getTag(), newID, false) == nullptr)) {
472  return true;
473  } else {
474  return false;
475  }
476 }
477 
478 
479 void
482  // calculate middle point
483  const double middlePoint = (myAdditionalGeometry.getShape().length2D() * 0.5);
484  // calculate position
486  // calculate rotation
487  const double rot = (myAdditionalGeometry.getShape().size() == 1) ? myAdditionalGeometry.getShapeRotations().front() : myAdditionalGeometry.getShape().rotationDegreeAtOffset(middlePoint);
488  // draw additional ID
491  } else {
493  }
494  }
495 }
496 
497 
498 void
501  // calculate middle point
502  const double middlePoint = (myAdditionalGeometry.getShape().length2D() * 0.5);
503  // calculate position
505  // calculate rotation
506  const double rot = (myAdditionalGeometry.getShape().size() == 1) ? myAdditionalGeometry.getShapeRotations().front() : myAdditionalGeometry.getShape().rotationDegreeAtOffset(middlePoint);
507  // draw additional name
510  } else {
512  }
513  }
514 }
515 
516 
517 void
519  replaceParentElements(this, parse<std::vector<GNEEdge*> >(getNet(), value));
520 }
521 
522 
523 void
525  replaceParentElements(this, parse<std::vector<GNELane*> >(getNet(), value));
526 }
527 
528 
529 void
531  replaceChildElements(this, parse<std::vector<GNEEdge*> >(getNet(), value));
532 }
533 
534 
535 void
537  replaceChildElements(this, parse<std::vector<GNELane*> >(getNet(), value));
538 }
539 
540 
541 void
542 GNEAdditional::replaceAdditionalParent(SumoXMLTag tag, const std::string& value, const int parentIndex) {
543  std::vector<GNEAdditional*> parentAdditionals = getParentAdditionals();
544  parentAdditionals[parentIndex] = myNet->retrieveAdditional(tag, value);
545  // replace parent additionals
546  replaceParentElements(this, parentAdditionals);
547 }
548 
549 
550 void
551 GNEAdditional::replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex) {
552  std::vector<GNEDemandElement*> parentDemandElements = getParentDemandElements();
553  parentDemandElements[parentIndex] = myNet->retrieveDemandElement(tag, value);
554  // replace parent demand elements
555  replaceParentElements(this, parentDemandElements);
556 }
557 
558 
559 void
560 GNEAdditional::calculatePerpendicularLine(const double endLaneposition) {
561  if (getParentEdges().empty()) {
562  throw ProcessError("Invalid number of edges");
563  } else {
564  // get lanes
565  const GNELane* firstLane = getParentEdges().front()->getLanes().front();
566  const GNELane* lastLane = getParentEdges().front()->getLanes().back();
567  // get first and back lane shapes
568  PositionVector firstLaneShape = firstLane->getLaneShape();
569  PositionVector lastLaneShape = lastLane->getLaneShape();
570  // move shapes
571  firstLaneShape.move2side((firstLane->getParentEdge()->getNBEdge()->getLaneWidth(firstLane->getIndex()) * 0.5) + 1);
572  lastLaneShape.move2side(lastLane->getParentEdge()->getNBEdge()->getLaneWidth(lastLane->getIndex()) * -0.5);
573  // calculate lane postion
574  const double lanePosition = firstLaneShape.length2D() >= endLaneposition ? endLaneposition : firstLaneShape.length2D();
575  // update geometry
576  myAdditionalGeometry.updateGeometry({firstLaneShape.positionAtOffset2D(lanePosition), lastLaneShape.positionAtOffset2D(lanePosition)});
577  }
578 }
579 
580 
581 void
583  //
584 }
585 
586 
587 void
589  //
590 }
591 
592 
593 const std::map<std::string, std::string>&
595  return getParametersMap();
596 }
597 
598 
599 bool
601  // throw exception because this function mus be implemented in child (see GNEE3Detector)
602  throw ProcessError("Calling non-implemented function checkChildAdditionalRestriction during saving of " + getTagStr() + ". It muss be reimplemented in child class");
603 }
604 
605 
606 void
607 GNEAdditional::setEnabledAttribute(const int /*enabledAttributes*/) {
608  //
609 }
610 
611 
612 /****************************************************************************/
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:403
@ MID_OPEN_ADDITIONAL_DIALOG
open additional dialog (used in netedit)
Definition: GUIAppEnum.h:411
@ MID_COPY_NAME
Copy object name - popup entry.
Definition: GUIAppEnum.h:401
GUIGlObjectType
@ GLO_MAX
empty max
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
void writePermissions(OutputDevice &into, SVCPermissions permissions)
writes allowed disallowed attributes if needed;
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_E2DETECTOR_MULTILANE
an e2 detector over multiple lanes (used by Netedit)
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_LANE
@ SUMO_ATTR_FILE
@ SUMO_ATTR_Y
@ SUMO_ATTR_Z
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_X
@ SUMO_ATTR_POSITION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
Position getCenter() const
Returns the center of the boundary.
Definition: Boundary.cpp:111
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
Definition: FileHelpers.cpp:75
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:446
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:181
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
Definition: GLHelper.cpp:498
bool isAdditionalBlocked() const
Check if additional item is currently blocked (i.e. cannot be moved with mouse)
const std::string & getID() const
get ID
virtual std::string getAttribute(SumoXMLAttr key) const =0
virtual bool isAdditionalValid() const
check if current additional is valid to be writed into XML (by default true, can be reimplemented in ...
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
void updatePartialGeometry(const GNELane *lane)
partial update pre-computed geometry information
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
void replaceAdditionalParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace additional parent
GNEGeometry::Geometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
virtual void openAdditionalDialog()
open Additional Dialog
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
void replaceAdditionalChildLanes(const std::string &value)
replace additional child lanes
void replaceAdditionalParentEdges(const std::string &value)
replace additional parent edges
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Position getPositionInView() const
Returns position of additional in view.
void calculatePerpendicularLine(const double endLaneposition)
calculate perpendicular line between lane parents
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
std::string myAdditionalName
name of additional
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
Boundary myBoundary
Additional Boundary.
virtual void fixAdditionalProblem()
fix additional problem (by default throw an exception, has to be reimplemented in children)
void setSpecialColor(const RGBColor *color)
set special color
const RGBColor * mySpecialColor
pointer to special color (used for drawing Additional with a certain color, mainly used for selection...
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes
virtual bool checkChildAdditionalRestriction() const
check restriction with the number of children
GNEGeometry::SegmentGeometry myAdditionalSegmentGeometry
segment geometry to be precomputed in updateGeometry(...) (used by E2Multilane)
const GNEGeometry::SegmentGeometry & getAdditionalSegmentGeometry() const
obtain additional segment geometry
void replaceAdditionalChildEdges(const std::string &value)
replace additional child edges
GNEAdditional(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement, const std::vector< GNEJunction * > &junctionParents, const std::vector< GNEEdge * > &edgeParents, const std::vector< GNELane * > &laneParents, const std::vector< GNEAdditional * > &additionalParents, const std::vector< GNEShape * > &shapeParents, const std::vector< GNETAZElement * > &TAZElementParents, const std::vector< GNEDemandElement * > &demandElementParents, const std::vector< GNEGenericData * > &genericDataParents)
Constructor.
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
void writeAdditional(OutputDevice &device) const
writte additional element into a xml file
virtual ~GNEAdditional()
Destructor.
const std::string & getOptionalAdditionalName() const
Returns the additional name.
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position (Currently unused in shapes)
const GNEGeometry::Geometry & getAdditionalGeometry() const
obtain additional geometry
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
void setDefaultValues()
change all attributes of additional with their default values (note: this cannot be undo)
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const double offsetFront) const
Draws partial object (lane)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
virtual std::string getAdditionalProblem() const
return a string with the current additional problem (by default empty, can be reimplemented in childr...
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
const std::string & getTagStr() const
get tag assigned to this object in string format
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
FXIcon * getIcon() const
get FXIcon associated to this AC
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
const GNETagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:399
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:723
class for pack all variables related with DottedGeometry
Definition: GNEGeometry.h:187
class for NETEDIT geometries over lanes
Definition: GNEGeometry.h:76
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, double startPos=-1, double endPos=-1, const Position &extraFirstPosition=Position::INVALID, const Position &extraLastPosition=Position::INVALID)
update geometry shape
Definition: GNEGeometry.cpp:81
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given tolane
const GNEGeometry::Geometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
const GNEGeometry::DottedGeometry & getLane2laneDottedGeometry(const GNELane *toLane) const
get lane2lane dotted geometry
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
const std::vector< GNEAdditional * > & getChildAdditionals() const
return child additionals
void replaceParentElements(T *elementChild, const U &newParents)
replace parent elements
void replaceChildElements(T *elementChild, const U &newChildren)
replace child elements
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
const PositionVector & getLaneShape() const
Definition: GNELane.cpp:117
const GNEGeometry::DottedGeometry & getDottedLaneGeometry() const
get dotted lane geometry
Definition: GNELane.cpp:135
const GNEGeometry::Lane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:774
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:733
GNEEdge * getParentEdge() const
get arent edge
Definition: GNELane.cpp:111
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
Definition: GNENet.cpp:1337
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true) const
get edge by id
Definition: GNENet.cpp:1141
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
Definition: GNENet.cpp:2316
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
Definition: GNENet.cpp:2435
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2245
An special type of Attribute carrier that owns hierarchical elements.
bool canMaskXYZPositions() const
return true if tag correspond to an element that can mask the attributes "X", "Y" and "Z" position as...
bool hasTagSynonym() const
return true if tag correspond to an element that will be written in XML with another tag
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool hasMinimumNumberOfChildren() const
return true if tag correspond to an element that only have a limited number of children
bool canWriteChildrenSeparate() const
return true if tag correspond to an element that can write their child in a different file
SumoXMLTag getTagSynonym() const
get tag synonym
bool hasDialog() const
return true if tag correspond to an element that can be edited using a dialog
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute "attr"
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:491
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:368
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:40
The popup menu of a globject.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
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 buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIGlID getGlID() const
Returns the numerical id of the object.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
GUIVisualizationSizeSettings addSize
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
GUIVisualizationTextSettings addFullName
bool drawDottedContour() const
check if dotted contour can be drawn
bool drawAdditionals(const double exaggeration) const
check if additionals must be drawn
GUIVisualizationColorSettings colorSettings
color settings
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationDetectorSettings detectorSettings
Detector settings.
double getTextAngle(double objectAngle) const
return an angle that is suitable for reading text aligned with the given angle (degrees)
double getLaneWidth() const
Returns the default width of lanes of this edge.
Definition: NBEdge.h:605
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
void close()
Closes the device and removes it from the dictionary.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:239
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
double x() const
Returns the x-position.
Definition: Position.h:54
double z() const
Returns the z-position.
Definition: Position.h:64
double y() const
Returns the y-position.
Definition: Position.h:59
A list of positions.
double length2D() const
Returns the length.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const RGBColor RED
named colors
Definition: RGBColor.h:180
static bool isValidAdditionalID(const std::string &value)
whether the given string is a valid id for an additional object
static bool isValidDetectorID(const std::string &value)
whether the given string is a valid id for an detector
struct for variables used in Geometry extremes
Definition: GNEGeometry.h:58
double laneEndPosition
arrival position over lane
Definition: GNEGeometry.h:66
double laneStartPosition
depart position over lane
Definition: GNEGeometry.h:63
struct for pack all variables related with geometry of elemements divided in segments
Definition: GNEGeometry.h:261
static void drawDottedContourLane(const DottedContourType type, const GUIVisualizationSettings &s, const DottedGeometry &dottedGeometry, const double width, const bool drawFirstExtrem, const bool drawLastExtrem)
draw dotted contour for the given dottedGeometry (used by lanes, routes, etc.)
static void updateGeometricPath(GNEGeometry::SegmentGeometry &segmentGeometry, const GNELane *lane, GNEGeometry::ExtremeGeometry &extremeGeometry)
calculate route between edges
static void drawSegmentGeometry(const GNEViewNet *viewNet, const SegmentGeometry::Segment &segment, const double width)
draw geometry segment
static void drawGeometry(const GNEViewNet *viewNet, const Geometry &geometry, const double width)
draw geometry
bool showAdditionals() const
check if additionals has to be drawn
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const RGBColor E2Color
color for E2 detectors
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
double scaledSize(double scale, double constFactor=0.1) const
get scale size