Skip to content

Commit

Permalink
Added function getShapeEditedPopUpMenu(). Refs #14858
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Sep 6, 2024
1 parent 5171aef commit 8791c13
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 123 deletions.
44 changes: 24 additions & 20 deletions src/netedit/elements/network/GNEConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,28 +347,32 @@ GNEConnection::smootShape() {

GUIGLObjectPopupMenu*
GNEConnection::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {
GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
buildPopupHeader(ret, app);
buildCenterPopupEntry(ret);
buildNameCopyPopupEntry(ret);
// build selection and show parameters menu
myNet->getViewNet()->buildSelectionACPopupEntry(ret, this);
buildShowParamsPopupEntry(ret);
// build position copy entry
buildPositionCopyEntry(ret, app);
// check if we're in supermode network
if (myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
// create menu commands
FXMenuCommand* mcCustomShape = GUIDesigns::buildFXMenuCommand(ret, "Set custom connection shape", nullptr, &parent, MID_GNE_CONNECTION_EDIT_SHAPE);
GUIDesigns::buildFXMenuCommand(ret, "Smooth connection shape", nullptr, &parent, MID_GNE_CONNECTION_SMOOTH_SHAPE);
// check if menu commands has to be disabled
NetworkEditMode editMode = myNet->getViewNet()->getEditModes().networkEditMode;
// check if we're in the correct edit mode
if ((editMode == NetworkEditMode::NETWORK_CONNECT) || (editMode == NetworkEditMode::NETWORK_TLS) || (editMode == NetworkEditMode::NETWORK_CREATE_EDGE)) {
mcCustomShape->disable();
if (myShapeEdited) {
return getShapeEditedPopUpMenu(app, parent, getNBEdgeConnection().customShape);
} else {
GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
buildPopupHeader(ret, app);
buildCenterPopupEntry(ret);
buildNameCopyPopupEntry(ret);
// build selection and show parameters menu
myNet->getViewNet()->buildSelectionACPopupEntry(ret, this);
buildShowParamsPopupEntry(ret);
// build position copy entry
buildPositionCopyEntry(ret, app);
// check if we're in supermode network
if (myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
// create menu commands
FXMenuCommand* mcCustomShape = GUIDesigns::buildFXMenuCommand(ret, "Set custom connection shape", nullptr, &parent, MID_GNE_CONNECTION_EDIT_SHAPE);
GUIDesigns::buildFXMenuCommand(ret, "Smooth connection shape", nullptr, &parent, MID_GNE_CONNECTION_SMOOTH_SHAPE);
// check if menu commands has to be disabled
NetworkEditMode editMode = myNet->getViewNet()->getEditModes().networkEditMode;
// check if we're in the correct edit mode
if ((editMode == NetworkEditMode::NETWORK_CONNECT) || (editMode == NetworkEditMode::NETWORK_TLS) || (editMode == NetworkEditMode::NETWORK_CREATE_EDGE)) {
mcCustomShape->disable();
}
}
return ret;
}
return ret;
}


Expand Down
40 changes: 22 additions & 18 deletions src/netedit/elements/network/GNECrossing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,26 +292,30 @@ GNECrossing::drawTLSLinkNo(const GUIVisualizationSettings& s, const NBNode::Cros

GUIGLObjectPopupMenu*
GNECrossing::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {
GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
buildPopupHeader(ret, app);
buildCenterPopupEntry(ret);
buildNameCopyPopupEntry(ret);
// build selection and show parameters menu
myNet->getViewNet()->buildSelectionACPopupEntry(ret, this);
buildShowParamsPopupEntry(ret);
// build position copy entry
buildPositionCopyEntry(ret, app);
// check if we're in supermode network
if (myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
// create menu commands
FXMenuCommand* mcCustomShape = GUIDesigns::buildFXMenuCommand(ret, TL("Set custom crossing shape"), nullptr, &parent, MID_GNE_CROSSING_EDIT_SHAPE);
// check if menu commands has to be disabled
NetworkEditMode editMode = myNet->getViewNet()->getEditModes().networkEditMode;
if ((editMode == NetworkEditMode::NETWORK_CONNECT) || (editMode == NetworkEditMode::NETWORK_TLS) || (editMode == NetworkEditMode::NETWORK_CREATE_EDGE)) {
mcCustomShape->disable();
if (myShapeEdited) {
return getShapeEditedPopUpMenu(app, parent, getNBCrossing()->customShape);
} else {
GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
buildPopupHeader(ret, app);
buildCenterPopupEntry(ret);
buildNameCopyPopupEntry(ret);
// build selection and show parameters menu
myNet->getViewNet()->buildSelectionACPopupEntry(ret, this);
buildShowParamsPopupEntry(ret);
// build position copy entry
buildPositionCopyEntry(ret, app);
// check if we're in supermode network
if (myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
// create menu commands
FXMenuCommand* mcCustomShape = GUIDesigns::buildFXMenuCommand(ret, TL("Set custom crossing shape"), nullptr, &parent, MID_GNE_CROSSING_EDIT_SHAPE);
// check if menu commands has to be disabled
NetworkEditMode editMode = myNet->getViewNet()->getEditModes().networkEditMode;
if ((editMode == NetworkEditMode::NETWORK_CONNECT) || (editMode == NetworkEditMode::NETWORK_TLS) || (editMode == NetworkEditMode::NETWORK_CREATE_EDGE)) {
mcCustomShape->disable();
}
}
return ret;
}
return ret;
}


Expand Down
166 changes: 85 additions & 81 deletions src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,90 +442,94 @@ GNEJunction::buildTLSOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMen

GUIGLObjectPopupMenu*
GNEJunction::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {
GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
// build common commands
buildPopupHeader(ret, app);
buildCenterPopupEntry(ret);
buildNameCopyPopupEntry(ret);
// build selection and show parameters menu
myNet->getViewNet()->buildSelectionACPopupEntry(ret, this);
buildShowParamsPopupEntry(ret);
buildPositionCopyEntry(ret, app);
// add separator
new FXMenuSeparator(ret);
// check if we're in supermode network
if (myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
const int numSelectedJunctions = myNet->getAttributeCarriers()->getNumberOfSelectedJunctions();
const int numEndpoints = (int)myNBNode->getEndPoints().size();
// check if we're handling a selection
bool handlingSelection = isAttributeCarrierSelected() && (numSelectedJunctions > 1);
// check if menu commands has to be disabled
const bool invalidMode = (myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_CONNECT) ||
(myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_TLS) ||
(myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_CREATE_EDGE);
// build TLS operation
if (!invalidMode) {
buildTLSOperations(parent, ret, numSelectedJunctions);
}
// create menu commands
GUIDesigns::buildFXMenuCommand(ret, TL("Reset edge endpoints"), nullptr, &parent, MID_GNE_JUNCTION_RESET_EDGE_ENDPOINTS);
FXMenuCommand* mcCustomShape = GUIDesigns::buildFXMenuCommand(ret, TL("Set custom junction shape"), nullptr, &parent, MID_GNE_JUNCTION_EDIT_SHAPE);
FXMenuCommand* mcResetCustomShape = GUIDesigns::buildFXMenuCommand(ret, TL("Reset junction shape"), nullptr, &parent, MID_GNE_JUNCTION_RESET_SHAPE);
FXMenuCommand* mcReplaceByGeometryPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Replace junction by geometry point"), nullptr, &parent, MID_GNE_JUNCTION_REPLACE);
FXMenuCommand* mcSplitJunction = GUIDesigns::buildFXMenuCommand(ret, TLF("Split junction (% end points)", numEndpoints), nullptr, &parent, MID_GNE_JUNCTION_SPLIT);
FXMenuCommand* mcSplitJunctionAndReconnect = GUIDesigns::buildFXMenuCommand(ret, TL("Split junction and reconnect"), nullptr, &parent, MID_GNE_JUNCTION_SPLIT_RECONNECT);
// check if is a roundabout
if (myNBNode->isRoundabout()) {
GUIDesigns::buildFXMenuCommand(ret, TL("Select roundabout"), nullptr, &parent, MID_GNE_JUNCTION_SELECT_ROUNDABOUT);
} else {
// get radius
const double radius = (myNBNode->getRadius() == NBNode::UNSPECIFIED_RADIUS) ? OptionsCont::getOptions().getFloat("default.junctions.radius") : myNBNode->getRadius();
const std::string menuEntryInfo = TLF("Convert to roundabout (using junction attribute radius %)", toString(radius));
FXMenuCommand* mcRoundabout = GUIDesigns::buildFXMenuCommand(ret, menuEntryInfo.c_str(), nullptr, &parent, MID_GNE_JUNCTION_CONVERT_ROUNDABOUT);
// check if disable depending of number of edges
if ((getChildEdges().size() < 2) ||
((myGNEIncomingEdges.size() == 1) && (myGNEOutgoingEdges.size() == 1) && (myGNEIncomingEdges[0]->getFromJunction() == myGNEOutgoingEdges[0]->getToJunction()))) {
mcRoundabout->disable();
if (myShapeEdited) {
return getShapeEditedPopUpMenu(app, parent, myNBNode->getShape());
} else {
GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
// build common commands
buildPopupHeader(ret, app);
buildCenterPopupEntry(ret);
buildNameCopyPopupEntry(ret);
// build selection and show parameters menu
myNet->getViewNet()->buildSelectionACPopupEntry(ret, this);
buildShowParamsPopupEntry(ret);
buildPositionCopyEntry(ret, app);
// add separator
new FXMenuSeparator(ret);
// check if we're in supermode network
if (myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
const int numSelectedJunctions = myNet->getAttributeCarriers()->getNumberOfSelectedJunctions();
const int numEndpoints = (int)myNBNode->getEndPoints().size();
// check if we're handling a selection
bool handlingSelection = isAttributeCarrierSelected() && (numSelectedJunctions > 1);
// check if menu commands has to be disabled
const bool invalidMode = (myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_CONNECT) ||
(myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_TLS) ||
(myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_CREATE_EDGE);
// build TLS operation
if (!invalidMode) {
buildTLSOperations(parent, ret, numSelectedJunctions);
}
// create menu commands
GUIDesigns::buildFXMenuCommand(ret, TL("Reset edge endpoints"), nullptr, &parent, MID_GNE_JUNCTION_RESET_EDGE_ENDPOINTS);
FXMenuCommand* mcCustomShape = GUIDesigns::buildFXMenuCommand(ret, TL("Set custom junction shape"), nullptr, &parent, MID_GNE_JUNCTION_EDIT_SHAPE);
FXMenuCommand* mcResetCustomShape = GUIDesigns::buildFXMenuCommand(ret, TL("Reset junction shape"), nullptr, &parent, MID_GNE_JUNCTION_RESET_SHAPE);
FXMenuCommand* mcReplaceByGeometryPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Replace junction by geometry point"), nullptr, &parent, MID_GNE_JUNCTION_REPLACE);
FXMenuCommand* mcSplitJunction = GUIDesigns::buildFXMenuCommand(ret, TLF("Split junction (% end points)", numEndpoints), nullptr, &parent, MID_GNE_JUNCTION_SPLIT);
FXMenuCommand* mcSplitJunctionAndReconnect = GUIDesigns::buildFXMenuCommand(ret, TL("Split junction and reconnect"), nullptr, &parent, MID_GNE_JUNCTION_SPLIT_RECONNECT);
// check if is a roundabout
if (myNBNode->isRoundabout()) {
GUIDesigns::buildFXMenuCommand(ret, TL("Select roundabout"), nullptr, &parent, MID_GNE_JUNCTION_SELECT_ROUNDABOUT);
} else {
// get radius
const double radius = (myNBNode->getRadius() == NBNode::UNSPECIFIED_RADIUS) ? OptionsCont::getOptions().getFloat("default.junctions.radius") : myNBNode->getRadius();
const std::string menuEntryInfo = TLF("Convert to roundabout (using junction attribute radius %)", toString(radius));
FXMenuCommand* mcRoundabout = GUIDesigns::buildFXMenuCommand(ret, menuEntryInfo.c_str(), nullptr, &parent, MID_GNE_JUNCTION_CONVERT_ROUNDABOUT);
// check if disable depending of number of edges
if ((getChildEdges().size() < 2) ||
((myGNEIncomingEdges.size() == 1) && (myGNEOutgoingEdges.size() == 1) && (myGNEIncomingEdges[0]->getFromJunction() == myGNEOutgoingEdges[0]->getToJunction()))) {
mcRoundabout->disable();
}
}
// check multijunctions
const std::string multi = ((numSelectedJunctions > 1) && isAttributeCarrierSelected()) ? TLF(" of % junctions", numSelectedJunctions) : "";
FXMenuCommand* mcClearConnections = GUIDesigns::buildFXMenuCommand(ret, TL("Clear connections") + multi, nullptr, &parent, MID_GNE_JUNCTION_CLEAR_CONNECTIONS);
FXMenuCommand* mcResetConnections = GUIDesigns::buildFXMenuCommand(ret, TL("Reset connections") + multi, nullptr, &parent, MID_GNE_JUNCTION_RESET_CONNECTIONS);
// check if current mode is correct
if (invalidMode) {
mcCustomShape->disable();
mcClearConnections->disable();
mcResetConnections->disable();
}
// check if we're handling a selection
if (handlingSelection) {
mcResetCustomShape->setText(TL("Reset junction shapes"));
}
// disable mcClearConnections if junction hasn't connections
if (getGNEConnections().empty()) {
mcClearConnections->disable();
}
// disable mcResetCustomShape if junction doesn't have a custom shape
if (myNBNode->getShape().size() == 0) {
mcResetCustomShape->disable();
}
// checkIsRemovable requires turnarounds to be computed. This is ugly
if ((myNBNode->getIncomingEdges().size() == 2) && (myNBNode->getOutgoingEdges().size() == 2)) {
NBTurningDirectionsComputer::computeTurnDirectionsForNode(myNBNode, false);
}
std::string reason = TL("wrong edit mode");
if (invalidMode || !myNBNode->checkIsRemovableReporting(reason)) {
mcReplaceByGeometryPoint->setText(mcReplaceByGeometryPoint->getText() + " (" + reason.c_str() + ")");
mcReplaceByGeometryPoint->disable();
}
// check if disable split junctions
if (numEndpoints == 1) {
mcSplitJunction->disable();
mcSplitJunctionAndReconnect->disable();
}
}
// check multijunctions
const std::string multi = ((numSelectedJunctions > 1) && isAttributeCarrierSelected()) ? TLF(" of % junctions", numSelectedJunctions) : "";
FXMenuCommand* mcClearConnections = GUIDesigns::buildFXMenuCommand(ret, TL("Clear connections") + multi, nullptr, &parent, MID_GNE_JUNCTION_CLEAR_CONNECTIONS);
FXMenuCommand* mcResetConnections = GUIDesigns::buildFXMenuCommand(ret, TL("Reset connections") + multi, nullptr, &parent, MID_GNE_JUNCTION_RESET_CONNECTIONS);
// check if current mode is correct
if (invalidMode) {
mcCustomShape->disable();
mcClearConnections->disable();
mcResetConnections->disable();
}
// check if we're handling a selection
if (handlingSelection) {
mcResetCustomShape->setText(TL("Reset junction shapes"));
}
// disable mcClearConnections if junction hasn't connections
if (getGNEConnections().empty()) {
mcClearConnections->disable();
}
// disable mcResetCustomShape if junction doesn't have a custom shape
if (myNBNode->getShape().size() == 0) {
mcResetCustomShape->disable();
}
// checkIsRemovable requires turnarounds to be computed. This is ugly
if ((myNBNode->getIncomingEdges().size() == 2) && (myNBNode->getOutgoingEdges().size() == 2)) {
NBTurningDirectionsComputer::computeTurnDirectionsForNode(myNBNode, false);
}
std::string reason = TL("wrong edit mode");
if (invalidMode || !myNBNode->checkIsRemovableReporting(reason)) {
mcReplaceByGeometryPoint->setText(mcReplaceByGeometryPoint->getText() + " (" + reason.c_str() + ")");
mcReplaceByGeometryPoint->disable();
}
// check if disable split junctions
if (numEndpoints == 1) {
mcSplitJunction->disable();
mcSplitJunctionAndReconnect->disable();
}
return ret;
}
return ret;
}


Expand Down
Loading

0 comments on commit 8791c13

Please sign in to comment.