private void GenerateSurfaceData(NMeshSurfaceSeries surface) { int nCountX = surface.Data.GridSizeX; int nCountZ = surface.Data.GridSizeZ; const double dIntervalX = 40.0; const double dIntervalZ = 40.0; double dIncrementX = (dIntervalX / nCountX); double dIncrementZ = (dIntervalZ / nCountZ); double pz = -(dIntervalZ / 2); for (int j = 0; j < nCountZ; j++, pz += dIncrementZ) { double px = -(dIntervalX / 2); for (int i = 0; i < nCountX; i++, px += dIncrementX) { double x = px + Math.Sin(pz) * 0.4; double z = pz + Math.Cos(px) * 0.4; double y = Math.Sin(px * 0.33) * Math.Sin(pz * 0.33); if (y < 0) { y = -y * 0.7; } double tmp = (1 - x * x - z * z); y -= tmp * tmp * 0.000001; surface.Data.SetValue(i, j, y, x, z); } } }
void FillData2(NMeshSurfaceSeries surface) { double y, x, z; int nCountX = surface.Data.GridSizeX; int nCountZ = surface.Data.GridSizeZ; const double dIntervalX = 20.0; const double dIntervalZ = 20.0; double dIncrementX = (dIntervalX / nCountX); double dIncrementZ = (dIntervalZ / nCountZ); z = -(dIntervalZ / 2); for (int j = 0; j < nCountZ; j++, z += dIncrementZ) { x = -(dIntervalX / 2); for (int i = 0; i < nCountX; i++, x += dIncrementX) { if ((x > 0) && (x < 10) && (z > -7) && (z < 7)) { y = 15 * Math.Abs(Math.Sin(x / 4) * Math.Cos(z / 4)); } else { y = 2 * Math.Sin(x / 2) * Math.Cos(z / 2); } surface.Data.SetValue(i, j, y, x, z); } } }
void FillData1(NMeshSurfaceSeries surface) { double y, x, z; int nCountX = surface.Data.GridSizeX; int nCountZ = surface.Data.GridSizeZ; const double dIntervalX = 20.0; const double dIntervalZ = 20.0; double dIncrementX = (dIntervalX / nCountX); double dIncrementZ = (dIntervalZ / nCountZ); z = -(dIntervalZ / 2); for (int j = 0; j < nCountZ; j++, z += dIncrementZ) { x = -(dIntervalX / 2); for (int i = 0; i < nCountX; i++, x += dIncrementX) { y = Math.Sqrt((x * x) + (z * z) + 2); y -= 0.08 * Math.Sqrt(Math.Abs(Math.Sinh(x))); if (x < 0) { y += 0.11 * x * x; } surface.Data.SetValue(i, j, y, x, z); } } }
void FillDataXY(NMeshSurfaceSeries surface) { double x, y, z; int nCountX = surface.Data.GridSizeX; int nCountZ = surface.Data.GridSizeZ; const double dIntervalX = 4.4; const double dIntervalZ = 4.4; double dIncrementX = (dIntervalX / nCountX); double dIncrementZ = (dIntervalZ / nCountZ); for (int j = 0; j < nCountZ; j++) { for (int i = 0; i < nCountX; i++) { x = -(dIntervalX / 2) + (i * dIncrementX); z = -(dIntervalZ / 2) + (j * dIncrementZ); y = 8 * Math.Cos(x * x) + 5 * Math.Sin(z * z); x += Math.Sin(j / 4.0) / 4.0; z += Math.Cos(i / 4.0) / 4.0; surface.Data.SetValue(i, j, y, x, z); } } }
private void FillModeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; switch (FillModeComboBox.SelectedIndex) { case 0: surface.FillMode = SurfaceFillMode.None; SmoothShadingCheckBox.IsEnabled = false; break; case 1: surface.FillMode = SurfaceFillMode.Uniform; SmoothShadingCheckBox.IsEnabled = true; break; case 2: surface.FillMode = SurfaceFillMode.Zone; SmoothShadingCheckBox.IsEnabled = true; break; } nChartControl1.Refresh(); }
private void FillData(NMeshSurfaceSeries surface) { int nCountX = surface.Data.GridSizeX; int nCountZ = surface.Data.GridSizeZ; double x, y, z; double dAngle = 0; double dRadius = 100.0; double dElevation = 0; for (int j = 0; j < nCountZ; j++) { for (int i = 0; i < nCountX; i++) { x = dRadius * Math.Cos(dAngle) * (1 + i); z = dRadius * Math.Sin(dAngle) * (1 + i); y = dElevation + Math.Sin(i * 0.1) + Math.Sin(i * 0.004) * 5; surface.Data.SetValue(i, j, y, x, z); } if (j < 700) { dRadius -= 0.1; } else { dRadius += 0.1; } dElevation += 0.2; dAngle += 0.008 * Math.PI; } }
private void FillData(NMeshSurfaceSeries surface) { double x, y, z; int nCountX = surface.Data.GridSizeX; int nCountZ = surface.Data.GridSizeZ; const double dIntervalX = 8.0; const double dIntervalZ = 8.0; double dIncrementX = (dIntervalX / nCountX); double dIncrementZ = (dIntervalZ / nCountZ); for (int j = 0; j < nCountZ; j++) { for (int i = 0; i < nCountX; i++) { x = -(dIntervalX / 2) + (i * dIncrementX); z = -(dIntervalZ / 2) + (j * dIncrementZ); y = Math.Log(Math.Abs(x) * Math.Abs(z)); x += Math.Sin(j / 2.0) / 2.2; z += Math.Cos(i / 2.0) / 2.2; if (y > -7) { surface.Data.SetValue(i, j, y, x, z); } else { surface.Data.SetValue(i, j, DBNull.Value, DBNull.Value, DBNull.Value); } } } }
private void FillModeCombo_SelectedIndexChanged(object sender, System.EventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; switch (fillModeCombo.SelectedIndex) { case 0: surface.FillMode = SurfaceFillMode.None; smoothShadingCheck.Enabled = false; break; case 1: surface.FillMode = SurfaceFillMode.Uniform; smoothShadingCheck.Enabled = true; break; case 2: surface.FillMode = SurfaceFillMode.Zone; smoothShadingCheck.Enabled = true; break; case 3: surface.FillMode = SurfaceFillMode.ZoneTexture; smoothShadingCheck.Enabled = true; break; } nChartControl1.Refresh(); }
private void UpdateSurface() { NMeshSurfaceSeries surface = (NMeshSurfaceSeries)nChartControl1.Charts[0].Series[0]; switch (paletteModeCombo.SelectedIndex) { case 0: surface.AutomaticPalette = true; surface.SyncPaletteWithAxisScale = false; paletteStepsCombo.Enabled = true; break; case 1: surface.AutomaticPalette = true; surface.SyncPaletteWithAxisScale = true; paletteStepsCombo.Enabled = false; break; case 2: surface.AutomaticPalette = false; paletteStepsCombo.Enabled = false; break; } if (smoothPaletteCheck.Checked) { surface.SmoothPalette = true; surface.PaletteSteps = paletteStepsCombo.SelectedIndex + 1; } else { surface.SmoothPalette = false; surface.PaletteSteps = paletteStepsCombo.SelectedIndex + 2; } }
private void CustomValueScrollBar_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs <double> e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; surface.PositionValue = CustomValueScrollBar.Value * 20.0f; nChartControl1.Refresh(); }
private void PositionModeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; surface.PositionMode = (SurfacePositionMode)PositionModeComboBox.SelectedIndex; nChartControl1.Refresh(); }
private void CustomValueScroll_ValueChanged(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; surface.PositionValue = customValueScroll.Value / 20.0f; nChartControl1.Refresh(); }
public override void Initialize() { base.Initialize(); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.None; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Mesh Surface With Empty Data Points"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 25.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); // setup axes NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale = new NLinearScaleConfigurator(); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale; // setup surface series NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series.Add(SeriesType.MeshSurface); surface.Name = "Surface"; surface.Legend.Mode = SeriesLegendMode.SeriesLogic; surface.FillMode = SurfaceFillMode.Zone; surface.PositionValue = 0.5; surface.Data.SetGridSize(20, 20); surface.SyncPaletteWithAxisScale = false; surface.PaletteSteps = 8; surface.ValueFormatter.FormatSpecifier = "0.00"; FillData(surface); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); smoothShadingCheck.Checked = true; }
private void FrameModeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; surface.FrameMode = (SurfaceFrameMode)FrameModeComboBox.SelectedIndex; nChartControl1.Refresh(); // form controls FrameColorModeComboBox.IsEnabled = (surface.FrameMode != SurfaceFrameMode.None); }
private void FrameModeCombo_SelectedIndexChanged(object sender, System.EventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; surface.FrameMode = (SurfaceFrameMode)frameModeCombo.SelectedIndex; nChartControl1.Refresh(); // form controls frameColorModeCombo.Enabled = (surface.FrameMode != SurfaceFrameMode.None); }
private void DrawFlatCheck_CheckedChanged(object sender, System.EventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; surface.DrawFlat = drawFlatCheck.Checked; nChartControl1.Refresh(); // form controls positionModeCombo.Enabled = drawFlatCheck.Checked; customValueScroll.Enabled = drawFlatCheck.Checked; }
private void DrawFlatCheckBox_Checked(object sender, System.Windows.RoutedEventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; surface.DrawFlat = (bool)DrawFlatCheckBox.IsChecked; // form controls PositionModeComboBox.IsEnabled = (bool)DrawFlatCheckBox.IsChecked; CustomValueScrollBar.IsEnabled = (bool)DrawFlatCheckBox.IsChecked; nChartControl1.Refresh(); }
private void FillStyleButton_Click(object sender, System.EventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; NFillStyle fillStyleResult; if (NFillStyleTypeEditor.Edit(surface.FillStyle, out fillStyleResult)) { surface.FillStyle = fillStyleResult; nChartControl1.Refresh(); } }
private void SmoothShadingCheckBox_Checked(object sender, System.Windows.RoutedEventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; if ((bool)SmoothShadingCheckBox.IsChecked) { surface.ShadingMode = ShadingMode.Smooth; } else { surface.ShadingMode = ShadingMode.Flat; } nChartControl1.Refresh(); }
private void FillData(NMeshSurfaceSeries surface, DataTable dt) { int rowcount = 0; //surface.Data.Clear(); foreach (DataRow dr in dt.Rows) { for (int t = 0; t < dt.Columns.Count; t++) { double value = Convert.ToInt32(dr[t]); surface.Data.SetValue(rowcount, t, value, rowcount, t); } rowcount++; } }
private void SmoothShadingCheck_CheckedChanged(object sender, System.EventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; if (smoothShadingCheck.Checked) { surface.ShadingMode = ShadingMode.Smooth; } else { surface.ShadingMode = ShadingMode.Flat; } nChartControl1.Refresh(); }
/// <summary> /// Initializer constructor /// </summary> /// <param name="vecA"></param> /// <param name="vecB"></param> /// <param name="vecC"></param> /// <param name="vecD"></param> public NDragPlane(NVector3DD vecA, NVector3DD vecB, NVector3DD vecC, NVector3DD vecD) { NPointSeries pointSeries = new NPointSeries(); pointSeries.Tag = (int)1; pointSeries.PointShape = PointShape.Sphere; pointSeries.UseXValues = true; pointSeries.UseZValues = true; pointSeries.DataLabelStyle.Visible = false; pointSeries.InflateMargins = false; pointSeries.Size = new NLength(8); pointSeries.Values.Add(vecA.Y); pointSeries.XValues.Add(vecA.X); pointSeries.ZValues.Add(vecA.Z); pointSeries.FillStyles[0] = new NColorFillStyle(Color.Red); pointSeries.Values.Add(vecB.Y); pointSeries.XValues.Add(vecB.X); pointSeries.ZValues.Add(vecB.Z); pointSeries.FillStyles[1] = new NColorFillStyle(Color.Blue); pointSeries.Values.Add(vecC.Y); pointSeries.XValues.Add(vecC.X); pointSeries.ZValues.Add(vecC.Z); pointSeries.FillStyles[2] = new NColorFillStyle(Color.Blue); pointSeries.Values.Add(vecD.Y); pointSeries.XValues.Add(vecD.X); pointSeries.ZValues.Add(vecD.Z); pointSeries.FillStyles[3] = new NColorFillStyle(Color.Red); m_PointSeries = pointSeries; NMeshSurfaceSeries meshSeries = new NMeshSurfaceSeries(); meshSeries.Data.SetGridSize(2, 2); m_MeshSurface = meshSeries; m_MeshSurface.FillMode = SurfaceFillMode.Uniform; m_MeshSurface.FrameMode = SurfaceFrameMode.None; m_MeshSurface.FillStyle = new NColorFillStyle(Color.Blue); m_MeshSurface.FillStyle.SetTransparencyPercent(50.0f); UpdateMeshSurface(); }
private void FrameColorModeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; switch (FrameColorModeComboBox.SelectedIndex) { case 0: surface.FrameColorMode = SurfaceFrameColorMode.Uniform; break; case 1: surface.FrameColorMode = SurfaceFrameColorMode.Zone; break; } nChartControl1.Refresh(); }
private void SmoothPaletteCheckBox_Checked(object sender, System.Windows.RoutedEventArgs e) { NChart chart = nChartControl1.Charts[0]; NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series[0]; if ((bool)SmoothPaletteCheckBox.IsChecked) { surface.SmoothPalette = true; surface.PaletteSteps = 7; surface.Legend.Format = "<zone_value>"; } else { surface.SmoothPalette = false; surface.PaletteSteps = 8; surface.Legend.Format = "<zone_begin> - <zone_end>"; } nChartControl1.Refresh(); }
private void FillData(NMeshSurfaceSeries surface) { double x, y, z; int nCountX = surface.Data.GridSizeX; int nCountZ = surface.Data.GridSizeZ; for (int j = 0; j < nCountZ; j++) { for (int i = 0; i < nCountX; i++) { x = 2 + i + Math.Sin(j / 4.0) * 2; z = 1 + j + Math.Cos(i / 4.0); y = Math.Sin(i / 3.0) * Math.Sin(j / 3.0); if (y < 0) { y = Math.Abs(y / 2.0); } surface.Data.SetValue(i, j, y, x, z); } } }
void FillData(NMeshSurfaceSeries surface) { int m = 200; int n = 100; int lastM = m - 1; int lastN = n - 1; double centerX = 0; double centerZ = 0; double centerY = 0; double radius1 = 100.0; double radius2 = 10.0; double beginAlpha = 0; double endAlpha = NMath.PI2; double alphaStep = 2 * NMath.PI2 / m; double beginBeta = 0; double endBeta = NMath.PI2; double betaStep = NMath.PI2 / n; NVector2DD[] arrPrecomputedData = new NVector2DD[m]; for (int i = 0; i < m; i++) { // calculate the current angle, its cos and sin double alpha = (i == lastM) ? (endAlpha) : (beginAlpha + i * alphaStep); arrPrecomputedData[i].X = Math.Cos(alpha); arrPrecomputedData[i].Y = Math.Sin(alpha); } int vertexIndex = 0; surface.Data.SetGridSize(m, n); Color beginColor = Color.Red; Color endColor = Color.Blue; float offset = -100; for (int j = 0; j < n; j++) { // calculate the current beta angle double beta = (j == lastN) ? (endBeta) : (beginBeta + j * betaStep); double fCosBeta = (float)Math.Cos(beta); double fSinBeta = (float)Math.Sin(beta); offset = -100; for (int i = 0; i < m; i++) { double fCosAlpha = arrPrecomputedData[i].X; double fSinAlpha = arrPrecomputedData[i].Y; double fx = fCosBeta * radius2 + radius1; double dx = fx * fCosAlpha; double dz = fx * fSinAlpha; double dy = -(fSinBeta * radius2); double x = centerX + dx; double y = centerY + dy + offset; double z = centerZ + dz; offset++; surface.Data.SetValue(i, j, y, x, z); double length = Math.Sqrt(dx * dx + dz * dz + dy * dy); surface.Data.SetColor(i, j, InterpolateColors(beginColor, endColor, (float)i / (float)100)); //(length - (radius1 - radius2)) / radius2)); vertexIndex++; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.HighSpeed; 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("Mesh Surface With Custom Colors"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // no legend nChartControl1.Legends.Clear(); // configure the chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 55.0f; chart.Depth = 55.0f; chart.Height = 55.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(new NRange1DD(-120, 120), true, true); chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(-120, 120), true, true); chart.Axis(StandardAxis.Depth).View = new NRangeAxisView(new NRange1DD(-120, 120), true, true); // setup axes NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale = new NLinearScaleConfigurator(); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale; // setup surface NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series.Add(SeriesType.MeshSurface); surface.Name = "Surface"; surface.FrameMode = SurfaceFrameMode.None; surface.FillMode = SurfaceFillMode.CustomColors; surface.ShadingMode = ShadingMode.Smooth; surface.Data.UseColors = true; surface.Data.SetGridSize(50, 50); FillData(surface); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); chart.LightModel.EnableLighting = false; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights); } }
private void FillDataCompare(NMeshSurfaceSeries surface) { DataTable dt = (DataTable)gridControl1.DataSource; int rowcount = dt.Rows.Count; int colcount = dt.Columns.Count; for (int row = 0; row < rowcount; row++) { for (int col = colcount - 1; col >= 0; col--) { if (m_issixteenbit) { int indexinmap = ((row * colcount) + col) * 2; Int32 ivalue = Convert.ToInt32(m_map_compare_content[indexinmap]) * 256; ivalue += Convert.ToInt32(m_map_compare_content[indexinmap + 1]); //Int32 diffivalue = Convert.ToInt32(m_map_content[indexinmap]) * 256; //diffivalue += Convert.ToInt32(m_map_content[indexinmap + 1]); //if (diffivalue != 0) { if (ivalue > 32000) { ivalue = 65536 - ivalue; ivalue = -ivalue; } double value = ivalue; if (m_viewtype != SuiteViewType.Decimal && m_viewtype != SuiteViewType.Hexadecimal && m_viewtype != SuiteViewType.ASCII) { value *= correction_factor; value += correction_offset; } surface.Data.SetValue((rowcount - 1) - row, col, value, (rowcount - 1) - row, col); } //logger.Debug(surface.Name + ": " + row.ToString() + " " + col.ToString() + " value: " + value.ToString()); } else { int indexinmap = ((row * colcount) + col); Int32 ivalue = Convert.ToInt32(m_map_compare_content[indexinmap]); //Int32 diffivalue = Convert.ToInt32(m_map_content[indexinmap]); //if (diffivalue != 0) { double value = ivalue; if (m_viewtype != SuiteViewType.Decimal && m_viewtype != SuiteViewType.Hexadecimal && m_viewtype != SuiteViewType.ASCII) { value *= correction_factor; value += correction_offset; } surface.Data.SetValue((rowcount - 1) - row, col, value, (rowcount - 1) - row, col); } } } } }
private void FillDataOriginal(NMeshSurfaceSeries surface) { DataTable dt = (DataTable)gridControl1.DataSource; int rowcount = dt.Rows.Count; int colcount = dt.Columns.Count; for (int row = 0; row < rowcount; row++) { for (int col = 0; col < colcount; col++) { try { if (m_issixteenbit) { int indexinmap = ((row * colcount) + col) * 2; Int32 ivalue = Convert.ToInt32(m_map_original_content[indexinmap]) * 256; ivalue += Convert.ToInt32(m_map_original_content[indexinmap + 1]); //Int32 diffivalue = Convert.ToInt32(m_map_content[indexinmap]) * 256; //diffivalue += Convert.ToInt32(m_map_content[indexinmap + 1]); //if (diffivalue != 0) { if (ivalue > 32000) { ivalue = 65536 - ivalue; ivalue = -ivalue; } double value = ivalue; if (m_viewtype != SuiteViewType.Decimal && m_viewtype != SuiteViewType.Hexadecimal && m_viewtype != SuiteViewType.ASCII) { value *= correction_factor; value += correction_offset; // bij origineel wel doen } surface.Data.SetValue((rowcount - 1) - row, col, value, (rowcount - 1) - row, col); } //logger.Debug(surface.Name + ": " + row.ToString() + " " + col.ToString() + " value: " + value.ToString()); } else { int indexinmap = ((row * colcount) + col); Int32 ivalue = Convert.ToInt32(m_map_original_content[indexinmap]); //Int32 diffivalue = Convert.ToInt32(m_map_content[indexinmap]); //if (diffivalue != 0) { double value = ivalue; if (m_viewtype != SuiteViewType.Decimal && m_viewtype != SuiteViewType.Hexadecimal && m_viewtype != SuiteViewType.ASCII) { value *= correction_factor; value += correction_offset; } surface.Data.SetValue((rowcount - 1) - row, col, value, (rowcount - 1) - row, col); } //logger.Debug(surface.Name + ": " + row.ToString() + " " + col.ToString() + " value: " + value.ToString()); } } catch (Exception E) { logger.Debug("Failed to fill data for original map: " + E.Message); } } } }
private void FillData(NMeshSurfaceSeries surface) { DataTable dt = (DataTable)gridControl1.DataSource; int rowcount = 0; //surface.Data.Clear(); foreach (DataRow dr in dt.Rows) { for (int t = 0; t < dt.Columns.Count; t++) { double value = Convert.ToInt32(dr[t]); if (m_viewtype != SuiteViewType.Decimal && m_viewtype != SuiteViewType.Hexadecimal && m_viewtype != SuiteViewType.ASCII) { value *= correction_factor; if (!_isCompareViewer) value += correction_offset; } surface.Data.SetValue(rowcount, t, value, /*y_axisvalues.GetValue(rowcount)*/ rowcount, /*x_axisvalues.GetValue(t)*/ t); } rowcount++; } /*if (m_issixteenbit) { for (int tel = 0; tel < m_map_content.Length; tel+=2) { } } else { for (int tel = 0; tel < m_map_content.Length; tel++) { int _y = tel / m_TableWidth; int _x = tel % m_TableWidth; surface.Data.SetValue(_x, _y, Convert.ToInt32(m_map_content[tel])); } }*/ }
private void FillData(NMeshSurfaceSeries surface) { try { DataTable dt = (DataTable)gridControl1.DataSource; int rowcount = 0; now_realMaxValue = double.MinValue; now_realMinValue = double.MaxValue; //surface.Data.Clear(); foreach (DataRow dr in dt.Rows) { for (int t = 0; t < dt.Columns.Count; t++) { double value = 0; if (m_viewtype == ViewType.Easy || m_viewtype == ViewType.Decimal) { value = Convert.ToInt32(dr[t]); } else if (m_viewtype == ViewType.Hexadecimal) { value = Convert.ToInt32(dr[t].ToString(), 16); } if (m_viewtype != ViewType.Decimal && m_viewtype != ViewType.Hexadecimal && m_viewtype != ViewType.ASCII) { value *= correction_factor; if (!_isCompareViewer) value += correction_offset; } surface.Data.SetValue(rowcount, t, value, /*y_axisvalues.GetValue(rowcount)*/ rowcount, /*x_axisvalues.GetValue(t)*/ t); if (value > now_realMaxValue) now_realMaxValue = value; if (value < now_realMinValue) now_realMinValue = value; } rowcount++; } if (now_realMaxValue != double.MinValue) { surface.Palette.Clear(); double diff = now_realMaxValue - now_realMinValue; if (m_OnlineMode) { surface.Palette.Add(now_realMinValue, Color.Wheat); surface.Palette.Add(now_realMinValue + 0.25 * diff, Color.LightBlue); surface.Palette.Add(now_realMinValue + 0.50 * diff, Color.SteelBlue); surface.Palette.Add(now_realMinValue + 0.75 * diff, Color.Blue); surface.Palette.Add(now_realMinValue + diff, Color.DarkBlue); } else { surface.Palette.Add(now_realMinValue, Color.Green); surface.Palette.Add(now_realMinValue + 0.25 * diff, Color.Yellow); surface.Palette.Add(now_realMinValue + 0.50 * diff, Color.Orange); surface.Palette.Add(now_realMinValue + 0.75 * diff, Color.OrangeRed); surface.Palette.Add(now_realMinValue + diff, Color.Red); } surface.PaletteSteps = 4; surface.AutomaticPalette = false; } /*if (m_issixteenbit) { for (int tel = 0; tel < m_map_content.Length; tel+=2) { } } else { for (int tel = 0; tel < m_map_content.Length; tel++) { int _y = tel / m_TableWidth; int _x = tel % m_TableWidth; surface.Data.SetValue(_x, _y, Convert.ToInt32(m_map_content[tel])); } }*/ } catch (Exception E) { Console.WriteLine("FillData: " + E.Message); } }
public override void Initialize() { base.Initialize(); nChartControl1.Settings.RenderSurface = RenderSurface.Window; nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.None; 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("Mesh Surface"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 25.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); // setup axes NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale = new NLinearScaleConfigurator(); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale; // setup surface series NMeshSurfaceSeries surface = new NMeshSurfaceSeries(); chart.Series.Add(surface); surface.ShadingMode = ShadingMode.Smooth; surface.FillMode = SurfaceFillMode.ZoneTexture; surface.FrameMode = SurfaceFrameMode.None; surface.Data.SetGridSize(100, 100); // define a custom palette surface.Palette.Clear(); surface.Palette.Add(-0.8, DarkOrange); surface.Palette.Add(-0.4, LightOrange); surface.Palette.Add(-0.2, LightGreen); surface.Palette.Add(0, Turqoise); surface.Palette.Add(0.4, Blue); surface.Palette.Add(0.8, Purple); surface.Palette.Add(1, BeautifulRed); // generate data GenerateSurfaceData(surface); // apply layout ConfigureStandardLayout(chart, title, null); // form controls paletteModeCombo.SelectedIndex = 0; paletteStepsCombo.SelectedIndex = 6; smoothPaletteCheck.Checked = false; }
private void BuildNewNChart(byte[] m_map_content) { try { DataTable dt = (DataTable)gridControl1.DataSource; nChartControl1 = new NChartControl(); nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.HighSpeed; nChartControl1.Controller.Tools.Add(new NSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); nChartControl1.MouseWheel += new MouseEventHandler(nChartControl1_MouseWheel); nChartControl1.MouseDown += new MouseEventHandler(nChartControl1_MouseDown); nChartControl1.MouseUp += new MouseEventHandler(nChartControl1_MouseUp); nChartControl1.Dock = DockStyle.Fill; xtraTabPage2.Controls.Add(nChartControl1); //nChartControl1.Charts.Clear(); NChart chart = nChartControl1.Charts[0]; nChartControl1.Legends.Clear(); chart.Enable3D = true; chart.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 35.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleConfiguratorX.MaxTickCount = dt.Rows.Count; scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount; //scaleConfiguratorX.AutoLabels = true; NScaleTitleStyle titleStyleX = (NScaleTitleStyle)scaleConfiguratorX.Title; titleStyleX.Text = Y_axis_name; //<GS-08032010> as waarden nog omzetten indien noodzakelijk (MAP etc) scaleConfiguratorX.AutoLabels = false; scaleConfiguratorX.Labels.Clear(); for (int t = y_axisvalues.Length - 1; t >= 0; t--) { string yvalue = y_axisvalues.GetValue(t).ToString(); //if (Y_axis_name == "MAP" || Y_axis_name == "Pressure error (bar)") { try { float v = (float)Convert.ToDouble(yvalue); yvalue = v.ToString("F2"); } catch (Exception cE) { logger.Debug(cE.Message); } } scaleConfiguratorX.Labels.Add(yvalue); } NStandardScaleConfigurator scaleConfiguratorY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator; scaleConfiguratorY.MajorTickMode = MajorTickMode.AutoMaxCount; scaleConfiguratorY.MaxTickCount = dt.Columns.Count; //scaleConfiguratorY.AutoLabels = true; NScaleTitleStyle titleStyleY = (NScaleTitleStyle)scaleConfiguratorY.Title; titleStyleY.Text = X_axis_name; scaleConfiguratorY.AutoLabels = false; scaleConfiguratorY.Labels.Clear(); for (int t = 0; t < x_axisvalues.Length; t++) { string xvalue = x_axisvalues.GetValue(t).ToString(); //if (X_axis_name == "MAP" || X_axis_name == "Pressure error (bar)") { try { float v = (float)Convert.ToDouble(xvalue); xvalue = v.ToString("F2"); } catch (Exception cE) { logger.Debug(cE.Message); } } scaleConfiguratorY.Labels.Add(xvalue); } NStandardScaleConfigurator scaleConfiguratorZ = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleConfiguratorZ.MajorTickMode = MajorTickMode.AutoMaxCount; NScaleTitleStyle titleStyleZ = (NScaleTitleStyle)scaleConfiguratorZ.Title; titleStyleZ.Text = Z_axis_name; scaleConfiguratorZ.AutoLabels = true; chart.Wall(ChartWallType.Back).Visible = false; chart.Wall(ChartWallType.Left).Visible = false; chart.Wall(ChartWallType.Right).Visible = false; chart.Wall(ChartWallType.Floor).Visible = false; NMeshSurfaceSeries surface = null; chart.Series.Clear(); if (chart.Series.Count == 0) { surface = (NMeshSurfaceSeries)chart.Series.Add(SeriesType.MeshSurface); } else { surface = (NMeshSurfaceSeries)chart.Series[0]; } surface.Name = "Surface"; surface.PositionValue = 10.0; surface.Palette.Clear(); surface.Data.SetGridSize(dt.Columns.Count, dt.Rows.Count); surface.ValueFormatter.FormatSpecifier = "0.00"; surface.FillMode = SurfaceFillMode.Zone; // <GS-08032010> surface.SmoothPalette = true; surface.FrameColorMode = SurfaceFrameColorMode.Uniform; surface.FillStyle.SetTransparencyPercent(25); surface.FrameMode = SurfaceFrameMode.MeshContour; double diff = m_realMaxValue - m_realMinValue; surface.Palette.Add(m_realMinValue, Color.Green); surface.Palette.Add(m_realMinValue + 0.25 * diff, Color.Yellow); surface.Palette.Add(m_realMinValue + 0.50 * diff, Color.Orange); surface.Palette.Add(m_realMinValue + 0.75 * diff, Color.OrangeRed); surface.Palette.Add(m_realMinValue + diff, Color.Red); surface.PaletteSteps = 4; surface.AutomaticPalette = false; FillData(surface, dt); // hier nChartControl1.Refresh(); } catch (Exception E) { logger.Debug("Failed to refresh mesh chart: " + E.Message); } }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Surface Fill Styles"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend nChartControl1.Legends.Clear(); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 70.0f; chart.Depth = 70.0f; chart.Height = 30.0f; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); if (!IsPostBack) { RotationTextBox.Text = chart.Projection.Rotation.ToString(); ElevationTextBox.Text = chart.Projection.Elevation.ToString(); } else { chart.Projection.Rotation = (float)Convert.ToDouble(RotationTextBox.Text); chart.Projection.Elevation = (float)Convert.ToDouble(ElevationTextBox.Text); } // setup Y axis NLinearScaleConfigurator linearScaleConfigurator = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScaleConfigurator.StripStyles.Add(stripStyle); // setup X axis linearScaleConfigurator = new NLinearScaleConfigurator(); linearScaleConfigurator.RoundToTickMin = false; linearScaleConfigurator.RoundToTickMax = false; linearScaleConfigurator.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Floor, ChartWallType.Back }; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScaleConfigurator; // setup Z axis linearScaleConfigurator = new NLinearScaleConfigurator(); linearScaleConfigurator.RoundToTickMin = false; linearScaleConfigurator.RoundToTickMax = false; linearScaleConfigurator.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Floor, ChartWallType.Left }; chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScaleConfigurator; // setup mesh surface series NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series.Add(SeriesType.MeshSurface); surface.Name = "Surface"; surface.FrameMode = SurfaceFrameMode.None; surface.FillMode = SurfaceFillMode.Uniform; surface.AutomaticPalette = false; surface.Data.SetGridSize(50, 50); surface.ShadingMode = ShadingMode.Smooth; switch (SurfaceFillEffectDropDownList.SelectedIndex) { case 0: // Color surface.FillStyle = new NColorFillStyle(Red); break; case 1: // Gradient surface.FillStyle = new NGradientFillStyle(GradientStyle.FromCenter, GradientVariant.Variant1, Color.White, DarkOrange); break; case 2: // Image surface.FillStyle = new NImageFillStyle(this.MapPathSecure(this.TemplateSourceDirectory + "\\SurfaceTexture.jpg")); break; case 3: // Pattern surface.FillStyle = new NHatchFillStyle(HatchStyle.HorizontalBrick, Color.White, DarkOrange); break; case 4: surface.FillStyle = new NAdvancedGradientFillStyle(AdvancedGradientScheme.Fire1, 12); break; } FillDataXY(surface); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }