TSimpleGraph
v2.1
|
Copyright ©
Kambiz R. Khojasteh. All rights reserved.
Get future component updates from http://www.delphiarea.com.
Delphi 4 | Delphi 5 | Delphi 6 | Delphi 7 | Delphi 2005 |
TSimpleGraph is a visual component, which provides a simple user interface for drawing graphs. The control and its graph objects are fully customizable in the way that let you create almost any kind of graphs.
Currently the control has seven node objects for basic geometric shapes: Triangle, Rhomboid, Rectangle, Round Rectangle, Pentagon, Hexagon, and Ellipse. In addition, by sub classing a class and overriding one or two methods, you can provide your own desired nodes. The line (link) object of the control is very flexible, and can be hook to other objects or connect them together.
By the way, the control has also some methods for supporting Delphi's clipboard and printer objects.
TSimpleGraph
= class(TCustomControl) TSimpleGraph is a windowed control that provides a canvas for drawing a graph. It also manages relation between graph objects and the application.
|
TGraphConstraints = class(TPersistent)
|
TGraphObjectList
= class(TPersistent)
|
TGrephObjectClass
= class of TGraphObject
|
TGraphLinkClass
= class of TGraphLink
|
TGraphNodeClass
= class of TGraphNode
|
TPolygonalNode
= class(TGraphNode) (Abstract)
|
TRoundRectangularNode
= class(TGraphNode) |
TEllipticNode
= class(TGraphNode) |
TTriangularNode
= class(TPolygonalNode) |
TRectangularNode = class(TPolygonalNode) |
TRhomboidalNode
= class(TPolygonalNode) |
TPentagonalNode
= class(TPolygonalNode) |
THexagonalNode = class(TPolygonalNode) |
TGraphScrollBar
= class(TPersistent) |
TMemoryHandleStream
= class(TMemoryStream)
|
TCanvasRecall = class(TObject)
|
WrapText(Canvas: TCanvas; const Text: String; MaxWidth: Integer): String; |
function MinimizeText(Canvas: TCanvas; const Text: String; const Rect: TRect): String; |
function
IsBetween(Value: Integer; Bound1, Bound2: Integer): Boolean; |
function
TransformRgn(Rgn: HRGN; const XForm: TXForm): HRGN; |
function NormalizeAngle(const Angle: Double): Double; Converts the angle specified by the Angle parameter, so that it falls in the range from -Pi to Pi radians. |
function EqualPoint(const Pt1, Pt2: TPoint): Boolean; Returns True if both points passed as parameter are equal. |
procedure
TransformPoints(var Points: array of TPoint; const XForm: TXForm); Transforms points specified by the Points parameter with the transform marix specifies by the XForm parameter. |
procedure
RotatePoints(var Points: array of TPoint; const Angle: Double; const
OrgPt: TPoint); Rotates points specified by the Points parameter around the point specified by the OrgPt parameter. The amount of rotation specifies by the Angle parameter, and is in radians. |
procedure ScalePoints(var Points: array of TPoint; const Factor: Double; const RefPt: TPoint); Scales distance of points specified by the Points parameter from the point specified by the RefPt parameter. The amount of scale specifies by the Factor parameter. |
procedure ShiftPoints(var Points: array of TPoint; dX, dY: Integer; const RefPt: TPoint); Moves points specified by the Points parameter according to their placement relative to the point specified by the RefPt parameter. The amount of movement specifies by dX and dY parameters. Positive values of dX and dY parameters cause the points go far from the reference point, and negative values cause the point go toward the refrence point. |
procedure
OffsetPoints(var Points: array of TPoint; dX, dY: Integer); Moves the specified points by the specified offsets. |
function
CenterOfPoints(var Points: array of TPoint): TPoint; Returns the center point of the specified points. |
function
BoundsRectOfPoints(var Points: array of TPoint): TRect; Returns the bounding rectangle of the specified points. |
function NearestPoint(const Points: array of TPoint; const RefPt: TPoint;
out NearestPt: TPoint): Integer; Returns the index of the point in the array, which is the nearest to the reference point. Also, the nearest point will be copied in to the NearestPt parameter. |
function MakeSquare(const Center: TPoint; Radius: Integer): TRect; Returns a square (rectangle) that is reperesented by its center point and radius. |
function
MakeRect(const Corner1, Corner2: TPoint): TRect; Returns a rectangle that is reperesented by its two corner points. |
function
CenterOfRect(const Rect: TRect): TPoint; Returns the center point of the rectangle specified by Rect parameter. |
function LineLength(const LinePt1, LinePt2: TPoint): Double; Returns lenght of the line represented by its two endpoints as LinePt1 and LinePt2 parameters. |
function
LineSlopeAngle(const LinePt1, LinePt2: TPoint): Double; Returns the slope angle in radians of the line that passes through the points represented by LinePt1 and LinePt2 parameters. |
function DistanceToLine(const LinePt1, LinePt2: TPoint; const QueryPt: TPoint): Double; Returns the distance of a point specified by the QuaryPt parameter from the line represented by its two endpoints as LinePt1 and LinePt2 parameters. |
function NearestPointOnLine(const LinePt1, LinePt2: TPoint; const RefPt: TPoint): TPoint; Returns the point on the line represented by its two endpoints as LinePt1 and LinePt2 parameters, which is the nearest to the point specified by the RefPt parameter. |
function NextPointOfLine(const LineAngle: Double; const ThisPt: TPoint;
const DistanceFromThisPt: Double): TPoint; |
function
IntersectLines(const Line1Pt: TPoint; const Line1Angle: Double; const
Line2Pt: TPoint; const Line2Angle: Double; out Intersect: TPoint):
Boolean ; If the two specified lines intersect each other, the function returns True and sets the Intersect parameter to the intersection point. Otherwise, the function returns False. The Line1Angle and Line2Angle parameters shold be in range from -Pi to Pi radians. |
function IntersectLineRect(const LinePt: TPoint; const LineAngle: Double; const Rect: TRect): TPoints; Retruns a dynamic array of points containing the intersection coordinates of the rectangle specified by the Bounds parameter and the line specified by LinePt and LineAngle parameters. The LineAngle parameter shold be in range from -Pi to Pi radians. |
function IntersectLineRoundRect(const LinePt: TPoint; const LineAngle: Double; const Bounds: TRect; CW, CH: Integer): TPoints; Retruns a dynamic array of points containing the intersection coordinates of the round rectangle specified by the Bounds, CW, and CH parameters and the line specified by LinePt and LineAngle parameters. The LineAngle parameter shold be in range from -Pi to Pi radians. |
function
IntersectLineEllipse(const LinePt: TPoint; const LineAngle: Double; const Bounds: TRect): TPoints; Retruns a dynamic array of points containing the intersection coordinates of the ellipse specified by the Bounds parameter and the line specified by LinePt and LineAngle parameters. The LineAngle parameter shold be in range from -Pi to Pi radians. |
function IntersectLinePolygon(const LinePt: TPoint; const LineAngle: Double; |
function IntersectLinePolyline(const LinePt: TPoint; const LineAngle: Double; |
GENERAL | |
CTRL |
In conjunction with some actions, toggles snap to gird mode on/off. |
TAB | Selects the next selectable object. |
SHIFT+TAB | Selectes the previous selectable object. |
DELETE | Removes the selected objects. |
LEFT |
Moves left selected and movable objects. |
RIGHT | Moves right selected and movable objects. |
UP | Moves up selected and movable objects. |
DOWN | Moves down selected and movable objects. |
NODES | |
SHIFT+LEFT |
Decreases width of selected and resizable nodes. |
SHIFT+RIGHT | Increases width of selected and resizable nodes. |
SHIFT+UP | Decreases height of selected and resizable nodes. |
SHIFT+DOWN | Increases height of selected and resizable nodes. |
GENERAL | |
CLICK |
Selects the clicked object if it is selectable, and clears previous selection. |
SHIFT+CLICK | Toggles selection of the clicked object, and keeps the old selection. If the object is not selectable, it would not be selected. |
WHEEL UP | Increases zoom by the factor specified by ZoomStep property. |
WHEEL DOWN | Decreases zoom by the factor specified by ZoomStep property. |
DESIGNER | |
DRAG |
Selects selectable objects in the marked area, and clears previous selection. Holding CTRL key down causes only node object be selected. |
SHIFT+DRAG | Toggles selection of the objects in the marked area, and keeps the old selection unchanged. If any object is not selectable, it would not be selected. Holding CTRL key down causes only selection of node objects toggles. |
ALT+DRAG | Zooms the marked area in. |
NODES | |
DRAG CLINET |
If the node is movable, moves the node. |
DRAG MARKER | If the node is resizable, resize the node according to the dragging marker. |
LINKS | |
DRAG LINE/CAPTION |
If the link can be moved, moves
the link. |
DRAG POINT | If the point is not fixed, moves the point. If the point is an endpoint, and ALT key is not down, dropping the point on an object establishes a link. |
ALT+CLICK POINT | If the point is not fixed, removes the point. |
ALT+CLICK LINE | If the link is not marked as fixed, inserts a new breakpoint at the clicked coordinates. |
RIGHT+CLICK | If a point is dragging, inserts a new breakpoint. The source point of the drag action, keeps its dragging state. |
Here are list of changes. General compatibility issues are markded as red.
Special thanks to:
TSimpleGraph component is freeware. You may copy component's files AS LONG AS YOU COPY ALL OF THEM. If you want to change the source code in order to improve the component's features, performance, etc. please send me the new source code so that I can have a look at it. The changed source code should contain descriptions what you have changed, and of course your name. The only thing you MAY NOT CHANGE is the ORIGINAL COPYRIGHT INFORMATION.
TSimpleGraph component is provided "AS IS" without any warranty of any kind, either express or implied. The entire risk as to the quality and performance of the software is with you. The author is NOT liable for any DAMAGES resulting from the use and misuse of the component, especially he is NOT liable for DAMAGES that were caused BY ANY VERSION WHICH HAS NOT BEEN PROGRAMMED BY THE AUTHOR HIMSELF.
|
END OF DOCUMENT |