Your company's Logo

    Home Contact us Download Site map About us

i-Logic Products
Utilities
CadDraw

CadDraw Component for Delphi


Download - here for free at this link:

For Delphi 7 -  caddrawdelphi7a.zip (1-16-07)

For Kylix 3 -  caddrawkylix3.zip (12-14-03)

CaddrawGDI version that uses Windows GdiPlus.dll:
For Delphi 7 - caddrawGDI.zip (1-16-07)
For Delphi 2006 caddrawGDI2006.zip (1-16-07)
  • Source code is Not available.
  • Installations include demo program.

Installation - 

Windows - Unzip files to a directory. Open Delphi - Main Menu - Component - Install Packages. Press "Add". Find and choose "Caddraw.bpl", and that should put it in the Delphi component bar under the "i-Logic" tab.

Kylix - Same thing except choose "bplCaddraw.so".

Need to have files in Delphi search path.


CadDraw Component

The CadDraw component is a window for displaying points, lines, and arcs. creates elements in memory for redrawing on the window.

All angle input is in ordinary decimal degrees - not radians.

Angles are measured as 3 o'clock is zero and going counter-clockwise.


Properties - 

  • Color - The current color for drawing points, lines, and arcs.
  • BackgroundColor - The background color of the drawing.
  • View:TDView - One of the four standard views - vTOP, vFRONT, vSIDE, vISO
  • Units:TDUnits - Either - uINCH or uMM. Used in output to IGES file.
  • DrawMode - The current drawing pen mode on the canvas. This can be any of the Windows Delphi defined pen modes: TPenMode = (pmBlack, pmWhite, pmNop, pmNot, pmCopy, pmNotCopy, pmMergePenNot, pmMaskPenNot, pmMergeNotPen, pmMaskNotPen, pmMerge, pmNotMerge, pmMask, pmNotMask, pmXor, pmNotXor)
        The default is pmCopy;
  • LineType:Integer - An integer representing one of the Windows LineTypes. The default is 0 which is a solid line;

0,1 =:psSolid; 
2 =psDot; 
3 =psDashDot;
4 =psDashDotDot;

  • CenterX:Double - The center of the draw window in coordinates from the origin. Set this and redraw the window to shift the view in the X direction.
  • CenterY:Double - The center of the draw window in coordinates from the origin. Set this and redraw the window to shift the view in the Y direction.
  • PickFilter:TDFilter -  default fAll; TDFilter=(fAll,fPoints, fLines, fArcs, fPointLine, fPointArc, fLineArc);
  • XRotation:Double - Rotates the view around the X Axis (in decimal degrees). Will show at next redraw.
  • YRotation:Double - Rotates the view around the Y Axis (in decimal degrees). Will show at next redraw.
  • ZRotation:Double - Rotates the view around the Z Axis (in decimal degrees). Will show at next redraw.
  • CadType:Integer -  The type of CAD file for reading and writing. CDL=1; DXF=2; IGES=3; default=1;

CadDraw supports reading and writing the different file types to different degrees. CADL files are supported best. Supports points, lines, and 3D arcs, colors, line types. These are used by CadKey and most CAM systems.

DXF supports points, lines, 2D arcs, polylines, colors.

IGES supports points, lines, 2D arcs, no colors.

All of these are ascii text files.

  • Layer[index]:boolean - CadDraw has drawing layers 1 through 254. You can turn visibility on or off each individual layer. Only the visible layers are draw at the redraw command;
  • MousePan:Boolean - This controls whether the drawing pans across the window when the middle mouse button is held down, or the Cntrl-Left Mouse is used. The default true;
  • ArcView[Index:integer]:TDView3D - Array of defined arc-views. ArcView=1 is the normal top X,Y view. 

In order to draw an arc in any other view than the normal top X,Y view, you have to define that arcview first;

This version is limited to 90 different views;

We will not explain here what an arc view consists of except to say that its the same format found in a CADL text file.

 

  • ElementCount:Integer - Read only. Returns the number of elements in memory;
  • ViewSize:Double - This is what zooms the drawing in and out. The number represents the size of height (or width, whichever is smaller) that the window represents in units. For instance, if you set the size to 100 inches you will zoom way out on the drawing. If you set the size to 1 inch, you will zoom way in on the drawing. 
  • Elements[Index:integer]:TElement - The array of CAD elements in memory. Any element index over ElementCount is undefined.
  • IsDeleted[Index:integer]:Boolean - Tags that element as deleted but does not remove it from memory. Elements tagged as deleted are not redrawn. They can be undeleted by setting to false. Deleted elements are not saved to file.
  • ShowAxis:Boolean - Draws the Axis lines all the time.
  • PrintMonochrome :Boolean- When printing, ignores color information of the elements.

Methods:

These 6 methods only draw in the window, they don't save the elements in memory.

  • procedure DrawPoint(x,y,z:double); - Draws a point at coordinates;
  • procedure DrawLine(x1,y1,z1,x2,y2,z2: double) Draws a line at coordinates.
  • procedure DrawArc(View:Integer; X,Y,Z,Radius,StartAngle,EndAngle: double); - Draws an arc. The View is the defined arc-view. For normal 2D drawing the view=1.
  • procedure DrawPointX(Point1:TDPoint) - Same as DrawPoint except input as TDPoint.
  • procedure DrawLineX(Line1:TDLine);
  • procedure DrawArcX(Arc1:TDArc); 2D arcs only

 

These 6 methods only create the element in memory, they don't draw anything. The functions return the element number;

  • function MakePoint(X,Y,Z: double);
  • function MakeLine(x1,y1,z1,x2,y2,z2: double);
  • function MakeArc(View:integer; X,Y,Z,Radius,StartAngle,EndAngle: double);
  • function MakePointX(Point1:TDPoint);
  • function MakeLineX(Line1:TDLine);
  • function MakeArcX(Arc1:TDArc); 2D arcs only.

 

  • procedure LoadFromFile(Filename:string); - Load CAD elements from a CDL, DXF, or IGS file. It uses the file format according to the file extension or the CadType property.
  • procedure SaveToFile(Filename:string) - Saves CAD elements to a CDL, DXF, or IGS file. It uses the file format according to the file extension or the CadType property.
  • procedure PrintCad - Sends the vector graphics to the printer.
  • procedure PrintBMP - Sends the bitmap of the drawing window to the printer.
  • procedure DrawElement(Index:Integer); - Draws the point, line, or arc in the element at that index in the array of elements.
  • procedure Redraw - Redraws the window.
  • procedure Clear - Erases the windows and draws the background in the background color. doesn't delete any elements in memory.
  • procedure RotateView(X,Y,Z:double); - Rotates the drawing view around each axis. Input is in degrees around the X axis, Y axis, Z axis. The center screen coordinates stay the same. 
  • procedure ViewCenter(X,Y:double); - This is what pans the drawing view. This method redraws the window.
  • function PixelToCoord(X,Y:Integer):TDpoint - Function for converting window pixel coordinates to drawing coordinates, according to the current view.
  • function CoordToPixel(X,Y,Z:double):TPoint - Function for converting coordinates to window pixel coordinates, according to the current view.
  • procedure Pick - Starts the pick procedure. CadDraw will be waiting for a mouse click in the window, and will call the OnPick Event with any element it found. Only available in Top view 1.
  • procedure Pan(X,Y:double) - Moves the drawing view incrementally by these drawing units and redraws the screen.
  • procedure ClearElements - Erases all elements and frees the memory.
  • procedure DrawAxis - Draws temporary intersecting lines along the X,Y, and Z axis as a visual help to know where the origin is. It is erased at the next redraw.
  • procedure ZoomAll - Zooms the drawing to the extents of all the CAD elements.
    procedure ZoomHalf - Zooms out to half the scale of the present area.
  • procedure ZoomDouble - Zooms in to cover twice the scale of  the present area.
  • procedure ZoomLast - Zooms back to whatever the last zoom was.
  • procedure ZoomWindow(X1,Y1,X2,Y2:integer) - Zooms in on the drawing to the size of this pixel rectangle in the current window. The new drawing center will be where the center of this rectangle was. You would use this function if you used the mouse to make a window to zoom in.
  • procedure SaveBMP(Filename:string) - Saves the drawing on the component as a bitmap file.
  • procedure SaveGIF(Filename:string) - Saves the drawing on the component as a GIF bitmap file.
  • procedure SaveJPEG(Filename:string) - Saves the drawing on the component as a JPEG bitmap file.
  • procedure WmfToClipboard - Copies the drawing as a windows metafile to the clipboard.  Not available in Kylix version.
  • procedure BmpToClipboard - Copies the drawing as a windows bitmap to the clipboard.  Not available in Kylix version.
  • procedure NewOrigin (X,Y,Z:double) - Shifts all the elements so this point is now X0, Y0, Z0.
  • procedure AddToGroup (Index:integer)- Adds this element number to the Group. Index of zero will add all elements to the Group.
  • procedure ClearGroup - Removes all elements from the Group.
  • procedure RotateGroup (Angle,CenterX,CenterY:double; NumberOfTimes:integer; Leave:boolean) - Rotates the CAD elements that have been grouped. Rotates around a point in the current view. Copies the rotation NumberOf Times. Will delete the original Group if Leave=False.
  • procedure RotateElement (Index:integer; Angle, CenterX, CenterY: double) - Rotates Element identified by Index around a point in current view.
  • procedure ShiftGroup (X,Y,Z: double; NumberOfTimes: integer; Leave: boolean) - Shifts the Grouped Elements by x,y,z and makes NumberOfTimes shifted copies. If Leave=False then original Group is deleted.
  • procedure DeleteGroup  - Deletes the elements in the group.
  • procedure ShiftElement (Index:integer; X,Y,Z: double) - Shifts the coordinates of the element by X,Y,Z.
  • procedure SetExtents - Recalculates the extents of the drawing so Zoom All will put the drawing in the middle of the window.
  • Events

    • OnPick - Event is triggered when mouse button is pressed after the Pick function is called.
    • OnZoom - Event is triggered when any of the zoom commands are finished redrawing the window.
    • OnChangeView - Event is triggered before redrawing when the view is changed;

    Note: All features only supported in Delphi 7 version.


CadCalc Component

The CadCalc component is not needed for CadDraw to work. The CadCalc component provides convenient geometry calculations for finding the points of intersecting lines and arcs, constructing tangent lines and arcs, and so on.

These are all 2D calculations. In this version, all these arcs are treated as full circles when finding intersections and tangents. So the intersection points can be anywhere on the full circle.

Functions that return an integer return 0 for success and non-zero for error code.

All angle input and output is in decimal degrees.

Methods:

  • function PointXYZ(X,Y,Z:double; var Point1:TDPoint):integer - Turns X,Y,Z coordinates into a TDPoint.
  • function Point2Lines(Line1,Line2:TDLine; var Point1:TDPoint):Integer - Finds the intersection of two lines.
  • function Point2Arcs(Arc1,Arc2:TDArc; PickPoint:TDPoint; var Point1:TDPoint):Integer - Finds the intersection of two arcs. Since there are two possibilities, it returns the point closest to PickPoint.
  • function PointLineArc(Line1:TDLine; Arc1:TDArc; PickPoint:TDPoint; var Point1:TDPoint):Integer - Finds the intersection of a line and arc.  Since there are two possibilities, it returns the point closest to PickPoint.
  • function Points2Arcs(Arc1,Arc2:TDArc;var Point1,Point2:TDPoint):Integer - Finds the intersection of two arcs. It returns both possibilities.
  • function PointArcAngle(Arc1:TDArc;Angle:Double;var Point1:TDPoint):Integer - Finds the point on an arc at an angle.
  • function PointCenterArc(Arc1:TDArc;var Point1:TDPoint):Integer - Returns the center point of the arc.
  • function Line2Points(Point1,Point2:TDPoint; var Line1:TDLine):Integer - Returns the line made from these two points.
  • function LinePointAngle(Point1:TDPoint; Angle,Length:double; var Line1:TDLine):Integer - Returns the line starting at point1 and going at an angle for length distance.
  • function LineTangentPoint(PickPoint,Point1:TDPoint; Arc1:TDArc;var Line1:TDLine):Integer - A line tangent to an arc, passing through a point.
  • function LinePerpPoint(Point1:TDPoint;Line1:TDLine; var Line2:TDLine):Integer; - A line perpendicular to a line passing through a point.
  • function LineParPoint(Point1:TDPoint;Line1:TDLine; var Line2:TDLine):Integer;  - A line parallel to a line that is passing through a point.
  • function LineTan2Arcs(Arc1,Arc2:TDArc; PickPoint1,PickPoint2:TDPoint; var Line1:TDLine):Integer;  
  • function LineTanAngle(Arc1:TDArc; Angle,Length:double; var Line1:TDLine): Integer;  - A line tangent to an arc at a certain angle.
  • function LineOffset(Line1:TDLine; Distance:double; PickPoint:TDPoint; var Line2:TDLine):Integer;  - A line that is offset a distance from another line.
  • function ArcCenterRad(Point1:TDPoint; Radius,StartAngle,EndAngle:double; var Arc1:TDArc):Integer;  - Arc with center and radius.
  • function ArcCenterTanLine(Point1:TDPoint; Line1:TDLine; StartAngle,EndAngle:double; var Arc1:TDArc):Integer;  - Arc with center at point and tangent to a line.
  • function ArcCenterPoint(Point1,Point2:TDPoint; StartAngle,EndAngle:double; var Arc1:TDArc):Integer;  - Arc with center at point and passing through a point.
  • function ArcCenterTanArc(PickPoint,Point1:TDPoint; Arc1:TDArc; StartAngle,EndAngle:double; var Arc2:TDArc):Integer;  - Arc with center at point and tangent to another arc.
  • function Arc3Points(Point1,Point2,Point3:TDPoint; StartAngle,EndAngle:double; var Arc1:TDArc):Integer;  - Arc passing through 3 points
  • function ArcTanLinePoint(Line1:TDLine; PickPoint,Point1:TDPoint; Radius,StartAngle,EndAngle:double; var Arc1:TDArc):Integer;  - Arc tangent to line through point.
  • function ArcTan2Lines(Line1,Line2:TDLine; Radius,StartAngle,EndAngle:double; PickPoint1,PickPoint2:TDPoint; var Arc1:TDArc):Integer;  - Arc tangent to two lines with certain radius.
  • function ArcTanLineArc(Line1:TDLine;Arc1:TDArc; Radius,StartAngle,EndAngle:double; PickPoint1,PickPoint2:TDPoint; var Arc2:TDArc):Integer;  - Arc tangent to a line and an arc.
  • function ArcTan2Arcs(Arc1,Arc2:TDArc; Radius,StartAngle,EndAngle:double; PickPoint1,PickPoint2:TDPoint; var Arc3:TDArc):Integer;  - Arc tangent to two arcs.
  • function ArcTanLine2Points(Line1:TDLine; Point1,Point2:TDPoint; StartAngle,EndAngle:double; var Arc1:TDArc):Integer;  - Arc tangent to a line and passing through two points.
  • function ArcTanArcPoint(Arc1:TDArc; PickPoint,Point1:TDPoint; Radius,StartAngle,EndAngle:double; var Arc2:TDArc):Integer;  - Arc tangent to an arc passing through a point, nearest the Pick Point.
  • function ArcThrough2Points(Point1,Point2:TDPoint; Radius,StartAngle,EndAngle:double; var Arc1,Arc2:TDArc):Integer;  - Arc through 2 points with radius, always created on the right side depending on which point is first.
  • function ArcBetween2Points(Point1,Point2:TDPoint; StartAngle,EndAngle:double; var Arc1:TDArc):Integer; 
  • function ArcTan3Lines(Line1,Line2,Line3:TDLine; PickPoint:TDPoint; StartAngle,EndAngle:double; var Arc1:TDArc):Integer;
    //*********************************
  • function GetLineLength(Line1:TDLine):double;
  • function GetClosestPoint(E:TElement; PickPoint:TDPoint; var Point1:TDPoint):Integer;  - A point on the line that is closest to the pick point.
  • function GetClosestPointLine(Line1:TDLine; PickPoint:TDPoint; var Point1:TDPoint):Integer;
  • function GetClosestPointArc(Arc1:TDArc; PickPoint:TDPoint; var Point1:TDPoint):Integer;
  • function FixAngle(Angle:double):double; - Changes the angle so it is within 0-360.
  • function GetAngle(X1,Y1,X2,Y2:double):double; - Returns the angle from x1,y1 to x2,y2
  • function GetAngle2Points(Point1,Point2:TDPoint):double; - Same with points
  • function GetAngleLine(Line1:TDLine):double; - Returns angle from first endpoint to second endpoint.
  • function Distance(X1,Y1,X2,Y2:double):double; - 2D distance from x1,y1 to x2,y2.
  • function Distance2Points(Point1,Point2:TDPoint):double; - Same with points - Z is ignored.
  • function Distance3D(Point1,Point2:TDPoint):double; 3D distance.
  • function MidPoint(X1,Y1,Z1,X2,Y2,Z2:double):TDPoint; - Returns 3D Point between 2 points.
  • function MidPoint2Points(Point1,Point2:TDPoint):TDPoint; - Same with points.
  • function PointFromElement(E:TElement):TDPoint; - Returns a point extracted from element. If element is Line then returns first endpoint. If element is arc then returns center point of arc.
  • function LineFromElement(E:TElement):TDLine; - Extracts the coord array and puts it in TDLine. 
  • function ArcFromElement(E:TElement):TDArc; - Extracts the coord array and puts it in TDArc. 
  • function GetArcEndPoints(Arc1:TDArc;var Point1,Point2:TDPoint):Integer; - Returns the two endpoints of the arc. 
  • function GetArcLength(Radius,StartAngle,EndAngle:double): double; - Returns the length of an arc.
  • function GetArcAngle(StartAngle,EndAngle:double; Direction:Integer): double; - Returns the included angle. Direction is 2=clockwise; 3=counter clockwise; default is counter clockwise;
  • function MidArc(Arc1:TDArc):TDPoint; - Returns point halfway around arc.
  • function CalcErr(index:integer):string; - Returns error strings for errors 900 and above.

caddrawdelphi7.zip

caddrawkylix3.zip


Next
 

 

Ayn Rand Quotes:
Happiness is that state of consciousness which proceeds from the achievement of one's values.
  •  
The spread of evil is the symptom of a vacuum. whenever evil wins, it is only by default: by the moral failure of those who evade the fact that there can be no compromise on basic principles.
  •  
A creative man is motivated by the desire to achieve, not by the desire to beat others.
  •  
Achievement of your happiness is the only moral purpose of your life, and that happiness, not pain or mindless self-indulgence, is the proof of your moral integrity, since it is the proof and the result of your loyalty to the achievement of your values.
  •  
Contradictions do not exist. Whenever you think you are facing a contradiction, check your premises. You will find that one of them is wrong.
  •  
Force and mind are opposites; morality ends where a gun begins
  •  
Government "help" to business is just as disastrous as government persecution... the only way a government can be of service to national prosperity is by keeping its hands off.
  •  
Individual rights are not subject to a public vote; a majority has no right to vote away the rights of a minority; the political function of rights is precisely to protect minorities from oppression by majorities (and the smallest minority on earth is the individual).

 

    
    
 

Copyright ©2008 i-Logic Software. email: support@i-logic.com