SUMO - Simulation of Urban MObility
GNEDialog_Wizard.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // The "About" - dialog for NETEDIT, (adapted from GUIDialog_AboutSUMO)
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
35 #include <utils/common/ToString.h>
37 #include "GNEDialog_Wizard.h"
38 
39 
40 // ===========================================================================
41 // FOX callback mapping
42 // ===========================================================================
43 FXDEFMAP(GNEDialog_Wizard::InputString) InputStringMap[] = {
45 };
46 FXDEFMAP(GNEDialog_Wizard::InputBool) InputBoolMap[] = {
48 };
49 FXDEFMAP(GNEDialog_Wizard::InputInt) InputIntMap[] = {
51 };
52 FXDEFMAP(GNEDialog_Wizard::InputFloat) InputFloatMap[] = {
54 };
55 
56 // Object implementation
57 FXIMPLEMENT(GNEDialog_Wizard::InputString, FXHorizontalFrame, InputStringMap, ARRAYNUMBER(InputStringMap))
58 FXIMPLEMENT(GNEDialog_Wizard::InputBool, FXHorizontalFrame, InputBoolMap, ARRAYNUMBER(InputBoolMap))
59 FXIMPLEMENT(GNEDialog_Wizard::InputInt, FXHorizontalFrame, InputIntMap, ARRAYNUMBER(InputIntMap))
60 FXIMPLEMENT(GNEDialog_Wizard::InputFloat, FXHorizontalFrame, InputFloatMap, ARRAYNUMBER(InputFloatMap))
61 
62 // ===========================================================================
63 // method definitions
64 // ===========================================================================
65 GNEDialog_Wizard::GNEDialog_Wizard(FXWindow* parent, const char* titleName, int width, int height) :
66  FXDialogBox(parent, titleName, GUIDesignDialogBox, 0, 0, width, height) {
68  FXVerticalFrame* contentFrame = new FXVerticalFrame(this, GUIDesignContentsFrame);
69 
70  FXTabBook* tabbook = new FXTabBook(contentFrame, 0, 0, GUIDesignTabBook);
71 
72  for (auto it_topic : oc.getSubTopics()) {
73  if (it_topic == "Configuration") {
74  continue;
75  }
76  new FXTabItem(tabbook, it_topic.c_str(), NULL, TAB_LEFT_NORMAL);
77  FXScrollWindow* scrollTab = new FXScrollWindow(tabbook, LAYOUT_FILL_X | LAYOUT_FILL_Y);
78  FXVerticalFrame* tabContent = new FXVerticalFrame(scrollTab, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y);
79  const std::vector<std::string> entries = oc.getSubTopicsEntries(it_topic);
80  for (auto it_opt : entries) {
81  if (it_opt != "geometry.remove" && it_opt != "edges.join" && it_opt != "geometry.split" && it_opt != "ramps.guess" && it_opt != "ramps.set") {
82  std::string type = oc.getTypeName(it_opt);
83  if (type == "STR" || type == "FILE") {
84  new InputString(tabContent, it_opt);
85  } else if (type == "BOOL") {
86  new InputBool(tabContent, it_opt);
87  } else if (type == "INT") {
88  new InputInt(tabContent, it_opt);
89  } else if (type == "FLOAT") {
90  new InputFloat(tabContent, it_opt);
91  }
92  // @todo missing types (type INT[] is only used in microsim)
93  }
94  }
95  }
96 
97  // ok-button
98  new FXButton(contentFrame, "OK\t\tContine with the import.", GUIIconSubSys::getIcon(ICON_ACCEPT), this, ID_ACCEPT, GUIDesignButtonOK);
99 }
100 
101 
103 
104 // ===========================================================================
105 // Option input classes method definitions
106 // ===========================================================================
107 GNEDialog_Wizard::InputString::InputString(FXComposite* parent, const std::string& name) :
108  FXHorizontalFrame(parent, LAYOUT_FILL_X),
109  myName(name) {
111  new FXLabel(this, name.c_str());
112  myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_NORMAL | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2);
113  myTextField->setText(oc.getString(name).c_str());
114 }
115 
116 
117 long
118 GNEDialog_Wizard::InputString::onCmdSetOption(FXObject*, FXSelector, void*) {
120  oc.resetWritable();
121  oc.set(myName, myTextField->getText().text());
122  return 1;
123 }
124 
125 
126 GNEDialog_Wizard::InputBool::InputBool(FXComposite* parent, const std::string& name) :
127  FXHorizontalFrame(parent, LAYOUT_FILL_X),
128  myName(name) {
130  new FXLabel(this, name.c_str());
131  myCheck = new FXMenuCheck(this, "", this, MID_GNE_SET_ATTRIBUTE);
132  myCheck->setCheck(oc.getBool(name));
133 }
134 
135 
136 long
137 GNEDialog_Wizard::InputBool::onCmdSetOption(FXObject*, FXSelector, void*) {
139  oc.resetWritable();
140  oc.set(myName, myCheck->getCheck() ? "true" : "false");
141  return 1;
142 }
143 
144 
145 GNEDialog_Wizard::InputInt::InputInt(FXComposite* parent, const std::string& name) :
146  FXHorizontalFrame(parent, LAYOUT_FILL_X),
147  myName(name) {
149  new FXLabel(this, name.c_str());
150  myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_INTEGER | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2);
151  myTextField->setText(toString(oc.getInt(name)).c_str());
152 }
153 
154 
155 long
156 GNEDialog_Wizard::InputInt::onCmdSetOption(FXObject*, FXSelector, void*) {
158  oc.resetWritable();
159  oc.set(myName, myTextField->getText().text());
160  return 1;
161 }
162 
163 
164 GNEDialog_Wizard::InputFloat::InputFloat(FXComposite* parent, const std::string& name) :
165  FXHorizontalFrame(parent, LAYOUT_FILL_X),
166  myName(name) {
168  new FXLabel(this, name.c_str());
169  myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_REAL | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2);
170  myTextField->setText(toString(oc.getFloat(name)).c_str());
171 }
172 
173 
174 long
175 GNEDialog_Wizard::InputFloat::onCmdSetOption(FXObject*, FXSelector, void*) {
177  oc.resetWritable();
178  oc.set(myName, myTextField->getText().text());
179  return 1;
180 }
181 
182 
183 /****************************************************************************/
FXDEFMAP(GNEDialog_Wizard::InputString) InputStringMap[]
const std::vector< std::string > & getSubTopics() const
return the list of subtopics
Definition: OptionsCont.h:637
void resetWritable()
Resets all options to be writeable.
FXMenuCheck * myCheck
menu check
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
#define GUIDesignContentsFrame
design for the main content frame of every frame/dialog
Definition: GUIDesigns.h:253
~GNEDialog_Wizard()
Destructor.
long onCmdSetOption(FXObject *, FXSelector, void *)
try to set new attribute value
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
std::string getTypeName(const std::string name)
return the type name for the given option
Definition: OptionsCont.h:653
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
attribute edited
Definition: GUIAppEnum.h:586
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
#define GUIDesignTabBook
desgin for TabBooks
Definition: GUIDesigns.h:425
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:393
A storage for options typed value containers)
Definition: OptionsCont.h:99
long onCmdSetOption(FXObject *, FXSelector, void *)
try to set new attribute value
#define GUIDesignButtonOK
Definition: GUIDesigns.h:98
std::vector< std::string > getSubTopicsEntries(const std::string &subtopic) const
return the list of entries for the given subtopic
Definition: OptionsCont.h:643
FXTextField * myTextField
text field
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
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