示例#1
0
        protected override SamplerStatus Sampler(JigPrompts prompts)
        {
            switch (mCurJigFactorNumber)
            {
            case 1:
                var promtOp1 = new JigPromptPointOptions
                {
                    UserInputControls = (UserInputControls.Accept3dCoordinates
                                         | UserInputControls.NoNegativeResponseAccepted
                                         | UserInputControls.NoZeroResponseAccepted
                                         | UserInputControls.NullResponseAccepted),
                    Message = "指定插入点: \n"
                };

                var prResult1 = prompts.AcquirePoint(promtOp1);
                if (prResult1.Value.Equals(mPosition))
                {
                    return(SamplerStatus.NoChange);
                }
                if (prResult1.Status == PromptStatus.OK)
                {
                    mPosition = prResult1.Value;
                    return(SamplerStatus.OK);
                }
                return(SamplerStatus.Cancel);

            case 2:
                if (bl)
                {
                    var promtOpt2 = new JigPromptAngleOptions
                    {
                        UserInputControls = UserInputControls.NullResponseAccepted,
                        BasePoint         = mPosition,
                        UseBasePoint      = true,
                        Cursor            = CursorType.RubberBand,
                        Message           = "指定旋转角度: \n"
                    };

                    var prResult2 = prompts.AcquireAngle(promtOpt2);

                    if (prResult2.Status == PromptStatus.OK)
                    {
                        if (prResult2.Value.Equals(mdeltaAngle))
                        {
                            return(SamplerStatus.NoChange);
                        }
                        mdeltaAngle = prResult2.Value;
                        return(SamplerStatus.OK);
                    }
                }
                return(SamplerStatus.Cancel);
            }
            return(SamplerStatus.OK);
        }
示例#2
0
文件: JigDrag.cs 项目: iamHXQ/Oy
        static SamplerStatus GetAngle(JigPrompts prompts)
        {
            var rst = prompts.AcquireAngle(_AngleOptions);

            _rst = rst;
            if (rst.Value != _double)
            {
                _double = rst.Value;
                return(SamplerStatus.OK);
            }
            else
            {
                return(SamplerStatus.NoChange);
            }
        }
            protected override SamplerStatus Sampler(JigPrompts prompts)
            {
                switch (mCurJigFactorNumber)
                {
                case 1:
                    JigPromptPointOptions prOptions1 = new JigPromptPointOptions("\nBlock position:");
                    PromptPointResult     prResult1  = prompts.AcquirePoint(prOptions1);
                    if (prResult1.Status == PromptStatus.Cancel)
                    {
                        return(SamplerStatus.Cancel);
                    }

                    if (prResult1.Value.Equals(mPosition))
                    {
                        return(SamplerStatus.NoChange);
                    }
                    else
                    {
                        mPosition = prResult1.Value;
                        return(SamplerStatus.OK);
                    }

                case 2:
                    JigPromptAngleOptions prOptions2 = new JigPromptAngleOptions("\nBlock rotation angle:");
                    prOptions2.BasePoint    = (Entity as BlockReference).Position;
                    prOptions2.UseBasePoint = true;
                    PromptDoubleResult prResult2 = prompts.AcquireAngle(prOptions2);
                    if (prResult2.Status == PromptStatus.Cancel)
                    {
                        return(SamplerStatus.Cancel);
                    }

                    if (prResult2.Value.Equals(mRotation))
                    {
                        return(SamplerStatus.NoChange);
                    }
                    else
                    {
                        mRotation = prResult2.Value;
                        return(SamplerStatus.OK);
                    }

                default:
                    break;
                }

                return(SamplerStatus.OK);
            }
示例#4
0
        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);
        }
示例#5
0
            protected override SamplerStatus Sampler(JigPrompts prompts)
            {
                JigPromptAngleOptions jpao = new JigPromptAngleOptions(Environment.NewLine + "Specify the rotation: ")
                {
                    DefaultValue      = 0.0,
                    UseBasePoint      = true,
                    BasePoint         = this.BlockRef.Position,
                    Cursor            = CursorType.RubberBand,
                    UserInputControls = (UserInputControls.Accept3dCoordinates | UserInputControls.UseBasePointElevation | UserInputControls.NullResponseAccepted)
                };
                PromptDoubleResult pdr = prompts.AcquireAngle(jpao);

                if (this.Rot == pdr.Value)
                {
                    return(SamplerStatus.NoChange);
                }
                else
                {
                    this.Rot = pdr.Value;
                }
                return(SamplerStatus.OK);
            }
示例#6
0
            protected override SamplerStatus Sampler(JigPrompts prompts)
            {
                //throw new System.Exception("The method or operation is not implemented.");


                if (GetPoint)
                {
                    JigPromptPointOptions jppo = new JigPromptPointOptions("Select Measeared jackpanel Position : \n");

                    jppo.UserInputControls = (UserInputControls.Accept3dCoordinates |
                                              UserInputControls.NullResponseAccepted |
                                              UserInputControls.NoNegativeResponseAccepted);

                    PromptPointResult ppr = prompts.AcquirePoint(jppo);

                    if (ppr.Status == PromptStatus.OK)
                    {
                        Point2d NewPoint = new Point2d(ppr.Value.X, ppr.Value.Y);

                        if (NewPoint.IsEqualTo(BasePoint))
                        {
                            //v2d = new Vector2d(0, 0);

                            return(SamplerStatus.NoChange);
                        }
                        else
                        {
                            //v2d = BasePoint - NewPoint;

                            BasePoint = new Point2d(ppr.Value.X, ppr.Value.Y);

                            //ed.WriteMessage("POINT OK. \n");

                            return(SamplerStatus.OK);
                        }
                    }
                    else
                    {
                        //v2d = new Vector2d(0, 0);

                        return(SamplerStatus.Cancel);
                    }
                }
                else if (GetAngle)
                {
                    JigPromptAngleOptions jpao = new JigPromptAngleOptions("Select Measured jackpanel Angle : \n");

                    jpao.UseBasePoint = true;

                    jpao.BasePoint = new Point3d(BasePoint.X, BasePoint.Y, 0);

                    PromptDoubleResult pdr = prompts.AcquireAngle(jpao);

                    if (pdr.Status == PromptStatus.OK)
                    {
                        if (pdr.Value == NewAngle)
                        {
                            return(SamplerStatus.NoChange);
                        }
                        else
                        {
                            NewAngle = pdr.Value;// -NewAngle;

                            return(SamplerStatus.OK);
                        }
                    }
                    else
                    {
                        return(SamplerStatus.Cancel);
                    }
                }

                return(SamplerStatus.NoChange);
            }
            /// <inheritdoc />
            protected override SamplerStatus Sampler(JigPrompts prompts)
            {
                switch (_promptCounter)
                {
                case 0:
                {
                    var jigOpts = new JigPromptPointOptions($"\n{Language.GetItem(LangItem, "msg13")}:");
                    jigOpts.UserInputControls =
                        UserInputControls.Accept3dCoordinates |
                        UserInputControls.NoZeroResponseAccepted |
                        UserInputControls.NoNegativeResponseAccepted;
                    var res = prompts.AcquirePoint(jigOpts);
                    var pnt = res.Value;
                    if (pnt != _position)
                    {
                        _position  = pnt;
                        _basePoint = _position;
                    }
                    else
                    {
                        return(SamplerStatus.NoChange);
                    }

                    if (res.Status == PromptStatus.Cancel)
                    {
                        return(SamplerStatus.Cancel);
                    }

                    return(SamplerStatus.OK);
                }

                case 1:
                {
                    var jigOpts = new JigPromptAngleOptions($"\n{Language.GetItem(LangItem, "msg14")}:");
                    jigOpts.UserInputControls =
                        UserInputControls.Accept3dCoordinates |
                        UserInputControls.NoNegativeResponseAccepted |
                        UserInputControls.GovernedByUCSDetect |
                        UserInputControls.UseBasePointElevation;
                    jigOpts.Cursor       = CursorType.RubberBand;
                    jigOpts.UseBasePoint = true;
                    jigOpts.BasePoint    = _basePoint;
                    var res       = prompts.AcquireAngle(jigOpts);
                    var angleTemp = res.Value;
                    if (Math.Abs(angleTemp - _angle) > Tolerance.Global.EqualVector)
                    {
                        _angle = angleTemp;
                    }
                    else
                    {
                        return(SamplerStatus.NoChange);
                    }

                    if (res.Status == PromptStatus.Cancel)
                    {
                        return(SamplerStatus.Cancel);
                    }

                    return(SamplerStatus.OK);
                }

                default:
                    return(SamplerStatus.NoChange);
                }
            }
示例#8
0
        // 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);
        }
示例#9
0
 // 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);
     }
 }