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

#ifndef _GTSTGB_H
#define _GTSTGB_H     1

#include "List.h"
#include "gtsglob.h"
#include "gtsgraf.h"
#include "gtsbst.h"

//==================================================================
//		Definition
//		for abstract baseclass BstInfo
//==================================================================

class BstInfo  {
  protected:
    BstInfo  ();
    BstInfo  (const BstInfo& copy);
    virtual ~BstInfo ();

    void operator = (const BstInfo& copy);

    virtual void read  (InputFile& fin, int ausgabe, int info) = 0;
    virtual void write (ostream& ostrm) const = 0;

    int       ObjAusgabeArt;
    int       ObjInfoArt;
    double    ObjGroesse;
    Ustring   ObjText;

};  // ENDE BstInfo

//==================================================================
//		Definition
//		for class BstTextInfo
//==================================================================

class BstTextInfo : public BstInfo {
  public:
    BstTextInfo  ();
    BstTextInfo  (const BstTextInfo& copy);
    ~BstTextInfo ();

    void operator = (const BstTextInfo& copy);

    virtual void read  (InputFile& fin, int ausgabe = 0, int info = 7);
    virtual void write (ostream& ostrm) const;

    void setText (Ustring newText);

    void show  (GeoObject& parent);

  private:
    GeoObject ObjGeometry;
    static Attribute* ClassTextAttribute;
};  // ENDE BstTextInfo

//==================================================================
//		Definition
//		for class BstVariante
//==================================================================

class BstVariante {
  public:
    BstVariante  (const unsigned typ, const unsigned variante);
    ~BstVariante ();

    // NOT und VOID*-Operatoren
    bool operator ! () const;
    operator void*  () const;

    void read (InputFile& fin);

    void setName (const char *name);
    void setName (const Ustring& name);

    unsigned getTyp      () const;
    unsigned getVariante () const;

    const Ustring&     getName    () const;
    const BstTextInfo& BstNrInfo  () const;

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

    typBSPBasis *BSP       () const;
    typBTPBasis *BTP       () const;

    const DynArray<Vec3D>&   PalPositions  () const;

  private:
    Ustring     ObjName;
    unsigned    ObjTyp;
    unsigned    ObjVariante;
    Angle       ObjFlusswinkel;
    BstTextInfo ObjBstNrInfo;

    DynArray<GeoObject> ObjGeometries;

    typBSPBasis *ObjBSPBasis;
    typBTPBasis *ObjBTPBasis;

    DynArray<Vec3D>   ObjPalPositions;

    // both declared, but not defined
    BstVariante (const BstVariante& bv);
    const BstVariante& operator = (const BstVariante& bv);

    void readKontur       (InputFile& fin);
    void readPositions    (InputFile& fin);
    void readBstNr        (InputFile& fin);
    void initBTPParameter (const BstVariante *zTGB);
    void initBSPParameter ();
    void showArrow        ();

    static unsigned    ClassRefCounter;
    static Attribute*  ClassPermAttribute;
    static Attribute*  ClassArrowAttribute;

    static Pattern*    ClassArrowTipPattern;
    static Pattern*    ClassArrowStickPattern;

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

//==================================================================
//		Definition
//		for class BstBasis
//==================================================================

class BstBasis {
  public:
    BstBasis  (unsigned typ);
    ~BstBasis ();

    void read (InputFile& fin, unsigned beginSatz, unsigned variantSatz);

    void append (const BstVariante& newVariante);

    BstVariante* findBstVariante   (const unsigned variante) const;
    BstVariante* findBstUeberIndex (const unsigned index) const;

    void AusgabeInhaltsverzeichnis ();

    void setName (const char *name);
    void setName (const Ustring& name);

    unsigned       getTyp  () const;
    const Ustring& getName () const;

    Ustring getVariantNamen   () const;

  private:
    Ustring  ObjName;
    unsigned ObjTyp;

    List<BstVariante> ObjVariantListe;

    // both declared, but not defined
    BstBasis (const BstBasis& bv);
    const BstBasis& operator = (const BstBasis& bv);
};  // ENDE BstBasis

//==================================================================
//		Definition
//		for class Bibliothek
//==================================================================

class typBibliothek {
   public:
      typBibliothek   (Ustring name);
      ~typBibliothek  ();
      void Oeffnen    ();
      void Schliessen ();
      void erzeugeInhaltsverzeichnis (unsigned Btyp, unsigned Vtyp);
      void AusgabeInhaltsverzeichnis ();
      void leseBasisNamen ();
      BstVariante *SucheBaustein (unsigned btyp, unsigned vtyp);
      BstVariante *SucheBausteinUeberIndex (unsigned bindex, unsigned vindex);
      LCursor<BstBasis> BsttypInListe (unsigned Btyp);
      void VarianteInBstBasisListe (BstBasis &zhilfe, unsigned Btyp, unsigned Vtyp);
      void EndeGliedern (BstBasis &Z) { BstBasisListe.append(Z); };
      BstBasis *Letztes () { return BstBasisListe.Last(); };
      bool LeseBaustein (unsigned btyp, unsigned vtyp);

      unsigned getTypOffset    () const;
      unsigned getTypMulti     () const;
      unsigned getVarMulti     () const;
      unsigned getSegOffset    () const;
      unsigned getNumPosOffset () const;
      unsigned getInfo1Offset  () const;
      unsigned getTextOffset   () const;
      void     setTexturesPath (Ustring texturepath);
      void     setVrmlPath     (Ustring vrmlpath);
      Ustring  getTexturesPath () const;
      Ustring  getVrmlPath     () const;
      Ustring  BausteinNamen   ();
      Ustring  VariantNamenUeberIndex      (unsigned index);
      Ustring VariantNamenUeberBausteintyp (unsigned btyp);

   protected:
      void LeseInhaltverzeichnis ();
      void leseOffset (void);
      List<BstBasis> BstBasisListe;
      Ustring   DatName;
      Ustring   ObjTexturesPath;
      Ustring   ObjVrmlPath;
      unsigned  ObjTypOffset;
      unsigned  ObjTypMulti;
      unsigned  ObjVarMulti;
      unsigned  ObjSegOffset;
      unsigned  ObjNumPosOffset;
      unsigned  ObjSymPosOffset;
      unsigned  ObjInfo1Offset;
      unsigned  ObjInfo2Offset;
      unsigned  ObjInfo3Offset;
      unsigned  ObjTextOffset;
};  // ENDE typTgbBibliothek

#endif /* _GTSTGB_H */
