Beispiel #1
0
        private void InitRenderer()
        {
            // Create the Renderer 3D control.
            //Renderer3D myRenderer3D = new Renderer3D();

            // Add the Renderer control to the panel
            // mainPanel.Controls.Clear();
            //mainPanel.Controls.Add(myRenderer3D);

            // Create a range for the graph generation
            Range xRange = new Range(workTimeArr.Min(), workTimeArr.Max());
            Range yRange = new Range(wrArr.Min(), wrArr.Max());
            int   steps  = 50;

            // Build a nice surface to display with cool alpha colors
            // (alpha 0.8 for surface color and 0.5 for wireframe)
            MyMapper mapper = new MyMapper();

            mapper.coeff = coeffs;
            Shape surface = Builder.buildOrthonomal(new OrthonormalGrid(xRange, steps, yRange, steps), mapper);

            surface.ColorMapper        = new ColorMapper(new ColorMapRainbow(), surface.Bounds.zmin, surface.Bounds.zmax, new nzy3D.Colors.Color(1, 1, 1, 0.8));
            surface.FaceDisplayed      = true;
            surface.WireframeDisplayed = true;
            surface.WireframeColor     = Color.CYAN;
            surface.WireframeColor.mul(new Color(1, 1, 1, 0.5));

            // Create the chart and embed the surface within
            Chart chart = new Chart(myRenderer3D, Quality.Nicest);

            chart.Scene.Graph.Add(surface);


            Scatter scatter = new Scatter(coor.ToArray(), Color.RED, 10);

            chart.Scene.Graph.Add(scatter);


            IAxeLayout axeLayout = chart.AxeLayout;

            axeLayout.TickLineDisplayed   = true;
            axeLayout.XTickLabelDisplayed = true;
            axeLayout.YTickLabelDisplayed = true;
            axeLayout.ZTickLabelDisplayed = true;
            axeLayout.XAxeLabelDisplayed  = true;
            axeLayout.YAxeLabelDisplayed  = true;
            axeLayout.ZAxeLabelDisplayed  = true;
            axeLayout.XAxeLabel           = "Work time (secs)";
            axeLayout.YAxeLabel           = "Work rest ratio";
            axeLayout.ZAxeLabel           = "Cal per min";

            axeLayout = chart.AxeLayout;

            // Create a mouse control
            nzy3D.Chart.Controllers.Mouse.Camera.CameraMouseController mouse = new nzy3D.Chart.Controllers.Mouse.Camera.CameraMouseController();
            mouse.addControllerEventListener(myRenderer3D);
            chart.addController(mouse);

            // This is just to ensure code is reentrant (used when code is not called in Form_Load but another reentrant event)
            DisposeBackgroundThread();

            // Create a thread to control the camera based on mouse movements
            t = new nzy3D.Chart.Controllers.Thread.Camera.CameraThreadController();
            t.addControllerEventListener(myRenderer3D);
            mouse.addSlaveThreadController(t);
            chart.addController(t);
            t.Start();

            // Associate the chart with current control
            myRenderer3D.setView(chart.View);

            this.Refresh();
        }