graph3d.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2005-2009, 2011 Taneli Kalvas. All rights reserved.
6  *
7  * You can redistribute this software and/or modify it under the terms
8  * of the GNU General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this library (file "COPYING" included in the package);
19  * if not, write to the Free Software Foundation, Inc., 51 Franklin
20  * Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * If you have questions about your rights to use or distribute this
23  * software, please contact Berkeley Lab's Technology Transfer
24  * Department at TTD@lbl.gov. Other questions, comments and bug
25  * reports should be sent directly to the author via email at
26  * taneli.kalvas@jyu.fi.
27  *
28  * NOTICE. This software was developed under partial funding from the
29  * U.S. Department of Energy. As such, the U.S. Government has been
30  * granted for itself and others acting on its behalf a paid-up,
31  * nonexclusive, irrevocable, worldwide license in the Software to
32  * reproduce, prepare derivative works, and perform publicly and
33  * display publicly. Beginning five (5) years after the date
34  * permission to assert copyright is obtained from the U.S. Department
35  * of Energy, and subject to any subsequent five (5) year renewals,
36  * the U.S. Government is granted for itself and others acting on its
37  * behalf a paid-up, nonexclusive, irrevocable, worldwide license in
38  * the Software to reproduce, prepare derivative works, distribute
39  * copies to the public, perform publicly and display publicly, and to
40  * permit others to do so.
41  */
42 
43 #ifndef GRAPH3D_HPP
44 #define GRAPH3D_HPP 1
45 
46 
47 #include "graph.hpp"
48 #include "error.hpp"
49 
50 
53 enum view_e {
54  VIEW_XY = 0,
60 };
61 
62 
78 class Graph3D : public Graph {
79 
80 protected:
81 
83  int _vb[3];
84  int _level;
86 public:
87 
90  Graph3D() {
91  _view = VIEW_XY;
92  _vb[0] = 0;
93  _vb[1] = 1;
94  _vb[2] = 2;
95  _level = 0;
96  }
97 
100  virtual ~Graph3D() {}
101 
111  virtual void plot( cairo_t *cairo, const Coordmapper *cm, const double range[4] ) = 0;
112 
117  virtual void plot_sample( cairo_t *cairo, double x, double y, double width, double height ) = 0;
118 
124  virtual void get_bbox( double bbox[4] ) = 0;
125 
130  void set_view( view_e view, int level ) {
131  switch( view ) {
132  case VIEW_XY:
133  _vb[0] = 0;
134  _vb[1] = 1;
135  _vb[2] = 2;
136  break;
137  case VIEW_XZ:
138  _vb[0] = 0;
139  _vb[1] = 2;
140  _vb[2] = 1;
141  break;
142  case VIEW_YX:
143  _vb[0] = 1;
144  _vb[1] = 0;
145  _vb[2] = 2;
146  break;
147  case VIEW_YZ:
148  _vb[0] = 1;
149  _vb[1] = 2;
150  _vb[2] = 0;
151  break;
152  case VIEW_ZX:
153  _vb[0] = 2;
154  _vb[1] = 0;
155  _vb[2] = 1;
156  break;
157  case VIEW_ZY:
158  _vb[0] = 2;
159  _vb[1] = 1;
160  _vb[2] = 0;
161  break;
162  default:
164  break;
165  }
166  _view = view;
167  _level = level;
168  }
169 };
170 
171 
172 #endif
Abstract base class for drawable plots.
Definition: graph.hpp:56
Definition: graph3d.hpp:55
view_e
View types.
Definition: graph3d.hpp:53
Base for plottable graphs.
virtual ~Graph3D()
Virtual destructor.
Definition: graph3d.hpp:100
void set_view(view_e view, int level)
Set the view of 3D drawable.
Definition: graph3d.hpp:130
Definition: graph3d.hpp:59
virtual void get_bbox(double bbox[4])=0
Get bounding box of drawable.
Definition: graph3d.hpp:58
#define ERROR_LOCATION
Macro for setting error location when throwing errors.
Definition: error.hpp:72
Definition: graph3d.hpp:57
Graph3D()
Constructor.
Definition: graph3d.hpp:90
Linear-linear 2D coordinate mapper.
Definition: coordmapper.hpp:119
Abstract base class for geometry slice plots.
Definition: graph3d.hpp:78
Error class to use if requested feature is unimplemented.
Definition: error.hpp:218
Error classes and handling
virtual void plot_sample(cairo_t *cairo, double x, double y, double width, double height)=0
Plot sample for legend.
Definition: graph3d.hpp:54
virtual void plot(cairo_t *cairo, const Coordmapper *cm, const double range[4])=0
Plot graph with cairo.
int _vb[3]
Coordinate index for first, second and third axes.
Definition: graph3d.hpp:83
view_e _view
Geometry view direction.
Definition: graph3d.hpp:82
Definition: graph3d.hpp:56
int _level
Level of slice in mesh units.
Definition: graph3d.hpp:84