public static Matrix4D GetTransform( IViewDescription view, Size2D targetSize, bool invertY) { return(ViewUtil.GetTransform(view, new Rectangle2D(0.0, 0.0, targetSize.X, targetSize.Y), invertY)); }
public static Bitmap CreateViewportConfigurationBitmap( DxfModel model, string vportName, GraphicsConfig graphicsConfig, SmoothingMode smoothingMode, int width, int height) { Bitmap bitmap = new Bitmap(width, height); Rectangle2D targetRectangle = new Rectangle2D(0.0, 0.0, (double)width, (double)height); Rectangle drawingBounds = new Rectangle(0, 0, width, height); using (Graphics graphics = Graphics.FromImage((Image)bitmap)) { graphics.SmoothingMode = smoothingMode; graphics.Clear((System.Drawing.Color)graphicsConfig.BackColor); GDIGraphics3D gdiGraphics3D = new GDIGraphics3D(graphicsConfig); gdiGraphics3D.CreateDrawables(model); foreach (DxfVPort vport in (DxfHandledObjectCollection <DxfVPort>)model.VPorts) { if (vportName.Equals(vport.Name, StringComparison.InvariantCultureIgnoreCase)) { IViewDescription viewDescription = vport.ViewDescription; Matrix4D transform = ViewUtil.GetTransform(viewDescription, targetRectangle, true); float num = 1f - (float)(viewDescription.ViewportCenter.Y + viewDescription.ViewportHeight / 2.0); RectangleF rect = new RectangleF((float)width * (float)(viewDescription.ViewportCenter.X - viewDescription.ViewportWidth / 2.0), (float)height * num, (float)width * (float)viewDescription.ViewportWidth, (float)height * (float)viewDescription.ViewportHeight); graphics.Clip = new System.Drawing.Region(rect); gdiGraphics3D.Draw(graphics, drawingBounds, transform); } } } return(bitmap); }
private static Bounds2D smethod_7(IViewDescription view) { Vector2D vector2D = 0.5 * new Vector2D(view.ViewportWidth, view.ViewportHeight); WW.Math.Point2D viewportCenter = (WW.Math.Point2D)view.ViewportCenter; return(new Bounds2D(viewportCenter - vector2D, viewportCenter + vector2D)); }
public static Matrix4D GetTransform( IViewDescription view, double targetWidth, double targetHeight, bool invertY) { return(ViewUtil.GetTransform(view, new Rectangle2D(0.0, 0.0, targetWidth, targetHeight), invertY)); }
public static Matrix4D GetBasicModelToViewportTransform(IViewDescription view) { Matrix4D matrix4D1 = view.IsTargetPaper ? Transformation4D.Translation(-view.ViewCenter.X, -view.ViewCenter.Y, 0.0) : Transformation4D.Translation(-view.ViewCenter.X, -view.ViewCenter.Y, -view.ViewDirection.GetLength()) * Transformation4D.RotateZ(view.ViewTwistAngle) * DxfUtil.GetToWCSTransform(view.ViewDirection).GetTranspose() * Transformation4D.Translation(-(Vector3D)view.ViewTarget); if ((view.ViewModeFlags & ViewportStatusFlags.PerspectiveMode) != ViewportStatusFlags.None) { double num1 = 1.0 / System.Math.Tan(0.5 * (2.0 * System.Math.Atan(18.0 / view.FocalLength))); double num2 = 0.5 * view.ViewWidth; Matrix4D matrix4D2 = new Matrix4D(num2, 0.0, 0.0, 0.0, 0.0, num2, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0); matrix4D1 = Transformation4D.Scaling(num1, num1, 1.0) * matrix4D2 * matrix4D1; } return(matrix4D1); }
public static Matrix4D GetTransform( IViewDescription view, Rectangle2D targetRectangle, bool invertY) { Matrix4D viewportTransform = ViewUtil.GetBasicModelToViewportTransform(view); double num = System.Math.Min(targetRectangle.Width * view.ViewportWidth / view.ViewWidth, targetRectangle.Height * view.ViewportHeight / view.ViewHeight); double x = targetRectangle.Center.X + (view.ViewportCenter.X - 0.5) * targetRectangle.Width; double y1 = targetRectangle.Center.Y; double y2 = !invertY ? y1 + (view.ViewportCenter.Y - 0.5) * targetRectangle.Height : y1 - (view.ViewportCenter.Y - 0.5) * targetRectangle.Height; return(Transformation4D.Translation(x, y2, 0.0) * Transformation4D.Scaling(num, invertY ? -num : num, num) * viewportTransform); }
public BasicLayoutRenderInfo(IViewDescription viewDescription) { double val1 = viewDescription.ViewportWidth / viewDescription.ViewWidth; double val2 = viewDescription.ViewportHeight / viewDescription.ViewHeight; if (DxfUtil.IsSaneNotZero(val1) && DxfUtil.IsSaneNotZero(val2)) { this.ModelToLayoutScaling = System.Math.Min(val1, val2); Vector2D vector2D = val1 > val2 ? new Vector2D(0.5 * val2 / val1 * viewDescription.ViewportWidth, 0.5 * viewDescription.ViewportHeight) : new Vector2D(0.5 * viewDescription.ViewportWidth, 0.5 * val1 / val2 * viewDescription.ViewportHeight); WW.Math.Point2D viewportCenter = (WW.Math.Point2D)viewDescription.ViewportCenter; this.LayoutViewport = new Bounds2D(viewportCenter - vector2D, viewportCenter + vector2D); this.ModelToLayoutTransform = Transformation4D.Translation((WW.Math.Vector3D)viewDescription.ViewportCenter) * Transformation4D.Scaling(this.ModelToLayoutScaling) * ViewUtil.GetBasicModelToViewportTransform(viewDescription) * Transformation4D.Translation(-(WW.Math.Vector3D)viewDescription.ViewportCenter); } else { this.LayoutViewport = new Bounds2D(); this.ModelToLayoutTransform = Matrix4D.Identity; this.ModelToLayoutScaling = 0.0; } }