示例#1
0
        private void InternalDrawLinePrimitive(ILineSegmentGraphic line)
        {
            Surface.FinalBuffer.Graphics.Transform = line.SpatialTransform.CumulativeTransform;
            line.CoordinateSystem = CoordinateSystem.Source;

            Surface.FinalBuffer.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            // Draw drop shadow
            _pen.Color = Color.Black;
            _pen.Width = CalculateScaledPenWidth(line, 1, Dpi);

            SetDashStyle(line);

            SizeF dropShadowOffset = GetDropShadowOffset(line, Dpi);

            Surface.FinalBuffer.Graphics.DrawLine(
                _pen,
                line.Point1 + dropShadowOffset,
                line.Point2 + dropShadowOffset);

            // Draw line
            _pen.Color = line.Color;

            Surface.FinalBuffer.Graphics.DrawLine(
                _pen,
                line.Point1,
                line.Point2);

            Surface.FinalBuffer.Graphics.SmoothingMode = SmoothingMode.None;

            line.ResetCoordinateSystem();
            Surface.FinalBuffer.Graphics.ResetTransform();
        }
示例#2
0
        /// <summary>
        /// Draws a line primitive to the specified destination buffer.
        /// </summary>
        /// <param name="buffer">The destination buffer.</param>
        /// <param name="pen">A GDI pen to use for drawing.</param>
        /// <param name="line">The line primitive to be drawn.</param>
        /// <param name="dpi">The intended output DPI.</param>
        public static void DrawLinePrimitive(IGdiBuffer buffer, Pen pen, ILineSegmentGraphic line, float dpi = _nominalScreenDpi)
        {
            buffer.Graphics.Transform     = line.SpatialTransform.CumulativeTransform;
            line.CoordinateSystem         = CoordinateSystem.Source;
            buffer.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            try
            {
                // Draw drop shadow
                pen.Color = Color.Black;
                pen.Width = CalculateScaledPenWidth(line, 1, dpi);

                SetDashStyle(pen, line);

                var dropShadowOffset = GetDropShadowOffset(line, dpi);
                buffer.Graphics.DrawLine(
                    pen,
                    line.Point1 + dropShadowOffset,
                    line.Point2 + dropShadowOffset);

                // Draw line
                pen.Color = line.Color;

                buffer.Graphics.DrawLine(
                    pen,
                    line.Point1,
                    line.Point2);
            }
            finally
            {
                buffer.Graphics.SmoothingMode = SmoothingMode.None;
                line.ResetCoordinateSystem();
                buffer.Graphics.ResetTransform();
            }
        }
 public void Dispose()
 {
     if (_lineGraphic != null)
     {
         _lineGraphic.Point1Changed -= _lineGraphic_Point1Changed;
         _lineGraphic.Point2Changed -= _lineGraphic_Point2Changed;
         _lineGraphic = null;
     }
 }
示例#4
0
 private void OnCloneComplete()
 {
     _angleCalloutGraphic1 = (AngleCalloutGraphic)CollectionUtils.SelectFirst(base.Graphics, g => g.Name == "callout1");
     _angleCalloutGraphic2 = (AngleCalloutGraphic)CollectionUtils.SelectFirst(base.Graphics, g => g.Name == "callout2");
     _extenderLine1        = (ILineSegmentGraphic)CollectionUtils.SelectFirst(base.Graphics, g => g.Name == "extender1");
     _extenderLine2        = (ILineSegmentGraphic)CollectionUtils.SelectFirst(base.Graphics, g => g.Name == "extender2");
     _riserLine1           = (ILineSegmentGraphic)CollectionUtils.SelectFirst(base.Graphics, g => g.Name == "riser1");
     _riserLine2           = (ILineSegmentGraphic)CollectionUtils.SelectFirst(base.Graphics, g => g.Name == "riser2");
 }
 private static void SerializeDashedLine(ILineSegmentGraphic lineSegmentGraphic, GraphicAnnotationSequenceItem serializationState)
 {
     lineSegmentGraphic.CoordinateSystem = CoordinateSystem.Source;
     try
     {
         SerializeDashedLine(lineSegmentGraphic.Point1, lineSegmentGraphic.Point2, lineSegmentGraphic.SpatialTransform, serializationState, true);
     }
     finally
     {
         lineSegmentGraphic.ResetCoordinateSystem();
     }
 }
示例#6
0
            /// <summary>
            /// Draws <paramref name="riser"/> to rise from the point <paramref name="pV"/> on the vector P (defined by <paramref name="p1"/> <paramref name="p2"/>)
            /// to the point <paramref name="intersection"/>. The vector P is redefined to be the vector between <paramref name="pV"/> and
            /// <paramref name="intersection"/>, with direction depending on original orientation of vector P.
            /// </summary>
            /// <param name="p1"></param>
            /// <param name="p2"></param>
            /// <param name="pV"></param>
            /// <param name="intersection"></param>
            private static void DrawRiserLine(ILineSegmentGraphic riser, ref PointF p1, ref PointF p2, PointF pV, PointF intersection)
            {
                // extend riser past intersection by a bit
                PointF pW = new PointF(intersection.X - pV.X, intersection.Y - pV.Y);
                float  pF = 1 + (float)((_minLength + 1) / Math.Sqrt((pW.X * pW.X + pW.Y * pW.Y)));

                pW = new PointF(pV.X + pW.X * pF, pV.Y + pW.Y * pF);

                //TODO (CR Mar 2010): this kind of calculation in a function (CrossProduct)
                if ((pW.X - pV.X) * (p2.Y - p1.Y) - (pW.Y - pV.Y) * (p2.X - p1.X) < 0)
                {
                    PointF temp = pW;
                    pW = pV;
                    pV = temp;
                }
                riser.Visible = true;
                riser.Point1  = p1 = pV;
                riser.Point2  = p2 = pW;
            }
示例#7
0
            /// <summary>
            /// Draws <paramref name="extender"/> to extend the vector P (defined by <paramref name="p1"/> <paramref name="p2"/>)
            /// to the point where <paramref name="p1"/> <paramref name="pX"/> projects onto P. The projected point is returned.
            /// Vector P is redefined to be the vector including the project point.
            /// </summary>
            private static PointF DrawExtenderLine(ILineSegmentGraphic extender, ref PointF p1, ref PointF p2, PointF pX)
            {
                float  pF = DotProduct(p1, pX, p1, p2) / DotProduct(p1, p2, p1, p2);
                PointF pC = new PointF(p1.X + pF * (p2.X - p1.X), p1.Y + pF * (p2.Y - p1.Y));

                if (pF > 1)
                {
                    extender.Visible = true;
                    extender.Point1  = p2;
                    extender.Point2  = p2 = pC;
                }
                else if (pF < 0)
                {
                    extender.Visible = true;
                    extender.Point2  = p1;
                    extender.Point1  = p1 = pC;
                }

                return(pC);
            }
示例#8
0
			public ShowAnglesToolGraphic()
			{
				base.Graphics.Add(_angleCalloutGraphic1 = new AngleCalloutGraphic());
				base.Graphics.Add(_angleCalloutGraphic2 = new AngleCalloutGraphic());
				base.Graphics.Add(_extenderLine1 = new LinePrimitive());
				base.Graphics.Add(_extenderLine2 = new LinePrimitive());
				base.Graphics.Add(_riserLine1 = new LinePrimitive());
				base.Graphics.Add(_riserLine2 = new LinePrimitive());

				_angleCalloutGraphic1.ShowArrowhead = _angleCalloutGraphic2.ShowArrowhead = false;
				_angleCalloutGraphic1.LineStyle = _angleCalloutGraphic2.LineStyle = LineStyle.Dash;
				_angleCalloutGraphic1.Name = "callout1";
				_angleCalloutGraphic2.Name = "callout2";
				_extenderLine1.Name = "extender1";
				_extenderLine2.Name = "extender2";
				_riserLine1.Name = "riser1";
				_riserLine2.Name = "riser2";

				_endPoints = new PointsList(new PointF[] {PointF.Empty, PointF.Empty, PointF.Empty, PointF.Empty}, this);

				this.Color = Color.Coral;
				this.LineStyle = LineStyle.Dot;
			}
示例#9
0
            public ShowAnglesToolGraphic()
            {
                base.Graphics.Add(_angleCalloutGraphic1 = new AngleCalloutGraphic());
                base.Graphics.Add(_angleCalloutGraphic2 = new AngleCalloutGraphic());
                base.Graphics.Add(_extenderLine1        = new LinePrimitive());
                base.Graphics.Add(_extenderLine2        = new LinePrimitive());
                base.Graphics.Add(_riserLine1           = new LinePrimitive());
                base.Graphics.Add(_riserLine2           = new LinePrimitive());

                _angleCalloutGraphic1.ShowArrowhead = _angleCalloutGraphic2.ShowArrowhead = false;
                _angleCalloutGraphic1.LineStyle     = _angleCalloutGraphic2.LineStyle = LineStyle.Dash;
                _angleCalloutGraphic1.Name          = "callout1";
                _angleCalloutGraphic2.Name          = "callout2";
                _extenderLine1.Name = "extender1";
                _extenderLine2.Name = "extender2";
                _riserLine1.Name    = "riser1";
                _riserLine2.Name    = "riser2";

                _endPoints = new PointsList(new PointF[] { PointF.Empty, PointF.Empty, PointF.Empty, PointF.Empty }, this);

                this.Color     = Color.Coral;
                this.LineStyle = LineStyle.Dot;
            }
 public LineSegmentGraphicPointsAdapter(ILineSegmentGraphic lineGraphic)
 {
     _lineGraphic = lineGraphic;
     _lineGraphic.Point1Changed += _lineGraphic_Point1Changed;
     _lineGraphic.Point2Changed += _lineGraphic_Point2Changed;
 }
示例#11
0
		private void InternalDrawLinePrimitive(ILineSegmentGraphic line) {
			Surface.FinalBuffer.Graphics.Transform = line.SpatialTransform.CumulativeTransform;
			line.CoordinateSystem = CoordinateSystem.Source;

			Surface.FinalBuffer.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

			// Draw drop shadow
			_pen.Color = Color.Black;
			_pen.Width = CalculateScaledPenWidth(line, 1, Dpi);

			SetDashStyle(line);

			SizeF dropShadowOffset = GetDropShadowOffset(line, Dpi);
			Surface.FinalBuffer.Graphics.DrawLine(
				_pen,
				line.Point1 + dropShadowOffset,
				line.Point2 + dropShadowOffset);

			// Draw line
			_pen.Color = line.Color;

			Surface.FinalBuffer.Graphics.DrawLine(
				_pen,
				line.Point1,
				line.Point2);

			Surface.FinalBuffer.Graphics.SmoothingMode = SmoothingMode.None;

			line.ResetCoordinateSystem();
			Surface.FinalBuffer.Graphics.ResetTransform();
		}
示例#12
0
		/// <summary>
		/// Draws a line primitive to the specified destination buffer.
		/// </summary>
		/// <param name="buffer">The destination buffer.</param>
		/// <param name="pen">A GDI pen to use for drawing.</param>
		/// <param name="line">The line primitive to be drawn.</param>
		/// <param name="dpi">The intended output DPI.</param>
		public static void DrawLinePrimitive(IGdiBuffer buffer, Pen pen, ILineSegmentGraphic line, float dpi = _nominalScreenDpi)
		{
			buffer.Graphics.Transform = line.SpatialTransform.CumulativeTransform;
			line.CoordinateSystem = CoordinateSystem.Source;
			buffer.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
			try
			{
				// Draw drop shadow
				pen.Color = Color.Black;
				pen.Width = CalculateScaledPenWidth(line, 1, dpi);

				SetDashStyle(pen, line);

				var dropShadowOffset = GetDropShadowOffset(line, dpi);
				buffer.Graphics.DrawLine(
					pen,
					line.Point1 + dropShadowOffset,
					line.Point2 + dropShadowOffset);

				// Draw line
				pen.Color = line.Color;

				buffer.Graphics.DrawLine(
					pen,
					line.Point1,
					line.Point2);
			}
			finally
			{
				buffer.Graphics.SmoothingMode = SmoothingMode.None;
				line.ResetCoordinateSystem();
				buffer.Graphics.ResetTransform();
			}
		}
示例#13
0
					public void Dispose()
					{
						if (_lineGraphic != null)
						{
							_lineGraphic.Point1Changed -= _lineGraphic_Point1Changed;
							_lineGraphic.Point2Changed -= _lineGraphic_Point2Changed;
							_lineGraphic = null;
						}
					}
示例#14
0
					public LineSegmentGraphicPointsAdapter(ILineSegmentGraphic lineGraphic)
					{
						_lineGraphic = lineGraphic;
						_lineGraphic.Point1Changed += _lineGraphic_Point1Changed;
						_lineGraphic.Point2Changed += _lineGraphic_Point2Changed;
					}
示例#15
0
			private void OnCloneComplete()
			{
				_angleCalloutGraphic1 = (AngleCalloutGraphic) CollectionUtils.SelectFirst(base.Graphics, g => g.Name == "callout1");
				_angleCalloutGraphic2 = (AngleCalloutGraphic) CollectionUtils.SelectFirst(base.Graphics, g => g.Name == "callout2");
				_extenderLine1 = (ILineSegmentGraphic) CollectionUtils.SelectFirst(base.Graphics, g => g.Name == "extender1");
				_extenderLine2 = (ILineSegmentGraphic) CollectionUtils.SelectFirst(base.Graphics, g => g.Name == "extender2");
				_riserLine1 = (ILineSegmentGraphic) CollectionUtils.SelectFirst(base.Graphics, g => g.Name == "riser1");
				_riserLine2 = (ILineSegmentGraphic) CollectionUtils.SelectFirst(base.Graphics, g => g.Name == "riser2");
			}
示例#16
0
			/// <summary>
			/// Draws <paramref name="extender"/> to extend the vector P (defined by <paramref name="p1"/> <paramref name="p2"/>)
			/// to the point where <paramref name="p1"/> <paramref name="pX"/> projects onto P. The projected point is returned.
			/// Vector P is redefined to be the vector including the project point.
			/// </summary>
			private static PointF DrawExtenderLine(ILineSegmentGraphic extender, ref PointF p1, ref PointF p2, PointF pX)
			{
				float pF = DotProduct(p1, pX, p1, p2)/DotProduct(p1, p2, p1, p2);
				PointF pC = new PointF(p1.X + pF*(p2.X - p1.X), p1.Y + pF*(p2.Y - p1.Y));

				if (pF > 1)
				{
					extender.Visible = true;
					extender.Point1 = p2;
					extender.Point2 = p2 = pC;
				}
				else if (pF < 0)
				{
					extender.Visible = true;
					extender.Point2 = p1;
					extender.Point1 = p1 = pC;
				}

				return pC;
			}
示例#17
0
			/// <summary>
			/// Draws <paramref name="riser"/> to rise from the point <paramref name="pV"/> on the vector P (defined by <paramref name="p1"/> <paramref name="p2"/>)
			/// to the point <paramref name="intersection"/>. The vector P is redefined to be the vector between <paramref name="pV"/> and
			/// <paramref name="intersection"/>, with direction depending on original orientation of vector P.
			/// </summary>
			/// <param name="p1"></param>
			/// <param name="p2"></param>
			/// <param name="pV"></param>
			/// <param name="intersection"></param>
			private static void DrawRiserLine(ILineSegmentGraphic riser, ref PointF p1, ref PointF p2, PointF pV, PointF intersection)
			{
				// extend riser past intersection by a bit
				PointF pW = new PointF(intersection.X - pV.X, intersection.Y - pV.Y);
				float pF = 1 + (float) ((_minLength + 1)/Math.Sqrt((pW.X*pW.X + pW.Y*pW.Y)));
				pW = new PointF(pV.X + pW.X*pF, pV.Y + pW.Y*pF);

				//TODO (CR Mar 2010): this kind of calculation in a function (CrossProduct)
				if ((pW.X - pV.X)*(p2.Y - p1.Y) - (pW.Y - pV.Y)*(p2.X - p1.X) < 0)
				{
					PointF temp = pW;
					pW = pV;
					pV = temp;
				}
				riser.Visible = true;
				riser.Point1 = p1 = pV;
				riser.Point2 = p2 = pW;
			}