Пример #1
0
        private GCodeVertexBuffer Create3DDataForLayer(int layerIndex, GCodeRenderInfo renderInfo)
        {
            var colorVertexData  = new VectorPOD <ColorVertexData>();
            var vertexIndexArray = new VectorPOD <int>();

            featureStartIndex[layerIndex].Clear();
            featureEndIndex[layerIndex].Clear();

            for (int i = 0; i < renderFeatures[layerIndex].Count; i++)
            {
                featureStartIndex[layerIndex].Add(vertexIndexArray.Count);

                RenderFeatureBase feature = renderFeatures[layerIndex][i];

                if (feature != null)
                {
                    // Build the color and index data for the feature
                    feature.CreateRender3DData(colorVertexData, vertexIndexArray, renderInfo);
                }

                featureEndIndex[layerIndex].Add(vertexIndexArray.Count);
            }

            // Construct and return the new VertexBuffer object with all color/index data
            return(new GCodeVertexBuffer(vertexIndexArray.Array, colorVertexData.Array));
        }
Пример #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 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);
                    }
                }
            }
        }
Пример #3
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);
                        }
                    }
                }
            }
        }
Пример #4
0
        private void Create3DDataForLayer(int layerIndex,
                                          VectorPOD <ColorVertexData> colorVertexData,
                                          VectorPOD <int> vertexIndexArray,
                                          GCodeRenderInfo renderInfo)
        {
            colorVertexData.Clear();
            vertexIndexArray.Clear();
            featureStartIndex[layerIndex].Clear();
            featureEndIndex[layerIndex].Clear();

            for (int i = 0; i < renderFeatures[layerIndex].Count; i++)
            {
                featureStartIndex[layerIndex].Add(vertexIndexArray.Count);
                RenderFeatureBase feature = renderFeatures[layerIndex][i];
                if (feature != null)
                {
                    feature.CreateRender3DData(colorVertexData, vertexIndexArray, renderInfo);
                }
                featureEndIndex[layerIndex].Add(vertexIndexArray.Count);
            }
        }