![]() |
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,2002 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.14 2002/01/18 22:42:53 jeroen Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXGLSHAPE_H 00025 #define FXGLSHAPE_H 00026 00027 #ifndef FXGLOBJECT_H 00028 #include "FXGLObject.h" 00029 #endif 00030 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 FXVec position; // Middle of the Bounding Box 00059 FXMaterial material[2]; // Front and back material properties 00060 FXRange 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(FXRange& 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 FXString getTipText() const { return tip; } 00136 00137 /// Set the material for specified side (where side = 0 or 1) 00138 void setMaterial(FXint side,const FXMaterial &mtl); 00139 00140 /// Get the material for specified side (where side = 0 or 1) 00141 void getMaterial(FXint side,FXMaterial &mtl) const; 00142 00143 /// Save shape to a stream 00144 virtual void save(FXStream& store) const; 00145 00146 /// Load shape from a stream 00147 virtual void load(FXStream& store); 00148 }; 00149 00150 #endif 00151