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

FXGLObject.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * O p e n G L O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXGLObject.h,v 1.28.2.3 2006/11/17 16:02:31 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXGLOBJECT_H
25 #define FXGLOBJECT_H
26 
27 #ifndef FXOBJECT_H
28 #include "FXObject.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 class FXGLViewer;
35 class FXGLObject;
36 
37 
38 /// Basic OpenGL object
39 class FXAPI FXGLObject : public FXObject {
41 public:
42  enum {
43  ID_LAST=10000 // Leaving ample room for FXGLViewer subclasses
44  };
45 public:
46 
47  /// Constructors
49 
50  /// Copy constructor
51  FXGLObject(const FXGLObject& orig):FXObject(orig){}
52 
53  /// Called by the viewer to get bounds for this object
54  virtual void bounds(FXRangef& box);
55 
56  /// Draw this object in a viewer
57  virtual void draw(FXGLViewer* viewer);
58 
59  /// Draw this object for hit-testing purposes
60  virtual void hit(FXGLViewer* viewer);
61 
62  /// Copy this object
63  virtual FXGLObject* copy();
64 
65  /// Identify sub-object given path
66  virtual FXGLObject* identify(FXuint* path);
67 
68  /// Return true if this object can be dragged around
69  virtual FXbool canDrag() const;
70 
71  /// Return true if this object can be deleted from the scene
72  virtual FXbool canDelete() const;
73 
74  /// Drag this object from one position to another
75  virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty);
76 
77  /// Destructor
78  virtual ~FXGLObject(){}
79  };
80 
81 
82 /// List of GL objects
84 
85 
86 /// Group object
87 class FXAPI FXGLGroup : public FXGLObject {
89 protected:
90  FXGLObjectList list; // List of all objects
91 public:
92 
93  /// Constructor
94  FXGLGroup(){ }
95 
96  /// Copy constructor
97  FXGLGroup(const FXGLGroup& orig):FXGLObject(orig),list(orig.list){ }
98 
99  /// Return list of childern
100  FXGLObjectList& getList(){ return list; }
101 
102  /// Return bounding box
103  virtual void bounds(FXRangef& box);
104 
105  /// Draw into viewer
106  virtual void draw(FXGLViewer* viewer);
107 
108  /// Hit in viewer
109  virtual void hit(FXGLViewer* viewer);
110 
111  /// Copy this object
112  virtual FXGLObject* copy();
113 
114  /// Identify object by means of path
115  virtual FXGLObject* identify(FXuint* path);
116 
117  /// Return TRUE if group can be dragged
118  virtual FXbool canDrag() const;
119 
120  /// Drag group object
121  virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty);
123  /// Return number of children
124  FXint no() const { return list.no(); }
126  /// Child at position
127  FXGLObject* child(FXint pos) const { return list[pos]; }
129  /// Insert child object at given position
130  void insert(FXint pos,FXGLObject* obj){ list.insert(pos,obj); }
132  /// Prepend child object
133  void prepend(FXGLObject* obj){ list.prepend(obj); }
135  /// Append child object
136  void append(FXGLObject* obj){ list.append(obj); }
138  /// Replace child object
139  void replace(FXint pos,FXGLObject* obj){ list.replace(pos,obj); }
141  /// Remove child object
142  void remove(FXGLObject* obj){ list.remove(obj); }
144  /// Remove child object at given position
145  void erase(FXint pos){ list.erase(pos); }
147  /// Remove all children
148  void clear(){ list.clear(); }
149 
150  /// Stream save and load
151  virtual void save(FXStream& store) const;
152  virtual void load(FXStream& store);
153 
154  /// Destructor
155  virtual ~FXGLGroup();
156  };
157 
159 /// OpenGL Point Object
160 class FXAPI FXGLPoint : public FXGLObject {
162 public:
163  FXVec3f pos;
164 public:
165 
166  /// Default constructor
167  FXGLPoint();
168 
169  /// Copy constructor
170  FXGLPoint(const FXGLPoint& orig);
171 
172  /// Construct with specified coordinates
173  FXGLPoint(FXfloat x,FXfloat y,FXfloat z);
174 
175  /// Copy this object
176  virtual FXGLObject* copy();
177 
178  /// Called by the viewer to get bounds for this object
179  virtual void bounds(FXRangef& box);
180 
181  /// Draw this object in a viewer
182  virtual void draw(FXGLViewer* viewer);
183 
184  /// Draw this object for hit-testing purposes
185  virtual void hit(FXGLViewer* viewer);
186 
187  /// Save to a stream
188  virtual void save(FXStream& store) const;
189 
190  /// Load from a stream
191  virtual void load(FXStream& store);
192  };
193 
195 /// OpenGL Line Object
196 class FXAPI FXGLLine : public FXGLObject {
198 public:
199  FXGLPoint fm,to;
200 public:
201 
202  /// Default constructor
203  FXGLLine();
204 
205  /// Copy constructor
206  FXGLLine(const FXGLLine& orig);
207 
208  /// Construct with specified endpoints
209  FXGLLine(FXfloat fx,FXfloat fy,FXfloat fz,FXfloat tx,FXfloat ty,FXfloat tz);
210 
211  /// Called by the viewer to get bounds for this object
212  virtual void bounds(FXRangef& box);
213 
214  /// Draw this object in a viewer
215  virtual void draw(FXGLViewer* viewer);
216 
217  /// Copy this object
218  virtual FXGLObject* copy();
219 
220  /// Draw this object for hit-testing purposes
221  virtual void hit(FXGLViewer* viewer);
222 
223  /// Save to a stream
224  virtual void save(FXStream& store) const;
225 
226  /// Load from a stream
227  virtual void load(FXStream& store);
228  };
229 
230 }
231 
232 #endif
233 
Basic OpenGL object.
Definition: FXGLObject.h:39
FXObjectList & erase(FXint pos)
Remove object at pos.
FXObjectList & replace(FXint pos, FXObject *object)
Replace object at position by given object.
FXint no() const
Return number of objects.
Definition: FXObjectList.h:53
unsigned int FXuint
Definition: fxdefs.h:389
FXObjectList & remove(const FXObject *object)
Remove object.
FXObjectListOf< FXGLObject > FXGLObjectList
List of GL objects.
Definition: FXGLObject.h:83
OpenGL viewer widget.
Definition: FXGLViewer.h:100
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:386
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
OpenGL Line Object.
Definition: FXGLObject.h:194
Group object.
Definition: FXGLObject.h:87
virtual ~FXGLObject()
Destructor.
Definition: FXGLObject.h:78
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:390
Single-precision 3-element vector.
Definition: FXVec3f.h:36
OpenGL Point Object.
Definition: FXGLObject.h:158
Bounds.
Definition: FXRangef.h:35
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
float FXfloat
Definition: fxdefs.h:391
FXObjectList & clear()
Remove all objects.
FXGLObject()
Constructors.
Definition: FXGLObject.h:48
Specialize list to pointers to TYPE.
Definition: FXObjectList.h:145
FXObjectList & prepend(FXObject *object)
Prepend object.
FXGLObject(const FXGLObject &orig)
Copy constructor.
Definition: FXGLObject.h:51
FXObjectList & insert(FXint pos, FXObject *object)
Insert object at certain position.
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXObjectList & append(FXObject *object)
Append object.

Copyright © 1997-2005 Jeroen van der Zijp