protected override bool WorldDraw(WorldDraw draw)
        {
            _line.StartPoint = _startPoint;
            _line.EndPoint   = _currentPoint;
            draw.Geometry.Draw(_line);
            for (var i = 0; i < _dimensions.Count; i++)
            {
                var tuple = _dimensions[i];
                if (tuple.Item2 is RotatedDimension rotatedDimension)
                {
                    var newDimLinePoint = _line.GetClosestPointTo(rotatedDimension.DimLinePoint, true);
                    rotatedDimension.DimLinePoint = newDimLinePoint;
                    _dimensions[i] = new Tuple <ObjectId, Dimension, Point3d>(tuple.Item1, tuple.Item2, newDimLinePoint);
                    draw.Geometry.Draw(tuple.Item2);
                }

                if (tuple.Item2 is AlignedDimension alignedDimension)
                {
                    var newDimLinePoint = _line.GetClosestPointTo(alignedDimension.DimLinePoint, true);
                    alignedDimension.DimLinePoint = newDimLinePoint;
                    _dimensions[i] = new Tuple <ObjectId, Dimension, Point3d>(tuple.Item1, tuple.Item2, newDimLinePoint);
                    draw.Geometry.Draw(tuple.Item2);
                }
            }

            return(true);
        }
Example #2
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            draw.Geometry.Draw(_line);
            draw.Geometry.Draw(_circle);

            return(true);
        }
Example #3
0
        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            if (drawable is Entity ent)
            {
                var id = GrasshopperData.GetGrasshopperData(ent);
                if (!id.IsNull)
                {
                    var database   = id.Database;
                    var docExt     = GhBcConnection.GrasshopperDataExtension.GrasshopperDataManager(database);
                    var ghDrawable = docExt?.Drawable(id);
                    if (ghDrawable == null)
                    {
                        return(base.WorldDraw(drawable, wd));
                    }

                    bool needToDraw = false;
                    using (var transaction = database.TransactionManager.StartTransaction())
                    {
                        var ghData = transaction.GetObject(id, OpenMode.ForRead) as GrasshopperData;
                        needToDraw = ghData.IsVisible;
                        transaction.Commit();
                    }
                    if (needToDraw)
                    {
                        using (var trSt = new TraitsState(wd.SubEntityTraits))
                        {
                            wd.Geometry.Draw(ghDrawable);
                        }
                        wd.SubEntityTraits.Transparency = new Transparency((byte)GhDataSettings.HostTransparency);
                    }
                }
            }
            return(base.WorldDraw(drawable, wd));
        }
        //显示重载
        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            LArrow3 la = new LArrow3(drawable);

            la.WorldDraw(wd);
            return(base.WorldDraw(drawable, wd));
        }
Example #5
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            Calculate();
            List <Entity> inMemoryEntities = new List <Entity>(Entities.Count);

            lock (Entities)
            {
                foreach (Entity ent in Entities.ToArray())
                {
                    //Entity inMemoryEntity = (Entity)ent.GetTransformedCopy(ToWcsTransform);
                    Entity inMemoryEntity = (Entity)ent.Clone();
                    inMemoryEntities.Add(inMemoryEntity);
                    draw.Geometry.Draw(inMemoryEntity);
                }
            }

            List <Entity> buffer = new List <Entity>(inMemoryEntities);

            System.Threading.Thread thread = new System.Threading.Thread(obj =>
            {
                foreach (Entity ent in (List <Entity>)obj)
                {
                    ent.Dispose();
                }
                ((List <Entity>)obj).Clear();
            });
            thread.Start(buffer);
            return(true);
        }
Example #6
0
        /// <inheritdoc />
        protected override bool WorldDraw(WorldDraw draw)
        {
            if (Pts.Count == 1)
            {
                return(draw.Geometry.WorldLine(Pts[0].Convert3d(), newPt.Convert3d()));
            }

            using (var pl = Pts.CreatePolyline())
            {
                pl.Closed        = true;
                pl.ColorIndex    = 7;
                pl.LinetypeId    = crossLineTypeId;
                pl.LineWeight    = LineWeight.LineWeight018;
                pl.LinetypeScale = 1;
                draw.Geometry.Draw(pl);
            }

            try
            {
                var pts = Pts.ToList();
                pts.Add(newPt);
                using (var hatch = pts.CreateHatch())
                {
                    hatch.SetHatchPattern(HatchPatternType.UserDefined, "SOLID");
                    hatch.Color        = hatchColor;
                    hatch.Transparency = hatchTransp;
                    return(draw.Geometry.Draw(hatch));
                }
            }
            catch
            {
                return(true);
            }
        }
Example #7
0
        /// <inheritdoc />
        protected override bool WorldDraw(WorldDraw draw)
        {
            var oldCmdEcho = Application.GetSystemVariable("CMDECHO");

            Application.SetSystemVariable("CMDECHO", 0);

            draw.Geometry.Draw(_line);

            _tb.UpgradeOpen();

            // Длина по вертикали
            var lenVer = _line.StartPoint.Y - _line.EndPoint.Y;

            if (lenVer > _originTableHeight)
            {
                _tb.InsertRows(_tb.Rows.Count, _rowHeight, 1);
            }

            if (lenVer < _originTableHeight)
            {
                if (_tb.Rows.Count - 1 > _stopRows)
                {
                    _tb.DeleteRows(_tb.Rows.Count - 1, 1);
                }
            }

            draw.Geometry.Draw(_tb);
            _originTableHeight = _tb.GeometricExtents.MaxPoint.Y - _tb.GeometricExtents.MinPoint.Y;

            Application.SetSystemVariable("CMDECHO", oldCmdEcho);
            return(true);
        }
Example #8
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            WorldGeometry geo = draw.Geometry;

            if (geo != null)
            {
                if (jigUpdate)
                {
                    stair = MyFunctions.CreateStair3D(steps, riser, tread, landing, width, slope);
                }
                switch (jigStatus)
                {
                case 0:
                    geo.PushModelTransform(matDisplacement);
                    geo.Draw(stair);
                    geo.PopModelTransform();
                    break;

                case 1:
                    geo.PushModelTransform(matDisplacement.PreMultiplyBy(matRotation));
                    geo.Draw(stair);
                    geo.PopModelTransform();
                    break;;

                default: return(false);
                }
            }
            return(true);
        }
Example #9
0
        protected override bool WorldDrawData(WorldDraw draw)
        {
            if (!_capturing)
            {
                _drawing = true;

                // Draw each of our lines

                short oidx = draw.SubEntityTraits.Color;

                foreach (var ln in _lines)
                {
                    // Set the colour and lineweight in the subentity
                    // traits based on the original line

                    if (ln != null)
                    {
                        draw.SubEntityTraits.Color      = (short)ln.ColorIndex;
                        draw.SubEntityTraits.LineWeight = ln.LineWeight;

                        ln.WorldDraw(draw);
                    }
                }

                draw.SubEntityTraits.Color = oidx;

                _drawing = false;
            }

            return(base.WorldDrawData(draw));
        }
        /// <inheritdoc />
        protected override bool WorldDraw(WorldDraw draw)
        {
            try
            {
                var mInsertPt = _currentPoint;
                switch (_insertSnap)
                {
                case InsertSnap.TopLeft:
                    mInsertPt = _currentPoint;
                    break;

                case InsertSnap.TopRight:
                    mInsertPt = new Point3d(_currentPoint.X - _table.Width, _currentPoint.Y, _currentPoint.Z);
                    break;

                case InsertSnap.BottomLeft:
                    mInsertPt = new Point3d(_currentPoint.X, _currentPoint.Y + _table.Height, _currentPoint.Z);
                    break;

                case InsertSnap.BottomRight:
                    mInsertPt = new Point3d(_currentPoint.X - _table.Width, _currentPoint.Y + _table.Height, _currentPoint.Z);
                    break;
                }

                _table.Position = mInsertPt;

                return(draw.Geometry.Draw(_table));
            }
            catch
            {
                return(false);
            }
        }
        protected override bool WorldDraw(WorldDraw _draw)
        {
            try
            {
                currentPoint = new Point3d(currentPoint.X, basePoint.Y, currentPoint.Z);
                transform    = Matrix3d.Displacement(basePoint.GetVectorTo(currentPoint));
                var geometry = _draw.Geometry;
                if (geometry != null)
                {
                    geometry.PushModelTransform(transform);
                    foreach (var entity in entities)
                    {
                        geometry.Draw(entity);
                    }
                    geometry.PopModelTransform();
                }

                return(true);
            }
            catch (Exception _ex)
            {
                CADProxy.Editor.WriteMessage(_ex.Message);
                return(false);
            }
        }
Example #12
0
        //显示重载
        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            Line     line = (Line)drawable;
            Vector3d vec;
            Point3d  pnt;

            double arrowLen = (double)line.XData.AsArray()[1].Value;

            if (line.Length == 0)
            {
                vec = Vector3d.XAxis;
                pnt = line.StartPoint;
            }
            else
            {
                double cenpar = (line.StartParam + line.EndParam) / 2;
                vec = line.GetFirstDerivative(cenpar).GetNormal();
                pnt = line.GetPointAtParameter(cenpar);
            }
            Vector3d v1 = vec.TransformBy(Matrix3d.Rotation(Math.PI / 6, Vector3d.ZAxis, Point3d.Origin));
            Vector3d v2 = vec.TransformBy(Matrix3d.Rotation(-Math.PI / 6, Vector3d.ZAxis, Point3d.Origin));

            wd.Geometry.Draw(new Line(pnt, pnt + v1 * arrowLen));
            wd.Geometry.Draw(new Line(pnt, pnt + v2 * arrowLen));
            return(base.WorldDraw(drawable, wd));
        }
Example #13
0
        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            if (!DBEntityCopy.Instance.isDBEntityCopy)
            {
                var objectIdCollection = new ObjectIdCollection();
                var points             = GetSymbolValueByObjectId(UserGripOverrule.objectId, ref objectIdCollection);
                foreach (var v in points)
                {
                    wd.Geometry.WorldLine(UserGripOverrule.pt, (Point3d)v);
                }
            }


            //var objIds = new ObjectId[objectIdCollection.Count];
            //objectIdCollection.CopyTo(objIds, 0);
            //ManyEntityCopy dragger = new ManyEntityCopy();

            //var dragResult = dragger.StartDrag(UserGripOverrule.pt, objIds);

            //if (dragResult.Status == PromptStatus.OK)
            //{
            //}



            //foreach (Entity draggingEntity in objectIdCollection)
            //{
            //    draggingEntity.TransformBy(displacementMatrix);
            //    wd.Geometry.Draw(draggingEntity);
            //}

            return(base.WorldDraw(drawable, wd));
        }
Example #14
0
 protected override bool WorldDraw(WorldDraw Draw)
 {
     Draw.Geometry.Draw(this.entity_0[0]);
     Draw.Geometry.Draw(this.entity_0[1]);
     Draw.Geometry.Draw(this.entity_0[2]);
     return(true);
 }
Example #15
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            WorldGeometry geo = draw.Geometry;

            if (geo != null)
            {
                Vector3d vec  = basePoint.GetVectorTo(secondPoint);
                Matrix3d disp = Matrix3d.Displacement(this.basePoint.GetVectorTo(this.secondPoint));
                //geo.PushModelTransform(disp);
                for (int i = 0; i < blockPosition.Count; i++)
                {
                    Point3d tempPoint = blockPosition[i] + vec;
                    brefs[i].Position = tempPoint;
                    geo.Draw(brefs[i]);
                }

                for (int i = 0; i < linesPosition.Count; i++)
                {
                    Point3d tempStartPoint = linesPosition[i].Item1 + vec;
                    Point3d tempEndPoint   = linesPosition[i].Item2 + vec;

                    lines[i].StartPoint = tempStartPoint;
                    lines[i].EndPoint   = tempEndPoint;
                    geo.Draw(lines[i]);
                }
                //geo.PopModelTransform();
                return(true);
            }
            return(false);
        }
Example #16
0
        public override bool WorldDraw(Drawable d, WorldDraw wd)
        {
            double radius = 0.0;

            if (d is DBObject)
            {
                radius = PipeRadiusForObject((DBObject)d);
            }

            if (radius > 0.0)
            {
                Line line = d as Line;

                if (line != null)
                {
                    // Draw the line as is, with overruled attributes

                    base.WorldDraw(line, wd);
                    if (!line.Id.IsNull && line.Length > 0.0)
                    {
                        // Draw a pipe around the line

                        EntityColor c =
                            wd.SubEntityTraits.TrueColor;
                        wd.SubEntityTraits.TrueColor =
                            new EntityColor(0x00AfAfff);
                        wd.SubEntityTraits.LineWeight =
                            LineWeight.LineWeight000;
                        Circle clr =
                            new Circle(
                                line.StartPoint,
                                line.EndPoint - line.StartPoint,
                                radius
                                );
                        ExtrudedSurface pipe = new ExtrudedSurface();
                        try
                        {
                            pipe.CreateExtrudedSurface(
                                clr, line.EndPoint - line.StartPoint, sweepOpts
                                );
                        }
                        catch
                        {
                            Document doc =
                                Application.DocumentManager.MdiActiveDocument;
                            doc.Editor.WriteMessage(
                                "\nFailed with CreateExtrudedSurface."
                                );
                        }
                        clr.Dispose();
                        pipe.WorldDraw(wd);
                        pipe.Dispose();
                        wd.SubEntityTraits.TrueColor = c;
                    }
                    return(true);
                }
            }
            return(base.WorldDraw(d, wd));
        }
Example #17
0
        public bool WorldDraw(WorldDraw wd)
        {
            createInstance();
            bool WorldD = BaseDrawable.WorldDraw(wd);

            tr.Dispose();
            return(WorldD);
        }
    protected override bool WorldDrawData(WorldDraw draw)
    {
      // This simply draws our points

      draw.Geometry.Polypoint(_points, null, null);

      return true;
    }
Example #19
0
 //用传入的第一个点构造
 protected override bool WorldDraw(WorldDraw draw)
 {
     for (int i = 0; i < m_EntCopyArr.Length; i++)
     {
         draw.Geometry.Draw(m_EntCopyArr[i]);
     }
     return(true);
 }
Example #20
0
 protected override bool WorldDraw(WorldDraw draw)
 {
     for (int i = 0; i < selectEntity.Length; i++)
     {
         draw.Geometry.Draw(selectEntity[i]);
     }
     return(true);
 }
Example #21
0
 protected override bool WorldDraw(WorldDraw Draw)
 {
     foreach (Entity obj in this.entity_0)
     {
         Draw.Geometry.Draw((Drawable)obj);
     }
     return(true);
 }
Example #22
0
 protected override bool SubWorldDraw(WorldDraw pWorldDraw)
 {
     if (null != cloneEnt)
     {
         return(cloneEnt.WorldDraw(pWorldDraw));
     }
     return(true);
 }
Example #23
0
        protected override bool WorldDrawData(WorldDraw draw)
        {
            // This simply draws our points

            draw.Geometry.Polypoint(_points, null, null);

            return(true);
        }
Example #24
0
 // WorldDraw函数用于刷新屏幕上显示的图形.
 protected override bool WorldDraw(WorldDraw draw)
 {
     for (int i = 0; i <= ids.Length - 1; i++)
     {
         // 刷新画面.
         draw.Geometry.Draw(entCopy[i]);
     }
     return(true);
 }
Example #25
0
        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            if (wd.RegenAbort || wd.IsDragging)
            {
                return base.WorldDraw(drawable, wd);
            }

            RebarPos pos = drawable as RebarPos;
            if (pos == null)
            {
                return base.WorldDraw(drawable, wd);
            }

            PosShape shape = PosShape.GetPosShape(pos.Shape);
            Extents3d? shapeExt = shape.Bounds;
            if (!shapeExt.HasValue)
            {
                return base.WorldDraw(drawable, wd);
            }
            Extents3d ext = shapeExt.Value;

            WorldGeometry g = wd.Geometry;
            SubEntityTraits s = wd.SubEntityTraits;
            TextStyle style = new TextStyle();

            // Get geometry
            Point3d pt = pos.BasePoint;
            Vector3d dir = pos.DirectionVector;
            Vector3d up = pos.UpVector;
            Vector3d norm = pos.NormalVector;

            double w = pos.Width / dir.Length;
            double h = pos.Height / dir.Length;

            // Draw shape
            double xmin = ext.MinPoint.X, ymin = ext.MinPoint.Y, xmax = ext.MaxPoint.X, ymax = ext.MaxPoint.Y;

            // Scale
            double scale = 0.025;
            // Client offsets
            double xoff = (w - scale * (xmax - xmin)) / 2.0;
            double yoff = 2.0 * h;//(h - scale * (ymax - ymin)) / 2.0;

            // Transform
            Matrix3d trans = Matrix3d.AlignCoordinateSystem(new Point3d(xmin, ymin, 0), Vector3d.XAxis / scale, Vector3d.YAxis / scale, Vector3d.ZAxis / scale, pt + dir * xoff + up * yoff, dir, up, norm);
            g.PushModelTransform(trans);

            // Draw shapes
            shape.SetShapeTexts(pos.A, pos.B, pos.C, pos.D, pos.E, pos.F);
            g.Draw(shape);
            shape.ClearShapeTexts();

            // Reset transform
            g.PopModelTransform();

            return base.WorldDraw(drawable, wd);
        }
        protected override bool SubWorldDraw(WorldDraw wd)
        {
            SetColor(wd.SubEntityTraits, Colour);
            int drawablesForViewport = Drawables.Count(drawable => !drawable.WorldDraw(wd));

            SetColor(wd.SubEntityTraits, ColourSelected);
            drawablesForViewport += SelectedDrawables.Count(drawable => !drawable.WorldDraw(wd));
            return(drawablesForViewport == 0);
        }
Example #27
0
        // Show block in its current position
        protected override bool WorldDraw(WorldDraw draw)
        {
            var inMemoryBlockRef = new BlockReference(point, blockDefId);

            draw.Geometry.Draw(inMemoryBlockRef);
            inMemoryBlockRef.Dispose();

            return(true);
        }
Example #28
0
            protected override bool SubWorldDraw(WorldDraw wd)
            {
                foreach (var _ent in EntitiyList)
                {
                    _ent.WorldDraw(wd);
                }

                return(true);
            }
Example #29
0
        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            if (!wd.Context.IsPlotGeneration) // Не в состоянии печати!
            {
                var ent = drawable as Entity;
                if (ent != null && !ent.IsAProxy && !ent.IsCancelling && !ent.IsDisposed && !ent.IsErased)
                {
                    try
                    {
                        if (ent.IsModPlusProduct())
                        {
                            double height = (double)AcApp.GetSystemVariable("VIEWSIZE");
                            var    scale  = height / 1500;
                            var    offset = 20;
                            var    plane  = ent.GetPlane();

                            Matrix3d          ucs     = AcApp.DocumentManager.MdiActiveDocument.Editor.CurrentUserCoordinateSystem;
                            var               extents = ent.GeometricExtents;
                            var               pt      = extents.MaxPoint.TransformBy(ucs.Inverse());
                            Point3dCollection points  = new Point3dCollection();
                            points.Add(new Point3d(pt.X + ((offset + 00) * scale), pt.Y + ((offset + 00) * scale), plane.PointOnPlane.Z));
                            points.Add(new Point3d(pt.X + ((offset + 00) * scale), pt.Y + ((offset + 10) * scale), plane.PointOnPlane.Z));
                            points.Add(new Point3d(pt.X + ((offset + 10) * scale), pt.Y + ((offset + 10) * scale), plane.PointOnPlane.Z));
                            points.Add(new Point3d(pt.X + ((offset + 10) * scale), pt.Y + ((offset + 30) * scale), plane.PointOnPlane.Z));
                            points.Add(new Point3d(pt.X + ((offset + 00) * scale), pt.Y + ((offset + 30) * scale), plane.PointOnPlane.Z));
                            points.Add(new Point3d(pt.X + ((offset + 00) * scale), pt.Y + ((offset + 40) * scale), plane.PointOnPlane.Z));
                            points.Add(new Point3d(pt.X + ((offset + 30) * scale), pt.Y + ((offset + 40) * scale), plane.PointOnPlane.Z));
                            points.Add(new Point3d(pt.X + ((offset + 30) * scale), pt.Y + ((offset + 30) * scale), plane.PointOnPlane.Z));
                            points.Add(new Point3d(pt.X + ((offset + 20) * scale), pt.Y + ((offset + 30) * scale), plane.PointOnPlane.Z));
                            points.Add(new Point3d(pt.X + ((offset + 20) * scale), pt.Y + ((offset + 10) * scale), plane.PointOnPlane.Z));
                            points.Add(new Point3d(pt.X + ((offset + 30) * scale), pt.Y + ((offset + 10) * scale), plane.PointOnPlane.Z));
                            points.Add(new Point3d(pt.X + ((offset + 30) * scale), pt.Y + ((offset + 00) * scale), plane.PointOnPlane.Z));
                            points.Add(new Point3d(pt.X + ((offset + 00) * scale), pt.Y + ((offset + 00) * scale), plane.PointOnPlane.Z));

                            short    backupColor    = wd.SubEntityTraits.Color;
                            FillType backupFillType = wd.SubEntityTraits.FillType;
                            wd.SubEntityTraits.FillType = FillType.FillAlways;
                            wd.SubEntityTraits.Color    = 150;
                            wd.Geometry.Polygon(points);
                            wd.SubEntityTraits.FillType = FillType.FillNever;

                            // restore
                            wd.SubEntityTraits.Color    = backupColor;
                            wd.SubEntityTraits.FillType = backupFillType;
                        }
                    }
                    catch (System.Exception exception)
                    {
                        // not showing. Only sending by AppMetrica
                        Statistic.SendException(exception);
                    }
                }
            }

            return(base.WorldDraw(drawable, wd));
        }
Example #30
0
        protected override bool WorldDrawData(WorldDraw draw)
        {
            // This simply draws our points

            if (_points != null && _points.Count > 0)
            {
                draw.Geometry.Polypoint(_points, null, null);
            }

            return(true);
        }
Example #31
0
            public override bool WorldDraw(Drawable drawable, WorldDraw wd)
            {
                Circle c = (Circle)drawable;

                LineSegment3d[] lines = GetLines(c);
                foreach (LineSegment3d l in lines)
                {
                    wd.Geometry.WorldLine(l.StartPoint, l.EndPoint);
                }
                return(base.WorldDraw(drawable, wd));
            }
Example #32
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            var displacementMatrix = m_displacemenMatrix;

            foreach (var draggingEntity in m_entitiesToDrag)
            {
                draggingEntity.TransformBy(displacementMatrix);
                draw.Geometry.Draw(draggingEntity);
            }
            return(true);
        }
Example #33
0
 protected override bool WorldDraw(WorldDraw draw)
 {
     WorldGeometry geo = draw.Geometry;
      if (geo != null)
      {
     // Отрисовка линий.
     _lines = getLines();
     foreach (var line in _lines)
     {
        geo.Draw(line);
     }
      }
      return true;
 }
Example #34
0
        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            if (wd.RegenAbort || wd.IsDragging)
            {
                return base.WorldDraw(drawable, wd);
            }

            RebarPos pos = drawable as RebarPos;
            if (pos == null || (pos.IncludeInBOQ && !pos.Detached))
            {
                return base.WorldDraw(drawable, wd);
            }

            // Get geometry
            Point3d minpt;
            Point3d maxpt;
            pos.TextBox(out minpt, out maxpt);
            minpt = minpt.DivideBy(pos.Scale);
            maxpt = maxpt.DivideBy(pos.Scale);

            using (Solid solid = new Solid())
            {
                solid.SetPointAt(0, new Point3d(minpt.X - 0.15, minpt.Y - 0.15, 0));
                solid.SetPointAt(1, new Point3d(maxpt.X + 0.15, minpt.Y - 0.15, 0));
                solid.SetPointAt(2, new Point3d(minpt.X - 0.15, maxpt.Y + 0.15, 0));
                solid.SetPointAt(3, new Point3d(maxpt.X + 0.15, maxpt.Y + 0.15, 0));
                solid.Color = mColor;
                solid.LayerId = PosUtility.DefpointsLayer;

                Matrix3d trans = Matrix3d.AlignCoordinateSystem(
                    Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis,
                    pos.BasePoint, pos.DirectionVector, pos.UpVector, pos.NormalVector);

                solid.TransformBy(trans);
                wd.Geometry.Draw(solid);
            }

            // Draw the entity over shading
            return base.WorldDraw(drawable, wd);
        }
      public override bool WorldDraw(Drawable drawable, WorldDraw wd)
      {
         // draw the base class
         bool ret = base.WorldDraw(drawable, wd);

         DB.Curve curve = drawable as DB.Curve;
         if (curve != null)
         {
            Isoline isoline = new Isoline(curve);
            if (isoline.IsIsoline)
            {
               var lines = isoline.GetLines(curve);
               foreach (var line in lines)
               {
                  wd.Geometry.Draw(line);
               }
            }
         }

         // return the base
         return true;
      }
Example #36
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            WorldGeometry geo = draw.Geometry;
             if (geo != null)
             {
            geo.PushModelTransform(UCS); // Не очень понятно, что это.

            if (_allVertex.Count != 0)
            {
               // Копирование точек полилинии во временную колекцию
               Point3dCollection tempAllVertex = new Point3dCollection();
               foreach (Point3d pt in _allVertex)
                  tempAllVertex.Add(pt);
               // Последняя вершина полилинии.
               Point3d pt1 = _allVertex[_allVertex.Count - 1];
               // Точка отрогональная по длинной стороне к текущей указанной.
               Point3d ptNew = GetPointOrhto(pt1, _lastVertex);
               // Получение вершин для полилинии текущего участка.
               Point3dCollection _tempNewSectionPts = GetContourVertex(pt1, ptNew);
               // Добавление вершин последнего участка к остальным.
               if (_tempNewSectionPts.Count > 0)
               {
                  foreach (Point3d pt in _tempNewSectionPts)
                     tempAllVertex.Add(pt);
               }
               // Отрисовка полилинии.
               geo.Polyline(tempAllVertex, Vector3d.ZAxis, IntPtr.Zero);
            }
            geo.PopModelTransform(); // Что это?
             }
             return true;
        }
Example #37
0
 public bool WorldDraw(WorldDraw wd)
 {
     createInstance();
     bool WorldD = BaseDrawable.WorldDraw(wd);
     tr.Dispose();
     return WorldD;
 }
    protected override bool WorldDraw(WorldDraw draw)
    {
      if (_snapshot)
      {
        if (_points.Count > 0)
        {
          List<ColoredPoint3d> vecList = GeneratePointCloud(1, true);

          // Add the core list to the total set

          _totalVecs.AddRange(vecList);

          // Make a copy of the latest set of jigged points

          Point3d[] tmp = new Point3d[_points.Count];
          _points.CopyTo(tmp, 0);

          // Add the copy to the list of snapshot previews

          _snapped.Add(new Point3dCollection(tmp));
        }
      }

      short origColor = draw.SubEntityTraits.Color;

      for (int i = 0; i < _snapped.Count; i++)
      {
        // Cycle through colour indeces for each snapshot

        draw.SubEntityTraits.Color = (short)(i + 1);
        
        // Draw the actual snapshot, one by one

        if (_snapped[i].Count > 0)
          draw.Geometry.Polypoint(_snapped[i], null, null);
      }

      // Set the colour back to the original

      draw.SubEntityTraits.Color = origColor;

      if (_snapshot)
      {
        // Reset the flag, timer and check whether finished

        _snapshot = false;
        Finished = (--_numShots == 0);
        _timer.Enabled = true;
      }
      else
      {
        // This simply draws our points

        if (_points.Count > 0)
          draw.Geometry.Polypoint(_points, null, null);
      }

      return true;
    }
    protected override bool WorldDrawData(WorldDraw draw)
    {
      if (!base.WorldDrawData(draw))
        return false;

      TransientManager ctm =
        TransientManager.CurrentTransientManager;
      IntegerCollection ints = new IntegerCollection();

      // Draw any outstanding segments (and do so only once)

      bool wasCalibrating = _calibrating;

      while (_lineSegs.Count > 0)
      {
        // Get the line segment and remove it from the list

        LineSegment3d ls = _lineSegs[0];
        _lineSegs.RemoveAt(0);

        // Create an equivalent, red, database line
        // (or yellow, if calibrating)

        Line ln = new Line(ls.StartPoint, ls.EndPoint);
        ln.ColorIndex = (wasCalibrating ? 2 : 1);
        _lines.Add(ln);

        // Draw it as transient graphics

        ctm.AddTransient(
          ln, TransientDrawingMode.DirectShortTerm,
          128, ints
        );

        _calibrating = false;
      }

      if (_drawing)
      {
        if (_cursor == null)
        {
          if (_vertices.Count > 0)
          {
            // Clear our skeleton

            ClearTransients();

            _curPt = _vertices[_vertices.Count - 1];

            // Make our sphere 10cm in diameter (5cm radius)

            Solid3d sol = new Solid3d();
            sol.CreateSphere(0.05);
            _cursor = sol;
            _cursor.TransformBy(
              Matrix3d.Displacement(_curPt - Point3d.Origin)
            );

            _cursor.ColorIndex = 2;

            ctm.AddTransient(
              _cursor, TransientDrawingMode.DirectShortTerm,
              128, ints
            );
          }
        }
        else
        {
          if (_vertices.Count > 0)
          {
            Point3d newPt = _vertices[_vertices.Count - 1];
            _cursor.TransformBy(
              Matrix3d.Displacement(newPt - _curPt)
            );
            _curPt = newPt;

            ctm.UpdateTransient(_cursor, ints);
          }
        }
      }
      else // !_drawing
      {
        if (_cursor != null)
        {
          ctm.EraseTransient(_cursor, ints);
          _cursor.Dispose();
          _cursor = null;
        }
      }

      return true;
    }
Example #40
0
        protected override bool WorldDrawData(WorldDraw draw)
        {
            if (!base.WorldDrawData(draw))
                return false;

            short origCol = draw.SubEntityTraits.Color;

            if (_resizing)
            {
                using (Solid3d cylinder = new Solid3d())
                {
                    try
                    {
                        cylinder.CreateFrustum(_profSide, _profSide, _profSide,_profSide);

                        if (cylinder != null)
                        {
                            cylinder.TransformBy(
                              Matrix3d.Displacement(
                                _resizeLocation - Point3d.Origin
                              )
                            );

                            // Draw the cursor

                            draw.SubEntityTraits.Color = ColorIndex;
                            cylinder.WorldDraw(draw);
                        }
                    }
                    catch (System.Exception ex)
                    {
                        _doc.Editor.WriteMessage(
                          "\nException: {0} - {1}", ex.Message, ex.InnerException
                        );
                    }
                    finally
                    {
                        draw.SubEntityTraits.Color = origCol;
                    }
                }
                return true;
            }

            // If we're currently drawing...

            if (_drawing)
            {
                Solid3d sol = null;
                try
                {
                    // If we have vertices that haven't yet been drawn...

                    if (_vertices.Count > 1 //&&
                        //_vertices.Count - 1 > _lastDrawnVertex
                      )
                    {
                        // ... generate a tube

                        if (GenerateTube(_profSide, _vertices, out sol))
                        {
                            // We now need to break the pipe...

                            // If it was created, add it to our list to draw

                            _created.Add(sol);
                            sol = null;

                            // Clear all but the last vertex to draw from
                            // next time

                            ClearAllButLast(_vertices, 1);
                        }
                    }
                }
                catch
                {
                    // If the tube generation failed...

                    if (sol != null)
                    {
                        sol.Dispose();
                    }

                    // Loop, creating the most recent successful tube we can

                    bool succeeded = false;
                    int n = 1;

                    do
                    {
                        try
                        {
                            // Generate the previous, working tube using all
                            // but the last points (if it fails, one more is
                            // excluded per iteration, until we get a working
                            // tube)

                            GenerateTube(
                              _profSide, GetAllButLast(_vertices, n++), out sol
                            );

                            _created.Add(sol);
                            sol = null;
                            succeeded = true;
                        }
                        catch { }
                    }
                    while (!succeeded && n < _vertices.Count);

                    if (succeeded)
                    {
                        ClearAllButLast(_vertices, n - 1);

                        if (_vertices.Count > 1)
                        {
                            try
                            {
                                // And generate a tube for the remaining vertices

                                GenerateTube(_profSide, _vertices, out sol);
                            }
                            catch
                            {
                                succeeded = false;
                            }
                        }
                    }

                    if (!succeeded && sol != null)
                    {
                        sol.Dispose();
                        sol = null;
                    }
                }

                // Draw our solid(s)

                draw.SubEntityTraits.Color = ColorIndex;

                foreach (DBObject obj in _created)
                {
                    Entity ent = obj as Entity;
                    if (ent != null)
                    {
                        try
                        {
                            ent.WorldDraw(draw);
                        }
                        catch
                        { }
                    }
                }

                if (sol != null)
                {
                    try
                    {
                        sol.WorldDraw(draw);
                    }
                    catch
                    { }
                }

                if (_vertices.Count > 0)
                {
                    Point3d lastPt = _vertices[_vertices.Count - 1];

                    // Create a cursor sphere

                    using (Solid3d cursor = new Solid3d())
                    {
                        try
                        {
                            cursor.CreateFrustum(_profSide, _profSide, _profSide, _profSide );

                            if (cursor != null)
                            {
                                cursor.TransformBy(
                                  Matrix3d.Displacement(lastPt - Point3d.Origin)
                                );

                                // Draw the cursor

                                draw.SubEntityTraits.Color = 5; //ColorIndex;

                                cursor.WorldDraw(draw);
                            }
                        }
                        catch { }
                    }
                }

                if (sol != null)
                {
                    sol.Dispose();
                }
            }

            draw.SubEntityTraits.Color = origCol;

            return true;
        }
Example #41
0
 protected virtual bool WorldDrawData(WorldDraw draw)
 {
   return false;
 }
Example #42
0
 protected override bool WorldDraw(WorldDraw draw)
 {
   return WorldDrawData(draw);
 }
    protected override bool WorldDrawData(WorldDraw draw)
    {
      if (!_capturing)
      {
        _drawing = true;

        // Draw each of our lines

        short oidx = draw.SubEntityTraits.Color;

        foreach (Line ln in _lines)
        {
          // Set the colour and lineweight in the subentity
          // traits based on the original line

          if (ln != null)
          {
            draw.SubEntityTraits.Color = (short)ln.ColorIndex;
            draw.SubEntityTraits.LineWeight = ln.LineWeight;

            ln.WorldDraw(draw);
          }
        }

        draw.SubEntityTraits.Color = oidx;

        _drawing = false;
      }

      return base.WorldDrawData(draw);
    }
Example #44
0
        private Boolean GetPlineOffset(double offset, Autodesk.AutoCAD.DatabaseServices.Polyline source, WorldDraw wd, Boolean IsOverrideLineType = false)
        {
            try
            {
                DBObjectCollection dbcol = source.GetOffsetCurves(offset);
                for (int i = 0; i < dbcol.Count; i++)
                {
                    Autodesk.AutoCAD.DatabaseServices.Polyline pln = dbcol[i] as Autodesk.AutoCAD.DatabaseServices.Polyline;

                    for (int j = 0; j < pln.NumberOfVertices; j++)
                    {
                        if (pln.GetSegmentType(j) == SegmentType.Line)
                        {
                            Autodesk.AutoCAD.Geometry.LineSegment3d line = pln.GetLineSegmentAt(j);
                            wd.Geometry.Polyline(new Autodesk.AutoCAD.Geometry.Point3dCollection() { line.StartPoint, line.EndPoint }, pln.Normal, new System.IntPtr(0));
                        }
                        else if (pln.GetSegmentType(j) == SegmentType.Arc)
                        {
                            Autodesk.AutoCAD.Geometry.CircularArc3d arc = pln.GetArcSegmentAt(j);
                            //Get center point
                            Double startPt = pln.GetDistAtPoint(pln.GetPoint3dAt(j));
                            Double endPt = pln.GetDistAtPoint(pln.GetPoint3dAt(j + 1));
                            Double centrPt = startPt + (endPt - startPt) / 2.0d;
                            Autodesk.AutoCAD.Geometry.Point3d pt = pln.GetPointAtDist(centrPt);
                            //Draw arc
                            wd.Geometry.CircularArc(arc.StartPoint, pt, arc.EndPoint, ArcType.ArcSimple);
                        }
                        else
                        {
                            //If other SegmentType - nothing to do
                        }
                    }
                    dbcol[i].Dispose();
                }

                return true;
            }
            catch (System.Exception ex)
            {
                AcadApp.AcaEd.WriteMessage("\nERROR: MarkingDarawOverrule.GetPlineOffset " + ex + "\n");
            }
            return false;
        }
    protected override bool WorldDrawData(WorldDraw draw)
    {
      if (!base.WorldDrawData(draw))
        return false;

      short origCol = draw.SubEntityTraits.Color;

      // If we're currently drawing...

      if (_drawing)
      {
        try
        {
          // Let's start by creating our spline path

          if ((_path == null && _vertices.Count > 1) ||
              (_path != null &&
                _vertices.Count > _path.NumFitPoints))
          {
            if (_path != null)
              _path.Dispose();

            _path = new Spline(_vertices, 0, 0.0);

            // And our sweep profile, if we don't have one

            if (_profile != null)
              _profile.Dispose();

            _profile =
              new Circle(
                _vertices[0],
                _vertices[1] - _vertices[0],
                _profRad
              );

            // And our sweep options, if we don't have one

            if (_sweepOpts == null)
            {
              SweepOptionsBuilder sob =
                new SweepOptionsBuilder();

              // Align the entity to sweep to the path

              sob.Align =
                SweepOptionsAlignOption.AlignSweepEntityToPath;

              // The base point is the start of the path

              sob.BasePoint = _path.StartPoint;

              // The profile will rotate to follow the path

              sob.Bank = true;
              _sweepOpts = sob.ToSweepOptions();
            }

            // Finally create a blank solid, if it's null

            if (_tube == null)
              _tube = new Solid3d();

            // And sweep our profile along our path

            _tube.CreateSweptSolid(_profile, _path, _sweepOpts);
          }
        }
        catch (Autodesk.AutoCAD.Runtime.Exception ex)
        {
          _sweepBroken = true;
          _tube.Dispose();
          _tube = null;
          _doc.Editor.WriteMessage(
            "\nException: {0}", ex.Message
          );
        }

        // Draw our path, if we have one

        if (_path != null)
        {
          draw.SubEntityTraits.Color = transPathColor;
          _path.WorldDraw(draw);
        }

        // And our solid

        if (_tube != null)
        {
          draw.SubEntityTraits.Color = transSolColor;
          _tube.WorldDraw(draw);
        }

        if (_vertices.Count > 0)
        {
          // Get the last point (at which our cursor should
          // be located, if it exists)

          Point3d lastPt = _vertices[_vertices.Count - 1];

          if (_cursor == null)
          {
            // Create a cursor sphere

            _cursor = new Solid3d();
            ((Solid3d)_cursor).CreateSphere(_profRad);
            _curPt = Point3d.Origin;
          }

          // Move it to the current point

          _cursor.TransformBy(
            Matrix3d.Displacement(lastPt - _curPt)
          );
          _curPt = lastPt;

          // Draw the cursor

          draw.SubEntityTraits.Color =
            (_sweepBroken ? transPathColor : transSolColor);

          _cursor.WorldDraw(draw);
        }
      }

      draw.SubEntityTraits.Color = origCol;

      return true;
    }
Example #46
0
 public virtual void SaveAs(WorldDraw mode, SaveType st)
 {
     createInstance();
     BaseEntity.SaveAs(mode,st);
     tr.Dispose();
 }
 protected override bool WorldDraw(WorldDraw draw)
 {
     draw.Geometry.Draw(m_PolyLine2);
     return true;
 }
Example #48
0
        protected override bool WorldDrawData(WorldDraw draw)
        {
            if (!base.WorldDrawData(draw))
                return false;

            short origCol = draw.SubEntityTraits.Color;

            if (_resizing)
            {
                //  using (Solid3d cube = new Solid3d())
                //{
                try
                {


                    //cube.CreateBox(0.5, 0.5, 0.5);
                    _firstdraw = _firstdraw + 1;


                    if (cube != null)
                    {
                        //int i = 20000;
                        bool chk = false;
                        //cube.TransformBy(
                        //  Matrix3d.Displacement(
                        //     _resizeLocation - Point3d.Origin
                        //  )
                        //  );

                        // Draw the cursor

                        draw.SubEntityTraits.Color = ColorIndex;
                        cube.WorldDraw(draw);
                        vRot = leftHand.GetVectorTo(rightHand); ;// new Point3d(-3, 4, 0).GetVectorTo(new Point3d(-3, -4, 0)); //rightHand.GetVectorTo(leftHand);

                        System.Threading.Thread.Sleep((int)System.TimeSpan.FromSeconds(0.2).TotalMilliseconds);

                        //chk = (leftHand.Z < leftHip.Z);

                        //while (true)
                        //{
                        //  if (chk)
                        //    break;
                        //Point3d pt1 = rightHand - leftHand;
                        cube.TransformBy(Matrix3d.Rotation(0.1, vRot, Point3d.Origin));
                        //}

                        /*if (chk)
                        {
                            cube.TransformBy(Matrix3d.Rotation(1.046, vRot, leftHand));
                            System.Threading.Thread.Sleep((int)System.TimeSpan.FromSeconds(2).TotalMilliseconds);
                        }  */

                        //cube.TransformBy(Matrix3d.Rotation(0.5236, vRot, leftHand));
                    }

                    // if(_changeaxis)

                    //            vRot = rightHand.GetVectorTo(leftHand);
                    //          cube.TransformBy(Matrix3d.Rotation(0.5236,vRot,leftHand));

                    //   if (leftHand.Z > leftHip.Z)
                    //     _isRotate = false;

                }
                catch (System.Exception ex)
                {

                    _doc.Editor.WriteMessage(
                      "\nException: {0} - {1}", ex.Message, ex.InnerException
                    );
                }
                finally
                {
                    draw.SubEntityTraits.Color = origCol;
                }
                // }
                return true;
            }

            if (_isRotate)
            {
                cube.WorldDraw(draw);
            }

            // If we're currently drawing...

            if (_drawing)
            {
                Solid3d sol = null;
                try
                {
                    // If we have vertices that haven't yet been drawn...

                    if (_vertices.Count > 1 //&&
                        //_vertices.Count - 1 > _lastDrawnVertex
                      )
                    {
                        // ... generate a tube

                        if (GenerateTube(_profSide, _vertices, out sol))
                        {
                            // We now need to break the pipe...

                            // If it was created, add it to our list to draw

                            _created.Add(sol);
                            sol = null;

                            // Clear all but the last vertex to draw from
                            // next time

                            ClearAllButLast(_vertices, 1);
                        }
                    }
                }
                catch
                {
                    // If the tube generation failed...

                    if (sol != null)
                    {
                        sol.Dispose();
                    }

                    // Loop, creating the most recent successful tube we can

                    bool succeeded = false;
                    int n = 1;

                    do
                    {
                        try
                        {
                            // Generate the previous, working tube using all
                            // but the last points (if it fails, one more is
                            // excluded per iteration, until we get a working
                            // tube)

                            GenerateTube(
                              _profSide, GetAllButLast(_vertices, n++), out sol
                            );

                            _created.Add(sol);
                            sol = null;
                            succeeded = true;
                        }
                        catch { }
                    }
                    while (!succeeded && n < _vertices.Count);

                    if (succeeded)
                    {
                        ClearAllButLast(_vertices, n - 1);

                        if (_vertices.Count > 1)
                        {
                            try
                            {
                                // And generate a tube for the remaining vertices

                                GenerateTube(_profSide, _vertices, out sol);
                            }
                            catch
                            {
                                succeeded = false;
                            }
                        }
                    }

                    if (!succeeded && sol != null)
                    {
                        sol.Dispose();
                        sol = null;
                    }
                }

                // Draw our solid(s)

                draw.SubEntityTraits.Color = ColorIndex;

                foreach (DBObject obj in _created)
                {
                    Entity ent = obj as Entity;
                    if (ent != null)
                    {
                        try
                        {
                            ent.WorldDraw(draw);
                        }
                        catch
                        { }
                    }
                }

                if (sol != null)
                {
                    try
                    {
                        sol.WorldDraw(draw);
                    }
                    catch
                    { }
                }

                if (_vertices.Count > 0)
                {
                    Point3d lastPt = _vertices[_vertices.Count - 1];

                    // Create a cursor sphere

                    using (Solid3d cursor = new Solid3d())
                    {
                        try
                        {
                            cursor.CreateBox(_profSide, _profSide, _profSide);

                            if (cursor != null)
                            {
                                cursor.TransformBy(
                                  Matrix3d.Displacement(lastPt - Point3d.Origin)
                                );

                                // Draw the cursor

                                draw.SubEntityTraits.Color = 4; // ColorIndex;

                                cursor.WorldDraw(draw);
                            }
                        }
                        catch { }
                    }
                }

                if (sol != null)
                {
                    sol.Dispose();
                }
            }

            draw.SubEntityTraits.Color = origCol;

            return true;
        }
Example #49
0
        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            if (LineTypesOfDoubleLines == null || LineTypesOfDoubleLines.Count == 0)
            {
                AcadApp.AcaEd.WriteMessage("\nERROR: MarkingDarawOverrule Filter do not work!\n");
                return base.WorldDraw(drawable, wd);
            }

            try
            {
                // Cast Drawable to Polyline so we can access its methods and
                // properties
                Autodesk.AutoCAD.DatabaseServices.Polyline pln = drawable as Autodesk.AutoCAD.DatabaseServices.Polyline;

                Double scaleFactor = pln.LinetypeScale;

                foreach (var lineType in LineTypesOfDoubleLines)
                {
                    if (pln.Linetype == lineType.LineTypeName)
                    {
                        if (lineType.EntityType == RazmType.typeOfEntity.DoubleLineCenter)
                        {
                            GetPlineOffset(-Offset/2.0d * scaleFactor, pln, wd);
                            GetPlineOffset(Offset / 2.0d * scaleFactor, pln, wd);
                        }
                        else if (lineType.EntityType == RazmType.typeOfEntity.DoubleLineSide)
                        {
                            GetPlineOffset(-Offset * scaleFactor, pln, wd);
                            ObjectId curLT = wd.SubEntityTraits.LineType;
                            using (var trans = AcadApp.StartTransaction())
                            {
                                LinetypeTable lt = trans.GetObject(AcadApp.AcaDb.LinetypeTableId, OpenMode.ForRead) as LinetypeTable;
                                wd.SubEntityTraits.LineType = lt["Continuous"];
                            }
                            GetPlineOffset(0.0d * scaleFactor, pln, wd, true);
                        }
                        return true;
                    }
                }
                //If collection don't have item with current item's layer name
                //Draw as is, without overrule
                return base.WorldDraw(drawable, wd);
            }
            catch (System.Exception ex)
            {
                AcadApp.AcaEd.WriteMessage("\nERROR: MarkingDarawOverrule.WorldDraw " + ex + "\n");
            }
                return true;
        }