Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEAdditionalDialog.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>
25#include <netedit/GNEUndoList.h>
26
27#include "GNEAdditionalDialog.h"
28
29// ===========================================================================
30// FOX callback mapping
31// ===========================================================================
32
33FXDEFMAP(GNEAdditionalDialog) GNEAdditionalDialogMap[] = {
34 FXMAPFUNC(SEL_KEYPRESS, 0, GNEAdditionalDialog::onKeyPress),
35 FXMAPFUNC(SEL_KEYRELEASE, 0, GNEAdditionalDialog::onKeyRelease),
36 FXMAPFUNC(SEL_CLOSE, 0, GNEAdditionalDialog::onCmdCancel),
40};
41
42// Object abstract implementation
43FXIMPLEMENT_ABSTRACT(GNEAdditionalDialog, FXTopWindow, GNEAdditionalDialogMap, ARRAYNUMBER(GNEAdditionalDialogMap))
44
45// ===========================================================================
46// member method definitions
47// ===========================================================================
48
49GNEAdditionalDialog::GNEAdditionalDialog(GNEAdditional* editedAdditional, bool updatingElement, int width, int height) :
50 FXTopWindow(editedAdditional->getNet()->getViewNet(), ("Edit '" + editedAdditional->getID() + "' data").c_str(), editedAdditional->getACIcon(), editedAdditional->getACIcon(), GUIDesignDialogBoxExplicit(width, height)),
51 myEditedAdditional(editedAdditional),
52 myUpdatingElement(updatingElement),
53 myChangesDescription("change " + editedAdditional->getTagStr() + " values"),
54 myNumberOfChanges(0) {
55 // create main frame
56 FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
57 // Create frame for contents
58 myContentFrame = new FXVerticalFrame(mainFrame, GUIDesignContentsFrame);
59 // create buttons centered
60 FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
61 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
62 myAcceptButton = GUIDesigns::buildFXButton(buttonsFrame, TL("Accept"), "", TL("Close accepting changes"), GUIIconSubSys::getIcon(GUIIcon::ACCEPT), this, MID_GNE_BUTTON_ACCEPT, GUIDesignButtonAccept);
63 myCancelButton = GUIDesigns::buildFXButton(buttonsFrame, TL("Cancel"), "", TL("Close discarding changes"), GUIIconSubSys::getIcon(GUIIcon::CANCEL), this, MID_GNE_BUTTON_CANCEL, GUIDesignButtonCancel);
64 myResetButton = GUIDesigns::buildFXButton(buttonsFrame, TL("Reset"), "", TL("Reset to previous values"), GUIIconSubSys::getIcon(GUIIcon::RESET), this, MID_GNE_BUTTON_RESET, GUIDesignButtonReset);
65 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
66}
67
68
70 // return focus to GNEViewNet to avoid minimization
71 getParent()->setFocus();
72}
73
74
75FXint
77 // create Dialog
78 create();
79 // show in the given position
80 show(placement);
81 // refresh APP
82 getApp()->refresh();
83 // open as modal dialog (will block all windows until stop() or stopModal() is called)
84 return getApp()->runModalFor(this);
85}
86
87
92
93
94long
95GNEAdditionalDialog::onKeyPress(FXObject* sender, FXSelector sel, void* ptr) {
96 return FXTopWindow::onKeyPress(sender, sel, ptr);
97}
98
99
100long
101GNEAdditionalDialog::onKeyRelease(FXObject* sender, FXSelector sel, void* ptr) {
102 return FXTopWindow::onKeyRelease(sender, sel, ptr);
103}
104
105
106void
108 // change FXDialogBox title
109 setTitle(newHeader.c_str());
110}
111
112
113void
120
121
122void
124 // commit changes or abort last command group depending of number of changes did
125 if (myNumberOfChanges < myEditedAdditional->getNet()->getViewNet()->getUndoList()->currentCommandGroupSize()) {
127 } else {
129 }
130}
131
132
133void
137
138
139void
145
146
147/****************************************************************************/
FXDEFMAP(GNEAdditionalDialog) GNEAdditionalDialogMap[]
@ MID_GNE_BUTTON_CANCEL
cancel button
@ MID_GNE_BUTTON_RESET
reset 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:617
#define GUIDesignButtonAccept
Accept Button.
Definition GUIDesigns.h:162
#define GUIDesignButtonCancel
Cancel Button.
Definition GUIDesigns.h:168
#define GUIDesignContentsFrame
design for the main content frame of every frame/dialog with padding and spacing
Definition GUIDesigns.h:393
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:405
#define GUIDesignButtonReset
Reset Button.
Definition GUIDesigns.h:171
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frame extended in all directions
Definition GUIDesigns.h:396
#define GUIDesignHorizontalFrame
Horizontal frame extended over frame parent with padding and spacing.
Definition GUIDesigns.h:334
#define TL(string)
Definition MsgHandler.h:315
Dialog to edit sequences, parameters, etc.. of Additionals.
virtual long onCmdCancel(FXObject *sender, FXSelector sel, void *ptr)=0
event after press cancel button
virtual long onCmdAccept(FXObject *sender, FXSelector sel, void *ptr)=0
void changeAdditionalDialogHeader(const std::string &newHeader)
change additional dialog header
int myNumberOfChanges
number of GNEChanges_... in dialog
GNEAdditional * getEditedAdditional() const
get edited Additional
void acceptChanges()
Accept changes did in this dialog.
std::string myChangesDescription
description of changes did in this additional dialog
long onKeyPress(FXObject *sender, FXSelector sel, void *ptr)
event after press a key
void cancelChanges()
Cancel changes did in this dialog.
FXint openAsModalDialog(FXuint placement=PLACEMENT_CURSOR)
execute dialog as modal
GNEAdditional * myEditedAdditional
pointer to edited additional
void initChanges()
init a new group of changes that will be do it in dialog
void resetChanges()
reset changes did in this dialog.
virtual long onCmdReset(FXObject *, FXSelector, void *)=0
event after press cancel button
long onKeyRelease(FXObject *sender, FXSelector sel, void *ptr)
event after release a key
An Element which don't belong to GNENet but has influence in the simulation.
GNENet * getNet() const
get pointer to net
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2147
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
GNEUndoList * getUndoList() const
get the undoList object
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