Beispiel #1
0
        public override bool CopyFrom(object obj)
        {
            var isCopied = base.CopyFrom(obj);

            if (isCopied && !object.ReferenceEquals(this, obj))
            {
                var from = obj as DensityImageLegend;
                if (null != from)
                {
                    _cachedArea = new DensityLegendArea(from._cachedArea)
                    {
                        ParentObject = this
                    };

                    ChildCloneToMember(ref _axisStyles, from._axisStyles);
                    _axisStyles.UpdateCoordinateSystem(_cachedArea.CoordinateSystem);
                    _axisStyles.ParentObject = this;

                    _bitmap = null != from._bitmap ? (Bitmap)from._bitmap.Clone() : null;

                    _plotItemProxy = new Main.RelDocNodeProxy(from._plotItemProxy, true, this);
                }
            }
            return(isCopied);
        }
Beispiel #2
0
        private void UpdateIfPlotItemChanged()
        {
            if (null == PlotItem)
            {
                return;
            }

            // Test whether the scale type is still the same than the scale of the plot item
            // If not, we must create a new cachedArea
            if (_cachedArea.Scales[0].GetType() != PlotItem.Style.Scale.GetType())
            {
                var cachedScale      = (NumericalScale)PlotItem.Style.Scale.Clone();
                var scaleTickSpacing = Altaxo.Graph.Scales.Scale.CreateDefaultTicks(cachedScale.GetType()); // we have to use CreateDefaultTicks because the scale of the DensityImagePlotStyle has NoTickspacing as TickSpacing
                _cachedArea = new DensityLegendArea(Size, true, false, cachedScale, scaleTickSpacing)
                {
                    ParentObject = this
                };
            }

            // We set the boundaries of our legend scale to the org and end of the z-scale of the density image PlotItem.
            using (var suspendToken = ScaleWithTicks.DataBoundsObject.SuspendGetToken())
            {
                ScaleWithTicks.DataBoundsObject.Reset();

                // Note: we do not use PlotItem.Style.Scale.DataBoundsObject here to merge with ScaleWithTicks.DataBoundsObject
                // this is because in the PlotItem we can limit the scale to show only relevant data and to eliminate outliers
                // that's why we bind our DataBoundsObject to the resulting Scale org and end
                ScaleWithTicks.DataBoundsObject.Add(PlotItem.Style.Scale.Org);
                ScaleWithTicks.DataBoundsObject.Add(PlotItem.Style.Scale.End);

                suspendToken.Resume();
            }
        }
Beispiel #3
0
            public DensityLegendArea(DensityLegendArea from)
            {
                _size = from._size;

                _scales = from._scales.Clone();
                _scales.ParentObject = this;

                _coordinateSystem = (CS.G2DCartesicCoordinateSystem)from._coordinateSystem.Clone();
                _coordinateSystem.ParentObject = this;
            }
Beispiel #4
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();
        }
Beispiel #5
0
			public DensityLegendArea(DensityLegendArea from)
			{
				this._size = from._size;

				this._scales = from._scales.Clone();
				this._scales.ParentObject = this;

				this._coordinateSystem = (CS.G2DCartesicCoordinateSystem)from._coordinateSystem.Clone();
				this._coordinateSystem.ParentObject = this;
			}
Beispiel #6
0
		private void UpdateIfPlotItemChanged()
		{
			if (null == PlotItem)
				return;

			// Test whether the scale type is still the same than the scale of the plot item
			// If not, we must create a new cachedArea
			if (_cachedArea.Scales[0].GetType() != PlotItem.Style.Scale.GetType())
			{
				var cachedScale = (NumericalScale)PlotItem.Style.Scale.Clone();
				var scaleTickSpacing = Altaxo.Graph.Scales.Scale.CreateDefaultTicks(cachedScale.GetType()); // we have to use CreateDefaultTicks because the scale of the DensityImagePlotStyle has NoTickspacing as TickSpacing
				_cachedArea = new DensityLegendArea(Size, true, false, cachedScale, scaleTickSpacing) { ParentObject = this };
			}

			// We set the boundaries of our legend scale to the org and end of the z-scale of the density image PlotItem.
			using (var suspendToken = ScaleWithTicks.DataBoundsObject.SuspendGetToken())
			{
				ScaleWithTicks.DataBoundsObject.Reset();

				// Note: we do not use PlotItem.Style.Scale.DataBoundsObject here to merge with ScaleWithTicks.DataBoundsObject
				// this is because in the PlotItem we can limit the scale to show only relevant data and to eliminate outliers
				// that's why we bind our DataBoundsObject to the resulting Scale org and end
				ScaleWithTicks.DataBoundsObject.Add(PlotItem.Style.Scale.Org);
				ScaleWithTicks.DataBoundsObject.Add(PlotItem.Style.Scale.End);

				suspendToken.Resume();
			}
		}
Beispiel #7
0
		public override bool CopyFrom(object obj)
		{
			var isCopied = base.CopyFrom(obj);
			if (isCopied && !object.ReferenceEquals(this, obj))
			{
				var from = obj as DensityImageLegend;
				if (null != from)
				{
					_cachedArea = new DensityLegendArea(from._cachedArea) { ParentObject = this };

					ChildCloneToMember(ref _axisStyles, from._axisStyles);
					this._axisStyles.UpdateCoordinateSystem(_cachedArea.CoordinateSystem);
					this._axisStyles.ParentObject = this;

					this._bitmap = null != from._bitmap ? (Bitmap)from._bitmap.Clone() : null;

					_plotItemProxy = new Main.RelDocNodeProxy(from._plotItemProxy, true, this);
				}
			}
			return isCopied;
		}
Beispiel #8
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");

			this.ParentObject = futureParentObject;
			this.PlotItem = plotItem;
			if (null == this._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.");

			this.SetSize(graphicSize.X, graphicSize.Y, Main.EventFiring.Suppressed);
			this.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;
			this.UpdateTransformationMatrix();
		}