BotNavSim  v0.4.3
Mobile Robot Simulation
UI_SimulationBatch Class Reference

IToolbar class for displaying and editing the simulation batch list More...

Inheritance diagram for UI_SimulationBatch:
Collaboration diagram for UI_SimulationBatch:

Public Member Functions

 UI_SimulationBatch ()
 

Properties

bool contextual [get]
 
bool hidden [get, set]
 
string windowTitle [get]
 
Rect windowRect [get, set]
 
GUI.WindowFunction windowFunction [get]
 
string currentDir [get]
 
- Properties inherited from IToolbar
bool contextual [get]
 Gets a value indicating whether this IToolbar is contextual. More...
 
bool hidden [get, set]
 Gets or sets a value indicating whether this IToolbar is hidden. 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 Refresh ()
 Refresh this the files and folders in current directory More...
 
void BatchListWindow (int windowID)
 List Simulation.Settings in Simulation.batch and provide controls and editing the Simulation.batch More...
 
void XmlBrowser (int windowID)
 Browse for XML files to deserialize into Simulation.Settings More...
 

Private Attributes

Stack< GUI.WindowFunction > _windows
 
UI_SimulationSettings _editSettings
 
List< string > _files
 
List< string > _folders
 
string _subPath
 
Simulation.Settings _settings
 

Detailed Description

IToolbar class for displaying and editing the simulation batch list

Definition at line 9 of file UI_SimulationBatch.cs.

Constructor & Destructor Documentation

UI_SimulationBatch.UI_SimulationBatch ( )

Definition at line 11 of file UI_SimulationBatch.cs.

11  {
14  _files = new List<string>();
15  _folders = new List<string>();
16  _windows = new Stack<GUI.WindowFunction>();
17  _windows.Push(BatchListWindow);
18  // hide window initially
19  hidden = true;
20  }
List< string > _folders
void BatchListWindow(int windowID)
List Simulation.Settings in Simulation.batch and provide controls and editing the Simulation...
List< string > _files
Stack< GUI.WindowFunction > _windows
An instantiable class that provides a UI for editing a given Simulation.Settings object ...
UI_SimulationSettings _editSettings
Simulation.Settings _settings
This is a manager class used to overlook the running of a simulation.
Definition: Simulation.cs:8

Here is the call graph for this function:

Member Function Documentation

void UI_SimulationBatch.BatchListWindow ( int  windowID)
private

List Simulation.Settings in Simulation.batch and provide controls and editing the Simulation.batch

Definition at line 75 of file UI_SimulationBatch.cs.

75  {
76 
77  GUILayout.BeginHorizontal(GUILayout.Width(UI_Toolbar.I.innerWidth));
78 
79  // add a new simulation to batch
80  if (GUILayout.Button("Add new simulation")) {
84  }
85  // load a simulation from xml file
86  if (GUILayout.Button("Add to batch from file...")) {
87  Refresh();
88  _windows.Push(XmlBrowser);
89  }
90  GUILayout.EndHorizontal();
91 
92  // Batch list
93  GUILayout.Label("Currently in batch:");
94  if (Simulation.batch.Count < 1) {
95  GUILayout.Label("None");
96  }
97 
98  for(int i = 0; i < Simulation.batch.Count; i++) {
99  Simulation.Settings batchItem = Simulation.batch[i];
100  // batch list table row by row
101  GUILayout.BeginHorizontal(GUILayout.Width(UI_Toolbar.I.innerWidth));
102  // display batch position
103  if (i+1 == Simulation.simulationNumber) {
104  GUILayout.Label("->");
105  }
106  // label
107  string label = i+1 + ". " + batchItem.title + ", " + batchItem.time;
108  if (batchItem.active) label += ", RUNNING";
109  GUILayout.Label(label);
110  // edit these settings
111  if (GUILayout.Button("Edit")) {
112  _settings = batchItem;
115  }
116  if (GUILayout.Button("X")) {
117  Simulation.batch.RemoveAt(i);
118  }
119  // indicate which have been executed already
120  // if (batchItem.executed)
121 
122  GUILayout.EndHorizontal();
123  }
124 
125  GUILayout.Space (10);
126  // start simulating
127  if (Simulation.batch.Count > 0) {
128  if (GUILayout.Button("Start Batch")) {
129  BotNavSim.state = BotNavSim.State.Simulating;
130  Simulation.Begin();
131  }
132  GUILayout.Space(20);
133  // remove all simulations from batch
134  GUILayout.Space (20);
135  if (GUILayout.Button("Clear Batch")) {
136  Simulation.batch.Clear();
137  }
138  }
139  }
static List< Settings > batch
List of settings to iterate through in batch mode.
Definition: Simulation.cs:254
static int simulationNumber
Gets the simulation number (index in batch list, 1 to batch.Count).
Definition: Simulation.cs:259
float innerWidth
Definition: UI_Toolbar.cs:33
static UI_Toolbar I
Singleton pattern.
Definition: UI_Toolbar.cs:16
Stack< GUI.WindowFunction > _windows
void XmlBrowser(int windowID)
Browse for XML files to deserialize into Simulation.Settings
An instantiable class that provides a UI for editing a given Simulation.Settings object ...
UI_SimulationSettings _editSettings
UI Toolbar provides controls for choosing which UI windows to display
Definition: UI_Toolbar.cs:11
void Refresh()
Refresh this the files and folders in current directory
Simulation.Settings _settings
This is a manager class used to overlook the running of a simulation.
Definition: Simulation.cs:8
static void Begin()
Begin simulating.
Definition: Simulation.cs:412
static State state
Gets or sets the state.
Definition: BotNavSim.cs:45
Interface for classes that implement a GUI.WindowFunction
List< IWindowFunction > additionalWindows
The additional windows to be drawn outside the toolbar. used for classes like UI_SimulationSettings ...
Definition: UI_Toolbar.cs:27
BotNavSim high-level manager class. Holds BotNavSim.State and controls state transition behaviour...
Definition: BotNavSim.cs:7

Here is the call graph for this function:

Here is the caller graph for this function:

void UI_SimulationBatch.Refresh ( )
private

Refresh this the files and folders in current directory

Definition at line 66 of file UI_SimulationBatch.cs.

66  {
69  }
List< string > _folders
static List< string > ListFiles(string path, string pattern=null)
Lists file names in directory.
Definition: FileBrowser.cs:30
List< string > _files
static List< string > ListFolders(string path)
Lists folder names in directory.
Definition: FileBrowser.cs:16
File browser utility class for finding files and folders.
Definition: FileBrowser.cs:9

Here is the call graph for this function:

Here is the caller graph for this function:

void UI_SimulationBatch.XmlBrowser ( int  windowID)
private

Browse for XML files to deserialize into Simulation.Settings

Definition at line 144 of file UI_SimulationBatch.cs.

144  {
145  // back button
146  GUILayout.BeginHorizontal(GUILayout.Width(UI_Toolbar.I.innerWidth));
147  if (GUILayout.Button("<", GUILayout.Width(30f))) {
148  _windows.Pop();
149  }
150  // refresh files and folders
151  if (GUILayout.Button("R", GUILayout.Width(30f))) {
152  Refresh();
153  }
154  GUILayout.EndHorizontal();
155 
156  // go up one directory
157  if (_subPath != "") {
158  if (GUILayout.Button("..")) {
159  _subPath = Directory.GetParent(_subPath).Name;
160  Refresh();
161  }
162  }
163  // list subdirectories
164  for (int i = 0; i < _folders.Count; i++) {
165  // enter subdirectory
166  if (GUILayout.Button(_folders[i])) {
167  _subPath += "\\" + new DirectoryInfo(_folders[i]).Name;
168  Refresh();
169  }
170  }
171  // list files
172  for (int i = 0; i < _files.Count; i++) {
173  // try paths from file
174  if (GUILayout.Button(_files[i])) {
175  string path = currentDir + "\\" + _files[i];
176  Simulation.Settings settings = ObjectSerializer.DeSerializeObject<Simulation.Settings>(path);
177  if (settings != null) {
178  settings.active = false;
179  Simulation.batch.Add(settings);
180  _windows.Pop();
181  }
182  }
183  }
184 
185  }
List< string > _folders
static List< Settings > batch
List of settings to iterate through in batch mode.
Definition: Simulation.cs:254
List< string > _files
float innerWidth
Definition: UI_Toolbar.cs:33
static UI_Toolbar I
Singleton pattern.
Definition: UI_Toolbar.cs:16
Stack< GUI.WindowFunction > _windows
bool active
Gets or sets a value indicating whether this Simulation.Settings is active and determines which prope...
Definition: Simulation.cs:143
UI Toolbar provides controls for choosing which UI windows to display
Definition: UI_Toolbar.cs:11
void Refresh()
Refresh this the files and folders in current directory
This is a manager class used to overlook the running of a simulation.
Definition: Simulation.cs:8
Object serializer utility class.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

UI_SimulationSettings UI_SimulationBatch._editSettings
private

Definition at line 57 of file UI_SimulationBatch.cs.

List<string> UI_SimulationBatch._files
private

Definition at line 58 of file UI_SimulationBatch.cs.

List<string> UI_SimulationBatch._folders
private

Definition at line 59 of file UI_SimulationBatch.cs.

Simulation.Settings UI_SimulationBatch._settings
private

Definition at line 61 of file UI_SimulationBatch.cs.

string UI_SimulationBatch._subPath
private

Definition at line 60 of file UI_SimulationBatch.cs.

Stack<GUI.WindowFunction> UI_SimulationBatch._windows
private

Definition at line 56 of file UI_SimulationBatch.cs.

Property Documentation

bool UI_SimulationBatch.contextual
get

Definition at line 22 of file UI_SimulationBatch.cs.

string UI_SimulationBatch.currentDir
get

Definition at line 50 of file UI_SimulationBatch.cs.

bool UI_SimulationBatch.hidden
getset

Definition at line 30 of file UI_SimulationBatch.cs.

GUI.WindowFunction UI_SimulationBatch.windowFunction
get

Definition at line 44 of file UI_SimulationBatch.cs.

Rect UI_SimulationBatch.windowRect
getset

Definition at line 40 of file UI_SimulationBatch.cs.

string UI_SimulationBatch.windowTitle
get

Definition at line 34 of file UI_SimulationBatch.cs.


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