49 #include "SliceNode.hh" 59 SliceNode::SliceNode(
BaseNode * _parent,
60 const std::string& _name ) :
65 set_visible_box(
Vec3f( 0, 0, 0 ),
68 set_texture_box(
Vec3f( 0, 0, 0 ),
71 set_cursor(
Vec3f( 0.5, 0.5, 0.5 ) );
78 SliceNode::~SliceNode()
87 SliceNode::view_frame(
bool _view_frame )
89 view_frame_ = _view_frame;
128 if ( is_enabled( NONE ) )
131 glPushAttrib(GL_LIGHTING_BIT);
132 glPushAttrib(GL_ENABLE_BIT);
133 glPushAttrib(GL_COLOR_BUFFER_BIT);
139 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
163 SliceNode::draw_frame()
const 171 glColor3f( 1, 1, 1 );
173 glVertex3f( visible_min_[0], visible_min_[1], visible_min_[2] );
174 glVertex3f( visible_min_[0], visible_min_[1], visible_max_[2] );
175 glVertex3f( visible_min_[0], visible_max_[1], visible_min_[2] );
176 glVertex3f( visible_min_[0], visible_max_[1], visible_max_[2] );
177 glVertex3f( visible_max_[0], visible_max_[1], visible_min_[2] );
178 glVertex3f( visible_max_[0], visible_max_[1], visible_max_[2] );
179 glVertex3f( visible_max_[0], visible_min_[1], visible_min_[2] );
180 glVertex3f( visible_max_[0], visible_min_[1], visible_max_[2] );
182 glVertex3f( visible_min_[0], visible_min_[1], visible_min_[2] );
183 glVertex3f( visible_min_[0], visible_max_[1], visible_min_[2] );
184 glVertex3f( visible_min_[0], visible_min_[1], visible_max_[2] );
185 glVertex3f( visible_min_[0], visible_max_[1], visible_max_[2] );
186 glVertex3f( visible_max_[0], visible_min_[1], visible_min_[2] );
187 glVertex3f( visible_max_[0], visible_max_[1], visible_min_[2] );
188 glVertex3f( visible_max_[0], visible_min_[1], visible_max_[2] );
189 glVertex3f( visible_max_[0], visible_max_[1], visible_max_[2] );
191 glVertex3f( visible_min_[0], visible_min_[1], visible_min_[2] );
192 glVertex3f( visible_max_[0], visible_min_[1], visible_min_[2] );
193 glVertex3f( visible_min_[0], visible_min_[1], visible_max_[2] );
194 glVertex3f( visible_max_[0], visible_min_[1], visible_max_[2] );
195 glVertex3f( visible_min_[0], visible_max_[1], visible_min_[2] );
196 glVertex3f( visible_max_[0], visible_max_[1], visible_min_[2] );
197 glVertex3f( visible_min_[0], visible_max_[1], visible_max_[2] );
198 glVertex3f( visible_max_[0], visible_max_[1], visible_max_[2] );
204 glColor3f( 1, 1, 1 );
206 if ( is_enabled( XY_PLANE ) )
208 glVertex3f( visible_min_[0], visible_min_[1], cursor_[2] );
209 glVertex3f( visible_max_[0], visible_min_[1], cursor_[2] );
210 glVertex3f( visible_max_[0], visible_min_[1], cursor_[2] );
211 glVertex3f( visible_max_[0], visible_max_[1], cursor_[2] );
212 glVertex3f( visible_max_[0], visible_max_[1], cursor_[2] );
213 glVertex3f( visible_min_[0], visible_max_[1], cursor_[2] );
214 glVertex3f( visible_min_[0], visible_max_[1], cursor_[2] );
215 glVertex3f( visible_min_[0], visible_min_[1], cursor_[2] );
219 if ( is_enabled( YZ_PLANE ) )
221 glVertex3f( cursor_[0], visible_min_[1], visible_min_[2] );
222 glVertex3f( cursor_[0], visible_min_[1], visible_max_[2] );
223 glVertex3f( cursor_[0], visible_min_[1], visible_max_[2] );
224 glVertex3f( cursor_[0], visible_max_[1], visible_max_[2] );
225 glVertex3f( cursor_[0], visible_max_[1], visible_max_[2] );
226 glVertex3f( cursor_[0], visible_max_[1], visible_min_[2] );
227 glVertex3f( cursor_[0], visible_max_[1], visible_min_[2] );
228 glVertex3f( cursor_[0], visible_min_[1], visible_min_[2] );
232 if ( is_enabled( XZ_PLANE ) )
234 glVertex3f( visible_min_[0], cursor_[1], visible_min_[2] );
235 glVertex3f( visible_max_[0], cursor_[1], visible_min_[2] );
236 glVertex3f( visible_max_[0], cursor_[1], visible_min_[2] );
237 glVertex3f( visible_max_[0], cursor_[1], visible_max_[2] );
238 glVertex3f( visible_max_[0], cursor_[1], visible_max_[2] );
239 glVertex3f( visible_min_[0], cursor_[1], visible_max_[2] );
240 glVertex3f( visible_min_[0], cursor_[1], visible_max_[2] );
241 glVertex3f( visible_min_[0], cursor_[1], visible_min_[2] );
252 SliceNode::draw_planes()
const 257 glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
265 for (
int i = 0; i < 3; ++i )
267 rel[i] = ( cursor_[i]-texture_min_[i] ) / ( texture_max_[i] - texture_min_[i] );
268 tcmin[i] = ( visible_min_[i] - texture_min_[i] )
269 / ( texture_max_[i] - texture_min_[i] );
270 tcmax[i] = ( visible_max_[i] - texture_min_[i] )
271 / ( texture_max_[i] - texture_min_[i] );
274 if ( cursor_[2] >= visible_min_[2] &&
275 cursor_[2] <= visible_max_[2] &&
276 is_enabled( XY_PLANE ) )
280 glNormal3f( 0, 0, 1 );
282 glTexCoord3f( tcmin[0], tcmin[1], rel[2] );
283 glVertex3f( visible_min_[0], visible_min_[1], cursor_[2] );
285 glTexCoord3f( tcmax[0], tcmin[1], rel[2] );
286 glVertex3f( visible_max_[0], visible_min_[1], cursor_[2] );
288 glTexCoord3f( tcmax[0], tcmax[1], rel[2] );
289 glVertex3f( visible_max_[0], visible_max_[1], cursor_[2] );
291 glTexCoord3f( tcmin[0], tcmax[1], rel[2] );
292 glVertex3f( visible_min_[0], visible_max_[1], cursor_[2] );
297 if ( cursor_[0] >= visible_min_[0] &&
298 cursor_[0] <= visible_max_[0] &&
299 is_enabled( YZ_PLANE ) )
303 glNormal3f( -1, 0, 0 );
305 glTexCoord3f( rel[0], tcmin[1], tcmin[2] );
306 glVertex3f( cursor_[0], visible_min_[1], visible_min_[2] );
308 glTexCoord3f( rel[0], tcmin[1], tcmax[2] );
309 glVertex3f( cursor_[0], visible_min_[1], visible_max_[2] );
311 glTexCoord3f( rel[0], tcmax[1], tcmax[2] );
312 glVertex3f( cursor_[0], visible_max_[1], visible_max_[2] );
314 glTexCoord3f( rel[0], tcmax[1], tcmin[2] );
315 glVertex3f( cursor_[0], visible_max_[1], visible_min_[2] );
320 if ( cursor_[1] >= visible_min_[1] &&
321 cursor_[1] <= visible_max_[1] &&
322 is_enabled( XZ_PLANE ) )
326 glNormal3f( 0, -1, 0 );
328 glTexCoord3f( tcmin[0], rel[1], tcmin[2] );
329 glVertex3f( visible_min_[0], cursor_[1], visible_min_[2] );
331 glTexCoord3f( tcmax[0], rel[1], tcmin[2] );
332 glVertex3f( visible_max_[0], cursor_[1], visible_min_[2] );
334 glTexCoord3f( tcmax[0], rel[1], tcmax[2] );
335 glVertex3f( visible_max_[0], cursor_[1], visible_max_[2] );
337 glTexCoord3f( tcmin[0], rel[1], tcmax[2] );
338 glVertex3f( visible_min_[0], cursor_[1], visible_max_[2] );
351 SliceNode::cursor()
const 361 SliceNode::set_cursor(
const Vec3f & _cursor )
371 SliceNode::is_enabled( Plane _plane )
const 373 return enabled_ == _plane;
381 SliceNode::set_enabled( Plane _plane )
391 SliceNode::set_visible_box(
const Vec3f & _box_min,
392 const Vec3f & _box_max )
394 visible_min_ = _box_min;
395 visible_max_ = _box_max;
403 SliceNode::set_texture_box(
const Vec3f & _box_min,
404 const Vec3f & _box_max )
406 texture_min_ = _box_min;
407 texture_max_ = _box_max;
static void enable(GLenum _cap, bool _warnRemoved=true)
replaces glEnable, but supports locking
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
void pick(GLState &_state, PickTarget _target) override
Namespace providing different geometric functions concerning angles.
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
PickTarget
What target to use for picking.
DrawModes::DrawMode availableDrawModes() const override
static void disable(GLenum _cap, bool _warnRemoved=true)
replaces glDisable, but supports locking
VectorT< float, 3 > Vec3f
bool pick_set_maximum(size_t _idx)
Set the maximal number of primitives/components of your object.
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode) override
Draw this node using the draw modes _drawMode.
DrawMode NONE
not a valid draw mode
static void blendFunc(GLenum _sfactor, GLenum _dfactor)
replaces glBlendFunc, supports locking
void pick_set_name(size_t _idx)
sets the current name/color (like glLoadName(_idx))
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax) override