Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

movie Class Reference

A class to keep track of the frames in a movie. More...

#include <movie.h>

List of all members.

Public Member Functions

void get_limits (double min_coords[3], double max_coords[3])
 Function to get the limits from a movie.

int read (char *file)
 Function to read a movie from an animp movie file.

void read (ap_frame *f)
 Function to read 1 frame from the current movie file.

void read (char *text, void *data, int size)
 Function to read arbitrary data from the current movie file.

void read_pdb ()
 Function to read a pdb (Protein Data Bank) file.

int read_int (char *text)
 Function to read an int from an animp movie file.

void read (ap_array< sphere_s > *spheres)
 Function to read an array of spheres with short coordinates.

void read (ap_array< sphere_f > *spheres)
 Function to read an array of spheres.

void read (ap_array< cylinder_s > *cylinders)
 Function to read an array of cylinders with short coordinates.

void read (ap_array< cylinder_f > *cylinders)
 Function to read an array of cylinders.

void putback ()
 Function to back up the FILE pointer to "un-read" an int.

int write (char *file)
 Function to write an animp movie file.

int write ()
 Function to write a frame to a animp movie file.

void write (ap_frame *f)
 Function to write 1 frame to an animp movie file.

void write (char *text, int n)
 Function to write an int to an animp movie file.

void write (char *text, char *data)
 Function to write a string to an animp movie file.

void write (char *text, void *data, int size)
 Function to write a arbitrary data to an animp movie file.

void print ()
 Function to print a movie to stdout.

void add_static (ap_frame *f)
 Function to add a static frame to a movie.

void add_static (ap_frame &f)
 Function to add a static frame to a movie.

void add (ap_frame *f)
 Function to add a frame to a movie.

void add (ap_frame &f)
 Function to add a frame to a movie.

void add (ap_color *c)
 Function to add a color to the movie's color array.

void add (ap_color c)
 Function to add a color to the movie's color array.

void add_color (string color_name, int r, int g, int b, int a)
 Function to add a named color to the movie's color array.

 movie ()
 Default constructor.

 movie (char *file)
 Constructor with an output file name.

 movie (int size)
 Constructor for a movie with size frames.

 ~movie ()
 Destructor.


Public Attributes

ap_array< ap_color > * colors
 Array of colors.

ap_framestatic_frame
 Frame drawn in each image.

int current_frame
 Frame number for the current frame.

ap_array< ap_frame > * frames
 The dynamic frames.

FILE * fp
 FILE pointer used for reading/writing.

int frame_count
 Number of frames in frames array.

long count_offset
 Position in a movie file for the frame count.

bool colors_written
 Whether colors have been written yet.

bool limits_started
 Whether there are any valid limits yet.

double min_coords [3]
 Minimum x, y and z coordinates.

double max_coords [3]
 Maximum x, y and z coordinates.


Detailed Description

A class to keep track of the frames in a movie.

Author:
Ray Seyfarth
An animp movie consists of a color array, a static frame and a sequence of dynamic frames. At each display time, animp will draw the static frame along with one of the dynamic frames. If the movie is playing, the dynamic frame counter will advance with each frame presented.

Bug:
Amimp movie files are machine-specific binary files.

Todo:
Convert animp to use a machine-independent binary format.

Add code to the movie class to read/write text movie files.

Add code for saving a movie file with adjusted colors.


Constructor & Destructor Documentation

movie::movie  ) 
 

Default constructor.

movie::movie char *  file  ) 
 

Constructor with an output file name.

If a movie is created using this constructor, an output file is opened and pieces are written as they are added.

movie::movie int  size  ) 
 

Constructor for a movie with size frames.

movie::~movie  )  [inline]
 

Destructor.

It deletes the arrays.


Member Function Documentation

void movie::get_limits double  min_coords[3],
double  max_coords[3]
 

Function to get the limits from a movie.

The gl_box class needs to get the limits from the current movie to help with setting the eye and focus coordinates.

Parameters:
min_coords Array to receive the minimum coordinates
max_coords Array to receive the maximum coordinates

int movie::read char *  file  ) 
 

Function to read a movie from an animp movie file.

Parameters:
file Name of the animp movie file
This function reads the number of frames in the movie, allocates the frames array and reads the frames data.

If the file begins with "Animp001", it is read as an animp movie file. Otherwise it assumed to be a pdb file.

Bug:
It is possible that a file might be something other than an animp movie file or pdb file. This is not detected.

void movie::read ap_frame f  ) 
 

Function to read 1 frame from the current movie file.

Parameters:
f Pointer to the frame object to receive the data

void movie::read char *  text,
void *  data,
int  size
 

Function to read arbitrary data from the current movie file.

There are several read functions for various basic and array data types. Each of these calls this function to perform the read and passes an identifying string into this read to be part of possible error messages.

Parameters:
text String to present as part of an error message
data Pointer to the data to read
size Number of bytes to read into the data array

void movie::read_pdb  ) 
 

Function to read a pdb (Protein Data Bank) file.

The Protein Data Bank format is a commonly-used format for storing atomic structure of molecules. Animp can display a molecule from a pdb file using spheres for atoms and cylinders for bonds. It uses the CPK (Corey, Pauling, Kultun) color schemes for elements and uses atomic radii based on the non-ionic versions of atoms.

int movie::read_int char *  text  ) 
 

Function to read an int from an animp movie file.

Parameters:
text Descriptive phrase to be part of potential error messages
Returns:
Integer value read from the file

void movie::read ap_array< sphere_s > *  spheres  ) 
 

Function to read an array of spheres with short coordinates.

Parameters:
spheres Point to array to receive the spheres

void movie::read ap_array< sphere_f > *  spheres  ) 
 

Function to read an array of spheres.

Parameters:
spheres Point to array to receive the spheres

void movie::read ap_array< cylinder_s > *  cylinders  ) 
 

Function to read an array of cylinders with short coordinates.

Parameters:
cylinders Point to array to receive the cylinders

void movie::read ap_array< cylinder_f > *  cylinders  ) 
 

Function to read an array of cylinders.

Parameters:
cylinders Point to array to receive the cylinders

void movie::putback  ) 
 

Function to back up the FILE pointer to "un-read" an int.

Several functions need to read an int and possibly decide not to use the value. Putback allows them to effectively put back the value so that another function can read that int next.

int movie::write char *  file  ) 
 

Function to write an animp movie file.

Parameters:
file Name of the animp movie file
This function writes the number of frames in the movie and writes the frames data.

int movie::write  ) 
 

Function to write a frame to a animp movie file.

Parameters:
file Name of the animp movie file
This function writes the number of frames in the movie and writes the frames data.

void movie::write ap_frame f  ) 
 

Function to write 1 frame to an animp movie file.

Parameters:
f Pointer to the frame to write

void movie::write char *  text,
int  n
 

Function to write an int to an animp movie file.

Parameters:
text Descriptive phrase to be part of potential error messages
n Int to write to the file

void movie::write char *  text,
char *  data
 

Function to write a string to an animp movie file.

Parameters:
text Descriptive phrase to be part of potential error messages
data String to write to the file
It uses strlen to determine how many bytes to write.

void movie::write char *  text,
void *  data,
int  size
 

Function to write a arbitrary data to an animp movie file.

This function is called by the other write functions to do the actual work. It attempts to write and prints an error message if the write fails.

Parameters:
text Descriptive phrase to be part of potential error messages
data Data to write to the file
size Number of bytes from data to write to the file

void movie::print  ) 
 

Function to print a movie to stdout.

void movie::add_static ap_frame f  ) 
 

Function to add a static frame to a movie.

Parameters:
f Pointer to frame to add to the movie

void movie::add_static ap_frame f  ) 
 

Function to add a static frame to a movie.

Parameters:
f frame to add to the movie

void movie::add ap_frame f  ) 
 

Function to add a frame to a movie.

Parameters:
f Pointer to frame to add to the movie
The frames array is reallocated if needed to add f to the array.

void movie::add ap_frame f  ) 
 

Function to add a frame to a movie.

Parameters:
f frame to add to the movie
The frames array is reallocated if needed to add f to the array.

void movie::add ap_color c  ) 
 

Function to add a color to the movie's color array.

Parameters:
c Pointer to the color to add

void movie::add ap_color  c  ) 
 

Function to add a color to the movie's color array.

Parameters:
c Color to add

void movie::add_color string  color_name,
int  r,
int  g,
int  b,
int  a
 

Function to add a named color to the movie's color array.

To color atoms conveniently add_color is used to add a color with a name like "He" for Helium. This adds the color to the colors array and adds entries to the color_table and rev_color_table maps. Then it is easy to get the color index from the name and vice-versa.

Parameters:
color_name Name of color to add
r Red color value (0-255)
g Green color value (0-255)
b Blue color value (0-255)
a Alpha color value (0-255)


Member Data Documentation

ap_array<ap_color>* movie::colors
 

Array of colors.

ap_frame* movie::static_frame
 

Frame drawn in each image.

int movie::current_frame
 

Frame number for the current frame.

ap_array<ap_frame>* movie::frames
 

The dynamic frames.

FILE* movie::fp
 

FILE pointer used for reading/writing.

int movie::frame_count
 

Number of frames in frames array.

long movie::count_offset
 

Position in a movie file for the frame count.

When a movie is written frame-by-frame, the frame count is not known until the end. At the end it is necessary to write the frame count in the movie file. The count_offset variable holds the address for writing the frame count.

bool movie::colors_written
 

Whether colors have been written yet.

bool movie::limits_started
 

Whether there are any valid limits yet.

double movie::min_coords[3]
 

Minimum x, y and z coordinates.

double movie::max_coords[3]
 

Maximum x, y and z coordinates.


The documentation for this class was generated from the following files:
Generated on Thu Nov 27 08:17:11 2003 for Animp - Animated Particles by doxygen 1.3.2