Esempio n. 1
0
        public ArgbColor GetPlotColor(DxfEntity localBlockContext, WW.Cad.Model.Color color)
        {
            ArgbColor argbColor;

            if (this.graphicsConfig_0.PlotStyleManager != null)
            {
                argbColor = this.graphicsConfig_0.PlotStyleManager((IPlotPropertyOwner) new Class1065((IPlotPropertyOwner)localBlockContext, color), this).Color;
            }
            else if (color == WW.Cad.Model.Color.ByBlock)
            {
                if (localBlockContext.Color == EntityColor.ByLayer)
                {
                    DxfLayer layer = localBlockContext.GetLayer(this);
                    argbColor = layer == null ? DxfIndexedColor.DefaultColor : layer.Color.ToArgbColor(this.graphicsConfig_0.IndexedColors);
                }
                else
                {
                    argbColor = localBlockContext.DxfColor != null?localBlockContext.DxfColor.Color.ToArgbColor(this.graphicsConfig_0.IndexedColors) : (!(localBlockContext.Color == EntityColor.ByBlock) ? localBlockContext.Color.ToArgbColor(this.graphicsConfig_0.IndexedColors) : (this.dxfColor_0 == null ? this.entityColor_0.ToArgbColor(this.graphicsConfig_0.IndexedColors) : this.dxfColor_0.Color.ToArgbColor(this.graphicsConfig_0.IndexedColors)));
                }
            }
            else if (color == WW.Cad.Model.Color.ByLayer)
            {
                DxfLayer layer = localBlockContext.GetLayer(this);
                argbColor = layer == null ? DxfIndexedColor.DefaultColor : layer.Color.ToArgbColor(this.graphicsConfig_0.IndexedColors);
            }
            else
            {
                argbColor = color.ToArgbColor(this.graphicsConfig_0.IndexedColors);
            }
            return(argbColor);
        }
Esempio n. 2
0
 public void CreateXLine(DxfEntity entity, Vector4D?startPoint, Segment4D segment)
 {
     System.Windows.Point windowsPoint1 = this.matrix4D_0.TransformToWindowsPoint(segment.Start);
     System.Windows.Point windowsPoint2 = this.matrix4D_0.TransformToWindowsPoint(segment.End);
     this.class453_0.method_1(windowsPoint1, false, false);
     this.class453_0.method_3(windowsPoint2, true);
 }
Esempio n. 3
0
        public void UpdateDrawables(
            DxfEntity entity,
            System.Action <DrawContext.Wireframe, IWireframeGraphicsFactory2> updateDrawables,
            Func <IWireframeGraphicsFactory2, IWireframeGraphicsFactory2> graphicsFactoryWrapper)
        {
            if (!this.bool_0)
            {
                throw new Exception("Property AreDrawablesUpdateable is false.");
            }
            List <WpfWireframeGraphics3D.Class451> class451List;

            if (!this.dictionary_0.TryGetValue(entity, out class451List))
            {
                return;
            }
            WpfWireframeGraphics3D.Class451[] array            = class451List.ToArray();
            WpfWireframeGraphics3D.Class452   graphicsFactory  = (WpfWireframeGraphics3D.Class452) this.CreateGraphicsFactory();
            IWireframeGraphicsFactory2        graphicsFactory2 = (IWireframeGraphicsFactory2)graphicsFactory;

            if (graphicsFactoryWrapper != null)
            {
                graphicsFactory2 = graphicsFactoryWrapper((IWireframeGraphicsFactory2)graphicsFactory);
            }
            foreach (WpfWireframeGraphics3D.Class451 entityDrawablesInfo in array)
            {
                this.RemoveDrawables(entityDrawablesInfo, true);
                graphicsFactory.CurrentColoredDrawableNode  = new LinkedListNodeRef <Interface37>(entityDrawablesInfo.EntityDrawableNode.List, entityDrawablesInfo.EntityDrawableNode);
                graphicsFactory.CurrentEntityDrawablesInfo  = entityDrawablesInfo.Parent;
                graphicsFactory.ExistingEntityDrawablesInfo = entityDrawablesInfo;
                updateDrawables(entityDrawablesInfo.DrawContext, graphicsFactory2);
            }
        }
Esempio n. 4
0
        internal static DxfEntitiesSection EntitiesSectionFromBuffer(DxfCodePairBufferReader buffer)
        {
            var entities = new List <DxfEntity>();

            entities.Clear();
            while (buffer.ItemsRemain)
            {
                var pair = buffer.Peek();
                if (DxfCodePair.IsSectionEnd(pair))
                {
                    // done reading entities
                    buffer.Advance(); // swallow (0, ENDSEC)
                    break;
                }

                if (pair.Code != 0)
                {
                    throw new DxfReadException("Expected new entity.", pair);
                }

                var entity = DxfEntity.FromBuffer(buffer);
                if (entity != null)
                {
                    entities.Add(entity);
                }
            }

            var section   = new DxfEntitiesSection();
            var collected = GatherEntities(entities);

            section.Entities.AddRange(collected);
            return(section);
        }
Esempio n. 5
0
        public static XElement ToXElement(this DxfEntity entity)
        {
            // elements are simply flattened in the z plane; the world transform in the main function handles the rest
            switch (entity)
            {
            case DxfArc arc:
                return(arc.ToXElement());

            case DxfCircle circle:
                return(circle.ToXElement());

            case DxfEllipse el:
                return(el.ToXElement());

            case DxfLine line:
                return(line.ToXElement());

            case DxfLwPolyline poly:
                return(poly.ToXElement());

            case DxfPolyline polyline:
                return(polyline.ToXElement());

            case DxfSpline spline:
                return(spline.ToXElement());

            case DxfHatch hatch:
                return(hatch.ToXElement());

            default:
                return(null);
            }
        }
Esempio n. 6
0
 public void CreateRay(
     DxfEntity entity,
     DrawContext.Wireframe drawContext,
     ArgbColor color,
     Segment4D segment)
 {
 }
Esempio n. 7
0
 public Class509(DxfEntity entity, DrawContext.Surface drawContext)
 {
     this.dxfEntity_0 = entity;
     this.surface_0   = drawContext;
     this.linkedList_0.AddLast((ISurfaceDrawable)SurfaceGraphicsCache.Class510.class510_0);
     this.linkedList_0.AddLast((ISurfaceDrawable)SurfaceGraphicsCache.Class510.class510_0);
 }
Esempio n. 8
0
 protected DrawContext(DrawContext from)
 {
     this.image_0               = from.image_0;
     this.graphics_0            = from.graphics_0;
     this.dxfModel_0            = from.dxfModel_0;
     this.dxfLayout_0           = from.dxfLayout_0;
     this.graphicsConfig_0      = from.graphicsConfig_0;
     this.dxfLayer_0            = from.dxfLayer_0;
     this.dxfLayer_1            = from.dxfLayer_1;
     this.dxfEntity_0           = from.dxfEntity_0;
     this.dxfBlock_0            = from.dxfBlock_0;
     this.drawContext_0         = from.drawContext_0;
     this.dxfEntity_1           = from.dxfEntity_1;
     this.entityColor_0         = from.entityColor_0;
     this.transparency_0        = from.transparency_0;
     this.dxfColor_0            = from.dxfColor_0;
     this.dxfLineType_0         = from.dxfLineType_0;
     this.short_0               = from.short_0;
     this.int_0                 = from.int_0;
     this.int_1                 = from.int_1;
     this.dxfWipeoutVariables_0 = from.dxfWipeoutVariables_0;
     this.dictionary_0          = from.dictionary_0;
     this.double_0              = from.double_0;
     this.double_1              = from.double_1;
 }
Esempio n. 9
0
        public void UpdateDrawables(DxfEntity entity)
        {
            if (!this.bool_0)
            {
                throw new Exception("Property AreDrawablesUpdateable is false.");
            }
            SurfaceGraphicsCache.Class507        class507 = new SurfaceGraphicsCache.Class507(this);
            List <SurfaceGraphicsCache.Class508> class508List;

            if (!this.dictionary_0.TryGetValue(entity, out class508List))
            {
                return;
            }
            foreach (SurfaceGraphicsCache.Class508 entityDrawablesInfo in class508List.ToArray())
            {
                class507.CurrentDrawableNode        = entityDrawablesInfo.FirstDrawable.Previous;
                class507.CurrentEntityDrawablesInfo = entityDrawablesInfo.Parent;
                bool flag = entityDrawablesInfo.FirstDrawable.List != null;
                this.RemoveDrawables(entityDrawablesInfo);
                if (flag)
                {
                    entity.Draw(entityDrawablesInfo.DrawContext, (ISurfaceGraphicsFactory)class507);
                }
            }
        }
Esempio n. 10
0
 public void CreateLine(DxfEntity entity, Vector4D start, Vector4D end)
 {
     System.Windows.Point windowsPoint1 = this.matrix4D_0.TransformToWindowsPoint(start);
     System.Windows.Point windowsPoint2 = this.matrix4D_0.TransformToWindowsPoint(end);
     this.class453_0.method_1(windowsPoint1, false, false);
     this.class453_0.method_3(windowsPoint2, true);
 }
Esempio n. 11
0
            public void BeginGeometry(
                DxfEntity entity,
                DrawContext.Wireframe drawContext,
                ArgbColor color,
                bool forText,
                bool fill,
                bool stroke,
                bool correctForBackgroundColor)
            {
                if (this.class453_0 != null)
                {
                    throw new InvalidOperationException("BeginGeometry calls may not be nested.");
                }
                this.class453_0 = new WpfWireframeGraphics3D.Class452.Class453(this.objectTaggerDelegate_0(entity, (DrawContext)drawContext));
                Brush brush = (correctForBackgroundColor ? this.interface11_0 : this.interface11_1).imethod_0(color);

                this.class453_0.Path.Fill = brush;
                if (fill)
                {
                    this.class453_0.Fill = true;
                }
                if (stroke)
                {
                    this.class453_0.Stroke                = true;
                    this.class453_0.Path.Stroke           = brush;
                    this.class453_0.Path.StrokeThickness  = this.method_0(entity, (DrawContext)drawContext, forText);
                    this.class453_0.Path.StrokeMiterLimit = 2.0;
                    if (this.wpfWireframeGraphics3D_0.pathStrokePreparerDelegate_0 != null)
                    {
                        this.wpfWireframeGraphics3D_0.pathStrokePreparerDelegate_0(this.class453_0.Path, entity, (DrawContext)drawContext, forText);
                    }
                }
                this.linkedListNodeRef_0.Insert((Interface37) new Class747((FrameworkElement)this.class453_0.Path));
            }
Esempio n. 12
0
 public void RenderEntity(DxfEntity dxfEntity, Graphics graphics, int height)
 {
     if (dxfEntity is DxfPolyline dxfPolyline)
     {
         RenderEntity(dxfPolyline, graphics, height);
     }
     else if (dxfEntity is DxfLwPolyline dxfLwPolyline)
     {
         RenderEntity(dxfLwPolyline, graphics, height);
     }
     else if (dxfEntity is DxfLine dxfLine)
     {
         RenderEntity(dxfLine, graphics, height);
     }
     else if (dxfEntity is DxfSpline dxfSpline)
     {
         RenderEntity(dxfSpline, graphics, height);
     }
     else if (dxfEntity is DxfCircle dxfCircle)
     {
         if (dxfCircle is DxfArc dxfArc)
         {
             RenderEntity(dxfArc, graphics, height);
         }
         else
         {
             RenderEntity(dxfCircle, graphics, height);
         }
     }
     else if (dxfEntity is DxfInsert dxfInsert)
     {
         RenderEntity(dxfInsert, graphics, height);
     }
 }
Esempio n. 13
0
        public void UpdateDrawables(
            DxfEntity entity,
            System.Action <DrawContext.Wireframe, IWireframeGraphicsFactory> updateDrawables,
            Func <IWireframeGraphicsFactory, IWireframeGraphicsFactory> graphicsFactoryWrapper)
        {
            if (!this.bool_1)
            {
                throw new Exception("Property AreDrawablesUpdateable is false.");
            }
            List <GDIGraphics3D.Class941> class941List;

            if (!this.dictionary_0.TryGetValue(entity, out class941List))
            {
                return;
            }
            GDIGraphics3D.Class941[]  array                    = class941List.ToArray();
            GDIGraphics3D.Class942    graphicsFactory          = (GDIGraphics3D.Class942) this.CreateGraphicsFactory();
            IWireframeGraphicsFactory wireframeGraphicsFactory = (IWireframeGraphicsFactory)graphicsFactory;

            if (graphicsFactoryWrapper != null)
            {
                wireframeGraphicsFactory = graphicsFactoryWrapper((IWireframeGraphicsFactory)graphicsFactory);
            }
            foreach (GDIGraphics3D.Class941 entityDrawablesInfo in array)
            {
                graphicsFactory.CurrentlyInTextMode = new bool?();
                this.RemoveDrawables(entityDrawablesInfo, true);
                graphicsFactory.CurrentColoredDrawableNode     = new LinkedListNodeRef <Interface12>(entityDrawablesInfo.EntityDrawableNode.List, entityDrawablesInfo.EntityDrawableNode);
                graphicsFactory.CurrentTextColoredDrawableNode = new LinkedListNodeRef <Interface12>(entityDrawablesInfo.TextEntityDrawableNode.List, entityDrawablesInfo.TextEntityDrawableNode);
                graphicsFactory.CurrentEntityDrawablesInfo     = entityDrawablesInfo.Parent;
                graphicsFactory.ExistingEntityDrawablesInfo    = entityDrawablesInfo;
                updateDrawables(entityDrawablesInfo.DrawContext, wireframeGraphicsFactory);
            }
        }
Esempio n. 14
0
        public static DxfEntity ToDxfEntity(this Entity item, Layer layer)
        {
            DxfEntity entity = null;

            switch (item.Kind)
            {
            case EntityKind.Aggregate:
                // no-op.  aggregates are handled separately
                break;

            case EntityKind.Arc:
                // if start/end angles are a full circle, write it that way instead
                var arc = (Arc)item;
                if (arc.StartAngle == 0.0 && arc.EndAngle == 360.0)
                {
                    entity = new Circle(arc.Center, arc.Radius, arc.Normal, arc.Color).ToDxfCircle(layer);
                }
                else
                {
                    entity = ((Arc)item).ToDxfArc(layer);
                }
                break;

            case EntityKind.Circle:
                entity = ((Circle)item).ToDxfCircle(layer);
                break;

            case EntityKind.Ellipse:
                entity = ((Ellipse)item).ToDxfEllipse(layer);
                break;

            case EntityKind.Line:
                entity = ((Line)item).ToDxfLine(layer);
                break;

            case EntityKind.Location:
                entity = ((Location)item).ToDxfLocation(layer);
                break;

            case EntityKind.Polyline:
                entity = ((Polyline)item).ToDxfPolyline(layer);
                break;

            case EntityKind.Text:
                entity = ((Text)item).ToDxfText(layer);
                break;

            default:
                Debug.Assert(false, "Unsupported entity type: " + item.GetType().Name);
                break;
            }

            if (entity != null)
            {
                entity.AssignDxfEntityColor(item.Color);
            }

            return(entity);
        }
Esempio n. 15
0
        public static Entity ToEntity(this DxfEntity item)
        {
            Entity entity = null;

            switch (item.EntityType)
            {
            case DxfEntityType.Arc:
                entity = ((DxfArc)item).ToArc();
                break;

            case DxfEntityType.Circle:
                entity = ((DxfCircle)item).ToCircle();
                break;

            case DxfEntityType.Ellipse:
                entity = ((DxfEllipse)item).ToEllipse();
                break;

            case DxfEntityType.Leader:
                entity = ((DxfLeader)item).ToPolyline();
                break;

            case DxfEntityType.Line:
                entity = ((DxfLine)item).ToLine();
                break;

            case DxfEntityType.LwPolyline:
                entity = ((DxfLwPolyline)item).ToPolyline();
                break;

            case DxfEntityType.Point:
                entity = ((DxfModelPoint)item).ToPoint();
                break;

            case DxfEntityType.Polyline:
                entity = ((DxfPolyline)item).ToPolyline();
                break;

            case DxfEntityType.Text:
                entity = ((DxfText)item).ToText();
                break;

            case DxfEntityType.Face:
            case DxfEntityType.ModelerGeometry:
            case DxfEntityType.ProxyEntity:
            case DxfEntityType.Ray:
            case DxfEntityType.Region:
            case DxfEntityType.Seqend:
            case DxfEntityType.Solid:
            case DxfEntityType.Tolerance:
            case DxfEntityType.Trace:
            case DxfEntityType.Vertex:
            case DxfEntityType.XLine:
                //Debug.Fail("Unsupported DXF entity type: " + item.GetType().Name);
                break;
            }

            return(entity);
        }
Esempio n. 16
0
        private static void EnsureFileContainsEntity(DxfEntity entity, string text, DxfAcadVersion version = DxfAcadVersion.R12)
        {
            var file = new DxfFile();

            file.Header.Version = version;
            file.Entities.Add(entity);
            VerifyFileContains(file, text, sectionType: DxfSectionType.Entities);
        }
Esempio n. 17
0
 public void GetBounds(DxfModel model, DxfEntity entity, Matrix4D modelTransform)
 {
     using (DrawContext.Wireframe context = (DrawContext.Wireframe) new DrawContext.Wireframe.ModelSpace(model, this.graphicsConfig_0, modelTransform))
     {
         IWireframeGraphicsFactory graphicsFactory = this.CreateGraphicsFactory();
         entity.Draw(context, graphicsFactory);
     }
 }
Esempio n. 18
0
 public void CreateXLine(
     DxfEntity entity,
     DrawContext.Wireframe drawContext,
     ArgbColor color,
     Vector4D?startPoint,
     Segment4D segment)
 {
 }
Esempio n. 19
0
 public void CreateRay(
     DxfEntity entity,
     DrawContext.Wireframe drawContext,
     ArgbColor color,
     Segment4D segment)
 {
     this.method_4(segment, color);
 }
Esempio n. 20
0
 public void CreateRay(
     DxfEntity entity,
     DrawContext.Wireframe drawContext,
     ArgbColor color,
     Segment4D segment)
 {
     this.linkedListNodeRef_0.Insert((IWireframeDrawable) new WireframeGraphicsCache.Class965(entity, drawContext, color, segment));
 }
Esempio n. 21
0
 public virtual void CreateDot(
     DxfEntity entity,
     DrawContext.Wireframe drawContext,
     ArgbColor color,
     bool forText,
     Vector4D position)
 {
 }
Esempio n. 22
0
 public void CreateRay(
     DxfEntity entity,
     DrawContext.Wireframe drawContext,
     ArgbColor color,
     Segment4D segment)
 {
     this.iwireframeGraphicsFactory_0.CreateRay(entity, drawContext, this.func_0(color), segment);
 }
Esempio n. 23
0
 public ArgbColor GetPlotColor(DxfEntity entity)
 {
     if (this.graphicsConfig_0.PlotStyleManager == null)
     {
         return(entity.GetColor(this));
     }
     return(this.graphicsConfig_0.PlotStyleManager((IPlotPropertyOwner)entity, this).Color);
 }
Esempio n. 24
0
 public short GetLineWeight(DxfEntity entity)
 {
     if (this.graphicsConfig_0.PlotStyleManager == null)
     {
         return(entity.GetLineWeight(this));
     }
     return(this.graphicsConfig_0.PlotStyleManager((IPlotPropertyOwner)entity, this).LineWeight);
 }
Esempio n. 25
0
 public void CreateRay(
     DxfEntity entity,
     DrawContext.Wireframe drawContext,
     ArgbColor color,
     Segment4D segment)
 {
     this.method_4(false, (Interface12) new Class345(new Vector4D?(segment.Start), segment, this.GetColor(color), drawContext.GetLineWeight(entity)));
 }
Esempio n. 26
0
        private static void EnsureFileDoesNotContainWithEntity(DxfEntity entity, string unwantedText, DxfAcadVersion version = DxfAcadVersion.R12)
        {
            var file = new DxfFile();

            file.Header.Version = version;
            file.Entities.Add(entity);
            VerifyFileDoesNotContain(file, unwantedText, sectionType: DxfSectionType.Entities);
        }
Esempio n. 27
0
 public virtual void CreateShape(
     DxfEntity entity,
     DrawContext.Wireframe drawContext,
     ArgbColor color,
     bool forText,
     IShape4D shape)
 {
 }
Esempio n. 28
0
 public override bool IsVisible(DxfEntity entity)
 {
     if (entity.InPaperSpace(this.RootBlockContext))
     {
         return(false);
     }
     return(!this.dxfViewport_0.FrozenLayers.Contains(this.GetEffectiveLayer(entity.Layer)));
 }
Esempio n. 29
0
 public void CreateXLine(DxfEntity entity, Vector4D?startPoint, Segment4D segment)
 {
     WpfWireframeGraphics3DUsingDrawingVisual.Class380.Class381 class381 = this.stack_0.Peek();
     System.Windows.Point windowsPoint1 = this.matrix4D_0.TransformToWindowsPoint(segment.Start);
     System.Windows.Point windowsPoint2 = this.matrix4D_0.TransformToWindowsPoint(segment.End);
     class381.method_1(windowsPoint1, false, false);
     class381.method_3(windowsPoint2, false);
 }
Esempio n. 30
0
 public Class396(
     DxfEntity entity,
     DrawContext.Wireframe context,
     IWireframeGraphicsFactory2 graphicsFactory)
 {
     this.dxfEntity_0 = entity;
     this.wireframe_0 = context;
     this.iwireframeGraphicsFactory2_0 = graphicsFactory;
 }
Esempio n. 31
0
        /// <summary>
        /// 单独用来处理frame的函数
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="location"></param>
        /// <param name="relativeStartLocation"></param>
        /// <returns></returns>
        public static DxfEntity getFrameEntity(DxfEntity entity, DLocation location, DLocation relativeStartLocation,double increaseWidth)
        {
            switch (entity.EntityType)
            {
                case "LINE":
                    {
                        DxfLine dxfLine = (DxfLine)entity;
                        double lineLenght = dxfLine.End.X - dxfLine.Start.X;
                        double lineHeight = dxfLine.End.Y - dxfLine.Start.Y;
                        if (Math.Round(dxfLine.Start.Y * 1000) / 1000 == Math.Round(dxfLine.End.Y * 1000) / 1000)
                        {
                            //消除绘图人员的语法错误
                            if (dxfLine.Start.X > dxfLine.End.X)
                            {
                                dxfLine.Start = new Point3D(dxfLine.Start.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance + increaseWidth, dxfLine.Start.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfLine.ZAxis.Z);
                                dxfLine.End = new Point3D(dxfLine.Start.X + lineLenght, dxfLine.Start.Y + lineHeight, location.Z);
                            }
                            else
                            {
                                dxfLine.Start = new Point3D(dxfLine.Start.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfLine.Start.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfLine.ZAxis.Z);
                                dxfLine.End = new Point3D(dxfLine.Start.X + lineLenght+increaseWidth, dxfLine.Start.Y + lineHeight, location.Z);
                            }

                        }
                        else
                        {
                            if (Math.Round(dxfLine.Start.X * 10) / 10 == Math.Round(frameLastLineX * 10) / 10)
                            {
                                double tempX = dxfLine.Start.X;
                                dxfLine.Start = new Point3D(dxfLine.Start.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance+increaseWidth/2, dxfLine.Start.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfLine.ZAxis.Z);
                                //因为此处的dxfLine.Start.x==dxfLineEnd.x所以不需要+increaseWidth
                                dxfLine.End = new Point3D(dxfLine.Start.X + lineLenght, dxfLine.Start.Y + lineHeight, location.Z);
                            }
                            else
                            {
                                dxfLine.Start = new Point3D(dxfLine.Start.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfLine.Start.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfLine.ZAxis.Z);
                                dxfLine.End = new Point3D(dxfLine.Start.X + lineLenght, dxfLine.Start.Y + lineHeight, location.Z);
                            }
                        }
                        return dxfLine;
                    };
                case "TEXT":
                    {
                        DxfText dxfText = (DxfText)entity;
                        //解决乱码问题
                        dxfText.Style = textStyle;
                        TextValue textValue = new TextValue();
                        if (dxfText.Text.Equals("产品代码:"))
                        {
                            dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z);
                            dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                            textValue.text = dxfText.Text;
                            textValue.height = dxfText.Height;
                            textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X,dxfText.AlignmentPoint1.Y,dxfText.AlignmentPoint1.Z);
                            textValue.valuePosition = new DLocation(textValue.textPosition.X+4*RelativeDistance.width,textValue.textPosition.Y,textValue.textPosition.Z);
                            textValueList.Add(textValue);
                        }
                        else if (dxfText.Text.Equals("项目名称:"))
                        {
                            dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z);
                            dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                            textValue.text = dxfText.Text;
                            textValue.height = dxfText.Height;
                            textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z);
                            textValue.valuePosition = new DLocation(textValue.textPosition.X + 4 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z);
                            textValueList.Add(textValue);
                        }
                        else if (dxfText.Text.Equals("设备描述:"))
                        {
                            dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z);
                            dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                            textValue.text = dxfText.Text;
                            textValue.height = dxfText.Height;
                            textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z);
                            textValue.valuePosition = new DLocation(textValue.textPosition.X + 4 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z);
                            textValueList.Add(textValue);
                        }
                        else if (dxfText.Text.Equals("买方:"))
                        {
                            dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z);
                            dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                            textValue.text = dxfText.Text;
                            textValue.height = dxfText.Height;
                            textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z);
                            textValue.valuePosition = new DLocation(textValue.textPosition.X + 2 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z);
                            textValueList.Add(textValue);
                        }
                        else if (dxfText.Text.Equals("订单号:"))
                        {
                            dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z);
                            dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                            textValue.text = dxfText.Text;
                            textValue.height = dxfText.Height;
                            textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z);
                            textValue.valuePosition = new DLocation(textValue.textPosition.X + 3 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z);
                            textValueList.Add(textValue);
                        }
                        else if (dxfText.Text.Equals("买方联系人:"))
                        {
                            dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z);
                            dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                            textValue.text = dxfText.Text;
                            textValue.height = dxfText.Height;
                            textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z);
                            textValue.valuePosition = new DLocation(textValue.textPosition.X + 5 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z);
                            textValueList.Add(textValue);
                        }
                        else if (dxfText.Text.Equals("易龙销售:"))
                        {
                            dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z);
                            dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                            textValue.text = dxfText.Text;
                            textValue.height = dxfText.Height;
                            textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z);
                            textValue.valuePosition = new DLocation(textValue.textPosition.X + 4 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z);
                            textValueList.Add(textValue);
                        }
                        else if (dxfText.Text.Equals("软件序列号:"))
                        {
                            dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z);
                            dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                            textValue.text = dxfText.Text;
                            textValue.height = dxfText.Height;
                            textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z);
                            textValue.valuePosition = new DLocation(textValue.textPosition.X + 5 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z);
                            textValueList.Add(textValue);
                        }
                        else if (dxfText.Text.Equals("系列号:"))
                        {
                            dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z);
                            dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                            textValue.text = dxfText.Text;
                            textValue.height = dxfText.Height;
                            textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z);
                            textValue.valuePosition = new DLocation(textValue.textPosition.X + 3 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z);
                            textValueList.Add(textValue);
                        }
                        else if (dxfText.Text.Equals("时间:"))
                        {
                            dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance + increaseWidth / 2, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z);
                            dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                            textValue.text = dxfText.Text;
                            textValue.height = dxfText.Height;
                            textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z);
                            textValue.valuePosition = new DLocation(textValue.textPosition.X + 2 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z);
                            textValueList.Add(textValue);
                        }
                        else
                        {
                            dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z);
                            dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                        }
                        return dxfText;
                    }
                case "ELLIPSE":
                    {
                        DxfEllipse dxfEllipse = (DxfEllipse)entity;
                        dxfEllipse.Center = new Point3D(dxfEllipse.Center.X - relativeStartLocation.X + location.X-RelativeDistance.xDistance, dxfEllipse.Center.Y - relativeStartLocation.Y + location.Y-RelativeDistance.yDistance, dxfEllipse.Center.Z);
                        return dxfEllipse;
                    }
                case "LWPOLYLINE":
                    {
                        DxfLwPolyline dxfLwPolyLine = (DxfLwPolyline)entity;
                        int len = dxfLwPolyLine.Vertices.Count;

                        //获得Frame最右边的X值
                        Point2D rightPoint2d = getFrameRightX(dxfLwPolyLine.Vertices);

                        for (int i = 0; i < len; i++)
                        {
                            if (isPolyLinePoint(rightPoint2d, dxfLwPolyLine.Vertices[i].Position))
                            {
                                dxfLwPolyLine.Vertices[i].Position = new Point2D(dxfLwPolyLine.Vertices[i].Position.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance+increaseWidth, dxfLwPolyLine.Vertices[i].Position.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance);
                            }
                            else
                            {
                                dxfLwPolyLine.Vertices[i].Position = new Point2D(dxfLwPolyLine.Vertices[i].Position.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfLwPolyLine.Vertices[i].Position.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance);
                            }
                        }

                        return dxfLwPolyLine;
                    }
                case "SOLID":
                    {
                        DxfSolid dxfSolid = (DxfSolid)entity;

                        int len = dxfSolid.Points.Count;
                        for (int i = 0; i < len;i++ )
                        {
                            //可能会出问题
                            if(i==1||i==3)
                            dxfSolid.Points[i] = new Point3D(dxfSolid.Points[i].X - relativeStartLocation.X + location.X - RelativeDistance.xDistance+increaseWidth, dxfSolid.Points[i].Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfSolid.Points[i].Z);
                            else
                            dxfSolid.Points[i] = new Point3D(dxfSolid.Points[i].X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfSolid.Points[i].Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfSolid.Points[i].Z);
                        }
                        return dxfSolid;
                    }
                case "SPLINE":
                    {
                        DxfSpline dxfSpline = (DxfSpline)entity;
                        int len=dxfSpline.ControlPoints.Count;
                        for (int i = 0; i < len;i++ )
                        {
                            dxfSpline.ControlPoints[i] = new Point3D(dxfSpline.ControlPoints[i].X - relativeStartLocation.X + location.X- RelativeDistance.xDistance, dxfSpline.ControlPoints[i].Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfSpline.ControlPoints[i].Z);
                        }
                        return dxfSpline;
                    }
                default: return entity;
            }
        }
Esempio n. 32
0
        private static DLocation topViewRightLocation; //下一个坐标

        #endregion Fields

        #region Methods

        /// <summary>
        /// 获取计算好的entity
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="location"></param>
        /// <param name="relativeStartLocation"></param>
        /// <returns></returns>
        public static DxfEntity getCaculateLocationEntity(DxfEntity entity,DLocation location,DLocation relativeStartLocation)
        {
            switch (entity.EntityType){
                case "LINE":
                    {
                    DxfLine dxfLine = (DxfLine)entity;
                    double lineLenght = dxfLine.End.X - dxfLine.Start.X;
                    double lineHeight=dxfLine.End.Y-dxfLine.Start.Y;
                    dxfLine.Start = new Point3D(dxfLine.Start.X - relativeStartLocation.X + location.X, dxfLine.Start.Y - relativeStartLocation.Y + location.Y, location.Z);
                    dxfLine.End = new Point3D(dxfLine.Start.X+lineLenght,dxfLine.Start.Y+lineHeight,location.Z);
                    //只需要将Line的坐标加入,每个图形底部都存在Line
                    if (Math.Round(dxfLine.Start.Y*10)/10 == Math.Round(dxfLine.End.Y*10)/10||Math.Round(dxfLine.Start.X*10)/10==Math.Round(dxfLine.End.X*10)/10)
                    {
                        positionList.Add(dxfLine.Start);
                        positionList.Add(dxfLine.End);
                    }
                    return dxfLine;
                    };
                case "ARC":
                    {
                    DxfArc dxfArc = (DxfArc)entity;
                    int flag = 0;
                    if (dxfArc.Center.X < 0)
                    {
                        flag = 1;
                    }
                    dxfArc.Center = new Point3D(Math.Abs(dxfArc.Center.X)-relativeStartLocation.X+location.X,dxfArc.Center.Y-relativeStartLocation.Y+location.Y,dxfArc.Center.Z);

                    if (flag == 1)
                    {
                        dxfArc.Center = new Point3D(0 - dxfArc.Center.X, dxfArc.Center.Y, dxfArc.Center.Z);
                    }
                    return dxfArc;
                    };
                case "CIRCLE":
                    {
                        DxfCircle dxfCircle =(DxfCircle)entity;
                        dxfCircle.Center = new Point3D(dxfCircle.Center.X-relativeStartLocation.X+location.X,dxfCircle.Center.Y-relativeStartLocation.Y+location.Y,dxfCircle.Center.Z);
                        return dxfCircle;
                    }
                case "POINT":
                    {
                        DxfPoint dxfPoint = (DxfPoint)entity;
                        dxfPoint.Position = new Point3D(dxfPoint.Position.X - relativeStartLocation.X + location.X, dxfPoint.Position.Y - relativeStartLocation.Y + location.Y, dxfPoint.Position.Z);
                        return dxfPoint;
                    }
                case "TEXT":
                    {
                        DxfText dxfText =(DxfText)entity;
                        dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X-relativeStartLocation.X+location.X,dxfText.AlignmentPoint1.Y-relativeStartLocation.Y+location.Y,dxfText.AlignmentPoint1.Z);
                        dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1;
                        return dxfText;
                    }
                case "ELLIPSE":
                    {
                        DxfEllipse dxfEllipse = (DxfEllipse)entity;
                        dxfEllipse.Center = new Point3D(dxfEllipse.Center.X - relativeStartLocation.X + location.X, dxfEllipse.Center.Y - relativeStartLocation.Y + location.Y, dxfEllipse.Center.Z);
                        return dxfEllipse;
                    }
                case "LWPOLYLINE":
                    {
                        DxfLwPolyline dxfLwPolyLine = (DxfLwPolyline)entity;
                        int len = dxfLwPolyLine.Vertices.Count;
                        for (int i = 0; i < len; i++)
                        {
                            dxfLwPolyLine.Vertices[i].Position = new Point2D(dxfLwPolyLine.Vertices[i].Position.X - relativeStartLocation.X + location.X, dxfLwPolyLine.Vertices[i].Position.Y - relativeStartLocation.Y + location.Y);
                        }

                        return dxfLwPolyLine;
                    }
                case "DIMENSION":
                    {
                        DxfDimension.Aligned dxfDimension =(DxfDimension.Aligned)entity;
                        DxfDimension.Aligned tempDemsion = new DxfDimension.Aligned(testModel.DefaultDimensionStyle);
                        dxfDimension.ExtensionLine1StartPoint = new Point3D(dxfDimension.ExtensionLine1StartPoint.X-relativeStartLocation.X+location.X,dxfDimension.ExtensionLine1StartPoint.Y-relativeStartLocation.Y+location.Y,location.Z);
                        dxfDimension.ExtensionLine2StartPoint = new Point3D(dxfDimension.ExtensionLine2StartPoint.X-relativeStartLocation.X+location.X,dxfDimension.ExtensionLine2StartPoint.Y-relativeStartLocation.Y+location.Y,location.Z);
                       // dxfDimension.DimensionLineLocation = new Point3D(dxfDimension.DimensionLineLocation.X-relativeStartLocation.X+location.X,dxfDimension.DimensionLineLocation.Y-relativeStartLocation.Y+location.Y,dxfDimension.DimensionLineLocation.Z);
                        tempDemsion.ExtensionLine1StartPoint = dxfDimension.ExtensionLine1StartPoint;
                        tempDemsion.ExtensionLine2StartPoint = dxfDimension.ExtensionLine2StartPoint;
                        tempDemsion.Color = dxfDimension.Color;
                        tempDemsion.DimensionStyleOverrides.TextHeight = 56d;
                        tempDemsion.DimensionStyleOverrides.ArrowSize = 20d;
                        if (Math.Round(dxfDimension.ExtensionLine1StartPoint.X * 100) / 100 == Math.Round(dxfDimension.ExtensionLine2StartPoint.X * 100) / 100)
                        {
                            tempDemsion.Text = "" + Convert.ToInt32(Math.Abs(dxfDimension.ExtensionLine1StartPoint.Y - dxfDimension.ExtensionLine2StartPoint.Y) + 0.5);
                        }
                        else
                        {
                            tempDemsion.Text = "" + Convert.ToInt32(Math.Abs(dxfDimension.ExtensionLine1StartPoint.X - dxfDimension.ExtensionLine2StartPoint.X) + 0.5);
                        }

                        tempDemsion.DimensionLineLocation = new Point3D(dxfDimension.DimensionLineLocation.X - relativeStartLocation.X + location.X, dxfDimension.DimensionLineLocation.Y - relativeStartLocation.Y + location.Y, dxfDimension.DimensionLineLocation.Z);

                        return tempDemsion;

                    }
                case "INSERT":
                    {
                        DxfInsert dxfInsert = (DxfInsert)entity;

                        //可行,但是存在很多点点
                        dxfInsert.InsertionPoint = new Point3D(dxfInsert.InsertionPoint.X - relativeStartLocation.X + location.X, dxfInsert.InsertionPoint.Y - relativeStartLocation.Y + location.Y, dxfInsert.InsertionPoint.Z);
                        return dxfInsert;
                    }
                case "HATCH":
                    {
                        DxfHatch dxfHatch = (DxfHatch)entity;
                        int len = dxfHatch.BoundaryPaths.Count;
                        for (int i = 0; i < len; i++)
                        {
                            int len1 = dxfHatch.BoundaryPaths[i].Edges.Count;
                            for (int j = 0; j < len1;j++ )
                            {
                                DxfHatch.BoundaryPath.LineEdge lineEdge = (DxfHatch.BoundaryPath.LineEdge)dxfHatch.BoundaryPaths[i].Edges[j];
                                lineEdge.Start = new Point2D(lineEdge.Start.X-relativeStartLocation.X+location.X,lineEdge.Start.Y-relativeStartLocation.Y+location.Y);
                                lineEdge.End = new Point2D(lineEdge.End.X-relativeStartLocation.X+location.X,lineEdge.End.Y-relativeStartLocation.Y+location.Y);
                            }
                        }
                            return dxfHatch;
                    }
                default:return entity;
            }
        }
Esempio n. 33
0
 public EntityEventArgs(DxfEntity entity)
 {
     this.entity = entity;
 }