Esempio n. 1
0
        private static Image <Bgra32> RenderToBitmap(DxfModel model)
        {
            var graphicsConfig = (GraphicsConfig)GraphicsConfig.AcadLikeWithWhiteBackground.Clone();

            BoundsCalculator boundsCalculator = new BoundsCalculator();

            boundsCalculator.GetBounds(model);
            Bounds3D bounds = boundsCalculator.Bounds;

            int      size      = 2000;
            Matrix4D transform = DxfUtil.GetScaleTransform(
                bounds.Min,
                bounds.Max,
                bounds.Center,
                new Point3D(0, size, 0),
                new Point3D(size, 0, 0),
                new Point3D(0.5d * size, 0.5d * size, 0)
                );

            Memory <Bgra32> memory = new Memory <Bgra32>();

            Image.WrapMemory <Bgra32>(memory, 10, 10);
            Image <Bgra32> bitmap = ImageExporter.CreateBitmap <Bgra32>(
                model, transform,
                graphicsConfig,
                //new GraphicsOptions(false),
                new Size(size, size));

            return(bitmap);
        }
        private async void openAutoCadFileMenuItem_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker openPicker = new FileOpenPicker();

            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
            openPicker.FileTypeFilter.Add(".dwg");
            openPicker.FileTypeFilter.Add(".dxf");

            StorageFile file = await openPicker.PickSingleFileAsync();

            if (file != null)
            {
                Stream inStream = await file.OpenStreamForReadAsync();

                model = DwgReader.Read(inStream);

                var graphicsConfig = GraphicsConfig.AcadLikeWithBlackBackground;
                cadGraphics = new NetCoreGraphics3D(graphicsConfig, ImageRenderOptions.Default.GraphicsOptions);
                cadGraphics.CreateDrawables(model);
                bounds = new Bounds3D();
                cadGraphics.BoundingBox(bounds);

                resizeEventDelayer.StopStart();
            }
        }
Esempio n. 3
0
 public ViewControl() {
     InitializeComponent();
     SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     SetStyle(ControlStyles.DoubleBuffer, true);
     SetStyle(ControlStyles.UserPaint, true);
     {
         GraphicsConfig graphicsConfig = new GraphicsConfig(BackColor);
         fishNetGraphics3D = new GDIGraphics3D(graphicsConfig);
     }
     {
         GraphicsConfig graphicsConfig = new GraphicsConfig(BackColor);
         graphicsConfig.FixedForegroundColor = System.Drawing.Color.Red;
         dynamicGdiGraphics3D = new GDIGraphics3D(graphicsConfig);
     }
     {
         GraphicsConfig graphicsConfig = new GraphicsConfig(BackColor);
         axisGraphics3D = new GDIGraphics3D(graphicsConfig);
     }
     {
         GraphicsConfig graphicsConfig = new GraphicsConfig(BackColor);
         polyGdiGraphics3D = new GDIGraphics3D(graphicsConfig);
     }
     this.KeyUp += new KeyEventHandler(ViewControl_KeyUp);
     modelPoly = new DxfModel();
     bounds = new Bounds3D();
 }
Esempio n. 4
0
 public static Matrix4D GetBoundsToScreenTransform(
     Bounds3D bounds,
     int width,
     int height)
 {
     return(Transformation4D.GetBoundsToScreenTransform(bounds, width, height, 0));
 }
Esempio n. 5
0
        public static Bitmap CreateAutoSizedBitmap(
            DxfModel model,
            GDIGraphics3D cadGraphics,
            SmoothingMode smoothingMode,
            Matrix4D transform,
            System.Drawing.Color backColor,
            Size maxSize)
        {
            cadGraphics.CreateDrawables(model);
            Bounds3D bounds = new Bounds3D();

            cadGraphics.BoundingBox(bounds, transform);
            int      num1       = maxSize.Width - 4;
            int      num2       = maxSize.Height - 4;
            Matrix4D transform1 = DxfUtil.GetScaleTransform(bounds.Corner1, bounds.Corner2, new WW.Math.Point3D(bounds.Corner1.X, bounds.Corner2.Y, 0.0), new WW.Math.Point3D(0.0, (double)num2, 0.0), new WW.Math.Point3D((double)num1, 0.0, 0.0), new WW.Math.Point3D(2.0, 2.0, 0.0)) * transform;

            bounds.Reset();
            cadGraphics.BoundingBox(bounds, transform1);
            if (!bounds.Initialized)
            {
                return(ImageExporter.CreateEmptyBitmap(backColor, maxSize.Width, maxSize.Height));
            }
            WW.Math.Vector3D delta = bounds.Delta;
            int width  = System.Math.Min(maxSize.Width, (int)System.Math.Ceiling(delta.X) + 4);
            int height = System.Math.Min(maxSize.Height, (int)System.Math.Ceiling(delta.Y) + 4);

            return(ImageExporter.CreateBitmap(cadGraphics, smoothingMode, transform1, backColor, width, height));
        }
Esempio n. 6
0
        public static Bitmap CreateAutoSizedBitmap(
            DxfModel model,
            DxfLayout layout,
            ICollection <DxfViewport> viewports,
            Matrix4D transform,
            GraphicsConfig graphicsConfig,
            SmoothingMode smoothingMode,
            System.Drawing.Color backColor,
            Size maxSize)
        {
            BoundsCalculator boundsCalculator = new BoundsCalculator(graphicsConfig);

            boundsCalculator.GetBounds(model, layout, viewports, transform);
            Bounds3D bounds = boundsCalculator.Bounds;

            if (!bounds.Initialized)
            {
                return(ImageExporter.CreateEmptyBitmap(backColor, maxSize.Width, maxSize.Height));
            }
            int      num1           = maxSize.Width - 4;
            int      num2           = maxSize.Height - 4;
            Matrix4D scaleTransform = DxfUtil.GetScaleTransform(bounds.Corner1, bounds.Corner2, new WW.Math.Point3D(bounds.Corner1.X, bounds.Corner2.Y, 0.0), new WW.Math.Point3D(0.0, (double)num2, 0.0), new WW.Math.Point3D((double)num1, 0.0, 0.0), new WW.Math.Point3D(2.0, 2.0, 0.0));
            Matrix4D to2DTransform  = scaleTransform * transform;

            WW.Math.Vector3D vector3D = scaleTransform.Transform(bounds.Corner2) - scaleTransform.Transform(bounds.Corner1);
            int width  = System.Math.Min(maxSize.Width, (int)System.Math.Ceiling(System.Math.Abs(vector3D.X)) + 4);
            int height = System.Math.Min(maxSize.Height, (int)System.Math.Ceiling(System.Math.Abs(vector3D.Y)) + 4);

            return(ImageExporter.CreateBitmap(model, layout, viewports, graphicsConfig, smoothingMode, backColor, to2DTransform, width, height));
        }
Esempio n. 7
0
 public void BoundingBox(Bounds3D bounds, Matrix4D transform)
 {
     for (int index = 0; index < this.interface23_0.Length; ++index)
     {
         this.interface23_0[index].BoundingBox(bounds, transform);
     }
 }
Esempio n. 8
0
        public ViewControl()
        {
            InitializeComponent();
            //控制控件闪烁
            SetStyle(ControlStyles.AllPaintingInWmPaint, true); //禁止擦除背景
            SetStyle(ControlStyles.DoubleBuffer, true);         //双缓冲
            SetStyle(ControlStyles.UserPaint, true);            //自行绘制图片
            GraphicsConfig graphicsConfig = new GraphicsConfig();

            graphicsConfig.BackColor = BackColor;
            graphicsConfig.CorrectColorForBackgroundColor = true;
            gdiGraphics3D = new GDIGraphics3D(graphicsConfig);
            gdiGraphics3D.EnableDrawablesUpdate();
            graphicsCache        = new WireframeGraphicsCache(false, true);
            graphicsCache.Config = graphicsConfig;
            graphicsHelper       = new GraphicsHelper(System.Drawing.Color.Blue);
            bounds = new Bounds3D();

            transformationProvider = new SimpleTransformationProvider3D();
            transformationProvider.TransformsChanged += new EventHandler(transformationProvider_TransformsChanged);
            panInteractor              = new SimplePanInteractor(transformationProvider);
            rectZoomInteractor         = new SimpleRectZoomInteractor(transformationProvider);
            zoomWheelInteractor        = new SimpleZoomWheelInteractor(transformationProvider);
            rectZoomInteractorDrawable = new SimpleRectZoomInteractor.WinFormsDrawable(rectZoomInteractor);
        }
Esempio n. 9
0
        public void openFile(string filename)
        {
            modelTransform      = Matrix4D.Identity;
            from2DTransform     = gdiGraphics3D.To2DTransform.GetInverse();
            translation         = Vector3D.Zero;
            mouseDown           = false;
            shiftPressed        = false;
            lastMouseLocation.X = (int)0.5d * ClientSize.Width;
            lastMouseLocation.Y = (int)0.5d * ClientSize.Height;
            mouseClickLocation  = lastMouseLocation;
            scaleFactor         = 1d;

            if (filename == "" || filename == null)
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "AutoCad files (*.dwg, *.dxf)|*.dxf;*.dwg";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    filename = dialog.FileName;
                }
            }
            if (!string.IsNullOrEmpty(filename))
            {
                // To prevent flicker.
                SetStyle(ControlStyles.AllPaintingInWmPaint, true);
                SetStyle(ControlStyles.DoubleBuffer, true);
                SetStyle(ControlStyles.UserPaint, true);

                ImageControl.BackColor = System.Drawing.Color.Black;

                try
                {
                    string extension = Path.GetExtension(filename);
                    if (string.Compare(extension, ".dwg", true) == 0)
                    {
                        model = DwgReader.Read(filename);
                    }
                    else
                    {
                        model = DxfReader.Read(filename);
                    }

                    this.Text = filename;

                    gdiGraphics3D.CreateDrawables(model);



                    bounds = new Bounds3D();
                    gdiGraphics3D.BoundingBox(bounds, modelTransform);
                    CalculateTo2DTransform();
                    ImageControl.Invalidate();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 10
0
 public InsideTestResult TryIsInside(Bounds3D box)
 {
     if (box.Min.X > this.corner2.X || box.Max.X < this.corner1.X || (box.Min.Y > this.corner2.Y || box.Max.Y < this.corner1.Y))
     {
         return(InsideTestResult.Outside);
     }
     return(box.Min.X >= this.corner1.X && box.Max.X <= this.corner2.X && (box.Min.Y >= this.corner1.Y && box.Max.Y <= this.corner2.Y) ? InsideTestResult.Inside : InsideTestResult.BothSides);
 }
Esempio n. 11
0
 public int method_10(Bounds3D bounds, Matrix4D transformation)
 {
     foreach (Point3D point in this.list_0)
     {
         bounds.Update(transformation.Transform(point));
     }
     return(this.dictionary_0.Count + this.list_1.Count);
 }
Esempio n. 12
0
        public void BoundingBox(Bounds3D bounds, Matrix4D transform)
        {
            Vector4D p1 = transform.Transform(this.vector4D_0);

            bounds.Update(p1);
            Vector4D p2 = transform.Transform(this.vector4D_1);

            bounds.Update(p2);
        }
Esempio n. 13
0
        public Bounds3D GetBounds()
        {
            Bounds3D bounds3D = new Bounds3D();

            foreach (Point3D p in (List <Point3D>) this)
            {
                bounds3D.Update(p);
            }
            return(bounds3D);
        }
Esempio n. 14
0
 public void UpdateBounds(Bounds3D bounds, Matrix4D modelTransform)
 {
     foreach (Polyline4D polyline4D in (IEnumerable <Polyline4D>) this.ilist_0)
     {
         for (int index = polyline4D.Count - 1; index >= 0; --index)
         {
             bounds.Update(modelTransform.Transform(polyline4D[index]));
         }
     }
 }
Esempio n. 15
0
        public void BoundingBox(Bounds3D bounds, Matrix4D transform)
        {
            Vector4D vector4D1 = this.vector4D_1 * this.size2D_0.X;
            Vector4D vector4D2 = this.vector4D_2 * this.size2D_0.Y;

            bounds.Update(transform.TransformTo3D(this.vector4D_0));
            bounds.Update(transform.TransformTo3D(this.vector4D_0 + vector4D1));
            bounds.Update(transform.TransformTo3D(this.vector4D_0 + vector4D2));
            bounds.Update(transform.TransformTo3D(this.vector4D_0 + vector4D1 + vector4D2));
        }
Esempio n. 16
0
        public void BoundingBox(Bounds3D bounds, Matrix4D transform)
        {
            Matrix4D matrix4D = transform * this.class908_0.Transformation;
            Bounds2D bounds1  = this.class908_0.Text.Font.Metrics.GetBounds(this.class908_0.Text.Text, Enum24.flag_0);

            bounds.Update(matrix4D.TransformTo4D(bounds1.Corner1));
            bounds.Update(matrix4D.TransformTo4D(bounds1.Corner2));
            bounds.Update(matrix4D.TransformTo4D(new WW.Math.Point2D(bounds1.Corner2.X, bounds1.Corner1.Y)));
            bounds.Update(matrix4D.TransformTo4D(new WW.Math.Point2D(bounds1.Corner1.X, bounds1.Corner2.Y)));
        }
Esempio n. 17
0
 // BVHBuildNode Public Methods
 public void InitLeaf(int first, int n, Bounds3D b)
 {
     firstPrimOffset = first;
     nPrimitives     = n;
     bounds          = b;
     children[0]     = children[1] = null;
     //++leafNodes;
     //++totalLeafNodes;
     //totalPrimitives += n;
 }
Esempio n. 18
0
 public void BoundingBox(Bounds3D bounds, Matrix4D transform)
 {
     if (this.polyline4D_1 == null)
     {
         return;
     }
     foreach (Vector4D vector in (List <Vector4D>) this.polyline4D_1)
     {
         bounds.Update(transform.Transform(vector));
     }
 }
Esempio n. 19
0
 public void BoundingBox(Bounds3D bounds, Matrix4D transform)
 {
     foreach (Interface12 nterface12 in this.linkedList_0)
     {
         nterface12.BoundingBox(bounds, transform);
     }
     foreach (Interface12 nterface12 in this.linkedList_1)
     {
         nterface12.BoundingBox(bounds, transform);
     }
 }
Esempio n. 20
0
 public void BoundingBox(Bounds3D bounds, Matrix4D transform)
 {
     if (this.linkedList_0 == null)
     {
         return;
     }
     for (LinkedListNode <Interface12> linkedListNode = this.linkedList_0.First; linkedListNode != null; linkedListNode = linkedListNode.Next)
     {
         linkedListNode.Value.BoundingBox(bounds, transform);
     }
 }
Esempio n. 21
0
 public static Matrix4D GetBoundsToScreenTransform(
     Bounds3D bounds,
     int width,
     int height,
     int margin)
 {
     if (!bounds.Initialized)
     {
         return(Matrix4D.Identity);
     }
     return(Transformation4D.GetBoundsToScreenTransform(bounds.Min, bounds.Max, width, height, margin));
 }
Esempio n. 22
0
        public void UpdateBounds(Bounds3D bounds, Matrix4D modelTransform)
        {
            if (this.point2D_0 == null)
            {
                return;
            }
            Matrix4D matrix4D = modelTransform * this.matrix4D_0;

            foreach (Point2D point in this.point2D_0)
            {
                bounds.Update(matrix4D.TransformTo4D(point));
            }
        }
Esempio n. 23
0
        // todo: need to figure out better naming
        // this is the replacement for operator()(bounds3f) in the c++ code
        public Bounds3D AtBounds(Bounds3D b)
        {
            Bounds3D ret = new Bounds3D(AtPoint(new Point3D(b.MinPoint.X, b.MinPoint.Y, b.MinPoint.Z)));

            ret = ret.Union(AtPoint(new Point3D(b.MaxPoint.X, b.MinPoint.Y, b.MinPoint.Z)));
            ret = ret.Union(AtPoint(new Point3D(b.MinPoint.X, b.MaxPoint.Y, b.MinPoint.Z)));
            ret = ret.Union(AtPoint(new Point3D(b.MinPoint.X, b.MinPoint.Y, b.MaxPoint.Z)));
            ret = ret.Union(AtPoint(new Point3D(b.MinPoint.X, b.MaxPoint.Y, b.MaxPoint.Z)));
            ret = ret.Union(AtPoint(new Point3D(b.MaxPoint.X, b.MaxPoint.Y, b.MinPoint.Z)));
            ret = ret.Union(AtPoint(new Point3D(b.MaxPoint.X, b.MinPoint.Y, b.MaxPoint.Z)));
            ret = ret.Union(AtPoint(new Point3D(b.MaxPoint.X, b.MaxPoint.Y, b.MaxPoint.Z)));
            return(ret);
        }
Esempio n. 24
0
        public InsideTestResult CheckClipping(IInsideTester4D region)
        {
            if (this.point2D_0 == null)
            {
                return(InsideTestResult.Outside);
            }
            Bounds3D box = new Bounds3D();

            foreach (Point2D point in this.point2D_0)
            {
                box.Update(this.matrix4D_0.TransformTo3D(point));
            }
            return(region.TryIsInside(box));
        }
Esempio n. 25
0
        public unsafe void BoundingBox(Bounds3D bounds, Matrix4D transform)
        {
            int length = this.vector4D_0.Length;

            fixed(Vector4D *vector4DPtr1 = this.vector4D_0)
            {
                Vector4D *vector4DPtr2 = vector4DPtr1;

                for (Vector4D *vector4DPtr3 = vector4DPtr2 + length; vector4DPtr2 < vector4DPtr3; ++vector4DPtr2)
                {
                    Vector4D p = transform.Transform(*vector4DPtr2);
                    bounds.Update(p);
                }
            }
        }
Esempio n. 26
0
        } // End Sub WriteDefaultLayoutToPdf

        /// <summary>
        /// Write a complete model to a PDF file.
        /// </summary>
        /// <remarks>
        /// The model is scaled to fit the paper inside the margin.
        /// This code will center the model on top of the page.
        /// </remarks>
        /// <param name="model">DXF model to write</param>
        /// <param name="paperSize">targeted paper size</param>
        /// <param name="margin">margin around model print in inches</param>
        /// <param name="outfile">path of PDF output file</param>
        /// <param name="embedFonts">embed fonts into PDF?</param>
        /// <param name="lineWeight">default line weight in 100th of mm</param>
        private static void WriteModelToPdf(DxfModel model, System.Drawing.Printing.PaperSize paperSize, float margin, string outfile, bool embedFonts, short lineWeight)
        {
            WW.Cad.Drawing.BoundsCalculator boundsCalculator = new WW.Cad.Drawing.BoundsCalculator();
            boundsCalculator.GetBounds(model);
            Bounds3D bounds = boundsCalculator.Bounds;

            // Lengths in inches.
            float pageWidth  = paperSize.Width / 100f;
            float pageHeight = paperSize.Height / 100f;

            // Scale and transform such that its fits max width/height
            // and the top middle of the cad drawing will match the
            // top middle of the pdf page.
            // The transform transforms to pdf pixels.
            double   scaling;
            Matrix4D to2DTransform = DxfUtil.GetScaleTransform(
                bounds.Corner1,
                bounds.Corner2,
                new Point3D(bounds.Center.X, bounds.Corner2.Y, 0d),
                new Point3D(new Vector3D(margin, margin, 0d) * PdfExporter.InchToPixel),
                new Point3D(new Vector3D(pageWidth - margin, pageHeight - margin, 0d) * PdfExporter.InchToPixel),
                new Point3D(new Vector3D(pageWidth / 2d, pageHeight - margin, 0d) * PdfExporter.InchToPixel),
                out scaling
                );

            using (System.IO.Stream stream = System.IO.File.Create(outfile))
            {
                PdfExporter pdfGraphics = new PdfExporter(stream);
                pdfGraphics.ExportLayers      = true;
                pdfGraphics.UseMultipleLayers = false;
                pdfGraphics.EmbedFonts        = embedFonts;
                WW.Cad.Drawing.GraphicsConfig config = (WW.Cad.Drawing.GraphicsConfig)WW.Cad.Drawing.GraphicsConfig.AcadLikeWithWhiteBackground.Clone();
                config.TryDrawingTextAsText = embedFonts;
                config.DefaultLineWeight    = lineWeight;

                pdfGraphics.DrawPage(
                    model,
                    config,
                    to2DTransform,
                    scaling,
                    null,
                    null,
                    paperSize
                    );

                pdfGraphics.EndDocument();
            } // End Using stream
        }     // End Sub WriteModelToPdf
Esempio n. 27
0
        public InsideTestResult TryIsInside(Bounds3D bounds)
        {
            InsideTestResult insideTestResult1 = InsideTestResult.None;

            foreach (IClippingTransformer clippingTransformer in this.linkedList_0)
            {
                InsideTestResult insideTestResult2 = clippingTransformer.TryIsInside(bounds);
                if (insideTestResult2 == InsideTestResult.Outside)
                {
                    return(insideTestResult2);
                }
                insideTestResult1 |= insideTestResult2;
                bounds             = DxfUtil.Transform(bounds, clippingTransformer.Matrix);
            }
            return(insideTestResult1);
        }
Esempio n. 28
0
        private void OpenDxfFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "AutoCad files (*.dwg, *.dxf)|*.dxf;*.dwg";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                filename = dialog.FileName;
            }
            if (!string.IsNullOrEmpty(filename))
            {
                //this.xtraTabPage1.BackColor = System.Drawing.Color.Black;
                try
                {
                    //通过文件扩展名判断CAD文件是dwg格式还是dxf格式
                    string extension = Path.GetExtension(filename);
                    if (string.Compare(extension, ".dwg", true) == 0)
                    {
                        model = DwgReader.Read(filename);
                    }
                    else
                    {
                        model = DxfReader.Read(filename);
                    }
                    //将控件的标签添加上文件名
                    this.xtraTabPage1.Text = "二维仿真(" + Path.GetFileName(filename) + ")";
                    //设置控件背景为黑色
                    this.xtraTabPage1.BackColor = System.Drawing.Color.Black;

                    //使用GDIGraphics3D绘制CAD文件的方法
                    //创建中间可绘制对象
                    gdiGraphics3D = new GDIGraphics3D(GraphicsConfig.BlackBackgroundCorrectForBackColor);
                    gdiGraphics3D.CreateDrawables(model);
                    //获得bounding box
                    bounds = new Bounds3D();
                    gdiGraphics3D.BoundingBox(bounds, modelTransform);
                    //计算GDIGraphics3D的属性To2DTransform
                    CalculateTo2DTransform();
                    //响应控件的Paint事件,画CAD文件
                }
                catch (Exception ex)
                {
                    MessageBox.Show("文件有错!请用AutoCad打开,通过“文件-核查”尝试修复。错误信息:" + ex.Message);
                }
            }
        }
Esempio n. 29
0
        void ILeader.imethod_0(
            DrawContext context,
            IList <WW.Math.Point3D> points,
            IList <WW.Math.Point3D> polyline)
        {
            DxfEntity entity = this.dxfObjectReference_6.Value as DxfEntity;

            if (entity == null)
            {
                return;
            }
            WW.Math.Point3D point = points[points.Count - 1];
            Vector3D        zaxis = this.HorizontalDirection;

            zaxis.Normalize();
            if (this.hookLineDirection_0 == HookLineDirection.Same)
            {
                zaxis = -zaxis;
            }
            BoundsCalculator boundsCalculator = new BoundsCalculator(context.Config);
            Matrix4D         transpose        = DxfUtil.GetToWCSTransform(zaxis).GetTranspose();
            Matrix4D         matrix4D         = Transformation4D.Translation(-(Vector3D)point);

            boundsCalculator.GetBounds(context.Model, entity, transpose * matrix4D);
            Bounds3D bounds = boundsCalculator.Bounds;

            if (!bounds.Initialized)
            {
                return;
            }
            double z1   = bounds.Min.Z;
            double z2   = bounds.Max.Z;
            double num1 = 0.5 * (z1 + z2);
            bool   flag = this.dxfDimensionStyleOverrides_0.TextVerticalAlignment != DimensionTextVerticalAlignment.Above && this.dxfDimensionStyleOverrides_0.TextVerticalPosition >= -0.7 && this.dxfDimensionStyleOverrides_0.TextVerticalPosition <= 0.7;
            double num2 = this.dxfDimensionStyleOverrides_0.ScaleFactor;

            if (num2 == 0.0)
            {
                num2 = 1.0;
            }
            double num3 = this.dxfDimensionStyleOverrides_0.DimensionLineGap * num2;
            double num4 = !flag ? (num1 < 0.0 ? z1 : z2) : System.Math.Max(z1 - num3, 0.0);

            polyline.Add(point + zaxis * num4);
        }
Esempio n. 30
0
        internal void method_0(
            DxfTableContent tableContent,
            double width,
            double height,
            double rotation,
            double horizontalMargin,
            double verticalMargin)
        {
            DxfBlock valueObject = this.ValueObject as DxfBlock;

            if (valueObject == null)
            {
                this.dxfContentFormat_0.method_6(1.0);
            }
            else
            {
                DxfInsert dxfInsert = new DxfInsert(valueObject);
                foreach (DxfTableAttribute dxfTableAttribute in (List <DxfTableAttribute>) this.dxfTableAttributeCollection_0)
                {
                    if (dxfTableAttribute.AttributeDefinition != null)
                    {
                        DxfAttribute dxfAttribute1 = new DxfAttribute(dxfTableAttribute.AttributeDefinition);
                        dxfAttribute1.Text = dxfTableAttribute.Value;
                        DxfAttribute dxfAttribute2 = dxfAttribute1;
                        dxfAttribute2.AlignmentPoint1 = dxfAttribute2.AlignmentPoint1 - valueObject.BasePoint;
                        if (dxfAttribute1.AlignmentPoint2.HasValue)
                        {
                            DxfAttribute     dxfAttribute3   = dxfAttribute1;
                            WW.Math.Point3D? alignmentPoint2 = dxfAttribute3.AlignmentPoint2;
                            WW.Math.Vector3D basePoint       = valueObject.BasePoint;
                            dxfAttribute3.AlignmentPoint2 = alignmentPoint2.HasValue ? new WW.Math.Point3D?(alignmentPoint2.GetValueOrDefault() - basePoint) : new WW.Math.Point3D?();
                        }
                    }
                }
                BoundsCalculator boundsCalculator = new BoundsCalculator();
                boundsCalculator.GetBounds(tableContent.Model, (DxfEntity)dxfInsert);
                Bounds3D bounds    = boundsCalculator.Bounds;
                Matrix4D transform = Transformation4D.Translation(valueObject.BasePoint) * Transformation4D.RotateZ(rotation) * Transformation4D.Translation(-valueObject.BasePoint);
                bounds.Transform(transform);
                Vector2D vector2D = new Vector2D((width - 2.0 * horizontalMargin) / bounds.Delta.X, (height - 2.0 * verticalMargin) / bounds.Delta.Y);
                this.dxfContentFormat_0.BlockScale = System.Math.Min(vector2D.X, vector2D.Y);
            }
        }
Esempio n. 31
0
    void Start()
    {
        Application.targetFrameRate = 60;

        // Initialize bounds
        m_Bounds_All   = new Bounds3D();
        m_Bounds_Upper = new Bounds3D();
        m_Bounds_Lower = new Bounds3D();

        // Set reference to the Bound in the GUI Bounds
        m_GUIBounds.m_Bounds = m_Bounds_All;

        m_OSCHandler = OSCHandler.Instance;

        // Get transforms if the group has any children
        if (transform.childCount != 0)
        {
            UpdateTransforms();
        }
    }
Esempio n. 32
0
        public void initParameter()
        {
            model=null;
            gdiGraphics3D=null;
            bounds=null;
            //Matrix4D tempfrom2DTransform;
            //from2DTransform=tempfrom2DTransform;
            //Point tempmouseClickLocation;
            //mouseClickLocation=tempmouseClickLocation;
            mouseDown=false;
            shiftPressed=false;

            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.UserPaint, true);
            GraphicsConfig graphicsConfig = new GraphicsConfig();
            //graphicsConfig.BackColor = BackColor;
            graphicsConfig.CorrectColorForBackgroundColor = true;
            gdiGraphics3D = new GDIGraphics3D(graphicsConfig);
            bounds = new Bounds3D();

            transformationProvider = new SimpleTransformationProvider3D();
            transformationProvider.TransformsChanged += new EventHandler(transformationProvider_TransformsChanged);
            panInteractor = new SimplePanInteractor(transformationProvider);
            rectZoomInteractor = new SimpleRectZoomInteractor(transformationProvider);
            zoomWheelInteractor = new SimpleZoomWheelInteractor(transformationProvider);
            rectZoomInteractorDrawable = new SimpleRectZoomInteractor.WinFormsDrawable(rectZoomInteractor);
        }