Example #1
0
        void initGraph()
        {
            uiSplit.Dock = DockStyle.Fill;
            mRenderer3D  = new Renderer3D();
            uiSplit.Panel2.Controls.Add(mRenderer3D);
            mRenderer3D.Dock = DockStyle.Fill;

            //init surface
            initSurface();

            // Create the chart and embed the surface within
            mChart = new Chart(mRenderer3D, Quality.Nicest);
            mChart.Scene.Graph.Add(mSurface);
            mAxeLayout = mChart.AxeLayout;
            mChart.Scene.Views.First().BackgroundColor = Color.BLACK;
            mAxeLayout.MainColor = Color.WHITE;

            DisplayXTicks     = true;
            DisplayXAxisLabel = true;
            DisplayYTicks     = true;
            DisplayYAxisLabel = true;
            DisplayZTicks     = false;
            DisplayZAxisLabel = false;

            DisplayTickLines = true;

            // Create a mouse control
            CameraMouseController mouse = new CameraMouseController();

            mouse.addControllerEventListener(mRenderer3D);
            mChart.addController(mouse);

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

            // Create a thread to control the camera based on mouse movements
            mCamera = new CameraThreadController();
            mCamera.addControllerEventListener(mRenderer3D);
            mouse.addSlaveThreadController(mCamera);
            mChart.addController(mCamera);
            //mCamera.Start();

            // Associate the chart with current control
            mRenderer3D.setView(mChart.View);
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            // MVVM made simple : DataContext is current object
            this.DataContext = this;

            // Create the interop host control.
            System.Windows.Forms.Integration.WindowsFormsHost fromHost =
                new System.Windows.Forms.Integration.WindowsFormsHost();

            //// Create the Renderer 3D control.
            Renderer3D renderer = new Renderer3D();

            // Assign the Renderer 3D control as the host control's child.
            fromHost.Child = renderer;
            gridContent.Children.Add(fromHost);

            // Create the chart and embed the surface within
            dataChart = new nzy3D.Chart.Chart(renderer, Quality.Nicest);
            axeLayout = dataChart.AxeLayout;

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

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

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

            // Associate the chart with current control
            renderer.setView(dataChart.View);
        }
Example #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // MVVM made simple : DataContext is current object
            this.DataContext = this;

            // Create the interop host control.
            System.Windows.Forms.Integration.WindowsFormsHost host =
                new System.Windows.Forms.Integration.WindowsFormsHost();

            // Create the Renderer 3D control.
            Renderer3D renderer = new Renderer3D();

            // Assign the Renderer 3D control as the host control's child.
            host.Child = renderer;

            // Add the interop host control to the Grid
            // control's collection of child controls.
            this.MainGrid.Children.Add(host);

            // Create a range for the graph generation
            Range range = new Range(-150, 150);
            int   steps = 50;

            // Build a nice surface to display with cool alpha colors
            // (alpha 0.8 for surface color and 0.5 for wireframe)
            Shape surface = Builder.buildOrthonomal(new OrthonormalGrid(range, steps, range, steps), new MyMapper());

            surface.ColorMapper        = new ColorMapper(new ColorMapRainbow(), surface.Bounds.zmin, surface.Bounds.zmax, new 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(renderer, Quality.Nicest);

            chart.Scene.Graph.Add(surface);
            axeLayout         = chart.AxeLayout;
            DisplayXTicks     = true;
            DisplayXAxisLabel = true;
            DisplayYTicks     = true;
            DisplayYAxisLabel = true;
            DisplayZTicks     = true;
            DisplayZAxisLabel = true;
            DisplayTickLines  = true;

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

            // This is just to ensure code is reentrant (used when code is not 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(renderer);
            mouse.addSlaveThreadController(t);
            chart.addController(t);
            t.Start();

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