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-2020 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, GNEMultipleParametersDialog* ParameterDialogParent);
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 toogleAddButton();
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 
153  };
154 
155  // ===========================================================================
156  // class ParametersOperations
157  // ===========================================================================
158 
159  class ParametersOperations : protected FXGroupBox {
162 
163  public:
165  ParametersOperations(FXVerticalFrame* frame, GNEMultipleParametersDialog* ParameterDialogParent);
166 
169 
173  long onCmdLoadParameters(FXObject*, FXSelector, void*);
174 
176  long onCmdSaveParameters(FXObject*, FXSelector, void*);
177 
179  long onCmdClearParameters(FXObject*, FXSelector, void*);
180 
182  long onCmdSortParameters(FXObject*, FXSelector, void*);
183 
185  long onCmdHelpParameter(FXObject*, FXSelector, void*);
186 
188 
189  protected:
191  FOX_CONSTRUCTOR(ParametersOperations)
192 
193  private:
197  public:
199  GNEParameterHandler(ParametersOperations* ParametersOperationsParent, const std::string& file);
200 
203 
206 
212  void myStartElement(int element, const SUMOSAXAttributes& attrs);
213 
214  private:
217  };
218 
221 
223  FXButton* mySortButton;
224 
226  FXButton* myClearButton;
227 
229  FXButton* myLoadButton;
230 
232  FXButton* mySaveButton;
233 
235  FXButton* myHelpButton;
236  };
237 
238  // ===========================================================================
239  // class ParametersOptions
240  // ===========================================================================
241 
242  class ParametersOptions : protected FXGroupBox {
243 
244  public:
246  ParametersOptions(FXVerticalFrame* frame, GNEMultipleParametersDialog* ParameterDialogParent);
247 
250 
252  bool onlyForExistentKeys() const;
253 
254  private:
257 
259  FXCheckButton* myOnlyForExistentKeys;
260  };
261 
264 
267 
271  long onCmdAccept(FXObject*, FXSelector, void*);
272 
274  long onCmdCancel(FXObject*, FXSelector, void*);
275 
277  long onCmdReset(FXObject*, FXSelector, void*);
279 
280 protected:
282  FOX_CONSTRUCTOR(GNEMultipleParametersDialog)
283 
284 
285  GNEInspectorFrame::ParametersEditorInspector* myParametersEditorInspector;
286 
289 
292 
295 
297  FXButton* myAcceptButton;
298 
300  FXButton* myCancelButton;
301 
303  FXButton* myResetButton;
304 
305 private:
307  void constructor();
308 
311 
314 };
315 
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
GNEMultipleParametersDialog * myParameterDialogParent
pointer to Shape Frame Parent
ParametersOptions(FXVerticalFrame *frame, GNEMultipleParametersDialog *ParameterDialogParent)
constructor
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
GNEMultipleParametersDialog * myParameterDialogParent
pointer to ParameterDialog parent
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)
ParametersValues(FXHorizontalFrame *frame, GNEMultipleParametersDialog *ParameterDialogParent)
constructor
long onCmdButtonPress(FXObject *, FXSelector, void *)
event when user press a remove (or add) button
ParametersOperations * myParametersOperations
pointer to parameters operations
long onCmdAccept(FXObject *, FXSelector, void *)
long onCmdCancel(FXObject *, FXSelector, void *)
event after press cancel button
GNEMultipleParametersDialog(GNEInspectorFrame::ParametersEditorInspector *parametersEditorInspector)
Constructor for parameter editor inspector.
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
GNEInspectorFrame::ParametersEditorInspector * myParametersEditorInspector
FOX need this.
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.