source: nanovis/trunk/FlowBox.cpp @ 5722

Last change on this file since 5722 was 4056, checked in by ldelgass, 10 years ago

Use nv namespace for internal classes (not Rappture) to make it easier to find
dependencies on the Rappture libraries.

  • Property svn:eol-style set to native
File size: 2.6 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
4 *
5 * Authors:
6 *   Wei Qiao <qiaow@purdue.edu>
7 *   Insoo Woo <iwoo@purdue.edu>
8 *   George A. Howlett <gah@purdue.edu>
9 *   Leif Delgass <ldelgass@purdue.edu>
10 */
11
12#include <float.h>
13#include <assert.h>
14
15#include <vrmath/Vector3f.h>
16#include <vrmath/Vector4f.h>
17#include <vrmath/Matrix4x4d.h>
18
19#include "FlowBox.h"
20#include "Volume.h"
21#include "Trace.h"
22
23using namespace nv;
24using namespace vrmath;
25
26FlowBox::FlowBox(const char *name) :
27    _name(name)
28{
29    _sv.isHidden = false;
30    _sv.corner1.x = 0.0f;
31    _sv.corner1.y = 0.0f;
32    _sv.corner1.z = 0.0f;
33    _sv.corner2.x = 1.0f;
34    _sv.corner2.y = 1.0f;
35    _sv.corner2.z = 1.0f;
36    _sv.lineWidth = 1.2f;
37    _sv.color.r = _sv.color.b = _sv.color.g = _sv.color.a = 1.0f;
38}
39
40FlowBox::~FlowBox()
41{
42    TRACE("Freeing switches");
43    FreeSwitches(_switches, &_sv, 0);
44}
45
46void
47FlowBox::getBounds(Vector3f& bboxMin,
48                   Vector3f& bboxMax) const
49{
50    bboxMin.set(_sv.corner1.x, _sv.corner1.y, _sv.corner1.z);
51    bboxMax.set(_sv.corner2.x, _sv.corner2.y, _sv.corner2.z);
52}
53
54void
55FlowBox::render(Volume *vol)
56{
57    TRACE("Box: '%s'", _name.c_str());
58
59    glPushAttrib(GL_ENABLE_BIT);
60
61    glEnable(GL_DEPTH_TEST);
62    glDisable(GL_TEXTURE_2D);
63    glDisable(GL_BLEND);
64
65    glMatrixMode(GL_MODELVIEW);
66    glPushMatrix();
67
68    TRACE("box bounds %g,%g %g,%g %g,%g",
69          _sv.corner1.x, _sv.corner2.x,
70          _sv.corner1.y, _sv.corner2.y,
71          _sv.corner1.z, _sv.corner2.z);
72
73    float x0, y0, z0, x1, y1, z1;
74
75    x0 = _sv.corner1.x;
76    x1 = _sv.corner2.x;
77    y0 = _sv.corner1.y;
78    y1 = _sv.corner2.y;
79    z0 = _sv.corner1.z;
80    z1 = _sv.corner2.z;
81
82    glColor4d(_sv.color.r, _sv.color.g, _sv.color.b, _sv.color.a);
83    glLineWidth(_sv.lineWidth);
84    glBegin(GL_LINE_LOOP);
85    {
86        glVertex3d(x0, y0, z0);
87        glVertex3d(x1, y0, z0);
88        glVertex3d(x1, y1, z0);
89        glVertex3d(x0, y1, z0);
90    }
91    glEnd();
92    glBegin(GL_LINE_LOOP);
93    {
94        glVertex3d(x0, y0, z1);
95        glVertex3d(x1, y0, z1);
96        glVertex3d(x1, y1, z1);
97        glVertex3d(x0, y1, z1);
98    }
99    glEnd();
100   
101    glBegin(GL_LINE_LOOP);
102    {
103        glVertex3d(x0, y0, z0);
104        glVertex3d(x0, y0, z1);
105        glVertex3d(x0, y1, z1);
106        glVertex3d(x0, y1, z0);
107    }
108    glEnd();
109   
110    glBegin(GL_LINE_LOOP);
111    {
112        glVertex3d(x1, y0, z0);
113        glVertex3d(x1, y0, z1);
114        glVertex3d(x1, y1, z1);
115        glVertex3d(x1, y1, z0);
116    }
117    glEnd();
118
119    glPopMatrix();
120    glPopAttrib();
121
122    assert(CheckGL(AT));
123}
Note: See TracBrowser for help on using the repository browser.