![]() |
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,2006 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.28.2.3 2006/11/17 16:02:31 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 /// Basic OpenGL object 00039 class FXAPI FXGLObject : public FXObject { 00040 FXDECLARE(FXGLObject) 00041 public: 00042 enum { 00043 ID_LAST=10000 // Leaving ample room for FXGLViewer subclasses 00044 }; 00045 public: 00046 00047 /// Constructors 00048 FXGLObject(){} 00049 00050 /// Copy constructor 00051 FXGLObject(const FXGLObject& orig):FXObject(orig){} 00052 00053 /// Called by the viewer to get bounds for this object 00054 virtual void bounds(FXRangef& box); 00055 00056 /// Draw this object in a viewer 00057 virtual void draw(FXGLViewer* viewer); 00058 00059 /// Draw this object for hit-testing purposes 00060 virtual void hit(FXGLViewer* viewer); 00061 00062 /// Copy this object 00063 virtual FXGLObject* copy(); 00064 00065 /// Identify sub-object given path 00066 virtual FXGLObject* identify(FXuint* path); 00067 00068 /// Return true if this object can be dragged around 00069 virtual FXbool canDrag() const; 00070 00071 /// Return true if this object can be deleted from the scene 00072 virtual FXbool canDelete() const; 00073 00074 /// Drag this object from one position to another 00075 virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty); 00076 00077 /// Destructor 00078 virtual ~FXGLObject(){} 00079 }; 00080 00081 00082 /// List of GL objects 00083 typedef FXObjectListOf<FXGLObject> FXGLObjectList; 00084 00085 00086 /// Group object 00087 class FXAPI FXGLGroup : public FXGLObject { 00088 FXDECLARE(FXGLGroup) 00089 protected: 00090 FXGLObjectList list; // List of all objects 00091 public: 00092 00093 /// Constructor 00094 FXGLGroup(){ } 00095 00096 /// Copy constructor 00097 FXGLGroup(const FXGLGroup& orig):FXGLObject(orig),list(orig.list){ } 00098 00099 /// Return list of childern 00100 FXGLObjectList& getList(){ return list; } 00101 00102 /// Return bounding box 00103 virtual void bounds(FXRangef& box); 00104 00105 /// Draw into viewer 00106 virtual void draw(FXGLViewer* viewer); 00107 00108 /// Hit in viewer 00109 virtual void hit(FXGLViewer* viewer); 00110 00111 /// Copy this object 00112 virtual FXGLObject* copy(); 00113 00114 /// Identify object by means of path 00115 virtual FXGLObject* identify(FXuint* path); 00116 00117 /// Return TRUE if group can be dragged 00118 virtual FXbool canDrag() const; 00119 00120 /// Drag group object 00121 virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty); 00122 00123 /// Return number of children 00124 FXint no() const { return list.no(); } 00125 00126 /// Child at position 00127 FXGLObject* child(FXint pos) const { return list[pos]; } 00128 00129 /// Insert child object at given position 00130 void insert(FXint pos,FXGLObject* obj){ list.insert(pos,obj); } 00131 00132 /// Prepend child object 00133 void prepend(FXGLObject* obj){ list.prepend(obj); } 00134 00135 /// Append child object 00136 void append(FXGLObject* obj){ list.append(obj); } 00137 00138 /// Replace child object 00139 void replace(FXint pos,FXGLObject* obj){ list.replace(pos,obj); } 00140 00141 /// Remove child object 00142 void remove(FXGLObject* obj){ list.remove(obj); } 00143 00144 /// Remove child object at given position 00145 void erase(FXint pos){ list.erase(pos); } 00146 00147 /// Remove all children 00148 void clear(){ list.clear(); } 00149 00150 /// Stream save and load 00151 virtual void save(FXStream& store) const; 00152 virtual void load(FXStream& store); 00153 00154 /// Destructor 00155 virtual ~FXGLGroup(); 00156 }; 00157 00158 00159 /// OpenGL Point Object 00160 class FXAPI FXGLPoint : public FXGLObject { 00161 FXDECLARE(FXGLPoint) 00162 public: 00163 FXVec3f pos; 00164 public: 00165 00166 /// Default constructor 00167 FXGLPoint(); 00168 00169 /// Copy constructor 00170 FXGLPoint(const FXGLPoint& orig); 00171 00172 /// Construct with specified coordinates 00173 FXGLPoint(FXfloat x,FXfloat y,FXfloat z); 00174 00175 /// Copy this object 00176 virtual FXGLObject* copy(); 00177 00178 /// Called by the viewer to get bounds for this object 00179 virtual void bounds(FXRangef& box); 00180 00181 /// Draw this object in a viewer 00182 virtual void draw(FXGLViewer* viewer); 00183 00184 /// Draw this object for hit-testing purposes 00185 virtual void hit(FXGLViewer* viewer); 00186 00187 /// Save to a stream 00188 virtual void save(FXStream& store) const; 00189 00190 /// Load from a stream 00191 virtual void load(FXStream& store); 00192 }; 00193 00194 00195 /// OpenGL Line Object 00196 class FXAPI FXGLLine : public FXGLObject { 00197 FXDECLARE(FXGLLine) 00198 public: 00199 FXGLPoint fm,to; 00200 public: 00201 00202 /// Default constructor 00203 FXGLLine(); 00204 00205 /// Copy constructor 00206 FXGLLine(const FXGLLine& orig); 00207 00208 /// Construct with specified endpoints 00209 FXGLLine(FXfloat fx,FXfloat fy,FXfloat fz,FXfloat tx,FXfloat ty,FXfloat tz); 00210 00211 /// Called by the viewer to get bounds for this object 00212 virtual void bounds(FXRangef& box); 00213 00214 /// Draw this object in a viewer 00215 virtual void draw(FXGLViewer* viewer); 00216 00217 /// Copy this object 00218 virtual FXGLObject* copy(); 00219 00220 /// Draw this object for hit-testing purposes 00221 virtual void hit(FXGLViewer* viewer); 00222 00223 /// Save to a stream 00224 virtual void save(FXStream& store) const; 00225 00226 /// Load from a stream 00227 virtual void load(FXStream& store); 00228 }; 00229 00230 } 00231 00232 #endif 00233
![]() |