BotNavSim  v0.4.3
Mobile Robot Simulation
UI_LogLoader Class Reference

IToolbar class provides controls for loading and viewing CSV data logs. More...

Inheritance diagram for UI_LogLoader:
Collaboration diagram for UI_LogLoader:

Public Member Functions

 UI_LogLoader ()
 

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 the files and folders in current directory More...
 
bool IsMouseOver ()
 Determines whether the mouse was hovering over the last drawn rect object More...
 
void CsvBrowser (int windowID)
 GUI window function: browse and load CSV files More...
 
void Legend (int windowID)
 GUI window function: Display controls for loaded CSV files. More...
 

Private Attributes

Stack< GUI.WindowFunction > _windows
 
List< string > _files
 
List< string > _folders
 
string _subPath
 

Detailed Description

IToolbar class provides controls for loading and viewing CSV data logs.

Definition at line 9 of file UI_LogLoader.cs.

Constructor & Destructor Documentation

UI_LogLoader.UI_LogLoader ( )

Definition at line 11 of file UI_LogLoader.cs.

11  {
12  if (!Directory.Exists(Strings.logFileDirectory))
13  Directory.CreateDirectory(Strings.logFileDirectory);
14  // initialise file browsing
17  _subPath = "\\";
18  // initialise window stack
19  _windows = new Stack<GUI.WindowFunction>();
20  _windows.Push(Legend);
21  hidden = true;
22  }
static List< string > ListFiles(string path, string pattern=null)
Lists file names in directory.
Definition: FileBrowser.cs:30
static string logFileDirectory
Gets the log file directory.
Definition: Strings.cs:52
List< string > _folders
Definition: UI_LogLoader.cs:59
void Legend(int windowID)
GUI window function: Display controls for loaded CSV files.
Stack< GUI.WindowFunction > _windows
Definition: UI_LogLoader.cs:57
string _subPath
Definition: UI_LogLoader.cs:60
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
List< string > _files
Definition: UI_LogLoader.cs:58
A utility class for strings used in this project.
Definition: Strings.cs:9

Here is the call graph for this function:

Member Function Documentation

void UI_LogLoader.CsvBrowser ( int  windowID)
private

GUI window function: browse and load CSV files

Definition at line 82 of file UI_LogLoader.cs.

82  {
83  // hide button
84  GUILayout.BeginHorizontal();
85  if (GUILayout.Button("<", GUILayout.Width(30f))) {
86  _windows.Pop();
87  }
88  // refresh files and folders
89  if (GUILayout.Button("R", GUILayout.Width(30f))) {
90  Refresh();
91  }
92  GUILayout.EndHorizontal();
93 
94  // go up one directory
95  if (_subPath != "") {
96  if (GUILayout.Button("..")) {
97  _subPath = Directory.GetParent(_subPath).Name;
98  Refresh();
99  }
100  }
101  // list subdirectories
102  for (int i = 0; i < _folders.Count; i++) {
103  // enter subdirectory
104  if (GUILayout.Button(_folders[i])) {
105  _subPath += new DirectoryInfo(_folders[i]).Name;
106  Refresh();
107  }
108  }
109  if (LogLoader.loading) {
110  GUILayout.Label("Loading...");
111  }
112  else {
113  // list files
114  for (int i = 0; i < _files.Count; i++) {
115  // try paths from file
116  if (GUILayout.Button(_files[i])) {
117  // change state when loading first data
118  if (BotNavSim.isIdle) {
119  BotNavSim.state = BotNavSim.State.ViewingData;
120  }
121  LogLoader.LoadPaths(currentDir + "\\" + _files[i]);
122  }
123  }
124  }
125 
126  }
string currentDir
Definition: UI_LogLoader.cs:51
static bool loading
Gets a value indicating whether this LogLoader is loading from CSV.
Definition: LogLoader.cs:33
static void LoadPaths(string csvFilePath)
Loads the paths stored in a CSV file. Also attempts to load the relevant environment.
Definition: LogLoader.cs:86
List< string > _folders
Definition: UI_LogLoader.cs:59
static bool isIdle
Gets a value indicating whether BotNavSim is idle.
Definition: BotNavSim.cs:58
Stack< GUI.WindowFunction > _windows
Definition: UI_LogLoader.cs:57
string _subPath
Definition: UI_LogLoader.cs:60
void Refresh()
Refresh the files and folders in current directory
Definition: UI_LogLoader.cs:65
Log loader high level BotNavSim state manager
Definition: LogLoader.cs:10
static State state
Gets or sets the state.
Definition: BotNavSim.cs:45
List< string > _files
Definition: UI_LogLoader.cs:58
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:

bool UI_LogLoader.IsMouseOver ( )
private

Determines whether the mouse was hovering over the last drawn rect object

Returns
true if mouse over; otherwise, false.

Definition at line 74 of file UI_LogLoader.cs.

74  {
75  return Event.current.type == EventType.Repaint &&
76  GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition);
77  }

Here is the caller graph for this function:

void UI_LogLoader.Legend ( int  windowID)
private

GUI window function: Display controls for loaded CSV files.

Definition at line 131 of file UI_LogLoader.cs.

131  {
132  // back button
133  GUILayout.BeginHorizontal(GUILayout.Width(UI_Toolbar.I.innerWidth));
134  if (GUILayout.Button("<", GUILayout.Width(30f))) {
135  hidden = true;
136  }
137  if (GUILayout.Button("Load from CSV...")) {
138  _windows.Push(CsvBrowser);
139  }
140  GUILayout.EndHorizontal();
141 
142  if (LogLoader.paths.Count < 1) {
143  GUILayout.Label("No paths loaded.");
144  }
145 
146  // list botpaths
147  Color c = GUI.contentColor;
148  for(int i = 0; i < LogLoader.paths.Count; i++) {
149  GUILayout.BeginHorizontal();
150  GUI.contentColor = LogLoader.paths[i].color;
151  if (GUILayout.Button(LogLoader.paths[i].csvName)) {
152  LogLoader.paths[i].visible = !LogLoader.paths[i].visible;
153  continue;
154  }
155  // highlight path if mouseover button
156  // this event appears to be broken
157  if (IsMouseOver()) {
158  LogLoader.paths[i].highlight = true;
159  } else {
160  LogLoader.paths[i].highlight = false;
161  }
162  // observe button
163  if (GUILayout.Button("O")) {
165  }
166  // unload path button
167  if (GUILayout.Button("X")) {
169  }
170  GUILayout.EndHorizontal();
171  }
172  // reset content color
173  GUI.contentColor = c;
174 
175  }
void CsvBrowser(int windowID)
GUI window function: browse and load CSV files
Definition: UI_LogLoader.cs:82
float innerWidth
Definition: UI_Toolbar.cs:33
static UI_Toolbar I
Singleton pattern.
Definition: UI_Toolbar.cs:16
static void SetAreaOfInterest(int index)
Sets the area of interest by index.
static void RemovePath(BotPath path)
Removes the path.
Definition: LogLoader.cs:272
Stack< GUI.WindowFunction > _windows
Definition: UI_LogLoader.cs:57
UI Toolbar provides controls for choosing which UI windows to display
Definition: UI_Toolbar.cs:11
Log loader high level BotNavSim state manager
Definition: LogLoader.cs:10
static List< BotPath > paths
The BotPaths loaded from file.
Definition: LogLoader.cs:25
bool IsMouseOver()
Determines whether the mouse was hovering over the last drawn rect object
Definition: UI_LogLoader.cs:74
Controls the camera orientation and render modes according to ViewMode in viewModeList user input...

Here is the call graph for this function:

Here is the caller graph for this function:

void UI_LogLoader.Refresh ( )
private

Refresh the files and folders in current directory

Definition at line 65 of file UI_LogLoader.cs.

65  {
68  }
string currentDir
Definition: UI_LogLoader.cs:51
static List< string > ListFiles(string path, string pattern=null)
Lists file names in directory.
Definition: FileBrowser.cs:30
List< string > _folders
Definition: UI_LogLoader.cs:59
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
List< string > _files
Definition: UI_LogLoader.cs:58

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

List<string> UI_LogLoader._files
private

Definition at line 58 of file UI_LogLoader.cs.

List<string> UI_LogLoader._folders
private

Definition at line 59 of file UI_LogLoader.cs.

string UI_LogLoader._subPath
private

Definition at line 60 of file UI_LogLoader.cs.

Stack<GUI.WindowFunction> UI_LogLoader._windows
private

Definition at line 57 of file UI_LogLoader.cs.

Property Documentation

bool UI_LogLoader.contextual
get

Definition at line 24 of file UI_LogLoader.cs.

string UI_LogLoader.currentDir
get

Definition at line 51 of file UI_LogLoader.cs.

bool UI_LogLoader.hidden
getset

Definition at line 31 of file UI_LogLoader.cs.

GUI.WindowFunction UI_LogLoader.windowFunction
get

Definition at line 45 of file UI_LogLoader.cs.

Rect UI_LogLoader.windowRect
getset

Definition at line 41 of file UI_LogLoader.cs.

string UI_LogLoader.windowTitle
get

Definition at line 35 of file UI_LogLoader.cs.


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