Esempio n. 1
0
        private void InitLinkTargetScales(bool initData)
        {
            if (initData)
            {
                _linkScaleChoices = new SelectableListNodeList
                {
                    new SelectableListNode("None", null, false)
                };

                // find the parent layer
                var mylayer = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing <HostLayer>(_doc);
                if (null != mylayer)
                {
                    var siblingLayers = mylayer.SiblingLayers;
                    if (null != siblingLayers)
                    {
                        var scaleLinkedTo = _doc is LinkedScale ? ((LinkedScale)_doc).ScaleLinkedTo : null;

                        for (int i = 0; i < siblingLayers.Count; ++i)
                        {
                            var lxy = siblingLayers[i] as XYPlotLayer;
                            if (null == lxy)
                            {
                                continue;
                            }

                            for (int j = 0; j < lxy.Scales.Count; ++j)
                            {
                                var scale = lxy.Scales[j];

                                if (LinkedScale.WouldScaleBeDependentOnMe(_doc, scale))
                                {
                                    continue; // Scale would be dependent on _doc, thus we can not link to it
                                }
                                var    scaleName = j == 0 ? "x" : (j == 1 ? "y" : (j == 2 ? "z" : string.Format("{0}.", j)));
                                string name      = string.Format("Layer[{0}] - {1} scale", i, scaleName);
                                _linkScaleChoices.Add(new SelectableListNode(name, scale, object.ReferenceEquals(scale, scaleLinkedTo)));
                            }
                        }
                    }
                }

                if (null == _linkScaleChoices.FirstSelectedNode)
                {
                    _linkScaleChoices[0].IsSelected = true;
                }
            }

            if (_view != null)
            {
                _view.InitializeLinkTargets(_linkScaleChoices);
            }
        }
Esempio n. 2
0
        private void SetupOldAxis(int idx, Altaxo.Graph.Scales.Deprecated.Scale axis, bool isLinked, double orgA, double orgB, double endA, double endB)
        {
            Scale transScale = null;

            if (axis is Altaxo.Graph.Scales.Deprecated.TextScale)
            {
                transScale = new TextScale();
            }
            else if (axis is Altaxo.Graph.Scales.Deprecated.DateTimeScale)
            {
                transScale = new DateTimeScale();
            }
            else if (axis is Altaxo.Graph.Scales.Deprecated.Log10Scale)
            {
                transScale = new Log10Scale();
            }
            else if (axis is Altaxo.Graph.Scales.Deprecated.AngularScale)
            {
                transScale = (axis as Altaxo.Graph.Scales.Deprecated.AngularScale).UseDegrees ? new AngularDegreeScale() : (Scale) new AngularRadianScale();
            }
            else if (axis is Altaxo.Graph.Scales.Deprecated.LinearScale)
            {
                transScale = new LinearScale();
            }
            else
            {
                throw new ArgumentException("Axis type unknown");
            }

            if (transScale.RescalingObject is IUnboundNumericScaleRescaleConditions)
            {
                (transScale.RescalingObject as IUnboundNumericScaleRescaleConditions).SetUserParameters(BoundaryRescaling.AutoTempFixed, BoundariesRelativeTo.Absolute, axis.OrgAsVariant, BoundaryRescaling.AutoTempFixed, BoundariesRelativeTo.Absolute, axis.EndAsVariant);
            }

            if (transScale.RescalingObject is Altaxo.Graph.Scales.Rescaling.NumericScaleRescaleConditions &&
                axis.RescalingObject is Altaxo.Graph.Scales.Rescaling.NumericScaleRescaleConditions)
            {
                ((Altaxo.Graph.Scales.Rescaling.NumericScaleRescaleConditions)transScale.RescalingObject).CopyFrom((Altaxo.Graph.Scales.Rescaling.NumericScaleRescaleConditions)axis.RescalingObject);
            }

            if (isLinked)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                var ls = new LinkedScale(transScale, idx);
#pragma warning restore CS0618 // Type or member is obsolete
                ls.SetLinkParameter(orgA, orgB, endA, endB);
                transScale = ls;
            }

            _scales[idx] = transScale;
        }