home *** CD-ROM | disk | FTP | other *** search
- PRODUCT : TURBO GRAPHIX TOOLBOX NUMBER : 202
- VERSION : 1.03A
- OS : PC-DOS
- DATE : March 10, 1986
-
- TITLE : UPDATE FROM VERSION 1.03A TO VERSION 1.05A
-
- This packet contains update information regarding the following
- topics for the Turbo Graphix Toolbox.
-
-
- 1) AXIS DRAWING MODULE AXIS.HGH PAGE 3
-
- 2) POLYGON DRAWING MODULE POLYGON.HGH PAGE 9
-
- 3) BAR CHART MODULE HISTOGRM.HGH PAGE 13
-
- This patch will update version 1.03A of the Turbo Graphix Toolbox
- to version 1.05A. The Turbo Graphix ToolBox is provided in
- source code form, so you can make these changes directly to the
- source code. The reason these changes must be made is that the
- calls to SelectWindow from procedures DrawAxis, DrawPolygon, and
- DrawHistogram set the variables X1Glb, Y1Glb, X2Glb, and Y2Glb to
- zero. These are the global descriptors for the axis margins in
- the current window, but they are destroyed upon leaving procedure
- DrawAxis. The changes described in the following pages modify the
- procedures AXIS.HGH, POLYGON.HGH, and HISTOGRM.HGH so that the
- axis margins maintain the correct values. After the modifications
- have been made, a typical calling sequence for plotting several
- curves on a common axis frame would be:
-
-
- DrawAxis(...); { Define the axis frame. }
- DrawPolygon(...); { Plot first curve. }
- ResetAxis; { Set AxisGlb to true. }
- DrawPolygon(...); { Plot second curve. }
- ResetAxis; { Set AxisGlb to true. }
- DrawHistogram(...); { Plot third curve. }
-
-
- If you make the changes described, you should change the header
- of all the modules that end in .HGH to read:
-
- "TURBO GRAPHIX version 1.05A"
-
- You should change the module version number in AXIS.HGH,
- POLYGON.HGH,and HISTOGRM.HGH to read:
-
- "Module version 1.05A"
-
- Note: You should also delete the variable declaration:
-
- Font : IBMFont;
-
- from the file DUMMY.INC .
- AXIS.HGH
- (***********************************************************)
- (* TURBO GRAPHIX version 1.03A *)
- (* *)
- (* Axis drawing module *)
- (* Module version 1.03A *)
- (* *)
- (* Copyright (C) 1985 by *)
- (* BORLAND International *)
- (***********************************************************)
- ****************** ( CHANGE 1.03A TO 1.05A ) ******************
-
- procedure DrawAxis(XDens,YDens,XLeft,YTop,XRight,YBottom,XAxis,
- YAxis:integer;
- Arrows:boolean);
- x2,y2,MaxExponentX,MaxExponentY,i,ys,xs,Delta,NPoints:integer;
- Difference,Number,s,Fract:real;
- X1RefLoc,X2RefLoc,Y1RefLoc,Y2RefLoc,X1RefLoc2,X2RefLoc2,
- Y1RefLoc2,Y2RefLoc2:integer;
- ClippingLoc,DirectModeLoc,HeaderLoc:boolean;
-
- function StringNumber(X1:real;
- MaxExponent:integer):wrkstring;
- var y:wrkstring;
- begin
- str(X1*exp(-MaxExponent*ln(10.0)):5:2,y);
- StringNumber:=y;
- end;
-
- function GetExponent(X1:real):integer;
- begin
- GetExponent:=0;
- if X1<>0.0 then
- if abs(X1)>=1.0 then
- GetExponent:=trunc(ln(abs(X1))/ln(10.0))
- else GetExponent:=-trunc(abs(ln(abs(X1)))/ln(10.0)+1.0);
- end;
-
- procedure DrawNum(x1,y1,MaxExponent:integer;
- Number:real);
- var i:integer;
- StrNumber:wrkstring;
- begin
- StrNumber:=StringNumber(Number,MaxExponent);
- y1:=y1-3;
- for i:=1 to 5 do DrawAscii(x1,y1,1,ord(StrNumber[i]));
- end;
- (AXIS.HGH cont.)
- function Balance:integer;
- begin
- Balance:=0;
- s:=s+Fract;
- if s>=0 then
- begin
- s:=s-1.0;
- Balance:=1;
- end;
- end;
-
- procedure DrawExponent(x1,y1,MaxExponent:integer);
- var i:integer;
- StrNumber:wrkstring;
- begin
- y1:=y1-3;
- x1:=x1+1;
- DrawAscii(x1,y1,1,49);
- DrawAscii(x1,y1,1,48);
- str(MaxExponent:3,StrNumber);
- y1:=y1-3;
- x1:=x1-7;
- for i:=1 to 3 do DrawAscii(x1,y1,1,ord(StrNumber[i]));
- end;
-
- begin { DrawAxis }
- LineStyleLoc:=LinestyleGlb;
- SetLineStyle(0);
-
- AxisGlb:=true; <----------{***** DELETE THIS LINE. *****}
-
- DirectModeLoc:=DirectModeGlb;
- DirectModeGlb:=true;
- with window[WindowNdxGlb] do
- begin
- X1RefLoc:=x1;
- X2RefLoc:=x2;
- Y1RefLoc:=y1;
- Y2RefLoc:=y2;
-
- <---|
- X1Glb:=XLeft; |
- X2Glb:=XRight; |--------{***** DELETE THIS BLOCK. *****}
- Y1Glb:=YTop; |
- Y2Glb:=YBottom; |
- <---|
-
- (AXIS.HGH cont.)
-
- {**** CHANGE THE FOLLOWING CALL TO ReDefineWindow TO READ :
- ****}
- {
- ReDefineWindow(WindowNdxGlb,x1+XLeft,y1+YTop,x2-XRight,y2-YBottom);
- }
-
- ReDefineWindow(WindowNdxGlb,x1+X1Glb,y1+Y1Glb,x2-X2Glb,y2-Y2Glb);
-
- SelectWindow(WindowNdxGlb);
- end;
- if (XDens<0) xor (YDens<0) then
- begin
- HeaderLoc:=HeaderGlb;
- HeaderGlb:=False;
- DrawBorder;
- HeaderGlb:=HeaderLoc;
- end;
- XDens:=abs(XDens);
- YDens:=abs(YDens);
- if XDens>9 then XDens:=0;
- if YDens>9 then YDens:=0;
- xk0:=(X1RefGlb+4) shl 3;
- yk0:=Y2RefGlb-14;
- yk1:=Y1RefGlb+6;
- xk1:=xk0;
- yk2:=yk0;
- xk2:=(X2RefGlb-2) shl 3+7;
- if (XAxis>=0) or (YAxis>=0) then
- begin
- ClippingLoc:=ClippingGlb;
- ClippingGlb:=true;
- with window[WindowNdxGlb] do
- begin
- X1RefLoc2:=x1;
- X2RefLoc2:=x2;
- Y1RefLoc2:=y1;
- Y2RefLoc2:=y2;
- end;
- ReDefineWindow(WindowNdxGlb,X1RefLoc2+4,Y1RefLoc2+6,
- X2RefLoc2-2,Y2RefLoc2-14);
- SelectWindow(WindowNdxGlb);
- DirectModeGlb:=false;
-
- (AXIS.HGH cont.)
- if (XAxis>=0) then
- begin
- SetLineStyle(XAxis);
- DrawLine(X1WldGlb,Y1WldGlb+Y2WldGlb,X2WldGlb,
- Y1WldGlb+Y2WldGlb);
- SetLineStyle(0);
- end;
- if (YAxis>=0) then
- begin
- SetLinestyle(YAxis);
- DrawLine(0,Y1WldGlb,0,Y2WldGlb);
- SetLineStyle(0);
- end;
- ClippingGlb:=ClippingLoc;
- DirectModeGlb:=true;
- ReDefineWindow(WindowNdxGlb,X1RefLoc2,Y1RefLoc2,
- X2RefLoc2,Y2RefLoc2);
- SelectWindow(WindowNdxGlb);
- end;
- if YDens>=2 then
- begin
- DrawLine(xk0,yk0,xk1,yk1);
- if Arrows then
- begin
- DrawLine(xk0,yk1,xk0-4,yk1+4);
- DrawLine(xk0,yk1,xk0+4,yk1+4);
- dp(xk0,yk1-1);
- end;
- end;
- if XDens>=2 then
- begin
- DrawLine(xk0,yk0,xk2+1,yk2);
- if Arrows then
- begin
- DrawLine(xk2,yk2,xk2-4,yk2-4);
- DrawLine(xk2,yk2,xk2-4,yk2+4);
- end;
- end;
- if (abs(yk0-yk1)>=35) and (abs(xk2-xk1)>=150) then
- begin
- DrawLine(xk0,yk0,xk0-4,yk0);
- DrawLine(xk0,yk0,xk0,yk0+4);
- Delta:=Y2RefGlb-Y1RefGlb-20;
- NPoints:=Delta div 7;
- NDiff:=Delta-(NPoints shl 3)+NPoints;
- if YDens>=4 then
-
- begin
- if abs(Y2WldGlb)>abs(Y1WldGlb)
- then MaxExponentY:=GetExponent(Y2WldGlb)
- else MaxExponentY:=GetExponent(Y1WldGlb);
- DrawNum(X1RefGlb shl 3,yk0+1,MaxExponentY,Y1WldGlb);
- if MaxExponentY<>0
- then DrawExponent(X1RefGlb shl 3+1,yk1+2,MaxExponentY);
- end;
- Fract:=NDiff/NPoints;
- s:=-Fract;
- ys:=yk0;
- Difference:=(Y2WldGlb-Y1WldGlb)/NPoints;
- for i:=1 to NPoints do
- begin
- ys:=ys-7-Balance;
- if (YDens>2) and (ys>Y1RefGlb+13) then
- begin
- Number:=Y1WldGlb+i*Difference;
- DrawLine(xk0,ys,xk0-4,ys);
- if YDens>=4 then if i mod (10-YDens)=0 then
- DrawNum(X1RefGlb shl 3,ys+1,MaxExponentY,Number);
- end;
- end;
- if XDens>=4 then
- begin
- if abs(X2WldGlb)>abs(X1WldGlb)
- then MaxExponentX:=GetExponent(X2WldGlb)
- else MaxExponentX:=GetExponent(X1WldGlb);
- DrawNum(xk0-14,yk0+10,MaxExponentX,X1WldGlb);
- if MaxExponentX<>0
- then DrawExponent(xk2-13,yk0+10,MaxExponentX);
- end;
- Delta:=abs(X2RefGlb-X1RefGlb) shl 3-41;
- NPoints:=Delta div 30;
- NDiff:Delta-(NPoints shl 5)+(NPoints shl 1);
- Fract:=NDiff/NPoints;
- s:=-Fract;
- xs:=xko-1;
- Difference:=(X2WldGlb-X1WldGlb)/NPoints;
- for i:=1 to NPoints do
-
-
- (AXIS.HGH cont.)
- begin
- xs:=xs+30+Balance:
- if (XDens>2) and (xs<X2RefGlb shl 3+7-24) then
- begin
- Number:=X1WldGlb+i*Difference;
- DrawLine(xs,yk0,xs,yk0+4);
- if XDens>=4 then if i mod (10-XDens)=0 then
- DrawNum(xs-14,yk0+10,MaxExponentX,Number);
- end;
- end;
- end;
- ReDefineWindow(WindowNdxGlb,X1RefLoc,Y1RefLoc,
- X2RefLoc,Y2RefLoc);
- SelectWindow(WindowNdxGlb);
- DirectModeGlb:=DirectModeLoc;
- SetLineStyle(LineStyleLoc);
-
- |---{ ***** INSERT THE FOLLOWING BLOCK. *****}
- <------------|
- | AxisGlb := true;
- | X1Glb := XLeft;
- | X2Glb := XRight;
- | Y1Glb := YTop;
- | Y2Glb := YBottom;
- |
- |---{ ***************************************}
- end;
-
- {***** APPEND THE FOLLOWING PROCEDURE TO AXIS.HGH *****}
-
- procedure ResetAxis;
- begin
- AxisGlb := true;
- end;
-
- POLYGON.HGH
- (***********************************************************)
- (* *)
- (* TURBO GRAPHIX version 1.03A *)
- (* *)
- (* Polygon drawing module *)
- (* Module version 1.03A *)
- (* *)
- (* Copyright (C) 1985 by *)
- (* BORLAND International *)
- (***********************************************************)
- ********************( CHANGE 1.03A TO 1.05A )********************
-
- procedure DrawPolygon(A:PlotArray;
- I0,NPoints,Line,Scale,Lines:integer);
- var i,x1,x2,y1,y2,XOffset,YOffset:integer;
- X1RefLoc,Y1RefLoc,X2RefLoc,Y2RefLoc:integer;
- DeltaY,XOs1,XOs2,YOs1,YOs2:integer;
- AutoClip,DirectModeLoc,PlotLine,PlotSymbol:boolean;
-
- X1Loc,Y1Loc,X2Loc,Y2Loc:integer; <--{*** INSERT THIS LINE.
- ***}
-
- procedure DrawPointClipped(x,y:integer);
- begin
- if (x1>X1RefGlb shl 3) and (x2<X2RefGlb shl 3+7) then
- if (y1>Y1RefGlb) and (y2<Y2RefGlb) then dp(x,y);
- end;
-
- procedure DrawItem(X,Y:integer);
- var LineStyleLoc:integer;
-
- begin
- LineStyleLoc:=LineStyleGlb;
- SetLineStyle(0);
- case Line of
- 2: DrawCrossDiag(X,Y,Scale);
- 3,4:
- DrawSquareC(X-Scale,Y+Scale,X+Scale,Y-Scale,(Line=4));
- 5: DrawDiamond(X,Y,Scale+1);
- 6: DrawWye(X,Y,Scale+1);
- 1: DrawCross(X,Y,Scale);
- 8: DrawCircleDirect(X,Y,Scale+1,False);
- 9: begin
- PlotLine:=false;
- if AutoClip then DrawPointClipped(X,Y)
- else dp(X,Y);
- end;
-
- (POLYGON.HGH cont.)
-
- 7: DrawStar(X,Y,Scale);
- end;
- SetLineStyle(LineStyleLoc);
- end;
-
- begin
- if abs(NPoints-I0)>=2 then
-
- begin
- <-------------|{***** INSERT THE FOLLOWING BLOCK. *****}
- |
- | X1Loc := X1Glb;
- | Y1Loc := Y1Glb;
- | X2Loc := X2Glb;
- | Y2Loc := Y2Glb;
- |
- |{***************************************}
- DirectModeLoc:=DirectModeGlb;
- DirectModeGlb:=true;
- AutoClip:=(NPoints<0);
- NPoints:=abs(NPoints);
- XOs1:=1;
- XOs2:=1;
- YOs1:=6;
- YOs2:=6;
- if AxisGlb then
- begin
- XOs1:=4;
- XOs2:=2;
- YOs1:=6;
- YOs2:=14;
- if (((X2RefGlb+7-XOs2-X1RefGlb+XOs1) > (XOs1+XOs2) shl 1)
- and
- (Y2RefGlb-YOs2-Y1RefGlb+YOs1 > (YOs1+YOs2) shl 1))
- then
- begin
- X1RefLoc:=X1RefGlb;
- x1:=X1RefGlb+XOs1+X1Glb;
- Y1RefLoc:=Y1RefGlb;
- y1:=Y1RefGlb+YOs1+Y1Glb;
- X2RefLoc:=X2RefGlb;
- x2:=X2RefGlb-XOs2-X2Glb;
- Y2RefLoc:=Y2RefGlb;
- y2:=Y2RefGlb-YOs2-Y2Glb;
- ReDefineWindow(WindowNdxGlb,x1,y1,x2,y2);
- SelectWindow(WindowNdxGlb);
-
- (POLYGON.HGH cont.)
-
- <-----------------|{***** INSERT THE FOLLOWING LINE.
- *****}
- |
- | AxisGlb := true;
- |
- |{**************************************}
- end;
- end;
-
- PlotLine:=(Line>=0);
- PlotSymbol:=(Line<>0);
- Line:=abs(Line);
- Scale:=abs(Scale);
- if Lines<0 then
- DeltaY:=trunc(1.0/(abs(Y1WldGlb)+abs(Y2WldGlb)) *
- abs(Y1WldGlb) *
- abs(Y2RefGlb-Y1RefGlb))+1
- else DeltaY:=0;
- if (NPoints<2) and MessageGlb then
- writeln('<DrawPolygon>: too few data pairs -> (NPoints) >=
- 2')
- else
- begin
- x1:=WindowX(A[I0,1]);
- y1:=Y2RefGlb+Y1RefGlb-WindowY(A[I0,2]);
- DrawItem(x1,y1);
- if Abs(Lines)=1 then
- if AutoClip then DrawLineClipped(x1,Y2RefGlb-DeltaY,x1,y1)
- else DrawLine(x1,Y2RefGlb-DeltaY,x1,y1);
- for i:=I0+1 to NPoints do
- begin
- x2:=WindowX(A[i,1]);
- y2:=Y2RefGlb+Y1RefGlb-WindowY(A[i,2]);
- DrawItem(x2,y2);
- if Abs(Lines)=1 then
- if AutoClip then
- DrawLineClipped(x2,Y2RefGlb-DeltaY,x2,y2)
- else DrawLine(x2,Y2RefGlb-DeltaY,x2,y2);
- if PlotLine then
- if AutoClip then DrawLineClipped(x1,y1,x2,y2)
- else DrawLine(x1,y1,x2,y2);
- x1:=x2;
- y1:=y2;
- end;
- end;
- if AxisGlb then
- begin
- ReDefineWindow(WindowNdxGlb,X1RefLoc,Y1RefLoc,X2RefLoc,Y2RefLoc);
- SelectWindow(WindowNdxGlb);
- <------------------|{***** INSERT THE FOLLOWING BLOCK.
- *****}
- |
- | X1Glb := X1Loc;
- | Y1Glb := Y1Loc;
- | X2Glb := X2Loc;
- | Y2Glb := Y2Loc;
- |
- |{***************************************}
-
- AxisGlb:=false;
- end;
- DirectModeGlb:=DirectModeLoc;
- end
- else error(18,4);
- end;
-
-
- HISTOGRM.HGH
- (***********************************************************)
- (* *)
- (* TURBO GRAPHIX version 1.03A *)
- (* *)
- (* Bar chart module *)
- (* Module version 1.03A *)
- (* *)
- (* Copyright (C) 1985 by: *)
- (* BORLAND International *)
- (* *)
- (***********************************************************)
- *******************( CHANGE 1.03A TO 1.05A )
- *********************
-
- procedure DrawHistogram(A:PlotArray;
- NPoints:integer;
- Hatching:boolean;
- HatchStyle:integer);
-
- var x1,x2,y2,NPixels,Delta,NDiff,YRef:integer;
- LineStyleLoc,i:integer;
- Fract,s,y,YAxis:real;
- DirectModeLoc,Negative:boolean;
- wtemp:WindowType;
- <------------------|{***** INSERT THE FOLLOWING LINE.
- *****}
- |
- | X1Loc,Y1Loc,X2Loc,Y2Loc:integer;
- |
- |{**************************************}
- function Balance:integer;
- begin
- Balance:=0;
- s:=s+Fract;
- if s>=0.0 then
- begin
- s:=s-1.0;
- Balance:=1;
- end;
- end;
-
- begin { DrawHistogram }
- if abs(NPoints)>=2 then
- begin
-
- (HISTOGRM.HGH cont.)
-
- <--------------------|{***** INSERT THE FOLLOWING BLOCK.
- *****}
- |
- | X1Loc := X1Glb;
- | Y1Loc := Y1Glb;
- | X2Loc := X2Glb;
- | Y2Loc := Y2Glb;
- |
- |{***************************************}
- LineStyleLoc:=LinestyleGlb;
- SetLineStyle(0);
- if AxisGlb then
- begin
- wtemp:=window[WindowNdxGlb];
- ReDefineWindow(WindowNdxGlb,X1RefGlb+4+X1Glb,
- Y1RefGlb+6+Y1Glb,
- X2RefGlb-2-X2Glb,Y2RefGlb-14-Y2Glb);
- SelectWindow(WindowNdxGlb);
-
- <----------------|{***** INSERT THE FOLLOWING LINE.
- *****}
- |
- | AxisGlb := true;
- |
- |{**************************************}
- end;
- DirectModeLoc:=DirectModeGlb;
- DirectModeGlb:=true;
- Negative:=NPoints<0;
- NPoints:=abs(NPoints);
- NPixels:=(X2RefGlb-X1RefGlb) shl 3+7;
- Delta:=NPixels div NPoints;
- NDiff:=NPixels-Delta*NPoints;
- Fract:=NDiff/NPoints;
- s:=-Fract;
- x1:=X1RefGlb shl 3;
- YRef:=trunc(Y2RefGlb+Y1RefGlb-AyGlb);
- if Negative then DrawStraight(x1,X2RefGlb shl 3+7,YRef);
- YAxis:=Y1RefGlb;
- if BYGlb>0 then YAxis:=Y2RefGlb;
-
- (HISTOGRM.HGH cont.)
-
- for i:=1 to NPoints do
- begin
- x2:=x1+Delta+Balance;
- y:=A[i,2];
- if not Negative then y:=abs(y);
- if AxisGlb then y2:=trunc(AyGlb+ByGlb*y)
- else y2:=trunc((AyGlb+ByGlb*y)*0.99);
- y2:=Y2RefGlb+Y1RefGlb-y2;
- if not Negative then
- begin
- DrawLine(x1,YAxis,x1,y2);
- DrawStraight(x1,x2,y2);
- DrawLine(x2,y2,x2,YAxis);
- if Hatching then
- if odd(i) then hatch(x1,y2,x2,YAxis,HatchStyle)
- else hatch(x1,y2,x2,YAxis,-HatchStyle);
- end
- else
- begin
- DrawLine(x1,YRef,x1,y2);
- DrawStraight(x1,x2,y2);
- DrawLine(x2,y2,x2,YRef);
- if Hatching then
- if YRef-y2<0 then
- if odd(i) then hatch(x1,YRef,x2,y2,HatchStyle)
- else hatch(x1,YRef,x2,y2,-HatchStyle)
- else if odd(i) then hatch(x1,y2,x2,YRef,HatchStyle)
- else hatch(x1,y2,x2,YRef,-HatchStyle);
- end;
- x1:=x2;
- end;
- if AxisGlb then
- begin
- window[WindowNdxGlb]:=wtemp;
- SelectWindow(WindowNdxGlb);
-
- (HISTOGRM.HGH cont.)
-
- <-------------|{***** INSERT THE FOLLOWING BLOCK. *****}
- |
- | X1Glb := X1Loc;
- | Y1Glb := Y1Loc;
- | X2Glb := X2Loc;
- | Y2Glb := Y2Loc;
- |
- |{***************************************}
-
- AxisGlb:=false;
- end;
- DirectModeGlb:=DirectModeLoc;
- SetLineStyle(LineStyleLoc);
- end
- else error(19,4);
- end;
-
-