MPQC 2.3.1

- Main Page
- Related Pages
- Classes
- Files

- File List

render.h
1 //
2 // render.h
3 //
4 // Copyright (C) 1996 Limit Point Systems, Inc.
5 //
6 // Author: Curtis Janssen <cljanss@limitpt.com>
7 // Maintainer: LPS
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27
28 #ifdef __GNUC__
29 #pragma interface
30 #endif
31
32 #ifndef _util_render_render_h
33 #define _util_render_render_h
34
35 #include <util/class/class.h>
36 #include <util/render/appearance.h>
37 #include <util/render/material.h>
38 #include <util/render/transform.h>
39 #include <util/render/stack.h>
40
41 namespace sc {
42
43 class RenderedObject;
44 class AnimatedObject;
45 class RenderedObjectSet;
46 class RenderedSphere;
47 class RenderedPolygons;
48 class RenderedPolylines;
49
50 class Render: public DescribedClass {
51 protected:
52 Ref<Material> default_material_;
53 Ref<Appearance> default_appearance_;
54 Ref<Transform> default_transform_;
55
56 Stack<Ref<Material> > material_stack_;
57 Stack<Ref<Appearance> > appearance_stack_;
58 Stack<Ref<Transform> > transform_stack_;
59
60 virtual void push_material(const Ref<Material>& m);
61 virtual void push_appearance(const Ref<Appearance>& a);
62 virtual void push_transform(const Ref<Transform>& t);
63 virtual Ref<Material> pop_material();
64 virtual Ref<Appearance> pop_appearance();
65 virtual Ref<Transform> pop_transform();
66
67 public:
68 Render();
69 Render(const Ref<KeyVal>&);
70 virtual ~Render();
71
72 Ref<Material> default_material() { return default_material_; }
73 Ref<Appearance> default_appearance() { return default_appearance_; }
74 Ref<Transform> default_transform() { return default_transform_; }
75 void default_material(const Ref<Material>& m) { default_material_ = m; }
76 void default_appearance(const Ref<Appearance>& a) {default_appearance_ = a;}
77 void default_transform(const Ref<Transform>& t) {default_transform_ = t;}
78
79 virtual void clear() = 0;
80
81 virtual void render(const Ref<RenderedObject>&);
82 virtual void animate(const Ref<AnimatedObject> &);
83
84 virtual void set(const Ref<RenderedObjectSet>&);
85 virtual void sphere(const Ref<RenderedSphere>&);
86 virtual void polygons(const Ref<RenderedPolygons>&) = 0;
87 virtual void polylines(const Ref<RenderedPolylines>&) = 0;
88 };
89
90
91 class FileRender: public Render {
92 protected:
93 char* filename_;
94 char* basename_;
95 std::streambuf *sbuf_;
96 int delete_sbuf_;
97 int depth_;
98
99 char *get_filename(const char *objectname);
100 void open_sbuf(const char *objectname);
101 void close_sbuf();
102 public:
103 FileRender(const char * filename);
104 FileRender(std::ostream &o = ExEnv::out0());
105 FileRender(const Ref<KeyVal>&);
106 virtual ~FileRender();
107
108 void clear();
109
110 virtual void set_filename(const char *name);
111 virtual void set_basename(const char *name);
112 virtual const char *file_extension();
113 };
114
115 }
116
117 #endif
118
119 // Local Variables:
120 // mode: c++
121 // c-file-style: "CLJ"
122 // End: