FXGLShape.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                   O p e n G L   S h a p e   O b j e c t                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXGLShape.h,v 1.25 2006/01/22 17:58:03 fox Exp $                         *
00023 ********************************************************************************/
00024 #ifndef FX_DISABLEGL
00025 
00026 #if FX_GRAPHINGMODULE
00027 
00028 #ifndef FXGLSHAPE_H
00029 #define FXGLSHAPE_H
00030 
00031 #ifndef FXGLOBJECT_H
00032 #include "FXGLObject.h"
00033 #endif
00034 
00035 namespace FX {
00036 
00037 
00038 class FXGLViewer;
00039 class FXGLObject;
00040 
00041 
00042 // Shape drawing options
00043 enum {
00044   SURFACE_SINGLESIDED   = 0,              // Single-sided [both sides same]
00045   SURFACE_DUALSIDED     = 0x00000001,     // Dual-sided surface
00046   SHADING_NONE          = 0,              // No light source
00047   SHADING_SMOOTH        = 0x00000002,     // Smooth shaded
00048   SHADING_FLAT          = 0x00000004,     // Flag shaded
00049   FACECULLING_OFF       = 0,              // No face culling
00050   FACECULLING_ON        = 0x00000008,     // Cull backward facing surfaces
00051   STYLE_SURFACE         = 0x00000010,     // Draw filled surfaces
00052   STYLE_WIREFRAME       = 0x00000020,     // Draw wire frame
00053   STYLE_POINTS          = 0x00000040,     // Draw as points
00054   STYLE_BOUNDBOX        = 0x00000080      // Draw bounding box
00055   };
00056 
00057 
00058 
00060 class FXGRAPHINGMODULEAPI FXGLShape : public FXGLObject {
00061   FXDECLARE_ABSTRACT(FXGLShape)
00062 protected:
00063   FXVec3f       position;             // Middle of the Bounding Box
00064   FXMaterial    material[2];          // Front and back material properties
00065   FXRangef      range;                // Range box
00066   FXuint    options;              // Drawing options
00067   FXString  tip;
00068 protected:
00069   FXGLShape();
00070   virtual void drawshape(FXGLViewer*){}  // To be overloaded by derived class
00071   void drawbox();
00072   void drawhandles();
00073 public:
00074   long onDNDDrop(FXObject*,FXSelector,void*);
00075   long onDNDMotion(FXObject*,FXSelector,void*);
00076   long onQueryTip(FXObject*,FXSelector,void*);
00077   long onCmdShadeOff(FXObject*,FXSelector,void*);
00078   long onUpdShadeOff(FXObject*,FXSelector,void*);
00079   long onCmdShadeOn(FXObject*,FXSelector,void*);
00080   long onUpdShadeOn(FXObject*,FXSelector,void*);
00081   long onCmdShadeSmooth(FXObject*,FXSelector,void*);
00082   long onUpdShadeSmooth(FXObject*,FXSelector,void*);
00083   long onCmdFrontMaterial(FXObject*,FXSelector,void*);
00084   long onUpdFrontMaterial(FXObject*,FXSelector,void*);
00085   long onCmdBackMaterial(FXObject*,FXSelector,void*);
00086   long onUpdBackMaterial(FXObject*,FXSelector,void*);
00087   long onCmdDrawingStyle(FXObject*,FXSelector,void*);
00088   long onUpdDrawingStyle(FXObject*,FXSelector,void*);
00089 public:
00090   enum {
00091     ID_SHADEOFF=FXGLObject::ID_LAST,
00092     ID_SHADEON,
00093     ID_SHADESMOOTH,
00094     ID_TOGGLE_SIDED,
00095     ID_TOGGLE_CULLING,
00096     ID_STYLE_POINTS,
00097     ID_STYLE_WIREFRAME,
00098     ID_STYLE_SURFACE,
00099     ID_STYLE_BOUNDINGBOX,
00100     ID_FRONT_MATERIAL,
00101     ID_BACK_MATERIAL,
00102     ID_LAST
00103     };
00104 public:
00105 
00107   FXGLShape(FXfloat x,FXfloat y,FXfloat z,FXuint opts);
00108 
00110   FXGLShape(FXfloat x,FXfloat y,FXfloat z,FXuint opts,const FXMaterial& front,const FXMaterial& back);
00111 
00113   FXGLShape(const FXGLShape& orig);
00114 
00116   virtual void bounds(FXRangef& box);
00117 
00119   virtual void draw(FXGLViewer* viewer);
00120 
00122   virtual void hit(FXGLViewer* viewer);
00123 
00125   virtual FXGLObject* copy();
00126 
00128   virtual FXbool canDrag() const;
00129 
00131   virtual FXbool canDelete() const;
00132 
00134   virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty);
00135 
00137   FXuint getOptions() const { return options; }
00138 
00140   void setOptions(FXuint opts) { options=opts; }
00141 
00143   void setTipText(const FXString& text){ tip=text; }
00144 
00146   const FXString& getTipText() const { return tip; }
00147 
00149   void setMaterial(FXint side,const FXMaterial &mtl);
00150 
00152   void getMaterial(FXint side,FXMaterial &mtl) const;
00153 
00155   const FXVec3f &getPosition() const { return position; }
00156 
00158   void setPosition(const FXVec3f &pos);
00159 
00161   virtual void save(FXStream& store) const;
00162 
00164   virtual void load(FXStream& store);
00165   };
00166 
00167 }
00168 
00169 #endif
00170 #endif
00171 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:22 2009 for TnFOX by doxygen v1.4.7