home
 
 
 
Tidal Forces Graphing
{
												Tidal Forces Graphing
												© Charles Chandler
												http://qdl.scs-inc.us/?top=8311
											}
											PROCEDURE Main;
											CONST
											folder = 'Plug-ins\CLC\Geophysics\Data\Tidal Forces\';
											maxY = 200;
											minY = -120;
											xScale = 5;
											yScale = .3;
											VAR
											objName, dataFile, timeString, placeName :STRING;
											objHand, recHand, wallHand, polyHand :HANDLE;
											x, y, lastX, eventTime, minX, xVal :REAL;
											cnt, vertCnt, fileNumber :INTEGER;
											 
											PROCEDURE PlaceText(text :STRING; x, y, rot, size :REAL; just, vAlign :STRING);
											CONST
											isMirrored = false;
											VAR
											justInt, vAlignInt :INTEGER;
											BEGIN
											CreateText(text);
											SetTextOrientation(LNewObj, x, y, rot, isMirrored);
											IF (just = 'left'  ) THEN justInt := 1 ELSE
											IF (just = 'center') THEN justInt := 2 ELSE
											IF (just = 'right' ) THEN justInt := 3;
											SetTextJust(LNewObj, justInt);
											IF (vAlign = 'top'    ) THEN vAlignInt := 1 ELSE
											IF (vAlign = 'textTop') THEN vAlignInt := 2 ELSE
											IF (vAlign = 'center' ) THEN vAlignInt := 3 ELSE
											IF (vAlign = 'textBot') THEN vAlignInt := 4 ELSE
											IF (vAlign = 'bot'    ) THEN vAlignInt := 5;
											SetTextVerticalAlign(LNewObj, vAlignInt);
											SetTextSize(LNewObj, 0, Len(text), size);
											END;
											 
											BEGIN
											IF GetCustomObjectInfo(objName, objHand, recHand, wallHand) THEN BEGIN
											SetObjectVariableBoolean(objHand, 800, TRUE);
											fileNumber := pFile;
											IF pPlus THEN BEGIN
											fileNumber := fileNumber + 1;
											SetRField(objHand, objName, 'Plus', 'False');
											END;
											IF pMinus THEN BEGIN
											fileNumber := fileNumber - 1;
											SetRField(objHand, objName, 'Minus', 'False');
											END;
											IF (fileNumber < 1) THEN fileNumber := 54;
											IF (fileNumber > 54) THEN fileNumber := 1;
											lastX := 0;
											minX := 999;
											dataFile := Concat(folder, fileNumber, '.txt');
											 
											Open(dataFile);
											ReadLn(timeString);
											ReadLn(placeName);
											ReadLn(eventTime);
											OpenPoly;
											BeginPoly;
											WHILE NOT EOF(dataFile) DO BEGIN
											ReadLn(x, y);
											IF (x < lastX) THEN x := x + 24;
											IF (x < minX) THEN minX := x;
											AddPoint(x * xScale, y * yScale);
											lastX := x;
											END;
											EndPoly;
											polyHand := LNewObj;
											Close(dataFile);
											 
											vertCnt := GetVertNum(polyHand);
											FOR cnt := 1 TO vertCnt DO BEGIN
											GetPolyPt(polyHand, cnt, x, y);
											xVal := x / 5;
											IF (Trunc(xVal) = xVal) THEN BEGIN
											IF (Trunc(xVal) MOD 2 = 0) THEN BEGIN
											MoveTo(x, minY * yScale);
											LineTo(x, (minY * yScale) - 2);
											IF (xVal > 23) THEN xVal := xVal - 24;
											PlaceText(Concat(xVal), x, (minY * yScale) - 3, 0, 12, 'center', 'top');
											END ELSE BEGIN
											MoveTo(x, minY * yScale);
											LineTo(x, (minY * yScale) - 1);
											END;
											END;
											END;
											PlaceText('Hour (UTC)', ((minX + lastX) / 2) * xScale, (minY * yScale) - 11, 0, 12, 'center', 'top');
											 
											FOR cnt := minY TO maxY DO BEGIN
											IF (cnt MOD 20 = 0) THEN BEGIN
											MoveTo(minX * xScale, cnt * yScale);
											LineTo((minX * xScale) - 2, cnt * yScale);
											PlaceText(Concat(cnt), (minX * xScale) - 4, cnt * yScale, 0, 12, 'right', 'center');
											END ELSE IF (cnt MOD 10 = 0) THEN BEGIN
											MoveTo(minX * xScale, cnt * yScale);
											LineTo((minX * xScale) - 1, cnt * yScale);
											END;
											END;
											PlaceText('Microgals', (minX * xScale) - 19, ((minY + maxY) / 2) * yScale, 90, 12, 'center', 'bottom');
											 
											Rect(minX * xScale, minY * yScale, (minX + 24) * xScale, maxY * yScale);
											SetFPat(LNewObj, 0);
											 
											IF (eventTime < minX) THEN eventTime := eventTime + 24;
											MoveTo(eventTime * xScale, minY * yScale);
											LineTo(eventTime * xScale, maxY * yScale);
											SetLS(LNewObj, -5);
											 
											PlaceText(placeName, eventTime * xScale, (maxY * yScale) + 8, 0, 12, 'center', 'top');
											PlaceText(timeString, eventTime * xScale, (maxY * yScale) + 14, 0, 12, 'center', 'top');
											 
											SetRField(objHand, objName, 'File', Concat(fileNumber));
											IF (False) THEN BEGIN
											Rect((minX * xScale) - 21, (minY * yScale) - 19, ((minX + 24) * xScale) + 6, (maxY * yScale) + 16);
											SetFPat(LNewObj, 0);
											END ELSE BEGIN
											Locus((minX * xScale) - 21, (minY * yScale) - 19); Locus(((minX + 24) * xScale) + 6, (maxY * yScale) + 16);
											END;
											END;
											END;
											Run(Main);
										 

Powered by Quick Disclosure Lite
© 2010~2021 SCS-INC.US