Changeset 1b0bf6a in git


Ignore:
Timestamp:
28/02/15 11:07:44 (5 years ago)
Author:
Olly Betts <olly@…>
Branches:
line_contents, master, stereo, travis-osx
Children:
cd4684a
Parents:
b4f28e0
Message:

src/export.cc,src/exportfilter.h: Pass bounding box as parameters to
header() method rather than storing them as static data.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rb4f28e0 r1b0bf6a  
     1Sat Feb 28 11:06:25 GMT 2015  Olly Betts <olly@survex.com>
     2
     3        * src/export.cc,src/exportfilter.h: Pass bounding box as parameters to
     4          header() method rather than storing them as static data.
     5
    16Wed Feb 25 06:34:53 GMT 2015  Olly Betts <olly@survex.com>
    27
  • src/export.cc

    rb4f28e0 r1b0bf6a  
    104104}
    105105
    106 /* bounds */
    107 static double min_x, min_y, min_z, max_x, max_y, max_z;
    108 
    109106static double text_height; /* for station labels */
    110107static double marker_size; /* for station markers */
     
    131128    const int * passes() const;
    132129    bool fopen(const char *fnm_out);
    133     void header(const char *, const char *, time_t);
     130    void header(const char *, const char *, time_t,
     131                double min_x, double min_y, double min_z,
     132                double max_x, double max_y, double max_z);
    134133    void line(const img_point *, const img_point *, bool, bool);
    135134    void label(const img_point *, const char *, bool, int);
     
    160159
    161160void
    162 DXF::header(const char *, const char *, time_t)
     161DXF::header(const char *, const char *, time_t,
     162            double min_x, double min_y, double min_z,
     163            double max_x, double max_y, double max_z)
    163164{
    164165   fprintf(fh, "0\nSECTION\n"
     
    394395    Skencil() { }
    395396    const int * passes() const;
    396     void header(const char *, const char *, time_t);
     397    void header(const char *, const char *, time_t,
     398                double min_x, double min_y, double min_z,
     399                double max_x, double max_y, double max_z);
    397400    void start_pass(int layer);
    398401    void line(const img_point *, const img_point *, bool, bool);
     
    410413
    411414void
    412 Skencil::header(const char *, const char *, time_t)
     415Skencil::header(const char *, const char *, time_t,
     416                double min_x, double min_y, double /*min_z*/,
     417                double max_x, double max_y, double /*max_z*/)
    413418{
    414419   fprintf(fh, "##Sketch 1 2\n"); /* File format version */
     
    549554    SVG() : to_close(NULL), close_g(false) { pending[0] = '\0'; }
    550555    const int * passes() const;
    551     void header(const char *, const char *, time_t);
     556    void header(const char *, const char *, time_t,
     557                double min_x, double min_y, double min_z,
     558                double max_x, double max_y, double max_z);
    552559    void start_pass(int layer);
    553560    void line(const img_point *, const img_point *, bool, bool);
     
    571578
    572579void
    573 SVG::header(const char * title, const char *, time_t)
     580SVG::header(const char * title, const char *, time_t,
     581            double min_x, double min_y, double /*min_z*/,
     582            double max_x, double max_y, double /*max_z*/)
    574583{
    575584   size_t i;
     
    732741    const char * find_name_plt(const img_point *p);
    733742
     743    double min_N, max_N, min_E, max_E, min_A, max_A;
     744
    734745  public:
    735746    PLT() { }
    736747    const int * passes() const;
    737     void header(const char *, const char *, time_t);
     748    void header(const char *, const char *, time_t,
     749                double min_x, double min_y, double min_z,
     750                double max_x, double max_y, double max_z);
    738751    void line(const img_point *, const img_point *, bool, bool);
    739752    void label(const img_point *, const char *, bool, int);
     
    749762
    750763void
    751 PLT::header(const char *title, const char *, time_t)
    752 {
    753    size_t i;
     764PLT::header(const char *title, const char *, time_t,
     765            double min_x, double min_y, double min_z,
     766            double max_x, double max_y, double max_z)
     767{
    754768   htab = (point **)osmalloc(HTAB_SIZE * ossizeof(point *));
    755    for (i = 0; i < HTAB_SIZE; ++i) htab[i] = NULL;
     769   for (size_t i = 0; i < HTAB_SIZE; ++i) htab[i] = NULL;
    756770   /* Survex is E, N, Alt - PLT file is N, E, Alt */
     771   min_N = min_y / METRES_PER_FOOT;
     772   max_N = max_y / METRES_PER_FOOT;
     773   min_E = min_x / METRES_PER_FOOT;
     774   max_E = max_x / METRES_PER_FOOT;
     775   min_A = min_z / METRES_PER_FOOT;
     776   max_A = max_z / METRES_PER_FOOT;
    757777   fprintf(fh, "Z %.3f %.3f %.3f %.3f %.3f %.3f\r\n",
    758            min_y / METRES_PER_FOOT, max_y / METRES_PER_FOOT,
    759            min_x / METRES_PER_FOOT, max_x / METRES_PER_FOOT,
    760            min_z / METRES_PER_FOOT, max_z / METRES_PER_FOOT);
     778           min_N, max_N, min_E, max_E, min_A, max_A);
    761779   fprintf(fh, "N%s D 1 1 1 C%s\r\n", survey ? survey : "X",
    762780           (title && title[0]) ? title : "X");
     
    820838   /* Survex is E, N, Alt - PLT file is N, E, Alt */
    821839   fprintf(fh, "X %.3f %.3f %.3f %.3f %.3f %.3f\r\n",
    822            min_y / METRES_PER_FOOT, max_y / METRES_PER_FOOT,
    823            min_x / METRES_PER_FOOT, max_x / METRES_PER_FOOT,
    824            min_z / METRES_PER_FOOT, max_z / METRES_PER_FOOT);
     840           min_N, max_N, min_E, max_E, min_A, max_A);
    825841   /* Yucky DOS "end of textfile" marker */
    826842   PUTC('\x1a', fh);
     
    830846  public:
    831847    EPS() { }
    832     void header(const char *, const char *, time_t);
     848    void header(const char *, const char *, time_t,
     849                double min_x, double min_y, double min_z,
     850                double max_x, double max_y, double max_z);
    833851    void line(const img_point *, const img_point *, bool, bool);
    834852    void label(const img_point *, const char *, bool, int);
     
    838856
    839857void
    840 EPS::header(const char *title, const char *, time_t)
     858EPS::header(const char *title, const char *, time_t,
     859            double min_x, double min_y, double /*min_z*/,
     860            double max_x, double max_y, double /*max_z*/)
    841861{
    842862   const char * fontname_labels = "helvetica"; // FIXME
     
    11921212   }
    11931213
    1194    /* Get drawing corners */
     1214   /* Get bounding box */
     1215   double min_x, min_y, min_z, max_x, max_y, max_z;
    11951216   min_x = min_y = min_z = HUGE_VAL;
    11961217   max_x = max_y = max_z = -HUGE_VAL;
     
    12841305
    12851306   /* Header */
    1286    filt->header(title.mb_str(), datestamp.mb_str(), datestamp_numeric);
     1307   filt->header(title.mb_str(), datestamp.mb_str(), datestamp_numeric,
     1308                min_x, min_y, min_z, max_x, max_y, max_z);
    12871309
    12881310   p1.x = p1.y = p1.z = 0; /* avoid compiler warning */
  • src/exportfilter.h

    rb4f28e0 r1b0bf6a  
    44 */
    55
    6 /* Copyright (C) 2005,2012,2013,2014 Olly Betts
     6/* Copyright (C) 2005,2012,2013,2014,2015 Olly Betts
    77 *
    88 * This program is free software; you can redistribute it and/or modify
     
    4040        return (fh != NULL);
    4141    }
    42     virtual void header(const char *, const char *, time_t) { }
     42    virtual void header(const char *, const char *, time_t,
     43                        double, double, double,
     44                        double, double, double) { }
    4345    virtual void start_pass(int) { }
    4446    virtual void line(const img_point *, const img_point *, bool, bool) = 0;
Note: See TracChangeset for help on using the changeset viewer.