shift presets
This commit is contained in:
parent
8033e98f20
commit
aa856e2404
|
@ -110,7 +110,7 @@ class API(object):
|
|||
def camera(self, **data):
|
||||
result = {}
|
||||
for key, value in data.items():
|
||||
getattr(ctl.camera, key)(**value)
|
||||
result[key] = getattr(ctl.camera, key)(**value)
|
||||
return result
|
||||
|
||||
def run(self, **data):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>CAMP can capture canals</title>
|
||||
<link rel="stylesheet" href="static/sg/slick.grid.css" type="text/css"/>
|
||||
<link rel="stylesheet" href="static/sg/css/smoothness/jquery-ui-1.8.16.custom.css" type="text/css"/>
|
||||
|
@ -104,6 +104,7 @@
|
|||
<h2>Import:</h2>
|
||||
<li><input class="import_sequence" type="file">import sequence</input></li>
|
||||
<li><input class="import_presets" type="file">import presets</input></li>
|
||||
<li><button class="shift_presets">shift presets</button></li>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -122,5 +123,10 @@
|
|||
<script src="static/sg/slick.grid.js"></script>
|
||||
|
||||
<script src="static/js/cccc.js"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
init()
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -53,16 +53,20 @@ if (value == null || value == undefined || !value.length || !isInt(value)) {
|
|||
|
||||
var presets = [];
|
||||
|
||||
function presetSelect() {
|
||||
var options = ''
|
||||
presets.forEach(function(preset) {
|
||||
options += '<option value="'+preset.id+'">' + preset.id + ': ' + preset.name + '</option>';
|
||||
})
|
||||
return $('<select name="preset-editor">' + options + '</select>')
|
||||
}
|
||||
|
||||
function PresetEditor(args) {
|
||||
var $preset;
|
||||
var scope = this;
|
||||
|
||||
this.init = function () {
|
||||
var options = ''
|
||||
presets.forEach(function(preset) {
|
||||
options += '<option value="'+preset.id+'">' + preset.id + ': ' + preset.name + '</option>';
|
||||
})
|
||||
$preset = $('<select name="preset-editor">' + options + '</select>')
|
||||
$preset = presetSelect()
|
||||
.appendTo(args.container);
|
||||
scope.focus();
|
||||
};
|
||||
|
@ -353,14 +357,28 @@ function updateStatus() {
|
|||
$('button.delete').attr({disabled: !gotSelection})
|
||||
}
|
||||
|
||||
$(function () {
|
||||
api('getPresets', {}, function(response) {
|
||||
presets = response.result.presets
|
||||
loadData(JSON.parse(localStorage.sequence || '[]'))
|
||||
updateStatus()
|
||||
setInterval(updateStatus, 1000)
|
||||
|
||||
var preset_offset = {}, current_position = {};
|
||||
|
||||
function updateShiftStatus() {
|
||||
api('camera', {
|
||||
'status': {}
|
||||
}, function(response) {
|
||||
if (response.result) {
|
||||
if (response.result.status) {
|
||||
current_position = response.result.status;
|
||||
var preset = presets[parseInt($('select[name=preset-editor]').val(), 10)];
|
||||
preset_offset['azimuth'] = preset['position']['azimuth'] - current_position['azimuth'];
|
||||
preset_offset['elevation'] = preset['position']['elevation'] - current_position['elevation'];
|
||||
preset_offset['absoluteZoom'] = preset['position']['absoluteZoom'] - current_position['absoluteZoom'];
|
||||
updateDelta()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
function updateDelta() {
|
||||
$('#delta').html(JSON.stringify(preset_offset, null, ' '))
|
||||
}
|
||||
|
||||
function deleteRows() {
|
||||
var result = confirm("Are you sure you want to delete " + grid.getSelectedRows().length + " row(s)?");
|
||||
|
@ -480,6 +498,10 @@ $('button.export_presets').on({click: function() {
|
|||
href: url, download: 'presets.json'
|
||||
});
|
||||
}})
|
||||
$('button.shift_presets').on({click: function() {
|
||||
document.location.href = '/static/shift_presets.html';
|
||||
}});
|
||||
|
||||
$('button.all_presets').on({click: function() {
|
||||
api('getPresets', {}, function(response) {
|
||||
presets = response.result.presets
|
||||
|
@ -518,3 +540,59 @@ $('input.import_presets').on({change: function() {
|
|||
}
|
||||
reader.readAsText(this.files[0]);
|
||||
}})
|
||||
|
||||
|
||||
function shiftPresets(offset, callback) {
|
||||
api('getPresets', {}, function(response) {
|
||||
presets = response.result.presets
|
||||
presets.forEach(function(preset) {
|
||||
if (offset.azimuth) {
|
||||
preset['position']['azimuth'] += offset.azimuth
|
||||
}
|
||||
if (offset.elevation) {
|
||||
preset['position']['elevation'] += offset.elevation
|
||||
}
|
||||
if (offset.absoluteZoom) {
|
||||
preset['position']['absoluteZoom'] += offset.absoluteZoom
|
||||
}
|
||||
})
|
||||
api('setPresets', {
|
||||
'presets': presets
|
||||
}, function(response) {
|
||||
presets = response.result.presets
|
||||
callback && callback()
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function init() {
|
||||
api('getPresets', {}, function(response) {
|
||||
presets = response.result.presets
|
||||
loadData(JSON.parse(localStorage.sequence || '[]'))
|
||||
updateStatus()
|
||||
setInterval(updateStatus, 1000)
|
||||
})
|
||||
}
|
||||
|
||||
function init_shift() {
|
||||
api('getPresets', {}, function(response) {
|
||||
presets = response.result.presets
|
||||
presetSelect().on({
|
||||
change: updateShiftStatus
|
||||
}).appendTo($('body'))
|
||||
$('<pre>').attr({id: 'delta'}).appendTo($('body'))
|
||||
$('<button>').html('Shift All Presets')
|
||||
.appendTo($('body')).on({
|
||||
click: function() {
|
||||
$('body').html('updating presets...')
|
||||
shiftPresets(preset_offset, function() {
|
||||
document.location.href = '/'
|
||||
})
|
||||
}
|
||||
})
|
||||
updateShiftStatus()
|
||||
setInterval(updateShiftStatus, 5000)
|
||||
})
|
||||
|
||||
}
|
||||
|
|
33
static/shift_presets.html
Normal file
33
static/shift_presets.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>CAMP can capture canals</title>
|
||||
<link rel="stylesheet" href="/static/sg/css/smoothness/jquery-ui-1.8.16.custom.css" type="text/css"/>
|
||||
<style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script src="/static/sg/lib/jquery-1.7.min.js"></script>
|
||||
<script src="/static/sg/lib/jquery-ui-1.8.16.custom.min.js"></script>
|
||||
<script src="/static/sg/lib/jquery.event.drag-2.2.js"></script>
|
||||
<script src="/static/sg/lib/jquery.event.drop-2.2.js"></script>
|
||||
<script src="/static/sg/slick.core.js"></script>
|
||||
<script src="/static/sg/plugins/slick.cellrangedecorator.js"></script>
|
||||
<script src="/static/sg/plugins/slick.cellrangeselector.js"></script>
|
||||
<script src="/static/sg/plugins/slick.cellselectionmodel.js"></script>
|
||||
<script src="/static/sg/plugins/slick.rowmovemanager.js"></script>
|
||||
<script src="/static/sg/slick.formatters.js"></script>
|
||||
<script src="/static/sg/slick.editors.js"></script>
|
||||
<script src="/static/sg/slick.grid.js"></script>
|
||||
|
||||
<script src="/static/js/cccc.js"></script>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
init_shift()
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user