Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEDemandElementDialog.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// A abstract class for editing additional elements
19/****************************************************************************/
20
23#include <netedit/GNENet.h>
24#include <netedit/GNEViewNet.h>
27#include <netedit/GNEUndoList.h>
28
30
31// ===========================================================================
32// FOX callback mapping
33// ===========================================================================
34
35FXDEFMAP(GNEDemandElementDialog) GNEDemandElementDialogMap[] = {
36 FXMAPFUNC(SEL_KEYPRESS, 0, GNEDemandElementDialog::onKeyPress),
37 FXMAPFUNC(SEL_KEYRELEASE, 0, GNEDemandElementDialog::onKeyRelease),
38 FXMAPFUNC(SEL_CLOSE, 0, GNEDemandElementDialog::onCmdCancel),
43};
44
45// Object abstract implementation
46FXIMPLEMENT_ABSTRACT(GNEDemandElementDialog, FXTopWindow, GNEDemandElementDialogMap, ARRAYNUMBER(GNEDemandElementDialogMap))
47
48// ===========================================================================
49// member method definitions
50// ===========================================================================
51
52GNEDemandElementDialog::GNEDemandElementDialog(GNEDemandElement* editedDemandElement, bool updatingElement, int width, int height) :
53 FXTopWindow(editedDemandElement->getNet()->getViewNet(), ("Edit '" + editedDemandElement->getID() + "' data").c_str(), editedDemandElement->getACIcon(), editedDemandElement->getACIcon(), GUIDesignDialogBoxExplicit(width, height)),
54 myEditedDemandElement(editedDemandElement),
55 myUpdatingElement(updatingElement),
56 myChangesDescription("Change " + editedDemandElement->getTagStr() + " values"),
57 myNumberOfChanges(0) {
58 // create main frame
59 FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
60 // Create frame for contents
61 myContentFrame = new FXVerticalFrame(mainFrame, GUIDesignContentsFrame);
62 // create buttons centered
63 FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
64 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
65 myKeepOldButton = GUIDesigns::buildFXButton(buttonsFrame, TL("&Accept"), "", TL("close accepting changes"), GUIIconSubSys::getIcon(GUIIcon::ACCEPT), this, MID_GNE_BUTTON_ACCEPT, GUIDesignButtonAccept);
66 myCancelButton = GUIDesigns::buildFXButton(buttonsFrame, TL("&Cancel"), "", TL("close discarding changes"), GUIIconSubSys::getIcon(GUIIcon::CANCEL), this, MID_GNE_BUTTON_CANCEL, GUIDesignButtonCancel);
67 myResetButton = GUIDesigns::buildFXButton(buttonsFrame, TL("&Reset"), "", TL("reset to previous values"), GUIIconSubSys::getIcon(GUIIcon::RESET), this, MID_GNE_BUTTON_RESET, GUIDesignButtonReset);
68 myFocusButton = GUIDesigns::buildFXButton(buttonsFrame, "&F", "", "", nullptr, this, MID_GNE_BUTTON_FOCUS, GUIDesignButtonFocus);
69
70 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
71}
72
73
75 // return focus to GNEViewNet to avoid minimization
76 getParent()->setFocus();
77}
78
79
80FXint
82 // create Dialog
83 create();
84 // show in the given position
85 show(placement);
86 // refresh APP
87 getApp()->refresh();
88 // open as modal dialog (will block all windows until stop() or stopModal() is called)
89 return getApp()->runModalFor(this);
90}
91
92
97
98
99long
100GNEDemandElementDialog::onKeyPress(FXObject* sender, FXSelector sel, void* ptr) {
101 return FXTopWindow::onKeyPress(sender, sel, ptr);
102}
103
104
105long
106GNEDemandElementDialog::onKeyRelease(FXObject* sender, FXSelector sel, void* ptr) {
107 return FXTopWindow::onKeyRelease(sender, sel, ptr);
108}
109
110
111long
112GNEDemandElementDialog::onCmdFocusOnFrame(FXObject*, FXSelector, void*) {
113 setFocus();
114 return 1;
115}
116
117
118void
120 // change FXDialogBox title
121 setTitle(newHeader.c_str());
122}
123
124
125void
132
133
134void
136 // commit changes or abort last command group depending of number of changes did
137 if (myNumberOfChanges < myEditedDemandElement->getNet()->getViewNet()->getUndoList()->currentCommandGroupSize()) {
139 } else {
141 }
142 // refresh frame
144}
145
146
147void
151
152
153void
159
160
161/****************************************************************************/
FXDEFMAP(GNEDemandElementDialog) GNEDemandElementDialogMap[]
@ MID_GNE_BUTTON_CANCEL
cancel button
@ MID_GNE_BUTTON_RESET
reset button
@ MID_GNE_BUTTON_FOCUS
focus button
@ MID_GNE_BUTTON_ACCEPT
accept button
#define GUIDesignDialogBoxExplicit(width, height)
design for dialog box with specific width and height (for example, additional dialogs)
Definition GUIDesigns.h:614
#define GUIDesignButtonAccept
Accept Button.
Definition GUIDesigns.h:156
#define GUIDesignButtonCancel
Cancel Button.
Definition GUIDesigns.h:162
#define GUIDesignContentsFrame
design for the main content frame of every frame/dialog with padding and spacing
Definition GUIDesigns.h:387
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:399
#define GUIDesignButtonFocus
Focus Button.
Definition GUIDesigns.h:174
#define GUIDesignButtonReset
Reset Button.
Definition GUIDesigns.h:165
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frame extended in all directions
Definition GUIDesigns.h:390
#define GUIDesignHorizontalFrame
Horizontal frame extended over frame parent with padding and spacing.
Definition GUIDesigns.h:328
#define TL(string)
Definition MsgHandler.h:315
void updateControls()
update control contents after undo/redo or recompute
GNENet * getNet() const
get pointer to net
Dialog to edit sequences, parameters, etc.. of DemandElements.
virtual long onCmdAccept(FXObject *sender, FXSelector sel, void *ptr)=0
void acceptChanges()
Accept changes did in this dialog.
GNEDemandElement * myEditedDemandElement
pointer to edited additional
long onCmdFocusOnFrame(FXObject *sender, FXSelector sel, void *ptr)
focus on frame
FXint openAsModalDialog(FXuint placement=PLACEMENT_CURSOR)
execute dialog as modal
GNEDemandElement * getEditedDemandElement() const
get edited DemandElement
long onKeyRelease(FXObject *sender, FXSelector sel, void *ptr)
event after release a key
void initChanges()
init a new group of changes that will be do it in dialog
virtual long onCmdCancel(FXObject *sender, FXSelector sel, void *ptr)=0
event after press cancel button
void cancelChanges()
Cancel changes did in this dialog.
void changeDemandElementDialogHeader(const std::string &newHeader)
change additional dialog header
virtual long onCmdReset(FXObject *, FXSelector, void *)=0
event after press cancel button
std::string myChangesDescription
description of changes did in this additional dialog
void resetChanges()
reset changes did in this dialog.
int myNumberOfChanges
number of GNEChanges_... in dialog
long onKeyPress(FXObject *sender, FXSelector sel, void *ptr)
event after press a key
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2163
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
int currentCommandGroupSize() const
get size of current CommandGroup
void abortLastChangeGroup()
reverts last active chained change group
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows
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