// $Source: /usr/local/SimSoft/SoftShop/XGraph/Space/GeoObj.h,v $
// $Revision: 1.20 $
// $Author: baum $
// $Date: 2001/11/29 15:52:24 $
//
// Login name of the user who locked the revision
// $Locker:  $
// Tag name used to checkout the file
// $Name: Release-20 $
// State assigned to revision
// $State: Exp $
//
//
// $Log: GeoObj.h,v $
// Revision 1.20  2001/11/29 15:52:24  baum
// -In Kalender.cpp und Kalender.h Handsteuerung eingebaut
//

#ifndef _GEOOBJECT_H
#define _GEOOBJECT_H  1

#ifndef _PATTERN_H
class Pattern;
#endif

#include "Angle.h"
#include "HMatrx3D.h"
#include "Vec3D.h"
#include "DynArray.h"
#include "Location.h"
#include "Wrap.h"

#include "Parent.h"

#ifdef _GEOOBJECT_CPP
#  undef _impexp
#  define _impexp __declspec(dllexport)
#elif defined BUILD_XGRAPH_DLL
#  undef _impexp
#  define _impexp
#else
#  undef _impexp
#  define _impexp __declspec(dllimport)
#endif

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

//==================================================================
//      some definitions	
//	for class GeoObject
//==================================================================
class _impexp GeoObject;

//##ModelId=4030D77F019B
typedef GeoObject* (GeoObject::*SelFunc) ();

//==================================================================
//		Class-Header
//		for class GeoObject
//==================================================================

//##ModelId=4030D77F029F
class _impexp GeoObject : public Parent {
  public:
    // constructors
	//##ModelId=4030D77F02A1
    GeoObject ();

    // copy-constructor
	//##ModelId=4030D77F02A2
    GeoObject (const GeoObject&);

    // copy-constructor with mum
	//##ModelId=4030D77F02B0
    GeoObject (const GeoObject& c, const Parent* mum);

    // constructor with inserted Pattern
	//##ModelId=4030D77F02B3
    GeoObject (const Pattern&);

    // destructor
	//##ModelId=4030D77F02BF
    virtual ~GeoObject ();

    // delte whole sub-content of GeoObjects
    // but not hisself, so you have also to call the destructor
    // be carefull while you're not exactly know what you doing!!!
    // (because of extern references)
	//##ModelId=4030D77F02C1
    const GeoObject& deleteContents ();

    // forget old sub-contents and copy whole new
    // without upper-contents as  Location and Mum
	//##ModelId=4030D77F02C2
    const GeoObject& copyContents (const GeoObject& copyObj);

    // yielding information about a GeoObject
    // everything is relative to
    // GeoObjetc's parent
	//##ModelId=4030D77F02CE
    const Vec3D&    Pos () const;
	//##ModelId=4030D77F02D0
    const Vec3D&    X   () const;
	//##ModelId=4030D77F02D2
    const Vec3D&    Z   () const;
	//##ModelId=4030D77F02D4
    const Location& Loc () const;

	//##ModelId=4030D77F02DE
    const HMatrx3D& T   () const;
	//##ModelId=4030D77F02E0
    const HMatrx3D& Ti  () const;
	//##ModelId=4030D77F02E2
    const Parent   *Mum () const;

    // this is in local coordinates
	//##ModelId=4030D77F02E4
    Vec3D Center () const;
	//##ModelId=4030D77F02EF
    Vec3D Len (const Vec3D& localDir) const;
	//##ModelId=4030D77F02F2
    const WrapBox& Wrap ();

    // indicate that Wrap needs recalculation
	//##ModelId=4030D77F02F3
    virtual void invalidateWrap ();

    // return copy of Wrap transformed to parent coordinates
	//##ModelId=4030D77F02FE
    WrapBox WrapForParent ();

    // transforming Vectors + Locations between own + parent coordinates
	//##ModelId=4030D77F02FF
    Vec3D& PtToChild      (Vec3D& pt) const;
	//##ModelId=4030D77F0302
    Vec3D& PtToParent     (Vec3D& pt) const;

	//##ModelId=4030D77F030E
    Vec3D& DirToChild     (Vec3D& dir) const;
	//##ModelId=4030D77F0311
    Vec3D& DirToParent    (Vec3D& dir) const;

	//##ModelId=4030D77F031C
    Location& LocToChild  (Location& loc) const;
	//##ModelId=4030D77F031F
    Location& LocToParent (Location& loc) const;

    // transforming Vectors + Locations between own + space coordinates
    // !!! the given vector !!!
    // !!! (as parameter)   !!!
    // !!! will changed     !!!
	//##ModelId=4030D77F0322
    virtual Vec3D& PtToLocal     (Vec3D& pt) const;
	//##ModelId=4030D77F032D
    virtual Vec3D& PtToSpace     (Vec3D& pt) const;

	//##ModelId=4030D77F0330
    virtual Vec3D& DirToLocal    (Vec3D& dir) const;
	//##ModelId=4030D77F033C
    virtual Vec3D& DirToSpace    (Vec3D& dir) const;

	//##ModelId=4030D77F033F
    virtual Location& LocToLocal (Location& loc) const;
	//##ModelId=4030D77F0342
    virtual Location& LocToSpace (Location& loc) const;

    // modifying the Contents
    // insert and remove GeoObjects are in 'Parent'
	//##ModelId=4030D77F034D
    void insert (Pattern& child);
	//##ModelId=4030D77F034F
    void remove (Pattern& child);

	//##ModelId=4030D77F035B
    void setParent (Parent& parent, unsigned newWrap = 1);
	//##ModelId=4030D77F035E
    void clearParent (unsigned newWrap = 1);

    // scale with parameters
	//##ModelId=4030D77F036C
    void scale (const Vec3D& fak, unsigned newWrap = 1);      // Pos = way * Ti
	//##ModelId=4030D77F036F
    void setScale (const Vec3D& scaleVec, unsigned newWrap = 1);      // Pos = way * Ti

    // moving with parameters taken as local coordinates
	//##ModelId=4030D77F037C
    void move (const Vec3D& way, unsigned newWrap = 1);      // Pos = way * Ti

    // moving with parameters taken as parent coordinates
	//##ModelId=4030D77F037F
    void changePos (const Vec3D& way, unsigned newWrap = 1); // Pos += way;
	//##ModelId=4030D77F038C
    void setPos (const Vec3D& newpos, unsigned newWrap = 1); // Pos = newpos;

    // rotating with parameters taken as local coordinates
	//##ModelId=4030D77F038F
    void rotate (const Vec3D&, const Angle&, unsigned newWrap = 1);// by angle about axis
	//##ModelId=4030D77F039C
    void rotateXTo (const Vec3D&, unsigned newWrap = 1);  // first by Z, then by Y
	//##ModelId=4030D77F03A9
    void rotateZTo (const Vec3D&, unsigned newWrap = 1);  // by X only

    // rotating with parameters taken as parent coordinates
	//##ModelId=4030D77F03AC
    void setXTo (const Vec3D&, unsigned newWrap = 1);     // first by Z, then by Y
	//##ModelId=4030D77F03B9
    void setZTo (const Vec3D&, unsigned newWrap = 1);     // by X only

    // placing with parameters taken as parent coordinates
	//##ModelId=4030D77F03BC
    void setLocTo (const Location&, unsigned newWrap = 1);// call setPos, setXTo, setZTo

    // getting DynArray of all included Patterns
	//##ModelId=4030D77F03C8
    const DynArray<Pattern>& PattArray () const;

    // methods for Selection
	//##ModelId=4030D77F03CA
    void setSelectionToNothing ();
	//##ModelId=4030D77F03CB
    void setSelectionToMe      ();
	//##ModelId=4030D77F03CC
    void setSelectionToMum     ();

	//##ModelId=4030D77F03D8
    virtual GeoObject *SelectionRequest () const;

  protected:

  private:
    // assignment operator declared, but not defined
	//##ModelId=4030D77F03DA
    GeoObject& operator = (const GeoObject&);

    // rebuild MT & MTi
	//##ModelId=4030D77F03DC
    void recalc ();

	//##ModelId=4030D7800000
    void calcWrap ();

    // data members
	//##ModelId=4030D7800002
    WrapBox  ObjWrapbox;
	//##ModelId=4030D7800010
    unsigned ObjWrapOK;
	//##ModelId=4030D7800015
    Location ObjLctn;
	//##ModelId=4030D7800020
    Vec3D    ObjScaleVec;
	//##ModelId=4030D7800025
    HMatrx3D ObjMT;
	//##ModelId=4030D7800031
    HMatrx3D ObjMTi;

	//##ModelId=4030D780003F
    Parent  *ObjMum;
	//##ModelId=4030D7800050
    DynArray<Pattern> ObjPBabes;

	//##ModelId=4030D780005E
    SelFunc ObjSelFunc;

    // the standard selection CB's
	//##ModelId=4030D7800062
    GeoObject* selToNothing ();
	//##ModelId=4030D780006D
    GeoObject* selToMe      ();
	//##ModelId=4030D780006E
    GeoObject* selToMum     ();

  // friends

};	// class GeoObject

#endif // !_GEOOBJECT_H


