public override void OnDraw(Graphics2D graphics2D)
 {
     graphics2D.Circle(Width / 2, Height / 2, Width / 2, RGBA_Bytes.White);
     graphics2D.Circle(Width / 2, Height / 2, Width / 2 - 1, RGBA_Bytes.Red);
     graphics2D.FillRectangle(Width / 2 - 1, Height / 2 - 3, Width / 2 + 1, Height / 2 + 3, RGBA_Bytes.White);
     base.OnDraw(graphics2D);
 }
 public override void OnDraw(Graphics2D graphics2D)
 {
     graphics2D.Circle(Width / 2, Height / 2, Width / 2, RGBA_Bytes.White);
     graphics2D.Circle(Width / 2, Height / 2, Width / 2 - 1, RGBA_Bytes.Red);
     graphics2D.FillRectangle(Width / 2 - 1, Height / 2 - 3, Width / 2 + 1, Height / 2 + 3, RGBA_Bytes.White);
     //graphics2D.DrawString("1", Width / 2, Height / 2 + 1, 8, Justification.Center, Baseline.BoundsCenter, RGBA_Bytes.White);
     base.OnDraw(graphics2D);
 }
        public void DoDrawBeforeChildren(Graphics2D graphics2D)
        {
            RadioButton radioButton = Parent as RadioButton;

            if (radioButton == null)
            {
                return;
            }
            Vector2 center = new Vector2(boxWidth / 2 + 1, boxWidth / 2 - labelTextWidget.Printer.TypeFaceStyle.DescentInPixels);

            // the check
            if (radioButton.Checked)
            {
                graphics2D.Circle(center, boxWidth / 4, radioButton.TextColor);
            }

            if (radioButton.MouseDownOnButton && radioButton.FirstWidgetUnderMouse)
            {
                // extra frame
                graphics2D.Render(new Stroke(new Ellipse(center, boxWidth / 2, boxWidth / 2), 2), radioButton.TextColor);
            }
            else
            {
                // the frame
                graphics2D.Render(new Stroke(new Ellipse(center, boxWidth / 2, boxWidth / 2)), radioButton.TextColor);
            }
        }
        private void DrawFaceEdge(FaceEdge faceEdge, Vector2 faceAverageCenter)
        {
            Vector2 start = MoveTowardsCenter(GetImagePosition(faceEdge.FirstVertex.Position), faceAverageCenter);
            Vector2 end   = MoveTowardsCenter(GetImagePosition(faceEdge.NextFaceEdge.FirstVertex.Position), faceAverageCenter);

            DrawEdgeLine(start, end, faceEdge.ID.ToString(), faceEdgeColor);
            graphics.Circle(start, 3, Color.Black);
            WriteStringAtPos("{0}".FormatWith(faceEdge.MeshEdge.ID), (start + end) / 2 + new Vector2(0, -12), meshEdgeColor);
            WriteStringAtPos("{0}".FormatWith(faceEdge.ContainingFace.ID), (start + end) / 2 + new Vector2(0, 12), faceColor);

            Vector2 delta  = end - start;
            Vector2 normal = delta.GetNormal();
            double  length = delta.Length;
            Vector2 left   = normal.GetPerpendicularLeft();

            // draw the starting vertex info
            WriteStringAtPos("{0}".FormatWith(faceEdge.FirstVertex.ID), start + normal * length * .10, vertexColor);

            // draw the next and prev faceEdge info
            WriteStringAtPos("{0}".FormatWith(faceEdge.NextFaceEdge.ID), start + normal * length * .60, faceEdgeColor);
            WriteStringAtPos("{0}".FormatWith(faceEdge.PrevFaceEdge.ID), start + normal * length * .40, faceEdgeColor);

            // draw the radialFaceEdge info
            WriteStringAtPos("{0}".FormatWith(faceEdge.RadialNextFaceEdge.ID), start + new Vector2(0, 7) + normal * length * .90, faceEdgeColor);
            WriteStringAtPos("{0}".FormatWith(faceEdge.radialPrevFaceEdge.ID), start + new Vector2(0, -7) + normal * length * .90, faceEdgeColor);
        }
		public void DoDrawBeforeChildren(Graphics2D graphics2D)
		{
			RadioButton radioButton = Parent as RadioButton;
			if (radioButton == null)
			{
				return;
			}
			Vector2 center = new Vector2(boxWidth / 2 + 1, boxWidth / 2 - labelTextWidget.Printer.TypeFaceStyle.DescentInPixels);

			// the check
			if (radioButton.Checked)
			{
				graphics2D.Circle(center, boxWidth / 4, radioButton.TextColor);
			}

			if (radioButton.MouseDownOnButton && radioButton.FirstWidgetUnderMouse)
			{
				// extra frame
				graphics2D.Render(new Stroke(new Ellipse(center, boxWidth / 2, boxWidth / 2), 2), radioButton.TextColor);
			}
			else
			{
				// the frame
				graphics2D.Render(new Stroke(new Ellipse(center, boxWidth / 2, boxWidth / 2)), radioButton.TextColor);
			}
		}
        void createThumbnailWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            PartThumbnailWidget thumbnailWidget = e.Argument as PartThumbnailWidget;

            if (thumbnailWidget != null)
            {
                if (thumbnailWidget.printItem == null)
                {
                    thumbnailWidget.image = new ImageBuffer(thumbnailWidget.noThumbnailImage);
                }
                else // generate the image
                {
                    Mesh loadedMesh = StlProcessing.Load(thumbnailWidget.printItem.FileLocation);

                    thumbnailWidget.image = new ImageBuffer(thumbnailWidget.buildingThumbnailImage);
                    thumbnailWidget.Invalidate();

                    if (loadedMesh != null)
                    {
                        ImageBuffer tempImage      = new ImageBuffer(thumbnailWidget.image.Width, thumbnailWidget.image.Height, 32, new BlenderBGRA());
                        Graphics2D  partGraphics2D = tempImage.NewGraphics2D();

                        List <MeshEdge> nonManifoldEdges = loadedMesh.GetNonManifoldEdges();
                        if (nonManifoldEdges.Count > 0)
                        {
                            if (File.Exists("RunUnitTests.txt"))
                            {
                                partGraphics2D.Circle(4, 4, 4, RGBA_Bytes.Red);
                            }
                        }
                        nonManifoldEdges = null;

                        AxisAlignedBoundingBox aabb = loadedMesh.GetAxisAlignedBoundingBox();
                        double          maxSize     = Math.Max(aabb.XSize, aabb.YSize);
                        double          scale       = thumbnailWidget.image.Width / (maxSize * 1.2);
                        RectangleDouble bounds2D    = new RectangleDouble(aabb.minXYZ.x, aabb.minXYZ.y, aabb.maxXYZ.x, aabb.maxXYZ.y);
                        PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partGraphics2D, loadedMesh,
                                                                             new Vector2((thumbnailWidget.image.Width / scale - bounds2D.Width) / 2 - bounds2D.Left,
                                                                                         (thumbnailWidget.image.Height / scale - bounds2D.Height) / 2 - bounds2D.Bottom),
                                                                             scale,
                                                                             thumbnailWidget.FillColor);

                        thumbnailWidget.image = new ImageBuffer(tempImage);
                        loadedMesh            = new Mesh();
                    }
                    else
                    {
                        thumbnailWidget.image = new ImageBuffer(thumbnailWidget.noThumbnailImage);
                    }
                }
                thumbnailWidget.Invalidate();
            }
        }
Beispiel #7
0
        private static ImageBuffer BuildImageFromMeshGroups(IObject3D loadedItem, int width, int height, bool debugNonManifoldEdges = false)
        {
            var visibleMeshes = loadedItem.VisibleMeshes().ToList();

            if (visibleMeshes?.Count > 0)
            {
                var        tempImage      = new ImageBuffer(width, height);
                Graphics2D partGraphics2D = tempImage.NewGraphics2D();
                partGraphics2D.Clear(new Color());

                AxisAlignedBoundingBox aabb = visibleMeshes[0].Mesh.GetAxisAlignedBoundingBox(visibleMeshes[0].WorldMatrix());

                for (int i = 1; i < visibleMeshes.Count; i++)
                {
                    aabb = AxisAlignedBoundingBox.Union(aabb, visibleMeshes[i].Mesh.GetAxisAlignedBoundingBox(visibleMeshes[i].WorldMatrix()));
                }

                double maxSize = Math.Max(aabb.XSize, aabb.YSize);
                double scale   = width / (maxSize * 1.2);

                var bounds2D = new RectangleDouble(aabb.minXYZ.X, aabb.minXYZ.Y, aabb.maxXYZ.X, aabb.maxXYZ.Y);
                foreach (var meshGroup in visibleMeshes)
                {
                    PolygonMesh.Rendering.OrthographicZProjection.DrawTo(
                        partGraphics2D,
                        meshGroup.Mesh,
                        meshGroup.WorldMatrix(),
                        new Vector2(
                            (width / scale - bounds2D.Width) / 2 - bounds2D.Left,
                            (height / scale - bounds2D.Height) / 2 - bounds2D.Bottom),
                        scale,
                        meshGroup.WorldColor());
                }

                if (debugNonManifoldEdges)
                {
                    foreach (var loadedMesh in visibleMeshes)
                    {
                        List <MeshEdge> nonManifoldEdges = loadedMesh.Mesh.GetNonManifoldEdges();
                        if (nonManifoldEdges.Count > 0)
                        {
                            partGraphics2D.Circle(width / 4, width / 4, width / 8, Color.Red);
                        }
                    }
                }

                // Force to all white and return
                return(tempImage);
            }

            return(null);
        }
        private static ImageBuffer BuildImageFromMeshGroups(List <MeshGroup> loadedMeshGroups, string stlHashCode, Point2D size)
        {
            if (loadedMeshGroups != null &&
                loadedMeshGroups.Count > 0 &&
                loadedMeshGroups[0].Meshes != null &&
                loadedMeshGroups[0].Meshes[0] != null)
            {
                ImageBuffer tempImage      = new ImageBuffer(size.x, size.y);
                Graphics2D  partGraphics2D = tempImage.NewGraphics2D();
                partGraphics2D.Clear(new RGBA_Bytes());

                AxisAlignedBoundingBox aabb = loadedMeshGroups[0].GetAxisAlignedBoundingBox();
                for (int meshGroupIndex = 1; meshGroupIndex < loadedMeshGroups.Count; meshGroupIndex++)
                {
                    aabb = AxisAlignedBoundingBox.Union(aabb, loadedMeshGroups[meshGroupIndex].GetAxisAlignedBoundingBox());
                }
                double          maxSize  = Math.Max(aabb.XSize, aabb.YSize);
                double          scale    = size.x / (maxSize * 1.2);
                RectangleDouble bounds2D = new RectangleDouble(aabb.minXYZ.x, aabb.minXYZ.y, aabb.maxXYZ.x, aabb.maxXYZ.y);
                foreach (MeshGroup meshGroup in loadedMeshGroups)
                {
                    foreach (Mesh loadedMesh in meshGroup.Meshes)
                    {
                        PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partGraphics2D, loadedMesh,
                                                                             new Vector2((size.x / scale - bounds2D.Width) / 2 - bounds2D.Left,
                                                                                         (size.y / scale - bounds2D.Height) / 2 - bounds2D.Bottom),
                                                                             scale, RGBA_Bytes.White);
                    }
                }

                if (File.Exists("RunUnitTests.txt"))
                {
                    foreach (Mesh loadedMesh in loadedMeshGroups[0].Meshes)
                    {
                        List <MeshEdge> nonManifoldEdges = loadedMesh.GetNonManifoldEdges();
                        if (nonManifoldEdges.Count > 0)
                        {
                            partGraphics2D.Circle(size.x / 4, size.x / 4, size.x / 8, RGBA_Bytes.Red);
                        }
                    }
                }

                tempImage.SetRecieveBlender(new BlenderPreMultBGRA());
                AllWhite.DoAllWhite(tempImage);

                // and give it back
                return(tempImage);
            }

            return(null);
        }
Beispiel #9
0
        private void AddAFloor()
        {
            ImageBuffer testImage = new ImageBuffer(200, 200);
            Graphics2D  graphics  = testImage.NewGraphics2D();
            Random      rand      = new Random(0);

            for (int i = 0; i < 100; i++)
            {
                RGBA_Bytes color = new RGBA_Bytes(rand.NextDouble(), rand.NextDouble(), rand.NextDouble());
                graphics.Circle(new Vector2(rand.NextDouble() * testImage.Width, rand.NextDouble() * testImage.Height), rand.NextDouble() * 40 + 10, color);
            }
            scene.shapes.Add(new PlaneShape(new Vector3(0, 0, 1), 0, new TextureMaterial(testImage, 0, 0, .2, 1)));
            //scene.shapes.Add(new PlaneShape(new Vector3(0, 0, 1), 0, new ChessboardMaterial(new RGBA_Floats(1, 1, 1), new RGBA_Floats(0, 0, 0), 0, 0, 1, 0.7)));
        }
Beispiel #10
0
        private static ImageBuffer BuildImageFromSTL(Mesh loadedMesh, string stlHashCode, Point2D size)
        {
            if (loadedMesh != null)
            {
                ImageBuffer tempImage      = new ImageBuffer(size.x, size.y, 32, new BlenderBGRA());
                Graphics2D  partGraphics2D = tempImage.NewGraphics2D();
                partGraphics2D.Clear(new RGBA_Bytes());

                List <MeshEdge> nonManifoldEdges = loadedMesh.GetNonManifoldEdges();
                if (nonManifoldEdges.Count > 0)
                {
                    if (File.Exists("RunUnitTests.txt"))
                    {
                        partGraphics2D.Circle(4, 4, 4, RGBA_Bytes.Red);
                    }
                }
                nonManifoldEdges = null;

                AxisAlignedBoundingBox aabb = loadedMesh.GetAxisAlignedBoundingBox();
                double          maxSize     = Math.Max(aabb.XSize, aabb.YSize);
                double          scale       = size.x / (maxSize * 1.2);
                RectangleDouble bounds2D    = new RectangleDouble(aabb.minXYZ.x, aabb.minXYZ.y, aabb.maxXYZ.x, aabb.maxXYZ.y);
                PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partGraphics2D, loadedMesh,
                                                                     new Vector2((size.x / scale - bounds2D.Width) / 2 - bounds2D.Left,
                                                                                 (size.y / scale - bounds2D.Height) / 2 - bounds2D.Bottom),
                                                                     scale, RGBA_Bytes.White);

                // and save it to disk
                string applicationUserDataPath = ApplicationDataStorage.Instance.ApplicationUserDataPath;
                string folderToSavePrintsTo    = Path.Combine(applicationUserDataPath, "data", "temp", "thumbnails");
                string tgaFileName             = Path.Combine(folderToSavePrintsTo, "{0}_{1}x{2}.tga".FormatWith(stlHashCode, size.x, size.y));

                if (!Directory.Exists(folderToSavePrintsTo))
                {
                    Directory.CreateDirectory(folderToSavePrintsTo);
                }
                ImageTgaIO.SaveImageData(tgaFileName, tempImage);

                // and give it back
                return(tempImage);
            }

            return(null);
        }
Beispiel #11
0
        private static ImageBuffer ColorCircle(int size, Color color)
        {
            var        imageBuffer    = new ImageBuffer(size, size);
            Graphics2D normalGraphics = imageBuffer.NewGraphics2D();
            var        center         = new Vector2(size / 2.0, size / 2.0);

            Color barColor;

            if (color != Color.Transparent)
            {
                normalGraphics.Circle(center, size / 2.0, color);
                barColor = Color.White;
            }
            else
            {
                barColor = new Color("#999");
            }

            normalGraphics.Line(center + new Vector2(-size / 4.0, -size / 4.0), center + new Vector2(size / 4.0, size / 4.0), barColor, 2 * GuiWidget.DeviceScale);
            normalGraphics.Line(center + new Vector2(-size / 4.0, size / 4.0), center + new Vector2(size / 4.0, -size / 4.0), barColor, 2 * GuiWidget.DeviceScale);

            return(imageBuffer);
        }
Beispiel #12
0
        private void CreateAndRenderPathing(Graphics2D graphics2D, Polygons polygonsToPathAround, Polygons travelPolysLine)
        {
            Polygons travelPolygons = CreateTravelPath(polygonsToPathAround, travelPolysLine);

            PathStorage travelPath = VertexSourceToClipperPolygons.CreatePathStorage(travelPolygons);

            travelPath.Add(0, 0, ShapePath.FlagsAndCommand.CommandStop);

            graphics2D.Render(new Stroke(travelPath), pathColor);

            //graphics2D.Render(optomizedTravelPath, optomizedPpathColor);

            foreach (Polygon polygon in polygonsToPathAround)
            {
                for (int i = 0; i < polygon.Count; i++)
                {
                    if (!polygon.IsVertexConcave(i))
                    {
                        graphics2D.Circle(polygon[i].X, polygon[i].Y, 4, RGBA_Bytes.Green);
                    }
                }
            }
        }
Beispiel #13
0
        private static ImageBuffer BuildImageFromMeshGroups(List <MeshGroup> loadedMeshGroups, string stlHashCode, Point2D size)
        {
            if (loadedMeshGroups != null &&
                loadedMeshGroups.Count > 0 &&
                loadedMeshGroups[0].Meshes != null &&
                loadedMeshGroups[0].Meshes[0] != null)
            {
                ImageBuffer tempImage      = new ImageBuffer(size.x, size.y, 32, new BlenderBGRA());
                Graphics2D  partGraphics2D = tempImage.NewGraphics2D();
                partGraphics2D.Clear(new RGBA_Bytes());

                AxisAlignedBoundingBox aabb = loadedMeshGroups[0].GetAxisAlignedBoundingBox();
                for (int meshGroupIndex = 1; meshGroupIndex < loadedMeshGroups.Count; meshGroupIndex++)
                {
                    aabb = AxisAlignedBoundingBox.Union(aabb, loadedMeshGroups[meshGroupIndex].GetAxisAlignedBoundingBox());
                }
                double          maxSize  = Math.Max(aabb.XSize, aabb.YSize);
                double          scale    = size.x / (maxSize * 1.2);
                RectangleDouble bounds2D = new RectangleDouble(aabb.minXYZ.x, aabb.minXYZ.y, aabb.maxXYZ.x, aabb.maxXYZ.y);
                foreach (MeshGroup meshGroup in loadedMeshGroups)
                {
                    foreach (Mesh loadedMesh in meshGroup.Meshes)
                    {
                        PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partGraphics2D, loadedMesh,
                                                                             new Vector2((size.x / scale - bounds2D.Width) / 2 - bounds2D.Left,
                                                                                         (size.y / scale - bounds2D.Height) / 2 - bounds2D.Bottom),
                                                                             scale, RGBA_Bytes.White);
                    }
                }

                if (File.Exists("RunUnitTests.txt"))
                {
                    foreach (Mesh loadedMesh in loadedMeshGroups[0].Meshes)
                    {
                        List <MeshEdge> nonManifoldEdges = loadedMesh.GetNonManifoldEdges();
                        if (nonManifoldEdges.Count > 0)
                        {
                            partGraphics2D.Circle(size.x / 4, size.x / 4, size.x / 8, RGBA_Bytes.Red);
                        }
                    }
                }

                // and save it to disk
                string imageFileName        = GetFilenameForSize(stlHashCode, size);
                string folderToSavePrintsTo = Path.GetDirectoryName(imageFileName);

                if (!Directory.Exists(folderToSavePrintsTo))
                {
                    Directory.CreateDirectory(folderToSavePrintsTo);
                }
                if (partExtension == ".png")
                {
                    ImageIO.SaveImageData(imageFileName, tempImage);
                }
                else
                {
                    ImageTgaIO.SaveImageData(imageFileName, tempImage);
                }

                // and give it back
                return(tempImage);
            }

            return(null);
        }
        static void CreateThumbnailsThread()
        {
            while (true)
            {
                if (listOfWidgetsNeedingThumbnails.Count > 0)
                {
                    LibraryThumbnailWidget thumbnailWidget = listOfWidgetsNeedingThumbnails[0];
                    if (thumbnailWidget.printItem == null)
                    {
                        thumbnailWidget.image = new ImageBuffer(thumbnailWidget.noThumbnailImage);
                    }
                    else // generate the image
                    {
                        Mesh loadedMesh = StlProcessing.Load(thumbnailWidget.printItem.FileLocation);

                        thumbnailWidget.image = new ImageBuffer(thumbnailWidget.buildingThumbnailImage);
                        thumbnailWidget.Invalidate();

                        if (loadedMesh != null)
                        {
                            ImageBuffer tempImage      = new ImageBuffer(thumbnailWidget.image.Width, thumbnailWidget.image.Height, 32, new BlenderBGRA());
                            Graphics2D  partGraphics2D = tempImage.NewGraphics2D();

                            List <MeshEdge> nonManifoldEdges = loadedMesh.GetNonManifoldEdges();
                            if (nonManifoldEdges.Count > 0)
                            {
                                if (File.Exists("RunUnitTests.txt"))
                                {
                                    partGraphics2D.Circle(4, 4, 4, RGBA_Bytes.Red);
                                }
                            }

                            AxisAlignedBoundingBox aabb = loadedMesh.GetAxisAlignedBoundingBox();
                            double          maxSize     = Math.Max(aabb.XSize, aabb.YSize);
                            double          scale       = thumbnailWidget.image.Width / (maxSize * 1.2);
                            RectangleDouble bounds2D    = new RectangleDouble(aabb.minXYZ.x, aabb.minXYZ.y, aabb.maxXYZ.x, aabb.maxXYZ.y);
                            PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partGraphics2D, loadedMesh,
                                                                                 new Vector2((thumbnailWidget.image.Width / scale - bounds2D.Width) / 2 - bounds2D.Left,
                                                                                             (thumbnailWidget.image.Height / scale - bounds2D.Height) / 2 - bounds2D.Bottom),
                                                                                 scale,
                                                                                 thumbnailWidget.FillColor);

                            thumbnailWidget.image = new ImageBuffer(tempImage);
                        }
                        else
                        {
                            thumbnailWidget.image = new ImageBuffer(thumbnailWidget.noThumbnailImage);
                        }
                    }
                    thumbnailWidget.Invalidate();

                    using (TimedLock.Lock(listOfWidgetsNeedingThumbnails, "CreateThumbnailsThread()"))
                    {
                        listOfWidgetsNeedingThumbnails.RemoveAt(0);

                        foreach (LibraryThumbnailWidget part in listOfWidgetsNeedingThumbnails)
                        {
                            // mark them so we try to add them again if needed
                            part.thumbNailHasBeenRequested = false;
                        }

                        listOfWidgetsNeedingThumbnails.Clear();
                    }
                }
                Thread.Sleep(100);
            }
        }
Beispiel #15
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            var inverseScale = 1 / scalingFactor;
            var offset       = Vector2.Zero;

            // Reset to zero
            var existing = graphics2D.GetTransform();

            existing.translation(out double x, out double y);
            offset.X += x;
            offset.Y += y;

            // Center
            if (this.Width > this.Height)
            {
                offset.X += (this.Width / 2) - (bedBounds.Width * scalingFactor / 2);
            }
            else
            {
                offset.Y += (this.Height / 2) - (bedBounds.Height * scalingFactor / 2);
            }

            // Offset considering bed bounds
            offset.X -= bedBounds.Left * scalingFactor;
            offset.Y -= bedBounds.Bottom * scalingFactor;

            // Apply transform
            graphics2D.PushTransform();
            graphics2D.SetTransform(Affine.NewScaling(scalingFactor) * Affine.NewTranslation(offset));

            // Draw the bed
            this.RenderBed(graphics2D);

            // Build hotend path
            if (this.RenderProbePath)
            {
                this.RenderProbingPath(graphics2D);
            }

            if (this.RenderLevelingData)
            {
                if (currentLevelingFunctions == null)
                {
                    PrintLevelingData levelingData = printer.Settings.Helpers.PrintLevelingData;

                    var printerShim = ApplicationController.Instance.Shim(printer);

                    currentLevelingFunctions = new LevelingFunctions(printerShim, levelingData);
                }

                var levelingTriangles = new VertexStorage();

                foreach (var region in currentLevelingFunctions.Regions)
                {
                    levelingTriangles.MoveTo(region.V0.X, region.V0.Y);

                    levelingTriangles.LineTo(region.V1.X, region.V1.Y);
                    levelingTriangles.LineTo(region.V2.X, region.V2.Y);
                    levelingTriangles.LineTo(region.V0.X, region.V0.Y);
                }

                graphics2D.Render(
                    new Stroke(levelingTriangles),
                    opaqueMinimumAccent);
            }

            // Render probe points
            int i = 0;

            foreach (var position in probePoints)
            {
                var center = new Vector2(position.X, position.Y);

                var textColor   = lightText;
                var circleColor = bedCircleColor;

                if (this.SimplePoints)
                {
                    graphics2D.Render(
                        new Ellipse(center, 4 * inverseScale),
                        simpleBedCircleColor);
                }
                else
                {
                    if (i < this.ActiveProbeIndex)
                    {
                        circleColor = opaqueMinimumAccent;
                        textColor   = circleText;
                    }
                    else if (i == this.ActiveProbeIndex)
                    {
                        circleColor = opaqueAccent;
                        textColor   = circleText;
                    }

                    if (i >= this.ActiveProbeIndex)
                    {
                        graphics2D.Circle(
                            center,
                            9 * inverseScale,
                            i == this.ActiveProbeIndex ? circleText : lightText);

                        graphics2D.Circle(
                            center,
                            8 * inverseScale,
                            circleColor);
                    }
                    else
                    {
                        graphics2D.Circle(
                            center,
                            9 * inverseScale,
                            circleColor);
                    }

                    graphics2D.DrawString(
                        $"{1 + i}",
                        center.X,
                        center.Y,
                        justification: Justification.Center,
                        baseline: Baseline.BoundsCenter,
                        pointSize: theme.FontSize7 * inverseScale,
                        color: textColor);

                    i++;
                }
            }

            graphics2D.PopTransform();

            base.OnDraw(graphics2D);
        }
Beispiel #16
0
        private void CreateAndRenderPathing(Graphics2D graphics2D, Polygons polygonsToPathAround, Polygons travelPolysLine)
        {
            Polygons travelPolygons = CreateTravelPath(polygonsToPathAround, travelPolysLine);

            PathStorage travelPath = VertexSourceToClipperPolygons.CreatePathStorage(travelPolygons);

            travelPath.Add(0, 0, ShapePath.FlagsAndCommand.CommandStop);

            graphics2D.Render(new Stroke(travelPath), pathColor);

            //graphics2D.Render(optomizedTravelPath, optomizedPpathColor);

            foreach (Polygon polygon in polygonsToPathAround)
            {
                for (int i = 0; i < polygon.Count; i++)
                {
                    if (!polygon.IsVertexConcave(i))
                    {
                        graphics2D.Circle(polygon[i].X, polygon[i].Y, 4, RGBA_Bytes.Green);
                    }
                }
            }
        }