forked from scamnasio/new_constellations
/
constellations.html
234 lines (205 loc) · 8.3 KB
/
constellations.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" content="chrome=1, IE=edge" http-equiv="X-UA-Compatible" />
<title>NCP</title>
<script src="http://www.worldwidetelescope.org/scripts/wwtsdk.aspx"></script>
<script>
// Create the WorldWide telescope object variable
var wwt;
var polyline1;
// Create variables to hold the changeable settings
var bShowCrosshairs = true;
var bShowUI = true;
var bShowFigures = true;
var bShowAnnotations = true;
var bShowPolyLine = false;
// This function initializes the wwt object and registers the wwtReady event
// once the initialization is done the wwtReady event will be fired
function initialize() {
wwt = wwtlib.WWTControl.initControl("WWTCanvas");
wwt.add_ready(wwtReady);
wwt.add_clicked(wwtClick);
// This ensures that events that would have fired before we registered them get fired
wwt.endInit();
}
// A simple function to toggle the settings
// This function is called from the checkbox entries setup in the html table
function toggleSetting(text) {
switch (text) {
case 'ShowUI':
bShowUI = !bShowUI;
wwt.hideUI(!bShowUI);
break;
case 'ShowCrosshairs':
bShowCrosshairs = !bShowCrosshairs;
wwt.settings.set_showCrosshairs(bShowCrosshairs);
break;
case 'ShowFigures':
bShowFigures = !bShowFigures;
wwt.settings.set_showConstellationFigures(bShowFigures);
break;
case 'ShowPolyLine':
bShowPolyLine = !bShowPolyLine;
if (bShowPolyLine) {
wwt.addAnnotation(polyline1);
} else {
wwt.removeAnnotation(polyline1);
}
break;
case 'ShowAlerts':
bShowAlerts = !bShowAlerts;
break;
}
}
// A function to change the view to different constellations
// This function is called from the button entries in the html table
function GotoConstellation(text) {
switch (text) {
case 'Sagittarius':
wwt.gotoRaDecZoom(286.485, -27.5231666666667, 60, false);
break;
case 'Aquarius':
wwt.gotoRaDecZoom(334.345, -9.21083333333333, 60, false);
break;
case 'Camelopardalis':
wwt.gotoRaDecZoom(90.0, 72.000, 100, false);
break;
case 'Vulpecula':
wwt.gotoRaDecZoom(303.47, 24.4426666666667, 100, false);
break;
}
}
// A function to create a polyline object
function createWWTPolyLine(lineColor, lineWidth, opacity, points) {
var polyline = wwt.createPolyLine(true);
polyline.set_lineColor(lineColor);
polyline.set_lineWidth(lineWidth);
polyline.set_opacity(opacity);
for (var i in points) {
polyline.addPoint(points[i][0], points[i][1]);
}
return polyline;
}
// A function to create a circle, and return a reference to the circle
var circleCount = 0;
function createWWTCircle(fill, lineColor, fillColor, lineWidth, opacity, radius, skyRelative, ra, dec) {
var circle = wwt.createCircle(fill);
circleCount++;
circle.set_id("Circle" + circleCount.toString());
circle.set_lineColor(lineColor);
circle.set_fillColor(fillColor);
circle.set_lineWidth(lineWidth);
circle.set_opacity(opacity);
circle.set_radius(radius);
circle.set_skyRelative(skyRelative);
circle.setCenter(ra, dec);
return circle;
}
// Simple function to clear all the annotations from the view
function clearAnnotations() {
wwt.clearAnnotations();
}
// Function that responds to the mouse click event
function wwtClick(obj, eventArgs) {
if (bShowPolyline) {
var points = [[,]];
var myPolyline = createWWTPolyLine("#01DFD7", 2, 1.0, points);
}
if (bShowAlerts){
alert("Click at " + eventArgs.get_RA().toString() + ", " + eventArgs.get_dec().toString());
}
}
// The following function will add any number of points [ra, dec] to a polyline.
function expandPolyLine(polyline, newPoints){
for (var i in newPoints){
polyline.addPoint(newPoints[i][0], newPoints[i][1]);
}
}
var polyline1 = wwtView.createPolyLine();
var points = [[123,-120], [220,-111]];
expandPolyLine(polyline1, points);
// The wwtReady function is called by the WWT Web Control software
// This function sets up the wwt object, and the initial defaults
// This function sets up the wwt object, and the initial defaults
function wwtReady() {
wwt.settings.set_showCrosshairs(bShowCrosshairs);
wwt.settings.set_showConstellationFigures(bShowFigures);
wwt.hideUI(!bShowUI);
wwt.settings.set_showConstellationBoundries(true);
// Create a polyline, with a fork at [300, -17]
var points1 = [[,]];
polyline1 = createWWTPolyLine("blue", 2, 1.0, points1);
polyline1.set_id("polyline1");
}
</script>
</head>
<body onload="initialize()" >
<!-- The body section creates a table with two columns. The first contains the -->
<!-- canvas object that the WWT web client uses as the render target. And the second a table within-->
<!-- the table, containing some buttons and checkboxes.-->
<table border="0" bgcolor="black">
<tr><td>
<div id="WorldWideTelescopeControlHost">
<div id="WWTCanvas" style="width: 1000px; height: 650px; border-style: none; border-width: 0px;">
</div>
</div>
</td><td>
<table border="0" cellspacing="4" cellpadding="4" bgcolor="D3D3D3">
<tr>
<th colspan="2"><h2 style="font-family:lucida grande">The New Constellations Project</h2></th>
</tr>
<tr>
<th colspan="2"><h5 style="font-family:lucida grande">Re-invent the constellations! Click to select a starting object and connect stars in the sky to create your own constellations.</h5></th>
</tr>
<!-- <tr>
<form action="demo_form.asp">
<select name="cars">
<option value="Go to Saggitarius">Go </option>
<option value="saab">Saab 95</option>
<option value="mercedes">Mercedes SLK</option>
<option value="audi">Audi TT</option>
</select>
<input type="submit" value="Submit">
</form>
</tr>-->
<tr>
<th colspan = "2">
<input type="button" id="Sagittarius" value="Go to Sagittarius" onclick="GotoConstellation('Sagittarius')"/>
<input type="button" id="Aquarius" value="Go to Aquarius" onclick="GotoConstellation('Aquarius')"/></th>
</tr>
<tr>
<th colspan = "2">
<input type="button" id="Camelopardalis" value="Go to Camelopardalis" onclick="GotoConstellation('Camelopardalis')"/>
<input type="button" id="Vulpecula" value="Go to Vulpecula" onclick="GotoConstellation('Vulpecula')"/></th>
</tr>
<!-- <tr>
<td> Show UI </td>
<td> <input id="UI" type="checkbox" checked="checked" onclick="toggleSetting('ShowUI');"/></td>
</tr>-->
<tr>
<td style="font-family:lucida grande"> Show Center Crosshairs</td>
<td> <input id="Crosshairs" type="checkbox" checked="checked" onclick="toggleSetting('ShowCrosshairs');"/></td>
</tr>
<tr>
<td style="font-family:lucida grande"> Show AIU Current Constellations </td>
<td> <input id="Figures" type="checkbox" checked="checked" onclick="toggleSetting('ShowFigures');"/></td>
</tr>
<tr>
<td style="font-family:lucida grande"> Show Line </td>
<td> <input id="PolyLine" type="checkbox" onclick="toggleSetting('ShowPolyLine');"/></td>
</tr>
<tr>
<!-- <td style="font-family:lucida grande"> Show Alerts </td>
<td> <input id="alerts" type="checkbox" onclick="toggleSetting('ShowAlerts');"/></td>
</tr> -->
<tr>
<td style="font-family:lucida grande"> Clear all the current figures</td>
<td> <input id="clear" type="button" value="Clear" onclick="clearAnnotations();"/></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>