Eclipse SUMO - Simulation of Urban MObility
GNEDemandElementDialog.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // A abstract class for editing additional elements
15 /****************************************************************************/
16 
17 // ===========================================================================
18 // included modules
19 // ===========================================================================
20 #include <config.h>
21 
25 #include <netedit/GNEViewNet.h>
26 #include <netedit/GNEUndoList.h>
27 
28 #include "GNEDemandElementDialog.h"
29 
30 // ===========================================================================
31 // FOX callback mapping
32 // ===========================================================================
33 
34 FXDEFMAP(GNEDemandElementDialog) GNEDemandElementDialogMap[] = {
35  FXMAPFUNC(SEL_KEYPRESS, 0, GNEDemandElementDialog::onKeyPress),
36  FXMAPFUNC(SEL_KEYRELEASE, 0, GNEDemandElementDialog::onKeyRelease),
37  FXMAPFUNC(SEL_CLOSE, 0, GNEDemandElementDialog::onCmdCancel),
41 };
42 
43 // Object abstract implementation
44 FXIMPLEMENT_ABSTRACT(GNEDemandElementDialog, FXTopWindow, GNEDemandElementDialogMap, ARRAYNUMBER(GNEDemandElementDialogMap))
45 
46 // ===========================================================================
47 // member method definitions
48 // ===========================================================================
49 
50 GNEDemandElementDialog::GNEDemandElementDialog(GNEDemandElement* editedDemandElement, bool updatingElement, int width, int height) :
51  FXTopWindow(editedDemandElement->getViewNet(), ("Edit '" + editedDemandElement->getID() + "' data").c_str(), editedDemandElement->getIcon(), editedDemandElement->getIcon(), GUIDesignDialogBoxExplicit(width, height)),
52  myEditedDemandElement(editedDemandElement),
53  myUpdatingElement(updatingElement),
54  myChangesDescription("change " + editedDemandElement->getTagStr() + " values"),
55  myNumberOfChanges(0) {
56  // create main frame
57  FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
58  // Create frame for contents
59  myContentFrame = new FXVerticalFrame(mainFrame, GUIDesignContentsFrame);
60  // create buttons centered
61  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
62  new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
63  myAcceptButton = new FXButton(buttonsFrame, "accept\t\tclose accepting changes", GUIIconSubSys::getIcon(ICON_ACCEPT), this, MID_GNE_ADDITIONALDIALOG_BUTTONACCEPT, GUIDesignButtonAccept);
64  myCancelButton = new FXButton(buttonsFrame, "cancel\t\tclose discarding changes", GUIIconSubSys::getIcon(ICON_CANCEL), this, MID_GNE_ADDITIONALDIALOG_BUTTONCANCEL, GUIDesignButtonCancel);
65  myResetButton = new FXButton(buttonsFrame, "reset\t\treset to previous values", GUIIconSubSys::getIcon(ICON_RESET), this, MID_GNE_ADDITIONALDIALOG_BUTTONRESET, GUIDesignButtonReset);
66  new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
67 }
68 
69 
71  // return focus to GNEViewNet to avoid minimization
72  getParent()->setFocus();
73 }
74 
75 
76 FXint
78  // create Dialog
79  create();
80  // show in the given position
81  show(placement);
82  // refresh APP
83  getApp()->refresh();
84  // open as modal dialog (will block all windows until stop() or stopModal() is called)
85  return getApp()->runModalFor(this);
86 }
87 
88 
91  return myEditedDemandElement;
92 }
93 
94 
95 long
96 GNEDemandElementDialog::onKeyPress(FXObject* sender, FXSelector sel, void* ptr) {
97  return FXTopWindow::onKeyPress(sender, sel, ptr);
98 }
99 
100 
101 long
102 GNEDemandElementDialog::onKeyRelease(FXObject* sender, FXSelector sel, void* ptr) {
103  return FXTopWindow::onKeyRelease(sender, sel, ptr);
104 }
105 
106 
107 void
109  // change FXDialogBox title
110  setTitle(newHeader.c_str());
111 }
112 
113 
114 void
116  // init commandGroup
118  // save number of command group changes
120 }
121 
122 
123 void
125  // commit changes or abort last command group depending of number of changes did
126  if (myNumberOfChanges < myEditedDemandElement->getViewNet()->getUndoList()->currentCommandGroupSize()) {
128  } else {
130  }
131 }
132 
133 
134 void
137 }
138 
139 
140 void
142  // abort last command group an start editing again
145 }
146 
147 /****************************************************************************/
GNEDemandElementDialog::getEditedDemandElement
GNEDemandElement * getEditedDemandElement() const
get edited DemandElement
Definition: GNEDemandElementDialog.cpp:90
GUIDesignAuxiliarHorizontalFrame
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:273
ICON_ACCEPT
@ ICON_ACCEPT
Definition: GUIIcons.h:386
GNEDemandElementDialog::acceptChanges
void acceptChanges()
Accept changes did in this dialog.
Definition: GNEDemandElementDialog.cpp:124
GNEDemandElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEDemandElement.h:55
GNEUndoList::p_end
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
Definition: GNEUndoList.cpp:79
GNEDemandElement::getViewNet
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which demand element element is located.
Definition: GNEDemandElement.cpp:253
GUIDesigns.h
GUIIconSubSys::getIcon
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
Definition: GUIIconSubSys.cpp:609
GUIDesignDialogBoxExplicit
#define GUIDesignDialogBoxExplicit(width, height)
design for dialog box with specift width and height (for example, additional dialogs)
Definition: GUIDesigns.h:445
GNEDemandElementDialog::cancelChanges
void cancelChanges()
Cancel changes did in this dialog.
Definition: GNEDemandElementDialog.cpp:135
GUIAppEnum.h
GNEDemandElementDialog::onCmdCancel
virtual long onCmdCancel(FXObject *sender, FXSelector sel, void *ptr)=0
event after press cancel button
GUIDesignContentsFrame
#define GUIDesignContentsFrame
design for the main content frame of every frame/dialog
Definition: GUIDesigns.h:282
GNEDemandElementDialog
Dialog to edit sequences, parameters, etc.. of DemandElements.
Definition: GNEDemandElementDialog.h:44
GNEDemandElementDialog::myNumberOfChanges
int myNumberOfChanges
number of GNEChanges_... in dialog
Definition: GNEDemandElementDialog.h:121
MID_GNE_ADDITIONALDIALOG_BUTTONRESET
@ MID_GNE_ADDITIONALDIALOG_BUTTONRESET
reset button
Definition: GUIAppEnum.h:973
GNEDemandElement.h
GUIDesignHorizontalFrame
#define GUIDesignHorizontalFrame
Definition: GUIDesigns.h:224
GNEViewNet.h
MID_GNE_ADDITIONALDIALOG_BUTTONACCEPT
@ MID_GNE_ADDITIONALDIALOG_BUTTONACCEPT
accept button
Definition: GUIAppEnum.h:969
GNEDemandElementDialog::initChanges
void initChanges()
init a new group of changes that will be do it in dialog
Definition: GNEDemandElementDialog.cpp:115
GNEDemandElementDialog::onCmdAccept
virtual long onCmdAccept(FXObject *sender, FXSelector sel, void *ptr)=0
GNEViewNet::getUndoList
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:1020
GUIDesignButtonReset
#define GUIDesignButtonReset
Reset Button.
Definition: GUIDesigns.h:107
ICON_RESET
@ ICON_RESET
Definition: GUIIcons.h:390
GNEUndoList::p_abortLastCommandGroup
void p_abortLastCommandGroup()
reverts last command group
Definition: GNEUndoList.cpp:103
GNEDemandElementDialog::myEditedDemandElement
GNEDemandElement * myEditedDemandElement
pointer to edited aditional
Definition: GNEDemandElementDialog.h:81
GNEDemandElementDialog::onKeyPress
long onKeyPress(FXObject *sender, FXSelector sel, void *ptr)
event after press a key
Definition: GNEDemandElementDialog.cpp:96
GNEDemandElementDialog::myChangesDescription
std::string myChangesDescription
description of changes did in this additional dialog
Definition: GNEDemandElementDialog.h:118
GNEUndoList::currentCommandGroupSize
int currentCommandGroupSize() const
get size of current CommandGroup
Definition: GNEUndoList.cpp:141
GUIDesignButtonAccept
#define GUIDesignButtonAccept
Accept Button.
Definition: GUIDesigns.h:101
MID_GNE_ADDITIONALDIALOG_BUTTONCANCEL
@ MID_GNE_ADDITIONALDIALOG_BUTTONCANCEL
cancel button
Definition: GUIAppEnum.h:971
GNEDemandElementDialog::~GNEDemandElementDialog
~GNEDemandElementDialog()
destructor
Definition: GNEDemandElementDialog.cpp:70
GNEDemandElementDialog::onCmdReset
virtual long onCmdReset(FXObject *, FXSelector, void *)=0
event after press cancel button
ICON_CANCEL
@ ICON_CANCEL
Definition: GUIIcons.h:387
GNEDemandElementDialog::openAsModalDialog
FXint openAsModalDialog(FXuint placement=PLACEMENT_CURSOR)
execute dialog as modal
Definition: GNEDemandElementDialog.cpp:77
GNEDemandElementDialog::resetChanges
void resetChanges()
reset changes did in this dialog.
Definition: GNEDemandElementDialog.cpp:141
GNEDemandElementDialog.h
GUIDesignAuxiliarFrame
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frames used to pack another frames extended in all directions
Definition: GUIDesigns.h:270
GUIDesignButtonCancel
#define GUIDesignButtonCancel
Cancel Button.
Definition: GUIDesigns.h:104
config.h
GNEUndoList::p_begin
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:72
FXDEFMAP
FXDEFMAP(GNEDemandElementDialog) GNEDemandElementDialogMap[]
GNEDemandElementDialog::changeDemandElementDialogHeader
void changeDemandElementDialogHeader(const std::string &newHeader)
change additional dialog header
Definition: GNEDemandElementDialog.cpp:108
GNEUndoList.h
GNEDemandElementDialog::onKeyRelease
long onKeyRelease(FXObject *sender, FXSelector sel, void *ptr)
event after release a key
Definition: GNEDemandElementDialog.cpp:102