Ejemplo n.º 1
0
        public override void FinalProcessScaleBoundaries(Altaxo.Data.AltaxoVariant org, Altaxo.Data.AltaxoVariant end, Scale scale)
        {
            _minorTicks.Clear();
            _majorTicks.Clear();
            _majorTextTicks.Clear();

            // make major ticks at integral numbers and minor ticks at halfway
            double dorg = org;
            double dend = end;

            if (!(dorg < dend))
            {
                return;
            }

            double span = Math.Abs(dend - dorg);

            if (double.IsInfinity(span))
            {
                return;
            }

            var textBounds = scale.DataBoundsObject as Boundaries.TextBoundaries;

            double majorSpan = 1;

            if (span > 100)
            {
                majorSpan = Math.Ceiling(span / 100);
            }

            double minorSpan = majorSpan / 2;

            double firstmajor = Math.Floor(dorg / majorSpan) - 1;   // -1 for safety and for minor
            double lastmajor  = Math.Ceiling(dend / majorSpan) + 1; // +1 for safety

            for (double maj = firstmajor; maj <= lastmajor; maj += 1)
            {
                double majortick = maj * majorSpan;
                double minortick = maj * majorSpan - minorSpan;

                if (majortick.IsInIntervalCC(dorg, dend))
                {
                    _majorTicks.Add(majortick);
                    int item = (int)(majortick - 1);
                    if (textBounds != null && item >= 0 && item < textBounds.NumberOfItems)
                    {
                        _majorTextTicks.Add(textBounds.GetItem(item));
                    }
                    else
                    {
                        _majorTextTicks.Add(majortick);
                    }
                }
                if (minortick.IsInIntervalCC(dorg, dend))
                {
                    _minorTicks.Add(minortick);
                }
            }
        }
Ejemplo n.º 2
0
            public virtual void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                AltaxoVariant s = (AltaxoVariant)obj;

                info.AddEnum("Content", s.m_Content);
                switch (s.m_Content)
                {
                case Content.VNull:
                    break;

                case Content.VDouble:
                    info.AddValue("Value", s.m_Double);
                    break;

                case Content.VDateTime:
                    info.AddValue("Value", (DateTime)s.m_Object);
                    break;

                case Content.VString:
                    info.AddValue("Value", (string)s.m_Object);
                    break;

                default:
                    info.AddValue("Value", s.m_Object);
                    break;
                }
            }
Ejemplo n.º 3
0
            protected virtual AltaxoVariant SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                AltaxoVariant s = (o == null ? new AltaxoVariant() : (AltaxoVariant)o);
                var           c = (Content)info.GetEnum("Content", typeof(Content));

                s._typeOfContent = c;

                switch (c)
                {
                case Content.VNull:
                    break;

                case Content.VDouble:
                    s._double = info.GetDouble("Value");
                    break;

                case Content.VDateTime:
                    s._object = info.GetDateTime("Value");
                    break;

                case Content.VString:
                    s._object = info.GetString("Value");
                    break;

                default:
                    s._object = info.GetValue("Value", s);
                    break;
                }

                return(s);
            }
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
0
        /// <inheritdoc/>
        public virtual bool CopyFrom(object obj, bool copyWithDataReferences)
        {
            if (object.ReferenceEquals(this, obj))
            {
                return(true);
            }

            var from = obj as BarGraphPlotStyle;

            if (null != from)
            {
                _relInnerGapX         = from._relInnerGapX;
                _relOuterGapX         = from._relOuterGapX;
                _xSizeLogical         = from._xSizeLogical;
                _xOffsetLogical       = from._xOffsetLogical;
                _independentFillColor = from._independentFillColor;
                ChildCloneToMember(ref _fillBrush, from._fillBrush);
                _independentFrameColor = from._independentFrameColor;
                ChildCloneToMember(ref _framePen, from._framePen);
                _startAtPreviousItem  = from._startAtPreviousItem;
                _previousItemYGap     = from._previousItemYGap;
                _usePhysicalBaseValue = from._usePhysicalBaseValue;
                _baseValue            = from._baseValue;
                EhSelfChanged();
                return(true);
            }
            return(false);
        }
 void DisplayData(int layerNumber, Altaxo.Data.AltaxoVariant x, Altaxo.Data.AltaxoVariant y)
 {
     Current.DataDisplay.WriteOneLine(string.Format(
                                          "Layer({0}) X={1}, Y={2}",
                                          layerNumber,
                                          x,
                                          y));
 }
Ejemplo n.º 7
0
 public void Swap(int i, int j)
 {
     foreach (DataColumn col in _colsToSwap)
     {
         _var   = col[i];
         col[i] = col[j];
         col[j] = _var;
     }
 }
    public void MergeYBoundsInto(IPlotArea layer, IPhysicalBoundaries pb, PlotItemCollection coll)
    {
      Dictionary<G2DPlotItem, Processed2DPlotData> plotDataList;
      IPhysicalBoundaries 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 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++;

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

          // 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]);

            }
          }
        }
      }
    }
Ejemplo n.º 9
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);
        }
        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));
        }
Ejemplo n.º 11
0
		// 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));
			}
		}
Ejemplo n.º 12
0
 // indexers
 public override void SetValueAt(int i, AltaxoVariant val)
 {
     try
     {
         this[i] = val.ToDateTime();
     }
     catch (Exception ex)
     {
         throw new ApplicationException(string.Format("Error: Try to set {0}[{1}] with the string {2}, exception: {3}", TypeAndName, i, val.ToString(), ex.Message));
     }
 }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
 public override bool vop_Subtraction_Rev(AltaxoVariant c2, out DataColumn c3)
 {
     if (c2.IsType(AltaxoVariant.Content.VDateTime))
     {
         var c22 = (DateTime)c2;
         c3 = c22 - this;
         return(true);
     }
     c3 = null;
     return(false);
 }
Ejemplo n.º 15
0
 // indexers
 public override void SetValueAt(int i, AltaxoVariant val)
 {
     if (val.IsTypeOrNull(AltaxoVariant.Content.VDateTime))
     {
         this[i] = (DateTime)val.m_Object;
     }
     else
     {
         throw new ApplicationException("Error: Try to set " + this.TypeAndName + "[" + i + "] with " + val.ToString());
     }
 }
Ejemplo n.º 16
0
 public override bool vop_Subtraction(AltaxoVariant c2, out DataColumn c3)
 {
     if (((AltaxoVariant)c2).IsType(AltaxoVariant.Content.VDateTime))
     {
         DateTime c22 = (DateTime)c2;
         c3 = this - c22;
         return(true);
     }
     c3 = null;
     return(false);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Finds the source row for a given value inside a given row range.
 /// </summary>
 /// <param name="srcXCol">Column where the value must be found.</param>
 /// <param name="xVal">Value to find.</param>
 /// <param name="range">Range of rows.</param>
 /// <returns>The row for which the element is equal to the value, or -1 if the value could not be found.</returns>
 private static int FindSrcXRow(DataColumn srcXCol, AltaxoVariant xVal, ContiguousIntegerRange range)
 {
     // Find the src row
     foreach (int idx in range)
     {
         if (srcXCol[idx] == xVal)
         {
             return(idx);
         }
     }
     return(-1);
 }
Ejemplo n.º 18
0
            public void Swap(int i, int j)
            {
                _table.DataColumns.SwapColumnPositions(i, j);
                DataColumnCollection prop = _table.PropCols;

                for (int n = 0; n < _propColumns; n++)
                {
                    _var       = prop[n][i];
                    prop[n][i] = prop[n][j];
                    prop[n][j] = _var;
                }
            }
Ejemplo n.º 19
0
        protected override string SetScaleOrgEnd(Altaxo.Data.AltaxoVariant org, Altaxo.Data.AltaxoVariant end)
        {
            var o = (DateTime)org;
            var e = (DateTime)end;

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

            InternalSetOrgEnd(o, e, false, false);

            return(null);
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
 /// <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");
     }
 }
Ejemplo n.º 22
0
            public void Swap(int i, int j)
            {
                int iNew = _selIndices[i];
                int jNew = _selIndices[j];

                _table.DataColumns.SwapColumnPositions(iNew, jNew);
                DataColumnCollection prop = _table.PropCols;

                for (int n = 0; n < _propColumns; n++)
                {
                    _var          = prop[n][iNew];
                    prop[n][iNew] = prop[n][jNew];
                    prop[n][jNew] = _var;
                }
            }
Ejemplo n.º 23
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);
     }
 }
Ejemplo n.º 24
0
        protected override string SetScaleOrgEnd(Altaxo.Data.AltaxoVariant org, Altaxo.Data.AltaxoVariant end)
        {
            var scaleLinkedTo = ScaleLinkedTo;

            if (null != scaleLinkedTo)
            {
                if (!IsStraightLink)
                {
                    org = (org - LinkOrgA) / LinkOrgB;
                    end = (end - LinkEndA) / LinkEndB;
                }

                throw new NotImplementedException("What should we do here?");
                //return scaleLinkedTo.SetScaleOrgEnd(org, end);
            }
            return(null);
        }
Ejemplo n.º 25
0
            public override double PhysicalVariantToNormal(Altaxo.Data.AltaxoVariant x)
            {
                switch (_segmentScaling)
                {
                case ScaleSegmentType.DifferenceToOrg:
                    x += _underlyingScale.NormalToPhysicalVariant(_relOrg);
                    break;

                case ScaleSegmentType.RatioToOrg:
                    x *= _underlyingScale.NormalToPhysicalVariant(_relOrg);
                    break;
                }

                double r = _underlyingScale.PhysicalVariantToNormal(x);

                return((r - _relOrg) / (_relEnd - _relOrg));
            }
Ejemplo n.º 26
0
        } // end of function

        private bool CalculateCrossCoordinates(PointD2D crossRootLayerCoord, out Altaxo.Data.AltaxoVariant x, out Altaxo.Data.AltaxoVariant y)
        {
            var layer = _cachedActiveLayer as XYPlotLayer;

            if (layer == null)
            {
                x = new AltaxoVariant();
                y = new AltaxoVariant();
                return(false);
            }

            var layerCoord = _cachedActiveLayerTransformation.InverseTransformPoint(crossRootLayerCoord);

            layer.CoordinateSystem.LayerToLogicalCoordinates(layerCoord.X, layerCoord.Y, out var r);
            x = layer.XAxis.NormalToPhysicalVariant(r.RX);
            y = layer.YAxis.NormalToPhysicalVariant(r.RY);
            return(true);
        }
        } // end of function

        void DisplayCrossCoordinates()
        {
            XYPlotLayer layer = _grac.ActiveLayer;

            if (layer == null)
            {
                return;
            }

            PointF layerXY = layer.GraphToLayerCoordinates(m_Cross);



            Logical3D r;

            layer.CoordinateSystem.LayerToLogicalCoordinates(layerXY.X, layerXY.Y, out r);
            Altaxo.Data.AltaxoVariant xphys = layer.XAxis.NormalToPhysicalVariant(r.RX);
            Altaxo.Data.AltaxoVariant yphys = layer.YAxis.NormalToPhysicalVariant(r.RY);

            this.DisplayData(_grac.CurrentLayerNumber, xphys, yphys);
        }
Ejemplo n.º 28
0
        public void CopyFrom(DropLinePlotStyle from, Main.EventFiring eventFiring)
        {
            if (object.ReferenceEquals(this, from))
            {
                return;
            }

            using (var suspendToken = SuspendGetToken())
            {
                _independentSkipFrequency         = from._independentSkipFrequency;
                _skipFrequency                    = from._skipFrequency;
                _ignoreMissingDataPoints          = from._ignoreMissingDataPoints;
                _independentOnShiftingGroupStyles = from._independentOnShiftingGroupStyles;

                _dropTargets = from._dropTargets; // immutable

                _additionalDropTargetIsEnabled            = from._additionalDropTargetIsEnabled;
                _additionalDropTargetPerpendicularAxis    = from._additionalDropTargetPerpendicularAxis;
                _additionalDropTargetUsePhysicalBaseValue = from._additionalDropTargetUsePhysicalBaseValue;
                _additionalDropTargetBaseValue            = from._additionalDropTargetBaseValue;

                ChildCopyToMember(ref _pen, from._pen);

                _independentColor = from._independentColor;

                _independentSymbolSize = from._independentSymbolSize;
                _symbolSize            = from._symbolSize;
                _lineWidth1Offset      = from._lineWidth1Offset;
                _lineWidth1Factor      = from._lineWidth1Factor;

                _gapAtStartOffset = from._gapAtStartOffset;
                _gapAtStartFactor = from._gapAtStartFactor;
                _gapAtEndOffset   = from._gapAtEndOffset;
                _gapAtEndFactor   = from._gapAtEndFactor;

                EhSelfChanged(EventArgs.Empty);

                suspendToken.Resume(eventFiring);
            }
        }
Ejemplo n.º 29
0
        int IComparable.CompareTo(object obj)
        {
            if (!(obj is AltaxoVariant))
            {
                throw new Exception("Can not compare AltaxoVariant to an object of type " + obj.GetType().ToString());
            }

            AltaxoVariant from = (AltaxoVariant)obj;

            if (this.m_Content != from.m_Content)
            {
                throw new Exception(string.Format("A variant of type {0} can not be compared to a variant of type {1}", this.m_Content.ToString(), from.m_Content.ToString()));
            }

            // both have the same content
            switch (m_Content)
            {
            case Content.VNull:
                return(0);

            case Content.VDouble:
                return(m_Double.CompareTo(from.m_Double));

            case Content.VDateTime:
                return(((DateTime)m_Object).CompareTo(from.m_Object));

            case Content.VString:
                return(((string)m_Object).CompareTo(from.m_Object));

            default:
                if (this.m_Object is IComparable)
                {
                    return(((IComparable)this).CompareTo(from.m_Object));
                }
                else
                {
                    throw new Exception(string.Format("The inner object of this AltaxoVariant (of typeof: {0}) does not implement IComparable", this.m_Object.GetType().ToString()));
                }
            }
        }
Ejemplo n.º 30
0
        } // end of function

        bool CalculateCrossCoordinates(out Altaxo.Data.AltaxoVariant x, out Altaxo.Data.AltaxoVariant y)
        {
            XYPlotLayer layer = _grac.ActiveLayer;

            if (layer == null)
            {
                x = new AltaxoVariant();
                y = new AltaxoVariant();
                return(false);
            }

            PointF layerXY = layer.GraphToLayerCoordinates(m_Cross);



            Logical3D r;

            layer.CoordinateSystem.LayerToLogicalCoordinates(layerXY.X, layerXY.Y, out r);
            x = layer.XAxis.NormalToPhysicalVariant(r.RX);
            y = layer.YAxis.NormalToPhysicalVariant(r.RY);
            return(true);
        }
Ejemplo n.º 31
0
        /// <summary>
        /// This function searches for patterns like aaa=bbb in the provided string. If it finds such a item, it creates a column named aaa
        /// and stores the value bbb at the same position in it as in the text column.
        /// </summary>
        /// <param name="strg">The string where to search for the patterns described above.</param>
        /// <param name="store">The column collection where to store the newly created columns of properties.</param>
        /// <param name="index">The index into the column where to store the property value.</param>
        public static void ExtractPropertiesFromString(string strg, Altaxo.Data.DataColumnCollection store, int index)
        {
            string pat;

            pat = @"(\S+)=(\S+)";

            var r = new Regex(pat, RegexOptions.Compiled | RegexOptions.IgnoreCase);

            for (Match m = r.Match(strg); m.Success; m = m.NextMatch())
            {
                string propname  = m.Groups[1].ToString();
                string propvalue = m.Groups[2].ToString();

                // System.Diagnostics.Trace.WriteLine("Found the pair " + propname + " : " + propvalue);

                if (!store.ContainsColumn(propname))
                {
                    Altaxo.Data.DataColumn col;
                    if (Altaxo.Serialization.DateTimeParsing.IsDateTime(propvalue))
                    {
                        col = new Altaxo.Data.DateTimeColumn();
                    }
                    else if (Altaxo.Serialization.NumberConversion.IsNumeric(propvalue))
                    {
                        col = new Altaxo.Data.DoubleColumn();
                    }
                    else
                    {
                        col = new Altaxo.Data.TextColumn();
                    }

                    store.Add(col, propname); // add the column to the collection
                }

                // now the column is present we can store the value in it.
                store[propname][index] = new Altaxo.Data.AltaxoVariant(propvalue);
            }
        }
Ejemplo n.º 32
0
        public virtual bool CopyFrom(object obj, bool copyWithDataReferences)
        {
            if (object.ReferenceEquals(this, obj))
            {
                return(true);
            }

            var from = obj as BarGraphPlotStyle;

            if (null != from)
            {
                _usePhysicalBaseValue = from._usePhysicalBaseValue;
                _baseValue            = from._baseValue;
                _startAtPreviousItem  = from._startAtPreviousItem;
                _previousItemZGap     = from._previousItemZGap;

                _independentColor = from._independentColor;
                _pen = from._pen;
                _useUniformCrossSectionThickness = from._useUniformCrossSectionThickness;

                _barShiftStrategy = from._barShiftStrategy;
                _barShiftMaxNumberOfItemsInOneDirection = from._barShiftMaxNumberOfItemsInOneDirection;
                _relInnerGapX = from._relInnerGapX;
                _relOuterGapX = from._relOuterGapX;
                _relInnerGapY = from._relInnerGapY;
                _relOuterGapY = from._relOuterGapY;

                _xSizeLogical   = from._xSizeLogical;
                _xOffsetLogical = from._xOffsetLogical;
                _ySizeLogical   = from._ySizeLogical;
                _yOffsetLogical = from._yOffsetLogical;

                EhSelfChanged();
                return(true);
            }
            return(false);
        }
Ejemplo n.º 33
0
		/// <summary>
		/// Calculates the ticks based on the org and end of the scale. Org and End now are given and can not be changed anymore.
		/// </summary>
		/// <param name="org">Scale origin.</param>
		/// <param name="end">Scale end.</param>
		/// <param name="scale">The scale.</param>
		public abstract void FinalProcessScaleBoundaries(AltaxoVariant org, AltaxoVariant end, Scale scale);
Ejemplo n.º 34
0
		/// <summary>
		/// Decides giving a raw org and end value, whether or not the scale boundaries should be extended to
		/// have more 'nice' values. If the boundaries should be changed, the function return true, and the
		/// org and end argument contain the proposed new scale boundaries.
		/// </summary>
		/// <param name="org">Raw scale org.</param>
		/// <param name="end">Raw scale end.</param>
		/// <param name="isOrgExtendable">True when the org is allowed to be extended.</param>
		/// <param name="isEndExtendable">True when the scale end can be extended.</param>
		/// <returns>True when org or end are changed. False otherwise.</returns>
		public abstract bool PreProcessScaleBoundaries(ref AltaxoVariant org, ref AltaxoVariant end, bool isOrgExtendable, bool isEndExtendable);
Ejemplo n.º 35
0
		protected override string FormatItem(AltaxoVariant item)
		{
			if (!string.IsNullOrEmpty(_formatString))
			{
				try
				{
					return string.Format(_formatString, item.ToObject());
				}
				catch (Exception)
				{
				}
			}
			return item.ToString();
		}
Ejemplo n.º 36
0
		public override bool vop_GreaterOrEqual(AltaxoVariant c2, out DataColumn c3)
		{
			if (((AltaxoVariant)c2).IsType(AltaxoVariant.Content.VDouble))
			{
				double c22 = (double)c2;
				c3 = this >= c22;
				return true;
			}
			c3 = null;
			return false;
		}
Ejemplo n.º 37
0
			/// <summary>Initializes a new instance of the <see cref="LocalArrayHolder"/> class.</summary>
			/// <param name="localArray">The local array of transformed y values. The array length is equal to the number of plot points.</param>
			/// <param name="pdata">The processed plot data. The plot range member of this instance is used to build a dictionary which associates the original row indices to the indices of the <paramref name="localArray"/>.</param>
			public LocalArrayHolder(AltaxoVariant[] localArray, Processed3DPlotData pdata)
			{
				_localArray = localArray;
				_originalRowIndexToPlotIndex = pdata.RangeList.GetDictionaryOfOriginalRowIndicesToPlotIndices();
			}
Ejemplo n.º 38
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++;
					G3DPlotItem 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;
		}
Ejemplo n.º 39
0
		private string DefaultDoubleConverter(AltaxoVariant x)
		{
			return ((double)x).ToString("r", _formatProvider);
		}
Ejemplo n.º 40
0
		public override bool vop_Division_Rev(AltaxoVariant c2, out DataColumn c3)
		{
			if (((AltaxoVariant)c2).IsType(AltaxoVariant.Content.VDouble))
			{
				double c22 = (double)c2;
				c3 = c22 / this;
				return true;
			}
			c3 = null;
			return false;
		}
Ejemplo n.º 41
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;
		}
Ejemplo n.º 42
0
		public override bool vop_Multiplication_Rev(AltaxoVariant c2, out DataColumn c3)
		{
			return vop_Multiplication(c2, out c3);
		}
Ejemplo n.º 43
0
		public override bool vop_Multiplication(AltaxoVariant c2, out DataColumn c3)
		{
			if (((AltaxoVariant)c2).IsType(AltaxoVariant.Content.VDouble))
			{
				double c22 = (double)c2;
				c3 = this * c22;
				return true;
			}
			c3 = null;
			return false;
		}
Ejemplo n.º 44
0
		/// <summary>
		/// Measures a couple of items and prepares them for being drawn.
		/// </summary>
		/// <param name="g">Graphics context.</param>
		/// <param name="font">Font used.</param>
		/// <param name="strfmt">String format used.</param>
		/// <param name="items">Array of items to be drawn.</param>
		/// <returns>An array of <see cref="IMeasuredLabelItem" /> that can be used to determine the size of each item and to draw it.</returns>
		public override IMeasuredLabelItem[] GetMeasuredItems(IGraphicsContext3D g, FontX3D font, AltaxoVariant[] items)
		{
			string[] titems = FormatItems(items);
			if (!string.IsNullOrEmpty(_prefix) || !string.IsNullOrEmpty(_suffix))
			{
				for (int i = 0; i < titems.Length; ++i)
					titems[i] = _prefix + titems[i] + _suffix;
			}

			MeasuredLabelItem[] litems = new MeasuredLabelItem[titems.Length];

			FontX3D localfont = font;

			for (int i = 0; i < titems.Length; ++i)
			{
				litems[i] = new MeasuredLabelItem(g, localfont, titems[i], _relativeLineSpacing, Alignment.Near, Alignment.Near, _textBlockAlignment);
			}

			return litems;
		}
Ejemplo n.º 45
0
		} // end of function

		private bool CalculateCrossCoordinates(PointD2D crossRootLayerCoord, out Altaxo.Data.AltaxoVariant x, out Altaxo.Data.AltaxoVariant y)
		{
			XYPlotLayer layer = _cachedActiveLayer as XYPlotLayer;
			if (layer == null)
			{
				x = new AltaxoVariant();
				y = new AltaxoVariant();
				return false;
			}

			var layerCoord = _cachedActiveLayerTransformation.InverseTransformPoint(crossRootLayerCoord);

			Logical3D r;
			layer.CoordinateSystem.LayerToLogicalCoordinates(layerCoord.X, layerCoord.Y, out r);
			x = layer.XAxis.NormalToPhysicalVariant(r.RX);
			y = layer.YAxis.NormalToPhysicalVariant(r.RY);
			return true;
		}
Ejemplo n.º 46
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;
		}
Ejemplo n.º 47
0
		private string DefaultTextConverter(AltaxoVariant x)
		{
			string s = x.ToString();

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

			return s;
		}
Ejemplo n.º 48
0
		public virtual bool CopyFrom(object obj, bool copyWithDataReferences)
		{
			if (object.ReferenceEquals(this, obj))
				return true;

			var from = obj as BarGraphPlotStyle;
			if (null != from)
			{
				this._usePhysicalBaseValue = from._usePhysicalBaseValue;
				this._baseValue = from._baseValue;
				this._startAtPreviousItem = from._startAtPreviousItem;
				this._previousItemZGap = from._previousItemZGap;

				this._independentColor = from._independentColor;
				this._pen = from._pen;
				this._useUniformCrossSectionThickness = from._useUniformCrossSectionThickness;

				this._barShiftStrategy = from._barShiftStrategy;
				this._barShiftMaxNumberOfItemsInOneDirection = from._barShiftMaxNumberOfItemsInOneDirection;
				this._relInnerGapX = from._relInnerGapX;
				this._relOuterGapX = from._relOuterGapX;
				this._relInnerGapY = from._relInnerGapY;
				this._relOuterGapY = from._relOuterGapY;

				this._xSizeLogical = from._xSizeLogical;
				this._xOffsetLogical = from._xOffsetLogical;
				this._ySizeLogical = from._ySizeLogical;
				this._yOffsetLogical = from._yOffsetLogical;

				EhSelfChanged();
				return true;
			}
			return false;
		}
Ejemplo n.º 49
0
		private string DefaultDateTimeConverter(AltaxoVariant x)
		{
			return ((DateTime)x).ToString("o");
		}
Ejemplo n.º 50
0
 // indexers
 public override void SetValueAt(int i, AltaxoVariant val)
 {
   if(val.IsTypeOrNull(AltaxoVariant.Content.VString))
     this[i] = (string)val;
   else
     this[i] = val.ToString();
   // throw new ApplicationException("Error: Try to set " + this.TypeAndName + "[" + i + "] with " + val.ToString());
 }
Ejemplo n.º 51
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 (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;
		}
Ejemplo n.º 52
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());
 }
Ejemplo n.º 53
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;
    }
Ejemplo n.º 54
0
		public override bool vop_ShiftRight_Rev(AltaxoVariant c2, out DataColumn c3)
		{
			if (((AltaxoVariant)c2).IsType(AltaxoVariant.Content.VDouble))
			{
				DoubleColumn c1 = this;
				int len = c1._count;
				Altaxo.Data.DoubleColumn c33 = new Altaxo.Data.DoubleColumn(len);
				long c22 = (long)(double)c2;
				for (int i = 0; i < len; i++)
					c33._data[i] = c22 >> ((int)c1._data[i]);
				c33._count = len;
				c3 = c33;
				return true;
			}
			c3 = null;
			return false;
		}
Ejemplo n.º 55
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);
		}
Ejemplo n.º 56
0
    /// <summary>
    /// Initialized a 2D identifier from the parallel axis and the physical value of the perpendicular axis.
    /// </summary>
    /// <param name="parallelAxisNumber">Number of parallel axis (0->X, 1->Y, 2->Z).</param>
    /// <param name="physicalValueOther">Physical value of the axis perendicular to the parallel axis.</param>
    /// <returns>A freshly created 2D line identifier.</returns>
    public static CSLineID FromPhysicalVariant(int parallelAxisNumber, AltaxoVariant physicalValueOther)
    {
      if (parallelAxisNumber < 0 || parallelAxisNumber > 2)
        throw new ArgumentOutOfRangeException("AxisNumber must be either 0, 1, or 2, but you provide: " + parallelAxisNumber.ToString());

      if (!physicalValueOther.Equals(physicalValueOther))
        throw new ArgumentException("You can not set physical values that return false when compared to itself, value is: " + physicalValueOther.ToString());

      
      CSLineID id = new CSLineID();
      id._parallelAxisNumber = parallelAxisNumber;
      id._physicalValueFirstOther = physicalValueOther;
      id._logicalValueFirstOther = double.NaN;
      id._usePhysicalValueFirstOther = true;

      id._logicalValueSecondOther = double.NaN;
      return id;
    }
Ejemplo n.º 57
0
		public void CopyFrom(DropLinePlotStyle from, Main.EventFiring eventFiring)
		{
			if (object.ReferenceEquals(this, from))
				return;

			using (var suspendToken = SuspendGetToken())
			{
				this._independentSkipFreq = from._independentSkipFreq;
				this._skipFreq = from._skipFreq;
				this._dropTargets = from._dropTargets; // immutable

				this._additionalDropTargetIsEnabled = from._additionalDropTargetIsEnabled;
				this._additionalDropTargetPerpendicularAxis = from._additionalDropTargetPerpendicularAxis;
				this._additionalDropTargetUsePhysicalBaseValue = from._additionalDropTargetUsePhysicalBaseValue;
				this._additionalDropTargetBaseValue = from._additionalDropTargetBaseValue;

				this._pen = from._pen; // immutable
				this._independentColor = from._independentColor;

				_independentSymbolSize = from._independentSymbolSize;
				_symbolSize = from._symbolSize;
				_lineWidth1Offset = from._lineWidth1Offset;
				_lineWidth1Factor = from._lineWidth1Factor;
				_lineWidth2Offset = from._lineWidth2Offset;
				_lineWidth2Factor = from._lineWidth2Factor;

				this._gapAtStartOffset = from._gapAtStartOffset;
				this._gapAtStartFactor = from._gapAtStartFactor;
				this._gapAtEndOffset = from._gapAtEndOffset;
				this._gapAtEndFactor = from._gapAtEndFactor;

				EhSelfChanged(EventArgs.Empty);

				suspendToken.Resume(eventFiring);
			}
		}
Ejemplo n.º 58
0
		public void Add(AltaxoVariant additionalTick)
		{
			_additionalTicks.Add(additionalTick);
			EhSelfChanged();
		}
Ejemplo n.º 59
0
		public override bool vop_ShiftLeft(AltaxoVariant c2, out DataColumn c3)
		{
			if (((AltaxoVariant)c2).IsType(AltaxoVariant.Content.VDouble))
			{
				int c22 = (int)(double)c2;
				c3 = this << c22;
				return true;
			}
			c3 = null;
			return false;
		}
Ejemplo n.º 60
0
 public override bool vop_ShiftRight(AltaxoVariant c2, out DataColumn c3)
 {
   if(((AltaxoVariant)c2).IsType(AltaxoVariant.Content.VDouble))
   {
     DoubleColumn c1=this;
     int len = c1.m_Count;
     Altaxo.Data.DoubleColumn c33 = new Altaxo.Data.DoubleColumn(len);
     int c22 = (int)(double)c2;
     for(int i=0;i<len;i++)
       c33.m_Array[i] = ((long)c1.m_Array[i]) >> c22;
     c33.m_Count = len;
     c3=c33;
     return true;
   }
   c3=null;
   return false;
 }