From 0e52247373acad9572440624c41846efd3a573d1 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 27 Oct 2006 22:18:48 +0200 Subject: add initial ImageMetaData classes --- src/EXIFImageMetaData.H | 46 ++++++++++++++++++++ src/ImageMetaData.H | 56 ++++++++++++++++++++++++ src/ImageMetaData.cxx | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 212 insertions(+) create mode 100644 src/EXIFImageMetaData.H create mode 100644 src/ImageMetaData.H create mode 100644 src/ImageMetaData.cxx diff --git a/src/EXIFImageMetaData.H b/src/EXIFImageMetaData.H new file mode 100644 index 0000000..b959dd3 --- /dev/null +++ b/src/EXIFImageMetaData.H @@ -0,0 +1,46 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This 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 +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#ifndef EXIF_IMAGE_META_DATA_H +#define EXIF_IMAGE_META_DATA_H + +class ExifImageMetaData { + ExifImageMetaData(); + + virtual int load_image(const char *name); + + virtual double get_longitude(); + virtual double get_latitude(); + virtual double get_height(); + virtual double get_direction(); + virtual double get_nick(); + virtual double get_tilt(); + virtual double get_focallength_sensor_ratio(); + virtual int get_projection_type(); + + virtual void set_longitude(double v); + virtual void set_latitude(double v); + virtual void set_height(double v); + virtual void set_direction(double v); + virtual void set_nick(double v); + virtual void set_tilt(double v); + virtual void set_focallength_sensor_ratio(double v); + virtual int set_projection_type(int v); +}; +#endif diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H new file mode 100644 index 0000000..79495f4 --- /dev/null +++ b/src/ImageMetaData.H @@ -0,0 +1,56 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This 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 +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#ifndef IMAGE_META_DATA_H +#define IMAGE_META_DATA_H + +class ImageMetaData { + protected: + double longitude; + double latitude; + double height; + double direction; + double nick; + double tilt; + double focallength_sensor_ratio; + int projection_type; + + public: + virtual int load_image(const char *name); + virtual int save_image(const char *name); + + double get_longitude(); + double get_latitude(); + double get_height(); + double get_direction(); + double get_nick(); + double get_tilt(); + double get_focallength_sensor_ratio(); + int get_projection_type(); + + void set_longitude(double v); + void set_latitude(double v); + void set_height(double v); + void set_direction(double v); + void set_nick(double v); + void set_tilt(double v); + void set_focallength_sensor_ratio(double v); + int set_projection_type(int v); +}; +#endif diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx new file mode 100644 index 0000000..0c868bd --- /dev/null +++ b/src/ImageMetaData.cxx @@ -0,0 +1,110 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This 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 +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#include +#include + +#include "ImageMetaData.H" + +ImageMetaData::ImageMetaData() { + longitude = NAN; + latitude = NAN; + height = NAN; + direction = NAN; + nick = NAN; + tilt = NAN; + focallength_sensor_ratio = NAN; + projection_type = -1; +} + + +double +ImageMetaData::get_longitude() { + return longitude; +} + +double +ImageMetaData::get_latitude() { + return latitude; +} + +double +ImageMetaData::get_height() { + return height; +} + +double +ImageMetaData::get_direction() { + return direction; +} + +double +ImageMetaData::get_nick() { + return nick; +} + +double +ImageMetaData::get_tilt() { + return tilt; +} + +double +ImageMetaData::get_focallength_sensor_ratio() { + return focallength_sensor_ratio; +} + + +void +ImageMetaData::set_longitude(double v) { + longitude = v; +} + +void +ImageMetaData::set_latitude(double v) { + latitude = v; +} + +void +ImageMetaData::set_height(double v) { + height = v; +} + +void +ImageMetaData::set_direction(double v) { + direction = v; +} + +void +ImageMetaData::set_nick(double v) { + nick = v; +} + +void +ImageMetaData::set_tilt(double v) { + tilt = v; +} + +void +ImageMetaData::set_focallength_sensor_ratio(double v) { + focallength_sensor_ratio = v; +} + +int ImageMetaData::set_projection_type(int v) { + projection_type = v; +} -- cgit v1.2.3 From 73e4398748f71c7254ae0971622e3ba085f6b90e Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 27 Oct 2006 22:22:33 +0200 Subject: update ImageMetaData files --- src/EXIFImageMetaData.H | 46 ---------------------------------------------- src/ExifImageMetaData.H | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/JpgcomImageMetaData.H | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 6 ++++++ 4 files changed, 99 insertions(+), 46 deletions(-) delete mode 100644 src/EXIFImageMetaData.H create mode 100644 src/ExifImageMetaData.H create mode 100644 src/JpgcomImageMetaData.H diff --git a/src/EXIFImageMetaData.H b/src/EXIFImageMetaData.H deleted file mode 100644 index b959dd3..0000000 --- a/src/EXIFImageMetaData.H +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// - -#ifndef EXIF_IMAGE_META_DATA_H -#define EXIF_IMAGE_META_DATA_H - -class ExifImageMetaData { - ExifImageMetaData(); - - virtual int load_image(const char *name); - - virtual double get_longitude(); - virtual double get_latitude(); - virtual double get_height(); - virtual double get_direction(); - virtual double get_nick(); - virtual double get_tilt(); - virtual double get_focallength_sensor_ratio(); - virtual int get_projection_type(); - - virtual void set_longitude(double v); - virtual void set_latitude(double v); - virtual void set_height(double v); - virtual void set_direction(double v); - virtual void set_nick(double v); - virtual void set_tilt(double v); - virtual void set_focallength_sensor_ratio(double v); - virtual int set_projection_type(int v); -}; -#endif diff --git a/src/ExifImageMetaData.H b/src/ExifImageMetaData.H new file mode 100644 index 0000000..b959dd3 --- /dev/null +++ b/src/ExifImageMetaData.H @@ -0,0 +1,46 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This 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 +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#ifndef EXIF_IMAGE_META_DATA_H +#define EXIF_IMAGE_META_DATA_H + +class ExifImageMetaData { + ExifImageMetaData(); + + virtual int load_image(const char *name); + + virtual double get_longitude(); + virtual double get_latitude(); + virtual double get_height(); + virtual double get_direction(); + virtual double get_nick(); + virtual double get_tilt(); + virtual double get_focallength_sensor_ratio(); + virtual int get_projection_type(); + + virtual void set_longitude(double v); + virtual void set_latitude(double v); + virtual void set_height(double v); + virtual void set_direction(double v); + virtual void set_nick(double v); + virtual void set_tilt(double v); + virtual void set_focallength_sensor_ratio(double v); + virtual int set_projection_type(int v); +}; +#endif diff --git a/src/JpgcomImageMetaData.H b/src/JpgcomImageMetaData.H new file mode 100644 index 0000000..bb701b5 --- /dev/null +++ b/src/JpgcomImageMetaData.H @@ -0,0 +1,47 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This 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 +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#ifndef IMAGE_META_DATA_H +#define IMAGE_META_DATA_H + +class ImageMetaData { + ImageMetaData(); + + virtual int load_image(const char *name); + + virtual double get_longitude(); + virtual double get_latitude(); + virtual double get_height(); + virtual double get_direction(); + virtual double get_nick(); + virtual double get_tilt(); + virtual double get_focallength_sensor_ratio(); + virtual int get_projection_type(); + + virtual void set_longitude(double v); + virtual void set_latitude(double v); + virtual void set_height(double v); + virtual void set_direction(double v); + virtual void set_nick(double v); + virtual void set_tilt(double v); + virtual void set_focallength_sensor_ratio(double v); + virtual int set_projection_type(int v); + +}; +#endif diff --git a/src/Makefile.am b/src/Makefile.am index 5577090..4b54bc8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,6 +17,9 @@ gipfel_SOURCES = \ JPEGOutputImage.cxx \ TIFFOutputImage.cxx \ PreviewOutputImage.cxx + ImageMetaData.cxx \ + JpgcomImageMetaData.cxx \ + ExifImageMetaData.cxx noinst_HEADERS = \ GipfelWidget.H \ @@ -34,4 +37,7 @@ noinst_HEADERS = \ JPEGOutputImage.H \ TIFFOutputImage.H \ PreviewOutputImage.H \ + ImageMetaData.H \ + JpgcomImageMetaData.H \ + ExifImageMetaData.H \ util.h -- cgit v1.2.3 From 8e2ebc4de19e6956549413a599f6e27daa498303 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 27 Oct 2006 23:24:13 +0200 Subject: implement ImageMetaData classes --- src/ExifImageMetaData.H | 25 ++---------- src/ExifImageMetaData.cxx | 70 ++++++++++++++++++++++++++++++++++ src/ImageMetaData.H | 6 ++- src/JpgcomImageMetaData.H | 30 +++------------ src/JpgcomImageMetaData.cxx | 93 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 177 insertions(+), 47 deletions(-) create mode 100644 src/ExifImageMetaData.cxx create mode 100644 src/JpgcomImageMetaData.cxx diff --git a/src/ExifImageMetaData.H b/src/ExifImageMetaData.H index b959dd3..bc567ff 100644 --- a/src/ExifImageMetaData.H +++ b/src/ExifImageMetaData.H @@ -20,27 +20,10 @@ #ifndef EXIF_IMAGE_META_DATA_H #define EXIF_IMAGE_META_DATA_H -class ExifImageMetaData { - ExifImageMetaData(); +#include "ImageMetaData.H" - virtual int load_image(const char *name); - - virtual double get_longitude(); - virtual double get_latitude(); - virtual double get_height(); - virtual double get_direction(); - virtual double get_nick(); - virtual double get_tilt(); - virtual double get_focallength_sensor_ratio(); - virtual int get_projection_type(); - - virtual void set_longitude(double v); - virtual void set_latitude(double v); - virtual void set_height(double v); - virtual void set_direction(double v); - virtual void set_nick(double v); - virtual void set_tilt(double v); - virtual void set_focallength_sensor_ratio(double v); - virtual int set_projection_type(int v); +class ExifImageMetaData : ImageMetaData { + virtual int load_image(char *name); + virtual int save_image(char *name); }; #endif diff --git a/src/ExifImageMetaData.cxx b/src/ExifImageMetaData.cxx new file mode 100644 index 0000000..05a43d5 --- /dev/null +++ b/src/ExifImageMetaData.cxx @@ -0,0 +1,70 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This 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 +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#include +#include +#include + +#include "util.h" + +#include "ExifImageMetaData.H" + +#define FOCAL_LENGTH_IN_35MM_FILM 0xa405 + +int +ExifImageMetaData::load_image(char *name) { + char * args[32]; + FILE *p; + pid_t pid; + int status; + char buf[1024]; + char val[1024]; + int id; + + args[0] = "exif"; + args[1] = "-i"; + args[2] = "-m"; + args[3] = name; + args[4] = NULL; + + p = pexecvp(args[0], args, &pid, "r"); + + if (p) { + while (fgets(buf, sizeof(buf), p) != NULL) { + if (sscanf(buf, "%d\t%s", &id, val) != 2) { + continue; + } + + switch(id) { + case FOCAL_LENGTH_IN_35MM_FILM: + focallength_sensor_ratio = atof(val) / 35; + break; + } + } + } + + fclose(p); + waitpid(pid, &status, 0); + if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { + fprintf(stderr, "%s not found\n", args[0]); + } + + return 0; +} + diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H index 79495f4..3349cab 100644 --- a/src/ImageMetaData.H +++ b/src/ImageMetaData.H @@ -32,8 +32,10 @@ class ImageMetaData { int projection_type; public: - virtual int load_image(const char *name); - virtual int save_image(const char *name); + ImageMetaData(); + + virtual int load_image(char *name); + virtual int save_image(char *name); double get_longitude(); double get_latitude(); diff --git a/src/JpgcomImageMetaData.H b/src/JpgcomImageMetaData.H index bb701b5..3d063c6 100644 --- a/src/JpgcomImageMetaData.H +++ b/src/JpgcomImageMetaData.H @@ -17,31 +17,13 @@ // USA. // -#ifndef IMAGE_META_DATA_H -#define IMAGE_META_DATA_H +#ifndef JPGCOM_IMAGE_META_DATA_H +#define JPGCOM_IMAGE_META_DATA_H -class ImageMetaData { - ImageMetaData(); - - virtual int load_image(const char *name); - - virtual double get_longitude(); - virtual double get_latitude(); - virtual double get_height(); - virtual double get_direction(); - virtual double get_nick(); - virtual double get_tilt(); - virtual double get_focallength_sensor_ratio(); - virtual int get_projection_type(); - - virtual void set_longitude(double v); - virtual void set_latitude(double v); - virtual void set_height(double v); - virtual void set_direction(double v); - virtual void set_nick(double v); - virtual void set_tilt(double v); - virtual void set_focallength_sensor_ratio(double v); - virtual int set_projection_type(int v); +#include "ImageMetaData.H" +class JpgcomImageMetaData : ImageMetaData { + virtual int load_image(char *name); + virtual int save_image(char *name); }; #endif diff --git a/src/JpgcomImageMetaData.cxx b/src/JpgcomImageMetaData.cxx new file mode 100644 index 0000000..39fb2b8 --- /dev/null +++ b/src/JpgcomImageMetaData.cxx @@ -0,0 +1,93 @@ +// +// Copyright 2006 by Johannes Hofmann +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This 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 +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// + +#include +#include +#include + +#include "util.h" + +#include "JpgcomImageMetaData.H" + +#define GIPFEL_FORMAT_1 "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, scale %lf, projection type %d" +#define GIPFEL_FORMAT_2 "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, focallength_sensor_ratio %lf, projection type %d" + +int +JpgcomImageMetaData::load_image(char *name) { + char * args[32]; + FILE *p; + pid_t pid; + int status; + char buf[1024]; + double lo, la, he, dir, ni, ti, fr; + int pt; + int ret = 1; + + args[0] = "rdjpgcom"; + args[1] = name; + args[2] = NULL; + + p = pexecvp(args[0], args, &pid, "r"); + + if (p) { + while (fgets(buf, sizeof(buf), p) != NULL) { + if (sscanf(buf, GIPFEL_FORMAT_2, + &lo, &la, &he, &dir, &ni, &ti, &fr, &pt) >= 7) { + + longitude = lo; + latitude = la; + height = he; + direction = dir; + nick = ni; + tilt = ti; + focallength_sensor_ratio = fr; + projection_type = pt; + + ret = 0; + + break; + } else if (sscanf(buf, GIPFEL_FORMAT_1, + &lo, &la, &he, &dir, &ni, &ti, &fr, &pt) >= 7) { + + longitude = lo; + latitude = la; + height = he; + direction = dir; + nick = ni; + tilt = ti; + focallength_sensor_ratio = fr; + projection_type = pt; + + ret = 2; // special return value for compatibility with + // old format + + break; + } + } + + fclose(p); + waitpid(pid, &status, 0); + if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { + fprintf(stderr, "%s not found\n", args[0]); + } + } + + return ret; +} + -- cgit v1.2.3 From 3863aa643f604f17b79684093fd34e7a67b093fa Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 28 Oct 2006 00:03:29 +0200 Subject: fix ImageMetaData classes --- src/ExifImageMetaData.H | 2 +- src/ExifImageMetaData.cxx | 11 ++++++--- src/GipfelWidget.cxx | 58 ++++++++++++++++++++++----------------------- src/ImageMetaData.H | 2 +- src/ImageMetaData.cxx | 16 ++++++++++++- src/JpgcomImageMetaData.H | 2 +- src/JpgcomImageMetaData.cxx | 3 +++ src/Makefile.am | 2 +- 8 files changed, 58 insertions(+), 38 deletions(-) diff --git a/src/ExifImageMetaData.H b/src/ExifImageMetaData.H index bc567ff..dd17871 100644 --- a/src/ExifImageMetaData.H +++ b/src/ExifImageMetaData.H @@ -22,7 +22,7 @@ #include "ImageMetaData.H" -class ExifImageMetaData : ImageMetaData { +class ExifImageMetaData : public ImageMetaData { virtual int load_image(char *name); virtual int save_image(char *name); }; diff --git a/src/ExifImageMetaData.cxx b/src/ExifImageMetaData.cxx index 05a43d5..1ba215e 100644 --- a/src/ExifImageMetaData.cxx +++ b/src/ExifImageMetaData.cxx @@ -47,13 +47,13 @@ ExifImageMetaData::load_image(char *name) { if (p) { while (fgets(buf, sizeof(buf), p) != NULL) { - if (sscanf(buf, "%d\t%s", &id, val) != 2) { + if (sscanf(buf, "%x\t%s", &id, val) != 2) { continue; } - + switch(id) { case FOCAL_LENGTH_IN_35MM_FILM: - focallength_sensor_ratio = atof(val) / 35; + focallength_sensor_ratio = atof(val) / 35.0; break; } } @@ -68,3 +68,8 @@ ExifImageMetaData::load_image(char *name) { return 0; } + +int +ExifImageMetaData::save_image(char *name) { +} + diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 75451ec..8314222 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -35,6 +35,8 @@ #include #include +#include "ExifImageMetaData.H" +#include "JpgcomImageMetaData.H" #include "Fl_Search_Chooser.H" #include "choose_hill.H" #include "util.h" @@ -76,14 +78,9 @@ GipfelWidget::GipfelWidget(int X,int Y,int W, int H): Fl_Widget(X, Y, W, H) { int GipfelWidget::load_image(char *file) { - char * args[32]; - FILE *p; - pid_t pid; - char buf[1024]; - double lo, la, he, dir, ni, ti, sc; - int status; - Projection::Projection_t pt = Projection::TANGENTIAL; Fl_Image *new_img; + ImageMetaData *md; + int ret; new_img = new Fl_JPEG_Image(file); @@ -112,32 +109,33 @@ GipfelWidget::load_image(char *file) { mb->add("Center Peak", 0, (Fl_Callback*) center_cb, this); // try to retrieve gipfel data from JPEG comment section - args[0] = "rdjpgcom"; - args[1] = file; - args[2] = NULL; - - p = pexecvp(args[0], args, &pid, "r"); - if (p) { - while (fgets(buf, sizeof(buf), p) != NULL) { - if (sscanf(buf, GIPFEL_FORMAT, &lo, &la, &he, &dir, &ni, &ti, &sc, &pt) >= 7) { - set_view_long(lo); - set_view_lat(la); - set_view_height(he); - set_center_angle(dir); - set_nick_angle(ni); - set_tilt_angle(ti); - set_scale(sc); - set_projection(pt); - - break; - } + md = new JpgcomImageMetaData(); + ret = md->load_image(file); + if (ret != 1) { + set_view_long(md->get_longitude()); + set_view_lat(md->get_latitude()); + set_view_height(md->get_height()); + set_center_angle(md->get_direction()); + set_nick_angle(md->get_nick()); + set_tilt_angle(md->get_tilt()); + set_projection((Projection::Projection_t) md->get_projection_type()); + if (ret == 2) { // special compatibility return code for old format + set_scale(md->get_focallength_sensor_ratio()); + } else { + set_scale(md->get_focallength_sensor_ratio() * img->w()); } - fclose(p); - waitpid(pid, &status, 0); - if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { - fprintf(stderr, "%s not found\n", args[0]); + } + + delete md; + + if (ret == 1) { + md = new ExifImageMetaData(); + ret = md->load_image(file); + if (ret == 0) { + set_scale(md->get_focallength_sensor_ratio() * img->w()); } + delete md; } return 0; diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H index 3349cab..1318e10 100644 --- a/src/ImageMetaData.H +++ b/src/ImageMetaData.H @@ -53,6 +53,6 @@ class ImageMetaData { void set_nick(double v); void set_tilt(double v); void set_focallength_sensor_ratio(double v); - int set_projection_type(int v); + void set_projection_type(int v); }; #endif diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx index 0c868bd..745529b 100644 --- a/src/ImageMetaData.cxx +++ b/src/ImageMetaData.cxx @@ -33,6 +33,15 @@ ImageMetaData::ImageMetaData() { projection_type = -1; } +int +ImageMetaData::load_image(char *name) { + return 1; +} + +int +ImageMetaData::save_image(char *name) { + return 1; +} double ImageMetaData::get_longitude() { @@ -69,6 +78,10 @@ ImageMetaData::get_focallength_sensor_ratio() { return focallength_sensor_ratio; } +int +ImageMetaData::get_projection_type() { + return projection_type; +} void ImageMetaData::set_longitude(double v) { @@ -105,6 +118,7 @@ ImageMetaData::set_focallength_sensor_ratio(double v) { focallength_sensor_ratio = v; } -int ImageMetaData::set_projection_type(int v) { +void +ImageMetaData::set_projection_type(int v) { projection_type = v; } diff --git a/src/JpgcomImageMetaData.H b/src/JpgcomImageMetaData.H index 3d063c6..70e266e 100644 --- a/src/JpgcomImageMetaData.H +++ b/src/JpgcomImageMetaData.H @@ -22,7 +22,7 @@ #include "ImageMetaData.H" -class JpgcomImageMetaData : ImageMetaData { +class JpgcomImageMetaData : public ImageMetaData { virtual int load_image(char *name); virtual int save_image(char *name); }; diff --git a/src/JpgcomImageMetaData.cxx b/src/JpgcomImageMetaData.cxx index 39fb2b8..8dcd54e 100644 --- a/src/JpgcomImageMetaData.cxx +++ b/src/JpgcomImageMetaData.cxx @@ -91,3 +91,6 @@ JpgcomImageMetaData::load_image(char *name) { return ret; } +int +JpgcomImageMetaData::save_image(char *name) { +} diff --git a/src/Makefile.am b/src/Makefile.am index 4b54bc8..a730123 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,7 +16,7 @@ gipfel_SOURCES = \ OutputImage.cxx \ JPEGOutputImage.cxx \ TIFFOutputImage.cxx \ - PreviewOutputImage.cxx + PreviewOutputImage.cxx \ ImageMetaData.cxx \ JpgcomImageMetaData.cxx \ ExifImageMetaData.cxx -- cgit v1.2.3 From 20286c5a434580d38dc0a85981503d6310b9e55a Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 28 Oct 2006 00:36:32 +0200 Subject: move Jpeg header writing to JpgcomImageMetaData class update NEWS --- NEWS | 7 ++++ src/ExifImageMetaData.H | 2 +- src/ExifImageMetaData.cxx | 3 +- src/GipfelWidget.cxx | 82 +++++++++------------------------------------ src/ImageMetaData.H | 2 +- src/ImageMetaData.cxx | 2 +- src/JpgcomImageMetaData.H | 2 +- src/JpgcomImageMetaData.cxx | 69 +++++++++++++++++++++++++++++++++++++- 8 files changed, 96 insertions(+), 73 deletions(-) diff --git a/NEWS b/NEWS index 7a4cfa5..e672b42 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,12 @@ gipfel ChangeLog ================= +gipfel-0.2.0 + - Change orientation format in jpeg header to make it independent + of the image size. One can now scale an already oriented image + without invalidating the orientation information. + - gipfel now tries to find a reasonable default for the scale value + when opening new images based on the "Focal Length In 35mm" Exif + tag, if it exists. gipfel-0.1.3 - Add stitching mode (gipfel -s). See README for details. diff --git a/src/ExifImageMetaData.H b/src/ExifImageMetaData.H index dd17871..f864b0f 100644 --- a/src/ExifImageMetaData.H +++ b/src/ExifImageMetaData.H @@ -24,6 +24,6 @@ class ExifImageMetaData : public ImageMetaData { virtual int load_image(char *name); - virtual int save_image(char *name); + virtual int save_image(char *in_img, char *out_img); }; #endif diff --git a/src/ExifImageMetaData.cxx b/src/ExifImageMetaData.cxx index 1ba215e..0de7478 100644 --- a/src/ExifImageMetaData.cxx +++ b/src/ExifImageMetaData.cxx @@ -70,6 +70,7 @@ ExifImageMetaData::load_image(char *name) { int -ExifImageMetaData::save_image(char *name) { +ExifImageMetaData::save_image(char *in_img, char *out_img) { + return 1; } diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 8314222..33a3987 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -39,7 +39,6 @@ #include "JpgcomImageMetaData.H" #include "Fl_Search_Chooser.H" #include "choose_hill.H" -#include "util.h" #include "GipfelWidget.H" #define CROSS_SIZE 2 @@ -74,8 +73,6 @@ GipfelWidget::GipfelWidget(int X,int Y,int W, int H): Fl_Widget(X, Y, W, H) { fl_register_images(); } -#define GIPFEL_FORMAT "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, scale %lf, projection type %d" - int GipfelWidget::load_image(char *file) { Fl_Image *new_img; @@ -108,8 +105,7 @@ GipfelWidget::load_image(char *file) { mb->box(FL_NO_BOX); mb->add("Center Peak", 0, (Fl_Callback*) center_cb, this); -// try to retrieve gipfel data from JPEG comment section - + // try to retrieve gipfel data from JPEG comment section md = new JpgcomImageMetaData(); ret = md->load_image(file); if (ret != 1) { @@ -148,79 +144,31 @@ GipfelWidget::get_image_filename() { int GipfelWidget::save_image(char *file) { - char * args[32]; - FILE *p, *out; - pid_t pid; - char buf[1024]; - int status; - size_t n; - struct stat in_stat, out_stat; + ImageMetaData *md; + int ret; if (img_file == NULL) { fprintf(stderr, "Nothing to save\n"); return 1; } - if (stat(img_file, &in_stat) != 0) { - perror("stat"); - return 1; - } - - if (stat(file, &out_stat) == 0) { - if (in_stat.st_ino == out_stat.st_ino) { - fprintf(stderr, "Input image %s and output image %s are the same file\n", - img_file, file); - return 1; - } - } + md = new JpgcomImageMetaData(); - out = fopen(file, "w"); - if (out == NULL) { - perror("fopen"); - return 1; - } + md->set_longitude(get_view_long()); + md->set_latitude(get_view_lat()); + md->set_height(get_view_height()); + md->set_direction(get_center_angle()); + md->set_nick(get_nick_angle()); + md->set_tilt(get_tilt_angle()); + md->set_focallength_sensor_ratio(get_scale() / (double) img->w()); + md->set_projection_type((int) get_projection()); - snprintf(buf, sizeof(buf), GIPFEL_FORMAT, - get_view_long(), - get_view_lat(), - get_view_height(), - get_center_angle(), - get_nick_angle(), - get_tilt_angle(), - get_scale(), - (int) get_projection()); - -// try to save gipfel data in JPEG comment section - args[0] = "wrjpgcom"; - args[1] = "-replace"; - args[2] = "-comment"; - args[3] = buf; - args[4] = img_file; - args[5] = NULL; - - p = pexecvp(args[0], args, &pid, "r"); - - if (p) { - while ((n = fread(buf, 1, sizeof(buf), p)) != 0) { - if (fwrite(buf, 1, n, out) != n) { - perror("fwrite"); - fclose(out); - fclose(p); - waitpid(pid, &status, 0); - } - } - fclose(p); - waitpid(pid, &status, 0); - if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { - fprintf(stderr, "%s not found\n", args[0]); - } - } + ret = md->save_image(img_file, file); + delete md; - fclose(out); - return 0; + return ret; } - int GipfelWidget::load_data(const char *file) { int r; diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H index 1318e10..637b758 100644 --- a/src/ImageMetaData.H +++ b/src/ImageMetaData.H @@ -35,7 +35,7 @@ class ImageMetaData { ImageMetaData(); virtual int load_image(char *name); - virtual int save_image(char *name); + virtual int save_image(char *in_img, char *out_img); double get_longitude(); double get_latitude(); diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx index 745529b..5c54a17 100644 --- a/src/ImageMetaData.cxx +++ b/src/ImageMetaData.cxx @@ -39,7 +39,7 @@ ImageMetaData::load_image(char *name) { } int -ImageMetaData::save_image(char *name) { +ImageMetaData::save_image(char *in_img, char *out_img) { return 1; } diff --git a/src/JpgcomImageMetaData.H b/src/JpgcomImageMetaData.H index 70e266e..944833a 100644 --- a/src/JpgcomImageMetaData.H +++ b/src/JpgcomImageMetaData.H @@ -24,6 +24,6 @@ class JpgcomImageMetaData : public ImageMetaData { virtual int load_image(char *name); - virtual int save_image(char *name); + virtual int save_image(char *in_img, char *out_img); }; #endif diff --git a/src/JpgcomImageMetaData.cxx b/src/JpgcomImageMetaData.cxx index 8dcd54e..407b6af 100644 --- a/src/JpgcomImageMetaData.cxx +++ b/src/JpgcomImageMetaData.cxx @@ -19,7 +19,9 @@ #include #include +#include #include +#include #include "util.h" @@ -92,5 +94,70 @@ JpgcomImageMetaData::load_image(char *name) { } int -JpgcomImageMetaData::save_image(char *name) { +JpgcomImageMetaData::save_image(char *in_img, char *out_img) { + char * args[32]; + FILE *p, *out; + pid_t pid; + char buf[1024]; + int status; + size_t n; + struct stat in_stat, out_stat; + + if (stat(in_img, &in_stat) != 0) { + perror("stat"); + return 1; + } + + if (stat(out_img, &out_stat) == 0) { + if (in_stat.st_ino == out_stat.st_ino) { + fprintf(stderr, "Input image %s and output image %s are the same file\n", + in_img, out_img); + return 1; + } + } + + out = fopen(out_img, "w"); + if (out == NULL) { + perror("fopen"); + return 1; + } + + snprintf(buf, sizeof(buf), GIPFEL_FORMAT_2, + longitude, + latitude, + height, + direction, + nick, + tilt, + focallength_sensor_ratio, + projection_type); + + // try to save gipfel data in JPEG comment section + args[0] = "wrjpgcom"; + args[1] = "-replace"; + args[2] = "-comment"; + args[3] = buf; + args[4] = in_img; + args[5] = NULL; + + p = pexecvp(args[0], args, &pid, "r"); + + if (p) { + while ((n = fread(buf, 1, sizeof(buf), p)) != 0) { + if (fwrite(buf, 1, n, out) != n) { + perror("fwrite"); + fclose(out); + fclose(p); + waitpid(pid, &status, 0); + } + } + fclose(p); + waitpid(pid, &status, 0); + if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { + fprintf(stderr, "%s not found\n", args[0]); + } + } + + fclose(out); + return 0; } -- cgit v1.2.3 From 9b5970605e362b5543f526818c8633d84595a76d Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 28 Oct 2006 00:37:12 +0200 Subject: remove panorama.c --- src/panorama.c | 386 --------------------------------------------------------- 1 file changed, 386 deletions(-) delete mode 100644 src/panorama.c diff --git a/src/panorama.c b/src/panorama.c deleted file mode 100644 index 2c58c65..0000000 --- a/src/panorama.c +++ /dev/null @@ -1,386 +0,0 @@ -/* - * "$Id: panorama.c,v 1.8 2005/04/12 19:56:42 hofmann Exp $" - * - * flpsed program. - * - * Copyright 2004,2005 by Johannes Hofmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - - -#include -#include -#include -#include -#include - -double pi, deg2rad; - -double distance(double phi_a, double lam_a, double phi_b, double lam_b); -double sin_alpha(double lam_a, double lam_b, double phi_b, double c); -double cos_alpha(double phi_a, double phi_b, double c); -double alpha(double phi_a, double lam_a, double phi_b, double lam_b); -double center_angle(double alph_a, double alph_b, double d1, double d2); -int read_file(double phi_a, double lam_a, char *name, - int dist, double h_d_ratio, double mm_per_deg, - double a_center); -int -main(int argc, char **argv) { - char c; - char *sep, *tmp, *data_file = NULL; - int errflg = 0; - int dist = 100000; - double phi_a, lam_a, phi_b, lam_b; - double h_d_ratio = 0.1, mm_per_deg = 200.0, dist_c_m1 = 0.0; - double dist_c_m2 = 0.0, a_center = 0.0; - char *pos = NULL, *m1 = NULL, *m2 = NULL, *m_c = NULL; - - pi = asin(1.0) * 2.0; - deg2rad = pi / 180.0; - - while ((c = getopt(argc, argv, "a:b:f:d:r:p:m:n:s:t:c:")) != EOF) { - switch (c) { - case 'a': - tmp = strdup(optarg); - if ((sep = strchr(tmp, ',')) == NULL) { - errflg++; - break; - } - *sep = '\0'; - phi_a = atof(tmp) * deg2rad; - lam_a = atof(sep+1) * deg2rad; - free(tmp); - break; - case 'b': - tmp = strdup(optarg); - if ((sep = strchr(tmp, ',')) == NULL) { - usage(); - } - *sep = '\0'; - phi_b = atof(tmp) * deg2rad; - lam_b = atof(sep+1) * deg2rad; - free(tmp); - break; - case 'f': - data_file = optarg; - break; - case 'd': - dist = atoi(optarg); - break; - case 'r': - h_d_ratio = atof(optarg); - break; - case 's': - dist_c_m1 = -atof(optarg); - break; - case 't': - dist_c_m2 = -atof(optarg); - break; - case 'p': - pos = optarg; - break; - case 'm': - m1 = optarg; - break; - case 'n': - m2 = optarg; - break; - case 'c': - m_c = optarg; - break; - } -} - -#if 0 - { - double a1 = 0.0, a2 = 90.0; - double d1 = -20.0, d2 = 10.0; - - fprintf(stderr, "==> %f\n", center_angle(a1*deg2rad, a2*deg2rad, d1, d2) / deg2rad); - exit(1); - } -#endif - - if (errflg) { - usage(); - exit(1); - } - - if (!data_file) { - usage(); - exit(1); - } - - if (pos){ - int n = get_pos(data_file, pos, &phi_a, &lam_a); - if (n == 0) { - fprintf(stderr, "No matching entry for %s in datafile.\n", - pos); - exit(1); - } else if (n > 1) { - fprintf(stderr, "More than one matching entry for %s in datafile.\n", - pos); - exit(1); - } - } - - if (m1 && m2) { - double phi, lam; - double a1, a2, a; - int n; - - n = get_pos(data_file, m1, &phi, &lam); - if (n == 0) { - fprintf(stderr, "No matching entry for %s in datafile.\n", - m1); - exit(1); - } else if (n > 1) { - fprintf(stderr, "More than one matching entry for %s in datafile.\n", - m1); - exit(1); - } - a1 = alpha(phi_a, lam_a, phi, lam); - - n = get_pos(data_file, m2, &phi, &lam); - if (n == 0) { - fprintf(stderr, "No matching entry for %s in datafile.\n", - m2); - exit(1); - } else if (n > 1) { - fprintf(stderr, "More than one matching entry for %s in datafile.\n", - m2); - exit(1); - } - a2 = alpha(phi_a, lam_a, phi, lam); - - a_center = center_angle(a1, a2, dist_c_m1, dist_c_m2); - mm_per_deg = (dist_c_m1 - dist_c_m2) / (tan(a1 - a_center) - tan(a2 - a_center)); - fprintf(stderr, "center_angle = %f\n", a_center / deg2rad); - - } - - - - read_file(phi_a, lam_a, data_file, dist, h_d_ratio, mm_per_deg, a_center); -} - - -#define PS_HEADER "%!\n \ -/mountain { % expects name, height, dist, deg on stack\n \ - newpath % Start a new path\n \ - gsave % Keep rotations temporary\n \ - rotate % Rotate by degrees on stack\n \ - dup \n \ - 0 moveto \n \ - add % End line at 20 + dist + height\n \ - dup % Duplicate end of line pos\n \ - 0 lineto\n \ - 10 add % Start text 10 from end of line \n \ - 0 moveto\n \ - show\n \ - stroke\n \ - grestore % Get back the unrotated state\n \ -} def \n \ -/Times-Roman findfont \n \ -8 scalefont \n \ -setfont \n \ -300 344 translate\n \ -5 0 moveto\n \ -0 0 5 0 360 arc\n \ -stroke -%11 0 moveto\n" - - -#define PS_HEADER_PHOTO "%!\n \ - /mountain { % expects name, height, dist, deg on stack\n \ - newpath\n \ - 0.352778 div % convert from mm to PS points\n \ - dup\n \ - dup\n \ - 200 exch moveto\n \ - 500 exch lineto\n \ - 500 exch moveto\n \ - pop \n \ - pop \n \ - show\n \ - stroke\n \ -} def\n \ -\n \ - /Times-Roman findfont \n \ - 6 scalefont \n \ - setfont \n - 0 420 translate \n" - - -int get_pos(char *filename, char *name, double *phi, double *lam) { - FILE *fp; - char buf[1024]; - char *vals[10]; - char **ap, *bp; - double height; - int found = 0; - - fp = fopen(filename, "r"); - if (!fp) { - perror("fopen"); - return 1; - } - - while (fgets(buf, sizeof(buf), fp)) { - bp = buf; - for (ap = vals; (*ap = strsep(&bp, ",")) != NULL;) - if (++ap >= &vals[10]) - break; - - if (strstr(vals[1], name)) { - *phi = atof(vals[3]) * deg2rad; - *lam = atof(vals[4]) * deg2rad; - height = atof(vals[5]); - fprintf(stderr, "Found matching entry: %s (%fm)\n", vals[1], height); - found++; - } - } - - fclose(fp); - return found; -} - - - -int read_file(double phi_a, double lam_a, char *name, - int dist, double h_d_ratio, double mm_per_deg, double a_center) { - FILE *fp; - char buf[1024]; - char *vals[10]; - char **ap, *bp; - double phi_b, lam_b, height, alph, dist_center; - - fp = fopen(name, "r"); - if (!fp) { - perror("fopen"); - return 1; - } - - printf("%s", PS_HEADER_PHOTO); - printf("/mm_per_deg %f def\n", mm_per_deg); - printf("/a_center %f def\n", a_center); - while (fgets(buf, sizeof(buf), fp)) { - bp = buf; - for (ap = vals; (*ap = strsep(&bp, ",")) != NULL;) - if (++ap >= &vals[10]) - break; - - phi_b = atof(vals[3]) * deg2rad; - lam_b = atof(vals[4]) * deg2rad; - - if (phi_a == phi_b && lam_a == lam_b) { - continue; - } - - height = atof(vals[5]); - - if (distance(phi_a, lam_a, phi_b, lam_b) * 6368000.0 > dist) { - continue; - } - - - if (height / (distance(phi_a, lam_a, phi_b, lam_b)* 6368000) < h_d_ratio) { - continue; - } - - alph = alpha(phi_a, lam_a, phi_b, lam_b); - alph = alph - a_center; - if (alph > pi / 2.0 || alph < - pi /2.0) { - continue; - } - - dist_center = tan(alph) * mm_per_deg; - - printf("(%s) %f %f %f mountain\n", vals[1], - height / 20.0, - distance(phi_a, lam_a, phi_b, lam_b) * 25000.0, - dist_center); - - -#if 0 - printf("%f %f %s %fm\n", - alpha(phi_a, lam_a, phi_b, lam_b), - distance(phi_a, lam_a, phi_b, lam_b) * 6368000, - vals[1], - height); -#endif - } - - printf("showpage\n"); - - fclose(fp); - return 0; -} - - -double -distance(double phi_a, double lam_a, double phi_b, double lam_b) { - return acos(sin(phi_a)*sin(phi_b) + cos(phi_a)*cos(phi_b)*cos(lam_a - lam_b)); -} - -double -sin_alpha(double lam_a, double lam_b, double phi_b, double c) { - return sin(lam_b - lam_a) * cos(phi_b) / sin(c); -} - -double -cos_alpha(double phi_a, double phi_b, double c) { - return (sin(phi_b) - sin(phi_a) * cos(c)) / (cos(phi_a) * sin(c)); -} - -double alpha(double phi_a, double lam_a, double phi_b, double lam_b) { - double dist, sin_alph, cos_alph, alph; - - dist = distance(phi_a, lam_a, phi_b, lam_b); - sin_alph = sin_alpha(lam_a, lam_b, phi_b, dist); - cos_alph = cos_alpha(phi_a, phi_b, dist); - - if (sin_alph > 0) { - alph = acos(cos_alph); - } else { - alph = 2.0 * pi - acos(cos_alph); - } - - return alph; -} - -double -center_angle(double alph_a, double alph_b, double d1, double d2) { - double tan_a, tan_b; - - fprintf(stderr, "a=%f, b=%f d1=%f d2=%f\n", - alph_a / deg2rad, alph_b / deg2rad, d1, d2); - - tan_a = tan(alph_a - alph_b); - fprintf(stderr, "tan_a %f\n", tan_a); - tan_b = (d2 - d1 + ((sqrt((d2*(d2 - (2.0*d1*(1.0 + (2.0 * tan_a * tan_a))))) + (d1*d1))))) / (2.0*d2*tan_a); - - fprintf(stderr, "tan_b=%f\n", tan_b); - return alph_a + atan(tan_b); -} - -void -usage() { - fprintf(stderr, - "usage: panorama -a ,\n" - " -b ,\n"); -} -- cgit v1.2.3 From 2c4c48b59dea2e96ff34469627bc2c5cf2c53f5a Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 28 Oct 2006 00:40:34 +0200 Subject: update README --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index ff96a64..9a6c469 100644 --- a/README +++ b/README @@ -21,6 +21,7 @@ Requirements - fltk-1.1.x (http://www.fltk.org) - libtiff (http://www.remotesensing.org/libtiff/) - libjpeg (http://www.ijg.org/) +- exif utility (http://libexif.sourceforge.net/) - ccmath library (http://freshmeat.net/projects/ccmath/) - gipfel works on UNIX-like system (e.g. Linux, *BSD and probably others) -- cgit v1.2.3 From 20d0a75d72711a11694c4796529acba280ac9443 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 29 Oct 2006 00:43:00 +0200 Subject: use Exif GPS Info if available --- src/ExifImageMetaData.cxx | 35 ++++++++++++++++++++++++++++++++++- src/GipfelWidget.cxx | 3 +++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/ExifImageMetaData.cxx b/src/ExifImageMetaData.cxx index 0de7478..4002e97 100644 --- a/src/ExifImageMetaData.cxx +++ b/src/ExifImageMetaData.cxx @@ -19,6 +19,7 @@ #include #include +#include #include #include "util.h" @@ -26,6 +27,29 @@ #include "ExifImageMetaData.H" #define FOCAL_LENGTH_IN_35MM_FILM 0xa405 +#define GPS_LATIITUDE 0x0002 +#define GPS_LONGITUDE 0x0004 +#define GPS_ALTITUDE 0x0006 + + +static double +degminsecstr2double(char *val) { + double ret, dv; + + ret = 0.0; + for (dv=1.0; dv <= 3600.0; dv = dv * 60.0) { + ret = ret + atof(val) / dv; + val = strchr(val, ','); + if (!val || val[1] == '\0') { + break; + } else { + val++; + } + } + + return ret; +} + int ExifImageMetaData::load_image(char *name) { @@ -47,7 +71,7 @@ ExifImageMetaData::load_image(char *name) { if (p) { while (fgets(buf, sizeof(buf), p) != NULL) { - if (sscanf(buf, "%x\t%s", &id, val) != 2) { + if (sscanf(buf, "%x\t%[^\n]\n", &id, val) != 2) { continue; } @@ -55,6 +79,15 @@ ExifImageMetaData::load_image(char *name) { case FOCAL_LENGTH_IN_35MM_FILM: focallength_sensor_ratio = atof(val) / 35.0; break; + case GPS_LONGITUDE: + longitude = degminsecstr2double(val); + break; + case GPS_LATIITUDE: + latitude = degminsecstr2double(val); + break; + case GPS_ALTITUDE: + height = atof(val); + break; } } } diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 33a3987..b8ebc79 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -130,6 +130,9 @@ GipfelWidget::load_image(char *file) { ret = md->load_image(file); if (ret == 0) { set_scale(md->get_focallength_sensor_ratio() * img->w()); + set_view_long(md->get_longitude()); + set_view_lat(md->get_latitude()); + set_view_height(md->get_height()); } delete md; } -- cgit v1.2.3 From da5192170bb7ed19a8eadbc8ac393b0fa222c7df Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 18:18:57 +0100 Subject: consolidate ExifImageMetaData and src/JpgcomImageMetaData into ImageMetaData --- src/ExifImageMetaData.H | 29 ------ src/ExifImageMetaData.cxx | 109 -------------------- src/GipfelWidget.cxx | 19 +--- src/ImageMetaData.H | 10 +- src/ImageMetaData.cxx | 242 ++++++++++++++++++++++++++++++++++++++++++-- src/JpgcomImageMetaData.H | 29 ------ src/JpgcomImageMetaData.cxx | 163 ----------------------------- src/Makefile.am | 6 +- src/gipfel.cxx | 3 +- 9 files changed, 247 insertions(+), 363 deletions(-) delete mode 100644 src/ExifImageMetaData.H delete mode 100644 src/ExifImageMetaData.cxx delete mode 100644 src/JpgcomImageMetaData.H delete mode 100644 src/JpgcomImageMetaData.cxx diff --git a/src/ExifImageMetaData.H b/src/ExifImageMetaData.H deleted file mode 100644 index f864b0f..0000000 --- a/src/ExifImageMetaData.H +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// - -#ifndef EXIF_IMAGE_META_DATA_H -#define EXIF_IMAGE_META_DATA_H - -#include "ImageMetaData.H" - -class ExifImageMetaData : public ImageMetaData { - virtual int load_image(char *name); - virtual int save_image(char *in_img, char *out_img); -}; -#endif diff --git a/src/ExifImageMetaData.cxx b/src/ExifImageMetaData.cxx deleted file mode 100644 index 4002e97..0000000 --- a/src/ExifImageMetaData.cxx +++ /dev/null @@ -1,109 +0,0 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// - -#include -#include -#include -#include - -#include "util.h" - -#include "ExifImageMetaData.H" - -#define FOCAL_LENGTH_IN_35MM_FILM 0xa405 -#define GPS_LATIITUDE 0x0002 -#define GPS_LONGITUDE 0x0004 -#define GPS_ALTITUDE 0x0006 - - -static double -degminsecstr2double(char *val) { - double ret, dv; - - ret = 0.0; - for (dv=1.0; dv <= 3600.0; dv = dv * 60.0) { - ret = ret + atof(val) / dv; - val = strchr(val, ','); - if (!val || val[1] == '\0') { - break; - } else { - val++; - } - } - - return ret; -} - - -int -ExifImageMetaData::load_image(char *name) { - char * args[32]; - FILE *p; - pid_t pid; - int status; - char buf[1024]; - char val[1024]; - int id; - - args[0] = "exif"; - args[1] = "-i"; - args[2] = "-m"; - args[3] = name; - args[4] = NULL; - - p = pexecvp(args[0], args, &pid, "r"); - - if (p) { - while (fgets(buf, sizeof(buf), p) != NULL) { - if (sscanf(buf, "%x\t%[^\n]\n", &id, val) != 2) { - continue; - } - - switch(id) { - case FOCAL_LENGTH_IN_35MM_FILM: - focallength_sensor_ratio = atof(val) / 35.0; - break; - case GPS_LONGITUDE: - longitude = degminsecstr2double(val); - break; - case GPS_LATIITUDE: - latitude = degminsecstr2double(val); - break; - case GPS_ALTITUDE: - height = atof(val); - break; - } - } - } - - fclose(p); - waitpid(pid, &status, 0); - if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { - fprintf(stderr, "%s not found\n", args[0]); - } - - return 0; -} - - -int -ExifImageMetaData::save_image(char *in_img, char *out_img) { - return 1; -} - diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index b8ebc79..2efd231 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -35,8 +35,7 @@ #include #include -#include "ExifImageMetaData.H" -#include "JpgcomImageMetaData.H" +#include "ImageMetaData.H" #include "Fl_Search_Chooser.H" #include "choose_hill.H" #include "GipfelWidget.H" @@ -106,7 +105,7 @@ GipfelWidget::load_image(char *file) { mb->add("Center Peak", 0, (Fl_Callback*) center_cb, this); // try to retrieve gipfel data from JPEG comment section - md = new JpgcomImageMetaData(); + md = new ImageMetaData(); ret = md->load_image(file); if (ret != 1) { set_view_long(md->get_longitude()); @@ -125,18 +124,6 @@ GipfelWidget::load_image(char *file) { delete md; - if (ret == 1) { - md = new ExifImageMetaData(); - ret = md->load_image(file); - if (ret == 0) { - set_scale(md->get_focallength_sensor_ratio() * img->w()); - set_view_long(md->get_longitude()); - set_view_lat(md->get_latitude()); - set_view_height(md->get_height()); - } - delete md; - } - return 0; } @@ -155,7 +142,7 @@ GipfelWidget::save_image(char *file) { return 1; } - md = new JpgcomImageMetaData(); + md = new ImageMetaData(); md->set_longitude(get_view_long()); md->set_latitude(get_view_lat()); diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H index 637b758..442aaef 100644 --- a/src/ImageMetaData.H +++ b/src/ImageMetaData.H @@ -21,7 +21,7 @@ #define IMAGE_META_DATA_H class ImageMetaData { - protected: + private: double longitude; double latitude; double height; @@ -31,11 +31,15 @@ class ImageMetaData { double focallength_sensor_ratio; int projection_type; + int load_image_jpgcom(char *name); + int save_image_jpgcom(char *in_img, char *out_img); + int load_image_exif(char *name); + public: ImageMetaData(); - virtual int load_image(char *name); - virtual int save_image(char *in_img, char *out_img); + int load_image(char *name); + int save_image(char *in_img, char *out_img); double get_longitude(); double get_latitude(); diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx index 5c54a17..424a792 100644 --- a/src/ImageMetaData.cxx +++ b/src/ImageMetaData.cxx @@ -17,32 +17,258 @@ // USA. // +#include #include #include +#include +#include +#include +#include + + +#include "util.h" #include "ImageMetaData.H" ImageMetaData::ImageMetaData() { longitude = NAN; latitude = NAN; - height = NAN; - direction = NAN; - nick = NAN; - tilt = NAN; - focallength_sensor_ratio = NAN; - projection_type = -1; + height = 0.0; + direction = 0.0; + nick = 0.0; + tilt = 0.0; + focallength_sensor_ratio = 1.0; + projection_type = 1; } + int ImageMetaData::load_image(char *name) { - return 1; + int ret; + + ret = load_image_jpgcom(name); + if (ret != 0) { + ret = load_image_exif(name); + } + + return ret; } int ImageMetaData::save_image(char *in_img, char *out_img) { - return 1; + return save_image_jpgcom(in_img, out_img); +} + +static double +degminsecstr2double(char *val) { + double ret, dv; + + ret = 0.0; + for (dv=1.0; dv <= 3600.0; dv = dv * 60.0) { + ret = ret + atof(val) / dv; + val = strchr(val, ','); + if (!val || val[1] == '\0') { + break; + } else { + val++; + } + } + + return ret; +} + +#define EXIF_FOCAL_LENGTH_IN_35MM_FILM 0xa405 +#define EXIF_GPS_LATIITUDE 0x0002 +#define EXIF_GPS_LONGITUDE 0x0004 +#define EXIF_GPS_ALTITUDE 0x0006 + +int +ImageMetaData::load_image_exif(char *name) { + char * args[32]; + FILE *p; + pid_t pid; + int status; + char buf[1024]; + char val[1024]; + int id; + + args[0] = "exif"; + args[1] = "-i"; + args[2] = "-m"; + args[3] = name; + args[4] = NULL; + + p = pexecvp(args[0], args, &pid, "r"); + + if (p) { + while (fgets(buf, sizeof(buf), p) != NULL) { + if (sscanf(buf, "%x\t%[^\n]\n", &id, val) != 2) { + continue; + } + + switch(id) { + case EXIF_FOCAL_LENGTH_IN_35MM_FILM: + focallength_sensor_ratio = atof(val) / 35.0; + break; + case EXIF_GPS_LONGITUDE: + longitude = degminsecstr2double(val); + break; + case EXIF_GPS_LATIITUDE: + latitude = degminsecstr2double(val); + break; + case EXIF_GPS_ALTITUDE: + height = atof(val); + break; + } + } + } + + fclose(p); + waitpid(pid, &status, 0); + if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { + fprintf(stderr, "%s not found\n", args[0]); + } + + return 0; +} + + +#define GIPFEL_FORMAT_1 "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, scale %lf, projection type %d" +#define GIPFEL_FORMAT_2 "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, focallength_sensor_ratio %lf, projection type %d" + +int +ImageMetaData::load_image_jpgcom(char *name) { + char * args[32]; + FILE *p; + pid_t pid; + int status; + char buf[1024]; + double lo, la, he, dir, ni, ti, fr; + int pt; + int ret = 1; + + args[0] = "rdjpgcom"; + args[1] = name; + args[2] = NULL; + + p = pexecvp(args[0], args, &pid, "r"); + + if (p) { + while (fgets(buf, sizeof(buf), p) != NULL) { + if (sscanf(buf, GIPFEL_FORMAT_2, + &lo, &la, &he, &dir, &ni, &ti, &fr, &pt) >= 7) { + + longitude = lo; + latitude = la; + height = he; + direction = dir; + nick = ni; + tilt = ti; + focallength_sensor_ratio = fr; + projection_type = pt; + + ret = 0; + + break; + } else if (sscanf(buf, GIPFEL_FORMAT_1, + &lo, &la, &he, &dir, &ni, &ti, &fr, &pt) >= 7) { + + longitude = lo; + latitude = la; + height = he; + direction = dir; + nick = ni; + tilt = ti; + focallength_sensor_ratio = fr; + projection_type = pt; + + ret = 2; // special return value for compatibility with + // old format + + break; + } + } + + fclose(p); + waitpid(pid, &status, 0); + if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { + fprintf(stderr, "%s not found\n", args[0]); + } + } + + return ret; } +int +ImageMetaData::save_image_jpgcom(char *in_img, char *out_img) { + char * args[32]; + FILE *p, *out; + pid_t pid; + char buf[1024]; + int status; + size_t n; + struct stat in_stat, out_stat; + + if (stat(in_img, &in_stat) != 0) { + perror("stat"); + return 1; + } + + if (stat(out_img, &out_stat) == 0) { + if (in_stat.st_ino == out_stat.st_ino) { + fprintf(stderr, "Input image %s and output image %s are the same file\n", + in_img, out_img); + return 1; + } + } + + out = fopen(out_img, "w"); + if (out == NULL) { + perror("fopen"); + return 1; + } + + snprintf(buf, sizeof(buf), GIPFEL_FORMAT_2, + longitude, + latitude, + height, + direction, + nick, + tilt, + focallength_sensor_ratio, + projection_type); + + // try to save gipfel data in JPEG comment section + args[0] = "wrjpgcom"; + args[1] = "-replace"; + args[2] = "-comment"; + args[3] = buf; + args[4] = in_img; + args[5] = NULL; + + p = pexecvp(args[0], args, &pid, "r"); + + if (p) { + while ((n = fread(buf, 1, sizeof(buf), p)) != 0) { + if (fwrite(buf, 1, n, out) != n) { + perror("fwrite"); + fclose(out); + fclose(p); + waitpid(pid, &status, 0); + } + } + fclose(p); + waitpid(pid, &status, 0); + if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { + fprintf(stderr, "%s not found\n", args[0]); + } + } + + fclose(out); + return 0; +} + + double ImageMetaData::get_longitude() { return longitude; diff --git a/src/JpgcomImageMetaData.H b/src/JpgcomImageMetaData.H deleted file mode 100644 index 944833a..0000000 --- a/src/JpgcomImageMetaData.H +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// - -#ifndef JPGCOM_IMAGE_META_DATA_H -#define JPGCOM_IMAGE_META_DATA_H - -#include "ImageMetaData.H" - -class JpgcomImageMetaData : public ImageMetaData { - virtual int load_image(char *name); - virtual int save_image(char *in_img, char *out_img); -}; -#endif diff --git a/src/JpgcomImageMetaData.cxx b/src/JpgcomImageMetaData.cxx deleted file mode 100644 index 407b6af..0000000 --- a/src/JpgcomImageMetaData.cxx +++ /dev/null @@ -1,163 +0,0 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// - -#include -#include -#include -#include -#include - -#include "util.h" - -#include "JpgcomImageMetaData.H" - -#define GIPFEL_FORMAT_1 "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, scale %lf, projection type %d" -#define GIPFEL_FORMAT_2 "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, focallength_sensor_ratio %lf, projection type %d" - -int -JpgcomImageMetaData::load_image(char *name) { - char * args[32]; - FILE *p; - pid_t pid; - int status; - char buf[1024]; - double lo, la, he, dir, ni, ti, fr; - int pt; - int ret = 1; - - args[0] = "rdjpgcom"; - args[1] = name; - args[2] = NULL; - - p = pexecvp(args[0], args, &pid, "r"); - - if (p) { - while (fgets(buf, sizeof(buf), p) != NULL) { - if (sscanf(buf, GIPFEL_FORMAT_2, - &lo, &la, &he, &dir, &ni, &ti, &fr, &pt) >= 7) { - - longitude = lo; - latitude = la; - height = he; - direction = dir; - nick = ni; - tilt = ti; - focallength_sensor_ratio = fr; - projection_type = pt; - - ret = 0; - - break; - } else if (sscanf(buf, GIPFEL_FORMAT_1, - &lo, &la, &he, &dir, &ni, &ti, &fr, &pt) >= 7) { - - longitude = lo; - latitude = la; - height = he; - direction = dir; - nick = ni; - tilt = ti; - focallength_sensor_ratio = fr; - projection_type = pt; - - ret = 2; // special return value for compatibility with - // old format - - break; - } - } - - fclose(p); - waitpid(pid, &status, 0); - if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { - fprintf(stderr, "%s not found\n", args[0]); - } - } - - return ret; -} - -int -JpgcomImageMetaData::save_image(char *in_img, char *out_img) { - char * args[32]; - FILE *p, *out; - pid_t pid; - char buf[1024]; - int status; - size_t n; - struct stat in_stat, out_stat; - - if (stat(in_img, &in_stat) != 0) { - perror("stat"); - return 1; - } - - if (stat(out_img, &out_stat) == 0) { - if (in_stat.st_ino == out_stat.st_ino) { - fprintf(stderr, "Input image %s and output image %s are the same file\n", - in_img, out_img); - return 1; - } - } - - out = fopen(out_img, "w"); - if (out == NULL) { - perror("fopen"); - return 1; - } - - snprintf(buf, sizeof(buf), GIPFEL_FORMAT_2, - longitude, - latitude, - height, - direction, - nick, - tilt, - focallength_sensor_ratio, - projection_type); - - // try to save gipfel data in JPEG comment section - args[0] = "wrjpgcom"; - args[1] = "-replace"; - args[2] = "-comment"; - args[3] = buf; - args[4] = in_img; - args[5] = NULL; - - p = pexecvp(args[0], args, &pid, "r"); - - if (p) { - while ((n = fread(buf, 1, sizeof(buf), p)) != 0) { - if (fwrite(buf, 1, n, out) != n) { - perror("fwrite"); - fclose(out); - fclose(p); - waitpid(pid, &status, 0); - } - } - fclose(p); - waitpid(pid, &status, 0); - if (WEXITSTATUS(status) == 127 || WEXITSTATUS(status) == 126) { - fprintf(stderr, "%s not found\n", args[0]); - } - } - - fclose(out); - return 0; -} diff --git a/src/Makefile.am b/src/Makefile.am index a730123..8ba69c1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,9 +17,7 @@ gipfel_SOURCES = \ JPEGOutputImage.cxx \ TIFFOutputImage.cxx \ PreviewOutputImage.cxx \ - ImageMetaData.cxx \ - JpgcomImageMetaData.cxx \ - ExifImageMetaData.cxx + ImageMetaData.cxx noinst_HEADERS = \ GipfelWidget.H \ @@ -38,6 +36,4 @@ noinst_HEADERS = \ TIFFOutputImage.H \ PreviewOutputImage.H \ ImageMetaData.H \ - JpgcomImageMetaData.H \ - ExifImageMetaData.H \ util.h diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 1106c48..13ef3e5 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -438,7 +439,7 @@ int main(int argc, char** argv) { if (view_point) { gipf->set_viewpoint(view_point); } else if (img_file && - gipf->get_view_lat()==0.0 && gipf->get_view_long()==0.0) { + (isnan(gipf->get_view_lat()) || isnan(gipf->get_view_long()))) { viewpoint_cb(NULL, NULL); } -- cgit v1.2.3 From 19bec8bde89fc08f6497a346b2121bcd96d1f528 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 18:37:27 +0100 Subject: fix problem with compatibility code --- src/GipfelWidget.cxx | 26 ++++++++++---------------- src/ImageMetaData.H | 3 ++- src/ImageMetaData.cxx | 11 +++++++---- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 2efd231..a1982d5 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -104,23 +104,17 @@ GipfelWidget::load_image(char *file) { mb->box(FL_NO_BOX); mb->add("Center Peak", 0, (Fl_Callback*) center_cb, this); - // try to retrieve gipfel data from JPEG comment section + // try to retrieve gipfel data from JPEG meta data md = new ImageMetaData(); - ret = md->load_image(file); - if (ret != 1) { - set_view_long(md->get_longitude()); - set_view_lat(md->get_latitude()); - set_view_height(md->get_height()); - set_center_angle(md->get_direction()); - set_nick_angle(md->get_nick()); - set_tilt_angle(md->get_tilt()); - set_projection((Projection::Projection_t) md->get_projection_type()); - if (ret == 2) { // special compatibility return code for old format - set_scale(md->get_focallength_sensor_ratio()); - } else { - set_scale(md->get_focallength_sensor_ratio() * img->w()); - } - } + md->load_image(file, img->w()); + set_view_long(md->get_longitude()); + set_view_lat(md->get_latitude()); + set_view_height(md->get_height()); + set_center_angle(md->get_direction()); + set_nick_angle(md->get_nick()); + set_tilt_angle(md->get_tilt()); + set_projection((Projection::Projection_t) md->get_projection_type()); + set_scale(md->get_focallength_sensor_ratio() * img->w()); delete md; diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H index 442aaef..7116d98 100644 --- a/src/ImageMetaData.H +++ b/src/ImageMetaData.H @@ -29,6 +29,7 @@ class ImageMetaData { double nick; double tilt; double focallength_sensor_ratio; + double scale; int projection_type; int load_image_jpgcom(char *name); @@ -38,7 +39,7 @@ class ImageMetaData { public: ImageMetaData(); - int load_image(char *name); + int load_image(char *name, int img_width); int save_image(char *in_img, char *out_img); double get_longitude(); diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx index 424a792..d78493d 100644 --- a/src/ImageMetaData.cxx +++ b/src/ImageMetaData.cxx @@ -38,16 +38,19 @@ ImageMetaData::ImageMetaData() { nick = 0.0; tilt = 0.0; focallength_sensor_ratio = 1.0; - projection_type = 1; + scale = NAN; + projection_type = 0; } int -ImageMetaData::load_image(char *name) { +ImageMetaData::load_image(char *name, int img_width) { int ret; ret = load_image_jpgcom(name); - if (ret != 0) { + if (ret == 2) { // old format + focallength_sensor_ratio = scale / (double) img_width; + } else if (ret == 1) { // get reasonable defaults from exif data ret = load_image_exif(name); } @@ -179,7 +182,7 @@ ImageMetaData::load_image_jpgcom(char *name) { direction = dir; nick = ni; tilt = ti; - focallength_sensor_ratio = fr; + scale = fr; projection_type = pt; ret = 2; // special return value for compatibility with -- cgit v1.2.3 From 4188cb198bec8a83cfeb893608af2bd39d515449 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 19:21:16 +0100 Subject: scale -> focal_length_35mm --- src/GipfelWidget.H | 4 ++-- src/GipfelWidget.cxx | 12 ++++++------ src/ImageMetaData.H | 6 +++--- src/ImageMetaData.cxx | 20 ++++++++++---------- src/gipfel.cxx | 26 +++++++++++++------------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index 7bcd3c0..f4c2850 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -78,7 +78,7 @@ class GipfelWidget : public Fl_Widget { void set_tilt_angle(double a); - void set_scale(double s); + void set_focal_length_35mm(double s); void set_height_dist_ratio(double r); @@ -100,7 +100,7 @@ class GipfelWidget : public Fl_Widget { double get_tilt_angle(); - double get_scale(); + double get_focal_length_35mm(); double get_height_dist_ratio(); diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index a1982d5..f38b21c 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -114,7 +114,7 @@ GipfelWidget::load_image(char *file) { set_nick_angle(md->get_nick()); set_tilt_angle(md->get_tilt()); set_projection((Projection::Projection_t) md->get_projection_type()); - set_scale(md->get_focallength_sensor_ratio() * img->w()); + set_focal_length_35mm(md->get_focal_length_35mm()); delete md; @@ -144,7 +144,7 @@ GipfelWidget::save_image(char *file) { md->set_direction(get_center_angle()); md->set_nick(get_nick_angle()); md->set_tilt(get_tilt_angle()); - md->set_focallength_sensor_ratio(get_scale() / (double) img->w()); + md->set_focal_length_35mm(get_focal_length_35mm()); md->set_projection_type((int) get_projection()); ret = md->save_image(img_file, file); @@ -469,8 +469,8 @@ GipfelWidget::set_tilt_angle(double a) { } void -GipfelWidget::set_scale(double s) { - pan->set_scale(s); +GipfelWidget::set_focal_length_35mm(double s) { + pan->set_scale(s * (double) img->w() / 35.0); set_labels(pan->get_visible_mountains()); redraw(); } @@ -503,8 +503,8 @@ GipfelWidget::get_tilt_angle() { } double -GipfelWidget::get_scale() { - return pan->get_scale(); +GipfelWidget::get_focal_length_35mm() { + return pan->get_scale() * 35.0 / (double) img->w(); } double diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H index 7116d98..48d5043 100644 --- a/src/ImageMetaData.H +++ b/src/ImageMetaData.H @@ -28,7 +28,7 @@ class ImageMetaData { double direction; double nick; double tilt; - double focallength_sensor_ratio; + double focal_length_35mm; double scale; int projection_type; @@ -48,7 +48,7 @@ class ImageMetaData { double get_direction(); double get_nick(); double get_tilt(); - double get_focallength_sensor_ratio(); + double get_focal_length_35mm(); int get_projection_type(); void set_longitude(double v); @@ -57,7 +57,7 @@ class ImageMetaData { void set_direction(double v); void set_nick(double v); void set_tilt(double v); - void set_focallength_sensor_ratio(double v); + void set_focal_length_35mm(double v); void set_projection_type(int v); }; #endif diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx index d78493d..a5d3726 100644 --- a/src/ImageMetaData.cxx +++ b/src/ImageMetaData.cxx @@ -37,7 +37,7 @@ ImageMetaData::ImageMetaData() { direction = 0.0; nick = 0.0; tilt = 0.0; - focallength_sensor_ratio = 1.0; + focal_length_35mm = 35.0; scale = NAN; projection_type = 0; } @@ -49,7 +49,7 @@ ImageMetaData::load_image(char *name, int img_width) { ret = load_image_jpgcom(name); if (ret == 2) { // old format - focallength_sensor_ratio = scale / (double) img_width; + focal_length_35mm = scale * 35.0 / (double) img_width; } else if (ret == 1) { // get reasonable defaults from exif data ret = load_image_exif(name); } @@ -111,7 +111,7 @@ ImageMetaData::load_image_exif(char *name) { switch(id) { case EXIF_FOCAL_LENGTH_IN_35MM_FILM: - focallength_sensor_ratio = atof(val) / 35.0; + focal_length_35mm = atof(val); break; case EXIF_GPS_LONGITUDE: longitude = degminsecstr2double(val); @@ -137,7 +137,7 @@ ImageMetaData::load_image_exif(char *name) { #define GIPFEL_FORMAT_1 "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, scale %lf, projection type %d" -#define GIPFEL_FORMAT_2 "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, focallength_sensor_ratio %lf, projection type %d" +#define GIPFEL_FORMAT_2 "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, focal_length_35mm %lf, projection type %d" int ImageMetaData::load_image_jpgcom(char *name) { @@ -167,7 +167,7 @@ ImageMetaData::load_image_jpgcom(char *name) { direction = dir; nick = ni; tilt = ti; - focallength_sensor_ratio = fr; + focal_length_35mm = fr; projection_type = pt; ret = 0; @@ -238,7 +238,7 @@ ImageMetaData::save_image_jpgcom(char *in_img, char *out_img) { direction, nick, tilt, - focallength_sensor_ratio, + focal_length_35mm, projection_type); // try to save gipfel data in JPEG comment section @@ -303,8 +303,8 @@ ImageMetaData::get_tilt() { } double -ImageMetaData::get_focallength_sensor_ratio() { - return focallength_sensor_ratio; +ImageMetaData::get_focal_length_35mm() { + return focal_length_35mm; } int @@ -343,8 +343,8 @@ ImageMetaData::set_tilt(double v) { } void -ImageMetaData::set_focallength_sensor_ratio(double v) { - focallength_sensor_ratio = v; +ImageMetaData::set_focal_length_35mm(double v) { + focal_length_35mm = v; } void diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 13ef3e5..dc15d8e 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -58,7 +58,7 @@ char *data_file = DEFAULT_DATAFILE; GipfelWidget *gipf = NULL; Fl_Dial *s_center = NULL; -Fl_Slider *s_nick, *s_scale, *s_tilt, *s_height_dist, *s_track_width; +Fl_Slider *s_nick, *s_focal_length, *s_tilt, *s_height_dist, *s_track_width; Fl_Value_Input *i_view_lat, *i_view_long, *i_view_height; Fl_Box *b_viewpoint; Fl_Menu_Bar *mb; @@ -72,7 +72,7 @@ static int stitch(int stitch_w, int stitch_h, int type, const char *path, void set_values() { s_center->value(gipf->get_center_angle()); s_nick->value(gipf->get_nick_angle()); - s_scale->value(gipf->get_scale()); + 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()); @@ -114,8 +114,8 @@ void save_cb() { } } -void scale_cb(Fl_Slider* o, void*) { - gipf->set_scale(o->value()); +void focal_length_cb(Fl_Slider* o, void*) { + gipf->set_focal_length_35mm(o->value()); } void angle_cb(Fl_Slider* o, void*) { @@ -245,15 +245,15 @@ create_control_window() { Fl_Box *west = new Fl_Box(0, 125, 40, 20, "West"); - s_scale = new Fl_Value_Slider(235, 60, 160, 15, "Scale"); - s_scale->type(1); - s_scale->box(FL_THIN_DOWN_BOX); - s_scale->labelsize(10); - s_scale->step(5.0); - s_scale->bounds(0.0, 10000.0); - s_scale->slider(FL_UP_BOX); - s_scale->callback((Fl_Callback*)scale_cb); - s_scale->align(FL_ALIGN_TOP); + 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, 200.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); -- cgit v1.2.3 From cb4f7e5d387385a289c5e45af0b0b53fe89ffe04 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 19:54:17 +0100 Subject: update NEWS --- NEWS | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index e672b42..f815647 100644 --- a/NEWS +++ b/NEWS @@ -1,12 +1,13 @@ gipfel ChangeLog ================= gipfel-0.2.0 - - Change orientation format in jpeg header to make it independent - of the image size. One can now scale an already oriented image - without invalidating the orientation information. + - Change scale factor to "focal length in 35mm" this makes it + independent of the image size. One can now scale an already + oriented image without invalidating the orientation information. - gipfel now tries to find a reasonable default for the scale value when opening new images based on the "Focal Length In 35mm" Exif tag, if it exists. + - GPS position Exif tags are used if they exist. gipfel-0.1.3 - Add stitching mode (gipfel -s). See README for details. -- cgit v1.2.3 From 364fadcbea5f37799bb42e663106e3a007746984 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 20:45:53 +0100 Subject: strip copyright --- src/Fl_Search_Chooser.H | 20 -------------------- src/Fl_Search_Chooser.cxx | 21 --------------------- src/Fl_Value_Dial.H | 20 -------------------- src/Fl_Value_Dial.cxx | 20 -------------------- src/GipfelWidget.H | 18 ------------------ src/GipfelWidget.cxx | 18 ------------------ src/Hill.H | 18 ------------------ src/Hill.cxx | 18 ------------------ src/ImageMetaData.H | 18 ------------------ src/ImageMetaData.cxx | 18 ------------------ src/JPEGOutputImage.H | 18 ------------------ src/JPEGOutputImage.cxx | 18 ------------------ src/OutputImage.H | 18 ------------------ src/OutputImage.cxx | 18 ------------------ src/Panorama.H | 18 ------------------ src/Panorama.cxx | 18 ------------------ src/PreviewOutputImage.H | 18 ------------------ src/PreviewOutputImage.cxx | 18 ------------------ src/Projection.H | 18 ------------------ src/Projection.cxx | 18 ------------------ src/ProjectionSphaeric.H | 18 ------------------ src/ProjectionSphaeric.cxx | 19 ------------------- src/ProjectionTangential.H | 18 ------------------ src/ProjectionTangential.cxx | 18 ------------------ src/Stitch.H | 18 ------------------ src/Stitch.cxx | 18 ------------------ src/TIFFOutputImage.H | 18 ------------------ src/TIFFOutputImage.cxx | 18 ------------------ src/ViewParams.H | 18 ------------------ src/choose_hill.H | 18 ------------------ src/choose_hill.cxx | 21 --------------------- src/gipfel.cxx | 20 -------------------- 32 files changed, 591 deletions(-) diff --git a/src/Fl_Search_Chooser.H b/src/Fl_Search_Chooser.H index c87f0de..c5e88d9 100644 --- a/src/Fl_Search_Chooser.H +++ b/src/Fl_Search_Chooser.H @@ -1,23 +1,3 @@ -// -// Value dial header file for the Fast Light Tool Kit (FLTK). -// -// Copyright 1998-2004 by Bill Spitzak and others. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef FL_SEARCH_CHOOSER_H #define FL_SEARCH_CHOOSER_H diff --git a/src/Fl_Search_Chooser.cxx b/src/Fl_Search_Chooser.cxx index 62aa7d1..f1cd6c3 100644 --- a/src/Fl_Search_Chooser.cxx +++ b/src/Fl_Search_Chooser.cxx @@ -1,24 +1,3 @@ -// -// Search Chooser widget for the Fast Light Tool Kit (FLTK). -// -// Copyright by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// -// #include #include diff --git a/src/Fl_Value_Dial.H b/src/Fl_Value_Dial.H index f9ac18c..71e32a4 100644 --- a/src/Fl_Value_Dial.H +++ b/src/Fl_Value_Dial.H @@ -1,23 +1,3 @@ -// -// Value dial header file for the Fast Light Tool Kit (FLTK). -// -// Copyright 1998-2004 by Bill Spitzak and others. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef Fl_Value_Dial_H #define Fl_Value_Dial_H diff --git a/src/Fl_Value_Dial.cxx b/src/Fl_Value_Dial.cxx index c837930..482ec2e 100644 --- a/src/Fl_Value_Dial.cxx +++ b/src/Fl_Value_Dial.cxx @@ -1,23 +1,3 @@ -// -// Value dial widget for the Fast Light Tool Kit (FLTK). -// -// Copyright 1998-2004 by Bill Spitzak and others. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index f4c2850..86e8d07 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef GipfelWidget_H #define GipfelWidget_H diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index f38b21c..30320de 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include diff --git a/src/Hill.H b/src/Hill.H index 13d7d64..5c8aca7 100644 --- a/src/Hill.H +++ b/src/Hill.H @@ -1,21 +1,3 @@ -// -// Copyright 2005 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef HILL_H #define HILL_H diff --git a/src/Hill.cxx b/src/Hill.cxx index 277cefe..5ec35ee 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -1,21 +1,3 @@ -// -// Copyright 2005 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H index 48d5043..6cb16fe 100644 --- a/src/ImageMetaData.H +++ b/src/ImageMetaData.H @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef IMAGE_META_DATA_H #define IMAGE_META_DATA_H diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx index a5d3726..6d66954 100644 --- a/src/ImageMetaData.cxx +++ b/src/ImageMetaData.cxx @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include diff --git a/src/JPEGOutputImage.H b/src/JPEGOutputImage.H index 50570e5..4a9e60f 100644 --- a/src/JPEGOutputImage.H +++ b/src/JPEGOutputImage.H @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef JPEGOUTPUTIMAGE_H #define JPEGOUTPUTIMAGE_H diff --git a/src/JPEGOutputImage.cxx b/src/JPEGOutputImage.cxx index 3f7fd11..7ca4cb5 100644 --- a/src/JPEGOutputImage.cxx +++ b/src/JPEGOutputImage.cxx @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include diff --git a/src/OutputImage.H b/src/OutputImage.H index 8792eb6..bae0ff5 100644 --- a/src/OutputImage.H +++ b/src/OutputImage.H @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef OUTPUTIMAGE_H #define OUTPUTIMAGE_H diff --git a/src/OutputImage.cxx b/src/OutputImage.cxx index f2e7296..e4da537 100644 --- a/src/OutputImage.cxx +++ b/src/OutputImage.cxx @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include diff --git a/src/Panorama.H b/src/Panorama.H index a538809..3f8312a 100644 --- a/src/Panorama.H +++ b/src/Panorama.H @@ -1,21 +1,3 @@ -// -// Copyright 2005 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef PANORAMA_H #define PANORAMA_H diff --git a/src/Panorama.cxx b/src/Panorama.cxx index ebf0b5b..f964e40 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -1,21 +1,3 @@ -// -// Copyright 2005 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include diff --git a/src/PreviewOutputImage.H b/src/PreviewOutputImage.H index 7095999..5852730 100644 --- a/src/PreviewOutputImage.H +++ b/src/PreviewOutputImage.H @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef PREVIEWOUTPUTIMAGE_H #define PREVIEWOUTPUTIMAGE_H diff --git a/src/PreviewOutputImage.cxx b/src/PreviewOutputImage.cxx index 8b09e80..3caef7f 100644 --- a/src/PreviewOutputImage.cxx +++ b/src/PreviewOutputImage.cxx @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include diff --git a/src/Projection.H b/src/Projection.H index 0a6ec81..cb9bc7e 100644 --- a/src/Projection.H +++ b/src/Projection.H @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef PROJECTION_H #define PROJECTION_H diff --git a/src/Projection.cxx b/src/Projection.cxx index 1916d55..d6dbd34 100644 --- a/src/Projection.cxx +++ b/src/Projection.cxx @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include diff --git a/src/ProjectionSphaeric.H b/src/ProjectionSphaeric.H index 06396f1..49fc74d 100644 --- a/src/ProjectionSphaeric.H +++ b/src/ProjectionSphaeric.H @@ -1,21 +1,3 @@ -// -// Copyright 2005 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef PROJECTIONSPHAERIC_H #define PROJECTIONSPHAERIC_H diff --git a/src/ProjectionSphaeric.cxx b/src/ProjectionSphaeric.cxx index e69882b..dbbcec6 100644 --- a/src/ProjectionSphaeric.cxx +++ b/src/ProjectionSphaeric.cxx @@ -1,22 +1,3 @@ -// -// Copyright 2005 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// - #include #include #include diff --git a/src/ProjectionTangential.H b/src/ProjectionTangential.H index e74511f..77c10d7 100644 --- a/src/ProjectionTangential.H +++ b/src/ProjectionTangential.H @@ -1,21 +1,3 @@ -// -// Copyright 2005 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef PROJECTIONTANGENTIAL_H #define PROJECTIONTANGENTIAL_H diff --git a/src/ProjectionTangential.cxx b/src/ProjectionTangential.cxx index 2578c5a..230662a 100644 --- a/src/ProjectionTangential.cxx +++ b/src/ProjectionTangential.cxx @@ -1,21 +1,3 @@ -// -// Copyright 2005 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include diff --git a/src/Stitch.H b/src/Stitch.H index 0bb6d48..2fbde1f 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -1,21 +1,3 @@ -// -// Copyright 2005 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef STITCH_H #define STITCH_H diff --git a/src/Stitch.cxx b/src/Stitch.cxx index af46968..ec1daf6 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include diff --git a/src/TIFFOutputImage.H b/src/TIFFOutputImage.H index 3a14279..1c9aad8 100644 --- a/src/TIFFOutputImage.H +++ b/src/TIFFOutputImage.H @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef TIFFOUTPUTIMAGE_H #define TIFFOUTPUTIMAGE_H diff --git a/src/TIFFOutputImage.cxx b/src/TIFFOutputImage.cxx index b8433ca..b528521 100644 --- a/src/TIFFOutputImage.cxx +++ b/src/TIFFOutputImage.cxx @@ -1,21 +1,3 @@ -// -// Copyright 2006 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include diff --git a/src/ViewParams.H b/src/ViewParams.H index 37c5e48..ba24f22 100644 --- a/src/ViewParams.H +++ b/src/ViewParams.H @@ -1,21 +1,3 @@ -// -// Copyright 2005 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef VIEWPARAMS_H #define VIEWPARAMS_H diff --git a/src/choose_hill.H b/src/choose_hill.H index e424d70..76fb018 100644 --- a/src/choose_hill.H +++ b/src/choose_hill.H @@ -1,21 +1,3 @@ -// -// Copyright 1998-2004 by Bill Spitzak and others. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #ifndef CHOOSE_HILL_H #define CHOOSE_HILL_H diff --git a/src/choose_hill.cxx b/src/choose_hill.cxx index f144d5e..9162e40 100644 --- a/src/choose_hill.cxx +++ b/src/choose_hill.cxx @@ -1,24 +1,3 @@ -// -// Search Chooser widget for the Fast Light Tool Kit (FLTK). -// -// Copyright by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// -// #include #include diff --git a/src/gipfel.cxx b/src/gipfel.cxx index dc15d8e..3ec7290 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -1,23 +1,3 @@ -// -// gipfel program. -// -// Copyright 2006 by Johannes Hofmann -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include -- cgit v1.2.3 From 6c50749f40e50a4b6a260a262b40035bfe83fd76 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 20:49:30 +0100 Subject: add simplified copyright --- src/Fl_Search_Chooser.H | 5 +++++ src/Fl_Search_Chooser.cxx | 5 +++++ src/Fl_Value_Dial.H | 5 +++++ src/Fl_Value_Dial.cxx | 5 +++++ src/GipfelWidget.H | 5 +++++ src/GipfelWidget.cxx | 5 +++++ src/Hill.H | 5 +++++ src/Hill.cxx | 5 +++++ src/ImageMetaData.H | 5 +++++ src/ImageMetaData.cxx | 5 +++++ src/JPEGOutputImage.H | 5 +++++ src/JPEGOutputImage.cxx | 5 +++++ src/OutputImage.H | 5 +++++ src/OutputImage.cxx | 5 +++++ src/Panorama.H | 5 +++++ src/Panorama.cxx | 5 +++++ src/PreviewOutputImage.H | 5 +++++ src/PreviewOutputImage.cxx | 5 +++++ src/Projection.H | 5 +++++ src/Projection.cxx | 5 +++++ src/ProjectionSphaeric.H | 5 +++++ src/ProjectionSphaeric.cxx | 5 +++++ src/ProjectionTangential.H | 5 +++++ src/ProjectionTangential.cxx | 5 +++++ src/Stitch.H | 5 +++++ src/Stitch.cxx | 5 +++++ src/TIFFOutputImage.H | 5 +++++ src/TIFFOutputImage.cxx | 5 +++++ src/ViewParams.H | 5 +++++ src/choose_hill.H | 5 +++++ src/choose_hill.cxx | 5 +++++ src/gipfel.cxx | 5 +++++ 32 files changed, 160 insertions(+) diff --git a/src/Fl_Search_Chooser.H b/src/Fl_Search_Chooser.H index c5e88d9..d3478c2 100644 --- a/src/Fl_Search_Chooser.H +++ b/src/Fl_Search_Chooser.H @@ -1,3 +1,8 @@ +// +// 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 FL_SEARCH_CHOOSER_H #define FL_SEARCH_CHOOSER_H diff --git a/src/Fl_Search_Chooser.cxx b/src/Fl_Search_Chooser.cxx index f1cd6c3..28396a0 100644 --- a/src/Fl_Search_Chooser.cxx +++ b/src/Fl_Search_Chooser.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/Fl_Value_Dial.H b/src/Fl_Value_Dial.H index 71e32a4..35a3adf 100644 --- a/src/Fl_Value_Dial.H +++ b/src/Fl_Value_Dial.H @@ -1,3 +1,8 @@ +// +// 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 Fl_Value_Dial_H #define Fl_Value_Dial_H diff --git a/src/Fl_Value_Dial.cxx b/src/Fl_Value_Dial.cxx index 482ec2e..773cb58 100644 --- a/src/Fl_Value_Dial.cxx +++ b/src/Fl_Value_Dial.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index 86e8d07..4b3166e 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 30320de..2927cde 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/Hill.H b/src/Hill.H index 5c8aca7..37ab44a 100644 --- a/src/Hill.H +++ b/src/Hill.H @@ -1,3 +1,8 @@ +// +// 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 HILL_H #define HILL_H diff --git a/src/Hill.cxx b/src/Hill.cxx index 5ec35ee..14b8f81 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H index 6cb16fe..5796964 100644 --- a/src/ImageMetaData.H +++ b/src/ImageMetaData.H @@ -1,3 +1,8 @@ +// +// 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 IMAGE_META_DATA_H #define IMAGE_META_DATA_H diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx index 6d66954..6519239 100644 --- a/src/ImageMetaData.cxx +++ b/src/ImageMetaData.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/JPEGOutputImage.H b/src/JPEGOutputImage.H index 4a9e60f..b3554c8 100644 --- a/src/JPEGOutputImage.H +++ b/src/JPEGOutputImage.H @@ -1,3 +1,8 @@ +// +// 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 JPEGOUTPUTIMAGE_H #define JPEGOUTPUTIMAGE_H diff --git a/src/JPEGOutputImage.cxx b/src/JPEGOutputImage.cxx index 7ca4cb5..6e685d0 100644 --- a/src/JPEGOutputImage.cxx +++ b/src/JPEGOutputImage.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/OutputImage.H b/src/OutputImage.H index bae0ff5..9be72c5 100644 --- a/src/OutputImage.H +++ b/src/OutputImage.H @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/OutputImage.cxx b/src/OutputImage.cxx index e4da537..ddf8e14 100644 --- a/src/OutputImage.cxx +++ b/src/OutputImage.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/Panorama.H b/src/Panorama.H index 3f8312a..80a8f69 100644 --- a/src/Panorama.H +++ b/src/Panorama.H @@ -1,3 +1,8 @@ +// +// 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 PANORAMA_H #define PANORAMA_H diff --git a/src/Panorama.cxx b/src/Panorama.cxx index f964e40..4674c47 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/PreviewOutputImage.H b/src/PreviewOutputImage.H index 5852730..8b41684 100644 --- a/src/PreviewOutputImage.H +++ b/src/PreviewOutputImage.H @@ -1,3 +1,8 @@ +// +// 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 PREVIEWOUTPUTIMAGE_H #define PREVIEWOUTPUTIMAGE_H diff --git a/src/PreviewOutputImage.cxx b/src/PreviewOutputImage.cxx index 3caef7f..4b1d993 100644 --- a/src/PreviewOutputImage.cxx +++ b/src/PreviewOutputImage.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/Projection.H b/src/Projection.H index cb9bc7e..6db0e97 100644 --- a/src/Projection.H +++ b/src/Projection.H @@ -1,3 +1,8 @@ +// +// 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 PROJECTION_H #define PROJECTION_H diff --git a/src/Projection.cxx b/src/Projection.cxx index d6dbd34..88ec5bf 100644 --- a/src/Projection.cxx +++ b/src/Projection.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/ProjectionSphaeric.H b/src/ProjectionSphaeric.H index 49fc74d..f80940a 100644 --- a/src/ProjectionSphaeric.H +++ b/src/ProjectionSphaeric.H @@ -1,3 +1,8 @@ +// +// 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 PROJECTIONSPHAERIC_H #define PROJECTIONSPHAERIC_H diff --git a/src/ProjectionSphaeric.cxx b/src/ProjectionSphaeric.cxx index dbbcec6..d4e7e43 100644 --- a/src/ProjectionSphaeric.cxx +++ b/src/ProjectionSphaeric.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/ProjectionTangential.H b/src/ProjectionTangential.H index 77c10d7..07ddaf9 100644 --- a/src/ProjectionTangential.H +++ b/src/ProjectionTangential.H @@ -1,3 +1,8 @@ +// +// 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 PROJECTIONTANGENTIAL_H #define PROJECTIONTANGENTIAL_H diff --git a/src/ProjectionTangential.cxx b/src/ProjectionTangential.cxx index 230662a..230767c 100644 --- a/src/ProjectionTangential.cxx +++ b/src/ProjectionTangential.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/Stitch.H b/src/Stitch.H index 2fbde1f..d29c2e9 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -1,3 +1,8 @@ +// +// 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 STITCH_H #define STITCH_H diff --git a/src/Stitch.cxx b/src/Stitch.cxx index ec1daf6..f378747 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/TIFFOutputImage.H b/src/TIFFOutputImage.H index 1c9aad8..820a281 100644 --- a/src/TIFFOutputImage.H +++ b/src/TIFFOutputImage.H @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/TIFFOutputImage.cxx b/src/TIFFOutputImage.cxx index b528521..cc1b289 100644 --- a/src/TIFFOutputImage.cxx +++ b/src/TIFFOutputImage.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/ViewParams.H b/src/ViewParams.H index ba24f22..b6f34a2 100644 --- a/src/ViewParams.H +++ b/src/ViewParams.H @@ -1,3 +1,8 @@ +// +// 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 VIEWPARAMS_H #define VIEWPARAMS_H diff --git a/src/choose_hill.H b/src/choose_hill.H index 76fb018..2425fa3 100644 --- a/src/choose_hill.H +++ b/src/choose_hill.H @@ -1,3 +1,8 @@ +// +// 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 CHOOSE_HILL_H #define CHOOSE_HILL_H diff --git a/src/choose_hill.cxx b/src/choose_hill.cxx index 9162e40..d3477f3 100644 --- a/src/choose_hill.cxx +++ b/src/choose_hill.cxx @@ -1,3 +1,8 @@ +// +// 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 diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 3ec7290..343d19f 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -1,3 +1,8 @@ +// +// 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 -- cgit v1.2.3 From 676ba063252eb60049e772df52a6fd687e89461b Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 21:22:43 +0100 Subject: more copyright simplification --- src/util.c | 25 ++++--------------------- src/util.h | 24 ++++-------------------- 2 files changed, 8 insertions(+), 41 deletions(-) diff --git a/src/util.c b/src/util.c index f33c1b4..df3126d 100644 --- a/src/util.c +++ b/src/util.c @@ -1,26 +1,9 @@ -/* - * "$Id: util.c,v 1.1 2005/02/28 17:56:51 hofmann Exp $" +/* + * Copyright 2006 Johannes Hofmann * - * flpsed program. - * - * Copyright 2005 by Johannes Hofmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. */ - #include #include #include diff --git a/src/util.h b/src/util.h index d5a71e1..ad0e423 100644 --- a/src/util.h +++ b/src/util.h @@ -1,24 +1,8 @@ -/* - * "$Id: util.h,v 1.2 2005/03/17 18:46:20 hofmann Exp $" +/* + * Copyright 2006 Johannes Hofmann * - * flpsed program. - * - * Copyright 2005 by Johannes Hofmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. */ #ifndef _UTIL_H_ #define _UTIL_H_ -- cgit v1.2.3 From ea2c78254d2c487d838b23e90dd3672dfd6939fc Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 21:31:32 +0100 Subject: fix segfault in Fl_Search_Chooser --- src/Fl_Search_Chooser.H | 1 - src/Fl_Search_Chooser.cxx | 5 ----- 2 files changed, 6 deletions(-) diff --git a/src/Fl_Search_Chooser.H b/src/Fl_Search_Chooser.H index d3478c2..821ffdd 100644 --- a/src/Fl_Search_Chooser.H +++ b/src/Fl_Search_Chooser.H @@ -28,7 +28,6 @@ class Fl_Search_Chooser { Fl_Search_Browser *sb; Fl_Search_Chooser(const char *title); - ~Fl_Search_Chooser(); void add(const char *t, void *d); void *data(); diff --git a/src/Fl_Search_Chooser.cxx b/src/Fl_Search_Chooser.cxx index 28396a0..d9bc92c 100644 --- a/src/Fl_Search_Chooser.cxx +++ b/src/Fl_Search_Chooser.cxx @@ -83,11 +83,6 @@ Fl_Search_Chooser::Fl_Search_Chooser(const char *title) { w->end(); } -Fl_Search_Chooser::~Fl_Search_Chooser() { - delete sb; - delete w; -} - void Fl_Search_Chooser::add(const char *t, void *d) { sb->add(t, d); -- cgit v1.2.3 From 09419b6f28bb7058c43501d1e1e10b71ef2499ab Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 21:48:01 +0100 Subject: increase max focal length --- src/gipfel.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 343d19f..3c204b7 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -230,12 +230,12 @@ create_control_window() { Fl_Box *west = 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 = 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, 200.0); + 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); -- cgit v1.2.3 From 3065ecc1e1c44770ecad9e4bf29c4b71f0a2bc52 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 22:19:08 +0100 Subject: reindent --- src/gipfel.cxx | 687 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 344 insertions(+), 343 deletions(-) diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 3c204b7..6eb4ee9 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -52,426 +52,427 @@ Fl_Menu_Bar *mb; #define STITCH_JPEG 2 #define STITCH_TIFF 4 static int stitch(int stitch_w, int stitch_h, int type, const char *path, - int argc, char **argv); + int argc, char **argv); void set_values() { - 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->get_projection() == Projection::TANGENTIAL) { - mb->mode(8, FL_MENU_RADIO|FL_MENU_VALUE); - mb->mode(9, FL_MENU_RADIO); - } else { - mb->mode(9, FL_MENU_RADIO|FL_MENU_VALUE); - mb->mode(8, FL_MENU_RADIO); - } + 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->get_projection() == Projection::TANGENTIAL) { + mb->mode(8, FL_MENU_RADIO|FL_MENU_VALUE); + mb->mode(9, FL_MENU_RADIO); + } else { + mb->mode(9, FL_MENU_RADIO|FL_MENU_VALUE); + mb->mode(8, FL_MENU_RADIO); + } } void quit_cb() { - exit(0); + exit(0); } void open_cb() { - char *file = fl_file_chooser("Open File?", "*.jpg", img_file); - if(file != NULL) { - gipf->load_image(file); - set_values(); - } + char *file = fl_file_chooser("Open File?", "*.jpg", img_file); + if(file != NULL) { + gipf->load_image(file); + set_values(); + } } void track_cb() { - char *file = fl_file_chooser("Track File?", NULL, NULL); - if (gipf->load_track(file) == 0) { - s_track_width->activate(); - } + char *file = fl_file_chooser("Track File?", NULL, NULL); + if (gipf->load_track(file) == 0) { + s_track_width->activate(); + } } void save_cb() { - char *file = fl_file_chooser("Save Image As?", NULL, NULL); - if (file) { - gipf->save_image(file); - } + char *file = fl_file_chooser("Save Image As?", NULL, NULL); + if (file) { + gipf->save_image(file); + } } void focal_length_cb(Fl_Slider* o, void*) { - gipf->set_focal_length_35mm(o->value()); + gipf->set_focal_length_35mm(o->value()); } void angle_cb(Fl_Slider* o, void*) { - gipf->set_center_angle(o->value()); + gipf->set_center_angle(o->value()); } void nick_cb(Fl_Slider* o, void*) { - gipf->set_nick_angle(o->value()); + gipf->set_nick_angle(o->value()); } void tilt_cb(Fl_Slider* o, void*) { - gipf->set_tilt_angle(o->value()); + gipf->set_tilt_angle(o->value()); } void h_d_cb(Fl_Slider* o, void*) { - gipf->set_height_dist_ratio(o->value()); + gipf->set_height_dist_ratio(o->value()); } void view_lat_cb(Fl_Value_Input* o, void*) { - gipf->set_view_lat(o->value()); + gipf->set_view_lat(o->value()); } void view_long_cb(Fl_Value_Input* o, void*) { - gipf->set_view_long(o->value()); + gipf->set_view_long(o->value()); } void view_height_cb(Fl_Value_Input* o, void*) { - gipf->set_view_height(o->value()); + gipf->set_view_height(o->value()); } void track_width_cb(Fl_Value_Input* o, void*) { - gipf->set_track_width(o->value()); + 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(); - } + 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 == NULL) { - gipf->set_projection(Projection::TANGENTIAL); - } else { - gipf->set_projection(Projection::SPHAERIC); - } + if(d == NULL) { + gipf->set_projection(Projection::TANGENTIAL); + } else { + gipf->set_projection(Projection::SPHAERIC); + } } void hidden_cb(Fl_Menu_* o, void*d) { - gipf->set_show_hidden(o->mvalue()->value()); + gipf->set_show_hidden(o->mvalue()->value()); } void comp_cb(Fl_Widget *, void *) { - gipf->comp_params(); - set_values(); + gipf->comp_params(); + set_values(); } void guess_cb(Fl_Widget *, void *) { - gipf->guess(); - set_values(); + gipf->guess(); + set_values(); } void about_cb() { - fl_message("gipfel -- and you know what you see.\n" - "Version %s\n\n" - "(c) Johannes Hofmann 2006\n\n" - "Default datafile by http://www.alpin-koordinaten.de\n", - VERSION); + fl_message("gipfel -- and you know what you see.\n" + "Version %s\n\n" + "(c) Johannes Hofmann 2006\n\n" + "Default datafile by http://www.alpin-koordinaten.de\n", + VERSION); } 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/&Quit", FL_CTRL+'q', (Fl_Callback*)quit_cb); + 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/&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("&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("&Option/Show Hidden", 0, (Fl_Callback *) hidden_cb, + (void *)0, FL_MENU_TOGGLE); - mb->add("&Option/Show Hidden", 0, (Fl_Callback *) hidden_cb, - (void *)0, FL_MENU_TOGGLE); - - mb->add("&Help/About", 0, (Fl_Callback*)about_cb); + mb->add("&Help/About", 0, (Fl_Callback*)about_cb); } void usage() { - fprintf(stderr, - "usage: gipfel [-v ] [-d ]\n" - " [-s] [-j ] [-t ] [-h ]\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" - " -s Stitch mode.\n" - " -w Width of result image.\n" - " -h Height of result image.\n" - " -j JPEG output file for Stitch mode.\n" - " -t Output directory for TIFF images in Stitch mode.\n" - " JPEG file(s) to use.\n"); + fprintf(stderr, + "usage: gipfel [-v ] [-d ]\n" + " [-s] [-j ] [-t ] [-h ]\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" + " -s Stitch mode.\n" + " -w Width of result image.\n" + " -h Height of result image.\n" + " -j JPEG output file for Stitch mode.\n" + " -t Output directory for TIFF images in Stitch mode.\n" + " JPEG file(s) to use.\n"); } Fl_Window * create_control_window() { - Fl_Window *win = new Fl_Window(400,350); - 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); - - Fl_Box *north = new Fl_Box(95, 40, 40, 20, "North"); - Fl_Box *south = new Fl_Box(95, 210, 40, 20, "South"); - Fl_Box *east = new Fl_Box(190, 125, 40, 20, "East"); - Fl_Box *west = 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(-20.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, 255, 300, 80, ""); - b_viewpoint->align(FL_ALIGN_TOP); - - i_view_lat = new Fl_Value_Input(40, 270, 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, 270, 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, 310, 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); - - // Buttons - Fl_Button *b = new Fl_Button(240, 210, 60, 20, "comp"); - b->color(FL_RED); - b->callback(comp_cb); - Fl_Button *b1 = new Fl_Button(320, 210, 60, 20, "guess"); - b1->callback(guess_cb); - b1->color(FL_GREEN); - - win->end(); - return win; + Fl_Window *win = new Fl_Window(400,350); + 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); + + Fl_Box *north = new Fl_Box(95, 40, 40, 20, "North"); + Fl_Box *south = new Fl_Box(95, 210, 40, 20, "South"); + Fl_Box *east = new Fl_Box(190, 125, 40, 20, "East"); + Fl_Box *west = 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(-20.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, 255, 300, 80, ""); + b_viewpoint->align(FL_ALIGN_TOP); + + i_view_lat = new Fl_Value_Input(40, 270, 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, 270, 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, 310, 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); + + // Buttons + Fl_Button *b = new Fl_Button(240, 210, 60, 20, "comp"); + b->color(FL_RED); + b->callback(comp_cb); + Fl_Button *b1 = new Fl_Button(320, 210, 60, 20, "guess"); + b1->callback(guess_cb); + b1->color(FL_GREEN); + + win->end(); + return win; } int main(int argc, char** argv) { - char c, *sep, *tmp, **my_argv; - char *view_point = NULL; - int err, bflag = 0, dflag = 0, my_argc; - int stitch_flag = 0, stitch_w = 2000, stitch_h = 500; - int jpeg_flag = 0, tiff_flag = 0; - char *outpath; - Fl_Window *control_win, *view_win; - Fl_Scroll *scroll; - - - err = 0; - while ((c = getopt(argc, argv, "?d:v:sw:h:j:t:")) != EOF) { - switch (c) { - case '?': - usage(); - exit(0); - break; - case 'd': - data_file = optarg; - break; - case 'v': - view_point = optarg; - break; - case 's': - stitch_flag++; - 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; - default: - err++; - } - } - - - my_argc = argc - optind; - my_argv = argv + optind; - - if (my_argc >= 1) { - img_file = my_argv[0]; - } - - if (data_file == NULL || err) { - usage(); - exit(1); - } - - if (stitch_flag) { - int type = STITCH_PREVIEW; - if (jpeg_flag) { - type = STITCH_JPEG; - } else if (tiff_flag) { - type = STITCH_TIFF; - } - stitch(stitch_w, stitch_h, type, outpath, my_argc, my_argv); - exit(0); - } - - Fl::get_system_colors(); - if (getenv("FLTK_SCHEME")) { - Fl::scheme(NULL); - } else { - Fl::scheme("plastic"); - } - - control_win = create_control_window(); - - view_win = new Fl_Window(800, 600); - - // 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); - if (img_file) { - gipf->load_image(img_file); - } - - view_win->size(gipf->w(), gipf->h()); - scroll->size(gipf->w(), gipf->h()); - - gipf->load_data(data_file); - 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(); + char c, *sep, *tmp, **my_argv; + char *view_point = NULL; + int err, bflag = 0, dflag = 0, my_argc; + int stitch_flag = 0, stitch_w = 2000, stitch_h = 500; + int jpeg_flag = 0, tiff_flag = 0; + char *outpath; + Fl_Window *control_win, *view_win; + Fl_Scroll *scroll; + + + err = 0; + while ((c = getopt(argc, argv, "?d:v:sw:h:j:t:")) != EOF) { + switch (c) { + case '?': + usage(); + exit(0); + break; + case 'd': + data_file = optarg; + break; + case 'v': + view_point = optarg; + break; + case 's': + stitch_flag++; + 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; + default: + err++; + } + } + + + my_argc = argc - optind; + my_argv = argv + optind; + + if (my_argc >= 1) { + img_file = my_argv[0]; + } + + if (data_file == NULL || err) { + usage(); + exit(1); + } + + if (stitch_flag) { + int type = STITCH_PREVIEW; + if (jpeg_flag) { + type = STITCH_JPEG; + } else if (tiff_flag) { + type = STITCH_TIFF; + } + stitch(stitch_w, stitch_h, type, outpath, my_argc, my_argv); + exit(0); + } + + Fl::get_system_colors(); + if (getenv("FLTK_SCHEME")) { + Fl::scheme(NULL); + } else { + Fl::scheme("plastic"); + } + + control_win = create_control_window(); + + view_win = new Fl_Window(800, 600); + + // 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); + if (img_file) { + gipf->load_image(img_file); + } + + view_win->size(gipf->w(), gipf->h()); + scroll->size(gipf->w(), gipf->h()); + + gipf->load_data(data_file); + 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(int stitch_w, int stitch_h, int type, const char *path, int argc, char **argv) { - Fl_Window *win; - Fl_Scroll *scroll; - Stitch *st = new Stitch(); - - for (int i=0; iload_image(argv[i]); - } - - if (type == STITCH_JPEG) { - - st->set_output((OutputImage*) new JPEGOutputImage(path, 90)); - st->resample(stitch_w, stitch_h, 0.0, 7.0); - - } else if (type == STITCH_TIFF) { - - for (int i=0; iset_output(argv[i], (OutputImage*) new TIFFOutputImage(buf)); - } - - st->resample(stitch_w, stitch_h, 0.0, 7.0); - - } 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((OutputImage*) img); - st->resample(stitch_w, stitch_h, 0.0, 7.0); - img->redraw(); - Fl::run(); - } - - return 0; + Fl_Window *win; + Fl_Scroll *scroll; + Stitch *st = new Stitch(); + + for (int i=0; iload_image(argv[i]); + } + + if (type == STITCH_JPEG) { + + st->set_output((OutputImage*) new JPEGOutputImage(path, 90)); + st->resample(stitch_w, stitch_h, 0.0, 7.0); + + } else if (type == STITCH_TIFF) { + + for (int i=0; iset_output(argv[i], (OutputImage*) new TIFFOutputImage(buf)); + } + + st->resample(stitch_w, stitch_h, 0.0, 7.0); + + } 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((OutputImage*) img); + st->resample(stitch_w, stitch_h, 0.0, 7.0); + img->redraw(); + Fl::run(); + } + + return 0; } -- cgit v1.2.3 From f8fb82ba705f6314d502b8efc8f03ecd16b8bed8 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 22:27:04 +0100 Subject: more reindent --- src/Fl_Search_Chooser.H | 30 +- src/Fl_Search_Chooser.cxx | 117 +++--- src/Fl_Value_Dial.H | 26 +- src/Fl_Value_Dial.cxx | 90 ++--- src/GipfelWidget.H | 122 +++--- src/GipfelWidget.cxx | 916 +++++++++++++++++++++---------------------- src/Hill.H | 96 ++--- src/Hill.cxx | 396 +++++++++---------- src/Panorama.H | 140 +++---- src/Panorama.cxx | 698 ++++++++++++++++----------------- src/Projection.H | 24 +- src/Projection.cxx | 10 +- src/ProjectionSphaeric.H | 18 +- src/ProjectionSphaeric.cxx | 198 +++++----- src/ProjectionTangential.H | 20 +- src/ProjectionTangential.cxx | 410 +++++++++---------- src/Stitch.H | 6 +- src/Stitch.cxx | 4 +- src/ViewParams.H | 10 +- src/choose_hill.cxx | 52 +-- src/util.c | 82 ++-- src/util.h | 4 +- 22 files changed, 1734 insertions(+), 1735 deletions(-) diff --git a/src/Fl_Search_Chooser.H b/src/Fl_Search_Chooser.H index 821ffdd..e968452 100644 --- a/src/Fl_Search_Chooser.H +++ b/src/Fl_Search_Chooser.H @@ -12,27 +12,27 @@ #include class Fl_Search_Browser : public Fl_Select_Browser { - public: - - Fl_Search_Browser(int X, int Y, int W, int H, const char *c):Fl_Select_Browser(X,Y,W,H,c){}; + public: - int find_prefix(const char *p); - private: - int find_prefix(const char *p, int s, int e); + 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); + private: + int find_prefix(const char *p, int s, int e); }; class Fl_Search_Chooser { - private: - public: - Fl_Window *w; - Fl_Search_Browser *sb; + private: + public: + Fl_Window *w; + Fl_Search_Browser *sb; - Fl_Search_Chooser(const char *title); + Fl_Search_Chooser(const char *title); - void add(const char *t, void *d); - void *data(); - void show(); - int shown(); + void add(const char *t, void *d); + void *data(); + void show(); + int shown(); }; #endif diff --git a/src/Fl_Search_Chooser.cxx b/src/Fl_Search_Chooser.cxx index d9bc92c..d4f93b2 100644 --- a/src/Fl_Search_Chooser.cxx +++ b/src/Fl_Search_Chooser.cxx @@ -13,98 +13,97 @@ 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 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); - } - } + 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); + } + } } static void input_cb(Fl_Input* in, void*c) { - Fl_Search_Browser *sb = ((Fl_Search_Chooser *) c)->sb; - sb->find_prefix(in->value()); + Fl_Search_Browser *sb = ((Fl_Search_Chooser *) c)->sb; + sb->find_prefix(in->value()); } static void ok_cb(Fl_Input* in, void*c) { - Fl_Search_Chooser *sc = (Fl_Search_Chooser *) c; - sc->w->hide(); + Fl_Search_Chooser *sc = (Fl_Search_Chooser *) c; + sc->w->hide(); } static void cancel_cb(Fl_Input* in, void*c) { - Fl_Search_Chooser *sc = (Fl_Search_Chooser *) c; - sc->sb->deselect(); - sc->w->hide(); + Fl_Search_Chooser *sc = (Fl_Search_Chooser *) c; + sc->sb->deselect(); + sc->w->hide(); } Fl_Search_Chooser::Fl_Search_Chooser(const char *title) { - w = new Fl_Window(320, 320, title?title:"Choose"); - Fl_Group *g = new Fl_Group(10, 10, w->w() - 10, w->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_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(); - w->end(); + w = new Fl_Window(320, 320, title?title:"Choose"); + Fl_Group *g = new Fl_Group(10, 10, w->w() - 10, w->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_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(); + w->end(); } void Fl_Search_Chooser::add(const char *t, void *d) { - sb->add(t, d); + sb->add(t, d); } void * Fl_Search_Chooser::data() { - int v = sb->value(); - if (v) { - return sb->data(v); - } else { - return NULL; - } + int v = sb->value(); + if (v) { + return sb->data(v); + } else { + return NULL; + } } void Fl_Search_Chooser::show() { - w->show(); + w->show(); } int Fl_Search_Chooser::shown() { - return w->shown(); + return w->shown(); } - diff --git a/src/Fl_Value_Dial.H b/src/Fl_Value_Dial.H index 35a3adf..94fda5a 100644 --- a/src/Fl_Value_Dial.H +++ b/src/Fl_Value_Dial.H @@ -10,19 +10,19 @@ #include class Fl_Value_Dial : public Fl_Dial { - 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;} + 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 index 773cb58..f210ca3 100644 --- a/src/Fl_Value_Dial.cxx +++ b/src/Fl_Value_Dial.cxx @@ -10,57 +10,57 @@ #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; -} + : 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(); + int sxx = x(), syy = y(), sww = w(), shh = h(); + int bxx = x(), byy = y(), bww = w(), bhh = h(); - 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())); + 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())); - char buf[128]; - format(buf); - fl_font(textfont(), textsize()); + char buf[128]; + format(buf); + 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); + 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); - } + 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 index 4b3166e..adbb623 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -12,108 +12,108 @@ #include "Panorama.H" class GipfelWidget : public Fl_Widget { - private: - Fl_Image *img; - Hill *cur_mountain; - Hills *marker; - Hills *track_points; - Hill *m1, *m2; - Panorama *pan; - Fl_Menu_Button *mb; - char *img_file; - double track_width; - int show_hidden; + private: + Fl_Image *img; + Hill *cur_mountain; + Hills *marker; + Hills *track_points; + Hill *m1, *m2; + Panorama *pan; + Fl_Menu_Button *mb; + char *img_file; + double track_width; + int show_hidden; - int handle(int event); + int handle(int event); - int set_cur_mountain(int m_x, int m_y); + int set_cur_mountain(int m_x, int m_y); - int set_mountain(int m_x, int m_y); + int set_mountain(int m_x, int m_y); - void set_labels(Hills *v); + void set_labels(Hills *v); - int get_rel_track_width(Hill *m); + int get_rel_track_width(Hill *m); - static int get_pixel_nearest(Fl_Image *img, double x, double y, - char *r, char *g, char *b); + static int get_pixel_nearest(Fl_Image *img, double x, double y, + char *r, char *g, char *b); - static int get_pixel(Fl_Image *img, int x, int y, - char *r, char *g, char *b); + static int get_pixel(Fl_Image *img, int x, int y, + char *r, char *g, char *b); - public: - GipfelWidget(int X,int Y,int W, int H); + public: + GipfelWidget(int X,int Y,int W, int H); - void center(); + void center(); - int load_image(char *file); + int load_image(char *file); - int save_image(char *file); - - const char * get_image_filename(); + int save_image(char *file); - int load_data(const char *file); + const char * get_image_filename(); - int load_track(const char *file); + int load_data(const char *file); - int set_viewpoint(const char *pos); + int load_track(const char *file); - void set_viewpoint(const Hill *m); + int set_viewpoint(const char *pos); - void set_center_angle(double a); + void set_viewpoint(const Hill *m); - void set_nick_angle(double a); + void set_center_angle(double a); - void set_tilt_angle(double a); + void set_nick_angle(double a); - void set_focal_length_35mm(double s); + void set_tilt_angle(double a); - void set_height_dist_ratio(double r); + void set_focal_length_35mm(double s); - void set_hide_value(double h); + void set_height_dist_ratio(double r); - void set_show_hidden(int h); + void set_hide_value(double h); - void set_view_lat(double v); + void set_show_hidden(int h); - void set_view_long(double v); + void set_view_lat(double v); - void set_view_height(double v); - - const char * get_viewpoint(); + void set_view_long(double v); - double get_center_angle(); + void set_view_height(double v); - double get_nick_angle(); + const char * get_viewpoint(); - double get_tilt_angle(); + double get_center_angle(); - double get_focal_length_35mm(); + double get_nick_angle(); - double get_height_dist_ratio(); + double get_tilt_angle(); - double get_view_lat(); + double get_focal_length_35mm(); - double get_view_long(); + double get_height_dist_ratio(); - double get_view_height(); + double get_view_lat(); - void set_track_width(double w); + double get_view_long(); - Projection::Projection_t get_projection(); + double get_view_height(); - void set_projection(Projection::Projection_t p); + void set_track_width(double w); - Hills *get_mountains(); + Projection::Projection_t get_projection(); - int comp_params(); + void set_projection(Projection::Projection_t p); - int guess(); + Hills *get_mountains(); - int update(); + int comp_params(); - int get_pixel(double a_view, double a_nick, - char *r, char *g, char *b); + int guess(); - void draw(); + int update(); + + int get_pixel(double a_view, double a_nick, + char *r, char *g, char *b); + + void draw(); }; #endif diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 2927cde..23cb075 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -37,75 +37,75 @@ static double pi_d, deg2rad; static void center_cb(Fl_Widget *o, void *f); GipfelWidget::GipfelWidget(int X,int Y,int W, int H): Fl_Widget(X, Y, W, H) { - int i; - - pi_d = asin(1.0) * 2.0; - deg2rad = pi_d / 180.0; - img = NULL; - pan = new Panorama(); - cur_mountain = NULL; - mb = NULL; - marker = new Hills(); - m1 = NULL; - m2 = NULL; - img_file = NULL; - track_width = 200.0; - show_hidden = 0; - - for (i=0; i<=3; i++) { - marker->add(new Hill(i * 10, 0)); - } - track_points = NULL; - fl_register_images(); + int i; + + pi_d = asin(1.0) * 2.0; + deg2rad = pi_d / 180.0; + img = NULL; + pan = new Panorama(); + cur_mountain = NULL; + mb = NULL; + marker = new Hills(); + m1 = NULL; + m2 = NULL; + img_file = NULL; + track_width = 200.0; + show_hidden = 0; + + for (i=0; i<=3; i++) { + marker->add(new Hill(i * 10, 0)); + } + track_points = NULL; + fl_register_images(); } int GipfelWidget::load_image(char *file) { - Fl_Image *new_img; - ImageMetaData *md; - int ret; + Fl_Image *new_img; + ImageMetaData *md; + int ret; + + new_img = new Fl_JPEG_Image(file); + + if (new_img == NULL) { + return 1; + } - new_img = new Fl_JPEG_Image(file); - - if (new_img == NULL) { - return 1; - } + if (img) { + delete img; + } - if (img) { - delete img; - } + img = new_img; - img = new_img; - - if (img_file) { - free(img_file); - } + if (img_file) { + free(img_file); + } - img_file = strdup(file); + img_file = strdup(file); - h(img->h()); - w(img->w()); + h(img->h()); + w(img->w()); - mb = new Fl_Menu_Button(x(),y(),w()+x(),h()+y(),"&popup"); - mb->type(Fl_Menu_Button::POPUP3); - mb->box(FL_NO_BOX); - mb->add("Center Peak", 0, (Fl_Callback*) center_cb, this); + mb = new Fl_Menu_Button(x(),y(),w()+x(),h()+y(),"&popup"); + mb->type(Fl_Menu_Button::POPUP3); + mb->box(FL_NO_BOX); + mb->add("Center Peak", 0, (Fl_Callback*) center_cb, this); - // try to retrieve gipfel data from JPEG meta data - md = new ImageMetaData(); - md->load_image(file, img->w()); - set_view_long(md->get_longitude()); - set_view_lat(md->get_latitude()); - set_view_height(md->get_height()); - set_center_angle(md->get_direction()); - set_nick_angle(md->get_nick()); - set_tilt_angle(md->get_tilt()); - set_projection((Projection::Projection_t) md->get_projection_type()); - set_focal_length_35mm(md->get_focal_length_35mm()); + // try to retrieve gipfel data from JPEG meta data + md = new ImageMetaData(); + md->load_image(file, img->w()); + set_view_long(md->get_longitude()); + set_view_lat(md->get_latitude()); + set_view_height(md->get_height()); + set_center_angle(md->get_direction()); + set_nick_angle(md->get_nick()); + set_tilt_angle(md->get_tilt()); + set_projection((Projection::Projection_t) md->get_projection_type()); + set_focal_length_35mm(md->get_focal_length_35mm()); - delete md; + delete md; - return 0; + return 0; } const char * @@ -115,557 +115,557 @@ GipfelWidget::get_image_filename() { int GipfelWidget::save_image(char *file) { - ImageMetaData *md; - int ret; + ImageMetaData *md; + int ret; - if (img_file == NULL) { - fprintf(stderr, "Nothing to save\n"); - return 1; - } + if (img_file == NULL) { + fprintf(stderr, "Nothing to save\n"); + return 1; + } - md = new ImageMetaData(); + md = new ImageMetaData(); - md->set_longitude(get_view_long()); - md->set_latitude(get_view_lat()); - md->set_height(get_view_height()); - md->set_direction(get_center_angle()); - md->set_nick(get_nick_angle()); - md->set_tilt(get_tilt_angle()); - md->set_focal_length_35mm(get_focal_length_35mm()); - md->set_projection_type((int) get_projection()); + md->set_longitude(get_view_long()); + md->set_latitude(get_view_lat()); + md->set_height(get_view_height()); + md->set_direction(get_center_angle()); + md->set_nick(get_nick_angle()); + md->set_tilt(get_tilt_angle()); + md->set_focal_length_35mm(get_focal_length_35mm()); + md->set_projection_type((int) get_projection()); - ret = md->save_image(img_file, file); - delete md; + ret = md->save_image(img_file, file); + delete md; - return ret; + return ret; } int GipfelWidget::load_data(const char *file) { - int r; + int r; - r = pan->load_data(file); - set_labels(pan->get_visible_mountains()); + r = pan->load_data(file); + set_labels(pan->get_visible_mountains()); - return r; + return r; } int GipfelWidget::load_track(const char *file) { - if (track_points) { - pan->remove_trackpoints(); - track_points->clobber(); - delete track_points; - } + if (track_points) { + pan->remove_trackpoints(); + track_points->clobber(); + delete track_points; + } - track_points = new Hills(); + track_points = new Hills(); - if (track_points->load(file) != 0) { - delete track_points; - track_points = NULL; - return 1; - } + if (track_points->load(file) != 0) { + delete track_points; + track_points = NULL; + return 1; + } + + for (int i=0; iget_num(); i++) { + track_points->get(i)->flags |= Hill::TRACK_POINT; + } - for (int i=0; iget_num(); i++) { - track_points->get(i)->flags |= Hill::TRACK_POINT; - } + pan->add_hills(track_points); + redraw(); - pan->add_hills(track_points); - redraw(); - - return 0; + return 0; } int GipfelWidget::set_viewpoint(const char *pos) { - int r; + int r; - r = pan->set_viewpoint(pos); - set_labels(pan->get_visible_mountains()); + r = pan->set_viewpoint(pos); + set_labels(pan->get_visible_mountains()); - return r; + return r; } void GipfelWidget::set_viewpoint(const Hill *m) { - pan->set_viewpoint(m); - set_labels(pan->get_visible_mountains()); + pan->set_viewpoint(m); + set_labels(pan->get_visible_mountains()); } static void draw_flag(int x, int y, char *s) { - Fl_Color c = fl_color(); + Fl_Color c = fl_color(); - fl_polygon(x, y - 10, x, y - 20, x + 10, y - 15); - fl_yxline(x, y, y - 10); - + fl_polygon(x, y - 10, x, y - 20, x + 10, y - 15); + fl_yxline(x, y, y - 10); - if (s) { - fl_color(FL_WHITE); - fl_draw(s, x , y - 12); - fl_color(c); - } + + if (s) { + fl_color(FL_WHITE); + fl_draw(s, x , y - 12); + fl_color(c); + } } void GipfelWidget::draw() { - Hills *mnts; - Hill *m; - int center_x = w() / 2; - int center_y = h() / 2; - int i; - - if (img == NULL) { - return; - } - - fl_push_clip(x(), y(), w(), h()); - img->draw(x(),y(),w(),h(),0,0); - - /* hills */ - fl_font(FL_HELVETICA, 10); - mnts = pan->get_visible_mountains(); - for (i=0; iget_num(); i++) { - m = mnts->get(i); - - if (m->flags & (Hill::DUPLICATE|Hill::TRACK_POINT)) { - continue; - } - - if (!show_hidden && (m->flags & Hill::HIDDEN)) { - continue; - } - - if (m == m1) { - fl_color(FL_RED); - draw_flag(center_x + m->x + x(), center_y + m->y + y(), "1"); - } else if (m == m2) { - fl_color(FL_RED); - draw_flag(center_x + m->x + x(), center_y + m->y + y(), "2"); - } else if (m->flags & Hill::HIDDEN) { - fl_color(FL_BLUE); - } else { - fl_color(FL_BLACK); - } - - fl_xyline(center_x + m->x + x() - CROSS_SIZE, center_y + m->y + y(), center_x + m->x + x() + CROSS_SIZE); - fl_yxline(center_x + m->x + x(), center_y + m->y + m->label_y + y() - CROSS_SIZE, center_y + m->y + y() + CROSS_SIZE); - - fl_draw(m->name, - center_x + m->x + x(), - center_y + m->y + m->label_y + y()); - } - - /* markers */ - for (i=0; iget_num(); i++) { - m = marker->get(i); - - fl_color(FL_GREEN); - fl_xyline(center_x + m->x + x() - CROSS_SIZE * 2, center_y + m->y + y(), center_x + m->x + x() + CROSS_SIZE * 2); - fl_yxline(center_x + m->x + x(), center_y + m->y + y() - CROSS_SIZE * 2, center_y + m->y + y() + CROSS_SIZE * 2); - draw_flag(center_x + m->x + x(), center_y + m->y + y(), NULL); - } - - /* track */ - if (track_points && track_points->get_num() > 0) { - int last_x, last_y, last_initialized = 0; - - for (i=1; iget_num(); i++) { - 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(center_x + x() + last_x, center_y + y() + last_y); - fl_vertex(center_x + x() + track_points->get(i)->x, - center_y + y() + track_points->get(i)->y); - fl_end_line(); - } - - last_x = track_points->get(i)->x; - last_y = track_points->get(i)->y; - last_initialized++; - } - fl_line_style(0); - } - - fl_pop_clip(); + Hills *mnts; + Hill *m; + int center_x = w() / 2; + int center_y = h() / 2; + int i; + + if (img == NULL) { + return; + } + + fl_push_clip(x(), y(), w(), h()); + img->draw(x(),y(),w(),h(),0,0); + + /* hills */ + fl_font(FL_HELVETICA, 10); + mnts = pan->get_visible_mountains(); + for (i=0; iget_num(); i++) { + m = mnts->get(i); + + if (m->flags & (Hill::DUPLICATE|Hill::TRACK_POINT)) { + continue; + } + + if (!show_hidden && (m->flags & Hill::HIDDEN)) { + continue; + } + + if (m == m1) { + fl_color(FL_RED); + draw_flag(center_x + m->x + x(), center_y + m->y + y(), "1"); + } else if (m == m2) { + fl_color(FL_RED); + draw_flag(center_x + m->x + x(), center_y + m->y + y(), "2"); + } else if (m->flags & Hill::HIDDEN) { + fl_color(FL_BLUE); + } else { + fl_color(FL_BLACK); + } + + fl_xyline(center_x + m->x + x() - CROSS_SIZE, center_y + m->y + y(), center_x + m->x + x() + CROSS_SIZE); + fl_yxline(center_x + m->x + x(), center_y + m->y + m->label_y + y() - CROSS_SIZE, center_y + m->y + y() + CROSS_SIZE); + + fl_draw(m->name, + center_x + m->x + x(), + center_y + m->y + m->label_y + y()); + } + + /* markers */ + for (i=0; iget_num(); i++) { + m = marker->get(i); + + fl_color(FL_GREEN); + fl_xyline(center_x + m->x + x() - CROSS_SIZE * 2, center_y + m->y + y(), center_x + m->x + x() + CROSS_SIZE * 2); + fl_yxline(center_x + m->x + x(), center_y + m->y + y() - CROSS_SIZE * 2, center_y + m->y + y() + CROSS_SIZE * 2); + draw_flag(center_x + m->x + x(), center_y + m->y + y(), NULL); + } + + /* track */ + if (track_points && track_points->get_num() > 0) { + int last_x, last_y, last_initialized = 0; + + for (i=1; iget_num(); i++) { + 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(center_x + x() + last_x, center_y + y() + last_y); + fl_vertex(center_x + x() + track_points->get(i)->x, + center_y + y() + track_points->get(i)->y); + fl_end_line(); + } + + last_x = track_points->get(i)->x; + last_y = track_points->get(i)->y; + last_initialized++; + } + fl_line_style(0); + } + + fl_pop_clip(); } static int overlap(int m1, int n1, int m2, int n2) { - return m1 <= n2 && n1 >= m2; + return m1 <= n2 && n1 >= m2; } void GipfelWidget::set_labels(Hills *v) { - int i, j, width, height; - Hill *m, *n; - - fl_font(FL_HELVETICA, 10); - height = fl_height(); - - for (i=0; iget_num(); i++) { - m = v->get(i); - - if (m->flags & (Hill::DUPLICATE|Hill::TRACK_POINT)) { - continue; - } - - if (!show_hidden && (m->flags & Hill::HIDDEN)) { - continue; - } - - width = (int) ceilf(fl_width(m->name)); - m->label_x = width; - m->label_y = 0; - for (j=0; j < i; j++) { - n = v->get(j); - - if (n->flags & (Hill::DUPLICATE | Hill::TRACK_POINT)) { - continue; - } - - if (!show_hidden && (n->flags & Hill::HIDDEN)) { - continue; - } - - // Check for overlapping labels and - // overlaps between labels and peak markers - if ((overlap(m->x, m->x + m->label_x, n->x, n->x + n->label_x) && - overlap(m->y + m->label_y - height, m->y + m->label_y, n->y + n->label_y - height, n->y + n->label_y)) || - (overlap(m->x, m->x + m->label_x, n->x - 2, n->x + 2) && - overlap(m->y + m->label_y - height, m->y + m->label_y, n->y - 2, n->y + 2))) { - m->label_y = n->y + n->label_y - m->y - height - 1; - } - } - } + int i, j, width, height; + Hill *m, *n; + + fl_font(FL_HELVETICA, 10); + height = fl_height(); + + for (i=0; iget_num(); i++) { + m = v->get(i); + + if (m->flags & (Hill::DUPLICATE|Hill::TRACK_POINT)) { + continue; + } + + if (!show_hidden && (m->flags & Hill::HIDDEN)) { + continue; + } + + width = (int) ceilf(fl_width(m->name)); + m->label_x = width; + m->label_y = 0; + for (j=0; j < i; j++) { + n = v->get(j); + + if (n->flags & (Hill::DUPLICATE | Hill::TRACK_POINT)) { + continue; + } + + if (!show_hidden && (n->flags & Hill::HIDDEN)) { + continue; + } + + // Check for overlapping labels and + // overlaps between labels and peak markers + if ((overlap(m->x, m->x + m->label_x, n->x, n->x + n->label_x) && + overlap(m->y + m->label_y - height, m->y + m->label_y, n->y + n->label_y - height, n->y + n->label_y)) || + (overlap(m->x, m->x + m->label_x, n->x - 2, n->x + 2) && + overlap(m->y + m->label_y - height, m->y + m->label_y, n->y - 2, n->y + 2))) { + m->label_y = n->y + n->label_y - m->y - height - 1; + } + } + } } int GipfelWidget::set_cur_mountain(int m_x, int m_y) { - Hills *mnts = pan->get_visible_mountains(); - Hill *m; - int center_x = w() / 2; - int center_y = h() / 2; - int i; - - for (i=0; iget_num(); i++) { - m = mnts->get(i); - if (m->flags & (Hill::DUPLICATE | 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) { - cur_mountain = m; - if (m1 != NULL && m2 != NULL) { - fprintf(stderr, "Resetting m1 and m2\n"); - m1 = NULL; - m2 = NULL; - } - - if (m1 == NULL) { - m1 = cur_mountain; - fprintf(stderr, "m1 = %s\n", m1->name); - } else if (m2 == NULL) { - m2 = cur_mountain; - fprintf(stderr, "m2 = %s\n", m2->name); - } - - redraw(); - return 0; - } - } + Hills *mnts = pan->get_visible_mountains(); + Hill *m; + int center_x = w() / 2; + int center_y = h() / 2; + int i; + + for (i=0; iget_num(); i++) { + m = mnts->get(i); + if (m->flags & (Hill::DUPLICATE | 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) { + cur_mountain = m; + if (m1 != NULL && m2 != NULL) { + fprintf(stderr, "Resetting m1 and m2\n"); + m1 = NULL; + m2 = NULL; + } + + if (m1 == NULL) { + m1 = cur_mountain; + fprintf(stderr, "m1 = %s\n", m1->name); + } else if (m2 == NULL) { + m2 = cur_mountain; + fprintf(stderr, "m2 = %s\n", m2->name); + } + + redraw(); + return 0; + } + } - for (i=0; iget_num(); i++) { - m = marker->get(i); + for (i=0; iget_num(); i++) { + m = marker->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) { - cur_mountain = m; - redraw(); - return 0; - } - } + 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) { + cur_mountain = m; + redraw(); + return 0; + } + } - cur_mountain = NULL; - redraw(); - return 1; + 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 == NULL) { - return 1; - } - - old_x = cur_mountain->x; - old_y = 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, - MAX(20, cur_mountain->label_x) + 2*CROSS_SIZE + 2, - MAX(20, old_label_y) + 22 ); - damage(4, center_x + x() + cur_mountain->x - 2*CROSS_SIZE - 1, - center_y + y() + cur_mountain->y + cur_mountain->label_y - 2*CROSS_SIZE - 20, - MAX(20, cur_mountain->label_x) + 2*CROSS_SIZE + 2, - MAX(20, cur_mountain->label_y) + 22 ); - - return 0; + int old_x, old_y, old_label_y; + int center_x = w() / 2; + int center_y = h() / 2; + + if (cur_mountain == NULL) { + return 1; + } + + old_x = cur_mountain->x; + old_y = 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, + MAX(20, cur_mountain->label_x) + 2*CROSS_SIZE + 2, + MAX(20, old_label_y) + 22 ); + damage(4, center_x + x() + cur_mountain->x - 2*CROSS_SIZE - 1, + center_y + y() + cur_mountain->y + cur_mountain->label_y - 2*CROSS_SIZE - 20, + MAX(20, cur_mountain->label_x) + 2*CROSS_SIZE + 2, + 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(); + 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(); + 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(); + pan->set_tilt_angle(a); + set_labels(pan->get_visible_mountains()); + redraw(); } void GipfelWidget::set_focal_length_35mm(double s) { - pan->set_scale(s * (double) img->w() / 35.0); - set_labels(pan->get_visible_mountains()); - redraw(); + pan->set_scale(s * (double) img->w() / 35.0); + set_labels(pan->get_visible_mountains()); + redraw(); } void GipfelWidget::set_projection(Projection::Projection_t p) { - pan->set_projection(p); - set_labels(pan->get_visible_mountains()); - redraw(); + pan->set_projection(p); + set_labels(pan->get_visible_mountains()); + redraw(); } Projection::Projection_t GipfelWidget::get_projection() { - return pan->get_projection(); + return pan->get_projection(); } double GipfelWidget::get_center_angle() { - return pan->get_center_angle(); + return pan->get_center_angle(); } double GipfelWidget::get_nick_angle() { - return pan->get_nick_angle(); + return pan->get_nick_angle(); } double GipfelWidget::get_tilt_angle() { - return pan->get_tilt_angle(); + return pan->get_tilt_angle(); } double GipfelWidget::get_focal_length_35mm() { - return pan->get_scale() * 35.0 / (double) img->w(); + return pan->get_scale() * 35.0 / (double) img->w(); } double GipfelWidget::get_height_dist_ratio() { - return pan->get_height_dist_ratio(); + return pan->get_height_dist_ratio(); } const char * GipfelWidget::get_viewpoint() { - return pan->get_viewpoint(); + return pan->get_viewpoint(); } double GipfelWidget::get_view_lat() { - return pan->get_view_lat(); + return pan->get_view_lat(); } double GipfelWidget::get_view_long() { - return pan->get_view_long(); + return pan->get_view_long(); } double GipfelWidget::get_view_height() { - return pan->get_view_height(); + return pan->get_view_height(); } void GipfelWidget::center() { - Hill *m = choose_hill(pan->get_close_mountains(), "Center Peak"); - if (m) { - set_center_angle(m->alph / deg2rad); - if (!m1 || (m1 && m2)) { - m1 = m; - } else { - m2 = m; - } - } + Hill *m = choose_hill(pan->get_close_mountains(), "Center Peak"); + if (m) { + set_center_angle(m->alph / deg2rad); + if (!m1 || (m1 && m2)) { + m1 = m; + } else { + m2 = m; + } + } } static void center_cb(Fl_Widget *o, void *f) { - ((GipfelWidget*)f)->center(); + ((GipfelWidget*)f)->center(); } void GipfelWidget::set_height_dist_ratio(double r) { - pan->set_height_dist_ratio(r); - set_labels(pan->get_visible_mountains()); - - redraw(); + 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(); + pan->set_hide_value(h); + set_labels(pan->get_visible_mountains()); + + redraw(); } void GipfelWidget::set_show_hidden(int h) { - show_hidden = h; - set_labels(pan->get_visible_mountains()); - - redraw(); + 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(); + 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(); + 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(); + pan->set_view_height(v); + set_labels(pan->get_visible_mountains()); + redraw(); } Hills* GipfelWidget::get_mountains() { - return pan->get_mountains(); + return pan->get_mountains(); } int GipfelWidget::comp_params() { - if (m1 == NULL || m2 == NULL) { - fprintf(stderr, "Position m1 and m2 first.\n"); - return 1; - } - fl_cursor(FL_CURSOR_WAIT); - pan->comp_params(m1, m2); - set_labels(pan->get_visible_mountains()); - redraw(); - fl_cursor(FL_CURSOR_DEFAULT); + if (m1 == NULL || m2 == NULL) { + fprintf(stderr, "Position m1 and m2 first.\n"); + return 1; + } + fl_cursor(FL_CURSOR_WAIT); + pan->comp_params(m1, m2); + set_labels(pan->get_visible_mountains()); + redraw(); + fl_cursor(FL_CURSOR_DEFAULT); } int GipfelWidget::guess() { - if (m1 == NULL) { - fprintf(stderr, "Position m1 first.\n"); - return 1; - } - fl_cursor(FL_CURSOR_WAIT); - pan->guess(marker, m1); - set_labels(pan->get_visible_mountains()); - redraw(); - fl_cursor(FL_CURSOR_DEFAULT); + if (m1 == NULL) { + fprintf(stderr, "Position m1 first.\n"); + return 1; + } + fl_cursor(FL_CURSOR_WAIT); + pan->guess(marker, m1); + set_labels(pan->get_visible_mountains()); + redraw(); + fl_cursor(FL_CURSOR_DEFAULT); } int GipfelWidget::update() { - redraw(); - Fl::wait(1.0); + redraw(); + Fl::wait(1.0); } int GipfelWidget::get_rel_track_width(Hill *m) { - double dist = pan->get_real_distance(m); + double dist = pan->get_real_distance(m); - return MAX((pan->get_scale() * track_width) / (dist * 10.0), 1.0); + return MAX((pan->get_scale() * track_width) / (dist * 10.0), 1.0); } void GipfelWidget::set_track_width(double w) { - track_width = w; - redraw(); + track_width = w; + redraw(); } int GipfelWidget::handle(int event) { - int mark_x, mark_y; - - switch(event) { - case FL_PUSH: - if (Fl::event_button() == 1) { - - mark_x = Fl::event_x()-x(); - mark_y = Fl::event_y()-y(); - set_cur_mountain(mark_x, mark_y); - - Fl::focus(this); - return 1; - } - break; - case FL_DRAG: - set_mountain(Fl::event_x()-x(), Fl::event_y()-y()); - return 1; - break; - case FL_FOCUS: - return 1; - break; - case FL_UNFOCUS: - return 0; - break; - } - return 0; + int mark_x, mark_y; + + switch(event) { + case FL_PUSH: + if (Fl::event_button() == 1) { + + mark_x = Fl::event_x()-x(); + mark_y = Fl::event_y()-y(); + set_cur_mountain(mark_x, mark_y); + + Fl::focus(this); + return 1; + } + break; + case FL_DRAG: + set_mountain(Fl::event_x()-x(), Fl::event_y()-y()); + return 1; + break; + case FL_FOCUS: + return 1; + break; + case FL_UNFOCUS: + return 0; + break; + } + return 0; } int GipfelWidget::get_pixel(double a_view, double a_nick, - char *r, char *g, char *b) { + char *r, char *g, char *b) { double px, py; @@ -678,7 +678,7 @@ GipfelWidget::get_pixel(double a_view, double a_nick, } return get_pixel_nearest(img, px + ((double) img->w()) / 2.0, - py + ((double) img->h()) / 2.0, r, g, b); + py + ((double) img->h()) / 2.0, r, g, b); } int @@ -694,40 +694,40 @@ GipfelWidget::get_pixel_nearest(Fl_Image *img, double x, double y, int GipfelWidget::get_pixel(Fl_Image *img, int x, int y, - char *r, char *g, char *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 char *buf = img->data()[0]; - switch ( img->d() ) { - case 1: { // 8bit - *r = *g = *b = *(buf+index); - break; - } - case 3: // 24bit - *r = *(buf+index+0); - *g = *(buf+index+1); - *b = *(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; - } - - return 0; + char *r, char *g, char *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 char *buf = img->data()[0]; + switch (img->d()) + { + case 1: + *r = *g = *b = *(buf+index); + break; + case 3: // 24bit + *r = *(buf+index+0); + *g = *(buf+index+1); + *b = *(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; + } + + return 0; +} diff --git a/src/Hill.H b/src/Hill.H index 37ab44a..2e95def 100644 --- a/src/Hill.H +++ b/src/Hill.H @@ -11,69 +11,69 @@ class Hill; class Hill { - private: - - public: - typedef enum { - DUPLICATE = 0x01, - TRACK_POINT = 0x02, - VISIBLE = 0x04, - HIDDEN = 0x08 - } flags_t; - - double phi, lam; - double height; - double alph; - double a_view; - double a_nick; - double dist; - int 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(int x_tmp, int y_tmp); - - ~Hill(); + private: + + public: + typedef enum { + DUPLICATE = 0x01, + TRACK_POINT = 0x02, + VISIBLE = 0x04, + HIDDEN = 0x08 + } flags_t; + + double phi, lam; + double height; + double alph; + double a_view; + double a_nick; + double dist; + int 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(int x_tmp, int y_tmp); + + ~Hill(); }; class Hills { - private: - int num, cap; - Hill **m; + private: + int num, cap; + Hill **m; - public: - Hills(); + public: + Hills(); - Hills(const Hills *h); + Hills(const Hills *h); - ~Hills(); + ~Hills(); - int load(const char *file); + int load(const char *file); - void mark_duplicates(double dist); + void mark_duplicates(double dist); - void add(Hill *m); + void add(Hill *m); - void add(Hills *h); + void add(Hills *h); - void sort_phi(); + void sort_phi(); - void sort_name(); + void sort_name(); - void sort(); - - void clear(); + void sort(); - void clobber(); + void clear(); - int get_num(); - - Hill *get(int n); + void clobber(); + + int get_num(); + + Hill *get(int n); }; #endif diff --git a/src/Hill.cxx b/src/Hill.cxx index 14b8f81..d5ce1f6 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -14,284 +14,284 @@ 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; + 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; - a_view = h.a_view; - a_view = h.a_view; - dist = h.dist; - x = h.x; - y = h.y; - label_x = h.label_x; - label_y = h.label_y; - flags = h.flags; + name = strdup(h.name); + phi = h.phi; + lam = h.lam; + height = h.height; + alph = h.alph; + a_view = h.a_view; + a_view = h.a_view; + dist = h.dist; + x = h.x; + y = h.y; + label_x = h.label_x; + label_y = h.label_y; + flags = h.flags; } Hill::Hill(int x_tmp, int y_tmp) { - name = NULL; - phi = 0.0; - lam = 0.0; - height = 0.0; - alph = 0.0; - x = x_tmp; - y = 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); - } + if (name) { + free(name); + } } Hills::Hills() { - num = 0; - cap = 100; - m = (Hill **) malloc(cap * sizeof(Hill *)); + num = 0; + cap = 100; + m = (Hill **) malloc(cap * sizeof(Hill *)); - pi_d = asin(1.0) * 2.0; - deg2rad = pi_d / 180.0; + 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 *)); + 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; + 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; + 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_phi(); - - for(i=0; iflags & Hill::TRACK_POINT) { - continue; - } - - if (m) { - j = i + 1; - n = get(j); - while (n && fabs(n->phi - m->phi) <= dist) { - if (! n->flags & Hill::DUPLICATE) { - if (fabs(n->lam - m->lam) <= dist && - fabs(n->height - m->height) <= 50.0 ) { - n->flags |= Hill::DUPLICATE; - } - } - j = j + 1; - n = get(j); - } - } - } + Hill *m, *n; + int i, j; + + sort_phi(); + + for(i=0; iflags & Hill::TRACK_POINT) { + continue; + } + + if (m) { + j = i + 1; + n = get(j); + while (n && fabs(n->phi - m->phi) <= dist) { + if (! n->flags & Hill::DUPLICATE) { + if (fabs(n->lam - m->lam) <= dist && + fabs(n->height - m->height) <= 50.0 ) { + n->flags |= Hill::DUPLICATE; + } + } + j = j + 1; + n = get(j); + } + } + } } Hills::~Hills() { - if (m) { - free(m); - } + if (m) { + free(m); + } } void Hills::add(Hill *m1) { - if (num >= cap) { - cap = cap?cap * 2:100; - m = (Hill **) realloc(m, cap * sizeof(Hill *)); - } + if (num >= cap) { + cap = cap?cap * 2:100; + m = (Hill **) realloc(m, cap * sizeof(Hill *)); + } - m[num++] = m1; + m[num++] = m1; } void Hills::add(Hills *h) { - for(int i=0; iget_num(); i++) { - add(h->get(i)); - } + for(int i=0; iget_num(); i++) { + add(h->get(i)); + } } static int comp_mountains(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; - } + 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; - } + 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; - - if (m1 && m2) { - return strcasecmp(m1->name, m2->name); - } else { - return 0; - } + Hill *m1 = *(Hill **)n1; + Hill *m2 = *(Hill **)n2; + + if (m1 && m2) { + return strcasecmp(m1->name, m2->name); + } else { + return 0; + } } void Hills::sort() { - if (!m) { - return; - } + if (!m) { + return; + } - qsort(m, num, sizeof(Hill *), comp_mountains); + qsort(m, num, sizeof(Hill *), comp_mountains); } void Hills::sort_phi() { - if (!m) { - return; - } + if (!m) { + return; + } - qsort(m, num, sizeof(Hill *), comp_mountains_phi); + qsort(m, num, sizeof(Hill *), comp_mountains_phi); } void Hills::sort_name() { - if (!m) { - return; - } + if (!m) { + return; + } - qsort(m, num, sizeof(Hill *), comp_mountains_name); + qsort(m, num, sizeof(Hill *), comp_mountains_name); } void Hills::clear() { - if (m) { - free(m); - m = NULL; - } - cap = 0; - num = 0; + if (m) { + free(m); + m = NULL; + } + cap = 0; + num = 0; } void Hills::clobber() { - int i; - - for(i=0; i= num) { - return NULL; - } else { - return m[n]; - } + if (n < 0 || n >= num) { + return NULL; + } else { + return m[n]; + } } diff --git a/src/Panorama.H b/src/Panorama.H index 80a8f69..81cdf8e 100644 --- a/src/Panorama.H +++ b/src/Panorama.H @@ -14,122 +14,122 @@ class Panorama { - private: - double view_phi, view_lam, view_height; - char *view_name; - double height_dist_ratio; - double view_angle; - double hide_value; - Hills *mountains; - Hills *close_mountains; - Hills *visible_mountains; - ViewParams parms; - Projection::Projection *proj; - Projection::Projection_t projection_type; - - Hill * get_pos(const char *name); + private: + double view_phi, view_lam, view_height; + char *view_name; + double height_dist_ratio; + double view_angle; + double hide_value; + Hills *mountains; + Hills *close_mountains; + Hills *visible_mountains; + ViewParams parms; + Projection::Projection *proj; + Projection::Projection_t projection_type; - void update_angles(); + Hill * get_pos(const char *name); - void update_coordinates(); + void update_angles(); - void update_close_mountains(); + void update_coordinates(); - void update_visible_mountains(); - - void mark_hidden(Hills *hills); + void update_close_mountains(); - double distance(double phi, double lam); + void update_visible_mountains(); - double sin_alpha(double lam, double phi, double c); + void mark_hidden(Hills *hills); - double cos_alpha(double phi, double c); + double distance(double phi, double lam); - double alpha(double phi, double lam); + double sin_alpha(double lam, double phi, double c); - double nick(double dist, double height); - - double comp_center_angle(double alph_a, double alph_b, double d1, double d2); + double cos_alpha(double phi, double c); - double comp_scale(double alph_a, double alph_b, double d1, double d2); + double alpha(double phi, double lam); - int get_matrix(double m[]); + double nick(double dist, double height); - int optimize(Hill *m1, Hill *m2); + double comp_center_angle(double alph_a, double alph_b, double d1, double d2); - double get_value(Hills *p); + double comp_scale(double alph_a, double alph_b, double d1, double d2); - double pi_d, deg2rad; + int get_matrix(double m[]); - public: - Panorama(); + int optimize(Hill *m1, Hill *m2); - ~Panorama(); - - int load_data(const char *name); + double get_value(Hills *p); - void add_hills(Hills *h); + double pi_d, deg2rad; - void remove_trackpoints(); + public: + Panorama(); - int set_viewpoint(const char *pos); + ~Panorama(); - void set_viewpoint(const Hill *m); + int load_data(const char *name); - void set_height_dist_ratio(double r); + void add_hills(Hills *h); - void set_hide_value(double h); + void remove_trackpoints(); - Hills * get_mountains(); + int set_viewpoint(const char *pos); - Hills * get_close_mountains(); + void set_viewpoint(const Hill *m); - Hills * get_visible_mountains(); + void set_height_dist_ratio(double r); - void set_center_angle(double a); + void set_hide_value(double h); - void set_nick_angle(double a); + Hills * get_mountains(); - void set_tilt_angle(double a); + Hills * get_close_mountains(); - void set_scale(double s); + Hills * get_visible_mountains(); - void set_view_lat(double v); + void set_center_angle(double a); - void set_view_long(double v); + void set_nick_angle(double a); - void set_view_height(double v); + void set_tilt_angle(double a); - const char * get_viewpoint(); + void set_scale(double s); - double get_center_angle(); + void set_view_lat(double v); - double get_nick_angle(); + void set_view_long(double v); - double get_tilt_angle(); + void set_view_height(double v); - double get_scale(); + const char * get_viewpoint(); - double get_height_dist_ratio(); - - double get_view_lat(); + double get_center_angle(); - double get_view_long(); + double get_nick_angle(); - double get_view_height(); + double get_tilt_angle(); - double get_earth_radius(Hill *m); + double get_scale(); - double get_real_distance(Hill *m); + double get_height_dist_ratio(); - int comp_params(Hill *m1, Hill *m2); + double get_view_lat(); - int guess(Hills *p1, Hill *m1); + double get_view_long(); - Projection::Projection_t get_projection(); + double get_view_height(); - void set_projection(Projection::Projection_t p); + double get_earth_radius(Hill *m); - int get_coordinates(double a_view, double a_nick, double *x, double *y); + double get_real_distance(Hill *m); + + int comp_params(Hill *m1, Hill *m2); + + int guess(Hills *p1, Hill *m1); + + Projection::Projection_t get_projection(); + + void set_projection(Projection::Projection_t p); + + int get_coordinates(double a_view, double a_nick, double *x, double *y); }; #endif diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 4674c47..4ecf2f4 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -16,580 +16,580 @@ #define EARTH_RADIUS 6371010.0 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; - view_name = NULL; - view_phi = 0.0; - view_lam = 0.0; - view_height = 0.0; - proj = NULL; - set_projection(Projection::TANGENTIAL); + 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; + view_name = NULL; + view_phi = 0.0; + view_lam = 0.0; + view_height = 0.0; + proj = NULL; + set_projection(Projection::TANGENTIAL); } Panorama::~Panorama() { - visible_mountains->clear(); - mountains->clobber(); - delete(visible_mountains); - delete(mountains); + 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; - } + if (mountains->load(name) != 0) { + fprintf(stderr, "Could not load datafile %s\n", name); + return 1; + } - mountains->mark_duplicates(0.00001); - update_angles(); + mountains->mark_duplicates(0.00001); + update_angles(); - return 0; + return 0; } void Panorama::add_hills(Hills *h) { - mountains->add(h); + mountains->add(h); - mountains->mark_duplicates(0.00001); - update_angles(); + mountains->mark_duplicates(0.00001); + update_angles(); } void Panorama::remove_trackpoints() { - Hills *h_new = new Hills(); - Hill *m; + Hills *h_new = new Hills(); + Hill *m; + + for(int i=0; iget_num(); i++) { + m = mountains->get(i); + if (! (m->flags & Hill::TRACK_POINT)) { + h_new->add(m); + } + } - for(int i=0; iget_num(); i++) { - m = mountains->get(i); - if (! (m->flags & Hill::TRACK_POINT)) { - h_new->add(m); - } - } - - delete mountains; - mountains = h_new; + 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"); - return 1; - } + Hill *m = get_pos(name); + if (m == NULL) { + fprintf(stderr, "Could not find exactly one entry for %s.\n"); + return 1; + } - set_viewpoint(m); - return 0; + 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 (m == NULL) { + return; + } - if (view_name) { - free(view_name); - } + view_phi = m->phi; + view_lam = m->lam; + view_height = m->height; + + if (view_name) { + free(view_name); + } - view_name = strdup(m->name); + view_name = strdup(m->name); - update_angles(); + update_angles(); } Hills * Panorama::get_mountains() { - return mountains; + return mountains; } Hills * Panorama::get_close_mountains() { - return close_mountains; + return close_mountains; } Hills * Panorama::get_visible_mountains() { - return visible_mountains; + return visible_mountains; } double Panorama::get_value(Hills *p) { - int i, j; - Hill *m; - double v = 0.0, d_min, d; - - if (isnan(parms.scale) || isnan(parms.a_center) || isnan(parms.a_tilt) || isnan(parms.a_nick) || - parms.scale < 500.0 || parms.scale > 100000.0 || - parms.a_nick > pi_d/4.0 || parms.a_nick < - pi_d/4.0 || - parms.a_tilt > pi_d/16.0 || parms.a_tilt < - pi_d/16.0) { - return 10000000.0; - } - - - for (i=0; iget_num(); i++) { - d_min = 1000.0; - for (j=0; jget_num(); j++) { - d = pow(p->get(i)->x - visible_mountains->get(j)->x, 2.0) + - pow(p->get(i)->y - visible_mountains->get(j)->y, 2.0); - if (d < d_min) { - d_min = d; - } - } - v = v + d_min; - } - - return v; + int i, j; + Hill *m; + double v = 0.0, d_min, d; + + if (isnan(parms.scale) || isnan(parms.a_center) || isnan(parms.a_tilt) || isnan(parms.a_nick) || + parms.scale < 500.0 || parms.scale > 100000.0 || + parms.a_nick > pi_d/4.0 || parms.a_nick < - pi_d/4.0 || + parms.a_tilt > pi_d/16.0 || parms.a_tilt < - pi_d/16.0) { + return 10000000.0; + } + + + for (i=0; iget_num(); i++) { + d_min = 1000.0; + for (j=0; jget_num(); j++) { + d = pow(p->get(i)->x - visible_mountains->get(j)->x, 2.0) + + pow(p->get(i)->y - visible_mountains->get(j)->y, 2.0); + if (d < d_min) { + d_min = d; + } + } + v = v + d_min; + } + + return v; } int Panorama::guess(Hills *p, Hill *m1) { - Hill *p2, *m_tmp1, *m_tmp2; - Hill *m2; - double best = 100000000.0, v; - double a_center_best, a_nick_best, a_tilt_best, scale_best; - int x1_sav, y1_sav; - int i, j; - - if (m1 == NULL) { - fprintf(stderr, "Position one mountain first.\n"); - return 1; - } - - m_tmp1 = m1; - x1_sav = m1->x; - y1_sav = m1->y; - - for (i=0; iget_num(); i++) { - p2 = p->get(i); - for (j=0; jget_num(); j++) { - m_tmp2 = close_mountains->get(j); - - m1 = m_tmp1; - m1->x = x1_sav; - m1->y = y1_sav; - - if (m_tmp2->flags & Hill::TRACK_POINT || - m1 == m_tmp2 || fabs(m1->alph - m_tmp2->alph) > pi_d *0.7) { - continue; - } - - m2 = m_tmp2; - m2->x = p2->x; - m2->y = p2->y; - - comp_params(m1, m2); - - v = get_value(p); - - if (v < best) { - best = v; - a_center_best = parms.a_center; - a_nick_best = parms.a_nick; - a_tilt_best = parms.a_tilt; - scale_best = parms.scale; - } - } - } - - if (best < 4000.0) { - parms.a_center = a_center_best; - parms.a_nick = a_nick_best; - parms.a_tilt = a_tilt_best; - parms.scale = scale_best; - } else { - fprintf(stderr, "No solution found.\n"); - } - update_visible_mountains(); - return 0; + Hill *p2, *m_tmp1, *m_tmp2; + Hill *m2; + double best = 100000000.0, v; + double a_center_best, a_nick_best, a_tilt_best, scale_best; + int x1_sav, y1_sav; + int i, j; + + if (m1 == NULL) { + fprintf(stderr, "Position one mountain first.\n"); + return 1; + } + + m_tmp1 = m1; + x1_sav = m1->x; + y1_sav = m1->y; + + for (i=0; iget_num(); i++) { + p2 = p->get(i); + for (j=0; jget_num(); j++) { + m_tmp2 = close_mountains->get(j); + + m1 = m_tmp1; + m1->x = x1_sav; + m1->y = y1_sav; + + if (m_tmp2->flags & Hill::TRACK_POINT || + m1 == m_tmp2 || fabs(m1->alph - m_tmp2->alph) > pi_d *0.7) { + continue; + } + + m2 = m_tmp2; + m2->x = p2->x; + m2->y = p2->y; + + comp_params(m1, m2); + + v = get_value(p); + + if (v < best) { + best = v; + a_center_best = parms.a_center; + a_nick_best = parms.a_nick; + a_tilt_best = parms.a_tilt; + scale_best = parms.scale; + } + } + } + + if (best < 4000.0) { + parms.a_center = a_center_best; + parms.a_nick = a_nick_best; + parms.a_tilt = a_tilt_best; + parms.scale = scale_best; + } else { + fprintf(stderr, "No solution found.\n"); + } + update_visible_mountains(); + return 0; } int Panorama::comp_params(Hill *m1, Hill *m2) { - int ret; + int ret; - ret = proj->comp_params(m1, m2, &parms); - update_visible_mountains(); - return ret; + ret = proj->comp_params(m1, m2, &parms); + update_visible_mountains(); + return ret; } void Panorama::set_center_angle(double a) { - parms.a_center = a * deg2rad; - update_visible_mountains(); + parms.a_center = a * deg2rad; + update_visible_mountains(); } void Panorama::set_nick_angle(double a) { - parms.a_nick = a * deg2rad; - update_coordinates(); + parms.a_nick = a * deg2rad; + update_coordinates(); } void Panorama::set_tilt_angle(double a) { - parms.a_tilt = a * deg2rad; - update_coordinates(); + parms.a_tilt = a * deg2rad; + update_coordinates(); } void Panorama::set_scale(double s) { - parms.scale = s; - update_coordinates(); + parms.scale = s; + update_coordinates(); } void Panorama::set_height_dist_ratio(double r) { - height_dist_ratio = r; - update_close_mountains(); + height_dist_ratio = r; + update_close_mountains(); } void Panorama::set_view_long(double v) { - view_lam = v * deg2rad; - update_angles(); + view_lam = v * deg2rad; + update_angles(); } void Panorama::set_view_lat(double v) { - view_phi = v * deg2rad; - update_angles(); + view_phi = v * deg2rad; + update_angles(); } void Panorama::set_view_height(double v) { - view_height = v; - update_angles(); + view_height = v; + update_angles(); } void Panorama::set_projection(Projection::Projection_t p) { - projection_type = p; - - if (proj) { - delete proj; - } - - switch(projection_type) { - case Projection::TANGENTIAL: - proj = new ProjectionTangential(); - view_angle = pi_d / 3.0; - break; - case Projection::SPHAERIC: - proj = new ProjectionSphaeric(); - view_angle = pi_d * 2.0; - break; - } - update_angles(); + projection_type = p; + + if (proj) { + delete proj; + } + + switch(projection_type) { + case Projection::TANGENTIAL: + proj = new ProjectionTangential(); + view_angle = pi_d / 3.0; + break; + case Projection::SPHAERIC: + proj = new ProjectionSphaeric(); + view_angle = pi_d * 2.0; + break; + } + update_angles(); } const char * Panorama::get_viewpoint() { - return view_name; + return view_name; } double Panorama::get_center_angle() { - return parms.a_center / deg2rad; + return parms.a_center / deg2rad; } double Panorama::get_nick_angle() { - return parms.a_nick / deg2rad; + return parms.a_nick / deg2rad; } double Panorama::get_tilt_angle() { - return parms.a_tilt / deg2rad; + return parms.a_tilt / deg2rad; } double Panorama::get_scale() { - return parms.scale; + return parms.scale; } double Panorama::get_height_dist_ratio() { - return height_dist_ratio; + return height_dist_ratio; } double Panorama::get_view_long() { - return view_lam / deg2rad; + return view_lam / deg2rad; } double Panorama::get_view_lat() { - return view_phi / deg2rad; + return view_phi / deg2rad; } double Panorama::get_view_height() { - return view_height; + return view_height; } Projection::Projection_t Panorama::get_projection() { - return projection_type; + return projection_type; } Hill * Panorama::get_pos(const char *name) { - int i; - int found = 0; - double p, l, h; - Hill *m, *ret; - - for (i=0; iget_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); - found++; - } - } + int i; + int found = 0; + double p, l, h; + Hill *m, *ret; + + for (i=0; iget_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); + found++; + } + } - if (found == 1) { - return ret; - } + if (found == 1) { + return ret; + } - return NULL; + return NULL; } void Panorama::update_angles() { - int i; - Hill *m; + int i; + Hill *m; - for (i=0; iget_num(); i++) { - m = mountains->get(i); - - m->dist = distance(m->phi, m->lam); - if (m->phi != view_phi || m->lam != view_lam) { - - m->alph = alpha(m->phi, m->lam); - m->a_nick = nick(m->dist, m->height); - } - } + for (i=0; iget_num(); i++) { + m = mountains->get(i); + m->dist = distance(m->phi, m->lam); + if (m->phi != view_phi || m->lam != view_lam) { - mountains->sort(); + m->alph = alpha(m->phi, m->lam); + m->a_nick = nick(m->dist, m->height); + } + } - update_close_mountains(); + + mountains->sort(); + + update_close_mountains(); } void Panorama::set_hide_value(double h) { - hide_value = h; - update_visible_mountains(); + hide_value = h; + update_visible_mountains(); } void Panorama::mark_hidden(Hills *hills) { - int i, j; - Hill *m, *n; - double h; - - for (i=0; iget_num(); i++) { - m = hills->get(i); - - m->flags &= ~Hill::HIDDEN; - - if (m->flags & Hill::DUPLICATE) { - continue; - } - - for (j=0; jget_num(); j++) { - n = hills->get(j); - - if (n->flags & Hill::DUPLICATE || 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; - } - } - - } + int i, j; + Hill *m, *n; + double h; + + for (i=0; iget_num(); i++) { + m = hills->get(i); + + m->flags &= ~Hill::HIDDEN; + + if (m->flags & Hill::DUPLICATE) { + continue; + } + + for (j=0; jget_num(); j++) { + n = hills->get(j); + + if (n->flags & Hill::DUPLICATE || 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() { - int i; - Hill *m; + int i; + Hill *m; + + close_mountains->clear(); - close_mountains->clear(); + for (i=0; iget_num(); i++) { + m = mountains->get(i); - for (i=0; iget_num(); i++) { - m = mountains->get(i); - - if (m->flags & Hill::TRACK_POINT || - ((m->phi != view_phi || m->lam != view_lam) && - (m->height / (m->dist * get_earth_radius(m)) - > height_dist_ratio))) { + if (m->flags & Hill::TRACK_POINT || + ((m->phi != view_phi || m->lam != view_lam) && + (m->height / (m->dist * get_earth_radius(m)) + > height_dist_ratio))) { - close_mountains->add(m); - } - } + close_mountains->add(m); + } + } - mark_hidden(close_mountains); - update_visible_mountains(); + mark_hidden(close_mountains); + update_visible_mountains(); } void Panorama::update_visible_mountains() { - int i; - Hill *m; + int i; + Hill *m; - visible_mountains->clear(); + visible_mountains->clear(); - for (i=0; iget_num(); i++) { - m = close_mountains->get(i); + for (i=0; iget_num(); i++) { + m = close_mountains->get(i); - m->a_view = m->alph - parms.a_center; + m->a_view = m->alph - parms.a_center; - if (m->a_view > pi_d) { - m->a_view -= 2.0*pi_d; - } else if (m->a_view < -pi_d) { - m->a_view += 2.0*pi_d; - } - - if (m->a_view < view_angle && m->a_view > - view_angle) { - visible_mountains->add(m); - m->flags |= Hill::VISIBLE; - } else { - m->flags &= ~Hill::VISIBLE; - } - } + if (m->a_view > pi_d) { + m->a_view -= 2.0*pi_d; + } else if (m->a_view < -pi_d) { + m->a_view += 2.0*pi_d; + } - update_coordinates(); + if (m->a_view < view_angle && m->a_view > - view_angle) { + visible_mountains->add(m); + m->flags |= Hill::VISIBLE; + } else { + m->flags &= ~Hill::VISIBLE; + } + } + + update_coordinates(); } void Panorama::update_coordinates() { - Hill *m; + Hill *m; + + for (int i=0; iget_num(); i++) { + m = visible_mountains->get(i); + double tmp_x, tmp_y; - for (int i=0; iget_num(); i++) { - m = visible_mountains->get(i); - double tmp_x, tmp_y; - - proj->get_coordinates(m->a_view, m->a_nick, &parms, &tmp_x, &tmp_y); - m->x = (int) rint(tmp_x); - m->y = (int) rint(tmp_y); - } + proj->get_coordinates(m->a_view, m->a_nick, &parms, &tmp_x, &tmp_y); + m->x = (int) rint(tmp_x); + m->y = (int) rint(tmp_y); + } } double Panorama::distance(double phi, double lam) { - return acos(sin(view_phi) * sin(phi) + - cos(view_phi) * cos(phi) * cos(view_lam - lam)); + return acos(sin(view_phi) * sin(phi) + + cos(view_phi) * cos(phi) * cos(view_lam - lam)); } double Panorama::sin_alpha(double lam, double phi, double c) { - return sin(lam - view_lam) * cos(phi) / sin(c); + return sin(lam - view_lam) * cos(phi) / sin(c); } double Panorama::cos_alpha(double phi, double c) { - return (sin(phi) - sin(view_phi) * cos(c)) / (cos(view_phi) * sin(c)); + return (sin(phi) - sin(view_phi) * cos(c)) / (cos(view_phi) * sin(c)); } double Panorama::alpha(double phi, double lam) { - double dist, sin_alph, cos_alph, alph; - - dist = distance(phi, lam); - sin_alph = sin_alpha(lam, phi, dist); - cos_alph = cos_alpha(phi, dist); + double dist, sin_alph, cos_alph, alph; - if (sin_alph > 0) { - alph = acos(cos_alph); - } else { - alph = 2.0 * pi_d - acos(cos_alph); - } + dist = distance(phi, lam); + sin_alph = sin_alpha(lam, phi, dist); + cos_alph = cos_alpha(phi, dist); + + if (sin_alph > 0) { + alph = acos(cos_alph); + } else { + alph = 2.0 * pi_d - acos(cos_alph); + } - if (alph > 2.0 * pi_d) { - alph = alph - 2.0 * pi_d; - } else if (alph < 0.0) { - alph = alph + 2.0 * pi_d; - } - return alph; + if (alph > 2.0 * pi_d) { + alph = alph - 2.0 * pi_d; + } else if (alph < 0.0) { + alph = alph + 2.0 * pi_d; + } + return alph; } double Panorama::nick(double dist, double height) { - double a, b, c; - double beta; + double a, b, c; + double beta; - b = height + EARTH_RADIUS; - c = view_height + EARTH_RADIUS; + b = height + EARTH_RADIUS; + c = view_height + EARTH_RADIUS; - a = pow(((b * (b - (2.0 * c * cos(dist)))) + (c * c)), (1.0 / 2.0)); - beta = acos((-(b*b) + (a*a) + (c*c))/(2 * a * c)); - - return beta - pi_d / 2.0; + a = pow(((b * (b - (2.0 * c * cos(dist)))) + (c * c)), (1.0 / 2.0)); + beta = acos((-(b*b) + (a*a) + (c*c))/(2 * a * c)); + + return beta - pi_d / 2.0; } double Panorama::get_earth_radius(Hill *m) { - return EARTH_RADIUS; + return EARTH_RADIUS; } double Panorama::get_real_distance(Hill *m) { - double a, b, c, gam; + double a, b, c, gam; - a = view_height + get_earth_radius(m); // using m here is not quite right - b = m->height + get_earth_radius(m); - gam = m->dist; + a = view_height + get_earth_radius(m); // using m here is not quite right + b = m->height + get_earth_radius(m); + gam = m->dist; - c = sqrt(pow(a, 2.0) + pow(b, 2.0) - 2.0 * a * b * cos(gam)); - return c; + c = sqrt(pow(a, 2.0) + pow(b, 2.0) - 2.0 * a * b * cos(gam)); + return c; } int Panorama::get_coordinates(double a_view, double a_nick, double *x, double *y) { a_view = a_view - parms.a_center; - if (a_view > pi_d) { - a_view -= 2.0*pi_d; - } else if (a_view < -pi_d) { - a_view += 2.0*pi_d; - } - - if (a_view > view_angle || a_view < - view_angle) { + if (a_view > pi_d) { + a_view -= 2.0*pi_d; + } else if (a_view < -pi_d) { + a_view += 2.0*pi_d; + } + + if (a_view > view_angle || a_view < - view_angle) { return 1; } - proj->get_coordinates(a_view, a_nick, &parms, x, y); + proj->get_coordinates(a_view, a_nick, &parms, x, y); return 0; } diff --git a/src/Projection.H b/src/Projection.H index 6db0e97..3bc816e 100644 --- a/src/Projection.H +++ b/src/Projection.H @@ -11,20 +11,20 @@ #include "ViewParams.H" class Projection { - protected: - double pi_d; + protected: + double pi_d; - public: - typedef enum { - TANGENTIAL = 0, - SPHAERIC = 1 - } Projection_t; + public: + typedef enum { + TANGENTIAL = 0, + SPHAERIC = 1 + } Projection_t; - Projection(); + Projection(); - virtual void get_coordinates(double a_view, double a_nick, - const ViewParams *parms, double *x, double *y); - - virtual int comp_params(const Hill *m1, const Hill *m2, ViewParams *parms); + virtual void get_coordinates(double a_view, double a_nick, + const ViewParams *parms, double *x, double *y); + + virtual int comp_params(const Hill *m1, const Hill *m2, ViewParams *parms); }; #endif diff --git a/src/Projection.cxx b/src/Projection.cxx index 88ec5bf..02674a7 100644 --- a/src/Projection.cxx +++ b/src/Projection.cxx @@ -10,17 +10,17 @@ #include "Projection.H" Projection::Projection() { - pi_d = asin(1.0) * 2.0; + pi_d = asin(1.0) * 2.0; }; void Projection::get_coordinates(double a_view, double a_nick, - const ViewParams *parms, double *x, double *y) { - fprintf(stderr, "Error: Projection::set_coordinates()\n"); + const ViewParams *parms, double *x, double *y) { + fprintf(stderr, "Error: Projection::set_coordinates()\n"); } int Projection::comp_params(const Hill *m1, const Hill *m2, ViewParams *parms) { - fprintf(stderr, "Error: Projection::comp_params()\n"); - return 1; + fprintf(stderr, "Error: Projection::comp_params()\n"); + return 1; } diff --git a/src/ProjectionSphaeric.H b/src/ProjectionSphaeric.H index f80940a..c6ce5f4 100644 --- a/src/ProjectionSphaeric.H +++ b/src/ProjectionSphaeric.H @@ -11,17 +11,17 @@ #include "Projection.H" class ProjectionSphaeric : public Projection { - private: + private: - double comp_scale(const Hill *m1, const Hill *m2, double d_m1_m2_2); - double comp_dir_view(const Hill *m1, const Hill *m2, double d_m1_2, double d_m2_2, double scale, double sign3); - double comp_nick_view(const Hill *m1, const Hill *m2, double d_m1_2, double scale, double dir_view, double sign1); - double comp_tilt_view(const Hill *m, double scale, double dir_view, double nick_view); + double comp_scale(const Hill *m1, const Hill *m2, double d_m1_m2_2); + double comp_dir_view(const Hill *m1, const Hill *m2, double d_m1_2, double d_m2_2, double scale, double sign3); + double comp_nick_view(const Hill *m1, const Hill *m2, double d_m1_2, double scale, double dir_view, double sign1); + double comp_tilt_view(const Hill *m, double scale, double dir_view, double nick_view); - public: - void get_coordinates(double a_view, double a_nick, const ViewParams *parms, - double *x, double *y); + public: + void get_coordinates(double a_view, double a_nick, const ViewParams *parms, + double *x, double *y); - int comp_params(const Hill *m1, const Hill *m2, ViewParams *parms); + int comp_params(const Hill *m1, const Hill *m2, ViewParams *parms); }; #endif diff --git a/src/ProjectionSphaeric.cxx b/src/ProjectionSphaeric.cxx index d4e7e43..96af4e0 100644 --- a/src/ProjectionSphaeric.cxx +++ b/src/ProjectionSphaeric.cxx @@ -14,142 +14,142 @@ int ProjectionSphaeric::comp_params(const Hill *m1, const Hill *m2, ViewParams *parms) { - const Hill *m_tmp; - double tmp_x, tmp_y; - double val; - ViewParams best, tmp; - double best_val = BEST_UNDEF; - double d_m1_2, d_m2_2, d_m1_m2_2; - int i, j; - - if (m1->x < m2->x) { - m_tmp = m1; - m1 = m2; - m2 = m_tmp; - } - - d_m1_2 = pow(m1->x, 2.0) + pow(m1->y, 2.0); - d_m2_2 = pow(m2->x, 2.0) + pow(m2->y, 2.0); - d_m1_m2_2 = pow(m1->x - m2->x, 2.0) + pow(m1->y - m2->y, 2.0); - - tmp.scale = comp_scale(m1, m2, d_m1_m2_2); - - for(i=0; i<2; i++) { // we need to try four possible solutions ... - for(j=0; j<2; j++) { - tmp.a_center = comp_dir_view(m1, m2, d_m1_2, d_m2_2, - tmp.scale, i==0?1.0:-1.0); - tmp.a_nick = comp_nick_view(m1, m2, d_m1_2, tmp.scale, tmp.a_center, - j==0?1.0:-1.0); - - // use the point with greater distance from center for tilt computation - if (d_m1_2 > d_m2_2) { - tmp.a_tilt = comp_tilt_view(m1, tmp.scale, tmp.a_center, tmp.a_nick); - } else { - tmp.a_tilt = comp_tilt_view(m2, tmp.scale, tmp.a_center, tmp.a_nick); - } - - if (isnan(tmp.a_center) || isnan(tmp.scale) || - isnan(tmp.a_nick) || isnan(tmp.a_tilt)) { - ; - } else { - get_coordinates(m1->a_view, m1->a_nick, &tmp, &tmp_x, &tmp_y); - val = sqrt(pow(tmp_x - m1->x, 2.0) + pow(tmp_y - m1->y, 2.0)); - get_coordinates(m2->a_view, m2->a_nick, &tmp, &tmp_x, &tmp_y); - val += sqrt(pow(tmp_x - m2->x, 2.0) + pow(tmp_y - m2->y, 2.0)); - - if (val < best_val) { - best_val = val; - best = tmp; - } - } - } - } - - if (best_val < BEST_UNDEF) { - *parms = best; - return 0; - } else { - return 1; - } + const Hill *m_tmp; + double tmp_x, tmp_y; + double val; + ViewParams best, tmp; + double best_val = BEST_UNDEF; + double d_m1_2, d_m2_2, d_m1_m2_2; + int i, j; + + if (m1->x < m2->x) { + m_tmp = m1; + m1 = m2; + m2 = m_tmp; + } + + d_m1_2 = pow(m1->x, 2.0) + pow(m1->y, 2.0); + d_m2_2 = pow(m2->x, 2.0) + pow(m2->y, 2.0); + d_m1_m2_2 = pow(m1->x - m2->x, 2.0) + pow(m1->y - m2->y, 2.0); + + tmp.scale = comp_scale(m1, m2, d_m1_m2_2); + + for(i=0; i<2; i++) { // we need to try four possible solutions ... + for(j=0; j<2; j++) { + tmp.a_center = comp_dir_view(m1, m2, d_m1_2, d_m2_2, + tmp.scale, i==0?1.0:-1.0); + tmp.a_nick = comp_nick_view(m1, m2, d_m1_2, tmp.scale, tmp.a_center, + j==0?1.0:-1.0); + + // use the point with greater distance from center for tilt computation + if (d_m1_2 > d_m2_2) { + tmp.a_tilt = comp_tilt_view(m1, tmp.scale, tmp.a_center, tmp.a_nick); + } else { + tmp.a_tilt = comp_tilt_view(m2, tmp.scale, tmp.a_center, tmp.a_nick); + } + + if (isnan(tmp.a_center) || isnan(tmp.scale) || + isnan(tmp.a_nick) || isnan(tmp.a_tilt)) { + ; + } else { + get_coordinates(m1->a_view, m1->a_nick, &tmp, &tmp_x, &tmp_y); + val = sqrt(pow(tmp_x - m1->x, 2.0) + pow(tmp_y - m1->y, 2.0)); + get_coordinates(m2->a_view, m2->a_nick, &tmp, &tmp_x, &tmp_y); + val += sqrt(pow(tmp_x - m2->x, 2.0) + pow(tmp_y - m2->y, 2.0)); + + if (val < best_val) { + best_val = val; + best = tmp; + } + } + } + } + + if (best_val < BEST_UNDEF) { + *parms = best; + return 0; + } else { + return 1; + } } void ProjectionSphaeric::get_coordinates(double a_view, double a_nick, const ViewParams *parms, double *x, double *y) { - double x_tmp, y_tmp; + double x_tmp, y_tmp; - x_tmp = a_view * parms->scale; - y_tmp = - (a_nick - parms->a_nick) * parms->scale; + x_tmp = a_view * parms->scale; + y_tmp = - (a_nick - parms->a_nick) * parms->scale; - // rotate by a_tilt; - *x = x_tmp * cos(parms->a_tilt) - y_tmp * sin(parms->a_tilt); - *y = x_tmp * sin(parms->a_tilt) + y_tmp * cos(parms->a_tilt); + // rotate by a_tilt; + *x = x_tmp * cos(parms->a_tilt) - y_tmp * sin(parms->a_tilt); + *y = x_tmp * sin(parms->a_tilt) + y_tmp * cos(parms->a_tilt); } double ProjectionSphaeric::comp_scale(const Hill *m1, const Hill *m2, double d_m1_m2_2) { - double sign1 = 1.0; - double nick_m1 = m1->a_nick; - double nick_m2 = m2->a_nick; - double dir_m1 = m1->alph; - double dir_m2 = m2->alph; + double sign1 = 1.0; + double nick_m1 = m1->a_nick; + double nick_m2 = m2->a_nick; + double dir_m1 = m1->alph; + double dir_m2 = m2->alph; - return (pow((d_m1_m2_2 / ((dir_m2 * dir_m2) - (2.0 * ((dir_m2 * dir_m1) + (nick_m2 * nick_m1))) + (nick_m2 * nick_m2) + (dir_m1 * dir_m1) + (nick_m1 * nick_m1))), (1.0 / 2.0)) * sign1); + return (pow((d_m1_m2_2 / ((dir_m2 * dir_m2) - (2.0 * ((dir_m2 * dir_m1) + (nick_m2 * nick_m1))) + (nick_m2 * nick_m2) + (dir_m1 * dir_m1) + (nick_m1 * nick_m1))), (1.0 / 2.0)) * sign1); } // using the sign3 parameter one can choose between the two possible solutions // sign3 must be 1.0 or -1.0 double ProjectionSphaeric::comp_dir_view(const Hill *m1, const Hill *m2, double d_m1_2, double d_m2_2, double scale, double sign3) { - double dir_view; - double nick_m1 = m1->a_nick; - double nick_m2 = m2->a_nick; - double dir_m1 = m1->alph; - double dir_m2 = m2->alph; + double dir_view; + double nick_m1 = m1->a_nick; + double nick_m2 = m2->a_nick; + double dir_m1 = m1->alph; + double dir_m2 = m2->alph; - dir_view = (((pow((16.0 * pow(scale, 4.0) * (((scale * scale) * ((2.0 * (((scale * scale) * ((dir_m1 * ((dir_m1 * ((nick_m1 * ((nick_m1 * ((nick_m2 * ((4.0 * nick_m1) - (6.0 * nick_m2))) - (nick_m1 * nick_m1))) + (nick_m2 * ((4.0 * (nick_m2 * nick_m2)) + (6.0 * (dir_m2 * dir_m2)) + (dir_m1 * dir_m1))))) - pow(nick_m2, 4.0))) + (nick_m1 * nick_m2 * dir_m2 * ((nick_m1 * ((12.0 * nick_m2) - (8.0 * nick_m1))) - (8.0 * (nick_m2 * nick_m2)))))) + ((dir_m2 * dir_m2) * ((nick_m1 * ((nick_m2 * (dir_m2 * dir_m2)) - pow(nick_m1, 3.0))) - pow(nick_m2, 4.0))))) + ((d_m1_2 + d_m2_2) * ((((nick_m1 * nick_m1) + (nick_m2 * nick_m2)) * ((dir_m1 * dir_m1) + (dir_m2 * dir_m2))) + pow(nick_m1, 4.0) + pow(nick_m2, 4.0))))) + (4.0 * ((dir_m1 * ((nick_m1 * ((nick_m1 * dir_m2 * (((scale * scale) * ((nick_m1 * nick_m1) + (dir_m1 * dir_m1) + (dir_m2 * dir_m2))) - d_m1_2 - d_m2_2)) - (dir_m1 * nick_m2 * (d_m2_2 + d_m1_2)))) + ((nick_m2 * nick_m2) * dir_m2 * (((scale * scale) * ((nick_m2 * nick_m2) + (dir_m1 * dir_m1) + (dir_m2 * dir_m2))) - d_m1_2 - d_m2_2)))) - (nick_m1 * nick_m2 * (dir_m2 * dir_m2) * (d_m1_2 + d_m2_2)))) + ((scale * scale) * ((nick_m1 * ((nick_m1 * ((nick_m2 * (((dir_m2 * dir_m2) * ((8.0 * nick_m1) - (12.0 * nick_m2))) + (nick_m1 * ((nick_m1 * ((6.0 * nick_m1) - (15.0 * nick_m2))) + (20.0 * (nick_m2 * nick_m2)))) - (15.0 * pow(nick_m2, 3.0)))) - ((dir_m1 * dir_m1) * ((dir_m1 * dir_m1) + (6.0 * (dir_m2 * dir_m2)))) - pow(dir_m2, 4.0) - pow(nick_m1, 4.0))) + (nick_m2 * ((8.0 * dir_m2 * ((dir_m2 * ((nick_m2 * nick_m2) - (dir_m1 * dir_m2))) - pow(dir_m1, 3.0))) + (6.0 * pow(nick_m2, 4.0)))))) - ((nick_m2 * nick_m2) * (((dir_m1 * dir_m1) * ((6.0 * (dir_m2 * dir_m2)) + (dir_m1 * dir_m1))) + pow(dir_m2, 4.0) + pow(nick_m2, 4.0))))) + (nick_m1 * nick_m2 * (d_m1_2 + d_m2_2) * ((8.0 * ((dir_m1 * dir_m2) - (nick_m1 * nick_m1) - (nick_m2 * nick_m2))) + (12.0 * nick_m1 * nick_m2))))) + (((d_m1_2 * ((2.0 * d_m2_2) - d_m1_2)) - (d_m2_2 * d_m2_2)) * ((nick_m1 * (nick_m1 - (2.0 * nick_m2))) + (nick_m2 * nick_m2))))), (1.0 / 2.0)) * sign3 / 2.0) + (2.0 * (scale * scale) * (((scale * scale) * ((dir_m1 * ((nick_m1 * (nick_m1 - (2.0 * nick_m2))) + (nick_m2 * nick_m2) - (dir_m2 * (dir_m2 + dir_m1)) + (dir_m1 * dir_m1))) + (dir_m2 * ((dir_m2 * dir_m2) + (nick_m1 * (nick_m1 - (2.0 * nick_m2))) + (nick_m2 * nick_m2))))) + ((dir_m2 - dir_m1) * (d_m1_2 - d_m2_2))))) / (4.0 * pow(scale, 4.0) * ((dir_m1 * (dir_m1 - (2.0 * dir_m2))) + (dir_m2 * dir_m2) + (nick_m1 * (nick_m1 - (2.0 * nick_m2))) + (nick_m2 * nick_m2)))); + dir_view = (((pow((16.0 * pow(scale, 4.0) * (((scale * scale) * ((2.0 * (((scale * scale) * ((dir_m1 * ((dir_m1 * ((nick_m1 * ((nick_m1 * ((nick_m2 * ((4.0 * nick_m1) - (6.0 * nick_m2))) - (nick_m1 * nick_m1))) + (nick_m2 * ((4.0 * (nick_m2 * nick_m2)) + (6.0 * (dir_m2 * dir_m2)) + (dir_m1 * dir_m1))))) - pow(nick_m2, 4.0))) + (nick_m1 * nick_m2 * dir_m2 * ((nick_m1 * ((12.0 * nick_m2) - (8.0 * nick_m1))) - (8.0 * (nick_m2 * nick_m2)))))) + ((dir_m2 * dir_m2) * ((nick_m1 * ((nick_m2 * (dir_m2 * dir_m2)) - pow(nick_m1, 3.0))) - pow(nick_m2, 4.0))))) + ((d_m1_2 + d_m2_2) * ((((nick_m1 * nick_m1) + (nick_m2 * nick_m2)) * ((dir_m1 * dir_m1) + (dir_m2 * dir_m2))) + pow(nick_m1, 4.0) + pow(nick_m2, 4.0))))) + (4.0 * ((dir_m1 * ((nick_m1 * ((nick_m1 * dir_m2 * (((scale * scale) * ((nick_m1 * nick_m1) + (dir_m1 * dir_m1) + (dir_m2 * dir_m2))) - d_m1_2 - d_m2_2)) - (dir_m1 * nick_m2 * (d_m2_2 + d_m1_2)))) + ((nick_m2 * nick_m2) * dir_m2 * (((scale * scale) * ((nick_m2 * nick_m2) + (dir_m1 * dir_m1) + (dir_m2 * dir_m2))) - d_m1_2 - d_m2_2)))) - (nick_m1 * nick_m2 * (dir_m2 * dir_m2) * (d_m1_2 + d_m2_2)))) + ((scale * scale) * ((nick_m1 * ((nick_m1 * ((nick_m2 * (((dir_m2 * dir_m2) * ((8.0 * nick_m1) - (12.0 * nick_m2))) + (nick_m1 * ((nick_m1 * ((6.0 * nick_m1) - (15.0 * nick_m2))) + (20.0 * (nick_m2 * nick_m2)))) - (15.0 * pow(nick_m2, 3.0)))) - ((dir_m1 * dir_m1) * ((dir_m1 * dir_m1) + (6.0 * (dir_m2 * dir_m2)))) - pow(dir_m2, 4.0) - pow(nick_m1, 4.0))) + (nick_m2 * ((8.0 * dir_m2 * ((dir_m2 * ((nick_m2 * nick_m2) - (dir_m1 * dir_m2))) - pow(dir_m1, 3.0))) + (6.0 * pow(nick_m2, 4.0)))))) - ((nick_m2 * nick_m2) * (((dir_m1 * dir_m1) * ((6.0 * (dir_m2 * dir_m2)) + (dir_m1 * dir_m1))) + pow(dir_m2, 4.0) + pow(nick_m2, 4.0))))) + (nick_m1 * nick_m2 * (d_m1_2 + d_m2_2) * ((8.0 * ((dir_m1 * dir_m2) - (nick_m1 * nick_m1) - (nick_m2 * nick_m2))) + (12.0 * nick_m1 * nick_m2))))) + (((d_m1_2 * ((2.0 * d_m2_2) - d_m1_2)) - (d_m2_2 * d_m2_2)) * ((nick_m1 * (nick_m1 - (2.0 * nick_m2))) + (nick_m2 * nick_m2))))), (1.0 / 2.0)) * sign3 / 2.0) + (2.0 * (scale * scale) * (((scale * scale) * ((dir_m1 * ((nick_m1 * (nick_m1 - (2.0 * nick_m2))) + (nick_m2 * nick_m2) - (dir_m2 * (dir_m2 + dir_m1)) + (dir_m1 * dir_m1))) + (dir_m2 * ((dir_m2 * dir_m2) + (nick_m1 * (nick_m1 - (2.0 * nick_m2))) + (nick_m2 * nick_m2))))) + ((dir_m2 - dir_m1) * (d_m1_2 - d_m2_2))))) / (4.0 * pow(scale, 4.0) * ((dir_m1 * (dir_m1 - (2.0 * dir_m2))) + (dir_m2 * dir_m2) + (nick_m1 * (nick_m1 - (2.0 * nick_m2))) + (nick_m2 * nick_m2)))); - return dir_view; + return dir_view; } double ProjectionSphaeric::comp_nick_view(const Hill *m1, const Hill *m2, double d_m1_2, double scale, double dir_view, double sign1) { - double nick_view; - double nick_m1 = m1->a_nick; - double dir_m1 = m1->alph; + double nick_view; + double nick_m1 = m1->a_nick; + double dir_m1 = m1->alph; - nick_view = ((pow(((d_m1_2 / (scale * scale)) - pow((dir_view - dir_m1), 2.0)), (1.0 / 2.0)) * sign1) + nick_m1); + nick_view = ((pow(((d_m1_2 / (scale * scale)) - pow((dir_view - dir_m1), 2.0)), (1.0 / 2.0)) * sign1) + nick_m1); - return nick_view; + return nick_view; } double ProjectionSphaeric::comp_tilt_view(const Hill *m, double scale, double dir_view, double nick_view) { - double sin_a_tilt1, sin_a_tilt2, sin_a_tilt, res; - double x_tmp = (m->alph - dir_view) * scale; - double y_tmp = (m->a_nick - nick_view) * scale; - double x = m->x; - double y = m->y; + double sin_a_tilt1, sin_a_tilt2, sin_a_tilt, res; + double x_tmp = (m->alph - dir_view) * scale; + double y_tmp = (m->a_nick - nick_view) * scale; + double x = m->x; + double y = m->y; - sin_a_tilt1 = - (y * - pow(x*x + y*y - y_tmp*y_tmp, 0.5) - x * y_tmp) / - (x*x + y*y); + sin_a_tilt1 = - (y * - pow(x*x + y*y - y_tmp*y_tmp, 0.5) - x * y_tmp) / + (x*x + y*y); - sin_a_tilt2 = - (y * pow(x*x + y*y - y_tmp*y_tmp, 0.5) - x * y_tmp) / - (x*x + y*y); + sin_a_tilt2 = - (y * pow(x*x + y*y - y_tmp*y_tmp, 0.5) - x * y_tmp) / + (x*x + y*y); - sin_a_tilt = fabs(sin_a_tilt1) < fabs(sin_a_tilt2)?sin_a_tilt1:sin_a_tilt2; + sin_a_tilt = fabs(sin_a_tilt1) < fabs(sin_a_tilt2)?sin_a_tilt1:sin_a_tilt2; - res = asin(sin_a_tilt); + res = asin(sin_a_tilt); - if (res > pi_d / 4.0) { - res = res - pi_d / 2.0; - } else if (res < -pi_d / 4.0) { - res = res + pi_d / 2.0; - } + if (res > pi_d / 4.0) { + res = res - pi_d / 2.0; + } else if (res < -pi_d / 4.0) { + res = res + pi_d / 2.0; + } + + return res; - return res; - } diff --git a/src/ProjectionTangential.H b/src/ProjectionTangential.H index 07ddaf9..13e354a 100644 --- a/src/ProjectionTangential.H +++ b/src/ProjectionTangential.H @@ -11,19 +11,19 @@ #include "Projection.H" class ProjectionTangential : public Projection { - private: - double comp_center_angle(double alph_a, double alph_b, double d1, double d2); + private: + 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); + double comp_scale(double alph_a, double alph_b, double d1, double d2); - double angle_dist(double a1, double a2); + double angle_dist(double a1, double a2); - int optimize(const Hill *m1, const Hill *m2, ViewParams *parms); + int optimize(const Hill *m1, const Hill *m2, ViewParams *parms); - public: - void get_coordinates(double a_view, double a_nick, const ViewParams *parms, - double *x, double *y); - - int comp_params(const Hill *m1, const Hill *m2, ViewParams *parms); + public: + void get_coordinates(double a_view, double a_nick, const ViewParams *parms, + double *x, double *y); + + int comp_params(const Hill *m1, const Hill *m2, ViewParams *parms); }; #endif diff --git a/src/ProjectionTangential.cxx b/src/ProjectionTangential.cxx index 230767c..8eed552 100644 --- a/src/ProjectionTangential.cxx +++ b/src/ProjectionTangential.cxx @@ -15,284 +15,284 @@ extern "C" { #include "ProjectionTangential.H" static int opt_step(double *tan_nick_view, - double *tan_dir_view, - double *n_scale, - double tan_dir_m1, - double tan_nick_m1, - double tan_dir_m2, - double tan_nick_m2, - double d_m1_2, double d_m2_2, double d_m1_m2_2); + double *tan_dir_view, + double *n_scale, + double tan_dir_m1, + double tan_nick_m1, + double tan_dir_m2, + double tan_nick_m2, + double d_m1_2, double d_m2_2, double d_m1_m2_2); static double comp_tilt(double tan_nick_view, double tan_dir_view, double n_scale, - double tan_nick_m, double tan_dir_m, - double x, double y, double pi_d); + double tan_nick_m, double tan_dir_m, + double x, double y, double pi_d); int ProjectionTangential::comp_params(const Hill *m1, const Hill *m2, ViewParams *parms) { - const Hill *tmp; - double a_center_tmp, scale_tmp, a_nick_tmp; - - scale_tmp = comp_scale(m1->alph, m2->alph, m1->x, m2->x); - if (isnan(scale_tmp) || scale_tmp < 100.0) { - // try again with mountains swapped - tmp = m1; - m1 = m2; - m2 = tmp; - scale_tmp = comp_scale(m1->alph, m2->alph, m1->x, m2->x); - } - - a_center_tmp = comp_center_angle(m1->alph, m2->alph, m1->x, m2->x); - a_nick_tmp = atan ((m1->y + tan(m1->a_nick) * parms->scale) / - (parms->scale - m1->y * tan(m1->a_nick))); - - if (isnan(a_center_tmp) || isnan(scale_tmp) || - scale_tmp < 100.0 || isnan(a_nick_tmp)) { - return 1; - } else { - - parms->a_center = a_center_tmp; - parms->scale = scale_tmp; - parms->a_nick = a_nick_tmp; - - optimize(m1, m2, parms); - - return 0; - } + const Hill *tmp; + double a_center_tmp, scale_tmp, a_nick_tmp; + + scale_tmp = comp_scale(m1->alph, m2->alph, m1->x, m2->x); + if (isnan(scale_tmp) || scale_tmp < 100.0) { + // try again with mountains swapped + tmp = m1; + m1 = m2; + m2 = tmp; + scale_tmp = comp_scale(m1->alph, m2->alph, m1->x, m2->x); + } + + a_center_tmp = comp_center_angle(m1->alph, m2->alph, m1->x, m2->x); + a_nick_tmp = atan ((m1->y + tan(m1->a_nick) * parms->scale) / + (parms->scale - m1->y * tan(m1->a_nick))); + + if (isnan(a_center_tmp) || isnan(scale_tmp) || + scale_tmp < 100.0 || isnan(a_nick_tmp)) { + return 1; + } else { + + parms->a_center = a_center_tmp; + parms->scale = scale_tmp; + parms->a_nick = a_nick_tmp; + + optimize(m1, m2, parms); + + return 0; + } } double ProjectionTangential::angle_dist(double a1, double a2) { - double ret; - - a1 = fmod(a1, 2.0 * pi_d); - if (a1 < 0.0) { - a1 = a1 + 2.0 * pi_d; - } - a2 = fmod(a2, 2.0 * pi_d); - if (a2 < 0.0) { - a2 = a2 + 2.0 * pi_d; - } - - ret = fabs(a1 - a2); - if (ret > pi_d) { - ret = 2.0 * pi_d - ret; - } - - return ret; + double ret; + + a1 = fmod(a1, 2.0 * pi_d); + if (a1 < 0.0) { + a1 = a1 + 2.0 * pi_d; + } + a2 = fmod(a2, 2.0 * pi_d); + if (a2 < 0.0) { + a2 = a2 + 2.0 * pi_d; + } + + ret = fabs(a1 - a2); + if (ret > pi_d) { + ret = 2.0 * pi_d - ret; + } + + return ret; } int ProjectionTangential::optimize(const Hill *m1, const Hill *m2, ViewParams *parms) { - int i; - double tan_nick_view, tan_dir_view, n_scale; - double tan_nick_m1, tan_dir_m1; - double tan_nick_m2, tan_dir_m2; - double d_m1_2, d_m2_2, d_m1_m2_2; - - d_m1_2 = pow(m1->x, 2.0) + pow(m1->y, 2.0); - d_m2_2 = pow(m2->x, 2.0) + pow(m2->y, 2.0); - d_m1_m2_2 = pow(m1->x - m2->x, 2.0) + pow(m1->y - m2->y, 2.0); - - tan_nick_view = tan(parms->a_nick); - tan_dir_view = tan(parms->a_center); - n_scale = parms->scale; - tan_dir_m1 = tan(m1->alph); - tan_nick_m1 = tan(m1->a_nick); - tan_dir_m2 = tan(m2->alph); - tan_nick_m2 = tan(m2->a_nick); - - for (i=0; i<5; i++) { - opt_step(&tan_nick_view, &tan_dir_view, &n_scale, - tan_dir_m1, tan_nick_m1, tan_dir_m2, tan_nick_m2, - d_m1_2, d_m2_2, d_m1_m2_2); - } - - if (isnan(tan_dir_view) || isnan(tan_nick_view) || isnan(n_scale)) { - fprintf(stderr, "No solution found.\n"); - return 1; - } - - parms->a_center = atan(tan_dir_view); - parms->a_nick = atan(tan_nick_view); - - if (parms->a_center > 2.0 * pi_d) { - parms->a_center = parms->a_center - 2.0 * pi_d; - } else if (parms->a_center < 0.0) { - parms->a_center = parms->a_center + 2.0 * pi_d; - } - - // atan(tan_dir_view) is not the only possible solution. - // Choose the one which is close to m1->alph. - if (angle_dist(parms->a_center, m1->alph) > pi_d/2.0) { - parms->a_center = parms->a_center + pi_d; - } - - parms->scale = n_scale; - - // use the point with greater distance from center for tilt computation - if (d_m1_2 > d_m2_2) { - parms->a_tilt = comp_tilt(tan_nick_view, tan_dir_view, n_scale, - tan_nick_m1, tan_dir_m1, - (double) m1->x, (double) m1->y, pi_d); - } else { - parms->a_tilt = comp_tilt(tan_nick_view, tan_dir_view, n_scale, - tan_nick_m2, tan_dir_m2, - (double) m2->x, (double) m2->y, pi_d); - } - - return 0; + int i; + double tan_nick_view, tan_dir_view, n_scale; + double tan_nick_m1, tan_dir_m1; + double tan_nick_m2, tan_dir_m2; + double d_m1_2, d_m2_2, d_m1_m2_2; + + d_m1_2 = pow(m1->x, 2.0) + pow(m1->y, 2.0); + d_m2_2 = pow(m2->x, 2.0) + pow(m2->y, 2.0); + d_m1_m2_2 = pow(m1->x - m2->x, 2.0) + pow(m1->y - m2->y, 2.0); + + tan_nick_view = tan(parms->a_nick); + tan_dir_view = tan(parms->a_center); + n_scale = parms->scale; + tan_dir_m1 = tan(m1->alph); + tan_nick_m1 = tan(m1->a_nick); + tan_dir_m2 = tan(m2->alph); + tan_nick_m2 = tan(m2->a_nick); + + for (i=0; i<5; i++) { + opt_step(&tan_nick_view, &tan_dir_view, &n_scale, + tan_dir_m1, tan_nick_m1, tan_dir_m2, tan_nick_m2, + d_m1_2, d_m2_2, d_m1_m2_2); + } + + if (isnan(tan_dir_view) || isnan(tan_nick_view) || isnan(n_scale)) { + fprintf(stderr, "No solution found.\n"); + return 1; + } + + parms->a_center = atan(tan_dir_view); + parms->a_nick = atan(tan_nick_view); + + if (parms->a_center > 2.0 * pi_d) { + parms->a_center = parms->a_center - 2.0 * pi_d; + } else if (parms->a_center < 0.0) { + parms->a_center = parms->a_center + 2.0 * pi_d; + } + + // atan(tan_dir_view) is not the only possible solution. + // Choose the one which is close to m1->alph. + if (angle_dist(parms->a_center, m1->alph) > pi_d/2.0) { + parms->a_center = parms->a_center + pi_d; + } + + parms->scale = n_scale; + + // use the point with greater distance from center for tilt computation + if (d_m1_2 > d_m2_2) { + parms->a_tilt = comp_tilt(tan_nick_view, tan_dir_view, n_scale, + tan_nick_m1, tan_dir_m1, + (double) m1->x, (double) m1->y, pi_d); + } else { + parms->a_tilt = comp_tilt(tan_nick_view, tan_dir_view, n_scale, + tan_nick_m2, tan_dir_m2, + (double) m2->x, (double) m2->y, pi_d); + } + + return 0; } void ProjectionTangential::get_coordinates(double a_view, double a_nick, const ViewParams *parms, double *x, double *y) { - double x_tmp, y_tmp; + double x_tmp, y_tmp; - x_tmp = tan(a_view) * parms->scale; - y_tmp = - (tan(a_nick - parms->a_nick) * parms->scale); + x_tmp = tan(a_view) * parms->scale; + y_tmp = - (tan(a_nick - parms->a_nick) * parms->scale); - // rotate by a_tilt; - *x = x_tmp * cos(parms->a_tilt) - y_tmp * sin(parms->a_tilt); - *y = x_tmp * sin(parms->a_tilt) + y_tmp * cos(parms->a_tilt); + // rotate by a_tilt; + *x = x_tmp * cos(parms->a_tilt) - y_tmp * sin(parms->a_tilt); + *y = x_tmp * sin(parms->a_tilt) + y_tmp * cos(parms->a_tilt); } double ProjectionTangential::comp_center_angle(double a1, double a2, double d1, double d2) { - double sign1 = 1.0; - double tan_acenter, tan_a1, tan_a2, a_center; + double sign1 = 1.0; + double tan_acenter, tan_a1, tan_a2, a_center; - tan_a1 = tan(a1); - tan_a2 = tan(a2); + tan_a1 = tan(a1); + tan_a2 = tan(a2); - tan_acenter = (((pow(((pow((1.0 + (tan_a1 * tan_a2)), 2.0) * ((d1 * d1) + (d2 * d2))) + (2.0 * d1 * d2 * ((2.0 * ((tan_a2 * tan_a1) - (tan_a2 * tan_a2))) - ((tan_a1 * tan_a1) * (2.0 + (tan_a2 * tan_a2))) - 1.0))), (1.0 / 2.0)) * sign1) + ((1.0 - (tan_a1 * tan_a2)) * (d1 - d2))) / (2.0 * ((d2 * tan_a2) - (d1 * tan_a1)))); + tan_acenter = (((pow(((pow((1.0 + (tan_a1 * tan_a2)), 2.0) * ((d1 * d1) + (d2 * d2))) + (2.0 * d1 * d2 * ((2.0 * ((tan_a2 * tan_a1) - (tan_a2 * tan_a2))) - ((tan_a1 * tan_a1) * (2.0 + (tan_a2 * tan_a2))) - 1.0))), (1.0 / 2.0)) * sign1) + ((1.0 - (tan_a1 * tan_a2)) * (d1 - d2))) / (2.0 * ((d2 * tan_a2) - (d1 * tan_a1)))); - a_center = atan(tan_acenter); + a_center = atan(tan_acenter); - if (a_center > 2.0 * pi_d) { - a_center = a_center - 2.0 * pi_d; - } else if (a_center < 0.0) { - a_center = a_center + 2.0 * pi_d; - } + if (a_center > 2.0 * pi_d) { + a_center = a_center - 2.0 * pi_d; + } else if (a_center < 0.0) { + a_center = a_center + 2.0 * pi_d; + } - // atan(tan_dir_view) is not the only possible solution. - // Choose the one which is close to m1->alph. - if (fabs(a_center - a1) > pi_d/2.0) { - a_center = a_center + pi_d; - } + // atan(tan_dir_view) is not the only possible solution. + // Choose the one which is close to m1->alph. + if (fabs(a_center - a1) > pi_d/2.0) { + a_center = a_center + pi_d; + } - return a_center; + return a_center; } double ProjectionTangential::comp_scale(double a1, double a2, double d1, double d2) { - double sign1 = 1.0; - double sc, tan_a1, tan_a2; + double sign1 = 1.0; + double sc, tan_a1, tan_a2; - tan_a1 = tan(a1); - tan_a2 = tan(a2); - - sc = ((((1.0 + (tan_a1 * tan_a2)) * (d1 - d2)) - (sign1 * pow((((1.0 + pow((tan_a1 * tan_a2), 2.0)) * ((d1 * d1) + (d2 * d2))) + (2.0 * ((tan_a1 * tan_a2 * pow((d1 + d2), 2.0)) - (d1 * d2 * (((tan_a1 * tan_a1) * (2.0 + (tan_a2 * tan_a2))) + 1.0 + (2.0 * (tan_a2 * tan_a2))))))), (1.0 / 2.0)))) / (2.0 * (tan_a1 - tan_a2))); + tan_a1 = tan(a1); + tan_a2 = tan(a2); - return sc; + sc = ((((1.0 + (tan_a1 * tan_a2)) * (d1 - d2)) - (sign1 * pow((((1.0 + pow((tan_a1 * tan_a2), 2.0)) * ((d1 * d1) + (d2 * d2))) + (2.0 * ((tan_a1 * tan_a2 * pow((d1 + d2), 2.0)) - (d1 * d2 * (((tan_a1 * tan_a1) * (2.0 + (tan_a2 * tan_a2))) + 1.0 + (2.0 * (tan_a2 * tan_a2))))))), (1.0 / 2.0)))) / (2.0 * (tan_a1 - tan_a2))); + + return sc; } static int get_matrix(double m[], - double tan_nick_view, double tan_dir_view, double n_scale, - double tan_dir_m1, double tan_nick_m1, - double tan_dir_m2, double tan_nick_m2) { - - m[0] = pow(n_scale,2.0)*(1.0/pow((tan_nick_m1*tan_nick_view + 1.0),2.0)*(2.0*tan_nick_m1 - 2.0 * tan_nick_view) + 2.0*tan_nick_m1*pow((tan_nick_m1 - tan_nick_view), 2.0)/pow((tan_nick_m1*tan_nick_view + 1.0), 3.0)); + double tan_nick_view, double tan_dir_view, double n_scale, + double tan_dir_m1, double tan_nick_m1, + double tan_dir_m2, double tan_nick_m2) { + + m[0] = pow(n_scale,2.0)*(1.0/pow((tan_nick_m1*tan_nick_view + 1.0),2.0)*(2.0*tan_nick_m1 - 2.0 * tan_nick_view) + 2.0*tan_nick_m1*pow((tan_nick_m1 - tan_nick_view), 2.0)/pow((tan_nick_m1*tan_nick_view + 1.0), 3.0)); - m[1] = pow(n_scale, 2.0) *(1.0/pow((tan_dir_m1*tan_dir_view + 1.0), 2.0) * (2.0*tan_dir_m1 - 2.0*tan_dir_view) + 2.0*tan_dir_m1*pow((tan_dir_m1 - tan_dir_view),2.0) / pow((tan_dir_m1*tan_dir_view + 1.0), 3.0)); + m[1] = pow(n_scale, 2.0) *(1.0/pow((tan_dir_m1*tan_dir_view + 1.0), 2.0) * (2.0*tan_dir_m1 - 2.0*tan_dir_view) + 2.0*tan_dir_m1*pow((tan_dir_m1 - tan_dir_view),2.0) / pow((tan_dir_m1*tan_dir_view + 1.0), 3.0)); - m[2] = -2.0*n_scale*(pow((tan_dir_m1 - tan_dir_view), 2.0)/pow((tan_dir_m1*tan_dir_view + 1.0), 2.0) + pow((tan_nick_m1 - tan_nick_view), 2.0)/pow((tan_nick_m1*tan_nick_view + 1.0), 2.0)); + m[2] = -2.0*n_scale*(pow((tan_dir_m1 - tan_dir_view), 2.0)/pow((tan_dir_m1*tan_dir_view + 1.0), 2.0) + pow((tan_nick_m1 - tan_nick_view), 2.0)/pow((tan_nick_m1*tan_nick_view + 1.0), 2.0)); - m[3] = pow(n_scale, 2.0)*(1.0/pow((tan_nick_m2*tan_nick_view + 1.0), 2.0)*(2.0*tan_nick_m2 - 2.0*tan_nick_view) + 2.0*tan_nick_m2*pow((tan_nick_m2 - tan_nick_view), 2.0)/pow((tan_nick_m2*tan_nick_view + 1.0), 3.0)); + m[3] = pow(n_scale, 2.0)*(1.0/pow((tan_nick_m2*tan_nick_view + 1.0), 2.0)*(2.0*tan_nick_m2 - 2.0*tan_nick_view) + 2.0*tan_nick_m2*pow((tan_nick_m2 - tan_nick_view), 2.0)/pow((tan_nick_m2*tan_nick_view + 1.0), 3.0)); - m[4] = pow(n_scale, 2.0)*(1.0/pow((tan_dir_m2*tan_dir_view + 1.0), 2.0)*(2.0*tan_dir_m2 - 2.0*tan_dir_view) + 2.0*tan_dir_m2*pow((tan_dir_m2 - tan_dir_view), 2.0)/pow((tan_dir_m2*tan_dir_view + 1.0), 3.0)); + m[4] = pow(n_scale, 2.0)*(1.0/pow((tan_dir_m2*tan_dir_view + 1.0), 2.0)*(2.0*tan_dir_m2 - 2.0*tan_dir_view) + 2.0*tan_dir_m2*pow((tan_dir_m2 - tan_dir_view), 2.0)/pow((tan_dir_m2*tan_dir_view + 1.0), 3.0)); - m[5] = -2.0*n_scale*(pow((tan_dir_m2 - tan_dir_view), 2.0)/pow((tan_dir_m2*tan_dir_view + 1.0), 2.0) + pow((tan_nick_m2 - tan_nick_view), 2.0)/pow((tan_nick_m2*tan_nick_view + 1.0), 2.0)); + m[5] = -2.0*n_scale*(pow((tan_dir_m2 - tan_dir_view), 2.0)/pow((tan_dir_m2*tan_dir_view + 1.0), 2.0) + pow((tan_nick_m2 - tan_nick_view), 2.0)/pow((tan_nick_m2*tan_nick_view + 1.0), 2.0)); - m[6] = 2.0*(n_scale*(tan_nick_m1 - tan_nick_view)/(tan_nick_m1*tan_nick_view + 1.0) - n_scale*(tan_nick_m2 - tan_nick_view)/(tan_nick_m2*tan_nick_view + 1.0))*(n_scale/(tan_nick_m1*tan_nick_view + 1.0) - n_scale/(tan_nick_m2*tan_nick_view + 1.0) + tan_nick_m1*n_scale*(tan_nick_m1 - tan_nick_view)/pow((tan_nick_m1*tan_nick_view + 1.0), 2.0) - tan_nick_m2*n_scale*(tan_nick_m2 - tan_nick_view)/pow((tan_nick_m2*tan_nick_view + 1.0),2.0)); + m[6] = 2.0*(n_scale*(tan_nick_m1 - tan_nick_view)/(tan_nick_m1*tan_nick_view + 1.0) - n_scale*(tan_nick_m2 - tan_nick_view)/(tan_nick_m2*tan_nick_view + 1.0))*(n_scale/(tan_nick_m1*tan_nick_view + 1.0) - n_scale/(tan_nick_m2*tan_nick_view + 1.0) + tan_nick_m1*n_scale*(tan_nick_m1 - tan_nick_view)/pow((tan_nick_m1*tan_nick_view + 1.0), 2.0) - tan_nick_m2*n_scale*(tan_nick_m2 - tan_nick_view)/pow((tan_nick_m2*tan_nick_view + 1.0),2.0)); - m[7] = 2.0*(n_scale*(tan_dir_m1 - tan_dir_view)/(tan_dir_m1*tan_dir_view + 1.0) - n_scale*(tan_dir_m2 - tan_dir_view)/(tan_dir_m2*tan_dir_view + 1.0))*(n_scale/(tan_dir_m1*tan_dir_view + 1.0) - n_scale/(tan_dir_m2*tan_dir_view + 1.0) + tan_dir_m1*n_scale*(tan_dir_m1 - tan_dir_view)/pow((tan_dir_m1*tan_dir_view + 1.0), 2.0) - tan_dir_m2*n_scale*(tan_dir_m2 - tan_dir_view)/pow((tan_dir_m2*tan_dir_view + 1.0), 2.0)); + m[7] = 2.0*(n_scale*(tan_dir_m1 - tan_dir_view)/(tan_dir_m1*tan_dir_view + 1.0) - n_scale*(tan_dir_m2 - tan_dir_view)/(tan_dir_m2*tan_dir_view + 1.0))*(n_scale/(tan_dir_m1*tan_dir_view + 1.0) - n_scale/(tan_dir_m2*tan_dir_view + 1.0) + tan_dir_m1*n_scale*(tan_dir_m1 - tan_dir_view)/pow((tan_dir_m1*tan_dir_view + 1.0), 2.0) - tan_dir_m2*n_scale*(tan_dir_m2 - tan_dir_view)/pow((tan_dir_m2*tan_dir_view + 1.0), 2.0)); - m[8] = - 2.0*(n_scale*(tan_dir_m1 - tan_dir_view)/(tan_dir_m1*tan_dir_view + 1.0) - n_scale*(tan_dir_m2 - tan_dir_view)/(tan_dir_m2*tan_dir_view + 1.0))*((tan_dir_m1 - tan_dir_view)/(tan_dir_m1*tan_dir_view + 1.0) - (tan_dir_m2 - tan_dir_view)/(tan_dir_m2*tan_dir_view + 1.0)) - 2.0*(n_scale*(tan_nick_m1 - tan_nick_view)/(tan_nick_m1*tan_nick_view + 1.0) - n_scale*(tan_nick_m2 - tan_nick_view)/(tan_nick_m2*tan_nick_view + 1.0))*((tan_nick_m1 - tan_nick_view)/(tan_nick_m1*tan_nick_view + 1.0) - (tan_nick_m2 - tan_nick_view)/(tan_nick_m2*tan_nick_view + 1.0)); + m[8] = - 2.0*(n_scale*(tan_dir_m1 - tan_dir_view)/(tan_dir_m1*tan_dir_view + 1.0) - n_scale*(tan_dir_m2 - tan_dir_view)/(tan_dir_m2*tan_dir_view + 1.0))*((tan_dir_m1 - tan_dir_view)/(tan_dir_m1*tan_dir_view + 1.0) - (tan_dir_m2 - tan_dir_view)/(tan_dir_m2*tan_dir_view + 1.0)) - 2.0*(n_scale*(tan_nick_m1 - tan_nick_view)/(tan_nick_m1*tan_nick_view + 1.0) - n_scale*(tan_nick_m2 - tan_nick_view)/(tan_nick_m2*tan_nick_view + 1.0))*((tan_nick_m1 - tan_nick_view)/(tan_nick_m1*tan_nick_view + 1.0) - (tan_nick_m2 - tan_nick_view)/(tan_nick_m2*tan_nick_view + 1.0)); - return 0; + return 0; } static int opt_step(double *tan_nick_view, - double *tan_dir_view, - double *n_scale, - double tan_dir_m1, - double tan_nick_m1, - double tan_dir_m2, - double tan_nick_m2, - double d_m1_2, double d_m2_2, double d_m1_m2_2) { - double a[9]; - double b[3]; - double a_x0[3], f_x0 [3], x0[3]; - int ret; + double *tan_dir_view, + double *n_scale, + double tan_dir_m1, + double tan_nick_m1, + double tan_dir_m2, + double tan_nick_m2, + double d_m1_2, double d_m2_2, double d_m1_m2_2) { + double a[9]; + double b[3]; + double a_x0[3], f_x0 [3], x0[3]; + int ret; + + get_matrix(a, *tan_nick_view, *tan_dir_view, *n_scale, + tan_dir_m1, tan_nick_m1, tan_dir_m2, tan_nick_m2); - get_matrix(a, *tan_nick_view, *tan_dir_view, *n_scale, - tan_dir_m1, tan_nick_m1, tan_dir_m2, tan_nick_m2); + f_x0[0] = d_m1_2 - (pow((*tan_nick_view-tan_nick_m1),2.0)/pow((tan_nick_m1**tan_nick_view+1), 2.0)+pow((*tan_dir_view-tan_dir_m1),2.0)/pow((tan_dir_m1**tan_dir_view+1),2.0))*pow(*n_scale, 2.0); - f_x0[0] = d_m1_2 - (pow((*tan_nick_view-tan_nick_m1),2.0)/pow((tan_nick_m1**tan_nick_view+1), 2.0)+pow((*tan_dir_view-tan_dir_m1),2.0)/pow((tan_dir_m1**tan_dir_view+1),2.0))*pow(*n_scale, 2.0); + f_x0[1] = d_m2_2 - (pow((*tan_nick_view-tan_nick_m2),2.0)/pow((tan_nick_m2**tan_nick_view+1),2.0)+pow((*tan_dir_view-tan_dir_m2),2.0)/pow((tan_dir_m2**tan_dir_view+1),2.0))*pow(*n_scale, 2.0); - f_x0[1] = d_m2_2 - (pow((*tan_nick_view-tan_nick_m2),2.0)/pow((tan_nick_m2**tan_nick_view+1),2.0)+pow((*tan_dir_view-tan_dir_m2),2.0)/pow((tan_dir_m2**tan_dir_view+1),2.0))*pow(*n_scale, 2.0); + f_x0[2] = d_m1_m2_2 - (pow((- (((*tan_dir_view - tan_dir_m1) * *n_scale) / (tan_dir_m1 * *tan_dir_view + 1.0)) + (((*tan_dir_view - tan_dir_m2) * *n_scale) / (tan_dir_m2 * *tan_dir_view + 1))), 2.0) + pow((- (((*tan_nick_view - tan_nick_m1) * *n_scale) / (tan_nick_m1 * *tan_nick_view + 1)) + ((*tan_nick_view - tan_nick_m2) * *n_scale) / (tan_nick_m2 * *tan_nick_view + 1)), 2.0)); - f_x0[2] = d_m1_m2_2 - (pow((- (((*tan_dir_view - tan_dir_m1) * *n_scale) / (tan_dir_m1 * *tan_dir_view + 1.0)) + (((*tan_dir_view - tan_dir_m2) * *n_scale) / (tan_dir_m2 * *tan_dir_view + 1))), 2.0) + pow((- (((*tan_nick_view - tan_nick_m1) * *n_scale) / (tan_nick_m1 * *tan_nick_view + 1)) + ((*tan_nick_view - tan_nick_m2) * *n_scale) / (tan_nick_m2 * *tan_nick_view + 1)), 2.0)); + x0[0] = *tan_nick_view; + x0[1] = *tan_dir_view; + x0[2] = *n_scale; - x0[0] = *tan_nick_view; - x0[1] = *tan_dir_view; - x0[2] = *n_scale; + rmmult(a_x0, a, x0, 3, 3, 1); - rmmult(a_x0, a, x0, 3, 3, 1); - - b[0] = a_x0[0] - f_x0[0]; - b[1] = a_x0[1] - f_x0[1]; - b[2] = a_x0[2] - f_x0[2]; + b[0] = a_x0[0] - f_x0[0]; + b[1] = a_x0[1] - f_x0[1]; + b[2] = a_x0[2] - f_x0[2]; - ret = solv(a, b, 3); + ret = solv(a, b, 3); - *tan_nick_view = b[0]; - *tan_dir_view = b[1]; - *n_scale = b[2]; + *tan_nick_view = b[0]; + *tan_dir_view = b[1]; + *n_scale = b[2]; - return 0; + return 0; } static double comp_tilt(double tan_nick_view, double tan_dir_view, double n_scale, - double tan_nick_m, double tan_dir_m, - double x, double y, double pi_d) { - double y_tmp, x_tmp, sin_a_tilt1, sin_a_tilt2, sin_a_tilt, res; + double tan_nick_m, double tan_dir_m, + double x, double y, double pi_d) { + double y_tmp, x_tmp, sin_a_tilt1, sin_a_tilt2, sin_a_tilt, res; - y_tmp = - (((tan_nick_view - tan_nick_m) * n_scale) / - (tan_nick_m * tan_nick_view + 1)); - x_tmp = - (((tan_dir_view - tan_dir_m) * n_scale) / - (tan_dir_m * tan_dir_view + 1)); + y_tmp = - (((tan_nick_view - tan_nick_m) * n_scale) / + (tan_nick_m * tan_nick_view + 1)); + x_tmp = - (((tan_dir_view - tan_dir_m) * n_scale) / + (tan_dir_m * tan_dir_view + 1)); - sin_a_tilt1 = - (y * - pow(x*x + y*y - y_tmp*y_tmp, 0.5) - x * y_tmp) / - (x*x + y*y); + sin_a_tilt1 = - (y * - pow(x*x + y*y - y_tmp*y_tmp, 0.5) - x * y_tmp) / + (x*x + y*y); - sin_a_tilt2 = - (y * pow(x*x + y*y - y_tmp*y_tmp, 0.5) - x * y_tmp) / - (x*x + y*y); + sin_a_tilt2 = - (y * pow(x*x + y*y - y_tmp*y_tmp, 0.5) - x * y_tmp) / + (x*x + y*y); - sin_a_tilt = fabs(sin_a_tilt1) < fabs(sin_a_tilt2)?sin_a_tilt1:sin_a_tilt2; + sin_a_tilt = fabs(sin_a_tilt1) < fabs(sin_a_tilt2)?sin_a_tilt1:sin_a_tilt2; - res = asin(sin_a_tilt); + res = asin(sin_a_tilt); - if (res > pi_d / 4.0) { - res = res - pi_d / 2.0; - } else if (res < -pi_d / 4.0) { - res = res + pi_d / 2.0; - } + if (res > pi_d / 4.0) { + res = res - pi_d / 2.0; + } else if (res < -pi_d / 4.0) { + res = res + pi_d / 2.0; + } - return res; + return res; } diff --git a/src/Stitch.H b/src/Stitch.H index d29c2e9..49dd6b8 100644 --- a/src/Stitch.H +++ b/src/Stitch.H @@ -12,19 +12,19 @@ #define MAX_PICS 256 - + class Stitch { private: GipfelWidget *gipf[MAX_PICS]; OutputImage *single_images[MAX_PICS]; OutputImage *merged_image; - + public: Stitch(); ~Stitch(); - + int load_image(char *file); OutputImage * set_output(OutputImage *img); diff --git a/src/Stitch.cxx b/src/Stitch.cxx index f378747..7e8f909 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -78,12 +78,12 @@ Stitch::set_output(const char *file, OutputImage *img) { int Stitch::resample(int w, int h, - double view_start, double view_end) { + double view_start, double view_end) { double step_view = (view_end - view_start) / w; char r, g, b; int y_off = h / 2; int merged_pixel_set; - double radius = (double) w / (view_end -view_start); + double radius = (double) w / (view_end -view_start); if (merged_image) { merged_image->init(w, h); diff --git a/src/ViewParams.H b/src/ViewParams.H index b6f34a2..d321253 100644 --- a/src/ViewParams.H +++ b/src/ViewParams.H @@ -8,11 +8,11 @@ #define VIEWPARAMS_H class ViewParams { - public: - double a_center; - double scale; - double a_nick; - double a_tilt; + public: + double a_center; + double scale; + double a_nick; + double a_tilt; }; #endif diff --git a/src/choose_hill.cxx b/src/choose_hill.cxx index d3477f3..879e18a 100644 --- a/src/choose_hill.cxx +++ b/src/choose_hill.cxx @@ -11,30 +11,30 @@ 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_name(); - - for (int i=0; iget_num(); i++) { - Hill *m = h_sort->get(i); - if (m->flags & (Hill::DUPLICATE | Hill::TRACK_POINT)) { - continue; - } - sc->add(m->name, m); - } - - delete h_sort; - - sc->show(); - while (sc->shown()) { - Fl::wait(); - } - - ret = (Hill*) sc->data(); - - delete(sc); - - return ret; + Fl_Search_Chooser *sc = new Fl_Search_Chooser(l?l:"Choose Hill"); + Hills *h_sort = new Hills(hills); + Hill *ret; + + h_sort->sort_name(); + + for (int i=0; iget_num(); i++) { + Hill *m = h_sort->get(i); + if (m->flags & (Hill::DUPLICATE | Hill::TRACK_POINT)) { + continue; + } + sc->add(m->name, m); + } + + delete h_sort; + + sc->show(); + while (sc->shown()) { + Fl::wait(); + } + + ret = (Hill*) sc->data(); + + delete(sc); + + return ret; } diff --git a/src/util.c b/src/util.c index df3126d..7a31712 100644 --- a/src/util.c +++ b/src/util.c @@ -12,48 +12,48 @@ FILE * pexecvp(const char *file, char *const argv[], pid_t *pid, char *type) { - FILE *iop; - int pdes[2]; + FILE *iop; + int pdes[2]; - if (pipe(pdes) < 0) { - return NULL; - } - - *pid = vfork(); + if (pipe(pdes) < 0) { + return NULL; + } - if (*pid == -1) { - perror("vfork"); - close(pdes[0]); - close(pdes[1]); - return NULL; - } else if (*pid == 0) { - /* child */ - - if (*type == 'r') { - close(pdes[0]); - if (pdes[1] != STDOUT_FILENO) { - dup2(pdes[1], STDOUT_FILENO); - close(pdes[1]); - } - } else { - close(pdes[1]); - if (pdes[0] != STDIN_FILENO) { - dup2(pdes[0], STDIN_FILENO); - close(pdes[0]); - } - } + *pid = vfork(); - execvp(file, argv); - exit(127); - } else { - /* parent */ - if (*type == 'r') { - iop = fdopen(pdes[0], "r"); - close(pdes[1]); - } else { - iop = fdopen(pdes[1], "w"); - close(pdes[0]); - } - return iop; - } + if (*pid == -1) { + perror("vfork"); + close(pdes[0]); + close(pdes[1]); + return NULL; + } else if (*pid == 0) { + /* child */ + + if (*type == 'r') { + close(pdes[0]); + if (pdes[1] != STDOUT_FILENO) { + dup2(pdes[1], STDOUT_FILENO); + close(pdes[1]); + } + } else { + close(pdes[1]); + if (pdes[0] != STDIN_FILENO) { + dup2(pdes[0], STDIN_FILENO); + close(pdes[0]); + } + } + + execvp(file, argv); + exit(127); + } else { + /* parent */ + if (*type == 'r') { + iop = fdopen(pdes[0], "r"); + close(pdes[1]); + } else { + iop = fdopen(pdes[1], "w"); + close(pdes[0]); + } + return iop; + } } diff --git a/src/util.h b/src/util.h index ad0e423..f30047e 100644 --- a/src/util.h +++ b/src/util.h @@ -13,8 +13,8 @@ extern "C" { #endif -FILE * -pexecvp(const char *file, char *const argv[], pid_t *pid, char *type); + FILE * + pexecvp(const char *file, char *const argv[], pid_t *pid, char *type); #ifdef __cplusplus } -- cgit v1.2.3 From a10646b1c87e6abc1651ae7160ddd2c7fd1753bc Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 22:38:13 +0100 Subject: set window title bar --- configure.ac | 2 +- src/gipfel.cxx | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 1b5d0ac..27e4908 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT(gipfel, 0.1.3, Johannes.Hofmann@gmx.de) +AC_INIT(gipfel, 0.2.0, Johannes.Hofmann@gmx.de) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([src/Panorama.H]) AC_CONFIG_HEADER(config.h) diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 6eb4ee9..cf43af7 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -42,6 +42,7 @@ char *img_file; char *data_file = DEFAULT_DATAFILE; GipfelWidget *gipf = NULL; +Fl_Window *control_win, *view_win; Fl_Dial *s_center = NULL; Fl_Slider *s_nick, *s_focal_length, *s_tilt, *s_height_dist, *s_track_width; Fl_Value_Input *i_view_lat, *i_view_long, *i_view_height; @@ -81,6 +82,8 @@ void open_cb() { char *file = fl_file_chooser("Open File?", "*.jpg", img_file); if(file != NULL) { gipf->load_image(file); + view_win->label(file); + control_win->label(file); set_values(); } } @@ -322,7 +325,6 @@ int main(int argc, char** argv) { int stitch_flag = 0, stitch_w = 2000, stitch_h = 500; int jpeg_flag = 0, tiff_flag = 0; char *outpath; - Fl_Window *control_win, *view_win; Fl_Scroll *scroll; @@ -404,6 +406,8 @@ int main(int argc, char** argv) { gipf = new GipfelWidget(0,0,800,600); if (img_file) { gipf->load_image(img_file); + view_win->label(img_file); + control_win->label(img_file); } view_win->size(gipf->w(), gipf->h()); -- cgit v1.2.3