COPASI API  4.16.103
qwt3dBars.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #include <QtGui/QBitmap>
16 
17 #include <qwt3d_color.h>
18 #include <qwt3d_plot.h>
19 #include "qwt3dBars.h"
20 //#include <iostream>
21 
23 {
24  configure(0, -1, -1);
25 }
26 
27 Bar::Bar(double rad, double showColumn, double showRow)
28 {
29  configure(rad, showColumn, showRow);
30 }
31 
32 // virtual
34 {}
35 
36 void Bar::configure(double rad, double showColumn, double showRow)
37 {
38  plot = 0;
39  radius_ = rad;
40  mShowColumn = showColumn;
41  mShowRow = showRow;
42 }
43 
45 {
46  drawZero();
47  diag_ = radius_;
48  glLineWidth(0);
49  glEnable(GL_POLYGON_OFFSET_FILL);
50  glPolygonOffset(1, 1);
51 }
52 
54 {}
55 
56 void Bar::draw(Qwt3D::Triple const& pos)
57 {
58  Qwt3D::GLStateBewarer sb(GL_LINE_SMOOTH, true);
59  sb.turnOn();
60 
61  //an option to add further labels
62  // if ((pos.x == mShowColumn) || (pos.y == mShowRow))
63  // {
64  // Label3D lb;
65  // lb.draw(pos, diag_, diag_ * 2);
66  //}
67 
68  // set the zero level
69  GLdouble minz = 0; //plot->hull().minVertex.z;
70 
71  Qwt3D::RGBA mTo = (*plot->dataColor())(pos);
72  Qwt3D::RGBA mFrom = (*plot->dataColor())(pos.x, pos.y, minz);
73 
74  glBegin(GL_QUADS);
75 
76  if (((int)(100 * pos.x) == (int)(100 * mShowColumn)) || ((int)(100 * pos.y) == (int)(100 * mShowRow)))
77  glColor3d(0.71, 0.835, 1); //(1, 0, 0);
78  else
79  glColor4d(mTo.r, mTo.g, mTo.b, mTo.a);
80 
81  //glColor4d(mFrom.r, mFrom.g, mFrom.b, mFrom.a);
82  glVertex3d(pos.x - diag_, pos.y - diag_, minz);
83  glVertex3d(pos.x + diag_, pos.y - diag_, minz);
84  glVertex3d(pos.x + diag_, pos.y + diag_, minz);
85  glVertex3d(pos.x - diag_, pos.y + diag_, minz);
86 
87  if (((int)(100 * pos.x) == (int)(100 * mShowColumn)) || ((int)(100 * pos.y) == (int)(100 * mShowRow)))
88  glColor3d(0.71, 0.835, 1); //(1, 0, 0);
89  else
90  glColor4d(mTo.r, mTo.g, mTo.b, mTo.a);
91 
92  glVertex3d(pos.x - diag_, pos.y - diag_, pos.z);
93  glVertex3d(pos.x + diag_, pos.y - diag_, pos.z);
94  glVertex3d(pos.x + diag_, pos.y + diag_, pos.z);
95  glVertex3d(pos.x - diag_, pos.y + diag_, pos.z);
96 
97  glColor4d(mFrom.r, mFrom.g, mFrom.b, mFrom.a);
98  glVertex3d(pos.x - diag_, pos.y - diag_, minz);
99  glVertex3d(pos.x + diag_, pos.y - diag_, minz);
100  glColor4d(mTo.r, mTo.g, mTo.b, mTo.a);
101  glVertex3d(pos.x + diag_, pos.y - diag_, pos.z);
102  glVertex3d(pos.x - diag_, pos.y - diag_, pos.z);
103 
104  glColor4d(mFrom.r, mFrom.g, mFrom.b, mFrom.a);
105  glVertex3d(pos.x - diag_, pos.y + diag_, minz);
106  glVertex3d(pos.x + diag_, pos.y + diag_, minz);
107  glColor4d(mTo.r, mTo.g, mTo.b, mTo.a);
108  glVertex3d(pos.x + diag_, pos.y + diag_, pos.z);
109  glVertex3d(pos.x - diag_, pos.y + diag_, pos.z);
110 
111  glColor4d(mFrom.r, mFrom.g, mFrom.b, mFrom.a);
112  glVertex3d(pos.x - diag_, pos.y - diag_, minz);
113  glVertex3d(pos.x - diag_, pos.y + diag_, minz);
114  glColor4d(mTo.r, mTo.g, mTo.b, mTo.a);
115  glVertex3d(pos.x - diag_, pos.y + diag_, pos.z);
116  glVertex3d(pos.x - diag_, pos.y - diag_, pos.z);
117 
118  glColor4d(mFrom.r, mFrom.g, mFrom.b, mFrom.a);
119  glVertex3d(pos.x + diag_, pos.y - diag_, minz);
120  glVertex3d(pos.x + diag_, pos.y + diag_, minz);
121  glColor4d(mTo.r, mTo.g, mTo.b, mTo.a);
122  glVertex3d(pos.x + diag_, pos.y + diag_, pos.z);
123  glVertex3d(pos.x + diag_, pos.y - diag_, pos.z);
124  glEnd();
125 
126  glColor3d(0, 0, 0);
127  glBegin(GL_LINES);
128  glVertex3d(pos.x - diag_, pos.y - diag_, minz); glVertex3d(pos.x + diag_, pos.y - diag_, minz);
129  glVertex3d(pos.x - diag_, pos.y - diag_, pos.z); glVertex3d(pos.x + diag_, pos.y - diag_, pos.z);
130  glVertex3d(pos.x - diag_, pos.y + diag_, pos.z); glVertex3d(pos.x + diag_, pos.y + diag_, pos.z);
131  glVertex3d(pos.x - diag_, pos.y + diag_, minz); glVertex3d(pos.x + diag_, pos.y + diag_, minz);
132 
133  glVertex3d(pos.x - diag_, pos.y - diag_, minz); glVertex3d(pos.x - diag_, pos.y + diag_, minz);
134  glVertex3d(pos.x + diag_, pos.y - diag_, minz); glVertex3d(pos.x + diag_, pos.y + diag_, minz);
135  glVertex3d(pos.x + diag_, pos.y - diag_, pos.z); glVertex3d(pos.x + diag_, pos.y + diag_, pos.z);
136  glVertex3d(pos.x - diag_, pos.y - diag_, pos.z); glVertex3d(pos.x - diag_, pos.y + diag_, pos.z);
137 
138  glVertex3d(pos.x - diag_, pos.y - diag_, minz); glVertex3d(pos.x - diag_, pos.y - diag_, pos.z);
139  glVertex3d(pos.x + diag_, pos.y - diag_, minz); glVertex3d(pos.x + diag_, pos.y - diag_, pos.z);
140  glVertex3d(pos.x + diag_, pos.y + diag_, minz); glVertex3d(pos.x + diag_, pos.y + diag_, pos.z);
141  glVertex3d(pos.x - diag_, pos.y + diag_, minz); glVertex3d(pos.x - diag_, pos.y + diag_, pos.z);
142  glEnd();
143 }
144 
146 {
147  glColor3d(0, 0, 0);
148  glBegin(GL_LINE_LOOP);
149  glVertex3d(plot->hull().minVertex.x, plot->hull().minVertex.y, 0);
150  glVertex3d(plot->hull().maxVertex.x, plot->hull().minVertex.y, 0);
151  glVertex3d(plot->hull().maxVertex.x, plot->hull().maxVertex.y, 0);
152  glVertex3d(plot->hull().minVertex.x, plot->hull().maxVertex.y, 0);
153  glEnd();
154 }
155 
156 void Label3D::draw(Qwt3D::Triple const& pos, double w, double h)
157 {
158  double gap = 0.3;
159  double posZ;
160 
161  if (pos.z < 0)
162  posZ = 0;
163  else
164  posZ = pos.z;
165 
166  glColor3d(1, 1, 1);
167  glBegin(GL_QUADS);
168  glVertex3d(pos.x - w, pos.y, posZ + gap);
169  glVertex3d(pos.x + w, pos.y, posZ + gap);
170  glVertex3d(pos.x + w, pos.y, posZ + gap + h);
171  glVertex3d(pos.x - w, pos.y, posZ + gap + h);
172  glEnd();
173  glColor3d(0.4, 0, 0);
174  glBegin(GL_LINE_LOOP);
175  glVertex3d(pos.x - w, pos.y, posZ + gap);
176  glVertex3d(pos.x + w, pos.y, posZ + gap);
177  glVertex3d(pos.x + w, pos.y, posZ + gap + h);
178  glVertex3d(pos.x - w, pos.y, posZ + gap + h);
179  glEnd();
180  glBegin(GL_LINES);
181  glVertex3d(pos.x, pos.y, posZ);
182  glVertex3d(pos.x, pos.y, posZ + gap);
183  glEnd();
184 }
void drawBegin()
Definition: qwt3dBars.cpp:44
double diag_
Definition: qwt3dBars.h:41
void configure(double rad, double showColumn, double showRow)
Definition: qwt3dBars.cpp:36
double mShowColumn
Definition: qwt3dBars.h:37
double mShowRow
Definition: qwt3dBars.h:38
virtual ~Bar()
Definition: qwt3dBars.cpp:33
void draw(Qwt3D::Triple const &, double w, double h)
Definition: qwt3dBars.cpp:156
void drawZero()
Definition: qwt3dBars.cpp:145
Bar()
Definition: qwt3dBars.cpp:22
double radius_
Definition: qwt3dBars.h:40
void drawEnd()
Definition: qwt3dBars.cpp:53
void draw(Qwt3D::Triple const &)
Definition: qwt3dBars.cpp:56