casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GLPCDisplayList.h
Go to the documentation of this file.
1 //# GLPCDisplayList.h: this defines GLPCDisplayList, which acts as a wrapper
2 //# around OpenGL display lists for the GLPixelCanvas.
3 //# Copyright (C) 2001
4 //# Associated Universities, Inc. Washington DC, USA.
5 //#
6 //# This library is free software; you can redistribute it and/or modify it
7 //# under the terms of the GNU Library General Public License as published by
8 //# the Free Software Foundation; either version 2 of the License, or (at your
9 //# option) any later version.
10 //#
11 //# This library is distributed in the hope that it will be useful, but WITHOUT
12 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 //# License for more details.
15 //#
16 //# You should have received a copy of the GNU Library General Public License
17 //# along with this library; if not, write to the Free Software Foundation,
18 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19 //#
20 //# Correspondence concerning AIPS++ should be addressed as follows:
21 //# Internet email: aips2-request@nrao.edu.
22 //# Postal address: AIPS++ Project Office
23 //# National Radio Astronomy Observatory
24 //# 520 Edgemont Road
25 //# Charlottesville, VA 22903-2475 USA
26 //#
27 //# $Id$
28 
29 // <summary>
30 // Display list support for GLPixelCanvas.
31 // </summary>
32 // <use visibility=local>
33 //
34 // <synopsis>
35 // These classes are used to implement display list support for GLPixelCanvas.
36 // Execution tracing is supported. The variable 'nspaces' gives the number
37 // of spaces to indent the printout. All of these classes are used internally
38 // by GLPixelCanvas and wouldn't be useful elsewhere.
39 // </synopsis>
40 //
41 // <prerequisite>
42 // <li> None
43 // </prerequisite>
44 //
45 // <thrown>
46 // None
47 // </thrown>
48 //
49 // <todo asof="2001/10/9">
50 //
51 // </todo>
52 
53 #ifndef TRIALDISPLAY_GLPCDISPLAYLIST_H
54 #define TRIALDISPLAY_GLPCDISPLAYLIST_H
55 
56 #include <string.h>
57 #include <GL/gl.h>
58 #include <casa/aips.h>
59 #include <casa/BasicSL/String.h>
60 
61 namespace casa { //# NAMESPACE CASA - BEGIN
62 
63 // <summary>
64 // Base class for the various display list subclasses.
65 // </summary>
67  public:
68  // Draw element unless disabled or force is true.
69  virtual void call(casacore::Bool force=false, const casacore::uInt nspaces=0);
70 
71  // enable/disable
72  // <group>
74  return enabled_;
75  }
77  return !enabled_;
78  }
79  virtual void disable();
80  virtual void enable();
81  // </group>
82 
83  // Each element has a name which is printed out when tracing.
84  // <group>
85  const char *name()const {
86  return name_.chars();
87  }
88  void name(const char *);
89  // </group>
90  // Enable/disable tracing.
91  // <group>
93  return trace_;
94  }
95  void trace(const casacore::Bool t) {
96  trace_ = t;
97  }
98  // </group>
99  // Begin recording commands.
100  // Recording is a one shot deal. After stop is called, recording
101  // can not be reenabled.
102  virtual void start(); //# Start recording.
103  // Stop display list recording. Ignored if not already recording.
104  virtual void stop();
105  // Each element is reference counted.
107  return usage_;
108  }
109  void ref();
110  void unref();
111  protected:
112  GLPCDisplayListElement(const char *name=NULL);
113  // Elements self delete when the reference count goes to 0.
114  virtual ~GLPCDisplayListElement();
115  void traceCheck(casacore::uInt spaces=0, const char *str=NULL,
116  const char *name=NULL);
117  private:
122  };
123 
124 // <summary>
125 // Returns a Display casacore::List Element for recording GL commands.
126 // </summary>
127 // <synopsis>
128 // Returns a Display casacore::List Element for recording GL commands.
129 // Commands are recorded until stop is called by creating an OpenGL
130 // display list and letting OpenGL do the actual recording. Calling
131 // stop ends the list. Typically, these OpenGL lists are very short,
132 // containing just one or two commands. eg. draw a rectangle.
133 // </synopsis>
135  public:
137 
138  GLPCDisplayListEntry::GLPCDisplayListEntry(
139  const char *name=NULL,
140  GLenum mode=GL_COMPILE_AND_EXECUTE);
141  virtual ~GLPCDisplayListEntry();
142  //# Draw list.
143  virtual void call(casacore::Bool force, const casacore::uInt spaces);
144  //# Recording is a one shot deal. After stop is called, recording
145  //# can not be reenabled.
146  virtual void start(); //# Start recording.
147  //# Stop display list recording. Ignored if not already recording.
148  virtual void stop();
149  protected:
150  private:
151  GLenum mode_;
152  GLuint id_;
154  };
155 
156 //#////////////////////////////////////////////////////////////////
157 
158 // <summary>
159 // DisplayListElement that can contain lists of other DisplayListElements.
160 // </summary>
161 // <synopsis>
162 // When GLPixelCanvas::newList() is called, a GLPCDisplayList is created
163 // to hold all the GLPCDisplayListEntrys that are created. A GLPCDisplayList
164 // can also hold other GLPCDisplayLists (drawList called inside a list).
165 // </synopsis>
167  public:
168  // Amount by which to increment the list of display lists when
169  // it fills up.
171 
172  GLPCDisplayList(const char *name=NULL,
174 
175  // Copy a display list's list.
176  GLPCDisplayList(const GLPCDisplayList &list);
178 
179  // Append another element to list.
180  void add(GLPCDisplayListElement *);
181 
182  // Run the current list.
183  virtual void call(casacore::Bool force=false, casacore::uInt spaces=0);
184 
185  // Translate the list.
186  // Set translation values. New values are added to current.
188 
189  //# Miscellaneous
190 
191  // Return current translation
192  void translation(casacore::Float &xo, casacore::Float &yo)const;
194  // Return/Set amount to increase id list by.
196  return sizeincr_;
197  }
198  void sizeincrement(const casacore::uInt sizeincr) {
199  sizeincr_ = sizeincr;
200  }
201  protected:
202  private:
203  void resize();
204  void unrefall();
205 
206  GLfloat xt_, yt_, zt_; //# Amount to translate display list.
207  casacore::uInt sizeincr_; //# Amount to increase listids_ when it's full.
208  casacore::uInt numentries_; //# # of entries & index to next free.
209  casacore::uInt listSize_; //# # of slots in list.
211  };
212 
213 
214 } //# NAMESPACE CASA - END
215 
216 #endif
casacore::Bool trace() const
Enable/disable tracing.
GLPCDisplayList(const char *name=NULL, casacore::uInt sizeincr=GLPCDisplayList::DefaultSizeIncrement)
virtual void stop()
Stop display list recording.
virtual void call(casacore::Bool force=false, const casacore::uInt nspaces=0)
Draw element unless disabled or force is true.
virtual void start()
Begin recording commands.
void add(GLPCDisplayListElement *)
Append another element to list.
GLPCDisplayListElement ** list_
casacore::uInt sizeincr_
virtual void start()
Begin recording commands.
casacore::uInt numentries_
virtual ~GLPCDisplayListElement()
Elements self delete when the reference count goes to 0.
Base class for the various display list subclasses.
casacore::uInt sizeincrement() const
Return/Set amount to increase id list by.
GLPCDisplayListElement(const char *name=NULL)
virtual void call(casacore::Bool force=false, casacore::uInt spaces=0)
Run the current list.
void sizeincrement(const casacore::uInt sizeincr)
casacore::Bool disabled() const
virtual void stop()
Stop display list recording.
Returns a Display casacore::List Element for recording GL commands.
const Char * chars() const
** Casacore synonym
Definition: String.h:559
casacore::uLong useCount() const
Each element is reference counted.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
float Float
Definition: aipstype.h:54
DisplayListElement that can contain lists of other DisplayListElements.
unsigned long uLong
Definition: aipstype.h:53
void trace(const casacore::Bool t)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void traceCheck(casacore::uInt spaces=0, const char *str=NULL, const char *name=NULL)
casacore::Bool enabled() const
enable/disable
void translation(casacore::Float &xo, casacore::Float &yo) const
Return current translation.
virtual void call(casacore::Bool force, const casacore::uInt spaces)
Draw element unless disabled or force is true.
void translate(casacore::Float xt, casacore::Float yt, casacore::Float zt=0.0)
Translate the list.
casacore::uInt listSize_
unsigned int uInt
Definition: aipstype.h:51
const char * name() const
Each element has a name which is printed out when tracing.