source: trunk/packages/vizservers/nanovis/transfer-function/ControlPoint.cpp @ 3177

Last change on this file since 3177 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

  • Property svn:eol-style set to native
File size: 3.4 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/* ======================================================================
3 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
4 *           Purdue Rendering and Perceptualization Lab (PURPL)
5 *
6 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
7 *
8 *  See the file "license.terms" for information on usage and
9 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10 * ======================================================================
11 */
12#include <math.h>
13#include "TransferFunctionMain.h"
14#include "ControlPoint.h"
15
16ControlPoint::ControlPoint(double _x, double _y)
17{
18    x = _x;
19    y = _y;
20
21    selected = false;
22    dragged = false;
23       
24    next = 0;
25}
26
27ControlPoint::~ControlPoint()
28{
29
30}
31
32void ControlPoint::glDraw()
33{
34    //Here is the code for drawing a vertex
35    double size = 4;
36
37    glMatrixMode( GL_MODELVIEW );
38    glPushMatrix();
39    glTranslatef( x, y, 0 );
40
41    glBegin(GL_LINES);
42
43    glVertex2d(-size, -size);
44    glVertex2d(+size, +size);
45
46    glVertex2d(-size, +size);
47    glVertex2d(+size, -size);
48       
49    glEnd();
50
51    //Special code for drawing selected vertex and dragged vertex.
52
53    if (selected && !dragged) {
54        double square = size + 4;
55               
56        glBegin(GL_LINE_LOOP);
57        glColor3d(1,0,0);                       
58        glVertex2d(-square, -square);
59        glVertex2d(-square, +square);
60        glVertex2d(+square, +square);
61        glVertex2d(+square, -square);
62        glColor3d(0,0,0);
63        glEnd();
64
65    } else if (selected && dragged) {
66        double square = 4*sqrt(size + 4);
67        glBegin(GL_LINE_LOOP);
68        glColor3d(1,0,0);
69        glVertex2d(-square, 0);
70        glVertex2d(0, +square);
71        glVertex2d(square, 0);
72        glVertex2d(0, -square);
73        glColor3d(0,0,0);
74        glEnd();
75
76    }
77    glPopMatrix();
78
79}
80
81void ControlPoint::glDraw_2()
82{
83    //Here is the code for drawing a vertex
84    double size = 4;
85
86    glMatrixMode( GL_MODELVIEW );
87    glPushMatrix();
88    glTranslatef( x, y, 0 );
89
90    glBegin(GL_POLYGON);
91    glVertex2d(-size, 0);
92    glVertex2d(-size, -size);
93    glVertex2d(+size, -size);
94    glVertex2d(+size, 0);       
95    glEnd();
96
97    //Special code for drawing selected vertex and dragged vertex.
98
99    if (selected && !dragged) {
100        double square = size + 4;
101               
102        glBegin(GL_LINE_LOOP);
103        glColor3d(1,0,0);                       
104        glVertex2d(-square, -square);
105        glVertex2d(-square, +square);
106        glVertex2d(+square, +square);
107        glVertex2d(+square, -square);
108        glColor3d(0,0,0);
109        glEnd();
110    } else if (selected && dragged) {
111        double square = 4*sqrt(size + 4);
112        glBegin(GL_LINE_LOOP);
113        glColor3d(1,0,0);
114        glVertex2d(-square, 0);
115        glVertex2d(0, +square);
116        glVertex2d(square, 0);
117        glVertex2d(0, -square);
118        glColor3d(0,0,0);
119        glEnd();
120    }
121    glPopMatrix();
122
123}
124
125void ControlPoint::glDraw_3()
126{
127    //Here is the code for drawing a vertex
128    double size = 7;
129
130    glMatrixMode( GL_MODELVIEW );
131    glPushMatrix();
132    glTranslatef( x, y, 0 );
133
134    glBegin(GL_LINES);
135
136    glVertex2d(-2, 0);
137    glVertex2d(-size, 0);
138
139    glVertex2d(2, 0);
140    glVertex2d(size, 0);
141
142
143    glVertex2d(0, -2);
144    glVertex2d(0, -size);
145
146    glVertex2d(0, 2);
147    glVertex2d(0, size);
148
149    glEnd();
150
151    glPopMatrix();
152}
153
154void ControlPoint::Set(double x, double y)
155{
156    this->x = x;
157    this->y = y;
158}
Note: See TracBrowser for help on using the repository browser.