public override IMeasuredLabelItem[] GetMeasuredItems(IGraphicsContext3D g, FontX3D font, AltaxoVariant[] items) { MeasuredLabelItem[] litems = new MeasuredLabelItem[items.Length]; var localfont1 = font; var localfont2 = font.WithSize(font.Size * 2 / 3); string[] firstp = new string[items.Length]; string[] middel = new string[items.Length]; string[] expos = new string[items.Length]; double[] mants = new double[items.Length]; double maxexposize = 0; int firstpartmin = int.MaxValue; int firstpartmax = int.MinValue; for (int i = 0; i < items.Length; ++i) { string firstpart, exponent; if (items[i].IsType(Altaxo.Data.AltaxoVariant.Content.VDouble)) { SplitInFirstPartAndExponent((double)items[i], out firstpart, out mants[i], out middel[i], out exponent); if (exponent.Length > 0) { firstpartmin = Math.Min(firstpartmin, firstpart.Length); firstpartmax = Math.Max(firstpartmax, firstpart.Length); } } else { firstpart = items[i].ToString(); middel[i] = string.Empty; exponent = string.Empty; } firstp[i] = firstpart; expos[i] = exponent; maxexposize = Math.Max(maxexposize, g.MeasureString(exponent, localfont2, PointD3D.Empty).X); } if (firstpartmax > 0 && firstpartmax > firstpartmin) // then we must use special measures to equilibrate the mantissa { firstp = NumericLabelFormattingAuto.FormatItems(mants); } for (int i = 0; i < items.Length; ++i) { string mid = string.Empty; if (!string.IsNullOrEmpty(expos[i])) { if (string.IsNullOrEmpty(firstp[i])) mid = "10"; else mid = "\u00D710"; } litems[i] = new MeasuredLabelItem(g, localfont1, localfont2, _prefix + firstp[i] + mid, expos[i], _suffix, maxexposize); } return litems; }
public override void DrawItem(IGraphicsContext3D g, IMaterial brush, FontX3D font, Altaxo.Data.AltaxoVariant item, PointD3D morg) { string firstpart, middelpart, exponent; double mant; SplitInFirstPartAndExponent((double)item, out firstpart, out mant, out middelpart, out exponent); var size1 = g.MeasureString(_prefix + firstpart + middelpart, font, morg); g.DrawString(_prefix + firstpart + middelpart, font, brush, morg); var orginalY = morg.Y; morg = morg + new VectorD3D(size1.X, size1.Y, 0); var font2 = font.WithSize(font.Size * 2 / 3.0); g.DrawString(exponent, font2, brush, morg); if (!string.IsNullOrEmpty(_suffix)) { var shiftX = g.MeasureString(exponent, font2, morg).X; morg = new PointD3D(morg.X + shiftX, orginalY, morg.Z); } if (!string.IsNullOrEmpty(_suffix)) { g.DrawString(_suffix, font, brush, morg); } }