Skip to content

Commit

Permalink
Release v0.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
lucalianas committed Nov 23, 2016
2 parents 490f44a + b6b4556 commit 8c3ac4a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/js/annotations_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ function AnnotationsController(canvas_id, default_config) {
if (canvas.length === 0) {
console.log('Creating a new canvas');
// create a canvas that will be used by paper.js
var canvas_size = viewport_controller.getCanvasSize();
$("body").append("<canvas id='" + this.canvas_id + "'></canvas>");
canvas.attr("width", canvas_size.width)
.attr("height", canvas_size.height);
this.canvas = canvas[0];
} else {
console.log('Using an existing canvas');
this.canvas = canvas[0];
}
var canvas_size = viewport_controller.getCanvasSize();
$(this.canvas).width(canvas_size.width)
.height(canvas_size.height);

this.paper_scope.setup(this.canvas);
// clean the canvas
Expand Down Expand Up @@ -421,8 +421,8 @@ function AnnotationsController(canvas_id, default_config) {
this.drawLine = function(shape_id, from_x, from_y, to_x, to_y, transform,
shape_conf, refresh_view) {
var points = [
{'x': from_x, 'y': from_y},
{'x': to_x, 'y': to_y}
{'point': {'x': from_x, 'y': from_y}},
{'point': {'x': to_x, 'y': to_y}}
];
this.drawPolyline(shape_id, points, transform, shape_conf, refresh_view);
};
Expand Down
30 changes: 30 additions & 0 deletions src/js/viewport_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,35 @@ function ViewerController(div_id, prefix_url, tile_sources, viewer_config, image
var img_zoom = event.eventSource.viewport_controller.getImageZoom();
event.eventSource.annotations_controller.setZoom(img_zoom);
});

this.viewer.addHandler('resize', function (event) {
var vctrl = event.eventSource.viewport_controller;
var actrl = event.eventSource.annotations_controller;

// get existing shapes and existing markers
var shapes = actrl.getShapesJSON();
if (actrl.getMarkersID) {
var markers_ids = actrl.getMarkersID();
} else {
var markers_ids = [];
}

// clear and rebuild canvas
actrl.clear();
actrl.canvas = undefined;
actrl.buildAnnotationsCanvas(vctrl);

// update zoom level and center of the canvas
var zoom = vctrl.getImageZoom();
actrl.setZoom(zoom);
var center = vctrl.getCenter();
actrl.setCenter(center.x, center.y);

// redraw shapes
actrl.drawShapesFromJSON(shapes);
if (markers_ids.length > 0) {
actrl.shapesToMarkers(markers_ids);
}
});
};
}
25 changes: 18 additions & 7 deletions templates/ome_seadragon/test/test_ome_roi.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
<meta charset="UTF-8">
<title>OPENSEADRAGON TEST VIEWER WITH ANNOTATIONS</title>

<link href="{{ host_name }}/static/ome_seadragon/css/bootstrap.min.css" rel="stylesheet">

<style type="text/css">
.container {
#graphic_container {
position: relative;
padding: 0;
}

.graphic_element {
width: 800px;
height: 600px;
width:100%;
height: 10px;
position: absolute;
padding: inherit;
}
</style>

Expand All @@ -28,6 +32,11 @@
$.get("{{ host_name }}/ome_seadragon/deepzoom/image_mpp/{{ image_id }}.dzi").done(function(data) {
console.log("Loading openseadragon viewer");

$("#openseadragon_viewer").height($(window).height() - 60);
$(window).resize(function() {
$('#openseadragon_viewer').height($(window).height() - 60);
});

var viewer_config = {
'showNavigator': true,
'showFullPageControl': false,
Expand Down Expand Up @@ -118,10 +127,12 @@
</script>
</head>
<body>
<div id="toolbar" style="height: 40px"></div>
<div id="graphics_container" class="container">
<div id="openseadragon_viewer" class="graphic_element"></div>
<canvas id="annotations_canvas" class="graphic_element"></canvas>
<div class="container-fluid">
<div id="toolbar" style="height: 40px"></div>
<div id="graphic_container" class="col-md-12">
<div id="openseadragon_viewer" class="graphic_element"></div>
<canvas id="annotations_canvas" class="graphic_element"></canvas>
</div>
</div>
</body>
</html>

0 comments on commit 8c3ac4a

Please sign in to comment.