コード例 #1
0
ファイル: PlotItemCollection.cs プロジェクト: olesar/Altaxo
        /// <summary>
        /// Prepare group styles forward, from the first to the last item.
        /// The function is called recursively for child PlotItemCollections, but only up in the hierarchy.
        /// This function therefore has no influence on items down in hierarchie, i.e. parental PlotItemCollections.
        /// </summary>
        /// <param name="parentGroupStyles">The parent plot group style collection.</param>
        /// <param name="layer">The plot layer.</param>
        /// <remarks>The preparation is used for:
        /// <para>BarGraph: to count items, calculating the width and position of each item afterwards.</para>
        /// <para>It is <b>not</b> used to enumerate colors, line styles etc., since this is done during the Apply stage.</para>
        /// </remarks>
        protected void PrepareGroupStylesForward_HierarchyUpOnly(PlotGroupStyleCollection parentGroupStyles, Graph3D.IPlotArea layer)
        {
            bool transferFromParentStyles =
                parentGroupStyles != null &&
                parentGroupStyles.Count != 0 &&
                parentGroupStyles.DistributeToChildGroups &&
                _plotGroupStyles.InheritFromParentGroups;

            // Announce the local plot group styles, that we start preparing
            _plotGroupStyles.BeginPrepare();

            //string thisname = Main.DocumentPath.GetPathString(this, int.MaxValue);
            //System.Diagnostics.Debug.WriteLine(string.Format("{0}:Begin:PrepareFWHUO", thisname));

            // if TransferFromParentStyles was choosen, transfer some of the plot group settings of the parental plot group styles to the local styles
            if (transferFromParentStyles)
            {
                PlotGroupStyleCollection.TransferFromTo(parentGroupStyles, _plotGroupStyles);
                //System.Diagnostics.Debug.WriteLine(string.Format("{0}:Begin:PrepareFWHUO (transfer from parent style", thisname));
            }

            // for each PlotItem in this collection, announce the preparation, using the local plot group style collection
            // after each item, announce a step to the plot group styles, so that the properties (like color etc.) can be stepped forward
            int last = _plotItems.Count - 1;

            for (int i = 0; i <= last; i++)
            {
                IGPlotItem pi = _plotItems[i];
                if (pi is PlotItemCollection)
                {
                    var pic = (PlotItemCollection)pi;
                    pic.PrepareGroupStylesForward_HierarchyUpOnly(_plotGroupStyles, layer);
                    _plotGroupStyles.PrepareStepIfForeignSteppingFalse(((PlotItemCollection)pi)._plotGroupStyles);
                }
                else
                {
                    pi.PrepareGroupStyles(_plotGroupStyles, layer);
                    _plotGroupStyles.PrepareStep();
                }
            }

            // after all our own PlotItems are prepared now,
            // if TransferFromParentStyles was choosen, transfer our own plot group settings back to the parental plot group styles
            // so that the parental plot group can continue i.e. with the color etc.
            if (transferFromParentStyles)
            {
                PlotGroupStyleCollection.TransferFromTo(_plotGroupStyles, parentGroupStyles);
                //System.Diagnostics.Debug.WriteLine(string.Format("{0}:End:PrepareFWHUO (transfer back to parent style", thisname));
            }

            // after preparation of all plot items is done, announce the end of preparation,
            // some of the calculations can be done only now.
            _plotGroupStyles.EndPrepare();
            //System.Diagnostics.Debug.WriteLine(string.Format("{0}:End:PrepareFWHUO", thisname));
        }
コード例 #2
0
        /// <summary>
        /// Prepare styles forward, but only up in the hierarchy.
        /// </summary>
        /// <param name="parentstyles">The parent group style collection.</param>
        /// <param name="layer">The plot layer.</param>
        protected void PrepareStylesForward_HierarchyUpOnly(PlotGroupStyleCollection parentstyles, IPlotArea layer)
        {
            bool transferFromParentStyles =
                parentstyles != null &&
                parentstyles.Count != 0 &&
                parentstyles.DistributeToChildGroups &&
                this._styles.InheritFromParentGroups;

            _styles.BeginPrepare();

            string thisname = Main.DocumentPath.GetPathString(this, int.MaxValue);

            System.Diagnostics.Debug.WriteLine(string.Format("{0}:Begin:PrepareFWHUO", thisname));
            if (transferFromParentStyles)
            {
                PlotGroupStyleCollection.TransferFromTo(parentstyles, _styles);
                System.Diagnostics.Debug.WriteLine(string.Format("{0}:Begin:PrepareFWHUO (transfer from parent style", thisname));
            }


            // now distibute the styles from the first item down to the last item
            int last = _plotItems.Count - 1;

            for (int i = 0; i <= last; i++)
            {
                IGPlotItem pi = _plotItems[i];
                if (pi is PlotItemCollection)
                {
                    PlotItemCollection pic = (PlotItemCollection)pi;
                    pic.PrepareStylesForward_HierarchyUpOnly(_styles, layer);
                    _styles.PrepareStepIfForeignSteppingFalse(((PlotItemCollection)pi)._styles);
                }
                else
                {
                    pi.PrepareStyles(_styles, layer);
                    _styles.PrepareStep();
                }
            }

            if (transferFromParentStyles)
            {
                PlotGroupStyleCollection.TransferFromTo(_styles, parentstyles);
                System.Diagnostics.Debug.WriteLine(string.Format("{0}:End:PrepareFWHUO (transfer back to parent style", thisname));
            }

            _styles.EndPrepare();
            System.Diagnostics.Debug.WriteLine(string.Format("{0}:End:PrepareFWHUO", thisname));
        }
コード例 #3
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)
            {
                _styles.BeginApply();
                for (int i = pivotidx; i >= 0; i--)
                {
                    IGPlotItem pi = _plotItems[i];
                    if (pi is PlotItemCollection)
                    {
                        _styles.Step(-1);
                        PlotItemCollection pic = (PlotItemCollection)pi;
                        pic.ApplyStylesBackward_HierarchyUpOnly(_styles);
                    }
                    else
                    {
                        pi.ApplyStyles(_styles);
                        if (i > 0)
                        {
                            _styles.Step(-1);
                        }
                    }
                }
                _styles.EndApply();
            }


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

            PlotItemCollection rootCollection = this;

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

            return(rootCollection);
        }
コード例 #4
0
ファイル: PlotItemCollection.cs プロジェクト: olesar/Altaxo
        /// <summary>
        /// Apply plot group styles forward, from the first to the last item.
        /// The function is called recursively for child PlotItemCollections, but only up in the hierarchy.
        /// This function therefore has no influence on items down in hierarchie, i.e. parental PlotItemCollections.
        /// </summary>
        /// <param name="parentGroupStyles">The parent plot group style collection.</param>
        /// <remarks>The application is used for example:
        /// <para>BarGraph: to calculate the exact position of each plot item.</para>
        /// <para>Color: To step forward through the available colors and apply each color to another PlotItem.</para>
        /// </remarks>

        protected void ApplyGroupStylesForward_HierarchyUpOnly(PlotGroupStyleCollection parentGroupStyles)
        {
            bool transferFromParentStyles =
                parentGroupStyles != null &&
                parentGroupStyles.Count != 0 &&
                parentGroupStyles.DistributeToChildGroups &&
                _plotGroupStyles.InheritFromParentGroups;

            // if TransferFromParentStyles was choosen, transfer some of the plot group settings of the parental plot group styles to the local styles
            if (transferFromParentStyles)
            {
                PlotGroupStyleCollection.TransferFromTo(parentGroupStyles, _plotGroupStyles);
            }

            // Announce the local plot group styles the begin of the application stage
            _plotGroupStyles.BeginApply();

            // for each PlotItem in this collection, announce the application, using the local plot group style collection
            // after each item, announce an application step (of stepwidth 1) to the plot group styles, so that the properties (like color etc.) can be stepped forward
            int last = _plotItems.Count - 1;

            for (int i = 0; i <= last; i++)
            {
                IGPlotItem pi = _plotItems[i];
                if (pi is PlotItemCollection)
                {
                    var pic = (PlotItemCollection)pi;
                    pic.ApplyGroupStylesForward_HierarchyUpOnly(_plotGroupStyles);
                    _plotGroupStyles.StepIfForeignSteppingFalse(1, ((PlotItemCollection)pi)._plotGroupStyles);
                }
                else
                {
                    pi.ApplyGroupStyles(_plotGroupStyles);
                    _plotGroupStyles.Step(1);
                }
            }
            // after application of PlotGroupStyles to all the plot items is done, announce the end of application,
            _plotGroupStyles.EndApply();

            if (transferFromParentStyles)
            {
                PlotGroupStyleCollection.TransferFromToIfBothSteppingEnabled(_plotGroupStyles, parentGroupStyles);
                parentGroupStyles.SetAllToApplied(); // to indicate that we have applied this styles and so to enable stepping
            }
        }
コード例 #5
0
        /// <summary>
        /// Apply styles forward, but only up in the hierarchy.
        /// </summary>
        /// <param name="parentstyles">The parent group style collection.</param>
        protected void ApplyStylesForward_HierarchyUpOnly(PlotGroupStyleCollection parentstyles)
        {
            bool transferFromParentStyles =
                parentstyles != null &&
                parentstyles.Count != 0 &&
                parentstyles.DistributeToChildGroups &&
                this._styles.InheritFromParentGroups;

            if (transferFromParentStyles)
            {
                PlotGroupStyleCollection.TransferFromTo(parentstyles, _styles);
            }

            _styles.BeginApply();

            // now distibute the styles from the first item down to the last item
            int last = _plotItems.Count - 1;

            for (int i = 0; i <= last; i++)
            {
                IGPlotItem pi = _plotItems[i];
                if (pi is PlotItemCollection)
                {
                    PlotItemCollection pic = (PlotItemCollection)pi;
                    pic.ApplyStylesForward_HierarchyUpOnly(_styles);
                    _styles.StepIfForeignSteppingFalse(1, ((PlotItemCollection)pi)._styles);
                }
                else
                {
                    pi.ApplyStyles(_styles);
                    _styles.Step(1);
                }
            }
            _styles.EndApply();

            if (transferFromParentStyles)
            {
                PlotGroupStyleCollection.TransferFromToIfBothSteppingEnabled(_styles, parentstyles);
                parentstyles.SetAllToApplied(); // to indicate that we have applied this styles and so to enable stepping
            }
        }
コード例 #6
0
ファイル: PlotItemCollection.cs プロジェクト: olesar/Altaxo
        /// <summary>
        /// Prepare 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>
        /// <param name="layer">The plot layer.</param>
        protected void PrepareStylesIterativeBackward(int pivotidx, IPlotArea layer)
        {
            // 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.BeginPrepare();
                for (int i = pivotidx; i >= 0; i--)
                {
                    IGPlotItem pi = _plotItems[i];
                    if (pi is PlotItemCollection)
                    {
                        _plotGroupStyles.PrepareStep();
                        var pic = (PlotItemCollection)pi;
                        pic.PrepareStylesBackward_HierarchyUpOnly(_plotGroupStyles, layer);
                    }
                    else
                    {
                        pi.PrepareGroupStyles(_plotGroupStyles, layer);
                        if (i > 0)
                        {
                            _plotGroupStyles.PrepareStep();
                        }
                    }
                }
                _plotGroupStyles.EndPrepare();
            }

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

            if (transferToParentStyles)
            {
                PlotGroupStyleCollection.TransferFromTo(_plotGroupStyles, ParentCollection._plotGroupStyles);
                ParentCollection.ApplyStylesIterativeBackward(ParentCollection._plotGroupStyles.Count - 1);
            }
        }
コード例 #7
0
        /// <summary>
        /// Apply styles backward from the last item to the first, but only upwards in the hierarchy.
        /// </summary>
        /// <param name="styles"></param>
        protected void ApplyStylesBackward_HierarchyUpOnly(PlotGroupStyleCollection styles)
        {
            bool transferToLocalStyles =
                styles != null &&
                styles.Count != 0 &&
                styles.DistributeToChildGroups &&
                this._styles.InheritFromParentGroups;

            if (!transferToLocalStyles)
            {
                return;
            }

            PlotGroupStyleCollection.TransferFromTo(styles, _styles);

            _styles.BeginApply();
            // now distibute the styles from the first item down to the last item
            int last = _plotItems.Count - 1;

            for (int i = last; i >= 0; i--)
            {
                IGPlotItem pi = _plotItems[i];
                if (pi is PlotItemCollection)
                {
                    _styles.Step(-1);
                    ((PlotItemCollection)pi).ApplyStylesBackward_HierarchyUpOnly(_styles);
                }
                else
                {
                    pi.ApplyStyles(_styles);
                    _styles.Step(-1);
                }
            }
            _styles.EndApply();

            PlotGroupStyleCollection.TransferFromToIfBothSteppingEnabled(_styles, styles);
        }