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
        }
        private IMVCANController CreateAxisStyleController(AxisStyle doc, UseDocument useDocumentCopy)
        {
            var result = (AxisStyleController)Current.Gui.GetControllerAndControl(new object[] { doc }, typeof(AxisStyleController), useDocumentCopy);

            result.MadeDirty += EhAxisStyleControllerDirty;
            return(result);
        }
Пример #3
0
        CreateProfileViewStyle(string name)
        {
            ObjectId idPVStyle = ObjectId.Null;

            ProfileViewStyleCollection pvStyleCol = BaseObjs._civDoc.Styles.ProfileViewStyles;

            try{
                idPVStyle = pvStyleCol[name];
            }
            catch {}

            if (!idPVStyle.IsNull)
            {
                return(idPVStyle);
            }

            idPVStyle = pvStyleCol.Add(name);
            using (var tr = BaseObjs.startTransactionDb()){
                ProfileViewStyle pvStyle = (ProfileViewStyle)tr.GetObject(idPVStyle, OpenMode.ForWrite);

                AxisStyle axisStyle = pvStyle.BottomAxis;
                axisStyle.MajorTickStyle.Size     = 0.01;
                axisStyle.MajorTickStyle.Interval = 50;
                axisStyle.TitleStyle.Text         = "Stations";

                axisStyle = pvStyle.TopAxis;
                axisStyle.TitleStyle.Text = "Feet";

                tr.Commit();
            }

            return(idPVStyle);
        }
Пример #4
0
 public FloatingScale(Main.Properties.IReadOnlyPropertyBag context)
     : base(new ItemLocationDirectAutoSize())
 {
     _scaleSpanValue = 0.25;
     _tickSpacing    = new SpanTickSpacing();
     _axisStyle      = new AxisStyle(new CSLineID(0, 0), true, false, true, null, context);
 }
 public bool InitializeDocument(params object[] args)
 {
     if (args.Length == 0 || !(args[0] is AxisStyle))
     {
         return(false);
     }
     _doc = (AxisStyle)args[0];
     this.SetElements(true);
     return(true);
 }
Пример #6
0
        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);
        }
Пример #7
0
        void SetCoordinateSystemDependentObjects(CSLineID id)
        {
            // collect the AxisStyleIdentifier from the actual layer and also all possible AxisStyleIdentifier
            _axisStyleIds = new Dictionary <CSLineID, CSAxisInformation>();
            _axisStyleInfoSortedByName = new List <CSAxisInformation>();
            foreach (CSLineID ids in _doc.CoordinateSystem.GetJoinedAxisStyleIdentifier(_doc.AxisStyles.AxisStyleIDs, new CSLineID[] { id }))
            {
                CSAxisInformation info = _doc.CoordinateSystem.GetAxisStyleInformation(ids);
                _axisStyleIds.Add(info.Identifier, info);
                _axisStyleInfoSortedByName.Add(info);
            }

            _planeIdentifier = new List <CSPlaneID>();
            _planeIdentifier.Add(CSPlaneID.Front);


            _axisScaleController   = new AxisScaleController[2];
            _GridStyleController   = new Dictionary <CSPlaneID, IMVCANController>();
            _TitleFormatController = new Dictionary <CSLineID, IMVCANController>();
            _MajorLabelController  = new Dictionary <CSLineID, IMVCANController>();
            _MinorLabelController  = new Dictionary <CSLineID, IMVCANController>();

            _enableAxisStyle   = new Dictionary <CSLineID, bool>();
            _enableMajorLabels = new Dictionary <CSLineID, bool>();
            _enableMinorLabels = new Dictionary <CSLineID, bool>();
            foreach (CSLineID ident in _axisStyleIds.Keys)
            {
                AxisStyle prop = _doc.AxisStyles[ident];
                if (prop == null)
                {
                    _enableAxisStyle.Add(ident, false);
                    _enableMajorLabels.Add(ident, false);
                    _enableMinorLabels.Add(ident, false);
                }
                else
                {
                    _enableAxisStyle.Add(ident, true);
                    _enableMajorLabels.Add(ident, prop.ShowMajorLabels);
                    _enableMinorLabels.Add(ident, prop.ShowMinorLabels);
                }
            }
        }
Пример #8
0
        public virtual void Render(IRenderContext rc, PlotModel model)
        {
#if DEBUG_MAP
            Console.WriteLine("render line region axis " + this.Name);
#endif
            if (!AxisVisible)
            {
                return;
            }

            OxyColor grid_color = OxyColors.Red;
            if (Theme != null)
            {
                AxisStyle style = Theme.GetStyle(ThemeMode) as AxisStyle;
                TitleColor    = Helper.ConvertColorToOxyColor(style.TitleColor);
                TextColor     = Helper.ConvertColorToOxyColor(style.LabelColor);
                TicklineColor = Helper.ConvertColorToOxyColor(style.LineColor);
                grid_color    = Helper.ConvertColorToOxyColor(style.GridColor);
            }

            UpdateAutoPoints();
            switch (Position)
            {
            case AxisPosition.Left:
                UpdateDataLeft(rc, model);
                break;

            case AxisPosition.Right:
                UpdateDataRight(rc, model);
                break;

            case AxisPosition.Top:
                break;

            case AxisPosition.Bottom:
                break;
            }

            RenderAxis(rc, model, grid_color);
            //render border
            rc.DrawRectangle(_bound, OxyColors.Transparent, TicklineColor, 1);
        }
Пример #9
0
        void SetCurrentTabController(bool pageChanged)
        {
            switch (_currentPageName)
            {
            case "Contents":
                if (pageChanged)
                {
                    View.SelectTab(_currentPageName);
                    SetLayerSecondaryChoice();
                }
                if (null == _layerContentsController)
                {
                    _layerContentsController = (ILineScatterLayerContentsController)Current.Gui.GetControllerAndControl(new object[] { _doc.PlotItems }, typeof(ILineScatterLayerContentsController), UseDocument.Directly);
                }
                _currentController  = _layerContentsController;
                View.CurrentContent = _currentController.ViewObject;
                break;

            case "Position":
                if (pageChanged)
                {
                    View.SelectTab(_currentPageName);
                    SetLayerSecondaryChoice();
                }
                if (null == _layerPositionController)
                {
                    _layerPositionController            = new LayerPositionController(_doc);
                    _layerPositionController.ViewObject = new LayerPositionControl();
                }
                _currentController  = _layerPositionController;
                View.CurrentContent = _layerPositionController.ViewObject;
                break;


            case "Scale":
                if (pageChanged)
                {
                    View.SelectTab(_currentPageName);
                    SetHorzVertSecondaryChoice();
                }
                if (_axisScaleController[_currentScale] == null)
                {
                    _axisScaleController[_currentScale]            = new AxisScaleController(_doc, _currentScale);
                    _axisScaleController[_currentScale].ViewObject = new AxisScaleControl();
                }
                _currentController  = _axisScaleController[_currentScale];
                View.CurrentContent = _currentController.ViewObject;
                break;

            case "CS":
                if (pageChanged)
                {
                    View.SelectTab(_currentPageName);
                    SetLayerSecondaryChoice();
                }
                if (null == this._coordinateController)
                {
                    this._coordinateController = new Altaxo.Gui.Graph.CoordinateSystemController(_doc.CoordinateSystem);
                    Current.Gui.FindAndAttachControlTo(this._coordinateController);
                }
                _currentController  = this._coordinateController;
                View.CurrentContent = this._coordinateController.ViewObject;
                break;

            case "GridStyle":
                if (pageChanged)
                {
                    View.SelectTab(_currentPageName);
                    SetPlaneSecondaryChoice();
                }

                if (!_GridStyleController.ContainsKey(_currentPlaneID))
                {
                    GridPlane           p    = _doc.GridPlanes.Contains(_currentPlaneID) ? _doc.GridPlanes[_currentPlaneID] : new GridPlane(_currentPlaneID);
                    GridPlaneController ctrl = new GridPlaneController(p);
                    Current.Gui.FindAndAttachControlTo(ctrl);
                    _GridStyleController.Add(_currentPlaneID, ctrl);
                }
                _currentController  = _GridStyleController[_currentPlaneID];
                View.CurrentContent = this._currentController.ViewObject;


                break;

            case "TitleAndFormat":
                if (pageChanged)
                {
                    View.SelectTab(_currentPageName);
                    SetEdgeSecondaryChoice();
                }

                if (!_TitleFormatController.ContainsKey(_currentAxisID))
                {
                    AxisStyle ast = _doc.AxisStyles.Contains(_currentAxisID) ? _doc.AxisStyles[_currentAxisID] : null;

                    if (null != ast)
                    {
                        _TitleFormatController.Add(_currentAxisID, (IMVCANController)Current.Gui.GetControllerAndControl(new object[] { ast }, typeof(IMVCANController), UseDocument.Directly));
                    }
                }

                _currentController = _TitleFormatController.ContainsKey(_currentAxisID) ? _TitleFormatController[_currentAxisID] : null;
                if (null != _currentController && null == _currentController.ViewObject)
                {
                    _currentController.ViewObject = new TitleFormatLayerControl();
                }


                View.SetCurrentContentWithEnable(
                    _currentController == null ? null : _currentController.ViewObject,
                    _currentController != null && _enableAxisStyle[_currentAxisID],
                    "Enable axis style");


                break;

            case "MajorLabels":
                if (pageChanged)
                {
                    View.SelectTab(_currentPageName);
                    SetEdgeSecondaryChoice();
                }

                if (!_enableAxisStyle[_currentAxisID])
                {
                    View.CurrentContent = null; // disable all, dont show any content
                }
                else // the axis style for this axis is at least activated
                {
                    if (!_MajorLabelController.ContainsKey(_currentAxisID))
                    {
                        AxisLabelStyle als = (AxisLabelStyle)_doc.AxisStyles[_currentAxisID].MajorLabelStyle;
                        if (null != als)
                        {
                            _MajorLabelController.Add(_currentAxisID, (IXYAxisLabelStyleController)Current.Gui.GetControllerAndControl(new object[] { als }, typeof(IXYAxisLabelStyleController), UseDocument.Directly));
                        }
                    }

                    _currentController = _MajorLabelController.ContainsKey(_currentAxisID)? _MajorLabelController[_currentAxisID] : null;

                    View.SetCurrentContentWithEnable(
                        _currentController == null ? null : _currentController.ViewObject,
                        _currentController != null && _enableMajorLabels[_currentAxisID],
                        "Enable major labels");
                }
                break;

            case "MinorLabels":
                if (pageChanged)
                {
                    View.SelectTab(_currentPageName);
                    SetEdgeSecondaryChoice();
                }

                if (!_enableAxisStyle[_currentAxisID])
                {
                    View.CurrentContent = null; // disable all, dont show any content
                }
                else // the axis style for this axis is at least activated
                {
                    if (!_MinorLabelController.ContainsKey(_currentAxisID))
                    {
                        AxisLabelStyle als = (AxisLabelStyle)_doc.AxisStyles[_currentAxisID].MinorLabelStyle;
                        if (null != als)
                        {
                            _MinorLabelController.Add(_currentAxisID, (IXYAxisLabelStyleController)Current.Gui.GetControllerAndControl(new object[] { als }, typeof(IXYAxisLabelStyleController), UseDocument.Directly));
                        }
                    }


                    _currentController = _MinorLabelController.ContainsKey(_currentAxisID) ? _MinorLabelController[_currentAxisID] : null;

                    View.SetCurrentContentWithEnable(
                        _currentController == null ? null : _currentController.ViewObject,
                        _currentController != null && _enableMinorLabels[_currentAxisID],
                        "Enable minor labels");
                }
                break;
            }
        }
Пример #10
0
 public AxisStyle AxisStyleEnsured(CSLineID id)
 {
   AxisStyle prop = AxisStyle(id);
   if (prop == null)
   {
     prop = new AxisStyle(id);
    // prop.CachedAxisInformation = _cachedCoordinateSystem.GetAxisStyleInformation(id);
     AddAxisStyle(prop);
   }
   return prop;
 }
Пример #11
0
 public void AddAxisStyle(AxisStyle value)
 {
   if (value != null)
   {
     _axisStyles.Add(value);
   }
 }
Пример #12
0
        public static AxisGeometry GetAxis(ICanvasResourceCreator resourceCreator, AxisStyle style, float dataWidth,
                                           float maxValue)
        {
            var totalHeight = style.DataAreaHeight + style.TopSpace + style.ArrowHeight;
            var totalWidth  = dataWidth + style.RightSpace + style.StartOffset + style.ArrowHeight;
            var zeroPoint   = new Vector2();

            var topPoint   = new Vector2(zeroPoint.X, zeroPoint.Y - totalHeight);
            var rightPoint = new Vector2(zeroPoint.X + totalWidth, zeroPoint.Y);

            //xy轴
            var builder = new CanvasPathBuilder(resourceCreator);

            builder.BeginFigure(new Vector2(topPoint.X, topPoint.Y + style.ArrowHeight));
            builder.AddLine(zeroPoint);
            builder.AddLine(new Vector2(rightPoint.X - style.ArrowHeight, rightPoint.Y));
            builder.EndFigure(CanvasFigureLoop.Open);

            //y轴箭头
            var arrowBuilder = new CanvasPathBuilder(resourceCreator);

            arrowBuilder.BeginFigure(new Vector2(topPoint.X - style.ArrowWidth / 2, topPoint.Y + style.ArrowHeight));
            arrowBuilder.AddLine(topPoint);
            arrowBuilder.AddLine(new Vector2(topPoint.X + style.ArrowWidth / 2, topPoint.Y + style.ArrowHeight));
            arrowBuilder.EndFigure(CanvasFigureLoop.Open);
            //x轴箭头
            arrowBuilder.BeginFigure(new Vector2(rightPoint.X - style.ArrowHeight,
                                                 rightPoint.Y - style.ArrowWidth / 2));
            arrowBuilder.AddLine(rightPoint);
            arrowBuilder.AddLine(new Vector2(rightPoint.X - style.ArrowHeight, rightPoint.Y + style.ArrowWidth / 2));
            arrowBuilder.EndFigure(CanvasFigureLoop.Open);

            var dataLeftTopPoint     = new Point(style.StartOffset, -style.DataAreaHeight);
            var dataRightBottomPoint = new Point(dataWidth + style.StartOffset, -style.LineWidth / 2);

            var valueGap       = maxValue / 5;
            var valueHeightGap = style.DataAreaHeight / 5;
            var markerPoints   = new List <Vector2>();
            var markerStrs     = new List <string>();

            for (int i = 0; i < 6; i++)
            {
                var markerPoint = new Vector2(0, -i * valueHeightGap);
                markerPoints.Add(markerPoint);
                if (i == 5)
                {
                    markerStrs.Add($"{maxValue}");
                }
                else
                {
                    var value = ValueFormatHelper.Round(i * valueGap, 3);
                    markerStrs.Add($"{value}");
                }
                builder.BeginFigure(markerPoint);
                builder.AddLine(new Vector2(markerPoint.X + style.ValueMarkerLineLength + style.LineWidth,
                                            markerPoint.Y));
                builder.EndFigure(CanvasFigureLoop.Open);
            }
            var axis = new AxisGeometry
            {
                AxisLine        = CanvasGeometry.CreatePath(builder),
                AxisArrow       = CanvasGeometry.CreatePath(arrowBuilder),
                AxisValueMarker = CreateValueMarker(resourceCreator, style.ValueMarkerFormat, markerPoints, markerStrs,
                                                    MarkerPosition.Left),
                DataRect = new Rect(dataLeftTopPoint, dataRightBottomPoint)
            };

            return(axis);
        }
Пример #13
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
        }
Пример #14
0
        bool ApplyCurrentController(bool force)
        {
            if (_currentController == null)
            {
                return(true);
            }

            if (!force && object.ReferenceEquals(_currentController, _lastControllerApplied))
            {
                return(true);
            }

            if (!_currentController.Apply())
            {
                return(false);
            }
            _lastControllerApplied = _currentController;

            if (object.ReferenceEquals(_currentController, _coordinateController))
            {
                _doc.CoordinateSystem = (G2DCoordinateSystem)_coordinateController.ModelObject;
                SetCoordinateSystemDependentObjects();
            }
            else if (_currentPageName == "TitleAndFormat")
            {
                // if we have enabled/disabled some items, we must update the enable states of the minor/major controllers
                AxisStyle axstyle = (AxisStyle)_currentController.ModelObject;
                if (_currentAxisID == axstyle.StyleID)
                {
                    _enableMajorLabels[axstyle.StyleID] = axstyle.ShowMajorLabels;
                    _enableMinorLabels[axstyle.StyleID] = axstyle.ShowMinorLabels;
                }
                else // than we have applied a position offset, and the old StyleID is no longer valid
                {
                    _doc.AxisStyles.Remove(_currentAxisID);
                    _doc.AxisStyles.Add(axstyle);
                    _currentAxisID = axstyle.StyleID; // take this for axstyle
                    SetCoordinateSystemDependentObjects();
                    SetEdgeSecondaryChoice();         // update left side list of choices
                    SetCurrentTabController(true);    // we must simulate a page change in order to update the title-format tab page
                }
            }
            else if (_currentPageName == "MajorLabels")
            {
                if (!_enableMajorLabels[_currentAxisID] && _doc.AxisStyles.Contains(_currentAxisID))
                {
                    _doc.AxisStyles[_currentAxisID].ShowMajorLabels = false;
                }
                if (_TitleFormatController.ContainsKey(_currentAxisID))
                {
                    _TitleFormatController.Remove(_currentAxisID);
                }
            }
            else if (_currentPageName == "MinorLabels")
            {
                if (!_enableMinorLabels[_currentAxisID] && _doc.AxisStyles.Contains(_currentAxisID))
                {
                    _doc.AxisStyles[_currentAxisID].ShowMinorLabels = false;
                }

                if (_TitleFormatController.ContainsKey(_currentAxisID))
                {
                    _TitleFormatController.Remove(_currentAxisID);
                }
            }
            else if (_currentPageName == "GridStyle")
            {
                GridPlane gp = (GridPlane)_currentController.ModelObject;
                this._doc.GridPlanes[_currentPlaneID] = gp.IsUsed ? gp : null;
            }

            return(true);
        }
Пример #15
0
        public override void Render(IRenderContext rc, PlotModel model1, AxisLayer axisLayer, int pass)
        {
#if DEBUG_MAP
            Console.WriteLine("render timecategoryaxis " + this.Name);
#endif
            PlotModel model           = this.PlotModel;
            OxyColor  live_color      = OxyColors.Red;
            OxyColor  forecast_color  = OxyColors.Red;
            OxyColor  separator_color = OxyColors.Red;
            OxyColor  grid_color      = OxyColors.Red;
            //OxyColor line_color = OxyColors.Red;
            if (Theme != null)
            {
                AxisStyle style = Theme.GetStyle(ThemeMode) as AxisStyle;
                TitleColor      = Helper.ConvertColorToOxyColor(style.TitleColor);
                TextColor       = Helper.ConvertColorToOxyColor(style.LabelColor);
                TicklineColor   = Helper.ConvertColorToOxyColor(style.LineColor);
                live_color      = Helper.ConvertColorToOxyColor(style.LiveColor);
                forecast_color  = Helper.ConvertColorToOxyColor(style.ForecastColor);
                separator_color = Helper.ConvertColorToOxyColor(style.SepatorColor);
                grid_color      = Helper.ConvertColorToOxyColor(style.GridColor);
            }

            //找到所有的y轴
            if (TimeLines != null)
            {
                //绘制线标值和线条
                FeatureTextIntersector intersector = new FeatureTextIntersector(FeatureTextIntersector.SortStyle.Horizontal, 3);
                for (int i = 0; i < TimeLines.Count; i++)
                {
                    string  label = TimeLines[i].Time.ToString("dd-HH");
                    OxySize size  = rc.MeasureText(label);
                    double  x     = TransformX(TimeLines[i].Index);
                    if (x < model.PlotArea.Left || x > model.PlotArea.Right)
                    {
                        continue;
                    }

                    double y  = model.PlotArea.Bottom;
                    double y2 = y + 5;

                    //if (TimeLines[i].TimeStyle == TimeStyle.Seperator)
                    //    continue;

                    intersector.Add(new FeatureText(label, new ScreenPoint(x, y + 7), size, new ScreenPoint(x, y)));
                }
                List <FeatureText> features = intersector.DiscaredIntersection(this.Angle);
                if (features != null)
                {
                    foreach (FeatureText feature in features)
                    {
                        rc.DrawText(feature.Position, feature.Text, TextColor, this.ActualFont, this.ActualFontSize, 200, this.Angle, HorizontalAlignment.Left, VerticalAlignment.Middle);
                    }
                }
                //绘制纵线
                foreach (Axis axis in model.Axes)
                {
                    if (axis.Position == AxisPosition.Left || axis.Position == AxisPosition.Right)
                    {
                        if (axis is IAxis)
                        {
                            IAxis y_axis = axis as IAxis;
                            if (!y_axis.AxisVisible)
                            {
                                continue;
                            }
                            foreach (TimeLine line in TimeLines)
                            {
                                OxyColor  color     = OxyColors.Red;
                                double    thickness = 1;
                                LineStyle style     = LineStyle.Solid;
                                switch (line.TimeStyle)
                                {
                                case TimeStyle.Forecast:
                                    color = forecast_color;
                                    style = LineStyle.Dash;
                                    break;

                                case TimeStyle.Live:
                                    color = live_color;
                                    break;

                                case TimeStyle.Seperator:
                                    color     = separator_color;
                                    style     = LineStyle.Dash;
                                    thickness = 2;
                                    break;
                                }

                                IList <ScreenPoint> sps = new List <ScreenPoint>();
                                double x   = TransformX(line.Index);
                                double top = y_axis.Bound.Top;
                                sps.Add(new ScreenPoint(x, top));
                                sps.Add(new ScreenPoint(x, y_axis.Bound.Bottom));

                                rc.DrawClippedLine(y_axis.Bound, sps, 2, color, thickness, style.GetDashArray(), LineJoin.Round, false);
                            }
                        }
                    }
                }
            }
        }
Пример #16
0
        internal void Refresh()
        {
            if (CurrentSize.Width == 0 || CurrentSize.Height == 0)
            {
                return;
            }

            _ax.Axis = _view.AxisX;
            _ay.Axis = _view.AxisY;
            List <string> list = new List <string>();

            foreach (Axis axis in _axes)
            {
                if ((axis.PositionInternal & AxisPosition.OverData) > AxisPosition.Near)
                {
                    Canvas.SetZIndex(axis, 1);
                }
                else
                {
                    Canvas.SetZIndex(axis, 0);
                }
                ((IAxis)axis).ClearLabels();
                axis.ResetLimits();
                axis.Chart = _view.Chart;
                if (((axis != _ax) && (axis != _ay)) && !string.IsNullOrEmpty(axis.AxisName))
                {
                    list.Add(axis.AxisName);
                }
            }

            if (_view.Renderer != null)
            {
                IView2DRenderer renderer = _view.Renderer as IView2DRenderer;
                if (renderer == null)
                {
                    return;
                }

                _ast = renderer.Axis;
                Size       sz        = new Size(CurrentSize.Width, CurrentSize.Height);
                Renderer2D rendererd = renderer as Renderer2D;
                if (rendererd != null)
                {
                    rendererd.ValidAuxAxes = list.ToArray();
                    if (_plot.Width > 0.0)
                    {
                        sz.Width = _plot.Width;
                    }
                    if (_plot.Height > 0.0)
                    {
                        sz.Height = _plot.Height;
                    }
                }

                Rect rect = renderer.Measure(sz);
                if (rect.Width > 0.0)
                {
                    _ax.SetLimits(rect.X, rect.X + rect.Width);
                }
                if (rect.Height > 0.0)
                {
                    _ay.SetLimits(rect.Y, rect.Y + rect.Height);
                }
            }

            switch (_ast)
            {
            case AxisStyle.None:
                if ((base.Width > 10.0) && (base.Height > 10.0))
                {
                    _plot = new Rect(5.0, 5.0, base.Width - 10.0, base.Height - 10.0);
                }
                using (List <Axis> .Enumerator enumerator3 = _axes.GetEnumerator())
                {
                    while (enumerator3.MoveNext())
                    {
                        enumerator3.Current.Visibility = Utils.VisHidden;
                    }
                }
                break;

            case AxisStyle.Cartesian:
                UpdateLayoutCartesian();
                break;

            case AxisStyle.Radar:
                using (List <Axis> .Enumerator enumerator2 = _axes.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        enumerator2.Current.Visibility = Visibility.Collapsed;
                    }
                }
                UpdateLayoutRadar();
                break;
            }

            Shape plotShape = _view.PlotShape;

            if (plotShape != null)
            {
                Canvas.SetLeft(plotShape, _view.PlotRect.Left);
                Canvas.SetTop(plotShape, _view.PlotRect.Top);
                plotShape.Width  = _view.PlotRect.Width;
                plotShape.Height = _view.PlotRect.Height;
                if (_ast == AxisStyle.None)
                {
                    plotShape.Visibility = Visibility.Collapsed;
                }
                else
                {
                    plotShape.Visibility = Visibility.Visible;
                }
            }

            if (_view.Chart.UpdateCount <= 0 && _view.Renderer != null)
            {
                CreateDataObjects();
                _view.Renderer.Dirty = false;
            }
        }
Пример #17
0
        public void RenderTop(IRenderContext rc, PlotModel model, OxyRect rect)
        {
            if (TimeLines == null)
            {
                return;
            }

            OxyRect  bound = rect;
            TimeLine live, seperator, forecast;

            TimeLines.GetLive(out live);
            TimeLines.GetSeperator(out seperator);
            TimeLines.GetForecast(out forecast);
            if (Theme != null)
            {
                AxisStyle style = Theme.GetStyle(ThemeMode) as AxisStyle;
                TitleColor    = Helper.ConvertColorToOxyColor(style.TitleColor);
                TextColor     = Helper.ConvertColorToOxyColor(style.LabelColor);
                TicklineColor = Helper.ConvertColorToOxyColor(style.LineColor);
            }
            if (seperator != null)
            {
                double x = this.TransformX(seperator.Index);
                if (live != null)
                {
                    double lx = this.TransformX(live.Index);

                    double center_x = 0;
                    if (lx > x)
                    {
                        center_x = bound.Right - (bound.Right - x) / 2;
                    }
                    else
                    {
                        center_x = bound.Left + (x - bound.Left) / 2;
                    }

                    if (!string.IsNullOrEmpty(live.GetTimeStyleDesc()))
                    {
                        OxySize text_size = rc.MeasureText(live.GetTimeStyleDesc());
                        double  y         = bound.Top;
                        rc.DrawText(new ScreenPoint(center_x - text_size.Width / 2, y), live.GetTimeStyleDesc(), TextColor);
                    }
                }

                if (forecast != null)
                {
                    double lx       = this.TransformX(forecast.Index);
                    double center_x = 0;
                    if (lx > x)
                    {
                        center_x = bound.Right - (bound.Right - x) / 2;
                    }
                    else
                    {
                        center_x = bound.Left + (x - bound.Left) / 2;
                    }


                    if (!string.IsNullOrEmpty(forecast.GetTimeStyleDesc()))
                    {
                        OxySize text_size = rc.MeasureText(forecast.GetTimeStyleDesc());
                        double  y         = bound.Top;
                        rc.DrawText(new ScreenPoint(center_x - text_size.Width / 2, y), forecast.GetTimeStyleDesc(), TextColor);
                    }
                }
            }
        }
 private void OnAxisStyleCreation(AxisStyle result)
 {
     MajorLabelCondController.AnnounceEnabledChanged(result.AreMajorLabelsEnabled);
     MinorLabelCondController.AnnounceEnabledChanged(result.AreMinorLabelsEnabled);
 }
Пример #19
0
        public DensityImageLegend(DensityImagePlotItem plotItem, Main.IDocumentNode futureParentObject, PointD2D initialLocation, PointD2D graphicSize, Main.Properties.IReadOnlyPropertyBag context)
            : base(new ItemLocationDirect())
        {
            if (null == plotItem)
            {
                throw new ArgumentNullException("plotItem");
            }
            if (null == futureParentObject)
            {
                throw new ArgumentNullException("futureParentObject");
            }

            ParentObject = futureParentObject;
            PlotItem     = plotItem;
            if (null == _plotItemProxy.DocumentPath)
            {
                throw new ArgumentException("No path could be found between plotItem and futureParentObject. This is an indication that one of the objects is not rooted.");
            }

            SetSize(graphicSize.X, graphicSize.Y, Main.EventFiring.Suppressed);
            SetPosition(initialLocation, Main.EventFiring.Suppressed);

            // _orientationIsVertical = true;
            // _scaleIsReversed = false;

            var cachedScale      = (NumericalScale)PlotItem.Style.Scale.Clone();
            var scaleTickSpacing = Altaxo.Graph.Scales.Scale.CreateDefaultTicks(cachedScale.GetType());

            _cachedArea = new DensityLegendArea(Size, true, false, cachedScale, scaleTickSpacing);
            //_cachedArea.ParentObject = this; // --> moved to the end of this function

            _axisStyles = new AxisStyleCollection();
            _axisStyles.UpdateCoordinateSystem(_cachedArea.CoordinateSystem);
            // _axisStyles.ParentObject = this; --> see below

            var sx0 = new AxisStyle(CSLineID.X0, true, true, false, "Z values", context);

            sx0.AxisLineStyle.FirstDownMajorTicks = true;
            sx0.AxisLineStyle.FirstUpMajorTicks   = false;
            sx0.AxisLineStyle.FirstDownMinorTicks = true;
            sx0.AxisLineStyle.FirstUpMinorTicks   = false;

            var sx1 = new AxisStyle(CSLineID.X1, true, false, false, null, context);

            sx1.AxisLineStyle.FirstDownMajorTicks = false;
            sx1.AxisLineStyle.FirstUpMajorTicks   = false;
            sx1.AxisLineStyle.FirstDownMinorTicks = false;
            sx1.AxisLineStyle.FirstUpMinorTicks   = false;

            var sy0 = new AxisStyle(CSLineID.Y0, true, false, false, "Color map", context);
            var sy1 = new AxisStyle(CSLineID.Y1, true, false, false, null, context);

            _axisStyles.Add(sx0);
            _axisStyles.Add(sx1);
            _axisStyles.Add(sy0);
            _axisStyles.Add(sy1);

            sx0.Title.Rotation = 90;
            sx0.Title.Location.ParentAnchorX = RADouble.NewRel(0);   // Left
            sx0.Title.Location.ParentAnchorY = RADouble.NewRel(0.5); // Center
            sx0.Title.Location.LocalAnchorX  = RADouble.NewRel(0.5); // Center
            sx0.Title.Location.LocalAnchorY  = RADouble.NewRel(1);   // Bottom
            sx0.Title.X = -Width / 3;
            sx0.Title.Y = 0;

            sy0.Title.Location.ParentAnchorX = RADouble.NewRel(0.5); // Center
            sy0.Title.Location.ParentAnchorY = RADouble.NewRel(0);   // Top
            sy0.Title.Location.LocalAnchorX  = RADouble.NewRel(0.5); // Center
            sy0.Title.Location.LocalAnchorY  = RADouble.NewRel(1);   // Bottom
            sy0.Title.X = 0;
            sy0.Title.Y = sy0.Title.Height / 2;

            // set the parent objects
            _axisStyles.ParentObject = this;
            _cachedArea.ParentObject = this;
            UpdateTransformationMatrix();
        }
Пример #20
0
 public AxisStyleControllerGlue(AxisStyle axisStyle)
 {
     _doc = axisStyle;
     InternalInitialize();
 }