From: <dev...@us...> - 2016-07-29 07:15:25
|
Revision: 18634 http://sourceforge.net/p/dcm4che/svn/18634 Author: devishree Date: 2016-07-29 07:15:22 +0000 (Fri, 29 Jul 2016) Log Message: ----------- OV-153 Move after rotation isn't working properly - Applied the rotations and flips to the thumbnail preview in the image pane Modified Paths: -------------- oviyam/oviyam/trunk/web/js/framecontent.js oviyam/oviyam/trunk/web/js/toolactivator.js Modified: oviyam/oviyam/trunk/web/js/framecontent.js =================================================================== --- oviyam/oviyam/trunk/web/js/framecontent.js 2016-07-29 07:05:35 UTC (rev 18633) +++ oviyam/oviyam/trunk/web/js/framecontent.js 2016-07-29 07:15:22 UTC (rev 18634) @@ -195,8 +195,8 @@ showImg(null,image,true); } -function showImg(imgSrc,image,updatePreview) { - var image = imgSrc!=null ? jQuery('#'+imgSrc.replace(/\./g,'_'), window.parent.document).get(0) : image; +function showImg(imgSrc,img,updatePreview) { + var image = imgSrc!=null ? jQuery('#'+imgSrc.replace(/\./g,'_'), window.parent.document).get(0) : img; if(image.src.indexOf('rawdata.png')>=0) { throw 'rawdata'; return; @@ -206,25 +206,35 @@ ctx.save(); ctx.setTransform(1,0,0,1,0,0); - ctx.clearRect(0,0,canvas.width,canvas.height); - ctx.translate(state.translationX, state.translationY); - + ctx.clearRect(0,0,canvas.width,canvas.height); + + var translate = true; + if(jQuery("#tool").html()=="move") { + ctx.translate(state.translationX, state.translationY); + translate = false; + } + if(state.vflip) { ctx.translate(0,canvas.height); ctx.scale(1,-1); } - + if(state.hflip) { ctx.translate(canvas.width,0); ctx.scale(-1,1); } - + if(state.rotate!=0) { ctx.translate(canvas.width/2,canvas.height/2); ctx.rotate(state.rotate===90 ? Math.PI/2 : state.rotate===180? Math.PI : (Math.PI*3)/2); ctx.translate(-canvas.width/2,-canvas.height/2); - } - ctx.scale(state.scale,state.scale); + } + + if(translate) { + ctx.translate(state.translationX, state.translationY); + } + ctx.scale(state.scale,state.scale); + ctx.drawImage(image,0,0); ctx.restore(); @@ -614,11 +624,43 @@ previewCanvas.width = highlightCanvas.width = getScreenNavImageWidth(); previewCanvas.height = highlightCanvas.height = getScreenNavImageHeight(); var context = previewCanvas.getContext('2d'); - context.drawImage(image,0,0,getScreenNavImageWidth(),getScreenNavImageHeight()); + //context.drawImage(image,0,0,getScreenNavImageWidth(),getScreenNavImageHeight()); + drawPreview(document.getElementById("previewCanvas"), image); drawoutline(); addNavigationListener(highlightCanvas); } +/** + * Renders preview image in preview canvase + * @param canvas Preview canvas + * @param image Preview image + */ +function drawPreview(canvas,image) { + var context = canvas.getContext('2d'); + context.save(); + context.setTransform(1,0,0,1,0,0); + context.clearRect(0,0,canvas.width,canvas.height); + if(state.vflip) { + context.translate(0,canvas.height); + context.scale(1,-1); + } + if(state.hflip) { + context.translate(canvas.width,0); + context.scale(-1,1); + } + if(state.rotate!=0) { + context.translate(canvas.width/2,canvas.height/2); + context.rotate(state.rotate===90 ? Math.PI/2 : state.rotate===180? Math.PI : (Math.PI*3)/2); + context.translate(-canvas.width/2,-canvas.height/2); + } + context.drawImage(image,0,0,getScreenNavImageWidth(),getScreenNavImageHeight()); + context.restore(); + + if(state.invert) { + window.parent.doInvert(jQuery('#previewCanvas').get(0),false); + } +} + function getScreenNavImageWidth() { return parseInt(navState.scale*navState.width); } Modified: oviyam/oviyam/trunk/web/js/toolactivator.js =================================================================== --- oviyam/oviyam/trunk/web/js/toolactivator.js 2016-07-29 07:05:35 UTC (rev 18633) +++ oviyam/oviyam/trunk/web/js/toolactivator.js 2016-07-29 07:15:22 UTC (rev 18634) @@ -148,7 +148,7 @@ function activateVFlip(tool) { var image = seriesUid + "_" + imgInc; state.vflip = state.vflip? false : true; - showImg(image); + showImg(image,null,true); flipOrientationToVertical(); } @@ -162,7 +162,7 @@ function activateHFlip(tool) { var image = seriesUid + "_" + imgInc; state.hflip = state.hflip? false : true; - showImg(image); + showImg(image,null,true); flipOrientationToHorizontal(); } @@ -186,7 +186,7 @@ state.rotate = 90; break; } - showImg(image); + showImg(image,null,true); rotateLeftTextOverlay(); } @@ -206,7 +206,7 @@ if(state.rotate>=360) { state.rotate=0; } - showImg(image); + showImg(image,null,true); rotateRightTextOverlay(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |