private void LightsInCameraSpaceCheck_CheckedChanged(object sender, EventArgs e)
        {
            NChart chart = nChartControl1.Charts[0];

            NPointLightSource light = new NPointLightSource();

            light.Ambient  = Color.FromArgb(64, 64, 64);
            light.Diffuse  = Color.FromArgb(230, 230, 230);
            light.Specular = Color.FromArgb(10, 10, 10);

            if (LightsInCameraSpaceCheck.Checked)
            {
                light.CoordinateMode = LightSourceCoordinateMode.Camera;
                light.Position       = new NVector3DF(0, 0, 50);
            }
            else
            {
                light.CoordinateMode = LightSourceCoordinateMode.Model;
                light.Position       = new NVector3DF(30, 20, 50);
            }

            chart.LightModel.LightSources.Clear();
            chart.LightModel.LightSources.Add(light);

            nChartControl1.Refresh();
        }
Esempio n. 2
0
        private void MultipleLightSources(NChart chart)
        {
            NPointLightSource light1 = new NPointLightSource();

            light1.CoordinateMode       = LightSourceCoordinateMode.Model;
            light1.Position             = new NVector3DF(0, 36, 16);
            light1.Ambient              = Color.FromArgb(60, 0, 0);
            light1.Diffuse              = Color.FromArgb(110, 20, 20);
            light1.Specular             = Color.FromArgb(80, 60, 60);
            light1.ConstantAttenuation  = 0.6f;
            light1.LinearAttenuation    = 0.004f;
            light1.QuadraticAttenuation = 0.0002f;

            NPointLightSource light2 = new NPointLightSource();

            light2.CoordinateMode       = LightSourceCoordinateMode.Model;
            light2.Position             = new NVector3DF(13.85f, 36, -8);
            light2.Ambient              = Color.FromArgb(0, 60, 0);
            light2.Diffuse              = Color.FromArgb(20, 110, 20);
            light2.Specular             = Color.FromArgb(60, 80, 60);
            light2.ConstantAttenuation  = 0.6f;
            light2.LinearAttenuation    = 0.004f;
            light2.QuadraticAttenuation = 0.0002f;

            NPointLightSource light3 = new NPointLightSource();

            light3.CoordinateMode       = LightSourceCoordinateMode.Model;
            light3.Position             = new NVector3DF(-13.85f, 36, -8);
            light3.Ambient              = Color.FromArgb(0, 0, 60);
            light3.Diffuse              = Color.FromArgb(20, 20, 110);
            light3.Specular             = Color.FromArgb(60, 60, 80);
            light3.ConstantAttenuation  = 0.6f;
            light3.LinearAttenuation    = 0.004f;
            light3.QuadraticAttenuation = 0.0002f;

            NPointLightSource light4 = new NPointLightSource();

            light4.CoordinateMode       = LightSourceCoordinateMode.Camera;
            light4.Position             = new NVector3DF(0, 0, 0);
            light4.Ambient              = Color.FromArgb(0, 0, 0);
            light4.Diffuse              = Color.FromArgb(90, 90, 90);
            light4.Specular             = Color.FromArgb(80, 80, 80);
            light4.ConstantAttenuation  = 0.9f;
            light4.LinearAttenuation    = 0.0004f;
            light4.QuadraticAttenuation = 0.0f;

            chart.LightModel.LightSources.Clear();
            chart.LightModel.LightSources.Add(light1);
            chart.LightModel.LightSources.Add(light2);
            chart.LightModel.LightSources.Add(light3);
            chart.LightModel.LightSources.Add(light4);
            chart.LightModel.EnableLighting         = true;
            chart.LightModel.LocalViewpointLighting = true;
            chart.LightModel.GlobalAmbientLight     = Color.FromArgb(60, 60, 60);
        }
Esempio n. 3
0
        private void PointLightInCameraSpace(NChart chart)
        {
            NPointLightSource light = new NPointLightSource();

            light.CoordinateMode       = LightSourceCoordinateMode.Camera;
            light.Position             = new NVector3DF(0, 0, 0);
            light.Ambient              = Color.FromArgb(100, 100, 100);
            light.Diffuse              = Color.FromArgb(210, 210, 210);
            light.Specular             = Color.FromArgb(90, 90, 90);
            light.ConstantAttenuation  = 0.3f;
            light.LinearAttenuation    = 0.0003f;
            light.QuadraticAttenuation = 0.00003f;

            chart.LightModel.LightSources.Clear();
            chart.LightModel.LightSources.Add(light);
            chart.LightModel.EnableLighting         = true;
            chart.LightModel.LocalViewpointLighting = true;
            chart.LightModel.GlobalAmbientLight     = Color.FromArgb(60, 60, 60);
        }
Esempio n. 4
0
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Controller.Tools.Clear();
            nChartControl1.Controller.Tools.Add(new NPanelSelectorTool());
            nChartControl1.Controller.Tools.Add(new NTrackballTool());

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("3D Pie Chart Shapes");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.ContentAlignment    = ContentAlignment.BottomCenter;
            title.Location            = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

            // setup the legend
            NLegend legend = nChartControl1.Legends[0];

            legend.SetPredefinedLegendStyle(PredefinedLegendStyle.BottomRight);

            NPieChart pieChart = new NPieChart();

            pieChart.Enable3D = true;

            nChartControl1.Charts.Clear();
            nChartControl1.Charts.Add(pieChart);

            NPointLightSource ls = new NPointLightSource();

            ls.CoordinateMode = LightSourceCoordinateMode.Camera;
            ls.Position       = new NVector3DF(0, 0, 50);
            ls.Ambient        = Color.FromArgb(30, 30, 30);
            ls.Diffuse        = Color.FromArgb(180, 180, 180);
            ls.Specular       = Color.FromArgb(100, 100, 100);

            pieChart.LightModel.LightSources.Clear();
            pieChart.LightModel.LightSources.Add(ls);

            pieChart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated);
            pieChart.Depth           = 10;
            pieChart.DisplayOnLegend = nChartControl1.Legends[0];
            pieChart.Location        = new NPointL(new NLength(20, NRelativeUnit.ParentPercentage), new NLength(20, NRelativeUnit.ParentPercentage));
            pieChart.Size            = new NSizeL(new NLength(60, NRelativeUnit.ParentPercentage), new NLength(60, NRelativeUnit.ParentPercentage));
            pieChart.InnerRadius     = new NLength(20, NRelativeUnit.ParentPercentage);

            NPieSeries pieSeries = (NPieSeries)pieChart.Series.Add(SeriesType.Pie);

            pieSeries.BorderStyle.Color = Color.LemonChiffon;

            pieSeries.DataLabelStyle.ArrowLength        = new NLength(10, NGraphicsUnit.Point);
            pieSeries.DataLabelStyle.ArrowPointerLength = new NLength(0, NGraphicsUnit.Point);

            pieSeries.Legend.Mode   = SeriesLegendMode.DataPoints;
            pieSeries.Legend.Format = "<label> <percent>";

            pieSeries.AddDataPoint(new NDataPoint(24, "Cars", new NColorFillStyle(Color.FromArgb(169, 121, 11))));
            pieSeries.AddDataPoint(new NDataPoint(18, "Airplanes", new NColorFillStyle(Color.FromArgb(157, 157, 92))));
            pieSeries.AddDataPoint(new NDataPoint(32, "Trains", new NColorFillStyle(Color.FromArgb(98, 152, 92))));
            pieSeries.AddDataPoint(new NDataPoint(23, "Ships", new NColorFillStyle(Color.FromArgb(111, 134, 181))));
            pieSeries.AddDataPoint(new NDataPoint(19, "Buses", new NColorFillStyle(Color.FromArgb(179, 63, 92))));

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor);

            styleSheet.Apply(nChartControl1.Document);

            // init form controls
            PieShapeCombo.FillFromEnum(typeof(PieStyle));
            PieShapeCombo.SelectedIndex = (int)PieStyle.Ring;

            PieLabelModeCombo.FillFromEnum(typeof(PieLabelMode));
            PieLabelModeCombo.SelectedIndex = 0;

            EdgePercentScroll.Value = (int)pieSeries.PieEdgePercent;
            OuterRadiusScroll.Value = (int)pieChart.Radius.Value;
            InnerRadiusScroll.Value = (int)pieChart.InnerRadius.Value;

            ArrowLengthScroll.Value        = (int)pieSeries.DataLabelStyle.ArrowLength.Value;
            ArrowPointerLengthScroll.Value = (int)pieSeries.DataLabelStyle.ArrowPointerLength.Value;
            ConnectorLengthScroll.Value    = (int)pieSeries.ConnectorLength.Value;
            LeadOffLengthScroll.Value      = (int)pieSeries.LeadOffArrowLength.Value;

            BeginAngleScroll.Value = (int)pieChart.BeginAngle;
            TotalAngleScroll.Value = (int)pieChart.TotalAngle;
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = new NLabel("Chart Walls<br/><font size = '9pt'>Demonstrates how to enable automatic wall visibility and automatic axis anchors</font>");

            title.TextStyle.FontStyle                   = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type            = ShadowType.LinearBlur;
            title.TextStyle.TextFormat                  = TextFormat.XML;
            title.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center;
            nChartControl1.Panels.Add(title);

            NChart chart = new NCartesianChart();

            nChartControl1.Panels.Add(chart);
            chart.Enable3D = true;
            chart.Width    = 55;
            chart.Height   = 25;
            chart.Depth    = 40;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);

            // add interlaced stripe to the Y axis
            NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);

            stripStyle.Interlaced  = true;
            stripStyle.ShowAtWalls = new ChartWallType[] {
                ChartWallType.Back,
                ChartWallType.Left,
                ChartWallType.Right,
                ChartWallType.Front
            };

            NStandardScaleConfigurator scaleY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;

            scaleY.StripStyles.Add(stripStyle);

            // create several series
            for (int i = 0; i < 4; i++)
            {
                NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
                bar.Values.FillRandom(Random, 6);
                bar.DataLabelStyle.Visible = false;
            }

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            // update form controls
            if (!IsPostBack)
            {
                RotationTextBox.Text  = chart.Projection.Rotation.ToString();
                ElevationTextBox.Text = chart.Projection.Elevation.ToString();
                LightsInCameraSpaceCheckBox.Checked = true;
                AutoWallsVisibilityCheckBox.Checked = true;

                AxisAnchorsModeDropDownList.Items.Add("Best Visibility");
                AxisAnchorsModeDropDownList.Items.Add("Auto Side");
                AxisAnchorsModeDropDownList.Items.Add("Manual");
                AxisAnchorsModeDropDownList.SelectedIndex = 0;
            }

            // configure lights
            NPointLightSource lightSource = new NPointLightSource();

            lightSource.Position = new NVector3DF(2, 2, 50);
            lightSource.Ambient  = Color.FromArgb(64, 64, 64);
            lightSource.Diffuse  = Color.FromArgb(255, 255, 255);
            lightSource.Specular = Color.FromArgb(100, 100, 100);

            chart.LightModel.LightSources.Clear();
            chart.LightModel.LightSources.Add(lightSource);
            chart.LightModel.GlobalAmbientLight = Color.FromArgb(0, 0, 0);

            if (LightsInCameraSpaceCheckBox.Checked)
            {
                lightSource.CoordinateMode = LightSourceCoordinateMode.Camera;
                lightSource.Position       = new NVector3DF(0, 0, 50);
            }
            else
            {
                lightSource.CoordinateMode = LightSourceCoordinateMode.Model;
                lightSource.Position       = new NVector3DF(100, 95, 110);
            }

            chart.Projection.Rotation  = (float)Convert.ToDouble(RotationTextBox.Text);
            chart.Projection.Elevation = (float)Convert.ToDouble(ElevationTextBox.Text);


            // update walls visiblity
            if (AutoWallsVisibilityCheckBox.Checked)
            {
                foreach (NChartWall wall in chart.Walls)
                {
                    wall.VisibilityMode = WallVisibilityMode.Auto;
                }
            }
            else
            {
                chart.Wall(ChartWallType.Left).VisibilityMode  = WallVisibilityMode.Visible;
                chart.Wall(ChartWallType.Back).VisibilityMode  = WallVisibilityMode.Visible;
                chart.Wall(ChartWallType.Floor).VisibilityMode = WallVisibilityMode.Visible;
                chart.Wall(ChartWallType.Front).VisibilityMode = WallVisibilityMode.Hidden;
                chart.Wall(ChartWallType.Top).VisibilityMode   = WallVisibilityMode.Hidden;
                chart.Wall(ChartWallType.Right).VisibilityMode = WallVisibilityMode.Hidden;
            }

            // update axis anchors
            NAxisAnchor anchorY = null;
            NAxisAnchor anchorX = null;
            NAxisAnchor anchorZ = null;

            switch (AxisAnchorsModeDropDownList.SelectedIndex)
            {
            case 0:
                anchorY = new NBestVisibilityAxisAnchor(AxisOrientation.Vertical);
                anchorX = new NBestVisibilityAxisAnchor(AxisOrientation.Horizontal);
                anchorZ = new NBestVisibilityAxisAnchor(AxisOrientation.Depth);
                break;

            case 1:
                anchorY = new NAutoSideAxisAnchor(AxisOrientation.Vertical);
                anchorX = new NAutoSideAxisAnchor(AxisOrientation.Horizontal);
                anchorZ = new NAutoSideAxisAnchor(AxisOrientation.Depth);
                break;

            case 2:
                anchorY = new NDockAxisAnchor(AxisDockZone.FrontLeft);
                anchorX = new NDockAxisAnchor(AxisDockZone.FrontBottom);
                anchorZ = new NDockAxisAnchor(AxisDockZone.BottomRight);
                break;
            }

            chart.Axis(StandardAxis.PrimaryY).Anchor = anchorY;
            chart.Axis(StandardAxis.PrimaryX).Anchor = anchorX;
            chart.Axis(StandardAxis.Depth).Anchor    = anchorZ;

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, null);
        }