diff options
author | Eric Guzman | 2012-06-11 13:28:42 -0700 |
---|---|---|
committer | Eric Guzman | 2012-06-11 13:28:42 -0700 |
commit | 3a4727ffc350216a434a7c6977b6a23653b77780 (patch) | |
tree | c5dff306f8803c36a16163ba5df1e7f492e762b5 /js/helper-classes/3D/snap-manager.js | |
parent | d6b46ba496c9c8974ae39bb476aea35bcd1ddaf1 (diff) | |
parent | 337efc667372326ae2f9984d89a47bb151016774 (diff) | |
download | ninja-3a4727ffc350216a434a7c6977b6a23653b77780.tar.gz |
Merge branch 'binding' of github.com:dhg637/ninja-internal into binding
Diffstat (limited to 'js/helper-classes/3D/snap-manager.js')
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 069c6022..a8b6e739 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js | |||
@@ -21,8 +21,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
21 | /////////////////////////////////////////////////////////////////////// | 21 | /////////////////////////////////////////////////////////////////////// |
22 | // Instance variables | 22 | // Instance variables |
23 | /////////////////////////////////////////////////////////////////////// | 23 | /////////////////////////////////////////////////////////////////////// |
24 | drawingCanvas: { value: null, writable: true}, | 24 | |
25 | 25 | currentStage: { value: null }, | |
26 | |||
26 | // we keep a stack of working planes to facilitate working on other planes temporarily | 27 | // we keep a stack of working planes to facilitate working on other planes temporarily |
27 | _workingPlaneStack : { value: [], writable: true }, | 28 | _workingPlaneStack : { value: [], writable: true }, |
28 | 29 | ||
@@ -83,14 +84,14 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
83 | popWorkingPlane : { value: function () { workingPlane = this._workingPlaneStack.pop(); return workingPlane; }}, | 84 | popWorkingPlane : { value: function () { workingPlane = this._workingPlaneStack.pop(); return workingPlane; }}, |
84 | 85 | ||
85 | getStageWidth : { value: function () { | 86 | getStageWidth : { value: function () { |
86 | return parseInt(this.application.ninja.currentDocument.model.documentRoot.offsetWidth); | 87 | return parseInt(this.currentStage.offsetWidth); |
87 | }}, | 88 | }}, |
88 | 89 | ||
89 | getStageHeight : { value: function () { | 90 | getStageHeight : { value: function () { |
90 | return parseInt(this.application.ninja.currentDocument.model.documentRoot.offsetHeight); | 91 | return parseInt(this.currentStage.offsetHeight); |
91 | }}, | 92 | }}, |
92 | 93 | ||
93 | getStage : { value: function() { return this.application.ninja.currentDocument.model.documentRoot; }}, | 94 | getStage : { value: function() { return this.currentStage; }}, |
94 | 95 | ||
95 | getGridVertexHitRad : { value: function() { return this._gridVertexHitRad; }}, | 96 | getGridVertexHitRad : { value: function() { return this._gridVertexHitRad; }}, |
96 | getGridEdgeHitRad : { value: function() { return this._gridEdgeHitRad; }}, | 97 | getGridEdgeHitRad : { value: function() { return this._gridEdgeHitRad; }}, |
@@ -480,10 +481,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
480 | { | 481 | { |
481 | var snapRec = this._elementCache[i]; | 482 | var snapRec = this._elementCache[i]; |
482 | var elt = snapRec.getElement(); | 483 | var elt = snapRec.getElement(); |
483 | if (elt.elementModel) | 484 | elt.elementModel.isIn2DSnapCache = false; |
484 | elt.elementModel.isIn2DSnapCache = false; | 485 | |
485 | else | ||
486 | console.log( "element in the 2D cache does not have an elementModel" ); | ||
487 | } | 486 | } |
488 | 487 | ||
489 | this._elementCache = null; | 488 | this._elementCache = null; |
@@ -540,10 +539,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
540 | snapRec.init( elt ); | 539 | snapRec.init( elt ); |
541 | this._elementCache.push( snapRec ); | 540 | this._elementCache.push( snapRec ); |
542 | 541 | ||
543 | if (!elt.elementModel) | ||
544 | { | ||
545 | NJUtils.makeModelFromElement(elt); | ||
546 | } | ||
547 | elt.elementModel.isIn2DSnapCache = true; | 542 | elt.elementModel.isIn2DSnapCache = true; |
548 | } | 543 | } |
549 | else if (elt.elementModel) | 544 | else if (elt.elementModel) |
@@ -612,10 +607,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
612 | snapRec.init( elt ); | 607 | snapRec.init( elt ); |
613 | this._elementCache.push( snapRec ); | 608 | this._elementCache.push( snapRec ); |
614 | 609 | ||
615 | if (!elt.elementModel) | ||
616 | { | ||
617 | NJUtils.makeModelFromElement(elt); | ||
618 | } | ||
619 | elt.elementModel.isIn2DSnapCache = true; | 610 | elt.elementModel.isIn2DSnapCache = true; |
620 | } | 611 | } |
621 | else if (elt.elementModel) | 612 | else if (elt.elementModel) |
@@ -2124,7 +2115,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
2124 | if (hitRec) | 2115 | if (hitRec) |
2125 | { | 2116 | { |
2126 | var saveContext = drawUtils.getDrawingSurfaceElement(); | 2117 | var saveContext = drawUtils.getDrawingSurfaceElement(); |
2127 | drawUtils.setDrawingSurfaceElement(this.drawingCanvas); | 2118 | drawUtils.setDrawingSurfaceElement(this.application.ninja.stage.drawingCanvas); |
2128 | var context = drawUtils.getDrawingContext(); | 2119 | var context = drawUtils.getDrawingContext(); |
2129 | if (context) | 2120 | if (context) |
2130 | { | 2121 | { |