Eclipse SUMO - Simulation of Urban MObility
GNEMultipleParametersDialog.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 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 // Dialog for edit multiple parameters
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
27 
28 // ===========================================================================
29 // class definitions
30 // ===========================================================================
31 
33 class GNEViewNet;
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
38 
43 class GNEMultipleParametersDialog : public FXDialogBox {
46 
47 public:
48 
49  // ===========================================================================
50  // class ParametersValues
51  // ===========================================================================
52 
53  class ParametersValues : protected FXGroupBox {
56 
57 
58  class ParameterRow;
59 
60  public:
62  ParametersValues(FXHorizontalFrame* frame);
63 
66 
68  void setParameters(const std::vector<std::pair<std::string, std::string> >& newParameters);
69 
71  void addParameter(std::pair<std::string, std::string> newParameter);
72 
74  void clearParameters();
75 
77  const std::vector<ParameterRow*> getParameterRows() const;
78 
80  bool keyExist(const std::string& key) const;
81 
85  long onPaint(FXObject* o, FXSelector f, void* p);
86 
88  long onCmdSetAttribute(FXObject*, FXSelector, void*);
89 
91  long onCmdButtonPress(FXObject*, FXSelector, void*);
92 
94 
95  protected:
97  FOX_CONSTRUCTOR(ParametersValues)
98 
99  private:
101  class ParameterRow {
102 
103  public:
105  ParameterRow(ParametersValues* ParametersValues, FXVerticalFrame* verticalFrameParent);
106 
108  ~ParameterRow();
109 
111  void disableRow();
112 
114  void enableRow(const std::string& parameter, const std::string& value) const;
115 
117  void toggleAddButton();
118 
120  bool isButtonInAddMode() const;
121 
123  void copyValues(const ParameterRow& other);
124 
126  FXTextField* keyField;
127 
129  FXTextField* valueField;
130 
132  FXButton* button;
133 
136 
137  private:
139  FXHorizontalFrame* horizontalFrame;
140  };
141 
143  FXLabel* myKeyLabel;
144 
146  FXVerticalFrame* myVerticalFrameRow;
147 
149  std::vector<ParameterRow*> myParameterRows;
150  };
151 
152  // ===========================================================================
153  // class ParametersOperations
154  // ===========================================================================
155 
156  class ParametersOperations : protected FXGroupBox {
159 
160  public:
162  ParametersOperations(FXVerticalFrame* frame, GNEMultipleParametersDialog* ParameterDialogParent);
163 
166 
170  long onCmdLoadParameters(FXObject*, FXSelector, void*);
171 
173  long onCmdSaveParameters(FXObject*, FXSelector, void*);
174 
176  long onCmdClearParameters(FXObject*, FXSelector, void*);
177 
179  long onCmdSortParameters(FXObject*, FXSelector, void*);
180 
182  long onCmdHelpParameter(FXObject*, FXSelector, void*);
183 
185 
186  protected:
188  FOX_CONSTRUCTOR(ParametersOperations)
189 
190  private:
194  public:
196  GNEParameterHandler(ParametersOperations* ParametersOperationsParent, const std::string& file);
197 
200 
203 
209  void myStartElement(int element, const SUMOSAXAttributes& attrs);
210 
211  private:
214  };
215 
218 
220  FXButton* mySortButton;
221 
223  FXButton* myClearButton;
224 
226  FXButton* myLoadButton;
227 
229  FXButton* mySaveButton;
230 
232  FXButton* myHelpButton;
233  };
234 
235  // ===========================================================================
236  // class ParametersOptions
237  // ===========================================================================
238 
239  class ParametersOptions : protected FXGroupBox {
240 
241  public:
243  ParametersOptions(FXVerticalFrame* frame);
244 
247 
249  bool onlyForExistentKeys() const;
250 
251  private:
253  FXCheckButton* myOnlyForExistentKeys;
254  };
255 
258 
261 
265  long onCmdAccept(FXObject*, FXSelector, void*);
266 
268  long onCmdCancel(FXObject*, FXSelector, void*);
269 
271  long onCmdReset(FXObject*, FXSelector, void*);
273 
274 protected:
276  FOX_CONSTRUCTOR(GNEMultipleParametersDialog)
277 
278 
280 
283 
286 
289 
291  FXButton* myAcceptButton;
292 
294  FXButton* myCancelButton;
295 
297  FXButton* myResetButton;
298 
299 private:
301  void constructor();
302 
305 
308 };
309 
GNEParameterHandler(ParametersOperations *ParametersOperationsParent, const std::string &file)
Constructor.
ParametersOperations * myParametersOperationsParent
pointer to ParametersOperations parent
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
long onCmdSortParameters(FXObject *, FXSelector, void *)
event when user press sort parameters button
long onCmdHelpParameter(FXObject *, FXSelector, void *)
event when user press help parameters button
long onCmdSaveParameters(FXObject *, FXSelector, void *)
event when user press save parameters button
long onCmdClearParameters(FXObject *, FXSelector, void *)
event when user press clear parameters button
GNEMultipleParametersDialog * myParameterDialogParent
pointer to Shape Frame Parent
ParametersOperations(FXVerticalFrame *frame, GNEMultipleParametersDialog *ParameterDialogParent)
FOX-declaration.
FXCheckButton * myOnlyForExistentKeys
apply changes only for existent keys
bool onlyForExistentKeys() const
apply changes to all elements
void enableRow(const std::string &parameter, const std::string &value) const
enable rlow
void copyValues(const ParameterRow &other)
copy values of other parameter Row
FXHorizontalFrame * horizontalFrame
frame in which elements of ParameterRow are placed
bool isButtonInAddMode() const
check if remove button is in mode "add"
ParameterRow(ParametersValues *ParametersValues, FXVerticalFrame *verticalFrameParent)
constructor
bool keyExist(const std::string &key) const
check if given key exist already
long onPaint(FXObject *o, FXSelector f, void *p)
FXVerticalFrame * myVerticalFrameRow
vertical frame in which rows are placed
void setParameters(const std::vector< std::pair< std::string, std::string > > &newParameters)
set parameters
const std::vector< ParameterRow * > getParameterRows() const
get vector with the ParameterRows
std::vector< ParameterRow * > myParameterRows
vector with the ParameterRows
long onCmdSetAttribute(FXObject *, FXSelector, void *)
event when user change an attribute
void addParameter(std::pair< std::string, std::string > newParameter)
add a single parameter
FXLabel * myKeyLabel
label for key (its neccesary because has to be resized in every onPaint() iteration)
long onCmdButtonPress(FXObject *, FXSelector, void *)
event when user press a remove (or add) button
ParametersValues(FXHorizontalFrame *frame)
constructor
ParametersOperations * myParametersOperations
pointer to parameters operations
long onCmdAccept(FXObject *, FXSelector, void *)
long onCmdCancel(FXObject *, FXSelector, void *)
event after press cancel button
GNEMultipleParametersDialog(GNEInspectorFrame::ParametersEditor *parametersEditorInspector)
Constructor for parameter editor inspector.
GNEInspectorFrame::ParametersEditor * myParametersEditor
FOX need this.
ParametersOptions * myParametersOptions
pointer to parameters options
ParametersValues * myParametersValues
pointer to parameters values
long onCmdReset(FXObject *, FXSelector, void *)
event after press reset button
void constructor()
auxiliar constructor
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.