~valavanisalex/ubuntu/maverick/scidavis/fix-604811

« back to all changes in this revision

Viewing changes to scidavis/src/Cone3D.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ruben Molina
  • Date: 2009-09-06 11:34:04 UTC
  • Revision ID: james.westby@ubuntu.com-20090906113404-4awaey82l3686w4q
Tags: upstream-0.2.3
ImportĀ upstreamĀ versionĀ 0.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    File                 : Cone3D.cpp
 
3
    Project              : SciDAVis
 
4
    --------------------------------------------------------------------
 
5
    Copyright            : (C) 2006 by Ion Vasilief, Tilman Benkert
 
6
    Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net
 
7
    Description          : 3D cone class (code from Cone class  in QwtPlot3D library with modified destructor)
 
8
                           
 
9
 ***************************************************************************/
 
10
 
 
11
/***************************************************************************
 
12
 *                                                                         *
 
13
 *  This program is free software; you can redistribute it and/or modify   *
 
14
 *  it under the terms of the GNU General Public License as published by   *
 
15
 *  the Free Software Foundation; either version 2 of the License, or      *
 
16
 *  (at your option) any later version.                                    *
 
17
 *                                                                         *
 
18
 *  This program is distributed in the hope that it will be useful,        *
 
19
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 
20
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 
21
 *  GNU General Public License for more details.                           *
 
22
 *                                                                         *
 
23
 *   You should have received a copy of the GNU General Public License     *
 
24
 *   along with this program; if not, write to the Free Software           *
 
25
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
 
26
 *   Boston, MA  02110-1301  USA                                           *
 
27
 *                                                                         *
 
28
 ***************************************************************************/
 
29
#include <math.h>
 
30
#include "qwt3d_color.h"
 
31
#include "qwt3d_plot.h"
 
32
#include "Cone3D.h"
 
33
 
 
34
using namespace Qwt3D;
 
35
 
 
36
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
37
//
 
38
//   Cone3D (code from Cone class  in QwtPlot3D library with modified destructor)
 
39
//
 
40
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
41
 
 
42
Cone3D::Cone3D()
 
43
{
 
44
        hat      = gluNewQuadric();
 
45
        disk     = gluNewQuadric();
 
46
 
 
47
  configure(0, 3);
 
48
}
 
49
 
 
50
Cone3D::Cone3D(double rad, unsigned quality)
 
51
{
 
52
        hat      = gluNewQuadric();
 
53
        disk     = gluNewQuadric();
 
54
 
 
55
  configure(rad, quality);
 
56
}
 
57
 
 
58
Cone3D::~Cone3D()
 
59
{
 
60
}
 
61
 
 
62
void Cone3D::configure(double rad, unsigned quality)
 
63
{
 
64
  plot = 0;
 
65
  radius_ = rad;
 
66
  quality_ = quality;
 
67
  oldstate_ = GL_FALSE;
 
68
 
 
69
        gluQuadricDrawStyle(hat,GLU_FILL);
 
70
        gluQuadricNormals(hat,GLU_SMOOTH);
 
71
        gluQuadricOrientation(hat,GLU_OUTSIDE);
 
72
        gluQuadricDrawStyle(disk,GLU_FILL);
 
73
        gluQuadricNormals(disk,GLU_SMOOTH);
 
74
        gluQuadricOrientation(disk,GLU_OUTSIDE);
 
75
}
 
76
 
 
77
void Cone3D::draw(Qwt3D::Triple const& pos)
 
78
{  
 
79
        RGBA rgba = (*plot->dataColor())(pos);
 
80
  glColor4d(rgba.r,rgba.g,rgba.b,rgba.a);
 
81
 
 
82
  GLint mode;
 
83
        glGetIntegerv(GL_MATRIX_MODE, &mode);
 
84
        glMatrixMode( GL_MODELVIEW );
 
85
  glPushMatrix();
 
86
 
 
87
  glTranslatef(pos.x, pos.y, pos.z);
 
88
 
 
89
  gluCylinder(hat, 0.0, radius_, radius_*2, quality_, 1);
 
90
  glTranslatef(0, 0, radius_*2);
 
91
        gluDisk(disk, 0.0, radius_, quality_, 1);
 
92
 
 
93
  glPopMatrix();
 
94
        glMatrixMode(mode);
 
95
}