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

FXGLObject.h

00001 /******************************************************************************** 00002 * * 00003 * O p e n G L O b j e c t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1998,2005 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: FXGLObject.h,v 1.26 2005/01/16 16:06:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXGLOBJECT_H 00025 #define FXGLOBJECT_H 00026 00027 #ifndef FXOBJECT_H 00028 #include "FXObject.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 class FXGLViewer; 00035 class FXGLObject; 00036 00037 00038 // List of objects 00039 typedef FXObjectListOf<FXGLObject> FXGLObjectList; 00040 00041 /// Basic OpenGL object 00042 class FXAPI FXGLObject : public FXObject { 00043 FXDECLARE(FXGLObject) 00044 public: 00045 enum { 00046 ID_LAST=10000 // Leaving ample room for FXGLViewer subclasses 00047 }; 00048 public: 00049 00050 /// Constructors 00051 FXGLObject(){} 00052 00053 /// Copy constructor 00054 FXGLObject(const FXGLObject& orig):FXObject(orig){} 00055 00056 /// Called by the viewer to get bounds for this object 00057 virtual void bounds(FXRangef& box); 00058 00059 /// Draw this object in a viewer 00060 virtual void draw(FXGLViewer* viewer); 00061 00062 /// Draw this object for hit-testing purposes 00063 virtual void hit(FXGLViewer* viewer); 00064 00065 /// Copy this object 00066 virtual FXGLObject* copy(); 00067 00068 /// Identify sub-object given path 00069 virtual FXGLObject* identify(FXuint* path); 00070 00071 /// Return true if this object can be dragged around 00072 virtual FXbool canDrag() const; 00073 00074 /// Return true if this object can be deleted from the scene 00075 virtual FXbool canDelete() const; 00076 00077 /// Drag this object from one position to another 00078 virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty); 00079 00080 /// Destructor 00081 virtual ~FXGLObject(){} 00082 }; 00083 00084 00085 // Suppress warning about FXGLGroup::list not being exported 00086 #ifdef _MSC_VER 00087 #if _MSC_VER >= 1200 00088 #pragma warning( push ) 00089 #endif 00090 #pragma warning( disable : 4251 ) 00091 #endif 00092 00093 00094 /// Group object 00095 class FXAPI FXGLGroup : public FXGLObject { 00096 FXDECLARE(FXGLGroup) 00097 protected: 00098 FXGLObjectList list; // List of all objects 00099 public: 00100 00101 /// Constructor 00102 FXGLGroup(){ } 00103 00104 /// Copy constructor 00105 FXGLGroup(const FXGLGroup& orig):FXGLObject(orig),list(orig.list){ } 00106 00107 /// Return list of childern 00108 FXGLObjectList& getList(){ return list; } 00109 00110 /// Return bounding box 00111 virtual void bounds(FXRangef& box); 00112 00113 /// Draw into viewer 00114 virtual void draw(FXGLViewer* viewer); 00115 00116 /// Hit in viewer 00117 virtual void hit(FXGLViewer* viewer); 00118 00119 /// Copy this object 00120 virtual FXGLObject* copy(); 00121 00122 /// Identify object by means of path 00123 virtual FXGLObject* identify(FXuint* path); 00124 00125 /// Return TRUE if group can be dragged 00126 virtual FXbool canDrag() const; 00127 00128 /// Drag group object 00129 virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty); 00130 00131 /// Return number of children 00132 FXint no() const { return list.no(); } 00133 00134 /// Child at position 00135 FXGLObject* child(FXint pos) const { return list[pos]; } 00136 00137 /// Insert child object at given position 00138 void insert(FXint pos,FXGLObject* obj){ list.insert(pos,obj); } 00139 00140 /// Prepend child object 00141 void prepend(FXGLObject* obj){ list.prepend(obj); } 00142 00143 /// Append child object 00144 void append(FXGLObject* obj){ list.append(obj); } 00145 00146 /// Replace child object 00147 void replace(FXint pos,FXGLObject* obj){ list.replace(pos,obj); } 00148 00149 /// Remove child object 00150 void remove(FXGLObject* obj){ list.remove(obj); } 00151 00152 /// Remove child object at given position 00153 void remove(FXint pos){ list.remove(pos); } 00154 00155 /// Remove all children 00156 void clear(){ list.clear(); } 00157 00158 /// Stream save and load 00159 virtual void save(FXStream& store) const; 00160 virtual void load(FXStream& store); 00161 00162 /// Destructor 00163 virtual ~FXGLGroup(); 00164 }; 00165 00166 00167 // Restore previous warning levels 00168 #ifdef _MSC_VER 00169 #if _MSC_VER >= 1200 00170 #pragma warning( pop ) 00171 #endif 00172 #endif 00173 00174 00175 /// OpenGL Point Object 00176 class FXAPI FXGLPoint : public FXGLObject { 00177 FXDECLARE(FXGLPoint) 00178 public: 00179 FXVec3f pos; 00180 public: 00181 00182 /// Default constructor 00183 FXGLPoint(); 00184 00185 /// Copy constructor 00186 FXGLPoint(const FXGLPoint& orig); 00187 00188 /// Construct with specified coordinates 00189 FXGLPoint(FXfloat x,FXfloat y,FXfloat z); 00190 00191 /// Copy this object 00192 virtual FXGLObject* copy(); 00193 00194 /// Called by the viewer to get bounds for this object 00195 virtual void bounds(FXRangef& box); 00196 00197 /// Draw this object in a viewer 00198 virtual void draw(FXGLViewer* viewer); 00199 00200 /// Draw this object for hit-testing purposes 00201 virtual void hit(FXGLViewer* viewer); 00202 00203 /// Save to a stream 00204 virtual void save(FXStream& store) const; 00205 00206 /// Load from a stream 00207 virtual void load(FXStream& store); 00208 }; 00209 00210 00211 /// OpenGL Line Object 00212 class FXAPI FXGLLine : public FXGLObject { 00213 FXDECLARE(FXGLLine) 00214 public: 00215 FXGLPoint fm,to; 00216 public: 00217 00218 /// Default constructor 00219 FXGLLine(); 00220 00221 /// Copy constructor 00222 FXGLLine(const FXGLLine& orig); 00223 00224 /// Construct with specified endpoints 00225 FXGLLine(FXfloat fx,FXfloat fy,FXfloat fz,FXfloat tx,FXfloat ty,FXfloat tz); 00226 00227 /// Called by the viewer to get bounds for this object 00228 virtual void bounds(FXRangef& box); 00229 00230 /// Draw this object in a viewer 00231 virtual void draw(FXGLViewer* viewer); 00232 00233 /// Copy this object 00234 virtual FXGLObject* copy(); 00235 00236 /// Draw this object for hit-testing purposes 00237 virtual void hit(FXGLViewer* viewer); 00238 00239 /// Save to a stream 00240 virtual void save(FXStream& store) const; 00241 00242 /// Load from a stream 00243 virtual void load(FXStream& store); 00244 }; 00245 00246 } 00247 00248 #endif 00249

Copyright © 1997-2005 Jeroen van der Zijp