Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNETemplateElementDialog.h
Go to the documentation of this file.
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/****************************************************************************/
18// A template based on GNEDialog used for editing elements
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
25
26// ===========================================================================
27// class definitions
28// ===========================================================================
29
30template <typename T>
32
33public:
36 GNEDialog(element->getNet()->getViewNet()->getViewParent()->getGNEAppWindows(),
37 TLF("Edit % '%'", element->getTagStr(), element->getID()).c_str(),
38 element->getTagProperty()->getGUIIcon(),
40 myElement(element),
41 myChangesDescription(TLF("change % values", element->getTagStr())) {
42 // init commandGroup
43 myElement->getNet()->getViewNet()->getUndoList()->begin(myElement, myChangesDescription);
44 }
45
48
50 T* getElement() const {
51 return myElement;
52 }
53
55 virtual void runInternalTest(const InternalTestStep::DialogArgument* dialogArgument) = 0;
56
60 virtual long onCmdAccept(FXObject* sender, FXSelector sel, void* ptr) = 0;
61
63 virtual long onCmdReset(FXObject*, FXSelector, void*) = 0;
64
66 long onCmdCancel(FXObject*, FXSelector, void*) {
67 myElement->getNet()->getViewNet()->getUndoList()->abortLastChangeGroup();
68 return closeDialogCanceling();
69 }
70
72 long onCmdAbort(FXObject*, FXSelector, void*) {
73 myElement->getNet()->getViewNet()->getUndoList()->abortLastChangeGroup();
74 return closeDialogAborting();
75 }
76
78
79protected:
83
85 T* myElement = nullptr;
86
89 myElement->getNet()->getViewNet()->getUndoList()->end();
90 return closeDialogAccepting();
91 }
92
94 void resetChanges() {
95 // abort last command group an start editing again
96 myElement->getNet()->getViewNet()->getUndoList()->abortLastChangeGroup();
97 myElement->getNet()->getViewNet()->getUndoList()->begin(myElement, myChangesDescription);
98 }
99
100private:
103
106
109};
#define TLF(string,...)
Definition MsgHandler.h:307
long closeDialogAborting()
close dialog aborting the changes
long closeDialogAccepting()
close dialog accepting the changes
OpenType
Open dialog type.
Definition GNEDialog.h:55
long closeDialogCanceling()
close dialog declining the changes
virtual long onCmdAccept(FXObject *sender, FXSelector sel, void *ptr)=0
called when accept or yes button is pressed (can be reimplemented in children)
virtual void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)=0
run internal test
T * myElement
pointer to edited element
long onCmdAbort(FXObject *, FXSelector, void *)
called when abort is called either closing dialog or pressing abort button
T * getElement() const
get edited element
virtual long onCmdReset(FXObject *, FXSelector, void *)=0
event after press cancel button
GNETemplateElementDialog(const GNETemplateElementDialog &)=delete
Invalidated copy constructor.
std::string myChangesDescription
description of changes did in this element dialog
long onCmdCancel(FXObject *, FXSelector, void *)
called when cancel or no button is pressed
GNETemplateElementDialog & operator=(const GNETemplateElementDialog &)=delete
Invalidated assignment operator.
GNETemplateElementDialog(T *element)
constructor
void resetChanges()
reset changes did in this dialog.
long acceptElementDialog()
close dialog commiting changes
GNETemplateElementDialog()
default constructor
dialog arguments, used for certain modal dialogs that can not be edited using tab