/// <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); } } }
/// <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 MoveGripPointsAt(Entity entity, GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags) { /*ArrowGripData gdata = new ArrowGripData(); * gdata.GripPoint = _getCustomGrip(entity); * grips.Add(gdata);*/ base.MoveGripPointsAt(entity, grips, offset, bitFlags); }
//移动夹点 public override void MoveGripPointsAt(Entity entity, GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags) { LArrow la = new LArrow(entity); foreach (GripData gd in grips) { if (gd is LArrowGripData) { LArrowGripData lagd = (LArrowGripData)gd; lagd.Move(la, offset); } } //排除自定义的夹点移动,让剩下的夹点按默认规则移动 for (int i = grips.Count - 1; i >= 0; i--) { if (grips[i] is LArrowGripData) { grips.Remove(grips[i]); } } if (grips.Count > 0) { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } }
//获取夹点,简单实体应重载该函数以获取更灵活的控制 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); }
public bool GetGripPointsAtSubentityPath(FullSubentityPath subPath, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags) { createInstance(); bool GetGripP = BaseEntity.GetGripPointsAtSubentityPath(subPath, grips, curViewUnitSize, gripSize, curViewDir, bitFlags); tr.Dispose(); return(GetGripP); }
//移动夹点 public override void MoveGripPointsAt(Entity entity, GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags) { var ismove = false; foreach (GripData gd in grips) { if (gd is UserGripData && ismove == false) { //UserGripData lagd = (UserGripData)gd; if (entity is BlockReference) { var brf = entity as BlockReference; brf.Position = brf.Position.Add(offset); } else if (entity is DBText) { var txt = entity as DBText; txt.Position = txt.Position.Add(offset); txt.AlignmentPoint = txt.AlignmentPoint.Add(offset); } else if (entity is MText) { var txt = entity as MText; txt.Location = txt.Location.Add(offset); } ismove = true; } } if (grips.Count > 0) { if (entity is BlockReference) { if (!ismove) { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } mpt1 = pt1.Add(offset); mpt2 = pt2.Add(offset); pt = GeTools.MidPoint(mpt1, mpt2); } else if (entity is DBText) { if (!ismove) { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } pt = ((DBText)entity).Position; } else if (entity is MText) { if (!ismove) { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } pt = ((MText)entity).Location; } } }
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); }
public override void MoveGripPointsAt(Entity entity, GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags) { /*ArrowGripData gdata = new ArrowGripData(); * gdata.GripPoint = _getCustomGrip(entity); * grips.Add(gdata);*/ base.MoveGripPointsAt(entity, grips, offset, bitFlags); #if DEBUG if (_entities != null) { IgorKL.ACAD3.Model.Tools.AppendEntity(_entities); _entities = null; } #endif }
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 }); } }
public override void MoveGripPointsAt(Entity entity, GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags) { var wall = entity as Line; if (wall != null) { var xdata = wall.GetXData(CommandJson.AppName); var data = DBHelper.GetNODData(CommandJson.AppName, xdata[0].Value.ToString())?.Data?.AsArray(); var wallPara = JsonConvert.DeserializeObject <Wall>( data[1].Value.ToString()); foreach (var grip in grips) { var wallGrip = grip as WallGripData; if (wallGrip != null) { if (wallGrip.IsStartPoint) { wall.StartPoint = wallGrip.GripPoint + offset; } else { wall.EndPoint = wallGrip.GripPoint + offset; } } wallPara.Pos.X = wall.StartPoint.X; wallPara.Pos.Y = wall.StartPoint.Y; wallPara.Dir.X = wall.EndPoint.X - wall.StartPoint.X; wallPara.Dir.Y = wall.EndPoint.Y - wall.StartPoint.Y; wallPara.Size.H = wall.Length; var newData = new ResultBuffer( new TypedValue((int)DxfCode.Text, wallPara.GetType().ToString()), new TypedValue((int)DxfCode.Text, JsonConvert.SerializeObject(wallPara) )); DBHelper.SetNODData(CommandJson.AppName, wall.Id.ToString(), new Xrecord { Data = newData }); } } }
public override void MoveGripPointsAt(Entity entity, GripDataCollection grips, Vector3d offset, Autodesk.AutoCAD.DatabaseServices.MoveGripPointsFlags bitFlags) { foreach (GripData grip in grips) { MyGrip myGrip = grip as MyGrip; if (myGrip != null) { myGrip.Move(entity, offset); } else { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } } }
/*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 }
public static Point3d GetStairInsertPoint(Solid3d stair3d) { GripDataCollection grips = new GripDataCollection(); GetGripPointsFlags bitFlags = GetGripPointsFlags.GripPointsOnly; stair3d.GetGripPoints(grips, 0, 0, Application.DocumentManager.MdiActiveDocument.Editor.GetCurrentView().ViewDirection, bitFlags); // Grip point [0] is the start point of the polyline defining the stair // Grip point [0,1,2] are the points defining the vertical line and grip point [2,3,4] defining the horizontal line of the first step Point3d pInsert = grips[0].GripPoint; grips.Dispose(); return(pInsert); }
/// <inheritdoc /> public override void MoveGripPointsAt( Entity entity, GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags) { try { if (IsApplicable(entity)) { foreach (var gripData in grips) { if (gripData is SecantNodalLeaderGrip levelMarkGrip) { var gripPoint = levelMarkGrip.GripPoint; var secantNodalLeader = levelMarkGrip.SecantNodalLeader; if (levelMarkGrip.GripName == GripName.InsertionPoint) { ((BlockReference)entity).Position = gripPoint + offset; secantNodalLeader.InsertionPoint = gripPoint + offset; } else if (levelMarkGrip.GripName == GripName.LeaderPoint) { secantNodalLeader.EndPoint = gripPoint + offset; } // Вот тут происходит перерисовка примитивов внутри блока secantNodalLeader.UpdateEntities(); secantNodalLeader.BlockRecord.UpdateAnonymousBlocks(); } else { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } } } else { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } } catch (Exception exception) { if (exception.ErrorStatus != ErrorStatus.NotAllowedForThisProxy) { ExceptionBox.Show(exception); } } }
public static Matrix3d GetStairDisplacment(Solid3d stair3d) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; GripDataCollection grips = new GripDataCollection(); GetGripPointsFlags bitFlags = GetGripPointsFlags.GripPointsOnly; stair3d.GetGripPoints(grips, 0, 0, ed.GetCurrentView().ViewDirection, bitFlags); // Grip point [0] is the start point of the polyline defining the stair Vector3d disp = Point3d.Origin.GetVectorTo(grips[0].GripPoint); grips.Dispose(); return(Matrix3d.Displacement(disp)); }
public static double GetStairRotationAngle(Solid3d stair3d) { GripDataCollection grips = new GripDataCollection(); GetGripPointsFlags bitFlags = GetGripPointsFlags.GripPointsOnly; stair3d.GetGripPoints(grips, 0, 0, Application.DocumentManager.MdiActiveDocument.Editor.GetCurrentView().ViewDirection, bitFlags); // Grip point [0] is the start point of the polyline defining the stair // Grip point [0,1,2] are the points defining the vertical line and grip point [2,3,4] defining the horizontal line of the first step Point2d start = new Point2d(grips[2].GripPoint.X, grips[2].GripPoint.Y); Point2d end = new Point2d(grips[4].GripPoint.X, grips[4].GripPoint.Y); Point3d pInsert = grips[0].GripPoint; grips.Dispose(); return(start.GetVectorTo(end).Angle); }
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); }
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); } }
/// <summary> /// Обработка ручек в методе MoveGripPointsAt класса <see cref="GripOverrule"/> для линейных интеллектуальных объектов /// </summary> /// <param name="entity">Примитив AutoCAD</param> /// <param name="grips">Коллекция ручек</param> /// <param name="offset">Смещение ручки</param> /// <param name="baseAction">Базовое действие метода MoveGripPointsAt для ручки</param> public static void LinearEntityGripPointMoveProcess( Entity entity, GripDataCollection grips, Vector3d offset, Action baseAction) { foreach (var gripData in grips) { if (gripData is LinearEntityVertexGrip vertexGrip) { var intellectualEntity = vertexGrip.IntellectualEntity; if (vertexGrip.GripIndex == 0) { ((BlockReference)entity).Position = vertexGrip.GripPoint + offset; intellectualEntity.InsertionPoint = vertexGrip.GripPoint + offset; } else if (vertexGrip.GripIndex == ((ILinearEntity)intellectualEntity).MiddlePoints.Count + 1) { intellectualEntity.EndPoint = vertexGrip.GripPoint + offset; } else { ((ILinearEntity)intellectualEntity).MiddlePoints[vertexGrip.GripIndex - 1] = vertexGrip.GripPoint + offset; } // Вот тут происходит перерисовка примитивов внутри блока intellectualEntity.UpdateEntities(); intellectualEntity.BlockRecord.UpdateAnonymousBlocks(); } else if (gripData is LinearEntityAddVertexGrip addVertexGrip) { addVertexGrip.NewPoint = addVertexGrip.GripPoint + offset; } else { baseAction.Invoke(); } } }
/// <inheritdoc /> public override void MoveGripPointsAt( Entity entity, GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags) { try { if (IsApplicable(entity)) { EntityUtils.LinearEntityGripPointMoveProcess( entity, grips, offset, () => base.MoveGripPointsAt(entity, grips, offset, bitFlags)); } else { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } } catch (Exception exception) { if (exception.ErrorStatus != ErrorStatus.NotAllowedForThisProxy) { ExceptionBox.Show(exception); } } }
public override void MoveGripPointsAt(Entity entity, GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags) { var donut = entity as Circle; if (donut != null) { var xdata = donut.GetXData(CommandClass.AppName); if (xdata != null && xdata.Length > 0) { foreach (var grip in grips) { var outGrip = grip as DonutOutGripData; if (outGrip != null) { donut.SetXData(CommandClass.AppName, 0, new TypedValue((int)DxfCode.ExtendedDataReal, (outGrip.GripPoint + offset - donut.Center).Length)); } var inGrip = grip as DonutInGripData; if (inGrip != null) { donut.Radius = (inGrip.GripPoint + offset - donut.Center).Length; //donut.SetXData(CommandClass.AppName, 0, // new TypedValue((int)DxfCode.ExtendedDataReal, // (outGrip.GripPoint + offset - donut.Center).Length)); } } } } if (grips.OfType <DonutOutGripData>().Count() < grips.Count) { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } }
/// <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 bool GetGripPointsAtSubentityPath(FullSubentityPath subPath, GripDataCollection grips, double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags) { createInstance(); bool GetGripP = BaseEntity.GetGripPointsAtSubentityPath(subPath, grips, curViewUnitSize, gripSize, curViewDir, bitFlags); tr.Dispose(); return GetGripP; }
/// <inheritdoc/> public override void MoveGripPointsAt( Entity entity, GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags) { try { if (IsApplicable(entity)) { // Проходим по коллекции ручек foreach (var gripData in grips) { if (gripData is BreakLineGrip gripPoint) { var breakLine = gripPoint.BreakLine; var scale = breakLine.GetFullScale(); // Далее, в зависимости от имени ручки произвожу действия if (gripPoint.GripName == BreakLineGripName.StartGrip) { // Переношу точку вставки блока, и точку, описывающую первую точку в примитиве // Все точки всегда совпадают (+ ручка) var newPt = gripPoint.GripPoint + offset; var length = breakLine.EndPoint.DistanceTo(newPt); if (length < breakLine.MinDistanceBetweenPoints * scale) { /* Если новая точка получается на расстоянии меньше минимального, то * переносим ее в направлении между двумя точками на минимальное расстояние */ var tmpInsertionPoint = ModPlus.Helpers.GeometryHelpers.Point3dAtDirection( breakLine.EndPoint, newPt, breakLine.EndPoint, breakLine.MinDistanceBetweenPoints * scale); if (breakLine.EndPoint.Equals(newPt)) { // Если точки совпали, то задаем минимальное значение tmpInsertionPoint = new Point3d( breakLine.EndPoint.X + (breakLine.MinDistanceBetweenPoints * scale), breakLine.EndPoint.Y, breakLine.EndPoint.Z); } ((BlockReference)entity).Position = tmpInsertionPoint; breakLine.InsertionPoint = tmpInsertionPoint; } else { ((BlockReference)entity).Position = gripPoint.GripPoint + offset; breakLine.InsertionPoint = gripPoint.GripPoint + offset; } } if (gripPoint.GripName == BreakLineGripName.MiddleGrip) { // Т.к. средняя точка нужна для переноса примитива, но не соответствует точки вставки блока // и получается как средняя точка между InsertionPoint и EndPoint, то я переношу // точку вставки var lengthVector = (breakLine.InsertionPoint - breakLine.EndPoint) / 2; ((BlockReference)entity).Position = gripPoint.GripPoint + offset + lengthVector; } if (gripPoint.GripName == BreakLineGripName.EndGrip) { var newPt = gripPoint.GripPoint + offset; if (newPt.Equals(((BlockReference)entity).Position)) { breakLine.EndPoint = new Point3d( ((BlockReference)entity).Position.X + (breakLine.MinDistanceBetweenPoints * scale), ((BlockReference)entity).Position.Y, ((BlockReference)entity).Position.Z); } // С конечной точкой все просто else { breakLine.EndPoint = gripPoint.GripPoint + offset; } } // Вот тут происходит перерисовка примитивов внутри блока breakLine.UpdateEntities(); breakLine.BlockRecord.UpdateAnonymousBlocks(); } else { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } } } else { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } } catch (Exception exception) { if (exception.ErrorStatus != ErrorStatus.NotAllowedForThisProxy) { ExceptionBox.Show(exception); } } }
public void MoveGripPointsAt(GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags) { createInstance(); BaseEntity.MoveGripPointsAt(grips, offset,bitFlags); tr.Dispose(); }
/// <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); } } }
//获取夹点,简单实体应重载该函数以获取更灵活的控制 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); } } }
/// <inheritdoc /> public override void MoveGripPointsAt( Entity entity, GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags) { try { if (IsApplicable(entity)) { foreach (var gripData in grips) { if (gripData is SectionVertexGrip vertexGrip) { var section = vertexGrip.Section; if (vertexGrip.GripIndex == 0) { ((BlockReference)entity).Position = vertexGrip.GripPoint + offset; section.InsertionPoint = vertexGrip.GripPoint + offset; } else if (vertexGrip.GripIndex == section.MiddlePoints.Count + 1) { section.EndPoint = vertexGrip.GripPoint + offset; } else { section.MiddlePoints[vertexGrip.GripIndex - 1] = vertexGrip.GripPoint + offset; } // Вот тут происходит перерисовка примитивов внутри блока section.UpdateEntities(); section.BlockRecord.UpdateAnonymousBlocks(); } else if (gripData is SectionTextGrip textGrip) { var section = textGrip.Section; if (textGrip.Name == TextGripName.TopText) { var topStrokeVector = section.MiddlePoints.Any() ? (section.InsertionPoint - section.MiddlePoints.First()).GetNormal() : (section.InsertionPoint - section.EndPoint).GetNormal(); var topShelfVector = topStrokeVector.GetPerpendicularVector().Negate(); var deltaY = topStrokeVector.DotProduct(offset) / section.BlockTransform.GetScale(); var deltaX = topShelfVector.DotProduct(offset) / section.BlockTransform.GetScale(); if (double.IsNaN(textGrip.CachedAlongTopShelfTextOffset)) { section.AlongTopShelfTextOffset = deltaX; } else { section.AlongTopShelfTextOffset = textGrip.CachedAlongTopShelfTextOffset + deltaX; } if (double.IsNaN(textGrip.CachedAcrossTopShelfTextOffset)) { section.AcrossTopShelfTextOffset = deltaY; } else { section.AcrossTopShelfTextOffset = textGrip.CachedAcrossTopShelfTextOffset + deltaY; } if (MainSettings.Instance.SectionDependentTextMovement) { if (double.IsNaN(textGrip.CachedAlongBottomShelfTextOffset)) { section.AlongBottomShelfTextOffset = deltaX; } else { section.AlongBottomShelfTextOffset = textGrip.CachedAlongBottomShelfTextOffset + deltaX; } if (double.IsNaN(textGrip.CachedAcrossBottomShelfTextOffset)) { section.AcrossBottomShelfTextOffset = deltaY; } else { section.AcrossBottomShelfTextOffset = textGrip.CachedAcrossBottomShelfTextOffset + deltaY; } } } if (textGrip.Name == TextGripName.BottomText) { var bottomStrokeVector = section.MiddlePoints.Any() ? (section.EndPoint - section.MiddlePoints.Last()).GetNormal() : (section.EndPoint - section.InsertionPoint).GetNormal(); var bottomShelfVector = bottomStrokeVector.GetPerpendicularVector(); var deltaY = bottomStrokeVector.DotProduct(offset) / section.BlockTransform.GetScale(); var deltaX = bottomShelfVector.DotProduct(offset) / section.BlockTransform.GetScale(); if (double.IsNaN(textGrip.CachedAlongBottomShelfTextOffset)) { section.AlongBottomShelfTextOffset = deltaX; } else { section.AlongBottomShelfTextOffset = textGrip.CachedAlongBottomShelfTextOffset + deltaX; } if (double.IsNaN(textGrip.CachedAcrossBottomShelfTextOffset)) { section.AcrossBottomShelfTextOffset = deltaY; } else { section.AcrossBottomShelfTextOffset = textGrip.CachedAcrossBottomShelfTextOffset + deltaY; } if (MainSettings.Instance.SectionDependentTextMovement) { if (double.IsNaN(textGrip.CachedAlongTopShelfTextOffset)) { section.AlongTopShelfTextOffset = deltaX; } else { section.AlongTopShelfTextOffset = textGrip.CachedAlongTopShelfTextOffset + deltaX; } if (double.IsNaN(textGrip.CachedAcrossTopShelfTextOffset)) { section.AcrossTopShelfTextOffset = deltaY; } else { section.AcrossTopShelfTextOffset = textGrip.CachedAcrossTopShelfTextOffset + deltaY; } } } section.UpdateEntities(); section.BlockRecord.UpdateAnonymousBlocks(); } else if (gripData is SectionAddVertexGrip addVertexGrip) { addVertexGrip.NewPoint = addVertexGrip.GripPoint + offset; } else { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } } } else { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } } catch (Exception exception) { if (exception.ErrorStatus != ErrorStatus.NotAllowedForThisProxy) { ExceptionBox.Show(exception); } } }
/// <inheritdoc /> public override void MoveGripPointsAt( Entity entity, GripDataCollection grips, Vector3d offset, MoveGripPointsFlags bitFlags) { try { if (IsApplicable(entity)) { foreach (var gripData in grips) { if (gripData is LevelMarkGrip levelMarkGrip) { var gripPoint = levelMarkGrip.GripPoint; var levelMark = levelMarkGrip.LevelMark; var scale = levelMark.GetFullScale(); var horV = (levelMark.EndPoint - levelMark.ObjectPoint).GetNormal(); if (levelMarkGrip.GripName == LevelMarkGripName.BasePoint) { ((BlockReference)entity).Position = gripPoint + offset; levelMark.InsertionPoint = gripPoint + offset; } else if (levelMarkGrip.GripName == LevelMarkGripName.ObjectPoint) { levelMark.ObjectPoint = gripPoint + offset; levelMark.BottomShelfStartPoint = new Point3d( levelMark.BottomShelfStartPoint.X, levelMark.ObjectPoint.Y, levelMark.BottomShelfStartPoint.Z); levelMark.EndPoint = new Point3d( levelMark.EndPoint.X, levelMark.ObjectPoint.Y, levelMark.EndPoint.Z); } else if (levelMarkGrip.GripName == LevelMarkGripName.BottomShelfStartPoint) { levelMark.BottomShelfStartPoint = gripPoint + offset; if (levelMark.ObjectLine) { levelMark.ObjectPoint = levelMark.BottomShelfStartPoint - (horV * levelMark.ObjectLineOffset * scale); levelMark.EndPoint = levelMark.BottomShelfStartPoint + (horV * _cachedBottomShelfLength); } else { levelMark.ObjectPoint = new Point3d( levelMark.ObjectPoint.X, levelMark.BottomShelfStartPoint.Y, levelMark.ObjectPoint.Z); levelMark.EndPoint = levelMark.BottomShelfStartPoint + (horV * levelMark.BottomShelfLength * scale); } } else if (levelMarkGrip.GripName == LevelMarkGripName.ArrowPoint) { levelMark.SetArrowPoint(gripPoint + offset); } else if (levelMarkGrip.GripName == LevelMarkGripName.TopShelfPoint) { levelMark.ShelfPoint = gripPoint + offset; } // Вот тут происходит перерисовка примитивов внутри блока levelMark.UpdateEntities(); levelMark.BlockRecord.UpdateAnonymousBlocks(); } else { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } } } else { base.MoveGripPointsAt(entity, grips, offset, bitFlags); } } catch (Exception exception) { if (exception.ErrorStatus != ErrorStatus.NotAllowedForThisProxy) { ExceptionBox.Show(exception); } } }