diff options
Diffstat (limited to 'js/stage/stage.reel/stage.js')
-rwxr-xr-x[-rw-r--r--] | js/stage/stage.reel/stage.js | 96 |
1 files changed, 53 insertions, 43 deletions
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 9e2df5a2..44e14827 100644..100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js | |||
@@ -4,11 +4,10 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Component = require("montage/ui/component").Component; | 8 | Component = require("montage/ui/component").Component, |
9 | 9 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, | |
10 | var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; | 10 | vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; |
11 | var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; | ||
12 | 11 | ||
13 | exports.Stage = Montage.create(Component, { | 12 | exports.Stage = Montage.create(Component, { |
14 | 13 | ||
@@ -20,8 +19,6 @@ exports.Stage = Montage.create(Component, { | |||
20 | zoomFactor: {value : 1 }, | 19 | zoomFactor: {value : 1 }, |
21 | 20 | ||
22 | _canvasSelectionPrefs: { value: { "thickness" : 1.0, "color" : "#46a1ff" } }, | 21 | _canvasSelectionPrefs: { value: { "thickness" : 1.0, "color" : "#46a1ff" } }, |
23 | _editSymbolPrefs: { value: { "thickness" : 2.0, "color" : "#C61F00" } }, | ||
24 | |||
25 | _canvasDrawingPrefs: { value: { "thickness" : 1.0, "color" : "#000" } }, | 22 | _canvasDrawingPrefs: { value: { "thickness" : 1.0, "color" : "#000" } }, |
26 | drawingContextPreferences: { get: function() { return this._canvasDrawingPrefs; } }, | 23 | drawingContextPreferences: { get: function() { return this._canvasDrawingPrefs; } }, |
27 | 24 | ||
@@ -116,9 +113,6 @@ exports.Stage = Montage.create(Component, { | |||
116 | _userContentLeft: { value: 0 }, | 113 | _userContentLeft: { value: 0 }, |
117 | _userContentTop: { value: 0 }, | 114 | _userContentTop: { value: 0 }, |
118 | _userContentBorder: { value: 0 }, | 115 | _userContentBorder: { value: 0 }, |
119 | savedLeftScroll: { value: null }, | ||
120 | savedTopScroll: { value: null }, | ||
121 | |||
122 | 116 | ||
123 | documentRoot: { | 117 | documentRoot: { |
124 | get: function () { return this._documentRoot; }, | 118 | get: function () { return this._documentRoot; }, |
@@ -205,6 +199,7 @@ exports.Stage = Montage.create(Component, { | |||
205 | this._drawingCanvas.addEventListener("mousedown", this, false); | 199 | this._drawingCanvas.addEventListener("mousedown", this, false); |
206 | this._drawingCanvas.addEventListener("mouseup", this, false); | 200 | this._drawingCanvas.addEventListener("mouseup", this, false); |
207 | this._drawingCanvas.addEventListener("dblclick", this, false); | 201 | this._drawingCanvas.addEventListener("dblclick", this, false); |
202 | this._drawingCanvas.addEventListener("mousewheel", this, false); | ||
208 | 203 | ||
209 | // Hide the canvas | 204 | // Hide the canvas |
210 | this.hideCanvas(true); | 205 | this.hideCanvas(true); |
@@ -247,6 +242,8 @@ exports.Stage = Montage.create(Component, { | |||
247 | 242 | ||
248 | this._scrollLeft = this._iframeContainer.scrollLeft; | 243 | this._scrollLeft = this._iframeContainer.scrollLeft; |
249 | this._scrollTop = this._iframeContainer.scrollTop; | 244 | this._scrollTop = this._iframeContainer.scrollTop; |
245 | this.application.ninja.currentDocument.savedLeftScroll = this._iframeContainer.scrollLeft; | ||
246 | this.application.ninja.currentDocument.savedTopScroll = this._iframeContainer.scrollTop; | ||
250 | 247 | ||
251 | this.userContentBorder = parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border")); | 248 | this.userContentBorder = parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border")); |
252 | 249 | ||
@@ -261,7 +258,6 @@ exports.Stage = Montage.create(Component, { | |||
261 | this.application.ninja.toolsData.selectedToolInstance._configure(true); | 258 | this.application.ninja.toolsData.selectedToolInstance._configure(true); |
262 | 259 | ||
263 | this.addEventListener("change@appModel.show3dGrid", this, false); | 260 | this.addEventListener("change@appModel.show3dGrid", this, false); |
264 | |||
265 | } | 261 | } |
266 | }, | 262 | }, |
267 | 263 | ||
@@ -362,6 +358,16 @@ exports.Stage = Montage.create(Component, { | |||
362 | } | 358 | } |
363 | }, | 359 | }, |
364 | 360 | ||
361 | handleMousewheel: { | ||
362 | value: function(event) { | ||
363 | if(event._event.wheelDelta > 0) { | ||
364 | this._iframeContainer.scrollTop -= 20; | ||
365 | } else { | ||
366 | this._iframeContainer.scrollTop += 20; | ||
367 | } | ||
368 | } | ||
369 | }, | ||
370 | |||
365 | /** | 371 | /** |
366 | * Enables the MouseMove on Canvas | 372 | * Enables the MouseMove on Canvas |
367 | */ | 373 | */ |
@@ -524,8 +530,7 @@ exports.Stage = Montage.create(Component, { | |||
524 | drawUtils.updatePlanes(); | 530 | drawUtils.updatePlanes(); |
525 | 531 | ||
526 | //TODO Set this variable in the needs draw so that it does not have to be calculated again for each draw for selection change | 532 | //TODO Set this variable in the needs draw so that it does not have to be calculated again for each draw for selection change |
527 | if(this.application.ninja.selectedElements.length) | 533 | if(this.application.ninja.selectedElements.length) { |
528 | { | ||
529 | // drawUtils.drawSelectionBounds handles the single selection case as well, | 534 | // drawUtils.drawSelectionBounds handles the single selection case as well, |
530 | // so we don't have to special-case the single selection case. | 535 | // so we don't have to special-case the single selection case. |
531 | // TODO drawUtils.drawSelectionBounds expects an array of elements. | 536 | // TODO drawUtils.drawSelectionBounds expects an array of elements. |
@@ -533,8 +538,7 @@ exports.Stage = Montage.create(Component, { | |||
533 | // TODO to work on _element instead of re-creating a new Array here. | 538 | // TODO to work on _element instead of re-creating a new Array here. |
534 | var selArray = new Array(); | 539 | var selArray = new Array(); |
535 | 540 | ||
536 | for(var i = 0; this.application.ninja.selectedElements[i];i++) | 541 | for(var i = 0; this.application.ninja.selectedElements[i];i++) { |
537 | { | ||
538 | var curElement = this.application.ninja.selectedElements[i]._element; | 542 | var curElement = this.application.ninja.selectedElements[i]._element; |
539 | 543 | ||
540 | // Add element to array that is used to calculate 3d-bounding box of all elements | 544 | // Add element to array that is used to calculate 3d-bounding box of all elements |
@@ -567,7 +571,7 @@ exports.Stage = Montage.create(Component, { | |||
567 | * @params: x, y, w, h | 571 | * @params: x, y, w, h |
568 | */ | 572 | */ |
569 | draw3DSelectionRectangle: { | 573 | draw3DSelectionRectangle: { |
570 | value:function(x0,y0, x1,y1, x2,y2, x3,y3){ | 574 | value:function(x0,y0, x1,y1, x2,y2, x3,y3) { |
571 | // this.clearCanvas(); | 575 | // this.clearCanvas(); |
572 | this.clearDrawingCanvas(); | 576 | this.clearDrawingCanvas(); |
573 | this._drawingContext.strokeStyle = this._canvasDrawingPrefs.color; | 577 | this._drawingContext.strokeStyle = this._canvasDrawingPrefs.color; |
@@ -612,7 +616,7 @@ exports.Stage = Montage.create(Component, { | |||
612 | * Draws selection highlight and reg. point for a given element | 616 | * Draws selection highlight and reg. point for a given element |
613 | */ | 617 | */ |
614 | drawElementBoundingBox: { | 618 | drawElementBoundingBox: { |
615 | value: function(elt, editMode) { | 619 | value: function(elt) { |
616 | this.stageDeps.viewUtils.setViewportObj( elt ); | 620 | this.stageDeps.viewUtils.setViewportObj( elt ); |
617 | var bounds3D = this.stageDeps.viewUtils.getElementViewBounds3D( elt ); | 621 | var bounds3D = this.stageDeps.viewUtils.getElementViewBounds3D( elt ); |
618 | 622 | ||
@@ -623,18 +627,16 @@ exports.Stage = Montage.create(Component, { | |||
623 | // } | 627 | // } |
624 | 628 | ||
625 | var zoomFactor = 1; | 629 | var zoomFactor = 1; |
626 | if (this._viewport.style && this._viewport.style.zoom) | 630 | if (this._viewport.style && this._viewport.style.zoom) { |
627 | { | ||
628 | zoomFactor = Number(this._viewport.style.zoom); | 631 | zoomFactor = Number(this._viewport.style.zoom); |
629 | } | 632 | } |
633 | |||
630 | var tmpMat = this.stageDeps.viewUtils.getLocalToGlobalMatrix( elt ); | 634 | var tmpMat = this.stageDeps.viewUtils.getLocalToGlobalMatrix( elt ); |
631 | for (var j=0; j<4; j++) | 635 | for (var j=0; j<4; j++) { |
632 | { | ||
633 | var localPt = bounds3D[j]; | 636 | var localPt = bounds3D[j]; |
634 | var tmpPt = this.stageDeps.viewUtils.localToGlobal2(localPt, tmpMat); | 637 | var tmpPt = this.stageDeps.viewUtils.localToGlobal2(localPt, tmpMat); |
635 | 638 | ||
636 | if(zoomFactor !== 1) | 639 | if(zoomFactor !== 1) { |
637 | { | ||
638 | tmpPt = vecUtils.vecScale(3, tmpPt, zoomFactor); | 640 | tmpPt = vecUtils.vecScale(3, tmpPt, zoomFactor); |
639 | 641 | ||
640 | tmpPt[0] += this._scrollLeft*(zoomFactor - 1); | 642 | tmpPt[0] += this._scrollLeft*(zoomFactor - 1); |
@@ -644,13 +646,9 @@ exports.Stage = Montage.create(Component, { | |||
644 | } | 646 | } |
645 | 647 | ||
646 | // draw it | 648 | // draw it |
647 | if(editMode) { | 649 | this.context.strokeStyle = this._canvasSelectionPrefs.color; |
648 | this.context.strokeStyle = this._editSymbolPrefs.color; | 650 | this.context.lineWidth = this._canvasSelectionPrefs.thickness; |
649 | this.context.lineWidth = this._editSymbolPrefs.thickness; | 651 | |
650 | } else { | ||
651 | this.context.strokeStyle = this._canvasSelectionPrefs.color; | ||
652 | this.context.lineWidth = this._canvasSelectionPrefs.thickness; | ||
653 | } | ||
654 | 652 | ||
655 | this.context.beginPath(); | 653 | this.context.beginPath(); |
656 | 654 | ||
@@ -664,13 +662,6 @@ exports.Stage = Montage.create(Component, { | |||
664 | 662 | ||
665 | this.context.closePath(); | 663 | this.context.closePath(); |
666 | this.context.stroke(); | 664 | this.context.stroke(); |
667 | |||
668 | /** Bug #25 - Do Not Draw the Registration point anymore on the top left since it's assumed there. | ||
669 | this.context.beginPath(); | ||
670 | this.context.arc(bounds3D[0][0], bounds3D[0][1] , 5, 0, Math.PI*2, false); | ||
671 | this.context.stroke(); | ||
672 | */ | ||
673 | |||
674 | } | 665 | } |
675 | }, | 666 | }, |
676 | 667 | ||
@@ -682,10 +673,8 @@ exports.Stage = Montage.create(Component, { | |||
682 | * | 673 | * |
683 | * @params: x, y, w, h | 674 | * @params: x, y, w, h |
684 | */ | 675 | */ |
685 | draw3DProjectedAndUnprojectedRectangles: | 676 | draw3DProjectedAndUnprojectedRectangles: { |
686 | { | 677 | value:function(unProjPts, projPts) { |
687 | value:function(unProjPts, projPts) | ||
688 | { | ||
689 | this.clearDrawingCanvas(); | 678 | this.clearDrawingCanvas(); |
690 | this._drawingContext.strokeStyle = this._canvasDrawingPrefs.color; | 679 | this._drawingContext.strokeStyle = this._canvasDrawingPrefs.color; |
691 | this._drawingContext.lineWidth = this._canvasDrawingPrefs.thickness; | 680 | this._drawingContext.lineWidth = this._canvasDrawingPrefs.thickness; |
@@ -739,7 +728,7 @@ exports.Stage = Montage.create(Component, { | |||
739 | * @params: x0, y0, x1, y1 | 728 | * @params: x0, y0, x1, y1 |
740 | */ | 729 | */ |
741 | drawLine: { | 730 | drawLine: { |
742 | value:function(x0, y0, x1, y1, strokeSize, strokeColor){ | 731 | value:function(x0, y0, x1, y1, strokeSize, strokeColor) { |
743 | this.clearDrawingCanvas(); | 732 | this.clearDrawingCanvas(); |
744 | this._drawingContext.strokeStyle = strokeColor; | 733 | this._drawingContext.strokeStyle = strokeColor; |
745 | this._drawingContext.lineWidth = strokeSize; | 734 | this._drawingContext.lineWidth = strokeSize; |
@@ -780,6 +769,12 @@ exports.Stage = Montage.create(Component, { | |||
780 | } | 769 | } |
781 | }, | 770 | }, |
782 | 771 | ||
772 | toViewportCoordinates: { | ||
773 | value: function(x,y) { | ||