コード例 #1
0
        public override void ProcessDataBounds(Altaxo.Data.AltaxoVariant org, bool orgfixed, Altaxo.Data.AltaxoVariant end, bool endfixed)
        {
            double dorg = org.ToDouble();
            double dend = end.ToDouble();

            if (!orgfixed)
            {
                dorg = Math.Ceiling(dorg) - 0.5;
            }
            if (!endfixed)
            {
                dend = Math.Floor(dend) + 0.5;
            }

            bool changed = false;

            changed       |= _cachedAxisOrg != dorg;
            _cachedAxisOrg = dorg;

            changed       |= _cachedAxisEnd != dend;
            _cachedAxisEnd = dend;

            changed        |= _cachedAxisSpan != (dend - dorg);
            _cachedAxisSpan = dend - dorg;

            changed |= _cachedOneByAxisSpan != (1 / _cachedAxisSpan);
            _cachedOneByAxisSpan = 1 / _cachedAxisSpan;

            if (changed)
            {
                OnChanged();
            }
        }
コード例 #2
0
ファイル: DoubleColumn.cs プロジェクト: Altaxo/Altaxo
		// indexers
		public override void SetValueAt(int i, AltaxoVariant val)
		{
			try
			{
				this[i] = val.ToDouble();
			}
			catch (Exception ex)
			{
				throw new ApplicationException(string.Format("Error: Try to set {0}[{1}] with the string {2}, exception: {3}", this.TypeAndName, i, val.ToString(), ex.Message));
			}
		}
コード例 #3
0
ファイル: TextScale.cs プロジェクト: olesar/Altaxo
        protected override string SetScaleOrgEnd(Altaxo.Data.AltaxoVariant org, Altaxo.Data.AltaxoVariant end)
        {
            double o = org.ToDouble();
            double e = end.ToDouble();

            if (!(o < e))
            {
                return("org is not less than end");
            }

            InternalSetOrgEnd(o, e);

            return(null);
        }
コード例 #4
0
ファイル: DateTimeScale.cs プロジェクト: carlhuth/GenXSource
 /// <summary>
 /// PhysicalVariantToNormal translates physical values into a normal value linear along the axis
 /// a physical value of the axis origin must return a value of zero
 /// a physical value of the axis end must return a value of one
 /// the function physicalToNormal must be provided by any derived class
 /// </summary>
 /// <param name="x">the physical value</param>
 /// <returns>
 /// the normalized value linear along the axis,
 /// 0 for axis origin, 1 for axis end</returns>
 public override double PhysicalVariantToNormal(Altaxo.Data.AltaxoVariant x)
 {
     if (x.IsType(AltaxoVariant.Content.VDateTime))
     {
         return(PhysicalToNormal((DateTime)x));
     }
     else if (x.CanConvertedToDouble)
     {
         return(PhysicalToNormal(new DateTime((long)(x.ToDouble() * 10000000))));
     }
     else
     {
         throw new ArgumentException("Variant x is neither DateTime nor numeric");
     }
 }
コード例 #5
0
 public override double PhysicalVariantToNormal(Altaxo.Data.AltaxoVariant x)
 {
     if (x.IsType(Altaxo.Data.AltaxoVariant.Content.VString))
     {
         int idx = _dataBounds.IndexOf(x.ToString());
         return(idx < 0? double.NaN : (1 + idx - _cachedAxisOrg) * _cachedOneByAxisSpan);
     }
     else if (x.CanConvertedToDouble)
     {
         return((x.ToDouble() - _cachedAxisOrg) * _cachedOneByAxisSpan);
     }
     else
     {
         return(double.NaN);
     }
 }
コード例 #6
0
        public void Paint(System.Drawing.Graphics g, IPlotArea layer, Processed2DPlotData pdata, Processed2DPlotData prevItemData, Processed2DPlotData nextItemData)
        {
            if (null == pdata)
            {
                throw new ArgumentNullException(nameof(pdata));
            }

            PlotRangeList rangeList = pdata.RangeList;

            System.Drawing.PointF[] ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;
            layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(0, 0), out var xleft, out var ybottom);
            layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(1, 1), out var xright, out var ytop);
            float xe = (float)xright;
            float ye = (float)ybottom;

            var path = new GraphicsPath();

            double globalBaseValue;

            if (_usePhysicalBaseValue)
            {
                globalBaseValue = layer.YAxis.PhysicalVariantToNormal(_baseValue);
                if (double.IsNaN(globalBaseValue))
                {
                    globalBaseValue = 0;
                }
            }
            else
            {
                globalBaseValue = _baseValue.ToDouble();
            }

            bool useVariableFillColor  = null != _fillBrush && null != _cachedColorForIndexFunction && !_independentFillColor;
            bool useVariableFrameColor = null != _framePen && null != _cachedColorForIndexFunction && !_independentFrameColor;

            var fillBrush = _fillBrush == null ? null : useVariableFillColor?_fillBrush.Clone() : _fillBrush;

            var framePen = _framePen == null ? null : useVariableFrameColor?_framePen.Clone() : _framePen;

            int j = -1;

            foreach (int originalRowIndex in pdata.RangeList.OriginalRowIndices())
            {
                j++;

                double xcn = _xOffsetLogical + layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalRowIndex));
                double xln = xcn - 0.5 * _xSizeLogical;
                double xrn = xcn + 0.5 * _xSizeLogical;

                double ycn    = layer.YAxis.PhysicalVariantToNormal(pdata.GetYPhysical(originalRowIndex));
                double ynbase = globalBaseValue;

                if (_startAtPreviousItem && pdata.PreviousItemData != null)
                {
                    double prevstart = layer.YAxis.PhysicalVariantToNormal(pdata.PreviousItemData.GetYPhysical(originalRowIndex));
                    if (!double.IsNaN(prevstart))
                    {
                        ynbase  = prevstart;
                        ynbase += Math.Sign(ynbase - globalBaseValue) * _previousItemYGap;
                    }
                }

                path.Reset();
                layer.CoordinateSystem.GetIsoline(path, new Logical3D(xln, ynbase), new Logical3D(xln, ycn));
                layer.CoordinateSystem.GetIsoline(path, new Logical3D(xln, ycn), new Logical3D(xrn, ycn));
                layer.CoordinateSystem.GetIsoline(path, new Logical3D(xrn, ycn), new Logical3D(xrn, ynbase));
                layer.CoordinateSystem.GetIsoline(path, new Logical3D(xrn, ynbase), new Logical3D(xln, ynbase));
                path.CloseFigure();

                if (null != fillBrush)
                {
                    if (useVariableFillColor)
                    {
                        fillBrush.Color = GdiColorHelper.ToNamedColor(_cachedColorForIndexFunction(originalRowIndex), "VariableColor");
                    }

                    fillBrush.SetEnvironment(path.GetBounds(), BrushX.GetEffectiveMaximumResolution(g, 1));
                    g.FillPath(fillBrush, path);
                }

                if (null != framePen)
                {
                    if (useVariableFrameColor)
                    {
                        framePen.Color = GdiColorHelper.ToNamedColor(_cachedColorForIndexFunction(originalRowIndex), "VariableColor");
                    }

                    framePen.SetEnvironment(path.GetBounds(), BrushX.GetEffectiveMaximumResolution(g, 1));
                    g.DrawPath(framePen, path);
                }
            }
        }
コード例 #7
0
 public override bool Add(Altaxo.Data.AltaxoVariant val)
 {
     return(Add(val.ToDouble()));
 }
コード例 #8
0
ファイル: NumericalScale.cs プロジェクト: Altaxo/Altaxo
		/// <summary>
		/// calculates the axis org and end using the databounds
		/// the org / end is adjusted only if it is not fixed
		/// and the DataBound object contains valid data
		/// </summary>
		public override void ProcessDataBounds(AltaxoVariant org, bool orgfixed, AltaxoVariant end, bool endfixed)
		{
			double dorg = org.ToDouble();
			double dend = end.ToDouble();

			ProcessDataBounds(dorg, orgfixed, dend, endfixed);
		}
コード例 #9
0
ファイル: BarGraphPlotStyle.cs プロジェクト: olesar/Altaxo
        public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData)
        {
            if (null == pdata)
            {
                throw new ArgumentNullException(nameof(pdata));
            }

            PlotRangeList rangeList = pdata.RangeList;
            var           ptArray   = pdata.PlotPointsInAbsoluteLayerCoordinates;

            layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(0, 0, 0), out var leftFrontBotton);
            layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(1, 1, 1), out var rightBackTop);

            double globalBaseValue;

            if (_usePhysicalBaseValue)
            {
                globalBaseValue = layer.ZAxis.PhysicalVariantToNormal(_baseValue);
                if (double.IsNaN(globalBaseValue))
                {
                    globalBaseValue = 0;
                }
            }
            else
            {
                globalBaseValue = _baseValue.ToDouble();
            }

            bool useVariableColor = null != _cachedColorForIndexFunction && !_independentColor;

            var pen = _pen;

            int j = -1;

            foreach (int originalRowIndex in pdata.RangeList.OriginalRowIndices())
            {
                j++;

                double xCenterLogical = layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalRowIndex));
                double xLowerLogical  = xCenterLogical + _xOffsetLogical;
                double xUpperLogical  = xLowerLogical + _xSizeLogical;

                double yCenterLogical = layer.YAxis.PhysicalVariantToNormal(pdata.GetYPhysical(originalRowIndex));
                double yLowerLogical  = yCenterLogical + _yOffsetLogical;
                double yUpperLogical  = yLowerLogical + _ySizeLogical;

                double zCenterLogical = layer.ZAxis.PhysicalVariantToNormal(pdata.GetZPhysical(originalRowIndex));
                double zBaseLogical   = globalBaseValue;

                if (_startAtPreviousItem && pdata.PreviousItemData != null)
                {
                    double prevstart = layer.ZAxis.PhysicalVariantToNormal(pdata.PreviousItemData.GetZPhysical(originalRowIndex));
                    if (!double.IsNaN(prevstart))
                    {
                        zBaseLogical  = prevstart;
                        zBaseLogical += Math.Sign(zBaseLogical - globalBaseValue) * _previousItemZGap;
                    }
                }

                layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(xLowerLogical, yCenterLogical, zBaseLogical), out var lcp);
                layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(xUpperLogical, yCenterLogical, zBaseLogical), out var ucp);
                layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(xCenterLogical, yLowerLogical, zBaseLogical), out var clp);
                layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(xCenterLogical, yUpperLogical, zBaseLogical), out var cup);

                double penWidth1 = (lcp - ucp).Length;
                double penWidth2 = (clp - cup).Length;

                if (_useUniformCrossSectionThickness)
                {
                    pen = pen.WithUniformThickness(Math.Min(penWidth1, penWidth2));
                }
                else
                {
                    pen = pen.WithThickness1(penWidth1);
                    pen = pen.WithThickness2(penWidth2);
                }

                if (useVariableColor)
                {
                    pen = pen.WithColor(GdiColorHelper.ToNamedColor(_cachedColorForIndexFunction(originalRowIndex), "VariableColor"));
                }

                var isoLine = layer.CoordinateSystem.GetIsoline(new Logical3D(xLowerLogical, yLowerLogical, zBaseLogical), new Logical3D(xLowerLogical, yLowerLogical, zCenterLogical));
                g.DrawLine(pen, isoLine);
            }
        }
コード例 #10
0
 // indexers
 public override void SetValueAt(int i, AltaxoVariant val)
 {
   if(val.IsType(AltaxoVariant.Content.VDouble))
     this[i] = val.m_Double;
   else if(val.CanConvertedToDouble)
     this[i] = val.ToDouble();
   else
     throw new ApplicationException("Error: Try to set " + this.TypeAndName + "[" + i + "] with the string " + val.ToString());
 }
コード例 #11
0
ファイル: DateTimeScale.cs プロジェクト: Altaxo/Altaxo
		/// <summary>
		/// calculates the axis org and end using the databounds
		/// the org / end is adjusted only if it is not fixed
		/// and the DataBound object contains valid data
		/// </summary>
		public override void ProcessDataBounds(AltaxoVariant org, bool orgfixed, AltaxoVariant end, bool endfixed)
		{
			DateTime dorg;
			DateTime dend;
			if (org.IsType(AltaxoVariant.Content.VDateTime))
				dorg = (DateTime)org;
			else if (org.CanConvertedToDouble)
				dorg = new DateTime((long)(org.ToDouble() * 1E7));
			else
				throw new ArgumentException("Variant org is not a DateTime nor a numeric value");

			if (end.IsType(AltaxoVariant.Content.VDateTime))
				dend = (DateTime)end;
			else if (end.CanConvertedToDouble)
				dend = new DateTime((long)(end.ToDouble() * 1E7));
			else
				throw new ArgumentException("Variant end is not a DateTime nor a numeric value");

			ProcessDataBounds(dorg, orgfixed, dend, endfixed);
		}