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