コード例 #1
0
 /// <summary>
 /// Copies the member variables from another coordinate system.
 /// </summary>
 /// <param name="fromb">The coordinate system to copy from.</param>
 public override void CopyFrom(G2DCoordinateSystem fromb)
 {
   base.CopyFrom(fromb);
   if (fromb is G3DCartesicCoordinateSystem)
   {
     G3DCartesicCoordinateSystem from = (G3DCartesicCoordinateSystem)fromb;
     this._projectionMatrix = from._projectionMatrix;
   }
 }
コード例 #2
0
        public void UpdateCoordinateSystem(G2DCoordinateSystem cs)
        {
            _cachedCoordinateSystem = cs;

            foreach (AxisStyle style in this._axisStyles)
            {
                style.CachedAxisInformation = _cachedCoordinateSystem.GetAxisStyleInformation(style.StyleID);
            }
        }
コード例 #3
0
 /// <summary>
 /// Copies the member variables from another coordinate system.
 /// </summary>
 /// <param name="fromb">The coordinate system to copy from.</param>
 public override void CopyFrom(G2DCoordinateSystem fromb)
 {
     base.CopyFrom(fromb);
     if (fromb is G3DCartesicCoordinateSystem)
     {
         G3DCartesicCoordinateSystem from = (G3DCartesicCoordinateSystem)fromb;
         this._projectionMatrix = from._projectionMatrix;
     }
 }
コード例 #4
0
        public bool Apply()
        {
            bool result = _instanceController == null || _instanceController.Apply();

            if (true == result)
            {
                _doc = _tempdoc;
            }
            return(result);
        }
コード例 #5
0
        void CopyFrom(AxisStyleCollection from)
        {
            this._axisStyles.Clear();
            for (int i = 0; i < from._axisStyles.Count; ++i)
            {
                this.Add((AxisStyle)from._axisStyles[i].Clone());
            }

            this._parent = from._parent;
            this._cachedCoordinateSystem = from._cachedCoordinateSystem;
        }
コード例 #6
0
 /// <summary>
 /// Copies the member variables from another coordinate system.
 /// </summary>
 /// <param name="fromb">The coordinate system to copy from.</param>
 public override void CopyFrom(G2DCoordinateSystem fromb)
 {
     base.CopyFrom(fromb);
     if (fromb is G2DCartesicCoordinateSystem)
     {
         G2DCartesicCoordinateSystem from = (G2DCartesicCoordinateSystem)fromb;
         this._isXYInterchanged = from._isXYInterchanged;
         this._isXreverse       = from._isXreverse;
         this._isYreverse       = from._isYreverse;
     }
 }
コード例 #7
0
 /// <summary>
 /// Copies the member variables from another coordinate system.
 /// </summary>
 /// <param name="fromb">The coordinate system to copy from.</param>
 public override void CopyFrom(G2DCoordinateSystem fromb)
 {
   base.CopyFrom(fromb);
   if (fromb is G2DCartesicCoordinateSystem)
   {
     G2DCartesicCoordinateSystem from = (G2DCartesicCoordinateSystem)fromb;
     this._isXYInterchanged = from._isXYInterchanged;
     this._isXreverse = from._isXreverse;
     this._isYreverse = from._isYreverse;
   }
 }
コード例 #8
0
		/// <summary>
		/// Copies the member variables from another coordinate system.
		/// </summary>
		/// <param name="fromb">The coordinate system to copy from.</param>
		public override void CopyFrom(G2DCoordinateSystem fromb)
		{
			if (object.ReferenceEquals(this, fromb))
				return;

			base.CopyFrom(fromb);
			if (fromb is G3DCartesicCoordinateSystem)
			{
				G3DCartesicCoordinateSystem from = (G3DCartesicCoordinateSystem)fromb;
				this._projectionMatrix = from._projectionMatrix;
			}
		}
コード例 #9
0
        /// <summary>
        /// Copies the member variables from another coordinate system.
        /// </summary>
        /// <param name="fromb">The coordinate system to copy from.</param>
        public override void CopyFrom(G2DCoordinateSystem fromb)
        {
            if (object.ReferenceEquals(this, fromb))
            {
                return;
            }

            base.CopyFrom(fromb);
            if (fromb is G3DCartesicCoordinateSystem)
            {
                var from = (G3DCartesicCoordinateSystem)fromb;
                _projectionMatrix = from._projectionMatrix;
            }
        }
コード例 #10
0
        void EhTypeChoiceChanged(object sender, EventArgs e)
        {
            ListNode sel = _view.SelectedNode;

            if (sel != null)
            {
                System.Type t = (System.Type)sel.Item;
                if (_tempdoc.GetType() != t)
                {
                    _tempdoc = (G2DCoordinateSystem)Activator.CreateInstance((System.Type)sel.Item);
                    Initialize(true);
                }
            }
        }
コード例 #11
0
		/// <summary>
		/// Copies the member variables from another coordinate system.
		/// </summary>
		/// <param name="fromb">The coordinate system to copy from.</param>
		public override void CopyFrom(G2DCoordinateSystem fromb)
		{
			if (object.ReferenceEquals(this, fromb))
				return;

			base.CopyFrom(fromb);
			if (fromb is G2DCartesicCoordinateSystem)
			{
				G2DCartesicCoordinateSystem from = (G2DCartesicCoordinateSystem)fromb;
				this._isXYInterchanged = from._isXYInterchanged;
				this._isXreverse = from._isXreverse;
				this._isYreverse = from._isYreverse;
			}
		}
コード例 #12
0
        /// <summary>
        /// Copies the member variables from another coordinate system.
        /// </summary>
        /// <param name="fromb">The coordinate system to copy from.</param>
        public override void CopyFrom(G2DCoordinateSystem fromb)
        {
            base.CopyFrom(fromb);
            if (fromb is G2DPolarCoordinateSystem)
            {
                G2DPolarCoordinateSystem from = (G2DPolarCoordinateSystem)fromb;
                this._isXYInterchanged = from._isXYInterchanged;
                this._isXreverse       = from._isXreverse;
                this._isYreverse       = from._isYreverse;

                this._radius = from._radius;
                this._midX   = from._midX;
                this._midY   = from._midY;
            }
        }
コード例 #13
0
    /// <summary>
    /// Copies the member variables from another coordinate system.
    /// </summary>
    /// <param name="fromb">The coordinate system to copy from.</param>
    public override void CopyFrom(G2DCoordinateSystem fromb)
    {
      base.CopyFrom(fromb);
      if (fromb is G2DPolarCoordinateSystem)
      {
        G2DPolarCoordinateSystem from = (G2DPolarCoordinateSystem)fromb;
        this._isXYInterchanged = from._isXYInterchanged;
        this._isXreverse = from._isXreverse;
        this._isYreverse = from._isYreverse;

        this._radius = from._radius;
        this._midX = from._midX;
        this._midY = from._midY;
      }
    }
コード例 #14
0
ファイル: AxisStyleCollection.cs プロジェクト: olesar/Altaxo
        private void CopyFrom(AxisStyleCollection from)
        {
            if (object.ReferenceEquals(this, from))
            {
                return;
            }

            _axisStyles.Clear();
            for (int i = 0; i < from._axisStyles.Count; ++i)
            {
                Add((AxisStyle)from._axisStyles[i].Clone());
            }

            //this._parent = from._parent;
            _cachedCoordinateSystem = from._cachedCoordinateSystem;
        }
コード例 #15
0
        /// <summary>
        /// Copies the member variables from another coordinate system.
        /// </summary>
        /// <param name="fromb">The coordinate system to copy from.</param>
        public override void CopyFrom(G2DCoordinateSystem fromb)
        {
            if (object.ReferenceEquals(this, fromb))
            {
                return;
            }

            base.CopyFrom(fromb);
            if (fromb is G2DCartesicCoordinateSystem)
            {
                var from = (G2DCartesicCoordinateSystem)fromb;
                _isXYInterchanged = from._isXYInterchanged;
                _isXreverse       = from._isXreverse;
                _isYreverse       = from._isYreverse;
            }
        }
コード例 #16
0
		/// <summary>
		/// Copies the member variables from another coordinate system.
		/// </summary>
		/// <param name="fromb">The coordinate system to copy from.</param>
		public override void CopyFrom(G2DCoordinateSystem fromb)
		{
			if (object.ReferenceEquals(this, fromb))
				return;

			base.CopyFrom(fromb);
			if (fromb is G2DPolarCoordinateSystem)
			{
				G2DPolarCoordinateSystem from = (G2DPolarCoordinateSystem)fromb;
				this._isXYInterchanged = from._isXYInterchanged;
				this._isXreverse = from._isXreverse;
				this._isYreverse = from._isYreverse;

				this._radius = from._radius;
				this._midX = from._midX;
				this._midY = from._midY;
			}
		}
コード例 #17
0
        /// <summary>
        /// Copies the member variables from another coordinate system.
        /// </summary>
        /// <param name="fromb">The coordinate system to copy from.</param>
        public override void CopyFrom(G2DCoordinateSystem fromb)
        {
            if (object.ReferenceEquals(this, fromb))
            {
                return;
            }

            base.CopyFrom(fromb);
            if (fromb is G2DPolarCoordinateSystem)
            {
                var from = (G2DPolarCoordinateSystem)fromb;
                _isXYInterchanged = from._isXYInterchanged;
                _isXreverse       = from._isXreverse;
                _isYreverse       = from._isYreverse;

                _radius = from._radius;
                _midX   = from._midX;
                _midY   = from._midY;
            }
        }
コード例 #18
0
ファイル: AxisLabelStyle.cs プロジェクト: olesar/Altaxo
        /// <summary>
        /// Paints the axis style labels.
        /// </summary>
        /// <param name="g">Graphics environment.</param>
        /// <param name="coordSyst">The coordinate system. Used to get the path along the axis.</param>
        /// <param name="scale">Scale.</param>
        /// <param name="tickSpacing">If not <c>null</c>, this parameter provides a custom tick spacing that is used instead of the default tick spacing of the scale.</param>
        /// <param name="styleInfo">Information about begin of axis, end of axis.</param>
        /// <param name="outerDistance">Distance between axis and labels.</param>
        /// <param name="useMinorTicks">If true, minor ticks are shown.</param>
        public virtual void Paint(Graphics g, G2DCoordinateSystem coordSyst, Scale scale, TickSpacing tickSpacing, CSAxisInformation styleInfo, double outerDistance, bool useMinorTicks)
        {
            _cachedAxisStyleInfo = styleInfo;
            CSLineID    styleID = styleInfo.Identifier;
            Scale       raxis   = scale;
            TickSpacing ticking = tickSpacing;

            _enclosingPath.Reset();
            _enclosingPath.FillMode = FillMode.Winding; // with Winding also overlapping rectangles are selected
            var helperPath = new GraphicsPath();
            var math       = new Matrix();

            Logical3D r0 = styleID.GetLogicalPoint(styleInfo.LogicalValueAxisOrg);
            Logical3D r1 = styleID.GetLogicalPoint(styleInfo.LogicalValueAxisEnd);

            Logical3D outer;
            var       dist_x = outerDistance; // Distance from axis tick point to label
            var       dist_y = outerDistance; // y distance from axis tick point to label

            // dist_x += this._font.SizeInPoints/3; // add some space to the horizontal direction in order to separate the chars a little from the ticks

            // next statement is necessary to have a consistent string length both
            // on 0 degree rotated text and rotated text
            // without this statement, the text is fitted to the pixel grid, which
            // leads to "steps" during scaling
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

            double[]        relpositions;
            AltaxoVariant[] ticks;
            if (useMinorTicks)
            {
                relpositions = ticking.GetMinorTicksNormal(raxis);
                ticks        = ticking.GetMinorTicksAsVariant();
            }
            else
            {
                relpositions = ticking.GetMajorTicksNormal(raxis);
                ticks        = ticking.GetMajorTicksAsVariant();
            }

            if (!_suppressedLabels.IsEmpty)
            {
                var filteredTicks        = new List <AltaxoVariant>();
                var filteredRelPositions = new List <double>();

                for (int i = 0; i < ticks.Length; i++)
                {
                    if (_suppressedLabels.ByValues.Contains(ticks[i]))
                    {
                        continue;
                    }
                    if (_suppressedLabels.ByNumbers.Contains(i))
                    {
                        continue;
                    }
                    if (_suppressedLabels.ByNumbers.Contains(i - ticks.Length))
                    {
                        continue;
                    }

                    filteredTicks.Add(ticks[i]);
                    filteredRelPositions.Add(relpositions[i]);
                }
                ticks        = filteredTicks.ToArray();
                relpositions = filteredRelPositions.ToArray();
            }

            IMeasuredLabelItem[] labels = _labelFormatting.GetMeasuredItems(g, _font, _stringFormat, ticks);

            double     emSize    = _font.Size;
            CSAxisSide labelSide = null != _labelSide ? _labelSide.Value : styleInfo.PreferredLabelSide;

            for (int i = 0; i < ticks.Length; i++)
            {
                double r = relpositions[i];

                if (!Altaxo.Calc.RMath.IsInIntervalCC(r, -1000, 1000))
                {
                    continue;
                }

                outer = coordSyst.GetLogicalDirection(styleID.ParallelAxisNumber, labelSide);
                PointD2D tickorg = coordSyst.GetNormalizedDirection(r0, r1, r, outer, out var outVector);
                PointD2D tickend = tickorg + outVector * outerDistance;

                PointD2D msize = labels[i].Size;
                PointD2D morg  = tickend;

                if (_automaticRotationShift)
                {
                    double alpha = _rotation * Math.PI / 180 - Math.Atan2(outVector.Y, outVector.X);
                    double shift = msize.Y * 0.5 * Math.Abs(Math.Sin(alpha)) + (msize.X + _font.Size / 2) * 0.5 * Math.Abs(Math.Cos(alpha));
                    morg = morg + outVector * shift;
                }
                else
                {
                    morg = morg.WithXPlus(outVector.X * _font.Size / 3);
                }

                var mrect = new RectangleD2D(morg, msize);
                if (_automaticRotationShift)
                {
                    AdjustRectangle(ref mrect, StringAlignment.Center, StringAlignment.Center);
                }
                else
                {
                    AdjustRectangle(ref mrect, _horizontalAlignment, _verticalAlignment);
                }

                math.Reset();
                math.Translate((float)morg.X, (float)morg.Y);
                if (_rotation != 0)
                {
                    math.Rotate((float)-_rotation);
                }
                math.Translate((float)(mrect.X - morg.X + emSize * _xOffset), (float)(mrect.Y - morg.Y + emSize * _yOffset));

                System.Drawing.Drawing2D.GraphicsState gs = g.Save();
                g.MultiplyTransform(math);

                if (_backgroundStyle != null)
                {
                    _backgroundStyle.Draw(g, new RectangleD2D(PointD2D.Empty, msize));
                }

                _brush.SetEnvironment(new RectangleD2D(PointD2D.Empty, msize), BrushX.GetEffectiveMaximumResolution(g, 1));
                labels[i].Draw(g, _brush, new PointF(0, 0));
                g.Restore(gs); // Restore the graphics state

                helperPath.Reset();
                helperPath.AddRectangle(new RectangleF(PointF.Empty, (SizeF)msize));
                helperPath.Transform(math);

                _enclosingPath.AddPath(helperPath, true);
            }
        }
コード例 #19
0
 public CoordinateSystemController(G2DCoordinateSystem doc)
 {
     _doc     = doc;
     _tempdoc = (G2DCoordinateSystem)doc.Clone();
     Initialize(true);
 }
コード例 #20
0
ファイル: AxisLabelStyle.cs プロジェクト: Altaxo/Altaxo
		/// <summary>
		/// Paints the axis style labels.
		/// </summary>
		/// <param name="g">Graphics environment.</param>
		/// <param name="coordSyst">The coordinate system. Used to get the path along the axis.</param>
		/// <param name="scale">Scale.</param>
		/// <param name="tickSpacing">If not <c>null</c>, this parameter provides a custom tick spacing that is used instead of the default tick spacing of the scale.</param>
		/// <param name="styleInfo">Information about begin of axis, end of axis.</param>
		/// <param name="outerDistance">Distance between axis and labels.</param>
		/// <param name="useMinorTicks">If true, minor ticks are shown.</param>
		public virtual void Paint(Graphics g, G2DCoordinateSystem coordSyst, Scale scale, TickSpacing tickSpacing, CSAxisInformation styleInfo, double outerDistance, bool useMinorTicks)
		{
			_cachedAxisStyleInfo = styleInfo;
			CSLineID styleID = styleInfo.Identifier;
			Scale raxis = scale;
			TickSpacing ticking = tickSpacing;

			_enclosingPath.Reset();
			_enclosingPath.FillMode = FillMode.Winding; // with Winding also overlapping rectangles are selected
			GraphicsPath helperPath = new GraphicsPath();
			Matrix math = new Matrix();

			Logical3D r0 = styleID.GetLogicalPoint(styleInfo.LogicalValueAxisOrg);
			Logical3D r1 = styleID.GetLogicalPoint(styleInfo.LogicalValueAxisEnd);

			PointD2D outVector;
			Logical3D outer;
			var dist_x = outerDistance; // Distance from axis tick point to label
			var dist_y = outerDistance; // y distance from axis tick point to label

			// dist_x += this._font.SizeInPoints/3; // add some space to the horizontal direction in order to separate the chars a little from the ticks

			// next statement is necessary to have a consistent string length both
			// on 0 degree rotated text and rotated text
			// without this statement, the text is fitted to the pixel grid, which
			// leads to "steps" during scaling
			g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

			double[] relpositions;
			AltaxoVariant[] ticks;
			if (useMinorTicks)
			{
				relpositions = ticking.GetMinorTicksNormal(raxis);
				ticks = ticking.GetMinorTicksAsVariant();
			}
			else
			{
				relpositions = ticking.GetMajorTicksNormal(raxis);
				ticks = ticking.GetMajorTicksAsVariant();
			}

			if (!_suppressedLabels.IsEmpty)
			{
				List<AltaxoVariant> filteredTicks = new List<AltaxoVariant>();
				List<double> filteredRelPositions = new List<double>();

				for (int i = 0; i < ticks.Length; i++)
				{
					if (_suppressedLabels.ByValues.Contains(ticks[i]))
						continue;
					if (_suppressedLabels.ByNumbers.Contains(i))
						continue;
					if (_suppressedLabels.ByNumbers.Contains(i - ticks.Length))
						continue;

					filteredTicks.Add(ticks[i]);
					filteredRelPositions.Add(relpositions[i]);
				}
				ticks = filteredTicks.ToArray();
				relpositions = filteredRelPositions.ToArray();
			}

			IMeasuredLabelItem[] labels = _labelFormatting.GetMeasuredItems(g, _font, _stringFormat, ticks);

			double emSize = _font.Size;
			CSAxisSide labelSide = null != _labelSide ? _labelSide.Value : styleInfo.PreferredLabelSide;
			for (int i = 0; i < ticks.Length; i++)
			{
				double r = relpositions[i];

				if (!Altaxo.Calc.RMath.IsInIntervalCC(r, -1000, 1000))
					continue;

				outer = coordSyst.GetLogicalDirection(styleID.ParallelAxisNumber, labelSide);
				PointD2D tickorg = coordSyst.GetNormalizedDirection(r0, r1, r, outer, out outVector);
				PointD2D tickend = tickorg + outVector * outerDistance;

				PointD2D msize = labels[i].Size;
				PointD2D morg = tickend;

				if (_automaticRotationShift)
				{
					double alpha = _rotation * Math.PI / 180 - Math.Atan2(outVector.Y, outVector.X);
					double shift = msize.Y * 0.5 * Math.Abs(Math.Sin(alpha)) + (msize.X + _font.Size / 2) * 0.5 * Math.Abs(Math.Cos(alpha));
					morg = morg + outVector * shift;
				}
				else
				{
					morg = morg.WithXPlus(outVector.X * _font.Size / 3);
				}

				RectangleD2D mrect = new RectangleD2D(morg, msize);
				if (_automaticRotationShift)
					AdjustRectangle(ref mrect, StringAlignment.Center, StringAlignment.Center);
				else
					AdjustRectangle(ref mrect, _horizontalAlignment, _verticalAlignment);

				math.Reset();
				math.Translate((float)morg.X, (float)morg.Y);
				if (this._rotation != 0)
				{
					math.Rotate((float)-this._rotation);
				}
				math.Translate((float)(mrect.X - morg.X + emSize * _xOffset), (float)(mrect.Y - morg.Y + emSize * _yOffset));

				System.Drawing.Drawing2D.GraphicsState gs = g.Save();
				g.MultiplyTransform(math);

				if (this._backgroundStyle != null)
					_backgroundStyle.Draw(g, new RectangleD2D(PointD2D.Empty, msize));

				_brush.SetEnvironment(new RectangleD2D(PointD2D.Empty, msize), BrushX.GetEffectiveMaximumResolution(g, 1));
				labels[i].Draw(g, _brush, new PointF(0, 0));
				g.Restore(gs); // Restore the graphics state

				helperPath.Reset();
				helperPath.AddRectangle(new RectangleF(PointF.Empty, (SizeF)msize));
				helperPath.Transform(math);

				_enclosingPath.AddPath(helperPath, true);
			}
		}