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

FXGLShape.h
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,2016 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (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 *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXGLSHAPE_H
22 #define FXGLSHAPE_H
23 
24 #ifndef FXGLOBJECT_H
25 #include "FXGLObject.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 class FXGLViewer;
32 class FXGLObject;
33 
34 
35 // Shape drawing options
36 enum {
37  SURFACE_SINGLESIDED = 0, // Single-sided [both sides same]
38  SURFACE_DUALSIDED = 0x00000001, // Dual-sided surface
39  SHADING_NONE = 0, // No light source
40  SHADING_SMOOTH = 0x00000002, // Smooth shaded
41  SHADING_FLAT = 0x00000004, // Flag shaded
42  FACECULLING_OFF = 0, // No face culling
43  FACECULLING_ON = 0x00000008, // Cull backward facing surfaces
44  STYLE_SURFACE = 0x00000010, // Draw filled surfaces
45  STYLE_WIREFRAME = 0x00000020, // Draw wire frame
46  STYLE_POINTS = 0x00000040, // Draw as points
47  STYLE_BOUNDBOX = 0x00000080 // Draw bounding box
48  };
49 
50 
51 
53 class FXAPI FXGLShape : public FXGLObject {
54  FXDECLARE_ABSTRACT(FXGLShape)
55 protected:
56  FXVec3f position; // Middle of the Bounding Box
57  FXMaterial material[2]; // Front and back material properties
58  FXRangef range; // Range box
59  FXuint options; // Drawing options
60  FXString tip;
61 protected:
62  FXGLShape();
63  virtual void drawshape(FXGLViewer*){} // To be overloaded by derived class
64  void drawbox();
65  void drawhandles();
66 public:
67  long onDNDDrop(FXObject*,FXSelector,void*);
68  long onDNDMotion(FXObject*,FXSelector,void*);
69  long onQueryTip(FXObject*,FXSelector,void*);
70  long onCmdShadeOff(FXObject*,FXSelector,void*);
71  long onUpdShadeOff(FXObject*,FXSelector,void*);
72  long onCmdShadeOn(FXObject*,FXSelector,void*);
73  long onUpdShadeOn(FXObject*,FXSelector,void*);
74  long onCmdShadeSmooth(FXObject*,FXSelector,void*);
75  long onUpdShadeSmooth(FXObject*,FXSelector,void*);
76  long onCmdFrontMaterial(FXObject*,FXSelector,void*);
77  long onUpdFrontMaterial(FXObject*,FXSelector,void*);
78  long onCmdBackMaterial(FXObject*,FXSelector,void*);
79  long onUpdBackMaterial(FXObject*,FXSelector,void*);
80  long onCmdDrawingStyle(FXObject*,FXSelector,void*);
81  long onUpdDrawingStyle(FXObject*,FXSelector,void*);
82 public:
83  enum {
84  ID_SHADEOFF=FXGLObject::ID_LAST,
85  ID_SHADEON,
86  ID_SHADESMOOTH,
87  ID_TOGGLE_SIDED,
88  ID_TOGGLE_CULLING,
89  ID_STYLE_POINTS,
90  ID_STYLE_WIREFRAME,
91  ID_STYLE_SURFACE,
92  ID_STYLE_BOUNDINGBOX,
93  ID_FRONT_MATERIAL,
94  ID_BACK_MATERIAL,
95  ID_LAST
96  };
97 public:
98 
100  FXGLShape(FXfloat x,FXfloat y,FXfloat z,FXuint opts);
101 
103  FXGLShape(FXfloat x,FXfloat y,FXfloat z,FXuint opts,const FXMaterial& front,const FXMaterial& back);
104 
106  FXGLShape(const FXGLShape& orig);
107 
109  virtual void bounds(FXRangef& box);
110 
112  virtual void draw(FXGLViewer* viewer);
113 
115  virtual void hit(FXGLViewer* viewer);
116 
118  virtual FXGLObject* copy();
119 
121  virtual FXbool canDrag() const;
122 
124  virtual FXbool canDelete() const;
125 
127  virtual FXbool drag(FXGLViewer* viewer,FXint fx,FXint fy,FXint tx,FXint ty);
128 
130  void setTipText(const FXString& text){ tip=text; }
131 
133  const FXString& getTipText() const { return tip; }
134 
136  virtual void setPosition(const FXVec3f& pos);
137 
139  const FXVec3f& getPosition() const { return position; }
140 
142  void setMaterial(FXint side,const FXMaterial &mtl);
143 
145  void getMaterial(FXint side,FXMaterial &mtl) const;
146 
148  virtual void save(FXStream& store) const;
149 
151  virtual void load(FXStream& store);
152  };
153 
154 }
155 
156 #endif
157 

Copyright © 1997-2016 Jeroen van der Zijp