Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

/home/jeroen/FOX/fox/fox-1.7.33/include/FXGLShape.h
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,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (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                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXGLSHAPE_H
00022 #define FXGLSHAPE_H
00023 
00024 #ifndef FXGLOBJECT_H
00025 #include "FXGLObject.h"
00026 #endif
00027 
00028 namespace FX {
00029 
00030 
00031 class FXGLViewer;
00032 class FXGLObject;
00033 
00034 
00035 // Shape drawing options
00036 enum {
00037   SURFACE_SINGLESIDED   = 0,              // Single-sided [both sides same]
00038   SURFACE_DUALSIDED     = 0x00000001,     // Dual-sided surface
00039   SHADING_NONE          = 0,              // No light source
00040   SHADING_SMOOTH        = 0x00000002,     // Smooth shaded
00041   SHADING_FLAT          = 0x00000004,     // Flag shaded
00042   FACECULLING_OFF       = 0,              // No face culling
00043   FACECULLING_ON        = 0x00000008,     // Cull backward facing surfaces
00044   STYLE_SURFACE         = 0x00000010,     // Draw filled surfaces
00045   STYLE_WIREFRAME       = 0x00000020,     // Draw wire frame
00046   STYLE_POINTS          = 0x00000040,     // Draw as points
00047   STYLE_BOUNDBOX        = 0x00000080      // Draw bounding box
00048   };
00049 
00050 
00051 
00053 class FXAPI FXGLShape : public FXGLObject {
00054   FXDECLARE_ABSTRACT(FXGLShape)
00055 protected:
00056   FXVec3f       position;             // Middle of the Bounding Box
00057   FXMaterial    material[2];          // Front and back material properties
00058   FXRangef      range;                // Range box
00059   FXuint  options;              // Drawing options
00060   FXString  tip;
00061 protected:
00062   FXGLShape();
00063   virtual void drawshape(FXGLViewer*){}  // To be overloaded by derived class
00064   void drawbox();
00065   void drawhandles();
00066 public:
00067   long onDNDDrop(FXObject*,FXSelector,void*);
00068   long onDNDMotion(FXObject*,FXSelector,void*);
00069   long onQueryTip(FXObject*,FXSelector,void*);
00070   long onCmdShadeOff(FXObject*,FXSelector,void*);
00071   long onUpdShadeOff(FXObject*,FXSelector,void*);
00072   long onCmdShadeOn(FXObject*,FXSelector,void*);
00073   long onUpdShadeOn(FXObject*,FXSelector,void*);
00074   long onCmdShadeSmooth(FXObject*,FXSelector,void*);
00075   long onUpdShadeSmooth(FXObject*,FXSelector,void*);
00076   long onCmdFrontMaterial(FXObject*,FXSelector,void*);
00077   long onUpdFrontMaterial(FXObject*,FXSelector,void*);
00078   long onCmdBackMaterial(FXObject*,FXSelector,void*);
00079   long onUpdBackMaterial(FXObject*,FXSelector,void*);
00080   long onCmdDrawingStyle(FXObject*,FXSelector,void*);
00081   long onUpdDrawingStyle(FXObject*,FXSelector,void*);
00082 public:
00083   enum {
00084     ID_SHADEOFF=FXGLObject::ID_LAST,
00085     ID_SHADEON,
00086     ID_SHADESMOOTH,
00087     ID_TOGGLE_SIDED,
00088     ID_TOGGLE_CULLING,
00089     ID_STYLE_POINTS,
00090     ID_STYLE_WIREFRAME,
00091     ID_STYLE_SURFACE,
00092     ID_STYLE_BOUNDINGBOX,
00093     ID_FRONT_MATERIAL,
00094     ID_BACK_MATERIAL,
00095     ID_LAST
00096     };
00097 public:
00098 
00100   FXGLShape(FXfloat x,FXfloat y,FXfloat z,FXuint opts);
00101 
00103   FXGLShape(FXfloat x,FXfloat y,FXfloat z,FXuint opts,const FXMaterial& front,const FXMaterial& back);
00104 
00106   FXGLShape(const FXGLShape& orig);
00107 
00109   virtual void bounds(FXRangef& box);
00110 
00112   virtual void draw(FXGLViewer* viewer);
00113 
00115   virtual void hit(FXGLViewer* viewer);
00116 
00118   virtual FXGLObject* copy();
00119 
00121   virtual FXbool canDrag() const;
00122 
00124   virtual FXbool canDelete() const;
00125 
00127   virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty);
00128 
00130   void setTipText(const FXString& text){ tip=text; }
00131 
00133   const FXString& getTipText() const { return tip; }
00134 
00136   virtual void setPosition(const FXVec3f& pos);
00137 
00139   const FXVec3f& getPosition() const { return position; }
00140 
00142   void setMaterial(FXint side,const FXMaterial &mtl);
00143 
00145   void getMaterial(FXint side,FXMaterial &mtl) const;
00146 
00148   virtual void save(FXStream& store) const;
00149 
00151   virtual void load(FXStream& store);
00152   };
00153 
00154 }
00155 
00156 #endif
00157 

Copyright © 1997-2011 Jeroen van der Zijp