/// <summary> /// Gets the symbol size for the index idx. /// </summary> /// <param name="idx"></param> /// <returns></returns> private double GetSymbolSize(int idx) { var dataColumn = DataColumn; if (null != dataColumn) { var val = _scale.PhysicalToNormal(dataColumn[idx]); if (val >= 0 && val <= 1) { if (_numberOfSteps > 0) { val = val < 1 ? (Math.Floor(val * _numberOfSteps) + 0.5) / _numberOfSteps : (_numberOfSteps - 0.5) / _numberOfSteps; } return(_symbolSizeAt0 + val * (_symbolSizeAt1 - _symbolSizeAt0)); } else if (val < 0) { return(_symbolSizeBelow); } else if (val > 1) { return(_symbolSizeAbove); } else { return(_symbolSizeInvalid); } } else { return(_symbolSizeInvalid); } }
/// <summary> /// Gets the color for the index idx. /// </summary> /// <param name="idx">Index into the row of the data column.</param> /// <returns>The calculated color for the provided index.</returns> private Color GetColor(int idx) { var dataColumn = DataColumn; if (null != dataColumn) { return(_colorProvider.GetColor(_scale.PhysicalToNormal(dataColumn[idx]))); } else { return(_colorProvider.GetColor(double.NaN)); } }
/// <summary> /// This will create a point list out of the data, which can be used to plot the data. In order to create this list, /// the function must have knowledge how to calculate the points out of the data. This will be done /// by a function provided by the calling function. /// </summary> /// <param name="layer">The plot layer.</param> /// <returns>An array of plot points in layer coordinates.</returns> public Processed2DPlotData GetRangesAndPoints( Gdi.IPlotArea layer) { const int functionPoints = 1000; const double MaxRelativeValue = 1E6; // allocate an array PointF to hold the line points PointF[] ptArray = new PointF[functionPoints]; Processed2DPlotData result = new Processed2DPlotData(); MyPlotData pdata = new MyPlotData(); result.PlotPointsInAbsoluteLayerCoordinates = ptArray; double[] xPhysArray = new double[functionPoints]; double[] yPhysArray = new double[functionPoints]; pdata._xPhysical = xPhysArray; pdata._yPhysical = yPhysArray; result.XPhysicalAccessor = new IndexedPhysicalValueAccessor(pdata.GetXPhysical); result.YPhysicalAccessor = new IndexedPhysicalValueAccessor(pdata.GetYPhysical); // double xorg = layer.XAxis.Org; // double xend = layer.XAxis.End; // Fill the array with values // only the points where x and y are not NaNs are plotted! int i, j; bool bInPlotSpace = true; int rangeStart = 0; PlotRangeList rangeList = new PlotRangeList(); result.RangeList = rangeList; Gdi.G2DCoordinateSystem coordsys = layer.CoordinateSystem; NumericalScale xaxis = layer.XAxis as NumericalScale; NumericalScale yaxis = layer.YAxis as NumericalScale; if (xaxis == null || yaxis == null) { return(null); } for (i = 0, j = 0; i < functionPoints; i++) { double x_rel = ((double)i) / (functionPoints - 1); double x = xaxis.NormalToPhysical(x_rel); double y = Evaluate(x); if (Double.IsNaN(x) || Double.IsNaN(y)) { if (!bInPlotSpace) { bInPlotSpace = true; rangeList.Add(new PlotRange(rangeStart, j)); } continue; } // double x_rel = layer.XAxis.PhysicalToNormal(x); double y_rel = yaxis.PhysicalToNormal(y); // chop relative values to an range of about -+ 10^6 if (y_rel > MaxRelativeValue) { y_rel = MaxRelativeValue; } if (y_rel < -MaxRelativeValue) { y_rel = -MaxRelativeValue; } // after the conversion to relative coordinates it is possible // that with the choosen axis the point is undefined // (for instance negative values on a logarithmic axis) // in this case the returned value is NaN double xcoord, ycoord; if (coordsys.LogicalToLayerCoordinates(new Logical3D(x_rel, y_rel), out xcoord, out ycoord)) { if (bInPlotSpace) { bInPlotSpace = false; rangeStart = j; } xPhysArray[j] = x; yPhysArray[j] = y; ptArray[j].X = (float)xcoord; ptArray[j].Y = (float)ycoord; j++; } else { if (!bInPlotSpace) { bInPlotSpace = true; rangeList.Add(new PlotRange(rangeStart, j)); } } } // end for if (!bInPlotSpace) { bInPlotSpace = true; rangeList.Add(new PlotRange(rangeStart, j)); // add the last range } return(result); }
private Color GetColor(double val) { double relval = _scale.PhysicalToNormal(val); return(_colorProvider.GetColor(relval)); }