Newer
Older
/***********************************************************************
* FXRuby -- the Ruby language bindings for the FOX GUI toolkit.
* Copyright (c) 2001-2009 by Lyle Johnson. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* For further information please contact the author by e-mail
* at "lyle@lylejohnson.name".
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
***********************************************************************/
class FXGLViewer;
class FXGLObject;
// Shape drawing options
enum {
SURFACE_SINGLESIDED = 0, // Single-sided [both sides same]
SURFACE_DUALSIDED = 0x00000001, // Dual-sided surface
SHADING_NONE = 0, // No light source
SHADING_SMOOTH = 0x00000002, // Smooth shaded
SHADING_FLAT = 0x00000004, // Flag shaded
FACECULLING_OFF = 0, // No face culling
FACECULLING_ON = 0x00000008, // Cull backward facing surfaces
STYLE_SURFACE = 0x00000010, // Draw filled surfaces
STYLE_WIREFRAME = 0x00000020, // Draw wire frame
STYLE_POINTS = 0x00000040, // Draw as points
STYLE_BOUNDBOX = 0x00000080 // Draw bounding box
};
/// OpenGL Shape Object
class FXGLShape : public FXGLObject {
protected:
FXVec3f position; // Middle of the Bounding Box
FXMaterial material[2]; // Front and back material properties
FXRangef range; // Range box
FXuint options; // Drawing options
FXString tip;
protected:
FXGLShape();
virtual void drawshape(FXGLViewer*){} // To be overloaded by derived class
void drawbox();
void drawhandles();
public:
long onDNDDrop(FXObject*,FXSelector,void*);
long onDNDMotion(FXObject*,FXSelector,void* PTR_EVENT);
long onQueryTip(FXObject*,FXSelector,void*);
long onCmdShadeOff(FXObject*,FXSelector,void*);
long onUpdShadeOff(FXObject*,FXSelector,void*);
long onCmdShadeOn(FXObject*,FXSelector,void*);
long onUpdShadeOn(FXObject*,FXSelector,void*);
long onCmdShadeSmooth(FXObject*,FXSelector,void*);
long onUpdShadeSmooth(FXObject*,FXSelector,void*);
long onCmdFrontMaterial(FXObject*,FXSelector,void*);
long onUpdFrontMaterial(FXObject*,FXSelector,void*);
long onCmdBackMaterial(FXObject*,FXSelector,void*);
long onUpdBackMaterial(FXObject*,FXSelector,void*);
long onCmdDrawingStyle(FXObject*,FXSelector,void*);
long onUpdDrawingStyle(FXObject*,FXSelector,void*);
public:
enum {
ID_SHADEOFF=FXGLObject::ID_LAST,
ID_SHADEON,
ID_SHADESMOOTH,
ID_TOGGLE_SIDED,
ID_TOGGLE_CULLING,
ID_STYLE_POINTS,
ID_STYLE_WIREFRAME,
ID_STYLE_SURFACE,
ID_STYLE_BOUNDINGBOX,
ID_FRONT_MATERIAL,
ID_BACK_MATERIAL,
ID_LAST
};
public:
%extend {
/// Construct with specified origin and options
FXGLShape(FXfloat x,FXfloat y,FXfloat z,FXuint opts){
return new FXRbGLShape(x,y,z,opts);
}
/// Construct with specified origin, options and front and back materials
FXGLShape(FXfloat x,FXfloat y,FXfloat z,FXuint opts,const FXMaterial& front,const FXMaterial& back){
return new FXRbGLShape(x,y,z,opts,front,back);
}
}
%extend {
/// Identify sub-object given path
virtual FXGLObject* identify(FXuint* path,FXint n){
return self->identify(path);
}
}
/// Set the tool tip message for this object
void setTipText(const FXString& text);
/// Get the tool tip message for this object
const FXString& getTipText() const;
/// Set the material for specified side (where side = 0 or 1)
void setMaterial(FXint side,const FXMaterial &mtl);
%extend {
// Get position
FXVec3f getPosition() const {
FXASSERT(self->isMemberOf(FXMETACLASS(FXRbGLShape)));
return dynamic_cast<const FXRbGLShape*>(self)->getPosition();
}
// Set position
void setPosition(const FXVec3f& pos) {
FXASSERT(self->isMemberOf(FXMETACLASS(FXRbGLShape)));
dynamic_cast<FXRbGLShape*>(self)->setPosition(pos);
}
// Get the material for specified side (where side = 0 or 1)
FXMaterial getMaterial(FXint side) const {
FXMaterial mtl;
self->getMaterial(side, mtl);
return mtl;
}
// Set the range for this shape
void setRange(const FXRangef& box){
FXASSERT(self->isMemberOf(FXMETACLASS(FXRbGLShape)));
dynamic_cast<FXRbGLShape*>(self)->setRange(box);
}
}
// Destructor
virtual ~FXGLShape();
};
DECLARE_FXOBJECT_VIRTUALS(FXGLShape)
DECLARE_FXGLOBJECT_VIRTUALS(FXGLShape)
DECLARE_FXGLSHAPE_VIRTUALS(FXGLShape)