#ifndef pz_plot_H #define pz_plot_H /* Plotting routines */ /* Last edited on 2015-01-20 16:49:31 by stolfilocal */ #include #include #include #include #include #include #include #include #include /* CURVES, SEGMENTS, MATCHINGS */ /* The following procedures draw into an already open {PSStream}, */ /* with the current graphics settings. */ void pz_plot_curve ( PSStream *f, pz_r3_chain_t *c, bool_t closed, /* (:= TRUE) */ int drawEvery, /* (:= 1) */ int phase /* (:= 0) */ ); /* Draws the given curve into file {f}, as a polygonal. If {drawEvery>1}, uses only the first sample, last sample, and one sample out of every {drawEvery} samples (including {c[phase]}). */ void pz_plot_dots ( PSStream *f, pz_r3_chain_t *c, double size, /* (:= 2.0) */ int drawEvery, /* (:= 1) */ int phase /* (:= 0) */ ); /* Draws dots at the points of the given curve into file {f}, plotting only one sample out of every {drawEvery} samples, including {c[phase]} (modulo the array's length). The dots' diameter is {size} times the current line width. */ void pz_plot_frame ( PSStream *f, r3_t color, double lineWidth ); /* Draws a rectangular frame around the current plotting area. */ void pz_plot_grid ( PSStream *f, double gridStep, r3_t color, /* (:= (r3_t){{0,0,0}}) */ double lineWidth /* (:= 0.05) */ ); /* Draws a coordinate grid with specified increment between lines, within the current client rectangle. */ void pz_plot_star ( PSStream *f, r3_t color, double radius ); /* Draws a star with given radius (in millimeters) near the upper left corner of the plotting area. */ void pz_plot_match ( PSStream *f, pz_match_t *m, pz_r3_chain_t *vA, pz_r3_chain_t *vB, pz_segment_t *segA, pz_segment_t *segB, int drawEvery, int phaseA, int phaseB ); /* Draws into {f} lines connecting the points of {vA} and {vB} that are connected by the pairing {m}, with the current line thickness, color, and style. The pairing is interpreted relative to segments {segA} and {segB}. If {drawEvery > 1}, plots only one every {drawEvery} pairs, including the pair {(phaseA,phaseB)} */ void pz_plot_segment ( PSStream *f, pz_segment_t *s, pz_r3_chain_t *c, /* Mapped curve */ bool_t closed, /* TRUE considers the curve closed. */ int drawEvery, /* (:= 1) Plot every {drawEvery} samples. */ int phase /* (:= 0) Phase of dot sampling. */ ); /* Plots a segment of a curve, with the current line thickness, color, and style. The segment extends from {c[s.ini]} to {c[s.fin]}. The indices {s.ini} and {s.fin} are reduced modulo {(c.ne)}; if {s.ini > s.fin}, the plotted segment is actually {c[0..s.fin]} and {c[s.ini..(c.ne - 1)]}. In this case, if {closed} is TRUE, point {c[(c.ne - 1)]} is connected to {c[0]}. If {drawEvery > 1} plots only one every {drawEvery} samples, synchronized with {c[phase]}. */ void pz_plot_segment_dots ( PSStream *f, pz_segment_t *s, pz_r3_chain_t *c, /* Mapped curve */ double size, /* (:= 2.0) */ int drawEvery, /* (:= 1) Plot every {drawEvery} samples. */ int phase /* (:= 0) Sampling phase */ ); /* Draws dots at every {drawEvery} samples of the segment {s}, with the current line color. The dots' diameter is {size} times the current line width. If {drawEvery > 1} plots only one every {drawEvery} samples, sybchronized with {c[phase]}. */ void pz_plot_segment_label ( PSStream *f, pz_segment_t *s, pz_r3_chain_t *c, double minRelDist, char *label, double size, /* (:= 12.0) */ char *font /* (:= "Courier") */ ); /* Labels the segment {s} of curve {c}. The label is placed between the segment's midpoint and the aproximate center of the whole curve, close to the segment's approximate barycenter, but at least {minRelDist} of the way from the midpoint to the curve center. */ void pz_plot_segment_pointer ( PSStream *f, pz_segment_t *s, pz_r3_chain_t *c, double frac, double width, /* (:= 4.0) */ double length, /* (:= 8.0) */ bool_t inside /* (:= TRUE) */ ); /* Places an arrowhead pointing to a point {frac} the way from the start to the end of the segment {s} of {c}, taking into account wrap-around and reversal. Thus {frac==0} means at start, {frac==1} means at end. The dimensions are relative to the current line width, The arrowhead is painted solid with the current line color. If {inside==TRUE} the arrow is placed inside the curve, otherwise it is placed outside pointing in. */ void pz_plot_segment_brackets ( PSStream *f, pz_segment_t *s, pz_r3_chain_t *c, double width, /* (:= 8.0) */ double length /* (:= 4.0) */ ); /* Draws start and finish markers at both ends of segment {s} of {c}, taking into account wrap-around and reversal. The dimensions are relative to the current line width. The brackets are drawn with the current line style and color. */ /* ALL-IN-ONE PROCS */ /* The following procedures use fixed colors, line widths, and styles: */ void pz_plot_candidate ( PSStream *f, pz_candidate_t *cand, pz_r3_chain_t *c0, pz_r3_chain_t *c1, /* Curves, already mapped; */ bool_t whole, bool_t closed, bool_t colors, bool_t thicker, bool_t dots, bool_t pointers, double labelSize, int drawEvery, /* (:= 1) */ int drawMatchEvery /* (:= 0) */ ); /* Plots a candidate, consisting of two segments of the given curves {c0} and {c1} (which must have been translated and rotated by the client as desired). The two segments are drawn in thick red and blue. The segments may wrap around the end of the array, as explained in the {pz_plot_segment} procedure above. If {whole} is TRUE, the unmatched parts of the contours are drawn in thin black. If {closed} is TRUE, the last point of each curve is connected to the first. If {colors} is true, uses red for the first segment, blue for the second segment, and black for the rest of both outlines. Otherwise draws the entire outlines in black. If {thicker} is true, the cancidate's segments are drawn with double-thickness lines; otherwise the same thickness is used for the entire outlines. If {dots} is TRUE then dots are drawn at the sample positions. If {pointers} is true, draws arrowheads pointing at the start and end of each segment. if (( {labelSize > 0}, the number of each contour (as specified by {cand}) is drawn somewhere near its center.. If {drawEvery > 1}, plots only one every {drawEvery} points of each contour. If {drawMatchEvery > 0} and the pairing {cand.pm} is not NULL, the matched sample pairs are drawn in thin gray. If {drawMatchEvery > 1}, only one out of every {drawMatchEvery} pairs is plotted. */ void pz_plot_half_candidate ( PSStream *f, pz_segment_t *s, pz_r3_chain_t *c, /* pz_plot_curve, already mapped; */ bool_t whole, /* TRUE plots the whole {c}, false plots only {s}. */ bool_t closed, /* TRUE if the curve {c} (NOT the segment!) is closed. */ r3_t color, /* Color for drawing the segment {s}. */ bool_t thicker, /* TRUE draws the segment {s} thicker. */ bool_t dots, /* TRUE to draw a dot at each sample position. */ bool_t pointers, /* TRUE to draw pointers at the segment's ends. */ double labelSize, /* Label font size, in points. */ int drawEvery /* (:= 1) Plots one every this many points of {c}. */ ); /* Draws one half of a candidate (minus the pairing), as above: the segment {s} in the specified color, the rest of the curve {c} in black. */ typedef void pz_plot_seg_seg_proc_t ( pz_segment_pair *t, pz_segment_pair *tRef ); void pz_plot_try_all_shifts ( pz_segment_pair *s, pz_segment_pair *sRef, pz_plot_seg_seg_proc_t proc ); /* Calls {proc(t,tRef)}, for some some segment pair {tRef} that is equivalent to {sRef} modulo full cycle shift, and every segment {t} that is equivalent to {s} and intersects {tRef}. */ int pz_plot_compute_draw_every ( PSStream *f, double eps, double step, bool_t all ); /* Computes the largest integer number {d} of sampling steps of length {step} that correspond to at most {eps} millimeters in either scale. As special cases, if {all == TRUE} or {step == 0}, returns {d == 1}. */ /* PAGINATION OPTIONS */ typedef struct pz_plot_paging_options_t { bool_t epsFormat; /* TRUE to use Encapsulated Postscript. */ /* Scale-defining options: */ pz_window_t window; /* Plotting X and Y ranges in client units. */ double actualHor; /* Actual plot area width in mm. */ double actualVer; /* Actual plot area height in mm. */ /* Plot options for non-EPS format: */ int nCols; /* Number of drawings per row. */ int nRows; /* Number of drawings per column. */ } pz_plot_paging_options_t; #define pz_plot_paging_OPTIONS_HELP \ " [ -objectSize WIDTH HEIGHT | \\\n" \ " -window XMIN XMAX YMIN YMAX \\\n" \ " ] \\\n" \ " [ -epsFormat [ -actualSize WIDTH HEIGHT ] | \\\n" \ " -nDrawingsPerPage NUMBER NUMBER \\\n" \ " ]" pz_plot_paging_options_t *pz_plot_parse_paging_options ( argparser_t *pp, bool_t single, double defaultHor, /* Default plotting area width in mm. */ double defaultVer /* Default plotting area height in mm. */ ); /* Parses the {pz_plot_paging_options_t} attributes from the command line, as described by {pz_plot_paging_OPTIONS_HELP}. The {single} parameter chooses between default values appropriate for programs that produce single or multiple drawings: | single==TRUE: -nDrawingsPerPage 1 1 -actualSize 160 160. | single==FALSE: -nDrawingsPerPage 4 5 -actualSize 40 40. */ /* Copyright © 2001 Universidade Estadual de Campinas (UNICAMP). Authors: Helena C. G. Leitão and Jorge Stolfi. This file can be freely distributed, used, and modified, provided that this copyright and authorship notice is preserved, and that any modified versions are clearly marked as such. This software has NO WARRANTY of correctness or applicability for any purpose. Neither the authors nor their employers chall be held responsible for any losses or damages that may result from its use. */ #endif