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

FXGLShape.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * O p e n G L S h a p e 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: FXGLShape.h,v 1.25 2006/01/22 17:58:03 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXGLSHAPE_H
25 #define FXGLSHAPE_H
26 
27 #ifndef FXGLOBJECT_H
28 #include "FXGLObject.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 class FXGLViewer;
35 class FXGLObject;
36 
37 
38 // Shape drawing options
39 enum {
40  SURFACE_SINGLESIDED = 0, // Single-sided [both sides same]
41  SURFACE_DUALSIDED = 0x00000001, // Dual-sided surface
42  SHADING_NONE = 0, // No light source
43  SHADING_SMOOTH = 0x00000002, // Smooth shaded
44  SHADING_FLAT = 0x00000004, // Flag shaded
45  FACECULLING_OFF = 0, // No face culling
46  FACECULLING_ON = 0x00000008, // Cull backward facing surfaces
47  STYLE_SURFACE = 0x00000010, // Draw filled surfaces
48  STYLE_WIREFRAME = 0x00000020, // Draw wire frame
49  STYLE_POINTS = 0x00000040, // Draw as points
50  STYLE_BOUNDBOX = 0x00000080 // Draw bounding box
51  };
52 
53 
54 
55 /// OpenGL Shape Object
56 class FXAPI FXGLShape : public FXGLObject {
58 protected:
59  FXVec3f position; // Middle of the Bounding Box
60  FXMaterial material[2]; // Front and back material properties
61  FXRangef range; // Range box
62  FXuint options; // Drawing options
63  FXString tip;
64 protected:
65  FXGLShape();
66  virtual void drawshape(FXGLViewer*){} // To be overloaded by derived class
67  void drawbox();
68  void drawhandles();
69 public:
70  long onDNDDrop(FXObject*,FXSelector,void*);
71  long onDNDMotion(FXObject*,FXSelector,void*);
72  long onQueryTip(FXObject*,FXSelector,void*);
73  long onCmdShadeOff(FXObject*,FXSelector,void*);
74  long onUpdShadeOff(FXObject*,FXSelector,void*);
75  long onCmdShadeOn(FXObject*,FXSelector,void*);
76  long onUpdShadeOn(FXObject*,FXSelector,void*);
77  long onCmdShadeSmooth(FXObject*,FXSelector,void*);
78  long onUpdShadeSmooth(FXObject*,FXSelector,void*);
79  long onCmdFrontMaterial(FXObject*,FXSelector,void*);
80  long onUpdFrontMaterial(FXObject*,FXSelector,void*);
81  long onCmdBackMaterial(FXObject*,FXSelector,void*);
82  long onUpdBackMaterial(FXObject*,FXSelector,void*);
83  long onCmdDrawingStyle(FXObject*,FXSelector,void*);
84  long onUpdDrawingStyle(FXObject*,FXSelector,void*);
85 public:
86  enum {
87  ID_SHADEOFF=FXGLObject::ID_LAST,
88  ID_SHADEON,
89  ID_SHADESMOOTH,
90  ID_TOGGLE_SIDED,
91  ID_TOGGLE_CULLING,
92  ID_STYLE_POINTS,
93  ID_STYLE_WIREFRAME,
94  ID_STYLE_SURFACE,
95  ID_STYLE_BOUNDINGBOX,
96  ID_FRONT_MATERIAL,
97  ID_BACK_MATERIAL,
98  ID_LAST
99  };
100 public:
101 
102  /// Construct with specified origin and options
103  FXGLShape(FXfloat x,FXfloat y,FXfloat z,FXuint opts);
104 
105  /// Construct with specified origin, options and front and back materials
106  FXGLShape(FXfloat x,FXfloat y,FXfloat z,FXuint opts,const FXMaterial& front,const FXMaterial& back);
107 
108  /// Copy constructor
109  FXGLShape(const FXGLShape& orig);
110 
111  /// Called by the viewer to get bounds for this object
112  virtual void bounds(FXRangef& box);
113 
114  /// Draw this object in a viewer
115  virtual void draw(FXGLViewer* viewer);
117  /// Draw this object for hit-testing purposes
118  virtual void hit(FXGLViewer* viewer);
120  /// Copy this object
121  virtual FXGLObject* copy();
122 
123  /// Return true if this object can be dragged around
124  virtual FXbool canDrag() const;
125 
126  /// Return true if this object can be deleted from the scene
127  virtual FXbool canDelete() const;
128 
129  /// Drag this object from one position to another
130  virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty);
131 
132  /// Set the tool tip message for this object
133  void setTipText(const FXString& text){ tip=text; }
134 
135  /// Get the tool tip message for this object
136  const FXString& getTipText() const { return tip; }
137 
138  /// Set the material for specified side (where side = 0 or 1)
139  void setMaterial(FXint side,const FXMaterial &mtl);
140 
141  /// Get the material for specified side (where side = 0 or 1)
142  void getMaterial(FXint side,FXMaterial &mtl) const;
143 
144  /// Save shape to a stream
145  virtual void save(FXStream& store) const;
146 
147  /// Load shape from a stream
148  virtual void load(FXStream& store);
149  };
150 
151 }
152 
153 #endif
154 
Draw wire frame.
Definition: FXGLShape.h:51
Definition: FXGLViewer.h:79
Basic OpenGL object.
Definition: FXGLObject.h:39
Single-sided [both sides same].
Definition: FXGLShape.h:43
Dual-sided surface.
Definition: FXGLShape.h:44
Smooth shaded.
Definition: FXGLShape.h:46
unsigned int FXuint
Definition: fxdefs.h:396
Cull backward facing surfaces.
Definition: FXGLShape.h:49
FXuint FXSelector
Association key.
Definition: FXObject.h:53
OpenGL viewer widget.
Definition: FXGLViewer.h:100
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:393
#define FXDECLARE_ABSTRACT(classname)
Macro to set up abstract class declaration.
Definition: FXObject.h:114
Draw filled surfaces.
Definition: FXGLShape.h:50
No light source.
Definition: FXGLShape.h:45
No face culling.
Definition: FXGLShape.h:48
Leaving ample room for FXGLViewer subclasses.
Definition: FXGLObject.h:43
Draw bounding box.
Definition: FXGLShape.h:53
int FXint
Definition: fxdefs.h:397
OpenGL Shape Object.
Definition: FXGLShape.h:64
Single-precision 3-element vector.
Definition: FXVec3f.h:36
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:398
Flag shaded.
Definition: FXGLShape.h:47
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33
Draw as points.
Definition: FXGLShape.h:52

Copyright © 1997-2005 Jeroen van der Zijp