unit Globals;

{Global declarations for Image program.}

interface

	uses
		QuickDraw, PrintTraps;

	const
		Version = 128;

		AppleMenu = 128;

		FileMenu = 129;
		NewItem = 1;
		OpenItem = 2;
		ImportItem = 3;
		CloseItem = 4;
		SaveItem = 6;
		SaveAsItem = 7;
		RecordPreferencesItem = 8;
		RevertItem = 10;
		DuplicateItem = 11;
		GetInfoItem = 12;
		SetHalftoneItem = 14;
		PageSetupItem = 15;
		PrintItem = 16;
		QuitItem = 18;

		EditMenu = 130;
		UndoItem = 1;
		CutItem = 3;
		CopyItem = 4;
		PasteItem = 5;
		ClearItem = 6;
		FillItem = 8;
		InvertItem = 9;
		DrawBoundaryItem = 10;
		SelectAllItem = 12;
		ScaleSelectionItem = 13;
		RotateLeftItem = 15;
		RotateRightItem = 16;
		FlipVerticalItem = 17;
		FlipHorizontalItem = 18;
		RotateAndScaleItem = 19;
		UnzoomItem = 21;
		ShowClipboardItem = 22;

		OptionsMenu = 131;
		InvertPaletteItem = 1;
		SetNumberItem = 2;
		SetExtraColorsItem = 3;
		GrayscaleItem = 5;
		PseudoColorItem = 6;
		AppleColorsItem = 7;
		RainbowItem = 8;
		PreferencesItem = 10;
		PlotOptionsItem = 11;
		ScaleToFitItem = 12;
		ThresholdItem = 13;
		ShowPasteControlItem = 14;
		PropagateItem = 15;

		EnhanceMenu = 132;
		SmoothItem = 1;
		SharpenItem = 2;
		EdgeDetectItem = 3;
		ReduceNoiseItem = 4;
		DitherItem = 5;
		ConvolveItem = 6;
		BinaryItem = 8;
		ArithmeticItem = 9;
		ApplyItem = 10;
		EnhanceItem = 11;
		EqualizeItem = 12;
		ChangeItem = 13;

		BinaryMenu = 35; {Sub Menu}
		MakeBinaryItem = 1;
		ErosionItem = 3;
		DilationItem = 4;
		OpeningItem = 5;
		ClosingItem = 6;
		IterationsItem = 7;
		OutlineItem = 9;
		SkeletonizeItem = 10;

		ArithmeticMenu = 37; {Sub Menu}
		AddItem = 1;
		SubtractItem = 2;
		MultiplyItem = 3;
		DivideItem = 4;

		AnalyzeMenu = 133;
		MeasureItem = 1;
		AnalyzeItem = 2;
		ShowItem = 3;
		HistogramItem = 4;
		PlotItem = 5;
		Plot3DItem = 6;
		OptionsItem = 7;
		SetScaleItem = 9;
		CalibrateItem = 10;
		RedoItem = 11;
		DeleteItem = 12;
		ResetItem = 13;
		RestoreItem = 14;
		MarkItem = 15;

{$IFC Arlo }
  FFTMenu = 150;
  FFTItem = 1;
  InverseFFTItem = 2;
  AutoItem = 3;
  FFTSettingsItem = 4;
  DyadicOpsItem = 5;
  FilterItem = 7;
  PassItem = 8;
  ThresholdZeroItem = 9;
  MaskItem = 10;
  MaskNfilterSettingsItem = 11;
  UpdatePSItem = 13;
  BlockSwapItem = 14;

  PSScalingMenu = 151;
  LogItem = 1;
  NthRootItem = 2;
  LinearItem = 3;

  NthRootMenu = 152;

  AutoMenu = 153;
  AutoFilterItem = 1;
  AutoPassItem = 2;
  AutoThreshZeroItem = 3;
  AutoMaskItem = 5;
{$ENDC }

		TextMenu = 134;
		LeftItem = 5;
		CenterItem = 6;
		RightItem = 7;
		NoBackgroundItem = 9;
		WithBackgroundItem = 10;

		FontMenu = 32; {Sub Menus}
		SizeMenu = 33;
		StyleMenu = 34;

		WindowsMenu = 138;
		NextWindowItem = 1;
		StackWindowsItem = 2;
		TileWindowsItem = 3;
		SelectToolsItem = 5;
		SelectGrayMapItem = 6;
		SelectLutItem = 7;
		SelectResultsItem = 8;
		SelectHistogramItem = 9;
		SelectPlotItem = 10;

		UserMenu = 139;

		VideoMenu = 140;
		StartItem = 1;
		AverageItem = 2;
		SaveBlankFieldItem = 3;
		SetVideoItem = 4;
		MakeMovieItem = 6;
		AnimateItem = 7;
		PhotoModeItem = 9;
		SortItem = 10;

		SortPaletteMenu = 36; {Sub Menu}
		byHueItem = 1;
		bySaturationItem = 2;
		byBrightnessItem = 3;


		HeaderSize = 512;
		TiffDirSize = 256;
		MaxPixelsPerLine = 2048;
		tleft = 36;
		ttop = 40;
		twidth = 44;
		tmiddle = 22;
		theight = 277;
		gmleft = 2;
		gmtop = 338;
		gmwidth = 78;
		gmheight = 118;
		gmRectLeft = 7;
		gmRectTop = 6;
		gmRectRight = 71;
		gmRectBottom = 70;
		gmSlideWidth = 68;
		gmSlideHeight = 7;
		gmSlide1Offset = 8;
		gmSlide2Offset = 19;
		gmIconWidth = 17;
		gmIconHeight = 14;
		gmIconOffset = 31;
		gmIcon1Left = 17;
		gmIcon2Left = 46;
		cleft = 2;
		ctop = 40;
		cwidth = 30;
		rwidth = 200;
		rheight = 225;
		hleft = 220;
		hwidth = 256;
		hheight = 120;
		MaxPseudoColors = 32;
		MaxPseudoColorsLessOne = 31;
{$IFC Arlo }
  FFTKind = 87;
{$ENDC }
PicKind = 88;
		HistoKind = 89;
		ProfilePlotKind = 90;
		LUTKind = 91;
		GrayMapKind = 92;
		ToolKind = 93;
		ResultsKind = 94;
		CalibrationPlotKind = 95;
		PasteControlKind = 96;
		IOErrorID = 400;
		MessageID = 300;
		AboutID = 256;
		VersItem = 2;
		MemItem = 3;
		StackSize = 40000;
		ToolFont = 249;      {Bits 7-14 of font resource ID(31884) }
		WindowsMenuItems = 11;       {Items in Windows menu before images}
		ho = 2;
		vo = 4;
		WhiteIndex = 0;
		BlackIndex = 255;
		OvalSize = 15;
		LinesLeft = 13;
		LinesRight = 40;
		nLinetypes = 6;
		CheckMarkChar = 65;
		TxPlain = 1;
		TxBold = 2;
		TxItalic = 3;
		TxUnderLine = 4;
		TxOutLine = 5;
		TxShadow = 6;
		FileID8 = 'IPICIMAG';
		DefaultBufferSize = 307200; {Enough for 640x480 image}
		PickerCursorID = 111;
		LUTCursorID = 112;
		gmCursorID = 113;
		GrabberCursorID = 114;
		PencilCursorID = 115;
		CrossCursorID = 117;
		CrossCursorPlusID = 118;
		CrossCursorMinusID = 119;
		BucketCursorID = 120;
		GlassCursorPlusID = 121;
		GlassCursorMinusID = 122;
		WandCursorID = 123;
		AppleDefaultCLUT = 8;
		SpectrumCLUT = 200;
		KlutzID = 200;
		PixelPaintID = 999; {Used for PixelPaint and Canvas CLUTs}
		GhostWindow = $A84;
		GrayRgnGlobal = $9EE;
		MBarHeight = $BAA;
		MaxPics = 250;
		NoColor = -1;
		FirstExtraColorsEntry = 1;
		MaxExtraColors = 6;
		MaxExtraPlus2 = 8;
		ExtraColorsHeight = 10;
		MyMaxLong = 2000000000;
		MaxTextBufSize = 30000;
		MaxLengths = 100;
		MaxPoints = 200;
		MaxRegions = 250;
		MaxStandards = 20;
		BadReal = 999999.999;
		NoValue = -999999.999;
		TabSpacing = 12;
		MaxPolyVertices = 4000;
		pi = 3.14159265;
		ValuesVStart = 11;
		ValuesHStart = 4;
    {TIFF Constants}
		short = 3;
		long = 4;
		SubFileType = 255;
		ImageWidth = 256;
		ImageLength = 257;
		BitsPerSample = 258;
		Compression = 259;
		PhotoInterp = 262;
		StripOffsets = 273;
		RowsPerStrip = 278;
		XResolution = 282;
		YResolution = 283;
		ResolutionUnit = 296;
		ImageHdrTag = -22222; {43314}
		TiffFillerSize = 80;
		RoiHandleSize = 5;
		CancelResetID = 3;
		npcItems = 8;
		blend = 32;
		LeftArrow = 28;
		RightArrow = 29;
		UpArrow = 30;
		DownArrow = 31;
		hPicOffset = 8;
		vPicOffset = 16;
		transparent = 36;
		qcRowBytes = 1024;


	type
		BitMapHandle = ^BitMapPtr;
		BitMapPtr = ^BitMap;
		UnsignedByte = 0..255;
		LineType = packed array[0..MaxPixelsPerLine] of UnsignedByte;
		ClutTable = packed array[0..255] of integer;
		ColorArray = packed array[0..MaxPseudoColorsLessOne] of byte;
		ColorArrayX = packed array[0..MaxPseudoColorsLessOne] of integer;
		PicType = (pdp11, NewPicture, normal, PictFile, Leftover, imported, QuickCaptureType, NullPicture, BlankField, TiffFile, InvertedTIFF, FourBitTIFF, ScionType);
		LUTModeType = (PseudoColor32, AppleDefault, Spectrum, GrayScale, Custom, CustomGrayscale);
		ExtraColorsArray = array[1..MaxExtraColors] of rgbColor;
		MyCSpecArray = array[0..255] of ColorSpec;
		CoefficientArray = array[1..6] of double;
		CurveFitType = (StraightLine, Poly2, Poly3, Poly4, Poly5, ExpoFit, PowerFit, LogFit);
		UnitsType = (Nanometers, Micrometers, Millimeters, Centimeters, Meters, Kilometers, Inches, Feet, Miles, Pixels);
		FileDepthType = (EightBits, SixteenBitsUnsigned, SixteenBitsSigned);
		PicHeader = record
				FileID: packed array[1..8] of char; {8  8}
				hnlines: integer;                    {2  10}
				hPixelsPerLine: integer;        {2  12}
				hversion: integer;                   {2  14}
				hLutMode: LutModeType;          {2  16}
				hnColors: integer;                   {2  18}
				hr, hg, hb: ColorArray;              {96 114}
				hColorStart: integer;                {2  116}
				hColorWidth: integer;                {2  118}
				hExtraColors: ExtraColorsArray;   {36 154}
				hnExtraColors: integer;              {2  156}
				hForegroundIndex: integer;     {2  158}
				hBackgroundIndex: integer;      {2  160}
				hRawSpatialScale: double;        {8  168}
				Unused2: integer;                    {2  170}
				Unused3: integer;                    {2  172}
				hUnitsID: integer;                   {2  174}
				hp1x, hp1y, hp2x, hp2y: integer;     {8  182}
				hfit: CurveFitType;                  {2  184}
				hnCoefficients: integer;           {2  186}
				hCoeff: CoefficientArray;         {48 234}
				hUM: string[15];                    {16 250}
				hContainsOutline: boolean;       {1  251}
				hBinaryPic: boolean;                {1  252}
				hThresholdStart: integer;         {2 254}
				hThresholdEnd: integer;            {2  256}
				hScaleMagnification: real;        {4  260}
				UnusedBytes: packed array[1..252] of byte;
			end;
		PicInfo = record
				nlines, PixelsPerLine: integer;
				PicSize: LongInt;
				PicBaseAddr: ptr;
				osPort: cGrafPtr;         {Offscreen Port}
				PicRect: rect;
				roiRect, osRoiRect: rect;
				osroiRgn: rgnHandle;
{$IFC Arlo }
    RoiType: (RgnRoi, RectRoi, OvalRoi, RoundRectRoi, MaskRoi, NoRoi);
{$ELSEC }
    RoiType: (RgnRoi, RectRoi, OvalRoi, RoundRectRoi, NoRoi);
{$ENDC }
				SrcRect: rect;
				wrect: rect;
				initwrect: rect;
				savewrect, SaveSrcRect: rect;
				SaveMagnification: extended;
				savehloc, savevloc: integer;  {Old window location in global coordinates}
				RoiShowing: boolean;
				title: string[30];
				NewPic: boolean;
				Magnification: extended;
				vref: integer;
				PictureType: PicType;
				wptr: WindowPtr;
				PicNum: integer;
				ScaleToFitWindow: boolean;
				Changes: boolean;
				nColors: integer;
				RedX, GreenX, BlueX: ColorArrayX;
				ColorStart, ColorWidth: integer;
				LUTMode: LUTModeType;
				cTable: MyCSpecArray;
				BytesPerRow: integer;
				PixMapSize: LongInt;
				RawSpatialScale, SpatialScale, ScaleMagnification, PixelsPerCM, UnitsPerCM: extended;
				units: string[2];
				FullUnits: string[11];
				UnitOfMeasure: string[15];
				UnitsID: UnitsType;
				p1x, p1y, p2x, p2y: integer; {Control points for grayscale transfer function}
				DeltaX, DeltaY: integer;
				HeaderOffset: LongInt;
				ImageDataOffset: LongInt;
				Fit: CurveFitType;
				nCoefficients: integer;
				Coefficient: CoefficientArray;
				Calibrated: boolean;
				BinaryPic: boolean;
				WindowState: (NormalWindow, TiledSmall, TiledSmallScaled, TiledBig, TiledBigScaled);
				FileDepth: FileDepthType;
{$IFC Arlo }
    FHTBuf: ptr;					{ pointer to area for FFT calcuations }
    FHTScale: integer;			{ power of 2 by which FHT stored in FHTBuf is divided }
{$ENDC }
			end;
		InfoPtr = ^PicInfo;
		ToolType = (MagnifyingGlass, SelectionTool, Grabber, OvalSelectionTool, Pencil, PolygonTool, Eraser, FreehandTool, Brush, RoundedRectTool, ruler, LUTTool, PaintBucket, TextTool, PlotTool, AirbrushTool, Wand, PickerTool, AngleTool, PointingTool);
		OpType = (InvertOp, PaintOp, FrameOp, EraseOp, PasteOp, AddOp, SubtractOp, MultiplyOp, DivideOp);
		ObjectType = (lineObj, oval, SelectionOval, Rectangle, RoundedRect, PlotLine, SelectionRect, LengthObj, BrushObj);
		FilterType = (WeightedAvg, UnweightedAvg, fsharpen, fshadow, EdgeDetect, ReduceNoise, dither, erosion, dilation, OutlineFilter, skeletonize);
		rhptr = ^RgnHandle;
		FlipRotateType = (RotateLeft, RotateRight, FlipVertical, FlipHorizontal);
		TextBackType = (NoBack, WithBack);
		HistogramType = array[0..255] of LongInt;
		str4 = packed array[1..4] of char;
		LookupTable = packed array[0..255] of UnsignedByte;
		TextBufType = packed array[1..MaxTextBufSize] of char;
		TextBufPtr = ^TextBufType;
		SortArray = array[1..9] of integer;
		StandardsArray = array[1..MaxStandards] of extended;
		ResultsType = (NoResults, AreaT, LengthT, PointT);
		MeasurementTypes = (AreaM, MeanM, StdDevM, xyLocM, ModeM, PerimeterM, MajorAxisM, MinorAxisM, AngleM, IntDenM);
		xyArray = array[1..MaxPolyVertices] of integer;
		TiffHdr = record
				ByteOrder: packed array[1..2] of char;
				Version: integer;
				FirstIFDOffset: LongInt;
			end;
		TiffEntry = record
				TagField: integer;
				ftype: integer;
				length: LongInt;
				offset: LongInt;
			end;
		pcItemType = (pcRadioButton, pcButton);
		WhatToImportType = (ImportTIFF, ImportMCID, ImportPalette, ImportCustom);
		FateTable = array[0..255] of integer;
		SaveAsWhatType = (asTIFF, asPICT, asMacPaint, asRawData, asPalette, asOutline, asRegions, asLengths, asPoints, asPlotValues, asHistogramValues);
		MeasurementsType = record
				mean: array[0..MaxRegions] of real;
				sd: array[0..MaxRegions] of real;
				PixelCount: array[0..MaxRegions] of LongInt;
				mode: array[0..MaxRegions] of real;
				IntegratedDensity: array[0..MaxRegions] of real;
				plength: array[0..MaxRegions] of real;
				xcenter, ycenter: array[0..MaxRegions] of real;
				MajorAxis, MinorAxis: array[0..MaxRegions] of real;
				orientation: array[0..MaxRegions] of real;
			end;
		MeasurementsPtr = ^MeasurementsType;

{$IFC Arlo }
  DyadicFDOp = (Add, Subtract, Multiply, Divide, ConjugateMultiply);
  FFTConfiguration = packed record
    PSScale: integer;					{ scaling of power spectra 1..10 }
    xyScaled: boolean;				{ allows FFT'ing of non-power-of-2 square regions }
    useBigBufForFFT: boolean;		{ use BigBuf instead of FHTBuf for all FFTs }
    doMeanZero: boolean;			{ subtract mean from data before computing FFT to remove DC component }
    doZeroPad: boolean;				{ embeds NxN image in 2Nx2N zerod rect before FFTing }
    doAveragePad: boolean;			{ embeds NxN image in 2Nx2N rect filled with NxN avg before FFTing }
    autoMask: boolean;				{ mask automatically before performing FFT }
    autoFilter: boolean;				{ filter (everything selected) automatically on inverse FFT }
    autoPass: boolean;				{ pass (filter out everything but selection) automatically on inverse FFT }
    autoThreshold: boolean;			{ zero everything within Threshold limits automatically on inverse FFT }
    autoInverseFFT: boolean;		{ set if the product/difference... etc of two FFT's is to be immediately IFFT'd }
    clipExtrema: boolean;			{ clip min and max of power spectrum to give range in 1..254  instead of 0..255 }
    FreqDomainOp: DyadicFDOp;	{ default Dyadic operation in the Frequency Domain }
   end;

  MaskingMode = (gaussian, cosine, linear, parabolic);
  MaskingConfiguration = packed record
    maskMode: MaskingMode;	{ transition type }
    percentWidth: integer;		{ percent of radius; 100% => only center-most pixel unaffected }
    pixelWidth: integer;			{ width of filter transition region in the Frequency domain }
    minLevel: integer;			{ In units [%] i.e. [0..100].  Amount by which pixels outside selection are mult'd during pass }
    maxLevel: integer;			{ In units [%] i.e. [0..100].  Amount by which pixels inside transition are mult'd during pass }
   end;

{$ENDC }


	var
		TraceInfo: str4;
		finished: boolean;
		trect, gmrect, GrayMapRect, GrayMapRect2, crect, HistoRect: rect;
		gmSlide1, gmslide2, gmSlide1i, gmSlide2i, gmicon1, gmicon2: rect;
		gmSlide1Loc: integer;
		gmFixedSlope: boolean;
		ToolWindow, GrayMapWindow, LUTWindow, ResultsWindow, HistoWindow, PlotWindow, PasteControl: WindowPtr;
		BuggyWatch: CursHandle;
		cr, tab, BackSpace: char;
		CharCount: LongInt;
		ScreenPort: GrafPtr;
		CScreenPort: cGrafPtr;
		ticks: LongInt;
		MonoFunction: ClutTable;
		PaletteRec: record
				NumberOfColors: integer;
				RedData: ColorArray;
				GreenData: ColorArray;
				BlueData: ColorArray;
			end;
		Info: InfoPtr;
		ToolCursor: array[ToolType] of Cursor;
		PickerCursor, LUTCursor, gmCursor, CrossPlusCursor, CrossMinusCursor, GlassMinusCursor, watch: Cursor;
		CurrentTool, PreviousTool, FirstTool, LastTool: ToolType;
		ToolRect: array[ToolType] of rect;
		ToolChar, ToolCursorChar: array[ToolType] of char;
		ToolTime, LutTime: longInt;
		nPics: integer;
		PicWindow: array[1..MaxPics] of WindowPtr;
		ScreenWidth, ScreenHeight: integer;
		ScreenBase: ptr;
		ScreenRowBytes: LongInt;
		Histogram: HistogramType;
		HistogramThresholdStart, HistogramThresholdEnd: integer;
		ForegroundIndex, BackgroundIndex: integer;
		CurrentColorIndex, ClipColorIndex: integer;
		lines: array[1..nLineTypes] of rect;
		CheckRect: rect;
		LineWidth, LineIndex: integer;
		StartOfLines: integer;
		SaveInfo: InfoPtr;
		MaskRgn: RgnHandle;
		PlotPICT: PicHandle;
		PlotLeft, PlotTop, PlotWidth, PlotHeight: integer;
		PlotMin, PlotMax: extended;
		PlotCount, PlotAvg: integer;
		PlotData: LineType;
		PlotMean: extended;
		InvertPlots, AutoscalePlots, LinePlot, DrawPlotLabels, FixedSizePlot: boolean;
		ProfilePlotMin, ProfilePlotMax: extended;
		ProfilePlotWidth, ProfilePlotHeight: integer;
		UndoBuf, ClipBuf, BigBuf: ptr;
		ClipBufSize, UndoBufSize, BigBufSize: LongInt;
		UndoInfoRec: PicInfo;
		UndoInfo: InfoPtr;
		CurrentUndoSize: LongInt;
		AirbrushDiameter, AirbrushRadius, AirbrushRadius2: integer;
		BrushHeight, BrushWidth: integer;
		Settings: record
				sForegroundIndex, sBackgroundIndex: integer;
				sBrushHeight, sBrushWidth: integer;
				sAirbrushDiameter: integer;
				sLUTMode: LUTModeType;
				sColorStart, sColorWidth: integer;
				sCurrentFontID: integer;
				sCurrentStyle: style;
				sCurrentSize: integer;
				sTextJust: integer;
				sTextBack: TextBackType;
				snExtraColors: integer;
				sExtraColors: ExtraColorsArray;
				sInvertVideo: boolean;
				sMeasurements: set of MeasurementTypes;
				sInvertPlots, sAutoScalePlots, sLinePlot, sDrawPlotLabels, sFixedSizePlot: boolean;
				sProfilePlotMin, sProfilePlotMax: extended;
				sProfilePlotWidth, sProfilePlotHeight: integer;
				sFramesToAverage: integer;
				sNewPicWidth, sNewPicHeight: integer;
				sBufferSize: LongInt;
				sMaxScionWidth: integer;
				sThresholdToForeground, sNonThresholdToBackground: boolean;
				sVideoChannel: integer;
				sWhatToImport: WhatToImportType;
				sImportCustomWidth, sImportCustomHeight: integer;
				sImportCustomOffset: LongInt;
				sWandAutoMeasure, sWandAutoNumber: boolean;
				sBinaryIterations: integer;
				sScaleArithmetic: boolean;
				sUseZeroForBlack: boolean;
				sInvertYCoordinates: boolean;
				sPrecision: integer;
				sMinParticleSize, sMaxParticleSize: LongInt;
				sIgnoreParticlesTouchingEdge, sLabelParticles, sOutlineParticles: boolean;
{$IFC Arlo }
    sFFTConfig: FFTConfiguration;
    sMaskConfig: MaskingConfiguration;
{$ENDC }
			end;
		CurrentFontID, CurrentSize, NumFontItems: integer;
		CurrentStyle: Style;
		InsertionPoint: point; {Offscreen coordinates}
		IsInsertionPoint: boolean;
		TextJust: integer;
		TextBack: TextBackType;
		TextStr: str255;
		TextRect: rect;
		TextStart: point;
		BlinkTime: LongInt;
		pat: array[0..7] of pattern;
		PatIndex: integer;
		OpPending: boolean;
		CurrentOp: OpType;
		IsOK: boolean;
		PaletteName: string[32];
		PicLeftBase, PicTopBase, PicLeft, PicTop: integer;
		ClipBufInfoRec: PicInfo;
		ClipBufInfo: InfoPtr;
		MouseState: (NotInRoi, InRoi, DownInRoi);
		MouseDownLoc, osMouseDownLoc: point;
		OldRoiRect: rect;
		WhatsOnClip: (Nothing, AColor, RectPic, NonRectPic, ImportedPic, TextOnClip);
		ClipTextInBuffer: boolean;
		PasteMode: (NormalPaste, LiveSelection, PasteFromCamera);
		ExtraColors: ExtraColorsArray;
		nExtraColors: integer;
		PasteTransferMode: integer;
		cheight: integer;
		ExtraColorsRect: array[1..MaxExtraPlus2] of rect;
		ExtraColorsEntry: array[1..MaxExtraPlus2] of integer;
		StretchMode: boolean;
		IdentityFunction: boolean;
		OldScrapCount: integer;
		ClipboardConverted: boolean;
		results: record
				tmean, x, y, minCalibratedValue, maxCalibratedValue, length, angle: extended;
				hloc, MinIndex, MaxIndex, imode, imean: integer;
			end;
		FrameGrabber: (QuickCapture, Scion, NoFrameGrabber);
		DTSlotBase, ScionSlotBase: LongInt;
		ControlReg, ChannelReg: ptr;
		Digitizing: boolean;
		debugging: boolean;
		NoInfo: InfoPtr;
		NoInfoRec: PicInfo;
		BlankLine: LineType;
		UndoFromClip: boolean;
		Thresholding, ThresholdToForeground, NonThresholdToBackground: boolean;
		ThresholdStart, ThresholdEnd: integer;
		ThresholdColor: RGBColor;
		SaveCTable: ^MyCSpecArray;
		BlankFieldInfo: InfoPtr;
		BlankFieldMean: integer;
		QuickCaptureInfo, ScionInfo: InfoPtr;
		InvertVideo: boolean;
		VideoChannel: integer;
		TextBufSize, TextBufColumn, TextBufLineCount: integer;
		TextBufP: TextBufPtr;
		MeasurementsP: MeasurementsPtr;
		BitInfoCount: integer;
		nRegions, nRegions2, UnsavedAreas: integer;
		nPoints, UnsavedPoints: integer;
		nLengths, nLengths2, UnsavedLengths: integer;
		Lengths: array[0..MaxLengths] of real;
		xLoc: array[1..MaxPoints] of integer;
		yLoc: array[1..MaxPoints] of integer;
		umean: array[0..MaxStandards] of real; {Uncalibrated means}
		StandardValues: StandardsArray;
		nStandards: integer;
		value: array[0..255] of extended;
		MinValue, MaxValue, FitGoodness, FitSD: extended;
		PlotLeftMargin, PlotTopMargin, PlotBottomMargin, PlotRightMargin: integer;
{$IFC Arlo }
  WhatToUndo: (NothingToUndo, UndoEdit, UndoFlip, UndoRotate, UndoScale, UndoFilter, UndoPaste, UndoTransform, UndoClear, UndoMeasurement, UndoContrastEnhancement, UndoEqualization, UndoZoom, UndoPlot, UndoOutline, UndoMask);
{$ELSEC }
  WhatToUndo: (NothingToUndo, UndoEdit, UndoFlip, UndoRotate, UndoScale, UndoFilter, UndoPaste, UndoTransform, UndoClear, UndoMeasurement, UndoContrastEnhancement, UndoEqualization, UndoZoom, UndoPlot, UndoOutline);
{$ENDC }
		WhatToCopy: (NothingToCopy, CopySelection, CopyCLUT, CopyGrayMap, CopyPlot, CopyCalibrationPlot, CopyHistogram, CopyRegions, CopyLengths, CopyPoints, CopyColor);
		WhatToPrint: (NothingToPrint, PrintImage, PrintSelection, PrintAreas, PrintLengths, PrintPoints, PrintPlot, PrintHistogram);
		PrintRecord: THPrint;
		isLaserWriter: boolean;
		printing, ShowingList, Copying: boolean;
		HalftoneFrequency, HalftoneAngle: integer;
		HalftoneDotFunction: boolean;
{$ IFC Arlo }
AppleMenuH, FileMenuH, EditMenuH, OptionsMenuH, EnhanceMenuH, BinaryMenuH, ArithmeticMenuH, AnalyzeMenuH, VideoMenuH, SortPaletteMenuH, TextMenuH, FontMenuH, SizeMenuH, StyleMenuH, WindowsMenuH, UserMenuH, FFTMenuH, PSScalingMenuH, NthRootMenuH, AutoMenuH: MenuHandle;
{$ ELSEC }
		AppleMenuH, FileMenuH, EditMenuH, OptionsMenuH, EnhanceMenuH, BinaryMenuH, ArithmeticMenuH, AnalyzeMenuH, VideoMenuH, SortPaletteMenuH, TextMenuH, FontMenuH, SizeMenuH, StyleMenuH, WindowsMenuH, UserMenuH: MenuHandle;
{$ ENDC}
		rleft, rtop: integer;
		ListDone: boolean;
		ListWindow: WindowPtr;
		ScrollBar: ControlHandle;
		ListTE: TEHandle;
		ListPageSize: integer;
		ListButton: array[1..4] of rect;
		measuring: boolean;
		Measurements: set of MeasurementTypes;
		nMeasurements: integer;
		FramesToAverage: integer;
		PixelLength: extended;
		xLabel, yLabel, zLabel: string[31];
		xValueLoc, yValueLoc, zValueLoc: integer;
		MenuBarHeight: integer;
		NewPicWidth, NewPicHeight: integer;
		RestoreUndoBuf: boolean;
		WhatToOpen: (OpenImage, OpenPICT2, OpenTIFF, OpenMCID, OpenUnknown, OpenImported, OpenCustom);
		WhatToImport: WhatToImportType;
		ImportCustomWidth, ImportCustomHeight: integer;
		ImportCustomOffset: LongInt;
		ImportCustomDepth: FileDepthType;
		ImportSwapBytes, ImportAll: boolean;
		TiffInfo: record
				Header: TiffHdr;   {8}
				nEntries: integer; {2}
				directory: array[1..7] of TiffEntry; {84}
				NextIFD: LongInt;  {4}
				filler: array[1..TiffFillerSize] of integer;
			end;
		IntelByteOrder: boolean;
		BufferSize: LongInt;
		MaxScionWidth: integer;
		isSelectionTool: boolean;
		SelectionMode: (NewSelection, AddSelection, SubSelection);
		RoiMovementState: (Unconstrained, Constrained, ConstrainedH, ConstrainedV);
		pcItem: array[1..npcItems] of record
				r: rect;
				itype: pcItemType;
				str: string[20];
			end;
		PictF: integer;
		PictBuffer, curPictBufPtr: ptr;
		BytesInPictBuffer: LongInt;
		FitsInPictBuffer, RoiNudged, SavingOutline, RestoringOutline, GrayMapReady, RedoSelection: boolean;
		ThresholdingMode: (LutThresholding, GrayMapThresholding, BinaryImage, NoThresholding);
		WandAutoMeasure, WandAutoNumber, RedirectSampling: boolean;
		LabelParticles, OutlineParticles, IgnoreParticlesTouchingEdge: boolean;
		MinParticleSize, MaxParticleSize: LongInt;
		OptionKeyWasDown, ScaleArithmetic, FitEllipse, AnalyzingParticles: boolean;
		WhiteRGB, BlackRGB, ForegroundRGB, BackgroundRGB: RGBColor;
		BinaryIterations: integer;
		nMonitors: integer;
		Monitors: array[1..6] of GDHandle;
		ResultsMessage: str255;
		DTStartTicks, DTFrameCount: LongInt;
		SaveAsWhat: SaveAsWhatType;
		SaveAllFlag: (NoSaveAll, SaveAllStage1, SaveAllStage2);
		UseZeroForBlack, InvertYCoordinates, ContinuousHistogram: boolean;
		qcPort: cGrafPtr;
		qcWidth, qcHeight: integer;
		RoiUpdateTime: LongInt; {Time required to draw ROI outline. Set to 0 to force redraw.}
		Precision: integer; {Digits to right of decimal point}
		MeasurementToRedo: integer;
		Has32BitQuickDraw: boolean;

{$IFC Arlo }
  InFrequencyDomain: boolean;			{ set according to which kind of window info^ describes }
  FFTNumber: integer;					{ total number of Forward FFTs calculated for this session }
  InverseFFTNumber: integer;			{ total number of Inverse FFTs calculated for this session }
  FFTConfig: FFTConfiguration;			{ FFT Configuration Settings }
  MaskConfig: MaskingConfiguration;	{ Masking Settings }
{$ENDC }


implementation

end.