Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/GNEViewParent.cpp
169665 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/****************************************************************************/
14
/// @file GNEViewParent.cpp
15
/// @author Jakob Erdmann
16
/// @date Feb 2011
17
///
18
// A single child window which contains a view of the edited network (adapted
19
// from GUISUMOViewParent)
20
// While we don't actually need MDI for netedit it is easier to adapt existing
21
// structures than to write everything from scratch.
22
/****************************************************************************/
23
24
#include <netedit/GNETagProperties.h>
25
#include <netedit/dialogs/basic/GNEErrorBasicDialog.h>
26
#include <netedit/dialogs/GNEACChooserDialog.h>
27
#include <netedit/elements/network/GNEWalkingArea.h>
28
#include <netedit/frames/common/GNEDeleteFrame.h>
29
#include <netedit/frames/common/GNEInspectorFrame.h>
30
#include <netedit/frames/common/GNEMoveFrame.h>
31
#include <netedit/frames/common/GNESelectorFrame.h>
32
#include <netedit/frames/data/GNEEdgeDataFrame.h>
33
#include <netedit/frames/data/GNEEdgeRelDataFrame.h>
34
#include <netedit/frames/data/GNETAZRelDataFrame.h>
35
#include <netedit/frames/data/GNEMeanDataFrame.h>
36
#include <netedit/frames/demand/GNEContainerFrame.h>
37
#include <netedit/frames/demand/GNEContainerPlanFrame.h>
38
#include <netedit/frames/demand/GNEPersonFrame.h>
39
#include <netedit/frames/demand/GNEPersonPlanFrame.h>
40
#include <netedit/frames/demand/GNERouteFrame.h>
41
#include <netedit/frames/demand/GNERouteDistributionFrame.h>
42
#include <netedit/frames/demand/GNEStopFrame.h>
43
#include <netedit/frames/demand/GNEVehicleFrame.h>
44
#include <netedit/frames/demand/GNETypeFrame.h>
45
#include <netedit/frames/demand/GNETypeDistributionFrame.h>
46
#include <netedit/frames/network/GNEAdditionalFrame.h>
47
#include <netedit/frames/network/GNEConnectorFrame.h>
48
#include <netedit/frames/network/GNECreateEdgeFrame.h>
49
#include <netedit/frames/network/GNECrossingFrame.h>
50
#include <netedit/frames/network/GNEShapeFrame.h>
51
#include <netedit/frames/network/GNEProhibitionFrame.h>
52
#include <netedit/frames/network/GNEWireFrame.h>
53
#include <netedit/frames/network/GNEDecalFrame.h>
54
#include <netedit/frames/network/GNETAZFrame.h>
55
#include <netedit/frames/network/GNETLSEditorFrame.h>
56
#include <utils/foxtools/MFXMenuButtonTooltip.h>
57
#include <utils/gui/div/GUIDesigns.h>
58
#include <utils/xml/NamespaceIDs.h>
59
60
#include "GNEApplicationWindow.h"
61
#include "GNETagPropertiesDatabase.h"
62
#include "GNENet.h"
63
#include "GNEUndoList.h"
64
#include "GNEViewNet.h"
65
#include "GNEViewParent.h"
66
67
// ===========================================================================
68
// FOX callback mapping
69
// ===========================================================================
70
71
FXDEFMAP(GNEViewParent) GNEViewParentMap[] = {
72
FXMAPFUNC(SEL_COMMAND, MID_MAKESNAPSHOT, GNEViewParent::onCmdMakeSnapshot),
73
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_J_LOCATEJUNCTION, GNEViewParent::onCmdLocate),
74
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_E_LOCATEEDGE, GNEViewParent::onCmdLocate),
75
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_W_LOCATEWALKINGAREA, GNEViewParent::onCmdLocate),
76
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_V_LOCATEVEHICLE, GNEViewParent::onCmdLocate),
77
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_P_LOCATEPERSON, GNEViewParent::onCmdLocate),
78
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_C_LOCATECONTAINER, GNEViewParent::onCmdLocate),
79
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_R_LOCATEROUTE, GNEViewParent::onCmdLocate),
80
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_S_LOCATESTOP, GNEViewParent::onCmdLocate),
81
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_T_LOCATETLS, GNEViewParent::onCmdLocate),
82
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_A_LOCATEADDITIONAL, GNEViewParent::onCmdLocate),
83
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_O_LOCATEPOI, GNEViewParent::onCmdLocate),
84
FXMAPFUNC(SEL_COMMAND, MID_HOTKEY_SHIFT_L_LOCATEPOLY, GNEViewParent::onCmdLocate),
85
FXMAPFUNC(SEL_COMMAND, FXMDIChild::ID_MDI_MENUCLOSE, GNEViewParent::onCmdClose),
86
FXMAPFUNC(SEL_CHANGED, MID_GNE_VIEWPARENT_FRAMEAREAWIDTH, GNEViewParent::onCmdUpdateFrameAreaWidth),
87
};
88
89
// Object implementation
90
FXIMPLEMENT(GNEViewParent, GUIGlChildWindow, GNEViewParentMap, ARRAYNUMBER(GNEViewParentMap))
91
92
93
// ===========================================================================
94
// member method definitions
95
// ===========================================================================
96
97
GNEViewParent::GNEViewParent(FXMDIClient* p, FXMDIMenu* mdimenu, const FXString& name, GNEApplicationWindow* parentWindow,
98
FXGLCanvas* share, GNENet* net, GNEUndoList* undoList, FXIcon* ic, FXuint opts, FXint x, FXint y, FXint w, FXint h) :
99
GUIGlChildWindow(p, parentWindow, mdimenu, name, parentWindow->getToolbarsGrip().navigation, ic, opts, x, y, w, h),
100
myGNEAppWindows(parentWindow) {
101
// Add child to parent
102
myGUIMainWindowParent->addGLChild(this);
103
104
// Create Vertical separator
105
new FXVerticalSeparator(myGripNavigationToolbar, GUIDesignVerticalSeparator);
106
107
// Create undo/redo buttons
108
myUndoButton = new MFXButtonTooltip(myGripNavigationToolbar, myGNEAppWindows->getStaticTooltipMenu(),
109
std::string("\t") + TL("Undo") + std::string("\t") + TL("Undo the last change. (Ctrl+Z)"),
110
GUIIconSubSys::getIcon(GUIIcon::UNDO), parentWindow, MID_HOTKEY_CTRL_Z_UNDO, GUIDesignButtonToolbar);
111
myRedoButton = new MFXButtonTooltip(myGripNavigationToolbar, myGNEAppWindows->getStaticTooltipMenu(),
112
std::string("\t") + TL("Redo") + std::string("\t") + TL("Redo the last change. (Ctrl+Y)"),
113
GUIIconSubSys::getIcon(GUIIcon::REDO), parentWindow, MID_HOTKEY_CTRL_Y_REDO, GUIDesignButtonToolbar);
114
115
// Create Vertical separator
116
new FXVerticalSeparator(myGripNavigationToolbar, GUIDesignVerticalSeparator);
117
118
// create compute path manager button
119
myComputePathManagerButton = new MFXButtonTooltip(myGripNavigationToolbar, myGNEAppWindows->getStaticTooltipMenu(),
120
std::string("\t") + TL("Compute path manager") + std::string("\t") + TL("Compute path manager."),
121
GUIIconSubSys::getIcon(GUIIcon::COMPUTEPATHMANAGER), parentWindow, MID_GNE_TOOLBAREDIT_COMPUTEPATHMANAGER, GUIDesignButtonToolbar);
122
123
// Create Frame Splitter
124
myFramesSplitter = new FXSplitter(myChildWindowContentFrame, this, MID_GNE_VIEWPARENT_FRAMEAREAWIDTH, GUIDesignSplitter | SPLITTER_HORIZONTAL);
125
126
// Create frames Area (vertical frame)
127
myFramesArea = new FXVerticalFrame(myFramesSplitter, GUIDesignFrameArea);
128
129
// Create view area
130
myViewArea = new FXHorizontalFrame(myFramesSplitter, GUIDesignViewnArea);
131
132
// Add the view to a temporary parent so that we can add items to myViewArea in the desired order
133
FXComposite* tmp = new FXComposite(this);
134
135
// Create view net
136
GNEViewNet* viewNet = new GNEViewNet(tmp, myViewArea, *myGUIMainWindowParent, this, net, undoList, myGUIMainWindowParent->getGLVisual(), share);
137
138
// show toolbar grips
139
myGNEAppWindows->getToolbarsGrip().buildMenuToolbarsGrip();
140
141
// Set pointer myView with the created view net
142
myView = viewNet;
143
144
// build frames
145
myCommonFrames.buildCommonFrames(this, viewNet);
146
myNetworkFrames.buildNetworkFrames(this, viewNet);
147
myDemandFrames.buildDemandFrames(this, viewNet);
148
myDataFrames.buildDataFrames(this, viewNet);
149
150
// set default frames area width
151
myFramesArea->setWidth(GUIDesignFramesAreaDefaultWidth);
152
153
// Update frame areas after creation
154
onCmdUpdateFrameAreaWidth(nullptr, 0, nullptr);
155
156
// Hide all Frames Area
157
hideFramesArea();
158
159
// Build view toolBars
160
myView->buildViewToolBars(this);
161
162
// create windows
163
GUIGlChildWindow::create();
164
}
165
166
167
GNEViewParent::~GNEViewParent() {
168
// delete toolbar grips
169
myGNEAppWindows->getToolbarsGrip().destroyParentToolbarsGrips();
170
// Remove child before remove
171
myGUIMainWindowParent->removeGLChild(this);
172
}
173
174
175
void
176
GNEViewParent::hideAllFrames() {
177
myCommonFrames.hideCommonFrames();
178
myNetworkFrames.hideNetworkFrames();
179
myDemandFrames.hideDemandFrames();
180
myDataFrames.hideDataFrames();
181
}
182
183
184
GNEFrame*
185
GNEViewParent::getCurrentShownFrame() const {
186
if (myCommonFrames.isCommonFrameShown()) {
187
return myCommonFrames.getCurrentShownFrame();
188
} else if (myNetworkFrames.isNetworkFrameShown()) {
189
return myNetworkFrames.getCurrentShownFrame();
190
} else if (myDemandFrames.isDemandFrameShown()) {
191
return myDemandFrames.getCurrentShownFrame();
192
} else if (myDataFrames.isDataFrameShown()) {
193
return myDataFrames.getCurrentShownFrame();
194
} else {
195
return nullptr;
196
}
197
}
198
199
200
GNEInspectorFrame*
201
GNEViewParent::getInspectorFrame() const {
202
return myCommonFrames.inspectorFrame;
203
}
204
205
206
GNEDeleteFrame*
207
GNEViewParent::getDeleteFrame() const {
208
return myCommonFrames.deleteFrame;
209
}
210
211
212
GNESelectorFrame*
213
GNEViewParent::getSelectorFrame() const {
214
return myCommonFrames.selectorFrame;
215
}
216
217
218
GNEMoveFrame*
219
GNEViewParent::getMoveFrame() const {
220
return myCommonFrames.moveFrame;
221
}
222
223
224
GNEConnectorFrame*
225
GNEViewParent::getConnectorFrame() const {
226
return myNetworkFrames.connectorFrame;
227
}
228
229
230
GNETLSEditorFrame*
231
GNEViewParent::getTLSEditorFrame() const {
232
return myNetworkFrames.TLSEditorFrame;
233
}
234
235
236
GNEAdditionalFrame*
237
GNEViewParent::getAdditionalFrame() const {
238
return myNetworkFrames.additionalFrame;
239
}
240
241
242
GNECrossingFrame*
243
GNEViewParent::getCrossingFrame() const {
244
return myNetworkFrames.crossingFrame;
245
}
246
247
248
GNETAZFrame*
249
GNEViewParent::getTAZFrame() const {
250
return myNetworkFrames.TAZFrame;
251
}
252
253
254
GNEShapeFrame*
255
GNEViewParent::getShapeFrame() const {
256
return myNetworkFrames.polygonFrame;
257
}
258
259
260
GNEProhibitionFrame*
261
GNEViewParent::getProhibitionFrame() const {
262
return myNetworkFrames.prohibitionFrame;
263
}
264
265
266
GNEWireFrame*
267
GNEViewParent::getWireFrame() const {
268
return myNetworkFrames.wireFrame;
269
}
270
271
272
GNEDecalFrame*
273
GNEViewParent::getDecalFrame() const {
274
return myNetworkFrames.decalFrame;
275
}
276
277
278
GNECreateEdgeFrame*
279
GNEViewParent::getCreateEdgeFrame() const {
280
return myNetworkFrames.createEdgeFrame;
281
}
282
283
284
GNERouteDistributionFrame*
285
GNEViewParent::getRouteDistributionFrame() const {
286
return myDemandFrames.routeDistributionFrame;
287
}
288
289
290
GNERouteFrame*
291
GNEViewParent::getRouteFrame() const {
292
return myDemandFrames.routeFrame;
293
}
294
295
296
GNEVehicleFrame*
297
GNEViewParent::getVehicleFrame() const {
298
return myDemandFrames.vehicleFrame;
299
}
300
301
302
GNETypeFrame*
303
GNEViewParent::getTypeFrame() const {
304
return myDemandFrames.typeFrame;
305
}
306
307
308
GNETypeDistributionFrame*
309
GNEViewParent::getTypeDistributionFrame() const {
310
return myDemandFrames.typeDistributionFrame;
311
}
312
313
314
GNEStopFrame*
315
GNEViewParent::getStopFrame() const {
316
return myDemandFrames.stopFrame;
317
}
318
319
320
GNEPersonFrame*
321
GNEViewParent::getPersonFrame() const {
322
return myDemandFrames.personFrame;
323
}
324
325
326
GNEPersonPlanFrame*
327
GNEViewParent::getPersonPlanFrame() const {
328
return myDemandFrames.personPlanFrame;
329
}
330
331
332
GNEContainerFrame*
333
GNEViewParent::getContainerFrame() const {
334
return myDemandFrames.containerFrame;
335
}
336
337
338
GNEContainerPlanFrame*
339
GNEViewParent::getContainerPlanFrame() const {
340
return myDemandFrames.containerPlanFrame;
341
}
342
343
344
GNEEdgeDataFrame*
345
GNEViewParent::getEdgeDataFrame() const {
346
return myDataFrames.edgeDataFrame;
347
}
348
349
350
GNEEdgeRelDataFrame*
351
GNEViewParent::getEdgeRelDataFrame() const {
352
return myDataFrames.edgeRelDataFrame;
353
}
354
355
356
GNETAZRelDataFrame*
357
GNEViewParent::getTAZRelDataFrame() const {
358
return myDataFrames.TAZRelDataFrame;
359
}
360
361
362
GNEMeanDataFrame*
363
GNEViewParent::getMeanDataFrame() const {
364
return myDataFrames.meanDataFrame;
365
}
366
367
368
void
369
GNEViewParent::showFramesArea() {
370
const bool frameShown = myCommonFrames.isCommonFrameShown() ||
371
myNetworkFrames.isNetworkFrameShown() ||
372
myDemandFrames.isDemandFrameShown() ||
373
myDataFrames.isDataFrameShown();
374
// show and recalc framesArea if at least there is a frame shown
375
if (frameShown) {
376
myFramesArea->recalc();
377
myFramesArea->show();
378
}
379
}
380
381
382
void
383
GNEViewParent::hideFramesArea() {
384
const bool frameShown = myCommonFrames.isCommonFrameShown() ||
385
myNetworkFrames.isNetworkFrameShown() ||
386
myDemandFrames.isDemandFrameShown() ||
387
myDataFrames.isDataFrameShown();
388
// hide and recalc frames Area if all frames are hidden is enabled
389
if (!frameShown) {
390
myFramesArea->hide();
391
myFramesArea->recalc();
392
}
393
}
394
395
396
GUIMainWindow*
397
GNEViewParent::getGUIMainWindow() const {
398
return myGUIMainWindowParent;
399
}
400
401
402
GNEApplicationWindow*
403
GNEViewParent::getGNEAppWindows() const {
404
return myGNEAppWindows;
405
}
406
407
408
void
409
GNEViewParent::eraseACChooserDialog(GNEACChooserDialog* chooserDialog) {
410
if (chooserDialog == nullptr) {
411
throw ProcessError("ChooserDialog already deleted");
412
} else if (chooserDialog == myACChoosers.ACChooserJunction) {
413
myACChoosers.ACChooserJunction = nullptr;
414
} else if (chooserDialog == myACChoosers.ACChooserEdges) {
415
myACChoosers.ACChooserEdges = nullptr;
416
} else if (chooserDialog == myACChoosers.ACChooserWalkingAreas) {
417
myACChoosers.ACChooserWalkingAreas = nullptr;
418
} else if (chooserDialog == myACChoosers.ACChooserVehicles) {
419
myACChoosers.ACChooserVehicles = nullptr;
420
} else if (chooserDialog == myACChoosers.ACChooserPersons) {
421
myACChoosers.ACChooserPersons = nullptr;
422
} else if (chooserDialog == myACChoosers.ACChooserContainers) {
423
myACChoosers.ACChooserContainers = nullptr;
424
} else if (chooserDialog == myACChoosers.ACChooserRoutes) {
425
myACChoosers.ACChooserRoutes = nullptr;
426
} else if (chooserDialog == myACChoosers.ACChooserStops) {
427
myACChoosers.ACChooserStops = nullptr;
428
} else if (chooserDialog == myACChoosers.ACChooserTLS) {
429
myACChoosers.ACChooserTLS = nullptr;
430
} else if (chooserDialog == myACChoosers.ACChooserAdditional) {
431
myACChoosers.ACChooserAdditional = nullptr;
432
} else if (chooserDialog == myACChoosers.ACChooserPOI) {
433
myACChoosers.ACChooserPOI = nullptr;
434
} else if (chooserDialog == myACChoosers.ACChooserPolygon) {
435
myACChoosers.ACChooserPolygon = nullptr;
436
} else if (chooserDialog == myACChoosers.ACChooserProhibition) {
437
myACChoosers.ACChooserProhibition = nullptr;
438
} else if (chooserDialog == myACChoosers.ACChooserWire) {
439
myACChoosers.ACChooserWire = nullptr;
440
} else {
441
throw ProcessError("Unregistered chooserDialog");
442
}
443
}
444
445
446
void
447
GNEViewParent::updateUndoRedoButtons() {
448
myGNEAppWindows->getUndoList()->onUpdUndo(myUndoButton, 0, nullptr);
449
myGNEAppWindows->getUndoList()->onUpdRedo(myRedoButton, 0, nullptr);
450
}
451
452
453
FXVerticalFrame*
454
GNEViewParent::getFramesArea() const {
455
return myFramesArea;
456
}
457
458
459
int
460
GNEViewParent::getFrameAreaWidth() const {
461
return myFramesArea->getWidth();
462
}
463
464
465
void
466
GNEViewParent::setFrameAreaWidth(const int frameAreaWith) {
467
myFramesArea->setWidth(frameAreaWith);
468
onCmdUpdateFrameAreaWidth(0, 0, 0);
469
}
470
471
472
long
473
GNEViewParent::onCmdMakeSnapshot(FXObject*, FXSelector, void*) {
474
// get the new file name
475
FXFileDialog opendialog(this, TL("Save Snapshot"));
476
opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::CAMERA));
477
opendialog.setSelectMode(SELECTFILE_ANY);
478
opendialog.setPatternList(SUMOXMLDefinitions::ImageFileExtensions.getMultilineString().c_str());
479
if (gCurrentFolder.length() != 0) {
480
opendialog.setDirectory(gCurrentFolder);
481
}
482
if (!opendialog.execute() || !MFXUtils::userPermitsOverwritingWhenFileExists(this, opendialog.getFilename())) {
483
return 1;
484
}
485
gCurrentFolder = opendialog.getDirectory();
486
std::string file = opendialog.getFilename().text();
487
if (file.find(".") == std::string::npos) {
488
file.append(".png");
489
WRITE_MESSAGE(TL("No file extension was specified - saving Snapshot as PNG."));
490
}
491
const std::string error = myView->makeSnapshot(file);
492
if (error.size() > 0) {
493
// open error message box
494
GNEErrorBasicDialog(myGNEAppWindows, TL("Saving failed."), error.c_str());
495
} else {
496
WRITE_MESSAGE(TL("Snapshot successfully saved!"));
497
}
498
return 1;
499
}
500
501
502
long
503
GNEViewParent::onCmdClose(FXObject*, FXSelector /* sel */, void*) {
504
myGUIMainWindowParent->handle(this, FXSEL(SEL_COMMAND, MID_HOTKEY_CTRL_W_CLOSESIMULATION), nullptr);
505
return 1;
506
}
507
508
509
long
510
GNEViewParent::onCmdLocate(FXObject*, FXSelector sel, void*) {
511
GNEViewNet* viewNet = dynamic_cast<GNEViewNet*>(myView);
512
// check that viewNet exist
513
if (viewNet) {
514
// declare a vector in which save attribute carriers to locate
515
std::map<std::string, GNEAttributeCarrier*> ACsToLocate;
516
int messageId = FXSELID(sel);
517
GNEACChooserDialog** chooserLoc = nullptr;
518
std::string locateTitle;
519
switch (messageId) {
520
case MID_HOTKEY_SHIFT_J_LOCATEJUNCTION:
521
chooserLoc = &myACChoosers.ACChooserJunction;
522
locateTitle = TL("Junction Chooser");
523
for (const auto& junction : viewNet->getNet()->getAttributeCarriers()->getJunctions()) {
524
ACsToLocate[junction.second->getID()] = junction.second;
525
}
526
break;
527
case MID_HOTKEY_SHIFT_E_LOCATEEDGE:
528
chooserLoc = &myACChoosers.ACChooserEdges;
529
locateTitle = TL("Edge Chooser");
530
for (const auto& edge : viewNet->getNet()->getAttributeCarriers()->getEdges()) {
531
ACsToLocate[edge.second->getID()] = edge.second;
532
}
533
break;
534
case MID_HOTKEY_SHIFT_W_LOCATEWALKINGAREA:
535
chooserLoc = &myACChoosers.ACChooserWalkingAreas;
536
locateTitle = TL("WalkingArea Chooser");
537
for (const auto& walkingArea : viewNet->getNet()->getAttributeCarriers()->getWalkingAreas()) {
538
ACsToLocate[walkingArea.second->getID()] = walkingArea.second;
539
}
540
break;
541
case MID_HOTKEY_SHIFT_V_LOCATEVEHICLE: {
542
chooserLoc = &myACChoosers.ACChooserVehicles;
543
locateTitle = TL("Vehicle Chooser");
544
// fill ACsToLocate with all vehicles
545
for (const auto& vehicleTag : NamespaceIDs::vehicles) {
546
for (const auto& vehicle : viewNet->getNet()->getAttributeCarriers()->getDemandElements().at(vehicleTag)) {
547
ACsToLocate[vehicle.second->getID()] = vehicle.second;
548
}
549
}
550
break;
551
}
552
case MID_HOTKEY_SHIFT_P_LOCATEPERSON:
553
chooserLoc = &myACChoosers.ACChooserPersons;
554
locateTitle = TL("Person Chooser");
555
// fill ACsToLocate with all persons
556
for (const auto& personTag : NamespaceIDs::persons) {
557
for (const auto& person : viewNet->getNet()->getAttributeCarriers()->getDemandElements().at(personTag)) {
558
ACsToLocate[person.second->getID()] = person.second;
559
}
560
}
561
break;
562
case MID_HOTKEY_SHIFT_C_LOCATECONTAINER:
563
chooserLoc = &myACChoosers.ACChooserContainers;
564
locateTitle = TL("Container Chooser");
565
// fill ACsToLocate with all containers
566
for (const auto& containerTag : NamespaceIDs::containers) {
567
for (const auto& container : viewNet->getNet()->getAttributeCarriers()->getDemandElements().at(containerTag)) {
568
ACsToLocate[container.second->getID()] = container.second;
569
}
570
}
571
break;
572
case MID_HOTKEY_SHIFT_R_LOCATEROUTE:
573
chooserLoc = &myACChoosers.ACChooserRoutes;
574
locateTitle = TL("Route Chooser");
575
for (const auto& route : viewNet->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_ROUTE)) {
576
ACsToLocate[route.second->getID()] = route.second;
577
}
578
break;
579
case MID_HOTKEY_SHIFT_S_LOCATESTOP: {
580
chooserLoc = &myACChoosers.ACChooserStops;
581
locateTitle = TL("Stop Chooser");
582
// fill ACsToLocate with all vehicles
583
for (const auto& stopTag : NamespaceIDs::stops) {
584
for (const auto& flowTAZ : viewNet->getNet()->getAttributeCarriers()->getDemandElements().at(stopTag)) {
585
ACsToLocate[flowTAZ.second->getID()] = flowTAZ.second;
586
}
587
}
588
break;
589
}
590
case MID_HOTKEY_SHIFT_T_LOCATETLS:
591
chooserLoc = &myACChoosers.ACChooserTLS;
592
locateTitle = TL("TLS Chooser");
593
// fill ACsToLocate with junctions that haven TLS
594
for (const auto& junction : viewNet->getNet()->getAttributeCarriers()->getJunctions()) {
595
if (junction.second->getNBNode()->getControllingTLS().size() > 0) {
596
ACsToLocate[junction.second->getID()] = junction.second;
597
}
598
}
599
break;
600
case MID_HOTKEY_SHIFT_A_LOCATEADDITIONAL:
601
chooserLoc = &myACChoosers.ACChooserAdditional;
602
locateTitle = TL("Additional Chooser");
603
for (const auto& additionalTag : viewNet->getNet()->getAttributeCarriers()->getAdditionals()) {
604
const auto tagProperty = viewNet->getNet()->getTagPropertiesDatabase()->getTagProperty(additionalTag.first, true);
605
// avoid shapes and TAZs
606
if (!tagProperty->isShapeElement() && !tagProperty->isTAZElement()) {
607
for (const auto& additional : additionalTag.second) {
608
ACsToLocate[additional.second->getID()] = additional.second;
609
}
610
}
611
}
612
break;
613
case MID_HOTKEY_SHIFT_O_LOCATEPOI:
614
chooserLoc = &myACChoosers.ACChooserPOI;
615
locateTitle = TL("POI Chooser");
616
// fill ACsToLocate with all POIs
617
for (const auto& POITag : NamespaceIDs::POIs) {
618
for (const auto& poi : viewNet->getNet()->getAttributeCarriers()->getAdditionals().at(POITag)) {
619
ACsToLocate[poi.second->getID()] = poi.second;
620
}
621
}
622
break;
623
case MID_HOTKEY_SHIFT_L_LOCATEPOLY:
624
chooserLoc = &myACChoosers.ACChooserPolygon;
625
locateTitle = TL("Poly Chooser");
626
// fill ACsToLocate with all polygons
627
for (const auto& polygonTag : NamespaceIDs::polygons) {
628
for (const auto& polygon : viewNet->getNet()->getAttributeCarriers()->getAdditionals().at(polygonTag)) {
629
ACsToLocate[polygon.second->getID()] = polygon.second;
630
}
631
}
632
break;
633
default:
634
throw ProcessError("Unknown Message ID in onCmdLocate");
635
}
636
if (*chooserLoc) {
637
// restore focus in the existent chooser dialog
638
GNEACChooserDialog* chooser = *chooserLoc;
639
chooser->restore();
640
chooser->setFocus();
641
chooser->raise();
642
} else {
643
GNEACChooserDialog* chooser = new GNEACChooserDialog(this, messageId, GUIIconSubSys::getIcon(GUIIcon::LOCATEJUNCTION), locateTitle, ACsToLocate);
644
*chooserLoc = chooser;
645
}
646
// update locator popup
647
myLocatorPopup->popdown();
648
myLocatorButton->killFocus();
649
myLocatorPopup->update();
650
}
651
return 1;
652
}
653
654
655
long
656
GNEViewParent::onKeyPress(FXObject* o, FXSelector sel, void* eventData) {
657
myView->onKeyPress(o, sel, eventData);
658
return 0;
659
}
660
661
662
long
663
GNEViewParent::onKeyRelease(FXObject* o, FXSelector sel, void* eventData) {
664
myView->onKeyRelease(o, sel, eventData);
665
return 0;
666
}
667
668
669
long
670
GNEViewParent::onCmdUpdateFrameAreaWidth(FXObject*, FXSelector, void*) {
671
const int framesAreaWidth = myFramesArea->getWidth();
672
// set width of FramesArea in all frames
673
myCommonFrames.setCommonFramesWidth(framesAreaWidth);
674
myNetworkFrames.setNetworkFramesWidth(framesAreaWidth);
675
myDemandFrames.setDemandFramesWidth(framesAreaWidth);
676
myDataFrames.setDataFramesWidth(framesAreaWidth);
677
return 0;
678
}
679
680
// ---------------------------------------------------------------------------
681
// GNEViewParent::CommonFrames - methods
682
// ---------------------------------------------------------------------------
683
684
GNEViewParent::CommonFrames::CommonFrames() {
685
}
686
687
688
void
689
GNEViewParent::CommonFrames::buildCommonFrames(GNEViewParent* viewParent, GNEViewNet* viewNet) {
690
inspectorFrame = new GNEInspectorFrame(viewParent, viewNet);
691
selectorFrame = new GNESelectorFrame(viewParent, viewNet);
692
moveFrame = new GNEMoveFrame(viewParent, viewNet);
693
deleteFrame = new GNEDeleteFrame(viewParent, viewNet);
694
}
695
696
697
void
698
GNEViewParent::CommonFrames::hideCommonFrames() {
699
inspectorFrame->hide();
700
deleteFrame->hide();
701
selectorFrame->hide();
702
moveFrame->hide();
703
}
704
705
706
void
707
GNEViewParent::CommonFrames::setCommonFramesWidth(int frameWidth) {
708
// set width in all frames
709
inspectorFrame->setFrameWidth(frameWidth);
710
deleteFrame->setFrameWidth(frameWidth);
711
selectorFrame->setFrameWidth(frameWidth);
712
moveFrame->setFrameWidth(frameWidth);
713
}
714
715
716
bool
717
GNEViewParent::CommonFrames::isCommonFrameShown() const {
718
// check all frames
719
if (inspectorFrame->shown()) {
720
return true;
721
} else if (deleteFrame->shown()) {
722
return true;
723
} else if (selectorFrame->shown()) {
724
return true;
725
} else if (moveFrame->shown()) {
726
return true;
727
} else {
728
return false;
729
}
730
}
731
732
733
GNEFrame*
734
GNEViewParent::CommonFrames::getCurrentShownFrame() const {
735
// check all frames
736
if (inspectorFrame->shown()) {
737
return inspectorFrame;
738
} else if (deleteFrame->shown()) {
739
return deleteFrame;
740
} else if (selectorFrame->shown()) {
741
return selectorFrame;
742
} else if (moveFrame->shown()) {
743
return moveFrame;
744
} else {
745
return nullptr;
746
}
747
}
748
749
// ---------------------------------------------------------------------------
750
// GNEViewParent::NetworkFrames - methods
751
// ---------------------------------------------------------------------------
752
753
GNEViewParent::NetworkFrames::NetworkFrames() {}
754
755
756
void
757
GNEViewParent::NetworkFrames::buildNetworkFrames(GNEViewParent* viewParent, GNEViewNet* viewNet) {
758
connectorFrame = new GNEConnectorFrame(viewParent, viewNet);
759
TLSEditorFrame = new GNETLSEditorFrame(viewParent, viewNet);
760
additionalFrame = new GNEAdditionalFrame(viewParent, viewNet);
761
crossingFrame = new GNECrossingFrame(viewParent, viewNet);
762
TAZFrame = new GNETAZFrame(viewParent, viewNet);
763
polygonFrame = new GNEShapeFrame(viewParent, viewNet);
764
prohibitionFrame = new GNEProhibitionFrame(viewParent, viewNet);
765
wireFrame = new GNEWireFrame(viewParent, viewNet);
766
decalFrame = new GNEDecalFrame(viewParent, viewNet);
767
createEdgeFrame = new GNECreateEdgeFrame(viewParent, viewNet);
768
}
769
770
771
void
772
GNEViewParent::NetworkFrames::hideNetworkFrames() {
773
connectorFrame->hide();
774
TLSEditorFrame->hide();
775
additionalFrame->hide();
776
crossingFrame->hide();
777
TAZFrame->hide();
778
polygonFrame->hide();
779
prohibitionFrame->hide();
780
wireFrame->hide();
781
decalFrame->hide();
782
createEdgeFrame->hide();
783
}
784
785
786
void
787
GNEViewParent::NetworkFrames::setNetworkFramesWidth(int frameWidth) {
788
// set width in all frames
789
connectorFrame->setFrameWidth(frameWidth);
790
TLSEditorFrame->setFrameWidth(frameWidth);
791
additionalFrame->setFrameWidth(frameWidth);
792
crossingFrame->setFrameWidth(frameWidth);
793
TAZFrame->setFrameWidth(frameWidth);
794
polygonFrame->setFrameWidth(frameWidth);
795
prohibitionFrame->setFrameWidth(frameWidth);
796
wireFrame->setFrameWidth(frameWidth);
797
decalFrame->setFrameWidth(frameWidth);
798
createEdgeFrame->setFrameWidth(frameWidth);
799
}
800
801
802
bool
803
GNEViewParent::NetworkFrames::isNetworkFrameShown() const {
804
// check all frames
805
if (connectorFrame->shown()) {
806
return true;
807
} else if (TLSEditorFrame->shown()) {
808
return true;
809
} else if (additionalFrame->shown()) {
810
return true;
811
} else if (crossingFrame->shown()) {
812
return true;
813
} else if (TAZFrame->shown()) {
814
return true;
815
} else if (polygonFrame->shown()) {
816
return true;
817
} else if (prohibitionFrame->shown()) {
818
return true;
819
} else if (wireFrame->shown()) {
820
return true;
821
} else if (decalFrame->shown()) {
822
return true;
823
} else if (createEdgeFrame->shown()) {
824
return true;
825
} else {
826
return false;
827
}
828
}
829
830
831
GNEFrame*
832
GNEViewParent::NetworkFrames::getCurrentShownFrame() const {
833
// check all frames
834
if (connectorFrame->shown()) {
835
return connectorFrame;
836
} else if (TLSEditorFrame->shown()) {
837
return TLSEditorFrame;
838
} else if (additionalFrame->shown()) {
839
return additionalFrame;
840
} else if (crossingFrame->shown()) {
841
return crossingFrame;
842
} else if (TAZFrame->shown()) {
843
return TAZFrame;
844
} else if (polygonFrame->shown()) {
845
return polygonFrame;
846
} else if (prohibitionFrame->shown()) {
847
return prohibitionFrame;
848
} else if (wireFrame->shown()) {
849
return wireFrame;
850
} else if (decalFrame->shown()) {
851
return decalFrame;
852
} else if (createEdgeFrame->shown()) {
853
return createEdgeFrame;
854
} else {
855
return nullptr;
856
}
857
}
858
859
// ---------------------------------------------------------------------------
860
// GNEViewParent::DemandFrames - methods
861
// ---------------------------------------------------------------------------
862
863
GNEViewParent::DemandFrames::DemandFrames() {
864
}
865
866
867
void
868
GNEViewParent::DemandFrames::buildDemandFrames(GNEViewParent* viewParent, GNEViewNet* viewNet) {
869
routeFrame = new GNERouteFrame(viewParent, viewNet);
870
routeDistributionFrame = new GNERouteDistributionFrame(viewParent, viewNet);
871
vehicleFrame = new GNEVehicleFrame(viewParent, viewNet);
872
typeFrame = new GNETypeFrame(viewParent, viewNet);
873
typeDistributionFrame = new GNETypeDistributionFrame(viewParent, viewNet);
874
stopFrame = new GNEStopFrame(viewParent, viewNet);
875
personFrame = new GNEPersonFrame(viewParent, viewNet);
876
personPlanFrame = new GNEPersonPlanFrame(viewParent, viewNet);
877
containerFrame = new GNEContainerFrame(viewParent, viewNet);
878
containerPlanFrame = new GNEContainerPlanFrame(viewParent, viewNet);
879
}
880
881
882
void
883
GNEViewParent::DemandFrames::hideDemandFrames() {
884
routeFrame->hide();
885
routeDistributionFrame->hide();
886
vehicleFrame->hide();
887
typeFrame->hide();
888
typeDistributionFrame->hide();
889
stopFrame->hide();
890
personFrame->hide();
891
personPlanFrame->hide();
892
containerFrame->hide();
893
containerPlanFrame->hide();
894
}
895
896
897
void
898
GNEViewParent::DemandFrames::setDemandFramesWidth(int frameWidth) {
899
// set width in all frames
900
routeFrame->setFrameWidth(frameWidth);
901
routeDistributionFrame->setFrameWidth(frameWidth);
902
vehicleFrame->setFrameWidth(frameWidth);
903
typeFrame->setFrameWidth(frameWidth);
904
typeDistributionFrame->setFrameWidth(frameWidth);
905
stopFrame->setFrameWidth(frameWidth);
906
personFrame->setFrameWidth(frameWidth);
907
personPlanFrame->setFrameWidth(frameWidth);
908
containerFrame->setFrameWidth(frameWidth);
909
containerPlanFrame->setFrameWidth(frameWidth);
910
}
911
912
913
bool
914
GNEViewParent::DemandFrames::isDemandFrameShown() const {
915
// check all frames
916
if (routeFrame->shown()) {
917
return true;
918
} else if (routeDistributionFrame->shown()) {
919
return true;
920
} else if (vehicleFrame->shown()) {
921
return true;
922
} else if (typeFrame->shown()) {
923
return true;
924
} else if (typeDistributionFrame->shown()) {
925
return true;
926
} else if (stopFrame->shown()) {
927
return true;
928
} else if (personFrame->shown()) {
929
return true;
930
} else if (personPlanFrame->shown()) {
931
return true;
932
} else if (containerFrame->shown()) {
933
return true;
934
} else if (containerPlanFrame->shown()) {
935
return true;
936
} else {
937
return false;
938
}
939
}
940
941
942
GNEFrame*
943
GNEViewParent::DemandFrames::getCurrentShownFrame() const {
944
// check all frames
945
if (routeFrame->shown()) {
946
return routeFrame;
947
} else if (routeDistributionFrame->shown()) {
948
return routeDistributionFrame;
949
} else if (vehicleFrame->shown()) {
950
return vehicleFrame;
951
} else if (typeFrame->shown()) {
952
return typeFrame;
953
} else if (typeDistributionFrame->shown()) {
954
return typeDistributionFrame;
955
} else if (stopFrame->shown()) {
956
return stopFrame;
957
} else if (personFrame->shown()) {
958
return personFrame;
959
} else if (personPlanFrame->shown()) {
960
return personPlanFrame;
961
} else if (containerFrame->shown()) {
962
return containerFrame;
963
} else if (containerPlanFrame->shown()) {
964
return containerPlanFrame;
965
} else {
966
return nullptr;
967
}
968
}
969
970
// ---------------------------------------------------------------------------
971
// GNEViewParent::DataFrames - methods
972
// ---------------------------------------------------------------------------
973
974
GNEViewParent::DataFrames::DataFrames() {
975
}
976
977
978
void
979
GNEViewParent::DataFrames::buildDataFrames(GNEViewParent* viewParent, GNEViewNet* viewNet) {
980
edgeDataFrame = new GNEEdgeDataFrame(viewParent, viewNet);
981
edgeRelDataFrame = new GNEEdgeRelDataFrame(viewParent, viewNet);
982
TAZRelDataFrame = new GNETAZRelDataFrame(viewParent, viewNet);
983
meanDataFrame = new GNEMeanDataFrame(viewParent, viewNet);
984
}
985
986
987
void
988
GNEViewParent::DataFrames::hideDataFrames() {
989
edgeDataFrame->hide();
990
edgeRelDataFrame->hide();
991
TAZRelDataFrame->hide();
992
meanDataFrame->hide();
993
}
994
995
996
void
997
GNEViewParent::DataFrames::setDataFramesWidth(int frameWidth) {
998
// set width in all frames
999
edgeDataFrame->setFrameWidth(frameWidth);
1000
edgeRelDataFrame->setFrameWidth(frameWidth);
1001
TAZRelDataFrame->setFrameWidth(frameWidth);
1002
meanDataFrame->setFrameWidth(frameWidth);
1003
}
1004
1005
1006
bool
1007
GNEViewParent::DataFrames::isDataFrameShown() const {
1008
// check all frames
1009
if (edgeDataFrame->shown()) {
1010
return true;
1011
} else if (edgeRelDataFrame->shown()) {
1012
return true;
1013
} else if (TAZRelDataFrame->shown()) {
1014
return true;
1015
} else if (meanDataFrame->shown()) {
1016
return true;
1017
} else {
1018
return false;
1019
}
1020
}
1021
1022
1023
GNEFrame*
1024
GNEViewParent::DataFrames::getCurrentShownFrame() const {
1025
// check all frames
1026
if (edgeDataFrame->shown()) {
1027
return edgeDataFrame;
1028
} else if (edgeRelDataFrame->shown()) {
1029
return edgeRelDataFrame;
1030
} else if (TAZRelDataFrame->shown()) {
1031
return TAZRelDataFrame;
1032
} else if (meanDataFrame->shown()) {
1033
return meanDataFrame;
1034
} else {
1035
return nullptr;
1036
}
1037
}
1038
1039
// ---------------------------------------------------------------------------
1040
// GNEViewParent::ACChoosers - methods
1041
// ---------------------------------------------------------------------------
1042
1043
GNEViewParent::ACChoosers::ACChoosers() {
1044
}
1045
1046
1047
GNEViewParent::ACChoosers::~ACChoosers() {
1048
// remove all dialogs if are active
1049
if (ACChooserJunction) {
1050
delete ACChooserJunction;
1051
}
1052
if (ACChooserEdges) {
1053
delete ACChooserEdges;
1054
}
1055
if (ACChooserWalkingAreas) {
1056
delete ACChooserWalkingAreas;
1057
}
1058
if (ACChooserRoutes) {
1059
delete ACChooserRoutes;
1060
}
1061
if (ACChooserStops) {
1062
delete ACChooserStops;
1063
}
1064
if (ACChooserVehicles) {
1065
delete ACChooserVehicles;
1066
}
1067
if (ACChooserPersons) {
1068
delete ACChooserPersons;
1069
}
1070
if (ACChooserContainers) {
1071
delete ACChooserContainers;
1072
}
1073
if (ACChooserTLS) {
1074
delete ACChooserTLS;
1075
}
1076
if (ACChooserAdditional) {
1077
delete ACChooserAdditional;
1078
}
1079
if (ACChooserPOI) {
1080
delete ACChooserPOI;
1081
}
1082
if (ACChooserPolygon) {
1083
delete ACChooserPolygon;
1084
}
1085
if (ACChooserProhibition) {
1086
delete ACChooserProhibition;
1087
}
1088
if (ACChooserWire) {
1089
delete ACChooserWire;
1090
}
1091
}
1092
1093
1094
/****************************************************************************/
1095
1096