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

EggMakeFont Class Reference

This program reads a rasterized font stored in a Metafont/TeX pk file format, and generates an egg file and texture map that can be used with TextNode to render text using the font. More...

#include <eggMakeFont.h>

Inheritance diagram for EggMakeFont:

EggWriter EggBase WithOutputFile ProgramBase List of all members.

Public Types

typedef pdeque< string > Args

Public Member Functions

 EggMakeFont ()
void run ()
void add_normals_options ()
 Adds -no, -np, etc.

void add_transform_options ()
 Adds -TS, -TT, etc.

virtual EggWriteras_writer ()
 Returns this object as an EggWriter pointer, if it is in fact an EggWriter, or NULL if it is not.

virtual void post_process_egg_file ()
 Performs any processing of the egg file that is appropriate before writing it out.

void write_egg_file ()
 Writes out the egg file as the normal result of the program.

virtual EggReaderas_reader ()
 Returns this object as an EggReader pointer, if it is in fact an EggReader, or NULL if it is not.

void show_description ()
 Writes the program description to stderr.

void show_usage ()
 Writes the usage line(s) to stderr.

void show_options ()
 Describes each of the available options to stderr.

void show_text (const string &text)
 Formats the indicated text to stderr with the known _terminal_width.

void show_text (const string &prefix, int indent_width, string text)
 Formats the indicated text and its prefix for output to stderr with the known _terminal_width.

virtual void parse_command_line (int argc, char *argv[])
 Dispatches on each of the options on the command line, and passes the remaining parameters to handle_args().

string get_exec_command () const
 Returns the command that invoked this program, as a shell-friendly string, suitable for pasting into the comments of output files.

ostream & get_output ()
 Returns an output stream that corresponds to the user's intended egg file output--either stdout, or the named output file.

bool has_output_filename () const
 Returns true if the user specified an output filename, false otherwise (e.g.

Filename get_output_filename () const
 If has_output_filename() returns true, this is the filename that the user specified.


Static Public Member Functions

void convert_paths (EggNode *node, PathReplace *path_replace, const DSearchPath &additional_path)
 Recursively walks the egg hierarchy.


Public Attributes

Filename _program_name
Args _program_args

Protected Types

enum  NormalsMode { NM_strip, NM_polygon, NM_vertex, NM_preserve }
typedef bool(* OptionDispatchFunction )(const string &opt, const string &parm, void *data)
typedef bool(* OptionDispatchMethod )(ProgramBase *self, const string &opt, const string &parm, void *data)

Protected Member Functions

virtual bool handle_args (Args &args)
 Does something with the additional arguments on the command line (after all the -options have been parsed).

bool ns_dispatch_dimensions (const string &opt, const string &arg)
 Reads the dimensions of the output image and stores them in _output_[xyz]size.

virtual bool post_command_line ()
 This is called after the command line has been completely processed, and it gives the program a chance to do some last-minute processing and validation of the options and arguments.

bool ns_dispatch_normals (const string &opt, const string &arg, void *mode)
 Accepts one of -no, -np, etc.

bool ns_dispatch_rotate_xyz (const string &opt, const string &arg, void *var)
 Handles -TR, which specifies a rotate transform about the three cardinal axes.

bool ns_dispatch_rotate_axis (const string &opt, const string &arg, void *var)
 Handles -TA, which specifies a rotate transform about an arbitrary axis.

void append_command_comment (EggData &_data)
 Inserts a comment into the beginning of the indicated egg file corresponding to the command line that invoked this program.

void set_program_description (const string &description)
 Sets the description of the program that will be reported by show_usage().

void clear_runlines ()
 Removes all of the runlines that were previously added, presumably before adding some new ones.

void add_runline (const string &runline)
 Adds an additional line to the list of lines that will be displayed to describe briefly how the program is to be run.

void clear_options ()
 Removes all of the options that were previously added, presumably before adding some new ones.

void add_option (const string &option, const string &parm_name, int index_group, const string &description, OptionDispatchFunction option_function, bool *bool_var=(bool *) NULL, void *option_data=(void *) NULL)
 Adds (or redefines) a command line option.

void add_option (const string &option, const string &parm_name, int index_group, const string &description, OptionDispatchMethod option_method, bool *bool_var=(bool *) NULL, void *option_data=(void *) NULL)
 This is another variant on add_option(), above, except that it receives a pointer to a "method", which is really just another static (or global) function, whose first parameter is a ProgramBase *.

bool redescribe_option (const string &option, const string &description)
 Changes the description associated with a previously-defined option.

bool remove_option (const string &option)
 Removes a previously-defined option.

void add_path_replace_options ()
 Adds -pr etc.

void add_path_store_options ()
 Adds -ps etc.

bool check_last_arg (ProgramBase::Args &args, int minimum_args)
 Checks if the last filename on the argument list is a file with the expected extension (if _allow_last_param was set true), and removes it from the argument list if it is.

bool verify_output_file_safe () const
 This is called when the output file is given as the last parameter on the command line.


Static Protected Member Functions

bool dispatch_dimensions (ProgramBase *self, const string &opt, const string &arg, void *)
 Reads the dimensions of the output image and stores them in _output_[xyz]size.

bool dispatch_normals (ProgramBase *self, const string &opt, const string &arg, void *mode)
 Accepts one of -no, -np, etc.

bool dispatch_scale (const string &opt, const string &arg, void *var)
 Handles -TS, which specifies a scale transform.

bool dispatch_rotate_xyz (ProgramBase *self, const string &opt, const string &arg, void *var)
 Handles -TR, which specifies a rotate transform about the three cardinal axes.

bool dispatch_rotate_axis (ProgramBase *self, const string &opt, const string &arg, void *var)
 Handles -TA, which specifies a rotate transform about an arbitrary axis.

bool dispatch_translate (const string &opt, const string &arg, void *var)
 Handles -TT, which specifies a translate transform.

void append_command_comment (EggData &_data, const string &comment)
 Inserts a comment into the beginning of the indicated egg file corresponding to the command line that invoked this program.

bool dispatch_none (const string &opt, const string &arg, void *)
 Standard dispatch function for an option that takes no parameters, and does nothing special.

bool dispatch_true (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes no parameters, and when it is present sets a bool variable to the 'true' value.

bool dispatch_false (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes no parameters, and when it is present sets a bool variable to the 'false' value.

bool dispatch_count (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes no parameters, but whose presence on the command line increments an integer counter for each time it appears.

bool dispatch_int (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as an integer.

bool dispatch_int_pair (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes a pair of integer parameters.

bool dispatch_double (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a double.

bool dispatch_double_pair (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes a pair of double parameters.

bool dispatch_double_triple (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes a triple of double parameters.

bool dispatch_double_quad (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes a quad of double parameters.

bool dispatch_color (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes a color, either as r,g,b or as r,g,b,a.

bool dispatch_string (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a string.

bool dispatch_filename (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a filename.

bool dispatch_search_path (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a single directory name to add to a search path.

bool dispatch_coordinate_system (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a coordinate system string.

bool dispatch_units (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a unit of distance measurement.

bool dispatch_image_type (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to indicate an image file type, like rgb, bmp, jpg, etc.

bool dispatch_path_replace (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a single component of a path replace request.

bool dispatch_path_store (const string &opt, const string &arg, void *var)
 Standard dispatch function for an option that takes one parameter, which is to be interpreted as a path store string.

bool handle_help_option (const string &opt, const string &arg, void *)
 Called when the user enters '-h', this describes how to use the program and then exits.

void format_text (ostream &out, bool &last_newline, const string &prefix, int indent_width, const string &text, int line_width)
 Word-wraps the indicated text to the indicated output stream.


Protected Attributes

NormalsMode _normals_mode
double _normals_threshold
bool _got_transform
LMatrix4d _transform
bool _got_coordinate_system
CoordinateSystem _coordinate_system
EggData _data
PointerTo< PathReplace_path_replace
bool _got_path_store
bool _got_path_directory
bool _allow_last_param
bool _allow_stdout
bool _binary_output
string _preferred_extension
bool _got_output_filename
Filename _output_filename

Private Member Functions

TexCoordd get_uv (double x, double y)
 Given the X, Y coordinates of a particular pixel on the image, return the corresponding UV coordinates.

LPoint2d get_xy (double x, double y)
 Given X, Y coordinates in pixels, scale to unit coordinates for the character's geometry.

EggVertexmake_vertex (const LPoint2d &xy)
 Allocates and returns a new vertex from the vertex pool representing the indicated 2-d coordinates.

void copy_character (const CharPlacement &pl)
 Copy the indicated character image to its home on the bitmap and generate egg structures for it.

bool consider_scale_factor (double scale_factor)
 Attempts to place all of the characters on an image of the indicated size (scaled up from the output image size by scale_factor in each dimension).

void choose_scale_factor (double too_small, double too_large)
 Binary search on scale factor, given a factor that is known to be too small and one that is known to be too large.

bool choose_scale_factor ()
 Tries several scale_factors until an optimal one (that is, the smallest one that all letters fit within) is found.

void choose_image_size ()
 Chooses a size for the output image that should yield a scale_factor in the range (2.5 ..

void unsmooth_rgb (PNMImage &image)
 Make the image jaggy in RGB (but leave it antialiased in alpha).

string expand_hyphen (const string &str)
 If a hyphen appears in the string anywhere but in the first and last position, replace it with a sequence of characters.


Private Attributes

Filename _output_image_filename
Filename _input_font_filename
bool _got_output_size
Colorf _fg
Colorf _bg
bool _use_alpha
int _output_xsize
int _output_ysize
int _output_zsize
double _buffer_pixels
double _poly_pixels
bool _got_scale_factor
double _scale_factor
bool _no_reduce
double _gaussian_radius
double _ds
double _scale
double _ppu
bool _get_all
string _only_chars
bool _small_caps
double _small_caps_scale
FontFile_font

Detailed Description

This program reads a rasterized font stored in a Metafont/TeX pk file format, and generates an egg file and texture map that can be used with TextNode to render text using the font.

Definition at line 54 of file eggMakeFont.h.


Member Typedef Documentation

typedef pdeque<string> ProgramBase::Args [inherited]
 

Definition at line 66 of file programBase.h.

typedef bool(* ProgramBase::OptionDispatchFunction)(const string &opt, const string &parm, void *data) [protected, inherited]
 

Definition at line 71 of file programBase.h.

typedef bool(* ProgramBase::OptionDispatchMethod)(ProgramBase *self, const string &opt, const string &parm, void *data) [protected, inherited]
 

Definition at line 72 of file programBase.h.


Member Enumeration Documentation

enum EggWriter::NormalsMode [protected, inherited]
 

Enumeration values:
NM_strip 
NM_polygon 
NM_vertex 
NM_preserve 

Definition at line 68 of file eggWriter.h.

Referenced by EggWriter::handle_args().


Constructor & Destructor Documentation

EggMakeFont::EggMakeFont  ) 
 

Definition at line 45 of file eggMakeFont.cxx.

References ProgramBase::dispatch_color(), dispatch_dimensions(), ProgramBase::dispatch_double(), ProgramBase::dispatch_filename(), ProgramBase::dispatch_int(), ProgramBase::dispatch_none(), ProgramBase::dispatch_string(), and NULL.


Member Function Documentation

void EggWriter::add_normals_options  )  [inherited]
 

Adds -no, -np, etc.

as valid options for this program. If the user specifies one of the options on the command line, the normals will be adjusted when the egg file is written out.

Definition at line 139 of file eggWriter.cxx.

References EggWriter::dispatch_normals(), and NULL.

void ProgramBase::add_option const string &  option,
const string &  parm_name,
int  index_group,
const string &  description,
OptionDispatchMethod  option_method,
bool *  bool_var = (bool *)NULL,
void *  option_data = (void *)NULL
[protected, inherited]
 

This is another variant on add_option(), above, except that it receives a pointer to a "method", which is really just another static (or global) function, whose first parameter is a ProgramBase *.

We can't easily add a variant that accepts a real method, because the C++ syntax for methods requires us to know exactly what class object the method is defined for, and we want to support adding pointers for methods that are defined in other classes. So we have this hacky thing, which requires the "method" to be declared static, and receive its this pointer explicitly, as the first argument.

Definition at line 690 of file programBase.cxx.

References ProgramBase::_got_path_directory, ProgramBase::_got_path_store, ProgramBase::_path_replace, ProgramBase::add_option(), ProgramBase::dispatch_filename(), and ProgramBase::dispatch_path_store().

void ProgramBase::add_option const string &  option,
const string &  parm_name,
int  index_group,
const string &  description,
OptionDispatchFunction  option_function,
bool *  bool_var = (bool *)NULL,
void *  option_data = (void *)NULL
[protected, inherited]
 

Adds (or redefines) a command line option.

When parse_command_line() is executed it will look for these options (followed by a hyphen) on the command line; when a particular option is found it will call the indicated option_function, supplying the provided option_data. This allows the user to define a function that does some special behavior for any given option, or to use any of a number of generic pre-defined functions to fill in data for each option.

Each option may or may not take a parameter. If parm_name is nonempty, it is assumed that the option does take a parameter (and parm_name contains the name that will be printed by show_options()). This parameter will be supplied as the second parameter to the dispatch function. If parm_name is empty, it is assumed that the option does not take a parameter. There is no provision for optional parameters.

The options are listed first in order by their index_group number, and then in the order that add_option() was called. This provides a mechanism for listing the options defined in derived classes before those of the base classes.

Definition at line 634 of file programBase.cxx.

References ProgramBase::_path_replace, ProgramBase::add_option(), ProgramBase::dispatch_path_replace(), ProgramBase::dispatch_search_path(), NULL, and PointerTo< PathReplace >::p().

Referenced by SomethingToEgg::add_animation_options(), ProgramBase::add_option(), EggReader::add_texture_options(), SomethingToEgg::add_units_options(), EggMultiBase::EggMultiBase(), EggMultiFilter::EggMultiFilter(), EggReader::EggReader(), EggTextureCards::EggTextureCards(), EggToBam::EggToBam(), EggToC::EggToC(), EggTopstrip::EggTopstrip(), EggTrans::EggTrans(), FltTrans::FltTrans(), GtkStats::GtkStats(), ImageResize::ImageResize(), and TestProgram::TestProgram().

void ProgramBase::add_path_replace_options  )  [protected, inherited]
 

Adds -pr etc.

as valid options for this program. These are appropriate for a model converter or model reader type program, and specify how to locate possibly-invalid pathnames in the source model file.

Definition at line 771 of file programBase.cxx.

void ProgramBase::add_path_store_options  )  [protected, inherited]
 

Adds -ps etc.

as valid options for this program. These are appropriate for a model converter type program, and specify how to represent filenames in the output file.

Definition at line 818 of file programBase.cxx.

void ProgramBase::add_runline const string &  runline  )  [protected, inherited]
 

Adds an additional line to the list of lines that will be displayed to describe briefly how the program is to be run.

Each line should be something like "[opts] arg1 arg2", that is, it does *not* include the name of the program, but it includes everything that should be printed after the name of the program.

Normally there is only one runline for a given program, but it is possible to define more than one.

Definition at line 552 of file programBase.cxx.

void EggWriter::add_transform_options  )  [inherited]
 

Adds -TS, -TT, etc.

as valid options for this program. If the user specifies one of the options on the command line, the data will be transformed when the egg file is written out.

Definition at line 183 of file eggWriter.cxx.

void EggBase::append_command_comment EggData _data,
const string &  comment
[static, protected, inherited]
 

Inserts a comment into the beginning of the indicated egg file corresponding to the command line that invoked this program.

Normally this function is called automatically when appropriate by EggWriter, and it's not necessary to call it explicitly.

Definition at line 212 of file eggBase.cxx.

void EggBase::append_command_comment EggData _data  )  [protected, inherited]
 

Inserts a comment into the beginning of the indicated egg file corresponding to the command line that invoked this program.

Normally this function is called automatically when appropriate by EggWriter, and it's not necessary to call it explicitly.

Definition at line 187 of file eggBase.cxx.

EggReader * EggBase::as_reader  )  [virtual, inherited]
 

Returns this object as an EggReader pointer, if it is in fact an EggReader, or NULL if it is not.

This is intended to work around the C++ limitation that prevents downcasts past virtual inheritance. Since both EggReader and EggWriter inherit virtually from EggBase, we need functions like this to downcast to the appropriate pointer.

Reimplemented in EggReader.

Definition at line 72 of file eggBase.cxx.

References NULL.

EggWriter * EggWriter::as_writer  )  [virtual, inherited]
 

Returns this object as an EggWriter pointer, if it is in fact an EggWriter, or NULL if it is not.

This is intended to work around the C++ limitation that prevents downcasts past virtual inheritance. Since both EggReader and EggWriter inherit virtually from EggBase, we need functions like this to downcast to the appropriate pointer.

Reimplemented from EggBase.

Definition at line 233 of file eggWriter.cxx.

References EggBase::_data, EggWriter::NM_preserve, EggWriter::NM_vertex, and nout.

bool WithOutputFile::check_last_arg ProgramBase::Args args,
int  minimum_args
[protected, inherited]
 

Checks if the last filename on the argument list is a file with the expected extension (if _allow_last_param was set true), and removes it from the argument list if it is.

Returns true if the arguments are good, false if something is invalid.

minimum_args is the number of arguments we know must be input parameters and therefore cannot be interpreted as output filenames.

Definition at line 159 of file withOutputFile.cxx.

References WithOutputFile::_got_output_filename, WithOutputFile::_output_filename, Filename::exists(), nassertr, and nout.

Referenced by EggWriter::post_process_egg_file(), and ImageWriter::write_image().

void EggMakeFont::choose_image_size  )  [private]
 

Chooses a size for the output image that should yield a scale_factor in the range (2.5 ..

4], which will give pretty good antialiased letters.

Definition at line 606 of file eggMakeFont.cxx.

References size_t.

bool EggMakeFont::choose_scale_factor  )  [private]
 

Tries several scale_factors until an optimal one (that is, the smallest one that all letters fit within) is found.

Returns when all characters have been successfully placed on the layout.

Returns true if successful, or false if it just could not be done.

Definition at line 559 of file eggMakeFont.cxx.

void EggMakeFont::choose_scale_factor double  too_small,
double  too_large
[private]
 

Binary search on scale factor, given a factor that is known to be too small and one that is known to be too large.

Definition at line 521 of file eggMakeFont.cxx.

void ProgramBase::clear_options  )  [protected, inherited]
 

Removes all of the options that were previously added, presumably before adding some new ones.

Normally you wouldn't want to do this unless you want to completely replace all of the options defined by base classes.

Definition at line 573 of file programBase.cxx.

References ProgramBase::Option::_bool_var, ProgramBase::Option::_description, ProgramBase::Option::_index_group, ProgramBase::_next_sequence, ProgramBase::Option::_option, ProgramBase::Option::_option_data, ProgramBase::Option::_option_function, ProgramBase::Option::_option_method, ProgramBase::_options_by_name, ProgramBase::Option::_parm_name, ProgramBase::Option::_sequence, ProgramBase::_sorted_options, and NULL.

void ProgramBase::clear_runlines  )  [protected, inherited]
 

Removes all of the runlines that were previously added, presumably before adding some new ones.

Definition at line 523 of file programBase.cxx.

References ProgramBase::Option::_bool_var, ProgramBase::Option::_description, ProgramBase::Option::_index_group, ProgramBase::_next_sequence, ProgramBase::Option::_option, ProgramBase::Option::_option_data, ProgramBase::Option::_option_function, ProgramBase::Option::_option_method, ProgramBase::_options_by_name, ProgramBase::Option::_parm_name, ProgramBase::Option::_sequence, ProgramBase::_sorted_options, and NULL.

bool EggMakeFont::consider_scale_factor double  scale_factor  )  [private]
 

Attempts to place all of the characters on an image of the indicated size (scaled up from the output image size by scale_factor in each dimension).

Returns true if all the characters fit, or false if the image was too small. In either case, leaves _scale_factor and _working_* set to reflect the chosen scale factor.

Definition at line 483 of file eggMakeFont.cxx.

void EggBase::convert_paths EggNode node,
PathReplace path_replace,
const DSearchPath additional_path
[static, inherited]
 

Recursively walks the egg hierarchy.

Any filenames encountered are replaced according to the indicated PathReplace.

Definition at line 116 of file eggBase.cxx.

void EggMakeFont::copy_character const CharPlacement pl  )  [private]
 

Copy the indicated character image to its home on the bitmap and generate egg structures for it.

Definition at line 340 of file eggMakeFont.cxx.

References _small_caps, _small_caps_scale, and TexCoordd.

bool ProgramBase::dispatch_color const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes a color, either as r,g,b or as r,g,b,a.

The data pointer is to an array of four floats, e.g. a Colorf.

Definition at line 1159 of file programBase.cxx.

References ProgramBase::show_description(), ProgramBase::show_options(), and ProgramBase::show_usage().

Referenced by EggMakeFont(), and EggTextureCards::EggTextureCards().

bool ProgramBase::dispatch_coordinate_system const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a coordinate system string.

The data pointer is to a CoordinateSystem variable.

Definition at line 1281 of file programBase.cxx.

Referenced by EggBase::EggBase(), and EggMultiBase::EggMultiBase().

bool ProgramBase::dispatch_count const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes no parameters, but whose presence on the command line increments an integer counter for each time it appears.

-v is often an option that works this way. The data pointer is to an int counter variable.

Definition at line 944 of file programBase.cxx.

References string_to_float(), and tokenize().

Referenced by MayaToEgg::MayaToEgg(), and TestProgram::TestProgram().

bool EggMakeFont::dispatch_dimensions ProgramBase self,
const string &  opt,
const string &  arg,
void * 
[static, protected]
 

Reads the dimensions of the output image and stores them in _output_[xyz]size.

Definition at line 237 of file eggMakeFont.cxx.

Referenced by EggMakeFont().

bool ProgramBase::dispatch_double const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a double.

The data pointer is to an double variable.

Definition at line 1024 of file programBase.cxx.

References DSearchPath::append_directory(), Filename::from_os_specific(), and nout.

Referenced by SomethingToEgg::add_animation_options(), EggMakeFont(), FltTrans::FltTrans(), ImageResize::ImageResize(), and MayaToEgg::MayaToEgg().

bool ProgramBase::dispatch_double_pair const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes a pair of double parameters.

The data pointer is to an array of two doubles.

Definition at line 1049 of file programBase.cxx.

References CoordinateSystem, CS_invalid, nout, and parse_coordinate_system_string().

Referenced by EggTextureCards::EggTextureCards().

bool ProgramBase::dispatch_double_quad const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes a quad of double parameters.

The data pointer is to an array of four doubles.

Definition at line 1120 of file programBase.cxx.

References PathReplace::add_pattern(), nout, and size_t.

Referenced by EggTextureCards::EggTextureCards().

bool ProgramBase::dispatch_double_triple const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes a triple of double parameters.

The data pointer is to an array of three doubles.

Definition at line 1084 of file programBase.cxx.

References PNMFileTypeRegistry::get_ptr(), PNMFileTypeRegistry::get_type_from_extension(), nout, NULL, and PNMFileTypeRegistry::write_types().

Referenced by EggCrop::EggCrop().

bool ProgramBase::dispatch_false const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes no parameters, and when it is present sets a bool variable to the 'false' value.

This is another way to handle a boolean flag. See also dispatch_none() and dispatch_true().

The data pointer is to a bool variable.

Definition at line 921 of file programBase.cxx.

Referenced by EggTopstrip::EggTopstrip().

bool ProgramBase::dispatch_filename const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a filename.

The data pointer is to a Filename variable.

Definition at line 1223 of file programBase.cxx.

Referenced by ProgramBase::add_option(), CVSCopy::CVSCopy(), EggMakeFont(), EggMultiFilter::EggMultiFilter(), EggPalettize::EggPalettize(), EggTopstrip::EggTopstrip(), and FltTrans::FltTrans().

bool ProgramBase::dispatch_image_type const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes one parameter, which is to indicate an image file type, like rgb, bmp, jpg, etc.

The data pointer is to a PNMFileType pointer.

Definition at line 1338 of file programBase.cxx.

References ProgramBase::_got_option_indent, ProgramBase::_got_terminal_width, and ProgramBase::_terminal_width.

Referenced by EggReader::add_texture_options().

bool ProgramBase::dispatch_int const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes one parameter, which is to be interpreted as an integer.

The data pointer is to an int variable.

Definition at line 964 of file programBase.cxx.

Referenced by EggMakeFont(), EggToBam::EggToBam(), GtkStats::GtkStats(), TestProgram::TestProgram(), and TextStats::TextStats().

bool ProgramBase::dispatch_int_pair const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes a pair of integer parameters.

The data pointer is to an array of two integers.

Definition at line 989 of file programBase.cxx.

bool ProgramBase::dispatch_none const string &  opt,
const string &  arg,
void * 
[static, protected, inherited]
 

Standard dispatch function for an option that takes no parameters, and does nothing special.

Typically this would be used for a boolean flag, whose presence means something and whose absence means something else. Use the bool_var parameter to add_option() to determine whether the option appears on the command line or not.

Definition at line 869 of file programBase.cxx.

References nout.

Referenced by BamInfo::BamInfo(), CVSCopy::CVSCopy(), EggMakeFont(), EggMultiBase::EggMultiBase(), EggMultiFilter::EggMultiFilter(), EggPalettize::EggPalettize(), EggReader::EggReader(), EggTextureCards::EggTextureCards(), EggToBam::EggToBam(), EggToC::EggToC(), EggToX::EggToX(), EggTrans::EggTrans(), FltInfo::FltInfo(), ImageResize::ImageResize(), MayaCopy::MayaCopy(), MayaToEgg::MayaToEgg(), SoftCVS::SoftCVS(), and TestProgram::TestProgram().

bool EggWriter::dispatch_normals ProgramBase self,
const string &  opt,
const string &  arg,
void *  mode
[static, protected, inherited]
 

Accepts one of -no, -np, etc.

and sets _normals_mode as indicated. The void * argument is a pointer to a NormalsMode variable that indicates which switch was passed.

Definition at line 392 of file eggWriter.cxx.

References EggBase::as_writer(), and EggWriter::ns_dispatch_rotate_xyz().

Referenced by EggWriter::add_normals_options().

bool ProgramBase::dispatch_path_replace const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a single component of a path replace request.

The data pointer is to a PathReplace variable.

Definition at line 1370 of file programBase.cxx.

Referenced by ProgramBase::add_option().

bool ProgramBase::dispatch_path_store const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a path store string.

The data pointer is to a PathStore variable.

Definition at line 1398 of file programBase.cxx.

Referenced by ProgramBase::add_option().

bool EggWriter::dispatch_rotate_axis ProgramBase self,
const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Handles -TA, which specifies a rotate transform about an arbitrary axis.

Var is an LMatrix4d.

Definition at line 541 of file eggWriter.cxx.

bool EggWriter::dispatch_rotate_xyz ProgramBase self,
const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Handles -TR, which specifies a rotate transform about the three cardinal axes.

Var is an LMatrix4d.

Definition at line 481 of file eggWriter.cxx.

bool EggWriter::dispatch_scale const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Handles -TS, which specifies a scale transform.

Var is an LMatrix4d.

Definition at line 438 of file eggWriter.cxx.

References EggBase::as_writer(), and EggWriter::ns_dispatch_rotate_axis().

bool ProgramBase::dispatch_search_path const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a single directory name to add to a search path.

The data pointer is to a DSearchPath variable. This kind of option may appear multiple times on the command line; each time, the new directory is appended.

Definition at line 1254 of file programBase.cxx.

Referenced by ProgramBase::add_option().

bool ProgramBase::dispatch_string const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a string.

The data pointer is to a string variable.

Definition at line 1203 of file programBase.cxx.

Referenced by SomethingToEgg::add_units_options(), CVSCopy::CVSCopy(), EggMakeFont(), EggPalettize::EggPalettize(), EggTopstrip::EggTopstrip(), and SoftCVS::SoftCVS().

bool EggWriter::dispatch_translate const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Handles -TT, which specifies a translate transform.

Var is an LMatrix4d.

Definition at line 598 of file eggWriter.cxx.

bool ProgramBase::dispatch_true const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes no parameters, and when it is present sets a bool variable to the 'true' value.

This is another way to handle a boolean flag. See also dispatch_none() and dispatch_false().

The data pointer is to a bool variable.

Definition at line 894 of file programBase.cxx.

References string_to_double().

Referenced by EggTopstrip::EggTopstrip().

bool ProgramBase::dispatch_units const string &  opt,
const string &  arg,
void *  var
[static, protected, inherited]
 

Standard dispatch function for an option that takes one parameter, which is to be interpreted as a unit of distance measurement.

The data pointer is to a DistanceUnit variable.

Definition at line 1310 of file programBase.cxx.

string EggMakeFont::expand_hyphen const string &  str  )  [private]
 

If a hyphen appears in the string anywhere but in the first and last position, replace it with a sequence of characters.

For example, 0-9 becomes 0123456789. Return the new string.

Definition at line 686 of file eggMakeFont.cxx.

void ProgramBase::format_text ostream &  out,
bool &  last_newline,
const string &  prefix,
int  indent_width,
const string &  text,
int  line_width
[static, protected, inherited]
 

Word-wraps the indicated text to the indicated output stream.

The first line is prefixed with the indicated prefix, then tabbed over to indent_width where the text actually begins. A newline is inserted at or before column line_width. Each subsequent line begins with indent_width spaces.

An embedded newline character ('
') forces a line break, while an embedded carriage-return character (''), or two or more consecutive newlines, marks a paragraph break, which is usually printed as a blank line. Redundant newline and carriage-return characters are generally ignored.

The flag last_newline should be initialized to false for the first call to format_text, and then preserved for future calls; it tracks the state of trailing newline characters between calls so we can correctly identify doubled newlines.

Definition at line 1479 of file programBase.cxx.

Referenced by ProgramBase::show_options().

string ProgramBase::get_exec_command  )  const [inherited]
 

Returns the command that invoked this program, as a shell-friendly string, suitable for pasting into the comments of output files.

Definition at line 396 of file programBase.cxx.

ostream & WithOutputFile::get_output  )  [inherited]
 

Returns an output stream that corresponds to the user's intended egg file output--either stdout, or the named output file.

Definition at line 68 of file withOutputFile.cxx.

References WithOutputFile::_output_filename, and Filename::set_binary().

Filename WithOutputFile::get_output_filename  )  const [inherited]
 

If has_output_filename() returns true, this is the filename that the user specified.

Otherwise, it returns the empty string.

Definition at line 127 of file withOutputFile.cxx.

References WithOutputFile::_allow_last_param, WithOutputFile::_allow_stdout, WithOutputFile::_got_output_filename, WithOutputFile::_output_filename, WithOutputFile::_preferred_extension, Filename::from_os_specific(), Filename::get_extension(), nout, and WithOutputFile::verify_output_file_safe().

TexCoordd EggMakeFont::get_uv double  x,
double  y
[private]
 

Given the X, Y coordinates of a particular pixel on the image, return the corresponding UV coordinates.

Definition at line 291 of file eggMakeFont.cxx.

References EggBase::_coordinate_system.

LPoint2d EggMakeFont::get_xy double  x,
double  y
[private]
 

Given X, Y coordinates in pixels, scale to unit coordinates for the character's geometry.

Definition at line 308 of file eggMakeFont.cxx.

References height, width, x, and y.

bool EggMakeFont::handle_args ProgramBase::Args args  )  [protected, virtual]
 

Does something with the additional arguments on the command line (after all the -options have been parsed).

Returns true if the arguments are good, false otherwise.

Reimplemented from EggWriter.

Definition at line 215 of file eggMakeFont.cxx.

References EggBase::as_writer(), and ns_dispatch_dimensions().

bool ProgramBase::handle_help_option const string &  opt,
const string &  arg,
void *  data
[static, protected, inherited]
 

Called when the user enters '-h', this describes how to use the program and then exits.

Definition at line 1423 of file programBase.cxx.

bool WithOutputFile::has_output_filename  )  const [inherited]
 

Returns true if the user specified an output filename, false otherwise (e.g.

the output file is implicitly stdout).

Definition at line 110 of file withOutputFile.cxx.

EggVertex * EggMakeFont::make_vertex const LPoint2d &  xy  )  [private]
 

Allocates and returns a new vertex from the vertex pool representing the indicated 2-d coordinates.

Definition at line 323 of file eggMakeFont.cxx.

bool EggMakeFont::ns_dispatch_dimensions const string &  opt,
const string &  arg
[protected]
 

Reads the dimensions of the output image and stores them in _output_[xyz]size.

Definition at line 254 of file eggMakeFont.cxx.

Referenced by handle_args().

bool EggWriter::ns_dispatch_normals const string &  opt,
const string &  arg,
void *  mode
[protected, inherited]
 

Accepts one of -no, -np, etc.

and sets _normals_mode as indicated. The void * argument is a pointer to a NormalsMode variable that indicates which switch was passed.

Definition at line 413 of file eggWriter.cxx.

References string_to_double().

Referenced by EggWriter::write_egg_file().

bool EggWriter::ns_dispatch_rotate_axis const string &  opt,
const string &  arg,
void *  var
[protected, inherited]
 

Handles -TA, which specifies a rotate transform about an arbitrary axis.

Var is an LMatrix4d.

Definition at line 558 of file eggWriter.cxx.

Referenced by EggWriter::dispatch_scale().

bool EggWriter::ns_dispatch_rotate_xyz const string &  opt,
const string &  arg,
void *  var
[protected, inherited]
 

Handles -TR, which specifies a rotate transform about the three cardinal axes.

Var is an LMatrix4d.

Definition at line 498 of file eggWriter.cxx.

Referenced by EggWriter::dispatch_normals().

void ProgramBase::parse_command_line int  argc,
char *  argv[]
[virtual, inherited]
 

Dispatches on each of the options on the command line, and passes the remaining parameters to handle_args().

If an error on the command line is detected, will automatically call show_usage() and exit(1).

Reimplemented in GtkBase.

Definition at line 241 of file programBase.cxx.

References ProgramBase::_options_by_name.

Referenced by GtkBase::~GtkBase().

bool EggWriter::post_command_line  )  [protected, virtual, inherited]
 

This is called after the command line has been completely processed, and it gives the program a chance to do some last-minute processing and validation of the options and arguments.

It should return true if everything is fine, false if there is an error.

Reimplemented from EggBase.

Reimplemented in EggFilter, SomethingToEgg, and EggCrop.

Definition at line 366 of file eggWriter.cxx.

void EggWriter::post_process_egg_file  )  [virtual, inherited]
 

Performs any processing of the egg file that is appropriate before writing it out.

This includes any normal adjustments the user requested via -np, etc.

Normally, you should not need to call this function directly; write_egg_file() calls it for you. You should call this only if you do not use write_egg_file() to write out the resulting egg file.

Reimplemented in SomethingToEgg.

Definition at line 260 of file eggWriter.cxx.

References WithOutputFile::_got_output_filename, ProgramBase::_got_path_directory, WithOutputFile::_output_filename, ProgramBase::_path_replace, WithOutputFile::check_last_arg(), Filename::get_dirname(), and nout.

bool ProgramBase::redescribe_option const string &  option,
const string &  description
[protected, inherited]
 

Changes the description associated with a previously-defined option.

Returns true if the option was changed, false if it hadn't been defined.

Definition at line 726 of file programBase.cxx.

Referenced by BamToEgg::BamToEgg(), EggToBam::EggToBam(), FltToEgg::FltToEgg(), LwoToEgg::LwoToEgg(), and XFileToEgg::XFileToEgg().

bool ProgramBase::remove_option const string &  option  )  [protected, inherited]
 

Removes a previously-defined option.

Returns true if the option was removed, false if it hadn't existed.

Definition at line 746 of file programBase.cxx.

void EggMakeFont::run void   ) 
 

Definition at line 718 of file eggMakeFont.cxx.

References EggBase::_data, EggTexture::F_alpha, EggTexture::F_luminance_alpha, EggTexture::F_rgba, EggTexture::F_unspecified, and EggTexture::Format.

void ProgramBase::set_program_description const string &  description  )  [protected, inherited]
 

Sets the description of the program that will be reported by show_usage().

The description should be one long string of text. Embedded newline characters are interpreted as paragraph breaks and printed as blank lines.

Definition at line 508 of file programBase.cxx.

Referenced by BamToEgg::BamToEgg(), EggTrans::EggTrans(), FltToEgg::FltToEgg(), FltTrans::FltTrans(), LwoToEgg::LwoToEgg(), and XFileToEgg::XFileToEgg().

void ProgramBase::show_description  )  [inherited]
 

Writes the program description to stderr.

Definition at line 153 of file programBase.cxx.

References ProgramBase::_program_name, ProgramBase::_runlines, Filename::get_basename_wo_extension(), nout, and ProgramBase::show_text().

Referenced by ProgramBase::dispatch_color().

void ProgramBase::show_options  )  [inherited]
 

Describes each of the available options to stderr.

Definition at line 186 of file programBase.cxx.

References ProgramBase::_last_newline, ProgramBase::_terminal_width, ProgramBase::format_text(), and ProgramBase::get_terminal_width().

Referenced by ProgramBase::dispatch_color().

void ProgramBase::show_text const string &  prefix,
int  indent_width,
string  text
[inherited]
 

Formats the indicated text and its prefix for output to stderr with the known _terminal_width.

Definition at line 214 of file programBase.cxx.

References ProgramBase::_program_args, ProgramBase::_program_name, argv, Filename::from_os_specific(), long_options, and options.

void ProgramBase::show_text const string &  text  )  [inline, inherited]
 

Formats the indicated text to stderr with the known _terminal_width.

Definition at line 34 of file programBase.I.

Referenced by ProgramBase::show_description(), ProgramBase::show_usage(), and WordWrapStreamBuf::write_chars().

void ProgramBase::show_usage  )  [inherited]
 

Writes the usage line(s) to stderr.

Definition at line 166 of file programBase.cxx.

References ProgramBase::Option::_description, ProgramBase::_got_option_indent, ProgramBase::Option::_option, ProgramBase::_option_indent, ProgramBase::_options_by_index, ProgramBase::Option::_parm_name, ProgramBase::_terminal_width, ProgramBase::get_terminal_width(), nout, ProgramBase::show_text(), and ProgramBase::sort_options().

Referenced by ProgramBase::dispatch_color().

void EggMakeFont::unsmooth_rgb PNMImage image  )  [private]
 

Make the image jaggy in RGB (but leave it antialiased in alpha).

This will result in correct antialiasing when the text is loaded in the player.

Definition at line 660 of file eggMakeFont.cxx.

References _font, _input_font_filename, and nout.

bool WithOutputFile::verify_output_file_safe  )  const [protected, inherited]
 

This is called when the output file is given as the last parameter on the command line.

Since this is a fairly dangerous way to specify the output file (it's easy to accidentally overwrite an input file this way), the convention is to disallow this syntax if the output file already exists.

This function will test if the output file exists, and issue a warning message if it does, returning false. If all is well, it will return true.

Definition at line 217 of file withOutputFile.cxx.

Referenced by WithOutputFile::get_output_filename().

void EggWriter::write_egg_file  )  [inherited]
 

Writes out the egg file as the normal result of the program.

This calls post_process_egg_file() to perform any last minute processing (like normal computation) and then writes out the file to the output stream returned by get_output().

Definition at line 315 of file eggWriter.cxx.

References EggBase::as_writer(), and EggWriter::ns_dispatch_normals().

Referenced by EggCrop::post_command_line().


Member Data Documentation

bool WithOutputFile::_allow_last_param [protected, inherited]
 

Definition at line 64 of file withOutputFile.h.

Referenced by WithOutputFile::get_output_filename().

bool WithOutputFile::_allow_stdout [protected, inherited]
 

Definition at line 65 of file withOutputFile.h.

Referenced by WithOutputFile::get_output_filename(), and WithOutputFile::~WithOutputFile().

Colorf EggMakeFont::_bg [private]
 

Definition at line 85 of file eggMakeFont.h.

bool WithOutputFile::_binary_output [protected, inherited]
 

Definition at line 66 of file withOutputFile.h.

double EggMakeFont::_buffer_pixels [private]
 

Definition at line 88 of file eggMakeFont.h.

CoordinateSystem EggBase::_coordinate_system [protected, inherited]
 

Definition at line 72 of file eggBase.h.

Referenced by EggMultiBase::EggMultiBase(), get_uv(), and XFileToEgg::XFileToEgg().

EggData EggBase::_data [protected, inherited]
 

Definition at line 73 of file eggBase.h.

Referenced by EggWriter::as_writer(), EggCrop::post_command_line(), EggTrans::run(), EggToC::run(), and run().

double EggMakeFont::_ds [private]
 

Definition at line 94 of file eggMakeFont.h.

Colorf EggMakeFont::_fg [private]
 

Definition at line 85 of file eggMakeFont.h.

FontFile* EggMakeFont::_font [private]
 

Definition at line 102 of file eggMakeFont.h.

Referenced by unsmooth_rgb().

double EggMakeFont::_gaussian_radius [private]
 

Definition at line 93 of file eggMakeFont.h.

bool EggMakeFont::_get_all [private]
 

Definition at line 97 of file eggMakeFont.h.

bool EggBase::_got_coordinate_system [protected, inherited]
 

Definition at line 71 of file eggBase.h.

Referenced by EggMultiBase::EggMultiBase().

bool WithOutputFile::_got_output_filename [protected, inherited]
 

Definition at line 68 of file withOutputFile.h.

Referenced by SomethingToEgg::apply_parameters(), WithOutputFile::check_last_arg(), FltTrans::FltTrans(), WithOutputFile::get_output_filename(), EggWriter::post_process_egg_file(), and WithOutputFile::~WithOutputFile().

bool EggMakeFont::_got_output_size [private]
 

Definition at line 84 of file eggMakeFont.h.

bool ProgramBase::_got_path_directory [protected, inherited]
 

Definition at line 125 of file programBase.h.

Referenced by ProgramBase::add_option(), and EggWriter::post_process_egg_file().

bool ProgramBase::_got_path_store [protected, inherited]
 

Definition at line 124 of file programBase.h.

Referenced by ProgramBase::add_option().

bool EggMakeFont::_got_scale_factor [private]
 

Definition at line 90 of file eggMakeFont.h.

bool EggWriter::_got_transform [protected, inherited]
 

Definition at line 77 of file eggWriter.h.

Filename EggMakeFont::_input_font_filename [private]
 

Definition at line 83 of file eggMakeFont.h.

Referenced by unsmooth_rgb().

bool EggMakeFont::_no_reduce [private]
 

Definition at line 92 of file eggMakeFont.h.

NormalsMode EggWriter::_normals_mode [protected, inherited]
 

Definition at line 74 of file eggWriter.h.

Referenced by EggWriter::handle_args().

double EggWriter::_normals_threshold [protected, inherited]
 

Definition at line 75 of file eggWriter.h.

Referenced by EggWriter::handle_args().

string EggMakeFont::_only_chars [private]
 

Definition at line 98 of file eggMakeFont.h.

Filename WithOutputFile::_output_filename [protected, inherited]
 

Definition at line 69 of file withOutputFile.h.

Referenced by SomethingToEgg::apply_parameters(), WithOutputFile::check_last_arg(), FltTrans::FltTrans(), WithOutputFile::get_output(), WithOutputFile::get_output_filename(), EggWriter::post_process_egg_file(), and WithOutputFile::~WithOutputFile().

Filename EggMakeFont::_output_image_filename [private]
 

Definition at line 82 of file eggMakeFont.h.

int EggMakeFont::_output_xsize [private]
 

Definition at line 87 of file eggMakeFont.h.

int EggMakeFont::_output_ysize [private]
 

Definition at line 87 of file eggMakeFont.h.

int EggMakeFont::_output_zsize [private]
 

Definition at line 87 of file eggMakeFont.h.

PointerTo< PathReplace > ProgramBase::_path_replace [protected, inherited]
 

Definition at line 123 of file programBase.h.

Referenced by ProgramBase::add_option(), and EggWriter::post_process_egg_file().

double EggMakeFont::_poly_pixels [private]
 

Definition at line 89 of file eggMakeFont.h.

double EggMakeFont::_ppu [private]
 

Definition at line 96 of file eggMakeFont.h.

string WithOutputFile::_preferred_extension [protected, inherited]
 

Definition at line 67 of file withOutputFile.h.

Referenced by FltTrans::FltTrans(), and WithOutputFile::get_output_filename().

Args ProgramBase::_program_args [inherited]
 

Definition at line 68 of file programBase.h.

Referenced by ProgramBase::show_text().

Filename ProgramBase::_program_name [inherited]
 

Definition at line 67 of file programBase.h.

Referenced by ProgramBase::show_description(), and ProgramBase::show_text().

double EggMakeFont::_scale [private]
 

Definition at line 95 of file eggMakeFont.h.

double EggMakeFont::_scale_factor [private]
 

Definition at line 91 of file eggMakeFont.h.

bool EggMakeFont::_small_caps [private]
 

Definition at line 99 of file eggMakeFont.h.

Referenced by copy_character().

double EggMakeFont::_small_caps_scale [private]
 

Definition at line 100 of file eggMakeFont.h.

Referenced by copy_character().

LMatrix4d EggWriter::_transform [protected, inherited]
 

Definition at line 78 of file eggWriter.h.

bool EggMakeFont::_use_alpha [private]
 

Definition at line 86 of file eggMakeFont.h.


The documentation for this class was generated from the following files:
Generated on Fri May 2 03:26:17 2003 for Panda-Tool by doxygen1.3