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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // A class for visualizing and editing POIS in netedit (adapted from
18 // GUIPolygon and NLHandler)
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <string>
32 #include <utility>
34 #include <utils/geom/Position.h>
38 #include <utils/xml/XMLSubSys.h>
45 #include <utils/gui/div/GLHelper.h>
51 #include <netwrite/NWWriter_SUMO.h>
52 
53 #include "GNENet.h"
54 #include "GNEEdge.h"
55 #include "GNEUndoList.h"
56 #include "GNEViewNet.h"
57 #include "GNEChange_Attribute.h"
58 #include "GNEPoly.h"
59 #include "GNEJunction.h"
60 
61 // ===========================================================================
62 // static members
63 // ===========================================================================
64 const double GNEPoly::myHintSize = 0.8;
65 
66 // ===========================================================================
67 // method definitions
68 // ===========================================================================
69 GNEPoly::GNEPoly(GNENet* net, const std::string& id, const std::string& type, const PositionVector& shape, bool geo, bool fill,
70  const RGBColor& color, double layer, double angle, const std::string& imgFile, bool movementBlocked, bool shapeBlocked) :
71  GUIPolygon(id, type, color, shape, geo, fill, layer, angle, imgFile),
72  GNEShape(net, SUMO_TAG_POLY, ICON_LOCATEPOLY, movementBlocked, shapeBlocked),
73  myNetElementShapeEdited(NULL),
74  myClosedShape(shape.front() == shape.back()),
75  mySimplifiedShape(false),
76  myCurrentMovingVertexIndex(-1) {
77  // check if imgFile is valid
78  if (!imgFile.empty() && GUITexturesHelper::getTextureID(imgFile) == -1) {
79  setImgFile("");
80  }
81  // set GEO shape
83  for (int i = 0; i < (int) myGeoShape.size(); i++) {
85  }
86 }
87 
88 
90 
91 
92 int
93 GNEPoly::moveVertexShape(const int index, const Position& oldPos, const Position& offset) {
94  // only move shape if block movement block shape are disabled
95  if (!myBlockMovement && !myBlockShape && (index != -1)) {
96  // check that index is correct before change position
97  if (index < (int)myShape.size()) {
98  // save current moving vertex
100  // if closed shape and cliked is first or last, move both giving more priority to first always
101  if (myClosedShape && (index == 0 || index == (int)myShape.size() - 1)) {
102  myShape.front() = oldPos;
103  myShape.front().add(offset);
104  myShape.back() = oldPos;
105  myShape.back().add(offset);
106  return 0;
107  } else {
108  // change position of vertex
109  myShape[index] = oldPos;
110  myShape[index].add(offset);
111  return index;
112  }
113  } else {
114  throw InvalidArgument("Index greater than shape size");
115  }
116  } else {
117  return index;
118  }
119 }
120 
121 
122 void
123 GNEPoly::moveEntireShape(const PositionVector& oldShape, const Position& offset) {
124  // only move shape if block movement is disabled and block shape is enabled
125  if (!myBlockMovement && myBlockShape) {
126  // restore original shape
127  myShape = oldShape;
128  // change all points of the shape shape using offset
129  for (auto& i : myShape) {
130  i.add(offset);
131  }
132  // update Geometry after moving
133  updateGeometry();
134  }
135 }
136 
137 
138 void
140  if (!myBlockMovement) {
141  // disable current moving vertex
143  // restore original shape into shapeToCommit
144  PositionVector shapeToCommit = myShape;
145  // first check if double points has to be removed
146  shapeToCommit.removeDoublePoints(myHintSize);
147  if (shapeToCommit.size() != myShape.size()) {
148  WRITE_WARNING("Merged shape's point")
149  }
150  // check if polygon has to be closed
151  if (shapeToCommit.size() > 1 && shapeToCommit.front().distanceTo2D(shapeToCommit.back()) < (2 * myHintSize)) {
152  shapeToCommit.pop_back();
153  shapeToCommit.push_back(shapeToCommit.front());
154  }
155  // only use GNEChange_Attribute if we aren't editing a junction's shape
156  if (myNetElementShapeEdited == NULL) {
157  myShape = oldShape;
158  // commit new shape
159  undoList->p_begin("moving " + toString(SUMO_ATTR_SHAPE) + " of " + toString(getTag()));
160  undoList->p_add(new GNEChange_Attribute(this, SUMO_ATTR_SHAPE, toString(shapeToCommit)));
161  undoList->p_end();
162  } else {
163  setAttribute(SUMO_ATTR_SHAPE, toString(shapeToCommit));
164  }
165  }
166 }
167 
168 
169 void
171  // simply refresh element in net
172  myNet->refreshElement(this);
173 }
174 
175 void
177  writeXML(device, myGEO);
178 }
179 
180 
181 Position
183  return myShape.getPolygonCenter();
184 }
185 
186 
187 GUIGlID
189  return GUIPolygon::getGlID();
190 }
191 
192 
193 const std::string&
195  if (myNetElementShapeEdited != NULL) {
197  } else {
198  return myNet->getMicrosimID();
199  }
200 }
201 
202 
205  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
206  buildPopupHeader(ret, app);
209  // build selection and show parameters menu
212  FXMenuCommand* simplifyShape = new FXMenuCommand(ret, "Simplify Shape\t\tReplace current shape with a rectangle", 0, &parent, MID_GNE_POLYGON_SIMPLIFY_SHAPE);
213  // disable simplify shape if polygon was already simplified
214  if (mySimplifiedShape) {
215  simplifyShape->disable();
216  }
217  // create open or close polygon's shape only if myNetElementShapeEdited is NULL
218  if (myNetElementShapeEdited == NULL) {
219  if (myClosedShape) {
220  new FXMenuCommand(ret, "Open shape\t\tOpen polygon's shape", 0, &parent, MID_GNE_POLYGON_OPEN);
221  } else {
222  new FXMenuCommand(ret, "Close shape\t\tClose polygon's shape", 0, &parent, MID_GNE_POLYGON_CLOSE);
223  }
224  }
225  // create a extra FXMenuCommand if mouse is over a vertex
226  int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
227  if (index != -1) {
228  FXMenuCommand* removeGeometryPoint = new FXMenuCommand(ret, "Remove geometry point\t\tRemove geometry point under mouse", 0, &parent, MID_GNE_POLYGON_DELETE_GEOMETRY_POINT);
229  FXMenuCommand* setFirstPoint = new FXMenuCommand(ret, "Set first geometry point\t\tSet", 0, &parent, MID_GNE_POLYGON_SET_FIRST_POINT);
230  // disable setFirstPoint if shape only have three points
231  if ((myClosedShape && (myShape.size() <= 4)) || (!myClosedShape && (myShape.size() <= 3))) {
232  removeGeometryPoint->disable();
233  }
234  // disable setFirstPoint if mouse is over first point
235  if (index == 0) {
236  setFirstPoint->disable();
237  }
238  }
239  return ret;
240 }
241 
242 
245  return GUIPolygon::getParameterWindow(app, parent);
246 }
247 
248 
249 Boundary
252 }
253 
254 
255 void
257  // change temporally attribute color if polygon is selected
258  bool selected = gSelected.isSelected(GLO_POLYGON, getGlID());
259  // simply use GUIPolygon::drawGL
261  // draw geometry details hints if is not too small
262  if (s.scale * myHintSize > 1.) {
263  // set values relative to mouse position regarding to shape
264  bool mouseOverVertex = false;
265  bool modeMove = myNet->getViewNet()->getCurrentEditMode() == GNE_MODE_MOVE;
266  Position mousePosition = myNet->getViewNet()->getPositionInformation();
267  double distanceToShape = myShape.distance2D(mousePosition);
268  Position PostionOverShapeLine = myShape.size() > 1 ? myShape.positionAtOffset2D(myShape.nearest_offset_to_point2D(mousePosition)) : myShape[0];
269  // set colors
270  RGBColor invertedColor, darkerColor;
271  if (selected) {
272  invertedColor = myNet->selectionColor.invertedColor();
273  darkerColor = myNet->selectedLaneColor;
274  } else {
275  invertedColor = GLHelper::getColor().invertedColor();
276  darkerColor = GLHelper::getColor().changedBrightness(-32);
277  }
278  // push matrix
279  glPushName(getGlID());
280  // Draw geometry hints if polygon's shape isn't blocked
281  if (myBlockShape == false) {
282  // draw a boundary for moving using darkerColor
283  glPushMatrix();
284  glTranslated(0, 0, GLO_POLYGON + 0.01);
285  GLHelper::setColor(darkerColor);
287  glPopMatrix();
288  // draw points of shape
289  for (auto i : myShape) {
290  glPushMatrix();
291  glTranslated(i.x(), i.y(), GLO_POLYGON + 0.02);
292  // Change color of vertex and flag mouseOverVertex if mouse is over vertex
293  if (modeMove && (i.distanceTo(mousePosition) < myHintSize)) {
294  mouseOverVertex = true;
295  GLHelper::setColor(invertedColor);
296  } else {
297  GLHelper::setColor(darkerColor);
298  }
300  glPopMatrix();
301  // draw special symbols (Start, End and Block)
302  if (i == myShape.front()) {
303  // draw a "s" over first point
304  glPushMatrix();
305  glTranslated(i.x(), i.y(), GLO_POLYGON + 0.03);
306  GLHelper::drawText("S", Position(), .1, 2 * myHintSize, invertedColor);
307  glPopMatrix();
308  } else if ((i == myShape.back()) && (myClosedShape == false)) {
309  // draw a "e" over last point if polygon isn't closed
310  glPushMatrix();
311  glTranslated(i.x(), i.y(), GLO_POLYGON + 0.03);
312  GLHelper::drawText("E", Position(), .1, 2 * myHintSize, invertedColor);
313  glPopMatrix();
314  }
315  }
316  // check if draw moving hint has to be drawed
317  if (modeMove && (mouseOverVertex == false) && (myBlockMovement == false) && (distanceToShape < myHintSize)) {
318  // push matrix
319  glPushMatrix();
320  glTranslated(PostionOverShapeLine.x(), PostionOverShapeLine.y(), GLO_POLYGON + 0.04);
321  GLHelper::setColor(invertedColor);
323  glPopMatrix();
324  }
325  }
326  // pop name
327  glPopName();
328  }
329 }
330 
331 
332 int
333 GNEPoly::getVertexIndex(const Position& pos, bool createIfNoExist) {
334  // first check if vertex already exists
335  for (auto i : myShape) {
336  if (i.distanceTo2D(pos) < myHintSize) {
337  return myShape.indexOfClosest(i);
338  }
339  }
340  // if vertex doesn't exist, insert it
341  if (createIfNoExist && (myShape.distance2D(pos) < myHintSize)) {
342  return myShape.insertAtClosest(pos);
343  } else {
344  return -1;
345  }
346 }
347 
348 
349 void
350 GNEPoly::deleteGeometryPoint(const Position& pos, bool allowUndo) {
351  if (myShape.size() > 1) {
352  // obtain index
353  PositionVector modifiedShape = myShape;
354  int index = modifiedShape.indexOfClosest(pos);
355  // remove point dependending of
356  if (myClosedShape && (index == 0 || index == (int)modifiedShape.size() - 1)) {
357  modifiedShape.erase(modifiedShape.begin());
358  modifiedShape.erase(modifiedShape.end() - 1);
359  myShape.push_back(modifiedShape.front());
360  } else {
361  modifiedShape.erase(modifiedShape.begin() + index);
362  }
363  // set new shape depending of allowUndo
364  if (allowUndo) {
365  myNet->getViewNet()->getUndoList()->p_begin("delete geometry point");
368  } else {
369  // set new shape
370  myShape = modifiedShape;
371  // Check if new shape is closed
372  myClosedShape = (myShape.front() == myShape.back());
373  // disable simplified shape flag
374  mySimplifiedShape = false;
375  // update geometry to avoid grabbing Problems
376  updateGeometry();
377  }
378  } else {
379  WRITE_WARNING("Number of remaining points insufficient")
380  }
381 }
382 
383 
384 bool
386  return myClosedShape;
387 }
388 
389 
390 void
392  if (element) {
393  myNetElementShapeEdited = element;
394  } else {
395  throw InvalidArgument("Junction cannot be NULL");
396  }
397 }
398 
399 
403 }
404 
405 
406 void
407 GNEPoly::openPolygon(bool allowUndo) {
408  // only open if shape is closed
409  if (myClosedShape) {
410  if (allowUndo) {
411  myNet->getViewNet()->getUndoList()->p_begin("open polygon");
414  } else {
415  myClosedShape = false;
416  myShape.pop_back();
417  // disable simplified shape flag
418  mySimplifiedShape = false;
419  // update geometry to avoid grabbing Problems
420  updateGeometry();
421  }
422  } else {
423  WRITE_WARNING("Polygon already opened")
424  }
425 }
426 
427 
428 void
429 GNEPoly::closePolygon(bool allowUndo) {
430  // only close if shape is opened
431  if (myClosedShape == false) {
432  if (allowUndo) {
433  myNet->getViewNet()->getUndoList()->p_begin("close shape");
436  } else {
437  myClosedShape = true;
439  // disable simplified shape flag
440  mySimplifiedShape = false;
441  // update geometry to avoid grabbing Problems
442  updateGeometry();
443  }
444  } else {
445  WRITE_WARNING("Polygon already closed")
446  }
447 }
448 
449 
450 void
451 GNEPoly::changeFirstGeometryPoint(int oldIndex, bool allowUndo) {
452  // check that old index is correct
453  if (oldIndex >= (int)myShape.size()) {
454  throw InvalidArgument("Invalid old Index");
455  } else if (oldIndex == 0) {
456  WRITE_WARNING("Selected point must be different of the first point")
457  } else {
458  // Configure new shape
459  PositionVector newShape;
460  for (int i = oldIndex; i < (int)myShape.size(); i++) {
461  newShape.push_back(myShape[i]);
462  }
463  if (myClosedShape) {
464  for (int i = 1; i < oldIndex; i++) {
465  newShape.push_back(myShape[i]);
466  }
467  newShape.push_back(newShape.front());
468  } else {
469  for (int i = 0; i < oldIndex; i++) {
470  newShape.push_back(myShape[i]);
471  }
472  }
473  // set new rotated shape
474  if (allowUndo) {
475  myNet->getViewNet()->getUndoList()->p_begin("change first geometry point");
478  } else {
479  // set new shape
480  myShape = newShape;
481  // Check if new shape is closed
482  myClosedShape = (myShape.front() == myShape.back());
483  // disable simplified shape flag
484  mySimplifiedShape = false;
485  // update geometry to avoid grabbing Problems
486  updateGeometry();
487  }
488  }
489 }
490 
491 
492 void
493 GNEPoly::simplifyShape(bool allowUndo) {
494  if (!mySimplifiedShape) {
495  const Boundary b = myShape.getBoxBoundary();
496  PositionVector simplifiedShape;
497  // create a square as simplified shape
498  simplifiedShape.push_back(Position(b.xmin(), b.ymin()));
499  simplifiedShape.push_back(Position(b.xmin(), b.ymax()));
500  simplifiedShape.push_back(Position(b.xmax(), b.ymax()));
501  simplifiedShape.push_back(Position(b.xmax(), b.ymin()));
502  simplifiedShape.push_back(simplifiedShape[0]);
503  // set new shape depending of allowUndo
504  if (allowUndo) {
505  myNet->getViewNet()->getUndoList()->p_begin("simplify shape");
508  } else {
509  // set new shape
510  myShape = simplifiedShape;
511  // Check if new shape is closed
512  myClosedShape = (myShape.front() == myShape.back());
513  // update geometry to avoid grabbing Problems
514  updateGeometry();
515  }
516  // change flag after setting simplified shape
517  mySimplifiedShape = true;
518  } else {
519  WRITE_WARNING("Polygon already simplified")
520  }
521 }
522 
523 
524 std::string
526  switch (key) {
527  case SUMO_ATTR_ID:
528  return myID;
529  case SUMO_ATTR_SHAPE:
530  return toString(myShape);
531  case SUMO_ATTR_GEOSHAPE:
532  return toString(myGeoShape);
533  case SUMO_ATTR_COLOR:
534  return toString(myColor);
535  case SUMO_ATTR_FILL:
536  return toString(myFill);
537  case SUMO_ATTR_LAYER:
538  return toString(myLayer);
539  case SUMO_ATTR_TYPE:
540  return myType;
541  case SUMO_ATTR_IMGFILE:
542  return myImgFile;
543  case SUMO_ATTR_ANGLE:
544  return toString(getNaviDegree());
545  case SUMO_ATTR_GEO:
546  return toString(myGEO);
548  return toString(myBlockMovement);
550  return toString(myBlockShape);
552  return toString(myClosedShape);
553  default:
554  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
555  }
556 }
557 
558 
559 void
560 GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
561  if (value == getAttribute(key)) {
562  return; //avoid needless changes, later logic relies on the fact that attributes have changed
563  }
564  switch (key) {
565  case SUMO_ATTR_ID:
566  case SUMO_ATTR_SHAPE:
567  case SUMO_ATTR_GEOSHAPE:
568  case SUMO_ATTR_COLOR:
569  case SUMO_ATTR_FILL:
570  case SUMO_ATTR_LAYER:
571  case SUMO_ATTR_TYPE:
572  case SUMO_ATTR_IMGFILE:
573  case SUMO_ATTR_ANGLE:
574  case SUMO_ATTR_GEO:
578  undoList->p_add(new GNEChange_Attribute(this, key, value));
579  break;
580  default:
581  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
582  }
583 }
584 
585 
586 bool
587 GNEPoly::isValid(SumoXMLAttr key, const std::string& value) {
588  switch (key) {
589  case SUMO_ATTR_ID:
590  return isValidID(value) && (myNet->retrievePolygon(value, false) == 0);
591  case SUMO_ATTR_SHAPE:
592  case SUMO_ATTR_GEOSHAPE: {
593  bool ok = true;
594  // check if shape can be parsed
595  PositionVector shape = GeomConvHelper::parseShapeReporting(value, "user-supplied position", 0, ok, true);
596  return (shape.size() > 0);
597  }
598  case SUMO_ATTR_COLOR:
599  return canParse<RGBColor>(value);
600  case SUMO_ATTR_FILL:
601  return canParse<bool>(value);
602  case SUMO_ATTR_LAYER:
603  return canParse<double>(value);
604  case SUMO_ATTR_TYPE:
605  return true;
606  case SUMO_ATTR_IMGFILE:
607  if (value == "") {
608  return true;
609  } else if (isValidFilename(value)) {
610  // check that image can be loaded
611  return GUITexturesHelper::getTextureID(value) != -1;
612  } else {
613  return false;
614  }
615  case SUMO_ATTR_ANGLE:
616  return canParse<double>(value);
617  case SUMO_ATTR_GEO:
618  return canParse<bool>(value);
620  return canParse<bool>(value);
622  return canParse<bool>(value);
624  if (canParse<bool>(value)) {
625  bool closePolygon = parse<bool>(value);
626  if (closePolygon && (myShape.begin() == myShape.end())) {
627  // Polygon already closed, then invalid value
628  return false;
629  } else if (!closePolygon && (myShape.begin() != myShape.end())) {
630  // Polygon already open, then invalid value
631  return false;
632  } else {
633  return true;
634  }
635  } else {
636  return false;
637  }
638  default:
639  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
640  }
641 }
642 
643 // ===========================================================================
644 // private
645 // ===========================================================================
646 
647 void
648 GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value) {
649  switch (key) {
650  case SUMO_ATTR_ID: {
651  std::string oldID = myID;
652  myID = value;
653  myNet->changeShapeID(this, oldID);
654  break;
655  }
656  case SUMO_ATTR_SHAPE: {
657  bool ok = true;
658  // set new shape
659  myShape = GeomConvHelper::parseShapeReporting(value, "netedit-given", 0, ok, true);
660  // set GEO shape
662  for (int i = 0; i < (int) myGeoShape.size(); i++) {
664  }
665  // Check if new shape is closed
666  myClosedShape = (myShape.front() == myShape.back());
667  // disable simplified shape flag
668  mySimplifiedShape = false;
669  // update geometry of shape edited element
672  }
673  break;
674  }
675  case SUMO_ATTR_GEOSHAPE: {
676  bool ok = true;
677  // set new GEO shape
678  myGeoShape = GeomConvHelper::parseShapeReporting(value, "netedit-given", 0, ok, true);
679  // set shape
680  myShape = myGeoShape ;
681  for (int i = 0; i < (int) myShape.size(); i++) {
683  }
684  // Check if new shape is closed
685  myClosedShape = (myShape.front() == myShape.back());
686  // disable simplified shape flag
687  mySimplifiedShape = false;
688  // update geometry of shape edited element
691  }
692  break;
693  }
694  case SUMO_ATTR_COLOR:
695  myColor = parse<RGBColor>(value);
696  break;
697  case SUMO_ATTR_FILL:
698  myFill = parse<bool>(value);
699  break;
700  case SUMO_ATTR_LAYER:
701  myLayer = parse<double>(value);
702  break;
703  case SUMO_ATTR_TYPE:
704  myType = value;
705  break;
706  case SUMO_ATTR_IMGFILE:
707  myType = value;
708  break;
709  case SUMO_ATTR_ANGLE:
710  setNaviDegree(parse<double>(value));
711  break;
712  case SUMO_ATTR_GEO:
713  myGEO = parse<bool>(value);
714  break;
716  myBlockMovement = parse<bool>(value);
717  break;
719  myBlockShape = parse<bool>(value);
720  break;
722  myClosedShape = parse<bool>(value);
723  if (myClosedShape) {
725  } else {
726  myShape.pop_back();
727  }
728  // disable simplified shape flag
729  mySimplifiedShape = false;
730  break;
731  default:
732  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
733  }
734  // update geometry after every change
735  updateGeometry();
736 }
737 
738 
739 /****************************************************************************/
PositionVector myShape
The positions of the polygon.
Definition: SUMOPolygon.h:124
close opened polygon
Definition: GUIAppEnum.h:747
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:137
void openPolygon(bool allowUndo=true)
open polygon
Definition: GNEPoly.cpp:407
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:131
double scale
information about a lane&#39;s width (temporary, used for a single view)
GNEPoly(GNENet *net, const std::string &id, const std::string &type, const PositionVector &shape, bool geo, bool fill, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool movementBlocked, bool shapeBlocked)
Constructor.
Definition: GNEPoly.cpp:69
bool myGEO
specify if shape is handled as GEO coordinate (Main used in netedit)
Definition: SUMOPolygon.h:127
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:156
a polygon
mode for moving things
Definition: GNEViewNet.h:52
bool myFill
Information whether the polygon has to be filled.
Definition: SUMOPolygon.h:130
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:183
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
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) ...
void refreshElement(GUIGlObject *o)
refreshes boundary information for o and update
Definition: GNENet.cpp:1082
block shape of a graphic element (Used mainly in GNEShapes)
const std::string & getParentName() const
Returns the name of the parent object.
Definition: GNEPoly.cpp:194
int indexOfClosest(const Position &p) const
index of the closest position to p
static const RGBColor selectedLaneColor
color of selected lane
Definition: GNENet.h:110
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
A layer number.
Stores the information about how to visualize structures.
bool isPolygonClosed() const
check if polygon is closed
Definition: GNEPoly.cpp:385
double y() const
Returns the y-position.
Definition: Position.h:67
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(...)
Definition: GNEPoly.cpp:139
void updateGeometry()
update pre-computed geometry information
Definition: GNEPoly.cpp:170
double x() const
Returns the x-position.
Definition: Position.h:62
Close shape of a polygon (Used by GNEPolys)
int getVertexIndex(const Position &pos, bool createIfNoExist=true)
return index of a vertex of shape, or of a new vertex if position is over an shape&#39;s edge ...
Definition: GNEPoly.cpp:333
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
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:487
GNEPoly * retrievePolygon(const std::string &id, bool failHard=true) const
get Polygon by id
Definition: GNENet.cpp:935
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:91
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition: GNEPoly.h:214
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:84
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
PositionVector myGeoShape
Latitude of Polygon.
Definition: GNEPoly.h:208
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
RGBColor invertedColor() const
obtain inverted of current RGBColor
Definition: RGBColor.cpp:145
static bool isValidFilename(const std::string &value)
true if value is a valid file value
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:350
GNENet * myNet
the net to inform about updates
Definition: GNEShape.h:157
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
void closePolygon(bool allowUndo=true)
close polygon
Definition: GNEPoly.cpp:429
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
std::string myType
The type of the Shape.
Definition: Shape.h:157
GUIVisualizationSizeSettings polySize
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
static bool isValidID(const std::string &value)
true if value is a valid sumo ID
GNENetElement * myNetElementShapeEdited
junction of which the shape is being edited (optional)
Definition: GNEPoly.h:205
GNEUndoList * getUndoList() const
get the undoList object
void removeDoublePoints(double minDist=POSITION_EPS, bool assertLength=false)
Removes positions if too near.
bool myBlockShape
flag for block shape
Definition: GNEShape.h:163
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
simplify polygon geometry
Definition: GUIAppEnum.h:745
double getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:93
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:449
bool myBlockMovement
flag to block movement
Definition: GNEShape.h:160
void writeShape(OutputDevice &device)
writte shape element into a xml file
Definition: GNEPoly.cpp:176
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
Definition: GNEUndoList.cpp:91
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A list of positions.
static const double myHintSize
hint size of vertex
Definition: GNEPoly.h:221
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
friend class GNEChange_Attribute
declare friend class
int myCurrentMovingVertexIndex
index of vertex that is been moved (-1 means that none vertex is been moved)
Definition: GNEPoly.h:217
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
block movement of a graphic element
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIPolygon.cpp:80
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEPoly.cpp:256
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:125
edge: the shape in xml-definition
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEPoly.cpp:587
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:350
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:560
void changeShapeID(GNEShape *s, const std::string &OldID)
change Shape ID
Definition: GNENet.cpp:1964
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in all GNEAttributeCarriers.
Definition: GNEPoly.cpp:525
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEPoly.cpp:204
EditMode getCurrentEditMode() const
get the current edit mode
unsigned int GUIGlID
Definition: GUIGlObject.h:49
std::string myID
The name of the object.
Definition: Named.h:126
int moveVertexShape(const int index, const Position &oldPos, const Position &offset)
change position of a vertex of shape without commiting change
Definition: GNEPoly.cpp:93
virtual void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIPolygon.cpp:142
void setShapeEditedElement(GNENetElement *element)
retrieve the netElement of which the shape is being edited
Definition: GNEPoly.cpp:391
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition: GNEPoly.cpp:493
virtual void updateGeometry()=0
update pre-computed geometry information
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEPoly.cpp:182
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GNEPoly.cpp:188
void setNaviDegree(const double angle)
Sets a new angle in navigational degrees.
Definition: Shape.h:136
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNEPoly.cpp:244
std::string myImgFile
The angle of the Shape.
Definition: Shape.h:169
The popup menu of a globject.
GNENetElement * getShapeEditedElement() const
retrieve the junction of which the shape is being edited
Definition: GNEPoly.cpp:401
RGBColor myColor
The color of the Shape.
Definition: Shape.h:160
void setImgFile(const std::string &imgFile)
Sets a new imgFile.
Definition: Shape.h:143
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
double myLayer
The layer of the Shape.
Definition: Shape.h:163
GUIGlID getGlID() const
Returns the numerical id of the object.
void writeXML(OutputDevice &out, bool geo=false)
Definition: SUMOPolygon.cpp:55
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
Set a vertex of polygon as first verte.
Definition: GUIAppEnum.h:751
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
~GNEPoly()
Destructor.
Definition: GNEPoly.cpp:89
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
static const RGBColor selectionColor
Definition: GNENet.h:107
bool myClosedShape
flag to indicate if polygon is open or closed
Definition: GNEPoly.h:211
open closed polygon
Definition: GUIAppEnum.h:749
void add(double xoff, double yoff, double zoff)
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:143
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIPolygon.cpp:93
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void closePolygon()
ensures that the last position equals the first
GUISelectedStorage gSelected
A global holder of selected objects.
A color information.
A window containing a gl-object&#39;s parameter.
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition: GNEPoly.cpp:451
static PositionVector parseShapeReporting(const std::string &shpdef, const std::string &objecttype, const char *objectid, bool &ok, bool allowEmpty, bool report=true)
Builds a PositionVector from a string representation, reporting occured errors.
Fill the polygon.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
begin/end of the description of a polygon
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEPoly.cpp:250
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1607
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEPoly.cpp:123
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:455
SumoXMLTag getTag() const
get XML Tag assigned to this object