public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData) { if (this._labelColumnProxy.Document == null) return; if (null != _attachedPlane) _attachedPlane = layer.UpdateCSPlaneID(_attachedPlane); PlotRangeList rangeList = pdata.RangeList; var ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates; Altaxo.Data.IReadableColumn labelColumn = this._labelColumnProxy.Document; bool isUsingVariableColorForLabelText = null != _cachedColorForIndexFunction && IsColorReceiver; bool isUsingVariableColorForLabelBackground = null != _cachedColorForIndexFunction && (null != _backgroundStyle && _backgroundStyle.SupportsUserDefinedMaterial && (_backgroundColorLinkage == ColorLinkage.Dependent || _backgroundColorLinkage == ColorLinkage.PreserveAlpha)); bool isUsingVariableColor = isUsingVariableColorForLabelText || isUsingVariableColorForLabelBackground; IMaterial clonedTextBrush = _material; IMaterial clonedBackBrush = null; if (isUsingVariableColorForLabelBackground) clonedBackBrush = _backgroundStyle.Material; // save the graphics stat since we have to translate the origin var gs = g.SaveGraphicsState(); double xpos = 0, ypos = 0, zpos = 0; double xpre, ypre, zpre; double xdiff, ydiff, zdiff; bool isFormatStringContainingBraces = _labelFormatString?.IndexOf('{') >= 0; var culture = System.Threading.Thread.CurrentThread.CurrentCulture; bool mustUseLogicalCoordinates = null != this._attachedPlane || 0 != _cachedLogicalShiftX || 0 != _cachedLogicalShiftY || 0 != _cachedLogicalShiftZ; for (int r = 0; r < rangeList.Count; r++) { int lower = rangeList[r].LowerBound; int upper = rangeList[r].UpperBound; int offset = rangeList[r].OffsetToOriginal; for (int j = lower; j < upper; j += _skipFrequency) { string label; if (string.IsNullOrEmpty(_labelFormatString)) { label = labelColumn[j + offset].ToString(); } else if (!isFormatStringContainingBraces) { label = labelColumn[j + offset].ToString(_labelFormatString, culture); } else { // the label format string can contain {0} for the label column item, {1} for the row index, {2} .. {4} for the x, y and z component of the data point label = string.Format(_labelFormatString, labelColumn[j + offset], j + offset, pdata.GetPhysical(0, j + offset), pdata.GetPhysical(1, j + offset), pdata.GetPhysical(2, j + offset)); } if (string.IsNullOrEmpty(label)) continue; double localSymbolSize = _symbolSize; if (null != _cachedSymbolSizeForIndexFunction) { localSymbolSize = _cachedSymbolSizeForIndexFunction(j + offset); } double localFontSize = _fontSizeOffset + _fontSizeFactor * localSymbolSize; if (!(localFontSize > 0)) continue; _font = _font.WithSize(localFontSize); // Start of preparation of brushes, if a variable color is used if (isUsingVariableColor) { var c = _cachedColorForIndexFunction(j + offset); if (isUsingVariableColorForLabelText) { clonedTextBrush = clonedTextBrush.WithColor(new NamedColor(AxoColor.FromArgb(c.A, c.R, c.G, c.B), "e")); } if (isUsingVariableColorForLabelBackground) { if (_backgroundColorLinkage == ColorLinkage.PreserveAlpha) clonedBackBrush = clonedBackBrush.WithColor(new NamedColor(AxoColor.FromArgb(clonedBackBrush.Color.Color.A, c.R, c.G, c.B), "e")); else clonedBackBrush = clonedBackBrush.WithColor(new NamedColor(AxoColor.FromArgb(c.A, c.R, c.G, c.B), "e")); } } // end of preparation of brushes for variable colors if (mustUseLogicalCoordinates) // we must use logical coordinates because either there is a shift of logical coordinates, or an attached plane { Logical3D r3d = layer.GetLogical3D(pdata, j + offset); r3d.RX += _cachedLogicalShiftX; r3d.RY += _cachedLogicalShiftY; r3d.RZ += _cachedLogicalShiftZ; if (null != this._attachedPlane) { var pp = layer.CoordinateSystem.GetPointOnPlane(this._attachedPlane, r3d); xpre = pp.X; ypre = pp.Y; zpre = pp.Z; } else { PointD3D pt; layer.CoordinateSystem.LogicalToLayerCoordinates(r3d, out pt); xpre = pt.X; ypre = pt.Y; zpre = pt.Z; } } else // no shifting, thus we can use layer coordinates { xpre = ptArray[j].X; ypre = ptArray[j].Y; zpre = ptArray[j].Z; } xdiff = xpre - xpos; ydiff = ypre - ypos; zdiff = zpre - zpos; xpos = xpre; ypos = ypre; zpos = zpre; g.TranslateTransform(xdiff, ydiff, zdiff); g.RotateTransform(_rotationX, _rotationY, _rotationZ); this.Paint(g, label, localSymbolSize, clonedTextBrush, clonedBackBrush); g.RotateTransform(-_rotationX, -_rotationY, -_rotationZ); } // end for } g.RestoreGraphicsState(gs); // Restore the graphics state }