Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEOverlappedInspection.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Frame for overlapped elements
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNEViewNet.h>
27
29
30
31// ===========================================================================
32// FOX callback mapping
33// ===========================================================================
34
42
43
44// Object implementation
45FXIMPLEMENT(GNEOverlappedInspection, MFXGroupBoxModule, OverlappedInspectionMap, ARRAYNUMBER(OverlappedInspectionMap))
46
47
48// ===========================================================================
49// method definitions
50// ===========================================================================
51
52GNEOverlappedInspection::GNEOverlappedInspection(GNEFrame* frameParent, const bool onlyJunctions) :
53 MFXGroupBoxModule(frameParent, onlyJunctions? TL("Overlapped junctions") : TL("Overlapped elements")),
54 myFrameParent(frameParent),
55 myOnlyJunctions(onlyJunctions) {
56 FXHorizontalFrame* frameButtons = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
57 // Create previous Item Button
59 // create current index button
60 myCurrentIndexButton = GUIDesigns::buildFXButton(frameButtons, "", "", "", nullptr, this, MID_GNE_OVERLAPPED_SHOWLIST, GUIDesignButton);
61 // Create next Item Button
63 // Create list of overlapped elements (by default hidden)
64 myOverlappedElementList = new FXList(getCollapsableFrame(), this, MID_GNE_OVERLAPPED_ITEMSELECTED, GUIDesignListFixedHeight);
65 // by default list of overlapped elements is hidden)
66 myOverlappedElementList->hide();
67 // Create help button
68 myHelpButton = GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Help"), "", "", nullptr, this, MID_HELP, GUIDesignButtonRectangular);
69 // by default hidden
70 hide();
71}
72
73
75
76
77void
78GNEOverlappedInspection::showOverlappedInspection(GNEViewNetHelper::ViewObjectsSelector& viewObjects, const Position &clickedPosition, const bool shiftKeyPressed) {
79 // check if filter all except junctions
80 if (myOnlyJunctions) {
81 viewObjects.filterAllExcept(GLO_JUNCTION);
82 } else {
83 // filter by supermode
84 viewObjects.filterBySuperMode();
85 // filtger edges if we clicked over a lane
86 if (viewObjects.getAttributeCarrierFront() && viewObjects.getAttributeCarrierFront() == viewObjects.getLaneFront()) {
87 viewObjects.filterEdges();
88 }
89 }
90 // in this point, check if we want to iterate over existent overlapped inspection, or we want to inspet a new set of elements
92 if (shiftKeyPressed) {
93 onCmdInspectPreviousElement(nullptr, 0, nullptr);
94 } else {
95 onCmdInspectNextElement(nullptr, 0, nullptr);
96 }
97 } else {
99 myItemIndex = 0;
101 }
102 // update clicked position and refresh overlapped inspection
103 myClickedPosition = clickedPosition;
105}
106
107
108void
115
116
117void
121
122void
124 // show modul depending of number of overlapped elements
125 if (myOverlappedACs.size() > 1) {
126 // update text of current index button
127 myCurrentIndexButton->setText((toString(myItemIndex + 1) + " / " + toString(myOverlappedACs.size())).c_str());
128 // clear and fill list again
129 myOverlappedElementList->clearItems();
130 for (int i = 0; i < (int)myOverlappedACs.size(); i++) {
131 myOverlappedElementList->insertItem(i, myOverlappedACs.at(i)->getID().c_str(), myOverlappedACs.at(i)->getACIcon());
132 }
133 // select current item
134 myOverlappedElementList->getItem(myItemIndex)->setSelected(TRUE);
135 // show modul
136 show();
137 // call selectedOverlappedElement
139 } else {
140 if (myOverlappedACs.size() > 0) {
142 } else {
144 }
145 hide();
146 }
147}
148
149
150bool
152 // show GNEOverlappedInspection modul
153 return shown();
154}
155
156
157int
161
162
163long
165 // check if there is items
166 if (myOverlappedElementList->getNumItems() > 0) {
167 // set index (it works as a ring)
168 if (myItemIndex > 0) {
169 myItemIndex--;
170 } else {
171 myItemIndex = ((int)myOverlappedACs.size() - 1);
172 }
174 }
175 return 1;
176}
177
178
179long
181 // check if there is items
182 if (myOverlappedElementList->getNumItems() > 0) {
183 // set index (it works as a ring)
184 myItemIndex = (myItemIndex + 1) % myOverlappedACs.size();
186 }
187 return 1;
188}
189
190
191long
192GNEOverlappedInspection::onCmdShowList(FXObject*, FXSelector, void*) {
193 // show or hide element list
194 if (myOverlappedElementList->shown()) {
196 } else {
198 }
199 if (myOverlappedElementList->getNumItems() <= 10) {
200 myOverlappedElementList->setHeight(23 * myOverlappedElementList->getNumItems());
201 } else {
202 myOverlappedElementList->setHeight(230);
203 }
204 myOverlappedElementList->recalc();
205 // recalc and update frame
206 recalc();
207 return 1;
208}
209
210long
212 for (int i = 0; i < myOverlappedElementList->getNumItems(); i++) {
213 if (myOverlappedElementList->getItem(i)->isSelected()) {
214 myItemIndex = i;
216 return 1;
217 }
218 }
219 return 0;
220}
221
222
223long
225 FXDialogBox* helpDialog = new FXDialogBox(getCollapsableFrame(), TL("GEO attributes Help"), GUIDesignDialogBox);
226 std::ostringstream help;
227 help
228 << TL(" - Click in the same position") << "\n"
229 << TL(" for inspect next element") << "\n"
230 << TL(" - Shift + Click in the same") << "\n"
231 << TL(" position for inspect") << "\n"
232 << TL(" previous element");
233 new FXLabel(helpDialog, help.str().c_str(), nullptr, GUIDesignLabelFrameInformation);
234 // "OK"
235 GUIDesigns::buildFXButton(helpDialog, TL("OK"), "", TL("close"), GUIIconSubSys::getIcon(GUIIcon::ACCEPT), helpDialog, FXDialogBox::ID_ACCEPT, GUIDesignButtonOK);
236 helpDialog->create();
237 helpDialog->show(PLACEMENT_SCREEN);
238 return 1;
239}
240
241
243
244/****************************************************************************/
FXDEFMAP(GNEOverlappedInspection) OverlappedInspectionMap[]
@ MID_GNE_OVERLAPPED_PREVIOUS
inspect previous element in overlapped module
@ MID_GNE_OVERLAPPED_ITEMSELECTED
list item selected in overlapped module
@ MID_HELP
help button
Definition GUIAppEnum.h:653
@ MID_GNE_OVERLAPPED_SHOWLIST
show list of overlapped elements
@ MID_GNE_OVERLAPPED_NEXT
inspect next element in overlapped module
#define GUIDesignButton
Definition GUIDesigns.h:82
#define GUIDesignListFixedHeight
design for FXLists with height fixed
Definition GUIDesigns.h:689
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:399
#define GUIDesignDialogBox
Definition GUIDesigns.h:599
#define GUIDesignButtonRectangular
little rectangular button used in frames (For example, in "help" buttons)
Definition GUIDesigns.h:94
#define GUIDesignButtonOK
Definition GUIDesigns.h:153
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition GUIDesigns.h:279
@ GLO_JUNCTION
a junction
@ BIGARROWLEFT
@ BIGARROWRIGHT
#define TL(string)
Definition MsgHandler.h:315
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
virtual void selectedOverlappedElement(GNEAttributeCarrier *AC)
open GNEAttributesCreator extended dialog
Definition GNEFrame.cpp:292
void clearOverlappedInspection()
clear overlapped inspection
void refreshOverlappedInspection()
show template editor
FXButton * myCurrentIndexButton
Button for current index.
Position myClickedPosition
clicked position
std::vector< GNEAttributeCarrier * > myOverlappedACs
objects under cursor
long onCmdShowList(FXObject *, FXSelector, void *)
show list of overlapped elements
void hiderOverlappedInspection()
hide overlapped inspection
void showOverlappedInspection(GNEViewNetHelper::ViewObjectsSelector &viewObjects, const Position &clickedPosition, const bool shiftKeyPressed)
show overlapped inspection
long onCmdOverlappingHelp(FXObject *, FXSelector, void *)
Called when user press the help button.
bool overlappedInspectionShown() const
check if overlappedInspection modul is shown
long onCmdListItemSelected(FXObject *, FXSelector, void *)
called when a list item is selected
long onCmdInspectPreviousElement(FXObject *, FXSelector, void *)
Inspect previous element (from top to bot)
int myItemIndex
current index item
GNEFrame * myFrameParent
current frame parent
long onCmdInspectNextElement(FXObject *, FXSelector, void *)
Inspect next Element (from top to bot)
FXList * myOverlappedElementList
list of overlapped elements
int getNumberOfOverlappedACs() const
get number of overlapped ACSs
const bool myOnlyJunctions
flag to indicate that this modul is only for junctions
class used to group all variables related with objects under cursor after a click over view
void filterAllExcept(GUIGlObjectType exception)
filter all elements except the given GLO type
const std::vector< GNEAttributeCarrier * > & getAttributeCarriers() const
get vector with ACs
void filterEdges()
filter (remove) edges
void filterBySuperMode()
filter by supermode
GNEAttributeCarrier * getAttributeCarrierFront() const
get front attribute carrier or a pointer to nullptr
GNELane * getLaneFront() const
get front lane or a pointer to nullptr
static FXButton * buildFXButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXIcon *ic, FXObject *tgt, FXSelector sel, FXuint opts=BUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build button
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
MFXGroupBoxModule (based on FXGroupBox)
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toggled)
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:322
double distanceSquaredTo(const Position &p2) const
returns the square of the distance to another position
Definition Position.h:271