BotNavSim  v0.4.3
Mobile Robot Simulation
UI_SimulationSettings Class Reference

An instantiable class that provides a UI for editing a given Simulation.Settings object More...

Inheritance diagram for UI_SimulationSettings:
Collaboration diagram for UI_SimulationSettings:

Public Member Functions

 UI_SimulationSettings (Simulation.Settings simSettings)
 

Properties

Simulation.Settings settings [get]
 
string windowTitle [get]
 
GUI.WindowFunction windowFunction [get]
 Edit Simulation.Settings window function. Note that when the back button is pressed on the main window this will empty the stack and this window property will return null. To check whether the stack is empty see completed flag property. More...
 
Rect windowRect [get, set]
 Window size and position. More...
 
- Properties inherited from IWindowFunction
string windowTitle [get]
 Gets the window title. More...
 
Rect windowRect [get, set]
 Gets or sets the window rect (window size and position). More...
 
GUI.WindowFunction windowFunction [get]
 Gets the window function definition for GUILayout.Window() More...
 

Private Member Functions

void SimulationSettingsWindow (int windowID)
 Edit Simulation.Settings window function (always top of _windows stack) More...
 
void EnvironmentGalleryWindow (int windowID)
 Environment gallery window. More...
 
void RobotGalleryWindow (int windowID)
 Robot gallery window. More...
 
void NavListWindow (int windowID)
 Navigation algorithm gallery window. More...
 

Private Attributes

Stack< GUI.WindowFunction > _windows
 
Simulation.Settings _settings
 

Detailed Description

An instantiable class that provides a UI for editing a given Simulation.Settings object

Definition at line 9 of file UI_SimulationSettings.cs.

Constructor & Destructor Documentation

UI_SimulationSettings.UI_SimulationSettings ( Simulation.Settings  simSettings)

Definition at line 14 of file UI_SimulationSettings.cs.

14  {
15  _windows = new Stack<GUI.WindowFunction>();
17  _settings = simSettings;
18  }
void SimulationSettingsWindow(int windowID)
Edit Simulation.Settings window function (always top of _windows stack)
Simulation.Settings _settings
Stack< GUI.WindowFunction > _windows

Here is the call graph for this function:

Member Function Documentation

void UI_SimulationSettings.EnvironmentGalleryWindow ( int  windowID)
private

Environment gallery window.

Definition at line 255 of file UI_SimulationSettings.cs.

255  {
256  // back button and refresh button
257  GUILayout.BeginHorizontal();
258  if (GUILayout.Button("<", GUILayout.Width(30f))) {
259  _windows.Pop();
260  }
261  if (GUILayout.Button("R", GUILayout.Width(30f))) {
263  }
264  GUILayout.Label("Environment Gallery");
265  GUILayout.EndHorizontal();
266 
267  // gallery goes here...
268  for(int i = 0; i < EnvLoader.environmentsFound.Count; i++) {
269  if (GUILayout.Button(EnvLoader.environmentsFound[i].name)) {
270  settings.environmentName = EnvLoader.environmentsFound[i].name;
271  _windows.Pop();
272  }
273  }
274 
275  GUILayout.Space(10);
276 
277  // start environment creator
278  GUILayout.Button("Create new environment...");
279 
280  GUI.DragWindow();
281  }
static List< GameObject > environmentsFound
Definition: EnvLoader.cs:11
Simulation.Settings settings
Environment loader searches for and loads environment GameObjects from the Unity Resources folder...
Definition: EnvLoader.cs:9
static void SearchForEnvironments()
Searchs for environments.
Definition: EnvLoader.cs:16
Stack< GUI.WindowFunction > _windows

Here is the call graph for this function:

Here is the caller graph for this function:

void UI_SimulationSettings.NavListWindow ( int  windowID)
private

Navigation algorithm gallery window.

Definition at line 317 of file UI_SimulationSettings.cs.

317  {
318  // back button and refresh button
319  GUILayout.BeginHorizontal();
320  if (GUILayout.Button("<", GUILayout.Width(30f))) {
321  _windows.Pop();
322  }
323  if (GUILayout.Button("R", GUILayout.Width(30f))) {
325  }
326  GUILayout.Label("Nav Algorithm List");
327  GUILayout.EndHorizontal();
328 
329  // gallery
330  foreach(string s in NavLoader.pluginsFound) {
331  if (GUILayout.Button(s)) {
332  settings.navigationAssemblyName = s;
333  _windows.Pop();
334  }
335  }
336 
337  GUI.DragWindow();
338  }
Simulation.Settings settings
static void SearchForPlugins()
Searchs for plugins in the INavigation directory (Strings.navigationPluginDirectory) Results are stor...
Definition: NavLoader.cs:22
static List< string > pluginsFound
List of .dll files that implement INavigation.
Definition: NavLoader.cs:15
Stack< GUI.WindowFunction > _windows
Used to find and load INavigation implementations from .dll files.
Definition: NavLoader.cs:10

Here is the call graph for this function:

Here is the caller graph for this function:

void UI_SimulationSettings.RobotGalleryWindow ( int  windowID)
private

Robot gallery window.

Definition at line 286 of file UI_SimulationSettings.cs.

286  {
287  // back button and refresh button
288  GUILayout.BeginHorizontal();
289  if (GUILayout.Button("<", GUILayout.Width(30f))) {
290  _windows.Pop();
291  }
292  if (GUILayout.Button("R", GUILayout.Width(30f))) {
294  }
295  GUILayout.Label("Robot Gallery");
296  GUILayout.EndHorizontal();
297 
298  // gallery goes here...
299  for(int i = 0; i < BotLoader.robotsFound.Count; i++) {
300  if (GUILayout.Button(BotLoader.robotsFound[i].name)) {
301  settings.robotName = BotLoader.robotsFound[i].name;
302  _windows.Pop();
303  }
304  }
305 
306  GUILayout.Space (10);
307 
308  // start robot creator
309  GUILayout.Button("Create new robot...");
310 
311  GUI.DragWindow();
312  }
Simulation.Settings settings
Bot loader provides functions for finding and loading robots.
Definition: BotLoader.cs:8
static void SearchForRobots()
Searchs for robots.
Definition: BotLoader.cs:19
static List< GameObject > robotsFound
List of robots found in the Robots/ resources directory
Definition: BotLoader.cs:13
Stack< GUI.WindowFunction > _windows

Here is the call graph for this function:

Here is the caller graph for this function:

void UI_SimulationSettings.SimulationSettingsWindow ( int  windowID)
private

Edit Simulation.Settings window function (always top of _windows stack)

Parameters
windowIDWindow ID.

Definition at line 63 of file UI_SimulationSettings.cs.

63  {
64 
65 
66  GUILayout.BeginHorizontal();
67 
68  if (!_settings.active) {
69  // if this settings is already batched
70  if (Simulation.batch.Contains(_settings)) {
71  // button to remove from batch
72  if (GUILayout.Button("Remove from batch")) {
73  Simulation.batch.Remove(_settings);
74  _windows.Pop();
75  return;
76  }
77  // cancel button
78  if (GUILayout.Button("Close window")) {
79  _windows.Pop();
80  return;
81  }
82  }
83  // this settings isn't in the batch
84  else {
85  // button to add valid settings to batch
86  if (_settings.isValid) {
87  if (GUILayout.Button("Add to batch")) {
89  _windows.Pop();
90  return;
91  }
92  }
93  // cancel button
94  if (GUILayout.Button("Cancel")) {
95  _windows.Pop();
96  return;
97  }
98  }
99  }
100  else {
101  GUILayout.Button("Simulation running!");
102  if (GUILayout.Button("Close")) {
103  _windows.Pop();
104  return;
105  }
106  }
107 
108  GUILayout.EndHorizontal();
109 
110  float lw = 200f;
111 
112  // copy settings for UI
113  string title = settings.title;
114  string robotName = settings.robotName;
115  string environmentName = settings.environmentName;
116  string navigationAssemblyName = settings.navigationAssemblyName;
117  string numberOfTests = settings.numberOfTests.ToString();
118  string testTime = settings.maximumTestTime.ToString();
119  bool randomDest = settings.randomizeDestination;
120  bool randomStart = settings.randomizeOrigin;
121  bool repeatOnComplete = settings.continueOnNavObjectiveComplete;
122  bool repeatOnStuck = settings.continueOnRobotIsStuck;
123 
124  // if settings is in use by Simulation
125  if (settings.active) {
126  // display only
127  GUILayout.Label(settings.title + "\n" +
128  settings.robotName + "\n" +
129  settings.environmentName + "\n" +
130  settings.navigationAssemblyName);
131  }
132  else {
133  // provide controls for editing
134 
135  // edit title
136  GUILayout.BeginHorizontal();
137  GUILayout.Label("Title", GUILayout.Width(lw));
138  title = GUILayout.TextField(title);
139  GUILayout.EndHorizontal();
140 
141  // edit number of tests
142  GUILayout.BeginHorizontal();
143  GUILayout.Label("Number of tests: ", GUILayout.Width(lw));
144  numberOfTests = GUILayout.TextField(numberOfTests);
145  GUILayout.EndHorizontal();
146 
147  // change the robot
148  GUILayout.BeginHorizontal();
149  GUILayout.Label("Robot selection: ", GUILayout.Width(lw));
150  if (GUILayout.Button(robotName)) {
153  }
154  GUILayout.EndHorizontal();
155 
156  // change the environment
157  GUILayout.BeginHorizontal();
158  GUILayout.Label("Environment selection: ", GUILayout.Width(lw));
159  if (GUILayout.Button(environmentName)) {
162  }
163  GUILayout.EndHorizontal();
164 
165  // change the navigation assembly
166  GUILayout.BeginHorizontal();
167  GUILayout.Label("Algorithm selection: ", GUILayout.Width(lw));
168  if (GUILayout.Button(navigationAssemblyName)) {
170  _windows.Push(NavListWindow);
171  }
172  GUILayout.EndHorizontal();
173  }
174 
175  // toggle random start position
176  GUILayout.BeginHorizontal();
177  GUILayout.Label("Randomize Start: ", GUILayout.Width(lw));
178  randomStart = GUILayout.Toggle(randomStart,"");
179  GUILayout.EndHorizontal();
180 
181  // toggle random destination position
182  GUILayout.BeginHorizontal();
183  GUILayout.Label("Randomize Destination: ", GUILayout.Width(lw));
184  randomDest = GUILayout.Toggle(randomDest,"");
185  GUILayout.EndHorizontal();
186 
187  // if settings is in use by Simulation
188  if (settings.active) {
189  // display time remaining and edit maximum test time
190  GUILayout.BeginHorizontal();
191  GUILayout.Label("Time (s): " + Simulation.time.ToString("G2"), GUILayout.Width(lw));
192  testTime = GUILayout.TextField(testTime);
193  GUILayout.EndHorizontal();
194  }
195  else {
196  // edit maximum test time
197  GUILayout.BeginHorizontal();
198  GUILayout.Label("Maximum Simulation Time (s): ", GUILayout.Width(lw));
199  testTime = GUILayout.TextField(testTime);
200  GUILayout.EndHorizontal();
201  }
202 
203  // edit toggle for automatically starting a new test
204  GUILayout.BeginHorizontal();
205  GUILayout.Label("Repeat on complete: " , GUILayout.Width(lw));
206  repeatOnComplete = GUILayout.Toggle(repeatOnComplete,"");
207  GUILayout.EndHorizontal();
208 
209  // edit toggle for stuck detection
210  GUILayout.BeginHorizontal();
211  GUILayout.Label("Repeat on stuck: ", GUILayout.Width(lw));
212  repeatOnStuck = GUILayout.Toggle(repeatOnStuck, "");
213  GUILayout.EndHorizontal();
214 
215  // check for valid data input before copying back to settings object
216  bool valid = true;
217  foreach(char c in Strings.invalidFileNameChars) {
218  if (title.Contains(c.ToString())) valid = false;
219  }
220  if (valid) settings.title = title;
221 
222  if (Strings.IsDigitsOnly(numberOfTests)) {
223  try {
224  settings.numberOfTests = Convert.ToInt32(numberOfTests);
225  }
226  catch {
227  Debug.Log("User should enter a number...");
228  }
229  }
230 
231  if (Strings.IsDigitsOnly(testTime)) {
232  try {
233  settings.maximumTestTime = Convert.ToInt32(testTime);
234  }
235  catch {
236  Debug.Log("User should enter a number...");
237  }
238  }
239 
240  // copy valid data back to settings
241  settings.robotName = robotName;
242  settings.environmentName = environmentName;
243  settings.navigationAssemblyName = navigationAssemblyName;
244  settings.randomizeDestination = randomDest;
245  settings.randomizeOrigin = randomStart;
246  settings.continueOnNavObjectiveComplete = repeatOnComplete;
247  settings.continueOnRobotIsStuck = repeatOnStuck;
248 
249  GUI.DragWindow();
250  }
static List< Settings > batch
List of settings to iterate through in batch mode.
Definition: Simulation.cs:254
void NavListWindow(int windowID)
Navigation algorithm gallery window.
Simulation.Settings settings
Environment loader searches for and loads environment GameObjects from the Unity Resources folder...
Definition: EnvLoader.cs:9
static void SearchForPlugins()
Searchs for plugins in the INavigation directory (Strings.navigationPluginDirectory) Results are stor...
Definition: NavLoader.cs:22
void RobotGalleryWindow(int windowID)
Robot gallery window.
Simulation.Settings _settings
Bot loader provides functions for finding and loading robots.
Definition: BotLoader.cs:8
static char[] invalidFileNameChars
Gets the invalid file name chars.
Definition: Strings.cs:68
This is a manager class used to overlook the running of a simulation.
Definition: Simulation.cs:8
void EnvironmentGalleryWindow(int windowID)
Environment gallery window.
static void SearchForRobots()
Searchs for robots.
Definition: BotLoader.cs:19
static bool IsDigitsOnly(string str)
Determines if is digits only the specified str.
Definition: Strings.cs:106
A utility class for strings used in this project.
Definition: Strings.cs:9
static float time
Time (in seconds) since robot started searching for destination.
Definition: Simulation.cs:366
static void SearchForEnvironments()
Searchs for environments.
Definition: EnvLoader.cs:16
Stack< GUI.WindowFunction > _windows
Used to find and load INavigation implementations from .dll files.
Definition: NavLoader.cs:10

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

Simulation.Settings UI_SimulationSettings._settings
private

Definition at line 12 of file UI_SimulationSettings.cs.

Stack<GUI.WindowFunction> UI_SimulationSettings._windows
private

Definition at line 11 of file UI_SimulationSettings.cs.

Property Documentation

Simulation.Settings UI_SimulationSettings.settings
get

Definition at line 20 of file UI_SimulationSettings.cs.

GUI.WindowFunction UI_SimulationSettings.windowFunction
get

Edit Simulation.Settings window function. Note that when the back button is pressed on the main window this will empty the stack and this window property will return null. To check whether the stack is empty see completed flag property.

Definition at line 42 of file UI_SimulationSettings.cs.

Rect UI_SimulationSettings.windowRect
getset

Window size and position.

Definition at line 54 of file UI_SimulationSettings.cs.

string UI_SimulationSettings.windowTitle
get

Definition at line 26 of file UI_SimulationSettings.cs.


The documentation for this class was generated from the following file: