Eclipse SUMO - Simulation of Urban MObility
GNEPoly.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 /****************************************************************************/
14 // A class for visualizing and editing POIS in netedit (adapted from
15 // GUIPolygon and NLHandler)
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <string>
26 #include <utils/gui/div/GLHelper.h>
28 #include <netedit/GNENet.h>
30 #include <netedit/GNEUndoList.h>
31 #include <netedit/GNEViewNet.h>
33 
34 #include "GNEPoly.h"
35 
36 
37 // ===========================================================================
38 // static members
39 // ===========================================================================
40 
41 const double GNEPoly::myHintSize = 0.8;
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
46 GNEPoly::GNEPoly(GNENet* net, const std::string& id, const std::string& type, const PositionVector& shape, bool geo, bool fill, double lineWidth,
47  const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath, bool movementBlocked, bool shapeBlocked) :
48  GUIPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, relativePath),
49  GNEShape(net, SUMO_TAG_POLY, movementBlocked, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}),
50  myNetElementShapeEdited(nullptr),
51  myBlockShape(shapeBlocked),
52  myClosedShape(shape.front() == shape.back()),
53  mySimplifiedShape(false),
54 myCurrentMovingVertexIndex(-1) {
55  // check if imgFile is valid
56  if (!imgFile.empty() && GUITexturesHelper::getTextureID(imgFile) == -1) {
57  setShapeImgFile("");
58  }
59  // set GEO shape
60  myGeoShape = myShape;
61  for (int i = 0; i < (int) myGeoShape.size(); i++) {
62  GeoConvHelper::getFinal().cartesian2geo(myGeoShape[i]);
63  }
64 }
65 
66 
68 
69 
70 std::string
72  int counter = myNet->getPolygons().size();
73  while (myNet->retrievePolygon(getID() + toString(childTag) + toString(counter), false) != nullptr) {
74  counter++;
75  }
76  return (getID() + toString(childTag) + toString(counter));
77 }
78 
79 
80 void
82  // save current centering boundary
84 }
85 
86 
87 void
89  // check that endGeometryMoving was called only once
91  // Remove object from net
93  // reset myMovingGeometryBoundary
95  // add object into grid again (using the new centering boundary)
97  }
98 }
99 
100 
101 int
102 GNEPoly::moveVertexShape(const int index, const Position& oldPos, const Position& offset) {
103  // only move shape if block movement block shape are disabled
104  if (!myBlockMovement && !myBlockShape && (index != -1)) {
105  // check that index is correct before change position
106  if (index < (int)myShape.size()) {
107  // save current moving Geometry Point
109  // if closed shape and cliked is first or last, move both giving more priority to first always
110  if (myClosedShape && (index == 0 || index == (int)myShape.size() - 1)) {
111  // Change position of first shape Geometry Point and filtern position using snap to active grid
112  myShape.front() = oldPos;
113  myShape.front().add(offset);
114  myShape.front() = myNet->getViewNet()->snapToActiveGrid(myShape[index]);
115  // Change position of last shape Geometry Point and filtern position using snap to active grid
116  myShape.back() = oldPos;
117  myShape.back().add(offset);
118  myShape.back() = myNet->getViewNet()->snapToActiveGrid(myShape[index]);
119  } else {
120  // change position of Geometry Point and filtern position using snap to active grid
121  myShape[index] = oldPos;
122  myShape[index].add(offset);
123  myShape[index] = myNet->getViewNet()->snapToActiveGrid(myShape[index]);
124  }
125  // return index of moved Geometry Point
126  return index;
127  } else {
128  throw InvalidArgument("Index greater than shape size");
129  }
130  } else {
131  return index;
132  }
133 }
134 
135 
136 void
137 GNEPoly::moveEntireShape(const PositionVector& oldShape, const Position& offset) {
138  // only move shape if block movement is disabled and block shape is enabled
139  if (!myBlockMovement && myBlockShape) {
140  // restore original shape
141  myShape = oldShape;
142  // change all points of the shape shape using offset
143  for (auto& i : myShape) {
144  i.add(offset);
145  }
146  // update Geometry after moving
147  updateGeometry();
148  }
149 }
150 
151 
152 void
154  if (!myBlockMovement) {
155  // disable current moving vertex
157  // restore original shape into shapeToCommit
158  PositionVector shapeToCommit = myShape;
159  // restore old shape in polygon (to avoid problems with RTree)
160  myShape = oldShape;
161  // first check if double points has to be removed
162  shapeToCommit.removeDoublePoints(myHintSize);
163  if (shapeToCommit.size() != myShape.size() && !myNet->getViewNet()->getEditShapes().editingNetElementShapes) {
164  WRITE_WARNING("Merged shape's point")
165  }
166 
167  // check if polygon has to be closed
168  if (shapeToCommit.size() > 1 && shapeToCommit.front().distanceTo2D(shapeToCommit.back()) < (2 * myHintSize)) {
169  shapeToCommit.pop_back();
170  shapeToCommit.push_back(shapeToCommit.front());
171  }
172  // only use GNEChange_Attribute if we aren't editing a junction's shape
173  if (myNetElementShapeEdited == nullptr) {
174  // commit new shape
175  undoList->p_begin("moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
176  undoList->p_add(new GNEChange_Attribute(this, myNet, SUMO_ATTR_SHAPE, toString(shapeToCommit)));
177  undoList->p_end();
178  } else {
179  // set new shape calling private setAttribute function
180  setAttribute(SUMO_ATTR_SHAPE, toString(shapeToCommit));
181  }
182  }
183 }
184 
185 
186 void
188  // nothing to do
189 }
190 
191 void
193  writeXML(device, myGEO);
194 }
195 
196 
197 Position
199  return myShape.getPolygonCenter();
200 }
201 
202 
203 Boundary
205  // Return Boundary depending if myMovingGeometryBoundary is initialised (important for move geometry)
208  } else {
210  }
211 }
212 
213 
214 GUIGlID
216  return GUIPolygon::getGlID();
217 }
218 
219 
220 std::string
222  if (myNetElementShapeEdited != nullptr) {
224  } else {
225  return myNet->getMicrosimID();
226  }
227 }
228 
229 
232  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
233  buildPopupHeader(ret, app);
236  // build selection and show parameters menu
239  FXMenuCommand* simplifyShape = new FXMenuCommand(ret, "Simplify Shape\t\tReplace current shape with a rectangle", nullptr, &parent, MID_GNE_POLYGON_SIMPLIFY_SHAPE);
240  // disable simplify shape if polygon was already simplified
241  if (mySimplifiedShape || myShape.size() <= 2) {
242  simplifyShape->disable();
243  }
244  // create open or close polygon's shape only if myNetElementShapeEdited is nullptr
245  if (myNetElementShapeEdited == nullptr) {
246  if (myClosedShape) {
247  new FXMenuCommand(ret, "Open shape\t\tOpen polygon's shape", nullptr, &parent, MID_GNE_POLYGON_OPEN);
248  } else {
249  new FXMenuCommand(ret, "Close shape\t\tClose polygon's shape", nullptr, &parent, MID_GNE_POLYGON_CLOSE);
250  }
251  }
252  // create a extra FXMenuCommand if mouse is over a vertex
253  int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false, false);
254  if (index != -1) {
255  FXMenuCommand* removeGeometryPoint = new FXMenuCommand(ret, "Remove geometry point\t\tRemove geometry point under mouse", nullptr, &parent, MID_GNE_POLYGON_DELETE_GEOMETRY_POINT);
256  FXMenuCommand* setFirstPoint = new FXMenuCommand(ret, "Set first geometry point\t\tSet", nullptr, &parent, MID_GNE_POLYGON_SET_FIRST_POINT);
257  // disable setFirstPoint if shape only have three points
258  if ((myClosedShape && (myShape.size() <= 4)) || (!myClosedShape && (myShape.size() <= 2))) {
259  removeGeometryPoint->disable();
260  }
261  // disable setFirstPoint if mouse is over first point
262  if (index == 0) {
263  setFirstPoint->disable();
264  }
265  }
266  return ret;
267 }
268 
269 
272  return GUIPolygon::getParameterWindow(app, parent);
273 }
274 
275 
276 void
278  // first obtain poly exaggeration
279  const double polyExaggeration = s.polySize.getExaggeration(s, this);
280  // first check if poly can be drawn
281  if ((polyExaggeration > 0) && myNet->getViewNet()->getDemandViewOptions().showShapes()) {
282  // Obtain constants
283  const Position mousePosition = myNet->getViewNet()->getPositionInformation();
284  const double vertexWidth = myHintSize * MIN2((double)1, s.polySize.getExaggeration(s, this));
285  const double vertexWidthSquared = (vertexWidth * vertexWidth);
286  const double contourWidth = (myHintSize / 4.0) * polyExaggeration;
287  // check if boundary has to be drawn
288  if (s.drawBoundaries) {
290  }
291  // push name (needed for getGUIGlObjectsUnderCursor(...)
292  glPushName(getGlID());
293  // first check if inner polygon can be drawn
294  if (s.drawForPositionSelection && getFill()) {
295  if (myShape.around(mousePosition)) {
296  // push matrix
297  glPushMatrix();
298  glTranslated(mousePosition.x(), mousePosition.y(), GLO_POLYGON + 0.04);
299  setColor(s, false);
301  glPopMatrix();
302  }
303  } else if (checkDraw(s)) {
304  // draw inner polygon
306  }
307  // draw geometry details hints if is not too small and isn't in selecting mode
308  if (s.scale * vertexWidth > 1.) {
309  // obtain values relative to mouse position regarding to shape
310  bool mouseOverVertex = false;
311  const double distanceToShape = myShape.distance2D(mousePosition);
312  const Position positionOverLane = myShape.positionAtOffset2D(myShape.nearest_offset_to_point2D(mousePosition));
313  // set colors
314  RGBColor invertedColor, darkerColor;
315  if (drawUsingSelectColor()) {
316  invertedColor = s.colorSettings.selectionColor.invertedColor();
317  darkerColor = s.colorSettings.selectionColor.changedBrightness(-32);
318  } else {
319  invertedColor = GLHelper::getColor().invertedColor();
320  darkerColor = GLHelper::getColor().changedBrightness(-32);
321  }
322  // Draw geometry hints if polygon's shape isn't blocked
323  if (myBlockShape == false) {
324  // draw a boundary for moving using darkerColor
325  glPushMatrix();
326  glTranslated(0, 0, GLO_POLYGON + 0.01);
327  GLHelper::setColor(darkerColor);
328  if (s.drawForPositionSelection) {
329  if (positionOverLane.distanceSquaredTo2D(mousePosition) <= (contourWidth * contourWidth)) {
330  // push matrix
331  glPushMatrix();
332  // translate to position over lane
333  glTranslated(positionOverLane.x(), positionOverLane.y(), 0);
334  // Draw circle
336  // pop draw matrix
337  glPopMatrix();
338  }
339  } else if (!s.drawForPositionSelection) {
341  }
342  glPopMatrix();
343  // draw shape points only in Network supemode
345  for (const auto vertex : myShape) {
346  if (!s.drawForRectangleSelection || (mousePosition.distanceSquaredTo2D(vertex) <= (vertexWidthSquared + 2))) {
347  glPushMatrix();
348  glTranslated(vertex.x(), vertex.y(), GLO_POLYGON + 0.02);
349  // Change color of vertex and flag mouseOverVertex if mouse is over vertex
350  if ((myNet->getViewNet()->getEditModes().networkEditMode == GNE_NMODE_MOVE) && (vertex.distanceSquaredTo2D(mousePosition) < vertexWidthSquared)) {
351  mouseOverVertex = true;
352  GLHelper::setColor(invertedColor);
353  } else {
354  GLHelper::setColor(darkerColor);
355  }
357  glPopMatrix();
358  // draw elevation or special symbols (Start, End and Block)
360  // Push matrix
361  glPushMatrix();
362  // Traslate to center of detector
363  glTranslated(vertex.x(), vertex.y(), getType() + 1);
364  // draw Z
365  GLHelper::drawText(toString(vertex.z()), Position(), .1, 0.7, RGBColor::BLUE);
366  // pop matrix
367  glPopMatrix();
368  } else if ((vertex == myShape.front()) && !s.drawForRectangleSelection &&
369  s.drawDetail(s.detailSettings.geometryPointsText, polyExaggeration)) {
370  // draw a "s" over first point
371  glPushMatrix();
372  glTranslated(vertex.x(), vertex.y(), GLO_POLYGON + 0.03);
373  GLHelper::drawText("S", Position(), .1, 2 * vertexWidth, invertedColor);
374  glPopMatrix();
375  } else if ((vertex == myShape.back()) && (myClosedShape == false) && !s.drawForRectangleSelection &&
376  s.drawDetail(s.detailSettings.geometryPointsText, polyExaggeration)) {
377  // draw a "e" over last point if polygon isn't closed
378  glPushMatrix();
379  glTranslated(vertex.x(), vertex.y(), GLO_POLYGON + 0.03);
380  GLHelper::drawText("E", Position(), .1, 2 * vertexWidth, invertedColor);
381  glPopMatrix();
382  }
383  }
384  }
385  // check if draw moving hint has to be drawed
386  if ((myNet->getViewNet()->getEditModes().networkEditMode == GNE_NMODE_MOVE) && (distanceToShape < vertexWidth) &&
387  (mouseOverVertex == false) && (myBlockMovement == false)) {
388  // push matrix
389  glPushMatrix();
390  const Position hintPos = myShape.size() > 1 ? positionOverLane : myShape[0];
391  glTranslated(hintPos.x(), hintPos.y(), GLO_POLYGON + 0.04);
392  GLHelper::setColor(invertedColor);
394  glPopMatrix();
395  }
396  }
397  }
398  }
399  // check if dotted contour has to be drawn
400  if (myNet->getViewNet()->getDottedAC() == this) {
402  }
403  // pop name
404  glPopName();
405  }
406 }
407 
408 
409 int
410 GNEPoly::getVertexIndex(Position pos, bool createIfNoExist, bool snapToGrid) {
411  // check if position has to be snapped to grid
412  if (snapToGrid) {
413  pos = myNet->getViewNet()->snapToActiveGrid(pos);
414  }
415  // first check if vertex already exists
416  for (auto i : myShape) {
417  if (i.distanceTo2D(pos) < myHintSize) {
418  return myShape.indexOfClosest(i);
419  }
420  }
421  // if vertex doesn't exist, insert it
422  if (createIfNoExist) {
423  return myShape.insertAtClosest(pos, true);
424  } else {
425  return -1;
426  }
427 }
428 
429 
430 void
431 GNEPoly::deleteGeometryPoint(const Position& pos, bool allowUndo) {
432  if (myShape.size() > 1) {
433  // obtain index
434  PositionVector modifiedShape = myShape;
435  int index = modifiedShape.indexOfClosest(pos);
436  // remove point dependending of
437  if (myClosedShape && (index == 0 || index == (int)modifiedShape.size() - 1) && (myShape.size() > 2)) {
438  modifiedShape.erase(modifiedShape.begin());
439  modifiedShape.erase(modifiedShape.end() - 1);
440  modifiedShape.push_back(modifiedShape.front());
441  } else {
442  modifiedShape.erase(modifiedShape.begin() + index);
443  }
444  // set new shape depending of allowUndo
445  if (allowUndo) {
446  myNet->getViewNet()->getUndoList()->p_begin("delete geometry point");
449  } else {
450  // first remove object from grid due shape is used for boundary
452  // set new shape
453  myShape = modifiedShape;
454  // Check if new shape is closed
455  myClosedShape = (myShape.front() == myShape.back());
456  // disable simplified shape flag
457  mySimplifiedShape = false;
458  // add object into grid again
459  myNet->addGLObjectIntoGrid(this);
460  }
461  } else {
462  WRITE_WARNING("Number of remaining points insufficient")
463  }
464 }
465 
466 
467 bool
469  return myBlockShape;
470 }
471 
472 
473 bool
475  return myClosedShape;
476 }
477 
478 
479 void
481  if (element) {
482  myNetElementShapeEdited = element;
483  } else {
484  throw InvalidArgument("Junction cannot be nullptr");
485  }
486 }
487 
488 
492 }
493 
494 
495 void
496 GNEPoly::openPolygon(bool allowUndo) {
497  // only open if shape is closed
498  if (myClosedShape) {
499  if (allowUndo) {
500  myNet->getViewNet()->getUndoList()->p_begin("open polygon");
503  } else {
504  myClosedShape = false;
505  myShape.pop_back();
506  // disable simplified shape flag
507  mySimplifiedShape = false;
508  // update geometry to avoid grabbing Problems
509  updateGeometry();
510  }
511  } else {
512  WRITE_WARNING("Polygon already opened")
513  }
514 }
515 
516 
517 void
518 GNEPoly::closePolygon(bool allowUndo) {
519  // only close if shape is opened
520  if (myClosedShape == false) {
521  if (allowUndo) {
522  myNet->getViewNet()->getUndoList()->p_begin("close shape");
525  } else {
526  myClosedShape = true;
528  // disable simplified shape flag
529  mySimplifiedShape = false;
530  // update geometry to avoid grabbing Problems
531  updateGeometry();
532  }
533  } else {
534  WRITE_WARNING("Polygon already closed")
535  }
536 }
537 
538 
539 void
540 GNEPoly::changeFirstGeometryPoint(int oldIndex, bool allowUndo) {
541  // check that old index is correct
542  if (oldIndex >= (int)myShape.size()) {
543  throw InvalidArgument("Invalid old Index");
544  } else if (oldIndex == 0) {
545  WRITE_WARNING("Selected point must be different of the first point")
546  } else {
547  // Configure new shape
548  PositionVector newShape;
549  for (int i = oldIndex; i < (int)myShape.size(); i++) {
550  newShape.push_back(myShape[i]);
551  }
552  if (myClosedShape) {
553  for (int i = 1; i < oldIndex; i++) {
554  newShape.push_back(myShape[i]);
555  }
556  newShape.push_back(newShape.front());
557  } else {
558  for (int i = 0; i < oldIndex; i++) {
559  newShape.push_back(myShape[i]);
560  }
561  }
562  // set new rotated shape
563  if (allowUndo) {
564  myNet->getViewNet()->getUndoList()->p_begin("change first geometry point");
567  } else {
568  // set new shape
569  myShape = newShape;
570  // Check if new shape is closed
571  myClosedShape = (myShape.front() == myShape.back());
572  // disable simplified shape flag
573  mySimplifiedShape = false;
574  // update geometry to avoid grabbing Problems
575  updateGeometry();
576  }
577  }
578 }
579 
580 
581 void
582 GNEPoly::simplifyShape(bool allowUndo) {
583  if (!mySimplifiedShape && myShape.size() > 2) {
584  const Boundary b = myShape.getBoxBoundary();
585  PositionVector simplifiedShape;
586  if (myShape.isClosed()) {
587  // create a square as simplified shape
588  simplifiedShape.push_back(Position(b.xmin(), b.ymin()));
589  simplifiedShape.push_back(Position(b.xmin(), b.ymax()));
590  simplifiedShape.push_back(Position(b.xmax(), b.ymax()));
591  simplifiedShape.push_back(Position(b.xmax(), b.ymin()));
592  simplifiedShape.push_back(simplifiedShape[0]);
593  } else {
594  // create a line as simplified shape
595  simplifiedShape.push_back(myShape.front());
596  simplifiedShape.push_back(myShape.back());
597  }
598  // set new shape depending of allowUndo
599  if (allowUndo) {
600  myNet->getViewNet()->getUndoList()->p_begin("simplify shape");
603  } else {
604  // set new shape
605  myShape = simplifiedShape;
606  // Check if new shape is closed
607  myClosedShape = (myShape.front() == myShape.back());
608  // update geometry to avoid grabbing Problems
609  updateGeometry();
610  }
611  // change flag after setting simplified shape
612  mySimplifiedShape = true;
613  } else {
614  WRITE_WARNING("Polygon already simplified")
615  }
616 }
617 
618 
619 std::string
621  switch (key) {
622  case SUMO_ATTR_ID:
623  return myID;
624  case SUMO_ATTR_SHAPE:
625  return toString(myShape);
626  case SUMO_ATTR_GEOSHAPE:
628  case SUMO_ATTR_COLOR:
629  return toString(getShapeColor());
630  case SUMO_ATTR_FILL:
631  return toString(myFill);
632  case SUMO_ATTR_LINEWIDTH:
633  return toString(myLineWidth);
634  case SUMO_ATTR_LAYER:
636  return "default";
637  } else {
638  return toString(getShapeLayer());
639  }
640  case SUMO_ATTR_TYPE:
641  return getShapeType();
642  case SUMO_ATTR_IMGFILE:
643  return getShapeImgFile();
645  return toString(getShapeRelativePath());
646  case SUMO_ATTR_ANGLE:
647  return toString(getShapeNaviDegree());
648  case SUMO_ATTR_GEO:
649  return toString(myGEO);
651  return toString(myBlockMovement);
653  return toString(myBlockShape);
655  return toString(myClosedShape);
656  case GNE_ATTR_SELECTED:
658  case GNE_ATTR_PARAMETERS:
659  return getParametersStr();
660  default:
661  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
662  }
663 }
664 
665 
666 void
667 GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
668  if (value == getAttribute(key)) {
669  return; //avoid needless changes, later logic relies on the fact that attributes have changed
670  }
671  switch (key) {
672  case SUMO_ATTR_ID:
673  case SUMO_ATTR_SHAPE:
674  case SUMO_ATTR_GEOSHAPE:
675  case SUMO_ATTR_COLOR:
676  case SUMO_ATTR_FILL:
677  case SUMO_ATTR_LINEWIDTH:
678  case SUMO_ATTR_LAYER:
679  case SUMO_ATTR_TYPE:
680  case SUMO_ATTR_IMGFILE:
682  case SUMO_ATTR_ANGLE:
683  case SUMO_ATTR_GEO:
687  case GNE_ATTR_SELECTED:
688  case GNE_ATTR_PARAMETERS:
689  undoList->p_add(new GNEChange_Attribute(this, myNet, key, value));
690  break;
691  default:
692  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
693  }
694 }
695 
696 
697 bool
698 GNEPoly::isValid(SumoXMLAttr key, const std::string& value) {
699  switch (key) {
700  case SUMO_ATTR_ID:
701  return SUMOXMLDefinitions::isValidTypeID(value) && (myNet->retrievePolygon(value, false) == nullptr);
702  case SUMO_ATTR_SHAPE:
703  case SUMO_ATTR_GEOSHAPE:
704  // empty shapes AREN'T allowed
705  if (value.empty()) {
706  return false;
707  } else {
708  return canParse<PositionVector>(value);
709  }
710  case SUMO_ATTR_COLOR:
711  return canParse<RGBColor>(value);
712  case SUMO_ATTR_FILL:
713  return canParse<bool>(value);
714  case SUMO_ATTR_LINEWIDTH:
715  return canParse<double>(value) && (parse<double>(value) >= 0);
716  case SUMO_ATTR_LAYER:
717  if (value == "default") {
718  return true;
719  } else {
720  return canParse<double>(value);
721  }
722  case SUMO_ATTR_TYPE:
723  return true;
724  case SUMO_ATTR_IMGFILE:
725  if (value == "") {
726  return true;
727  } else {
728  // check that image can be loaded
729  return GUITexturesHelper::getTextureID(value) != -1;
730  }
732  return canParse<bool>(value);
733  case SUMO_ATTR_ANGLE:
734  return canParse<double>(value);
735  case SUMO_ATTR_GEO:
736  return canParse<bool>(value);
738  return canParse<bool>(value);
740  return canParse<bool>(value);
742  if (canParse<bool>(value)) {
743  bool closePolygon = parse<bool>(value);
744  if (closePolygon && (myShape.begin() == myShape.end())) {
745  // Polygon already closed, then invalid value
746  return false;
747  } else if (!closePolygon && (myShape.begin() != myShape.end())) {
748  // Polygon already open, then invalid value
749  return false;
750  } else {
751  return true;
752  }
753  } else {
754  return false;
755  }
756  case GNE_ATTR_SELECTED:
757  return canParse<bool>(value);
758  case GNE_ATTR_PARAMETERS:
759  return Parameterised::areParametersValid(value);
760  default:
761  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
762  }
763 }
764 
765 bool
767  // check if we're in supermode Network
769  return true;
770  } else {
771  return false;
772  }
773 }
774 
775 // ===========================================================================
776 // private
777 // ===========================================================================
778 
779 void
780 GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value) {
781  // first remove object from grid due almost modificactions affects to boundary (but avoided for certain attributes)
782  if ((key != SUMO_ATTR_ID) && (key != GNE_ATTR_PARAMETERS) && (key != GNE_ATTR_SELECTED)) {
784  }
785  switch (key) {
786  case SUMO_ATTR_ID: {
787  std::string oldID = myID;
788  myID = value;
789  myNet->changeShapeID(this, oldID);
790  setMicrosimID(value);
791  break;
792  }
793  case SUMO_ATTR_SHAPE: {
794  // set new shape
795  myShape = parse<PositionVector>(value);
796  // set GEO shape
798  for (int i = 0; i < (int) myGeoShape.size(); i++) {
800  }
801  // Check if new shape is closed
802  myClosedShape = (myShape.front() == myShape.back());
803  // disable simplified shape flag
804  mySimplifiedShape = false;
805  // update geometry of shape edited element
808  }
809  break;
810  }
811  case SUMO_ATTR_GEOSHAPE: {
812  // set new GEO shape
813  myGeoShape = parse<PositionVector>(value);
814  // set shape
815  myShape = myGeoShape ;
816  for (int i = 0; i < (int) myShape.size(); i++) {
818  }
819  // Check if new shape is closed
820  myClosedShape = (myShape.front() == myShape.back());
821  // disable simplified shape flag
822  mySimplifiedShape = false;
823  // update geometry of shape edited element
826  }
827  break;
828  }
829  case SUMO_ATTR_COLOR:
830  setShapeColor(parse<RGBColor>(value));
831  break;
832  case SUMO_ATTR_FILL:
833  myFill = parse<bool>(value);
834  break;
835  case SUMO_ATTR_LINEWIDTH:
836  myLineWidth = parse<double>(value);
837  break;
838  case SUMO_ATTR_LAYER:
839  if (value == "default") {
841  } else {
842  setShapeLayer(parse<double>(value));
843  }
844  break;
845  case SUMO_ATTR_TYPE:
846  setShapeType(value);
847  break;
848  case SUMO_ATTR_IMGFILE:
849  setShapeImgFile(value);
850  // all textures must be refresh
852  break;
854  setShapeRelativePath(parse<bool>(value));
855  break;
856  case SUMO_ATTR_ANGLE:
857  setShapeNaviDegree(parse<double>(value));
858  break;
859  case SUMO_ATTR_GEO:
860  myGEO = parse<bool>(value);
861  break;
863  myBlockMovement = parse<bool>(value);
864  break;
866  myBlockShape = parse<bool>(value);
867  break;
869  myClosedShape = parse<bool>(value);
870  if (myClosedShape) {
873  } else {
874  myShape.pop_back();
875  myGeoShape.pop_back();
876  }
877  // disable simplified shape flag
878  mySimplifiedShape = false;
879  break;
880  case GNE_ATTR_SELECTED:
881  if (parse<bool>(value)) {
883  } else {
885  }
886  break;
887  case GNE_ATTR_PARAMETERS:
888  setParametersStr(value);
889  break;
890  default:
891  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
892  }
893  // add object into grid again (but avoided for certain attributes)
894  if ((key != SUMO_ATTR_ID) && (key != GNE_ATTR_PARAMETERS) && (key != GNE_ATTR_SELECTED)) {
895  myNet->addGLObjectIntoGrid(this);
896  }
897 }
898 
899 
900 const GUIGlObject*
902  return this;
903 }
904 
905 /****************************************************************************/
GUIGlObject::getType
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.cpp:180
GNEShape::myMovingGeometryBoundary
Boundary myMovingGeometryBoundary
boundary used during moving of elements
Definition: GNEShape.h:200
Shape::setShapeType
void setShapeType(const std::string &type)
Sets a new type.
Definition: Shape.h:122
SUMO_ATTR_TYPE
@ SUMO_ATTR_TYPE
Definition: SUMOXMLDefinitions.h:381
GUIVisualizationSettings::polySize
GUIVisualizationSizeSettings polySize
Definition: GUIVisualizationSettings.h:616
SUMO_ATTR_ANGLE
@ SUMO_ATTR_ANGLE
Definition: SUMOXMLDefinitions.h:794
GUIVisualizationSettings::drawForPositionSelection
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
Definition: GUIVisualizationSettings.h:644
GNEPoly::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEPoly.cpp:204
GLHelper::getColor
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:627
SUMO_ATTR_GEOSHAPE
@ SUMO_ATTR_GEOSHAPE
Definition: SUMOXMLDefinitions.h:817
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:73
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:62
Parameterised::getParametersStr
std::string getParametersStr() const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
Definition: Parameterised.cpp:112
PositionVector::getPolygonCenter
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
Definition: PositionVector.cpp:400
SUMO_ATTR_IMGFILE
@ SUMO_ATTR_IMGFILE
Definition: SUMOXMLDefinitions.h:792
GNEAttributeCarrier::getID
const std::string getID() const
function to support debugging
Definition: GNEAttributeCarrier.cpp:1289
GNEPoly::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEPoly.cpp:221
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
SUMO_TAG_POLY
@ SUMO_TAG_POLY
begin/end of the description of a polygon
Definition: SUMOXMLDefinitions.h:57
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
SUMOPolygon::writeXML
void writeXML(OutputDevice &out, bool geo=false)
Definition: SUMOPolygon.cpp:49
MID_GNE_POLYGON_OPEN
@ MID_GNE_POLYGON_OPEN
open closed polygon
Definition: GUIAppEnum.h:904
GNEPoly::openPolygon
void openPolygon(bool allowUndo=true)
open polygon
Definition: GNEPoly.cpp:496
GeoConvHelper::x2cartesian_const
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
Definition: GeoConvHelper.cpp:417
Boundary::ymin
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:130
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
Shape::getShapeNaviDegree
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:96
GNEShape::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
Definition: GNEShape.cpp:108
GNEUndoList::p_end
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
Definition: GNEUndoList.cpp:79
GUIVisualizationSettings::drawForRectangleSelection
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
Definition: GUIVisualizationSettings.h:647
GUIVisualizationSettings::drawBoundaries
bool drawBoundaries
enable or disable draw boundaries
Definition: GUIVisualizationSettings.h:638
GLHelper::drawBoxLines
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:182
MID_GNE_POLYGON_SET_FIRST_POINT
@ MID_GNE_POLYGON_SET_FIRST_POINT
Set a vertex of polygon as first verte.
Definition: GUIAppEnum.h:906
GNENet::removeGLObjectFromGrid
void removeGLObjectFromGrid(GUIGlObject *o)
add GL Object into net
Definition: GNENet.cpp:1328
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
GNENetElement::updateGeometry
virtual void updateGeometry()=0
update pre-computed geometry information
GNEPoly::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNEPoly.cpp:187
GNEPoly::generateChildID
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEPoly.cpp:71
GUIGLObjectPopupMenu.h
Shape::DEFAULT_LAYER
static const double DEFAULT_LAYER
Definition: Shape.h:43
GNEPoly::mySimplifiedShape
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition: GNEPoly.h:233
Boundary::xmax
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:124
GNEPoly::isPolygonClosed
bool isPolygonClosed() const
check if polygon is closed
Definition: GNEPoly.cpp:474
SUMO_ATTR_COLOR
@ SUMO_ATTR_COLOR
A color information.
Definition: SUMOXMLDefinitions.h:704
GNEPoly::commitShapeChange
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(....
Definition: GNEPoly.cpp:153
Shape::setShapeImgFile
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
Definition: Shape.h:157
GNEPoly::myGeoShape
PositionVector myGeoShape
Latitude of Polygon.
Definition: GNEPoly.h:224
Shape::getShapeImgFile
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:103
GNENet::changeShapeID
void changeShapeID(GNEShape *s, const std::string &OldID)
change Shape ID
Definition: GNENet.cpp:2622
SUMO_ATTR_ID
@ SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:378
GLHelper.h
GNEPoly::GNEPoly
GNEPoly(GNENet *net, const std::string &id, const std::string &type, const PositionVector &shape, bool geo, bool fill, double lineWidth, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool relativePath, bool movementBlocked, bool shapeBlocked)
Constructor.
Definition: GNEPoly.cpp:46
SUMOPolygon::myShape
PositionVector myShape
The positions of the polygon.
Definition: SUMOPolygon.h:132
MID_GNE_POLYGON_DELETE_GEOMETRY_POINT
@ MID_GNE_POLYGON_DELETE_GEOMETRY_POINT
delete geometry point
Definition: GUIAppEnum.h:908
PositionVector
A list of positions.
Definition: PositionVector.h:45
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
GUIPolygon::setColor
void setColor(const GUIVisualizationSettings &s, bool disableSelectionColor) const
set color
Definition: GUIPolygon.cpp:239
SUMOPolygon::myLineWidth
double myLineWidth
The line width for drawing an unfilled polygon.
Definition: SUMOPolygon.h:141
PositionVector::isClosed
bool isClosed() const
check if PositionVector is closed
Definition: PositionVector.cpp:1325
GLHelper::setColor
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:621
PositionVector::getBoxBoundary
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
Definition: PositionVector.cpp:390
Shape::getShapeColor
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition: Shape.h:82
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
GUISUMOAbstractView::snapToActiveGrid
Position snapToActiveGrid(const Position &pos, bool snapXY=true) const
Returns a position that is mapped to the closest grid point if the grid is active.
Definition: GUISUMOAbstractView.cpp:196
gPrecisionGeo
int gPrecisionGeo
Definition: StdDefs.cpp:27
MID_GNE_POLYGON_CLOSE
@ MID_GNE_POLYGON_CLOSE
close opened polygon
Definition: GUIAppEnum.h:902
GUIVisualizationDetailSettings::geometryPointsText
static const double geometryPointsText
details for Geometry Points Texts
Definition: GUIVisualizationSettings.h:295
Shape::setShapeRelativePath
void setShapeRelativePath(bool relativePath)
Sets a new relativePath value.
Definition: Shape.h:164
GLO_POLYGON
@ GLO_POLYGON
a polygon
Definition: GUIGlObjectTypes.h:104
GLHelper::drawBoundary
static void drawBoundary(const Boundary &b)
Draw a boundary (used for debugging)
Definition: GLHelper.cpp:817
GUIAppEnum.h
GNENet::retrievePolygon
GNEPoly * retrievePolygon(const std::string &id, bool failHard=true) const
get Polygon by id
Definition: GNENet.cpp:1102
GNEAttributeCarrier::GNEChange_Attribute
friend class GNEChange_Attribute
declare friend class
Definition: GNEAttributeCarrier.h:57
GNEPoly::myNetElementShapeEdited
GNENetElement * myNetElementShapeEdited
junction of which the shape is being edited (optional)
Definition: GNEPoly.h:221
GNEUndoList::p_add
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
Definition: GNEUndoList.cpp:131
PositionVector::add
void add(double xoff, double yoff, double zoff)
Definition: PositionVector.cpp:617
GUIPolygon::drawInnerPolygon
void drawInnerPolygon(const GUIVisualizationSettings &s, bool disableSelectionColor) const
draw inner Polygon (before pushName() )
Definition: GUIPolygon.cpp:278
GLHelper::drawFilledCircle
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:348
PositionVector::nearest_offset_to_point2D
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
Definition: PositionVector.cpp:817
GNEPoly::isPolygonBlocked
bool isPolygonBlocked() const
return true if polygon is blocked
Definition: GNEPoly.cpp:468
GLHelper::drawText
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, int align=0, double width=-1)
Definition: GLHelper.cpp:673
RGBColor
Definition: RGBColor.h:39
SUMO_ATTR_LINEWIDTH
@ SUMO_ATTR_LINEWIDTH
Definition: SUMOXMLDefinitions.h:715
GUIGlObject::setMicrosimID
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
Definition: GUIGlObject.cpp:173
GNEPoly::closePolygon
void closePolygon(bool allowUndo=true)
close polygon
Definition: GNEPoly.cpp:518
Boundary::reset
void reset()
Resets the boundary.
Definition: Boundary.cpp:66
GNEViewNet::getEditShapes
const GNEViewNetHelper::EditShapes & getEditShapes() const
get Edit Shape modul
Definition: GNEViewNet.cpp:470
NamedObjectCont::size
int size() const
Returns the number of stored items within the container.
Definition: NamedObjectCont.h:116
SUMOPolygon::myGEO
bool myGEO
specify if shape is handled as GEO coordinate (Main used in netedit)
Definition: SUMOPolygon.h:135
GUIVisualizationSettings::detailSettings
GUIVisualizationDetailSettings detailSettings
detail settings
Definition: GUIVisualizationSettings.h:683
Boundary::xmin
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:118
GNEShape
Definition: GNEShape.h:34
Shape::getShapeLayer
double getShapeLayer() const
Returns the layer of the Shape.
Definition: Shape.h:89
GeoConvHelper::getFinal
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
Definition: GeoConvHelper.h:105
GUIGlObject::buildNameCopyPopupEntry
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
Definition: GUIGlObject.cpp:225
GUISUMOAbstractView::getVisualisationSettings
GUIVisualizationSettings * getVisualisationSettings() const
get visualitation settings
Definition: GUISUMOAbstractView.cpp:1395
GNEPoly::myHintSize
static const double myHintSize
hint size of vertex
Definition: GNEPoly.h:240
PositionVector::around
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
Definition: PositionVector.cpp:74
GNEViewNet::buildSelectionACPopupEntry
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:338
GUITexturesHelper.h
GNEViewNet::getNetworkViewOptions
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:452
GNEPoly::myCurrentMovingVertexIndex
int myCurrentMovingVertexIndex
index of vertex that is been moved (-1 means that none vertex is been moved)
Definition: GNEPoly.h:236
PositionVector::closePolygon
void closePolygon()
ensures that the last position equals the first
Definition: PositionVector.cpp:1231
GNEShape::myNet
GNENet * myNet
the net to inform about updates
Definition: GNEShape.h:197
GNEViewNet.h
GUIGlObject::getGlID
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.cpp:149
GNEPoly::startGeometryMoving
void startGeometryMoving()
Definition: GNEPoly.cpp:81
GNEViewNet::getDottedAC
const GNEAttributeCarrier * getDottedAC() const
get AttributeCarrier under cursor
Definition: GNEViewNet.cpp:1026
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
SUMO_ATTR_LAYER
@ SUMO_ATTR_LAYER
A layer number.
Definition: SUMOXMLDefinitions.h:712
GLHelper::drawShapeDottedContourAroundClosedShape
static void drawShapeDottedContourAroundClosedShape(const GUIVisualizationSettings &s, const int type, const PositionVector &shape)
draw a dotted contour around the given closed shape with certain width
Definition: GLHelper.cpp:496
GNE_ATTR_PARAMETERS
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
Definition: SUMOXMLDefinitions.h:989
GNE_ATTR_CLOSE_SHAPE
@ GNE_ATTR_CLOSE_SHAPE
Close shape of a polygon (Used by GNEPolys)
Definition: SUMOXMLDefinitions.h:985
RGBColor::BLUE
static const RGBColor BLUE
Definition: RGBColor.h:191
GUIVisualizationSettings::scale
double scale
information about a lane's width (temporary, used for a single view)
Definition: GUIVisualizationSettings.h:632
GNE_SUPERMODE_NETWORK
@ GNE_SUPERMODE_NETWORK
Network mode (Edges, junctions, etc..)
Definition: GNEViewNetHelper.h:46
GNEShape::drawUsingSelectColor
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
Definition: GNEShape.cpp:144
GNEViewNetHelper::EditModes::currentSupermode
Supermode currentSupermode
the current supermode
Definition: GNEViewNetHelper.h:305
GeoConvHelper::cartesian2geo
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
Definition: GeoConvHelper.cpp:293
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GNEPoly::writeShape
void writeShape(OutputDevice &device)
writte shape element into a xml file
Definition: GNEPoly.cpp:192
Position::x
double x() const
Returns the x-position.
Definition: Position.h:56
GNEEdge.h
GNE_ATTR_BLOCK_SHAPE
@ GNE_ATTR_BLOCK_SHAPE
block shape of a graphic element (Used mainly in GNEShapes)
Definition: SUMOXMLDefinitions.h:983
GNEViewNet::getUndoList
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:1020
GNEViewNet::getDemandViewOptions
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
Definition: GNEViewNet.cpp:458
GNEPoly::deleteGeometryPoint
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:431
GNEPoly::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
Definition: GNEPoly.cpp:667
GUIPolygon::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIPolygon.cpp:127
GNEViewNetHelper::NetworkViewOptions::editingElevation
bool editingElevation() const
check if we're editing elevation
Definition: GNEViewNetHelper.cpp:1653
Shape::getShapeType
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:75
GNENetElement
Definition: GNENetElement.h:43
GUIGlObject
Definition: GUIGlObject.h:65
GNEPoly::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEPoly.cpp:620
PositionVector::indexOfClosest
int indexOfClosest(const Position &p) const
index of the closest position to p
Definition: PositionVector.cpp:940
GNEPoly::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEPoly.cpp:231
GUISUMOAbstractView::getPositionInformation
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Definition: GUISUMOAbstractView.cpp:190
Shape::getShapeRelativePath
bool getShapeRelativePath() const
Returns the relativePath of the Shape.
Definition: Shape.h:110
GNEViewNetHelper::DemandViewOptions::showShapes
bool showShapes() const
check if shapes has to be hide
Definition: GNEViewNetHelper.cpp:1779
GNEPoly::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEPoly.cpp:277
SUMO_ATTR_RELATIVEPATH
@ SUMO_ATTR_RELATIVEPATH
Definition: SUMOXMLDefinitions.h:793
SUMOPolygon::getShape
const PositionVector & getShape() const
Returns whether the shape of the polygon.
Definition: SUMOPolygon.h:81
PositionVector::insertAtClosest
int insertAtClosest(const Position &p, bool interpolateZ)
inserts p between the two closest positions
Definition: PositionVector.cpp:959
GNEShape::myBlockMovement
bool myBlockMovement
flag to block movement
Definition: GNEShape.h:203
SUMO_ATTR_FILL
@ SUMO_ATTR_FILL
Fill the polygon.
Definition: SUMOXMLDefinitions.h:714
GNENet::getViewNet
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2117
Position::distanceSquaredTo2D
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition: Position.h:248
GUIGlObject::buildPopupHeader
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
Definition: GUIGlObject.cpp:207
GUIVisualizationSettings::colorSettings
GUIVisualizationColorSettings colorSettings
color settings
Definition: GUIVisualizationSettings.h:677
GNEPoly::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEPoly.cpp:698
PositionVector::distance2D
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector)
Definition: PositionVector.cpp:1259
GUIVisualizationColorSettings::selectionColor
RGBColor selectionColor
basic selection color
Definition: GUIVisualizationSettings.h:129
GUIVisualizationSettings::getCircleResolution
int getCircleResolution() const
function to calculate circle resolution for all circles drawn in drawGL(...) functions
Definition: GUIVisualizationSettings.cpp:1679
GNEPoly::moveVertexShape
int moveVertexShape(const int index, const Position &oldPos, const Position &offset)
change position of a vertex of shape without commiting change
Definition: GNEPoly.cpp:102
Parameterised::setParametersStr
void setParametersStr(const std::string &paramsString)
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
Definition: Parameterised.cpp:139
GNEPoly::getGUIGlObject
const GUIGlObject * getGUIGlObject() const
get GUIGlObject associated to this GNEShape
Definition: GNEPoly.cpp:901
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
GNEPoly.h
GUIPolygon::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIPolygon.cpp:140
GNENet::addGLObjectIntoGrid
void addGLObjectIntoGrid(GUIGlObject *o)
add GL Object into net
Definition: GNENet.cpp:1322
GUIMainWindow
Definition: GUIMainWindow.h:46
Position::y
double y() const
Returns the y-position.
Definition: Position.h:61
SUMOXMLDefinitions::isValidTypeID
static bool isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
Definition: SUMOXMLDefinitions.cpp:979
PositionVector::positionAtOffset2D
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
Definition: PositionVector.cpp:273
Parameterised::areParametersValid
static bool areParametersValid(const std::string &value, bool report=false)
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
Definition: Parameterised.cpp:166
GNE_SUPERMODE_DEMAND
@ GNE_SUPERMODE_DEMAND
Demanding mode (Routes, Vehicles etc..)
Definition: GNEViewNetHelper.h:48
GUIGlID
unsigned int GUIGlID
Definition: GUIGlObject.h:42
InvalidArgument
Definition: UtilExceptions.h:56
Shape::setShapeLayer
void setShapeLayer(const double layer)
Sets a new layer.
Definition: Shape.h:143
GNE_ATTR_BLOCK_MOVEMENT
@ GNE_ATTR_BLOCK_MOVEMENT
block movement of a graphic element
Definition: SUMOXMLDefinitions.h:981
GUIGlObject::buildShowParamsPopupEntry
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
Definition: GUIGlObject.cpp:248
GNEPoly::setShapeEditedElement
void setShapeEditedElement(GNENetElement *element)
retrieve the netElement of which the shape is being edited
Definition: GNEPoly.cpp:480
GNEPoly::simplifyShape
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition: GNEPoly.cpp:582
GUIGlObject::buildCenterPopupEntry
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
Definition: GUIGlObject.cpp:216
GNEPoly::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEPoly.cpp:198
GNEPoly::~GNEPoly
~GNEPoly()
Destructor.
Definition: GNEPoly.cpp:67
GUIPolygon::setShapeNaviDegree
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
Definition: GUIPolygon.h:111
GNEPoly::getGlID
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GNEPoly.cpp:215
GNEPoly::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNEPoly.cpp:271
GUITexturesHelper::clearTextures
static void clearTextures()
clears loaded textures
Definition: GUITexturesHelper.cpp:136
RGBColor::invertedColor
RGBColor invertedColor() const
obtain inverted of current RGBColor
Definition: RGBColor.cpp:142
SUMOPolygon::myFill
bool myFill
Information whether the polygon has to be filled.
Definition: SUMOPolygon.h:138
GNEPoly::getShapeEditedElement
GNENetElement * getShapeEditedElement() const
retrieve the junction of which the shape is being edited
Definition: GNEPoly.cpp:490
Boundary::isInitialised
bool isInitialised() const
check if Boundary is Initialised
Definition: Boundary.cpp:216
GNE_ATTR_SELECTED
@ GNE_ATTR_SELECTED
element is selected
Definition: SUMOXMLDefinitions.h:971
StringTokenizer.h
GNEViewNet::getEditModes
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:434
GUIVisualizationSettings::drawDetail
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
Definition: GUIVisualizationSettings.cpp:1669
MID_GNE_POLYGON_SIMPLIFY_SHAPE
@ MID_GNE_POLYGON_SIMPLIFY_SHAPE
simplify polygon geometry
Definition: GUIAppEnum.h:900
GNEAttributeCarrier::getTagStr
const std::string & getTagStr() const
get tag assigned to this object in string format
Definition: GNEAttributeCarrier.cpp:1267
SUMOPolygon::getFill
bool getFill() const
Returns whether the polygon is filled.
Definition: SUMOPolygon.h:89
GNEUndoList
Definition: GNEUndoList.h:48
ShapeContainer::getPolygons
const Polygons & getPolygons() const
Returns all polygons.
Definition: ShapeContainer.h:149
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GNEPoly::myBlockShape
bool myBlockShape
flag for block shape
Definition: GNEPoly.h:227
Named::myID
std::string myID
The name of the object.
Definition: Named.h:133
GNEUndoList::p_begin
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:72
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
RGBColor::changedBrightness
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:153
GNEViewNetHelper::EditShapes::editingNetElementShapes
bool editingNetElementShapes
flag to edit net element shapes
Definition: GNEViewNetHelper.h:862
GUIPolygon::checkDraw
bool checkDraw(const GUIVisualizationSettings &s) const
check if Polygon can be drawn
Definition: GUIPolygon.cpp:256
GUITexturesHelper::getTextureID
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
Definition: GUITexturesHelper.cpp:112
GNEPoly::getVertexIndex
int getVertexIndex(Position pos, bool createIfNoExist, bool snapToGrid)
return index of a vertex of shape, or of a new vertex if position is over an shape's edge
Definition: GNEPoly.cpp:410
SUMO_ATTR_SHAPE
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
Definition: SUMOXMLDefinitions.h:690
GUIGlObject::getMicrosimID
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.cpp:163
GNEViewNetHelper::EditModes::networkEditMode
NetworkEditMode networkEditMode
the current Network edit mode
Definition: GNEViewNetHelper.h:308
GNEPoly::moveEntireShape
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEPoly.cpp:137
GNEPoly::myClosedShape
bool myClosedShape
flag to indicate if polygon is open or closed
Definition: GNEPoly.h:230
GNE_NMODE_MOVE
@ GNE_NMODE_MOVE
mode for moving network elements
Definition: GNEViewNetHelper.h:62
SUMO_ATTR_GEO
@ SUMO_ATTR_GEO
Definition: SUMOXMLDefinitions.h:816
GNEShape::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNEShape.cpp:123
GUIPolygon
Definition: GUIPolygon.h:41
GNEChange_Attribute.h
GNENet.h
GUIVisualizationSizeSettings::getExaggeration
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
Definition: GUIVisualizationSettings.cpp:212
Shape::setShapeColor
void setShapeColor(const RGBColor &col)
Sets a new color.
Definition: Shape.h:129
GNEShape::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNEShape.cpp:138
GNEPoly::endGeometryMoving
void endGeometryMoving()
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
Definition: GNEPoly.cpp:88
PositionVector::removeDoublePoints
void removeDoublePoints(double minDist=POSITION_EPS, bool assertLength=false)
Removes positions if too near.
Definition: PositionVector.cpp:1344
GNEPoly::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEPoly.cpp:766
GNEUndoList.h
Boundary::ymax
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:136
GNEPoly::changeFirstGeometryPoint
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition: GNEPoly.cpp:540