UNPKG

awv3

Version:
2 lines 33.4 kB
"use strict";function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function hoverFunction(e,t){if(e instanceof _constraint2["default"]||e.interact.hover){if(clearTimeout(t.__sketchControlsHandler.timeoutID),e instanceof _constraint2["default"])return e.hover(),void t.refresh();t.currentSketch.hideConstraints(),t.currentSketch.getObjectsOnSketch().forEach(function(e){return e.interact.unhover&&e.interact.unhover()}),e.interact.hover(),t.currentSketch.showConstraints(e),t.refresh()}}function unhoverFunction(e,t){if(e instanceof _constraint2["default"]||e.interact.hover){if(e instanceof _constraint2["default"])return e.unhover(),t.refresh(),void(t.__sketchControlsHandler.timeoutID=setTimeout(function(){t.currentSketch&&t.currentSketch.hideConstraints()},1e3));e.interact.unhover(),t.refresh(),t.__sketchControlsHandler.timeoutID=setTimeout(function(){t.currentSketch&&t.currentSketch.hideConstraints()},1e3)}}function dragstartFunction(e,t,n,r){e instanceof _geomobjects.Point&&(t.__sketchControlsHandler.lastDragPoint=e.position.clone()),t.modelData.incrementalLevel&&(t.stateDiff=null,t.mouseStates=[null,null],t.sketchStates=[null,null],t.mouseStates[0]=t.__sketchControlsHandler.lastDragPoint,t.sketchStates[0]=t.currentSketch.getState(),t.movedObject=e,t.__sketchControlsHandler.linearIntervalID=setInterval(function(){},n),t.__sketchControlsHandler.MUCIntervalID=setInterval(function(){if(_cchelpers.logLevel>=5&&console.log(_helpers.Timestamp.get(),"MUC tick"),t.mouseStates[0]){var n=t.modelData.interactionPoint.clone();n=t.currentSketch.getSnappedPointWrap(n.clone(),e,t.mouseStates[0].clone()),t.moveUnderConstraints(e,n),t.refresh()}},r))}function hoverSubstrateFunction(e,t){e.interact.hover&&(clearTimeout(t.__sketchControlsHandler.timeoutID),t.currentSketch.hideConstraints(),e.interact.hover(),t.currentSketch.showConstraints(e),t.refresh())}function unhoverSubstrateFunction(e,t){e.interact.unhover&&(e.interact.unhover(),t.refresh(),t.__sketchControlsHandler.timeoutID=setTimeout(function(){t.currentSketch&&(t.currentSketch.hideConstraints(),e.hovered=!1)},1e3))}exports.__esModule=!0,exports.filletHandler=exports.vertical_distanceHandler=exports.horizontal_distanceHandler=exports.equal_radiusHandler=exports.radiusHandler=exports.equal_distanceHandler=exports.colinearHandler=exports.symmetricHandler=exports.midpointHandler=exports.concentricHandler=exports.parallelityHandler=exports.perpendicularityHandler=exports.verticalityHandler=exports.horizontalityHandler=exports.tangencyHandler=exports.angleoxHandler=exports.angleHandler=exports.distanceHandler=exports.incidenceHandler=exports.fixationHandler=exports.constraintsHandler=exports.polylineHandler=exports.arcTangentHandler=exports.arcMiddleHandler=exports.arcControlHandler=exports.arcCenterHandler=exports.arcHandler=exports.lineHandler=exports.pointHandler=exports.simpleDrawHandler=exports.deleteHandler=exports.emptyHandler=exports.baseHandler=void 0;var _promise=require("babel-runtime/core-js/promise"),_promise2=_interopRequireDefault(_promise),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_regenerator=require("babel-runtime/regenerator"),_regenerator2=_interopRequireDefault(_regenerator),_asyncToGenerator2=require("babel-runtime/helpers/asyncToGenerator"),_asyncToGenerator3=_interopRequireDefault(_asyncToGenerator2),dragendFunction=function(){var e=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function t(e,n,r,i){var o,s,a;return _regenerator2["default"].wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.modelData.incrementalLevel){t.next=9;break}return clearInterval(n.__sketchControlsHandler.linearIntervalID),clearInterval(n.__sketchControlsHandler.MUCIntervalID),n.mouseStates=[null,null],n.sketchStates=[null,null],n.stateDiff=null,n.movedObject=null,t.next=9,n.currentSketch.updateFromServer(n.server);case 9:if(!e.endDrag){t.next=12;break}return t.next=12,e.endDrag(n.currentSketch,n.server);case 12:if(!n.modelData.incrementalLevel){t.next=15;break}return t.next=15,n.currentSketch.solveConstraints();case 15:if(!n.modelData.autoconstraintIncremental){t.next=21;break}return o=n.currentSketch,s=new _constraintgen.ConstraintGenerator(o),a=s.generateImpliedConstraints(_sketch2["default"].ForObjectsWithChildren(e)),t.next=21,o.addToSketch(a,{updateSketch:!0});case 21:case"end":return t.stop()}},t,this)}));return function(t,n,r,i){return e.apply(this,arguments)}}(),dragFunction=function(){var e=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function t(e,n){var r,i;return _regenerator2["default"].wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n.modelData.incrementalLevel){t.next=16;break}if(r=n.modelData.interactionPoint.clone(),r=n.currentSketch.getSnappedPointWrap(r.clone(),e,n.__sketchControlsHandler.lastDragPoint.clone()),i=n.__sketchControlsHandler.lastDragPoint.sub(r).negate(),!(e instanceof _geomobjects.Point)){t.next=9;break}return t.next=7,e.move(r);case 7:t.next=14;break;case 9:return t.next=11,e.moveRelative;case 11:if(t.t0=t.sent,!t.t0){t.next=14;break}e.moveRelative(i);case 14:n.refresh(),n.__sketchControlsHandler.lastDragPoint=r;case 16:case"end":return t.stop()}},t,this)}));return function(t,n){return e.apply(this,arguments)}}(),_cchelpers=require("sketcher/cchelpers"),_constraint=require("sketcher/constraint"),_constraint2=_interopRequireDefault(_constraint),_sketch=require("sketcher/sketch"),_sketch2=_interopRequireDefault(_sketch),_geomutils=require("sketcher/geomutils"),_geomobjects=require("sketcher/geomobjects"),_constraintgen=require("sketcher/constraintgen"),_fillet=require("sketcher/fillet"),_fillet2=_interopRequireDefault(_fillet),_controls=require("sketcher/controls"),Controls=_interopRequireWildcard(_controls),_three=require("three"),_three2=_interopRequireDefault(_three),_object=require("three/object3"),_object2=_interopRequireDefault(_object),_helpers=require("core/helpers"),baseHandler=exports.baseHandler=function(){function e(t){(0,_classCallCheck3["default"])(this,e),this.sketcher=t,this.sketch=t.currentSketch}return e.prototype.click=function(e){},e.prototype.mouseMove=function(e){},e.prototype.consoleExecute=function(e){},e.prototype.finish=function(){},e}();baseHandler.prototype.shiftDirections=8;var emptyHandler=exports.emptyHandler=function(e){function t(n){function r(e){var t,r,i=this;e.interact.createInteraction({priority:10}).on((t={},t[_object2["default"].Events.Interaction.Hovered]=function(t){if(!a.hasItemDragged)return hoverFunction(e,n)},t[_object2["default"].Events.Interaction.Unhovered]=function(t){if(!a.hasItemDragged)return unhoverFunction(e,n)},t[_object2["default"].Events.Interaction.Picked]=function(){var t=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(t){return _regenerator2["default"].wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof _constraint2["default"])){t.next=2;break}return t.abrupt("return");case 2:n.__parentView.controls.enabled=!1,n.__sketchControlsHandler.lastDragPoint=n.modelData.interactionPoint.clone(),a.hasItemDragged=!1;case 5:case"end":return t.stop()}},r,i)}));return function(e){return t.apply(this,arguments)}}(),t[_object2["default"].Events.Interaction.Dropped]=function(){var t=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(t){return _regenerator2["default"].wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof _constraint2["default"])){t.next=2;break}return t.abrupt("return");case 2:if(n.__parentView.controls.enabled=!0,!a.hasItemDragged){t.next=6;break}return t.next=6,dragendFunction(e,n);case 6:a.hasItemDragged=!1;case 7:case"end":return t.stop()}},r,i)}));return function(e){return t.apply(this,arguments)}}(),t[_object2["default"].Events.Interaction.Dragged]=function(){var t=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(t){return _regenerator2["default"].wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof _constraint2["default"])){t.next=2;break}return t.abrupt("return");case 2:if(a.hasItemDragged){t.next=6;break}return a.hasItemDragged=!0,t.next=6,dragstartFunction(e,n,o,s);case 6:return t.next=8,dragFunction(e,n);case 8:case"end":return t.stop()}},r,i)}));return function(e){return t.apply(this,arguments)}}(),t)),e.constraintsSubstrate&&e.constraintsSubstrate.createInteraction({priority:10}).on((r={},r[_object2["default"].Events.Interaction.Hovered]=function(t){return hoverSubstrateFunction(e,n)},r[_object2["default"].Events.Interaction.Unhovered]=function(t){return unhoverSubstrateFunction(e,n)},r))}(0,_classCallCheck3["default"])(this,t);var i=(0,_possibleConstructorReturn3["default"])(this,e.call(this,n));i.timeoutID=void 0,i.linearIntervalID=void 0,i.MUCIntervalID=void 0;var o=10,s=100;i.lastDragPoint=new _three2["default"].Vector3(0,0,0),i.hasItemDragged=!1;var a=i,c=n.currentSketch.getObjectsOnSketch();return _sketch2["default"].ForObjectsWithChildren(c,r),i}return(0,_inherits3["default"])(t,e),t.prototype.finish=function(){var e=this.sketcher.currentSketch.getObjectsOnSketch();_sketch2["default"].ForObjectsWithChildren(e,function(e){e.interact.removeInteraction(),e.constraintsSubstrate&&e.constraintsSubstrate.removeInteraction()})},t}(baseHandler),deleteHandler=exports.deleteHandler=function(e){function t(n){function r(e){var t,r,i=this;e.interact.createInteraction({priority:10}).on((t={},t[_object2["default"].Events.Interaction.Hovered]=function(t){if(o.deletingItem!==e)return hoverFunction(e,n)},t[_object2["default"].Events.Interaction.Unhovered]=function(t){return unhoverFunction(e,n)},t[_object2["default"].Events.Interaction.Clicked]=function(){var t=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(t){var s;return _regenerator2["default"].wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e.parent instanceof _geomobjects.GeometricObject||o.hasItemDeleted)){t.next=2;break}return t.abrupt("return");case 2:return o.deletingItem=e,e instanceof _constraint2["default"]&&(s=e.args.filter(function(e){return e.constraintsSubstrate.visible})[0],0!==n.currentSketch.updateConstraints(s)&&clearTimeout(n.__sketchControlsHandler.timeoutID)),unhoverFunction(e,n),t.next=7,n.currentSketch.removeFromSketch(e);case 7:if(o.deletingItem=null,!n.modelData.incrementalLevel){t.next=11;break}return t.next=11,n.currentSketch.solveConstraints();case 11:n.refresh();case 12:case"end":return t.stop()}},r,i)}));return function(e){return t.apply(this,arguments)}}(),t)),e.constraintsSubstrate&&e.constraintsSubstrate.createInteraction({priority:-1}).on((r={},r[_object2["default"].Events.Interaction.Hovered]=function(t){return hoverSubstrateFunction(e,n)},r[_object2["default"].Events.Interaction.Unhovered]=function(t){return unhoverSubstrateFunction(e,n)},r))}(0,_classCallCheck3["default"])(this,t);var i=(0,_possibleConstructorReturn3["default"])(this,e.call(this,n));i.deletingItem=null;var o=i,s=n.currentSketch.getObjectsOnSketch();return _sketch2["default"].ForObjectsWithChildren(s,r),i}return(0,_inherits3["default"])(t,e),t.prototype.finish=function(){var e=this.sketcher.currentSketch.getObjectsOnSketch();_sketch2["default"].ForObjectsWithChildren(e,function(e){e.interact.removeInteraction(),e.constraintsSubstrate&&e.constraintsSubstrate.removeInteraction()})},t}(baseHandler),simpleDrawHandler=exports.simpleDrawHandler=function(e){function t(n){(0,_classCallCheck3["default"])(this,t);var r=(0,_possibleConstructorReturn3["default"])(this,e.call(this,n));return n.__parentView.interaction.changeCursor=!1,r.sketcher.modelMethods.consoleFocus(),r.sketcher.refresh(),r.clear(),r}return(0,_inherits3["default"])(t,e),t.prototype.clear=function(){this.preview=null,this.ignoreClicksAndMoves=!1,this.state=0,this.clicksPos=[]},t.prototype.mouseMove=function(e){if(!this.ignoreClicksAndMoves){e.copy(this.doSnapping(e));var t=this.preview;this.updatePreview(e);var n=this.preview;n!=t&&(t&&this.sketch.removeAuxObject(t),n&&this.sketch.addAuxObject(n)),this.sketcher.refresh()}},t.prototype.click=function(e){var t=this;if(this.sketcher.modelMethods.consoleFocus(),!this.ignoreClicksAndMoves&&(this.mouseMove(e),this.handleClick(e)))return this.clicksPos[this.state]=e,this.state+=1,this.state==this.statesCount?(this.ignoreClicksAndMoves=!0,this.sketch.addToSketch(this.preview,{autoconstraint:!0}).then(function(){return t.sketcher.modelData.incrementalLevel&&t.sketcher.currentSketch.solveConstraints()}).then(function(){t.clear(),t.sketcher.refresh()})):void 0},t.prototype.isClickDuplicate=function(e){return this.clicksPos.some(function(t){return t.equals(e)})},t.prototype.consoleExecute=function(e){var t=e.trim().split(/\s+/),n=t.map(parseFloat);if(2===n.length&&n.every(isFinite))return this.click(new _three2["default"].Vector3(n[0],n[1],0))},t.prototype.finish=function(){this.preview&&this.sketch.removeAuxObject(this.preview),this.sketcher.refresh()},t.prototype.doSnapping=function(e){return this.preview instanceof _geomobjects.Point?this.sketch.getSnappedPointWrap(e,this.preview,this.preview.position):this.preview instanceof _geomobjects.Arc||this.preview instanceof _geomobjects.Line?this.sketch.getSnappedPointWrap(e,this.preview.points[1],this.preview.points[1].position):e},t.prototype.handleClick=function(e){return!this.isClickDuplicate(e)},t}(baseHandler),pointHandler=exports.pointHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n))}return(0,_inherits3["default"])(t,e),t.prototype.updatePreview=function(e){this.preview instanceof _geomobjects.Point||(this.preview=new _geomobjects.Point),this.preview.position.copy(e)},t}(simpleDrawHandler);pointHandler.prototype.statesCount=1;var lineHandler=exports.lineHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n))}return(0,_inherits3["default"])(t,e),t.prototype.updatePreview=function(e){if(1!==this.state)return pointHandler.prototype.updatePreview.call(this,e);var t={start:this.clicksPos[0],end:e};this.preview=(0,_geomutils.createGeomObject)(t,this.preview)},t.prototype.doSnapping=function(e){return this.preview instanceof _geomobjects.Point?this.sketch.getSnappedPointWrap(e,this.preview.points[0],this.preview.points[0].position):this.preview instanceof _geomobjects.Line?this.sketch.getSnappedPointWrap(e,this.preview.points[1],this.preview.points[1].position):e},t}(simpleDrawHandler);lineHandler.prototype.statesCount=2;var arcHandler=exports.arcHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n))}return(0,_inherits3["default"])(t,e),t.prototype.updatePreview=function(e){if(2!==this.state)return lineHandler.prototype.updatePreview.call(this,e);var t;if("control"===this.lastPointMode)t=(0,_geomutils.drawArcBy_S_E_CPh)(this.clicksPos[0],this.clicksPos[1],e);else if("middle"===this.lastPointMode)t=(0,_geomutils.drawArcBy_S_E_M)(this.clicksPos[0],this.clicksPos[1],e);else{var n=this.sketcher.__parentView.interaction.shiftKey;t=(0,_geomutils.drawArcBy_S_E_Ch)(this.clicksPos[0],this.clicksPos[1],e,n)}this.preview=(0,_geomutils.createGeomObject)(t,this.preview)},t.prototype.doSnapping=function(e){return this.preview instanceof _geomobjects.Point?this.sketch.getSnappedPointWrap(e.clone(),this.preview,this.preview.position):this.preview instanceof _geomobjects.Line?this.sketch.getSnappedPointWrap(e.clone(),this.preview.points[1],this.preview.points[1].position):this.preview instanceof _geomobjects.Arc?this.sketch.getSnappedPointWrap(e.clone(),this.preview.centerPoint,this.preview.centerPoint.position):e},t}(simpleDrawHandler);arcHandler.prototype.statesCount=3;var arcCenterHandler=exports.arcCenterHandler=function(e){function t(n){(0,_classCallCheck3["default"])(this,t);var r=(0,_possibleConstructorReturn3["default"])(this,e.call(this,n));return r.lastPointMode="center",r}return(0,_inherits3["default"])(t,e),t}(arcHandler),arcControlHandler=exports.arcControlHandler=function(e){function t(n){(0,_classCallCheck3["default"])(this,t);var r=(0,_possibleConstructorReturn3["default"])(this,e.call(this,n));return r.lastPointMode="control",r}return(0,_inherits3["default"])(t,e),t}(arcHandler),arcMiddleHandler=exports.arcMiddleHandler=function(e){function t(n){(0,_classCallCheck3["default"])(this,t);var r=(0,_possibleConstructorReturn3["default"])(this,e.call(this,n));return r.lastPointMode="middle",r}return(0,_inherits3["default"])(t,e),t}(arcHandler),arcTangentHandler=exports.arcTangentHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n))}return(0,_inherits3["default"])(t,e),t.prototype.updatePreview=function(e){if(1!==this.state)return pointHandler.prototype.updatePreview.call(this,e);var t=(0,_geomutils.drawArcBy_S_T_E)(this.clicksPos[0],this.from.tangent,e);this.preview=(0,_geomutils.createGeomObject)(t,this.preview)},t.prototype.handleClick=function(e){if(0!==this.state)return simpleDrawHandler.prototype.handleClick.call(this,e);var t=this.sketch.getObjectsOnSketch();t=t.filter(function(e){return e instanceof _geomobjects.Line||e instanceof _geomobjects.Arc});var n=[];return t.forEach(function(t){for(var r=0;r<2;r++){var i=t.points[r];if(i.position.equals(e)){var o=t.getTangent(e);o.length()<.9||(0==r&&o.negate(),n.push({object:t,pointIdx:r,tangent:o}))}}}),1==n.length&&(this.from=n[0],!0)},t}(simpleDrawHandler);arcTangentHandler.prototype.statesCount=2;var polylineHandler=exports.polylineHandler=function(e){function t(n){(0,_classCallCheck3["default"])(this,t);var r=(0,_possibleConstructorReturn3["default"])(this,e.call(this,n));return r.edgeHandler=null,r.lastPoint=null,r.ignoreClicksAndMoves=!1,r.changeEdgeType("line"),r.sketcher.refresh(),r}return(0,_inherits3["default"])(t,e),t.prototype.changeEdgeType=function(e){this.finish();var t=Controls[e+"Handler"];this.edgeHandler=new t(this.sketcher),this.lastPoint&&this.edgeHandler.click(this.lastPoint.position)},t.prototype.click=function(e){var t=this;if(!this.ignoreClicksAndMoves){this.ignoreClicksAndMoves=!0,this.edgeHandler.mouseMove(e);var n=this.edgeHandler.preview,r=this.edgeHandler.click(e)||_promise2["default"].resolve();return r.then(function(){if(0===t.edgeHandler.state){var e=_promise2["default"].resolve();if(t.lastPoint){var r=new _constraintgen.ConstraintsAdder(t.sketcher.currentSketch);r.add(_constraint2["default"].Type.INCIDENCE,[t.lastPoint,n.points[0]]);var i=r.commit();i.length>0&&(e=t.sketcher.currentSketch.addToSketch(i).then(function(){return t.sketcher.modelData.incrementalLevel&&t.sketcher.currentSketch.solveConstraints()}))}return t.lastPoint=n.points[1],e.then(function(){return t.edgeHandler.click(t.lastPoint.position)})}}).then(function(){t.ignoreClicksAndMoves=!1})}},t.prototype.mouseMove=function(e){this.edgeHandler.mouseMove(e)},t.prototype.finish=function(){this.edgeHandler&&(this.edgeHandler.finish(),this.edgeHandler=null)},t}(baseHandler);polylineHandler.prototype.consoleExecute=simpleDrawHandler.prototype.consoleExecute;var constraintsHandler=exports.constraintsHandler=function(e){function t(n,r,i,o,s,a){(0,_classCallCheck3["default"])(this,t);var c=(0,_possibleConstructorReturn3["default"])(this,e.call(this,n));if(!s){s=[];for(var l=0;l<i;l++)s[l]=[_geomobjects.Point,_geomobjects.Line,_geomobjects.Arc]}for(var l=0;l<i;l++)0===s[l].length&&(s[l]=[_geomobjects.Point,_geomobjects.Line,_geomobjects.Arc]);if(!a){a=[];for(var l=0;l<i;++l)a[l]="Select object "+(l+1)+" (",a[l]+=s[l].map(function(e){return e.prototype.type}).join("/"),a[l]+=")"}n.setPrompt(a[0]);var u=[];c.candidateObjects=[];for(var l=0;l<i;l++)c.candidateObjects[l]=[],_sketch2["default"].ForObjectsWithChildren(n.currentSketch.getObjectsOnSketch(),function(e){s[l].indexOf(e.constructor)!==-1&&c.candidateObjects[l].push(e)}),c.candidateObjects[l].forEach(function(e){var t;return e.interact.createInteraction({priority:10}).on((t={},t[_object2["default"].Events.Interaction.Hovered]=function(t){e.interact.hover(),n.refresh()},t[_object2["default"].Events.Interaction.Unhovered]=function(t){e.interact.unhover(),n.refresh()},t[_object2["default"].Events.Interaction.Clicked]=function(t){function s(t){(0,_cchelpers.trackPromise)(n.currentSketch.addToSketch(t,{updateSketch:!0}).then(function(){return n.modelData.incrementalLevel&&n.currentSketch.solveConstraints()}).then(function(){e.interact.unhover(),n.chooseTool("empty"),n.refresh()}))}if(u.indexOf(e)!==-1)return void n.setPrompt("Select different object");if(u.push(e)!==i)return void n.setPrompt(a[u.length]);var c=o?n.askConstraintParams({expression:"",value:0,fixed:!0}):_promise2["default"].resolve({});c.then(function(e){return s(new _constraint2["default"](r,u,e))})},t))});return c}return(0,_inherits3["default"])(t,e),t.prototype.finish=function(){this.sketcher.setPrompt(""),this.sketcher.modelData.declineConstraint(),this.candidateObjects.forEach(function(e){return e.forEach(function(e){return e.interact.removeInteraction()})})},t}(baseHandler),fixationHandler=exports.fixationHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.FIXATION,1,!1))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),incidenceHandler=exports.incidenceHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.INCIDENCE,2,!1,[[_geomobjects.Point],[]]))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),distanceHandler=exports.distanceHandler=function(e){function t(n,r){return(0,_classCallCheck3["default"])(this,t),r=r||_constraint2["default"].Type.DISTANCE,(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,r,2,!0))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),angleHandler=exports.angleHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.ANGLE,2,!0,[[_geomobjects.Line],[_geomobjects.Line]]))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),angleoxHandler=exports.angleoxHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.ANGLEOX,1,!0,[[_geomobjects.Line]]))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),tangencyHandler=exports.tangencyHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.TANGENCY,2))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),horizontalityHandler=exports.horizontalityHandler=function(e){function t(n,r){return(0,_classCallCheck3["default"])(this,t),r=r||_constraint2["default"].Type.HORIZONTALITY,(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,r,1,!1,[[_geomobjects.Line]],["Select Line"]))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),verticalityHandler=exports.verticalityHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.VERTICALITY))}return(0,_inherits3["default"])(t,e),t}(horizontalityHandler),perpendicularityHandler=exports.perpendicularityHandler=function(e){function t(n,r){return(0,_classCallCheck3["default"])(this,t),r=r||_constraint2["default"].Type.PERPENDICULARITY,(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,r,2,!1,[[_geomobjects.Line],[_geomobjects.Line]]))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),parallelityHandler=exports.parallelityHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.PARALLELITY))}return(0,_inherits3["default"])(t,e),t}(perpendicularityHandler),concentricHandler=exports.concentricHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.CONCENTRIC,2,!1,[[_geomobjects.Arc],[_geomobjects.Arc]]))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),midpointHandler=exports.midpointHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.MIDPOINT,3,!1,[[],[_geomobjects.Point],[]]))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),symmetricHandler=exports.symmetricHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.SYMMETRIC,3,!1,[[_geomobjects.Line],[],[]]))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),colinearHandler=exports.colinearHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.COLINEAR,2,!1,[[_geomobjects.Line],[_geomobjects.Line]]))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),equal_distanceHandler=exports.equal_distanceHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.EQUAL_DISTANCE,4))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),radiusHandler=exports.radiusHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.RADIUS,1,!0,[[_geomobjects.Arc]]))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),equal_radiusHandler=exports.equal_radiusHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.EQUAL_RADIUS,2,!1,[[_geomobjects.Arc],[_geomobjects.Arc]]))}return(0,_inherits3["default"])(t,e),t}(constraintsHandler),horizontal_distanceHandler=exports.horizontal_distanceHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.HORIZONTAL_DISTANCE))}return(0,_inherits3["default"])(t,e),t}(distanceHandler),vertical_distanceHandler=exports.vertical_distanceHandler=function(e){function t(n){return(0,_classCallCheck3["default"])(this,t),(0,_possibleConstructorReturn3["default"])(this,e.call(this,n,_constraint2["default"].Type.VERTICAL_DISTANCE))}return(0,_inherits3["default"])(t,e),t}(distanceHandler),filletHandler=exports.filletHandler=function(e){function t(n){(0,_classCallCheck3["default"])(this,t);var r=(0,_possibleConstructorReturn3["default"])(this,e.call(this,n));return r.processor=new _fillet2["default"](n,n.currentSketch),r.busy=!1,r.filletablePoints=[],r.filletArcs=[],r.preview=null,r.updateInteractiveObjects(),r}return(0,_inherits3["default"])(t,e),t.prototype.clear=function(){this.filletablePoints.forEach(function(e){return e.interact.removeInteraction()}),this.filletArcs.forEach(function(e){return e.interact.removeInteraction()}),this.filletablePoints=[],this.filletArcs=[]},t.prototype.updateInteractiveObjects=function(){function e(e){a.preview={arc:null,lineStart:null,lineEnd:null},a.preview.arc=(0,_geomutils.createGeomObject)({start:e.arc.points[0].position.clone(),end:e.arc.points[1].position.clone(),center:e.arc.centerPoint.position.clone(),clockwise:e.arc.clockwise},a.preview.arc),a.preview.lineStart=(0,_geomutils.createGeomObject)({start:e.lines[0].points[0].position.clone(),end:e.lines[0].points[1].position.clone()},a.preview.lineStart),a.preview.lineEnd=(0,_geomutils.createGeomObject)({start:e.lines[1].points[0].position.clone(),end:e.lines[1].points[1].position.clone()},a.preview.lineEnd),a.sketcher.currentSketch.addAuxObject(a.preview.arc),a.sketcher.currentSketch.addAuxObject(a.preview.lineStart),a.sketcher.currentSketch.addAuxObject(a.preview.lineEnd)}function t(){a.preview.arc&&a.sketcher.currentSketch.removeAuxObject(a.preview.arc),a.preview.lineStart&&a.sketcher.currentSketch.removeAuxObject(a.preview.lineStart),a.preview.lineEnd&&a.sketcher.currentSketch.removeAuxObject(a.preview.lineEnd),a.preview=null}function n(e){var t=a.sketcher.modelData.interactionPoint.clone(),n=(0,_geomutils.drawArcBy_Angle_M)(e.vertex.position.clone(),e.arcEnds[0].position.clone().sub(e.vertex.position).normalize(),e.arcEnds[1].position.clone().sub(e.vertex.position).normalize(),t);n||(n={start:e.vertex.position.clone(),end:e.vertex.position.clone()}),n.clockwise=e.arc.clockwise;var r=e.lineEnds[0]===e.lines[0].points[0]?1:0,i=e.lineEnds[1]===e.lines[1].points[0]?1:0,o=Math.min(e.lines[0].points[r].position.clone().sub(e.vertex.position).length(),e.lines[1].points[i].position.clone().sub(e.vertex.position).length(),n.start.clone().sub(e.vertex.position).length());if(n.start.clone().sub(e.vertex.position).length()>o){n.start=n.start.clone().sub(e.vertex.position).normalize().multiplyScalar(o).add(e.vertex.position),n.end=n.end.clone().sub(e.vertex.position).normalize().multiplyScalar(o).add(e.vertex.position);var s=n.center.clone().sub(e.vertex.position).normalize(),c=n.start.clone().sub(e.vertex.position).angleTo(n.end.clone().sub(e.vertex.position));n.center=s.multiplyScalar(o/Math.cos(c/2)).add(e.vertex.position)}var l=a.preview.arc,u=(0,_geomutils.createGeomObject)(n,a.preview.arc);u!=l&&(l&&a.sketch.removeAuxObject(l),u&&(a.sketch.addAuxObject(u),a.preview.arc=u)),l=a.preview.lineStart,u=(0,_geomutils.createGeomObject)({start:e.lines[0].points[r].position.clone(),end:n.start.clone()},a.preview.lineStart),u!=l&&(l&&this.sketch.removeAuxObject(l),u&&(a.sketch.addAuxObject(u),a.preview.lineStart=u)),l=a.preview.lineEnd,u=(0,_geomutils.createGeomObject)({start:e.lines[1].points[i].position.clone(),end:n.end.clone()},a.preview.lineEnd),u!=l&&(l&&a.sketch.removeAuxObject(l),u&&(a.sketch.addAuxObject(u),a.preview.lineEnd=u))}function r(e){var t;e.interact.createInteraction({priority:10}).on((t={},t[_object2["default"].Events.Interaction.Hovered]=function(t){e.interact.hover(),c.refresh()},t[_object2["default"].Events.Interaction.Unhovered]=function(t){e.interact.unhover(),c.refresh()},t[_object2["default"].Events.Interaction.Clicked]=function(t){if(!a.busy){var n=a.processor.RecognizeFilletableAngle(e.position);if(n){var r=a.processor.CalculateFilletParamsByRadius(n,10);if(r)return a.busy=!0,a.processor.CreateNewFillet(n,r).then(function(){a.updateInteractiveObjects(),a.busy=!1})}}},t))}function i(r){var i;r.interact.createInteraction({priority:10}).on((i={},i[_object2["default"].Events.Interaction.Hovered]=function(e){r.interact.hover(),c.refresh()},i[_object2["default"].Events.Interaction.Unhovered]=function(e){r.interact.unhover(),c.refresh()},i[_object2["default"].Events.Interaction.Picked]=function(t){if(!a.busy){var n=a.processor.RecognizeFilletByArc(r);if(n){var i=a.sketcher.__parentView.interaction.shiftKey;if(!i){var o=a.processor.DeleteFillet(n);return o.then(function(){n.arc.interact.unhover(),a.updateInteractiveObjects(),a.busy=!1; })}a.busy=!0,c.__parentView.controls.enabled=!1,n.arc.interact.unhover(),n.arc.setVisible(!1),n.lines.forEach(function(e){return e.setVisible(!1)}),e(n),c.refresh(),a.busy=!1}}},i[_object2["default"].Events.Interaction.Dropped]=function(e){if(!a.busy&&a.preview){var n=a.processor.RecognizeFilletByArc(r);if(n){a.busy=!0;var i,o=a.preview.arc?a.preview.arc.radius:n.arc.radius,s=a.processor.CalculateFilletParamsByRadius(n,o);return i=a.preview.arc instanceof _geomobjects.Arc?a.processor.ChangeFillet(n,s):a.processor.DeleteFillet(n),t(),c.__parentView.controls.enabled=!0,n.lines.forEach(function(e){return e.setVisible(!0)}),i.then(function(){a.updateInteractiveObjects(),n.arc.setVisible(!0),n.arc.interact.unhover(),a.sketcher.refresh(),a.busy=!1})}}},i[_object2["default"].Events.Interaction.Dragged]=function(e){if(!a.busy&&a.preview){var t=a.processor.RecognizeFilletByArc(r);t&&n(t)}},i))}var o=this;this.clear();var s=this.sketcher.currentSketch.getObjectsOnSketch();_sketch2["default"].ForObjectsWithChildren(s,function(e){e instanceof _geomobjects.Point&&o.processor.RecognizeFilletableAngle(e.position)&&o.filletablePoints.push(e)}),s.forEach(function(e){e instanceof _geomobjects.Arc&&o.processor.RecognizeFilletByArc(e)&&o.filletArcs.push(e)});var a=this,c=a.sketcher;this.filletablePoints.forEach(r),this.filletArcs.forEach(i)},t.prototype.finish=function(){this.clear()},t}(baseHandler);