//>>built define(["dijit","dojo","dojox","dojo/require!dojox/drawing/tools/Arrow,dojox/drawing/util/positioning"],function(_1,_2,_3){ _2.provide("dojox.drawing.tools.custom.Vector"); _2.require("dojox.drawing.tools.Arrow"); _2.require("dojox.drawing.util.positioning"); _3.drawing.tools.custom.Vector=_3.drawing.util.oo.declare(_3.drawing.tools.Arrow,function(_4){ this.minimumSize=this.style.arrows.length; this.addShadow({size:3,mult:2}); },{draws:true,type:"dojox.drawing.tools.custom.Vector",minimumSize:30,showAngle:true,changeAxis:function(_5){ _5=_5!==undefined?_5:this.style.zAxis?0:1; if(_5==0){ this.style.zAxis=false; this.data.cosphi=0; }else{ this.style.zAxis=true; var p=this.points; var pt=this.zPoint(); this.setPoints([{x:p[0].x,y:p[0].y},{x:pt.x,y:pt.y}]); } this.render(); },_createZeroVector:function(_6,d,_7){ var s=_6=="hit"?this.minimumSize:this.minimumSize/6; var f=_6=="hit"?_7.fill:null; d={cx:this.data.x1,cy:this.data.y1,rx:s,ry:s}; this.remove(this[_6]); this[_6]=this.container.createEllipse(d).setStroke(_7).setFill(f); this.util.attr(this[_6],"drawingType","stencil"); },_create:function(_8,d,_9){ this.remove(this[_8]); this[_8]=this.container.createLine(d).setStroke(_9); this._setNodeAtts(this[_8]); },onDrag:function(_a){ if(this.created){ return; } var x1=_a.start.x,y1=_a.start.y,x2=_a.x,y2=_a.y; if(this.keys.shift&&!this.style.zAxis){ var pt=this.util.snapAngle(_a,45/180); x2=pt.x; y2=pt.y; } if(this.keys.alt){ var dx=x2>x1?((x2-x1)/2):((x1-x2)/-2); var dy=y2>y1?((y2-y1)/2):((y1-y2)/-2); x1-=dx; x2-=dx; y1-=dy; y2-=dy; } if(this.style.zAxis){ var _b=this.zPoint(_a); x2=_b.x; y2=_b.y; } this.setPoints([{x:x1,y:y1},{x:x2,y:y2}]); this.render(); },onTransform:function(_c){ if(!this._isBeingModified){ this.onTransformBegin(); } this.setPoints(this.points); this.render(); },anchorConstrain:function(x,y){ if(!this.style.zAxis){ return null; } var _d=this.style.zAngle*Math.PI/180; var _e=x<0?x>-y:x<-y; var dx=_e?x:-y/Math.tan(_d); var dy=!_e?y:-Math.tan(_d)*x; return {x:dx,y:dy}; },zPoint:function(_f){ if(_f===undefined){ if(!this.points[0]){ return null; } var d=this.pointsToData(); _f={start:{x:d.x1,y:d.y1},x:d.x2,y:d.y2}; } var _10=this.util.length(_f); var _11=this.util.angle(_f); _11<0?_11=360+_11:_11; _11=_11>135&&_11<315?this.style.zAngle:this.util.oppAngle(this.style.zAngle); return this.util.pointOnCircle(_f.start.x,_f.start.y,_10,_11); },pointsToData:function(p){ p=p||this.points; var _12=0; var obj={start:{x:p[0].x,y:p[0].y},x:p[1].x,y:p[1].y}; if(this.style.zAxis&&(this.util.length(obj)>this.minimumSize)){ var _13=this.util.angle(obj); _13<0?_13=360+_13:_13; _12=_13>135&&_13<315?1:-1; } this.data={x1:p[0].x,y1:p[0].y,x2:p[1].x,y2:p[1].y,cosphi:_12}; return this.data; },dataToPoints:function(o){ o=o||this.data; if(o.radius||o.angle){ var _14=0; var pt=this.util.pointOnCircle(o.x,o.y,o.radius,o.angle); if(this.style.zAxis||(o.cosphi&&o.cosphi!=0)){ this.style.zAxis=true; _14=o.angle>135&&o.angle<315?1:-1; } this.data=o={x1:o.x,y1:o.y,x2:pt.x,y2:pt.y,cosphi:_14}; } this.points=[{x:o.x1,y:o.y1},{x:o.x2,y:o.y2}]; return this.points; },render:function(){ this.onBeforeRender(this); if(this.getRadius()>=this.minimumSize){ this._create("hit",this.data,this.style.currentHit); this._create("shape",this.data,this.style.current); }else{ this.data.cosphi=0; this._createZeroVector("hit",this.data,this.style.currentHit); this._createZeroVector("shape",this.data,this.style.current); } },onUp:function(obj){ if(this.created||!this._downOnCanvas){ return; } this._downOnCanvas=false; if(!this.shape){ var d=100; obj.start.x=this.style.zAxis?obj.start.x+d:obj.start.x; obj.y=obj.y+d; this.setPoints([{x:obj.start.x,y:obj.start.y},{x:obj.x,y:obj.y}]); this.render(); } if(this.getRadius()