Ejemplo n.º 1
0
 public override void OnDraw(GeometryBuilder dc)
 {
     dc.Clear();
     dc.Color = McDbEntity.ByObject;
     dc.DrawCircle(_basePnt, _radius);
     dc.DrawCircle(_basePnt, _radius / 2.0);
     dc.TextHeight = 31;
     dc.DrawMText(_basePnt, Vector3d.XAxis, _predText, HorizTextAlign.Center, VertTextAlign.Center, _radius / 2.05);
 }
Ejemplo n.º 2
0
        public override void OnDraw(GeometryBuilder dc)
        {
            dc.Clear();
            dc.Color = McDbEntity.ByObject;//color will be taken from object properties and object will be redrawn after color change

            if (V_true == 0)
            {
                double pos_thickness = Thickness < 0 ? Thickness * -1 : Thickness;
                if (pos_thickness < 3)
                {
                    V = 16;
                }
                else if (pos_thickness == 3)
                {
                    V = 20;
                }
                else if (pos_thickness == 4)
                {
                    V = 35;
                }
                else if (pos_thickness > 4)
                {
                    V = 50;
                }
            }
            else
            {
                V = V_true;
            }

            Polyline3d polyround = new Polyline3d(poly);

            _length_sum = 0;

            //HostMgd.EditorInput.Editor ed = HostMgd.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            for (int i = 2; i < polyround.Vertices.Count; i += 2)
            {
                //double angle1 = Math.Atan2(polyround.Vertices[i - 2].Point.X - polyround.Vertices[i - 1].Point.X, polyround.Vertices[i - 2].Point.Y - polyround.Vertices[i - 1].Point.Y);
                //double angle2 = Math.Atan2(polyround.Vertices[i - 1].Point.X - polyround.Vertices[i].Point.X, polyround.Vertices[i - 1].Point.Y - polyround.Vertices[i].Point.Y);

                double anglesum = (polyround.Vertices[i - 1].Point.X - polyround.Vertices[i].Point.X) * (polyround.Vertices[i - 2].Point.Y - polyround.Vertices[i].Point.Y) - (polyround.Vertices[i - 1].Point.Y - polyround.Vertices[i].Point.Y) * (polyround.Vertices[i - 2].Point.X - polyround.Vertices[i].Point.X);//Math.Atan((angle2 - angle1) / (1 + angle2 * angle1));//angle1 + angle2

                double a = polyround.Vertices[i - 2].Point.DistanceTo(polyround.Vertices[i - 1].Point);
                double b = polyround.Vertices[i - 1].Point.DistanceTo(polyround.Vertices[i].Point);
                double c = polyround.Vertices[i - 2].Point.DistanceTo(polyround.Vertices[i].Point);

                double angle = Math.Acos((Math.Pow(a, 2) + Math.Pow(b, 2) - Math.Pow(c, 2)) / (2 * a * b));
                angle = angle * 180 / Math.PI;

                double r             = V * 0.16;
                double pos_thickness = Thickness < 0 ? Thickness * -1 : Thickness;
                double BA            = Math.PI / 180 * (180 - angle) * (r + k_factor * pos_thickness);

                _length_sum += BA;

                double radius;
                if (anglesum < 0)
                {
                    radius = V * 0.16;
                }
                else
                {
                    radius = V * 0.16 + Thickness;
                }
                if (Thickness < 0)
                {
                    radius += Thickness * -1;
                }


                polyround.Vertices.MakeFilletAtVertex(i - 1, radius);
            }

            for (int i = 0; i < polyround.Vertices.Count; i += 2)
            {
                LineSeg3d line = polyround.Segments[i] as LineSeg3d;
                _length_sum += line.Length;
            }

            _length_sum = Math.Round(_length_sum, 4);

            Polyline3d offset = polyround.GetTrimmedOffset(-Thickness)[0];

            dc.DrawPolyline(polyround);
            dc.DrawPolyline(offset);
            dc.DrawLine(polyround.Points.FirstPoint, offset.Points.FirstPoint);
            dc.DrawLine(polyround.Points.LastPoint, offset.Points.LastPoint);
            Polyline3d middlePoly = polyround.GetTrimmedOffset(-Thickness * (Thickness < 0 ? 1 - k_factor : k_factor))[0];

            dc.TextHeight = 2.5 * DbEntity.Scale;   //Use annotation scale
            dc.DrawMText(_textPoint, Vector3d.XAxis, Math.Round(_length_sum, 1).ToString(), HorizTextAlign.Center, VertTextAlign.Center);
            dc.StrLineType   = "Center";
            dc.Color         = Color.Yellow;
            dc.LinetypeScale = DbEntity.LinetypeScale * 0.3;
            dc.DrawPolyline(middlePoly);
        }