Exemplo n.º 1
0
        /// <summary>
        /// Apply styles, beginning at item 'pivotidx' in this collection, iterative backwards up and down the hierarchy.
        /// It stops at the first item of a collection here or down the hierarchy that do not inherit from it's parent collection.
        /// </summary>
        /// <param name="pivotidx">The index of the item where the application process starts.</param>
        /// <returns>The plot item collection where the process stops.</returns>
        protected PlotItemCollection ApplyStylesIterativeBackward(int pivotidx)
        {
            // if the pivot is lower than 0, we first distibute all changes to the first item and
            // then from the first item again down the line
            if (pivotidx > 0)
            {
                _plotGroupStyles.BeginApply();
                for (int i = pivotidx; i >= 0; i--)
                {
                    IGPlotItem pi = _plotItems[i];
                    if (pi is PlotItemCollection)
                    {
                        _plotGroupStyles.Step(-1);
                        var pic = (PlotItemCollection)pi;
                        pic.ApplyStylesBackward_HierarchyUpOnly(_plotGroupStyles);
                    }
                    else
                    {
                        pi.ApplyGroupStyles(_plotGroupStyles);
                        if (i > 0)
                        {
                            _plotGroupStyles.Step(-1);
                        }
                    }
                }
                _plotGroupStyles.EndApply();
            }

            // now use this styles to copy to the parent
            bool transferToParentStyles =
                ParentCollection != null &&
                ParentCollection._plotGroupStyles.Count != 0 &&
                ParentCollection._plotGroupStyles.DistributeToChildGroups &&
                _plotGroupStyles.InheritFromParentGroups;

            PlotItemCollection rootCollection = this;

            if (transferToParentStyles)
            {
                PlotGroupStyleCollection.TransferFromTo(_plotGroupStyles, ParentCollection._plotGroupStyles);
                rootCollection = ParentCollection.ApplyStylesIterativeBackward(ParentCollection._plotGroupStyles.Count - 1);
            }

            return(rootCollection);
        }
Exemplo n.º 2
0
        public void CopyFrom(PlotItemCollection from, Gdi.GraphCopyOptions options)
        {
            if (object.ReferenceEquals(this, from))
            {
                return;
            }

            if (Gdi.GraphCopyOptions.CopyLayerPlotStyles == (Gdi.GraphCopyOptions.CopyLayerPlotStyles & options))
            {
                var thisFlat = Flattened;
                var fromFlat = from.Flattened;
                int len      = Math.Min(thisFlat.Length, fromFlat.Length);
                for (int i = 0; i < len; i++)
                {
                    thisFlat[i].SetPlotStyleFromTemplate(fromFlat[i], PlotGroupStrictness.Strict);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Distribute the changes made to the plotitem 'pivotitem' to all other items in the collection and if neccessary, also up and down the plot item tree.
        /// </summary>
        /// <param name="pivotitem">The plot item where changes to the plot item's styles were made.</param>
        public void DistributeChanges(IGPlotItem pivotitem)
        {
            int pivotidx = _plotItems.IndexOf(pivotitem);

            if (pivotidx < 0)
            {
                return;
            }

            // Distribute the changes backward to the first item
            PrepareStylesIterativeBackward(pivotidx, ParentLayer);
            PlotItemCollection rootCollection = ApplyStylesIterativeBackward(pivotidx);

            // now prepare and apply the styles forward normally beginning from the root collection
            // we can set the parent styles to null since rootCollection is the lowest collection that don't inherit from a lower group.
            rootCollection.PrepareGroupStylesForward_HierarchyUpOnly(null, ParentLayer);
            rootCollection.ApplyGroupStylesForward_HierarchyUpOnly(null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlotItemCollection"/> class.
        /// </summary>
        /// <param name="owner">The owner of this collection.</param>
        /// <param name="plotItems">The plot items that should initially belong to this collection.</param>
        /// <param name="clonePlotItems">If set to <c>true</c> the plot items are cloned before added to this collection. If false, the plot items are added directly to this collection.</param>
        public PlotItemCollection(XYZPlotLayer owner, PlotItemCollection plotItems, bool clonePlotItems)
        {
            _parent          = owner;
            _plotGroupStyles = new PlotGroupStyleCollection()
            {
                ParentObject = this
            };
            if (clonePlotItems)
            {
                _plotItems = new ObservableList <IGPlotItem>(plotItems.Select(pi => { var result = (IGPlotItem)pi.Clone(); result.ParentObject = this; return(result); }));
            }
            else
            {
                _plotItems = new ObservableList <IGPlotItem>(plotItems);
            }
            _plotItems.CollectionChanged += EhPlotItemsCollectionChanged;

            // special way neccessary to handle plot groups
            ChildCopyToMember(ref _plotGroupStyles, plotItems._plotGroupStyles);
        }
Exemplo n.º 5
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                PlotItemCollection s = null != o ? (PlotItemCollection)o : new PlotItemCollection();

                int count     = info.OpenArray();
                var plotItems = new IGPlotItem[count];

                for (int i = 0; i < count; i++)
                {
                    s.Add((IGPlotItem)info.GetValue("PlotItem", s));
                }
                info.CloseArray(count);

                s._plotGroupStyles = (PlotGroupStyleCollection)info.GetValue("GroupStyles", s);
                if (null != s._plotGroupStyles)
                {
                    s._plotGroupStyles.ParentObject = s;
                }

                return(s);
            }
Exemplo n.º 6
0
 /// <summary>
 /// Copy constructor. Clones (!) all items. The parent owner is set to null and has to be set afterwards.
 /// </summary>
 /// <param name="from">The PlotItemCollection to clone this list from.</param>
 public PlotItemCollection(PlotItemCollection from)
     :
     this(null, from, true)
 {
 }