예제 #1
0
        /// <summary>
        /// Called to initialize the example
        /// </summary>
        /// <param name="chartControl"></param>
        public override void Create()
        {
            nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.HighSpeed;

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = new NLabel("Grid Surface Cross Section");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic);
            title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue);
            title.DockMode            = PanelDockMode.Top;
            title.Margins             = new NMarginsL(10);
            nChartControl1.Panels.Add(title);

            NDockPanel containerPanel = new NDockPanel();

            containerPanel.PositionChildPanelsInContentBounds = true;
            containerPanel.Margins  = new NMarginsL(10, 0, 10, 10);
            containerPanel.DockMode = PanelDockMode.Fill;
            nChartControl1.Panels.Add(containerPanel);

            // configure the chart
            NCartesianChart surfaceChart = new NCartesianChart();

            containerPanel.ChildPanels.Add(surfaceChart);
            surfaceChart.DockMode   = PanelDockMode.Top;
            surfaceChart.Size       = new NSizeL(new NLength(0.0f), new NLength(70.0f, NRelativeUnit.ParentPercentage));
            surfaceChart.Enable3D   = true;
            surfaceChart.Width      = 60.0f;
            surfaceChart.Depth      = 60.0f;
            surfaceChart.Height     = 15.0f;
            surfaceChart.BoundsMode = BoundsMode.Fit;
            surfaceChart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);
            surfaceChart.Projection.Elevation = 22;
            surfaceChart.Projection.Rotation  = -68;
            surfaceChart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft);

            // setup axes
            NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)surfaceChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;

            ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            ordinalScale.DisplayDataPointsBetweenTicks = false;

            ordinalScale = (NOrdinalScaleConfigurator)surfaceChart.Axis(StandardAxis.Depth).ScaleConfigurator;
            ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true);
            ordinalScale.DisplayDataPointsBetweenTicks = false;

            // add the surface series
            m_SurfaceSeries = new NGridSurfaceSeries();
            surfaceChart.Series.Add(m_SurfaceSeries);
            m_SurfaceSeries.Name          = "Surface";
            m_SurfaceSeries.Legend.Mode   = SeriesLegendMode.SeriesLogic;
            m_SurfaceSeries.PositionValue = 10.0;
            m_SurfaceSeries.Data.SetGridSize(1000, 1000);
            m_SurfaceSeries.SyncPaletteWithAxisScale       = false;
            m_SurfaceSeries.PaletteSteps                   = 8;
            m_SurfaceSeries.ValueFormatter.FormatSpecifier = "0.00";
            m_SurfaceSeries.FillStyle   = new NColorFillStyle(Color.YellowGreen);
            m_SurfaceSeries.ShadingMode = ShadingMode.Smooth;
            m_SurfaceSeries.FrameMode   = SurfaceFrameMode.None;
            m_SurfaceSeries.FillMode    = SurfaceFillMode.ZoneTexture;

            // add the cross section line series
            m_CrossSection3DSeries = new NPointSeries();
            surfaceChart.Series.Add(m_CrossSection3DSeries);
            m_CrossSection3DSeries.Size                   = new NLength(10);
            m_CrossSection3DSeries.PointShape             = PointShape.Sphere;
            m_CrossSection3DSeries.FillStyle              = new NColorFillStyle(Color.Red);
            m_CrossSection3DSeries.DataLabelStyle.Visible = false;
            m_CrossSection3DSeries.UseXValues             = true;
            m_CrossSection3DSeries.UseZValues             = true;

            FillData(m_SurfaceSeries);

            NCartesianChart crossSectionChart = new NCartesianChart();

            crossSectionChart.BoundsMode = BoundsMode.Stretch;
            crossSectionChart.DockMode   = PanelDockMode.Fill;
            crossSectionChart.Margins    = new NMarginsL(0, 10, 0, 0);

            crossSectionChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator            = new NLinearScaleConfigurator();
            crossSectionChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator.Title.Text = "Distance";
            crossSectionChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator.Title.Text = "Value";

            m_CrossSection2DSeries = new NLineSeries();
            m_CrossSection2DSeries.DataLabelStyle.Visible = false;
            m_CrossSection2DSeries.UseXValues             = true;
            crossSectionChart.Series.Add(m_CrossSection2DSeries);

            containerPanel.ChildPanels.Add(crossSectionChart);

            nChartControl1.View.RecalcLayout();

            NRange1DD xAxisRange = surfaceChart.Axis(StandardAxis.PrimaryX).Scale.RulerRange;
            NRange1DD yAxisRange = surfaceChart.Axis(StandardAxis.PrimaryY).Scale.RulerRange;
            NRange1DD zAxisRange = surfaceChart.Axis(StandardAxis.Depth).Scale.RulerRange;

            m_DragPlane = new NDragPlane(
                new NVector3DD(0, yAxisRange.End, 0),
                new NVector3DD(xAxisRange.End, yAxisRange.End, zAxisRange.End),
                new NVector3DD(xAxisRange.End, 0, zAxisRange.End),
                new NVector3DD(0, 0, 0)
                );

            m_DragPlane.DragPlaneChanged += new EventHandler(OnDragPlaneChanged);
            m_DragPlaneTool           = new NDragPlaneTool(m_DragPlane);
            m_DragPlaneTool.DragPlane = DragPlaneSurface.XZ;
            m_DragPlane.AddToChart(surfaceChart);

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

            // enable fixed axis ranges
            surfaceChart.Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(xAxisRange, true, true);
            surfaceChart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(yAxisRange, true, true);
            surfaceChart.Axis(StandardAxis.Depth).View    = new NRangeAxisView(zAxisRange, true, true);

            // turn off plot box clipping
            surfaceChart.Axis(StandardAxis.PrimaryX).ClipMode = AxisClipMode.Never;
            surfaceChart.Axis(StandardAxis.PrimaryY).ClipMode = AxisClipMode.Never;
            surfaceChart.Axis(StandardAxis.Depth).ClipMode    = AxisClipMode.Never;

            // update the cross section
            OnDragPlaneChanged(null, null);
        }
예제 #2
0
 /// <summary>
 /// Initializer constructor
 /// </summary>
 /// <param name="dragPlane"></param>
 public NDragPlaneTool(NDragPlane dragPlane)
 {
     m_DragPlane        = dragPlane;
     m_OriginalPosition = new NVector3DD();
 }