www.mxdraw.com
内容索引主面
前一个向上下一个
IMxDrawHatch 接口

图案填充类,实现实心颜色填充和各种图案填充效果

IDL
[ object, uuid(A62D3DA5-4393-4182-9C73-591B4FF21673), dual, nonextensible, helpstring("IMxDrawHatch interface"), pointer_default(unique) ]
interface IMxDrawHatch : IMxDrawEntity;

MxDrawHatch.idl

例如: C# 读取填充属性,并设置到另一个新建的填充.

                      MxDrawEntity ent = (MxDrawEntity)axMxDrawX1.GetEntity("hatch");
                    if (ent == null)
                        return;
                    if (!(ent is MxDrawHatch) )
                    {
                          return;
                    }

                    MxDrawHatch hatch = (MxDrawHatch)ent;

                    MxDrawHatch newHatch = new MxDrawHatch();

                    // 读取选择到填充对象数据,把这个数据传给新建的newHathc对象。

                    newHatch.PatternAngle = hatch.PatternAngle;

                    // 循环得到填充边数据.
                    for (Int32 i = 0; i < hatch.NumLoops; i++)
                    {
                        if (!hatch.LoopTypeIsPolyline(i))
                        {
                            // 暂不支持曲线类型的边界.
                            continue;
                        }

                        Int32 iLootType = hatch.LoopTypeAt(i);

                        MxDrawResbuf loop = hatch.GetLoopAt(i);
                        if(loop == null)
                            continue;

                        // 下面可以得每个点的坐标,凸度.
                        for (Int32 j = 0; j + 1< loop.Count; )
                        {
                            MxDrawPoint pt = loop.AtPoint(j);
                            double dBulge = loop.AtDouble(j + 1);
                            j += 2;
                        }
                        // 把得到loop设置给新对象.

                        newHatch.AppendLoop(iLootType, loop);
                    }

                    //
                    newHatch.Elevation = hatch.Elevation;

                    // 读取图案定义数据.
                    for (Int32 i = 0; i < hatch.NumPatternDefinitions(); i++)
                    {
                        double Angle = 0.0, baseX = 0.0, baseY = 0.0, offsetX = 0.0, offsetY = 0.0;
                        MxDrawResbuf defData = hatch.GetPatternDefinitionAt(i, out Angle, out baseX, out baseY, out offsetX, out offsetY);

                        if (defData == null)
                            continue;

                        // 下面可以得每个图案定义线型数据 。

                        for (Int32 j = 0; j < defData.Count; j++ )
                        {
                            double dDashe = defData.AtDouble(j);
             
                        }

                        newHatch.AddPatternDefinition(Angle,baseX,baseY,offsetX,offsetY,defData);
                    }

                    //
                   newHatch.PatternType = hatch.PatternType;
                   newHatch.PatternName = hatch.PatternName;
                   newHatch.PatternScale = hatch.PatternScale;
                   newHatch.PatternSpace = hatch.PatternSpace;
                   newHatch.PatternDouble = hatch.PatternDouble;
                   newHatch.HatchStyle = hatch.HatchStyle;
                   newHatch.HatchObjectType = hatch.HatchObjectType;
                   newHatch.GradientType = hatch.GradientType;
                   newHatch.GradientName = hatch.GradientName;
                   newHatch.GradientAngle = hatch.GradientAngle;
                   newHatch.GradientOneColorMode = hatch.GradientOneColorMode;
                   newHatch.ShadeTintValue = hatch.ShadeTintValue;

                    // 把新的填充对象增加当前空间。

                   axMxDrawX1.DrawEntity(newHatch);
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!