// Borland C++ Builder
// Copyright (c) 1995, 2002 by Borland Software Corporation
// All rights reserved

// (DO NOT EDIT: machine generated header) 'HPGL2.pas' rev: 6.00

#ifndef HPGL2HPP
#define HPGL2HPP

#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <Clipbrd.hpp>	// Pascal unit
#include <Math.hpp>	// Pascal unit
#include <sgConsts.hpp>	// Pascal unit
#include <sgBitmap.hpp>	// Pascal unit
#include <Extrusion.hpp>	// Pascal unit
#include <DXFImage.hpp>	// Pascal unit
#include <DXFConv.hpp>	// Pascal unit
#include <Graphics.hpp>	// Pascal unit
#include <Classes.hpp>	// Pascal unit
#include <SysUtils.hpp>	// Pascal unit
#include <Windows.hpp>	// Pascal unit
#include <SysInit.hpp>	// Pascal unit
#include <System.hpp>	// Pascal unit

//-- user supplied -----------------------------------------------------------

namespace Hpgl2
{
//-- type declarations -------------------------------------------------------
class DELPHICLASS EsgHPGLError;
class PASCALIMPLEMENTATION EsgHPGLError : public Sysutils::Exception 
{
	typedef Sysutils::Exception inherited;
	
public:
	#pragma option push -w-inl
	/* Exception.Create */ inline __fastcall EsgHPGLError(const AnsiString Msg) : Sysutils::Exception(Msg) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateFmt */ inline __fastcall EsgHPGLError(const AnsiString Msg, const System::TVarRec * Args, const int Args_Size) : Sysutils::Exception(Msg, Args, Args_Size) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateRes */ inline __fastcall EsgHPGLError(int Ident)/* overload */ : Sysutils::Exception(Ident) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateResFmt */ inline __fastcall EsgHPGLError(int Ident, const System::TVarRec * Args, const int Args_Size)/* overload */ : Sysutils::Exception(Ident, Args, Args_Size) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateHelp */ inline __fastcall EsgHPGLError(const AnsiString Msg, int AHelpContext) : Sysutils::Exception(Msg, AHelpContext) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateFmtHelp */ inline __fastcall EsgHPGLError(const AnsiString Msg, const System::TVarRec * Args, const int Args_Size, int AHelpContext) : Sysutils::Exception(Msg, Args, Args_Size, AHelpContext) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateResHelp */ inline __fastcall EsgHPGLError(int Ident, int AHelpContext)/* overload */ : Sysutils::Exception(Ident, AHelpContext) { }
	#pragma option pop
	#pragma option push -w-inl
	/* Exception.CreateResFmtHelp */ inline __fastcall EsgHPGLError(System::PResStringRec ResStringRec, const System::TVarRec * Args, const int Args_Size, int AHelpContext)/* overload */ : Sysutils::Exception(ResStringRec, Args, Args_Size, AHelpContext) { }
	#pragma option pop
	
public:
	#pragma option push -w-inl
	/* TObject.Destroy */ inline __fastcall virtual ~EsgHPGLError(void) { }
	#pragma option pop
	
};


typedef void __fastcall (__closure *TsgHPGLProgressEvent)(Graphics::TProgressStage Stage, int Done, int Count);

#pragma pack(push, 4)
struct TsgHPPen
{
	Graphics::TColor Color;
	float Width;
} ;
#pragma pack(pop)

typedef Set<char, 0, 255>  TsgHPGLSymbols;

typedef void __fastcall (__closure *TpclProc)(char Cmd, bool Rel, int Param);

typedef void __fastcall (*TpclUnpackProc)(void * Src, void * Dst);

#pragma pack(push, 1)
struct THpBmpData
{
	Byte ClrSpace;
	Byte Encode;
	Byte BitsNdx;
	Byte BitsRed;
	Byte BitsGrn;
	Byte BitsBlu;
	Word WRed;
	Word WGrn;
	Word WBlu;
	Word BRed;
	Word BGrn;
	Word BBlu;
} ;
#pragma pack(pop)

class DELPHICLASS TpclReader;
class DELPHICLASS TsgHPGLReader;
class PASCALIMPLEMENTATION TsgHPGLReader : public System::TObject 
{
	typedef System::TObject inherited;
	
private:
	Classes::TList* FCmdPar;
	TpclReader* FPCL;
	Dxfconv::TsgDXFConverter* FConv;
	int FCurPenNum;
	int FLast;
	Dxfconv::TsgDXFLineType* FLType;
	AnsiString FDrawingName;
	bool FDoScaling;
	bool FError;
	Word FHPGLCmd;
	AnsiString FLblTerm;
	char *FMem;
	TsgHPGLProgressEvent FOnProgress;
	Sgconsts::TFPoint FPage;
	Sgconsts::TFPoint FPenPos;
	Sgconsts::TFPoint FPenPos0;
	Sgconsts::TFPoint FTextPos;
	bool FPenDown;
	Classes::TList* FPolyBuffer;
	bool FPolyMode;
	char *FPos;
	char *FLimit;
	char *FStart;
	Dxfconv::TsgDXFSection* FPSpace;
	bool FScaling;
	Sgconsts::TFPoint FScale;
	bool FRelative;
	int FRotation;
	int FRTLRes;
	float FRTLScale;
	Sgconsts::TFPoint FRealP1;
	Sgconsts::TFPoint FRealP2;
	Classes::TStream* FStream;
	char FTerminator;
	Sgconsts::TFPoint FUserP1;
	Sgconsts::TFPoint FUserP2;
	Sgconsts::TFPoint FArcStart;
	Sgconsts::TFPoint FArcEnd;
	Dxfconv::TsgDXFLayout* FLayout;
	int FLayoutNum;
	int FPolyIndex;
	int FHatchIndex;
	float FShading;
	int FTotal;
	float FTextWidth;
	float FTextHeight;
	float FTextRotation;
	float FFrame;
	float FSlant;
	Dxfconv::TsgFlatPoly* FFlat;
	Dxfconv::TsgFlatHatch* FHatch;
	Dxfconv::TsgDXFImageEnt* FImgEnt;
	Dxfconv::TsgCADClipInsert* FInsert;
	TsgHPPen FHPPens[257];
	Dxfconv::TsgDXFLayer* FLayers[257];
	bool FUsePSInstr;
	bool FEmpty;
	Byte FHAlign;
	bool __fastcall AddFlat(Dxfconv::TsgDXFEntity* AEntity);
	bool __fastcall AddToInsert(Dxfconv::TsgDXFEntity* AEntity);
	double __fastcall AddImage(Sgbitmap::TsgBitmap* BM);
	Graphics::TColor __fastcall CurColor(bool DoShading);
	bool __fastcall InsertHatch(Dxfconv::TsgDXFEntity* AEntity);
	Dxfconv::TsgDXFLayer* __fastcall GetLayer(int Index);
	void __fastcall AddArc(bool ArcAbs);
	void __fastcall AddThree(void);
	void __fastcall AddCircle(void);
	void __fastcall AddEntity(Dxfconv::TsgDXFEntity* AEntity);
	void __fastcall AddLine(void);
	void __fastcall AddPoly(void);
	void __fastcall AddPolyline(void);
	void __fastcall AddRectangle(bool ARelative);
	void __fastcall AddSpline(bool ARelative);
	void __fastcall AddSolid(bool ARelative);
	void __fastcall AddText(void);
	void __fastcall AddHatch(void);
	void __fastcall DoArc(bool ArcAbs, const Sgconsts::TFPoint &APoint, double AAngle);
	void __fastcall DoAddText(AnsiString &S);
	void __fastcall BeginPlot(void);
	void __fastcall MoveChar(void);
	void __fastcall FillType(void);
	void __fastcall FinishInsert(void);
	void __fastcall FlushHatch(void);
	void __fastcall FrameAdvance(void);
	void __fastcall Loads(Dxfconv::TsgDXFEntity* E);
	bool __fastcall CheckIndex(int AIndex);
	Sgconsts::TFPoint __fastcall CmdPoint(int Index);
	Sgconsts::TFPoint __fastcall ConvPoint(bool ARelative, const Sgconsts::TFPoint &P, Sgconsts::TFPoint &P1);
	void __fastcall ClearPolyBuffer(void);
	void __fastcall DoProgress(Graphics::TProgressStage Stage);
	bool __fastcall Eof(void);
	void __fastcall FindSymbol(const TsgHPGLSymbols &ASymbols, char &Ch);
	char __fastcall GetChar(void);
	char __fastcall GetChars(void);
	bool __fastcall GetCmdPar(bool ADoScale, bool ARelative);
	void __fastcall GetScales(void);
	AnsiString __fastcall GetStrCmdPar();
	void __fastcall InitPlot(void);
	void __fastcall InputPoints(void);
	void __fastcall InputWindow(void);
	void __fastcall PlotSize(void);
	bool __fastcall ProcHPGLCmd(Word ACmd);
	bool __fastcall ProcPJLCmp(void);
	bool __fastcall ProcRTLCmd(void);
	void __fastcall CharSlant(void);
	void __fastcall LabelOrigin(void);
	void __fastcall MergeControl(void);
	void __fastcall NewLayout(void);
	void __fastcall ProcPMCommand(void);
	void __fastcall Rotate(void);
	void __fastcall ReturnToSymbol(const TsgHPGLSymbols &ASymbols, char Ch);
	void __fastcall SetPenColor(void);
	void __fastcall SetPenWidth(void);
	void __fastcall SetLineType(void);
	void __fastcall SelectPen(void);
	void __fastcall SetScale(void);
	void __fastcall SimpleColors(int Param);
	void __fastcall TextHeight(void);
	void __fastcall TextRotation(void);
	void __fastcall UpdatePen(int N);
	
public:
	__fastcall TsgHPGLReader(Dxfconv::TsgDXFConverter* Conv, Classes::TStream* S);
	__fastcall virtual ~TsgHPGLReader(void);
	void __fastcall ReadFile(void);
};


class PASCALIMPLEMENTATION TpclReader : public Classes::TList 
{
	typedef Classes::TList inherited;
	
private:
	TsgHPGLReader* FOwner;
	Sgconsts::TFPoint FPenPos;
	int FRasterX;
	int FRasterY;
	int FDestX;
	int FDestY;
	int FResolution;
	int FMaxLen;
	int FCompress;
	int FMode;
	#pragma pack(push, 1)
	tagPALETTEENTRY FEntry;
	#pragma pack(pop)
	
	void *FSaved;
	#pragma pack(push, 1)
	THpBmpData FData;
	#pragma pack(pop)
	
	#pragma pack(push, 1)
	Windows::TMaxLogPalette FPalette;
	#pragma pack(pop)
	
	Byte FROP;
	bool FUseGDIPlus;
	void * __fastcall Unpack(bool Copy, void * P, TpclUnpackProc Proc);
	void __fastcall Reset(void);
	void __fastcall PushPalette(void);
	void __fastcall PopPalette(void);
	void __fastcall DoPlanes(void);
	void __fastcall DoPosition(char Cmd, bool Rel, int Param);
	void __fastcall DoMisc(char Cmd, bool Rel, int Param);
	void __fastcall DoBits(char Cmd, bool Rel, int Param);
	void __fastcall DoDest(char Cmd, bool Rel, int Param);
	void __fastcall DoParams(char Cmd, bool Rel, int Param);
	void __fastcall DoROP(char Cmd, bool Rel, int Param);
	void __fastcall DoRaster(char Cmd, bool Rel, int Param);
	void __fastcall DoFont(char Cmd, bool Rel, int Param);
	void __fastcall DoCmds(TpclProc Proc);
	void __fastcall DoRotate(System::TObject* Sender);
	void __fastcall SimpleColors(int Param);
	void __fastcall StartData(int Mode);
	void __fastcall EndData(void);
	void __fastcall ReadDataV(int ACount);
	void __fastcall ReadDataW(int ACount);
	
public:
	__fastcall TpclReader(TsgHPGLReader* AOwner);
	__fastcall virtual ~TpclReader(void);
	bool __fastcall Process(void);
	bool __fastcall Font(void);
};


class DELPHICLASS TsgHPGLConverter;
class PASCALIMPLEMENTATION TsgHPGLConverter : public Dxfconv::TsgDXFConverter 
{
	typedef Dxfconv::TsgDXFConverter inherited;
	
protected:
	TsgHPGLReader* FReader;
	virtual void __fastcall Initialize(const AnsiString FileName);
	void __fastcall InitLTypes(void);
	
public:
	virtual void __fastcall StopLoading(void);
public:
	#pragma option push -w-inl
	/* TsgDXFConverter.Create */ inline __fastcall TsgHPGLConverter(const AnsiString FileName) : Dxfconv::TsgDXFConverter(FileName) { }
	#pragma option pop
	#pragma option push -w-inl
	/* TsgDXFConverter.Destroy */ inline __fastcall virtual ~TsgHPGLConverter(void) { }
	#pragma option pop
	
};


class DELPHICLASS TsgHPGLImage;
class PASCALIMPLEMENTATION TsgHPGLImage : public Dxfimage::TsgDXFImage 
{
	typedef Dxfimage::TsgDXFImage inherited;
	
private:
	Sgconsts::TFPoint FPage;
	Graphics::TPen* FNullPen;
	int FMMWidth;
	int FMMHeight;
	bool FUsePSInstr;
	int __fastcall GetMMWidth(void);
	int __fastcall GetMMHeight(void);
	bool __fastcall GetUsePSInstr(void);
	void __fastcall SetUsePSInstr(const bool Value);
	void __fastcall SetSizes(void);
	
protected:
	virtual Dxfconv::TsgDXFConverter* __fastcall CreateConverter(void);
	HIDESBASE void __fastcall DoProgress(Graphics::TProgressStage Stage, int Done, int Count);
	virtual int __fastcall GetHeight(void);
	virtual int __fastcall GetWidth(void);
	virtual double __fastcall GetLineScale(void);
	virtual void __fastcall SetExtentsParameters(const Sgconsts::TFRect &ARect, const bool AIs3DExtents);
	
public:
	__fastcall virtual TsgHPGLImage(void);
	__fastcall virtual ~TsgHPGLImage(void);
	virtual void __fastcall Assign(Classes::TPersistent* Source);
	virtual Sgconsts::TFPoint __fastcall CommonToInternalUnits(const Sgconsts::TFPoint &Pt);
	Sgconsts::TFPoint __fastcall ConvertHPGLStepsToMM(const Sgconsts::TFPoint &APoint);
	Sgconsts::TFPoint __fastcall ConvertMMToHPGLSteps(const Sgconsts::TFPoint &APoint);
	virtual Sgconsts::TFPoint __fastcall InternalToCommonUnits(const Sgconsts::TFPoint &Pt);
	virtual void __fastcall LoadFromStream(Classes::TStream* S);
	virtual Dxfimage::TsgMeasurement __fastcall Measurement(void);
	__property int MMWidth = {read=GetMMWidth, nodefault};
	__property int MMHeight = {read=GetMMHeight, nodefault};
	__property bool UsePSInstruction = {read=GetUsePSInstr, write=SetUsePSInstr, nodefault};
};


//-- var, const, procedure ---------------------------------------------------
#define SHPGLImage "HPGL/2 image"
static const Word HPGLSteps = 0x3f8;
static const Word HPMaxPens = 0x100;
extern PACKAGE Word CF_HPGL;
extern PACKAGE int __fastcall OrdStr(const AnsiString S);

}	/* namespace Hpgl2 */
using namespace Hpgl2;
#pragma option pop	// -w-
#pragma option pop	// -Vx

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif	// HPGL2
