// $Source: /usr/local/SimSoft/Sfx3D/src/gsl/geometry.h,v $
// $Revision: 1.2 $
// $Author: baum $
// $Date: 2001/11/29 15:18:09 $
//
// Login name of the user who locked the revision
// $Locker:  $
// Tag name used to checkout the file
// $Name:  $
// State assigned to revision
// $State: Exp $
//
//
// $Log: geometry.h,v $
// Revision 1.2  2001/11/29 15:18:09  baum
// -Realzeitsteuerung eingebaut
// -Handsteuerung eingebaut
//

#ifndef _GEOMETRY_H
#define _GEOMETRY_H	1


#include "DynArray.h"
#include "Strings.h"

#include "Token.h"

#include "Vec3D.h"

#include "XGraph/Attribut.h"

#ifndef _PATTERN_H
  class Pattern;
#endif

#ifdef _GEOMETRY_CPP
#  undef _impexp
#  define _impexp __declspec(dllexport)
#elif defined BUILD_GRAF_DLL
#  undef _impexp
#  define _impexp
#else
#  undef _impexp
#  define _impexp __declspec(dllimport)
#endif

#if defined __GNUC__ || defined __hpux
#  undef _impexp
#  define _impexp
#endif

//==================================================================
//		Class-Header
//		for class TGBIdentity
//==================================================================

class _impexp TGBIdentity {
  public:
    TGBIdentity (const TGBIdentity&);
    TGBIdentity (unsigned typ, unsigned variant);
    ~TGBIdentity ();

    bool operator == (const TGBIdentity&);
    bool operator != (const TGBIdentity&);

    unsigned Typ () const;
    unsigned Variant () const;

  protected:

  private:
    unsigned ObjTyp;
    unsigned ObjVariant;

    TGBIdentity();
    TGBIdentity& operator = (const TGBIdentity&);
};

//==================================================================
//		Class-Header
//		for class TGBPattern
//==================================================================
class TGBLib;

class _impexp TGBPattern {
  public:
    static Pattern* buildText (const Ustring& text,
                               const double& height, const double& thikness,
                               const Vec3D& pos);

    GeoObject *MyGeometry () const;
    const DynArray<GeoObject>& AllGeometries () const;

    const TGBIdentity& Id () const;

    const double&  NumberHeight () const;
    const Vec3D&   NumberPos    () const;

    const double& SymbolHeight () const;
    const Vec3D&  SymbolPos    () const;

  protected:
    // constructor
    TGBPattern (unsigned typ, unsigned variant);

    // destructor
    virtual ~TGBPattern();

    // data-members
    TGBIdentity ObjId;
    DynArray<GeoObject> ObjGeometries;

    double ObjNumberHeight;
    Vec3D  ObjNumberPos;
    double ObjSymbolHeight;
    Vec3D  ObjSymbolPos;

    virtual void read  (TGBLib& tgbLib);
    void readGeometry  (TGBLib& tgbLib, int sentenceOffset, unsigned forWhom);
    void readPositions (TGBLib& tgbLib, int sentenceOffset);
    void readText      (TGBLib& tgbLib, int sentenceOffset);

    static unsigned   ClassRefCounter;
    static Attribute* ClassPermAttribute;
    static Attribute* ClassTempAttribute;
    static Attribute* ClassTextAttribute;

  private:
    TGBPattern();
    TGBPattern (const TGBPattern&);
    TGBPattern& operator = (const TGBPattern&);

    static void setup ();
    static void cleanup ();
};

//==================================================================
//		Class-Header
//		for class TGBPermPattern
//==================================================================

class _impexp TGBPermPattern : public TGBPattern {
  public:
    // constructor
    TGBPermPattern (TGBLib& tgbLib, unsigned typ, unsigned variant);

    // destructor
    virtual ~TGBPermPattern();

    const DynArray<Vec3D>& PalPositions   () const;
    const DynArray<Vec3D>& EntryPositions () const;
    const DynArray<Vec3D>& ExitPositions  () const;

  protected:

  private:
    // data-members
    DynArray<Vec3D> ObjPalPositions;
    DynArray<Vec3D> ObjEntryPositions;
    DynArray<Vec3D> ObjExitPositions;

    virtual void read (TGBLib& tgbLib);
    void readIOPositions (TGBLib& tgbLib, int sentenceOffset);

    TGBPermPattern();
    TGBPermPattern (const TGBPermPattern&);
    TGBPermPattern& operator = (const TGBPermPattern&);
};

//==================================================================
//		Class-Header
//		for class TGBTempPattern
//==================================================================

class _impexp TGBTempPattern : public TGBPattern {
  public:
    // constructor
    TGBTempPattern (TGBLib& tgbLib, unsigned typ, unsigned variant);

    // destructor
    virtual ~TGBTempPattern();

  protected:

  private:
    // data-members
    virtual void read (TGBLib& tgbLib);
    void readLogicGeometry (TGBLib& tgbLib, int sentenceOffset);

    TGBTempPattern();
    TGBTempPattern (const TGBTempPattern&);
    TGBTempPattern& operator = (const TGBTempPattern&);
};

//==================================================================
//		Class-Header
//		for class TGBLib
//==================================================================

class _impexp TGBLib {
  public:
    TGBLib ();
    ~TGBLib ();

    TGBPermPattern *findPerm (unsigned typ, unsigned variant);
    TGBTempPattern *findTemp (unsigned typ, unsigned variant);

    void BuildNumbers      ();
    void DontBuildNumbers  ();
    bool hasToBuildNumbers () const;

    unsigned TypOffset    () const;
    unsigned TypMulti     () const;
    unsigned VarMulti     () const;
    unsigned SegOffset    () const;
    unsigned NumPosOffset () const;
    unsigned SymPosOffset () const;
    unsigned TextOffset   () const;

    unsigned Info1Offset  () const;
    unsigned Info2Offset  () const;
    unsigned Info3Offset  () const;
    unsigned Info4Offset  () const;

    InputFile*     TGBFile      () const;
    const Ustring& TexturesPath () const;
    const Ustring& VrmlPath     () const;

  protected:

  private:
    void prepareForPerms ();
    void prepareForTemps ();

    void readTempOffsets ();
    void readPermOffsets ();

    // data-members
    bool ObjIsPreparedForPerms;
    bool ObjIsPreparedForTemps;
    bool ObjHasToBuildNumbers;
    unsigned ObjTypOffset;
    unsigned ObjTypMulti;
    unsigned ObjVarMulti;
    unsigned ObjSegOffset;
    unsigned ObjNumPosOffset;
    unsigned ObjSymPosOffset;
    unsigned ObjTextOffset;

    unsigned ObjInfo1Offset;
    unsigned ObjInfo2Offset;
    unsigned ObjInfo3Offset;
    unsigned ObjInfo4Offset;

    Ustring    ObjPermFileName;
    Ustring    ObjDefaultPermFileName;
    Ustring    ObjTempFileName;
    Ustring    ObjDefaultTempFileName;
    Ustring    ObjTexturesPath;
    Ustring    ObjDefaultTexturesPath;
    Ustring    ObjVrmlPath;
    Ustring    ObjDefaultVrmlPath;
    InputFile *ObjFile;

    DynArray<TGBPermPattern> ObjPermPattern;
    DynArray<TGBTempPattern> ObjTempPattern;

    TGBLib (const TGBLib&);
    const TGBLib& operator = (const TGBLib&);
};

#endif // !_GEOMETRY_H
