Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

VMDDisplayList.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2008 The Board of Trustees of the
00004  *cr                        University of Illinois
00005  *cr                         All Rights Reserved
00006  *cr
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: VMDDisplayList.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.35 $      $Date: 2008/03/27 19:36:49 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *   Display list data structure used to hold all of the rendering commands
00019  *   VMD generates and interprets in order to do its 3-D rendering.
00020  ***************************************************************************/
00021 
00022 #ifndef VMDLINKEDLIST_H__
00023 #define VMDLINKEDLIST_H__
00024 
00025 #include <string.h>
00026 #include "Matrix4.h"
00027 
00029 struct VMDClipPlane {
00030   float center[3]; 
00031   float normal[3]; 
00032   float color[3];  
00033   int mode;        
00034 
00036   VMDClipPlane() {
00037     center[0] = center[1] = center[2] = 0;
00038     normal[0] = normal[1] = 0; normal[2] = 1;
00039     color[0] = color[1] = color[2] = 0.5;
00040     mode = 0;
00041   }
00042 };
00043 
00044 #define VMD_MAX_CLIP_PLANE 6
00045 
00048 #define PBC_NONE   0x00  // don't draw any PBC images
00049 #define PBC_X      0x01  // +X images
00050 #define PBC_Y      0x02  // +Y images
00051 #define PBC_Z      0x04  // +Z images
00052 #define PBC_OPX    0x08  // -X images
00053 #define PBC_OPY    0x10  // -Y images
00054 #define PBC_OPZ    0x20  // -Z images
00055 #define PBC_NOSELF 0x40  // set this flag to NOT draw the original image
00056 
00057 
00060 class VMDDisplayList {
00061 private:
00062   struct CommandHeader {
00063     int code; 
00064     int size; 
00065   };
00066 
00067 public:
00068   VMDDisplayList();   
00069   ~VMDDisplayList();  
00070 
00071   void *operator new(size_t);           
00072   void operator delete(void *, size_t); 
00073 
00074   Matrix4 mat;          
00075   unsigned long serial; 
00076   int cacheskip;        
00077   int pbc;              
00078   int npbc;             
00079   Matrix4 transX, transY, transZ; 
00080   Matrix4 transXinv, transYinv, transZinv; 
00081 
00083 
00084   float ambient, specular, diffuse, shininess, opacity;
00085   int materialtag;  
00086 
00087 
00088   VMDClipPlane clipplanes[VMD_MAX_CLIP_PLANE]; 
00089 
00091   void *append(int code, int size);
00092 
00093   // Reset and also free up any linked memory blocks.  The original block will 
00094   // not be freed; it doesn't go away until you delete the object.
00095   void reset_and_free(unsigned long newserial);
00096 
00098   const VMDClipPlane *clipplane(int i) {
00099     if (i < 0 || i >= VMD_MAX_CLIP_PLANE) return NULL;
00100     return clipplanes+i;
00101   }
00102 
00104 
00105   // normals need not be normalized; it will be be normalized internally. 
00106   int set_clip_center(int i, const float *);
00107   int set_clip_normal(int i, const float *);
00108   int set_clip_color(int i, const float *);
00109   int set_clip_status(int i, int);
00111 
00112   struct VMDLinkIter {
00113     char *ptr;    // pointer to current place in memory pool
00114     int ncmds;    // commands remaining in the list
00115   };
00116 
00118   void first(VMDLinkIter *it) const {
00119     it->ptr = pool;
00120     it->ncmds = listsize;
00121   }
00122 
00124   int next(VMDLinkIter *it, char *&d) const {
00125     if (!(it->ncmds--)) return -1; // corresponds to DLASTCOMMAND
00126     CommandHeader *header = (CommandHeader *)(it->ptr);
00127     int code = header->code;
00128     int size = header->size;
00129     d = it->ptr + sizeof(CommandHeader);
00130     it->ptr += size;
00131     return code;
00132   }
00133 
00134 private:
00135   // number of commands in the display list
00136   int listsize; 
00137 
00138   // size of memory pool
00139   unsigned long poolsize;
00140 
00141   // amount of memory pool consumed by the current display list
00142   unsigned long poolused;
00143 
00144   // our memory pool
00145   char *pool;
00146 };    
00147 
00148 #endif

Generated on Sat Sep 6 01:27:16 2008 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002