![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
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,2009 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 * $Id: FXGLShape.h,v 1.32 2009/01/06 13:07:24 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXGLSHAPE_H 00024 #define FXGLSHAPE_H 00025 00026 #ifndef FXGLOBJECT_H 00027 #include "FXGLObject.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 class FXGLViewer; 00034 class FXGLObject; 00035 00036 00037 // Shape drawing options 00038 enum { 00039 SURFACE_SINGLESIDED = 0, // Single-sided [both sides same] 00040 SURFACE_DUALSIDED = 0x00000001, // Dual-sided surface 00041 SHADING_NONE = 0, // No light source 00042 SHADING_SMOOTH = 0x00000002, // Smooth shaded 00043 SHADING_FLAT = 0x00000004, // Flag shaded 00044 FACECULLING_OFF = 0, // No face culling 00045 FACECULLING_ON = 0x00000008, // Cull backward facing surfaces 00046 STYLE_SURFACE = 0x00000010, // Draw filled surfaces 00047 STYLE_WIREFRAME = 0x00000020, // Draw wire frame 00048 STYLE_POINTS = 0x00000040, // Draw as points 00049 STYLE_BOUNDBOX = 0x00000080 // Draw bounding box 00050 }; 00051 00052 00053 00054 /// OpenGL Shape Object 00055 class FXAPI FXGLShape : public FXGLObject { 00056 FXDECLARE_ABSTRACT(FXGLShape) 00057 protected: 00058 FXVec3f position; // Middle of the Bounding Box 00059 FXMaterial material[2]; // Front and back material properties 00060 FXRangef range; // Range box 00061 FXuint options; // Drawing options 00062 FXString tip; 00063 protected: 00064 FXGLShape(); 00065 virtual void drawshape(FXGLViewer*){} // To be overloaded by derived class 00066 void drawbox(); 00067 void drawhandles(); 00068 public: 00069 long onDNDDrop(FXObject*,FXSelector,void*); 00070 long onDNDMotion(FXObject*,FXSelector,void*); 00071 long onQueryTip(FXObject*,FXSelector,void*); 00072 long onCmdShadeOff(FXObject*,FXSelector,void*); 00073 long onUpdShadeOff(FXObject*,FXSelector,void*); 00074 long onCmdShadeOn(FXObject*,FXSelector,void*); 00075 long onUpdShadeOn(FXObject*,FXSelector,void*); 00076 long onCmdShadeSmooth(FXObject*,FXSelector,void*); 00077 long onUpdShadeSmooth(FXObject*,FXSelector,void*); 00078 long onCmdFrontMaterial(FXObject*,FXSelector,void*); 00079 long onUpdFrontMaterial(FXObject*,FXSelector,void*); 00080 long onCmdBackMaterial(FXObject*,FXSelector,void*); 00081 long onUpdBackMaterial(FXObject*,FXSelector,void*); 00082 long onCmdDrawingStyle(FXObject*,FXSelector,void*); 00083 long onUpdDrawingStyle(FXObject*,FXSelector,void*); 00084 public: 00085 enum { 00086 ID_SHADEOFF=FXGLObject::ID_LAST, 00087 ID_SHADEON, 00088 ID_SHADESMOOTH, 00089 ID_TOGGLE_SIDED, 00090 ID_TOGGLE_CULLING, 00091 ID_STYLE_POINTS, 00092 ID_STYLE_WIREFRAME, 00093 ID_STYLE_SURFACE, 00094 ID_STYLE_BOUNDINGBOX, 00095 ID_FRONT_MATERIAL, 00096 ID_BACK_MATERIAL, 00097 ID_LAST 00098 }; 00099 public: 00100 00101 /// Construct with specified origin and options 00102 FXGLShape(FXfloat x,FXfloat y,FXfloat z,FXuint opts); 00103 00104 /// Construct with specified origin, options and front and back materials 00105 FXGLShape(FXfloat x,FXfloat y,FXfloat z,FXuint opts,const FXMaterial& front,const FXMaterial& back); 00106 00107 /// Copy constructor 00108 FXGLShape(const FXGLShape& orig); 00109 00110 /// Called by the viewer to get bounds for this object 00111 virtual void bounds(FXRangef& box); 00112 00113 /// Draw this object in a viewer 00114 virtual void draw(FXGLViewer* viewer); 00115 00116 /// Draw this object for hit-testing purposes 00117 virtual void hit(FXGLViewer* viewer); 00118 00119 /// Copy this object 00120 virtual FXGLObject* copy(); 00121 00122 /// Return true if this object can be dragged around 00123 virtual FXbool canDrag() const; 00124 00125 /// Return true if this object can be deleted from the scene 00126 virtual FXbool canDelete() const; 00127 00128 /// Drag this object from one position to another 00129 virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty); 00130 00131 /// Set the tool tip message for this object 00132 void setTipText(const FXString& text){ tip=text; } 00133 00134 /// Get the tool tip message for this object 00135 const FXString& getTipText() const { return tip; } 00136 00137 /// Set the position 00138 virtual void setPosition(const FXVec3f& pos); 00139 00140 /// Get the position 00141 const FXVec3f& getPosition() const { return position; } 00142 00143 /// Set the material for specified side (where side = 0 or 1) 00144 void setMaterial(FXint side,const FXMaterial &mtl); 00145 00146 /// Get the material for specified side (where side = 0 or 1) 00147 void getMaterial(FXint side,FXMaterial &mtl) const; 00148 00149 /// Save shape to a stream 00150 virtual void save(FXStream& store) const; 00151 00152 /// Load shape from a stream 00153 virtual void load(FXStream& store); 00154 }; 00155 00156 } 00157 00158 #endif 00159
![]() |