47 double& endPosValue,
bool& friendlyPosition) :
64 const auto& parentLanes =
myMovedElement->getHierarchicalElement()->getParentLanes();
66 const bool allowChangeLane =
myMovedElement->getNet()->getViewNet()->getViewParent()->getMoveFrame()->getCommonMoveOptions()->getAllowChangeLane();
72 if (geometryPoints.empty()) {
75 if (geometryPoints.front() == 0) {
85 if (parentLanes.size() > 1) {
102 return myEndPos->getMoveOperation();
115 }
else if (key ==
myEndPos->myPosAttr) {
116 return myEndPos->getMovingAttribute(key);
150 }
else if (key ==
myEndPos->myPosAttr) {
188 }
else if (key ==
myEndPos->myPosAttr) {
230 }
else if (key ==
myEndPos->myPosAttr) {
269 }
else if (key ==
myEndPos->myPosAttr) {
313 }
else if ((
myMovedElement->getHierarchicalElement()->getParentLanes().size() == 1) &&
314 (
myStartPos->getFixedPositionOverLane(
false) > (
myEndPos->getFixedPositionOverLane(
false) - POSITION_EPS))) {
326 return TL(
"Lanes aren't consecutives");
328 return TL(
"Lanes aren't connected");
329 }
else if (!
myStartPos->isMoveElementValid()) {
331 }
else if (!
myEndPos->isMoveElementValid()) {
332 return myEndPos->getMovingProblem();
333 }
else if ((
myMovedElement->getHierarchicalElement()->getParentLanes().size() == 1) &&
334 (
myStartPos->getFixedPositionOverLane(
false) > (
myEndPos->getFixedPositionOverLane(
false) - POSITION_EPS))) {
335 return TL(
"starPos > (endPos - EPS)");
344 const auto undolist =
myMovedElement->getNet()->getViewNet()->getUndoList();
346 for (
int i = 1; i < (int)
myMovedElement->getHierarchicalElement()->getParentLanes().size(); i++) {
348 const auto firstLane =
myMovedElement->getHierarchicalElement()->getParentLanes().at(i - 1);
349 const auto secondLane =
myMovedElement->getHierarchicalElement()->getParentLanes().at(i);
351 bool foundConnection =
false;
352 for (
const auto& connection : firstLane->getParentEdge()->getGNEConnections()) {
353 if ((connection->getLaneFrom() == firstLane) && (connection->getLaneTo() == secondLane)) {
354 foundConnection =
true;
359 if (!foundConnection) {
361 NBEdge::Connection newCon(firstLane->getIndex(), secondLane->getParentEdge()->getNBEdge(), secondLane->getIndex());
369 if (
myMovedElement->getHierarchicalElement()->getParentLanes().size() == 1) {
371 const double finalLenght =
myMovedElement->getHierarchicalElement()->getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
372 const double maxStartPos = (
myEndPos->myPosOverLane ==
INVALID_DOUBLE) ? finalLenght : (
myEndPos->getFixedPositionOverLane(
false) - POSITION_EPS);
373 if (maxStartPos < POSITION_EPS) {
376 }
else if (
myStartPos->getFixedPositionOverLane(
false) > maxStartPos) {
378 const double newStartPos = (std::trunc(maxStartPos * 1000) / 1000);
412 if (
myStartPos->getFixedPositionOverLane(adjustGeometryFactor) < 0) {
414 }
else if (
myStartPos->getFixedPositionOverLane(adjustGeometryFactor) > (
myEndPos->getFixedPositionOverLane(adjustGeometryFactor) - POSITION_EPS)) {
415 return (
myEndPos->getFixedPositionOverLane(adjustGeometryFactor) - POSITION_EPS);
417 return myStartPos->getFixedPositionOverLane(adjustGeometryFactor);
424 if (
myEndPos->getFixedPositionOverLane(adjustGeometryFactor) < POSITION_EPS) {
426 }
else if (
myStartPos->getFixedPositionOverLane(adjustGeometryFactor) > (
myEndPos->getFixedPositionOverLane(adjustGeometryFactor) - POSITION_EPS)) {
427 return myEndPos->getFixedPositionOverLane(adjustGeometryFactor);
429 return myEndPos->getFixedPositionOverLane(adjustGeometryFactor);
461 myStartPos->commitMoveShape(moveResult, undoList);
462 myEndPos->commitMoveShape(moveResult, undoList);
465 myStartPos->commitMoveShape(moveResult, undoList);
468 myEndPos->commitMoveShape(moveResult, undoList);
477 const auto laneLength =
myMovedElement->getHierarchicalElement()->getParentLanes().front()->getLaneShapeLength();
484 double newStartPos = center - (newSize * 0.5);
485 double newEndPos = center + (newSize * 0.5);
487 if (newStartPos < 0) {
490 if (newEndPos > laneLength) {
491 newEndPos = laneLength;
499 double newStartPos = laneLength - newSize;
501 if (newStartPos < 0) {
508 double newEndPos = newSize;
510 if (newEndPos > laneLength) {
511 newEndPos = laneLength;
GUIViewObjectsHandler gViewObjectsHandler
const std::string invalid_return< std::string >::value
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ GNE_ATTR_FORCESIZE
size (used in stopping places)
@ GNE_ATTR_SIZE
size (used in stopping places)
@ GNE_ATTR_REFERENCE
reference position (used creating stoppingPlaces)
@ GNE_ATTR_SHIFTLANEINDEX
shift lane index (only used by elements over lanes)
const double INVALID_DOUBLE
invalid double
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static bool areLaneConnected(const std::vector< GNELane * > &lanes)
check if the given lanes are connected
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
double myMovingLateralOffset
move element lateral offset
GNEAttributeCarrier * myMovedElement
pointer to element
GNEMoveElement(GNEAttributeCarrier *movedElement)
constructor
std::string getMovingAttribute(SumoXMLAttr key) const override
get moving attribute
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
void fixMovingProblem()
fix moving problem
Position getMovingAttributePosition(SumoXMLAttr key) const override
get moving attribute position
double getEndFixedPositionOverLane(const bool adjustGeometryFactor) const
get end offset position over lane
void setSize(const std::string &value, GNEUndoList *undoList)
set size
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
double getMovingAttributeDouble(SumoXMLAttr key) const override
get moving attribute double
~GNEMoveElementLaneDouble()
Destructor.
GNEMoveElementLaneSingle * myEndPos
end position
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
GNEMoveOperation * getMoveOperation() override
get lane movable move operation for elements with
std::string getMovingProblem() const
return a string with the current moving problem
bool isMovingAttributeValid(SumoXMLAttr key, const std::string &value) const override
check if the given moving attribute is valid
PositionVector getMovingAttributePositionVector(SumoXMLAttr key) const override
get moving attribute positionVector
ReferencePosition myReferencePosition
reference position
bool isMoveElementValid() const
check if current moving element is valid to be written into XML
double getStartFixedPositionOverLane(const bool adjustGeometryFactor) const
get start offset position over lane
double myTemplateSize
size (only use in AttributeCarrier templates)
void writeMoveAttributes(OutputDevice &device, const bool writeLength) const
write move attributes
bool myTemplateForceSize
force size (only used in AttributeCarrier templates
static const double defaultSize
default element size
GNEMoveElementLaneDouble(GNEAttributeCarrier *element, SumoXMLAttr startPosAttr, double &startPosValue, SumoXMLAttr endPosAttr, double &endPosValue, bool &friendlyPosition)
Constructor.
GNEMoveElementLaneSingle * myStartPos
start position
void setMovingAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
set moving attribute (using undo-list)
double newFirstPos
new first position
double firstLaneOffset
lane offset
double newLastPos
new last position
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
A point in 2D or 3D with translation and scaling methods.
static StringBijection< ReferencePosition > ReferencePositions
reference positions (used creating certain elements in netedit)
A structure which describes a connection between edges or lanes.