AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
MeasureManager.cs
Go to the documentation of this file.
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// Licensed under the MIT License. See LICENSE in the project root for license information.
3
4
using
UnityEngine
;
5
using
System
.Collections;
6
using
HoloToolkit
.
Unity
;
7
using
System
.Collections.Generic;
8
using
System
;
9
using
HoloToolkit
.
Unity
.
InputModule
;
10
11
namespace
HoloToolkit
.Examples.GazeRuler
12
{
16
public
class
MeasureManager
:
Singleton
<MeasureManager>,
IHoldHandler
,
IInputClickHandler
17
{
18
private
IGeometry
manager;
19
public
GeometryMode
Mode
;
20
21
// set up prefabs
22
public
GameObject
LinePrefab
;
23
public
GameObject
PointPrefab
;
24
public
GameObject
ModeTipObject
;
25
public
GameObject
TextPrefab
;
26
27
private
void
Start()
28
{
29
InputManager
.
Instance
.PushFallbackInputHandler(gameObject);
30
31
// inti measure mode
32
switch
(Mode)
33
{
34
case
GeometryMode
.Polygon:
35
manager =
PolygonManager
.
Instance
;
36
break
;
37
default
:
38
manager =
LineManager
.
Instance
;
39
break
;
40
}
41
}
42
43
// place spatial point
44
public
void
OnSelect
()
45
{
46
manager.
AddPoint
(LinePrefab, PointPrefab, TextPrefab);
47
}
48
49
// delete latest line or geometry
50
public
void
DeleteLine
()
51
{
52
manager.
Delete
();
53
}
54
55
// delete all lines or geometry
56
public
void
ClearAll
()
57
{
58
manager.
Clear
();
59
}
60
61
// if current mode is geometry mode, try to finish geometry
62
public
void
OnPolygonClose
()
63
{
64
IPolygonClosable
client =
PolygonManager
.
Instance
;
65
client.
ClosePolygon
(LinePrefab, TextPrefab);
66
}
67
68
// change measure mode
69
public
void
OnModeChange
()
70
{
71
try
72
{
73
manager.
Reset
();
74
if
(Mode ==
GeometryMode
.Line)
75
{
76
Mode =
GeometryMode
.Polygon;
77
manager =
PolygonManager
.
Instance
;
78
}
79
else
80
{
81
Mode =
GeometryMode
.Line;
82
manager =
LineManager
.
Instance
;
83
}
84
}
85
catch
(Exception ex)
86
{
87
Debug
.Log(ex.Message);
88
}
89
ModeTipObject.SetActive(
true
);
90
}
91
92
public
void
OnHoldStarted
(
HoldEventData
eventData)
93
{
94
OnPolygonClose();
95
}
96
97
public
void
OnHoldCompleted
(
HoldEventData
eventData)
98
{
99
// Nothing to do
100
}
101
102
public
void
OnHoldCanceled
(
HoldEventData
eventData)
103
{
104
// Nothing to do
105
}
106
107
public
void
OnInputClicked
(
InputClickedEventData
eventData)
108
{
109
OnSelect();
110
}
111
}
112
113
public
class
Point
114
{
115
public
Vector3
Position
{
get
;
set
; }
116
117
public
GameObject Root {
get
;
set
; }
118
public
bool
IsStart {
get
;
set
; }
119
}
120
121
122
public
enum
GeometryMode
123
{
124
Line
,
125
Triangle
,
126
Rectangle
,
127
Cube
,
128
Polygon
129
}
130
}
HoloToolkit.Unity.InputModule
Definition:
AnimatedCursor.cs:7
HoloToolkit.Examples.GazeRuler.Line
Definition:
LineManager.cs:133
HoloToolkit.Examples.GazeRuler.Polygon
Definition:
PolygonManager.cs:192
HoloToolkit.Unity.InputModule.InputManager
Input Manager is responsible for managing input sources and dispatching relevant events to the approp...
Definition:
InputManager.cs:19
HoloToolkit.Examples.GazeRuler.MeasureManager.OnPolygonClose
void OnPolygonClose()
Definition:
MeasureManager.cs:62
System
HoloToolkit.Examples.GazeRuler.IGeometry.Clear
void Clear()
HoloToolkit.Examples.GazeRuler.MeasureManager.OnHoldCompleted
void OnHoldCompleted(HoldEventData eventData)
Definition:
MeasureManager.cs:97
HoloToolkit.Examples.GazeRuler.IGeometry.Reset
void Reset()
HoloToolkit.Examples.GazeRuler.MeasureManager.TextPrefab
GameObject TextPrefab
Definition:
MeasureManager.cs:25
HoloToolkit.Examples.GazeRuler.Point
Definition:
MeasureManager.cs:113
HoloToolkit.Examples.GazeRuler.LineManager
Manages all lines in the scene
Definition:
LineManager.cs:14
HoloToolkit.Examples.GazeRuler.MeasureManager.ModeTipObject
GameObject ModeTipObject
Definition:
MeasureManager.cs:24
HoloToolkit.Examples.GazeRuler.MeasureManager.LinePrefab
GameObject LinePrefab
Definition:
MeasureManager.cs:22
HoloToolkit.Examples.GazeRuler.IPolygonClosable.ClosePolygon
void ClosePolygon(GameObject LinePrefab, GameObject TextPrefab)
HoloToolkit.Unity.InputModule.IInputClickHandler
Interface to implement to react to simple click input.
Definition:
IInputClickHandler.cs:11
HoloToolkit.Examples.GazeRuler.GeometryMode.Rectangle
HoloToolkit.Examples.GazeRuler.MeasureManager.OnHoldCanceled
void OnHoldCanceled(HoldEventData eventData)
Definition:
MeasureManager.cs:102
HoloToolkit.Examples.GazeRuler.MeasureManager.ClearAll
void ClearAll()
Definition:
MeasureManager.cs:56
HoloToolkit.Examples.GazeRuler.MeasureManager.OnInputClicked
void OnInputClicked(InputClickedEventData eventData)
Definition:
MeasureManager.cs:107
HoloToolkit.Examples.GazeRuler.IGeometry.AddPoint
void AddPoint(GameObject LinePrefab, GameObject PointPrefab, GameObject TextPrefab)
HoloToolkit.Unity.Singleton.Instance
static T Instance
Returns the Singleton instance of the classes type. If no instance is found, then we search for an in...
Definition:
Singleton.cs:26
HoloToolkit.Unity.InputModule.IHoldHandler
Interface to implement to react to hold gestures.
Definition:
IHoldHandler.cs:11
HoloToolkit.Examples.GazeRuler.GeometryMode.Triangle
HoloToolkit.Examples.GazeRuler.MeasureManager.OnHoldStarted
void OnHoldStarted(HoldEventData eventData)
Definition:
MeasureManager.cs:92
HoloToolkit.Examples.GazeRuler.MeasureManager.OnSelect
void OnSelect()
Definition:
MeasureManager.cs:44
HoloToolkit.Examples.GazeRuler.IGeometry
interface for geometry class
Definition:
IGeometry.cs:12
HoloToolkit.Examples.GazeRuler.PolygonManager
manager all geometries in the scene
Definition:
PolygonManager.cs:14
Debug
HoloToolkit.Examples.GazeRuler.IGeometry.Delete
void Delete()
HoloToolkit.Examples.GazeRuler.MeasureManager.PointPrefab
GameObject PointPrefab
Definition:
MeasureManager.cs:23
HoloToolkit.Unity.InputModule.InputClickedEventData
Describes an input event that involves a tap.
Definition:
InputClickedEventData.cs:11
HoloToolkit.Examples.GazeRuler.IPolygonClosable
any geometry class inherit this interface should be closeable
Definition:
IPolygonClosable.cs:11
HoloToolkit.Examples.GazeRuler.MeasureManager.DeleteLine
void DeleteLine()
Definition:
MeasureManager.cs:50
HoloToolkit
HoloToolkit.Unity.InputModule.HoldEventData
Event dispatched when a hold gesture is detected.
Definition:
HoldEventData.cs:11
HoloToolkit.Examples.GazeRuler.MeasureManager
manager all measure tools here
Definition:
MeasureManager.cs:16
HoloToolkit.Examples.GazeRuler.GeometryMode.Cube
UnityEngine
HoloToolkit.Examples.GazeRuler.GeometryMode
GeometryMode
Definition:
MeasureManager.cs:122
HoloToolkit.Examples.GazeRuler.MeasureManager.Mode
GeometryMode Mode
Definition:
MeasureManager.cs:19
HoloToolkit.Unity
HoloToolkit.Examples.GazeRuler.MeasureManager.OnModeChange
void OnModeChange()
Definition:
MeasureManager.cs:69
HoloToolkit.Unity.InputModule.SupportedInputInfo.Position
HoloToolkit.Unity.Singleton
Singleton behaviour class, used for components that should only have one instance.
Definition:
Singleton.cs:14
Assets
HoloToolkit-Examples
GazeRuler
Scripts
MeasureManager.cs
Generated by
1.8.12