protected void PaintXErrorBars(System.Drawing.Graphics g, IPlotArea layer, Altaxo.Graph.Gdi.Plot.Data.Processed2DPlotData pdata) { // Plot error bars for the independent variable (x) PlotRangeList rangeList = pdata.RangeList; PointF[] ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates; INumericColumn posErrCol = _positiveErrorColumn.Document; INumericColumn negErrCol = _negativeErrorColumn.Document; if (posErrCol == null && negErrCol == null) return; // nothing to do if both error columns are null System.Drawing.Drawing2D.GraphicsPath errorBarPath = new System.Drawing.Drawing2D.GraphicsPath(); Region oldClippingRegion = g.Clip; Region newClip = (Region)oldClippingRegion.Clone(); foreach (PlotRange r in rangeList) { int lower = r.LowerBound; int upper = r.UpperBound; int offset = r.OffsetToOriginal; for (int j = lower; j < upper; j++) { AltaxoVariant x = pdata.GetXPhysical(j + offset); Logical3D lm = layer.GetLogical3D(pdata, j + offset); lm.RX += _cachedLogicalShiftOfIndependent; if (lm.IsNaN) continue; Logical3D lh = lm; Logical3D ll = lm; bool lhvalid = false; bool llvalid = false; if (posErrCol != null) { lh.RX = layer.XAxis.PhysicalVariantToNormal(x + Math.Abs(posErrCol[j + offset])); lhvalid = !lh.IsNaN; } if (negErrCol != null) { ll.RX = layer.XAxis.PhysicalVariantToNormal(x - Math.Abs(negErrCol[j + offset])); llvalid = !ll.IsNaN; } if (!(lhvalid || llvalid)) continue; // nothing to do for this point if both pos and neg logical point are invalid. // now paint the error bar if (_symbolGap) // if symbol gap, then clip the painting, exclude a rectangle of size symbolSize x symbolSize { double xlm, ylm; layer.CoordinateSystem.LogicalToLayerCoordinates(lm, out xlm, out ylm); newClip.Union(oldClippingRegion); newClip.Exclude(new RectangleF((float)(xlm - _symbolSize / 2), (float)(ylm - _symbolSize / 2), _symbolSize, _symbolSize)); g.Clip = newClip; } if (lhvalid && llvalid) { errorBarPath.Reset(); layer.CoordinateSystem.GetIsoline(errorBarPath, ll, lm); layer.CoordinateSystem.GetIsoline(errorBarPath, lm, lh); g.DrawPath(_strokePen, errorBarPath); } else if (llvalid) { layer.CoordinateSystem.DrawIsoline(g, _strokePen, ll, lm); } else if (lhvalid) { layer.CoordinateSystem.DrawIsoline(g, _strokePen, lm, lh); } // now the end bars if (_showEndBars) { if (lhvalid) { PointF outDir; layer.CoordinateSystem.GetNormalizedDirection(lm, lh, 1, new Logical3D(0, 1), out outDir); outDir.X *= _symbolSize / 2; outDir.Y *= _symbolSize / 2; double xlay, ylay; layer.CoordinateSystem.LogicalToLayerCoordinates(lh, out xlay, out ylay); // Draw a line from x,y to g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y)); } if (llvalid) { PointF outDir; layer.CoordinateSystem.GetNormalizedDirection(lm, ll, 1, new Logical3D(0, 1), out outDir); outDir.X *= _symbolSize / 2; outDir.Y *= _symbolSize / 2; double xlay, ylay; layer.CoordinateSystem.LogicalToLayerCoordinates(ll, out xlay, out ylay); // Draw a line from x,y to g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y)); } } } } g.Clip = oldClippingRegion; }