示例#1
0
        public override void CreateRender3DData(VectorPOD <ColorVertexData> colorVertexData, VectorPOD <int> indexData, GCodeRenderInfo renderInfo)
        {
            if ((renderInfo.CurrentRenderType & RenderType.Retractions) == RenderType.Retractions)
            {
                var position = new Vector3(this.position);

                // retract and unretract are the extruder color
                Color color = renderInfo.GetMaterialColor(extruderIndex);
                // except for extruder 0 where they are the red and blue we are familiar with
                if (extruderIndex == 0)
                {
                    if (extrusionAmount > 0)
                    {
                        color = Color.Blue;
                    }
                    else
                    {
                        color = Color.Red;
                    }
                }
                if (extrusionAmount > 0)
                {
                    // unretraction
                    CreatePointer(colorVertexData, indexData, position + new Vector3(0, 0, 1.3), position + new Vector3(0, 0, .3), Radius(1), 5, color);
                }
                else
                {
                    // retraction
                    CreatePointer(colorVertexData, indexData, position + new Vector3(0, 0, .3), position + new Vector3(0, 0, 1.3), Radius(1), 5, color);
                }
            }
        }
示例#2
0
        public override void CreateRender3DData(VectorPOD <ColorVertexData> colorVertexData, VectorPOD <int> indexData, GCodeRenderInfo renderInfo)
        {
            if ((renderInfo.CurrentRenderType & RenderType.Extrusions) == RenderType.Extrusions)
            {
                Vector3Float start  = this.GetStart(renderInfo);
                Vector3Float end    = this.GetEnd(renderInfo);
                double       radius = GetRadius(renderInfo.CurrentRenderType);

                Color lineColor;

                if (renderInfo.CurrentRenderType.HasFlag(RenderType.SpeedColors))
                {
                    lineColor = color;
                }
                else if (renderInfo.CurrentRenderType.HasFlag(RenderType.GrayColors))
                {
                    lineColor = ActiveTheme.Instance.IsDarkTheme ? Color.DarkGray : Color.Gray;
                }
                else
                {
                    lineColor = renderInfo.GetMaterialColor(extruderIndex);
                }

                CreateCylinder(colorVertexData, indexData, new Vector3(start), new Vector3(end), radius, 6, lineColor, layerHeight);
            }
        }
示例#3
0
        public override void Render(Graphics2D graphics2D, GCodeRenderInfo renderInfo)
        {
            if (renderInfo.CurrentRenderType.HasFlag(RenderType.Extrusions))
            {
                double extrusionLineWidths = GetExtrusionWidth(renderInfo.CurrentRenderType) * 2 * renderInfo.LayerScale;

                Color extrusionColor = Color.Black;

                if (renderInfo.CurrentRenderType.HasFlag(RenderType.SpeedColors))
                {
                    extrusionColor = color;
                }
                else if (renderInfo.CurrentRenderType.HasFlag(RenderType.GrayColors))
                {
                    extrusionColor = Color.Gray;
                }
                else
                {
                    extrusionColor = renderInfo.GetMaterialColor(extruderIndex);
                }

                if (renderInfo.CurrentRenderType.HasFlag(RenderType.TransparentExtrusion))
                {
                    extrusionColor = new Color(extrusionColor, 200);
                }

                // render the part using opengl
                Graphics2DOpenGL graphics2DGl = graphics2D as Graphics2DOpenGL;
                if (graphics2DGl != null)
                {
                    Vector3Float startF = this.GetStart(renderInfo);
                    Vector3Float endF   = this.GetEnd(renderInfo);
                    Vector2      start  = new Vector2(startF.x, startF.y);
                    renderInfo.Transform.transform(ref start);

                    Vector2 end = new Vector2(endF.x, endF.y);
                    renderInfo.Transform.transform(ref end);

                    graphics2DGl.DrawAALineRounded(start, end, extrusionLineWidths / 2, extrusionColor);
                }
                else
                {
                    VertexStorage pathStorage = new VertexStorage();
                    VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(pathStorage, renderInfo.Transform);
                    Stroke stroke = new Stroke(transformedPathStorage, extrusionLineWidths / 2);

                    stroke.line_cap(LineCap.Round);
                    stroke.line_join(LineJoin.Round);

                    Vector3Float start = this.GetStart(renderInfo);
                    Vector3Float end   = this.GetEnd(renderInfo);

                    pathStorage.Add(start.x, start.y, ShapePath.FlagsAndCommand.MoveTo);
                    pathStorage.Add(end.x, end.y, ShapePath.FlagsAndCommand.LineTo);

                    graphics2D.Render(stroke, 0, extrusionColor);
                }
            }
        }
        public override void CreateRender3DData(VectorPOD <ColorVertexData> colorVertexData, VectorPOD <int> indexData, GCodeRenderInfo renderInfo)
        {
            if ((renderInfo.CurrentRenderType & RenderType.Extrusions) == RenderType.Extrusions)
            {
                double radius = GetRadius(renderInfo.CurrentRenderType);

                Color lineColor;

                if (renderInfo.CurrentRenderType.HasFlag(RenderType.SpeedColors))
                {
                    lineColor = color;
                }
                else if (renderInfo.CurrentRenderType.HasFlag(RenderType.GrayColors))
                {
                    lineColor = this.gray;
                }
                else
                {
                    lineColor = renderInfo.GetMaterialColor(toolIndex);
                }

                CreateCylinder(colorVertexData, indexData, new Vector3(start), new Vector3(end), radius, 6, lineColor, layerHeight);
            }
        }
        public override void Render(Graphics2D graphics2D, GCodeRenderInfo renderInfo, bool highlightFeature = false)
        {
            if (renderInfo.CurrentRenderType.HasFlag(RenderType.Extrusions))
            {
                double extrusionLineWidths = GetExtrusionWidth(renderInfo.CurrentRenderType) * 2 * renderInfo.LayerScale;

                Color extrusionColor = Color.Black;

                if (highlightFeature)
                {
                    extrusionColor = RenderFeatureBase.HighlightColor;
                }
                else if (renderInfo.CurrentRenderType.HasFlag(RenderType.SpeedColors))
                {
                    extrusionColor = color;
                }
                else if (renderInfo.CurrentRenderType.HasFlag(RenderType.GrayColors))
                {
                    extrusionColor = Color.Gray;
                }
                else
                {
                    extrusionColor = renderInfo.GetMaterialColor(toolIndex);
                }

                if (renderInfo.CurrentRenderType.HasFlag(RenderType.TransparentExtrusion))
                {
                    extrusionColor = new Color(extrusionColor, 200);
                }

                if (graphics2D is Graphics2DOpenGL graphics2DGl)
                {
                    // render using opengl
                    var startPoint = new Vector2(start.X, start.Y);
                    renderInfo.Transform.transform(ref startPoint);

                    var endPoint = new Vector2(end.X, end.Y);
                    renderInfo.Transform.transform(ref endPoint);

                    var eWidth = extrusionLineWidths / 2;

                    graphics2DGl.DrawAALineRounded(startPoint, endPoint, eWidth, extrusionColor);

                    if (highlightFeature)
                    {
                        Render3DStartEndMarkers(graphics2DGl, eWidth / 2, startPoint, endPoint);
                    }
                }
                else
                {
                    // render using agg
                    var pathStorage            = new VertexStorage();
                    var transformedPathStorage = new VertexSourceApplyTransform(pathStorage, renderInfo.Transform);
                    var stroke = new Stroke(transformedPathStorage, extrusionLineWidths / 2)
                    {
                        LineCap  = LineCap.Round,
                        LineJoin = LineJoin.Round
                    };

                    pathStorage.Add(start.X, start.Y, ShapePath.FlagsAndCommand.MoveTo);
                    pathStorage.Add(end.X, end.Y, ShapePath.FlagsAndCommand.LineTo);

                    graphics2D.Render(stroke, extrusionColor);
                }
            }
        }