Пример #1
0
 internal static Matrix3d Dcs2Wcs(AbstractViewTableRecord v)
 {
     return
         (Matrix3d.Rotation(-v.ViewTwist, v.ViewDirection, v.Target) *
          Matrix3d.Displacement(v.Target - Point3d.Origin) *
          Matrix3d.PlaneToWorld(v.ViewDirection));
 }
 /// <summary>
 /// Returns the transformation matrix from the ViewportTableRecord DCS to WCS.
 /// </summary>
 /// <remarks>Borrowed from http://www.acadnetwork.com/index.php?topic=232.msg406#msg406</remarks>
 /// <param name="view">The ViewportTableRecord instance this method applies to.</param>
 /// <returns>The DCS to WCS transformation matrix.</returns>
 public static Matrix3d EyeToWorld(this AbstractViewTableRecord view)
 {
     return
         (Matrix3d.Rotation(-view.ViewTwist, view.ViewDirection, view.Target) *
          Matrix3d.Displacement(view.Target - Point3d.Origin) *
          Matrix3d.PlaneToWorld(view.ViewDirection));
 }
Пример #3
0
        /// <summary>
        /// 获取WCS到DCS的转换矩阵
        /// </summary>
        /// <param name="vtr">视图(ViewTableRecord)或视口(ViewportTableRecord)</param>
        /// <returns></returns>
        public static Matrix3d Wcs2Dcs(this AbstractViewTableRecord vtr)
        {
            //获取视图或视口平面到世界坐标系转换矩阵
            Matrix3d mat = Matrix3d.PlaneToWorld(vtr.ViewDirection);

            //将平移过的视口或视图回复到原始状态所需要的矩阵
            mat = Matrix3d.Displacement(vtr.Target - Point3d.Origin) * mat;
            //将旋转过的视口或视图回复到原始状态所需要的矩阵
            mat = Matrix3d.Rotation(-vtr.ViewTwist, vtr.ViewDirection, vtr.Target) * mat;
            return(mat.Inverse());//将矩阵进行转置
        }
Пример #4
0
        Stream(ArrayList data, AbstractViewTableRecord rec)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(AbstractViewTableRecord)));

            data.Add(new Snoop.Data.Point2d("Center point", rec.CenterPoint));
            data.Add(new Snoop.Data.Distance("Width", rec.Width));
            data.Add(new Snoop.Data.Distance("Height", rec.Height));
            data.Add(new Snoop.Data.Point3d("Target", rec.Target));
            data.Add(new Snoop.Data.Vector3d("View direction", rec.ViewDirection));
            data.Add(new Snoop.Data.Distance("View twist", rec.ViewTwist));
            data.Add(new Snoop.Data.Double("Lens length", rec.LensLength));
            data.Add(new Snoop.Data.Bool("Front clip at eye", rec.FrontClipAtEye));
            data.Add(new Snoop.Data.Distance("Front clip distance", rec.FrontClipDistance));
            data.Add(new Snoop.Data.Distance("Back clip distance", rec.BackClipDistance));
            data.Add(new Snoop.Data.Bool("Front clip enabled", rec.FrontClipEnabled));
            data.Add(new Snoop.Data.Bool("Back clip enabled", rec.BackClipEnabled));
            data.Add(new Snoop.Data.Distance("Elevation", rec.Elevation));
            data.Add(new Snoop.Data.Bool("Perspective enabled", rec.PerspectiveEnabled));
            // data.Add(new Snoop.Data.String("Render mode", rec.RenderMode.ToString()));
            data.Add(new Snoop.Data.Object("UCS", rec.Ucs));
            data.Add(new Snoop.Data.ObjectId("UCS name", rec.UcsName));
            data.Add(new Snoop.Data.String("UCS orthographic", rec.UcsOrthographic.ToString()));
            data.Add(new Snoop.Data.String("View orthographic", rec.ViewOrthographic.ToString()));

            data.Add(new Snoop.Data.Object("Ambient light color", rec.AmbientLightColor));
            data.Add(new Snoop.Data.ObjectId("Background ID", rec.Background));
            data.Add(new Snoop.Data.Double("Brightness", rec.Brightness));
            data.Add(new Snoop.Data.Double("Contrast", rec.Contrast));
            data.Add(new Snoop.Data.Bool("Default lighting on", rec.DefaultLightingOn));
            data.Add(new Snoop.Data.String("Default lighting type", rec.DefaultLightingType.ToString()));
            data.Add(new Snoop.Data.ObjectId("Sun ID", rec.SunId));
            data.Add(new Snoop.Data.ObjectId("Visual style ID", rec.VisualStyleId));

            ViewportTableRecord viewportRec = rec as ViewportTableRecord;

            if (viewportRec != null)
            {
                Stream(data, viewportRec);
                return;
            }

            ViewTableRecord viewRec = rec as ViewTableRecord;

            if (viewRec != null)
            {
                Stream(data, viewRec);
                return;
            }
        }
Пример #5
0
        public static void SetView(Point3d ptMin, Point3d ptMax, double scale)
        {
            Editor          editor      = Application.DocumentManager.MdiActiveDocument.Editor;
            ViewTableRecord currentView = editor.GetCurrentView();

            currentView.Height = Math.Abs(ptMax.Y - ptMin.Y) * scale;
            currentView.Width  = Math.Abs(ptMax.X - ptMin.X) * scale;
            AbstractViewTableRecord abstractViewTableRecord = currentView;
            Point2d centerPoint;

            centerPoint..ctor((ptMax.X + ptMin.X) / 2.0, (ptMax.Y + ptMin.Y) / 2.0);
            abstractViewTableRecord.CenterPoint = centerPoint;
            editor.SetCurrentView(currentView);
            Application.UpdateScreen();
        }
Пример #6
0
        internal static Extents3d ScreenExtents(
            AbstractViewTableRecord vtr
            )
        {
            // Get the centre of the screen in WCS and use it
            // with the diagonal vector to add the corners to the
            // extents object

            var ext = new Extents3d();
            var vec = new Vector3d(0.5 * vtr.Width, 0.5 * vtr.Height, 0);
            var ctr =
                new Point3d(vtr.CenterPoint.X, vtr.CenterPoint.Y, 0);
            var dcs = Utils.Dcs2Wcs(vtr);

            ext.AddPoint((ctr + vec).TransformBy(dcs));
            ext.AddPoint((ctr - vec).TransformBy(dcs));

            return(ext);
        }
 /// <summary>
 /// Returns the transformation matrix from the ViewportTableRecord WCS to DCS.
 /// </summary>
 /// <remarks>Borrowed from http://www.acadnetwork.com/index.php?topic=232.msg406#msg406</remarks>
 /// <param name="view">The ViewportTableRecord instance this method applies to.</param>
 /// <returns>The WCS to DCS transformation matrix.</returns>
 public static Matrix3d WorldToEye(this AbstractViewTableRecord view)
 {
     return(view.EyeToWorld().Inverse());
 }
Пример #8
0
        Stream(ArrayList data, AcDb.SymbolTableRecord tblRec)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(AcDb.SymbolTableRecord)));

            data.Add(new Snoop.Data.String("Name", tblRec.Name));
            data.Add(new Snoop.Data.Bool("Is dependent", tblRec.IsDependent));
            data.Add(new Snoop.Data.Bool("Is resolved", tblRec.IsResolved));

            // branch to all known major sub-classes
            AbstractViewTableRecord viewRec = tblRec as AbstractViewTableRecord;

            if (viewRec != null)
            {
                Stream(data, viewRec);
                return;
            }

            BlockTableRecord blkRec = tblRec as BlockTableRecord;

            if (blkRec != null)
            {
                Stream(data, blkRec);
                return;
            }

            DimStyleTableRecord dimRec = tblRec as DimStyleTableRecord;

            if (dimRec != null)
            {
                Stream(data, dimRec);
                return;
            }

            LayerTableRecord layRec = tblRec as LayerTableRecord;

            if (layRec != null)
            {
                Stream(data, layRec);
                return;
            }

            LinetypeTableRecord ltypeRec = tblRec as LinetypeTableRecord;

            if (ltypeRec != null)
            {
                Stream(data, ltypeRec);
                return;
            }

            TextStyleTableRecord textRec = tblRec as TextStyleTableRecord;

            if (textRec != null)
            {
                Stream(data, textRec);
                return;
            }

            UcsTableRecord ucsRec = tblRec as UcsTableRecord;

            if (ucsRec != null)
            {
                Stream(data, ucsRec);
                return;
            }
        }