Exemple #1
0
        /// <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));
        }
Exemple #2
0
        public override void PrepareGroupStyles(PlotGroupStyleCollection externalGroups, IPlotArea layer)
        {
            Processed2DPlotData pdata = GetRangesAndPoints(layer);

            if (null == _localGroups)
            {
                _localGroups = new PlotGroupStyleCollection()
                {
                    ParentObject = this
                }
            }
            ;

            using (var suspendToken = _localGroups.SuspendGetToken())
            {
                _localGroups.Clear();

                // first add missing local group styles
                _plotStyles.CollectLocalGroupStyles(externalGroups, _localGroups);

                // for the newly created group styles BeginPrepare must be called
                _localGroups.BeginPrepare();

                // now prepare the groups
                _plotStyles.PrepareGroupStyles(externalGroups, _localGroups, layer, pdata);

                // for the group styles in the local group, PrepareStep and EndPrepare must be called,
                _localGroups.PrepareStep();
                _localGroups.EndPrepare();

                suspendToken.ResumeSilently(); // we are not interested in changes in the _localGroup
            }
        }