示例#1
0
        /// <summary>Adds the y-values of a plot item to an array of y-values..</summary>
        /// <param name="vArray">The y array to be added to. If null, a new array will be allocated (and filled with the y-values of the plot item).</param>
        /// <param name="pdata">The pdata.</param>
        /// <returns>If the parameter <paramref name="vArray"/> was not null, then that <paramref name="vArray"/> is returned. Otherwise the newly allocated array is returned.</returns>
        public static AltaxoVariant[] AddUp(AltaxoVariant[] vArray, Processed3DPlotData pdata)
        {
            if (null == pdata)
            {
                throw new ArgumentNullException(nameof(pdata));
            }

            if (vArray == null)
            {
                vArray = new AltaxoVariant[pdata.RangeList.PlotPointCount];

                int j = -1;
                foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
                {
                    j++;
                    vArray[j] = pdata.GetZPhysical(originalIndex);
                }
            }
            else // this is not the first item
            {
                int j = -1;
                foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
                {
                    j++;
                    vArray[j] += pdata.GetZPhysical(originalIndex);
                }
            }
            return(vArray);
        }
示例#2
0
        /// <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);
        }
        private void DisplayCrossCoordinatesAndDifference(PointD2D rootLayerCoord)
        {
            if (_showRootLayerPrintCoordinates)
            {
                var crossLayerCoord = _cachedActiveLayerTransformation.InverseTransformPoint(_positionOfCrossInRootLayerCoordinates);
                var layerCoord      = _cachedActiveLayerTransformation.InverseTransformPoint(rootLayerCoord);
                Current.DataDisplay.WriteTwoLines(
                    string.Format("Layer({0}) XS={1} pt, YS={2} pt", _cachedActiveLayer.Name, crossLayerCoord.X, crossLayerCoord.Y),
                    string.Format("DeltaXS={0} pt, DeltaYS={1} pt, Distance={2} pt", layerCoord.X - crossLayerCoord.X, layerCoord.Y - crossLayerCoord.Y, Calc.RMath.Hypot(layerCoord.X - crossLayerCoord.X, layerCoord.Y - crossLayerCoord.Y))
                    );
            }
            else
            {
                if (CalculateCrossCoordinates(_positionOfCrossInRootLayerCoordinates, out var xphys, out var yphys) && CalculateCrossCoordinates(rootLayerCoord, out var xphys2, out var yphys2))
                {
                    double        distance = double.NaN;
                    AltaxoVariant dx = double.NaN, dy = double.NaN;
                    try
                    {
                        dx = xphys2 - xphys;
                        dy = yphys2 - yphys;
                        var r2 = dx * dx + dy * dy;
                        distance = Math.Sqrt(r2);
                    }
                    catch (Exception)
                    {
                    }

                    Current.DataDisplay.WriteTwoLines(
                        string.Format("Layer({0}) X={1}, Y={2}", _cachedActiveLayer.Name, xphys, yphys),
                        string.Format("DeltaX={0}, DeltaY={1}, Distance={2}", dx, dy, distance)
                        );
                }
            }
        }
示例#4
0
        public static bool TryParseMultipleAltaxoVariant(string s, out AltaxoVariant[] vals)
        {
            vals = null;
            bool failed = false;

            string[] parts  = s.Split(new char[] { '\t', '\r', '\n', ';' }, StringSplitOptions.RemoveEmptyEntries);
            var      result = new AltaxoVariant[parts.Length];

            for (int i = 0; i < result.Length; i++)
            {
                if (IsDouble(parts[i], out var dd))
                {
                    result[i] = dd;
                }
                else if (IsDateTime(parts[i], out var dt))
                {
                    result[i] = dt;
                }
                else
                {
                    result[i] = parts[i];
                }
            }

            if (failed)
            {
                return(false);
            }

            vals = result;
            return(true);
        }
示例#5
0
 public CSPlaneID(CSPlaneID from)
 {
     this._perpendicularAxisNumber = from._perpendicularAxisNumber;
     this._logicalValue            = from._logicalValue;
     this._usePhysicalValue        = from._usePhysicalValue;
     this._physicalValue           = from._physicalValue;
 }
示例#6
0
        /// <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);
        }
示例#7
0
 private CSPlaneID(int perpendicularAxisNumer, double logicalValue, bool usePhysicalValue, double physicalValue)
 {
     _perpendicularAxisNumber = perpendicularAxisNumer;
     _logicalValue            = logicalValue;
     _usePhysicalValue        = usePhysicalValue;
     _physicalValue           = physicalValue;
 }
示例#8
0
        protected override string FormatItem(AltaxoVariant item)
        {
            if (item.IsType(AltaxoVariant.Content.VDateTime) && !string.IsNullOrEmpty(_formatString))
            {
                var dt = item.ToDateTime();

                switch (_timeConversion)
                {
                case TimeConversion.ToLocal:
                    dt = dt.ToLocalTime();
                    break;

                case TimeConversion.ToUtc:
                    dt = dt.ToUniversalTime();
                    break;
                }

                bool showAlternate = false;
                showAlternate |= (_showAlternateFormattingAtMidnight && Math.Abs(dt.TimeOfDay.TotalSeconds) < 1);
                showAlternate |= (_showAlternateFormattingAtNoon && Math.Abs((dt.TimeOfDay - TimeSpan.FromHours(12)).TotalSeconds) < 1);

                try
                {
                    return(string.Format(showAlternate ? _formatStringAlternate : _formatString, dt));
                }
                catch (Exception)
                {
                }
            }
            return(item.ToString());
        }
示例#9
0
        private static void ConvertOrgEndToDateTimeValues(AltaxoVariant org, AltaxoVariant end, out DateTime dorg, out DateTime dend)
        {
            if (org.IsType(AltaxoVariant.Content.VDateTime))
            {
                dorg = 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 = 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");
            }
        }
示例#10
0
        public void MergeYBoundsInto(IPlotArea layer, IPhysicalBoundaries pb, PlotItemCollection coll)
        {
            var pbclone = (IPhysicalBoundaries)pb.Clone(); // before we can use CanUseStyle, we have to give physical y boundaries template

            CoordinateTransformingStyleBase.MergeYBoundsInto(pbclone, coll);
            if (!CanUseStyle(layer, coll, out var plotDataList))
            {
                pb.Add(pbclone);
                return;
            }

            // we put zero into the y-Boundaries, since the addition starts with that value
            pb.Add(new AltaxoVariant(0.0));

            AltaxoVariant[] ySumArray = null;

            int idx = -1;

            foreach (IGPlotItem pi in coll)
            {
                if (pi is G2DPlotItem)
                {
                    idx++;

                    var gpi = (G2DPlotItem)pi;
                    Processed2DPlotData pdata = plotDataList[gpi];

                    if (null != pdata)
                    {
                        // Note: we can not use AddUp function here, since
                        // when we have positive/negative items, the intermediate bounds
                        // might be wider than the bounds of the end result

                        if (ySumArray == null)
                        {
                            ySumArray = new AltaxoVariant[pdata.RangeList.PlotPointCount];

                            int j = -1;
                            foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
                            {
                                j++;
                                ySumArray[j] = pdata.GetYPhysical(originalIndex);
                                pb.Add(ySumArray[j]);
                            }
                        }
                        else // this is not the first item
                        {
                            int j = -1;
                            foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
                            {
                                j++;
                                ySumArray[j] += pdata.GetYPhysical(originalIndex);
                                pb.Add(ySumArray[j]);
                            }
                        }
                    }
                }
            }
        }
示例#11
0
        /// <summary>
        /// Determines whether the plot items in <paramref name="coll"/> can be plotted as stack. Presumption is that all plot items
        /// have the same number of plot points, and that all items have the same order of x values associated with the plot points.
        /// </summary>
        /// <param name="layer">Plot layer.</param>
        /// <param name="coll">Collection of plot items.</param>
        /// <param name="plotDataList">Output: dictionary with associates each plot item with a list of processed plot data.</param>
        /// <returns>Returns <c>true</c> if the plot items in <paramref name="coll"/> can be plotted as stack; otherwise, <c>false</c>.</returns>
        public static bool CanUseStyle(IPlotArea layer, PlotItemCollection coll, out Dictionary <G3DPlotItem, Processed3DPlotData> plotDataList)
        {
            plotDataList = new Dictionary <G3DPlotItem, Processed3DPlotData>();

            AltaxoVariant[] xArray = null;
            AltaxoVariant[] yArray = null;

            int idx = -1;

            foreach (IGPlotItem pi in coll)
            {
                if (pi is G3DPlotItem)
                {
                    idx++;
                    var gpi = (G3DPlotItem)pi;
                    Processed3DPlotData pdata = gpi.GetRangesAndPoints(layer);
                    plotDataList.Add(gpi, pdata);

                    if (xArray == null)
                    {
                        xArray = new AltaxoVariant[pdata.RangeList.PlotPointCount];
                        yArray = new AltaxoVariant[pdata.RangeList.PlotPointCount];

                        int j = -1;
                        foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
                        {
                            j++;
                            xArray[j] = pdata.GetXPhysical(originalIndex);
                            yArray[j] = pdata.GetYPhysical(originalIndex);
                        }
                    }
                    else // this is not the first item
                    {
                        if (pdata.RangeList.PlotPointCount != xArray.Length)
                        {
                            return(false);
                        }

                        int j = -1;
                        foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
                        {
                            j++;

                            if (xArray[j] != pdata.GetXPhysical(originalIndex))
                            {
                                return(false);
                            }

                            if (yArray[j] != pdata.GetYPhysical(originalIndex))
                            {
                                return(false);
                            }
                        }
                    }
                }
            }

            return(idx >= 1);
        }
示例#12
0
 public AltaxoVariant Transform(AltaxoVariant value)
 {
     foreach (var item in _transformations)
     {
         value = item.Transform(value);
     }
     return(value);
 }
示例#13
0
 public RangeOfNumericalValues()
 {
     _lowerValue       = 0;
     _isLowerInclusive = true;
     _upperValue       = 1;
     _isUpperInclusive = true;
     _columnProxy      = null;
 }
示例#14
0
            public Logical3D GetLogical3D(AltaxoVariant x, AltaxoVariant y)
            {
                var shifted = new Logical3D(
                    _xScale.PhysicalVariantToNormal(x),
                    _yScale.PhysicalVariantToNormal(y));

                return(shifted);
            }
示例#15
0
 public RangeOfNumericalValues(double lower, bool isLowerInclusive, double upper, bool isUpperInclusive, IReadableColumn column)
 {
     _lowerValue       = lower;
     _isLowerInclusive = isLowerInclusive;
     _upperValue       = upper;
     _isUpperInclusive = isUpperInclusive;
     ChildSetMember(ref _columnProxy, ReadableColumnProxyBase.FromColumn(column));
 }
示例#16
0
 /// <summary>
 /// Deserialization constructor. Initializes a new instance of the <see cref="RangeOfNumericalValues"/> class.
 /// </summary>
 /// <param name="info">The deserialization information.</param>
 /// <param name="lower">The lower.</param>
 /// <param name="isLowerInclusive">if set to <c>true</c> [is lower inclusive].</param>
 /// <param name="upper">The upper.</param>
 /// <param name="isUpperInclusive">if set to <c>true</c> [is upper inclusive].</param>
 /// <param name="columnProxy">The column.</param>
 protected RangeOfNumericalValues(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, double lower, bool isLowerInclusive, double upper, bool isUpperInclusive, IReadableColumnProxy columnProxy)
 {
     _lowerValue       = lower;
     _isLowerInclusive = isLowerInclusive;
     _upperValue       = upper;
     _isUpperInclusive = isUpperInclusive;
     ChildSetMember(ref _columnProxy, columnProxy);
 }
示例#17
0
        public void PaintPreprocessing(IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
        {
            if (!CanUseStyle(layer, coll, out var plotDataDict))
            {
                return;
            }
            else
            {
                paintContext.AddValue(this, plotDataDict);
            }

            AltaxoVariant[] vSumArray = null;
            foreach (IGPlotItem pi in coll)
            {
                if (pi is G3DPlotItem)
                {
                    var gpi   = pi as G3DPlotItem;
                    var pdata = plotDataDict[gpi];
                    vSumArray = AbsoluteStackTransform.AddUp(vSumArray, pdata);
                }
            }

            // now plot the data - the summed up y is in yArray
            AltaxoVariant[]     vArray           = null;
            Processed3DPlotData previousItemData = null;

            foreach (IGPlotItem pi in coll)
            {
                if (pi is G3DPlotItem)
                {
                    var gpi   = pi as G3DPlotItem;
                    var pdata = plotDataDict[gpi];
                    vArray = AbsoluteStackTransform.AddUp(vArray, pdata);
                    var localArray = new AltaxoVariant[vArray.Length];

                    int j = -1;
                    foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
                    {
                        j++;
                        AltaxoVariant v = 100 * vArray[j] / vSumArray[j];
                        localArray[j] = v;

                        var rel = new Logical3D(
                            layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalIndex)),
                            layer.YAxis.PhysicalVariantToNormal(pdata.GetYPhysical(originalIndex)),
                            layer.ZAxis.PhysicalVariantToNormal(v));

                        layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out var pabs);
                        pdata.PlotPointsInAbsoluteLayerCoordinates[j] = pabs;
                    }
                    // we have also to exchange the accessor for the physical z value and replace it by our own one
                    pdata.ZPhysicalAccessor = new IndexedPhysicalValueAccessor(delegate(int i)
                                                                               { return(localArray[i]); });
                    pdata.PreviousItemData = previousItemData;
                    previousItemData       = pdata;
                }
            }
        }
示例#18
0
            public Logical3D GetLogical3D(AltaxoVariant x, AltaxoVariant y)
            {
                Logical3D r;

                r.RX = XAxis.PhysicalVariantToNormal(x);
                r.RY = YAxis.PhysicalVariantToNormal(y);
                r.RZ = 0;
                return(r);
            }
示例#19
0
        private string DefaultTextConverter(AltaxoVariant x)
        {
            string s = x.ToString();

            s = s.Replace('\r', ' ');
            s = s.Replace('\n', ' ');

            return(s);
        }
 void DisplayData(object plotItem, int rowIndex, AltaxoVariant x, AltaxoVariant y)
 {
     Current.DataDisplay.WriteOneLine(string.Format(
                                          "{0}[{1}] X={2}, Y={3}",
                                          plotItem.ToString(),
                                          rowIndex,
                                          x,
                                          y));
 }
示例#21
0
        public void Paint(System.Drawing.Graphics g, IPlotArea layer, PlotItemCollection coll)
        {
            System.Drawing.Region[] clippingColl = new System.Drawing.Region[coll.Count];
            Processed2DPlotData[]   plotDataColl = new Processed2DPlotData[coll.Count];
            double[] xincColl = new double[coll.Count];
            double[] yincColl = new double[coll.Count];

            int idx = -1;
            Processed2DPlotData previousPlotData = null;

            for (int i = 0; i < coll.Count; i++)
            {
                if (coll[i] is G2DPlotItem)
                {
                    idx++;
                    double currxinc = xincColl[i] = idx * _xinc * _scaleXInc;
                    double curryinc = yincColl[i] = idx * _yinc * _scaleYInc;

                    G2DPlotItem         gpi      = coll[i] as G2DPlotItem;
                    Processed2DPlotData plotdata = plotDataColl[i] = gpi.GetRangesAndPoints(layer);
                    plotdata.PreviousItemData = previousPlotData;
                    previousPlotData          = plotdata;

                    int j = -1;
                    foreach (int rowIndex in plotdata.RangeList.OriginalRowIndices())
                    {
                        j++;

                        AltaxoVariant xx = plotdata.GetXPhysical(rowIndex) + currxinc;
                        AltaxoVariant yy = plotdata.GetYPhysical(rowIndex) + curryinc;

                        Logical3D rel = new Logical3D(layer.XAxis.PhysicalVariantToNormal(xx), layer.YAxis.PhysicalVariantToNormal(yy));
                        double    xabs, yabs;
                        layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out xabs, out yabs);
                        plotdata.PlotPointsInAbsoluteLayerCoordinates[j] = new System.Drawing.PointF((float)xabs, (float)yabs);
                    }

                    if (_useClipping)
                    {
                        GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
                    }
                }
            }
            for (int i = coll.Count - 1; i >= 0; i--)
            {
                if (null == plotDataColl[i])
                {
                    coll[i].Paint(g, layer);
                }
                else
                {
                    TransformedLayerWrapper layerwrapper = new TransformedLayerWrapper(layer, xincColl[i], yincColl[i]);
                    ((G2DPlotItem)coll[i]).Paint(g, layerwrapper, plotDataColl[i]);
                }
            }
        }
示例#22
0
 public override AltaxoVariant[] GetMinorTicksAsVariant()
 {
     double[]        ticks  = GetMinorTicks();
     AltaxoVariant[] vticks = new AltaxoVariant[ticks.Length];
     for (int i = 0; i < ticks.Length; ++i)
     {
         vticks[i] = ticks[i];
     }
     return(vticks);
 }
 private void DisplayData(object plotItem, int rowIndex, AltaxoVariant x, AltaxoVariant y)
 {
     Current.DataDisplay.WriteOneLine(string.Format(
                                          "{0}: {1}[{2}] X={3}, Y={4}",
                                          _layer.Name,
                                          plotItem.ToString(),
                                          rowIndex,
                                          x,
                                          y));
 }
示例#24
0
        public override Altaxo.Data.AltaxoVariant[] GetMinorTicksAsVariant()
        {
            AltaxoVariant[] result = new AltaxoVariant[_dataBounds.NumberOfItems + 1];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = new Altaxo.Data.AltaxoVariant(i + 0.5);
            }

            return(result);
        }
示例#25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RangeOfNumericalValues"/> class.
        /// </summary>
        /// <param name="from">Instance to copy the values from.</param>
        public RangeOfNumericalValues(RangeOfNumericalValues from)
        {
            _lowerValue       = from._lowerValue;
            _isLowerInclusive = from._isLowerInclusive;
            ;
            _upperValue       = from._upperValue;
            _isUpperInclusive = from._isUpperInclusive;

            ChildCloneToMember(ref _columnProxy, from._columnProxy);
        }
示例#26
0
        public static CSPlaneID FromPhysicalVariant(int perpendicularAxisNumber, AltaxoVariant physicalValue)
        {
#pragma warning disable CS1718 // Comparison made to same variable
            if (!(physicalValue == physicalValue))
            {
                throw new ArgumentException("You can not set physical values that return false when compared to itself, value is: " + physicalValue.ToString());
            }
#pragma warning restore CS1718 // Comparison made to same variable

            return(new CSPlaneID(perpendicularAxisNumber, double.NaN, true, physicalValue));
        }
示例#27
0
        public override Altaxo.Data.AltaxoVariant[] GetMajorTicksAsVariant()
        {
            var result = new Altaxo.Data.AltaxoVariant[_dataBounds.NumberOfItems];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = new AltaxoVariant(_dataBounds.GetItem(i));
            }

            return(result);
        }
示例#28
0
        public override AltaxoVariant[] GetMajorTicksAsVariant()
        {
            DateTime[] ticks  = GetMajorTicks();
            var        vticks = new AltaxoVariant[ticks.Length];

            for (int i = 0; i < ticks.Length; ++i)
            {
                vticks[i] = ticks[i];
            }
            return(vticks);
        }
示例#29
0
        public CSLineID(CSLineID from)
        {
            this._parallelAxisNumber         = from._parallelAxisNumber;
            this._logicalValueFirstOther     = from._logicalValueFirstOther;
            this._usePhysicalValueFirstOther = from._usePhysicalValueFirstOther;
            this._physicalValueFirstOther    = from._physicalValueFirstOther;

            this._logicalValueSecondOther     = from._logicalValueSecondOther;
            this._usePhysicalValueSecondOther = from._usePhysicalValueSecondOther;
            this._physicalValueSecondOther    = from._physicalValueSecondOther;
        }
示例#30
0
 protected virtual void UpdateTicksAndOrgEndUsingRescalingObject()
 {
     if (null == TickSpacing)
     {
         SetScaleOrgEnd(Rescaling.ResultingOrg, Rescaling.ResultingEnd);
     }
     else
     {
         AltaxoVariant org = Rescaling.ResultingOrg, end = Rescaling.ResultingEnd;
         TickSpacing.PreProcessScaleBoundaries(ref org, ref end, !Rescaling.IsResultingOrgFixed, !Rescaling.IsResultingEndFixed);
         SetScaleOrgEnd(org, end);
         TickSpacing.FinalProcessScaleBoundaries(org, end, this);
     }
 }
示例#31
0
		public AltaxoVariant Transform(AltaxoVariant value)
		{
			return -value;
		}
		public AltaxoVariant Transform(AltaxoVariant value)
		{
			return Math.Pow(10, value);
		}
示例#33
0
			public Logical3D GetLogical3D(AltaxoVariant x, AltaxoVariant y)
			{
				Logical3D r;
				r.RX = XAxis.PhysicalVariantToNormal(x);
				r.RY = YAxis.PhysicalVariantToNormal(y);
				r.RZ = 0;
				return r;
			}
		public AltaxoVariant Transform(AltaxoVariant value)
		{
			return Math.Exp(value);
		}
示例#35
0
		public AltaxoVariant Transform(AltaxoVariant value)
		{
			return _offset + value;
		}
示例#36
0
		public AltaxoVariant Transform(AltaxoVariant value)
		{
			return _scale * value;
		}