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 
31 #ifdef HAVE_VERSION_H
32 #include <version.h>
33 #endif
34 
39 #include <utils/common/ToString.h>
41 #include "GNEDialog_Wizard.h"
42 
43 #ifdef CHECK_MEMORY_LEAKS
44 #include <foreign/nvwa/debug_new.h>
45 #endif // CHECK_MEMORY_LEAKS
46 
47 
48 // ===========================================================================
49 // FOX callback mapping
50 // ===========================================================================
51 FXDEFMAP(GNEDialog_Wizard::InputString) InputStringMap[] = {
53 };
54 FXDEFMAP(GNEDialog_Wizard::InputBool) InputBoolMap[] = {
56 };
57 FXDEFMAP(GNEDialog_Wizard::InputInt) InputIntMap[] = {
59 };
60 FXDEFMAP(GNEDialog_Wizard::InputFloat) InputFloatMap[] = {
62 };
63 
64 // Object implementation
65 FXIMPLEMENT(GNEDialog_Wizard::InputString, FXHorizontalFrame, InputStringMap, ARRAYNUMBER(InputStringMap))
66 FXIMPLEMENT(GNEDialog_Wizard::InputBool, FXHorizontalFrame, InputBoolMap, ARRAYNUMBER(InputBoolMap))
67 FXIMPLEMENT(GNEDialog_Wizard::InputInt, FXHorizontalFrame, InputIntMap, ARRAYNUMBER(InputIntMap))
68 FXIMPLEMENT(GNEDialog_Wizard::InputFloat, FXHorizontalFrame, InputFloatMap, ARRAYNUMBER(InputFloatMap))
69 
70 // ===========================================================================
71 // method definitions
72 // ===========================================================================
73 GNEDialog_Wizard::GNEDialog_Wizard(FXWindow* parent, const char* name, int width, int height) :
74  FXDialogBox(parent, name, GUIDesignDialogBox, 0, 0, width, height) {
76  FXVerticalFrame* contentFrame = new FXVerticalFrame(this, GUIDesignContentsFrame);
77 
78  FXTabBook* tabbook = new FXTabBook(contentFrame, 0, 0, GUIDesignTabBook);
79 
80  const std::vector<std::string>& topics = oc.getSubTopics();
81  for (std::vector<std::string>::const_iterator it_topic = topics.begin(); it_topic != topics.end(); it_topic++) {
82  std::string topic = *it_topic;
83  if (topic == "Configuration") {
84  continue;
85  }
86  new FXTabItem(tabbook, topic.c_str(), NULL, TAB_LEFT_NORMAL);
87  FXScrollWindow* scrollTab = new FXScrollWindow(tabbook, LAYOUT_FILL_X | LAYOUT_FILL_Y);
88  FXVerticalFrame* tabContent = new FXVerticalFrame(scrollTab, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y);
89  const std::vector<std::string> entries = oc.getSubTopicsEntries(topic);
90  for (std::vector<std::string>::const_iterator it_opt = entries.begin(); it_opt != entries.end(); it_opt++) {
91  std::string name = *it_opt;
92  if (name != "geometry.remove" && name != "edges.join" && name != "geometry.split" && name != "ramps.guess" && name != "ramps.set") {
93  std::string type = oc.getTypeName(name);
94  if (type == "STR" || type == "FILE") {
95  new InputString(tabContent, name);
96  } else if (type == "BOOL") {
97  new InputBool(tabContent, name);
98  } else if (type == "INT") {
99  new InputInt(tabContent, name);
100  } else if (type == "FLOAT") {
101  new InputFloat(tabContent, name);
102  }
103  // @todo missing types (type INT[] is only used in microsim)
104  }
105  }
106  }
107 
108  // ok-button
109  new FXButton(contentFrame, "OK\t\tContine with the import.", GUIIconSubSys::getIcon(ICON_ACCEPT), this, ID_ACCEPT, GUIDesignButtonOK);
110 }
111 
112 
114 
115 // ===========================================================================
116 // Option input classes method definitions
117 // ===========================================================================
118 GNEDialog_Wizard::InputString::InputString(FXComposite* parent, const std::string& name) :
119  FXHorizontalFrame(parent, LAYOUT_FILL_X),
120  myName(name) {
122  new FXLabel(this, name.c_str());
123  myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_NORMAL | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2);
124  myTextField->setText(oc.getString(name).c_str());
125 }
126 
127 
128 long
129 GNEDialog_Wizard::InputString::onCmdSetOption(FXObject*, FXSelector, void*) {
131  oc.resetWritable();
132  oc.set(myName, myTextField->getText().text());
133  return 1;
134 }
135 
136 
137 GNEDialog_Wizard::InputBool::InputBool(FXComposite* parent, const std::string& name) :
138  FXHorizontalFrame(parent, LAYOUT_FILL_X),
139  myName(name) {
141  new FXLabel(this, name.c_str());
142  myCheck = new FXMenuCheck(this, "", this, MID_GNE_SET_ATTRIBUTE);
143  myCheck->setCheck(oc.getBool(name));
144 }
145 
146 
147 long
148 GNEDialog_Wizard::InputBool::onCmdSetOption(FXObject*, FXSelector, void*) {
150  oc.resetWritable();
151  oc.set(myName, myCheck->getCheck() ? "true" : "false");
152  return 1;
153 }
154 
155 
156 GNEDialog_Wizard::InputInt::InputInt(FXComposite* parent, const std::string& name) :
157  FXHorizontalFrame(parent, LAYOUT_FILL_X),
158  myName(name) {
160  new FXLabel(this, name.c_str());
161  myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_INTEGER | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2);
162  myTextField->setText(toString(oc.getInt(name)).c_str());
163 }
164 
165 
166 long
167 GNEDialog_Wizard::InputInt::onCmdSetOption(FXObject*, FXSelector, void*) {
169  oc.resetWritable();
170  oc.set(myName, myTextField->getText().text());
171  return 1;
172 }
173 
174 
175 GNEDialog_Wizard::InputFloat::InputFloat(FXComposite* parent, const std::string& name) :
176  FXHorizontalFrame(parent, LAYOUT_FILL_X),
177  myName(name) {
179  new FXLabel(this, name.c_str());
180  myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_REAL | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2);
181  myTextField->setText(toString(oc.getFloat(name)).c_str());
182 }
183 
184 
185 long
186 GNEDialog_Wizard::InputFloat::onCmdSetOption(FXObject*, FXSelector, void*) {
188  oc.resetWritable();
189  oc.set(myName, myTextField->getText().text());
190  return 1;
191 }
192 
193 
194 /****************************************************************************/
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
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:235
~GNEDialog_Wizard()
Destructor.
long onCmdSetOption(FXObject *, FXSelector, void *)
try to set new attribute value
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
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)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
#define GUIDesignTabBook
desgin for TabBooks
Definition: GUIDesigns.h:441
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:407
A storage for options typed value containers)
Definition: OptionsCont.h:99
attribute edited
Definition: GUIAppEnum.h:553
long onCmdSetOption(FXObject *, FXSelector, void *)
try to set new attribute value
#define GUIDesignButtonOK
Definition: GUIDesigns.h:101
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