Implement bare-bones WWT widget
This commit is contained in:
Родитель
1a4ca19c21
Коммит
b41af04a64
|
@ -58,3 +58,5 @@ distribute-*.tar.gz
|
|||
|
||||
# Mac OSX
|
||||
.DS_Store
|
||||
|
||||
js/node_modules
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var widgets = require('@jupyter-widgets/base');
|
||||
var _ = require("underscore");
|
||||
|
||||
var wwtmodule = require('./wwtsdk.js');
|
||||
|
||||
var WWTModel = widgets.DOMWidgetModel.extend({
|
||||
defaults: _.extend(widgets.DOMWidgetModel.prototype.defaults(), {
|
||||
|
@ -15,22 +16,28 @@ var WWTModel = widgets.DOMWidgetModel.extend({
|
|||
|
||||
var WWTView = widgets.DOMWidgetView.extend({
|
||||
|
||||
// initialize : function() {
|
||||
//
|
||||
// console.log("INITIALIZING");
|
||||
//
|
||||
// this.div1 = document.createElement("div");
|
||||
// this.div1.setAttribute("id", "WorldWideTelescopeControlHost")
|
||||
//
|
||||
// this.div2 = document.createElement("div");
|
||||
// this.div2.setAttribute("id", "UI")
|
||||
//
|
||||
// this.div3 = document.createElement("div");
|
||||
// this.div3.setAttribute("id", "WWTCanvas")
|
||||
//
|
||||
// WWTView.__super__.initialize.apply(this, arguments);
|
||||
//
|
||||
// },
|
||||
initialize : function() {
|
||||
|
||||
var div = document.createElement("div");
|
||||
div.setAttribute("id", "WWTCanvas");
|
||||
div.setAttribute("style", "width: 640px; height: 480px; border-style: none; border-width: 0px;")
|
||||
this.el.appendChild(div);
|
||||
|
||||
WWTView.__super__.initialize.apply(this, arguments);
|
||||
|
||||
this.wwt = wwtlib.WWTControl.initControl(div);
|
||||
this.wwt.add_ready(this.wwtReady);
|
||||
|
||||
},
|
||||
|
||||
wwtReady: function() {
|
||||
this.loadImageCollection('http://www.worldwidetelescope.org/wwtweb/catalog.aspx?W=surveys');
|
||||
this.settings.set_showConstellationBoundries(false);
|
||||
this.settings.set_showConstellationFigures(false);
|
||||
this.setForegroundImageByName('Digitized Sky Survey (Color)');
|
||||
this.setBackgroundImageByName('SFD Dust Map (Infrared)');
|
||||
this.setForegroundOpacity(0.5);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.model.on('msg:custom', this.handle_custom_message, this);
|
||||
|
@ -38,9 +45,11 @@ var WWTView = widgets.DOMWidgetView.extend({
|
|||
|
||||
handle_custom_message: function(msg) {
|
||||
console.log(msg);
|
||||
if (msg['event'] == 'center_on_coordinates') {
|
||||
this.wwt.gotoRaDecZoom(msg['ra'], msg['dec'], msg['fov'], msg['instant']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -29,6 +29,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@jupyter-widgets/base": "^1.0.0",
|
||||
"lodash": "^4.17.4"
|
||||
"concat-stream": "^1.6.0",
|
||||
"jquery": "^1.8.3",
|
||||
"lodash": "^4.17.4",
|
||||
"mock-browser": "^0.92.14"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import ipywidgets as widgets
|
||||
from traitlets import Unicode
|
||||
from traitlets import Unicode, default
|
||||
|
||||
from .model import WWTModel
|
||||
|
||||
|
@ -14,6 +14,10 @@ class JupyterWWTWidget(widgets.DOMWidget, WWTModel):
|
|||
_view_module_version = Unicode('^0.1.0').tag(sync=True)
|
||||
_model_module_version = Unicode('^0.1.0').tag(sync=True)
|
||||
|
||||
@default('layout')
|
||||
def _default_layout(self):
|
||||
return widgets.Layout(height='480px', align_self='stretch')
|
||||
|
||||
def send_msg(self, **kwargs):
|
||||
print("SEND", kwargs)
|
||||
self.send(kwargs)
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
}
|
||||
|
||||
function wwtReady() {
|
||||
initForWwt();
|
||||
wwt.loadImageCollection('http://www.worldwidetelescope.org/wwtweb/catalog.aspx?W=surveys');
|
||||
wwt.settings.set_showConstellationBoundries(false);
|
||||
wwt.settings.set_showConstellationFigures(false);
|
||||
|
@ -44,8 +43,6 @@
|
|||
wwt_ready = 1;
|
||||
}
|
||||
|
||||
function initForWwt() {}
|
||||
|
||||
function wwt_receive_message(msg) {
|
||||
if (msg['event'] == 'center_on_coordinates') {
|
||||
wwt.gotoRaDecZoom(msg['ra'], msg['dec'], msg['fov'], msg['instant']);
|
||||
|
@ -57,11 +54,6 @@
|
|||
</head>
|
||||
|
||||
<body onload="initialize()">
|
||||
|
||||
<div id="WorldWideTelescopeControlHost">
|
||||
<div id="UI" style="border-style: none; border-width: 0px; background-color: #000000"></div>
|
||||
|
||||
|
||||
<div id="WWTCanvas" style="width: 100; height: 100; border-style: none; border-width: 0px;"></div>
|
||||
</div>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче