 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
56 shapeRotations.clear();
58 multiShapeRotations.clear();
59 multiShapeLengths.clear();
60 multiShapeUnified.clear();
67 for (
auto i : multiShape) {
68 multiShapeUnified.append(i);
76 int numberOfSegments = (int)shape.size() - 1;
78 if (numberOfSegments >= 0) {
80 shapeRotations.reserve(numberOfSegments);
81 shapeLengths.reserve(numberOfSegments);
83 for (
int i = 0; i < numberOfSegments; ++i) {
91 shapeRotations.push_back((
double)atan2((s.
x() - f.
x()), (f.
y() - s.
y())) * (double) 180.0 / (
double)
M_PI);
100 std::vector<int> numberOfSegments;
101 for (
auto i : multiShape) {
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>());
109 for (
int i = 0; i < (int)multiShape.size(); i++) {
111 multiShapeRotations.back().reserve(numberOfSegments.at(i));
112 multiShapeLengths.back().reserve(numberOfSegments.at(i));
114 for (
int j = 0; j < numberOfSegments.at(i); j++) {
116 const Position& f = multiShape[i][j];
118 const Position& s = multiShape[i][j + 1];
120 multiShapeLengths.at(i).push_back(f.
distanceTo(s));
122 multiShapeRotations.at(i).push_back((
double)atan2((s.
x() - f.
x()), (f.
y() - s.
y())) * (double) 180.0 / (
double)
M_PI);
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) :
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)),
172 myAdditionalName(additionalName),
173 myBlockMovement(blockMovement),
175 mySpecialColor(nullptr) {
220 if (i.isWriteXMLOptional() && !i.isCombinable()) {
222 if (i.getDefaultValue() != attribute) {
224 if (i.hasAttrSynonym()) {
225 device.
writeAttr(i.getAttrSynonym(), attribute);
228 if (i.isSVCPermission()) {
243 device.
writeAttr(i.getAttr(), attribute);
249 if (i.hasAttrSynonym()) {
250 device.
writeAttr(i.getAttrSynonym(), attribute);
253 if (i.isSVCPermission()) {
268 device.
writeAttr(i.getAttr(), attribute);
277 deviceChildren.
writeXMLHeader(
"rerouterValue",
"additional_file.xsd");
281 if (i->getAdditionalParents().size() < 1) {
282 i->writeAdditional(deviceChildren);
284 i->writeAdditional(deviceChildren);
287 deviceChildren.
close();
291 if (i->getAdditionalParents().size() < 2) {
292 i->writeAdditional(device);
294 i->writeAdditional(device);
359 i->startGeometryMoving();
380 i->endGeometryMoving();
413 new FXMenuCommand(ret, (
"Copy " +
getTagStr() +
" name to clipboard").c_str(),
nullptr, ret,
MID_COPY_NAME);
415 new FXMenuSeparator(ret);
422 new FXMenuSeparator(ret);
429 new FXMenuCommand(ret, (
"Cursor position inner additional: " +
toString(innerPos)).c_str(),
nullptr,
nullptr, 0);
433 new FXMenuCommand(ret, (
"Cursor position over " +
toString(
SUMO_TAG_LANE) +
": " +
toString(innerPos + lanePos)).c_str(),
nullptr,
nullptr, 0);
439 new FXMenuCommand(ret, (
"Cursor position inner additional: " +
toString(innerPos)).c_str(),
nullptr,
nullptr, 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);
498 myAdditional(additional) {}
503 if (myAdditional->myGeometry.shape.size() > 0 && myAdditional->myGeometry.shape.length() != 0) {
505 rotation = myAdditional->myGeometry.shape.rotationDegreeAtOffset((myAdditional->myGeometry.shape.length() / 2.)) - 90;
506 }
else if (additionalLane) {
524 glTranslated(position.x(), position.y(), myAdditional->getType() + 0.1);
528 glRotated(rotation, 0, 0, -1);
530 glRotated(180, 0, 0, 1);
532 glTranslated(offset.x(), offset.y(), 0);
534 if (myAdditional->drawUsingSelectColor()) {
535 if (!myAdditional->getTagProperty().canBlockMovement()) {
538 }
else if (myAdditional->myBlockMovement) {
546 if (!myAdditional->getTagProperty().canBlockMovement()) {
549 }
else if (myAdditional->myBlockMovement) {
570 if (i.hasStaticDefaultValue()) {
682 result += i.first +
"=" + i.second +
"|";
685 if (!result.empty()) {
692 std::vector<std::pair<std::string, std::string> >
694 std::vector<std::pair<std::string, std::string> > result;
697 result.push_back(std::make_pair(i.first, i.second));
708 std::vector<std::string> parsedValues;
711 parsedValues.push_back(stValues.
next());
714 for (
auto i : parsedValues) {
715 std::vector<std::string> parsedParameters;
718 parsedParameters.push_back(stParam.
next());
722 setParameter(parsedParameters.front(), parsedParameters.back());
731 throw ProcessError(
"Calling non-implemented function checkAdditionalChildRestriction during saving of " +
getTagStr() +
". It muss be reimplemented in child class");
void writeAdditional(OutputDevice &device) const
writte additional element into a xml file
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
bool isAdditionalBlocked() const
Check if additional item is currently blocked (i.e. cannot be moved with mouse)
GNESelectorFrame * getSelectorFrame() const
get frame for GNE_NMODE_SELECT
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.
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
FXIcon * getIcon() const
get FXIcon associated to this AC
virtual Position getPositionInView() const =0
Returns position of additional in view.
An Element which don't belongs to GNENet but has influency in the simulation.
A window containing a gl-object's parameter.
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
const std::string & getAdditionalID() const
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
const std::string getID() const
function to support debugging
#define WRITE_WARNING(msg)
An upper class for objects with additional parameters.
void calculateMultiShapeRotationsAndLengths()
calculate multi shape rotations and lenghts
bool isPlacedInRTree() const
return true if Tag correspond to an element that has has to be placed in RTREE
PositionVector shape
The shape of the additional element.
bool canMaskStartEndPos() const
return true if tag correspond to an element that can mask the attributes "start" and "end" position a...
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
Static storage of an output device and its base (abstract) implementation.
void setRotation(GNELane *additionalLane=nullptr)
set Rotation of block Icon (must be called in updateGeometry() function)
Boundary movingGeometryBoundary
boundary used during moving of elements (to avoid insertion in RTREE
double z() const
Returns the z-position.
void removeGLObjectFromGrid(GUIGlObject *o)
add GL Object into net
bool hasNext()
returns the information whether further substrings exist
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
PositionVector getShape() const
Returns additional element's shape.
void updateAdditionalID(const std::string &oldID, GNEAdditional *additional)
update additional ID in container
void calculateMultiShapeUnified()
calculate multi shape unified
begin/end of the description of a single lane
static OptionsCont & getOptions()
Retrieves the options.
void setDefaultValues()
change all attributes of additional with their default values (note: this cannot be undo)
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
open additional dialog (used in netedit)
Copy object name - popup entry.
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
virtual bool isAdditionalValid() const
check if current additional is valid to be writed into XML (by default true, can be reimplemented in ...
An special type of Attribute carrier that owns hierarchical elements.
void changeAdditionalID(const std::string &newID)
change ID of additional
bool hasMinimumNumberOfChildren() const
return true if tag correspond to an element that only have a limited number of children
static bool isValidDetectorID(const std::string &value)
whether the given string is a valid id for an detector
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
void close()
Closes the device and removes it from the dictionary.
std::string secondOriginalPosition
value for saving second original position over lane before moving
bool canWriteChildrenSeparate() const
return true if tag correspond to an element that can sort their children automatic
BlockIcon myBlockIcon
variable BlockIcon
SumoXMLTag
Numbers representing SUMO-XML - element names.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
virtual std::string getAdditionalProblem() const
return a string with the current additional problem (by default empty, can be reimplemented in childr...
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
PositionVector shape
The shape of the netElement element.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
const RGBColor * mySpecialColor
pointer to special color (used for drawing Additional with a certain color, mainly used for selection...
AdditionalMove myMove
variable AdditionalMove
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute attr
A road/street connecting two junctions (netedit-version)
virtual bool checkAdditionalChildRestriction() const
check restriction with the number of children
GNENet * getNet() const
get the net object
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
SumoXMLTag getTagSynonym() const
get tag synonym
const AdditionalGeometry & getAdditionalGeometry() const
obtain AdditionalGeometry
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
virtual std::string getAttribute(SumoXMLAttr key) const =0
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
void reset()
Resets the boundary.
static const double lockIcon
lock icons
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)
GUIVisualizationDetailSettings detailSettings
detail settings
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
BlockIcon(GNEAdditional *additional)
constructor
void selectAttributeCarrier(bool changeFlag=true)
void writePermissions(OutputDevice &into, SVCPermissions permissions)
writes allowed disallowed attributes if needed;
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
GUIGlID getGlID() const
Returns the numerical id of the object.
begin/end of the description of an edge
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
Network mode (Edges, junctions, etc..)
void clearGeometry()
reset geometry
Supermode currentSupermode
the current supermode
A point in 2D or 3D with translation and scaling methods.
double x() const
Returns the x-position.
const TagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
static bool isValidGenericParameterKey(const std::string &value)
whether the given string is a valid key for a generic parameter
std::string myAdditionalName
name of additional
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse)
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
const NetElementGeometry & getGeometry() const
struct for pack all variables related with geometry of elemement
static bool isValidGenericParameterValue(const std::string &value)
whether the given string is a valid value for a generic parameter
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
~GNEAdditional()
Destructor.
void setSpecialColor(const RGBColor *color)
set special color
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void drawIcon(const GUIVisualizationSettings &s, const double exaggeration, const double size=0.5) const
draw lock icon
void addGLObjectIntoGrid(GUIGlObject *o)
add GL Object into net
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
double y() const
Returns the y-position.
bool hasTagSynonym() const
return true if tag correspond to an element that will be written in XML with another tag
std::string getGenericParametersStr() const
return generic parameters in string format
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
const std::vector< GNEAdditional * > & getAdditionalChildren() const
return vector of additionals that have as Parent this edge (For example, Calibrators)
AdditionalGeometry()
constructor
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which additional element is located.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
bool isDrawable() const
return true if tag correspond to a drawable element
GUISelectedStorage gSelected
A global holder of selected objects.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
bool hasDialog() const
return true if tag correspond to an element that can be edited using a dialog
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
AdditionalGeometry myGeometry
geometry to be precomputed in updateGeometry(...)
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
void clearParameter()
Clears the parameter map.
reserved GLO type to pack all additionals
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
void endGeometryMoving()
begin movement (used when user click over additional to start a movement, to avoid problems with prob...
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
void removeLockedObject(const GUIGlObjectType type)
set object unselected
const std::string & getTagStr() const
get tag assigned to this object in string format
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.
Copy typed object name - popup entry.
void startGeometryMoving()
Stores the information about how to visualize structures.
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
const std::vector< GNEDemandElement * > & getDemandElementChildren() const
return vector of demand elements that have as Parent this edge (For example, Calibrators)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Position originalViewPosition
value for saving first original position over lane before moving
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
std::string firstOriginalLanePosition
value for saving first original position over lane before moving
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
An special type of Attribute carrier that owns hierarchical elements.
virtual void openAdditionalDialog()
open Additional Dialog
void deselect(GUIGlID id)
Deselects the object with the given id.
bool canMaskXYZPositions() const
return true if tag correspond to an element that can mask the attributes "X", "Y" and "Z" position as...
GNEViewParent * getViewParent() const
get the net object
LockGLObjectTypes * getLockGLObjectTypes() const
get selected items Modul
virtual void fixAdditionalProblem()
fix additional problem (by default throw an exception, has to be reimplemented in children)
int getNumberOfAttributes() const
get number of attributes
void calculateShapeRotationsAndLengths()
calculate shape rotations and lenghts
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
void addedLockedObject(const GUIGlObjectType type)
set object selected