Beispiel #1
0
        /// <inheritdoc />
        public override void GetGripPoints(
            Entity entity, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
        {
            try
            {
                if (IsApplicable(entity))
                {
                    // Удаляю все ручки - это удалит ручку вставки блока
                    grips.Clear();

                    var nodalLeader = EntityReaderService.Instance.GetFromEntity <SecantNodalLeader>(entity);
                    if (nodalLeader != null)
                    {
                        grips.Add(new SecantNodalLeaderGrip(
                                      nodalLeader, GripType.BasePoint, GripName.InsertionPoint, nodalLeader.InsertionPoint));
                        grips.Add(new SecantNodalLeaderGrip(
                                      nodalLeader, GripType.Point, GripName.LeaderPoint, nodalLeader.EndPoint));

                        grips.Add(new SecantNodalLevelShelfPositionGrip(nodalLeader)
                        {
                            GripPoint = nodalLeader.EndPoint +
                                        (Vector3d.YAxis * ((nodalLeader.MainTextHeight + nodalLeader.TextVerticalOffset) * nodalLeader.GetFullScale())),
                            GripType = GripType.TwoArrowsLeftRight
                        });
                    }
                }
            }
            catch (Exception exception)
            {
                if (exception.ErrorStatus != ErrorStatus.NotAllowedForThisProxy)
                {
                    ExceptionBox.Show(exception);
                }
            }
        }
        public override void GetGripPoints(Entity entity,
                                           GripDataCollection grips, double curViewUnitSize,
                                           int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
        {
            var donut = entity as Circle;

            if (donut != null)
            {
                var xdata = donut.GetXData(CommandClass.AppName);
                if (xdata != null && xdata.Length > 0)
                {
                    var outRad = (double)xdata[0].Value;

                    grips.Add(new DonutOutGripData()
                    {
                        GripPoint = donut.Center + (Vector3d.XAxis * outRad).RotateBy(Math.PI / 4, Vector3d.ZAxis)
                    });
                    grips.Add(new DonutOutGripData()
                    {
                        GripPoint = donut.Center - (Vector3d.XAxis * outRad).RotateBy(Math.PI / 4, Vector3d.ZAxis)
                    });
                    grips.Add(new DonutOutGripData()
                    {
                        GripPoint = donut.Center + (Vector3d.YAxis * outRad).RotateBy(Math.PI / 4, Vector3d.ZAxis)
                    });
                    grips.Add(new DonutOutGripData()
                    {
                        GripPoint = donut.Center - (Vector3d.YAxis * outRad).RotateBy(Math.PI / 4, Vector3d.ZAxis)
                    });

/*
 *                  grips.Add(new DonutInGripData()
 *                  {
 *                      GripPoint = donut.Center + (Vector3d.XAxis * donut.Radius)
 *                  });
 *                  grips.Add(new DonutInGripData()
 *                  {
 *                      GripPoint = donut.Center - (Vector3d.XAxis * donut.Radius)
 *                  });
 *                  grips.Add(new DonutInGripData()
 *                  {
 *                      GripPoint = donut.Center + (Vector3d.YAxis * donut.Radius)
 *                  });
 *                  grips.Add(new DonutInGripData()
 *                  {
 *                      GripPoint = donut.Center - (Vector3d.YAxis * donut.Radius)
 *                  });*/
                }
            }

            base.GetGripPoints(entity, grips, curViewUnitSize, gripSize,
                               curViewDir, bitFlags);
        }
Beispiel #3
0
        public override void GetGripPoints(Entity entity, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
        {
            var wall = entity as Line;

            if (wall != null)
            {
                grips.Add(new WallGripData {
                    GripPoint = wall.StartPoint, IsStartPoint = true
                });
                grips.Add(new WallGripData {
                    GripPoint = wall.EndPoint, IsStartPoint = false
                });
            }
        }
        /// <inheritdoc />
        public override void GetGripPoints(
            Entity entity, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
        {
            try
            {
                if (IsApplicable(entity))
                {
                    // Удаляю все ручки - это удалит ручку вставки блока
                    grips.Clear();

                    var groundLine = EntityReaderService.Instance.GetFromEntity <GroundLine>(entity);
                    if (groundLine != null)
                    {
                        foreach (var grip in EntityUtils.GetLinearEntityGeneralGrips(groundLine, curViewUnitSize))
                        {
                            grips.Add(grip);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                if (exception.ErrorStatus != ErrorStatus.NotAllowedForThisProxy)
                {
                    ExceptionBox.Show(exception);
                }
            }
        }
        //获取夹点,简单实体应重载该函数以获取更灵活的控制
        public override void GetGripPoints(Entity entity, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
        {
            LArrow3 la = new LArrow3(entity);

            base.GetGripPoints(entity, grips, curViewUnitSize, gripSize, curViewDir, bitFlags);
            grips.Remove(grips[2]);
            grips.Add(new LArrowGripData3(la.Position));
        }
        /*public override void GetGripPoints(Entity entity, Point3dCollection gripPoints, IntegerCollection snapModes, IntegerCollection geometryIds)
         * {
         *  gripPoints.Add(_getCustomGrip(entity));
         *  base.GetGripPoints(entity, gripPoints, snapModes, geometryIds);
         * }*/

        public override void GetGripPoints(Entity entity, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
        {
            ArrowGripData gdata = new ArrowGripData();

            gdata.GripPoint = _getCustomGrip(entity);
            grips.Add(gdata);
            base.GetGripPoints(entity, grips, curViewUnitSize, gripSize, curViewDir, bitFlags);
        }
Beispiel #7
0
        /// <inheritdoc />
        public override void GetGripPoints(
            Entity entity, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
        {
            try
            {
                if (IsApplicable(entity))
                {
                    // Удаляю все ручки - это удалит ручку вставки блока
                    grips.Clear();

                    var levelMark = EntityReaderService.Instance.GetFromEntity <LevelMark>(entity);
                    if (levelMark != null)
                    {
                        grips.Add(new LevelMarkGrip(
                                      levelMark, GripType.BasePoint, LevelMarkGripName.BasePoint, levelMark.InsertionPoint));
                        grips.Add(new LevelMarkGrip(
                                      levelMark, GripType.Point, LevelMarkGripName.ObjectPoint, levelMark.ObjectPoint));
                        grips.Add(new LevelMarkGrip(
                                      levelMark, GripType.Point, LevelMarkGripName.BottomShelfStartPoint, levelMark.BottomShelfStartPoint));
                        grips.Add(new LevelMarkGrip(
                                      levelMark, GripType.Point, LevelMarkGripName.ArrowPoint, levelMark.EndPoint));
                        grips.Add(new LevelMarkGrip(
                                      levelMark, GripType.Point, LevelMarkGripName.TopShelfPoint, levelMark.ShelfPoint));

                        _cachedBottomShelfLength = Math.Abs(levelMark.EndPoint.X - levelMark.BottomShelfStartPoint.X);
                    }
                }
            }
            catch (Exception exception)
            {
                if (exception.ErrorStatus != ErrorStatus.NotAllowedForThisProxy)
                {
                    ExceptionBox.Show(exception);
                }
            }
        }
        /*public override void GetGripPoints(Entity entity, Point3dCollection gripPoints, IntegerCollection snapModes, IntegerCollection geometryIds)
         * {
         *  gripPoints.Add(_getCustomGrip(entity));
         *  base.GetGripPoints(entity, gripPoints, snapModes, geometryIds);
         * }*/

        public override void GetGripPoints(Entity entity, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
        {
            ArrowGripData gdata = new ArrowGripData();

            gdata.GripPoint = _getCustomGrip(entity);
            grips.Add(gdata);
            base.GetGripPoints(entity, grips, curViewUnitSize, gripSize, curViewDir, bitFlags);
#if DEBUG
            IgorKL.ACAD3.Model.Drawing.AnchorArrow.Arrow.SafeObject so =
                (IgorKL.ACAD3.Model.Drawing.AnchorArrow.Arrow.SafeObject)Model.Drawing.AnchorArrow.Arrow.SafeObject.NewFromEntity(entity, Model.Drawing.AnchorArrow.Arrow.SafeObject.AppName);

            _entities = so.Object.Explode().Select(x => x.GetTransformedCopy(Tools.GetAcadEditor().CurrentUserCoordinateSystem));
            //IgorKL.ACAD3.Model.Tools.AppendEntity(so.Object.Explode());
#endif
        }
Beispiel #9
0
        private void SetCableTrayBottomHeight(Entity ent, Vector3d offset, Point3d gripPoint)
        {
            GripDataCollection grips           = new GripDataCollection();
            GripDataCollection updateGrip      = new GripDataCollection();
            double             curViewUnitSize = 0;
            int                gripSize        = 0;
            Vector3d           curViewDir      = acDoc.Editor.GetCurrentView().ViewDirection;
            GetGripPointsFlags bitFlags        = GetGripPointsFlags.GripPointsOnly;

            ent.GetGripPoints(grips, curViewUnitSize, gripSize, curViewDir, bitFlags);
            foreach (GripData grip in grips)
            {
                if (grip.GripPoint == gripPoint)
                {
                    updateGrip.Add(grip);
                }
            }
            ent.MoveGripPointsAt(updateGrip, offset, MoveGripPointsFlags.Polar);
        }
Beispiel #10
0
            public override void GetGripPoints(Entity entity, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, Autodesk.AutoCAD.DatabaseServices.GetGripPointsFlags bitFlags)
            {
                base.GetGripPoints(entity, grips, curViewUnitSize, gripSize, curViewDir, bitFlags);

                Circle c = (Circle)entity;

                LineSegment3d[] lines = GetLines(c);
                m_grips[0]           = new LowerLeftGrip();
                m_grips[0].GripPoint = lines[0].StartPoint;
                m_grips[1]           = new UpperRightGrip();
                m_grips[1].GripPoint = lines[0].EndPoint;
                m_grips[2]           = new UpperLeftGrip();
                m_grips[2].GripPoint = lines[1].StartPoint;
                m_grips[3]           = new LowerRightGrip();
                m_grips[3].GripPoint = lines[1].EndPoint;
                foreach (GripData g in m_grips)
                {
                    grips.Add(g);
                }
            }
Beispiel #11
0
 //获取夹点,简单实体应重载该函数以获取更灵活的控制
 public override void GetGripPoints(Entity entity, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
 {
     try
     {
         objectId = entity.ObjectId;
         if (objectId.IsErased)
         {
             return;
         }
         if (entity is BlockReference)
         {
             var  brf = entity as BlockReference;
             bool b   = FeatureGripsMapping.instance.grips.ContainsKey(brf.Name);
             if (b)
             {
                 double xdist1 = FeatureGripsMapping.instance.grips[brf.Name].xdistn1;
                 double ydist1 = FeatureGripsMapping.instance.grips[brf.Name].ydistn1;
                 double xdist2 = FeatureGripsMapping.instance.grips[brf.Name].xdistn2;
                 double ydist2 = FeatureGripsMapping.instance.grips[brf.Name].ydistn2;
                 //double startAngle = FeatureGripsMapping.instance.grips[brf.Name].angle;
                 //grips.Remove(grips[2]);
                 pt1 = new Point3d(brf.Position.X + xdist1, brf.Position.Y + ydist1, 0);
                 pt2 = new Point3d(brf.Position.X + xdist2, brf.Position.Y + ydist2, 0);
                 pt1 = pt1.RotateBy(brf.Rotation /* + Math.PI / 180 *startAngle*/, Vector3d.ZAxis, brf.Position);
                 pt2 = pt2.RotateBy(brf.Rotation /* + Math.PI / 180 * startAngle*/, Vector3d.ZAxis, brf.Position);
                 grips.Add(new UserGripData(pt1));
                 if (pt2 != brf.Position)
                 {
                     grips.Add(new UserGripData(pt2));
                 }
                 // 取出当前窗口大小
                 var viewsize = (double)Application.GetSystemVariable("VIEWSIZE");
                 // 得到当前选择集的集合
                 var sset = entity.Database.GetEditor().SelectImplied().Value;
                 if (sset != null)
                 {
                     var objIds = sset.GetObjectIds();
                     if (objIds.Any())
                     {
                         var sels = objIds.Last(); //
                         if (viewsize <= 0.00025)
                         {
                             if (selents != sels)
                             {
                                 selents = sels;
                                 snapDevs(entity.ObjectId);
                             }
                         }
                     }
                 }
             }
             else
             {
                 //pt1 = pt2 = Point3d.Origin;
                 pt1 = pt2 = brf.Position;
                 nods1.Clear(); nods2.Clear();
             }
             base.GetGripPoints(entity, grips, curViewUnitSize, gripSize, curViewDir, bitFlags);
         }
         else if (entity is DBText)
         {
             var txt = entity as DBText;
             grips.Add(new UserGripData(txt.Position));
         }
         else if (entity is MText)
         {
             var txt = entity as MText;
             grips.Add(new UserGripData(txt.Location));
         }
     }
     catch (System.Exception ex)
     {
         PublicMethod.Instance.Editor.WriteMessageWithReturn("UserGripOverrule::GetGripPoints :" + ex.Message + "\n");
     }
 }
        /// <inheritdoc />
        public override void GetGripPoints(
            Entity entity, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
        {
            try
            {
                if (IsApplicable(entity))
                {
                    // Удаляю все ручки - это удалит ручку вставки блока
                    grips.Clear();

                    var section = EntityReaderService.Instance.GetFromEntity <Section>(entity);
                    if (section != null)
                    {
                        // insertion (start) grip
                        var vertexGrip = new SectionVertexGrip(section, 0)
                        {
                            GripPoint = section.InsertionPoint
                        };
                        grips.Add(vertexGrip);

                        // middle points
                        for (var index = 0; index < section.MiddlePoints.Count; index++)
                        {
                            vertexGrip = new SectionVertexGrip(section, index + 1)
                            {
                                GripPoint = section.MiddlePoints[index]
                            };
                            grips.Add(vertexGrip);

                            var removeVertexGrip = new SectionRemoveVertexGrip(section, index + 1)
                            {
                                GripPoint = section.MiddlePoints[index] - (Vector3d.YAxis * 20 * curViewUnitSize)
                            };
                            grips.Add(removeVertexGrip);
                        }

                        // end point
                        vertexGrip = new SectionVertexGrip(section, section.MiddlePoints.Count + 1)
                        {
                            GripPoint = section.EndPoint
                        };
                        grips.Add(vertexGrip);

                        #region AddVertex grips

                        // add vertex grips
                        for (var i = 0; i < section.MiddlePoints.Count; i++)
                        {
                            if (i == 0)
                            {
                                var addVertexGrip = new SectionAddVertexGrip(
                                    section,
                                    section.InsertionPoint, section.MiddlePoints[i])
                                {
                                    GripPoint = GeometryUtils.GetMiddlePoint3d(section.InsertionPoint, section.MiddlePoints[i])
                                };
                                grips.Add(addVertexGrip);
                            }
                            else
                            {
                                var addVertexGrip = new SectionAddVertexGrip(
                                    section,
                                    section.MiddlePoints[i - 1], section.MiddlePoints[i])
                                {
                                    GripPoint = GeometryUtils.GetMiddlePoint3d(section.MiddlePoints[i - 1], section.MiddlePoints[i])
                                };
                                grips.Add(addVertexGrip);
                            }

                            // last segment
                            if (i == section.MiddlePoints.Count - 1)
                            {
                                var addVertexGrip = new SectionAddVertexGrip(
                                    section,
                                    section.MiddlePoints[i], section.EndPoint)
                                {
                                    GripPoint = GeometryUtils.GetMiddlePoint3d(section.MiddlePoints[i], section.EndPoint)
                                };
                                grips.Add(addVertexGrip);
                            }
                        }

                        if (!section.MiddlePoints.Any())
                        {
                            var addVertexGrip = new SectionAddVertexGrip(section, section.InsertionPoint, section.EndPoint)
                            {
                                GripPoint = GeometryUtils.GetMiddlePoint3d(section.InsertionPoint, section.EndPoint)
                            };
                            grips.Add(addVertexGrip);
                        }

                        #endregion

                        #region Reverse Grips

                        var reverseGrip = new SectionReverseGrip(section)
                        {
                            GripPoint = section.EntityDirection == EntityDirection.LeftToRight
                                ? section.TopShelfEndPoint - (Vector3d.XAxis * 20 * curViewUnitSize)
                                : section.TopShelfEndPoint + (Vector3d.XAxis * 20 * curViewUnitSize)
                        };
                        grips.Add(reverseGrip);
                        reverseGrip = new SectionReverseGrip(section)
                        {
                            GripPoint = section.EntityDirection == EntityDirection.LeftToRight
                                ? section.BottomShelfEndPoint - (Vector3d.XAxis * 20 * curViewUnitSize)
                                : section.BottomShelfEndPoint + (Vector3d.XAxis * 20 * curViewUnitSize)
                        };
                        grips.Add(reverseGrip);

                        #endregion

                        #region Text grips

                        if (section.TopDesignationPoint != Point3d.Origin && section.HasTextValue())
                        {
                            var textGrip = new SectionTextGrip(section)
                            {
                                GripPoint = section.TopDesignationPoint,
                                Name      = TextGripName.TopText
                            };
                            grips.Add(textGrip);
                        }

                        if (section.BottomDesignationPoint != Point3d.Origin && section.HasTextValue())
                        {
                            var textGrip = new SectionTextGrip(section)
                            {
                                GripPoint = section.BottomDesignationPoint,
                                Name      = TextGripName.BottomText
                            };
                            grips.Add(textGrip);
                        }

                        #endregion
                    }
                }
            }
            catch (Exception exception)
            {
                if (exception.ErrorStatus != ErrorStatus.NotAllowedForThisProxy)
                {
                    ExceptionBox.Show(exception);
                }
            }
        }
Beispiel #13
0
        /// <inheritdoc />
        public override void GetGripPoints(
            Entity entity, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
        {
            Debug.Print("BreakLineGripPointOverrule");
            try
            {
                // Проверка дополнительных условий
                if (IsApplicable(entity))
                {
                    // Чтобы "отключить" точку вставки блока, нужно получить сначала блок
                    // Т.к. мы точно знаем для какого примитива переопределение, то получаем блок:
                    var blkRef = (BlockReference)entity;

                    // Удаляем стандартную ручку позиции блока (точки вставки)
                    GripData toRemove = null;
                    foreach (var gd in grips)
                    {
                        if (gd.GripPoint == blkRef.Position)
                        {
                            toRemove = gd;
                            break;
                        }
                    }

                    if (toRemove != null)
                    {
                        grips.Remove(toRemove);
                    }

                    // Получаем экземпляр класса, который описывает как должен выглядеть примитив
                    // т.е. правила построения графики внутри блока
                    // Информация собирается по XData и свойствам самого блока
                    var breakLine = EntityReaderService.Instance.GetFromEntity <BreakLine>(entity);

                    // Паранойя программиста =)
                    if (breakLine != null)
                    {
                        // Получаем первую ручку (совпадает с точкой вставки блока)
                        var gp = new BreakLineGrip(breakLine, BreakLineGripName.StartGrip)
                        {
                            GripPoint = breakLine.InsertionPoint
                        };
                        grips.Add(gp);

                        // получаем среднюю ручку
                        gp = new BreakLineGrip(breakLine, BreakLineGripName.MiddleGrip)
                        {
                            GripPoint = breakLine.MiddlePoint
                        };
                        grips.Add(gp);

                        // получаем конечную ручку
                        gp = new BreakLineGrip(breakLine, BreakLineGripName.EndGrip)
                        {
                            GripPoint = breakLine.EndPoint
                        };
                        grips.Add(gp);
                    }
                }
            }
            catch (Exception exception)
            {
                if (exception.ErrorStatus != ErrorStatus.NotAllowedForThisProxy)
                {
                    ExceptionBox.Show(exception);
                }
            }
        }