Skip to content

Commit

Permalink
Updated GNEOverlappedInspection. Refs #15936
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2024
1 parent c1becfd commit ddcfac6
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 86 deletions.
61 changes: 61 additions & 0 deletions src/netedit/GNEViewNetHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,33 @@ GNEViewNetHelper::ViewObjectsSelector::updateObjects() {
}


void
GNEViewNetHelper::ViewObjectsSelector::filterBySuperMode() {
if (myViewNet->getEditModes().isCurrentSupermodeNetwork()) {
filterDemandElements(true);
filterDataElements();
} else if (myViewNet->getEditModes().isCurrentSupermodeDemand()) {
filterNetworkElements(true);
filterAdditionals(true, true);
filterDataElements();
} else if (myViewNet->getEditModes().isCurrentSupermodeData()) {
filterNetworkElements(true);
filterDemandElements(true);
}
}


void
GNEViewNetHelper::ViewObjectsSelector::filterJunctions() {
// get all edges to filter
std::vector<const GUIGlObject*> junctions;
for (const auto& junction : myViewObjects.junctions) {
junctions.push_back(junction);
}
myViewObjects.filterElements(junctions);
}


void
GNEViewNetHelper::ViewObjectsSelector::filterEdges() {
// get all edges to filter
Expand Down Expand Up @@ -467,6 +494,22 @@ GNEViewNetHelper::ViewObjectsSelector::filterAdditionals(const bool includeStopp
}


void
GNEViewNetHelper::ViewObjectsSelector::filterNetworkElements(const bool includeJunctions) {
// get all elements to filter
std::vector<const GUIGlObject*> networkElements;
for (const auto& networkElement : myViewObjects.networkElements) {
if (!includeJunctions && (networkElement->getType() == GLO_JUNCTION)) {
continue;
} else {
networkElements.push_back(networkElement);
}
networkElements.push_back(networkElement);
}
myViewObjects.filterElements(networkElements);
}


void
GNEViewNetHelper::ViewObjectsSelector::filterDemandElements(const bool includeRoutes) {
// get all elements to filter
Expand All @@ -482,6 +525,24 @@ GNEViewNetHelper::ViewObjectsSelector::filterDemandElements(const bool includeRo
}


void
GNEViewNetHelper::ViewObjectsSelector::filterDataElements() {
// get all elements to filter
std::vector<const GUIGlObject*> datadElements;
for (const auto& datadElement : myViewObjects.edgeDatas) {
datadElements.push_back(datadElement);
}
for (const auto& datadElement : myViewObjects.edgeRelDatas) {
datadElements.push_back(datadElement);
}
for (const auto& datadElement : myViewObjects.TAZRelDatas) {
datadElements.push_back(datadElement);
}
myViewObjects.filterElements(datadElements);

}


void
GNEViewNetHelper::ViewObjectsSelector::filterLockedElements(const std::vector<GUIGlObjectType> ignoreFilter) {
std::vector<const GUIGlObject*> GUIGlObjects;
Expand Down
12 changes: 12 additions & 0 deletions src/netedit/GNEViewNetHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ struct GNEViewNetHelper {
/// @brief update objects (using gViewObjectsHandler)
void updateObjects();

/// @brief filter by supermode
void filterBySuperMode();

/// @brief filter (remove) junctions
void filterJunctions();

/// @brief filter (remove) edges
void filterEdges();

Expand All @@ -353,9 +359,15 @@ struct GNEViewNetHelper {
/// @brief filter (remove) additionals
void filterAdditionals(const bool includeStoppigPlaces, const bool includeTAZs);

/// @brief filter (remove) network elements
void filterNetworkElements(const bool includeJunctions);

/// @brief filter (remove) demand elements
void filterDemandElements(const bool includeRoutes);

/// @brief filter (remove) datga elements
void filterDataElements();

/// @brief filter locked elements (except the ignoreFilter)
void filterLockedElements(const std::vector<GUIGlObjectType> ignoreFilter = {});

Expand Down
97 changes: 28 additions & 69 deletions src/netedit/frames/GNEOverlappedInspection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <config.h>

#include <netedit/GNEViewNet.h>
#include <netedit/elements/network/GNELane.h>
#include <netedit/frames/common/GNEInspectorFrame.h>
#include <utils/gui/div/GUIDesigns.h>
#include <utils/gui/windows/GUIAppEnum.h>
Expand Down Expand Up @@ -48,69 +49,45 @@ FXIMPLEMENT(GNEOverlappedInspection, MFXGroupBoxModule, OverlappedInsp
// method definitions
// ===========================================================================

GNEOverlappedInspection::GNEOverlappedInspection(GNEFrame* frameParent) :
MFXGroupBoxModule(frameParent, TL("Overlapped elements")),
GNEOverlappedInspection::GNEOverlappedInspection(GNEFrame* frameParent, const bool onlyJunctions) :
MFXGroupBoxModule(frameParent, myOnlyJunctions? TL("Overlapped junctions") : TL("Overlapped elements")),
myFrameParent(frameParent),
myFilteredTag(SUMO_TAG_NOTHING),
myOnlyJunctions(onlyJunctions),
myItemIndex(0) {
// build elements
buildFXElements();
}


GNEOverlappedInspection::GNEOverlappedInspection(GNEFrame* frameParent, const SumoXMLTag filteredTag) :
MFXGroupBoxModule(frameParent, (TL("Overlapped ") + toString(filteredTag) + "s").c_str()),
myFrameParent(frameParent),
myFilteredTag(filteredTag),
myItemIndex(0) {
// build elements
buildFXElements();
FXHorizontalFrame* frameButtons = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
// Create previous Item Button
myPreviousElement = GUIDesigns::buildFXButton(frameButtons, "", "", "", GUIIconSubSys::getIcon(GUIIcon::BIGARROWLEFT), this, MID_GNE_OVERLAPPED_PREVIOUS, GUIDesignButtonRectangular);
// create current index button
myCurrentIndexButton = GUIDesigns::buildFXButton(frameButtons, "", "", "", nullptr, this, MID_GNE_OVERLAPPED_SHOWLIST, GUIDesignButton);
// Create next Item Button
myNextElement = GUIDesigns::buildFXButton(frameButtons, "", "", "", GUIIconSubSys::getIcon(GUIIcon::BIGARROWRIGHT), this, MID_GNE_OVERLAPPED_NEXT, GUIDesignButtonRectangular);
// Create list of overlapped elements (by default hidden)
myOverlappedElementList = new FXList(getCollapsableFrame(), this, MID_GNE_OVERLAPPED_ITEMSELECTED, GUIDesignListFixedHeight);
// by default list of overlapped elements is hidden)
myOverlappedElementList->hide();
// Create help button
myHelpButton = GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Help"), "", "", nullptr, this, MID_HELP, GUIDesignButtonRectangular);
}


GNEOverlappedInspection::~GNEOverlappedInspection() {}


void
GNEOverlappedInspection::showOverlappedInspection(const GNEViewNetHelper::ViewObjectsSelector& viewObjects, const Position& clickedPosition) {
GNEOverlappedInspection::showOverlappedInspection(GNEViewNetHelper::ViewObjectsSelector& viewObjects, const Position& clickedPosition) {
myOverlappedACs.clear();
mySavedClickedPosition = clickedPosition;
auto clickedACs = viewObjects.getAttributeCarriers();
// check if filter edges
if ((clickedACs.size() > 0) && (clickedACs.front()->getTagProperty().getTag() == SUMO_TAG_LANE)) {
// iterate over clickedAcs and remove edges
auto it = clickedACs.begin();
while (it != clickedACs.end()) {
if ((*it)->getTagProperty().getTag() == SUMO_TAG_EDGE) {
it = clickedACs.erase(it);
} else {
it++;
}
}
// filtger edges if we clicked over a lane
if (viewObjects.getAttributeCarrierFront() && viewObjects.getAttributeCarrierFront() == viewObjects.getLaneFront()) {
viewObjects.filterEdges();
}
// reserve
myOverlappedACs.reserve(clickedACs.size());
// iterate over objects under cursor
for (const auto& AC : clickedACs) {
bool insert = true;
// check supermode demand
if (myFrameParent->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
!AC->getTagProperty().isDemandElement()) {
insert = false;
}
// check supermode data
if (myFrameParent->getViewNet()->getEditModes().isCurrentSupermodeData() &&
!AC->getTagProperty().isGenericData()) {
insert = false;
}
// check filter
if ((myFilteredTag != SUMO_TAG_NOTHING) && (AC->getTagProperty().getTag() != myFilteredTag)) {
insert = false;
}
if (insert) {
myOverlappedACs.push_back(AC);
}
// filter depending of supermode
viewObjects.filterBySuperMode();
// check if filter all except junctions
if (myOnlyJunctions) {
viewObjects.filterNetworkElements(false);
}
myOverlappedACs = viewObjects.getAttributeCarriers();
refreshOverlappedInspection();
}

Expand Down Expand Up @@ -314,26 +291,8 @@ GNEOverlappedInspection::GNEOverlappedInspection() :
myNextElement(nullptr),
myOverlappedElementList(nullptr),
myHelpButton(nullptr),
myFilteredTag(SUMO_TAG_NOTHING),
myOnlyJunctions(false),
myItemIndex(0) {
}


void
GNEOverlappedInspection::buildFXElements() {
FXHorizontalFrame* frameButtons = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
// Create previous Item Button
myPreviousElement = GUIDesigns::buildFXButton(frameButtons, "", "", "", GUIIconSubSys::getIcon(GUIIcon::BIGARROWLEFT), this, MID_GNE_OVERLAPPED_PREVIOUS, GUIDesignButtonRectangular);
// create current index button
myCurrentIndexButton = GUIDesigns::buildFXButton(frameButtons, "", "", "", nullptr, this, MID_GNE_OVERLAPPED_SHOWLIST, GUIDesignButton);
// Create next Item Button
myNextElement = GUIDesigns::buildFXButton(frameButtons, "", "", "", GUIIconSubSys::getIcon(GUIIcon::BIGARROWRIGHT), this, MID_GNE_OVERLAPPED_NEXT, GUIDesignButtonRectangular);
// Create list of overlapped elements (by default hidden)
myOverlappedElementList = new FXList(getCollapsableFrame(), this, MID_GNE_OVERLAPPED_ITEMSELECTED, GUIDesignListFixedHeight);
// by default list of overlapped elements is hidden)
myOverlappedElementList->hide();
// Create help button
myHelpButton = GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Help"), "", "", nullptr, this, MID_HELP, GUIDesignButtonRectangular);
}

/****************************************************************************/
14 changes: 4 additions & 10 deletions src/netedit/frames/GNEOverlappedInspection.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,14 @@ class GNEOverlappedInspection : public MFXGroupBoxModule {
FXDECLARE(GNEOverlappedInspection)

public:
/// @brief constructor
GNEOverlappedInspection(GNEFrame* frameParent);

/// @brief constructor (used for filter objects under cusor
GNEOverlappedInspection(GNEFrame* frameParent, const SumoXMLTag filteredTag);
GNEOverlappedInspection(GNEFrame* frameParent, const bool onlyJunctions);

/// @brief destructor
~GNEOverlappedInspection();

/// @brief show overlapped inspection
void showOverlappedInspection(const GNEViewNetHelper::ViewObjectsSelector& viewObjects, const Position& clickedPosition);
void showOverlappedInspection(GNEViewNetHelper::ViewObjectsSelector& viewObjects, const Position& clickedPosition);

/// @brief show template editor
void refreshOverlappedInspection();
Expand Down Expand Up @@ -93,9 +90,6 @@ class GNEOverlappedInspection : public MFXGroupBoxModule {
/// @brief FOX needs this
GNEOverlappedInspection();

/// @brief build Fox Toolkit elemements
void buildFXElements();

private:
/// @brief current frame parent
GNEFrame* myFrameParent;
Expand All @@ -115,8 +109,8 @@ class GNEOverlappedInspection : public MFXGroupBoxModule {
/// @brief button for help
FXButton* myHelpButton;

/// @brief filtered tag
const SumoXMLTag myFilteredTag;
/// @brief flag to indicate that this modul is only for junctions
const bool myOnlyJunctions;

/// @brief objects under cursor
std::vector<GNEAttributeCarrier*> myOverlappedACs;
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/frames/common/GNEInspectorFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ GNEInspectorFrame::GNEInspectorFrame(GNEViewParent* viewParent, GNEViewNet* view
myBackButton->hide();

// Create Overlapped Inspection module
myOverlappedInspection = new GNEOverlappedInspection(this);
myOverlappedInspection = new GNEOverlappedInspection(this, false);

// Create Attributes Editor module
myAttributesEditor = new GNEAttributesEditor(this, TL("Attributes"), GNEAttributesEditor::EditorOptions::BASIC_ATTRIBUTES);
Expand Down Expand Up @@ -576,7 +576,7 @@ GNEInspectorFrame::selectedOverlappedElement(GNEAttributeCarrier* AC) {


void
GNEInspectorFrame::inspectClickedElement(const GNEViewNetHelper::ViewObjectsSelector& viewObjects, const Position& clickedPosition) {
GNEInspectorFrame::inspectClickedElement(GNEViewNetHelper::ViewObjectsSelector& viewObjects, const Position& clickedPosition) {
// get front unlocked AC
const auto AC = viewObjects.getAttributeCarrierFront();
// check if selection is blocked
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/frames/common/GNEInspectorFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class GNEInspectorFrame : public GNEFrame {
FOX_CONSTRUCTOR(GNEInspectorFrame)

/// @brief Inspect a singe element (the front of AC AttributeCarriers of ObjectUnderCursor
void inspectClickedElement(const GNEViewNetHelper::ViewObjectsSelector& viewObjects, const Position& clickedPosition);
void inspectClickedElement(GNEViewNetHelper::ViewObjectsSelector& viewObjects, const Position& clickedPosition);

private:
/// @brief Overlapped Inspection
Expand Down
6 changes: 3 additions & 3 deletions src/netedit/frames/network/GNETLSEditorFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ GNETLSEditorFrame::GNETLSEditorFrame(GNEViewParent* viewParent, GNEViewNet* view
GNEFrame(viewParent, viewNet, TL("Edit Traffic Light")),
myEditedDef(nullptr) {

// Create Overlapped Inspection module
myOverlappedInspection = new GNEOverlappedInspection(this, SUMO_TAG_JUNCTION);
// Create Overlapped Inspection module only for junctions
myOverlappedInspection = new GNEOverlappedInspection(this, true);

// create TLSJunction module
myTLSJunction = new GNETLSEditorFrame::TLSJunction(this);
Expand Down Expand Up @@ -164,7 +164,7 @@ GNETLSEditorFrame::frameWidthUpdated() {


void
GNETLSEditorFrame::editTLS(const Position& clickedPosition, const GNEViewNetHelper::ViewObjectsSelector& viewObjects) {
GNETLSEditorFrame::editTLS(const Position& clickedPosition, GNEViewNetHelper::ViewObjectsSelector& viewObjects) {
// first check if in viewObjects there is a junction
if (viewObjects.getJunctionFront()) {
// show objects under cursor
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/frames/network/GNETLSEditorFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ class GNETLSEditorFrame : public GNEFrame {
* @param[in] clickedPosition clicked position
* @param[in] viewObjects The clicked objects under cursor
*/
void editTLS(const Position& clickedPosition, const GNEViewNetHelper::ViewObjectsSelector& viewObjects);
void editTLS(const Position& clickedPosition, GNEViewNetHelper::ViewObjectsSelector& viewObjects);

/// @brief check if modifications in TLS was saved
bool isTLSSaved();
Expand Down

0 comments on commit ddcfac6

Please sign in to comment.