Path: blob/main/src/netedit/frames/common/GNEMoveFrame.cpp
169684 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GNEMoveFrame.cpp14/// @author Pablo Alvarez Lopez15/// @date Jun 202016///17// The Widget for move elements18/****************************************************************************/1920#include <netedit/GNENet.h>21#include <netedit/GNETagProperties.h>22#include <netedit/GNEUndoList.h>23#include <netedit/frames/common/GNEMoveFrame.h>24#include <utils/foxtools/MFXDynamicLabel.h>25#include <utils/gui/div/GUIDesigns.h>26#include <utils/gui/windows/GUIAppEnum.h>2728// ===========================================================================29// FOX callback mapping30// ===========================================================================3132FXDEFMAP(GNEMoveFrame::NetworkMoveOptions) NetworkMoveOptionsMap[] = {33FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNEMoveFrame::NetworkMoveOptions::onCmdChangeOption)34};3536FXDEFMAP(GNEMoveFrame::ChangeZInSelection) ChangeZInSelectionMap[] = {37FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNEMoveFrame::ChangeZInSelection::onCmdChangeZValue),38FXMAPFUNC(SEL_COMMAND, MID_CHOOSEN_OPERATION, GNEMoveFrame::ChangeZInSelection::onCmdChangeZMode),39FXMAPFUNC(SEL_COMMAND, MID_GNE_APPLY, GNEMoveFrame::ChangeZInSelection::onCmdApplyZ),40};4142FXDEFMAP(GNEMoveFrame::ShiftEdgeSelectedGeometry) ShiftEdgeGeometryMap[] = {43FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNEMoveFrame::ShiftEdgeSelectedGeometry::onCmdChangeShiftValue),44FXMAPFUNC(SEL_COMMAND, MID_GNE_APPLY, GNEMoveFrame::ShiftEdgeSelectedGeometry::onCmdShiftEdgeGeometry),45};4647FXDEFMAP(GNEMoveFrame::ShiftShapeGeometry) ShiftShapeGeometryMap[] = {48FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNEMoveFrame::ShiftShapeGeometry::onCmdChangeShiftValue),49FXMAPFUNC(SEL_COMMAND, MID_GNE_APPLY, GNEMoveFrame::ShiftShapeGeometry::onCmdShiftShapeGeometry),50};5152// Object implementation53FXIMPLEMENT(GNEMoveFrame::NetworkMoveOptions, MFXGroupBoxModule, NetworkMoveOptionsMap, ARRAYNUMBER(NetworkMoveOptionsMap))54FXIMPLEMENT(GNEMoveFrame::ChangeZInSelection, MFXGroupBoxModule, ChangeZInSelectionMap, ARRAYNUMBER(ChangeZInSelectionMap))55FXIMPLEMENT(GNEMoveFrame::ShiftEdgeSelectedGeometry, MFXGroupBoxModule, ShiftEdgeGeometryMap, ARRAYNUMBER(ShiftEdgeGeometryMap))56FXIMPLEMENT(GNEMoveFrame::ShiftShapeGeometry, MFXGroupBoxModule, ShiftShapeGeometryMap, ARRAYNUMBER(ShiftShapeGeometryMap))5758// ===========================================================================59// method definitions60// ===========================================================================6162// ---------------------------------------------------------------------------63// GNEMoveFrame::CommonMoveOptions - methods64// ---------------------------------------------------------------------------6566GNEMoveFrame::CommonMoveOptions::CommonMoveOptions(GNEMoveFrame* moveFrameParent) :67MFXGroupBoxModule(moveFrameParent, TL("Common move options")) {68// Create checkbox for enable/disable allow change lanes69myAllowChangeLanes = new FXCheckButton(getCollapsableFrame(), TL("Allow change lanes"), this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);70myAllowChangeLanes->setCheck(FALSE);71// Create checkbox for enable/disable merge geometry points72myMergeGeometryPoints = new FXCheckButton(getCollapsableFrame(), TL("Merge geometry points"), this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);73myMergeGeometryPoints->setCheck(TRUE);74}757677GNEMoveFrame::CommonMoveOptions::~CommonMoveOptions() {}787980bool81GNEMoveFrame::CommonMoveOptions::getAllowChangeLane() const {82return (myAllowChangeLanes->getCheck() == TRUE);83}848586bool87GNEMoveFrame::CommonMoveOptions::getMergeGeometryPoints() const {88return (myMergeGeometryPoints->getCheck() == TRUE);89}9091// ---------------------------------------------------------------------------92// GNEMoveFrame::NetworkMoveOptions - methods93// ---------------------------------------------------------------------------9495GNEMoveFrame::NetworkMoveOptions::NetworkMoveOptions(GNEMoveFrame* moveFrameParent) :96MFXGroupBoxModule(moveFrameParent, TL("Network move options")),97myMoveFrameParent(moveFrameParent) {98// Create checkbox for enable/disable move whole polygons99myMoveWholePolygons = new FXCheckButton(getCollapsableFrame(), TL("Move whole polygons"), this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);100myMoveWholePolygons->setCheck(FALSE);101// Create checkbox for force draw end geometry points102myForceDrawGeometryPoints = new FXCheckButton(getCollapsableFrame(), TL("Force draw geom. points"), this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);103myForceDrawGeometryPoints->setCheck(FALSE);104// Create checkbox for force draw end geometry points105myMoveOnlyJunctionCenter = new FXCheckButton(getCollapsableFrame(), TL("Move only junction center"), this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);106myMoveOnlyJunctionCenter->setCheck(FALSE);107}108109110GNEMoveFrame::NetworkMoveOptions::~NetworkMoveOptions() {}111112113void114GNEMoveFrame::NetworkMoveOptions::showNetworkMoveOptions() {115recalc();116show();117}118119120void121GNEMoveFrame::NetworkMoveOptions::hideNetworkMoveOptions() {122hide();123}124125126bool127GNEMoveFrame::NetworkMoveOptions::getMoveWholePolygons() const {128if (myMoveFrameParent->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&129(myMoveFrameParent->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE)) {130return (myMoveWholePolygons->getCheck() == TRUE);131} else {132return false;133}134}135136137bool138GNEMoveFrame::NetworkMoveOptions::getForceDrawGeometryPoints() const {139if (myMoveFrameParent->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&140(myMoveFrameParent->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE)) {141return (myForceDrawGeometryPoints->getCheck() == TRUE);142} else {143return false;144}145}146147148bool149GNEMoveFrame::NetworkMoveOptions::getMoveOnlyJunctionCenter() const {150if (myMoveFrameParent->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&151(myMoveFrameParent->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE)) {152return (myMoveOnlyJunctionCenter->getCheck() == TRUE);153} else {154return false;155}156}157158159long160GNEMoveFrame::NetworkMoveOptions::onCmdChangeOption(FXObject*, FXSelector, void*) {161// just update viewNet162myMoveFrameParent->getViewNet()->update();163return 1;164}165166// ---------------------------------------------------------------------------167// GNEMoveFrame::DemandMoveOptions - methods168// ---------------------------------------------------------------------------169170GNEMoveFrame::DemandMoveOptions::DemandMoveOptions(GNEMoveFrame* moveFrameParent) :171MFXGroupBoxModule(moveFrameParent, TL("Demand move options")),172myMoveFrameParent(moveFrameParent) {173// Create checkbox for enable/disable move whole polygons174myLeaveStopPersonsConnected = new FXCheckButton(getCollapsableFrame(), TL("Leave stopPersons connected"), this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);175myLeaveStopPersonsConnected->setCheck(FALSE);176}177178179GNEMoveFrame::DemandMoveOptions::~DemandMoveOptions() {}180181182void183GNEMoveFrame::DemandMoveOptions::showDemandMoveOptions() {184recalc();185show();186}187188189void190GNEMoveFrame::DemandMoveOptions::hideDemandMoveOptions() {191hide();192}193194195bool196GNEMoveFrame::DemandMoveOptions::getLeaveStopPersonsConnected() const {197if (myMoveFrameParent->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&198(myMoveFrameParent->getViewNet()->getEditModes().demandEditMode == DemandEditMode::DEMAND_MOVE)) {199return (myLeaveStopPersonsConnected->getCheck() == TRUE);200} else {201return false;202}203}204205// ---------------------------------------------------------------------------206// GNEMoveFrame::ShiftEdgeSelectedGeometry - methods207// ---------------------------------------------------------------------------208209GNEMoveFrame::ShiftEdgeSelectedGeometry::ShiftEdgeSelectedGeometry(GNEMoveFrame* moveFrameParent) :210MFXGroupBoxModule(moveFrameParent, TL("Shift selected edges geometry")),211myMoveFrameParent(moveFrameParent) {212// create horizontal frame213FXHorizontalFrame* myZValueFrame = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);214// create elements for Z value215new FXLabel(myZValueFrame, TL("Shift value"), 0, GUIDesignLabelThickedFixed(100));216myShiftValueTextField = new FXTextField(myZValueFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextFieldRestricted(TEXTFIELD_REAL));217myShiftValueTextField->setText("0");218// create apply button219myApplyZValue = GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Apply shift value"), "", TL("Shift edge geometry orthogonally to driving direction for all selected edges"),220GUIIconSubSys::getIcon(GUIIcon::MODEMOVE), this, MID_GNE_APPLY, GUIDesignButton);221}222223224GNEMoveFrame::ShiftEdgeSelectedGeometry::~ShiftEdgeSelectedGeometry() {}225226227void228GNEMoveFrame::ShiftEdgeSelectedGeometry::enableShiftEdgeGeometry() {229// enable elements230myShiftValueTextField->enable();231myApplyZValue->enable();232}233234235void236GNEMoveFrame::ShiftEdgeSelectedGeometry::disableShiftEdgeGeometry() {237// enable elements238myShiftValueTextField->disable();239myApplyZValue->disable();240}241242243long244GNEMoveFrame::ShiftEdgeSelectedGeometry::onCmdChangeShiftValue(FXObject*, FXSelector, void*) {245// just call onCmdShiftEdgeGeometry246return onCmdShiftEdgeGeometry(nullptr, 0, nullptr);247}248249250long251GNEMoveFrame::ShiftEdgeSelectedGeometry::onCmdShiftEdgeGeometry(FXObject*, FXSelector, void*) {252// get undo-list253auto undoList = myMoveFrameParent->getViewNet()->getUndoList();254// get value255const double shiftValue = GNEAttributeCarrier::parse<double>(myShiftValueTextField->getText().text());256// get selected edges257const auto selectedEdges = myMoveFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getSelectedEdges();258// begin undo-redo259myMoveFrameParent->getViewNet()->getUndoList()->begin(GUIIcon::EDGE, "shift edge geometries");260// iterate over edges261for (const auto& edge : selectedEdges) {262// get edge geometry263PositionVector edgeShape = edge->getNBEdge()->getGeometry();264// shift edge geometry265edgeShape.move2side(shiftValue);266// get first and last position267const Position shapeStart = edgeShape.front();268const Position shapeEnd = edgeShape.back();269// set inner geometry270edgeShape.pop_front();271edgeShape.pop_back();272// set new shape again273if (edgeShape.size() > 0) {274edge->setAttribute(SUMO_ATTR_SHAPE, toString(edgeShape), undoList);275}276// set new start and end positions277edge->setAttribute(GNE_ATTR_SHAPE_START, toString(shapeStart), undoList);278edge->setAttribute(GNE_ATTR_SHAPE_END, toString(shapeEnd), undoList);279}280// end undo-redo281myMoveFrameParent->getViewNet()->getUndoList()->end();282return 1;283}284285// ---------------------------------------------------------------------------286// GNEMoveFrame::ChangeZInSelection - methods287// ---------------------------------------------------------------------------288289GNEMoveFrame::ChangeZInSelection::ChangeZInSelection(GNEMoveFrame* moveFrameParent) :290MFXGroupBoxModule(moveFrameParent, TL("Change Z in selection")),291myMoveFrameParent(moveFrameParent) {292// create horizontal frame293FXHorizontalFrame* myZValueFrame = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);294// create elements for Z value295new FXLabel(myZValueFrame, TL("Z value"), 0, GUIDesignLabelThickedFixed(100));296myZValueTextField = new FXTextField(myZValueFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextFieldRestricted(TEXTFIELD_REAL));297myZValueTextField->setText("0");298// Create all options buttons299myAbsoluteValue = GUIDesigns::buildFXRadioButton(getCollapsableFrame(), TL("Absolute value"), "", TL("Set Z value as absolute"),300this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);301myRelativeValue = GUIDesigns::buildFXRadioButton(getCollapsableFrame(), TL("Relative value"), "", TL("Set Z value as relative"),302this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);303// create apply button304myApplyButton = GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Apply Z value"), "", TL("Apply Z value to all selected junctions"),305GUIIconSubSys::getIcon(GUIIcon::ACCEPT), this, MID_GNE_APPLY, GUIDesignButton);306// set absolute value as default307myAbsoluteValue->setCheck(true);308// set info label309myInfoLabel = new FXLabel(getCollapsableFrame(), "", nullptr, GUIDesignLabelFrameInformation);310}311312313GNEMoveFrame::ChangeZInSelection::~ChangeZInSelection() {}314315316void317GNEMoveFrame::ChangeZInSelection::enableChangeZInSelection() {318// enable elements319myZValueTextField->enable();320myAbsoluteValue->enable();321myRelativeValue->enable();322myApplyButton->enable();323// update info label324updateInfoLabel();325}326327328void329GNEMoveFrame::ChangeZInSelection::disableChangeZInSelection() {330// disable elements331myZValueTextField->disable();332myAbsoluteValue->disable();333myRelativeValue->disable();334myApplyButton->disable();335}336337338long339GNEMoveFrame::ChangeZInSelection::onCmdChangeZValue(FXObject* /*obj*/, FXSelector /*sel*/, void*) {340return 1;341}342343344long345GNEMoveFrame::ChangeZInSelection::onCmdChangeZMode(FXObject* obj, FXSelector, void*) {346if (obj == myAbsoluteValue) {347myAbsoluteValue->setCheck(true);348myRelativeValue->setCheck(false);349} else {350myAbsoluteValue->setCheck(false);351myRelativeValue->setCheck(true);352}353return 1;354}355356357long358GNEMoveFrame::ChangeZInSelection::onCmdApplyZ(FXObject*, FXSelector, void*) {359// get undo-list360auto undoList = myMoveFrameParent->getViewNet()->getUndoList();361// get value362const double zValue = GNEAttributeCarrier::parse<double>(myZValueTextField->getText().text());363// get junctions364const auto selectedJunctions = myMoveFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getSelectedJunctions();365// get selected edges366const auto selectedEdges = myMoveFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getSelectedEdges();367// begin undo-redo368myMoveFrameParent->getViewNet()->getUndoList()->begin(GUIIcon::MODEMOVE, "change Z values in selection");369// iterate over junctions370for (const auto& junction : selectedJunctions) {371if (junction->getNBNode()->hasCustomShape()) {372// get junction position373PositionVector junctionShape = junction->getNBNode()->getShape();374// modify z Value depending of absolute/relative375for (auto& shapePos : junctionShape) {376if (myAbsoluteValue->getCheck() == TRUE) {377shapePos.setz(zValue);378} else {379shapePos.add(Position(0, 0, zValue));380}381}382// set new position again383junction->setAttribute(SUMO_ATTR_SHAPE, toString(junctionShape), undoList);384}385// get junction position386Position junctionPos = junction->getNBNode()->getPosition();387// modify z Value depending of absolute/relative388if (myAbsoluteValue->getCheck() == TRUE) {389junctionPos.setz(zValue);390} else {391junctionPos.add(Position(0, 0, zValue));392}393// set new position again394junction->setAttribute(SUMO_ATTR_POSITION, toString(junctionPos), undoList);395}396// iterate over edges397for (const auto& edge : selectedEdges) {398// get edge geometry399PositionVector edgeShape = edge->getNBEdge()->getInnerGeometry();400// get first and last position401Position shapeStart = edge->getNBEdge()->getGeometry().front();402Position shapeEnd = edge->getNBEdge()->getGeometry().back();403// modify z Value depending of absolute/relative404for (auto& shapePos : edgeShape) {405if (myAbsoluteValue->getCheck() == TRUE) {406shapePos.setz(zValue);407} else {408shapePos.add(Position(0, 0, zValue));409}410}411// modify begin an end positions412if (myAbsoluteValue->getCheck() == TRUE) {413shapeStart.setz(zValue);414shapeEnd.setz(zValue);415} else {416shapeStart.add(Position(0, 0, zValue));417shapeEnd.add(Position(0, 0, zValue));418}419// set new shape again420if (edgeShape.size() > 0) {421edge->setAttribute(SUMO_ATTR_SHAPE, toString(edgeShape), undoList);422}423// set new start and end positions424if ((edge->getAttribute(GNE_ATTR_SHAPE_START).size() > 0) &&425(shapeStart.distanceSquaredTo2D(edge->getFromJunction()->getNBNode()->getPosition()) < 2)) {426edge->setAttribute(GNE_ATTR_SHAPE_START, toString(shapeStart), undoList);427}428if ((edge->getAttribute(GNE_ATTR_SHAPE_END).size() > 0) &&429(shapeEnd.distanceSquaredTo2D(edge->getToJunction()->getNBNode()->getPosition()) < 2)) {430edge->setAttribute(GNE_ATTR_SHAPE_END, toString(shapeEnd), undoList);431}432}433// end undo-redo434myMoveFrameParent->getViewNet()->getUndoList()->end();435// update info label436updateInfoLabel();437return 1;438}439440441void442GNEMoveFrame::ChangeZInSelection::updateInfoLabel() {443// get junctions444const auto selectedJunctions = myMoveFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getSelectedJunctions();445// get selected edges446const auto selectedEdges = myMoveFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getSelectedEdges();447// check if there is edges or junctions448if ((selectedJunctions.size() > 0) || (selectedEdges.size() > 0)) {449// declare minimum and maximum450double selectionMinimum = 0;451double selectionMaximum = 0;452// set first values453if (selectedJunctions.size() > 0) {454selectionMinimum = selectedJunctions.front()->getNBNode()->getPosition().z();455selectionMaximum = selectedJunctions.front()->getNBNode()->getPosition().z();456} else {457selectionMinimum = selectedEdges.front()->getNBEdge()->getGeometry().front().z();458selectionMaximum = selectedEdges.front()->getNBEdge()->getGeometry().front().z();459}460// declare average461double selectionAverage = 0;462// declare numPoints463int numPoints = 0;464// iterate over junctions465for (const auto& junction : selectedJunctions) {466// get z467const double z = junction->getNBNode()->getPosition().z();468// check min469if (z < selectionMinimum) {470selectionMinimum = z;471}472// check max473if (z > selectionMaximum) {474selectionMaximum = z;475}476// update average477selectionAverage += z;478// update numPoints479numPoints++;480}481// iterate over edges482for (const auto& edge : selectedEdges) {483// get inner geometry484const PositionVector innerGeometry = edge->getNBEdge()->getInnerGeometry();485// iterate over innerGeometry486for (const auto& geometryPoint : innerGeometry) {487// check min488if (geometryPoint.z() < selectionMinimum) {489selectionMinimum = geometryPoint.z();490}491// check max492if (geometryPoint.z() > selectionMaximum) {493selectionMaximum = geometryPoint.z();494}495// update average496selectionAverage += geometryPoint.z();497// update numPoints498numPoints++;499}500// check shape start501if (edge->getAttribute(GNE_ATTR_SHAPE_START).size() > 0) {502// get z503const double z = edge->getNBEdge()->getGeometry().front().z();504// check min505if (z < selectionMinimum) {506selectionMinimum = z;507}508// check max509if (z > selectionMaximum) {510selectionMaximum = z;511}512// update average513selectionAverage += z;514// update numPoints515numPoints++;516}517// check shape end518if (edge->getAttribute(GNE_ATTR_SHAPE_END).size() > 0) {519// get z520const double z = edge->getNBEdge()->getGeometry().back().z();521// check min522if (z < selectionMinimum) {523selectionMinimum = z;524}525// check max526if (z > selectionMaximum) {527selectionMaximum = z;528}529// update average530selectionAverage += z;531// update numPoints532numPoints++;533}534}535// update average536selectionAverage = (100 * selectionAverage) / (double)numPoints;537// floor average538selectionAverage = floor(selectionAverage);539selectionAverage *= 0.01;540// set label string541const std::string labelStr =542TL("- Num geometry points: ") + toString(numPoints) + "\n" +543TL("- Selection minimum Z: ") + toString(selectionMinimum) + "\n" +544TL("- Selection maximum Z: ") + toString(selectionMaximum) + "\n" +545TL("- Selection average Z: ") + toString(selectionAverage);546// update info label547myInfoLabel->setText(labelStr.c_str());548}549}550551// ---------------------------------------------------------------------------552// GNEMoveFrame::ShiftShapeGeometry - methods553// ---------------------------------------------------------------------------554555GNEMoveFrame::ShiftShapeGeometry::ShiftShapeGeometry(GNEMoveFrame* moveFrameParent) :556MFXGroupBoxModule(moveFrameParent, TL("Shift shape geometry")),557myMoveFrameParent(moveFrameParent) {558// create horizontal frame559FXHorizontalFrame* horizontalFrameX = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);560// create elements for Z value561new FXLabel(horizontalFrameX, "X value", 0, GUIDesignLabelThickedFixed(100));562myShiftValueXTextField = new FXTextField(horizontalFrameX, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextFieldRestricted(TEXTFIELD_REAL));563myShiftValueXTextField->setText("0");564// create horizontal frame565FXHorizontalFrame* horizontalFrameY = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);566// create elements for Z value567new FXLabel(horizontalFrameY, "Y value", 0, GUIDesignLabelThickedFixed(100));568myShiftValueYTextField = new FXTextField(horizontalFrameY, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextFieldRestricted(TEXTFIELD_REAL));569myShiftValueYTextField->setText("0");570// create apply button571GUIDesigns::buildFXButton(this,572TL("Shift shape geometry"), "", TL("Shift shape geometry orthogonally to driving direction for all selected shapes"),573GUIIconSubSys::getIcon(GUIIcon::MODEMOVE), this, MID_GNE_APPLY, GUIDesignButton);574}575576577GNEMoveFrame::ShiftShapeGeometry::~ShiftShapeGeometry() {}578579580void581GNEMoveFrame::ShiftShapeGeometry::showShiftShapeGeometry() {582// show module583show();584}585586587void588GNEMoveFrame::ShiftShapeGeometry::hideShiftShapeGeometry() {589// hide module590hide();591}592593594long595GNEMoveFrame::ShiftShapeGeometry::onCmdChangeShiftValue(FXObject*, FXSelector, void*) {596// just call onCmdShiftShapeGeometry597return onCmdShiftShapeGeometry(nullptr, 0, nullptr);598}599600601long602GNEMoveFrame::ShiftShapeGeometry::onCmdShiftShapeGeometry(FXObject*, FXSelector, void*) {603// get undo-list604auto undoList = myMoveFrameParent->getViewNet()->getUndoList();605// get values606const double shiftValueX = GNEAttributeCarrier::parse<double>(myShiftValueXTextField->getText().text());607const double shiftValueY = GNEAttributeCarrier::parse<double>(myShiftValueYTextField->getText().text());608const Position shiftValue(shiftValueX, shiftValueY);609// get selected polygons and POIs610const auto selectedShapes = myMoveFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getSelectedShapes();611std::vector<GNEAdditional*> polygons, POIs;612for (const auto& shape : selectedShapes) {613if (shape->getTagProperty()->getTag() == SUMO_TAG_POLY) {614polygons.push_back(shape);615} else {616POIs.push_back(shape);617}618}619// begin undo-redo620myMoveFrameParent->getViewNet()->getUndoList()->begin(GUIIcon::POLY, "shift shape geometries");621// iterate over shapes622for (const auto& polygon : polygons) {623// get shape geometry624PositionVector shape = GNEAttributeCarrier::parse<PositionVector>(polygon->getAttribute(SUMO_ATTR_SHAPE));625// shift shape geometry626shape.add(shiftValue);627// set new shape again628polygon->setAttribute(SUMO_ATTR_SHAPE, toString(shape), undoList);629}630// iterate over POIs631for (const auto& POI : POIs) {632// currently only for POIs (not for POILanes or POIGEOs633if (POI->getTagProperty()->hasAttribute(SUMO_ATTR_POSITION)) {634// get shape geometry635Position position = GNEAttributeCarrier::parse<Position>(POI->getAttribute(SUMO_ATTR_POSITION));636// shift shape geometry637position.add(shiftValue);638// set new shape again639POI->setAttribute(SUMO_ATTR_POSITION, toString(position), undoList);640}641}642// end undo-redo643myMoveFrameParent->getViewNet()->getUndoList()->end();644return 1;645}646647// ---------------------------------------------------------------------------648// GNEMoveFrame::Information - methods649// ---------------------------------------------------------------------------650651GNEMoveFrame::Information::Information(GNEMoveFrame* moveFrameParent) :652MFXGroupBoxModule(moveFrameParent, TL("Information")) {653// create info label654new MFXDynamicLabel(getCollapsableFrame(), (std::string("- ") + TL("Click over edge to create or edit geometry point.") + std::string("\n- ") + TL("Shift+click over edge to edit start or end geometry point.")).c_str(), 0, GUIDesignLabelFrameInformation);655// create source label656FXLabel* sourceLabel = new FXLabel(getCollapsableFrame(), TL("-Move geometry point"), 0, GUIDesignLabel(JUSTIFY_LEFT));657sourceLabel->setBackColor(MFXUtils::getFXColor(RGBColor::ORANGE));658// create target label659FXLabel* targetLabel = new FXLabel(getCollapsableFrame(), TL("-Merge geometry point"), 0, GUIDesignLabel(JUSTIFY_LEFT));660targetLabel->setBackColor(MFXUtils::getFXColor(RGBColor::CYAN));661}662663664GNEMoveFrame::Information::~Information() {}665666// ---------------------------------------------------------------------------667// GNEMoveFrame - methods668// ---------------------------------------------------------------------------669670GNEMoveFrame::GNEMoveFrame(GNEViewParent* viewParent, GNEViewNet* viewNet) :671GNEFrame(viewParent, viewNet, TL("Move")) {672// create common mode options673myCommonMoveOptions = new CommonMoveOptions(this);674// create network mode options675myNetworkMoveOptions = new NetworkMoveOptions(this);676// create demand mode options677myDemandMoveOptions = new DemandMoveOptions(this);678// create shift edge geometry module679myShiftEdgeSelectedGeometry = new ShiftEdgeSelectedGeometry(this);680// create change z selection681myChangeZInSelection = new ChangeZInSelection(this);682// create information label683myInformation = new Information(this);684// create shift shape geometry module685myShiftShapeGeometry = new ShiftShapeGeometry(this);686}687688689GNEMoveFrame::~GNEMoveFrame() {}690691692void693GNEMoveFrame::processClick(const Position& /*clickedPosition*/,694const GNEViewNetHelper::ViewObjectsSelector& /*viewObjects*/,695const GNEViewNetHelper::ViewObjectsSelector& /*objectsUnderGrippedCursor*/) {696// currently unused697}698699700void701GNEMoveFrame::show() {702// show network options frames703if (myViewNet->getEditModes().isCurrentSupermodeNetwork()) {704myNetworkMoveOptions->showNetworkMoveOptions();705} else {706myNetworkMoveOptions->hideNetworkMoveOptions();707}708// show demand options frames709if (myViewNet->getEditModes().isCurrentSupermodeDemand()) {710myDemandMoveOptions->showDemandMoveOptions();711} else {712myDemandMoveOptions->hideDemandMoveOptions();713}714// get selected junctions715const auto selectedJunctions = myViewNet->getNet()->getAttributeCarriers()->getSelectedJunctions();716// get selected edges717const auto selectedEdges = myViewNet->getNet()->getAttributeCarriers()->getSelectedEdges();718// check if there are junctions and edge selected719if ((selectedJunctions.size() > 0) || (selectedEdges.size() > 0)) {720myChangeZInSelection->enableChangeZInSelection();721} else {722myChangeZInSelection->disableChangeZInSelection();723}724// check if there are edges selected725if (selectedEdges.size() > 0) {726myShiftEdgeSelectedGeometry->enableShiftEdgeGeometry();727} else {728myShiftEdgeSelectedGeometry->disableShiftEdgeGeometry();729}730// check if there are shapes selected731if (myViewNet->getNet()->getAttributeCarriers()->getSelectedShapes().size() > 0) {732myShiftShapeGeometry->showShiftShapeGeometry();733} else {734myShiftShapeGeometry->hideShiftShapeGeometry();735}736// show737GNEFrame::show();738// recalc and update739recalc();740update();741}742743744void745GNEMoveFrame::hide() {746// hide frame747GNEFrame::hide();748}749750751GNEMoveFrame::CommonMoveOptions*752GNEMoveFrame::getCommonMoveOptions() const {753return myCommonMoveOptions;754}755756757GNEMoveFrame::NetworkMoveOptions*758GNEMoveFrame::getNetworkMoveOptions() const {759return myNetworkMoveOptions;760}761762763GNEMoveFrame::DemandMoveOptions*764GNEMoveFrame::getDemandMoveOptions() const {765return myDemandMoveOptions;766}767768/****************************************************************************/769770771