repair comment blocks

This commit is contained in:
David Rose 2010-06-30 18:33:28 +00:00
parent fec47d9aea
commit 50990675bd
11 changed files with 741 additions and 0 deletions

View File

@ -3,3 +3,72 @@
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef BACKUPCATALOG_H
#define BACKUPCATALOG_H
#include "pandaappbase.h"
#include "documentSpec.h"
#include "filename.h"
#include "pvector.h"
#include "pmap.h"
#include "pset.h"
////////////////////////////////////////////////////////////////////
// Class : BackupCatalog
// Description : This is the list of previous versions of this file
// (and possibly other files) stored in the "catalog", a
// text file within the download directory.
////////////////////////////////////////////////////////////////////
class BackupCatalog {
public:
BackupCatalog();
~BackupCatalog();
bool read(const Filename &filename);
bool write(const Filename &filename);
void clear();
class Entry {
public:
INLINE Entry();
INLINE bool operator < (const Entry &other) const;
INLINE const HTTPDate &get_date() const;
void delete_file(const Filename &dirname, const string &reason);
void input(istream &in);
void output(ostream &out) const;
void write(ostream &out) const;
string _document_name;
string _filename;
DocumentSpec _document_spec;
HTTPDate _download_date;
};
typedef pvector<Entry *> Entries;
typedef pmap<string, Entries> Table;
Table _table;
typedef pset<string> Filenames;
Filenames _filenames;
bool _dirty;
};
INLINE istream &operator >> (istream &in, BackupCatalog::Entry &entry);
INLINE ostream &operator << (ostream &out, const BackupCatalog::Entry &entry);
#include "backupCatalog.I"
#endif

View File

@ -3,3 +3,82 @@
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef HTTPBACKUP_H
#define HTTPBACKUP_H
#include "pandaappbase.h"
#include "programBase.h"
#include "backupCatalog.h"
#include "httpClient.h"
#include "urlSpec.h"
////////////////////////////////////////////////////////////////////
// Class : HTTPBackup
// Description : This program is designed to run periodically as a
// background task, e.g. via a cron job. It fetches the
// latest copy of a document from an HTTP server and
// stores it, along with an optional number of previous
// versions, in a local directory so that it may be
// backed up to tape.
//
// If the copy on disk is already the same as the latest
// copy available on the HTTP server, this program does
// nothing.
////////////////////////////////////////////////////////////////////
class HTTPBackup : public ProgramBase {
public:
HTTPBackup();
protected:
virtual bool handle_args(Args &args);
virtual bool post_command_line();
static bool dispatch_url(const string &opt, const string &arg, void *var);
public:
void run();
private:
bool fetch_latest();
bool cleanup_old();
void check_unique(string &filename);
private:
string _proxy;
bool _got_proxy;
URLSpec _url;
Filename _dirname;
Filename _catalog_name;
string _document_name;
string _version_append;
bool _always_download;
double _max_keep_days;
bool _got_max_keep_days;
double _min_keep_days;
int _max_keep_versions;
bool _got_max_keep_versions;
int _min_keep_versions;
double _check_days;
bool _got_check_days;
HTTPDate _max_keep_date;
HTTPDate _min_keep_date;
HTTPDate _now;
HTTPClient _http;
BackupCatalog _catalog;
};
#endif

View File

@ -2,4 +2,21 @@
// Created by: drose (04Apr02)
//
////////////////////////////////////////////////////////////////////
///
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef DEFAULT_FONT_H
#define DEFAULT_FONT_H
extern const unsigned char default_font[];
extern const int default_font_size;
#endif

View File

@ -3,3 +3,34 @@
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef DEFAULT_INDEX_ICONS_H
#define DEFAULT_INDEX_ICONS_H
extern const char *default_left_icon_filename;
extern const char *default_right_icon_filename;
extern const char *default_up_icon_filename;
extern const char *default_movie_icon_filename;
extern const char *default_sound_icon_filename;
extern const unsigned char default_left_icon[];
extern const int default_left_icon_len;
extern const unsigned char default_right_icon[];
extern const int default_right_icon_len;
extern const unsigned char default_up_icon[];
extern const int default_up_icon_len;
extern const unsigned char default_movie_icon[];
extern const int default_movie_icon_len;
extern const unsigned char default_sound_icon[];
extern const int default_sound_icon_len;
#endif

View File

@ -3,3 +3,57 @@
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef FONTSAMPLES_H
#define FONTSAMPLES_H
#include "pandatoolbase.h"
#include "programBase.h"
#include "filename.h"
#include "pvector.h"
class PNMTextMaker;
////////////////////////////////////////////////////////////////////
// Class : FontSamples
// Description : A program to generate one or more image files showing
// samples of various fonts.
////////////////////////////////////////////////////////////////////
class FontSamples : public ProgramBase {
public:
FontSamples();
virtual ~FontSamples();
protected:
virtual bool handle_args(Args &args);
virtual bool post_command_line();
public:
void run();
string _sample_text;
int _sample_height;
int _name_height;
Filename _name_font_filename;
double _font_aa_factor;
int _vert_space;
int _image_width;
int _image_height;
string _output_filename;
typedef pvector<Filename> Filenames;
Filenames _font_filenames;
PNMTextMaker *_name_text_maker;
};
#endif

View File

@ -3,3 +3,94 @@
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef INDEXIMAGE_H
#define INDEXIMAGE_H
#include "pandatoolbase.h"
#include "filename.h"
#include "pvector.h"
class RollDirectory;
class Photo;
class PNMTextMaker;
class PNMImage;
class PNMImageHeader;
////////////////////////////////////////////////////////////////////
// Class : IndexImage
// Description : An aggregate image containing several thumbnails, one
// for each of several photos. A roll directory will
// collect its photos into one or more IndexImages.
////////////////////////////////////////////////////////////////////
class IndexImage {
public:
IndexImage(RollDirectory *dir, int index);
~IndexImage();
bool add_photo(int index);
bool generate_images(const Filename &archive_dir, PNMTextMaker *text_maker);
bool make_reduced_image(Photo *photo, PNMImage &reduced_image,
bool generate_index_image, bool force_reduced);
bool generate_html(ostream &root_html, const Filename &archive_dir,
const Filename &roll_dir_root);
bool copy_reduced(const Filename &archive_dir);
void output(ostream &out) const;
void write(ostream &out, int indent_level) const;
private:
bool generate_reduced_html(ostream &html, Photo *photo, int photo_index,
int pi, const Filename &roll_dir_root);
void generate_nav_buttons(ostream &html, const Filename &prev_photo_filename,
const Filename &next_photo_filename,
const string &up_href);
static void compute_reduction(const PNMImageHeader &source_image,
PNMImage &dest_image,
int x_size, int y_size);
static void draw_box(PNMImage &image);
static void draw_frame(PNMImage &image,
int frame_left, int frame_top,
int frame_width, int frame_height,
int hole_left, int hole_top,
int hole_width, int hole_height);
private:
RollDirectory *_dir;
int _index;
string _name;
class PhotoInfo {
public:
int _photo_index;
int _x_place;
int _y_place;
};
typedef pvector<PhotoInfo> Photos;
Photos _photos;
int _index_x_size;
int _index_y_size;
string _index_basename;
};
INLINE ostream &operator << (ostream &out, const IndexImage &d) {
d.output(out);
return out;
}
#endif

View File

@ -3,3 +3,152 @@
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef INDEXPARAMETERS_H
#define INDEXPARAMETERS_H
#include "pandatoolbase.h"
#include "filename.h"
#include "dSearchPath.h"
#include "pnmImage.h"
// Some of these constants may be modified by command-line parameters
// from the user.
// The maximum size of the index image. It will shrink vertically to
// fit the images it contains, and it will shrink horizontally to fit
// a complete row of images (even if it does not contain a complete
// row). It will never be larger than this.
extern int max_index_size_array[2];
#define max_index_width (max_index_size_array[0])
#define max_index_height (max_index_size_array[1])
// The size of the individual thumbnail images, including the frames
// (if present). Thumbnail images are scaled to fit within this box.
extern int thumb_size_array[2];
#define thumb_width (thumb_size_array[0])
#define thumb_height (thumb_size_array[1])
// The total number of pixels reserved for the caption under each
// thumbnail image. This is the caption_font_size plus whatever
// spacing should be included between the caption and the image.
extern int thumb_caption_height;
// The size in pixels of the caption font. This depends on the point
// size of the font as reported by FreeType, so the actual height of
// the letters might be slightly lower or higher than this, depending
// on the font.
extern int caption_font_size;
// The amount of space, in pixels, between each two neighboring
// thumbnail images, and around the overall index image.
extern int thumb_space_array[2];
#define thumb_x_space (thumb_space_array[0])
#define thumb_y_space (thumb_space_array[1])
// The ratio by which the thumbnail images are reduced further when
// frames are drawn, to allow room for a frame that resembles a slide
// mount.
extern double frame_reduction_factor;
// The number of pixels of thickness to draw for the frames' outer
// bevels and inner bevels, respectively.
extern int frame_outer_bevel;
extern int frame_inner_bevel;
// The size of the reduced images on the individual image pages. The
// source image will be scaled to fit within this rectangle.
extern int reduced_size_array[2];
#define reduced_width (reduced_size_array[0])
#define reduced_height (reduced_size_array[1])
// The directory at the root of the output hierarchy (or as specified
// by -a on the command line).
extern Filename archive_dir;
// The filenames (or URLS) to the icon images for navigating the
// individual image pages.
extern Filename prev_icon;
extern Filename next_icon;
extern Filename up_icon;
extern Filename movie_icon;
extern Filename sound_icon;
const PNMImage &get_movie_icon();
const PNMImage &get_sound_icon();
// True to regenerate every image, whether it appears to need it or
// not.
extern bool force_regenerate;
// True to use the Rose formatting convention for roll directory names.
extern bool format_rose;
// True to sort roll directory names by date. Useful only with -r.
extern bool sort_date;
// True to place dummy thumbnails instead of loading actual images.
extern bool dummy_mode;
// True to draw frames (slide mounts) around each thumbnail image.
extern bool draw_frames;
// True to avoid introducing each roll directory on the index page
// with its own little header. This also ignored the roll.cm file if
// it exists.
extern bool omit_roll_headers;
extern DSearchPath cm_search;
// True to omit links to the full-size source images.
extern bool omit_full_links;
// True to omit complete.htm
extern bool omit_complete;
// True to caption photos with just a frame number instead of the
// whole image basename. This only works if the photo image filenames
// consist of the roll directory name concatenated with a frame number.
extern bool caption_frame_numbers;
void finalize_parameters();
// The following parameters are all computed based on the above.
// The number of thumbnail images that fit across an index image,
// horizontally and vertically.
extern int thumb_count_x;
extern int thumb_count_y;
// The total number of thumbnail images within each index image.
extern int max_thumbs;
// The number of pixels wide each index image will actually be, based
// on thumb_count_x.
extern int actual_index_width;
// The actual size of the rectangle each thumbnail image must be
// scaled into, accounting for the presence of a frame.
extern int thumb_interior_width;
extern int thumb_interior_height;
Filename compose_href(const Filename &rel_dir, const Filename &user_prefix,
const Filename &basename = Filename());
string escape_html(const string &input);
bool copy_file(const Filename &source_file, const Filename &dest_dir);
#endif

View File

@ -3,3 +3,64 @@
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef INDEXIFY_H
#define INDEXIFY_H
#include "pandatoolbase.h"
#include "programBase.h"
#include "filename.h"
#include "pvector.h"
class RollDirectory;
class PNMTextMaker;
////////////////////////////////////////////////////////////////////
// Class : Indexify
// Description : A program to generate a series of thumbnail images
// and HTML pages to view a number of image files in an
// archive directory, before writing the archive to a
// permanent medium like a CD.
////////////////////////////////////////////////////////////////////
class Indexify : public ProgramBase {
public:
Indexify();
virtual ~Indexify();
protected:
virtual bool handle_args(Args &args);
virtual bool post_command_line();
static bool dispatch_caption(const string &opt, const string &arg, void *var);
public:
void run();
void do_generate_images();
void do_copy_reduced();
string _front_title;
Filename _roll_dir_root;
string _photo_extension;
string _movie_extension;
string _sound_extension;
Filename _font_filename;
bool _generate_icons;
double _font_aa_factor;
bool _copy_reduced;
typedef pvector<RollDirectory *> RollDirs;
RollDirs _roll_dirs;
PNMTextMaker *_text_maker;
};
#endif

View File

@ -3,3 +3,65 @@
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef PHOTO_H
#define PHOTO_H
#include "pandatoolbase.h"
#include "filename.h"
class RollDirectory;
////////////////////////////////////////////////////////////////////
// Class : Photo
// Description : A single photo image within a roll directory.
////////////////////////////////////////////////////////////////////
class Photo {
public:
Photo(RollDirectory *dir, const Filename &basename,
const string &movie_extension, const string &sound_extension);
const Filename &get_basename() const;
const Filename &get_movie() const;
const Filename &get_sound() const;
const Filename &get_cm() const;
const string &get_name() const;
const string &get_frame_number() const;
void output(ostream &out) const;
public:
int _full_x_size;
int _full_y_size;
int _reduced_x_size;
int _reduced_y_size;
bool _has_reduced;
bool _has_movie;
bool _has_sound;
bool _has_cm;
private:
RollDirectory *_dir;
Filename _basename;
Filename _movie;
Filename _sound;
Filename _cm;
string _name;
string _frame_number;
};
INLINE ostream &operator << (ostream &out, const Photo &p) {
p.output(out);
return out;
}
#endif

View File

@ -3,3 +3,110 @@
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef ROLLDIRECTORY_H
#define ROLLDIRECTORY_H
#include "pandatoolbase.h"
#include "filename.h"
#include "pvector.h"
class Photo;
class IndexImage;
class PNMTextMaker;
////////////////////////////////////////////////////////////////////
// Class : RollDirectory
// Description : A representation of a single directory containing one
// or more photos.
////////////////////////////////////////////////////////////////////
class RollDirectory {
public:
RollDirectory(const Filename &dir);
~RollDirectory();
const Filename &get_dir() const;
const string &get_basename() const;
const string &get_name() const;
const string &get_desc() const;
bool scan(const string &photo_extension, const string &movie_extension,
const string &sound_extension);
void collect_index_images();
bool sort_date_before(const RollDirectory &other) const;
const Filename &get_newest_contributing_filename() const;
bool is_empty() const;
int get_num_photos() const;
Photo *get_photo(int n) const;
int get_num_index_images() const;
IndexImage *get_index_image(int n) const;
bool generate_images(const Filename &archive_dir, PNMTextMaker *text_maker);
bool generate_html(const Filename &archive_dir,
const Filename &roll_dir_root);
const string &get_comment_html() const;
const string &get_index_html() const;
bool copy_reduced(const Filename &archive_dir);
void output(ostream &out) const;
void write(ostream &out, int indent_level) const;
static bool insert_html_comment(ostream &html, Filename cm_filename);
private:
void add_photo(const Filename &basename, const string &movie_extension,
const string &sound_extension);
void add_contributing_filename(const Filename &filename);
static bool insert_html_comment_body(ostream &html, istream &cm);
static string format_basename(const string &basename);
void generate_nav_buttons(ostream &html,
const Filename &prev_roll_filename,
const Filename &next_roll_filename,
const string &up_href);
static bool compare_filenames(const string &a, const string &b);
public:
RollDirectory *_prev;
RollDirectory *_next;
private:
Filename _dir;
string _basename;
string _name;
string _desc;
typedef pvector<Photo *> Photos;
Photos _photos;
bool _got_ds_file;
Filename _ds_filename;
bool _got_ls_file;
Filename _ls_filename;
Filename _newest_contributing_filename;
typedef pvector<IndexImage *> IndexImages;
IndexImages _index_images;
string _comment_html;
string _index_html;
};
INLINE ostream &operator << (ostream &out, const RollDirectory &d) {
d.output(out);
return out;
}
#endif

View File

@ -3,3 +3,24 @@
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef PANDAAPPSYMBOLS_H
#define PANDAAPPSYMBOLS_H
/* See dtoolsymbols.h for a rant on the purpose of this file. */
#if defined(WIN32_VC) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC)
#else /* !WIN32_VC */
#endif /* WIN32_VC */
#endif