u3d.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  u3d.hpp : Ubit3D: tridimensional Box containers.
00004  *  Author: Matthieu Nottale
00005  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00006  *  (C) 1999-2006 / Eric Lecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00007  *
00008  * ***********************************************************************
00009  * COPYRIGHT NOTICE : 
00010  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00011  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00012  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00013  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00014  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00015  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00016  * ***********************************************************************
00017  * ==================================================== [(c)Elc] ======= *
00018  * ==================================================== ======== ======= */
00019 
00020 #ifndef _u3d_hpp_
00021 #define _u3d_hpp_
00022 //pragma ident  "@(#)u3d.hpp    ubit:05.05.00"
00023 
00024 #include <ubit/uprop.hpp>
00025 #include <ubit/ubox.hpp>
00026 #include <ubit/uctlmenu.hpp>
00027 #include <ubit/uevent.hpp>
00028 namespace ubit {
00029 
00030 /* ==================================================== ==== ======= */
00031   
00032 class UFrame3d: public UFrame {
00033 public:
00034   UBIT_ELEMENT_CLASS(UFrame3d, UFrame)
00035   
00036   UFrame3d(const UArgs& a = UArgs::none);
00037   friend UFrame3d& uframe3d(const UArgs& a = UArgs::none);
00038     
00039   static UStyle* createStyle();
00040 };
00041   
00042 /* ==================================================== ==== ======= */
00049 /* 3-Dimensional view, able to display UBox as planes in a 3D space.
00050 * The displayed view is a 60° wide perspective.
00051 * The position of the components is controlled with UPos3d properties.
00052 *
00053 * Event handling and drawing:
00054 * The mouse coordinates are transformed by the UView3d when passed to 
00055 * its children, so that the transformation  is transparent for them.
00056 * Similarly, when a child component is repainted, the drawing occurr
00057 * in it's local coordinate system.
00058 *
00059 * Position and movement:
00060 * The view itself can't be changed, but the position and orientation 
00061 * of it's child components is controlled by an UPos3d property.
00062 * Aditionnaly, a control menu can be associated with a UBox and a UPos3d
00063 * with the funciton UPos3dctlmenu.
00064 */
00065 class UPos3d : public UPos {
00066 public:
00067   UPos3d();
00068   UPos3d(float x, float y, float z);
00069   UPos3d(float x, float y, float z, float theta, float phi, float alpha);
00070 
00071   friend UPos3d& upos3d(float x, float y, float z);
00072   friend UPos3d& upos3d(float x, float y, float z,
00073                         float theta, float phi, float alpha);
00074   
00075   UPos3d& setSticky(bool sticky);
00077 
00078   //void set(const UPos& p)         {setImpl(p.x, p.y, true);}
00079   //void set(float _x, float _y)    {setImpl(_x, _y,true);}
00080   //void setX(float _x)             {setImpl(_x, y,true);}
00081   //void setY(float _y)             {setImpl(x, _y,true);}
00082   
00083   UPos3d& setXY(float _x, float _y) {setImpl(_x,_y,z, true); return *this;}
00084   UPos3d& setXYZ(float _x, float _y, float _z) {setImpl(_x,_y,_z,true); return *this;}
00085 
00086   UPos3d& setNormal(//float x, float y, float z,
00087                     float normal_x, float normal_y, float normal_z,
00088                     float alpha, bool update = true);
00089 
00090   UPos3d& setAngles(//float x, float y, float z,
00091                     float theta, float phi,
00092                     float alpha, bool update = true);
00093 
00094   UPos3d& rotate(float dtheta, float dphi, float dalpha);
00095   UPos3d& translate(float dx, float dy, float dz);
00096 
00097   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00098   
00099   virtual void setImpl(float _x, float _y, bool upd);
00100   virtual void setImpl(float _x, float _y, float _z, bool upd);
00101   virtual void update();
00102   
00103 private:
00104   friend class UView;
00105   friend class UFrameView3d;
00106   float z;
00107   float normal_x, normal_y, normal_z;
00108   float angle_alpha, angle_theta, angle_phi;
00109   float theta, phi, alpha;
00110   bool sticky;
00111   virtual void putProp(UContext*, UControl*);
00112 };
00113 
00114 /* ==================================================== ==== ======= */
00118 class UCtlmenu3d : public UCtlmenu {
00119 public:
00120   UCtlmenu3d(UPos3d&);
00121 };
00122 
00123 }
00124 #endif
00125 /* ==================================================== [TheEnd] ======= */
00126 /* ==================================================== ======== ======= */

Generated on Mon Jan 29 00:20:36 2007 for Ubit by  doxygen 1.4.7