|
@@ -39,12 +39,12 @@ function SingleImageView(option) {
|
|
this.image = undefined;
|
|
this.image = undefined;
|
|
this.render();
|
|
this.render();
|
|
});
|
|
});
|
|
- this.markControl.on('mark.tag.show', this, function(event, context, tag){
|
|
|
|
- if(this.task != undefined && tag != undefined){
|
|
|
|
- this.drawTag(tag);
|
|
|
|
|
|
+ this.markControl.on('mark.tag.show', this, function(event, context, tag) {
|
|
|
|
+ if (this.task != undefined && tag != undefined) {
|
|
|
|
+ this.drawTag(tag);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- this.markControl.on('mark.tag.clear', this, function(event, context, track){
|
|
|
|
|
|
+ this.markControl.on('mark.tag.clear', this, function(event, context, track) {
|
|
this.reloadImage();
|
|
this.reloadImage();
|
|
this.markControl.trigger('image.reload.event');
|
|
this.markControl.trigger('image.reload.event');
|
|
});
|
|
});
|
|
@@ -53,37 +53,45 @@ function SingleImageView(option) {
|
|
this.updateScrollTop(topPercent);
|
|
this.updateScrollTop(topPercent);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ this.markControl.on('mark.setting.init', this, function(event, context, setting) {
|
|
|
|
+ var scale = setting['image.view.scale'];
|
|
|
|
+ if (scale != undefined) {
|
|
|
|
+ this.scale = Number(scale);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
SingleImageView.prototype.init = function() {
|
|
SingleImageView.prototype.init = function() {
|
|
var self = this;
|
|
var self = this;
|
|
this.container = this.markControl.container.imageContent;
|
|
this.container = this.markControl.container.imageContent;
|
|
this.container.height(this.markControl.container.centerContent.height());
|
|
this.container.height(this.markControl.container.centerContent.height());
|
|
- this.container.css('overflow','scroll');
|
|
|
|
-
|
|
|
|
|
|
+ this.container.css('overflow', 'scroll');
|
|
|
|
+
|
|
this.canvas = $('<canvas></canvas>').appendTo(this.container)[0];
|
|
this.canvas = $('<canvas></canvas>').appendTo(this.container)[0];
|
|
this.ctx = this.canvas.getContext("2d");
|
|
this.ctx = this.canvas.getContext("2d");
|
|
-
|
|
|
|
- $(this.canvas).click(function(event){
|
|
|
|
- if(self.task != undefined){
|
|
|
|
- self.markControl.trigger('image.click.event', {
|
|
|
|
- positionX: ((event.pageX - $(self.canvas).offset().left)/$(self.canvas).width()).toFixed(3),
|
|
|
|
- positionY: ((event.pageY - $(self.canvas).offset().top)/$(self.canvas).height()).toFixed(3)
|
|
|
|
- });
|
|
|
|
|
|
+ this.ctx.fillStyle = "#FFFFFF";
|
|
|
|
+ this.scale = 1.0;
|
|
|
|
+
|
|
|
|
+ $(this.canvas).click(function(event) {
|
|
|
|
+ if (self.task != undefined) {
|
|
|
|
+ self.markControl.trigger('image.click.event', {
|
|
|
|
+ positionX: ((event.pageX - $(self.canvas).offset().left) / $(self.canvas).width()).toFixed(3),
|
|
|
|
+ positionY: ((event.pageY - $(self.canvas).offset().top) / $(self.canvas).height()).toFixed(3)
|
|
|
|
+ });
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+
|
|
this.imageControl = getDom(this.image_control_dom, this.markControl).insertBefore(this.markControl.container.assistantButton.parent());
|
|
this.imageControl = getDom(this.image_control_dom, this.markControl).insertBefore(this.markControl.container.assistantButton.parent());
|
|
this.imageControl.find('.zoom-out-button').click(this, function(event) {
|
|
this.imageControl.find('.zoom-out-button').click(this, function(event) {
|
|
- self.reloadImage(0.2);
|
|
|
|
|
|
+ self.reloadImage(0.2);
|
|
self.markControl.trigger('image.reload.event');
|
|
self.markControl.trigger('image.reload.event');
|
|
});
|
|
});
|
|
this.imageControl.find('.zoom-in-button').click(this, function(event) {
|
|
this.imageControl.find('.zoom-in-button').click(this, function(event) {
|
|
- self.reloadImage(-0.2);
|
|
|
|
|
|
+ self.reloadImage(-0.2);
|
|
self.markControl.trigger('image.reload.event');
|
|
self.markControl.trigger('image.reload.event');
|
|
});
|
|
});
|
|
this.imageControl.find('.zoom-fit-button').click(this, function(event) {
|
|
this.imageControl.find('.zoom-fit-button').click(this, function(event) {
|
|
- self.reloadImage();
|
|
|
|
|
|
+ self.reloadImage('fit');
|
|
self.markControl.trigger('image.reload.event');
|
|
self.markControl.trigger('image.reload.event');
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -95,42 +103,48 @@ SingleImageView.prototype.render = function() {
|
|
//设置画布大小及背景颜色
|
|
//设置画布大小及背景颜色
|
|
this.image = new Image();
|
|
this.image = new Image();
|
|
this.image.src = this.task.imageData;
|
|
this.image.src = this.task.imageData;
|
|
- this.image.scale = 1.0;
|
|
|
|
- this.image.onload = function(){
|
|
|
|
- self.canvas.width = Math.min(self.container.width(), self.image.width);
|
|
|
|
- self.canvas.height = self.canvas.width * self.image.height / self.image.width;
|
|
|
|
- self.ctx.fillStyle = "#FFFFFF";
|
|
|
|
- self.ctx.drawImage(self.image, 0, 0, self.image.width, self.image.height, 0, 0, self.canvas.width, self.canvas.height);
|
|
|
|
|
|
+ this.image.onload = function() {
|
|
|
|
+ self.reloadImage();
|
|
$(self.canvas).show();
|
|
$(self.canvas).show();
|
|
-
|
|
|
|
|
|
+
|
|
self.markControl.trigger('task.load.finish');
|
|
self.markControl.trigger('task.load.finish');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-SingleImageView.prototype.reloadImage = function(scale) {
|
|
|
|
- if(this.image != undefined){
|
|
|
|
- if(scale != undefined){
|
|
|
|
- this.image.scale = this.image.scale + scale;
|
|
|
|
- if(this.image.scale < 0.2){
|
|
|
|
- this.image.scale = 0.2;
|
|
|
|
- }else if(this.image.scale > 3){
|
|
|
|
- this.image.scale = 3;
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- this.image.scale = 1.0;
|
|
|
|
- }
|
|
|
|
- this.canvas.width = Math.min(this.container.width(), this.image.width) * this.image.scale;
|
|
|
|
|
|
+SingleImageView.prototype.reloadImage = function(scaleAddon) {
|
|
|
|
+ if (this.image != undefined) {
|
|
|
|
+ var scale = this.scale;
|
|
|
|
+ if (scaleAddon != undefined) {
|
|
|
|
+ if (scaleAddon=='fit') {
|
|
|
|
+ scale = 1.0;
|
|
|
|
+ } else {
|
|
|
|
+ scale += scaleAddon;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (scale < 0.2) {
|
|
|
|
+ scale = 0.2;
|
|
|
|
+ } else if (scale > 3) {
|
|
|
|
+ scale = 3;
|
|
|
|
+ }
|
|
|
|
+ if (scale != this.scale) {
|
|
|
|
+ this.markControl.trigger('mark.setting.change', {
|
|
|
|
+ 'image.view.scale': scale
|
|
|
|
+ });
|
|
|
|
+ this.scale = scale;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.canvas.width = Math.min(this.container.width(), this.image.width) * this.scale;
|
|
this.canvas.height = this.canvas.width * this.image.height / this.image.width;
|
|
this.canvas.height = this.canvas.width * this.image.height / this.image.width;
|
|
this.ctx.drawImage(this.image, 0, 0, this.image.width, this.image.height, 0, 0, this.canvas.width, this.canvas.height);
|
|
this.ctx.drawImage(this.image, 0, 0, this.image.width, this.image.height, 0, 0, this.canvas.width, this.canvas.height);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-SingleImageView.prototype.drawTag = function(tag){
|
|
|
|
- if(tag!=undefined && tag.positionX>0 && tag.positionY>0 && this.image!=undefined){
|
|
|
|
- this.ctx.font = parseInt(60 * this.image.scale) + "px Arial";
|
|
|
|
|
|
+SingleImageView.prototype.drawTag = function(tag) {
|
|
|
|
+ if (tag != undefined && tag.positionX > 0 && tag.positionY > 0 && this.image != undefined) {
|
|
|
|
+ this.ctx.font = parseInt(60 * this.scale) + "px Arial";
|
|
this.ctx.fillStyle = 'red';
|
|
this.ctx.fillStyle = 'red';
|
|
- this.ctx.fillText(tag.content, tag.positionX*this.canvas.width, tag.positionY*this.canvas.height);
|
|
|
|
|
|
+ this.ctx.fillText(tag.content, tag.positionX * this.canvas.width, tag.positionY * this.canvas.height);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|