public override VectorD3D MeasureItem(IGraphicsContext3D g, FontX3D font, Altaxo.Data.AltaxoVariant mtick, PointD3D morg)
        {
            SplitInFirstPartAndExponent(mtick, out var firstpart, out var mant, out var middelpart, out var exponent);

            var size1 = g.MeasureString(_prefix + firstpart + middelpart, font, PointD3D.Empty);
            var size2 = g.MeasureString(exponent, font, PointD3D.Empty);
            var size3 = g.MeasureString(_suffix, font, PointD3D.Empty);

            return(new VectorD3D(size1.X + size2.X + size3.X, size1.Y, font.Depth));
        }
 public MeasuredLabelItem(IGraphicsContext3D g, FontX3D font1, FontX3D font2, string firstpart, string exponent, string lastpart, double maxexposize)
 {
     _firstpart    = firstpart;
     _exponent     = exponent;
     _lastpart     = lastpart;
     _font1        = font1;
     _font2        = font2;
     _size1        = g.MeasureString(_firstpart, _font1, PointD3D.Empty);
     _size2        = g.MeasureString(_exponent, _font2, new PointD3D(_size1.X, 0, 0));
     _size3        = g.MeasureString(_lastpart, _font1, PointD3D.Empty);
     _rightPadding = maxexposize - _size2.X;
 }
        public override void DrawItem(IGraphicsContext3D g, IMaterial brush, FontX3D font, Altaxo.Data.AltaxoVariant item, PointD3D morg)
        {
            SplitInFirstPartAndExponent(item, out var firstpart, out var mant, out var middelpart, out var 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);
            }
        }
예제 #4
0
            public MeasuredLabelItem(IGraphicsContext3D g, FontX3D font, string itemtext, double lineSpacing, Alignment horizontalAlignment, Alignment verticalAlignment, Alignment textBlockAligment)
            {
                _text                = itemtext.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                _stringSize          = new VectorD3D[_text.Length];
                _font                = font;
                _horizontalAlignment = horizontalAlignment;
                _verticalAlignment   = verticalAlignment;
                _textBlockAligment   = textBlockAligment;
                _lineSpacing         = lineSpacing;
                _size                = VectorD3D.Empty;
                var bounds   = RectangleD3D.Empty;
                var position = PointD3D.Empty;

                for (int i = 0; i < _text.Length; ++i)
                {
                    _stringSize[i] = g.MeasureString(_text[i], _font, PointD3D.Empty);
                    bounds         = bounds.WithRectangleIncluded(new RectangleD3D(position, _stringSize[i]));
                    position       = position.WithYPlus(-_stringSize[i].Y * _lineSpacing);
                }
                _size = bounds.Size;
            }
        public override IMeasuredLabelItem[] GetMeasuredItems(IGraphicsContext3D g, FontX3D font, AltaxoVariant[] items)
        {
            var 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(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);
        }
예제 #6
0
			public MeasuredLabelItem(IGraphicsContext3D g, FontX3D font, string itemtext, double lineSpacing, Alignment horizontalAlignment, Alignment verticalAlignment, Alignment textBlockAligment)
			{
				_text = itemtext.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
				_stringSize = new VectorD3D[_text.Length];
				_font = font;
				_horizontalAlignment = horizontalAlignment;
				_verticalAlignment = verticalAlignment;
				_textBlockAligment = textBlockAligment;
				_lineSpacing = lineSpacing;
				_size = VectorD3D.Empty;
				var bounds = RectangleD3D.Empty;
				var position = PointD3D.Empty;
				for (int i = 0; i < _text.Length; ++i)
				{
					_stringSize[i] = g.MeasureString(_text[i], _font, PointD3D.Empty);
					bounds = bounds.WithRectangleIncluded(new RectangleD3D(position, _stringSize[i]));
					position = position.WithYPlus(-_stringSize[i].Y * _lineSpacing);
				}
				_size = bounds.Size;
			}
예제 #7
0
		/// <summary>
		/// Measures the item, i.e. returns the size of the item.
		/// </summary>
		/// <param name="g">Graphics context.</param>
		/// <param name="font">The font that is used to draw the item.</param>
		/// <param name="strfmt">String format used to draw the item.</param>
		/// <param name="mtick">The item to draw.</param>
		/// <param name="morg">The location the item will be drawn.</param>
		/// <returns>The size of the item if it would be drawn.</returns>
		public virtual VectorD3D MeasureItem(IGraphicsContext3D g, FontX3D font, Altaxo.Data.AltaxoVariant mtick, PointD3D morg)
		{
			string text = _prefix + FormatItem(mtick) + _suffix;
			return g.MeasureString(text, font, morg);
		}
예제 #8
0
			public MeasuredLabelItem(IGraphicsContext3D g, FontX3D font, string itemtext)
			{
				_text = itemtext;
				_font = font;
				_size = g.MeasureString(_text, _font, new PointD3D(0, 0, 0));
			}
예제 #9
0
 public MeasuredLabelItem(IGraphicsContext3D g, FontX3D font, string itemtext)
 {
     _text = itemtext;
     _font = font;
     _size = g.MeasureString(_text, _font, new PointD3D(0, 0, 0));
 }
예제 #10
0
		/// <summary>
		/// Paints one label.
		/// </summary>
		/// <param name="g"></param>
		/// <param name="label"></param>
		/// <param name="variableTextBrush">If not null, this argument provides the text brush that should be used now. If null, then the <see cref="_material"/> is used instead.</param>
		/// <param name="variableBackBrush"></param>
		public void Paint(IGraphicsContext3D g, string label, double symbolSize, IMaterial variableTextBrush, IMaterial variableBackBrush)
		{
			var fontSize = _font.Size;

			var xpos = _offsetX_Points + (_offsetX_EmUnits * fontSize) + (_offsetX_SymbolSizeUnits * symbolSize / 2);
			var ypos = _offsetY_Points + (_offsetY_EmUnits * fontSize) + (_offsetY_SymbolSizeUnits * symbolSize / 2);
			var zpos = _offsetZ_Points + (_offsetZ_EmUnits * fontSize) + (_offsetZ_SymbolSizeUnits * symbolSize / 2);
			var stringsize = g.MeasureString(label, _font, new PointD3D(xpos, ypos, zpos));

			if (this._backgroundStyle != null)
			{
				var x = xpos;
				var y = ypos;
				var z = zpos;

				switch (_alignmentX)
				{
					case Alignment.Center:
						x -= stringsize.X / 2;
						break;

					case Alignment.Far:
						x -= stringsize.X;
						break;
				}

				switch (_alignmentY)
				{
					case Alignment.Center:
						y -= stringsize.Y / 2;
						break;

					case Alignment.Far:
						y -= stringsize.Y;
						break;
				}
				if (null == variableBackBrush)
				{
					this._backgroundStyle.Draw(g, new RectangleD3D(x, y, z, stringsize.X, stringsize.Y, stringsize.Z));
				}
				else
				{
					this._backgroundStyle.Draw(g, new RectangleD3D(x, y, z, stringsize.X, stringsize.Y, stringsize.Z), variableBackBrush);
				}
			}

			var brush = null != variableTextBrush ? variableTextBrush : _material;
			g.DrawString(label, _font, brush, new PointD3D(xpos, ypos, zpos), _alignmentX, _alignmentY, _alignmentZ);
		}
예제 #11
0
        /// <summary>
        /// Measures the item, i.e. returns the size of the item.
        /// </summary>
        /// <param name="g">Graphics context.</param>
        /// <param name="font">The font that is used to draw the item.</param>
        /// <param name="mtick">The item to draw.</param>
        /// <param name="morg">The location the item will be drawn.</param>
        /// <returns>The size of the item if it would be drawn.</returns>
        public virtual VectorD3D MeasureItem(IGraphicsContext3D g, FontX3D font, Altaxo.Data.AltaxoVariant mtick, PointD3D morg)
        {
            string text = _prefix + FormatItem(mtick) + _suffix;

            return(g.MeasureString(text, font, morg));
        }
			public MeasuredLabelItem(IGraphicsContext3D g, FontX3D font1, FontX3D font2, string firstpart, string exponent, string lastpart, double maxexposize)
			{
				_firstpart = firstpart;
				_exponent = exponent;
				_lastpart = lastpart;
				_font1 = font1;
				_font2 = font2;
				_size1 = g.MeasureString(_firstpart, _font1, PointD3D.Empty);
				_size2 = g.MeasureString(_exponent, _font2, new PointD3D(_size1.X, 0, 0));
				_size3 = g.MeasureString(_lastpart, _font1, PointD3D.Empty);
				_rightPadding = maxexposize - _size2.X;
			}
		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);
			}
		}
		public override VectorD3D MeasureItem(IGraphicsContext3D g, FontX3D font, Altaxo.Data.AltaxoVariant mtick, PointD3D morg)
		{
			string firstpart, middelpart, exponent;
			double mant;
			SplitInFirstPartAndExponent((double)mtick, out firstpart, out mant, out middelpart, out exponent);

			var size1 = g.MeasureString(_prefix + firstpart + middelpart, font, PointD3D.Empty);
			var size2 = g.MeasureString(exponent, font, PointD3D.Empty);
			var size3 = g.MeasureString(_suffix, font, PointD3D.Empty);

			return new VectorD3D(size1.X + size2.X + size3.X, size1.Y, font.Depth);
		}