diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/data/pi/pi-data.js | 10 | ||||
-rwxr-xr-x | js/lib/geom/brush-stroke.js | 1423 | ||||
-rw-r--r-- | js/tools/BrushTool.js | 2 |
3 files changed, 751 insertions, 684 deletions
diff --git a/js/data/pi/pi-data.js b/js/data/pi/pi-data.js index 157cbc64..92d70141 100755 --- a/js/data/pi/pi-data.js +++ b/js/data/pi/pi-data.js | |||
@@ -703,13 +703,14 @@ exports.PiData = Montage.create( Montage, { | |||
703 | { | 703 | { |
704 | type : "color", | 704 | type : "color", |
705 | prop: "border", | 705 | prop: "border", |
706 | id : "stroke" | 706 | id : "stroke", |
707 | visible: false | ||
707 | }, | 708 | }, |
708 | { | 709 | { |
709 | type : "color", | 710 | type : "color", |
710 | id : "fill", | 711 | id : "fill", |
711 | prop: "background", | 712 | prop: "background", |
712 | visible : false, | 713 | visible : true, |
713 | divider : true | 714 | divider : true |
714 | } | 715 | } |
715 | ], | 716 | ], |
@@ -761,7 +762,9 @@ exports.PiData = Montage.create( Montage, { | |||
761 | valueMutator: parseFloat, | 762 | valueMutator: parseFloat, |
762 | min : 0, | 763 | min : 0, |
763 | max : 100, | 764 | max : 100, |
764 | value : 0 | 765 | value : 0, |
766 | acceptableUnits: [" "], | ||
767 | unit: " " | ||
765 | } | 768 | } |
766 | ] | 769 | ] |
767 | ] | 770 | ] |
@@ -788,6 +791,7 @@ exports.PiData = Montage.create( Montage, { | |||
788 | min : -90, | 791 | min : -90, |
789 | max : 90, | 792 | max : 90, |
790 | value : 0, | 793 | value : 0, |
794 | acceptableUnits: ["deg."], | ||
791 | unit : "deg." | 795 | unit : "deg." |
792 | } | 796 | } |
793 | ] | 797 | ] |
diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index 09a7023c..d9c2ab53 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js | |||
@@ -45,7 +45,7 @@ var BrushStroke = function GLBrushStroke() { | |||
45 | this._strokeAmountSmoothing = 0; | 45 | this._strokeAmountSmoothing = 0; |
46 | 46 | ||
47 | // currently, brush does not support a fill region | 47 | // currently, brush does not support a fill region |
48 | this.canFill = false; | 48 | this.canFill = true; |
49 | 49 | ||
50 | //threshold that tells us whether two samples are too far apart | 50 | //threshold that tells us whether two samples are too far apart |
51 | this._MAX_SAMPLE_DISTANCE_THRESHOLD = 5; | 51 | this._MAX_SAMPLE_DISTANCE_THRESHOLD = 5; |
@@ -65,777 +65,840 @@ var BrushStroke = function GLBrushStroke() { | |||
65 | this._planeMatInv = null; | 65 | this._planeMatInv = null; |
66 | this._planeCenter = null; | 66 | this._planeCenter = null; |
67 | this._dragPlane = null; | 67 | this._dragPlane = null; |
68 | }; //BrushStroke class defition | ||
68 | 69 | ||
69 | ///////////////////////////////////////////////////////// | 70 | BrushStroke.prototype = Object.create(GeomObj, {}); |
70 | // Property Accessors/Setters | ||
71 | ///////////////////////////////////////////////////////// | ||
72 | this.setCanvas = function(c) { | ||
73 | this._canvas = c; | ||
74 | } | ||
75 | |||
76 | this.setWorld = function (world) { | ||
77 | this._world = world; | ||
78 | }; | ||
79 | |||
80 | this.getWorld = function () { | ||
81 | return this._world; | ||
82 | }; | ||
83 | |||
84 | this.geomType = function () { | ||
85 | return this.GEOM_TYPE_BRUSH_STROKE; | ||
86 | }; | ||
87 | |||
88 | this.setDrawingTool = function (tool) { | ||
89 | this._drawingTool = tool; | ||
90 | }; | ||
91 | |||
92 | this.getDrawingTool = function () { | ||
93 | return this._drawingTool; | ||
94 | }; | ||
95 | |||
96 | this.setPlaneMatrix = function(planeMat){ | ||
97 | this._planeMat = planeMat; | ||
98 | }; | ||
99 | |||
100 | this.setPlaneMatrixInverse = function(planeMatInv){ | ||
101 | this._planeMatInv = planeMatInv; | ||
102 | }; | ||
103 | |||
104 | this.setPlaneCenter = function(pc){ | ||
105 | this._planeCenter = pc; | ||
106 | }; | ||
107 | |||
108 | this.setDragPlane = function(p){ | ||
109 | this._dragPlane = p; | ||
110 | }; | ||
111 | |||
112 | this.getNumPoints = function () { | ||
113 | if (this._LocalPoints.length) | ||
114 | return this._LocalPoints.length; | ||
115 | else | ||
116 | return this._Points.length; | ||
117 | }; | ||
118 | |||
119 | this.getPoint = function (index) { | ||
120 | return this._Points[index].slice(0); | ||
121 | }; | ||
122 | 71 | ||
123 | this.addPoint = function (pt) { | 72 | ///////////////////////////////////////////////////////// |
124 | //add the point only if it is some epsilon away from the previous point | 73 | // Property Accessors/Setters |
125 | var numPoints = this._Points.length; | 74 | ///////////////////////////////////////////////////////// |
126 | if (numPoints>0) { | 75 | BrushStroke.prototype.setCanvas = function(c) { |
127 | var threshold = this._MIN_SAMPLE_DISTANCE_THRESHOLD; | 76 | this._canvas = c; |
128 | var prevPt = this._Points[numPoints-1]; | 77 | }; |
129 | var diffPt = [prevPt[0]-pt[0], prevPt[1]-pt[1]]; | 78 | |
130 | var diffPtMag = Math.sqrt(diffPt[0]*diffPt[0] + diffPt[1]*diffPt[1]); | 79 | BrushStroke.prototype.setWorld = function (world) { |
131 | if (diffPtMag>threshold){ | 80 | this._world = world; |
132 | this._Points.push(pt); | 81 | }; |
133 | this._isDirty=true; | 82 | |
134 | this._isInit = false; | 83 | BrushStroke.prototype.getWorld = function () { |
135 | } | 84 | return this._world; |
136 | } else { | 85 | }; |
86 | |||
87 | BrushStroke.prototype.geomType = function () { | ||
88 | return this.GEOM_TYPE_BRUSH_STROKE; | ||
89 | }; | ||
90 | |||
91 | BrushStroke.prototype.setDrawingTool = function (tool) { | ||
92 | this._drawingTool = tool; | ||
93 | }; | ||
94 | |||
95 | BrushStroke.prototype.getDrawingTool = function () { | ||
96 | return this._drawingTool; | ||
97 | }; | ||
98 | |||
99 | BrushStroke.prototype.setPlaneMatrix = function(planeMat){ | ||
100 | this._planeMat = planeMat; | ||
101 | }; | ||
102 | |||
103 | BrushStroke.prototype.setPlaneMatrixInverse = function(planeMatInv){ | ||
104 | this._planeMatInv = planeMatInv; | ||
105 | }; | ||
106 | |||
107 | BrushStroke.prototype.setPlaneCenter = function(pc){ | ||
108 | this._planeCenter = pc; | ||
109 | }; | ||
110 | |||
111 | BrushStroke.prototype.setDragPlane = function(p){ | ||
112 | this._dragPlane = p; | ||
113 | }; | ||
114 | |||
115 | BrushStroke.prototype.getNumPoints = function () { | ||
116 | if (this._LocalPoints.length) | ||
117 | return this._LocalPoints.length; | ||
118 | else | ||
119 | return this._Points.length; | ||
120 | }; | ||
121 | |||
122 | BrushStroke.prototype.getPoint = function (index) { | ||
123 | return this._Points[index].slice(0); | ||
124 | }; | ||
125 | |||
126 | BrushStroke.prototype.addPoint = function (pt) { | ||
127 | //add the point only if it is some epsilon away from the previous point | ||
128 | var numPoints = this._Points.length; | ||
129 | if (numPoints>0) { | ||
130 | var threshold = this._MIN_SAMPLE_DISTANCE_THRESHOLD; | ||
131 | var prevPt = this._Points[numPoints-1]; | ||
132 | var diffPt = [prevPt[0]-pt[0], prevPt[1]-pt[1]]; | ||
133 | var diffPtMag = Math.sqrt(diffPt[0]*diffPt[0] + diffPt[1]*diffPt[1]); | ||
134 | if (diffPtMag>threshold){ | ||
137 | this._Points.push(pt); | 135 | this._Points.push(pt); |
138 | this._isDirty=true; | 136 | this._isDirty=true; |
139 | this._isInit = false; | 137 | this._isInit = false; |
140 | } | 138 | } |
141 | }; | 139 | } else { |
142 | 140 | this._Points.push(pt); | |
143 | this.insertPoint = function(pt, index){ | ||
144 | this._Points.splice(index, 0, pt); | ||
145 | this._isDirty=true; | 141 | this._isDirty=true; |
146 | this._isInit = false; | 142 | this._isInit = false; |
147 | }; | 143 | } |
144 | }; | ||
148 | 145 | ||
149 | this.isDirty = function(){ | 146 | BrushStroke.prototype.insertPoint = function(pt, index){ |
150 | return this._isDirty; | 147 | this._Points.splice(index, 0, pt); |
151 | }; | 148 | this._isDirty=true; |
149 | this._isInit = false; | ||
150 | }; | ||
152 | 151 | ||
153 | this.makeDirty = function(){ | 152 | BrushStroke.prototype.isDirty = function(){ |
154 | this._isDirty=true; | 153 | return this._isDirty; |
155 | }; | 154 | }; |
156 | 155 | ||
157 | this.getStageWorldCenter = function() { | 156 | BrushStroke.prototype.makeDirty = function(){ |
158 | return this._stageWorldCenter; | 157 | this._isDirty=true; |
159 | }; | 158 | }; |
160 | 159 | ||
161 | this.getBBoxMin = function () { | 160 | BrushStroke.prototype.getStageWorldCenter = function() { |
162 | return this._BBoxMin; | 161 | return this._stageWorldCenter; |
163 | }; | 162 | }; |
164 | 163 | ||
165 | this.getBBoxMax = function () { | 164 | Bru |