📄 reparc.cs
字号:
using System;
using System.Drawing;
// Creation date: 15.02.2004
// Checked: xx.08.2002
// Author: Otto Mayer (mot@root.ch)
// Version: 1.02
// copyright (C) 2004 root-software ag - B黵glen Switzerland - www.root.ch; Otto Mayer, Stefan Spirig, Roger Gartenmann
// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, version 2.1 of the License.
// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
// should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA www.opensource.org/licenses/lgpl-license.html
namespace Root.Reports {
//------------------------------------------------------------------------------------------14.03.2004
#region RepArcBase
//----------------------------------------------------------------------------------------------------
/// <summary>Base Class of the Arc, Circle, Ellipse and Pie Objects</summary>
/// <remarks>
/// This class is the base class of the <see cref="RepArc"/>, <see cref="RepCircle"/>, <see cref="RepEllipse"/> and <see cref="RepPie"/> classes.
/// </remarks>
public abstract class RepArcBase : RepObj {
/// <summary>Pen properties of the border line</summary>
internal PenProp _penProp;
/// <summary>Brush properties of the pie or circle</summary>
internal BrushProp _brushProp;
/// <summary>Angle in degrees measured clockwise from the x-axis to the first side of the pie section</summary>
internal Double _rStartAngle;
/// <summary>Angle in degrees measured clockwise from the startAngle parameter to the second side of the pie section</summary>
internal Double _rSweepAngle;
//----------------------------------------------------------------------------------------------------x
/// <summary>Initializes all parameters for an arc, circle, ellipse or pie.</summary>
/// <remarks>
/// This constructor must be called by all derived classes.
/// The pen properties <paramref name="penProp"/> can be set to draw a border line.
/// If the brush properties <paramref name="brushProp"/> are set, the interior of the shape will be filled.
/// The ellipse is defined by the bounding rectangle described by the <paramref name="rWidth"/> and
/// <paramref name="rHeight"/> parameters.
/// The parameters <paramref name="rStartAngle"/> and <paramref name="rSweepAngle"/> can be used to define a portion of an ellipse.
/// </remarks>
/// <param name="penProp">Pen properties of the border line</param>
/// <param name="brushProp">Brush properties of the fill</param>
/// <param name="rWidth">Width in points (1/72 inch) of the bounding rectangle that defines the ellipse</param>
/// <param name="rHeight">Height in points (1/72 inch) of the bounding rectangle that defines the ellipse</param>
/// <param name="rStartAngle">Angle in degrees measured clockwise from the x-axis to the start point of the arc</param>
/// <param name="rSweepAngle">Angle in degrees measured clockwise from the <paramref name="rStartAngle"/> parameter to
/// the end point of the arc</param>
public RepArcBase(PenProp penProp, BrushProp brushProp, Double rWidth, Double rHeight, Double rStartAngle, Double rSweepAngle) {
if (penProp != null) {
this._penProp = penProp.penProp_Registered;
}
if (brushProp != null) {
this._brushProp = brushProp.brushProp_Registered;
}
this.rWidth = rWidth;
this.rHeight = rHeight;
this._rStartAngle = rStartAngle;
this._rSweepAngle = rSweepAngle;
}
//----------------------------------------------------------------------------------------------------
/// <summary>Calculates the x- and y-coordinates of the ellipse for the specified angle.</summary>
/// <param name="rAngle">Angle in radians measured clockwise from the x-axis</param>
/// <param name="rX">x-coordinate in points (1/72 inch)</param>
/// <param name="rY">y-coordinate in points (1/72 inch)</param>
internal void GetEllipseXY(Double rAngle, out Double rX, out Double rY) {
const Double rPi1_2 = Math.PI / 2.0;
const Double rPi3_2 = Math.PI / 2.0 * 3.0;
rAngle = rAngle - Math.Floor(rAngle / 2.0 / Math.PI) * 2.0 * Math.PI;
Double rA = rWidth / 2.0;
Double rB = rHeight / 2.0;
if (RT.bEquals(rAngle, rPi1_2, 0.0001)) {
rX = 0;
rY = -rB;
return;
}
if (RT.bEquals(rAngle, rPi3_2, 0.0001)) {
rX = 0;
rY = rB;
return;
}
// tan(@) = y/x ==> y = x tan(@) @ != 0
// x^2/a^2 + y^2/b^2 = 1
// ==> 1. x^2/a^2 + x^2 tan(@)^2 / b^2 = 1
// 2. x^2 (1/a^2 + tan(@)^2 / b^2) = 1
// 3. x^2 = 1 / (1/a^2 + tan(@)^2 / b^2)
// 4. x = SQRT(1 / (1/a^2 + tan(@)^2 / b^2))
Double r = Math.Tan(-rAngle);
r = 1.0 / rA / rA + r * r / rB / rB;
rX = Math.Sqrt(1 / r);
if (rAngle > rPi1_2 && rAngle < rPi3_2) {
rX = -rX;
}
// y = x tan(@)
rY = rX * Math.Tan(-rAngle);
}
}
#endregion
//------------------------------------------------------------------------------------------14.03.2004
#region RepArc
//----------------------------------------------------------------------------------------------------
/// <summary>Report Arc Object</summary>
/// <remarks>
/// This object draws an arc representing a portion of an ellipse or circle.
/// </remarks>
public class RepArc : RepArcBase {
//------------------------------------------------------------------------------------------04.03.2004
/// <overloads>
/// <summary>Creates an arc representing a portion of an ellipse or circle.</summary>
/// <remarks>
/// The pen properties object <paramref name="penProp"/> determines the characteristics of the border line.
/// The arc represents a portion of an ellipse or circle.
/// </remarks>
/// </overloads>
///
/// <summary>Creates an arc representing a portion of an ellipse specified by the bounding rectangle in points (1/72 inch).</summary>
/// <remarks>
/// The pen properties object <paramref name="penProp"/> determines the characteristics of the border line.
/// The arc represents a portion of an ellipse that is defined by the bounding rectangle described by the
/// <paramref name="rWidth"/> and <paramref name="rHeight"/> parameters.
/// The parameters <paramref name="rStartAngle"/> and <paramref name="rSweepAngle"/> define the start and end point of the arc.
/// </remarks>
/// <param name="penProp">Pen properties of the arc</param>
/// <param name="rWidth">Width in points (1/72 inch) of the bounding rectangle that defines the ellipse from which the arc comes</param>
/// <param name="rHeight">Height in points (1/72 inch) of the bounding rectangle that defines the ellipse from which the arc comes</param>
/// <param name="rStartAngle">Angle in degrees measured clockwise from the x-axis to the start position of the arc</param>
/// <param name="rSweepAngle">Angle in degrees measured clockwise from the <paramref name="rStartAngle"/> parameter to
/// the end point of the arc</param>
public RepArc(PenProp penProp, Double rWidth, Double rHeight, Double rStartAngle, Double rSweepAngle)
: base(penProp, null, rWidth, rHeight, rStartAngle, rSweepAngle) {
}
//------------------------------------------------------------------------------------------04.03.2004
/// <summary>Creates an arc representing a portion of a circle specified by the radius in points (1/72 inch).</summary>
/// <remarks>
/// The pen properties object <paramref name="penProp"/> determines the characteristics of the border line.
/// The arc represents a portion of a circle that is defined by the parameter <paramref name="rRadius"/>.
/// The parameters <paramref name="rStartAngle"/> and <paramref name="rSweepAngle"/> define the start and end point of the arc.
/// </remarks>
/// <param name="penProp">Pen properties of the arc</param>
/// <param name="rRadius">Radius of the circle in points (1/72 inch)</param>
/// <param name="rStartAngle">Angle in degrees measured clockwise from the x-axis to the start position of the arc</param>
/// <param name="rSweepAngle">Angle in degrees measured clockwise from the <paramref name="rStartAngle"/> parameter to
/// the end point of the arc</param>
public RepArc(PenProp penProp, Double rRadius, Double rStartAngle, Double rSweepAngle)
: this(penProp, rRadius * 2.0, rRadius * 2.0, rStartAngle, rSweepAngle) {
}
}
#endregion
//------------------------------------------------------------------------------------------04.03.2004
#region RepArcMM
//----------------------------------------------------------------------------------------------------
/// <summary>Report Arc Object (metric version)</summary>
/// <remarks>
/// This object draws an arc representing a portion of an ellipse or circle.
/// </remarks>
public class RepArcMM : RepArc {
//------------------------------------------------------------------------------------------04.03.2004
/// <overloads>
/// <summary>Creates an arc representing a portion of an ellipse or circle.</summary>
/// <remarks>
/// The pen properties object <paramref name="penProp"/> determines the characteristics of the border line.
/// The arc represents a portion of an ellipse or circle.
/// </remarks>
/// </overloads>
///
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -