initial commit

This commit is contained in:
Mauro Torrez
2022-07-30 14:46:04 -03:00
commit 47650131de
312 changed files with 212465 additions and 0 deletions

782
ui/help.h Normal file
View File

@@ -0,0 +1,782 @@
// Copyright 2002, 2003, 2004 David Hilvert <dhilvert@auricle.dyndns.org>,
// <dhilvert@ugcs.caltech.edu>
/* This file is part of the Anti-Lamenessing Engine.
The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Anti-Lamenessing Engine; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Help messages
*/
#define BETWEEN_SECTIONS "\n"
#define HEADER_SPACE ""
class help {
private:
const char *package;
const char *version;
const char *invocation;
FILE *help_stream;
/*
* Stars
*
* This function produces a line of stars for banner output.
*/
void stars(unsigned int n) {
for (unsigned int i = 0; i < n; i++) {
fprintf(help_stream, "*");
}
fprintf(help_stream, "\n");
}
/*
* Banner
*
* This function aids in locating the start of help output.
*/
void banner(const char *name) {
const char *package_banner = " Help Text, version ";
const char *section_banner = "Section: ";
int plen = strlen(package) + strlen(package_banner) + strlen(version);
int slen = strlen(section_banner) + strlen(name);
int len = (plen > slen) ? plen : slen;
fprintf(help_stream, BETWEEN_SECTIONS);
stars(len);
fprintf(help_stream, "%s%s%s\n", package, package_banner, version);
fprintf(help_stream, "%s%s\n", section_banner, name);
stars(len);
}
public:
help(const char *package, const char *invocation, const char *version) {
this->invocation = invocation;
this->package = package;
this->version = version;
this->help_stream = stdout;
}
/*
* Describe how to use this program
*/
void usage() {
banner("Usage");
fprintf(help_stream,
BETWEEN_SECTIONS
"Usage: %s [<options>] <original-frame> [<supplemental-frame> ...] <output-file>\n"
" or: %s [<help option> ...]\n"
" or: %s --version\n"
BETWEEN_SECTIONS
"Help options:\n"
HEADER_SPACE
"--hu Usage (this message).\n"
"--hf Image files.\n"
"--he Exclusion regions.\n"
"--ha Alignment (not exposure-related).\n"
"--hr Rendering (not exposure-related).\n"
"--hx Exposure.\n"
"--ht Transformation data files.\n"
"--hc Control points.\n"
"--hl Filtering (PSFs, rendering chains).\n"
"--hd Devices.\n"
"--hi User Interfaces.\n"
"--hp Process details.\n"
"--hs Argument scope (Experimental).\n"
"--hv Video stream processing (Experimental).\n"
"--h3 3D Modeling (Experimental).\n"
"--hz Undocumented options.\n"
"--hA Concatenate all help pages.\n"
"\n",
invocation, invocation, invocation);
}
void defaults() {
banner("Defaults");
fprintf(help_stream,
BETWEEN_SECTIONS
"Default settings:\n"
HEADER_SPACE
"--q* options are no longer recognized.\n"
"\n"
);
}
void file() {
banner("File");
fprintf(help_stream,
BETWEEN_SECTIONS
"Cache options:\n"
HEADER_SPACE
"--cache <size> Cache up to <size> megabytes of image data. (256 is default)\n"
BETWEEN_SECTIONS
"Bit depth options:\n"
HEADER_SPACE
"--8bpc Write 8 bit per channel output\n"
"--16bpc Write 16 bit per channel output [default]\n"
BETWEEN_SECTIONS
"Output format options:\n"
HEADER_SPACE
#ifdef USE_MAGICK
"--auto Determine output file type automatically [default]\n"
"--raw Write raw PPM output\n"
"--plain Write plain PPM output\n"
#else
"--raw Write raw PPM output [default]\n"
"--plain Write plain PPM output\n"
#endif
BETWEEN_SECTIONS
"Incremental output:\n"
HEADER_SPACE
"--inc Produce rough incremental output.\n"
"--no-inc Don't produce any incremental output. [default]\n"
BETWEEN_SECTIONS
"Undefined values:\n"
HEADER_SPACE
"--def-nn <R> Use nearest-neighbor defined values within\n"
" radius <R>, zero outside. Default radius is 0.\n"
"\n"
);
}
void alignment() {
banner("Alignment");
fprintf(help_stream,
BETWEEN_SECTIONS
"Alignment channel options:\n"
HEADER_SPACE
"--align-all Align images using all color channels\n"
"--align-green Align images using the green channel\n"
"--align-sum Align images using a sum of channels [default]\n"
BETWEEN_SECTIONS
"Transformation options:\n"
HEADER_SPACE
"--translation Only adjust the position of images\n"
"--euclidean Adjust the position and orientation of images [default]\n"
"--projective Use projective transformations. Best quality, but slow.\n"
BETWEEN_SECTIONS
"Alignment following:\n"
HEADER_SPACE
"--follow Frames align closely with their predecessor. [default]\n"
"--identity Frames align closely with the original frame.\n"
BETWEEN_SECTIONS
"Alignment failure:\n"
HEADER_SPACE
"--fail-optimal Frames beneath threshold are aligned optimally. [default]\n"
"--fail-default Frames beneath threshold keep their default alignment.\n"
BETWEEN_SECTIONS
"Transformation file operations:\n"
HEADER_SPACE
"--trans-load <x> Load initial transformation settings from file <x>\n"
"--trans-save <x> Save final transformation data in file <x>\n"
BETWEEN_SECTIONS
"Tunable parameters:\n"
HEADER_SPACE
"--metric=x Set the alignment error metric exponent. (2 is default)\n"
"--threshold=x Minimum match percentage; -1 disables check. (-1 is default)\n"
"--perturb-upper=x Perturbation upper bound pixels/arclength (14%% is default)\n"
" ('x%%' uses a fraction of the smallest image dimension.)\n"
"--perturb-lower=x Perturbation lower bound pixels/arclength (.125 is default)\n"
" ('x%%' uses a fraction of the smallest image dimension.)\n"
"--rot-upper=x Rotation-specific upper bound in degrees (32.0 is default)\n"
"--bda-mult=x Barrel distortion adjustment multiplier (2.0 is default)\n"
"--bda-rate=x Barrel distortion rate of change maximum (8.0 is default)\n"
"--lod-preferred=x Preferred LOD scale is (2^floor(x))/perturb) (-3 is default)\n"
"--min-dimension=x Minimum dimension for reduced LOD is x (10 is default)\n"
"--mc <x> Statically sample ~x%% of available pixels (30 is default)\n"
BETWEEN_SECTIONS
"Certainty-weighted alignment:\n"
HEADER_SPACE
"--cw Weight alignment error by certainty.\n"
"--no-cw Don't weight alignment error by certainty. [default]\n"
BETWEEN_SECTIONS
"Alignment weight maps:\n"
HEADER_SPACE
"--wm <f> <x> <y> Use weight map image <f> at offset (<x>, <y>)\n"
BETWEEN_SECTIONS
"Frequency-weighted alignment:\n"
HEADER_SPACE
"--fl <h> <v> <a> High-pass filters: horizontal <h>, vertical <v>, average <a>.\n"
" Values should fall between 0 (pass all) and 1 (pass none).\n"
#ifndef USE_FFTW
"\n"
" NOTE: since this build of ALE does not link with FFTW,\n"
" this option is not supported. To use this option,\n"
" first re-build with FFTW support.\n"
"\n"
#endif
"--flshow <o> Write high-pass filtered data to file <o>.\n"
BETWEEN_SECTIONS
"Algorithmic alignment weighting:\n"
HEADER_SPACE
"--wmx <e> <r> <d> Write reference <r>, definition <d>, execute `<e> <f> <d>`,\n"
" read weights <r> back.\n"
#ifndef USE_UNIX
"\n"
" NOTE: since this build was not configured with\n"
" support for --wmx, this option is not supported.\n"
" To use this option, re-build with support for --wmx.\n"
#endif
BETWEEN_SECTIONS
"Perturbation Type [experimental]:\n"
HEADER_SPACE
"--perturb-output Apply perturbations in output image coordinates. [default]\n"
"--perturb-source Apply perturbations in source image coordinates.\n"
BETWEEN_SECTIONS
"Global searching:\n"
HEADER_SPACE
"--gs <type> Set global search to <type>, one of:\n"
" local Local alignment only\n"
" inner Alignment reference image inner region\n"
" outer Alignment reference image outer region\n"
" all Union of inner and outer\n"
" central inner if below threshold or better; else, outer.\n"
" defaults 'all' if default, 'local' otherwise. [default]\n"
" points Align by control points. Ignores gs-mo.\n"
"--gs-mo <x> Set <x> pixel min. overlap for global search. (67%% default)\n"
" ('x%%' uses a fraction of the total pixel count.)\n"
BETWEEN_SECTIONS
"Multi-alignment:\n"
HEADER_SPACE
"--multi <type> Set multi-alignment <type>, one of:\n"
" none Single alignment only\n"
" local Best local element\n"
" fill Best local element followed by filling [default]\n"
" llocal Least-size local element\n"
" global Best element\n"
"--md <x> Set element minimum dimension x. (100 is default)\n"
"--ma-cert <x> Set mean certainty lower bound. (0.01 is default)\n"
"\n"
);
}
void rendering() {
banner("Rendering");
fprintf(help_stream,
BETWEEN_SECTIONS
"Mimicking ALE 0.6.0 merging and drizzling (see --hl for details):\n"
HEADER_SPACE
" --dchain triangle:2 approximates merging.\n"
" --dchain fine:box:1 approximates drizzling.\n"
BETWEEN_SECTIONS
"Image extents:\n"
HEADER_SPACE
"--extend Increase image extents to accommodate all pixel data.\n"
"--no-extend Don't increase extents; crop to original frame. [default]\n"
BETWEEN_SECTIONS
"Tunable parameters:\n"
HEADER_SPACE
"--scale=x Scale images by the factor x, where x > 0. (1 is default)\n"
"--threshold=x Min. match threshold; a perfect match is 100. (0 is default)\n"
BETWEEN_SECTIONS
"Irani-Peleg iterative solver:\n"
HEADER_SPACE
#define FIXED16 4
#if ALE_COLORS == FIXED16
"--ips <i> Run <i> iterations. (0 is default)\n"
#else
"--ips <i> Run <i> iterations. (1 is default)\n"
#endif
#undef FIXED16
"--ip-mean Use the mean correction [default]\n"
"--ip-median Use the median correction\n"
"--ip-wl <x> Use weight limit <x>\n"
"--ip-nowl Use no weight limit [default]\n"
#if 0
BETWEEN_SECTIONS
"Unsharp Mask (was 'High-frequency Enhancement'):\n"
HEADER_SPACE
"--usm <m> Apply an unsharp mask with multiplier <m>.\n"
" (See also --device, --nlpsf, and --lpsf.)\n"
#endif
BETWEEN_SECTIONS
"Bayer pattern:\n"
HEADER_SPACE
"--bayer <b> Set the Bayer pattern to <b>, one of:\n"
" (clockwise from top left pixel)\n"
" rgbg Red-green-blue-green\n"
" gbgr Green-blue-green-red\n"
" grgb Green-red-green-blue\n"
" bgrg Blue-green-red-green\n"
" none RGB-RGB-RGB-RGB\n"
" Default is none or device-specific.\n"
BETWEEN_SECTIONS
"Color adjustment:\n"
HEADER_SPACE
"--exp-mult=c,r,b Adjust all channels by <c>, red by <r>, and blue by <b>.\n"
"\n"
);
}
void filtering() {
banner("Filtering");
fprintf(help_stream,
BETWEEN_SECTIONS
"Point-spread functions (used with --ips; see --hr):\n"
HEADER_SPACE
"--lpsf <p> Set linear colorspace point-spread function to <p>\n"
"--nlpsf <p> Set non-linear colorspace point-spread function to <p>\n"
" Available point-spread functions:\n"
" box=<diameter>\n"
" circle=<diameter>\n"
" gauss=<diameter of one std. deviation>\n"
" stdin\n"
" stdin_vg\n"
" <p>+<p> (summation)\n"
" <p>^<p> (convolution)\n"
" <n>*<p> (multiplication by a scalar <n>)\n"
" Default lpsf is either 'box=1.0' or device-specific.\n"
" Default nlpsf is either disabled or device-specific.\n"
BETWEEN_SECTIONS
"Rendering chains:\n"
HEADER_SPACE
"--wt <w> Set weight threshold for defined pixels (default is 0.0001).\n"
"--dchain <g> Use chain <g> to render the default output.\n"
"--ochain <g> <o> Use chain <g> to render output file <o>.\n"
"--achain <g> Use chain <g> to render the alignment reference image.\n"
"--afilter <s> Use SSF <s> to interpolate points in alignment.\n"
"--3d-chain <g> Use chain <g> by default to render 3d output.\n"
" Example chains:\n"
" triangle:2 ALE 0.6.0 merging (roughly)\n"
" fine:box:1 Drizzling (roughly)\n"
" fine:sinc*lanc:8 High-frequency preservation\n"
" last:nex:sinc*lanc:8 Useful for video stabilization\n"
" fine:box:1,triangle:2 Multi-resolution rendering\n"
" fine:sinc*lanc:8,sinc*lanc:8 Multi-resolution rendering\n"
" auto:box:1,fine:box:1,box:1 Range-resolution rendering.\n"
" More precisely, chains <g> are one of:\n"
" <g1>,<g2> Chain <g1> where defined; <g2> elsewhere.\n"
" <i> Use rendering invariant <i>.\n"
" Rendering invariants <i> are:\n"
" avg:<e> Avg. (mean) value using SSFE <e>.\n"
" avgf:<x>:<e> Avg. first up to weight <x> using SSFE <e>.\n"
" first:<e> First defined value using SSFE <e>.\n"
" last:<e> Last defined value using SSFE <e>.\n"
" max:<e> Maximum defined value using SSFE <e>.\n"
" min:<e> Minimum defined value using SSFE <e>.\n"
" median:<e> Median value using SSFE <e>.\n"
" <e> Same as avg:<e>.\n"
" Scaled sampling filters with exclusion (SSFE) <e> are:\n"
" ex:<s> Use SSF <s>; honor exclusion regions.\n"
" nex:<s> Use SSF <s>; don't honor exclusion regions.\n"
" <s> Same as ex:<s>\n"
" Scaled sampling filters (SSF) <s> are:\n"
" auto:<f> filter <f> from chain suffix resolutions.\n"
" fine:<f> filter <f> at output image resolution.\n"
" coarse:<f> filter <f> at resolution MIN(in, out).\n"
" <f> Same as coarse:<f>.\n"
" Sampling filters <f> are:\n"
" sinc Sinc filter. (very large diameter)\n"
" lanc:<x> Lanczos, diameter <x>.\n"
" triangle:<x> Triangle, diameter <x>.\n"
" box:<x> Box, diameter <x>.\n"
" gauss:<x> Gaussian, standard deviation <x>.\n"
" zero Zero function.\n"
" <f>*<f> Pointwise multiplication (windowing).\n"
" Defaults:\n"
" dchain auto:triangle:2,fine:box:1,triangle:2\n"
" 3d-chain fine:triangle:2,fine:gauss:0.75,triangle:2\n"
" achain triangle:2\n"
" afilter internal (approximates triangle:2)\n"
"\n"
);
}
void device() {
banner("Device");
fprintf(help_stream,
BETWEEN_SECTIONS
"Device (may set PSF, Bayer pattern, exposure, and view angle):\n"
HEADER_SPACE
"--device <d> Set the capture device to <d>.\n"
" Available devices (* expect linear inputs):\n"
" canon_300d *\n"
" canon_300d+50mm_1.4 *\n"
" canon_300d+50mm_1.4@1.4 *\n"
" canon_300d+50mm_1.8 *\n"
" canon_300d+85mm_1.8 *\n"
" nikon_d50 *\n"
" ov7620 *\n"
" xvp610_320x240\n"
" xvp610_640x480\n"
"\n"
);
}
void exclusion() {
banner("Exclusion");
fprintf(help_stream,
BETWEEN_SECTIONS
"Rendering-coordinate exclusion regions:\n"
HEADER_SPACE
"--ex <args> Exclude a specified volume.\n"
" <args> are space-delimited horizontal,\n"
" vertical, and frame limits:\n"
" <xmin> <xmax> <ymin> <ymax> <fmin> <fmax>\n"
" using unscaled rendering spatial coordinates.\n"
"--crop <args> Exclude the spatial complement of an area over a\n"
" specified set of frames. <args> are:\n"
" <xmin> <xmax> <ymin> <ymax> <fmin> <fmax>\n"
" using unscaled rendering spatial coordinates.\n"
BETWEEN_SECTIONS
"Frame-coordinate exclusion regions:\n"
HEADER_SPACE
"--fex <args> Exclude a specified volume.\n"
" <args> are space-delimited horizontal,\n"
" vertical, and frame limits:\n"
" <xmin> <xmax> <ymin> <ymax> <fmin> <fmax>\n"
" using unscaled frame spatial coordinates.\n"
"--fcrop <args> Exclude the spatial complement of an area over a\n"
" specified set of frames. <args> are:\n"
" <xmin> <xmax> <ymin> <ymax> <fmin> <fmax>\n"
" using unscaled frame spatial coordinates.\n"
"\n"
);
}
void exposure() {
banner("Exposure");
fprintf(help_stream,
BETWEEN_SECTIONS
"Certainty-weighted rendering:\n"
HEADER_SPACE
"--cx <x> Render with certainty exponent <x>. (default is 1)\n"
"--no-cx Render with uniform certainty.\n"
BETWEEN_SECTIONS
"Exposure registration:\n"
HEADER_SPACE
"--exp-register Register exposure between frames. [default]\n"
"--exp-noregister Assume uniform exposure across all frames.\n"
"--exp-meta-only Use only meta-data for registering exposure.\n"
BETWEEN_SECTIONS
"Range extension:\n"
HEADER_SPACE
"--exp-extend Extend to include all calculated values.\n"
"--exp-noextend Restrict to the original frame's range. [default]\n"
BETWEEN_SECTIONS
"Exposure value meta-data:\n"
HEADER_SPACE
"--ev <x> Set ISO 100 equivalent EV <x>. (default is 0)\n"
"--black <x> Set black level <x> as a fraction of saturation. (default 0)\n"
"\n"
);
}
void tdf() {
banner("Transformation data files");
fprintf(help_stream,
BETWEEN_SECTIONS
"Version 2 syntax overview:\n"
HEADER_SPACE
"{version string}\n"
"{supplemental frame 1 transformation}\n"
"{supplemental frame 2 transformation}\n"
"...\n"
BETWEEN_SECTIONS
"Version 3 syntax overview:\n"
HEADER_SPACE
"{version string}\n"
"{original frame transformation}\n"
"{supplemental frame 1 transformation}\n"
"{supplemental frame 2 transformation}\n"
"...\n"
BETWEEN_SECTIONS
"Version string:\n"
HEADER_SPACE
"V <x> Transformation data file version <x>.\n"
BETWEEN_SECTIONS
"Transformation overview:\n"
HEADER_SPACE
"{barrel/pincushion distortion command (optional; version 3 only)}\n"
"{projective, euclidean, or default command}\n"
BETWEEN_SECTIONS
"Barrel/pincushion distortion (version 3 only):\n"
HEADER_SPACE
"B <n> <coeff2> <coeff3> ... <coeff(n+1)>\n"
BETWEEN_SECTIONS
"Projective command:\n"
HEADER_SPACE
"P <xmax> <ymax> <tlx> <tly> <blx> <bly> <brx> <bry> <trx> <try>\n"
BETWEEN_SECTIONS
"Euclidean command:\n"
HEADER_SPACE
"E <xmax> <ymax> <xoffset> <yoffset> <angle>\n"
"\n"
BETWEEN_SECTIONS
"Comments:\n"
HEADER_SPACE
"# Lines beginning with '#' are comments.\n"
BETWEEN_SECTIONS
"Example:\n"
HEADER_SPACE
"# Version 3 transformation data file.\n"
"V 3\n"
"# Original frame, with barrel/pincushion distortion correction\n"
"B 3 0.1 0 -0.1\n"
"D\n"
"# Supplemental frame 1: shift a 640x480 image right by 100 pixels\n"
"E 640 480 100 0 0\n"
"\n"
);
}
void visp() {
banner("Video stream processing");
fprintf(help_stream,
BETWEEN_SECTIONS
"Video stream processing [Experimental]:\n"
HEADER_SPACE
"--visp <args> Process a video sequence.\n"
" <args> are:\n"
" <chain> <stabilization-type> <prefix> <suffix>\n"
" <chain> is a rendering chain. (see --hl)\n"
" <stabilization-type> is one of:\n"
" ma:<x> Moving average over 2*<x> + 1 frames\n"
" sf:<x> Stabilize to single frame number <x>\n"
" identity Same as ma:0\n"
" <prefix> is an output file prefix\n"
" <suffix> is an output file suffix\n"
"--visp-scale=<x> Use scale <x> for VISP output. (default is 1.0)\n"
"--exshow For single-invariant chains, show --ex regions dimmed.\n"
"\n");
}
void interface() {
banner("User Interface");
fprintf(help_stream,
BETWEEN_SECTIONS
"User Interfaces:\n"
HEADER_SPACE
"--ui=<type> Set user interface to <type>, one of:\n"
" quiet\n"
" stream\n"
" tty [default]\n"
" log\n"
#ifndef USE_IOCTL
"\n"
" NOTE: since ALE was compiled without terminal size check,\n"
" --ui=tty will behave identically to --ui=stream.\n"
" For additional output, recompile with terminal size check.\n"
#endif
"\n");
}
void cp() {
banner("Control Points");
fprintf(help_stream,
BETWEEN_SECTIONS
"Control point files:\n"
HEADER_SPACE
"--cpf-load=<f> Load control point data from file <f>\n"
"\n");
}
void d3() {
banner("3D Modeling [Experimental]");
fprintf(help_stream,
BETWEEN_SECTIONS
"Rendering:\n"
HEADER_SPACE
"--3dv <n> <o> Render, to file <o>, colors as viewed from frame <n>.\n"
"--3dd <n> <o> Render, to file <o>, depths as viewed from frame <n>.\n"
"--3dvp <args> <o> Render, to file <o>, colors viewed with projective <args>.\n"
"--3ddp <args> <o> Render, to file <o>, depths viewed with projective <args>.\n"
" <args> are W H V x y z P Y R:\n"
" W image width.\n"
" H image height.\n"
" V camera view angle.\n"
" x translation x component.\n"
" y translation y component.\n"
" z translation z component.\n"
" P rotation around x-axis.\n"
" Y rotation around y-axis.\n"
" R rotation around z-axis.\n"
"--occ-norm Normalize output with accumulated occupancy. [default]\n"
"--occ-nonorm Don't normalize output with accumulated occupancy.\n"
"--et <x> Set encounter threshold <x> for defined pixels.[default is 0]\n"
"--3dpx <args> Exclude a specified spatial volume following full-scene\n"
" reconstruction. <args> are:\n"
" <xmin> <xmax> <ymin> <ymax> <zmin> <zmax>\n"
"--3d-filter Use filtering for 3D color output. [default]\n"
"--3d-nofilter Don't use filtering for 3D color output.\n"
"--3d-dmr <x> Set radius for filtering median depth to <x> [default 0]\n"
"--3d-fmr <x> Set radius for filtering median diff to <x> [default 0]\n"
"--focus <ft> <op> Create focus region with type <ft> and options <op>:\n"
" Focus type:\n"
" d <d> focus at distance <d>\n"
" p <x> <y> focus at point (x, y)\n"
" Space-separated options may include zero or more of:\n"
" ci=<ci> camera index [default 0]\n"
" fr=<fr> focal range [default 0]\n"
" ht=<ht> horizontal tilt gradient [default 0]\n"
" vt=<vt> vertical tilt gradient [default 0]\n"
" ap=<ap> aperture diameter [default 3]\n"
" sc=<sc> sample count [default 3]\n"
" sx=<sx> start x coordinate [default -Inf]\n"
" ex=<ex> end x coordinate [default Inf]\n"
" sy=<sy> start y coordinate [default -Inf]\n"
" ey=<ey> end y coordinate [default Inf]\n"
" sd=<sd> start depth [default 0]\n"
" ed=<ed> end depth [default Inf]\n"
" sr=<sr> view sample randomization:\n"
" aperture per aperture [default]\n"
" pixel per pixel\n"
" fs=<fs> focal statistic, one of:\n"
" mean mean of views [default]\n"
" median median of views\n"
"\n"
BETWEEN_SECTIONS
"Camera parameters:\n"
HEADER_SPACE
"--view-angle <x> Set the initial diagonal view angle to <x> degrees.\n"
" (Default is 43.7 degrees or device-specific.)\n"
"--cpp-upper=<x> Set upper bound <x> for camera parameter perturbation,\n"
" in pixels or degrees [default is 32]\n"
"--cpp-lower=<x> Set lower bound <x> for camera parameter perturbation,\n"
" in pixels or degrees [default is 0.125]\n"
"--cpp-err-mean Use RMS error to determine camera parameters. [default]\n"
"--cpp-err-median Use median error to determine camera parameters. \n"
"--va-upper=<x> View-angle perturbation upper bound in degrees [default 32]\n"
"--st <x> Set stereo threshold to <x> pixels. [default is 4]\n"
"--vp-adjust Adjust the view point [default]\n"
"--vp-noadjust Do not adjust the view point\n"
"--vo-adjust Adjust the view orientation [default]\n"
"--vo-noadjust Do not adjust the view orientation\n"
BETWEEN_SECTIONS
"Transformation file operations:\n"
HEADER_SPACE
"--3d-trans-load=x Load initial transformation settings from file x\n"
"--3d-trans-save=x Save final transformation data in file x\n"
BETWEEN_SECTIONS
"Model rules:\n"
HEADER_SPACE
"--di-upper <x> Decimate primary input resolution by at most 2^x [default 0]\n"
"--di-lower <x> Decimate input resolutions by at least 2^x [default is 0]\n"
"--do-try <x> Decimate output resolution by 2^x if possible [default is 0]\n"
"--oc Clip scene to output regions.\n"
"--no-oc Do not clip scene to output regions. [default]\n"
"--fc <x> Set front-clip to <x> (0 < x < 1) [default is 0]\n"
"--rc <x> Set rear-clip to <x> (1 < x < inf) [default is inf]\n"
"--fx <x> Set falloff exponent to <x> [default is 1]\n"
"--tcem <x> Set third-camera error multiplier to <x> [default is 0]\n"
"--oui <x> Set occupancy update iterations to <x> [default is 10]\n"
"--pa <x> Set pairwise ambiguity to <x> [default is 3]\n"
"--pc <type> Set the type of pairwise comparisons:\n"
" auto Determine comparisons automatically. [default]\n"
" all Perform all comparisons.\n"
"\n");
}
void scope() {
banner("Argument scope [experimental]");
fprintf(help_stream,
BETWEEN_SECTIONS
"List of arguments admitting scoping:\n"
HEADER_SPACE
"--gs (see --ha for more details)\n"
"--gs-mo (see --ha for more details)\n"
"--threads (see --hp for more details)\n"
"--per-cpu (see --hp for more details)\n"
"--perturb-upper (see --ha for more details)\n"
"--ev (see --hx for more details)\n"
"--black (see --hx for more details)\n"
BETWEEN_SECTIONS
"Implicit file scope (implementation may be buggy):\n"
HEADER_SPACE
"arg1 file1 arg2 <arg2> applies only to files later than <file1>.\n"
" Example:\n"
"\n"
" --ev 10 file1 --ev 20 file2\n"
"\n"
" (file1 has EV 10; file2 has EV 20.)\n"
"\n"
BETWEEN_SECTIONS
"Hidden scope (implementation may be buggy):\n"
HEADER_SPACE
"[ args ] Hide the effects of <args> options within [ ... ] scope\n"
" Example:\n"
"\n"
" file1 [ --ev 20 file2 ] file3\n"
"\n"
" (The EV argument is limited to file2.)\n"
"\n"
BETWEEN_SECTIONS
"Exposed scope (implementation may be buggy):\n"
HEADER_SPACE
"[ arg1 < arg2 > ] Expose the effects of <arg2> outside of [ ... ] scope\n"
BETWEEN_SECTIONS
"Fully-exposed scope (implementation may be buggy):\n"
HEADER_SPACE
"{ arg1 } Same as [ < arg1 > ].\n"
"\n");
}
void process() {
banner("Process details");
fprintf(help_stream,
BETWEEN_SECTIONS
"Memory:\n"
HEADER_SPACE
"--resident <x> Max resident megapixels per array; 0 is unlimited (0 default)\n"
BETWEEN_SECTIONS
"Profiling:\n"
HEADER_SPACE
"--profile Output performance data\n"
BETWEEN_SECTIONS
"Thread count:\n"
"\n"
" If the CPU count cannot be determined, the default thread count\n"
" is 4. Otherwise, the default is one thread per CPU.\n"
"\n"
HEADER_SPACE
"--threads <n> Use <n> threads.\n"
#ifndef USE_PTHREAD
"\n"
" NOTE: since this build of ALE does not link with a\n"
" threading library, this option is not supported.\n"
" To use this option, first rebuild with support\n"
" for threads.\n"
"\n"
#endif
"--per-cpu <n> Use <n> threads for each detected CPU.\n"
#ifndef USE_PTHREAD
"\n"
" NOTE: since this build of ALE does not link with a\n"
" threading library, this option is not supported.\n"
" To use this option, first rebuild with support\n"
" for threads.\n"
"\n"
#endif
"\n");
}
void undocumented() {
banner("Undocumented");
fprintf(help_stream,
BETWEEN_SECTIONS
"Point-spread functions:\n"
HEADER_SPACE
"--psf-match <args> Can be used to evaluate PSFs. [details are undocumented]\n"
" <args> are:\n"
" <mr> <mg> <mb> <ar> <ag> <ab>\n"
" where:\n"
" r[calibrated] = r[input] * <mr> + <ar>\n"
BETWEEN_SECTIONS
"Projective transformation calculator:\n"
HEADER_SPACE
"--ptcalc\n"
BETWEEN_SECTIONS
"Traverse subspaces for 3D candidate selection:\n"
HEADER_SPACE
"--subspace-traverse\n"
"\n"
);
}
};
#undef BETWEEN_SECTIONS
#undef HEADER_SPACE

51
ui/implication.h Normal file
View File

@@ -0,0 +1,51 @@
// Copyright 2004 David Hilvert <dhilvert@auricle.dyndns.org>,
// <dhilvert@ugcs.caltech.edu>
/* This file is part of the Anti-Lamenessing Engine.
The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Anti-Lamenessing Engine; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __implication_h__
#define __implication_h__
/*
* Information about program implication logic.
*/
class implication {
public:
/*
* Describe an aspect of implication logic that
* results in a program parameter being changed.
*/
static void changed(const char *description, const char *changes, const char *option = NULL) {
fprintf(stderr, "\n\n");
fprintf(stderr, "Program options have been automatically modified to satisfy the following:\n\n");
fprintf(stderr, description);
fprintf(stderr, "\n\n");
fprintf(stderr, "Changes are as follows:\n\n");
fprintf(stderr, changes);
fprintf(stderr, "\n\n");
if (option) {
fprintf(stderr, "This is equivalent to manually setting the following options:\n\n");
fprintf(stderr, option);
fprintf(stderr, "\n\n");
}
}
};
#endif

301
ui/input.cc Normal file
View File

@@ -0,0 +1,301 @@
// Copyright 2006 David Hilvert <dhilvert@auricle.dyndns.org>,
// <dhilvert@ugcs.caltech.edu>
/* This file is part of the Anti-Lamenessing Engine.
The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Anti-Lamenessing Engine; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "input.h"
/*
* See input.h for details on these variables.
*/
std::stack<input::environment *> input::environment::environment_stack;
std::set<input::environment *> input::environment::environment_set;
int input::global_options = 1;
input::environment *input::genv = NULL;
/*
* List of options that can be used as nonglobals.
*/
const char *input::supported_nonglobal_option_table[] = {
"mc",
"threads",
"per-cpu",
"perturb-upper",
"ev",
"gs-mo",
"black",
"md",
"ma-cert",
"mi",
NULL
};
const char *input::focus_prefixes[] = {
"ci=",
"fr=",
"ht=",
"vt=",
"sy=",
"ey=",
"sx=",
"ex=",
"sd=",
"ed=",
"ap=",
"sc=",
"sr=",
"fs=",
NULL
};
/*
* Entries in this table are:
*
* name, map_name, map_value, arg_count, multi
*
* The table must be terminated with name of NULL.
*/
input::simple_option input::simple_option_table[] = {
{ "8bpc", "bpc" },
{ "16bpc", "bpc" },
{ "plain", "format" },
{ "raw", "format" },
{ "auto", "format" },
{ "align-all", "align" },
{ "align-green", "align" },
{ "align-sum", "align" },
{ "translation", "transformation" },
{ "euclidean", "transformation" },
{ "projective", "transformation" },
{ "identity", "transformation-default" },
{ "follow", "transformation-default" },
{ "perturb-output", "perturb" },
{ "perturb-source", "perturb" },
{ "fail-optimal", "fail" },
{ "fail-default", "fail" },
{ "profile" },
{ "extend" },
{ "no-extend", "extend", "0" },
{ "mc", NULL, NULL, 1 },
{ "cache", NULL, NULL, 1 },
{ "resident", NULL, NULL, 1 },
{ "ev", NULL, NULL, 1 },
{ "black", NULL, NULL, 1 },
{ "threads", NULL, NULL, 1 },
{ "per-cpu", NULL, NULL, 1 },
{ "oc" },
{ "no-oc", "oc", "0" },
{ "multi", NULL, NULL, 1 },
{ "gs", NULL, NULL, 1 },
{ "gs-mo", NULL, NULL, 1 },
{ "md", NULL, NULL, 1 },
{ "ma-cert", NULL, NULL, 1 },
{ "mi", NULL, NULL, 1 },
{ "focus", "error" },
{ "3ddp", NULL, NULL, 10, 1 },
{ "3dvp", NULL, NULL, 10, 1 },
{ "3dv", NULL, NULL, 2, 1 },
{ "3dd", NULL, NULL, 2, 1 },
{ "view-angle", NULL, NULL, 1 },
{ "cpf-load", NULL, NULL, 1 },
{ "ui", NULL, NULL, 1 },
{ "3d-fmr", NULL, NULL, 1 },
{ "3d-dmr", NULL, NULL, 1 },
{ "et", NULL, NULL, 1 },
{ "st", NULL, NULL, 1 },
{ "di-lower", NULL, NULL, 1 },
{ "rc", NULL, NULL, 1 },
{ "do-try", NULL, NULL, 1 },
{ "di-upper", NULL, NULL, 1 },
{ "fc", NULL, NULL, 1 },
{ "ecm", NULL, NULL, 1 },
{ "acm", NULL, NULL, 1 },
{ "def-nn", NULL, NULL, 1 },
{ "fx", NULL, NULL, 1 },
{ "tcem", NULL, NULL, 1 },
{ "oui", NULL, NULL, 1 },
{ "pa", NULL, NULL, 1 },
{ "pc", NULL, NULL, 1 },
{ "cw" },
{ "no-cw", "cw", "0" },
{ "wm", NULL, NULL, 3 },
{ "fl", NULL, NULL, 3 },
{ "wmx", NULL, NULL, 3 },
{ "flshow", NULL, NULL, 1 },
{ "3dpx", NULL, NULL, 6 },
{ "ex", NULL, NULL, 6, 1 },
{ "crop", NULL, NULL, 6, 1 },
{ "fex", NULL, NULL, 6, 1 },
{ "fcrop", NULL, NULL, 6, 1 },
{ "exshow" },
{ "wt", NULL, NULL, 1 },
{ "3d-chain", NULL, NULL, 1 },
{ "dchain", NULL, NULL, 1 },
{ "achain", NULL, NULL, 1 },
{ "afilter", NULL, NULL, 1 },
{ "ochain", NULL, NULL, 2 },
{ "visp", NULL, NULL, 5 },
{ "cx", NULL, NULL, 1 },
{ "no-cx", "cx", "0" },
{ "ip", NULL, NULL, 0 },
{ "bayer", NULL, NULL, 1 },
{ "lpsf", NULL, NULL, 1 },
{ "nlpsf", NULL, NULL, 1 },
{ "psf-match", NULL, NULL, 6 },
{ "device", NULL, NULL, 1 },
{ "usm", NULL, NULL, 1 },
{ "ipr", NULL, NULL, 1 },
{ "cpp-err-median", "cpp-err", "median" },
{ "cpp-err-mean", "cpp-err", "mean" },
{ "vp-adjust" },
{ "vp-noadjust", "vp-adjust", "0" },
{ "vo-adjust" },
{ "vo-noadjust", "vo-adjust", "0" },
{ "ip-mean", "ip-statistic", "mean" },
{ "ip-median", "ip-statistic", "median" },
{ "ip-wl", "ip-wl", "1", 1 },
{ "ip-nowl", "ip-wl", "0" },
{ "ips", NULL, NULL, 1 },
{ "ipc", NULL, NULL, 2 },
{ "exp-extend" },
{ "exp-noextend", "exp-extend", "0" },
{ "exp-register" },
{ "exp-noregister", "exp-register", "0" },
{ "exp-meta-only", "exp-register", "2" },
{ "drizzle-only" },
{ "subspace-traverse" },
{ "3d-filter" },
{ "3d-nofilter", "3d-filter", "0" },
{ "occ-norm" },
{ "occ-nonorm", "occ-norm", "0" },
{ "inc" },
{ "no-inc", "inc", "0" },
{ "exp-mult", NULL, NULL, 3 },
{ "visp-scale", NULL, NULL, 1 },
{ "scale", NULL, NULL, 1 },
{ "metric", NULL, NULL, 1 },
{ "threshold", NULL, NULL, 1 },
{ "drizzle-diam", NULL, NULL, 1 },
{ "perturb-upper", NULL, NULL, 1 },
{ "perturb-lower", NULL, NULL, 1 },
{ "stepsize", NULL, NULL, 1 },
{ "va-upper", NULL, NULL, 1 },
{ "cpp-upper", NULL, NULL, 1 },
{ "cpp-lower", NULL, NULL, 1 },
{ "hf-enhance", NULL, NULL, 1 },
{ "rot-upper", NULL, NULL, 1 },
{ "bda-mult", NULL, NULL, 1 },
{ "bda-rate", NULL, NULL, 1 },
{ "lod-preferred", NULL, NULL, 1 },
{ "min-dimension", NULL, NULL, 1 },
{ "model-load", NULL, NULL, 1 },
{ "model-save", NULL, NULL, 1 },
{ "trans-load", NULL, NULL, 1 },
{ "trans-save", NULL, NULL, 1 },
{ "3d-trans-load", NULL, NULL, 1 },
{ "3d-trans-save", NULL, NULL, 1 },
/*
* End of table.
*/
{ NULL }
};

3002
ui/input.h Normal file

File diff suppressed because it is too large Load Diff

71
ui/ui.cc Normal file
View File

@@ -0,0 +1,71 @@
// Copyright 2004 David Hilvert <dhilvert@auricle.dyndns.org>,
// <dhilvert@ugcs.caltech.edu>
/* This file is part of the Anti-Lamenessing Engine.
The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Anti-Lamenessing Engine; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ui_wo.h"
#include "ui_tty.h"
#include "ui_log.h"
#include "ui_quiet.h"
#include "input.h"
#include "ui.h"
#include "d2.h"
/*
* See ui.h for details on these variables.
*/
ui *ui::singleton = NULL;
int ui::type = 1; /* TTY is default */
int ui::output_performance_data = 0;
ui *ui::get() {
if (singleton == NULL) {
switch (type) {
case 0:
singleton = new ui_wo();
break;
case 1:
try {
singleton = new ui_tty();
} catch (...) {
singleton = new ui_wo();
}
break;
case 2:
singleton = new ui_log();
break;
case 3:
singleton = new ui_quiet();
break;
default:
assert(0);
}
}
return singleton;
}
void ui::handle_input(int argc, const char *argv[], const char *package, const char *short_version, const char *version) {
input::handle(argc, argv, package, short_version, version);
}
void ui::set_offset(d2::trans_single offset) {
}
void ui::set_offset(d2::transformation offset) {
}

798
ui/ui.h Normal file
View File

@@ -0,0 +1,798 @@
// Copyright 2004 David Hilvert <dhilvert@auricle.dyndns.org>,
// <dhilvert@ugcs.caltech.edu>
/* This file is part of the Anti-Lamenessing Engine.
The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Anti-Lamenessing Engine; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __ui_h__
#define __ui_h__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#include "../ale_pos.h"
#include "../config.h"
#if HAVE_TIME_H
#include <time.h>
#endif
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <map>
/*
* Time structures.
*/
namespace d2 {
struct trans_multi;
typedef trans_multi transformation;
struct trans_abstract;
struct trans_single;
}
class ale_timer_t {
#if HAVE_GETTIMEOFDAY
struct timeval tv;
#else
time_t tt;
#endif
double total;
public:
ale_timer_t() {
total = 0;
}
void start() {
#if HAVE_GETTIMEOFDAY
gettimeofday(&tv, NULL);
#else
tt = time(NULL);
#endif
}
void stop() {
#if HAVE_GETTIMEOFDAY
timeval t;
gettimeofday(&t, NULL);
t.tv_sec -= tv.tv_sec;
t.tv_usec -= tv.tv_usec;
total += t.tv_sec + ((double) 1 / (double) 1000000) * t.tv_usec;
#else
time_t t = time(NULL);
t -= tt;
total += t;
#endif
}
double get_total() {
return total;
}
};
/*
* User interface messages.
*/
class ui_wo;
class ui {
private:
static ui *singleton;
/*
* UI type
*
* 0. stream
* 1. tty
* 2. log
* 3. quiet
*/
static int type;
static int output_performance_data;
protected:
/*
* Data
*/
FILE *ui_stream;
struct status_type {
enum {
/*
* Special
*/
UNDEFINED,
/*
* Incremental rendering.
*/
LOAD_FILE, EXPOSURE_PASS_1,
LODCLUSTER_CREATE, PREMATCH, ALIGN, GLOBAL_ALIGN, POSTMATCH,
EXPOSURE_PASS_2, RENDERA, RENDERD, RENDERO, WRITED,
WRITEO, FRAME_DONE, SET_DONE, MULTI,
/*
* Irani-Peleg rendering.
*/
IP_RENDER, IP_STEP_DONE, IP_UPDATE, IP_WRITE,
/*
* 3D.
*/
D3_CONTROL_POINT_SOLVE, D3_SUBDIVIDING_SPACE,
D3_UPDATING_OCCUPANCY, D3_RENDER
} code, orender_current;
int arender_current;
double match_value;
int onum;
int steps;
int steps_completed;
int step_type;
double exp_multiplier[3];
double perturb_size;
double align_lod;
unsigned int frame_num;
unsigned int irani_peleg_stage;
unsigned int secondary_frame_num;
unsigned int view_num;
unsigned int x_coordinate, y_coordinate;;
unsigned int filtering, focusing;
unsigned int space_num;
unsigned int total_spaces;
double cp_max_perturb;
double cp_min_perturb;
double cp_cur_perturb;
double cp_cur_error;
int cache;
status_type() {
code = UNDEFINED;
steps_completed = 0;
cache = 1;
for (int k = 0; k < 3; k++)
exp_multiplier[k] = 1;
}
} status;
/*
* Performance data
*/
ale_timer_t d2_align_sample;
ale_timer_t d2_align_sim;
ale_timer_t d2_incremental;
ale_timer_t d2_irani_peleg;
std::map<double,ale_timer_t> perturb_timers;
/*
* Constructor
*/
ui() {
ui_stream = stderr;
}
/*
* Print function
*/
virtual void printf(const char *format, ...) = 0;
/*
* UI update function
*/
virtual void update() = 0;
/*
* Match format strings for textual UIs.
*/
const char *format_string_ok() {
return " okay (%9.6f%% match)";
}
const char *format_string_no_match() {
return " no match (%9.6f%% match)";
}
const char *format_string_working() {
return " (%9.6f%% match)";
}
public:
/*
* Handle options and other user input.
*/
static void handle_input(int argc, const char *argv[], const char *package,
const char *short_version, const char *version);
static ui *get();
static void set_stream() {
assert(singleton == NULL);
type = 0;
}
static void set_tty() {
assert(singleton == NULL);
type = 1;
}
static void set_log() {
assert (singleton == NULL);
type = 2;
}
static void set_quiet() {
assert(singleton == NULL);
type = 3;
}
static void set_profile() {
output_performance_data = 1;
}
/*
* Messages from the engine
*/
virtual void identify_output(const char *name) {
printf("Output file will be '%s'.\n", name);
}
virtual void d2_align_sim_start() {
d2_align_sim.start();
}
virtual void d2_align_sim_stop() {
d2_align_sim.stop();
}
virtual void d2_align_sample_start() {
d2_align_sample.start();
}
virtual void d2_align_sample_stop() {
d2_align_sample.stop();
}
virtual void d2_incremental_start() {
d2_incremental.start();
}
virtual void d2_incremental_stop() {
d2_incremental.stop();
}
virtual void d2_irani_peleg_start() {
d2_irani_peleg.start();
}
virtual void d2_irani_peleg_stop() {
d2_irani_peleg.stop();
}
virtual void exp_multiplier(double m0, double m1, double m2) {
status.exp_multiplier[0] = m0;
status.exp_multiplier[1] = m1;
status.exp_multiplier[2] = m2;
}
void exp_multiplier(double mult[3]) {
exp_multiplier(mult[0], mult[1], mult[2]);
}
virtual void set_steps(int count, int type = 0) {
status.steps = count;
status.step_type = type;
}
virtual void set_steps_completed(int count) {
status.steps_completed = count;
}
virtual void set_match(double match) {
status.match_value = (1 - match) * 100;
update();
}
virtual void set_offset(d2::trans_single offset);
virtual void set_offset(d2::trans_multi offset);
virtual void gs_mo(ale_pos gs_mo) {
}
virtual void cache_status(unsigned int c) {
status.cache = c;
}
virtual void loading_file() {
status.code = status.LOAD_FILE;
update();
}
virtual void exposure_1() {
status.code = status.EXPOSURE_PASS_1;
update();
}
virtual void exposure_2() {
status.code = status.EXPOSURE_PASS_2;
update();
}
virtual void prematching() {
status.code = status.PREMATCH;
update();
}
virtual void postmatching() {
status.code = status.POSTMATCH;
update();
}
virtual void constructing_lod_clusters(ale_pos lod) {
status.code = status.LODCLUSTER_CREATE;
status.align_lod = lod;
update();
}
virtual void global_alignment(ale_pos perturb, ale_pos lod) {
status.perturb_size = perturb;
status.align_lod = lod;
status.code = status.GLOBAL_ALIGN;
update();
}
virtual void aligning(ale_pos perturb, ale_pos lod) {
perturb_timers[perturb].start();
status.perturb_size = perturb;
status.align_lod = lod;
status.code = status.ALIGN;
update();
}
virtual void multi() {
status.code = status.MULTI;
update();
}
virtual void following() {
}
virtual void set_orender_current(int num) {
status.onum = num;
if (num == 0)
status.orender_current = status.RENDERD;
else
status.orender_current = status.RENDERO;
}
virtual void set_arender_current() {
status.arender_current = 1;
}
virtual void clear_arender_current() {
status.arender_current = 0;
}
virtual void rendering() {
/*
* Current alignment rendering tasks must complete
* before any current output rendering tasks can
* start.
*/
if (status.arender_current) {
status.code = status.RENDERA;
status.arender_current = 0;
} else {
status.code = status.orender_current;
}
update();
}
virtual void writing_output(int num) {
status.onum = num;
if (num == 0)
status.code = status.WRITED;
else
status.code = status.WRITEO;
update();
}
virtual void d3_control_point_data(double max_perturbation, double min_perturbation, double cur_perturbation,
double current_error) {
status.cp_max_perturb = max_perturbation;
status.cp_min_perturb = min_perturbation;
status.cp_cur_perturb = cur_perturbation;
status.cp_cur_error = current_error;
update();
}
virtual void d3_control_point_step() {
printf(".");
update();
}
virtual void d3_subdivision_status(unsigned int primary_frame, unsigned int secondary_frame,
unsigned int i, unsigned int j) {
status.code = status.D3_SUBDIVIDING_SPACE;
status.frame_num = primary_frame;
status.secondary_frame_num = secondary_frame;
status.y_coordinate = i;
status.x_coordinate = j;
update();
}
virtual void d3_total_spaces(int total_spaces) {
status.total_spaces = total_spaces;
}
virtual void d3_increment_spaces() {
status.total_spaces++;
}
virtual void d3_occupancy_status(int frame) {
status.code = status.D3_UPDATING_OCCUPANCY;
status.frame_num = frame;
status.space_num = 0;
update();
}
virtual void d3_increment_space_num() {
status.space_num++;
update();
}
virtual void d3_render_status(int filter, int focus, int frame, int view, int i, int j, int space) {
status.code = status.D3_RENDER;
status.filtering = filter;
status.focusing = focus;
status.frame_num = frame;
status.view_num = view;
status.y_coordinate = i;
status.x_coordinate = j;
status.space_num = space;
update();
}
/*
* Informational output
*/
virtual void ip_start() {
printf("Iterating Irani-Peleg");
}
virtual void refilter_start() {
printf("Re-filtering incremental results");
}
virtual void ip_frame_start(unsigned int num) {
status.code = status.IP_RENDER;
status.frame_num = num;
status.irani_peleg_stage = 0;
update();
}
virtual void ip_frame_simulate_start() {
status.code = status.IP_RENDER;
status.irani_peleg_stage = 1;
update();
}
virtual void ip_frame_correct_start() {
status.code = status.IP_RENDER;
status.irani_peleg_stage = 2;
update();
}
virtual void ip_update() {
status.code = status.IP_UPDATE;
update();
}
virtual void ip_write() {
status.code = status.IP_WRITE;
update();
}
virtual void ip_step_done() {
status.code = status.IP_STEP_DONE;
printf(".");
}
virtual void ip_done() {
printf("\n");
}
virtual void refilter_done() {
printf(".\n");
}
virtual void original_frame_start(const char *name) {
status.code = status.UNDEFINED;
printf("Original Frame:\n");
printf(" '%s'", name);
}
virtual void original_frame_done() {
status.code = status.FRAME_DONE;
update();
}
virtual void supplemental_frame_start(const char *name) {
static int section_announced = 0;
if (!section_announced) {
printf("Supplemental Frames:\n");
section_announced = 1;
}
status.code = status.UNDEFINED;
status.steps_completed = 0;
printf(" '%s'", name);
}
virtual void supplemental_frame_done() {
status.code = status.FRAME_DONE;
update();
}
virtual void alignment_degree_complete(int degree) {
if (status.step_type == 1) {
status.steps_completed++;
printf("*");
}
}
virtual void alignment_perturbation_level(ale_pos perturb, ale_pos lod) {
perturb_timers[status.perturb_size].stop();
perturb_timers[perturb].start();
status.perturb_size = perturb;
status.align_lod = lod;
if (status.step_type == 0) {
status.steps_completed++;
printf(".");
}
}
virtual void alignment_dims(unsigned int hr, unsigned int wr, unsigned int hi, unsigned int wi) {
}
virtual void start_multi_alignment_element(d2::trans_multi &tm) {
}
virtual void alignment_match_ok() {
status.code = status.UNDEFINED;
printf(format_string_ok(), status.match_value);
}
virtual void alignment_no_match() {
status.code = status.UNDEFINED;
printf(format_string_no_match(), status.match_value);
}
virtual void ale_2d_done(double value) {
status.code = status.UNDEFINED;
printf("Average match: %f%%", value);
status.code = status.SET_DONE;
update();
if (output_performance_data) {
printf("\n");
printf("Real time measurements\n");
printf("======================\n");
printf("\n");
printf("Alignment (sampling) : %f s\n", d2_align_sample.get_total());
printf("Alignment (checking) : %f s\n", d2_align_sim.get_total());
printf("Incremental rendering : %f s\n", d2_incremental.get_total());
printf("Irani-Peleg rendering : %f s\n", d2_irani_peleg.get_total());
printf("\n");
printf("Details (local alignment)\n");
printf("-------------------------\n");
int have_details = 0;
for (std::map<double,ale_timer_t>::iterator i = perturb_timers.begin();
i != perturb_timers.end(); i++) {
if (i->second.get_total() == 0.0
&& i == perturb_timers.begin())
continue;
printf("Alignment (perturb %f): %f s\n",
i->first, i->second.get_total());
have_details = 1;
}
if (!have_details) {
printf("No local alignment performed.\n");
}
printf("\n");
}
}
virtual void d3_start() {
status.code = status.UNDEFINED;
printf("Rendering 3D");
update();
}
virtual void d3_control_point_solve() {
status.code = status.D3_CONTROL_POINT_SOLVE;
update();
}
virtual void d3_init_view_angle(double angle) {
status.code = status.UNDEFINED;
update();
}
virtual void d3_final_view_angle(double angle) {
status.code = status.UNDEFINED;
update();
}
virtual void d3_control_point_solve_done() {
status.code = status.UNDEFINED;
update();
}
virtual void d3_subdividing_space() {
status.code = status.D3_SUBDIVIDING_SPACE;
update();
}
virtual void d3_subdividing_space_done() {
status.code = status.UNDEFINED;
update();
}
virtual void d3_updating_occupancy() {
status.code = status.D3_UPDATING_OCCUPANCY;
update();
}
virtual void d3_updating_occupancy_done() {
status.code = status.UNDEFINED;
update();
}
virtual void d3_writing_output(const char *name) {
static int section_announced = 0;
if (!section_announced) {
printf(":\n");
section_announced = 1;
}
printf(" '%s'", name);
update();
}
virtual void d3_writing_output_done() {
status.code = status.UNDEFINED;
printf(".\n");
update();
}
/*
* Warnings
*/
virtual void warn(const char *string) {
printf("\n\n*** Warning: %s. ***\n\n\n");
}
/*
* Errors
*/
virtual void exec_failure(const char *exec, const char *arg1, const char *arg2) {
printf("\n\n*** An error occurred while running `%s %s %s`. ***\n\n\n", exec, arg1, arg2);
exit(1);
}
virtual void fork_failure(const char *location) {
printf("\n\n*** Could not fork in %s. ***\n\n\n", location);
exit(1);
}
virtual void memory_error(const char *purpose) {
printf("\n\n*** Unable to allocate memory for %s. ***\n\n\n", purpose);
exit(1);
}
virtual void memory_error_location(const char *location) {
printf("\n\n*** Unable to allocate memory in %s.\n\n\n", location);
exit(1);
}
virtual void cli_not_enough(const char *option) {
printf("\n\n*** Not enough arguments for `%s' ***\n\n\n", option);
exit(1);
}
virtual void cli_bad_arg(const char *option) {
printf("\n\n*** Bad argument to `%s' ***\n\n", option);
exit(1);
}
virtual void error(const char *string) {
printf("\n\n*** Error: %s. ***\n\n\n", string);
exit(1);
}
virtual void illegal_option(const char *string) {
printf("\n\n*** Error: illegal option %s ***\n\n", string);
exit(1);
}
virtual void unknown_device(const char *string) {
printf("\n\n*** Error: unknown device %s ***\n\n", string);
exit(1);
}
virtual void error_hint(const char *error, const char *hint) {
printf("\n\n*** Error: %s", error);
printf( "\n*** Hint: %s\n\n\n", hint);
exit(1);
}
virtual void cache(double usage, double max) {
}
virtual void log_message(const char *message) {
}
virtual ~ui() {
}
};
#include "ui_wo.h"
#endif

60
ui/ui_log.cc Normal file
View File

@@ -0,0 +1,60 @@
// Copyright 2007 David Hilvert <dhilvert@auricle.dyndns.org>,
// <dhilvert@ugcs.caltech.edu>
/* This file is part of the Anti-Lamenessing Engine.
The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Anti-Lamenessing Engine; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ui.h"
#include "ui_log.h"
#include "d2.h"
void ui_log::set_offset(d2::trans_single offset, int marker) {
if (offset.is_projective()) {
printf("Alignment [%s %f %f %f %f %f %f %f %f %f %f]\n",
marker ? "Q" : "P",
(double) offset.scaled_width(),
(double) offset.scaled_height(),
(double) offset.gpt_get(0, 1),
(double) offset.gpt_get(0, 0),
(double) offset.gpt_get(1, 1),
(double) offset.gpt_get(1, 0),
(double) offset.gpt_get(2, 1),
(double) offset.gpt_get(2, 0),
(double) offset.gpt_get(3, 1),
(double) offset.gpt_get(3, 0) );
} else {
printf("Alignment [%s %f %f %f %f %f]\n",
marker ? "F" : "E",
(double) offset.scaled_width(),
(double) offset.scaled_height(),
(double) offset.eu_get(1),
(double) offset.eu_get(0),
(double) offset.eu_get(2) );
}
}
void ui_log::set_offset(d2::trans_single offset) {
set_offset(offset, 0);
}
void ui_log::set_offset(d2::transformation offset) {
set_offset(offset.get_element(offset.get_current_index()), 0);
}
void ui_log::start_multi_alignment_element(d2::trans_multi &tm) {
printf("Starting multi-alignment element %d.", tm.get_current_index());
}

212
ui/ui_log.h Normal file
View File

@@ -0,0 +1,212 @@
// Copyright 2004 David Hilvert <dhilvert@auricle.dyndns.org>,
// <dhilvert@ugcs.caltech.edu>
/* This file is part of the Anti-Lamenessing Engine.
The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Anti-Lamenessing Engine; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __ui_log_h__
#define __ui_log_h__
#include "ui.h"
/*
* Logging user interface.
*/
class ui_log : public ui {
private:
void printf(const char *format, ...) {
fprintf(ui_stream, "ale: %u: ", (unsigned int) time(NULL));
va_list ap;
va_start(ap, format);
vfprintf(ui_stream, format, ap);
va_end(ap);
if (format[strlen(format) - 1] != '\n')
fprintf(ui_stream, "\n");
}
void update() {
}
public:
ui_log() {
ui_stream = stdout;
}
void exp_multiplier(double m0, double m1, double m2) {
ui::exp_multiplier(m0, m1, m2);
printf("Exposure multiplier: %g, %g, %g\n", m0, m1, m2);
}
void set_steps(int count) {
printf("%d steps to complete\n", count);
}
void set_steps_completed(int count) {
printf("%d steps completed\n", count);
}
void set_match(double match) {
printf("match %g / mismatch %g\n", (1 - match), match);
}
void set_offset(d2::transformation);
void set_offset(d2::trans_single);
void start_multi_alignment_element(d2::trans_multi &);
void set_offset(d2::trans_single, int marker);
void gs_mo(ale_pos gs_mo) {
printf("Global search minimum overlap is %f pixels\n", (double) gs_mo);
}
void loading_file() {
printf("Loading file.\n");
}
void exposure_1() {
printf("Exposure pass 1.\n");
}
void exposure_2() {
printf("Exposure pass 2.\n");
}
void prematching() {
printf("Prematching.\n");
}
void postmatching() {
printf("Postmatching.\n");
}
void constructing_lod_clusters(ale_pos lod) {
printf("Constructing LOD cluster (%f)\n", (double) lod);
}
void global_alignment(ale_pos perturb, ale_pos lod) {
status.perturb_size = perturb;
printf("Global alignment (perturb=%f, lod=%f).\n", (double) perturb, (double) lod);
}
void aligning(ale_pos perturb, ale_pos lod) {
perturb_timers[perturb].start();
status.perturb_size = perturb;
printf("Aligning (perturb=%f, lod=%f).\n", (double) perturb, (double) lod);
}
void multi() {
printf("Assigning multi-alignment pixels.");
}
void following() {
printf("Applying initial-final following logic.\n");
}
void set_orender_current(int num) {
printf("Preparing to render output (index %d)\n", num);
}
void set_arender_current() {
printf("Preparing to render alignment reference image.\n");
}
void rendering() {
printf("Rendering.\n");
}
void writing_output(int num) {
printf("Writing output (index %d)\n", num);
}
void ip_frame_start(unsigned int num) {
printf("Starting Irani-Peleg frame %d.\n", num);
}
void ip_frame_simulate_start() {
printf("Simulating frame.");
}
void ip_frame_correct_start() {
printf("Correcting frame.\n");
}
void ip_write() {
printf("Writing.\n");
}
void ip_step_done() {
printf("Finished pass.");
}
void ip_done() {
printf("Irani-Peleg done.\n");
}
void original_frame_start(const char *name) {
printf("Starting original frame (%s)\n", name);
}
void original_frame_done() {
printf("Finished original frame\n");
}
void supplemental_frame_start(const char *name) {
printf("Starting supplemental frame (%s)\n", name);
}
void supplemental_frame_done() {
printf("Supplemental frame done.\n");
}
void alignment_perturbation_level(ale_pos perturb, ale_pos lod) {
perturb_timers[status.perturb_size].stop();
status.perturb_size = perturb;
perturb_timers[perturb].start();
printf("Perturbation set to %g; LOD set to %g.\n", (double) perturb, (double) lod);
}
void alignment_dims(unsigned int hr, unsigned int wr, unsigned int hi, unsigned int wi) {
printf("Aligning against reference (%u x %u), input (%u x %u).\n", wr, hr, wi, hi);
}
void alignment_match_ok() {
printf("Alignment match OK.\n");
}
void alignment_no_match() {
printf("Alignment failed to match.\n");
}
void cache(double usage, double max) {
printf("Cache usage is %.1f%% of %.0fMB.\n", 100 * usage / max, max);
}
void cache_status(unsigned int i) {
printf("Cache is full.\n");
}
void log_message(const char *message) {
printf(message);
}
};
#endif

55
ui/ui_quiet.h Normal file
View File

@@ -0,0 +1,55 @@
// Copyright 2004, 2007 David Hilvert <dhilvert@auricle.dyndns.org>,
// <dhilvert@ugcs.caltech.edu>
/* This file is part of the Anti-Lamenessing Engine.
The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Anti-Lamenessing Engine; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __ui_quiet_h__
#define __ui_quiet_h__
#include "ui.h"
/*
* Quiet user interface.
*/
class ui_quiet : public ui_wo {
protected:
void printf(const char *format, ...) {
/*
* Reject messages that aren't loud.
*/
if (!strstr(format, "\n***"))
return;
va_list ap;
va_start(ap, format);
vfprintf(ui_stream, format, ap);
va_end(ap);
}
void update() {
}
public:
ui_quiet() {
}
};
#endif

484
ui/ui_tty.h Normal file
View File

@@ -0,0 +1,484 @@
// Copyright 2004 David Hilvert <dhilvert@auricle.dyndns.org>,
// <dhilvert@ugcs.caltech.edu>
/* This file is part of the Anti-Lamenessing Engine.
The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Anti-Lamenessing Engine; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __ui_tty_h__
#define __ui_tty_h__
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#if HAVE_TIME_H
#include <time.h>
#endif
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include "../d2.h"
#include "ui.h"
#include "util.h"
/*
* TTY user interface
*/
class ui_tty : public ui {
private:
int terminal_width;
char *buffer;
int buffer_index;
int status_index;
int dirty;
#ifdef USE_PTHREAD
pthread_mutex_t lock;
pthread_t update_thread;
#endif
void clear_buffer() {
buffer[0] = '\0';
buffer_index = 0;
}
void write_buffer() {
if (buffer_index < 0)
return;
fputc('\r', ui_stream);
fputs(buffer, ui_stream);
status_index = buffer_index;
}
void status_clear() {
while (status_index < terminal_width) {
status_index++;
fprintf(ui_stream, " ");
}
}
void line_clear() {
fputc('\r', ui_stream);
for (int i = 0; i < terminal_width; i++) {
fprintf(ui_stream, " ");
}
}
int status_printf(int count, ...) {
if (buffer_index < 0)
return -1;
int n;
char *local_buffer = (char *) calloc(terminal_width - status_index, sizeof(char));
assert(local_buffer);
if (!local_buffer)
return -1;
for (int i = 0; i < count; i++) {
char *format = NULL;
va_list ap;
va_start(ap, count);
for (int arg = 0; arg < i + 1; arg++)
format = va_arg(ap, char *);
for (int arg = i + 1; arg < count; arg++)
va_arg(ap, char *);
assert (format);
n = vsnprintf(local_buffer, terminal_width - status_index, format, ap);
va_end(ap);
if (n < 0 || n > terminal_width - status_index - 1)
continue;
fputs(local_buffer, ui_stream);
status_index += n;
free(local_buffer);
return 0;
}
/*
* If we reach this point, then there was no valid string produced.
*/
status_clear();
free(local_buffer);
/*
* Failure.
*/
return -1;
}
void pad_align_status() {
for (int i = 0; i < status.steps - status.steps_completed; i++) {
status_printf(1, " ");
}
}
void pad_match_status() {
status_printf(1, " ");
}
int write_match_status() {
return status_printf(1, format_string_working(), status.match_value);
}
void write_status() {
if (status.code == status.UNDEFINED
|| status.code == status.FRAME_DONE
|| status.code == status.SET_DONE
|| status.code == status.IP_STEP_DONE) {
status_clear();
return;
}
if (status.code == status.GLOBAL_ALIGN
|| status.code == status.ALIGN
|| status.code == status.POSTMATCH
|| status.code == status.EXPOSURE_PASS_2) {
pad_align_status();
if (write_match_status()) {
clear_buffer();
fprintf(ui_stream, "\n");
write_match_status();
}
}
status_printf(1, " | ");
switch (status.code) {
case status_type::LOAD_FILE:
status_printf(4, "Loading Image (%s)",
"Loading Image", "Loading", "load",
status.cache ? "caching" : "cache is full");
break;
case status_type::EXPOSURE_PASS_1:
status_printf(3, "Registering exposure (first pass)", "Registering exposure", "regexp1");
break;
case status_type::LODCLUSTER_CREATE:
status_printf(3, "Creating LOD cluster, scale %g", "Creating LOD clusters", "lodcluster",
pow(2, -status.align_lod));
break;
case status_type::PREMATCH:
status_printf(3, "Calculating pre-alignment match", "Calculating match", "prematch");
break;
case status_type::MULTI:
status_printf(3, "Assigning multi-alignment pixels", "Multi-alignment", "multi");
break;
case status_type::GLOBAL_ALIGN:
case status_type::ALIGN:
status_printf(5, "%s [perturb=%6.3g] [lod=%6.3g] [exp_mult=%6.3g %6.3g %6.3g]",
"%s [perturb=%6.3g] [lod=%6.3g]",
"%s [perturb=%6.3g]",
"%s...",
"align",
(status.code == status_type::GLOBAL_ALIGN)
? "Global alignment"
: "Aligning",
status.perturb_size,
pow(2, -status.align_lod),
status.exp_multiplier[0],
status.exp_multiplier[1],
status.exp_multiplier[2]);
break;
case status_type::POSTMATCH:
status_printf(3, "Calculating post-alignment match", "Calculating match", "postmatch");
break;
case status_type::EXPOSURE_PASS_2:
status_printf(3, "Registering exposure (second pass)", "Registering exposure", "regexp2");
break;
case status_type::RENDERA:
status_printf(3, "Rendering alignment reference image", "Rendering", "render-a");
break;
case status_type::RENDERD:
status_printf(3, "Rendering default chain", "Rendering", "render-d");
break;
case status_type::RENDERO:
status_printf(3, "Rendering chain %d", "Rendering", "render-o%d", status.onum);
break;
case status_type::WRITED:
status_printf(4, "Writing default chain to '%s'",
"Writing '%s'", "Writing", "write-d", d2::image_rw::output_name());
break;
case status_type::WRITEO:
status_printf(3, "Writing image for chain %d", "Writing", "write-o%d", status.onum);
break;
case status_type::IP_RENDER:
status_printf(3, "Frame '%s'%s",
"Frame '%s'", "Processing",
d2::image_rw::name(status.frame_num), status.irani_peleg_stage
? ((status.irani_peleg_stage == 1) ? " [simulate ]" : " [backproject]")
: "");
break;
case status_type::IP_UPDATE:
status_printf(3, "Updating approximation", "Updating", "update");
break;
case status_type::IP_WRITE:
status_printf(3, "Writing '%s'", "Writing", "write", d2::image_rw::output_name());
break;
case status_type::D3_CONTROL_POINT_SOLVE:
status_printf(1, "Aligning control points, %g%% done, error=%g",
log(status.cp_cur_perturb / status.cp_max_perturb)
/ log(status.cp_min_perturb / status.cp_max_perturb),
status.cp_cur_error);
break;
case status_type::D3_SUBDIVIDING_SPACE:
status_printf(2, "Subdividing space, frame pair (%u, %u), y=%u, x=%u, spaces=%u",
"Subdividing space", status.frame_num,
status.secondary_frame_num, status.y_coordinate, status.x_coordinate,
status.total_spaces);
break;
case status_type::D3_UPDATING_OCCUPANCY:
status_printf(2, "Updating occupancy, step %u/%u, frame %u, space %u/%u",
"Updating occupancy", status.steps_completed,
status.steps, status.frame_num,
status.space_num, status.total_spaces);
break;
case status_type::D3_RENDER:
if (status.filtering == 0 && status.focusing == 0) {
status_printf(1, "space %u/%u",
status.space_num, status.total_spaces);
} else if (status.filtering == 1 && status.focusing == 0) {
status_printf(1, "frame %u, y=%u, x=%u",
status.frame_num, status.y_coordinate, status.x_coordinate);
} else if (status.filtering == 0 && status.focusing == 1) {
status_printf(1, "y=%u, x=%u, view=%u", status.y_coordinate, status.x_coordinate,
status.view_num);
} else if (status.filtering == 1 && status.focusing == 1) {
status_printf(1, "view=%u, y=%u, x=%u, frame=%u",
status.view_num, status.y_coordinate, status.x_coordinate,
status.frame_num);
}
break;
default:
break;
}
status_clear();
}
void write_all() {
write_buffer();
write_status();
}
void printf(const char *format, ...) {
#ifdef USE_PTHREAD
pthread_mutex_lock(&lock);
#endif
va_list ap;
int n = -1;
if (buffer_index >= 0 && buffer_index < terminal_width /* && format[strlen(format) - 1] != '\n' */) {
va_start(ap, format);
n = vsnprintf(buffer + buffer_index, terminal_width - buffer_index, format, ap);
va_end(ap);
}
if (n >= 0 && n < terminal_width - buffer_index) {
/*
* The message fits in the buffer, so update the index
* and write buffer and status information.
*/
buffer_index += n;
if (format[strlen(format) - 1] == '\n') {
line_clear();
write_buffer();
} else
write_all();
} else {
/*
* The message does not fit in the buffer, so write any
* existing buffer and append the new text to the stream.
*/
if (buffer_index >= 0) {
assert(buffer_index < terminal_width);
buffer[buffer_index] = '\0';
write_buffer();
}
buffer_index = -1;
va_start(ap, format);
vfprintf(ui_stream, format, ap);
va_end(ap);
}
/*
* This is not the only case that produces a newline,
* but ignoring other cases should be safe.
*/
if (format[strlen(format) - 1] == '\n') {
buffer_index = 0;
buffer[0] = '\0';
}
#ifdef USE_PTHREAD
pthread_mutex_unlock(&lock);
#endif
}
void update() {
static time_t last_update = 0;
time_t now = time(NULL);
/*
* Handle DONE status.
*/
if (status.code == status_type::FRAME_DONE) {
printf(".");
#ifdef USE_PTHREAD
pthread_mutex_lock(&lock);
#endif
fputc('\n', ui_stream);
buffer_index = 0;
buffer[0] = '\0';
#ifdef USE_PTHREAD
pthread_mutex_unlock(&lock);
#endif
} else if (status.code == status_type::SET_DONE) {
#ifdef USE_PTHREAD
pthread_mutex_lock(&lock);
#endif
fputc('\n', ui_stream);
buffer_index = 0;
buffer[0] = '\0';
#ifdef USE_PTHREAD
pthread_mutex_unlock(&lock);
#endif
} else {
/*
* Handle optional output.
*/
#ifdef USE_PTHREAD
pthread_mutex_lock(&lock);
#endif
if (now == last_update) {
dirty = 1;
} else {
dirty = 0;
last_update = now;
write_all();
}
#ifdef USE_PTHREAD
pthread_mutex_unlock(&lock);
#endif
}
}
public:
#ifdef USE_PTHREAD
static void *update_loop(void *vu) {
ui_tty *u = (ui_tty *) vu;
for(;;) {
#ifdef HAVE_NANOSLEEP
struct timespec t;
t.tv_sec = 0;
t.tv_nsec = 100000000;
nanosleep(&t, NULL);
#else
sleep(1);
#endif
if (u->dirty) {
pthread_mutex_lock(&u->lock);
u->write_all();
u->dirty = 0;
pthread_mutex_unlock(&u->lock);
}
}
return NULL;
}
#endif
/*
* Constructor may throw an exception to signal that using ui_wo would
* be more appropriate.
*/
ui_tty() {
int exception_value = 1;
if (!isatty(fileno(ui_stream)))
throw exception_value;
/*
* Don't use the last column, as this may cause
* wrapping in some environments (BSD, Hurd).
*/
terminal_width = get_terminal_width(ui_stream) - 1;
if (terminal_width < 0)
throw exception_value;
buffer = (char *) calloc(terminal_width + 1, sizeof(char));
assert (buffer);
if (!buffer)
throw exception_value;
buffer[0] = '\0';
buffer_index = 0;
dirty = 0;
/*
* Start an updating thread if possible.
*/
#ifdef USE_PTHREAD
pthread_mutex_init(&lock, NULL);
pthread_attr_t pattr;
pthread_attr_init(&pattr);
pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_JOINABLE);
pthread_create(&update_thread, NULL, update_loop, (void *) this);
#endif
}
~ui_tty() {
#ifdef USE_PTHREAD
pthread_cancel(update_thread);
pthread_join(update_thread, NULL);
#endif
free(buffer);
}
};
#endif

52
ui/ui_wo.h Normal file
View File

@@ -0,0 +1,52 @@
// Copyright 2004 David Hilvert <dhilvert@auricle.dyndns.org>,
// <dhilvert@ugcs.caltech.edu>
/* This file is part of the Anti-Lamenessing Engine.
The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Anti-Lamenessing Engine; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __ui_wo_h__
#define __ui_wo_h__
#include "ui.h"
/*
* Write-once user interface.
*/
class ui_wo : public ui {
private:
void printf(const char *format, ...) {
va_list ap;
va_start(ap, format);
vfprintf(ui_stream, format, ap);
va_end(ap);
}
void update() {
if (status.code == status.FRAME_DONE) {
printf(".\n");
} else if (status.code == status.SET_DONE) {
printf("\n");
}
}
public:
ui_wo() {
}
};
#endif

71
ui/unsupported.h Normal file
View File

@@ -0,0 +1,71 @@
// Copyright 2004 David Hilvert <dhilvert@auricle.dyndns.org>,
// <dhilvert@ugcs.caltech.edu>
/* This file is part of the Anti-Lamenessing Engine.
The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Anti-Lamenessing Engine; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __unsupported_h__
#define __unsupported_h__
/*
* Information about unsupported features.
*/
class unsupported {
public:
/*
* Describe a feature that is unsupported for now.
*/
static void fornow(const char *description) {
fprintf(stderr, "\n\n");
fprintf(stderr, "The following feature is currently unsupported:\n\n");
fprintf(stderr, description);
fprintf(stderr, "\n\n");
#if 0
fprintf(stderr, "For more information, see http://auricle.dyndns.org/ALE/unsupported/currently/\n\n");
#endif
exit(1);
}
/*
* Describe an option that is undocumented.
*/
static void undocumented(const char *description) {
fprintf(stderr, "\n\n");
fprintf(stderr, "Warning: %s is undocumented.\n", description);
}
/*
* Describe an option that is no longer supported.
*/
static void discontinued(const char *description, const char *alternative = NULL, const char *alternative2 = NULL) {
fprintf(stderr, "\n\n");
fprintf(stderr, "Error: %s is no longer supported.\n", description);
if (alternative && alternative2) {
fprintf(stderr, " Use either: %s\n", alternative);
fprintf(stderr, " or: %s\n", alternative2);
} else if (alternative)
fprintf(stderr, " Use: %s\n", alternative);
fprintf(stderr, "\n");
exit(1);
}
};
#endif

47
ui/util.h Normal file
View File

@@ -0,0 +1,47 @@
// Copyright 2004 David Hilvert <dhilvert@auricle.dyndns.org>,
// <dhilvert@ugcs.caltech.edu>
/* This file is part of the Anti-Lamenessing Engine.
The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Anti-Lamenessing Engine; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __util_h__
#define __util_h__
#ifdef USE_IOCTL
#include <sys/ioctl.h>
#endif
/*
* Returns the terminal width if possible. Else, returns
* -1. Based on the function 'determine_screen_width'
* in wget 1.9.1.
*/
static inline int get_terminal_width (FILE *tty_file) {
int error_code = -1;
#if defined USE_IOCTL && defined TIOCGWINSZ
struct winsize wsz;
if(ioctl(fileno(tty_file), TIOCGWINSZ, &wsz) < 0)
return error_code;
return wsz.ws_col;
#else
return error_code;
#endif
}
#endif