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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A abstract class for representation of additional elements
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #include <netedit/GNENet.h>
24 #include <netedit/GNEViewNet.h>
25 #include <netedit/GNEViewParent.h>
38 
39 #include "GNEAdditional.h"
40 
41 // ===========================================================================
42 // member method definitions
43 // ===========================================================================
44 
45 // ---------------------------------------------------------------------------
46 // GNEAdditional::AdditionalGeometry - methods
47 // ---------------------------------------------------------------------------
48 
50 
51 
52 void
54  shape.clear();
55  multiShape.clear();
56  shapeRotations.clear();
57  shapeLengths.clear();
58  multiShapeRotations.clear();
59  multiShapeLengths.clear();
60  multiShapeUnified.clear();
61 }
62 
63 
64 void
66  // merge all multishape parts in a single shape
67  for (auto i : multiShape) {
69  }
70 }
71 
72 
73 void
75  // Get number of parts of the shape
76  int numberOfSegments = (int)shape.size() - 1;
77  // If number of segments is more than 0
78  if (numberOfSegments >= 0) {
79  // Reserve memory (To improve efficiency)
80  shapeRotations.reserve(numberOfSegments);
81  shapeLengths.reserve(numberOfSegments);
82  // For every part of the shape
83  for (int i = 0; i < numberOfSegments; ++i) {
84  // Obtain first position
85  const Position& f = shape[i];
86  // Obtain next position
87  const Position& s = shape[i + 1];
88  // Save distance between position into myShapeLengths
89  shapeLengths.push_back(f.distanceTo(s));
90  // Save rotation (angle) of the vector constructed by points f and s
91  shapeRotations.push_back((double)atan2((s.x() - f.x()), (f.y() - s.y())) * (double) 180.0 / (double)M_PI);
92  }
93  }
94 }
95 
96 
97 void
99  // Get number of parts of the shape for every part shape
100  std::vector<int> numberOfSegments;
101  for (auto i : multiShape) {
102  // numseg cannot be 0
103  int numSeg = (int)i.size() - 1;
104  numberOfSegments.push_back((numSeg >= 0) ? numSeg : 0);
105  multiShapeRotations.push_back(std::vector<double>());
106  multiShapeLengths.push_back(std::vector<double>());
107  }
108  // If number of segments is more than 0
109  for (int i = 0; i < (int)multiShape.size(); i++) {
110  // Reserve size for every part
111  multiShapeRotations.back().reserve(numberOfSegments.at(i));
112  multiShapeLengths.back().reserve(numberOfSegments.at(i));
113  // iterate over each segment
114  for (int j = 0; j < numberOfSegments.at(i); j++) {
115  // Obtain first position
116  const Position& f = multiShape[i][j];
117  // Obtain next position
118  const Position& s = multiShape[i][j + 1];
119  // Save distance between position into myShapeLengths
120  multiShapeLengths.at(i).push_back(f.distanceTo(s));
121  // Save rotation (angle) of the vector constructed by points f and s
122  multiShapeRotations.at(i).push_back((double)atan2((s.x() - f.x()), (f.y() - s.y())) * (double) 180.0 / (double)M_PI);
123  }
124  }
125 }
126 
127 // ---------------------------------------------------------------------------
128 // GNEAdditional - methods
129 // ---------------------------------------------------------------------------
130 
131 GNEAdditional::GNEAdditional(const std::string& id, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement,
132  const std::vector<GNEEdge*>& edgeParents,
133  const std::vector<GNELane*>& laneParents,
134  const std::vector<GNEShape*>& shapeParents,
135  const std::vector<GNEAdditional*>& additionalParents,
136  const std::vector<GNEDemandElement*>& demandElementParents,
137  const std::vector<GNEEdge*>& edgeChildren,
138  const std::vector<GNELane*>& laneChildren,
139  const std::vector<GNEShape*>& shapeChildren,
140  const std::vector<GNEAdditional*>& additionalChildren,
141  const std::vector<GNEDemandElement*>& demandElementChildren) :
142  GUIGlObject(type, id),
143  GNEAttributeCarrier(tag),
144  Parameterised(),
145  GNEHierarchicalElementParents(this, edgeParents, laneParents, shapeParents, additionalParents, demandElementParents),
146  GNEHierarchicalElementChildren(this, edgeChildren, laneChildren, shapeChildren, additionalChildren, demandElementChildren),
147  myViewNet(viewNet),
148  myAdditionalName(additionalName),
149  myBlockMovement(blockMovement),
150  myBlockIcon(this),
151  mySpecialColor(nullptr) {
152 }
153 
154 
155 GNEAdditional::GNEAdditional(GNEAdditional* additionalParent, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement,
156  const std::vector<GNEEdge*>& edgeParents,
157  const std::vector<GNELane*>& laneParents,
158  const std::vector<GNEShape*>& shapeParents,
159  const std::vector<GNEAdditional*>& additionalParents,
160  const std::vector<GNEDemandElement*>& demandElementParents,
161  const std::vector<GNEEdge*>& edgeChildren,
162  const std::vector<GNELane*>& laneChildren,
163  const std::vector<GNEShape*>& shapeChildren,
164  const std::vector<GNEAdditional*>& additionalChildren,
165  const std::vector<GNEDemandElement*>& demandElementChildren) :
166  GUIGlObject(type, additionalParent->generateChildID(tag)),
167  GNEAttributeCarrier(tag),
168  Parameterised(),
169  GNEHierarchicalElementParents(this, edgeParents, laneParents, shapeParents, additionalParents, demandElementParents),
170  GNEHierarchicalElementChildren(this, edgeChildren, laneChildren, shapeChildren, additionalChildren, demandElementChildren),
171  myViewNet(viewNet),
172  myAdditionalName(additionalName),
173  myBlockMovement(blockMovement),
174  myBlockIcon(this),
175  mySpecialColor(nullptr) {
176 }
177 
178 
180 
181 
182 std::string
184  int counter = (int)getAdditionalChildren().size();
185  while (myViewNet->getNet()->retrieveAdditional(childTag, getID() + toString(childTag) + toString(counter), false) != nullptr) {
186  counter++;
187  }
188  return (getID() + toString(childTag) + toString(counter));
189 }
190 
191 
194  return myGeometry;
195 }
196 
197 
198 void
200  mySpecialColor = color;
201 }
202 
203 
204 void
206  // first check if minimum number of children is correct
208  WRITE_WARNING(getTagStr() + " with ID='" + getID() + "' cannot be written");
209  } else {
210  // Open Tag or synonym Tag
213  } else {
214  device.openTag(myTagProperty.getTag());
215  }
216  // iterate over attributes and write it
217  for (auto i : myTagProperty) {
218  // obtain attribute
219  std::string attribute = getAttribute(i.getAttr());
220  if (i.isWriteXMLOptional() && !i.isCombinable()) {
221  // Only write attributes with default value if is different from original
222  if (i.getDefaultValue() != attribute) {
223  // check if attribute must be written using a synonim
224  if (i.hasAttrSynonym()) {
225  device.writeAttr(i.getAttrSynonym(), attribute);
226  } else {
227  // SVC permissions uses their own writting function
228  if (i.isSVCPermission()) {
229  // disallow attribute musn't be written
230  if (i.getAttr() != SUMO_ATTR_DISALLOW) {
231  writePermissions(device, parseVehicleClasses(attribute));
232  }
233  } else if (myTagProperty.canMaskXYZPositions() && (i.getAttr() == SUMO_ATTR_POSITION)) {
234  // get position attribute and write it separate
235  Position pos = parse<Position>(getAttribute(SUMO_ATTR_POSITION));
236  device.writeAttr(SUMO_ATTR_X, toString(pos.x()));
237  device.writeAttr(SUMO_ATTR_Y, toString(pos.y()));
238  // write 0 only if is different from 0 (the default value)
239  if (pos.z() != 0) {
240  device.writeAttr(SUMO_ATTR_Z, toString(pos.z()));
241  }
242  } else {
243  device.writeAttr(i.getAttr(), attribute);
244  }
245  }
246  }
247  } else {
248  // Attributes without default values are always writted
249  if (i.hasAttrSynonym()) {
250  device.writeAttr(i.getAttrSynonym(), attribute);
251  } else {
252  // SVC permissions uses their own writting function
253  if (i.isSVCPermission()) {
254  // disallow attribute musn't be written
255  if (i.getAttr() != SUMO_ATTR_DISALLOW) {
256  writePermissions(device, parseVehicleClasses(attribute));
257  }
258  } else if (myTagProperty.canMaskXYZPositions() && (i.getAttr() == SUMO_ATTR_POSITION)) {
259  // get position attribute and write it separate
260  Position pos = parse<Position>(getAttribute(SUMO_ATTR_POSITION));
261  device.writeAttr(SUMO_ATTR_X, toString(pos.x()));
262  device.writeAttr(SUMO_ATTR_Y, toString(pos.y()));
263  // write 0 only if is different from 0 (the default value)
264  if (pos.z() != 0) {
265  device.writeAttr(SUMO_ATTR_Z, toString(pos.z()));
266  }
267  } else {
268  device.writeAttr(i.getAttr(), attribute);
269  }
270  }
271  }
272  }
273  // iterate over children and write it in XML (or in a different file)
274  if (myTagProperty.canWriteChildrenSeparate() && myTagProperty.hasAttribute(SUMO_ATTR_FILE) && !getAttribute(SUMO_ATTR_FILE).empty()) {
275  // we assume that rerouter values files is placed in the same folder as the additional file
277  deviceChildren.writeXMLHeader("rerouterValue", "additional_file.xsd");
278  // save children in a different filename
279  for (auto i : getAdditionalChildren()) {
280  // avoid to write two times additionals that haben two parents (Only write as child of first parent)
281  if (i->getAdditionalParents().size() < 1) {
282  i->writeAdditional(deviceChildren);
283  } else if (myTagProperty.getTag() == i->getTagProperty().getParentTag()) {
284  i->writeAdditional(deviceChildren);
285  }
286  }
287  deviceChildren.close();
288  } else {
289  for (auto i : getAdditionalChildren()) {
290  // avoid to write two times additionals that haben two parents (Only write as child of first parent)
291  if (i->getAdditionalParents().size() < 2) {
292  i->writeAdditional(device);
293  } else if (myTagProperty.getTag() == i->getTagProperty().getParentTag()) {
294  i->writeAdditional(device);
295  }
296  }
297  }
298  // save generic parameters (Always after children to avoid problems with additionals.xsd)
299  writeParams(device);
300  // Close tag
301  device.closeTag();
302  }
303 }
304 
305 
306 bool
308  return true;
309 }
310 
311 
312 std::string
314  return "";
315 }
316 
317 
318 void
320  throw InvalidArgument(getTagStr() + " cannot fix any problem");
321 }
322 
323 
324 void
326  throw InvalidArgument(getTagStr() + " doesn't have an additional dialog");
327 }
328 
329 
330 void
332  // only move if additional is drawable
333  if (myTagProperty.isDrawable()) {
334  // always save original position over view
336  // check if position over lane or lanes has to be saved
339  // obtain start and end position
342  } else {
343  // obtain position attribute
345  }
349  // obtain start and end position
352  }
353  // save current centering boundary if element is placed in RTree
356  }
357  // start geometry in all children
358  for (const auto& i : getDemandElementChildren()) {
359  i->startGeometryMoving();
360  }
361  }
362 }
363 
364 
365 void
367  // check that endGeometryMoving was called only once
368  if (myTagProperty.isDrawable()) {
369  // check if object must be placed in RTREE
371  // Remove object from net
373  // reset myMovingGeometryBoundary
375  // add object into grid again (using the new centering boundary)
377  }
378  // end geometry in all children
379  for (const auto& i : getDemandElementChildren()) {
380  i->endGeometryMoving();
381  }
382  }
383 }
384 
385 
386 GNEViewNet*
388  return myViewNet;
389 }
390 
391 
394  return myGeometry.shape;
395 }
396 
397 
398 bool
400  return myBlockMovement;
401 }
402 
403 
406  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
407  // build header
408  buildPopupHeader(ret, app);
409  // build menu command for center button and copy cursor position to clipboard
411  buildPositionCopyEntry(ret, false);
412  // buld menu commands for names
413  new FXMenuCommand(ret, ("Copy " + getTagStr() + " name to clipboard").c_str(), nullptr, ret, MID_COPY_NAME);
414  new FXMenuCommand(ret, ("Copy " + getTagStr() + " typed name to clipboard").c_str(), nullptr, ret, MID_COPY_TYPED_NAME);
415  new FXMenuSeparator(ret);
416  // build selection and show parameters menu
419  // show option to open additional dialog
420  if (myTagProperty.hasDialog()) {
421  new FXMenuCommand(ret, ("Open " + getTagStr() + " Dialog").c_str(), getIcon(), &parent, MID_OPEN_ADDITIONAL_DIALOG);
422  new FXMenuSeparator(ret);
423  }
424  // Show position parameters
427  // Show menu command inner position
428  const double innerPos = myGeometry.shape.nearest_offset_to_point2D(parent.getPositionInformation());
429  new FXMenuCommand(ret, ("Cursor position inner additional: " + toString(innerPos)).c_str(), nullptr, nullptr, 0);
430  // If shape isn't empty, show menu command lane position
431  if (myGeometry.shape.size() > 0) {
432  const double lanePos = lane->getGeometry().shape.nearest_offset_to_point2D(myGeometry.shape[0]);
433  new FXMenuCommand(ret, ("Cursor position over " + toString(SUMO_TAG_LANE) + ": " + toString(innerPos + lanePos)).c_str(), nullptr, nullptr, 0);
434  }
437  // Show menu command inner position
438  const double innerPos = myGeometry.shape.nearest_offset_to_point2D(parent.getPositionInformation());
439  new FXMenuCommand(ret, ("Cursor position inner additional: " + toString(innerPos)).c_str(), nullptr, nullptr, 0);
440  // If shape isn't empty, show menu command edge position
441  if (myGeometry.shape.size() > 0) {
442  const double edgePos = edge->getLanes().at(0)->getGeometry().shape.nearest_offset_to_point2D(myGeometry.shape[0]);
443  new FXMenuCommand(ret, ("Mouse position over " + toString(SUMO_TAG_EDGE) + ": " + toString(innerPos + edgePos)).c_str(), nullptr, nullptr, 0);
444  }
445  } else {
446  new FXMenuCommand(ret, ("Cursor position in view: " + toString(getPositionInView().x()) + "," + toString(getPositionInView().y())).c_str(), nullptr, nullptr, 0);
447  }
448  return ret;
449 }
450 
451 
454  // Create table
456  // Iterate over attributes
457  for (const auto& i : myTagProperty) {
458  // Add attribute and set it dynamic if aren't unique
459  if (i.isUnique()) {
460  ret->mkItem(i.getAttrStr().c_str(), false, getAttribute(i.getAttr()));
461  } else {
462  ret->mkItem(i.getAttrStr().c_str(), true, getAttribute(i.getAttr()));
463  }
464  }
465  // close building
466  ret->closeBuilding();
467  return ret;
468 }
469 
470 /*
471 Boundary
472 GNEAdditional::getCenteringBoundary() const {
473  // Return Boundary depending if myMovingGeometryBoundary is initialised (important for move geometry)
474  if (myMove.movingGeometryBoundary.isInitialised()) {
475  return myMove.movingGeometryBoundary;
476  } else if (myGeometry.shape.size() > 0) {
477  Boundary b = myGeometry.shape.getBoxBoundary();
478  b.grow(20);
479  return b;
480  } else if (myGeometry.multiShape.size() > 0) {
481  // obtain boundary of multishape fixed
482  Boundary b = myGeometry.multiShapeUnified.getBoxBoundary();
483  b.grow(20);
484  return b;
485  } else if (getAdditionalParents().size() > 0) {
486  return getAdditionalParents().at(0)->getCenteringBoundary();
487  } else {
488  return Boundary(-0.1, -0.1, 0.1, 0.1);
489  }
490 }
491 */
492 // ---------------------------------------------------------------------------
493 // GNEAdditional::BlockIcon - methods
494 // ---------------------------------------------------------------------------
495 
497  rotation(0.),
498  myAdditional(additional) {}
499 
500 
501 void
503  if (myAdditional->myGeometry.shape.size() > 0 && myAdditional->myGeometry.shape.length() != 0) {
504  // If length of the shape is distint to 0, Obtain rotation of center of shape
506  } else if (additionalLane) {
507  // If additional is over a lane, set rotation in the position over lane
508  double posOverLane = additionalLane->getGeometry().shape.nearest_offset_to_point2D(myAdditional->getPositionInView());
509  rotation = additionalLane->getGeometry().shape.rotationDegreeAtOffset(posOverLane) - 90;
510  } else {
511  // In other case, rotation is 0
512  rotation = 0;
513  }
514 }
515 
516 
517 void
518 GNEAdditional::BlockIcon::drawIcon(const GUIVisualizationSettings& s, const double exaggeration, const double size) const {
519  // check if block icon can be draw
521  // Start pushing matrix
522  glPushMatrix();
523  // Traslate to middle of shape
524  glTranslated(position.x(), position.y(), myAdditional->getType() + 0.1);
525  // Set draw color
526  glColor3d(1, 1, 1);
527  // Rotate depending of rotation
528  glRotated(rotation, 0, 0, -1);
529  // Rotate 180 degrees
530  glRotated(180, 0, 0, 1);
531  // Traslate depending of the offset
532  glTranslated(offset.x(), offset.y(), 0);
533  // Draw icon depending of the state of additional
536  // Draw not movable texture if additional isn't movable and is selected
538  } else if (myAdditional->myBlockMovement) {
539  // Draw lock texture if additional is movable, is blocked and is selected
541  } else {
542  // Draw empty texture if additional is movable, isn't blocked and is selected
544  }
545  } else {
547  // Draw not movable texture if additional isn't movable
549  } else if (myAdditional->myBlockMovement) {
550  // Draw lock texture if additional is movable and is blocked
552  } else {
553  // Draw empty texture if additional is movable and isn't blocked
555  }
556  }
557  // Pop matrix
558  glPopMatrix();
559  }
560 }
561 
562 // ---------------------------------------------------------------------------
563 // GNEAdditional - protected methods
564 // ---------------------------------------------------------------------------
565 
566 void
568  // iterate over attributes and set default value
569  for (const auto& i : myTagProperty) {
570  if (i.hasStaticDefaultValue()) {
571  setAttribute(i.getAttr(), i.getDefaultValue());
572  }
573  }
574 }
575 
576 
577 const std::string&
579  return getMicrosimID();
580 }
581 
582 
583 bool
584 GNEAdditional::isValidAdditionalID(const std::string& newID) const {
585  if (SUMOXMLDefinitions::isValidNetID(newID) && (myViewNet->getNet()->retrieveAdditional(myTagProperty.getTag(), newID, false) == nullptr)) {
586  return true;
587  } else {
588  return false;
589  }
590 }
591 
592 
593 bool
594 GNEAdditional::isValidDetectorID(const std::string& newID) const {
595  if (SUMOXMLDefinitions::isValidDetectorID(newID) && (myViewNet->getNet()->retrieveAdditional(myTagProperty.getTag(), newID, false) == nullptr)) {
596  return true;
597  } else {
598  return false;
599  }
600 }
601 
602 
603 void
604 GNEAdditional::changeAdditionalID(const std::string& newID) {
605  if (myViewNet->getNet()->retrieveAdditional(myTagProperty.getTag(), newID, false) != nullptr) {
606  throw InvalidArgument("An Additional with tag " + getTagStr() + " and ID = " + newID + " already exists");
607  } else {
608  // Save old ID
609  std::string oldID = getMicrosimID();
610  // set New ID
611  setMicrosimID(newID);
612  // update additional ID in the container of net
613  myViewNet->getNet()->updateAdditionalID(oldID, this);
614  }
615 }
616 
617 
618 void
620  if (!myViewNet) {
621  throw ProcessError("ViewNet cannot be nullptr");
622  } else {
624  // add object of list into selected objects
626  if (changeFlag) {
627  mySelected = true;
628  }
629  }
630 }
631 
632 
633 void
635  if (!myViewNet) {
636  throw ProcessError("ViewNet cannot be nullptr");
637  } else {
639  // remove object of list of selected objects
641  if (changeFlag) {
642  mySelected = false;
643 
644  }
645  }
646 }
647 
648 
649 bool
651  return mySelected;
652 }
653 
654 
655 bool
658  return true;
659  } else {
660  return false;
661  }
662 }
663 
664 
665 void
667  //
668 }
669 
670 
671 bool
673  return true;
674 }
675 
676 
677 std::string
679  std::string result;
680  // Generate an string using the following structure: "key1=value1|key2=value2|...
681  for (auto i : getParametersMap()) {
682  result += i.first + "=" + i.second + "|";
683  }
684  // remove the last "|"
685  if (!result.empty()) {
686  result.pop_back();
687  }
688  return result;
689 }
690 
691 
692 std::vector<std::pair<std::string, std::string> >
694  std::vector<std::pair<std::string, std::string> > result;
695  // iterate over parameters map and fill result
696  for (auto i : getParametersMap()) {
697  result.push_back(std::make_pair(i.first, i.second));
698  }
699  return result;
700 }
701 
702 
703 void
704 GNEAdditional::setGenericParametersStr(const std::string& value) {
705  // clear parameters
706  clearParameter();
707  // separate value in a vector of string using | as separator
708  std::vector<std::string> parsedValues;
709  StringTokenizer stValues(value, "|", true);
710  while (stValues.hasNext()) {
711  parsedValues.push_back(stValues.next());
712  }
713  // check that parsed values (A=B)can be parsed in generic parameters
714  for (auto i : parsedValues) {
715  std::vector<std::string> parsedParameters;
716  StringTokenizer stParam(i, "=", true);
717  while (stParam.hasNext()) {
718  parsedParameters.push_back(stParam.next());
719  }
720  // Check that parsed parameters are exactly two and contains valid chracters
721  if (parsedParameters.size() == 2 && SUMOXMLDefinitions::isValidGenericParameterKey(parsedParameters.front()) && SUMOXMLDefinitions::isValidGenericParameterValue(parsedParameters.back())) {
722  setParameter(parsedParameters.front(), parsedParameters.back());
723  }
724  }
725 }
726 
727 
728 bool
730  // throw exception because this function mus be implemented in child (see GNEE3Detector)
731  throw ProcessError("Calling non-implemented function checkAdditionalChildRestriction during saving of " + getTagStr() + ". It muss be reimplemented in child class");
732 }
733 
734 
735 void
736 GNEAdditional::setEnabledAttribute(const int /*enabledAttributes*/) {
737  //
738 }
739 
740 /****************************************************************************/
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
virtual void openAdditionalDialog()
open Additional Dialog
const TagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
bool hasTagSynonym() const
return true if tag correspond to an element that will be written in XML with another tag ...
virtual void fixAdditionalProblem()
fix additional problem (by default throw an exception, has to be reimplemented in children) ...
Copy object name - popup entry.
Definition: GUIAppEnum.h:369
void writePermissions(OutputDevice &into, SVCPermissions permissions)
writes allowed disallowed attributes if needed;
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
An special type of Attribute carrier that owns hierarchical elements.
void close()
Closes the device and removes it from the dictionary.
SumoXMLTag
Numbers representing SUMO-XML - element names.
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:1020
bool isAdditionalBlocked() const
Check if additional item is currently blocked (i.e. cannot be moved with mouse)
SumoXMLTag getTagSynonym() const
get tag synonym
void writeAdditional(OutputDevice &device) const
writte additional element into a xml file
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
void addedLockedObject(const GUIGlObjectType type)
set object selected
PositionVector shape
The shape of the netElement element.
Definition: GNENetElement.h:57
PositionVector multiShapeUnified
multi shape unified
Definition: GNEAdditional.h:86
void calculateMultiShapeRotationsAndLengths()
calculate multi shape rotations and lenghts
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
bool isDrawable() const
return true if tag correspond to a drawable element
void append(const PositionVector &v, double sameThreshold=2.0)
double z() const
Returns the z-position.
Definition: Position.h:67
std::vector< double > shapeRotations
The rotations of the single shape parts.
Definition: GNEAdditional.h:74
GUIGlObjectType
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
begin/end of the description of a single lane
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
const std::string & getAdditionalID() const
std::string secondOriginalPosition
value for saving second original position over lane before moving
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
struct for pack all variables related with geometry of elemement
Definition: GNEAdditional.h:51
GNEAdditional * myAdditional
pointer to additional parent
Stores the information about how to visualize structures.
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
GNEViewParent * getViewParent() const
get the net object
Definition: GNEViewNet.cpp:921
Position offset
The offSet of the block icon.
double y() const
Returns the y-position.
Definition: Position.h:62
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
PositionVector getShape() const
Returns additional element&#39;s shape.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
double x() const
Returns the x-position.
Definition: Position.h:57
bool isAttributeEnabled(SumoXMLAttr key) const
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes ...
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
bool canMaskStartEndPos() const
return true if tag correspond to an element that can mask the attributes "start" and "end" position a...
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
FXIcon * getIcon() const
get FXIcon associated to this AC
Position position
position of the block icon
BlockIcon myBlockIcon
variable BlockIcon
void clearGeometry()
reset geometry
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
Position originalViewPosition
value for saving first original position over lane before moving
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
BlockIcon(GNEAdditional *additional)
constructor
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void setDefaultValues()
change all attributes of additional with their default values (note: this cannot be undo) ...
const RGBColor * mySpecialColor
pointer to special color (used for drawing Additional with a certain color, mainly used for selection...
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
bool hasNext()
returns the information whether further substrings exist
virtual bool checkAdditionalChildRestriction() const
check restriction with the number of children
static bool isValidGenericParameterKey(const std::string &value)
whether the given string is a valid key for a generic parameter
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const AdditionalGeometry & getAdditionalGeometry() const
obtain AdditionalGeometry
virtual bool isAdditionalValid() const
check if current additional is valid to be writed into XML (by default true, can be reimplemented in ...
const std::vector< GNEAdditional * > & getAdditionalChildren() const
return vector of additionals that have as Parent this edge (For example, Calibrators) ...
void changeAdditionalID(const std::string &newID)
change ID of additional
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNEAdditional(const std::string &id, GNEViewNet *viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement, const std::vector< GNEEdge *> &edgeParents, const std::vector< GNELane *> &laneParents, const std::vector< GNEShape *> &shapeParents, const std::vector< GNEAdditional *> &additionalParents, const std::vector< GNEDemandElement *> &demandElementParents, const std::vector< GNEEdge *> &edgeChildren, const std::vector< GNELane *> &laneChildren, const std::vector< GNEShape *> &shapeChildren, const std::vector< GNEAdditional *> &additionalChildren, const std::vector< GNEDemandElement *> &demandElementChildren)
Constructor.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
double rotation
The rotation of the block icon.
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute) ...
const std::vector< GNEDemandElement * > & getDemandElementChildren() const
return vector of demand elements that have as Parent this edge (For example, Calibrators) ...
std::vector< std::vector< double > > multiShapeRotations
The rotations of the multi-shape parts.
Definition: GNEAdditional.h:80
virtual std::string getAdditionalProblem() const
return a string with the current additional problem (by default empty, can be reimplemented in childr...
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
AdditionalMove myMove
variable AdditionalMove
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
Definition: GNENet.cpp:2133
An special type of Attribute carrier that owns hierarchical elements.
bool canBlockMovement() const
return true if tag correspond to an element that can block their movement
bool showLockIcon() const
check if lock icon should be visible
Definition: GNEViewNet.cpp:951
LockGLObjectTypes * getLockGLObjectTypes() const
get selected items Modul
static bool isValidGenericParameterValue(const std::string &value)
whether the given string is a valid value for a generic parameter
void updateAdditionalID(const std::string &oldID, GNEAdditional *additional)
update additional ID in container
Definition: GNENet.cpp:2172
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
int getNumberOfAttributes() const
get number of attributes
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.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
PositionVector shape
The shape of the additional element.
Definition: GNEAdditional.h:68
A list of positions.
Supermode currentSupermode
the current supermode
std::string myAdditionalName
name of additional
void removeLockedObject(const GUIGlObjectType type)
set object unselected
void removeGLObjectFromGrid(GUIGlObject *o)
add GL Object into net
Definition: GNENet.cpp:1279
static bool isValidDetectorID(const std::string &value)
whether the given string is a valid id for an detector
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void selectAttributeCarrier(bool changeFlag=true)
std::vector< std::vector< double > > multiShapeLengths
The lengths of the multi-shape shape parts.
Definition: GNEAdditional.h:83
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:840
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
GNESelectorFrame * getSelectorFrame() const
get frame for GNE_NMODE_SELECT
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
bool isPlacedInRTree() const
return true if Tag correspond to an element that has has to be placed in RTREE
const std::string getID() const
function to support debugging
const NetElementGeometry & getGeometry() const
~GNEAdditional()
Destructor.
std::vector< PositionVector > multiShape
The multi-shape of the additional element (used by certain additionals)
Definition: GNEAdditional.h:71
void setSpecialColor(const RGBColor *color)
set special color
An upper class for objects with additional parameters.
Definition: Parameterised.h:43
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse) ...
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
void calculateShapeRotationsAndLengths()
calculate shape rotations and lenghts
begin/end of the description of an edge
std::vector< double > shapeLengths
The lengths of the single shape parts.
Definition: GNEAdditional.h:77
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
GUIVisualizationDetailSettings detailSettings
detail settings
reserved GLO type to pack all additionals
void reset()
Resets the boundary.
Definition: Boundary.cpp:67
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which additional element is located.
void deselect(GUIGlID id)
Deselects the object with the given id.
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:331
double length() const
Returns the length.
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
#define M_PI
Definition: odrSpiral.cpp:40
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
AdditionalGeometry myGeometry
geometry to be precomputed in updateGeometry(...)
const std::string & getTagStr() const
get tag assigned to this object in string format
Boundary movingGeometryBoundary
boundary used during moving of elements (to avoid insertion in RTREE
The popup menu of a globject.
static const double lockIcon
lock icons
std::string getGenericParametersStr() const
return generic parameters in string format
open additional dialog (used in netedit)
Definition: GUIAppEnum.h:379
GNENet * getNet() const
get the net object
Definition: GNEViewNet.cpp:927
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
GUIGlID getGlID() const
Returns the numerical id of the object.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:234
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute attr
const TagProperties & getTagProperty() const
get Tag Property assigned to this object
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
Definition: FileHelpers.cpp:67
std::string firstOriginalLanePosition
value for saving first original position over lane before moving
void drawIcon(const GUIVisualizationSettings &s, const double exaggeration, const double size=0.5) const
draw lock icon
void endGeometryMoving()
begin movement (used when user click over additional to start a movement, to avoid problems with prob...
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:399
bool hasDialog() const
return true if tag correspond to an element that can be edited using a dialog
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
Network mode (Edges, junctions, etc..)
void addGLObjectIntoGrid(GUIGlObject *o)
add GL Object into net
Definition: GNENet.cpp:1273
GUISelectedStorage gSelected
A global holder of selected objects.
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
Definition: GNENet.cpp:1179
void startGeometryMoving()
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:371
A window containing a gl-object&#39;s parameter.
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
void setRotation(GNELane *additionalLane=nullptr)
set Rotation of block Icon (must be called in updateGeometry() function)
bool hasMinimumNumberOfChildren() const
return true if tag correspond to an element that only have a limited number of children ...
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void calculateMultiShapeUnified()
calculate multi shape unified
void clearParameter()
Clears the parameter map.
virtual Position getPositionInView() const =0
Returns position of additional in view.