SUMO - Simulation of Urban MObility
GNEDialog_Wizard.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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // The "About" - dialog for NETEDIT, (adapted from GUIDialog_AboutSUMO)
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
34 #include <utils/common/ToString.h>
36 #include "GNEDialog_Wizard.h"
37 
38 
39 // ===========================================================================
40 // FOX callback mapping
41 // ===========================================================================
42 FXDEFMAP(GNEDialog_Wizard::InputString) InputStringMap[] = {
44 };
45 FXDEFMAP(GNEDialog_Wizard::InputBool) InputBoolMap[] = {
47 };
48 FXDEFMAP(GNEDialog_Wizard::InputInt) InputIntMap[] = {
50 };
51 FXDEFMAP(GNEDialog_Wizard::InputFloat) InputFloatMap[] = {
53 };
54 
55 // Object implementation
56 FXIMPLEMENT(GNEDialog_Wizard::InputString, FXHorizontalFrame, InputStringMap, ARRAYNUMBER(InputStringMap))
57 FXIMPLEMENT(GNEDialog_Wizard::InputBool, FXHorizontalFrame, InputBoolMap, ARRAYNUMBER(InputBoolMap))
58 FXIMPLEMENT(GNEDialog_Wizard::InputInt, FXHorizontalFrame, InputIntMap, ARRAYNUMBER(InputIntMap))
59 FXIMPLEMENT(GNEDialog_Wizard::InputFloat, FXHorizontalFrame, InputFloatMap, ARRAYNUMBER(InputFloatMap))
60 
61 // ===========================================================================
62 // method definitions
63 // ===========================================================================
64 GNEDialog_Wizard::GNEDialog_Wizard(FXWindow* parent, const char* titleName, int width, int height) :
65  FXDialogBox(parent, titleName, GUIDesignDialogBox, 0, 0, width, height) {
67  FXVerticalFrame* contentFrame = new FXVerticalFrame(this, GUIDesignContentsFrame);
68 
69  FXTabBook* tabbook = new FXTabBook(contentFrame, 0, 0, GUIDesignTabBook);
70 
71  for (auto it_topic : oc.getSubTopics()) {
72  if (it_topic == "Configuration") {
73  continue;
74  }
75  new FXTabItem(tabbook, it_topic.c_str(), NULL, TAB_LEFT_NORMAL);
76  FXScrollWindow* scrollTab = new FXScrollWindow(tabbook, LAYOUT_FILL_X | LAYOUT_FILL_Y);
77  FXVerticalFrame* tabContent = new FXVerticalFrame(scrollTab, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y);
78  const std::vector<std::string> entries = oc.getSubTopicsEntries(it_topic);
79  for (auto it_opt : entries) {
80  if (it_opt != "geometry.remove" && it_opt != "edges.join" && it_opt != "geometry.split" && it_opt != "ramps.guess" && it_opt != "ramps.set") {
81  std::string type = oc.getTypeName(it_opt);
82  if (type == "STR" || type == "FILE") {
83  new InputString(tabContent, it_opt);
84  } else if (type == "BOOL") {
85  new InputBool(tabContent, it_opt);
86  } else if (type == "INT") {
87  new InputInt(tabContent, it_opt);
88  } else if (type == "FLOAT") {
89  new InputFloat(tabContent, it_opt);
90  }
91  // @todo missing types (type INT[] is only used in microsim)
92  }
93  }
94  }
95 
96  // ok-button
97  new FXButton(contentFrame, "OK\t\tContine with the import.", GUIIconSubSys::getIcon(ICON_ACCEPT), this, ID_ACCEPT, GUIDesignButtonOK);
98 }
99 
100 
102 
103 // ===========================================================================
104 // Option input classes method definitions
105 // ===========================================================================
106 GNEDialog_Wizard::InputString::InputString(FXComposite* parent, const std::string& name) :
107  FXHorizontalFrame(parent, LAYOUT_FILL_X),
108  myName(name) {
110  new FXLabel(this, name.c_str());
111  myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_NORMAL | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2);
112  myTextField->setText(oc.getString(name).c_str());
113 }
114 
115 
116 long
117 GNEDialog_Wizard::InputString::onCmdSetOption(FXObject*, FXSelector, void*) {
119  oc.resetWritable();
120  oc.set(myName, myTextField->getText().text());
121  return 1;
122 }
123 
124 
125 GNEDialog_Wizard::InputBool::InputBool(FXComposite* parent, const std::string& name) :
126  FXHorizontalFrame(parent, LAYOUT_FILL_X),
127  myName(name) {
129  new FXLabel(this, name.c_str());
130  myCheck = new FXMenuCheck(this, "", this, MID_GNE_SET_ATTRIBUTE);
131  myCheck->setCheck(oc.getBool(name));
132 }
133 
134 
135 long
136 GNEDialog_Wizard::InputBool::onCmdSetOption(FXObject*, FXSelector, void*) {
138  oc.resetWritable();
139  oc.set(myName, myCheck->getCheck() ? "true" : "false");
140  return 1;
141 }
142 
143 
144 GNEDialog_Wizard::InputInt::InputInt(FXComposite* parent, const std::string& name) :
145  FXHorizontalFrame(parent, LAYOUT_FILL_X),
146  myName(name) {
148  new FXLabel(this, name.c_str());
149  myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_INTEGER | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2);
150  myTextField->setText(toString(oc.getInt(name)).c_str());
151 }
152 
153 
154 long
155 GNEDialog_Wizard::InputInt::onCmdSetOption(FXObject*, FXSelector, void*) {
157  oc.resetWritable();
158  oc.set(myName, myTextField->getText().text());
159  return 1;
160 }
161 
162 
163 GNEDialog_Wizard::InputFloat::InputFloat(FXComposite* parent, const std::string& name) :
164  FXHorizontalFrame(parent, LAYOUT_FILL_X),
165  myName(name) {
167  new FXLabel(this, name.c_str());
168  myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_REAL | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2);
169  myTextField->setText(toString(oc.getFloat(name)).c_str());
170 }
171 
172 
173 long
174 GNEDialog_Wizard::InputFloat::onCmdSetOption(FXObject*, FXSelector, void*) {
176  oc.resetWritable();
177  oc.set(myName, myTextField->getText().text());
178  return 1;
179 }
180 
181 
182 /****************************************************************************/
FXDEFMAP(GNEDialog_Wizard::InputString) InputStringMap[]
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
void resetWritable()
Resets all options to be writeable.
FXMenuCheck * myCheck
menu check
attribute edited
Definition: GUIAppEnum.h:526
const std::vector< std::string > & getSubTopics() const
return the list of subtopics
Definition: OptionsCont.h:636
#define GUIDesignContentsFrame
design for the main content frame of every frame/dialog
Definition: GUIDesigns.h:255
~GNEDialog_Wizard()
Destructor.
long onCmdSetOption(FXObject *, FXSelector, void *)
try to set new attribute value
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
std::string getTypeName(const std::string name)
return the type name for the given option
Definition: OptionsCont.h:652
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
#define GUIDesignTabBook
desgin for TabBooks
Definition: GUIDesigns.h:427
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
FXTextField * myTextField
text field
long onCmdSetOption(FXObject *, FXSelector, void *)
try to set new attribute value
FXTextField * myTextField
text field
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
#define GUIDesignDialogBox
Definition: GUIDesigns.h:395
std::vector< std::string > getSubTopicsEntries(const std::string &subtopic) const
return the list of entries for the given subtopic
Definition: OptionsCont.h:642
A storage for options typed value containers)
Definition: OptionsCont.h:98
long onCmdSetOption(FXObject *, FXSelector, void *)
try to set new attribute value
#define GUIDesignButtonOK
Definition: GUIDesigns.h:97
FXTextField * myTextField
text field
long onCmdSetOption(FXObject *, FXSelector, void *)
try to set new attribute value
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon