protected override SamplerStatus Sampler(JigPrompts prompts) { switch (mCurJigFactorNumber) { case 1: JigPromptDistanceOptions opts = new JigPromptDistanceOptions("\nAdjust Elevation"); opts.BasePoint = Entity.Location; opts.UseBasePoint = true; PromptDoubleResult pdr = prompts.AcquireDistance(opts); if (pdr.Status == PromptStatus.Cancel) { return(SamplerStatus.Cancel); } if (pdr.Value.Equals(mElevAdj)) { return(SamplerStatus.NoChange); } else { mElevAdj = pdr.Value; return(SamplerStatus.OK); } default: break; } return(SamplerStatus.OK); }
protected override SamplerStatus Sampler(JigPrompts prompts) { switch (step) { case 1: JigPromptPointOptions prOptions1 = new JigPromptPointOptions("\n圆心:"); PromptPointResult prResult1 = prompts.AcquirePoint(prOptions1); if (prResult1.Status == PromptStatus.Cancel) { return(SamplerStatus.Cancel); } if (prResult1.Value.Equals(_center)) { return(SamplerStatus.NoChange); } else { _center = prResult1.Value; return(SamplerStatus.OK); } case 2: JigPromptDistanceOptions prOptions2 = new JigPromptDistanceOptions("\n半径:"); prOptions2.BasePoint = _center; PromptDoubleResult prResult2 = prompts.AcquireDistance(prOptions2); if (prResult2.Status == PromptStatus.Cancel) { return(SamplerStatus.Cancel); } if (prResult2.Value.Equals(_radius)) { return(SamplerStatus.NoChange); } else { if (prResult2.Value < 0.0001) { return(SamplerStatus.NoChange); } else { _radius = prResult2.Value; return(SamplerStatus.OK); } } default: break; } return(SamplerStatus.OK); }
protected override SamplerStatus Sampler(JigPrompts prompts) { switch (CurrentInput) { // get the center point of the circle. case 0: Point3d oldPnt = centerPoint; PromptPointResult jigPromptResult = prompts.AcquirePoint("Pick the center point: "); if (jigPromptResult.Status == PromptStatus.OK) { centerPoint = jigPromptResult.Value; if (oldPnt.DistanceTo(centerPoint) < 0.0001) { return(SamplerStatus.NoChange); } } break; // get the radius of the circle. case 1: double oldRadius = radius; JigPromptDistanceOptions jigPromptDistance = new JigPromptDistanceOptions("Pick the radius: "); jigPromptDistance.UseBasePoint = true; jigPromptDistance.BasePoint = centerPoint; PromptDoubleResult jigPromptRadiusResult = prompts.AcquireDistance(jigPromptDistance); if (jigPromptRadiusResult.Status == PromptStatus.OK) { radius = jigPromptRadiusResult.Value; if (Math.Abs(radius) < 0.01) { radius = 1; } if (Math.Abs(oldRadius - radius) < 0.0001) { return(SamplerStatus.NoChange); } } break; } return(SamplerStatus.OK); }
static SamplerStatus GetDistance(JigPrompts prompts) { var rst = prompts.AcquireDistance(_DistanceOptions); _rst = rst; if (rst.Value != _double) { _double = rst.Value; return(SamplerStatus.OK); } else { return(SamplerStatus.NoChange); } }
protected override SamplerStatus Sampler(JigPrompts prompts) { if (!_pointAcquired) //insert point { JigPromptPointOptions jigOpts = new JigPromptPointOptions(); jigOpts.Message = "\nSelect insert point: "; jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates | UserInputControls.NullResponseAccepted | UserInputControls.NoNegativeResponseAccepted); jigOpts.BasePoint = Point3d.Origin; jigOpts.UseBasePoint = true; PromptPointResult jigPoint = prompts.AcquirePoint(jigOpts); if (jigPoint.Status != PromptStatus.OK) { return(SamplerStatus.Cancel); } if (_insertPoint.DistanceTo(jigPoint.Value) < 0.1) { return(SamplerStatus.NoChange); } _insertPoint = jigPoint.Value; } else //scale { JigPromptDistanceOptions jigOpts = new JigPromptDistanceOptions(); jigOpts.UserInputControls = UserInputControls.GovernedByOrthoMode; jigOpts.BasePoint = _insertPoint; jigOpts.UseBasePoint = true; jigOpts.Message = "\nSpecify size: "; PromptDoubleResult jigScale = prompts.AcquireDistance(jigOpts); if (jigScale.Status != PromptStatus.OK) { return(SamplerStatus.Cancel); } double delta = _previousScale - jigScale.Value; if (delta < 0.0) { delta *= -1; } if (delta < 0.01) { return(SamplerStatus.NoChange); } _scale = jigScale.Value; } return(SamplerStatus.OK); }
protected override SamplerStatus Sampler(JigPrompts prompts) { string jigResultValue = null; if (this.Options is JigPromptPointOptions pointOptions) { var result = prompts.AcquirePoint(pointOptions); this.JigResult = result; jigResultValue = result.Value.ToString(); } else if (this.Options is JigPromptDistanceOptions distanceOptions) { var result = prompts.AcquireDistance(distanceOptions); this.JigResult = result; jigResultValue = result.Value.ToString(); } else if (this.Options is JigPromptAngleOptions angleOptions) { var result = prompts.AcquireAngle(angleOptions); this.JigResult = result; jigResultValue = result.Value.ToString(); } else if (this.Options is JigPromptStringOptions stringOptions) { var result = prompts.AcquireString(stringOptions); this.JigResult = result; jigResultValue = result.StringResult; } if (jigResultValue == null) { return(SamplerStatus.Cancel); } else if (jigResultValue != this.JigResultValue) { this.JigResultValue = jigResultValue; return(SamplerStatus.OK); } return(SamplerStatus.NoChange); }
protected override SamplerStatus Sampler(JigPrompts prompts) { var jigOpt = new JigPromptDistanceOptions(); jigOpt.BasePoint = Circ1.Center; jigOpt.UseBasePoint = true; if (Step == 1) { jigOpt.Message = "\n请确定第一圈"; var res = prompts.AcquireDistance(jigOpt); if (res.Value != Circ1.Radius) { if (res.Value == 0) { Circ1.Radius = 0.1; } else { Circ1.Radius = res.Value; } } else { return(SamplerStatus.NoChange); } if (res.Status == PromptStatus.OK) { return(SamplerStatus.OK); } else { return(SamplerStatus.Cancel); } } if (Step == 2) { jigOpt.Message = "\n请确定第二圈"; var res = prompts.AcquireDistance(jigOpt); if (res.Value != Circ2.Radius) { if (res.Value == 0) { Circ2.Radius = 0.1; } else { Circ2.Radius = res.Value; } } else { return(SamplerStatus.NoChange); } if (res.Status == PromptStatus.OK) { return(SamplerStatus.OK); } else { return(SamplerStatus.Cancel); } } return(SamplerStatus.Cancel); }
// EntityJig protocol protected override SamplerStatus Sampler(JigPrompts prompts) { // Get the current phase var p = _phases[_phase]; // If we're dealing with a geometry-typed phase (distance, // point or angle input) we can use some common code var gp = p as GeometryPhase; if (gp != null) { JigPromptGeometryOptions opts; if (gp is DistancePhase) { opts = new JigPromptDistanceOptions(); } else if (gp is AnglePhase) { opts = new JigPromptAngleOptions(); } else if (gp is PointPhase) { opts = new JigPromptPointOptions(); } else // Should never happen { opts = null; } // Set up the user controls opts.UserInputControls = (UserInputControls.Accept3dCoordinates | UserInputControls.NoZeroResponseAccepted | UserInputControls.NoNegativeResponseAccepted); // All our distance inputs will be with a base point // (which means the initial base point or an offset from // that) opts.UseBasePoint = true; opts.Cursor = CursorType.RubberBand; opts.Message = p.Message; opts.BasePoint = (gp.Offset == null ? _pt.TransformBy(_ucs) : (_pt + gp.Offset.Invoke(_phases, _pt)).TransformBy(_ucs)); // The acquisition method varies on the phase type if (gp is DistancePhase) { var phase = (DistancePhase)gp; var pdr = prompts.AcquireDistance((JigPromptDistanceOptions)opts); if (pdr.Status == PromptStatus.OK) { // If the difference between the new value and its // previous value is negligible, return "no change" if (System.Math.Abs((double)phase.Value - pdr.Value) < Tolerance.Global.EqualPoint) { return(SamplerStatus.NoChange); } // Otherwise we update the appropriate variable // based on the phase phase.Value = pdr.Value; _phases[_phase] = phase; return(SamplerStatus.OK); } } else if (gp is PointPhase) { var phase = (PointPhase)gp; var ppr = prompts.AcquirePoint((JigPromptPointOptions)opts); if (ppr.Status == PromptStatus.OK) { // If the difference between the new value and its // previous value is negligible, return "no change" var tmp = ppr.Value.TransformBy(_ucs.Inverse()); if (tmp.DistanceTo((Point3d)phase.Value) < Tolerance.Global.EqualPoint) { return(SamplerStatus.NoChange); } // Otherwise we update the appropriate variable // based on the phase phase.Value = tmp; _phases[_phase] = phase; return(SamplerStatus.OK); } } else if (gp is AnglePhase) { var phase = (AnglePhase)gp; var par = prompts.AcquireAngle((JigPromptAngleOptions)opts); if (par.Status == PromptStatus.OK) { // If the difference between the new value and its // previous value is negligible, return "no change" if ((double)phase.Value - par.Value < Tolerance.Global.EqualPoint) { return(SamplerStatus.NoChange); } // Otherwise we update the appropriate variable // based on the phase phase.Value = par.Value; _phases[_phase] = phase; return(SamplerStatus.OK); } } } else { // p is StringPhase var phase = (StringPhase)p; var psr = prompts.AcquireString(p.Message); if (psr.Status == PromptStatus.OK) { phase.Value = psr.StringResult; _phases[_phase] = phase; return(SamplerStatus.OK); } } return(SamplerStatus.Cancel); }
// Override the Sampler function. protected override SamplerStatus Sampler(JigPrompts prompts) { // Create a switch statement. switch (currentInputValue) { // se 0 (zero) for the case. (getting center for the circle) case 0: Point3d oldPnt = centerPoint; PromptPointResult jigPromptResult = prompts.AcquirePoint("Pick center point : "); // Check the status of the PromptPointResult if (jigPromptResult.Status == PromptStatus.OK) { // Make the centerPoint member variable equal to the Value // property of the PromptPointResult centerPoint = jigPromptResult.Value; // Check to see if the cursor has moved. if ((oldPnt.DistanceTo(centerPoint) < 0.001)) { // If we get here then there has not been any change to the location // return SamplerStatus.NoChange return(SamplerStatus.NoChange); } } // If the code gets here than there has been a change in the location so // return SamplerStatus.OK return(SamplerStatus.OK); // Use 1 for the case. (getting radius for the circle) case 1: double oldRadius = radius; JigPromptDistanceOptions jigPromptDistanceOpts = new JigPromptDistanceOptions("Pick radius : "); jigPromptDistanceOpts.UseBasePoint = true; jigPromptDistanceOpts.BasePoint = centerPoint; // Now we ready to get input. PromptDoubleResult jigPromptDblResult = prompts.AcquireDistance(jigPromptDistanceOpts); // Check the status of the PromptDoubleResult if ((jigPromptDblResult.Status == PromptStatus.OK)) { radius = jigPromptDblResult.Value; // Check to see if the radius is too small if (Math.Abs(radius) < 0.1) { // Make the Member variable radius = to 1. This is // just an arbitrary value to keep the circle from being too small radius = 1; } // Check to see if the cursor has moved. if ((Math.Abs(oldRadius - radius) < 0.001)) { // If we get here then there has not been any change to the location // Return SamplerStatus.NoChange return(SamplerStatus.NoChange); } } // If we get here the cursor has moved. return SamplerStatus.OK return(SamplerStatus.OK); } // Return SamplerSataus.NoChange. This will not ever be hit as we are returning // in the switch statement. (just avoiding the compile error) return(SamplerStatus.NoChange); }
// Sampler函数用于检测用户的输入. protected override SamplerStatus Sampler(JigPrompts prompts) { if (mPromptCounter == 0) { // 定义一个点拖动交互类. JigPromptPointOptions optJigPoint = new JigPromptPointOptions("\n请指定椭圆弧轴上一点"); // 设置拖拽的光标类型. optJigPoint.Cursor = CursorType.RubberBand; // 设置拖动光标基点. optJigPoint.BasePoint = mCenterPt; optJigPoint.UseBasePoint = true; // 用AcquirePoint函数得到用户输入的点. PromptPointResult resJigPoint = prompts.AcquirePoint(optJigPoint); Point3d curPt = resJigPoint.Value; if (curPt != mMajorPt) { // mMajorPt = curPt; } else { return(SamplerStatus.NoChange); } if (resJigPoint.Status == PromptStatus.Cancel) { return(SamplerStatus.Cancel); } else { return(SamplerStatus.OK); } } else if (mPromptCounter == 1) { // 定义一个距离拖动交互类. JigPromptDistanceOptions optJigDis = new JigPromptDistanceOptions("\n请指定另一条半轴的长度"); // 设置对拖拽的约束:禁止输入零和负值. optJigDis.UserInputControls = UserInputControls.NoZeroResponseAccepted | UserInputControls.NoNegativeResponseAccepted; // 设置拖拽的光标类型. optJigDis.Cursor = CursorType.RubberBand; // 设置拖动光标基点. optJigDis.BasePoint = mCenterPt; optJigDis.UseBasePoint = true; // 用AcquireDistance函数得到用户输入的距离值. PromptDoubleResult resJigDis = prompts.AcquireDistance(optJigDis); double mRadiusRatioTemp = resJigDis.Value; if (mRadiusRatioTemp != mRadiusRatio) { // 保存当前距离值. mRadiusRatio = mRadiusRatioTemp; } else { return(SamplerStatus.NoChange); } if (resJigDis.Status == PromptStatus.Cancel) { return(SamplerStatus.Cancel); } else { return(SamplerStatus.OK); } } else if (mPromptCounter == 2) { // 设置椭圆弧0度基准角. double baseAng; Vector2d mMajorAxis2d = new Vector2d(mMajorAxis.X, mMajorAxis.Y); if (radiusRatio < 1) { baseAng = mMajorAxis2d.Angle; } else { baseAng = mMajorAxis2d.Angle + 0.5 * Math.PI; } // 设置系统变量“ANGBASE”. Application.SetSystemVariable("ANGBASE", baseAng); // 定义一个角度拖动交互类. JigPromptAngleOptions optJigAngle1 = new JigPromptAngleOptions("\n请指定椭圆弧的起始角度"); // 设置拖拽的光标类型. optJigAngle1.Cursor = CursorType.RubberBand; // 设置拖动光标基点. optJigAngle1.BasePoint = mCenterPt; optJigAngle1.UseBasePoint = true; // 用AcquireAngle函数得到用户输入的角度值. PromptDoubleResult resJigAngle1 = prompts.AcquireAngle(optJigAngle1); ang1 = resJigAngle1.Value; if (startAng != ang1) { // 保存当前角度值. startAng = ang1; } else { return(SamplerStatus.NoChange); } if (resJigAngle1.Status == PromptStatus.Cancel) { return(SamplerStatus.Cancel); } else { return(SamplerStatus.OK); } } else if (mPromptCounter == 3) { // 定义一个角度拖动交互类. JigPromptAngleOptions optJigAngle2 = new JigPromptAngleOptions("\n请指定椭圆弧的终止角度"); // 设置拖拽的光标类型. optJigAngle2.Cursor = CursorType.RubberBand; // 设置拖动光标基点. optJigAngle2.BasePoint = mCenterPt; optJigAngle2.UseBasePoint = true; // 用AcquireAngle函数得到用户输入的角度值. PromptDoubleResult resJigAngle2 = prompts.AcquireAngle(optJigAngle2); ang2 = resJigAngle2.Value; if (endAng != ang2) { // 保存当前角度值. endAng = ang2; } else { return(SamplerStatus.NoChange); } if (resJigAngle2.Status == PromptStatus.Cancel) { return(SamplerStatus.Cancel); } else { return(SamplerStatus.OK); } } else { return(SamplerStatus.NoChange); } }