63 myAdditionalName(additionalName),
64 myBlockMovement(blockMovement),
65 myFirstAdditionalParent(nullptr),
66 mySecondAdditionalParent(nullptr),
67 myBlockIconRotation(0.) {
147 for (
auto i : tagProperties) {
150 if (i.second.isOptional() && i.second.hasDefaultValue() && !i.second.isCombinable()) {
152 if (i.second.getDefaultValue() != attribute) {
154 if (i.second.hasAttrSynonym()) {
155 device.
writeAttr(i.second.getAttrSynonym(), attribute);
158 if (i.second.isSVCPermission()) {
170 if (i.second.hasAttrSynonym()) {
171 device.
writeAttr(i.second.getAttrSynonym(), attribute);
174 if (i.second.isSVCPermission()) {
191 deviceChilds.
writeXMLHeader(
"rerouterValue",
"additional_file.xsd");
195 if (i->getSecondAdditionalParent() ==
nullptr) {
196 i->writeAdditional(deviceChilds);
198 i->writeAdditional(deviceChilds);
201 deviceChilds.
close();
205 if (i->getSecondAdditionalParent() ==
nullptr) {
206 i->writeAdditional(device);
208 i->writeAdditional(device);
322 const std::vector<GNEAdditional*>&
332 std::vector<GNEAdditional*> sortedEntryExits;
336 sortedEntryExits.push_back(i);
340 for (
auto i : myAdditionalChilds) {
342 sortedEntryExits.push_back(i);
346 if (sortedEntryExits.size() == myAdditionalChilds.size()) {
347 myAdditionalChilds = sortedEntryExits;
349 throw ProcessError(
"Some additional childs were lost during sorting");
353 std::vector<std::pair<std::pair<double, double>,
GNEAdditional*> > sortedChilds;
356 sortedChilds.push_back(std::make_pair(std::make_pair(0., 0.), i));
359 sortedChilds.back().first.first = parse<double>(i->getAttribute(
SUMO_ATTR_TIME));
361 sortedChilds.back().first.first = parse<double>(i->getAttribute(
SUMO_ATTR_BEGIN));
365 sortedChilds.back().first.second = parse<double>(i->getAttribute(
SUMO_ATTR_END));
367 sortedChilds.back().first.second = sortedChilds.back().first.first;
371 std::sort(sortedChilds.begin(), sortedChilds.end());
373 if (sortedChilds.size() == myAdditionalChilds.size()) {
374 myAdditionalChilds.clear();
375 for (
auto i : sortedChilds) {
376 myAdditionalChilds.push_back(i.second);
379 throw ProcessError(
"Some additional childs were lost during sorting");
388 std::vector<std::pair<std::pair<double, double>,
GNEAdditional*> > sortedChilds;
391 sortedChilds.push_back(std::make_pair(std::make_pair(0., 0.), i));
394 sortedChilds.back().first.first = parse<double>(i->getAttribute(
SUMO_ATTR_TIME));
396 sortedChilds.back().first.first = parse<double>(i->getAttribute(
SUMO_ATTR_BEGIN));
400 sortedChilds.back().first.second = parse<double>(i->getAttribute(
SUMO_ATTR_END));
402 sortedChilds.back().first.second = sortedChilds.back().first.first;
406 std::sort(sortedChilds.begin(), sortedChilds.end());
408 if (sortedChilds.size() == myAdditionalChilds.size()) {
409 if (sortedChilds.size() <= 1) {
413 for (
int i = 0; i < (int)sortedChilds.size() - 1; i++) {
414 if (sortedChilds.at(i).first.second > sortedChilds.at(i + 1).first.first) {
421 throw ProcessError(
"Some additional childs were lost during sorting");
429 if (edge ==
nullptr) {
442 if (edge ==
nullptr) {
452 const std::vector<GNEEdge*>&
461 if (lane ==
nullptr) {
474 if (lane ==
nullptr) {
484 const std::vector<GNELane*>&
503 new FXMenuSeparator(ret);
510 new FXMenuSeparator(ret);
517 new FXMenuCommand(ret, (
"Cursor position inner additional: " +
toString(innerPos)).c_str(), 0, 0, 0);
527 new FXMenuCommand(ret, (
"Cursor position inner additional: " +
toString(innerPos)).c_str(), 0, 0, 0);
530 const double edgePos = edge->
getLanes().at(0)->getShape().nearest_offset_to_point2D(
myShape[0]);
547 if (i.second.isUnique()) {
564 }
else if (
myShape.size() > 0) {
571 return Boundary(-0.1, 0.1, 0, 1, 0, 1);
578 if (edges.size() == 0) {
581 }
else if (edges.size() == 1) {
586 auto it = edges.begin();
587 while (it != edges.end() - 1) {
591 if (currentEdge->
getID() == nextEdge->
getID()) {
600 "' ins't consecutive to " +
toString(nextEdge->
getTag()) +
" '" + nextEdge->
getID() +
"'");
615 if (i.second.hasDefaultValue()) {
627 }
else if (additionalLane) {
650 glRotated(180, 0, 0, 1);
691 for (
auto j : i->getLanes()) {
692 std::pair<Position, double> posRot;
694 if (j->getShape().length() - 6 > 0) {
695 posRot.first = j->getShape().positionAtOffset(j->getShape().length() - 6);
696 posRot.second = j->getShape().rotationDegreeAtOffset(j->getShape().length() - 6);
698 posRot.first = j->getShape().positionAtOffset(j->getShape().length());
699 posRot.second = j->getShape().rotationDegreeAtOffset(j->getShape().length());
707 std::pair<Position, double> posRot;
709 if (i->getShape().length() - 6 > 0) {
710 posRot.first = i->getShape().positionAtOffset(i->getShape().length() - 6);
711 posRot.second = i->getShape().rotationDegreeAtOffset(i->getShape().length() - 6);
713 posRot.first = i->getShape().positionAtOffset(i->getShape().length());
714 posRot.second = i->getShape().rotationDegreeAtOffset(i->getShape().length());
723 std::vector<Position> posConnection;
727 posConnection.push_back(i->getPositionInView());
730 posConnection.push_back(
Position(i->getPositionInView().x() + A, i->getPositionInView().y()));
732 posConnection.push_back(
Position(i->getPositionInView().x(), i->getPositionInView().y() - B));
736 posConnection.push_back(
Position(i->getPositionInView().x(), i->getPositionInView().y() + B));
738 posConnection.push_back(
Position(i->getPositionInView().x() - A, i->getPositionInView().y()));
748 std::vector<Position> posConnection;
752 posConnection.push_back(i.first);
755 posConnection.push_back(
Position(i.first.x() + A, i.first.y()));
757 posConnection.push_back(
Position(i.first.x(), i.first.y() - B));
761 posConnection.push_back(
Position(i.first.x(), i.first.y() + B));
763 posConnection.push_back(
Position(i.first.x() - A, i.first.y()));
779 glTranslated(0, 0,
getType() - 0.01);
782 for (
auto j = i.begin(); (j + 1) != i.end(); j++) {
813 throw InvalidArgument(
"Additional ID " + newID +
" contains invalid characters");
827 if (oldEdge ==
nullptr) {
841 if (oldLane ==
nullptr) {
920 throw ProcessError(
"Calling non-implemented function checkAdditionalChildRestriction during saving of " +
toString(
getTag()) +
". It muss be reimplemented in child class");
975 result += i.first +
"=" + i.second +
"|";
978 if (!result.empty()) {
985 std::vector<std::pair<std::string, std::string> >
987 std::vector<std::pair<std::string, std::string> > result;
990 result.push_back(std::make_pair(i.first, i.second));
1001 std::vector<std::string> parsedValues;
1004 parsedValues.push_back(stValues.
next());
1007 for (
auto i : parsedValues) {
1008 std::vector<std::string> parsedParameters;
1011 parsedParameters.push_back(stParam.
next());
1015 setParameter(parsedParameters.front(), parsedParameters.back());
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
void removeEdgeChild(GNEEdge *edge)
remove edge child
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
virtual void openAdditionalDialog()
open Additional Dialog
bool updateGenericParameter(const std::string &oldKey, const std::string &newKey)
update generic parameter
void addEdgeChild(GNEEdge *edge)
add edge child
Copy object name - popup entry.
void writePermissions(OutputDevice &into, SVCPermissions permissions)
writes allowed disallowed attributes if needed;
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
void close()
Closes the device and removes it from the dictionary.
SumoXMLTag
Numbers representing SUMO-XML - element names.
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
bool isAdditionalBlocked() const
Check if additional item is currently blocked (i.e. cannot be moved with mouse)
void setBlockIconRotation(GNELane *additionalLane=nullptr)
void writeAdditional(OutputDevice &device) const
writte additional element into a xml file
void removeAdditionalChild(GNEAdditional *additional)
remove additional child from this additional
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
bool hasMinimumNumberOfChilds() const
return true if tag correspond to an element that only have a limited number of childs ...
begin/end of the description of a single lane
const std::vector< GNEEdge * > & getEdgeChilds() const
get edge chidls
bool canBlockMovement() const
return true if tag correspond to an element that can block their movement
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
const std::string & getAdditionalID() const
returns Additional ID
const std::vector< GNELane * > & getLaneChilds() const
get lanes of VSS
void changeFirstAdditionalParent(const std::string &newAdditionalParentID)
change first additional parent of additional
GNEAdditional(const std::string &id, GNEViewNet *viewNet, GUIGlObjectType type, SumoXMLTag tag, std::string additionalName, bool blockMovement)
Constructor.
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
Boundary myMovingGeometryBoundary
boundary used during moving of elements
Stores the information about how to visualize structures.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
double y() const
Returns the y-position.
void unsetParameter(const std::string &key)
Removes a parameter.
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
PositionVector getShape() const
Returns additional element's shape.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
double x() const
Returns the x-position.
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes ...
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
weights: time range begin
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
FXIcon * getIcon() const
get FXIcon associated to this AC
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void setDefaultValues()
change all attributes of additional with their default values (note: this cannot be undo) ...
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
virtual bool checkAdditionalChildRestriction() const
check restriction with the number of childs
bool removeGenericParameter(const std::string &key)
remove generic parameter
static bool isValidGenericParameterKey(const std::string &value)
whether the given string is a valid key for a generic parameter
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void changeAdditionalID(const std::string &newID)
change ID of additional
A class that stores a 2D geometrical boundary.
std::vector< PositionVector > myChildConnectionPositions
Matrix with the Vertex's positions of connections between parents an their childs.
virtual std::string getAttribute(SumoXMLAttr key) const =0
#define WRITE_WARNING(msg)
static OptionsCont & getOptions()
Retrieves the options.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
SumoXMLTag getTagSynonym() const
get tag synonym
bool showLockIcon() const
check if lock icon should be visible
void drawChildConnections() const
draw connections between Parent and childrens
static bool isValidGenericParameterValue(const std::string &value)
whether the given string is a valid value for a generic parameter
void updateAdditionalID(const std::string &oldID, GNEAdditional *additional)
update additional ID in container
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void drawLockIcon(double size=0.5) const
draw lock icon
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
void addAdditionalChild(GNEAdditional *additional)
add additional child to this edge
PositionVector myShape
The shape of the additional element.
GNEAdditional * getSecondAdditionalParent() const
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
A point in 2D or 3D with translation and scaling methods.
std::string myAdditionalName
name of additional
void removeGLObjectFromGrid(GUIGlObject *o)
add GL Object into net
bool updateGenericParameterValue(const std::string &key, const std::string &newValue)
update value generic parameter
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void selectAttributeCarrier(bool changeFlag=true)
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
void updateChildConnections()
update Connection's geometry
Boundary & grow(double by)
extends the boundary by the given amount
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
const std::string getID() const
function to support debugging
void removeAdditionalChild(GNEAdditional *additional)
remove additional child from this edge
void sortAdditionalChilds()
sort childs (used by Rerouters and VSS)
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
bool hasTagSynonym() const
return true if tag correspond to an element that will be written in XML with another tag ...
~GNEAdditional()
Destructor.
An upper class for objects with additional parameters.
virtual void updateGeometry(bool updateGrid)=0
update pre-computed geometry information
Position myBlockIconOffset
The offSet of the block icon.
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse) ...
std::vector< GNEAdditional * > myAdditionalChilds
vector with the Additional childs
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
begin/end of the description of an edge
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
GNEAdditional * getFirstAdditionalParent() const
A road/street connecting two junctions (netedit-version)
void reset()
Resets the boundary.
void changeSecondAdditionalParent(const std::string &newAdditionalParentID)
change second additional parent of additional
trigger: the time of the step
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which additional element is located.
const PositionVector & getShape() const
returns the shape of the lane
void deselect(GUIGlID id)
Deselects the object with the given id.
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
double length() const
Returns the length.
GNEEdge * changeEdge(GNEEdge *oldEdge, const std::string &newEdgeID)
change edge of additional
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
An Element which don't belongs to GNENet but has influency in the simulation.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
std::vector< std::pair< Position, double > > mySymbolsPositionAndRotation
position and rotation of every simbol over lane
bool isInitialised() const
check if Boundary is Initialised
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
std::string getGenericParametersStr() const
return generic parameters in string format
open additional dialog (used in netedit)
GNENet * getNet() const
get the net object
std::string generateAdditionalChildID(SumoXMLTag childTag)
gererate a new ID for an additional child
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
GUIGlID getGlID() const
Returns the numerical id of the object.
Static storage of an output device and its base (abstract) implementation.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static bool isRouteValid(const std::vector< GNEEdge *> &edges, bool report)
check if a route is valid
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
void mouseOverObject(const GUIVisualizationSettings &s) const
method for check if mouse is over objects
static const TagValues & getTagProperties(SumoXMLTag tag)
get Tag Properties
void addAdditionalChild(GNEAdditional *additional)
add additional child to this additional
void removeLaneChild(GNELane *lane)
remove lane child
void endGeometryMoving()
begin movement (used when user click over additional to start a movement, to avoid problems with prob...
bool checkAdditionalChildsOverlapping() const
check if childs are overlapped (Used by Rerouters)
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return vector of additionals that have as Parent this edge (For example, Calibrators) ...
void addGLObjectIntoGrid(GUIGlObject *o)
add GL Object into net
GUISelectedStorage gSelected
A global holder of selected objects.
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
void startGeometryMoving()
Copy typed object name - popup entry.
A window containing a gl-object's parameter.
double myBlockIconRotation
The rotation of the block icon.
GNEAdditional * myFirstAdditionalParent
pointer to first Addititional parent
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
struct with the attribute Properties
GNELane * changeLane(GNELane *oldLane, const std::string &newLaneID)
change lane of additional
void addLaneChild(GNELane *lane)
add lane child
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
Position myBlockIconPosition
position of the block icon
std::vector< GNELane * > myLaneChilds
vector with the lane childs of this additional
bool addGenericParameter(const std::string &key, const std::string &value)
add generic parameter
void clearParameter()
Clears the parameter map.
GNEAdditional * mySecondAdditionalParent
pointer to second Addititional parent
std::vector< GNEEdge * > myEdgeChilds
vector with the edge childs of this additional
SumoXMLTag getTag() const
get XML Tag assigned to this object
SumoXMLTag getParentTag() const
if Tag owns a parent, return parent tag
virtual Position getPositionInView() const =0
Returns position of additional in view.