From 10ca7149aca0befafb73df2ff1089fe989d1b962 Mon Sep 17 00:00:00 2001 From: David Rose Date: Sun, 7 Apr 2002 18:37:10 +0000 Subject: [PATCH] even more options --- pandaapp/src/indexify/indexImage.cxx | 14 ++++++++--- pandaapp/src/indexify/indexImage.h | 3 ++- pandaapp/src/indexify/indexParameters.cxx | 7 ++++-- pandaapp/src/indexify/indexParameters.h | 10 ++++++++ pandaapp/src/indexify/indexify.cxx | 14 +++++++++++ pandaapp/src/indexify/photo.cxx | 29 +++++++++++++++++++++++ pandaapp/src/indexify/photo.h | 2 ++ pandaapp/src/indexify/rollDirectory.cxx | 24 ++++++++++--------- 8 files changed, 86 insertions(+), 17 deletions(-) diff --git a/pandaapp/src/indexify/indexImage.cxx b/pandaapp/src/indexify/indexImage.cxx index 2dd52eb2b7..d7a1b882f7 100644 --- a/pandaapp/src/indexify/indexImage.cxx +++ b/pandaapp/src/indexify/indexImage.cxx @@ -188,7 +188,15 @@ generate_images(const Filename &archive_dir, TextMaker *text_maker) { photo->_full_x_size = photo_image.get_x_size(); photo->_full_y_size = photo_image.get_y_size(); - if (!dummy_mode && generate_index_image) { + if (dummy_mode) { + // In dummy mode, we may or may not actually have a reduced + // image. In either case, ignore the file and compute its + // appropriate size from the source image. + compute_reduction(photo_image, reduced_image, reduced_width, reduced_height); + photo->_reduced_x_size = reduced_image.get_x_size(); + photo->_reduced_y_size = reduced_image.get_y_size(); + + } else if (generate_index_image) { // Now read the reduced image from disk, so we can put it on // the index image. nout << "Reading " << reduced_filename << "\n"; @@ -241,7 +249,7 @@ generate_images(const Filename &archive_dir, TextMaker *text_maker) { pinfo._y_place + y_center); if (text_maker != (TextMaker *)NULL) { - text_maker->generate_into(photo->get_name(), index_image, + text_maker->generate_into(photo->get_frame_number(), index_image, pinfo._x_place + thumb_width / 2, pinfo._y_place + thumb_height + thumb_caption_height); } @@ -597,7 +605,7 @@ compose_href(const Filename &rel_dir, const Filename &user_prefix, // the dest_image to the computed size. //////////////////////////////////////////////////////////////////// void IndexImage:: -compute_reduction(const PNMImage &source_image, PNMImage &dest_image, +compute_reduction(const PNMImageHeader &source_image, PNMImage &dest_image, int x_size, int y_size) { double x_scale = (double)x_size / (double)source_image.get_x_size(); double y_scale = (double)y_size / (double)source_image.get_y_size(); diff --git a/pandaapp/src/indexify/indexImage.h b/pandaapp/src/indexify/indexImage.h index a47f7de04d..3415d87967 100644 --- a/pandaapp/src/indexify/indexImage.h +++ b/pandaapp/src/indexify/indexImage.h @@ -28,6 +28,7 @@ class RollDirectory; class Photo; class TextMaker; class PNMImage; +class PNMImageHeader; //////////////////////////////////////////////////////////////////// // Class : IndexImage @@ -58,7 +59,7 @@ private: Filename compose_href(const Filename &rel_dir, const Filename &user_prefix, const Filename &basename = Filename()); - static void compute_reduction(const PNMImage &source_image, + static void compute_reduction(const PNMImageHeader &source_image, PNMImage &dest_image, int x_size, int y_size); static void draw_box(PNMImage &image); diff --git a/pandaapp/src/indexify/indexParameters.cxx b/pandaapp/src/indexify/indexParameters.cxx index 08efb8dae0..56d187a032 100644 --- a/pandaapp/src/indexify/indexParameters.cxx +++ b/pandaapp/src/indexify/indexParameters.cxx @@ -28,8 +28,8 @@ int thumb_height = 100; int thumb_caption_height = 12; int caption_font_size = 12; -int thumb_x_space = 14; -int thumb_y_space = 14; +int thumb_x_space = 12; +int thumb_y_space = 12; double frame_reduction_factor = 0.75; int frame_outer_bevel = 2; @@ -46,6 +46,9 @@ bool force_regenerate = false; bool format_rose = false; bool dummy_mode = false; bool draw_frames = false; +bool omit_roll_headers = false; +bool caption_frame_numbers = false; + // Computed parameters int thumb_count_x; diff --git a/pandaapp/src/indexify/indexParameters.h b/pandaapp/src/indexify/indexParameters.h index 0ba047b867..c7c51fc05b 100644 --- a/pandaapp/src/indexify/indexParameters.h +++ b/pandaapp/src/indexify/indexParameters.h @@ -88,6 +88,16 @@ 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; + +// 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(); diff --git a/pandaapp/src/indexify/indexify.cxx b/pandaapp/src/indexify/indexify.cxx index aed8e85b50..aff0816e03 100644 --- a/pandaapp/src/indexify/indexify.cxx +++ b/pandaapp/src/indexify/indexify.cxx @@ -130,6 +130,12 @@ Indexify() { "-up are not explicitly specified.", &Indexify::dispatch_none, &_generate_icons); + add_option + ("omitrh", "", 0, + "Omits roll headers introducing each roll directory, including any " + "headers defined in roll.cm files.", + &Indexify::dispatch_none, &omit_roll_headers); + add_option ("caption", "size[,spacing]", 0, "Specifies the font size in pixels of the thumbnail captions. If the " @@ -138,6 +144,14 @@ Indexify() { "-caption 0 to disable thumbnail captions.", &Indexify::dispatch_caption, NULL); + add_option + ("fnum", "", 0, + "Writes the frame number of each thumbnail image into the caption " + "on the index page, instead of the image filename. This only works " + "if the photo image filenames consist of the roll directory name " + "concatenated with a frame number.", + &Indexify::dispatch_none, &caption_frame_numbers); + add_option ("fontaa", "factor", 0, "Specifies a scale factor to apply to the fonts used for captioning " diff --git a/pandaapp/src/indexify/photo.cxx b/pandaapp/src/indexify/photo.cxx index 98ca9de347..bcd4f85fe6 100644 --- a/pandaapp/src/indexify/photo.cxx +++ b/pandaapp/src/indexify/photo.cxx @@ -17,6 +17,8 @@ //////////////////////////////////////////////////////////////////// #include "photo.h" +#include "indexParameters.h" +#include "rollDirectory.h" //////////////////////////////////////////////////////////////////// @@ -30,6 +32,20 @@ Photo(RollDirectory *dir, const Filename &basename) : _basename(basename) { _name = _basename.get_basename_wo_extension(); + _frame_number = _name; + if (caption_frame_numbers) { + const string &dirname = _dir->get_basename(); + + // If the initial prefix of the filename is the same as the roll + // directory, lop it off when caption_frame_numbers is in effect. + if (_frame_number.substr(0, dirname.length()) == dirname) { + _frame_number = _frame_number.substr(dirname.length()); + while (_frame_number.length() > 1 && _frame_number[0] == '0') { + _frame_number = _frame_number.substr(1); + } + } + } + _full_x_size = 0; _full_y_size = 0; _reduced_x_size = 0; @@ -58,6 +74,19 @@ get_name() const { return _name; } +//////////////////////////////////////////////////////////////////// +// Function: Photo::get_frame_number +// Access: Public +// Description: Returns the string describing the photo within the +// roll directory. This is usually the same string +// reported by get_name(), but it may be just the frame +// number if caption_frame_numbers is in effect. +//////////////////////////////////////////////////////////////////// +const string &Photo:: +get_frame_number() const { + return _frame_number; +} + //////////////////////////////////////////////////////////////////// // Function: Photo::output // Access: Public diff --git a/pandaapp/src/indexify/photo.h b/pandaapp/src/indexify/photo.h index 32c50132b2..89ba440bbe 100644 --- a/pandaapp/src/indexify/photo.h +++ b/pandaapp/src/indexify/photo.h @@ -35,6 +35,7 @@ public: const Filename &get_basename() const; const string &get_name() const; + const string &get_frame_number() const; void output(ostream &out) const; @@ -48,6 +49,7 @@ private: RollDirectory *_dir; Filename _basename; string _name; + string _frame_number; }; INLINE ostream &operator << (ostream &out, const Photo &p) { diff --git a/pandaapp/src/indexify/rollDirectory.cxx b/pandaapp/src/indexify/rollDirectory.cxx index d3c4d6ff34..b24f7bb875 100644 --- a/pandaapp/src/indexify/rollDirectory.cxx +++ b/pandaapp/src/indexify/rollDirectory.cxx @@ -299,18 +299,20 @@ generate_html(ostream &root_html, const Filename &archive_dir, const Filename &roll_dir_root) { nassertr(!_index_images.empty(), false); - Filename cm_filename(_dir, _basename); - cm_filename.set_extension("cm"); - if (cm_filename.exists()) { - // If the comment file for the roll exists, insert its contents - // here instead of the generic header. - if (!insert_html_comment(root_html, cm_filename)) { - return false; + if (!omit_roll_headers) { + Filename cm_filename(_dir, _basename); + cm_filename.set_extension("cm"); + if (cm_filename.exists()) { + // If the comment file for the roll exists, insert its contents + // here instead of the generic header. + if (!insert_html_comment(root_html, cm_filename)) { + return false; + } + + } else { + root_html + << "

" << _name << "

\n"; } - - } else { - root_html - << "

" << _name << "

\n"; } nout << "Generating " << Filename(archive_dir, "html/")