Exemple #1
0
        public void Render(Graphics2D graphics2D, GCodeRenderInfo renderInfo)
        {
            if (renderFeatures.Count > 0)
            {
                CreateFeaturesForLayerIfRequired(renderInfo.EndLayerIndex);

                int featuresOnLayer = renderFeatures[renderInfo.EndLayerIndex].Count;
                int endFeature      = (int)(featuresOnLayer * renderInfo.FeatureToEndOnRatio0To1 + .5);
                endFeature = Math.Max(0, Math.Min(endFeature, featuresOnLayer));

                int startFeature = (int)(featuresOnLayer * renderInfo.FeatureToStartOnRatio0To1 + .5);
                startFeature = Math.Max(0, Math.Min(startFeature, featuresOnLayer));

                // try to make sure we always draw at least one feature
                if (endFeature <= startFeature)
                {
                    endFeature = Math.Min(startFeature + 1, featuresOnLayer);
                }
                if (startFeature >= endFeature)
                {
                    // This can only happen if the sart and end are set to the last feature
                    // Try to set the start feture to one from the end
                    startFeature = Math.Max(endFeature - 1, 0);
                }

                for (int i = startFeature; i < endFeature; i++)
                {
                    RenderFeatureBase feature = renderFeatures[renderInfo.EndLayerIndex][i];
                    if (feature != null)
                    {
                        feature.Render(graphics2D, renderInfo);
                    }
                }
            }
        }
Exemple #2
0
        public void Render(Graphics2D graphics2D, GCodeRenderInfo renderInfo)
        {
            if (renderFeatures.Count > 0)
            {
                CreateFeaturesForLayerIfRequired(renderInfo.EndLayerIndex);

                int featuresOnLayer = renderFeatures[renderInfo.EndLayerIndex].Count;
                int endFeature      = (int)(featuresOnLayer * renderInfo.FeatureToEndOnRatio0To1 + .5);
                endFeature = Math.Max(0, Math.Min(endFeature, featuresOnLayer));

                int startFeature = (int)(featuresOnLayer * renderInfo.FeatureToStartOnRatio0To1 + .5);
                startFeature = Math.Max(0, Math.Min(startFeature, featuresOnLayer));

                // try to make sure we always draw at least one feature
                if (endFeature <= startFeature)
                {
                    endFeature = Math.Min(startFeature + 1, featuresOnLayer);
                }
                if (startFeature >= endFeature)
                {
                    // This can only happen if the start and end are set to the last feature
                    // Try to set the start feature to one from the end
                    startFeature = Math.Max(endFeature - 1, 0);
                }

                Graphics2DOpenGL graphics2DGl = graphics2D as Graphics2DOpenGL;
                if (graphics2DGl != null)
                {
                    graphics2DGl.PreRender(Color.White);
                    GL.Begin(BeginMode.Triangles);

                    int lastFeature = endFeature - 1;
                    for (int i = startFeature; i < endFeature; i++)
                    {
                        RenderFeatureBase feature = renderFeatures[renderInfo.EndLayerIndex][i];
                        if (feature != null)
                        {
                            feature.Render(graphics2DGl, renderInfo, highlightFeature: this.GCodeInspector && i == lastFeature);
                        }
                    }
                    GL.End();
                    graphics2DGl.PopOrthoProjection();
                }
                else
                {
                    for (int i = startFeature; i < endFeature; i++)
                    {
                        RenderFeatureBase feature = renderFeatures[renderInfo.EndLayerIndex][i];
                        if (feature != null)
                        {
                            feature.Render(graphics2D, renderInfo);
                        }
                    }
                }
            }
        }