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* name, int width, int height) :
66  FXDialogBox(parent, name, GUIDesignDialogBox, 0, 0, width, height) {
68  FXVerticalFrame* contentFrame = new FXVerticalFrame(this, GUIDesignContentsFrame);
69 
70  FXTabBook* tabbook = new FXTabBook(contentFrame, 0, 0, GUIDesignTabBook);
71 
72  const std::vector<std::string>& topics = oc.getSubTopics();
73  for (std::vector<std::string>::const_iterator it_topic = topics.begin(); it_topic != topics.end(); it_topic++) {
74  std::string topic = *it_topic;
75  if (topic == "Configuration") {
76  continue;
77  }
78  new FXTabItem(tabbook, topic.c_str(), NULL, TAB_LEFT_NORMAL);
79  FXScrollWindow* scrollTab = new FXScrollWindow(tabbook, LAYOUT_FILL_X | LAYOUT_FILL_Y);
80  FXVerticalFrame* tabContent = new FXVerticalFrame(scrollTab, FRAME_THICK | FRAME_RAISED | LAYOUT_FILL_X | LAYOUT_FILL_Y);
81  const std::vector<std::string> entries = oc.getSubTopicsEntries(topic);
82  for (std::vector<std::string>::const_iterator it_opt = entries.begin(); it_opt != entries.end(); it_opt++) {
83  std::string name = *it_opt;
84  if (name != "geometry.remove" && name != "edges.join" && name != "geometry.split" && name != "ramps.guess" && name != "ramps.set") {
85  std::string type = oc.getTypeName(name);
86  if (type == "STR" || type == "FILE") {
87  new InputString(tabContent, name);
88  } else if (type == "BOOL") {
89  new InputBool(tabContent, name);
90  } else if (type == "INT") {
91  new InputInt(tabContent, name);
92  } else if (type == "FLOAT") {
93  new InputFloat(tabContent, name);
94  }
95  // @todo missing types (type INT[] is only used in microsim)
96  }
97  }
98  }
99 
100  // ok-button
101  new FXButton(contentFrame, "OK\t\tContine with the import.", GUIIconSubSys::getIcon(ICON_ACCEPT), this, ID_ACCEPT, GUIDesignButtonOK);
102 }
103 
104 
106 
107 // ===========================================================================
108 // Option input classes method definitions
109 // ===========================================================================
110 GNEDialog_Wizard::InputString::InputString(FXComposite* parent, const std::string& name) :
111  FXHorizontalFrame(parent, LAYOUT_FILL_X),
112  myName(name) {
114  new FXLabel(this, name.c_str());
115  myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_NORMAL | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2);
116  myTextField->setText(oc.getString(name).c_str());
117 }
118 
119 
120 long
121 GNEDialog_Wizard::InputString::onCmdSetOption(FXObject*, FXSelector, void*) {
123  oc.resetWritable();
124  oc.set(myName, myTextField->getText().text());
125  return 1;
126 }
127 
128 
129 GNEDialog_Wizard::InputBool::InputBool(FXComposite* parent, const std::string& name) :
130  FXHorizontalFrame(parent, LAYOUT_FILL_X),
131  myName(name) {
133  new FXLabel(this, name.c_str());
134  myCheck = new FXMenuCheck(this, "", this, MID_GNE_SET_ATTRIBUTE);
135  myCheck->setCheck(oc.getBool(name));
136 }
137 
138 
139 long
140 GNEDialog_Wizard::InputBool::onCmdSetOption(FXObject*, FXSelector, void*) {
142  oc.resetWritable();
143  oc.set(myName, myCheck->getCheck() ? "true" : "false");
144  return 1;
145 }
146 
147 
148 GNEDialog_Wizard::InputInt::InputInt(FXComposite* parent, const std::string& name) :
149  FXHorizontalFrame(parent, LAYOUT_FILL_X),
150  myName(name) {
152  new FXLabel(this, name.c_str());
153  myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_INTEGER | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2);
154  myTextField->setText(toString(oc.getInt(name)).c_str());
155 }
156 
157 
158 long
159 GNEDialog_Wizard::InputInt::onCmdSetOption(FXObject*, FXSelector, void*) {
161  oc.resetWritable();
162  oc.set(myName, myTextField->getText().text());
163  return 1;
164 }
165 
166 
167 GNEDialog_Wizard::InputFloat::InputFloat(FXComposite* parent, const std::string& name) :
168  FXHorizontalFrame(parent, LAYOUT_FILL_X),
169  myName(name) {
171  new FXLabel(this, name.c_str());
172  myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_REAL | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2);
173  myTextField->setText(toString(oc.getFloat(name)).c_str());
174 }
175 
176 
177 long
178 GNEDialog_Wizard::InputFloat::onCmdSetOption(FXObject*, FXSelector, void*) {
180  oc.resetWritable();
181  oc.set(myName, myTextField->getText().text());
182  return 1;
183 }
184 
185 
186 /****************************************************************************/
FXDEFMAP(GNEDialog_Wizard::InputString) InputStringMap[]
attribute edited
Definition: GUIAppEnum.h:570
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
const std::vector< std::string > & getSubTopics() const
return the list of subtopics
Definition: OptionsCont.h:637
#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
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:65
std::string getTypeName(const std::string name)
return the type name for the given option
Definition: OptionsCont.h:653
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
#define GUIDesignTabBook
desgin for TabBooks
Definition: GUIDesigns.h:425
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:393
std::vector< std::string > getSubTopicsEntries(const std::string &subtopic) const
return the list of entries for the given subtopic
Definition: OptionsCont.h:643
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
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