Eclipse SUMO - Simulation of Urban MObility
GNEVTypeDistributionsDialog.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-2024 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 VType distributions
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
28 
29 // ===========================================================================
30 // class definitions
31 // ===========================================================================
32 
34 class GNETypeFrame;
35 class GNEViewNet;
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
40 
45 class GNEVTypeDistributionsDialog : public FXDialogBox {
48 
49 public:
50  // ===========================================================================
51  // class ParametersValues
52  // ===========================================================================
53 
54  class ParametersValues : protected FXGroupBox {
57 
58 
59  class ParameterRow;
60 
61  public:
63  ParametersValues(FXHorizontalFrame* frame, const std::string& name);
64 
67 
69  void setParameters(const std::vector<std::pair<std::string, std::string> >& newParameters);
70 
72  void addParameter(std::pair<std::string, std::string> newParameter);
73 
75  void clearParameters();
76 
78  const std::vector<ParameterRow*> getParameterRows() const;
79 
81  bool keyExist(const std::string& key) const;
82 
86  long onPaint(FXObject* o, FXSelector f, void* p);
87 
89  long onCmdSetAttribute(FXObject*, FXSelector, void*);
90 
92  long onCmdButtonPress(FXObject*, FXSelector, void*);
93 
95 
96  protected:
98  FOX_CONSTRUCTOR(ParametersValues)
99 
100  private:
102  class ParameterRow {
103 
104  public:
106  ParameterRow(ParametersValues* ParametersValues, FXVerticalFrame* verticalFrameParent);
107 
109  ~ParameterRow();
110 
112  void disableRow();
113 
115  void enableRow(const std::string& parameter, const std::string& value) const;
116 
118  void toggleAddButton();
119 
121  bool isButtonInAddMode() const;
122 
124  void copyValues(const ParameterRow& other);
125 
127  FXTextField* keyField;
128 
130  FXTextField* valueField;
131 
133  FXButton* button;
134  private:
136  FXHorizontalFrame* horizontalFrame;
137  };
138 
140  FXLabel* myKeyLabel;
141 
143  FXVerticalFrame* myVerticalFrameRow;
144 
146  std::vector<ParameterRow*> myParameterRows;
147  };
148 
149  // ===========================================================================
150  // class ParametersOperations
151  // ===========================================================================
152 
153  class ParametersOperations : protected FXGroupBox {
156 
157  public:
159  ParametersOperations(FXHorizontalFrame* frame, GNEVTypeDistributionsDialog* ParameterDialogParent);
160 
163 
167  long onCmdLoadParameters(FXObject*, FXSelector, void*);
168 
170  long onCmdSaveParameters(FXObject*, FXSelector, void*);
171 
173  long onCmdClearParameters(FXObject*, FXSelector, void*);
174 
176  long onCmdSortParameters(FXObject*, FXSelector, void*);
177 
179  long onCmdHelpParameter(FXObject*, FXSelector, void*);
180 
182 
183  protected:
185  FOX_CONSTRUCTOR(ParametersOperations)
186 
187  private:
191  public:
193  GNEParameterHandler(ParametersOperations* ParametersOperationsParent, const std::string& file);
194 
197 
200 
206  void myStartElement(int element, const SUMOSAXAttributes& attrs);
207 
208  private:
211  };
212 
215 
217  FXButton* mySortButton;
218 
220  FXButton* myClearButton;
221 
223  FXButton* myLoadButton;
224 
226  FXButton* mySaveButton;
227 
229  FXButton* myHelpButton;
230  };
231 
233  GNEVTypeDistributionsDialog(GNETypeFrame* typeFrameParent);
234 
237 
239  void openDialog();
240 
242  void closeDialog();
243 
247  long onCmdAccept(FXObject*, FXSelector, void*);
248 
250  long onCmdCancel(FXObject*, FXSelector, void*);
251 
253 
254 protected:
256  FOX_CONSTRUCTOR(GNEVTypeDistributionsDialog)
257 
258 
260 
263 
266 
268  FXButton* myAcceptButton;
269 
271  FXButton* myCancelButton;
272 
273 private:
276 
279 };
ParametersOperations * myParametersOperationsParent
pointer to ParametersOperations parent
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
GNEParameterHandler(ParametersOperations *ParametersOperationsParent, const std::string &file)
Constructor.
GNEVTypeDistributionsDialog * myParameterDialogParent
pointer to Shape Frame Parent
long onCmdHelpParameter(FXObject *, FXSelector, void *)
event when user press help parameters button
ParametersOperations(FXHorizontalFrame *frame, GNEVTypeDistributionsDialog *ParameterDialogParent)
FOX-declaration.
long onCmdSaveParameters(FXObject *, FXSelector, void *)
event when user press save parameters button
long onCmdClearParameters(FXObject *, FXSelector, void *)
event when user press clear parameters button
long onCmdSortParameters(FXObject *, FXSelector, void *)
event when user press sort parameters button
void enableRow(const std::string &parameter, const std::string &value) const
enable row
bool isButtonInAddMode() const
check if remove button is in mode "add"
void copyValues(const ParameterRow &other)
copy values of other parameter Row
ParameterRow(ParametersValues *ParametersValues, FXVerticalFrame *verticalFrameParent)
constructor
FXHorizontalFrame * horizontalFrame
frame in which elements of ParameterRow are placed
void setParameters(const std::vector< std::pair< std::string, std::string > > &newParameters)
set parameters
long onPaint(FXObject *o, FXSelector f, void *p)
FXLabel * myKeyLabel
label for key (its neccesary because has to be resized in every onPaint() iteration)
ParametersValues(FXHorizontalFrame *frame, const std::string &name)
constructor
long onCmdSetAttribute(FXObject *, FXSelector, void *)
event when user change an attribute
void addParameter(std::pair< std::string, std::string > newParameter)
add a single parameter
long onCmdButtonPress(FXObject *, FXSelector, void *)
event when user press a remove (or add) button
std::vector< ParameterRow * > myParameterRows
vector with the ParameterRows
FXVerticalFrame * myVerticalFrameRow
vertical frame in which rows are placed
bool keyExist(const std::string &key) const
check if given key exist already
const std::vector< ParameterRow * > getParameterRows() const
get vector with the ParameterRows
long onCmdAccept(FXObject *, FXSelector, void *)
GNEVTypeDistributionsDialog(GNETypeFrame *typeFrameParent)
Constructor.
long onCmdCancel(FXObject *, FXSelector, void *)
event after press cancel button
ParametersValues * myParametersValues
pointer to parameters values
ParametersOperations * myParametersOperations
pointer to parameters operations
GNETypeFrame * myTypeFrameParent
FOX need this.
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.