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 /****************************************************************************/
15 // A abstract class for editing additional elements
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
26 #include <netedit/GNEViewNet.h>
27 #include <netedit/GNEUndoList.h>
28 
29 #include "GNEDemandElementDialog.h"
30 
31 // ===========================================================================
32 // FOX callback mapping
33 // ===========================================================================
34 
35 FXDEFMAP(GNEDemandElementDialog) GNEDemandElementDialogMap[] = {
36  FXMAPFUNC(SEL_KEYPRESS, 0, GNEDemandElementDialog::onKeyPress),
37  FXMAPFUNC(SEL_KEYRELEASE, 0, GNEDemandElementDialog::onKeyRelease),
38  FXMAPFUNC(SEL_CLOSE, 0, GNEDemandElementDialog::onCmdCancel),
42 };
43 
44 // Object abstract implementation
45 FXIMPLEMENT_ABSTRACT(GNEDemandElementDialog, FXTopWindow, GNEDemandElementDialogMap, ARRAYNUMBER(GNEDemandElementDialogMap))
46 
47 // ===========================================================================
48 // member method definitions
49 // ===========================================================================
50 
51 GNEDemandElementDialog::GNEDemandElementDialog(GNEDemandElement* editedDemandElement, bool updatingElement, int width, int height) :
52  FXTopWindow(editedDemandElement->getViewNet(), ("Edit '" + editedDemandElement->getID() + "' data").c_str(), editedDemandElement->getIcon(), editedDemandElement->getIcon(), GUIDesignDialogBoxExplicit(width, height)),
53  myEditedDemandElement(editedDemandElement),
54  myUpdatingElement(updatingElement),
55  myChangesDescription("change " + editedDemandElement->getTagStr() + " values"),
56  myNumberOfChanges(0) {
57  // create main frame
58  FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
59  // Create frame for contents
60  myContentFrame = new FXVerticalFrame(mainFrame, GUIDesignContentsFrame);
61  // create buttons centered
62  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
63  new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
64  myAcceptButton = new FXButton(buttonsFrame, "accept\t\tclose accepting changes", GUIIconSubSys::getIcon(ICON_ACCEPT), this, MID_GNE_ADDITIONALDIALOG_BUTTONACCEPT, GUIDesignButtonAccept);
65  myCancelButton = new FXButton(buttonsFrame, "cancel\t\tclose discarding changes", GUIIconSubSys::getIcon(ICON_CANCEL), this, MID_GNE_ADDITIONALDIALOG_BUTTONCANCEL, GUIDesignButtonCancel);
66  myResetButton = new FXButton(buttonsFrame, "reset\t\treset to previous values", GUIIconSubSys::getIcon(ICON_RESET), this, MID_GNE_ADDITIONALDIALOG_BUTTONRESET, GUIDesignButtonReset);
67  new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
68 }
69 
70 
72  // return focus to GNEViewNet to avoid minimization
73  getParent()->setFocus();
74 }
75 
76 
77 FXint
79  // create Dialog
80  create();
81  // show in the given position
82  show(placement);
83  // refresh APP
84  getApp()->refresh();
85  // open as modal dialog (will block all windows until stop() or stopModal() is called)
86  return getApp()->runModalFor(this);
87 }
88 
89 
92  return myEditedDemandElement;
93 }
94 
95 
96 long
97 GNEDemandElementDialog::onKeyPress(FXObject* sender, FXSelector sel, void* ptr) {
98  return FXTopWindow::onKeyPress(sender, sel, ptr);
99 }
100 
101 
102 long
103 GNEDemandElementDialog::onKeyRelease(FXObject* sender, FXSelector sel, void* ptr) {
104  return FXTopWindow::onKeyRelease(sender, sel, ptr);
105 }
106 
107 
108 void
110  // change FXDialogBox title
111  setTitle(newHeader.c_str());
112 }
113 
114 
115 void
117  // init commandGroup
119  // save number of command group changes
121 }
122 
123 
124 void
126  // commit changes or abort last command group depending of number of changes did
127  if (myNumberOfChanges < myEditedDemandElement->getViewNet()->getUndoList()->currentCommandGroupSize()) {
129  } else {
131  }
132 }
133 
134 
135 void
138 }
139 
140 
141 void
143  // abort last command group an start editing again
146 }
147 
148 /****************************************************************************/
GNEDemandElementDialog::getEditedDemandElement
GNEDemandElement * getEditedDemandElement() const
get edited DemandElement
Definition: GNEDemandElementDialog.cpp:91
GUIDesignAuxiliarHorizontalFrame
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:289
ICON_ACCEPT
Definition: GUIIcons.h:380
GNEDemandElementDialog::acceptChanges
void acceptChanges()
Accept changes did in this dialog.
Definition: GNEDemandElementDialog.cpp:125
GNEDemandElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEDemandElement.h:54
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:80
GNEDemandElement::getViewNet
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which demand element element is located.
Definition: GNEDemandElement.cpp:408
GUIDesigns.h
GUIIconSubSys::getIcon
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
Definition: GUIIconSubSys.cpp:602
GUIDesignDialogBoxExplicit
#define GUIDesignDialogBoxExplicit(width, height)
design for dialog box with specift width and height (for example, additional dialogs)
Definition: GUIDesigns.h:461
GNEDemandElementDialog::cancelChanges
void cancelChanges()
Cancel changes did in this dialog.
Definition: GNEDemandElementDialog.cpp:136
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:298
GNEDemandElementDialog
Dialog to edit sequences, parameters, etc.. of DemandElements.
Definition: GNEDemandElementDialog.h:45
GNEDemandElementDialog::myNumberOfChanges
int myNumberOfChanges
number of GNEChanges_... in dialog
Definition: GNEDemandElementDialog.h:123
MID_GNE_ADDITIONALDIALOG_BUTTONRESET
reset button
Definition: GUIAppEnum.h:948
GNEDemandElement.h
GUIDesignHorizontalFrame
#define GUIDesignHorizontalFrame
Definition: GUIDesigns.h:240
GNEViewNet.h
MID_GNE_ADDITIONALDIALOG_BUTTONACCEPT
accept button
Definition: GUIAppEnum.h:944
GNEDemandElementDialog::initChanges
void initChanges()
init a new group of changes that will be do it in dialog
Definition: GNEDemandElementDialog.cpp:116
GNEDemandElementDialog::onCmdAccept
virtual long onCmdAccept(FXObject *sender, FXSelector sel, void *ptr)=0
GNEViewNet::getUndoList
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:933
GUIDesignButtonReset
#define GUIDesignButtonReset
Reset Button.
Definition: GUIDesigns.h:123
ICON_RESET
Definition: GUIIcons.h:384
GNEUndoList::p_abortLastCommandGroup
void p_abortLastCommandGroup()
reverts last command group
Definition: GNEUndoList.cpp:104
GNEDemandElementDialog::myEditedDemandElement
GNEDemandElement * myEditedDemandElement
pointer to edited aditional
Definition: GNEDemandElementDialog.h:83
GNEDemandElementDialog::onKeyPress
long onKeyPress(FXObject *sender, FXSelector sel, void *ptr)
event after press a key
Definition: GNEDemandElementDialog.cpp:97
GNEDemandElementDialog::myChangesDescription
std::string myChangesDescription
description of changes did in this additional dialog
Definition: GNEDemandElementDialog.h:120
GNEUndoList::currentCommandGroupSize
int currentCommandGroupSize() const
get size of current CommandGroup
Definition: GNEUndoList.cpp:142
GUIDesignButtonAccept
#define GUIDesignButtonAccept
Accept Button.
Definition: GUIDesigns.h:117
MID_GNE_ADDITIONALDIALOG_BUTTONCANCEL
cancel button
Definition: GUIAppEnum.h:946
GNEDemandElementDialog::~GNEDemandElementDialog
~GNEDemandElementDialog()
destructor
Definition: GNEDemandElementDialog.cpp:71
GNEDemandElementDialog::onCmdReset
virtual long onCmdReset(FXObject *, FXSelector, void *)=0
event after press cancel button
ICON_CANCEL
Definition: GUIIcons.h:381
GNEDemandElementDialog::openAsModalDialog
FXint openAsModalDialog(FXuint placement=PLACEMENT_CURSOR)
execute dialog as modal
Definition: GNEDemandElementDialog.cpp:78
GNEDemandElementDialog::resetChanges
void resetChanges()
reset changes did in this dialog.
Definition: GNEDemandElementDialog.cpp:142
GNEDemandElementDialog.h
GUIDesignAuxiliarFrame
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frames used to pack another frames extended in all directions
Definition: GUIDesigns.h:286
GUIDesignButtonCancel
#define GUIDesignButtonCancel
Cancel Button.
Definition: GUIDesigns.h:120
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:73
FXDEFMAP
FXDEFMAP(GNEDemandElementDialog) GNEDemandElementDialogMap[]
GNEDemandElementDialog::changeDemandElementDialogHeader
void changeDemandElementDialogHeader(const std::string &newHeader)
change additional dialog header
Definition: GNEDemandElementDialog.cpp:109
GNEUndoList.h
GNEDemandElementDialog::onKeyRelease
long onKeyRelease(FXObject *sender, FXSelector sel, void *ptr)
event after release a key
Definition: GNEDemandElementDialog.cpp:103