public bool Apply()
        {
            // read axis title
            _doc.TitleText = m_View.AxisTitle;

            if (null != _axisLineStyleController)
            {
                if (!_axisLineStyleController.Apply())
                {
                    return(false);
                }
                else
                {
                    _doc.AxisLineStyle = (AxisLineStyle)_axisLineStyleController.ModelObject;
                }
            }

            _doc.ShowMajorLabels = m_View.ShowMajorLabels;
            _doc.ShowMinorLabels = m_View.ShowMinorLabels;

            // if we have offset applying, create a brand new AxisStyle instance
            double offset = m_View.PositionOffset / 100;

            if (0 != offset)
            {
                AxisStyle newDoc = new AxisStyle(CSLineID.FromIDandFirstLogicalOffset(_doc.StyleID, offset));
                newDoc.CopyWithoutIdFrom(_doc);
                _doc = newDoc;
            }


            return(true); // all ok
        }
        public static void AddAxis(AxisStyleCollection collection, AxisCreationArguments creationArgs)
        {
            var context = collection.GetPropertyContext();
            var axstyle = new AxisStyle(creationArgs.CurrentStyle, false, false, false, null, context);

            if (creationArgs.TemplateStyle != null && collection.Contains(creationArgs.TemplateStyle))
            {
                axstyle.CopyWithoutIdFrom(collection[creationArgs.TemplateStyle]);
                if (creationArgs.MoveAxis)
                {
                    collection.Remove(creationArgs.TemplateStyle);
                }
            }
            collection.Add(axstyle);
        }
Beispiel #3
0
        public override void FixupInternalDataStructures()
        {
            base.FixupInternalDataStructures();

            var layer = Main.AbsoluteDocumentPath.GetRootNodeImplementing <XYPlotLayer>(this);

            if (null == layer)
            {
                _cachedLayerSegment = null;

                _cachedScale?.Dispose();
                _cachedScale = null;
                return;
            }

            layer.CoordinateSystem.LayerToLogicalCoordinates(X, Y, out var rBegin);

            Logical3D rEnd = rBegin;

            switch (_scaleSpanType)
            {
            case FloatingScaleSpanType.IsLogicalValue:
                rEnd[_scaleNumber] = rBegin[_scaleNumber] + _scaleSpanValue;
                break;

            case FloatingScaleSpanType.IsPhysicalEndOrgDifference:
            {
                var physValue = layer.Scales[_scaleNumber].NormalToPhysicalVariant(rBegin[_scaleNumber]);
                physValue += _scaleSpanValue; // to be replaced by the scale span
                var logValue = layer.Scales[_scaleNumber].PhysicalVariantToNormal(physValue);
                rEnd[_scaleNumber] = logValue;
            }
            break;

            case FloatingScaleSpanType.IsPhysicalEndOrgRatio:
            {
                var physValue = layer.Scales[_scaleNumber].NormalToPhysicalVariant(rBegin[_scaleNumber]);
                physValue *= _scaleSpanValue; // to be replaced by the scale span
                var logValue = layer.Scales[_scaleNumber].PhysicalVariantToNormal(physValue);
                rEnd[_scaleNumber] = logValue;
            }
            break;
            }

            // axis style
            var csLineId = new CSLineID(_scaleNumber, rBegin);

            if (_axisStyle.StyleID != csLineId)
            {
                var propertyContext = this.GetPropertyContext();
                var axStyle         = new AxisStyle(new CSLineID(_scaleNumber, rBegin), false, false, false, null, propertyContext);
                axStyle.CopyWithoutIdFrom(_axisStyle);
                _axisStyle = axStyle;
            }

            _cachedScale?.Dispose();
            _cachedScale = new ScaleSegment(layer.Scales[_scaleNumber], rBegin[_scaleNumber], rEnd[_scaleNumber], _scaleSegmentType);
            _tickSpacing.FinalProcessScaleBoundaries(_cachedScale.OrgAsVariant, _cachedScale.EndAsVariant, _cachedScale);
            _cachedScale.TickSpacing = _tickSpacing;
            _cachedLayerSegment      = new LayerSegment(layer, _cachedScale, rBegin, rEnd, _scaleNumber);

            _axisStyle.FixupInternalDataStructures(_cachedLayerSegment, _cachedLayerSegment.GetAxisStyleInformation); // we use here special AxisStyleInformation not provided by the underlying CS, but by the layer segment
        }