From 375d87a9b0ec1cf2fffd705adb870c86144d2400 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 26 Oct 2026 20:05:20 +0100 Subject: Replace the C++ implementation with the Rust port The Rust port (formerly gipfel-rs) is now the official successor to the FLTK/GSL C++ code base. This squashes the port into a single commit and removes the C++ sources (they remain in the git history below). Layout: crates/gipfel-core headless core: hills, panorama geometry, projections (maxima-generated derivatives), pure-Rust LM fit, gipfel: JPEG comment + EXIF I/O, profiles, stitching crates/gipfel-cli command-line tools (export, info, stitch, profiles) crates/gipfel-app Cosmic DE (libcosmic) GUI, binary name `gipfel` codegen/ maxima scripts + regen.sh for the projection code tests/ golden files + C++ reference harnesses (historical) The original README is kept for now; it will be updated to describe the Rust build. gipfel.dat, AUTHORS, ChangeLog and NEWS are unchanged. --- src/Fl_Search_Chooser.H | 42 --- src/Fl_Search_Chooser.cxx | 137 ------- src/Fl_Value_Dial.H | 29 -- src/Fl_Value_Dial.cxx | 67 ---- src/GipfelWidget.H | 93 ----- src/GipfelWidget.cxx | 822 ------------------------------------------ src/Hill.H | 69 ---- src/Hill.cxx | 341 ------------------ src/ImageMetaData.H | 65 ---- src/ImageMetaData.cxx | 322 ----------------- src/JPEGOutputImage.H | 38 -- src/JPEGOutputImage.cxx | 104 ------ src/Makefile.am | 45 --- src/Makefile.lsq_funcs | 7 - src/OutputImage.H | 32 -- src/OutputImage.cxx | 58 --- src/Panorama.H | 83 ----- src/Panorama.cxx | 476 ------------------------ src/PreviewOutputImage.H | 34 -- src/PreviewOutputImage.cxx | 65 ---- src/ProjectionCylindrical.H | 33 -- src/ProjectionCylindrical.cxx | 26 -- src/ProjectionLSQ.H | 59 --- src/ProjectionLSQ.cxx | 294 --------------- src/ProjectionRectilinear.H | 38 -- src/ProjectionRectilinear.cxx | 12 - src/ScanImage.H | 31 -- src/ScanImage.cxx | 118 ------ src/ScreenDump.H | 26 -- src/ScreenDump.cxx | 59 --- src/Stitch.H | 32 -- src/Stitch.cxx | 117 ------ src/TIFFOutputImage.H | 33 -- src/TIFFOutputImage.cxx | 97 ----- src/ViewParams.H | 21 -- src/choose_hill.H | 15 - src/choose_hill.cxx | 43 --- src/expr2c.mac | 28 -- src/gipfel.cxx | 738 ------------------------------------- src/lsq_cylindrical.mac | 38 -- src/lsq_rectilinear.mac | 60 --- src/strsep.c | 70 ---- src/strsep.h | 12 - 43 files changed, 4929 deletions(-) delete mode 100644 src/Fl_Search_Chooser.H delete mode 100644 src/Fl_Search_Chooser.cxx delete mode 100644 src/Fl_Value_Dial.H delete mode 100644 src/Fl_Value_Dial.cxx delete mode 100644 src/GipfelWidget.H delete mode 100644 src/GipfelWidget.cxx delete mode 100644 src/Hill.H delete mode 100644 src/Hill.cxx delete mode 100644 src/ImageMetaData.H delete mode 100644 src/ImageMetaData.cxx delete mode 100644 src/JPEGOutputImage.H delete mode 100644 src/JPEGOutputImage.cxx delete mode 100644 src/Makefile.am delete mode 100644 src/Makefile.lsq_funcs delete mode 100644 src/OutputImage.H delete mode 100644 src/OutputImage.cxx delete mode 100644 src/Panorama.H delete mode 100644 src/Panorama.cxx delete mode 100644 src/PreviewOutputImage.H delete mode 100644 src/PreviewOutputImage.cxx delete mode 100644 src/ProjectionCylindrical.H delete mode 100644 src/ProjectionCylindrical.cxx delete mode 100644 src/ProjectionLSQ.H delete mode 100644 src/ProjectionLSQ.cxx delete mode 100644 src/ProjectionRectilinear.H delete mode 100644 src/ProjectionRectilinear.cxx delete mode 100644 src/ScanImage.H delete mode 100644 src/ScanImage.cxx delete mode 100644 src/ScreenDump.H delete mode 100644 src/ScreenDump.cxx delete mode 100644 src/Stitch.H delete mode 100644 src/Stitch.cxx delete mode 100644 src/TIFFOutputImage.H delete mode 100644 src/TIFFOutputImage.cxx delete mode 100644 src/ViewParams.H delete mode 100644 src/choose_hill.H delete mode 100644 src/choose_hill.cxx delete mode 100644 src/expr2c.mac delete mode 100644 src/gipfel.cxx delete mode 100644 src/lsq_cylindrical.mac delete mode 100644 src/lsq_rectilinear.mac delete mode 100644 src/strsep.c delete mode 100644 src/strsep.h (limited to 'src') diff --git a/src/Fl_Search_Chooser.H b/src/Fl_Search_Chooser.H deleted file mode 100644 index 37ed431..0000000 --- a/src/Fl_Search_Chooser.H +++ /dev/null @@ -1,42 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef FL_SEARCH_CHOOSER_H -#define FL_SEARCH_CHOOSER_H - -#include -#include -#include - -class Fl_Search_Browser : public Fl_Select_Browser { - private: - int find_prefix(const char *p, int s, int e); - - public: - Fl_Search_Browser(int X, int Y, int W, int H, const char *c):Fl_Select_Browser(X,Y,W,H,c){}; - - int find_prefix(const char *p); -}; - -class Fl_Search_Chooser : public Fl_Window { - private: - Fl_Search_Browser *sb; - int visible_focus; - - static void input_cb(Fl_Input* in, void*c); - static void ok_cb(Fl_Input* in, void*c); - static void cancel_cb(Fl_Input* in, void*c); - - public: - Fl_Search_Chooser(const char *title); - - void close(); - void add(const char *t, void *d); - void *data(); - int handle(int event); -}; - -#endif diff --git a/src/Fl_Search_Chooser.cxx b/src/Fl_Search_Chooser.cxx deleted file mode 100644 index 286516c..0000000 --- a/src/Fl_Search_Chooser.cxx +++ /dev/null @@ -1,137 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include -#include -#include -#include "Fl_Search_Chooser.H" - -int -Fl_Search_Browser::find_prefix(const char *p) { - int i = find_prefix(p, 1, size()); - if (i == -1) { - return 1; - } else { - deselect(); - middleline(i); - select(i); - return 0; - } -} - -int -Fl_Search_Browser::find_prefix(const char *p, int s, int e) { - if (s < 0 || e > size() || s > e) { - fprintf(stderr, "Invalid search range %d %d\n", s, e); - return 1; - } else if (e - s <= 1) { - if (strncasecmp(p, text(s), strlen(p)) == 0) { - return s; - } else if (strncasecmp(p, text(e), strlen(p)) == 0){ - return e; - } else { - return -1; - } - } else { - int med = s + (e - s) / 2; - if (strncasecmp(p, text(med), strlen(p)) > 0) { - return find_prefix(p, med, e); - } else { - return find_prefix(p, s, med); - } - } -} - -void -Fl_Search_Chooser::input_cb(Fl_Input* in, void*c) { - Fl_Search_Browser *sb = ((Fl_Search_Chooser *) c)->sb; - sb->find_prefix(in->value()); -} - -void -Fl_Search_Chooser::ok_cb(Fl_Input* in, void*c) { - Fl_Search_Chooser *sc = (Fl_Search_Chooser *) c; - sc->close(); -} - -void -Fl_Search_Chooser::cancel_cb(Fl_Input* in, void*c) { - Fl_Search_Chooser *sc = (Fl_Search_Chooser *) c; - sc->sb->deselect(); - sc->close(); -} - -class Fl_Search_Input : public Fl_Input { - public: - Fl_Search_Input(int x, int y, int w, int h, const char *title) : - Fl_Input(x, y, w, h, title) {} - int handle(int event) { - if (event == FL_KEYBOARD && - (Fl::event_key() == FL_Up || Fl::event_key() == FL_Down)) { - return 0; - } else { - return Fl_Input::handle(event); - } - } -}; - -Fl_Search_Chooser::Fl_Search_Chooser(const char *title) : Fl_Window(320, 320, title?title:"Choose") { - callback((Fl_Callback*) cancel_cb, this); - visible_focus = Fl::visible_focus(); - Fl::visible_focus(0); - Fl_Group *g = new Fl_Group(10, 10, w() - 10, h() - 10); - sb = new Fl_Search_Browser(g->x(), g->y(), g->w() , g->h() - 100, NULL); - sb->type(FL_HOLD_BROWSER); - Fl_Input *in = new Fl_Search_Input(g->x()+50, g->h()-80, g->w()-80, 20, "Search"); - in->callback((Fl_Callback*) input_cb, this); - in->when(FL_WHEN_CHANGED); - Fl_Button *cancel_b = new Fl_Button(g->w()-200, g->h()-30, 80, 25, "Cancel"); - cancel_b->callback((Fl_Callback*) cancel_cb, this); - Fl_Button *ok_b = new Fl_Button(g->w()-100, g->h()-30, 80, 25, "Ok"); - ok_b->callback((Fl_Callback*) ok_cb, this); - Fl::focus(in); - g->end(); - end(); -} - -void -Fl_Search_Chooser::close() { - hide(); - Fl::visible_focus(visible_focus); -} - -void -Fl_Search_Chooser::add(const char *t, void *d) { - sb->add(t, d); -} - -void * -Fl_Search_Chooser::data() { - int v = sb->value(); - if (v) { - return sb->data(v); - } else { - return NULL; - } -} - -int -Fl_Search_Chooser::handle(int event) { - switch(event) { - case FL_KEYBOARD: - int key = Fl::event_key(); - - if (key == FL_Up || key == FL_Down) { - return sb->handle(event); - } else if (key == FL_Enter) { - close(); - } - } - - return Fl_Window::handle(event); -} diff --git a/src/Fl_Value_Dial.H b/src/Fl_Value_Dial.H deleted file mode 100644 index aa09407..0000000 --- a/src/Fl_Value_Dial.H +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef Fl_Value_Dial_H -#define Fl_Value_Dial_H - -#include - -class Fl_Value_Dial : public Fl_Dial { - private: - uchar textfont_, textsize_; - unsigned textcolor_; - public: - void draw(); - int handle(int event); - - Fl_Value_Dial(int x,int y,int w,int h, const char *l = 0); - Fl_Font textfont() const {return (Fl_Font)textfont_;} - void textfont(uchar s) {textfont_ = s;} - uchar textsize() const {return textsize_;} - void textsize(uchar s) {textsize_ = s;} - Fl_Color textcolor() const {return (Fl_Color)textcolor_;} - void textcolor(unsigned s) {textcolor_ = s;} -}; - -#endif diff --git a/src/Fl_Value_Dial.cxx b/src/Fl_Value_Dial.cxx deleted file mode 100644 index 9b54458..0000000 --- a/src/Fl_Value_Dial.cxx +++ /dev/null @@ -1,67 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include -#include "Fl_Value_Dial.H" - -Fl_Value_Dial::Fl_Value_Dial(int X, int Y, int W, int H, const char*l) - : Fl_Dial(X,Y,W,H,l) -{ - step(1,100); - textfont_ = FL_HELVETICA; - textsize_ = 10; - textcolor_ = FL_BLACK; -} - -void Fl_Value_Dial::draw() { - int sxx = x(), syy = y(), sww = w(), shh = h(); - int bxx = x(), byy = y(), bww = w(), bhh = h(); - char buf[128]; - - if (damage()&FL_DAMAGE_ALL) draw_box(box(),sxx,syy,sww,shh,color()); - Fl_Dial::draw(sxx+Fl::box_dx(box()), - syy+Fl::box_dy(box()), - sww-Fl::box_dw(box()), - shh-Fl::box_dh(box())); - - format(buf); // prints at most 20 chars - fl_font(textfont(), textsize()); - - fl_color(active_r() ? textcolor() : fl_inactive(textcolor())); - fl_draw(buf, bxx, byy + fl_height() - 2, bww, bhh, FL_ALIGN_TOP); -} - -int Fl_Value_Dial::handle(int event) { - switch (event) { - case FL_KEYBOARD : - switch (Fl::event_key()) { - case FL_Left: - handle_drag(clamp(increment(value(),-1))); - handle_release(); - return 1; - case FL_Right: - handle_drag(clamp(increment(value(),1))); - handle_release(); - return 1; - default: - return 0; - } - break; - case FL_FOCUS : - case FL_UNFOCUS : - if (Fl::visible_focus()) { - redraw(); - return 1; - } else return 0; - case FL_ENTER : - case FL_LEAVE : - return 1; - default: - return Fl_Dial::handle(event); - } -} diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H deleted file mode 100644 index db67d5e..0000000 --- a/src/GipfelWidget.H +++ /dev/null @@ -1,93 +0,0 @@ -// -// Copyright 2006 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef GipfelWidget_H -#define GipfelWidget_H - -#include - -#include -#include - -#include "Panorama.H" -#include "ImageMetaData.H" -#include "ScanImage.H" - -class GipfelWidget : public Fl_Group { - private: - Fl_Image *img; - Hill *cur_mountain, *focused_mountain; - Hills *track_points; - Hills *known_hills; - Panorama *pan; - char *img_file; - double track_width; - bool have_gipfel_info; - bool show_hidden; - ImageMetaData *md; - int mouse_x, mouse_y; - char focused_mountain_label[128]; - void (*params_changed_cb)(); - - int handle(int event); - Hill * find_mountain(Hills *mnts, int m_x, int m_y); - int toggle_known_mountain(int m_x, int m_y); - int set_mountain(int m_x, int m_y); - void set_labels(Hills *v); - int get_rel_track_width(Hill *m); - - static void find_peak_cb(Fl_Widget *o, void *f); - static void toggle_hidden_cb(Fl_Widget *o, void *f); - - public: - GipfelWidget(int X,int Y,int W, int H, void (*changed_cb)()); - - int load_image(char *file); - int save_image(char *file); - int export_hills(const char *file, FILE *fp); - const char * get_image_filename(); - int load_data(const char *file); - int load_track(const char *file); - int set_viewpoint(const char *pos); - void set_viewpoint(const Hill *m); - void set_center_angle(double a); - void set_nick_angle(double a); - void set_tilt_angle(double a); - void set_focal_length_35mm(double s); - void set_height_dist_ratio(double r); - void set_hide_value(double h); - void set_show_hidden(bool h); - void set_view_lat(double v); - void set_view_long(double v); - void set_view_height(double v); - const char * get_viewpoint() { return pan->get_viewpoint(); }; - double get_center_angle() { return pan->get_center_angle(); }; - double get_nick_angle() { return pan->get_nick_angle(); }; - double get_tilt_angle() { return pan->get_tilt_angle(); }; - double get_focal_length_35mm(); - double get_height_dist_ratio() { return pan->get_height_dist_ratio(); }; - double get_view_lat() { return pan->get_view_lat(); }; - double get_view_long() { return pan->get_view_long(); }; - double get_view_height() { return pan->get_view_height(); }; - void set_track_width(double w); - ProjectionLSQ::Projection_t projection() { - return pan->get_projection(); - }; - void projection(ProjectionLSQ::Projection_t p); - void get_distortion_params(double *k0, double *k1, double *x0) { - pan->get_distortion_params(k0, k1, x0); - }; - void set_distortion_params(double k0, double k1, double x0); - Hills *get_mountains() { return pan->get_mountains(); }; - int comp_params(); - int get_pixel(ScanImage::mode_t m, - double a_alph, double a_nick, int *r, int *g, int *b); - int get_distortion_profile_name(char *buf, int buflen); - int save_distortion_params(const char *prof_name, int force); - int load_distortion_params(const char *prof_name); - void draw(); -}; -#endif diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx deleted file mode 100644 index 30172a1..0000000 --- a/src/GipfelWidget.cxx +++ /dev/null @@ -1,822 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "Fl_Search_Chooser.H" -#include "choose_hill.H" -#include "ScanImage.H" -#include "GipfelWidget.H" - -#define CROSS_SIZE 2 - -static double pi_d, deg2rad; - -GipfelWidget::GipfelWidget(int X,int Y,int W, int H, void (*changed_cb)()): Fl_Group(X, Y, W, H) { - end(); - pi_d = asin(1.0) * 2.0; - deg2rad = pi_d / 180.0; - img = NULL; - pan = new Panorama(); - cur_mountain = NULL; - focused_mountain = NULL; - known_hills = new Hills(); - img_file = NULL; - track_width = 200.0; - show_hidden = false; - have_gipfel_info = false; - md = new ImageMetaData(); - track_points = NULL; - fl_register_images(); - mouse_x = mouse_y = 0; - params_changed_cb = changed_cb; -} - -int -GipfelWidget::load_image(char *file) { - Fl_Image *new_img; - double direction, nick, tilt, fl; - - new_img = new Fl_JPEG_Image(file); - - if (new_img == NULL) - return 1; - - if (img) - delete img; - - img = new_img; - - if (img_file) - free(img_file); - - img_file = strdup(file); - - known_hills->clear(); - - h(img->h()); - w(img->w()); - - // try to retrieve gipfel data from JPEG meta data - md->load_image(file); - set_view_long(md->longitude()); - set_view_lat(md->latitude()); - set_view_height(md->height()); - projection((ProjectionLSQ::Projection_t) md->projection_type()); - - have_gipfel_info = true; - direction = md->direction(); - if (isnan(direction)) { - set_center_angle(0.0); - have_gipfel_info = false; - } else { - set_center_angle(direction); - } - - nick = md->nick(); - if (isnan(nick)) { - set_nick_angle(0.0); - have_gipfel_info = false; - } else { - set_nick_angle(nick); - } - - tilt = md->tilt(); - if (isnan(tilt)) { - set_tilt_angle(0.0); - have_gipfel_info = false; - } else { - set_tilt_angle(tilt); - } - - fl = md->focal_length_35mm(); - if (isnan(fl) || fl == 0.0) { - set_focal_length_35mm(35.0); - have_gipfel_info = false; - } else { - set_focal_length_35mm(fl); - } - - // try to get distortion parameters in the following ordering: - // 1. gipfel data in JPEG comment - // 2. matching distortion profile - // 3. set the to 0.0, 0.0 - md->distortion_params(&pan->parms.k0, &pan->parms.k1, &pan->parms.x0); - if (isnan(pan->parms.k0)) { - char buf[1024]; - if (get_distortion_profile_name(buf, sizeof(buf)) == 0) - load_distortion_params(buf); - - if (isnan(pan->parms.k0)) - pan->parms.k0 = 0.0; - if (isnan(pan->parms.k1)) - pan->parms.k1 = 0.0; - if (isnan(pan->parms.x0)) - pan->parms.x0 = 0.0; - } - - return 0; -} - -const char * -GipfelWidget::get_image_filename() { - return img_file; -} - -int -GipfelWidget::save_image(char *file) { - if (img_file == NULL) { - fprintf(stderr, "Nothing to save\n"); - return 1; - } - - md->longitude(get_view_long()); - md->latitude(get_view_lat()); - md->height(get_view_height()); - md->direction(get_center_angle()); - md->nick(get_nick_angle()); - md->tilt(get_tilt_angle()); - md->focal_length_35mm(get_focal_length_35mm()); - md->projection_type((int) projection()); - md->distortion_params(pan->parms.k0, pan->parms.k1, pan->parms.x0); - - return md->save_image(img_file, file); -} - -int -GipfelWidget::load_data(const char *file) { - int r; - - r = pan->load_data(file); - set_labels(pan->get_visible_mountains()); - - return r; -} - -int -GipfelWidget::load_track(const char *file) { - if (track_points) { - pan->remove_hills(Hill::TRACK_POINT); - track_points->clobber(); - delete track_points; - } - - track_points = new Hills(); - - if (track_points->load(file) != 0) { - delete track_points; - track_points = NULL; - return 1; - } - - for (int i = 0; i < track_points->get_num(); i++) - track_points->get(i)->flags |= Hill::TRACK_POINT; - - pan->add_hills(track_points); - redraw(); - - return 0; -} - -int -GipfelWidget::set_viewpoint(const char *pos) { - int r; - - r = pan->set_viewpoint(pos); - set_labels(pan->get_visible_mountains()); - redraw(); - return r; -} - -void -GipfelWidget::set_viewpoint(const Hill *m) { - pan->set_viewpoint(m); - set_labels(pan->get_visible_mountains()); - redraw(); -} - -static void -draw_flag(int x, int y) { - fl_polygon(x, y - 10, x, y - 20, x + 10, y - 15); - fl_yxline(x, y, y - 10); - fl_circle(x , y, 3); -} - -void -GipfelWidget::draw() { - Hills *mnts; - Hill *m; - int i, height; - - if (img == NULL) - return; - - fl_push_clip(x(), y(), w(), h()); - img->draw(x(),y(),w(),h(),0,0); - - /* hills */ - fl_font(FL_HELVETICA, 8); - mnts = pan->get_visible_mountains(); - - fl_color(FL_YELLOW); - height = fl_height(); - for (i=0; iget_num(); i++) { - m = mnts->get(i); - int m_x = w() / 2 + x() + (int) rint(m->x); - int m_y = h() / 2 + y() + (int) rint(m->y); - - if ((m->flags & (Hill::DUPLIC|Hill::TRACK_POINT)) || - (!show_hidden && (m->flags & Hill::HIDDEN)) || - known_hills->contains(m) || m == focused_mountain) - continue; - - if (fabs(m->x) > img->w() / 2 || fabs(m->y) > img->h() / 2) - continue; - - fl_xyline(m_x - CROSS_SIZE, m_y, m_x + CROSS_SIZE); - fl_yxline(m_x, m_y + m->label_y - height, m_y + CROSS_SIZE); - fl_xyline(m_x, m_y + m->label_y - height, m_x + m->label_x); - } - - for (i=0; iget_num(); i++) { - m = mnts->get(i); - int m_x = w() / 2 + x() + (int) rint(m->x); - int m_y = h() / 2 + y() + (int) rint(m->y); - - if ((m->flags & (Hill::DUPLIC|Hill::TRACK_POINT)) || - (!show_hidden && (m->flags & Hill::HIDDEN)) || m == focused_mountain) - continue; - - if (fabs(m->x) > img->w() / 2 || fabs(m->y) > img->h() / 2) - continue; - - if (known_hills->contains(m)) { - if (known_hills->get_num() > 3) - fl_color(FL_GREEN); - else - fl_color(FL_RED); - - draw_flag(m_x, m_y); - fl_color(FL_BLACK); - } else if (m->flags & Hill::HIDDEN) { - fl_color(FL_BLUE); - } else { - fl_color(FL_BLACK); - } - - fl_draw(m->name, m_x + 2, m_y + m->label_y); - } - - if (focused_mountain) { - m = focused_mountain; - int m_x = w() / 2 + x() + (int) rint(m->x); - int m_y = h() / 2 + y() + (int) rint(m->y); - - fl_color(FL_YELLOW); - - fl_rectf(m_x, m_y - height, - (int) fl_width(focused_mountain_label) + 2, height + 2); - fl_color(FL_BLACK); - fl_draw(focused_mountain_label, m_x, m_y); - } - - - /* track */ - if (track_points && track_points->get_num() > 0) { - int last_x = 0, last_y = 0, last_initialized = 0; - - for (i=1; iget_num(); i++) { - m = track_points->get(i); - int m_x = w() / 2 + x() + (int) rint(m->x); - int m_y = h() / 2 + y() + (int) rint(m->y); - - if (!(track_points->get(i)->flags & Hill::VISIBLE)) - continue; - - if (track_points->get(i)->flags & Hill::HIDDEN) - fl_color(FL_BLUE); - else - fl_color(FL_RED); - - fl_line_style(FL_SOLID | FL_CAP_ROUND | FL_JOIN_ROUND, - get_rel_track_width(track_points->get(i))); - if (last_initialized) { - fl_begin_line(); - fl_vertex(last_x, last_y); - fl_vertex(m_x, m_y); - fl_end_line(); - } - - last_x = m_x; - last_y = m_y; - last_initialized++; - } - fl_line_style(0); - } - - fl_pop_clip(); -} - -static int -overlap(double x1, double l1, double x2, double l2) { - return x1 <= x2 + l2 && x1 + l1 >= x2; -} - -void -GipfelWidget::set_labels(Hills *v) { - int height; - - if (!img) - return; - - - fl_font(FL_HELVETICA, 8); - height = fl_height(); - - for (int i = 0; i < v->get_num(); i++) { - Hill *m = v->get(i); - Hills colliding; - - if (m->flags & (Hill::DUPLIC | Hill::TRACK_POINT)) - continue; - - if (!show_hidden && (m->flags & Hill::HIDDEN)) - continue; - - if (fabs(m->x) > img->w() / 2 || fabs(m->y) > img->h() / 2) - continue; - - m->label_x = (int) fl_width(m->name) + 1; - m->label_y = 0; - - for (int j = i - 1; j >= 0; j--) { - Hill *n = v->get(j); - - if (n->flags & (Hill::DUPLIC | Hill::TRACK_POINT)) - continue; - - if (!show_hidden && (n->flags & Hill::HIDDEN)) - continue; - - if (fabs(m->x) > img->w() / 2 || fabs(m->y) > img->h() / 2) - continue; - - if (overlap(m->x, m->label_x, n->x - CROSS_SIZE, n->label_x)) - colliding.add(n); - else - break; - } - - colliding.sort(Hills::SORT_LABEL_Y); - - for (int j = 0; j < colliding.get_num(); j++) { - Hill *n = colliding.get(j); - - // Check for overlapping labels and - // overlaps between labels and peak markers - if (overlap(m->y + m->label_y - height, height, - n->y + n->label_y - height, height) || - overlap(m->y + m->label_y - height, - height, n->y - CROSS_SIZE, 2 * CROSS_SIZE)) { - - m->label_y = (int) rint(n->y + n->label_y - m->y - height - 2); - } - } - } -} - -Hill * -GipfelWidget::find_mountain(Hills *mnts, int m_x, int m_y) { - Hill *m; - int center_x = w() / 2; - int center_y = h() / 2; - - for (int i = 0; i < mnts->get_num(); i++) { - m = mnts->get(i); - - if (m_x - center_x >= m->x - 2 && m_x - center_x < m->x + 2 && - m_y - center_y >= m->y - 2 && m_y - center_y < m->y + 2) - return m; - } - - return NULL; -} - -int -GipfelWidget::toggle_known_mountain(int m_x, int m_y) { - Hills *mnts = pan->get_visible_mountains(); - int center_x = w() / 2; - int center_y = h() / 2; - - for (int i = 0; i < mnts->get_num(); i++) { - Hill *m = mnts->get(i); - - if (m->flags & (Hill::DUPLIC | Hill::TRACK_POINT)) - continue; - - if (m_x - center_x >= m->x - 2 && m_x - center_x < m->x + 2 && - m_y - center_y >= m->y - 2 && m_y - center_y < m->y + 2) { - - - if (known_hills->contains(m)) - known_hills->remove(m); - else - known_hills->add(m); - - redraw(); - return 0; - } - } - - cur_mountain = NULL; - redraw(); - return 1; -} - -int -GipfelWidget::set_mountain(int m_x, int m_y) { - int old_x, old_y, old_label_y; - int center_x = w() / 2; - int center_y = h() / 2; - - if (!cur_mountain) - return 1; - - old_x = (int) rint(cur_mountain->x); - old_y = (int) rint(cur_mountain->y); - old_label_y = cur_mountain->label_y; - - cur_mountain->x = m_x - center_x; - cur_mountain->y = m_y - center_y; - cur_mountain->label_y = 0; - - damage(4, center_x + x() + old_x - 2*CROSS_SIZE - 1, - center_y + y() + old_y + old_label_y - 2*CROSS_SIZE - 20, - std::max(20, cur_mountain->label_x) + 2*CROSS_SIZE + 4, - std::max(20, old_label_y) + 22 ); - damage(4, - (int) rint(center_x + x() + cur_mountain->x - 2*CROSS_SIZE - 1), - (int) rint(center_y + y() + cur_mountain->y + cur_mountain->label_y - 2*CROSS_SIZE - 20), - std::max(20, cur_mountain->label_x) + 2*CROSS_SIZE + 4, - std::max(20, cur_mountain->label_y) + 22 ); - - return 0; -} - -void -GipfelWidget::set_center_angle(double a) { - pan->set_center_angle(a); - set_labels(pan->get_visible_mountains()); - redraw(); -} - -void -GipfelWidget::set_nick_angle(double a) { - pan->set_nick_angle(a); - set_labels(pan->get_visible_mountains()); - redraw(); -} - -void -GipfelWidget::set_tilt_angle(double a) { - pan->set_tilt_angle(a); - set_labels(pan->get_visible_mountains()); - redraw(); -} - -void -GipfelWidget::set_focal_length_35mm(double s) { - int w = std::max(img->w(), img->h()); // assume sensor is wider than high - pan->set_scale(s * (double) w / 35.0); - set_labels(pan->get_visible_mountains()); - redraw(); -} - -void -GipfelWidget::projection(ProjectionLSQ::Projection_t p) { - pan->set_projection(p); - set_labels(pan->get_visible_mountains()); - redraw(); -} - -void -GipfelWidget::set_distortion_params(double k0, double k1, double x0) { - pan->set_distortion_params(k0, k1, x0); - redraw(); -} - -double -GipfelWidget::get_focal_length_35mm() { - int w; - - if (img == NULL) - return NAN; - - w = std::max(img->w(), img->h()); // assume sensor is wider than high - return pan->get_scale() * 35.0 / (double) w; -} - -void -GipfelWidget::find_peak_cb(Fl_Widget *, void *f) { - GipfelWidget *g = (GipfelWidget*) f; - - Hill *m = choose_hill(g->pan->get_close_mountains(), "Find Peak"); - if (m) { - if (!g->known_hills->contains(m)) - g->known_hills->add(m); - - m->flags |= Hill::VISIBLE; - if (! g->pan->get_visible_mountains()->contains(m)) - g->pan->get_visible_mountains()->add(m); - g->set_labels(g->pan->get_visible_mountains()); - - g->cur_mountain = m; - g->set_mountain(g->mouse_x, g->mouse_y); - g->comp_params(); - } -} - -void -GipfelWidget::toggle_hidden_cb(Fl_Widget *, void *f) { - GipfelWidget *g = (GipfelWidget*) f; - - Hill *m = g->find_mountain(g->pan->get_visible_mountains(), g->mouse_x, g->mouse_y); - if (!m) - return; - - if (m->flags & Hill::HIDDEN) - m->flags &= ~Hill::HIDDEN; - else - m->flags |= Hill::HIDDEN; - - g->set_labels(g->pan->get_visible_mountains()); - g->redraw(); -} - -void -GipfelWidget::set_height_dist_ratio(double r) { - pan->set_height_dist_ratio(r); - set_labels(pan->get_visible_mountains()); - redraw(); -} - -void -GipfelWidget::set_hide_value(double h) { - pan->set_hide_value(h); - set_labels(pan->get_visible_mountains()); - redraw(); -} - -void -GipfelWidget::set_show_hidden(bool h) { - show_hidden = h; - set_labels(pan->get_visible_mountains()); - redraw(); -} - -void -GipfelWidget::set_view_lat(double v) { - pan->set_view_lat(v); - set_labels(pan->get_visible_mountains()); - redraw(); -} - -void -GipfelWidget::set_view_long(double v) { - pan->set_view_long(v); - set_labels(pan->get_visible_mountains()); - redraw(); -} - -void -GipfelWidget::set_view_height(double v) { - pan->set_view_height(v); - set_labels(pan->get_visible_mountains()); - redraw(); -} - -int -GipfelWidget::comp_params() { - int ret; - - fl_cursor(FL_CURSOR_WAIT); - ret = pan->comp_params(known_hills); - set_labels(pan->get_visible_mountains()); - redraw(); - fl_cursor(FL_CURSOR_DEFAULT); - if (params_changed_cb) - params_changed_cb(); - - return ret; -} - -int -GipfelWidget::get_rel_track_width(Hill *m) { - double dist = pan->get_real_distance(m); - - return (int) rint(std::max((pan->get_scale()*track_width)/(dist*10.0), 1.0)); -} - -void -GipfelWidget::set_track_width(double w) { - track_width = w; - redraw(); -} - -int -GipfelWidget::handle(int event) { - Hill *m; - - switch(event) { - case FL_PUSH: - mouse_x = Fl::event_x()-x(); - mouse_y = Fl::event_y()-y(); - if (Fl::event_button() == FL_LEFT_MOUSE) { - m = find_mountain(known_hills, mouse_x, mouse_y); - if (m) - cur_mountain = m; - } else if (Fl::event_button() == FL_MIDDLE_MOUSE) { - toggle_known_mountain(mouse_x, mouse_y); - if (focused_mountain) { - focused_mountain = NULL; - redraw(); - } - } else if (Fl::event_button() == FL_RIGHT_MOUSE) { - focused_mountain = NULL; - - Fl_Menu_Button rclick_menu(Fl::event_x_root(), - Fl::event_y_root(), 80, 1); - Hill *m = find_mountain(pan->get_visible_mountains(), - mouse_x, mouse_y); - char buf[1024]; - - rclick_menu.add("Find Peak", 0, find_peak_cb, this); - if (m) { - if (m->flags & Hill::HIDDEN) - snprintf(buf, sizeof(buf), "Unhide %s", m->name); - else - snprintf(buf, sizeof(buf), "Hide %s", m->name); - - rclick_menu.add(buf, 0, toggle_hidden_cb, this); - } - - rclick_menu.popup(); - } - - Fl::focus(this); - return 1; - case FL_DRAG: - set_mountain(Fl::event_x()-x(), Fl::event_y()-y()); - return 1; - case FL_RELEASE: - cur_mountain = NULL; - if (known_hills->get_num() > 0) - comp_params(); - return 1; - case FL_ENTER: - return 1; - case FL_LEAVE: - return 1; - case FL_MOVE: - m = find_mountain(pan->get_visible_mountains(), Fl::event_x()-x(), Fl::event_y()-y()); - if (m != focused_mountain && (!m || !known_hills->contains(m))) { - if (m) - snprintf(focused_mountain_label, - sizeof(focused_mountain_label) - 1, - "%s (%dm), distance %.2fkm", - m->name, (int) m->height, pan->get_real_distance(m) / 1000.0); - - focused_mountain = m; - redraw(); - } - return 1; - case FL_FOCUS: - return 1; - case FL_UNFOCUS: - return 0; - } - return 0; -} - -int -GipfelWidget::export_hills(const char *file, FILE *fp) { - Hills export_hills, *mnts; - - if (!have_gipfel_info) { - fprintf(stderr, "No gipfel info available for %s.\n", img_file); - return 0; - } - - if (file) { - if (export_hills.load(file) != 0) - return 1; - - for (int i = 0; i < export_hills.get_num(); i++) - export_hills.get(i)->flags |= Hill::EXPORT; - - pan->add_hills(&export_hills); - } - - fprintf(fp, "#\n# name\theight\tx\ty\tdistance\tflags\n#\n"); - - mnts = pan->get_visible_mountains(); - for (int i = 0; i < mnts->get_num(); i++) { - Hill *m = mnts->get(i); - int _x = (int) rint(m->x) + w() / 2; - int _y = (int) rint(m->y) + h() / 2; - - if (m->flags & Hill::DUPLIC || m->flags & Hill::HIDDEN || - (file && !(m->flags & Hill::EXPORT))) { - continue; - } - - if (_x < 0 || _x > w() || _y < 0 || _y > h()) - continue; - - fprintf(fp, "%s\t%d\t%d\t%d\t%d\n", - m->name, (int) rint(m->height), _x, _y, - (int) rint(pan->get_real_distance(m))); - } - - pan->remove_hills(Hill::EXPORT); - - return 0; -} - -int -GipfelWidget::get_pixel(ScanImage::mode_t m, - double a_alph, double a_nick, int *r, int *g, int *b) { - double px, py; - int ret; - - if (img == NULL) - return 1; - - if (pan->get_coordinates(a_alph, a_nick, &px, &py) != 0) - return 1; - - ret = ScanImage::get_pixel(img, m, px + ((double) img->w()) / 2.0, - py + ((double) img->h()) / 2.0, r, g, b); - - return ret; -} - -int -GipfelWidget::get_distortion_profile_name(char *buf, int buflen) { - int n; - - if (md && md->manufacturer() && md->model()) { - n = snprintf(buf, buflen, "%s_%s_%.2f_mm", - md->manufacturer(), md->model(), md->focal_length()); - - return n > buflen; - } else { - return 1; - } -} - -static Fl_Preferences dist_prefs(Fl_Preferences::USER, - "Johannes.HofmannATgmx.de", "gipfel/DistortionProfiles"); - -int -GipfelWidget::load_distortion_params(const char *prof_name) { - int ret = 0; - - Fl_Preferences prof(dist_prefs, prof_name); - ret += prof.get("k0", pan->parms.k0, pan->parms.k0); - ret += prof.get("k1", pan->parms.k1, pan->parms.k1); - ret += prof.get("x0", pan->parms.x0, pan->parms.x0); - - return !ret; -} - -int -GipfelWidget::save_distortion_params(const char *prof_name, int force) { - Fl_Preferences prof(dist_prefs, prof_name); - - if (!force && prof.entryExists("k0")) - return 1; - - prof.set("k0", pan->parms.k0); - prof.set("k1", pan->parms.k1); - prof.set("x0", pan->parms.x0); - - return 0; -} diff --git a/src/Hill.H b/src/Hill.H deleted file mode 100644 index c55db15..0000000 --- a/src/Hill.H +++ /dev/null @@ -1,69 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef HILL_H -#define HILL_H - -class Hill; - -class Hill { - public: - typedef enum { - DUPLIC = 0x01, - TRACK_POINT = 0x02, - VISIBLE = 0x04, - HIDDEN = 0x08, - EXPORT = 0x10, - } flags_t; - - double phi, lam; - double height; - double alph; - double a_nick; - double dist; - double x, y; - int label_x, label_y; - char *name; - int flags; - - Hill(const char *n, double p, double l, double h); - Hill(const Hill& h); - Hill(double x_tmp, double y_tmp); - ~Hill(); -}; - -class Hills { - private: - int num, cap; - Hill **m; - - public: - typedef enum { - SORT_ALPHA, - SORT_PHI, - SORT_NAME, - SORT_LABEL_Y, - SORT_X - } SortType; - - Hills(); - Hills(const Hills *h); - ~Hills(); - - int load(const char *file); - void mark_duplicates(double dist); - void add(Hill *m); - void remove(const Hill *m); - void add(Hills *h); - void sort(SortType t); - void clear(); - void clobber(); - int contains(const Hill *m) const; - inline int get_num() const { return num; }; - Hill *get(int n) const; -}; - -#endif diff --git a/src/Hill.cxx b/src/Hill.cxx deleted file mode 100644 index 2aad3f3..0000000 --- a/src/Hill.cxx +++ /dev/null @@ -1,341 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include -#include -extern "C" { -#include "strsep.h" -} -#include "Hill.H" - -static double pi_d, deg2rad; - -Hill::Hill(const char *n, double p, double l, double h) { - name = strdup(n); - phi = p; - lam = l; - height = h; - alph = 0.0; - x = 0; - y = 0; - flags = 0; -} - -Hill::Hill(const Hill& h) { - name = strdup(h.name); - phi = h.phi; - lam = h.lam; - height = h.height; - alph = h.alph; - dist = h.dist; - x = h.x; - y = h.y; - label_x = h.label_x; - label_y = h.label_y; - flags = h.flags; -} - -Hill::Hill(double x_tmp, double y_tmp) { - name = NULL; - phi = 0.0; - lam = 0.0; - height = 0.0; - alph = 0.0; - x = x_tmp; - y = y_tmp; -} - -Hill::~Hill() { - if (name) - free(name); -} - -Hills::Hills() { - num = 0; - cap = 100; - m = (Hill **) malloc(cap * sizeof(Hill *)); - - pi_d = asin(1.0) * 2.0; - deg2rad = pi_d / 180.0; -} - -Hills::Hills(const Hills *h) { - num = h->num; - cap = h->cap; - m = (Hill **) malloc(cap * sizeof(Hill *)); - memcpy(m, h->m, cap * sizeof(Hill *)); - - pi_d = asin(1.0) * 2.0; - deg2rad = pi_d / 180.0; -} - -int -Hills::load(const char *file) { - FILE *fp; - char buf[4000]; - char *vals[10]; - char **ap, *bp; - double phi, lam, height; - Hill *m; - int n; - - fp = fopen(file, "r"); - if (!fp) { - perror("fopen"); - return 1; - } - - while (fgets(buf, sizeof(buf), fp)) { - bp = buf; - memset(vals, 0, sizeof(vals)); - n = 0; - for (ap = vals; (*ap = strsep(&bp, ",")) != NULL;) { - n++; - if (++ap >= &vals[10]) - break; - } - - // standard format including name and description - if (n == 6 && vals[1] && vals [3] && vals[4] && vals[5]) { - phi = atof(vals[3]) * deg2rad; - lam = atof(vals[4]) * deg2rad; - height = atof(vals[5]); - - m = new Hill(vals[1], phi, lam, height); - - add(m); - // track point format - } else if (n == 3 && vals[0] && vals[1] && vals[2]) { - phi = atof(vals[0]) * deg2rad; - lam = atof(vals[1]) * deg2rad; - height = atof(vals[2]); - - m = new Hill("", phi, lam, height); - - add(m); - } - } - - fclose(fp); - - return 0; -} - -void Hills::mark_duplicates(double dist) { - Hill *m, *n; - int i, j; - - sort(SORT_PHI); - - for(i = 0; i < get_num(); i++) { - m = get(i); - - if (m) { - if (m->flags & Hill::TRACK_POINT) - continue; - - j = i + 1; - n = get(j); - while (n && fabs(n->phi - m->phi) <= dist) { - if (! (n->flags & Hill::DUPLIC)) { - if (fabs(n->lam - m->lam) <= dist && - fabs(n->height - m->height) <= 50.0 ) { - n->flags |= Hill::DUPLIC; - } - } - j = j + 1; - n = get(j); - } - } - } -} - -Hills::~Hills() { - if (m) - free(m); -} - -void -Hills::add(Hill *m1) { - if (num >= cap) { - cap = cap ? cap * 2 : 100; - m = (Hill **) realloc(m, cap * sizeof(Hill *)); - } - - m[num++] = m1; -} - -void -Hills::add(Hills *h) { - for (int i=0; iget_num(); i++) - add(h->get(i)); -} - -static int -comp_mountains_alpha(const void *n1, const void *n2) { - Hill *m1 = *(Hill **)n1; - Hill *m2 = *(Hill **)n2; - - if (m1 && m2) { - if (m1->alph < m2->alph) - return 1; - else if (m1->alph > m2->alph) - return -1; - else - return 0; - } else { - return 0; - } -} - -static int -comp_mountains_phi(const void *n1, const void *n2) { - Hill *m1 = *(Hill **)n1; - Hill *m2 = *(Hill **)n2; - - if (m1 && m2) { - if (m1->phi < m2->phi) - return 1; - else if (m1->phi > m2->phi) - return -1; - else - return 0; - } else { - return 0; - } -} - -static int -comp_mountains_name(const void *n1, const void *n2) { - Hill *m1 = *(Hill **)n1; - Hill *m2 = *(Hill **)n2; - int r; - - if (m1 && m2) { - r = strcasecmp(m1->name, m2->name); - if (r == 0) - return (int) (m1->height - m2->height); - else - return r; - } else { - return 0; - } -} - -static int -comp_mountains_label_y(const void *n1, const void *n2) { - Hill *m1 = *(Hill **)n1; - Hill *m2 = *(Hill **)n2; - - if (m1 && m2) { - if ((m2->y + m2->label_y) > (m1->y + m1->label_y)) - return 1; - else if ((m2->y + m2->label_y) < (m1->y + m1->label_y)) - return -1; - else - return 0; - } else { - return 0; - } -} - -static int -comp_mountains_x(const void *n1, const void *n2) { - Hill *m1 = *(Hill **)n1; - Hill *m2 = *(Hill **)n2; - - if (m1 && m2) { - if (m2->x < m1->x) - return 1; - else if (m2->x > m1->x) - return -1; - else - return 0; - } else { - return 0; - } -} - -void -Hills::sort(SortType t) { - int (*cmp)(const void *, const void *); - - if (!m || num < 2) - return; - - switch (t) { - case SORT_ALPHA: - cmp = comp_mountains_alpha; - break; - case SORT_PHI: - cmp = comp_mountains_phi; - break; - case SORT_NAME: - cmp = comp_mountains_name; - break; - case SORT_LABEL_Y: - cmp = comp_mountains_label_y; - break; - case SORT_X: - cmp = comp_mountains_x; - break; - default: - fprintf(stderr, "ERROR: Unknown sort type %d\n", t); - return; - } - - qsort(m, num, sizeof(Hill *), cmp); -} - -void -Hills::clear() { - if (m) { - free(m); - m = NULL; - } - cap = 0; - num = 0; -} - -int -Hills::contains(const Hill *m) const { - for (int i = 0; i < get_num(); i++) - if (get(i) == m) - return 1; - - return 0; -} - -void -Hills::remove(const Hill *h) { - for (int i = 0; i < get_num(); i++) { - if (get(i) == h) { - memmove(&m[i], &m[i+1], (get_num() - i - 1) * sizeof(Hill*)); - num--; - } - } -} - -void -Hills::clobber() { - int i; - - for (i = 0; i < get_num(); i++) - if (get(i)) - delete(get(i)); - - clear(); -} - -Hill * -Hills::get(int n) const { - if (n < 0 || n >= num) - return NULL; - else - return m[n]; -} diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H deleted file mode 100644 index 109652d..0000000 --- a/src/ImageMetaData.H +++ /dev/null @@ -1,65 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef IMAGE_META_DATA_H -#define IMAGE_META_DATA_H - -class ImageMetaData { - private: - char *_manufacturer; - char *_model; - double _longitude; - double _latitude; - double _height; - double _direction; - double _nick; - double _tilt; - double _k0; - double _k1; - double _x0; - double _focal_length; - double _focal_length_35mm; - double _scale; - int _projection_type; - int _have_gipfel_info; - - int load_image_jpgcom(char *name); - int save_image_jpgcom(char *in_img, char *out_img); - int load_image_exif(char *name); - void clear(); - - public: - ImageMetaData(); - ~ImageMetaData(); - - int load_image(char *name); - int save_image(char *in_img, char *out_img); - - const char *manufacturer() {return _manufacturer;}; - const char *model() {return _model;}; - double longitude() {return _longitude;}; - double latitude() {return _latitude;}; - double height() {return _height;}; - double direction() {return _direction;}; - double nick() {return _nick;}; - double tilt() {return _tilt;}; - double focal_length() {return _focal_length;}; - double focal_length_35mm() {return _focal_length_35mm;}; - int projection_type() {return _projection_type;}; - void distortion_params(double *_k0, double *_k1, double *_x0); - - void longitude(double v) {_longitude = v;}; - void latitude(double v) {_latitude = v;}; - void height(double v) {_height = v;}; - void direction(double v) {_direction = v;}; - void nick(double v) {_nick = v;}; - void tilt(double v) {_tilt = v;}; - void focal_length_35mm(double v) {_focal_length_35mm = v;}; - void projection_type(int v) {_projection_type = v;}; - void distortion_params(double k0, double k1, double x0); -}; - -#endif diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx deleted file mode 100644 index fa334aa..0000000 --- a/src/ImageMetaData.cxx +++ /dev/null @@ -1,322 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "../config.h" -#include "ImageMetaData.H" - -#if !defined(O_BINARY) -#define O_BINARY 0 -#endif - -ImageMetaData::ImageMetaData() { - _manufacturer = NULL; - _model = NULL; - clear(); -} - -ImageMetaData::~ImageMetaData() { - if (_manufacturer) - free(_manufacturer); - if (_model) - free(_model); -} - -void -ImageMetaData::clear() { - if (_manufacturer) - free(_manufacturer); - _manufacturer = NULL; - if (_model) - free(_model); - _model = NULL; - _longitude = NAN; - _latitude = NAN; - _height = NAN; - _direction = NAN; - _nick = NAN; - _tilt = NAN; - _k0 = NAN; - _k1 = NAN; - _x0 = NAN; - _focal_length = NAN; - _focal_length_35mm = NAN; - _scale = NAN; - _projection_type = 0; -} - -int -ImageMetaData::load_image(char *name) { - clear(); - load_image_jpgcom(name); - load_image_exif(name); // fill missing values from exif data - return 0; -} - -int -ImageMetaData::save_image(char *in_img, char *out_img) { - return save_image_jpgcom(in_img, out_img); -} - -static void -exifSetValue(double *destVal, Exiv2::ExifData *exifData, const char *name) { - Exiv2::ExifKey key(name); - Exiv2::ExifData::iterator pos = exifData->findKey(key); - pos = exifData->findKey(key); - if (pos != exifData->end() && pos->toFloat() >= 0) - *destVal = pos->toFloat(); -} - -static void -exifSetCoordinate(double *destVal, Exiv2::ExifData *exifData, const char *name) { - Exiv2::ExifKey key(name); - Exiv2::ExifData::iterator pos = exifData->findKey(key); - - if (pos != exifData->end()) { - if (pos->toFloat() >= 0) - *destVal = pos->toFloat(); - if (pos->toFloat(1) >= 0) - *destVal += pos->toFloat(1) / 60; - if (pos->toFloat(2) >= 0) - *destVal += pos->toFloat(2) / 3600; - } -} - -int -ImageMetaData::load_image_exif(char *name) { -#if EXIV2_TEST_VERSION(0,28,0) - Exiv2::Image::UniquePtr image; -#else - Exiv2::Image::AutoPtr image; -#endif - - try { - image = Exiv2::ImageFactory::open(name); - image->readMetadata(); - } catch (const Exiv2::Error &error) { - fprintf(stderr, "Error reading metadata\n"); - return 1; - } - - Exiv2::ExifData &exifData = image->exifData(); - if (exifData.empty()) { - fprintf(stderr, "%s: No Exif data found in the file", name); - return 1; - } - - Exiv2::ExifData::iterator pos = exifData.end(); - - if (!_manufacturer ) { - Exiv2::ExifKey key("Exif.Image.Make"); // tag auch wirklich vorhanden? - pos = exifData.findKey(key); - if (pos != exifData.end() && pos->size()) - _manufacturer = strdup(pos->toString().c_str()); - } - - if (!_model) { - Exiv2::ExifKey key("Exif.Image.Model"); - pos = exifData.findKey(key); - if (pos != exifData.end() && pos->size() ) - _model = strdup(pos->toString().c_str()); - } - - if (std::isnan(_focal_length)) - exifSetValue(&_focal_length, &exifData, "Exif.Photo.FocalLength"); - - if (std::isnan(_focal_length_35mm)) - exifSetValue(&_focal_length_35mm, &exifData, "Exif.Photo.FocalLengthIn35mmFilm"); - - if (std::isnan(_longitude)) - exifSetCoordinate(&_longitude, &exifData, "Exif.GPSInfo.GPSLongitude"); - - if (std::isnan(_latitude)) - exifSetCoordinate(&_latitude, &exifData, "Exif.GPSInfo.GPSLatitude"); - - if (std::isnan(_height)) - exifSetValue(&_height, &exifData, "Exif.GPSInfo.GPSAltitude"); - - return 0; -} - - -#define GIPFEL_FORMAT "gipfel: longitude " FMT_DOUBLE ", latitude " FMT_DOUBLE ", height " FMT_DOUBLE ", direction " FMT_DOUBLE ", nick " FMT_DOUBLE ", tilt " FMT_DOUBLE ", focal_length_35mm " FMT_DOUBLE ", projection type %d, k0 " FMT_DOUBLE ", k1 " FMT_DOUBLE ", x0 " FMT_DOUBLE "" - -#define FMT_DOUBLE "%lf" -static const char *gipfel_format_scan = GIPFEL_FORMAT; - -#undef FMT_DOUBLE -#define FMT_DOUBLE "%f" -static const char *gipfel_format_prnt = GIPFEL_FORMAT; - -#undef FMT_DOUBLE -#undef GIPFEL_FORMAT - -int -ImageMetaData::load_image_jpgcom(char *name) { - double lo, la, he, dir, ni, ti, fr, k0, k1, x0 = 0.0; - int pt = 0; - int n, ret = 1; -#if EXIV2_TEST_VERSION(0,28,0) - Exiv2::Image::UniquePtr image; -#else - Exiv2::Image::AutoPtr image; -#endif - - try { - image = Exiv2::ImageFactory::open(name); - image->readMetadata(); - } catch (const Exiv2::Error &error) { - fprintf(stderr, "Error reading metadata\n"); - return 1; - } - - const char *com = image->comment().c_str(); - - if ((n = sscanf(com, gipfel_format_scan, - &lo, &la, &he, &dir, &ni, &ti, &fr, &pt, &k0, &k1, &x0)) >= 8) { - _longitude = lo; - _latitude = la; - _height = he; - _direction = dir; - _nick = ni; - _tilt = ti; - _focal_length_35mm = fr; - _projection_type = pt; - - if (n >= 10) { - _k0 = k0; - _k1 = k1; - _x0 = x0; - } - - ret = 0; - } - - return ret; -} - -int -ImageMetaData::save_image_jpgcom(char *in_img, char *out_img) { - char buf[1024], *tmpname; - int n, in_fd, tmp_fd, err = 0; - - char* dirbuf = strdup(out_img); -#if HAVE_MKSTEMP - char tmpbuf[MAXPATHLEN]; - snprintf(tmpbuf, sizeof(tmpbuf), "%s/.gipfelXXXXXX", dirname(dirbuf)); - tmp_fd = mkstemp(tmpbuf); - tmpname = tmpbuf; -#else - tmpname = tempnam(dirname(dirbuf), ".gipfel"); - tmp_fd = open(tmpname, O_WRONLY|O_TRUNC|O_CREAT|O_BINARY, S_IRUSR|S_IWUSR); -#endif - free(dirbuf); - - if (tmp_fd == -1) { - perror("mkstemp"); - return 1; - } - - in_fd = open(in_img, O_RDONLY|O_BINARY); - if (in_fd == -1) { - perror("open"); - unlink(tmpname); - close(tmp_fd); - return 1; - } - - while ((n = read(in_fd, buf, sizeof(buf))) > 0) { - if (n < 0 || write(tmp_fd, buf, n) != n) { - perror("write"); - err++; - break; - } - } - - close(in_fd); - -#if EXIV2_TEST_VERSION(0,28,0) - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(tmpname); -#else - Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(tmpname); -#endif - if (!image.get()) - err++; - - image->readMetadata(); - image->clearComment(); - - snprintf(buf, sizeof(buf), gipfel_format_prnt, - _longitude, - _latitude, - _height, - _direction, - _nick, - _tilt, - _focal_length_35mm, - _projection_type, - _k0, _k1, _x0); - - image->setComment(buf); - - try { - image->writeMetadata(); - } catch (const Exiv2::Error &error) { - fprintf(stderr, "Error writing metadata\n"); - err++; - } - -#ifdef HAVE_FSYNC - fsync(tmp_fd); // make sure data is on disk before replacing orig file -#endif - - close(tmp_fd); - - if (err == 0) { // only overwrite existing image if everything was ok -#ifdef WIN32 - // Workaround as Windows does not seem to replace files on rename() - struct stat stFileInfo; - if (stat(out_img, &stFileInfo) == 0) - unlink(out_img); -#endif - - if (rename(tmpname, out_img) != 0) { - perror("rename"); - err++; - unlink(tmpname); - } - } - - return (err != 0); -} - -void -ImageMetaData::distortion_params(double *k0, double *k1, double *x0) { - *k0 = _k0; - *k1 = _k1; - *x0 = _x0; -} - -void -ImageMetaData::distortion_params(double k0, double k1, double x0) { - _k0 = k0; - _k1 = k1; - _x0 = x0; -} diff --git a/src/JPEGOutputImage.H b/src/JPEGOutputImage.H deleted file mode 100644 index 5ce9069..0000000 --- a/src/JPEGOutputImage.H +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef JPEGOUTPUTIMAGE_H -#define JPEGOUTPUTIMAGE_H - -#include -extern "C" { -#include -#undef HAVE_STDLIB_H -} - -#include "OutputImage.H" - -class JPEGOutputImage : public OutputImage { - private: - unsigned char *row; - char *file; - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - FILE *fp; - int quality; - - protected: - int init_internal(); - int set_pixel_internal(int x, int r, int g, int b); - int next_line_internal(); - int done_internal(); - - public: - JPEGOutputImage(const char *file, int quality = 90); - ~JPEGOutputImage(); -}; - -#endif diff --git a/src/JPEGOutputImage.cxx b/src/JPEGOutputImage.cxx deleted file mode 100644 index 8bbd40b..0000000 --- a/src/JPEGOutputImage.cxx +++ /dev/null @@ -1,104 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include -extern "C" { -#include -} - -#include "JPEGOutputImage.H" - -JPEGOutputImage::JPEGOutputImage(const char *f, int q) : OutputImage() { - file = strdup(f); - fp = NULL; - row = NULL; - quality = q; -} - -JPEGOutputImage::~JPEGOutputImage() { - if (row) - free(row); - if (file) - free(file); -} - -int -JPEGOutputImage::init_internal() { - if (row) - free(row); - row = NULL; - - row = (unsigned char*) calloc(3 * W, sizeof(char)); - if (!row) { - perror("calloc"); - return 1; - } - - if (fp) - fclose(fp); - - if ((fp = fopen(file, "wb")) == NULL) { - fprintf(stderr, "can't open %s\n", file); - return 1; - } - - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - jpeg_stdio_dest(&cinfo, fp); - cinfo.image_width = W; - cinfo.image_height = H; - cinfo.input_components = 3; /* # of color components per pixel */ - cinfo.in_color_space = JCS_RGB; - - jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, quality, TRUE); - - jpeg_start_compress(&cinfo, TRUE); - - return 0; -} - -int -JPEGOutputImage::set_pixel_internal(int x, int r, int g, int b) { - row[x*3+0] = (unsigned char) (r / 255); - row[x*3+1] = (unsigned char) (g / 255); - row[x*3+2] = (unsigned char) (b / 255); - - return 0; -} - -int -JPEGOutputImage::next_line_internal() { - JSAMPROW row_pointer[1]; - - row_pointer[0] = row; - jpeg_write_scanlines(&cinfo, row_pointer, 1); - memset(row, 0, sizeof(char) * 3 * W); - return 0; -} - -int -JPEGOutputImage::done_internal() { - jpeg_finish_compress(&cinfo); - jpeg_destroy_compress(&cinfo); - - if (fp) - fclose(fp); - fp = NULL; - - if (row) - free(row); - row = NULL; - - if (fp) - fclose(fp); - fp = NULL; - - return 0; -} - diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index 3d4a174..0000000 --- a/src/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ -bin_PROGRAMS = gipfel - -gipfel_SOURCES = \ - gipfel.cxx \ - GipfelWidget.cxx \ - Panorama.cxx \ - ProjectionLSQ.cxx \ - ProjectionRectilinear.cxx \ - ProjectionCylindrical.cxx \ - Hill.cxx \ - Fl_Value_Dial.cxx \ - Fl_Search_Chooser.cxx \ - choose_hill.cxx \ - Stitch.cxx \ - OutputImage.cxx \ - JPEGOutputImage.cxx \ - TIFFOutputImage.cxx \ - PreviewOutputImage.cxx \ - ImageMetaData.cxx \ - ScreenDump.cxx \ - ScanImage.cxx \ - strsep.c - -noinst_HEADERS = \ - GipfelWidget.H \ - Panorama.H \ - ProjectionLSQ.H \ - ProjectionRectilinear.H \ - ProjectionRectilinear_funcs.cxx \ - ProjectionCylindrical.H \ - ProjectionCylindrical_funcs.cxx \ - Hill.H \ - ViewParams.H \ - Fl_Value_Dial.H \ - Fl_Search_Chooser.H \ - choose_hill.H \ - Stitch.H \ - OutputImage.H \ - JPEGOutputImage.H \ - TIFFOutputImage.H \ - PreviewOutputImage.H \ - ImageMetaData.H \ - ScreenDump.H \ - ScanImage.H \ - strsep.h diff --git a/src/Makefile.lsq_funcs b/src/Makefile.lsq_funcs deleted file mode 100644 index 46bab6e..0000000 --- a/src/Makefile.lsq_funcs +++ /dev/null @@ -1,7 +0,0 @@ -all: ProjectionRectilinear_funcs.cxx ProjectionCylindrical_funcs.cxx - -ProjectionRectilinear_funcs.cxx: lsq_rectilinear.mac expr2c.mac - maxima -b lsq_rectilinear.mac | grep "^double" > ProjectionRectilinear_funcs.cxx - -ProjectionCylindrical_funcs.cxx: lsq_cylindrical.mac expr2c.mac - maxima -b lsq_cylindrical.mac | grep "^double" > ProjectionCylindrical_funcs.cxx diff --git a/src/OutputImage.H b/src/OutputImage.H deleted file mode 100644 index 0718074..0000000 --- a/src/OutputImage.H +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright 2006 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef OUTPUTIMAGE_H -#define OUTPUTIMAGE_H - -class OutputImage { - private: - int initialized; - - protected: - int W, H, line; - - virtual int init_internal() {return 0;}; - virtual int set_pixel_internal(int x, int r, int g, int b) {return 0;}; - virtual int next_line_internal() {return 0;}; - virtual int done_internal() {return 0;}; - - public: - OutputImage(); - virtual ~OutputImage() {}; - - virtual int init(int w1, int h1); - int set_pixel(int x, int r, int g, int b); - int next_line(); - int done(); -}; - -#endif diff --git a/src/OutputImage.cxx b/src/OutputImage.cxx deleted file mode 100644 index b4c4739..0000000 --- a/src/OutputImage.cxx +++ /dev/null @@ -1,58 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include - -#include "OutputImage.H" - -OutputImage::OutputImage() { - W = 0; - H = 0; - initialized = 0; -} - -int -OutputImage::init(int w1, int h1) { - int ret; - - W = w1; - H = h1; - line = 0; - - ret = init_internal(); - - if (ret == 0) - initialized = 1; - - return ret; -} - -int -OutputImage::set_pixel(int x, int r, int g, int b) { - if (!initialized || x < 0 || x >= W) - return 1; - else - return set_pixel_internal(x, r, g, b); -} - -int -OutputImage::next_line() { - if (!initialized || line++ >= H) - return 1; - else - return next_line_internal(); -} - -int -OutputImage::done() { - if (!initialized) { - return 1; - } else { - next_line(); - return done_internal(); - } -} diff --git a/src/Panorama.H b/src/Panorama.H deleted file mode 100644 index 1f4fdeb..0000000 --- a/src/Panorama.H +++ /dev/null @@ -1,83 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef PANORAMA_H -#define PANORAMA_H - -#include "Hill.H" -#include "ProjectionLSQ.H" -#include "ViewParams.H" - -class Panorama { - private: - double view_phi, view_lam, view_height; - char *view_name; - double height_dist_ratio; - double hide_value; - Hills *mountains; - Hills *close_mountains; - Hills *visible_mountains; - ProjectionLSQ *proj; - ProjectionLSQ::Projection_t projection_type; - double pi_d, deg2rad; - - Hill * get_pos(const char *name); - void update_angles(); - void update_coordinates(Hills *excluded_hills = NULL); - void update_close_mountains(); - void update_visible_mountains(Hills *excluded_hills = NULL); - void mark_hidden(Hills *hills); - double distance(double phi, double lam); - double alpha(const Hill *m); - double nick(const Hill *m); - double refraction(const Hill *m); - double comp_center_angle(double alph_a, double alph_b, double d1, double d2); - double comp_scale(double alph_a, double alph_b, double d1, double d2); - int get_matrix(double m[]); - int optimize(Hill *m1, Hill *m2); - int is_visible(double a_alph); - - public: - ViewParams parms; - - Panorama(); - ~Panorama(); - int load_data(const char *name); - void add_hills(Hills *h); - void remove_hills(int flags); - int set_viewpoint(const char *pos); - void set_viewpoint(const Hill *m); - void set_height_dist_ratio(double r); - void set_hide_value(double h); - Hills * get_mountains(); - Hills * get_close_mountains(); - Hills * get_visible_mountains(); - void set_center_angle(double a); - void set_nick_angle(double a); - void set_tilt_angle(double a); - void set_scale(double s); - void set_view_lat(double v); - void set_view_long(double v); - void set_view_height(double v); - const char * get_viewpoint(); - double get_center_angle(); - double get_nick_angle(); - double get_tilt_angle(); - double get_scale(); - double get_height_dist_ratio(); - double get_view_lat(); - double get_view_long(); - double get_view_height(); - double get_earth_radius(double latitude); - double get_real_distance(const Hill *m); - int comp_params(Hills *h); - ProjectionLSQ::Projection_t get_projection(); - void set_projection(ProjectionLSQ::Projection_t p); - void get_distortion_params(double *k0, double *k1, double *x0); - void set_distortion_params(double k0, double k1, double x0); - int get_coordinates(double a_alph, double a_nick, double *x, double *y); -}; -#endif diff --git a/src/Panorama.cxx b/src/Panorama.cxx deleted file mode 100644 index ccba04f..0000000 --- a/src/Panorama.cxx +++ /dev/null @@ -1,476 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include -#include - -#include "Panorama.H" -#include "ProjectionRectilinear.H" -#include "ProjectionCylindrical.H" - -#define EARTH_RADIUS 6371000.785 - -Panorama::Panorama() { - mountains = new Hills(); - close_mountains = new Hills(); - visible_mountains = new Hills(); - height_dist_ratio = 0.07; - hide_value = 1.2; - pi_d = asin(1.0) * 2.0; - deg2rad = pi_d / 180.0; - parms.a_center = 0.0; - parms.a_nick = 0.0; - parms.a_tilt = 0.0; - parms.scale = 3500.0; - parms.k0 = 0.0; - parms.k1 = 0.0; - parms.x0 = 0.0; - view_name = NULL; - view_phi = 0.0; - view_lam = 0.0; - view_height = 0.0; - proj = NULL; - set_projection(ProjectionLSQ::RECTILINEAR); -} - -Panorama::~Panorama() { - visible_mountains->clear(); - mountains->clobber(); - delete visible_mountains; - delete mountains; -} - -int -Panorama::load_data(const char *name) { - if (mountains->load(name) != 0) { - fprintf(stderr, "Could not load datafile %s\n", name); - return 1; - } - - mountains->mark_duplicates(0.00001); - update_angles(); - - return 0; -} - -void -Panorama::add_hills(Hills *h) { - mountains->add(h); - - mountains->mark_duplicates(0.00001); - update_angles(); -} - -void -Panorama::remove_hills(int flags) { - Hills *h_new = new Hills(); - Hill *m; - - for (int i = 0; i < mountains->get_num(); i++) { - m = mountains->get(i); - if (! (m->flags & flags)) - h_new->add(m); - } - - delete mountains; - mountains = h_new; -} - -int -Panorama::set_viewpoint(const char *name) { - Hill *m = get_pos(name); - if (m == NULL) { - fprintf(stderr, "Could not find exactly one entry for %s.\n", name); - return 1; - } - - set_viewpoint(m); - return 0; -} - -void -Panorama::set_viewpoint(const Hill *m) { - if (m == NULL) - return; - - view_phi = m->phi; - view_lam = m->lam; - view_height = m->height; - - if (view_name) - free(view_name); - - view_name = strdup(m->name); - - update_angles(); -} - -Hills * -Panorama::get_mountains() { - return mountains; -} - -Hills * -Panorama::get_close_mountains() { - return close_mountains; -} - -Hills * -Panorama::get_visible_mountains() { - return visible_mountains; -} - -int -Panorama::comp_params(Hills *h) { - int ret; - - ret = proj->comp_params(h, &parms); - if (ret == 0) - update_visible_mountains(h); - - return ret; -} - -void -Panorama::set_center_angle(double a) { - parms.a_center = a * deg2rad; - update_visible_mountains(); -} - -void -Panorama::set_nick_angle(double a) { - parms.a_nick = a * deg2rad; - update_coordinates(); -} - -void -Panorama::set_tilt_angle(double a) { - parms.a_tilt = a * deg2rad; - update_coordinates(); -} - -void -Panorama::set_scale(double s) { - parms.scale = s; - update_coordinates(); -} - -void -Panorama::get_distortion_params(double *k0, double *k1, double *x0) { - *k0 = parms.k0; - *k1 = parms.k1; - *x0 = parms.x0; -} - -void -Panorama::set_distortion_params(double k0, double k1, double x0) { - parms.k0 = k0; - parms.k1 = k1; - parms.x0 = x0; - update_coordinates(); -} - -void -Panorama::set_height_dist_ratio(double r) { - height_dist_ratio = r; - update_close_mountains(); -} - -void -Panorama::set_view_long(double v) { - view_lam = v * deg2rad; - update_angles(); -} - -void -Panorama::set_view_lat(double v) { - view_phi = v * deg2rad; - update_angles(); -} - -void -Panorama::set_view_height(double v) { - view_height = v; - update_angles(); -} - -void -Panorama::set_projection(ProjectionLSQ::Projection_t p) { - projection_type = p; - - if (proj) { - delete proj; - proj = NULL; - } - - switch(projection_type) { - case ProjectionLSQ::RECTILINEAR: - proj = new ProjectionRectilinear(); - break; - case ProjectionLSQ::CYLINDRICAL: - proj = new ProjectionCylindrical(); - break; - } - - update_angles(); -} - -const char * -Panorama::get_viewpoint() { - return view_name; -} - -double -Panorama::get_center_angle() { - return parms.a_center / deg2rad; -} - -double -Panorama::get_nick_angle() { - return parms.a_nick / deg2rad; -} - -double -Panorama::get_tilt_angle() { - return parms.a_tilt / deg2rad; -} - -double -Panorama::get_scale() { - return parms.scale; -} - -double -Panorama::get_height_dist_ratio() { - return height_dist_ratio; -} - -double -Panorama::get_view_long() { - return view_lam / deg2rad; -} - -double -Panorama::get_view_lat() { - return view_phi / deg2rad; -} - -double -Panorama::get_view_height() { - return view_height; -} - -ProjectionLSQ::Projection_t -Panorama::get_projection() { - return projection_type; -} - -Hill * -Panorama::get_pos(const char *name) { - Hill *m, *ret = NULL; - - for (int i = 0; i < mountains->get_num(); i++) { - m = mountains->get(i); - - if (strcmp(m->name, name) == 0) { - ret = m; - fprintf(stderr, "Found matching entry: %s (%fm)\n", - m->name, m->height); - } - } - - return ret; -} - -void -Panorama::update_angles() { - for (int i = 0; i < mountains->get_num(); i++) { - Hill *m = mountains->get(i); - - m->dist = distance(m->phi, m->lam); - if (m->phi != view_phi || m->lam != view_lam) - m->alph = alpha(m); - } - - mountains->sort(Hills::SORT_ALPHA); - - update_close_mountains(); -} - -void -Panorama::set_hide_value(double h) { - hide_value = h; - update_visible_mountains(); -} - -void -Panorama::mark_hidden(Hills *hills) { - double h; - - for (int i = 0; i < hills->get_num(); i++) { - Hill *m = hills->get(i); - - m->flags &= ~Hill::HIDDEN; - - if (m->flags & Hill::DUPLIC) - continue; - - for (int j = 0; j < hills->get_num(); j++) { - Hill *n = hills->get(j); - - if (n->flags & Hill::DUPLIC || n->flags & Hill::TRACK_POINT) - continue; - - if (m == n || fabs(m->alph - n->alph > pi_d / 2.0)) - continue; - - if (m->dist < n->dist || m->a_nick > n->a_nick) - continue; - - h = (n->a_nick - m->a_nick) / fabs(m->alph - n->alph); - if (isinf(h) || h > hide_value) - m->flags |= Hill::HIDDEN; - } - } -} - -void -Panorama::update_close_mountains() { - close_mountains->clear(); - - for (int i = 0; i < mountains->get_num(); i++) { - Hill *m = mountains->get(i); - - if (m->flags & Hill::TRACK_POINT || - ((m->phi != view_phi || m->lam != view_lam) && - (m->height / (m->dist * EARTH_RADIUS) > height_dist_ratio))) { - - m->a_nick = nick(m); - close_mountains->add(m); - } - } - - mark_hidden(close_mountains); - update_visible_mountains(); -} - -void -Panorama::update_visible_mountains(Hills *excluded_hills) { - visible_mountains->clear(); - - for (int i = 0; i < close_mountains->get_num(); i++) { - Hill *m = close_mountains->get(i); - - if (is_visible(m->alph)) { - visible_mountains->add(m); - m->flags |= Hill::VISIBLE; - } else { - m->flags &= ~Hill::VISIBLE; - } - } - - update_coordinates(excluded_hills); -} - -void -Panorama::update_coordinates(Hills *excluded_hills) { - for (int i = 0; i < visible_mountains->get_num(); i++) { - Hill *m = visible_mountains->get(i); - if (!excluded_hills || !excluded_hills->contains(m)) - proj->get_coordinates(m->alph, m->a_nick, &parms, &m->x, &m->y); - } -} - -double -Panorama::distance(double phi, double lam) { - double d_lam = view_lam - lam; - - return atan2(sqrt(pow(cos(phi) * sin(d_lam), 2.0) + - pow(cos(view_phi) * sin(phi) - sin(view_phi) * cos(phi) * cos(d_lam), 2.0)), - sin(view_phi) * sin(phi) + cos(view_phi) * cos(phi) * cos(d_lam)); -} - -double -Panorama::alpha(const Hill *m) { - double sin_alph, cos_alph; - - sin_alph = sin(m->lam - view_lam) * cos(m->phi) / sin(m->dist); - cos_alph = (sin(m->phi) - sin(view_phi) * cos(m->dist)) / - (cos(view_phi) * sin(m->dist)); - - return fmod(atan2(sin_alph, cos_alph) + 2.0 * pi_d, 2.0 * pi_d); -} - -// approximation of refraction effect as described by Tom Chester at -// http://tchester.org/sgm/analysis/peaks/refraction.html -double -Panorama::refraction(const Hill *m) { - double a, b, c, alpha = 6.5, T0 = 10.0; - - a = 2.9e-4 * exp (-view_height / 10000.0) / (1.0 + 2.9 * T0 / 760.0); - b = 2.9 * alpha / (760.0 * (1.0 + 2.9 * T0 / 760.0)); - c = a * (b - 1.0 / 10.0); - - return c * get_real_distance(m) / (2000.0 * (1.0 + a)); -} - -double -Panorama::nick(const Hill *m) { - double b, c, theta = refraction(m); - - b = m->height + get_earth_radius(m->phi); - c = view_height + get_earth_radius(view_phi); - - return atan((cos(m->dist) * b - c) / (sin(m->dist) * b)) - theta; -} - -// return local distance to center of WGS84 ellipsoid -double -Panorama::get_earth_radius(double phi) { - double a = 6378137.000; - double b = 6356752.315; - double r; - double ata = tan(phi); - - r = a*pow(pow(ata,2)+1,1.0/2.0)*fabs(b)*pow(pow(b,2)+pow(a,2)*pow(ata,2),-1.0/2.0); - return r; -} - -double -Panorama::get_real_distance(const Hill *m) { - double a, b, c, gam; - - a = view_height + get_earth_radius(view_phi); - b = m->height + get_earth_radius(m->phi); - gam = m->dist; - - c = sqrt(pow(a, 2.0) + pow(b, 2.0) - 2.0 * a * b * cos(gam)); - return c; -} - -int -Panorama::is_visible(double a_alph) { - double center_dist; - - center_dist = fabs(a_alph - parms.a_center); - if (center_dist > pi_d) { - center_dist = 2*pi_d - center_dist; - } - - return center_dist < proj->get_view_angle(); -} - -int -Panorama::get_coordinates(double a_alph, double a_nick, double *x, double *y) { - if (is_visible(a_alph)) { - proj->get_coordinates(a_alph, a_nick, &parms, x, y); - return 0; - } else { - return 1; - } -} diff --git a/src/PreviewOutputImage.H b/src/PreviewOutputImage.H deleted file mode 100644 index f37493b..0000000 --- a/src/PreviewOutputImage.H +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef PREVIEWOUTPUTIMAGE_H -#define PREVIEWOUTPUTIMAGE_H - -#include - -#include -#include - -#include "OutputImage.H" - -class PreviewOutputImage : public OutputImage , public Fl_Widget { - private: - uchar *data; - int d; - - protected: - int init_internal(); - int set_pixel_internal(int x, int r, int g, int b); - int next_line_internal(); - - public: - PreviewOutputImage(int X, int Y, int W, int H); - ~PreviewOutputImage(); - - void draw(); -}; - -#endif diff --git a/src/PreviewOutputImage.cxx b/src/PreviewOutputImage.cxx deleted file mode 100644 index 560f044..0000000 --- a/src/PreviewOutputImage.cxx +++ /dev/null @@ -1,65 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include - -#include -#include - -#include "PreviewOutputImage.H" - -PreviewOutputImage::PreviewOutputImage(int X, int Y, int W, int H): - OutputImage(), Fl_Widget(X, Y, W, H) { - d = 3; - data = NULL; -} - -PreviewOutputImage::~PreviewOutputImage() { - if (data) - free(data); -} - -int -PreviewOutputImage::init_internal() { - data = (uchar*) malloc(W * H * d); - memset(data, 0, W * H * d); - size(W, H); - return 0; -} - -int -PreviewOutputImage::set_pixel_internal(int x, int r, int g, int b) { - if (!data) - return 1; - - long index = (line * w() * d + (x * d)); - *(data+index+0) = (unsigned char) (r / 255); - *(data+index+1) = (unsigned char) (g / 255); - *(data+index+2) = (unsigned char) (b / 255); - - return 0; -} - -int -PreviewOutputImage::next_line_internal() { - if (line % 10 == 0) { - redraw(); - Fl::check(); - } - return 0; -} - -void -PreviewOutputImage::draw() { - if (!data) - return; - - fl_push_clip(x(), y(), w(), h()); - fl_draw_image(data, x(), y(), w(), h(), d); - fl_pop_clip(); -} diff --git a/src/ProjectionCylindrical.H b/src/ProjectionCylindrical.H deleted file mode 100644 index 06709c4..0000000 --- a/src/ProjectionCylindrical.H +++ /dev/null @@ -1,33 +0,0 @@ -// -// Copyright 2006 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef PROJECTIONCYLINDRICAL_H -#define PROJECTIONCYLINDRICAL_H - -#include "ProjectionLSQ.H" - -class ProjectionCylindrical : public ProjectionLSQ { - public: - - virtual double get_view_angle() {return 6.2831853;}; /* 360 deg */ - virtual int comp_params(const Hills *h, ViewParams *parms); - -#define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick - virtual double mac_x(ARGS); - virtual double mac_y(ARGS); - virtual double mac_x_dc_view(ARGS); - virtual double mac_x_dc_nick(ARGS); - virtual double mac_x_dc_tilt(ARGS); - virtual double mac_x_dscale(ARGS); - virtual double mac_y_dc_view(ARGS); - virtual double mac_y_dc_nick(ARGS); - virtual double mac_y_dc_tilt(ARGS); - virtual double mac_y_dscale(ARGS); -#undef ARGS - -}; - -#endif diff --git a/src/ProjectionCylindrical.cxx b/src/ProjectionCylindrical.cxx deleted file mode 100644 index 094b494..0000000 --- a/src/ProjectionCylindrical.cxx +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include - -#include "ProjectionCylindrical.H" - -#include "ProjectionCylindrical_funcs.cxx" - -int -ProjectionCylindrical::comp_params(const Hills *h, ViewParams *parms) { - Hills h_monotone(h); - - h_monotone.sort(Hills::SORT_X); - - // ensure that alpha is increasing with x. - for (int i = 1; i < h_monotone.get_num(); i++) - if (h_monotone.get(i)->alph < h_monotone.get(i - 1)->alph) - h_monotone.get(i)->alph += asin(1.0) * 4.0; // += 2pi - - return ProjectionLSQ::comp_params(&h_monotone, parms); -} diff --git a/src/ProjectionLSQ.H b/src/ProjectionLSQ.H deleted file mode 100644 index a380b4c..0000000 --- a/src/ProjectionLSQ.H +++ /dev/null @@ -1,59 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef PROJECTIONLSQ_H -#define PROJECTIONLSQ_H - -#include "Hill.H" -#include "ViewParams.H" - -class ProjectionLSQ { - private: - double comp_scale(double alph_a, double alph_b, double d1, double d2); - - int lsq(const Hills *m, ViewParams *parms, int distortion_correct); - - protected: - static double pi; - double sec(double a); - - public: - typedef enum { - RECTILINEAR = 0, - CYLINDRICAL = 1 - } Projection_t; - - ProjectionLSQ() {}; - virtual ~ProjectionLSQ() {}; - - void get_coordinates(double a_view, double a_nick, - const ViewParams *parms, double *x, double *y); - - virtual int comp_params(const Hills *h, ViewParams *parms); - - virtual double get_view_angle(); - -#define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick - virtual double mac_x(ARGS); - virtual double mac_y(ARGS); - virtual double mac_x_dc_view(ARGS); - virtual double mac_x_dc_nick(ARGS); - virtual double mac_x_dc_tilt(ARGS); - virtual double mac_x_dscale(ARGS); - virtual double mac_x_dk0(ARGS); - virtual double mac_x_dk1(ARGS); - virtual double mac_x_dx0(ARGS); - virtual double mac_y_dc_view(ARGS); - virtual double mac_y_dc_nick(ARGS); - virtual double mac_y_dc_tilt(ARGS); - virtual double mac_y_dscale(ARGS); - virtual double mac_y_dk0(ARGS); - virtual double mac_y_dk1(ARGS); - virtual double mac_y_dx0(ARGS); -#undef ARGS - -}; -#endif diff --git a/src/ProjectionLSQ.cxx b/src/ProjectionLSQ.cxx deleted file mode 100644 index bcbb206..0000000 --- a/src/ProjectionLSQ.cxx +++ /dev/null @@ -1,294 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "ProjectionLSQ.H" - -double ProjectionLSQ::pi = asin(1.0) * 2.0; - -double -ProjectionLSQ::sec(double a) { - return 1.0 / cos(a); -} - -double -ProjectionLSQ::get_view_angle() { - return 0.0; -} - -int -ProjectionLSQ::comp_params(const Hills *h, ViewParams *parms) { - const Hill *m1, *m2; - double scale_tmp; - int known_hills = h->get_num(); - ViewParams new_parms = *parms; - - if (known_hills < 1) { - fprintf(stderr, "Please position at least 1 hill\n"); - return 1; - } - - m1 = h->get(0); - new_parms.a_center = m1->alph; - new_parms.a_nick = 0.0; - - if (known_hills > 1) { - m2 = h->get(1); - - scale_tmp = comp_scale(m1->alph, m2->alph, m1->x, m2->x); - - if (isnan(scale_tmp) || scale_tmp < 50.0) { - fprintf(stderr, "Could not determine initial scale value (%f)\n", - scale_tmp); - return 1; - } - - new_parms.scale = scale_tmp; - new_parms.a_tilt = 0.0; - } - - if (known_hills > 3) { - fprintf(stderr, "Performing calibration\n"); - new_parms.k0 = 0.0; - new_parms.k1 = 0.0; - new_parms.x0 = 0.0; - } - - if (known_hills == 1) { - lsq(h, &new_parms, 0); - } else if (known_hills < 4) { - lsq(h, &new_parms, 1); - } else { - lsq(h, &new_parms, 1); - lsq(h, &new_parms, 2); - } - - if (isnan(new_parms.scale) || new_parms.scale < 50.0) { - fprintf(stderr, "Could not determine reasonable view parameters\n"); - return 1; - } - - *parms = new_parms; - - return 0; -} - -struct data { - ProjectionLSQ *p; - int level; - const Hills *h; - const ViewParams *old_params; -}; - -#define CALL(A) dat->p->A(parms.a_center, parms.a_nick, parms.a_tilt, parms.scale, parms.k0, parms.k1, parms.x0, m->alph, m->a_nick) - -static int -lsq_f (const gsl_vector * x, void *data, gsl_vector * f) { - struct data *dat = (struct data *) data; - ViewParams parms = *dat->old_params; - - parms.a_center = gsl_vector_get (x, 0); - parms.a_nick = gsl_vector_get (x, 1); - if (dat->level > 0) { - parms.a_tilt = gsl_vector_get (x, 2); - parms.scale = gsl_vector_get (x, 3); - } - if (dat->level > 1) { - parms.k0 = gsl_vector_get (x, 4); - parms.k1 = gsl_vector_get (x, 5); - parms.x0 = gsl_vector_get (x, 6); - } - - for (int i=0; ih->get_num(); i++) { - Hill *m = dat->h->get(i); - - double mx = CALL(mac_x); - double my = CALL(mac_y); - - gsl_vector_set (f, i*2, mx - m->x); - gsl_vector_set (f, i*2+1, my - m->y); - } - - return GSL_SUCCESS; -} - - -static int -lsq_df (const gsl_vector * x, void *data, gsl_matrix * J) { - struct data *dat = (struct data *) data; - ViewParams parms = *dat->old_params; - - parms.a_center = gsl_vector_get (x, 0); - parms.a_nick = gsl_vector_get (x, 1); - if (dat->level > 0) { - parms.a_tilt = gsl_vector_get (x, 2); - parms.scale = gsl_vector_get (x, 3); - } - if (dat->level > 1) { - parms.k0 = gsl_vector_get (x, 4); - parms.k1 = gsl_vector_get (x, 5); - parms.x0 = gsl_vector_get (x, 6); - } - - for (int i=0; ih->get_num(); i++) { - Hill *m = dat->h->get(i); - - gsl_matrix_set (J, 2*i, 0, CALL(mac_x_dc_view)); - gsl_matrix_set (J, 2*i, 1, CALL(mac_x_dc_nick)); - if (dat->level > 0) { - gsl_matrix_set (J, 2*i, 2, CALL(mac_x_dc_tilt)); - gsl_matrix_set (J, 2*i, 3, CALL(mac_x_dscale)); - } - if (dat->level > 1) { - gsl_matrix_set (J, 2*i, 4, CALL(mac_x_dk0)); - gsl_matrix_set (J, 2*i, 5, CALL(mac_x_dk1)); - gsl_matrix_set (J, 2*i, 6, CALL(mac_x_dx0)); - } - - gsl_matrix_set (J, 2*i+1, 0, CALL(mac_y_dc_view)); - gsl_matrix_set (J, 2*i+1, 1, CALL(mac_y_dc_nick)); - if (dat->level > 0) { - gsl_matrix_set (J, 2*i+1, 2, CALL(mac_y_dc_tilt)); - gsl_matrix_set (J, 2*i+1, 3, CALL(mac_y_dscale)); - } - if (dat->level > 1) { - gsl_matrix_set (J, 2*i+1, 4, CALL(mac_y_dk0)); - gsl_matrix_set (J, 2*i+1, 5, CALL(mac_y_dk1)); - gsl_matrix_set (J, 2*i+1, 6, CALL(mac_y_dx0)); - } - } - - return GSL_SUCCESS; -} - -static int -lsq_fdf (const gsl_vector * x, void *data, gsl_vector * f, gsl_matrix * J) { - lsq_f (x, data, f); - lsq_df (x, data, J); - - return GSL_SUCCESS; -} - -int -ProjectionLSQ::lsq(const Hills *h, ViewParams *parms, - int level) { - - const gsl_multifit_fdfsolver_type *T; - gsl_multifit_fdfsolver *s; - gsl_multifit_function_fdf f; - struct data dat; - double x_init[8]; - gsl_vector_view x; - int status; - int num_params; - - if (level == 0) - num_params = 2; - else if (level == 1) - num_params = 4; - else - num_params = 7; - - dat.p = this; - dat.level = level; - dat.h = h; - dat.old_params = parms; - - x_init[0] = parms->a_center; - x_init[1] = parms->a_nick; - x_init[2] = parms->a_tilt; - x_init[3] = parms->scale; - x_init[4] = parms->k0; - x_init[5] = parms->k1; - x_init[6] = parms->x0; - - x = gsl_vector_view_array (x_init, num_params); - - f.f = &lsq_f; - f.df = &lsq_df; - f.fdf = &lsq_fdf; - f.n = h->get_num() * 2; - f.p = num_params; - f.params = &dat; - - T = gsl_multifit_fdfsolver_lmsder; - s = gsl_multifit_fdfsolver_alloc (T, h->get_num() * 2, num_params); - gsl_multifit_fdfsolver_set (s, &f, &x.vector); - - for (int i=0; i<100; i++) { - status = gsl_multifit_fdfsolver_iterate (s); - if (status) { - break; - } - } - - parms->a_center = gsl_vector_get(s->x, 0); - parms->a_nick = gsl_vector_get(s->x, 1); - - if (level > 0) { - parms->a_tilt = gsl_vector_get(s->x, 2); - parms->scale = gsl_vector_get(s->x, 3); - } - if (level > 1) { - parms->k0 = gsl_vector_get(s->x, 4); - parms->k1 = gsl_vector_get(s->x, 5); - parms->x0 = gsl_vector_get(s->x, 6); - } - - gsl_multifit_fdfsolver_free (s); - - return 0; -} - -void -ProjectionLSQ::get_coordinates(double alph, double a_nick, - const ViewParams *parms, double *x, double *y) { - - // Normalize alph - parms->a_center to [-pi/2, pi/2] - if (alph - parms->a_center > pi) - alph -= 2.0 * pi; - else if (alph - parms->a_center < -pi) - alph += 2.0 * pi; - - *x = mac_x(parms->a_center, parms->a_nick, parms->a_tilt, parms->scale, - parms->k0, parms->k1, parms->x0, alph, a_nick); - *y = mac_y(parms->a_center, parms->a_nick, parms->a_tilt, parms->scale, - parms->k0, parms->k1, parms->x0, alph, a_nick); -} - -double -ProjectionLSQ::comp_scale(double a1, double a2, double d1, double d2) { - return (fabs(d1 - d2) / fabs(a1 - a2)); -} - -#define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick - -double ProjectionLSQ::mac_x(ARGS) {return NAN;} -double ProjectionLSQ::mac_y(ARGS) {return NAN;} -double ProjectionLSQ::mac_x_dc_view(ARGS) {return NAN;} -double ProjectionLSQ::mac_x_dc_nick(ARGS) {return NAN;} -double ProjectionLSQ::mac_x_dc_tilt(ARGS) {return NAN;} -double ProjectionLSQ::mac_x_dscale(ARGS) {return NAN;} -double ProjectionLSQ::mac_x_dk0(ARGS) {return NAN;} -double ProjectionLSQ::mac_x_dk1(ARGS) {return NAN;} -double ProjectionLSQ::mac_x_dx0(ARGS) {return NAN;} -double ProjectionLSQ::mac_y_dc_view(ARGS) {return NAN;} -double ProjectionLSQ::mac_y_dc_nick(ARGS) {return NAN;} -double ProjectionLSQ::mac_y_dc_tilt(ARGS) {return NAN;} -double ProjectionLSQ::mac_y_dscale(ARGS) {return NAN;} -double ProjectionLSQ::mac_y_dk0(ARGS) {return NAN;} -double ProjectionLSQ::mac_y_dk1(ARGS) {return NAN;} -double ProjectionLSQ::mac_y_dx0(ARGS) {return NAN;} diff --git a/src/ProjectionRectilinear.H b/src/ProjectionRectilinear.H deleted file mode 100644 index 2d799e3..0000000 --- a/src/ProjectionRectilinear.H +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef PROJECTIONRECTILINEAR_H -#define PROJECTIONRECTILINEAR_H - -#include "ProjectionLSQ.H" - -class ProjectionRectilinear : public ProjectionLSQ { - public: - - virtual double get_view_angle() {return 1.0471976;}; /* 60 deg */ - -#define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick - virtual double mac_x(ARGS); - virtual double mac_y(ARGS); - virtual double mac_x_dc_view(ARGS); - virtual double mac_x_dc_nick(ARGS); - virtual double mac_x_dc_tilt(ARGS); - virtual double mac_x_dscale(ARGS); - virtual double mac_x_dk0(ARGS); - virtual double mac_x_dk1(ARGS); - virtual double mac_x_dx0(ARGS); - virtual double mac_y_dc_view(ARGS); - virtual double mac_y_dc_nick(ARGS); - virtual double mac_y_dc_tilt(ARGS); - virtual double mac_y_dscale(ARGS); - virtual double mac_y_dk0(ARGS); - virtual double mac_y_dk1(ARGS); - virtual double mac_y_dx0(ARGS); -#undef ARGS - -}; - -#endif diff --git a/src/ProjectionRectilinear.cxx b/src/ProjectionRectilinear.cxx deleted file mode 100644 index 33cb3a7..0000000 --- a/src/ProjectionRectilinear.cxx +++ /dev/null @@ -1,12 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include - -#include "ProjectionRectilinear.H" - -#include "ProjectionRectilinear_funcs.cxx" diff --git a/src/ScanImage.H b/src/ScanImage.H deleted file mode 100644 index 1c1b91a..0000000 --- a/src/ScanImage.H +++ /dev/null @@ -1,31 +0,0 @@ -// -// Copyright 2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef ScanImage_H -#define ScanImage_H - -#include - -class ScanImage { - private: - static int get_pixel_nearest(Fl_Image *img, double x, double y, - int *r, int *g, int *b); - static int get_pixel_bicubic(Fl_Image *img, double x, double y, - int *r, int *g, int *b); - static int get_pixel(Fl_Image *img, int x, int y, - int *r, int *g, int *b); - - public: - typedef enum { - NEAREST = 0, - BICUBIC = 1 - } mode_t; - - static int get_pixel(Fl_Image *img, mode_t mode, - double x, double y, int *r, int *g, int *b); -}; - -#endif diff --git a/src/ScanImage.cxx b/src/ScanImage.cxx deleted file mode 100644 index 39f66a7..0000000 --- a/src/ScanImage.cxx +++ /dev/null @@ -1,118 +0,0 @@ -// -// Copyright 2007-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include - -#include -#include "ScanImage.H" - -int -ScanImage::get_pixel(Fl_Image *img, mode_t mode, - double x, double y, int *r, int *g, int *b) { - if (mode == BICUBIC) - return get_pixel_bicubic(img, x, y, r, g, b); - else - return get_pixel_nearest(img, x, y, r, g, b); -} - -int -ScanImage::get_pixel_nearest(Fl_Image *img, double x, double y, - int *r, int *g, int *b) { - - if (isnan(x) || isnan(y)) - return 1; - else - return get_pixel(img, (int) rint(x), (int) rint(y), r, g, b); -} - -static inline double -interp_cubic(double x, double x2, double x3, double *v) { - double a0, a1, a2, a3; - - a0 = v[3] - v[2] - v[0] + v[1]; - a1 = v[0] - v[1] - a0; - a2 = v[2] - v[0]; - a3 = v[1]; - - return a0 * x3 + a1 * x2 + a2 * x + a3; -} - -int -ScanImage::get_pixel_bicubic(Fl_Image *img, double x, double y, - int *r, int *g, int *b) { - - double fl_x = floor(x); - double fl_y = floor(y); - double dx = x - fl_x, dx2 = dx * dx, dx3 = dx2 * dx; - double dy = y - fl_y, dy2 = dy * dy, dy3 = dy2 * dy; - int ic[3]; - double c[3][4]; - double c1[3][4]; - - for (int iy = 0; iy < 4; iy++) { - for (int ix = 0; ix < 4; ix++) { - - if (get_pixel(img, (int) fl_x + ix - 1, (int) fl_y + iy - 1, - &ic[0], &ic[1], &ic[2]) != 0) - return 1; - - for (int l = 0; l < 3; l++) - c[l][ix] = (double) ic[l]; - } - - for (int l = 0; l < 3; l++) - c1[l][iy] = interp_cubic(dx, dx2, dx3, c[l]); - } - - *r = (int) rint(interp_cubic(dy, dy2, dy3, c1[0])); - *g = (int) rint(interp_cubic(dy, dy2, dy3, c1[1])); - *b = (int) rint(interp_cubic(dy, dy2, dy3, c1[2])); - return 0; -} - -int -ScanImage::get_pixel(Fl_Image *img, int x, int y, - int *r, int *g, int *b) { - if ( img->d() == 0 ) - return 1; - - if (x < 0 || x >=img->w() || y < 0 || y >= img->h()) - return 1; - - long index = (y * img->w() * img->d()) + (x * img->d()); // X/Y -> buf index - switch (img->count()) { - case 1: - { // bitmap - const unsigned char *buf = (const unsigned char*) img->data()[0]; - switch (img->d()) - { - case 1: - *r = *g = *b = *(buf+index); - break; - case 3: // 24bit - *r = (int) *(buf+index+0); - *g = (int) *(buf+index+1); - *b = (int) *(buf+index+2); - break; - default: // ?? - printf("Not supported: chans=%d\n", img->d()); - return 1; - } - break; - } - default: // ?? pixmap, bit vals - printf("Not supported: count=%d\n", img->count()); - return 1; - } - - *r = *r * 255; - *g = *g * 255; - *b = *b * 255; - - return 0; -} diff --git a/src/ScreenDump.H b/src/ScreenDump.H deleted file mode 100644 index 8564054..0000000 --- a/src/ScreenDump.H +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright 2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef SCREENDUMP_H -#define SCREENDUMP_H - -#include - -#include "OutputImage.H" - -class ScreenDump { - private: - int w, h; - unsigned char * rgb; - - public: - ScreenDump(Fl_Widget *widget); - ~ScreenDump(); - - int save(OutputImage *out); -}; - -#endif diff --git a/src/ScreenDump.cxx b/src/ScreenDump.cxx deleted file mode 100644 index f331a76..0000000 --- a/src/ScreenDump.cxx +++ /dev/null @@ -1,59 +0,0 @@ -// -// Copyright 2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include - -#include "ScreenDump.H" - -ScreenDump::ScreenDump(Fl_Widget *widget) { - Fl_Offscreen offscreen; - int x, y; - - x = widget->x(); - y = widget->y(); - w = widget->w(); - h = widget->h(); - - Fl::flush(); - widget->resize(0, 0, w, h); - - offscreen = fl_create_offscreen(w, h); - fl_begin_offscreen(offscreen); - widget->redraw(); - widget->draw(); - fl_color(FL_YELLOW); - fl_draw("created with gipfel", w - 80, h - 10); - rgb = fl_read_image(NULL, 0, 0, w, h); - fl_end_offscreen(); - fl_delete_offscreen(offscreen); - - widget->resize(x, y, w, h); -} - -ScreenDump::~ScreenDump() { - if (rgb) - delete[] rgb; -} - -int -ScreenDump::save(OutputImage *out) { - if (!rgb) - return 1; - - out->init(w, h); - - for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) { - unsigned char *px = &rgb[(y * w + x) * 3]; - out->set_pixel(x, px[0] * 255, px[1] * 255, px[2] * 255); - } - out->next_line(); - } - - return out->done(); -} diff --git a/src/Stitch.H b/src/Stitch.H deleted file mode 100644 index 7c9a60e..0000000 --- a/src/Stitch.H +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef STITCH_H -#define STITCH_H - -#include "GipfelWidget.H" -#include "OutputImage.H" -#include "ScanImage.H" - -#define MAX_PICS 256 - -class Stitch { - private: - GipfelWidget *gipf[MAX_PICS]; - int num_pics; - OutputImage *merged_image; - - public: - Stitch(); - ~Stitch(); - - int load_image(char *file); - OutputImage * set_output(OutputImage *img); - int resample(ScanImage::mode_t m, - int w, int h, double view_start, double view_end); -}; - -#endif diff --git a/src/Stitch.cxx b/src/Stitch.cxx deleted file mode 100644 index 7b9fc04..0000000 --- a/src/Stitch.cxx +++ /dev/null @@ -1,117 +0,0 @@ -// -// Copyright 2007-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include -#include -#include - -#include - -#include - -#include "OutputImage.H" -#include "Stitch.H" - -#define MAX_VALUE 65025 - -static double pi_d = asin(1.0) * 2.0; -static double deg2rad = pi_d / 180.0; - -Stitch::Stitch() { - for (int i = 0; i < MAX_PICS; i++) - gipf[i] = NULL; - - merged_image = NULL; - num_pics = 0; -} - -Stitch::~Stitch() { - for (int i = 0; i < MAX_PICS; i++) - if (gipf[i]) - delete gipf[i]; - else - break; -} - -int -Stitch::load_image(char *file) { - for (int i = 0; i < MAX_PICS; i++) { - if (gipf[i] == NULL) { - gipf[i] = new GipfelWidget(0, 0, 800, 600, NULL); - if (gipf[i]->load_image(file) != 0) { - delete gipf[i]; - gipf[i] = NULL; - } else { - num_pics++; - } - break; - } - } - - return 0; -} - -OutputImage* -Stitch::set_output(OutputImage *img) { - OutputImage *ret = merged_image; - merged_image = img; - return ret; -} - -int -Stitch::resample(ScanImage::mode_t m, - int w, int h, double view_start, double view_end) { - - view_start = view_start * deg2rad; - view_end = view_end * deg2rad; - - double step_view = (view_end - view_start) / w; - int r, g, b; - int y_off = h / 2; - int merged_pixel_set; - double radius = (double) w / (view_end -view_start); - - if (merged_image) - if (merged_image->init(w, h) != 0) - merged_image = NULL; - - for (int y = 0; y < h; y++) { - double a_nick = atan((double)(y_off - y)/radius); - - for (int x = 0; x < w; x++) { - double a_view; - a_view = view_start + x * step_view; - merged_pixel_set = 0; - for (int i = 0; i < num_pics; i++) { - if (merged_pixel_set) - continue; - - if (gipf[i]->get_pixel(m, a_view, a_nick, - &r, &g, &b) == 0) { - - r = std::max(std::min(r, MAX_VALUE), 0); - g = std::max(std::min(g, MAX_VALUE), 0); - b = std::max(std::min(b, MAX_VALUE), 0); - - if (!merged_pixel_set && merged_image) { - merged_image->set_pixel(x, r, g, b); - merged_pixel_set++; - } - } - } - } - - if (merged_image) - merged_image->next_line(); - } - - if (merged_image) - merged_image->done(); - - return 0; -} diff --git a/src/TIFFOutputImage.H b/src/TIFFOutputImage.H deleted file mode 100644 index b5409eb..0000000 --- a/src/TIFFOutputImage.H +++ /dev/null @@ -1,33 +0,0 @@ -// -// Copyright 2006 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef TIFFOUTPUTIMAGE_H -#define TIFFOUTPUTIMAGE_H - -#include -#include - -#include "OutputImage.H" - -class TIFFOutputImage : public OutputImage { - private: - int bitspersample; - unsigned char *row; - char *file; - TIFF *tiff; - - protected: - int init_internal(); - int set_pixel_internal(int x, int r, int g, int b); - int next_line_internal(); - int done_internal(); - - public: - TIFFOutputImage(const char *file, int b = 8); - ~TIFFOutputImage(); -}; - -#endif diff --git a/src/TIFFOutputImage.cxx b/src/TIFFOutputImage.cxx deleted file mode 100644 index e9f6a2b..0000000 --- a/src/TIFFOutputImage.cxx +++ /dev/null @@ -1,97 +0,0 @@ -// -// Copyright 2006 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include - -#include "TIFFOutputImage.H" - -TIFFOutputImage::TIFFOutputImage(const char *f, int b) : OutputImage () { - bitspersample = (b==16)?16:8; - file = strdup(f); - tiff = NULL; - row = NULL; -} - -TIFFOutputImage::~TIFFOutputImage() { - if (row) - free(row); - - if (file) - free(file); -} - -int -TIFFOutputImage::init_internal() { - if (row) - free(row); - row = NULL; - - row = (unsigned char*) calloc((bitspersample / 8) * 4 * W, sizeof(char)); - if (!row) { - perror("calloc"); - return 1; - } - - if (tiff) - TIFFClose(tiff); - - if ((tiff = TIFFOpen(file, "w")) == NULL){ - fprintf(stderr, "can't open %s\n", file); - return 1; - } - - TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, W); - TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, H); - TIFFSetField(tiff, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); - TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); - TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, 1); - TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, bitspersample); - TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 4); - - return 0; -} - -int -TIFFOutputImage::set_pixel_internal(int x, int r, int g, int b) { - if (bitspersample == 8) { - row[x*4+0] = (unsigned char) (r / 255); - row[x*4+1] = (unsigned char) (g / 255); - row[x*4+2] = (unsigned char) (b / 255); - row[x*4+3] = 255; - } else if (bitspersample == 16) { - unsigned short *row16 = (unsigned short*) row; - row16[x*4+0] = (unsigned short) r; - row16[x*4+1] = (unsigned short) g; - row16[x*4+2] = (unsigned short) b; - row16[x*4+3] = 65025; - } - - return 0; -} - -int -TIFFOutputImage::next_line_internal() { - TIFFWriteEncodedStrip(tiff, line - 1 , row, W * (bitspersample / 8) * 4); - - memset(row, 0, (bitspersample / 8) * 4 * W * sizeof(char)); - return 0; -} - -int -TIFFOutputImage::done_internal() { - if (tiff) - TIFFClose(tiff); - tiff = NULL; - - if (row) - free(row); - row = NULL; - - return 0; -} diff --git a/src/ViewParams.H b/src/ViewParams.H deleted file mode 100644 index b53a8df..0000000 --- a/src/ViewParams.H +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef VIEWPARAMS_H -#define VIEWPARAMS_H - -class ViewParams { - public: - double a_center; - double scale; - double a_nick; - double a_tilt; - double k0; - double k1; - double x0; -}; - -#endif diff --git a/src/choose_hill.H b/src/choose_hill.H deleted file mode 100644 index 27105dc..0000000 --- a/src/choose_hill.H +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#ifndef CHOOSE_HILL_H -#define CHOOSE_HILL_H - -#include "Fl_Search_Chooser.H" -#include "Hill.H" - -Hill *choose_hill(const Hills *hills, const char *l); - -#endif diff --git a/src/choose_hill.cxx b/src/choose_hill.cxx deleted file mode 100644 index 48e44d5..0000000 --- a/src/choose_hill.cxx +++ /dev/null @@ -1,43 +0,0 @@ -// -// Copyright 2006-2009 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include -#include "choose_hill.H" - -Hill* -choose_hill(const Hills *hills, const char *l) { - Fl_Search_Chooser *sc = new Fl_Search_Chooser(l?l:"Choose Hill"); - Hills *h_sort = new Hills(hills); - Hill *ret; - - h_sort->sort(Hills::SORT_NAME); - - for (int i=0; iget_num(); i++) { - char buf[256]; - - Hill *m = h_sort->get(i); - if (m->flags & (Hill::DUPLIC | Hill::TRACK_POINT)) - continue; - - snprintf(buf, sizeof(buf) - 1, "%s (%dm)", m->name, (int) m->height); - buf[sizeof(buf) - 1] = '\0'; - sc->add(buf, m); - } - - delete h_sort; - - sc->show(); - - while (sc->shown()) - Fl::wait(); - - ret = (Hill*) sc->data(); - delete sc; - - return ret; -} diff --git a/src/expr2c.mac b/src/expr2c.mac deleted file mode 100644 index 1522169..0000000 --- a/src/expr2c.mac +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2006-2009 Johannes Hofmann - */ - -load("stringproc")$ - -varsubst(v) := ssubst("_", "%", string(v))$ - -printdecl(vars) := ( - sprint("double", varsubst(first(vars))), - for v in rest(vars) do sprint(",", varsubst(v)), - sprint(";"))$ - -printdef(expr) := sprint(varsubst(first(expr)), "=", varsubst(second(expr)), ";")$ - -block2c(expr) := - if ?equal(op(expr), block) then ( - printdecl(first(expr)), - for d in reverse(rest(reverse(rest(expr)))) do printdef(d), - sprint("return", varsubst(last(expr)), ";")) - else - sprint("return", varsubst(expr), ";")$ - -expr2c(funcname, argstr, expr) := ( - sprint("double", funcname, "(", argstr, ") {"), - block2c(subst(pow, "^", optimize(expr))), - sprint("}", " -"))$ diff --git a/src/gipfel.cxx b/src/gipfel.cxx deleted file mode 100644 index bed5035..0000000 --- a/src/gipfel.cxx +++ /dev/null @@ -1,738 +0,0 @@ -// -// Copyright 2007-2023 Johannes Hofmann -// -// This software may be used and distributed according to the terms -// of the GNU General Public License, incorporated herein by reference. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Fl_Value_Dial.H" -#include "Fl_Search_Chooser.H" -#include "GipfelWidget.H" -#include "JPEGOutputImage.H" -#include "TIFFOutputImage.H" -#include "PreviewOutputImage.H" -#include "Stitch.H" -#include "ScreenDump.H" -#include "choose_hill.H" -#include "../config.h" - -#ifndef STD_DATADIR -#define STD_DATADIR "/usr/local/share" -#endif - -#define GIPFEL_DATADIR STD_DATADIR "/" PACKAGE_NAME -#define DATAFILE "gipfel.dat" - -static char *run_dir = NULL; -static char *img_file = NULL; -static char *data_file = NULL; - -static GipfelWidget *gipf = NULL; -static Fl_Scroll *scroll; -static Fl_Window *control_win, *view_win; -static Fl_Dial *s_center = NULL; -static Fl_Slider *s_nick, *s_focal_length, *s_tilt, *s_height_dist, *s_track_width; -static Fl_Value_Input *i_view_lat, *i_view_long, *i_view_height; -static Fl_Value_Input *i_distortion_k0, *i_distortion_k1, *i_distortion_x0; -static Fl_Box *b_viewpoint; -static Fl_Menu_Bar *mb; - -#define STITCH_PREVIEW 1 -#define STITCH_JPEG 2 -#define STITCH_TIFF 4 - -static int stitch(ScanImage::mode_t m , int b_16, - int stitch_w, int stitch_h, - double from, double to, int type, const char *path, int argc, char **argv); - -static int export_hills(const char *export_file, double visibility); -static int export_position(); - -static int -confirm_overwrite(const char *f) { - struct stat sb; - - if (stat(f, &sb) == 0) - return fl_choice("%s exists.\n", "Cancel", "Overwrite", NULL, f); - else - return 1; -} - -static char * -file_installed_or_local(const char *inst_dir, const char *name) { - assert(run_dir); - - struct stat sb; - int buflen = strlen(inst_dir) + strlen(run_dir) + strlen(name) + 1; - char *buf = (char *) malloc (buflen); - - snprintf(buf, buflen, "%s/%s", inst_dir, name); - if (stat(buf, &sb) == 0) - return buf; - - snprintf(buf, buflen, "%s/../%s", run_dir, name); - if (stat(buf, &sb) == 0) - return buf; - - free(buf); - return NULL; -} - -void set_values() { - double k0 = 0.0, k1 = 0.0, x0 = 0.0; - - s_center->value(gipf->get_center_angle()); - s_nick->value(gipf->get_nick_angle()); - s_focal_length->value(gipf->get_focal_length_35mm()); - s_tilt->value(gipf->get_tilt_angle()); - s_height_dist->value(gipf->get_height_dist_ratio()); - i_view_lat->value(gipf->get_view_lat()); - i_view_long->value(gipf->get_view_long()); - i_view_height->value(gipf->get_view_height()); - b_viewpoint->label(gipf->get_viewpoint()); - if (gipf->projection() == ProjectionLSQ::RECTILINEAR) { - mb->mode(9, FL_MENU_RADIO|FL_MENU_VALUE); - mb->mode(10, FL_MENU_RADIO); - } else { - mb->mode(10, FL_MENU_RADIO|FL_MENU_VALUE); - mb->mode(9, FL_MENU_RADIO); - } - - gipf->get_distortion_params(&k0, &k1, &x0); - i_distortion_k0->value(k0); - i_distortion_k1->value(k1); - i_distortion_x0->value(x0); -} - -void quit_cb() { - if (Fl::event() == FL_SHORTCUT && Fl::event_key() == FL_Escape) - return; // ignore Escape - exit(0); -} - -void open_cb() { - char *file = fl_file_chooser("Open File?", "*.jpg", img_file); - if (file) { - gipf->load_image(file); - scroll->position(0, 0); - view_win->label(file); - view_win->redraw(); - control_win->label(file); - set_values(); - if (img_file) - free(img_file); - img_file = strdup(file); - } -} - -void track_cb() { - char *file = fl_file_chooser("Track File?", NULL, NULL); - if (file && gipf->load_track(file) == 0) - s_track_width->activate(); -} - -void save_cb() { - char *file = fl_file_chooser("Save Image As?", NULL, img_file); - if (file && confirm_overwrite(file)) - if (gipf->save_image(file)) - fl_message("ERROR: Saving image %s failed.", file); -} - -void dump_cb(Fl_Widget * o, void*) { - fl_cursor(FL_CURSOR_WAIT); - ScreenDump dmp(gipf); // needs to be done before fl_file_chooser() - fl_cursor(FL_CURSOR_DEFAULT); - char *file = fl_file_chooser("Save Screen Dump As?", "*.jpg", NULL); - if (file && confirm_overwrite(file)) { - JPEGOutputImage out(file, 95); - if (dmp.save(&out)) - fl_message("ERROR: Saving image %s failed.", file); - } -} - -void focal_length_cb(Fl_Slider* o, void*) { - gipf->set_focal_length_35mm(o->value()); -} - -void angle_cb(Fl_Slider* o, void*) { - gipf->set_center_angle(o->value()); -} - -void nick_cb(Fl_Slider* o, void*) { - gipf->set_nick_angle(o->value()); -} - -void tilt_cb(Fl_Slider* o, void*) { - gipf->set_tilt_angle(o->value()); -} - -void h_d_cb(Fl_Slider* o, void*) { - gipf->set_height_dist_ratio(o->value()); -} - -void view_lat_cb(Fl_Value_Input* o, void*) { - gipf->set_view_lat(o->value()); -} - -void view_long_cb(Fl_Value_Input* o, void*) { - gipf->set_view_long(o->value()); -} - -void view_height_cb(Fl_Value_Input* o, void*) { - gipf->set_view_height(o->value()); -} - -void track_width_cb(Fl_Value_Input* o, void*) { - gipf->set_track_width(o->value()); -} - -void viewpoint_cb(Fl_Value_Input* o, void*) { - Hill *m = choose_hill(gipf->get_mountains(), "Choose Viewpoint"); - if (m) { - gipf->set_viewpoint(m); - set_values(); - } -} - -void proj_cb(Fl_Value_Input* o, void*d) { - if (d) - gipf->projection(ProjectionLSQ::CYLINDRICAL); - else - gipf->projection(ProjectionLSQ::RECTILINEAR); -} - -void hidden_cb(Fl_Menu_* o, void*d) { - gipf->set_show_hidden(o->mvalue()->value() != 0); -} - -void save_distortion_cb(Fl_Widget *, void *) { - char buf[1024]; - const char * prof_name; - double k0, k1, x0; - - buf[0] = '\0'; - gipf->get_distortion_params(&k0, &k1, &x0); - - gipf->get_distortion_profile_name(buf, sizeof(buf)); - prof_name = fl_input("Save Distortion Profile (k0=%f, k1=%f, x0=%f)", - buf, k0, k1, x0); - - if (prof_name == NULL) - return; - - if (gipf->save_distortion_params(prof_name, 0) != 0) { - if (fl_choice("A profile with this name exists.\n", - "Cancel", "Overwrite", NULL) == 1) - gipf->save_distortion_params(prof_name, 1); - } - set_values(); -} - -void load_distortion_cb(Fl_Widget *, void *) { - char buf[1024]; - const char * prof_name; - - buf[0] = '\0'; - gipf->get_distortion_profile_name(buf, sizeof(buf)); - prof_name = fl_input("Load Distortion Profile", buf); - - if (prof_name == NULL) - return; - - if (gipf->load_distortion_params(prof_name) != 0) - fl_alert("Could not load profile %s.", prof_name); - else - set_values(); -} - -void distortion_cb(Fl_Value_Input*, void*) { - gipf->set_distortion_params( - i_distortion_k0->value(), - i_distortion_k1->value(), - i_distortion_x0->value()); -} - -void about_cb() { - fl_message("gipfel -- Photogrammetry for Mountain Images.\n" - "Version %s\n\n" - "(c) Johannes Hofmann 2006-2023\n\n" - "Homepage: http://flpsed.org/gipfel.html\n\n" - "Default datafile from http://www.viewfinderpanoramas.org/ and\n" - "http://www.alpin-koordinaten.de\n", - VERSION); - -} - -void readme_cb() { - char *readme = file_installed_or_local(DOCDIR, "README"); - if (!readme) { - fprintf(stderr, "README file not found\n"); - return; - } - Fl_Window *win = new Fl_Window(800, 600, "README"); - Fl_Text_Buffer *textBuf = new Fl_Text_Buffer(); - Fl_Text_Display *textDisp = new Fl_Text_Display(0, 0, win->w(), win->h()); - - textDisp->textfont(FL_COURIER); - textDisp->buffer(textBuf); - win->resizable(textDisp); - textBuf->appendfile(readme); - free(readme); - win->end(); - win->show(); -} - -void fill_menubar(Fl_Menu_Bar* mb) { - mb->add("&File/L&oad Image", FL_CTRL+'o', (Fl_Callback*)open_cb); - mb->add("&File/&Save Image", FL_CTRL+'s', (Fl_Callback*)save_cb); - mb->add("&File/Choose &Viewpoint", FL_CTRL+'v', (Fl_Callback*)viewpoint_cb); - mb->add("&File/Load &Track", FL_CTRL+'t', (Fl_Callback*)track_cb); - mb->add("&File/Screen &Dump", FL_CTRL+'d', (Fl_Callback*)dump_cb); - mb->add("&File/&Quit", FL_CTRL+'q', (Fl_Callback*)quit_cb); - - mb->add("&Projection/Normal Projection", 0, (Fl_Callback *)proj_cb, - (void *)0, FL_MENU_RADIO|FL_MENU_VALUE); - mb->add("&Projection/Panoramic Projection", 0, (Fl_Callback *)proj_cb, - (void *)1, FL_MENU_RADIO); - - mb->add("&Distortion/Load Profile", 0, (Fl_Callback *)load_distortion_cb); - mb->add("&Distortion/Save Profile", 0, (Fl_Callback *)save_distortion_cb); - - mb->add("&Option/Show Hidden", 0, (Fl_Callback *) hidden_cb, - (void *)0, FL_MENU_TOGGLE); - - mb->add("&Help/Readme", 0, (Fl_Callback*)readme_cb); - mb->add("&Help/About", 0, (Fl_Callback*)about_cb); -} - -void usage() { - fprintf(stderr, - "usage: gipfel [-v ] [-d ]\n" - " [-s] [-j ] [-t ] [-h ]\n" - " [-e ] [-E] [-p]\n" - " []\n" - " -v Set point from which the picture was taken.\n" - " This must be a string that unambiguously \n" - " matches the name of an entry in the data file.\n" - " -d Use for GPS data.\n" - " -V Set initial visibility.\n" - " -u , Use distortion correction values k0,k1.\n" - " -s Stitch mode.\n" - " -4 Create 16bit output (only with TIFF stitching).\n" - " -r , Stitch range in degrees (e.g. 100.0,200.0).\n" - " -b Use bicubic interpolation for stitching.\n" - " -w Width of result image.\n" - " -h Height of result image.\n" - " -j JPEG output file in Stitch mode.\n" - " -t TIFF output file in Stitch mode.\n" - " -p Export position of image to stdout.\n" - " -e Export positions of hills from on image.\n" - " -E Export hills from default data file.\n" - " JPEG file(s) to use.\n"); -} - -Fl_Window * -create_control_window() { - Fl_Window *win = new Fl_Window(400,400); - mb = new Fl_Menu_Bar(0, 0, 400, 30); - fill_menubar(mb); - - s_center = new Fl_Value_Dial(40, 60, 150, 150, NULL); - s_center->type(FL_LINE_DIAL); - s_center->labelsize(10); - s_center->step(0.01); - s_center->bounds(0.0, 360.0); - s_center->angles(180, 540); - s_center->callback((Fl_Callback*)angle_cb); - - win->add(new Fl_Box(95, 40, 40, 20, "North")); - win->add(new Fl_Box(95, 210, 40, 20, "South")); - win->add(new Fl_Box(190, 125, 40, 20, "East")); - win->add(new Fl_Box(0, 125, 40, 20, "West")); - - s_focal_length = new Fl_Value_Slider(235, 60, 160, 15, "Focal Length in 35mm"); - s_focal_length->type(1); - s_focal_length->box(FL_THIN_DOWN_BOX); - s_focal_length->labelsize(10); - s_focal_length->step(0.01); - s_focal_length->bounds(1.0, 300.0); - s_focal_length->slider(FL_UP_BOX); - s_focal_length->callback((Fl_Callback*)focal_length_cb); - s_focal_length->align(FL_ALIGN_TOP); - - s_nick = new Fl_Value_Slider(235, 90, 160, 15, "Nick (deg.)"); - s_nick->type(1); - s_nick->box(FL_THIN_DOWN_BOX); - s_nick->labelsize(10); - s_nick->step(0.01); - s_nick->bounds(-40.0, 20.0); - s_nick->slider(FL_UP_BOX); - s_nick->callback((Fl_Callback*)nick_cb); - s_nick->align(FL_ALIGN_TOP); - - s_tilt = new Fl_Value_Slider(235, 120, 160, 15, "Tilt (deg.)"); - s_tilt->type(1); - s_tilt->box(FL_THIN_DOWN_BOX); - s_tilt->labelsize(10); - s_tilt->step(0.01); - s_tilt->bounds(-10.0, 10.0); - s_tilt->slider(FL_UP_BOX); - s_tilt->callback((Fl_Callback*)tilt_cb); - s_tilt->align(FL_ALIGN_TOP); - - s_height_dist = new Fl_Value_Slider(235, 150, 160, 15, "Visibility"); - s_height_dist->type(1); - s_height_dist->box(FL_THIN_DOWN_BOX); - s_height_dist->labelsize(10); - s_height_dist->step(-0.001); - s_height_dist->bounds(0.1, 0.01); - s_height_dist->slider(FL_UP_BOX); - s_height_dist->callback((Fl_Callback*)h_d_cb); - s_height_dist->align(FL_ALIGN_TOP); - - s_track_width = new Fl_Value_Slider(235, 180, 160, 15, "Track Width"); - s_track_width->type(1); - s_track_width->box(FL_THIN_DOWN_BOX); - s_track_width->labelsize(10); - s_track_width->step(1.0); - s_track_width->bounds(1.0, 500.0); - s_track_width->value(200.0); - s_track_width->slider(FL_UP_BOX); - s_track_width->callback((Fl_Callback*)track_width_cb); - s_track_width->align(FL_ALIGN_TOP); - s_track_width->deactivate(); - - // Viewpoint Stuff - b_viewpoint = new Fl_Box(FL_DOWN_BOX, 30, 305, 300, 80, ""); - b_viewpoint->align(FL_ALIGN_TOP); - - i_view_lat = new Fl_Value_Input(40, 320, 100, 20, "Latitude"); - i_view_lat->labelsize(10); - i_view_lat->align(FL_ALIGN_TOP); - i_view_lat->when(FL_WHEN_ENTER_KEY); - i_view_lat->callback((Fl_Callback*)view_lat_cb); - - i_view_long = new Fl_Value_Input(200, 320, 100, 20, "Longitude"); - i_view_long->labelsize(10); - i_view_long->align(FL_ALIGN_TOP); - i_view_long->when(FL_WHEN_ENTER_KEY); - i_view_long->callback((Fl_Callback*)view_long_cb); - - i_view_height = new Fl_Value_Input(40, 360, 80, 20, "Height"); - i_view_height->labelsize(10); - i_view_height->align(FL_ALIGN_TOP); - i_view_height->when(FL_WHEN_ENTER_KEY); - i_view_height->callback((Fl_Callback*)view_height_cb); - - i_distortion_k0 = new Fl_Value_Input(250, 200, 80, 20, "k0"); - i_distortion_k0->labelsize(10); - i_distortion_k0->textsize(10); - i_distortion_k0->align(FL_ALIGN_LEFT); - i_distortion_k0->when(FL_WHEN_ENTER_KEY); - i_distortion_k0->callback((Fl_Callback*)distortion_cb); - - i_distortion_k1 = new Fl_Value_Input(250, 225, 80, 20, "k1"); - i_distortion_k1->labelsize(10); - i_distortion_k1->textsize(10); - i_distortion_k1->align(FL_ALIGN_LEFT); - i_distortion_k1->when(FL_WHEN_ENTER_KEY); - i_distortion_k1->callback((Fl_Callback*)distortion_cb); - - i_distortion_x0 = new Fl_Value_Input(250, 250, 80, 20, "x0"); - i_distortion_x0->labelsize(10); - i_distortion_x0->textsize(10); - i_distortion_x0->align(FL_ALIGN_LEFT); - i_distortion_x0->when(FL_WHEN_ENTER_KEY); - i_distortion_x0->callback((Fl_Callback*)distortion_cb); - - win->end(); - return win; -} - -int main(int argc, char** argv) { - char c, **my_argv; - char *view_point = NULL; - int err, my_argc, sx, sy, sw, sh; - int stitch_flag = 0, stitch_w = 2000, stitch_h = 500; - int jpeg_flag = 0, tiff_flag = 0, distortion_flag = 0, position_flag = 0; - int export_flag = 0; - int bicubic_flag = 0, b_16_flag = 0; - double stitch_from = 0.0, stitch_to = 380.0; - double dist_k0 = 0.0, dist_k1 = 0.0, dist_x0 = 0.0; - double visibility = 0.07; - const char *outpath = "/tmp"; - const char *export_file = NULL; - - err = 0; - while ((c = getopt(argc, argv, ":?d:v:sw:h:j:t:u:br:4e:V:pE")) != EOF) { - switch (c) { - case '?': - usage(); - exit(0); - break; - case 'd': - data_file = optarg; - break; - case 'e': - export_flag++; - export_file = optarg; - break; - case 'E': - export_flag++; - break; - case 'v': - view_point = optarg; - break; - case 'V': - visibility = atof(optarg); - break; - case 's': - stitch_flag++; - break; - case 'p': - position_flag++; - break; - case '4': - b_16_flag++; - break; - case 'r': - stitch_flag++; - if (optarg && strcmp(optarg, ":")) { - stitch_from = atof(optarg); - if (strchr(optarg, ',')) - stitch_to = atof(strchr(optarg, ',') + 1); - } - break; - case 'u': - char *c; - distortion_flag++; - if (optarg && strcmp(optarg, ":")) { - dist_k0 = atof(optarg); - c = strchr(optarg, ','); - if (c) { - dist_k1 = atof(strchr(optarg, ',') + 1); - c = strchr(c + 1, ','); - if (c) - dist_x0 = atof(strchr(optarg, ',') + 1); - } - } - break; - case 'j': - jpeg_flag++; - outpath = optarg; - break; - case 't': - tiff_flag++; - outpath = optarg; - break; - case 'w': - stitch_w = atoi(optarg); - break; - case 'h': - stitch_h = atoi(optarg); - break; - case 'b': - bicubic_flag++; - break; - default: - err++; - } - } - - my_argc = argc - optind; - my_argv = argv + optind; - - char *exec_file = strdup(argv[0]); - run_dir = strdup(dirname(exec_file)); - free(exec_file); - - if (my_argc >= 1) - img_file = strdup(my_argv[0]); - - if (data_file == NULL) - data_file = file_installed_or_local(GIPFEL_DATADIR, "gipfel.dat"); - - if (data_file == NULL || err) { - usage(); - exit(1); - } - - if (stitch_flag) { - int type = 0; - if (jpeg_flag) { - type = STITCH_JPEG; - } else if (tiff_flag) { - type = STITCH_TIFF; - } else { - type = STITCH_PREVIEW; - } - - return stitch(bicubic_flag ? ScanImage::BICUBIC : ScanImage::NEAREST, - b_16_flag, - stitch_w, stitch_h, stitch_from, stitch_to, - type, outpath, my_argc, my_argv); - - } else if (export_flag) { - return export_hills(export_file, visibility); - } else if (position_flag) { - return export_position(); - } - - Fl::get_system_colors(); - if (getenv("FLTK_SCHEME")) - Fl::scheme(NULL); - else - Fl::scheme("plastic"); - - control_win = create_control_window(); - control_win->callback((Fl_Callback*) quit_cb); - - view_win = new Fl_Window(800, 600); - view_win->callback((Fl_Callback*) quit_cb); - - // The Fl_Group is used to avoid FL_DAMAGE_ALL in Fl_Scroll::position - Fl_Group *g = new Fl_Group(0, 0, view_win->w(), view_win->h()); - view_win->resizable(g); - scroll = new Fl_Scroll(0, 0, view_win->w(), view_win->h()); - - gipf = new GipfelWidget(0, 0, 800, 600, set_values); - if (img_file) { - gipf->load_image(img_file); - view_win->label(img_file); - control_win->label(img_file); - } - - if (distortion_flag) - gipf->set_distortion_params(dist_k0, dist_k1, dist_x0); - - Fl::screen_xywh(sx, sy, sw, sh); - view_win->size(std::min(gipf->w(), sw), std::min(gipf->h(), sh)); - scroll->size(view_win->w(), view_win->h()); - - gipf->load_data(data_file); - gipf->set_height_dist_ratio(visibility); - - scroll->end(); - - set_values(); - - view_win->resizable(scroll); - - view_win->end(); - view_win->show(1, argv); - control_win->show(1, argv); - - if (view_point) - gipf->set_viewpoint(view_point); - else if (img_file && - (isnan(gipf->get_view_lat()) || isnan(gipf->get_view_long()))) - viewpoint_cb(NULL, NULL); - - return Fl::run(); -} - -static int -stitch(ScanImage::mode_t m, int b_16, - int stitch_w, int stitch_h, double from, double to, - int type, const char *path, int argc, char **argv) { - - Fl_Window *win; - Fl_Scroll *scroll; - Stitch *st = new Stitch(); - - for (int i = 0; i < argc; i++) - st->load_image(argv[i]); - - if (type & STITCH_JPEG) { - - st->set_output(new JPEGOutputImage(path, 90)); - st->resample(m, stitch_w, stitch_h, from, to); - - } else if (type & STITCH_TIFF) { - - st->set_output(new TIFFOutputImage(path, b_16 ? 16 : 8)); - st->resample(m, stitch_w, stitch_h, from, to); - - } else { - win = new Fl_Window(0,0, stitch_w, stitch_h); - scroll = new Fl_Scroll(0, 0, win->w(), win->h()); - PreviewOutputImage *img = - new PreviewOutputImage(0, 0, stitch_w, stitch_h); - - win->resizable(scroll); - win->show(0, argv); - st->set_output(img); - - st->resample(m, stitch_w, stitch_h, from, to); - - img->redraw(); - Fl::run(); - } - - return 0; -} - -static int -export_hills(const char *export_file, double visibility) { - int ret; - - if (!img_file) { - fprintf(stderr, "export: No image file given.\n"); - return 1; - } - - gipf = new GipfelWidget(0,0,800,600, NULL); - gipf->load_image(img_file); - gipf->load_data(data_file); - gipf->set_height_dist_ratio(visibility); - ret = gipf->export_hills(export_file, stdout); - delete gipf; - gipf = NULL; - - return ret; -} - -static int -export_position() { - ImageMetaData md; - - if (!img_file) { - fprintf(stderr, "export: No image file given.\n"); - return 1; - } - - if (md.load_image(img_file) == 0) { - printf(",%s,,%f,%f,%d\n", img_file, - md.latitude(), - md.longitude(), - (int) rint(md.height())); - - return 0; - } else { - return 1; - } -} diff --git a/src/lsq_cylindrical.mac b/src/lsq_cylindrical.mac deleted file mode 100644 index ab706f5..0000000 --- a/src/lsq_cylindrical.mac +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2006-2009 Johannes Hofmann - */ - -/* - * cylindrical projection model - */ - -x : m_view - c_view$ -y : tan(c_nick - m_nick)$ -x_rot : y * sin(c_tilt) + x * cos(c_tilt)$ -y_rot : y * cos(c_tilt) - x * sin(c_tilt)$ -x_scale : x_rot * scale$ -y_scale : y_rot * scale$ - -/* - * Some mangling for C code generation - */ - -load("expr2c.mac")$ - -x_expand : trigexpand(x_scale)$ -y_expand : trigexpand(y_scale)$ - -args: "double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick"$ - -expr2c("ProjectionCylindrical::mac_x", args, x_expand)$ -expr2c("ProjectionCylindrical::mac_y", args, y_expand)$ - -expr2c("ProjectionCylindrical::mac_x_dc_view", args, diff(x_expand, c_view))$ -expr2c("ProjectionCylindrical::mac_x_dc_nick", args, diff(x_expand, c_nick))$ -expr2c("ProjectionCylindrical::mac_x_dc_tilt", args, diff(x_expand, c_tilt))$ -expr2c("ProjectionCylindrical::mac_x_dscale", args, diff(x_expand, scale))$ -expr2c("ProjectionCylindrical::mac_y_dc_view", args, diff(y_expand, c_view))$ -expr2c("ProjectionCylindrical::mac_y_dc_nick", args, diff(y_expand, c_nick))$ -expr2c("ProjectionCylindrical::mac_y_dc_tilt", args, diff(y_expand, c_tilt))$ -expr2c("ProjectionCylindrical::mac_y_dscale", args, diff(y_expand, scale))$ - diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac deleted file mode 100644 index 95ed273..0000000 --- a/src/lsq_rectilinear.mac +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2006-2009 Johannes Hofmann - */ - -/* - * rectilinear (pinhole) projection model with distortion correction - */ - -/* switch to cartesian coordinates */ -c_x : cos(m_nick) * cos(m_view - c_view)$ -c_y : cos(m_nick) * sin(m_view - c_view)$ -c_z : sin(m_nick)$ - -/* nick rotation */ -c_x_rot : cos(c_nick) * c_x + sin(c_nick) * c_z$ -c_y_rot : c_y$ -c_z_rot : -sin(c_nick) * c_x + cos(c_nick) * c_z$ - -/* pinhole projection */ -x : c_y_rot / c_x_rot$ -y : -c_z_rot / c_x_rot$ - -/* rotation around view axis */ -x_rot : y * sin(c_tilt) + x * cos(c_tilt) + x0$ -y_rot : y * cos(c_tilt) - x * sin(c_tilt)$ - -/* distortion correction */ -d : sqrt(x_rot ^ 2 + y_rot ^ 2)$ -dist_fact : d ^ 2 * k1 + d * k0$ -x_dist : x_rot * (1 + dist_fact) * scale$ -y_dist : y_rot * (1 + dist_fact) * scale$ - -/* - * Some mangling for C code generation - */ - -load("expr2c.mac")$ - -x_expand : trigexpand(x_dist)$ -y_expand : trigexpand(y_dist)$ - -args: "double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick"$ - -expr2c("ProjectionRectilinear::mac_x", args, x_expand)$ -expr2c("ProjectionRectilinear::mac_y", args, y_expand)$ - -expr2c("ProjectionRectilinear::mac_x_dc_view", args, diff(x_expand, c_view))$ -expr2c("ProjectionRectilinear::mac_x_dc_nick", args, diff(x_expand, c_nick))$ -expr2c("ProjectionRectilinear::mac_x_dc_tilt", args, diff(x_expand, c_tilt))$ -expr2c("ProjectionRectilinear::mac_x_dscale", args, diff(x_expand, scale))$ -expr2c("ProjectionRectilinear::mac_x_dk0", args, diff(x_expand, k0))$ -expr2c("ProjectionRectilinear::mac_x_dk1", args, diff(x_expand, k1))$ -expr2c("ProjectionRectilinear::mac_x_dx0", args, diff(x_expand, x0))$ -expr2c("ProjectionRectilinear::mac_y_dc_view", args, diff(y_expand, c_view))$ -expr2c("ProjectionRectilinear::mac_y_dc_nick", args, diff(y_expand, c_nick))$ -expr2c("ProjectionRectilinear::mac_y_dc_tilt", args, diff(y_expand, c_tilt))$ -expr2c("ProjectionRectilinear::mac_y_dscale", args, diff(y_expand, scale))$ -expr2c("ProjectionRectilinear::mac_y_dk0", args, diff(y_expand, k0))$ -expr2c("ProjectionRectilinear::mac_y_dk1", args, diff(y_expand, k1))$ -expr2c("ProjectionRectilinear::mac_y_dx0", args, diff(y_expand, x0))$ diff --git a/src/strsep.c b/src/strsep.c deleted file mode 100644 index c8e4be0..0000000 --- a/src/strsep.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 1992, 93, 96, 97, 98, 99, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include "../config.h" - -#ifndef HAVE_STRSEP - -#include "string.h" - -char * -strsep (char **stringp, const char *delim) -{ - char *begin, *end; - - begin = *stringp; - if (begin == NULL) - return NULL; - - /* A frequent case is when the delimiter string contains only one - character. Here we don't need to call the expensive `strpbrk' - function and instead work using `strchr'. */ - if (delim[0] == '\0' || delim[1] == '\0') - { - char ch = delim[0]; - - if (ch == '\0') - end = NULL; - else - { - if (*begin == ch) - end = begin; - else if (*begin == '\0') - end = NULL; - else - end = strchr (begin + 1, ch); - } - } - else - /* Find the end of the token. */ - end = strpbrk (begin, delim); - - if (end) - { - /* Terminate the token and set *STRINGP past NUL character. */ - *end++ = '\0'; - *stringp = end; - } - else - /* No more delimiters; this is the last token. */ - *stringp = NULL; - - return begin; -} - -#endif diff --git a/src/strsep.h b/src/strsep.h deleted file mode 100644 index 28295ba..0000000 --- a/src/strsep.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2008 Johannes Hofmann - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - */ - -#include "../config.h" - -#ifndef HAVE_STRSEP -char * strsep (char **stringp, const char *delim); -#endif -- cgit v1.2.3