diff options
Diffstat (limited to 'js/stage/stage.reel/stage.js')
-rwxr-xr-x | js/stage/stage.reel/stage.js | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 59eb9317..44e14827 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js | |||
@@ -19,8 +19,6 @@ exports.Stage = Montage.create(Component, { | |||
19 | zoomFactor: {value : 1 }, | 19 | zoomFactor: {value : 1 }, |
20 | 20 | ||
21 | _canvasSelectionPrefs: { value: { "thickness" : 1.0, "color" : "#46a1ff" } }, | 21 | _canvasSelectionPrefs: { value: { "thickness" : 1.0, "color" : "#46a1ff" } }, |
22 | _editSymbolPrefs: { value: { "thickness" : 2.0, "color" : "#C61F00" } }, | ||
23 | |||
24 | _canvasDrawingPrefs: { value: { "thickness" : 1.0, "color" : "#000" } }, | 22 | _canvasDrawingPrefs: { value: { "thickness" : 1.0, "color" : "#000" } }, |
25 | drawingContextPreferences: { get: function() { return this._canvasDrawingPrefs; } }, | 23 | drawingContextPreferences: { get: function() { return this._canvasDrawingPrefs; } }, |
26 | 24 | ||
@@ -201,6 +199,7 @@ exports.Stage = Montage.create(Component, { | |||
201 | this._drawingCanvas.addEventListener("mousedown", this, false); | 199 | this._drawingCanvas.addEventListener("mousedown", this, false); |
202 | this._drawingCanvas.addEventListener("mouseup", this, false); | 200 | this._drawingCanvas.addEventListener("mouseup", this, false); |
203 | this._drawingCanvas.addEventListener("dblclick", this, false); | 201 | this._drawingCanvas.addEventListener("dblclick", this, false); |
202 | this._drawingCanvas.addEventListener("mousewheel", this, false); | ||
204 | 203 | ||
205 | // Hide the canvas | 204 | // Hide the canvas |
206 | this.hideCanvas(true); | 205 | this.hideCanvas(true); |
@@ -259,7 +258,6 @@ exports.Stage = Montage.create(Component, { | |||
259 | this.application.ninja.toolsData.selectedToolInstance._configure(true); | 258 | this.application.ninja.toolsData.selectedToolInstance._configure(true); |
260 | 259 | ||
261 | this.addEventListener("change@appModel.show3dGrid", this, false); | 260 | this.addEventListener("change@appModel.show3dGrid", this, false); |
262 | |||
263 | } | 261 | } |
264 | }, | 262 | }, |
265 | 263 | ||
@@ -360,6 +358,16 @@ exports.Stage = Montage.create(Component, { | |||
360 | } | 358 | } |
361 | }, | 359 | }, |
362 | 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 | |||
363 | /** | 371 | /** |
364 | * Enables the MouseMove on Canvas | 372 | * Enables the MouseMove on Canvas |
365 | */ | 373 | */ |
@@ -522,8 +530,7 @@ exports.Stage = Montage.create(Component, { | |||
522 | drawUtils.updatePlanes(); | 530 | drawUtils.updatePlanes(); |
523 | 531 | ||
524 | //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 |
525 | if(this.application.ninja.selectedElements.length) | 533 | if(this.application.ninja.selectedElements.length) { |
526 | { | ||
527 | // drawUtils.drawSelectionBounds handles the single selection case as well, | 534 | // drawUtils.drawSelectionBounds handles the single selection case as well, |
528 | // 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. |
529 | // TODO drawUtils.drawSelectionBounds expects an array of elements. | 536 | // TODO drawUtils.drawSelectionBounds expects an array of elements. |
@@ -531,8 +538,7 @@ exports.Stage = Montage.create(Component, { | |||
531 | // 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. |
532 | var selArray = new Array(); | 539 | var selArray = new Array(); |
533 | 540 | ||
534 | for(var i = 0; this.application.ninja.selectedElements[i];i++) | 541 | for(var i = 0; this.application.ninja.selectedElements[i];i++) { |
535 | { | ||
536 | var curElement = this.application.ninja.selectedElements[i]._element; | 542 | var curElement = this.application.ninja.selectedElements[i]._element; |
537 | 543 | ||
538 | // 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 |
@@ -565,7 +571,7 @@ exports.Stage = Montage.create(Component, { | |||
565 | * @params: x, y, w, h | 571 | * @params: x, y, w, h |
566 | */ | 572 | */ |
567 | draw3DSelectionRectangle: { | 573 | draw3DSelectionRectangle: { |
568 | value:function(x0,y0, x1,y1, x2,y2, x3,y3){ | 574 | value:function(x0,y0, x1,y1, x2,y2, x3,y3) { |
569 | // this.clearCanvas(); | 575 | // this.clearCanvas(); |
570 | this.clearDrawingCanvas(); | 576 | this.clearDrawingCanvas(); |
571 | this._drawingContext.strokeStyle = this._canvasDrawingPrefs.color; | 577 | this._drawingContext.strokeStyle = this._canvasDrawingPrefs.color; |
@@ -610,7 +616,7 @@ exports.Stage = Montage.create(Component, { | |||
610 | * Draws selection highlight and reg. point for a given element | 616 | * Draws selection highlight and reg. point for a given element |
611 | */ | 617 | */ |
612 | drawElementBoundingBox: { | 618 | drawElementBoundingBox: { |
613 | value: function(elt, editMode) { | 619 | value: function(elt) { |
614 | this.stageDeps.viewUtils.setViewportObj( elt ); | 620 | this.stageDeps.viewUtils.setViewportObj( elt ); |
615 | var bounds3D = this.stageDeps.viewUtils.getElementViewBounds3D( elt ); | 621 | var bounds3D = this.stageDeps.viewUtils.getElementViewBounds3D( elt ); |
616 | 622 | ||
@@ -621,18 +627,16 @@ exports.Stage = Montage.create(Component, { | |||
621 | // } | 627 | // } |
622 | 628 | ||
623 | var zoomFactor = 1; | 629 | var zoomFactor = 1; |
624 | if (this._viewport.style && this._viewport.style.zoom) | 630 | if (this._viewport.style && this._viewport.style.zoom) { |
625 | { | ||
626 | zoomFactor = Number(this._viewport.style.zoom); | 631 | zoomFactor = Number(this._viewport.style.zoom); |
627 | } | 632 | } |
633 | |||
628 | var tmpMat = this.stageDeps.viewUtils.getLocalToGlobalMatrix( elt ); | 634 | var tmpMat = this.stageDeps.viewUtils.getLocalToGlobalMatrix( elt ); |
629 | for (var j=0; j<4; j++) | 635 | for (var j=0; j<4; j++) { |
630 | { | ||
631 | var localPt = bounds3D[j]; | 636 | var localPt = bounds3D[j]; |
632 | var tmpPt = this.stageDeps.viewUtils.localToGlobal2(localPt, tmpMat); | 637 | var tmpPt = this.stageDeps.viewUtils.localToGlobal2(localPt, tmpMat); |
633 | 638 | ||
634 | if(zoomFactor !== 1) | 639 | if(zoomFactor !== 1) { |
635 | { | ||
636 | tmpPt = vecUtils.vecScale(3, tmpPt, zoomFactor); | 640 | tmpPt = vecUtils.vecScale(3, tmpPt, zoomFactor); |
637 | 641 | ||
638 | tmpPt[0] += this._scrollLeft*(zoomFactor - 1); | 642 | tmpPt[0] += this._scrollLeft*(zoomFactor - 1); |
@@ -642,13 +646,9 @@ exports.Stage = Montage.create(Component, { | |||
642 | } | 646 | } |
643 | 647 | ||
644 | // draw it | 648 | // draw it |
645 | if(editMode) { | 649 | this.context.strokeStyle = this._canvasSelectionPrefs.color; |
646 | this.context.strokeStyle = this._editSymbolPrefs.color; | 650 | this.context.lineWidth = this._canvasSelectionPrefs.thickness; |
647 | this.context.lineWidth = this._editSymbolPrefs.thickness; | 651 | |
648 | } else { | ||
649 | this.context.strokeStyle = this._canvasSelectionPrefs.color; | ||
650 | this.context.lineWidth = this._canvasSelectionPrefs.thickness; | ||
651 | } | ||
652 | 652 | ||
653 | this.context.beginPath(); | 653 | this.context.beginPath(); |
654 | 654 | ||
@@ -662,13 +662,6 @@ exports.Stage = Montage.create(Component, { | |||
662 | 662 | ||
663 | this.context.closePath(); | 663 | this.context.closePath(); |
664 | this.context.stroke(); | 664 | this.context.stroke(); |
665 | |||
666 | /** Bug #25 - Do Not Draw the Registration point anymore on the top left since it's assumed there. | ||
667 | this.context.beginPath(); | ||
668 | this.context.arc(bounds3D[0][0], bounds3D[0][1] , 5, 0, Math.PI*2, false); | ||
669 | this.context.stroke(); | ||
670 | */ | ||
671 | |||
672 | } | 665 | } |
673 | }, | 666 | }, |
674 | 667 | ||
@@ -680,10 +673,8 @@ exports.Stage = Montage.create(Component, { | |||
680 | * | 673 | * |
681 | * @params: x, y, w, h | 674 | * @params: x, y, w, h |
682 | */ | 675 | */ |
683 | draw3DProjectedAndUnprojectedRectangles: | 676 | draw3DProjectedAndUnprojectedRectangles: { |
684 | { | 677 | value:function(unProjPts, projPts) { |
685 | value:function(unProjPts, projPts) | ||
686 | { | ||
687 | this.clearDrawingCanvas(); | 678 | this.clearDrawingCanvas(); |
688 | this._drawingContext.strokeStyle = this._canvasDrawingPrefs.color; | 679 | this._drawingContext.strokeStyle = this._canvasDrawingPrefs.color; |
689 | this._drawingContext.lineWidth = this._canvasDrawingPrefs.thickness; | 680 | this._drawingContext.lineWidth = this._canvasDrawingPrefs.thickness; |
@@ -737,7 +728,7 @@ exports.Stage = Montage.create(Component, { | |||
737 | * @params: x0, y0, x1, y1 | 728 | * @params: x0, y0, x1, y1 |
738 | */ | 729 | */ |
739 | drawLine: { | 730 | drawLine: { |
740 | value:function(x0, y0, x1, y1, strokeSize, strokeColor){ | 731 | value:function(x0, y0, x1, y1, strokeSize, strokeColor) { |
741 | this.clearDrawingCanvas(); | 732 | this.clearDrawingCanvas(); |
742 | this._drawingContext.strokeStyle = strokeColor; | 733 | this._drawingContext.strokeStyle = strokeColor; |
743 | this._drawingContext.lineWidth = strokeSize; | 734 | this._drawingContext.lineWidth = strokeSize; |